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
u762420987
p03575
python
s028735453
s928061270
460
21
27,952
3,064
Accepted
Accepted
95.43
from copy import deepcopy N, M = list(map(int, input().split())) graph = dict() for i in range(N): graph[i] = [] ab = [tuple(map(int, input().split())) for _ in range(M)] import numpy as np from scipy.sparse.csgraph import shortest_path from scipy.sparse import csr_matrix inf = float("inf") graph = np...
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): ...
25
57
619
1,412
from copy import deepcopy N, M = list(map(int, input().split())) graph = dict() for i in range(N): graph[i] = [] ab = [tuple(map(int, input().split())) for _ in range(M)] import numpy as np from scipy.sparse.csgraph import shortest_path from scipy.sparse import csr_matrix inf = float("inf") graph = np.zeros((N, N...
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = se...
false
56.140351
[ "-from copy import deepcopy", "+class UnionFind:", "+ def __init__(self, n):", "+ self.n = n", "+ self.parents = [-1] * n", "+", "+ def find(self, x):", "+ if self.parents[x] < 0:", "+ return x", "+ else:", "+ self.parents[x] = self.find(se...
false
0.549816
0.037383
14.707827
[ "s028735453", "s928061270" ]
u136869985
p03658
python
s344230730
s939568619
21
17
3,316
3,060
Accepted
Accepted
19.05
n,k=input().split() print((sum(sorted(list(map(int,input().split())))[:-int(k)-1:-1])))
N, K = list(map(int, input().split())) A = list(map(int, input().split())) A = sorted(A, reverse = True) ans = 0 for i in range(K): ans += A[i] print(ans)
2
9
86
162
n, k = input().split() print((sum(sorted(list(map(int, input().split())))[: -int(k) - 1 : -1])))
N, K = list(map(int, input().split())) A = list(map(int, input().split())) A = sorted(A, reverse=True) ans = 0 for i in range(K): ans += A[i] print(ans)
false
77.777778
[ "-n, k = input().split()", "-print((sum(sorted(list(map(int, input().split())))[: -int(k) - 1 : -1])))", "+N, K = list(map(int, input().split()))", "+A = list(map(int, input().split()))", "+A = sorted(A, reverse=True)", "+ans = 0", "+for i in range(K):", "+ ans += A[i]", "+print(ans)" ]
false
0.037884
0.038091
0.994566
[ "s344230730", "s939568619" ]
u744920373
p02803
python
s784484720
s850680795
694
614
3,188
3,316
Accepted
Accepted
11.53
H, W = list(map(int,input().split())) #A = [list(map(str,input().split())) for i in range(H)] A = [list(eval(input())) for i in range(H)] #from queue import Queue #from collections import deque dj = [1, 0, -1, 0] di = [0, 1, 0, -1] sum_sharp = sum([A[i].count('#') for i in range(H)]) fin_d_max = 1 fo...
H, W = list(map(int,input().split())) A = [list(eval(input())) for i in range(H)] #from queue import Queue #キューを使ったら1ケースだけTLEになった。 from collections import deque dj = [1, 0, -1, 0] di = [0, 1, 0, -1] sum_sharp = sum([A[i].count('#') for i in range(H)]) fin_d_max = 1 for s_i in range(H): for s_j in...
68
51
2,240
1,501
H, W = list(map(int, input().split())) # A = [list(map(str,input().split())) for i in range(H)] A = [list(eval(input())) for i in range(H)] # from queue import Queue # from collections import deque dj = [1, 0, -1, 0] di = [0, 1, 0, -1] sum_sharp = sum([A[i].count("#") for i in range(H)]) fin_d_max = 1 for s_i in range(...
H, W = list(map(int, input().split())) A = [list(eval(input())) for i in range(H)] # from queue import Queue #キューを使ったら1ケースだけTLEになった。 from collections import deque dj = [1, 0, -1, 0] di = [0, 1, 0, -1] sum_sharp = sum([A[i].count("#") for i in range(H)]) fin_d_max = 1 for s_i in range(H): for s_j in range(W): ...
false
25
[ "-# A = [list(map(str,input().split())) for i in range(H)]", "-# from queue import Queue", "-# from collections import deque", "+# from queue import Queue #キューを使ったら1ケースだけTLEになった。", "+from collections import deque", "+", "- # print(s_i,s_j)", "- q_i = []", "- # q_i = deque()", ...
false
0.039429
0.038215
1.031766
[ "s784484720", "s850680795" ]
u170201762
p02807
python
s807091447
s958295467
412
275
85,528
85,160
Accepted
Accepted
33.25
mod = 10**9+7 N = int(eval(input())) x = list(map(int,input().split())) fact = [1]*(N+1) for i in range(N): fact[i+1] = (i+1)*fact[i] fact[i+1] %= mod inv = [1]*(N+1) for i in range(N): inv[i] = pow(i,mod-2,mod) x1 = [] for m in range(1,N-1): x1.append(x[m]*m*inv[m+1]%mod) x2 = [] for n ...
mod = 10**9+7 N = int(eval(input())) x = list(map(int,input().split())) ans = 0 for j in range(1,N-1): ans += x[j]*j*pow(j+1,mod-2,mod) ans %= mod for i in range(N-2): ans += x[i]*(-N+i+2)*pow(N-i-1,mod-2,mod) ans %= mod for i in range(N-1): ans += (x[N-1]-x[i])*pow(N-1-i,mod-2,mod) ...
23
20
511
394
mod = 10**9 + 7 N = int(eval(input())) x = list(map(int, input().split())) fact = [1] * (N + 1) for i in range(N): fact[i + 1] = (i + 1) * fact[i] fact[i + 1] %= mod inv = [1] * (N + 1) for i in range(N): inv[i] = pow(i, mod - 2, mod) x1 = [] for m in range(1, N - 1): x1.append(x[m] * m * inv[m + 1] % m...
mod = 10**9 + 7 N = int(eval(input())) x = list(map(int, input().split())) ans = 0 for j in range(1, N - 1): ans += x[j] * j * pow(j + 1, mod - 2, mod) ans %= mod for i in range(N - 2): ans += x[i] * (-N + i + 2) * pow(N - i - 1, mod - 2, mod) ans %= mod for i in range(N - 1): ans += (x[N - 1] - x[i...
false
13.043478
[ "-fact = [1] * (N + 1)", "-for i in range(N):", "- fact[i + 1] = (i + 1) * fact[i]", "- fact[i + 1] %= mod", "-inv = [1] * (N + 1)", "-for i in range(N):", "- inv[i] = pow(i, mod - 2, mod)", "-x1 = []", "-for m in range(1, N - 1):", "- x1.append(x[m] * m * inv[m + 1] % mod)", "-x2 = ...
false
0.048102
0.049158
0.978504
[ "s807091447", "s958295467" ]
u426534722
p02299
python
s089517447
s771080837
130
120
8,256
8,260
Accepted
Accepted
7.69
import sys from operator import itemgetter, attrgetter from itertools import starmap import cmath from math import isinf, sqrt, acos, atan2 readline = sys.stdin.readline EPS = 1e-9 ONLINE_FRONT = -2 CLOCKWISE = -1 ON_SEGMENT = 0 COUNTER_CLOCKWISE = 1 ONLINE_BACK = 2 class Circle(object): __slots__ = ('...
import sys from operator import itemgetter, attrgetter from itertools import starmap import cmath from math import isinf, sqrt, acos, atan2 readline = sys.stdin.readline EPS = 1e-9 ONLINE_FRONT = -2 CLOCKWISE = -1 ON_SEGMENT = 0 COUNTER_CLOCKWISE = 1 ONLINE_BACK = 2 class Circle(object): __slots__ = ('...
90
90
3,083
3,081
import sys from operator import itemgetter, attrgetter from itertools import starmap import cmath from math import isinf, sqrt, acos, atan2 readline = sys.stdin.readline EPS = 1e-9 ONLINE_FRONT = -2 CLOCKWISE = -1 ON_SEGMENT = 0 COUNTER_CLOCKWISE = 1 ONLINE_BACK = 2 class Circle(object): __slots__ = ("c", "r") ...
import sys from operator import itemgetter, attrgetter from itertools import starmap import cmath from math import isinf, sqrt, acos, atan2 readline = sys.stdin.readline EPS = 1e-9 ONLINE_FRONT = -2 CLOCKWISE = -1 ON_SEGMENT = 0 COUNTER_CLOCKWISE = 1 ONLINE_BACK = 2 class Circle(object): __slots__ = ("c", "r") ...
false
0
[ "- print((contains(pg, complex(*list(map(float, readline().split()))))))", "+ print((contains(pg, complex(*list(map(int, readline().split()))))))" ]
false
0.045651
0.043785
1.042605
[ "s089517447", "s771080837" ]
u167647458
p02947
python
s486762512
s465259875
766
371
17,848
17,852
Accepted
Accepted
51.57
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) def main(): n = int(eval(input())) d = {} ans = 0 for _ in range(n): ss = ''.join(sorted(eval(input()))) d[ss] = d.get(ss, 0) + 1 fo...
def main(): n = int(eval(input())) d = {} ans = 0 for _ in range(n): ss = ''.join(sorted(eval(input()))) d[ss] = d.get(ss, 0) + 1 for k, v in list(d.items()): if v != 1: ans += (v*(v-1)) // 2 print(ans) if _...
25
18
475
336
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) def main(): n = int(eval(input())) d = {} ans = 0 for _ in range(n): ss = "".join(sorted(eval(input()))) d[ss] = d.get(ss, 0) + 1 for k, v in list(d.items()): ...
def main(): n = int(eval(input())) d = {} ans = 0 for _ in range(n): ss = "".join(sorted(eval(input()))) d[ss] = d.get(ss, 0) + 1 for k, v in list(d.items()): if v != 1: ans += (v * (v - 1)) // 2 print(ans) if __name__ == "__main__": main()
false
28
[ "-import math", "-", "-", "-def combinations_count(n, r):", "- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))", "-", "-", "- ans += combinations_count(v, 2)", "+ ans += (v * (v - 1)) // 2" ]
false
0.069109
0.032069
2.155016
[ "s486762512", "s465259875" ]
u606045429
p03168
python
s883658326
s590579948
2,000
278
3,444
20,640
Accepted
Accepted
86.1
N = int(eval(input())) P = list(map(float, input().split())) dp = [1] + [0] * N for p in P: dp = [p * a + (1 - p) * b for a, b in zip([0] + dp, dp)] print((sum(dp[-(-N // 2):])))
from numpy import zeros N = int(eval(input())) P = list(map(float, input().split())) dp = zeros(N + 1) dp[0] = 1.0 for p in P: T = dp dp = T * (1 - p) dp[1:] += T[:-1] * p print((dp[-(-N // 2):].sum()))
8
14
177
217
N = int(eval(input())) P = list(map(float, input().split())) dp = [1] + [0] * N for p in P: dp = [p * a + (1 - p) * b for a, b in zip([0] + dp, dp)] print((sum(dp[-(-N // 2) :])))
from numpy import zeros N = int(eval(input())) P = list(map(float, input().split())) dp = zeros(N + 1) dp[0] = 1.0 for p in P: T = dp dp = T * (1 - p) dp[1:] += T[:-1] * p print((dp[-(-N // 2) :].sum()))
false
42.857143
[ "+from numpy import zeros", "+", "-dp = [1] + [0] * N", "+dp = zeros(N + 1)", "+dp[0] = 1.0", "- dp = [p * a + (1 - p) * b for a, b in zip([0] + dp, dp)]", "-print((sum(dp[-(-N // 2) :])))", "+ T = dp", "+ dp = T * (1 - p)", "+ dp[1:] += T[:-1] * p", "+print((dp[-(-N // 2) :].sum()))...
false
0.033888
0.398041
0.085138
[ "s883658326", "s590579948" ]
u257162238
p02788
python
s226840372
s859486117
1,761
1,484
43,108
43,092
Accepted
Accepted
15.73
import bisect import operator import collections class RAQ(): def __init__(self, size): """初期化""" self.size = size self.sub = [0 for i in range(size + 1)] self.r = 0 self.v = 0 @classmethod def from_array(cls, a): st = cls(len(a)) ...
import bisect import operator import collections import sys input = sys.stdin.readline class RAQ(): def __init__(self, size): """初期化""" self.size = size self.sub = [0 for i in range(size + 1)] self.r = 0 self.v = 0 @classmethod def from_ar...
79
81
1,762
1,802
import bisect import operator import collections class RAQ: def __init__(self, size): """初期化""" self.size = size self.sub = [0 for i in range(size + 1)] self.r = 0 self.v = 0 @classmethod def from_array(cls, a): st = cls(len(a)) for i, x in enumerat...
import bisect import operator import collections import sys input = sys.stdin.readline class RAQ: def __init__(self, size): """初期化""" self.size = size self.sub = [0 for i in range(size + 1)] self.r = 0 self.v = 0 @classmethod def from_array(cls, a): st = c...
false
2.469136
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.039501
0.046502
0.849455
[ "s226840372", "s859486117" ]
u729133443
p03455
python
s890162166
s394811747
163
17
38,256
2,940
Accepted
Accepted
89.57
print(('EOvdedn'[eval(input().replace(' ','*'))%2::2]))
print(('EOvdedn'[sum(s in'04'for s in eval(input()))<1::2]))
1
1
53
52
print(("EOvdedn"[eval(input().replace(" ", "*")) % 2 :: 2]))
print(("EOvdedn"[sum(s in "04" for s in eval(input())) < 1 :: 2]))
false
0
[ "-print((\"EOvdedn\"[eval(input().replace(\" \", \"*\")) % 2 :: 2]))", "+print((\"EOvdedn\"[sum(s in \"04\" for s in eval(input())) < 1 :: 2]))" ]
false
0.061992
0.036987
1.676036
[ "s890162166", "s394811747" ]
u332385682
p03846
python
s866921470
s494368645
113
93
13,880
18,272
Accepted
Accepted
17.7
N = int(eval(input())) A = [int(a) for a in input().split()] check = [] if N % 2 == 0: for i in range(1, N, 2): check += [i, i] else: check += [0] for i in range(2, N, 2): check += [i, i] if check == sorted(A): print(((2 ** (N // 2)) % (10 ** 9 + 7))) else: pri...
from collections import Counter N = int(eval(input())) A = [int(a) for a in input().split()] check = {} if N % 2 == 0: for i in range(1, N, 2): check[i] = 2 else: check[0] = 1 for i in range(2, N, 2): check[i] = 2 if check == Counter(A): print(((2 ** (N // 2)) %...
19
20
317
349
N = int(eval(input())) A = [int(a) for a in input().split()] check = [] if N % 2 == 0: for i in range(1, N, 2): check += [i, i] else: check += [0] for i in range(2, N, 2): check += [i, i] if check == sorted(A): print(((2 ** (N // 2)) % (10**9 + 7))) else: print((0))
from collections import Counter N = int(eval(input())) A = [int(a) for a in input().split()] check = {} if N % 2 == 0: for i in range(1, N, 2): check[i] = 2 else: check[0] = 1 for i in range(2, N, 2): check[i] = 2 if check == Counter(A): print(((2 ** (N // 2)) % (10**9 + 7))) else: ...
false
5
[ "+from collections import Counter", "+", "-check = []", "+check = {}", "- check += [i, i]", "+ check[i] = 2", "- check += [0]", "+ check[0] = 1", "- check += [i, i]", "-if check == sorted(A):", "+ check[i] = 2", "+if check == Counter(A):" ]
false
0.037368
0.056387
0.662701
[ "s866921470", "s494368645" ]
u879309973
p03291
python
s924326850
s536651978
1,611
1,144
16,800
13,048
Accepted
Accepted
28.99
import numpy as np MOD = 10**9 + 7 def solve(s): n = len(s) dp = np.zeros((n+1, 4), dtype=int) dp[0,0] = 1 for i in range(n): t = 2 * int(s[i] == "?") + 1 dp[i+1] = t * dp[i] % MOD if s[i] == "A": dp[i+1,1] += dp[i,0] elif s[i] == "B": ...
import numpy as np MOD = 10**9 + 7 def solve(s): n = len(s) a = np.zeros(4, dtype=int) b = a.copy() a[0] = 1 for c in s: t = 2 * int(c == "?") + 1 b = t * a % MOD if c == "A": b[1] += a[0] elif c == "B": b[2] += a[1] elif ...
21
23
512
469
import numpy as np MOD = 10**9 + 7 def solve(s): n = len(s) dp = np.zeros((n + 1, 4), dtype=int) dp[0, 0] = 1 for i in range(n): t = 2 * int(s[i] == "?") + 1 dp[i + 1] = t * dp[i] % MOD if s[i] == "A": dp[i + 1, 1] += dp[i, 0] elif s[i] == "B": ...
import numpy as np MOD = 10**9 + 7 def solve(s): n = len(s) a = np.zeros(4, dtype=int) b = a.copy() a[0] = 1 for c in s: t = 2 * int(c == "?") + 1 b = t * a % MOD if c == "A": b[1] += a[0] elif c == "B": b[2] += a[1] elif c == "C": ...
false
8.695652
[ "- dp = np.zeros((n + 1, 4), dtype=int)", "- dp[0, 0] = 1", "- for i in range(n):", "- t = 2 * int(s[i] == \"?\") + 1", "- dp[i + 1] = t * dp[i] % MOD", "- if s[i] == \"A\":", "- dp[i + 1, 1] += dp[i, 0]", "- elif s[i] == \"B\":", "- dp[i + ...
false
0.394983
0.24803
1.592482
[ "s924326850", "s536651978" ]
u063052907
p03262
python
s377687088
s830274722
132
97
16,308
16,280
Accepted
Accepted
26.52
from functools import reduce from fractions import gcd def gcd_arg(lst): return reduce(gcd, lst) N, X = list(map(int, input().split())) lst_x = list(map(int, input().split())) + [X] lst_x.sort() lst_diff = [lst_x[i] - lst_x[i-1] for i in range(1, N+1)] ans = gcd_arg(lst_diff) print(ans)
from fractions import gcd N, X = list(map(int, input().split())) lst_x = list(map(int, input().split())) ans = abs(X - lst_x[0]) for x in lst_x[1::]: ans = gcd(ans, abs(X - x)) print(ans)
14
11
303
200
from functools import reduce from fractions import gcd def gcd_arg(lst): return reduce(gcd, lst) N, X = list(map(int, input().split())) lst_x = list(map(int, input().split())) + [X] lst_x.sort() lst_diff = [lst_x[i] - lst_x[i - 1] for i in range(1, N + 1)] ans = gcd_arg(lst_diff) print(ans)
from fractions import gcd N, X = list(map(int, input().split())) lst_x = list(map(int, input().split())) ans = abs(X - lst_x[0]) for x in lst_x[1::]: ans = gcd(ans, abs(X - x)) print(ans)
false
21.428571
[ "-from functools import reduce", "-", "-def gcd_arg(lst):", "- return reduce(gcd, lst)", "-", "-", "-lst_x = list(map(int, input().split())) + [X]", "-lst_x.sort()", "-lst_diff = [lst_x[i] - lst_x[i - 1] for i in range(1, N + 1)]", "-ans = gcd_arg(lst_diff)", "+lst_x = list(map(int, input().s...
false
0.049865
0.007173
6.951289
[ "s377687088", "s830274722" ]
u145950990
p03260
python
s300206111
s676658394
164
30
38,256
9,076
Accepted
Accepted
81.71
a,b = list(map(int,input().split())) print(('Yes' if a*b%2==1 else 'No'))
a,b = list(map(int,input().split())) if a*b%2==0: print('No') else: print('Yes')
2
5
66
86
a, b = list(map(int, input().split())) print(("Yes" if a * b % 2 == 1 else "No"))
a, b = list(map(int, input().split())) if a * b % 2 == 0: print("No") else: print("Yes")
false
60
[ "-print((\"Yes\" if a * b % 2 == 1 else \"No\"))", "+if a * b % 2 == 0:", "+ print(\"No\")", "+else:", "+ print(\"Yes\")" ]
false
0.036157
0.037583
0.962057
[ "s300206111", "s676658394" ]
u936985471
p03854
python
s559298924
s383455888
74
60
3,492
3,432
Accepted
Accepted
18.92
S=eval(input()) datas=["dream","dreamer","erase","eraser"] stack=[] stack.append(0) while stack: index=stack.pop() if index==len(S): print("YES") break for data in datas: if index+len(data)>len(S): continue if S[index:index+len(data)]==data: stack.append(index+len(data)) ...
S=eval(input()) W=("dream","dreamer","erase","eraser") s=[0] while s: i=s.pop() if i==len(S): print("YES") break for w in W: if S[i:i+len(w)]==w: s.append(i+len(w)) else: print("NO")
16
13
334
214
S = eval(input()) datas = ["dream", "dreamer", "erase", "eraser"] stack = [] stack.append(0) while stack: index = stack.pop() if index == len(S): print("YES") break for data in datas: if index + len(data) > len(S): continue if S[index : index + len(data)] == data:...
S = eval(input()) W = ("dream", "dreamer", "erase", "eraser") s = [0] while s: i = s.pop() if i == len(S): print("YES") break for w in W: if S[i : i + len(w)] == w: s.append(i + len(w)) else: print("NO")
false
18.75
[ "-datas = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]", "-stack = []", "-stack.append(0)", "-while stack:", "- index = stack.pop()", "- if index == len(S):", "+W = (\"dream\", \"dreamer\", \"erase\", \"eraser\")", "+s = [0]", "+while s:", "+ i = s.pop()", "+ if i == len(S):", "...
false
0.045732
0.056912
0.803557
[ "s559298924", "s383455888" ]
u226155577
p03203
python
s420999253
s621279765
1,036
599
65,996
30,168
Accepted
Accepted
42.18
H, W, N = list(map(int, input().split())) Y = [W+100]*(H+1) P = [[] for i in range(W+1)] for i in range(N): x, y = list(map(int, input().split())) if x < y: continue Y[x-y] = min(Y[x-y], y-1) P[y-1].append(x-1) base = 0 ans = H for y in range(W): while Y[base] == y: ba...
readline = open(0).readline write = open(1, 'w').write H, W, N = list(map(int, readline().split())) Y = [W+1]*(H+1) P = [[] for i in range(W+1)] for i in range(N): x, y = list(map(int, readline().split())) if x < y: continue Y[x-y] = min(Y[x-y], y-1) P[y-1].append(x-1) base = 0 a...
20
23
422
494
H, W, N = list(map(int, input().split())) Y = [W + 100] * (H + 1) P = [[] for i in range(W + 1)] for i in range(N): x, y = list(map(int, input().split())) if x < y: continue Y[x - y] = min(Y[x - y], y - 1) P[y - 1].append(x - 1) base = 0 ans = H for y in range(W): while Y[base] == y: ...
readline = open(0).readline write = open(1, "w").write H, W, N = list(map(int, readline().split())) Y = [W + 1] * (H + 1) P = [[] for i in range(W + 1)] for i in range(N): x, y = list(map(int, readline().split())) if x < y: continue Y[x - y] = min(Y[x - y], y - 1) P[y - 1].append(x - 1) base = 0...
false
13.043478
[ "-H, W, N = list(map(int, input().split()))", "-Y = [W + 100] * (H + 1)", "+readline = open(0).readline", "+write = open(1, \"w\").write", "+H, W, N = list(map(int, readline().split()))", "+Y = [W + 1] * (H + 1)", "- x, y = list(map(int, input().split()))", "+ x, y = list(map(int, readline().spl...
false
0.134356
0.062983
2.133211
[ "s420999253", "s621279765" ]
u620084012
p03151
python
s323377782
s778629422
282
133
82,224
93,804
Accepted
Accepted
52.84
N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) if sum(A) < sum(B): print((-1)) exit(0) t = 0 m = 0 L = [] for k in range(N): if A[k] > B[k]: L.append(A[k]-B[k]) else: m += B[k] - A[k] t += 1 if m == 0: print(...
N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) if sum(A) < sum(B): print((-1)) exit(0) C = [A[k]-B[k] for k in range(N)] C.sort() t = 0 ans = 0 for k in range(N): if C[k] >= 0: break else: t -= C[k] ans += 1 for k ...
29
26
430
426
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) if sum(A) < sum(B): print((-1)) exit(0) t = 0 m = 0 L = [] for k in range(N): if A[k] > B[k]: L.append(A[k] - B[k]) else: m += B[k] - A[k] t += 1 if m == 0: print((0)) exit(0) L...
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) if sum(A) < sum(B): print((-1)) exit(0) C = [A[k] - B[k] for k in range(N)] C.sort() t = 0 ans = 0 for k in range(N): if C[k] >= 0: break else: t -= C[k] ans += 1 for k in range(N - 1, ...
false
10.344828
[ "+C = [A[k] - B[k] for k in range(N)]", "+C.sort()", "-m = 0", "-L = []", "+ans = 0", "- if A[k] > B[k]:", "- L.append(A[k] - B[k])", "+ if C[k] >= 0:", "+ break", "- m += B[k] - A[k]", "- t += 1", "-if m == 0:", "- print((0))", "- exit(0)", "-L = ...
false
0.04716
0.06586
0.716067
[ "s323377782", "s778629422" ]
u013513417
p03160
python
s762256106
s339843886
179
127
13,928
24,340
Accepted
Accepted
29.05
N=int(eval(input())) L=list(map(int,input().split())) S=[0]*100010 for i in range(N): S[i]=L[i] DP=[10**12]*100010 DP[0]=0 for i in range(N): if DP[i+1]>DP[i]+abs(S[i+1]-S[i]): DP[i+1]=DP[i]+abs(S[i+1]-S[i]) if DP[i+2]>DP[i]+abs(S[i+2]-S[i]): DP[i+2]=DP[i]+abs(S[i+2]-S[i]) ...
N=int(eval(input())) S=list(map(int,input().split())) DP=[10**6]*(10**6) def chmin(a,b): if a>b: return b else: return a def chmax(a,b): if a>b: return a else: return b DP[0]=0 DP[1]=abs(S[1]-S[0]) for i in range(2,N): DP[i]=chmin(DP[i-1]+abs...
20
24
348
375
N = int(eval(input())) L = list(map(int, input().split())) S = [0] * 100010 for i in range(N): S[i] = L[i] DP = [10**12] * 100010 DP[0] = 0 for i in range(N): if DP[i + 1] > DP[i] + abs(S[i + 1] - S[i]): DP[i + 1] = DP[i] + abs(S[i + 1] - S[i]) if DP[i + 2] > DP[i] + abs(S[i + 2] - S[i]): DP...
N = int(eval(input())) S = list(map(int, input().split())) DP = [10**6] * (10**6) def chmin(a, b): if a > b: return b else: return a def chmax(a, b): if a > b: return a else: return b DP[0] = 0 DP[1] = abs(S[1] - S[0]) for i in range(2, N): DP[i] = chmin(DP[i - ...
false
16.666667
[ "-L = list(map(int, input().split()))", "-S = [0] * 100010", "-for i in range(N):", "- S[i] = L[i]", "-DP = [10**12] * 100010", "+S = list(map(int, input().split()))", "+DP = [10**6] * (10**6)", "+", "+", "+def chmin(a, b):", "+ if a > b:", "+ return b", "+ else:", "+ ...
false
0.042998
0.149236
0.288117
[ "s762256106", "s339843886" ]
u998435601
p02402
python
s162985848
s179365337
20
10
7,056
7,088
Accepted
Accepted
50
n = eval(input()) lis = list(map(int, input().split())) mn = lis[0] mx = lis[0] for t in lis: if mn > t: mn = t if mx < t: mx = t print(mn, mx, sum(lis))
n = eval(input()) lis = list(map(int, input().split())) mn = lis[0] mx = lis[0] for t in lis: if mn > t: mn = t if mx < t: mx = t print("%s %s %s" % (mn, mx, sum(lis)))
10
10
159
174
n = eval(input()) lis = list(map(int, input().split())) mn = lis[0] mx = lis[0] for t in lis: if mn > t: mn = t if mx < t: mx = t print(mn, mx, sum(lis))
n = eval(input()) lis = list(map(int, input().split())) mn = lis[0] mx = lis[0] for t in lis: if mn > t: mn = t if mx < t: mx = t print("%s %s %s" % (mn, mx, sum(lis)))
false
0
[ "-print(mn, mx, sum(lis))", "+print(\"%s %s %s\" % (mn, mx, sum(lis)))" ]
false
0.039692
0.043307
0.916544
[ "s162985848", "s179365337" ]
u592547545
p02767
python
s348992393
s228547898
20
18
3,064
3,064
Accepted
Accepted
10
def readinput(): n=int(eval(input())) x=list(map(int,input().split())) return n,x def mean(x): sum=0 for _ in x: sum+=_ return sum/len(x) def rss(x,xbar): sum=0 for _ in x: sum+=(_-xbar)**2 return sum def main(n,x): ans=0 xbar=mean(x) ...
def readinput(): n=int(eval(input())) x=list(map(int,input().split())) return n,x def mean(x): sum=0 for _ in x: sum+=_ return sum/len(x) def rss(x,xbar): sum=0 for _ in x: sum+=(_-xbar)**2 return sum def main(n,x): ans=0 xbar=mean(x) ...
44
44
757
757
def readinput(): n = int(eval(input())) x = list(map(int, input().split())) return n, x def mean(x): sum = 0 for _ in x: sum += _ return sum / len(x) def rss(x, xbar): sum = 0 for _ in x: sum += (_ - xbar) ** 2 return sum def main(n, x): ans = 0 xbar = m...
def readinput(): n = int(eval(input())) x = list(map(int, input().split())) return n, x def mean(x): sum = 0 for _ in x: sum += _ return sum / len(x) def rss(x, xbar): sum = 0 for _ in x: sum += (_ - xbar) ** 2 return sum def main(n, x): ans = 0 xbar = m...
false
0
[ "- ans = main2(n, x)", "+ ans = main(n, x)" ]
false
0.03651
0.039241
0.930421
[ "s348992393", "s228547898" ]
u413019025
p03611
python
s034093515
s808364697
91
66
14,300
14,300
Accepted
Accepted
27.47
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) def read_h(typ=int): return list(map(typ, input().split())) def read_v(n, m=1, typ=int): return [read_h() if m > 1 else typ(eval(input())) for _ in range(n)] def main(): N, = read_h() arr = read_h() from colle...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) def read_h(typ=int): return list(map(typ, input().split())) def read_v(n, m=1, typ=int): return [read_h() if m > 1 else typ(eval(input())) for _ in range(n)] def main(): N, = read_h() arr = read_h() cnts = [0]...
31
34
532
569
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) def read_h(typ=int): return list(map(typ, input().split())) def read_v(n, m=1, typ=int): return [read_h() if m > 1 else typ(eval(input())) for _ in range(n)] def main(): (N,) = read_h() arr = read_h() from collections import Count...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) def read_h(typ=int): return list(map(typ, input().split())) def read_v(n, m=1, typ=int): return [read_h() if m > 1 else typ(eval(input())) for _ in range(n)] def main(): (N,) = read_h() arr = read_h() cnts = [0] * 100000 for a...
false
8.823529
[ "- from collections import Counter", "-", "- c = Counter(arr)", "- cnt = 0", "- for X in list(c.keys()):", "- cnt = max(cnt, c.get(X - 1, 0) + c.get(X, 0) + c.get(X + 1, 0))", "- print(cnt)", "+ cnts = [0] * 100000", "+ for a in arr:", "+ cnts[a] += 1", "+ a...
false
0.074242
0.066504
1.116341
[ "s034093515", "s808364697" ]
u581187895
p02685
python
s398177660
s901069791
671
351
33,004
32,908
Accepted
Accepted
47.69
import sys sys.setrecursionlimit(10 ** 7) read = sys.stdin.buffer.read inp = sys.stdin.buffer.readline def resolve(): # nCk = n! / n!(n-k)! のテーブル作成 def COMinit(n, MOD): fact = [1, 1] fact_inv = [1, 1] inv = [0, 1] for i in range(2, n + 1): fact.append((f...
def resolve(): # nCk = n! / n!(n-k)! のテーブル作成 def COMinit(n, MOD): fact = [1, 1] fact_inv = [1, 1] inv = [0, 1] for i in range(2, n + 1): fact.append((fact[-1] * i) % MOD) inv.append((-inv[MOD % i] * (MOD // i)) % MOD) fact_inv.append...
42
40
1,094
1,050
import sys sys.setrecursionlimit(10**7) read = sys.stdin.buffer.read inp = sys.stdin.buffer.readline def resolve(): # nCk = n! / n!(n-k)! のテーブル作成 def COMinit(n, MOD): fact = [1, 1] fact_inv = [1, 1] inv = [0, 1] for i in range(2, n + 1): fact.append((fact[-1] * i) ...
def resolve(): # nCk = n! / n!(n-k)! のテーブル作成 def COMinit(n, MOD): fact = [1, 1] fact_inv = [1, 1] inv = [0, 1] for i in range(2, n + 1): fact.append((fact[-1] * i) % MOD) inv.append((-inv[MOD % i] * (MOD // i)) % MOD) fact_inv.append((fact_inv[...
false
4.761905
[ "-import sys", "-", "-sys.setrecursionlimit(10**7)", "-read = sys.stdin.buffer.read", "-inp = sys.stdin.buffer.readline", "-", "-", "- N, M, K = list(map(int, inp().split()))", "+ N, M, K = list(map(int, input().split()))", "+ m_mod = [1]", "+ for _ in range(N):", "+ m_mod.a...
false
0.151186
0.343868
0.439665
[ "s398177660", "s901069791" ]
u680851063
p02720
python
s490784508
s212204558
332
116
15,824
7,152
Accepted
Accepted
65.06
n = int(eval(input())) l = [_ for _ in range(1,10)] for i in range(10**5): if str(l[i])[-1] == '0': l.append(l[i]*10 + int(str(l[i])[-1])) l.append(l[i]*10 + int(str(l[i])[-1]) + 1) elif str(l[i])[-1] == '9': l.append(l[i]*10 + int(str(l[i])[-1]) - 1) l.append(l[i]*10...
n = int(eval(input())) l = [_ for _ in range(1,10)] cnt = 9 for i in range(10**5): if cnt >= n: break if str(l[i])[-1] == '0': l.append(l[i]*10 + int(str(l[i])[-1])) l.append(l[i]*10 + int(str(l[i])[-1]) + 1) cnt += 2 elif str(l[i])[-1] == '9': l.append...
18
24
518
614
n = int(eval(input())) l = [_ for _ in range(1, 10)] for i in range(10**5): if str(l[i])[-1] == "0": l.append(l[i] * 10 + int(str(l[i])[-1])) l.append(l[i] * 10 + int(str(l[i])[-1]) + 1) elif str(l[i])[-1] == "9": l.append(l[i] * 10 + int(str(l[i])[-1]) - 1) l.append(l[i] * 10 + ...
n = int(eval(input())) l = [_ for _ in range(1, 10)] cnt = 9 for i in range(10**5): if cnt >= n: break if str(l[i])[-1] == "0": l.append(l[i] * 10 + int(str(l[i])[-1])) l.append(l[i] * 10 + int(str(l[i])[-1]) + 1) cnt += 2 elif str(l[i])[-1] == "9": l.append(l[i] * 10...
false
25
[ "+cnt = 9", "+ if cnt >= n:", "+ break", "+ cnt += 2", "+ cnt += 2", "+ cnt += 3" ]
false
0.628743
0.062219
10.105351
[ "s490784508", "s212204558" ]
u017810624
p03112
python
s081591706
s826165174
1,511
747
85,676
65,628
Accepted
Accepted
50.56
import bisect a,b,q=list(map(int,input().split())) s=[-999999999999]+[int(eval(input())) for i in range(a)]+[999999999999] t=[-999999999999]+[int(eval(input())) for i in range(b)]+[999999999999] x=[int(eval(input())) for i in range(q)] for i in range(q): a1=s[bisect.bisect_left(s,x[i])-1] a2=s[bisect.bisect_...
import bisect import sys input=sys.stdin.readline a,b,q=list(map(int,input().split())) s=[-999999999999]+[int(eval(input())) for i in range(a)]+[999999999999] t=[-999999999999]+[int(eval(input())) for i in range(b)]+[999999999999] x=[int(eval(input())) for i in range(q)] for i in range(q): a1=s[bisect.bisect_...
15
17
507
545
import bisect a, b, q = list(map(int, input().split())) s = [-999999999999] + [int(eval(input())) for i in range(a)] + [999999999999] t = [-999999999999] + [int(eval(input())) for i in range(b)] + [999999999999] x = [int(eval(input())) for i in range(q)] for i in range(q): a1 = s[bisect.bisect_left(s, x[i]) - 1] ...
import bisect import sys input = sys.stdin.readline a, b, q = list(map(int, input().split())) s = [-999999999999] + [int(eval(input())) for i in range(a)] + [999999999999] t = [-999999999999] + [int(eval(input())) for i in range(b)] + [999999999999] x = [int(eval(input())) for i in range(q)] for i in range(q): a1 ...
false
11.764706
[ "+import sys", "+input = sys.stdin.readline" ]
false
0.076709
0.040802
1.880004
[ "s081591706", "s826165174" ]
u392319141
p02881
python
s849751093
s201045852
140
120
2,940
3,268
Accepted
Accepted
14.29
N = int(eval(input())) ans = N - 1 for i in range(1, int(N**0.5) + 100): if N % i != 0: continue j = N // i ans = min(ans, i + j - 2) print(ans)
N = int(eval(input())) # 約数の全列挙 def divisors(n): divisors = [] R = int(n**(0.5)) + 1 for i in range(1, R): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) # divisors.sort(reverse=True) # ソート return divisors an...
9
20
168
409
N = int(eval(input())) ans = N - 1 for i in range(1, int(N**0.5) + 100): if N % i != 0: continue j = N // i ans = min(ans, i + j - 2) print(ans)
N = int(eval(input())) # 約数の全列挙 def divisors(n): divisors = [] R = int(n ** (0.5)) + 1 for i in range(1, R): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) # divisors.sort(reverse=True) # ソート return divisors ans = 10**18 f...
false
55
[ "-ans = N - 1", "-for i in range(1, int(N**0.5) + 100):", "- if N % i != 0:", "- continue", "- j = N // i", "- ans = min(ans, i + j - 2)", "+# 約数の全列挙", "+def divisors(n):", "+ divisors = []", "+ R = int(n ** (0.5)) + 1", "+ for i in range(1, R):", "+ if n % i ==...
false
0.046531
0.085599
0.543592
[ "s849751093", "s201045852" ]
u474232743
p02413
python
s223306364
s739116534
40
30
7,780
7,708
Accepted
Accepted
25
(r, c) = list(map(int, input().split())) a = [[v for v in list(map(int, input().split()))] for r in range(r)] add_c = [sum(l) for l in a] for i in range(r): a[i].append(add_c[i]) add_r = [sum([a[i][j] for i in range(r)]) for j in range(c + 1)] a.append(add_r) for i in range(r + 1): print((' '.join(map(s...
(r, c) = list(map(int, input().split())) a = [[v for v in list(map(int, input().split()))] for r in range(r)] for i in range(r): a[i].append(sum(a[i])) add_r = [sum([a[i][j] for i in range(r)]) for j in range(c + 1)] a.append(add_r) for i in range(r + 1): print((' '.join(map(str, a[i]))))
9
8
324
296
(r, c) = list(map(int, input().split())) a = [[v for v in list(map(int, input().split()))] for r in range(r)] add_c = [sum(l) for l in a] for i in range(r): a[i].append(add_c[i]) add_r = [sum([a[i][j] for i in range(r)]) for j in range(c + 1)] a.append(add_r) for i in range(r + 1): print((" ".join(map(str, a[i]...
(r, c) = list(map(int, input().split())) a = [[v for v in list(map(int, input().split()))] for r in range(r)] for i in range(r): a[i].append(sum(a[i])) add_r = [sum([a[i][j] for i in range(r)]) for j in range(c + 1)] a.append(add_r) for i in range(r + 1): print((" ".join(map(str, a[i]))))
false
11.111111
[ "-add_c = [sum(l) for l in a]", "- a[i].append(add_c[i])", "+ a[i].append(sum(a[i]))" ]
false
0.037139
0.041454
0.895912
[ "s223306364", "s739116534" ]
u816631826
p03437
python
s491449168
s960987014
19
17
2,940
2,940
Accepted
Accepted
10.53
x,y = list(map(int,input().split())) if x%y == 0: print((-1)) else: print(x)
a,c=list(map(int,input().split())) print(((1+a)*(a%c>0)-1))
6
2
79
53
x, y = list(map(int, input().split())) if x % y == 0: print((-1)) else: print(x)
a, c = list(map(int, input().split())) print(((1 + a) * (a % c > 0) - 1))
false
66.666667
[ "-x, y = list(map(int, input().split()))", "-if x % y == 0:", "- print((-1))", "-else:", "- print(x)", "+a, c = list(map(int, input().split()))", "+print(((1 + a) * (a % c > 0) - 1))" ]
false
0.045206
0.046749
0.967009
[ "s491449168", "s960987014" ]
u107915058
p03611
python
s800115899
s150704886
289
97
92,648
22,412
Accepted
Accepted
66.44
N = int(eval(input())) a = list(map(int, input().split())) cnt = [0]*(10**7) for i in a: cnt[i-1] += 1 cnt[i] += 1 cnt[i+1] += 1 print((max(cnt)))
N = int(eval(input())) a = list(map(int, input().split())) cnt = [0]*(10**6) for i in a: cnt[i-1] += 1 cnt[i] += 1 cnt[i+1] += 1 print((max(cnt)))
8
8
157
157
N = int(eval(input())) a = list(map(int, input().split())) cnt = [0] * (10**7) for i in a: cnt[i - 1] += 1 cnt[i] += 1 cnt[i + 1] += 1 print((max(cnt)))
N = int(eval(input())) a = list(map(int, input().split())) cnt = [0] * (10**6) for i in a: cnt[i - 1] += 1 cnt[i] += 1 cnt[i + 1] += 1 print((max(cnt)))
false
0
[ "-cnt = [0] * (10**7)", "+cnt = [0] * (10**6)" ]
false
0.549405
0.17796
3.087243
[ "s800115899", "s150704886" ]
u896741788
p03805
python
s286778103
s428655880
48
24
3,064
3,064
Accepted
Accepted
50
from itertools import permutations as per ty,he=list(map(int,input().split())) l=[set(map(int,input().split())) for i in range(he)] ans=0 for g in per(list(range(2,ty+1))): co=[1]+list(g) for sd in zip(co,co[1:]): if set(sd) not in l:break else:ans+=1 print(ans)
n,m=list(map(int,input().split())) e=[[0 for _ in range(n)] for i in range(n)] for i in range(m): a,s=list(map(int,input().split())) e[a-1][s-1]=1;e[s-1][a-1]=1 ans=0 from itertools import permutations as pe for i in pe(list(range(1,n)),r=None): #rは長さ、Noneでiteraterの長さ pre=0 for a in i: ...
10
15
269
373
from itertools import permutations as per ty, he = list(map(int, input().split())) l = [set(map(int, input().split())) for i in range(he)] ans = 0 for g in per(list(range(2, ty + 1))): co = [1] + list(g) for sd in zip(co, co[1:]): if set(sd) not in l: break else: ans += 1 print(...
n, m = list(map(int, input().split())) e = [[0 for _ in range(n)] for i in range(n)] for i in range(m): a, s = list(map(int, input().split())) e[a - 1][s - 1] = 1 e[s - 1][a - 1] = 1 ans = 0 from itertools import permutations as pe for i in pe(list(range(1, n)), r=None): # rは長さ、Noneでiteraterの長さ pre...
false
33.333333
[ "-from itertools import permutations as per", "+n, m = list(map(int, input().split()))", "+e = [[0 for _ in range(n)] for i in range(n)]", "+for i in range(m):", "+ a, s = list(map(int, input().split()))", "+ e[a - 1][s - 1] = 1", "+ e[s - 1][a - 1] = 1", "+ans = 0", "+from itertools import...
false
0.049331
0.110249
0.447451
[ "s286778103", "s428655880" ]
u143492911
p03854
python
s828849506
s488050412
72
23
3,188
6,516
Accepted
Accepted
68.06
s=input()[::-1] while 0<len(s): if s[:5] in "maerd": s=s[5:] elif s[:5] in "esare": s=s[5:] elif s[:6] in "resare": s=s[6:] elif s[:7] in "remaerd": s=s[7:] else: print("NO") exit() print("YES")
import re s=input() print("YES") if re.match("^(dream|dreamer|erase|eraser)+$",s) else print("NO")
14
3
276
101
s = input()[::-1] while 0 < len(s): if s[:5] in "maerd": s = s[5:] elif s[:5] in "esare": s = s[5:] elif s[:6] in "resare": s = s[6:] elif s[:7] in "remaerd": s = s[7:] else: print("NO") exit() print("YES")
import re s = input() print("YES") if re.match("^(dream|dreamer|erase|eraser)+$", s) else print("NO")
false
78.571429
[ "-s = input()[::-1]", "-while 0 < len(s):", "- if s[:5] in \"maerd\":", "- s = s[5:]", "- elif s[:5] in \"esare\":", "- s = s[5:]", "- elif s[:6] in \"resare\":", "- s = s[6:]", "- elif s[:7] in \"remaerd\":", "- s = s[7:]", "- else:", "- print...
false
0.061244
0.046653
1.312766
[ "s828849506", "s488050412" ]
u858748695
p04040
python
s473379121
s985281543
1,203
1,001
3,064
18,980
Accepted
Accepted
16.79
#!/usr/bin/env python3 mod = 10**9 + 7 def inv(x): return pow(x, mod - 2, mod) def comb(n, k): res = 1 for i in range(k): res = (res * (n - i) * inv(i + 1)) % mod return res H, W, A, B = list(map(int, input().split())) c1 = comb(H - A - 1 + B, B) c2 = comb(A - 1 + W - B - 1,...
#!/usr/bin/env python3 mod = 10**9 + 7 H, W, A, B = list(map(int, input().split())) fct = [1] inv = [1] for i in range(1, H + W - 1): fct.append((fct[-1] * i) % mod) inv.append(pow(fct[i], mod - 2, mod)) def comb(n, k): return (fct[n] * inv[n - k] * inv[k]) % mod ans = 0 for i in range(B,...
23
20
511
442
#!/usr/bin/env python3 mod = 10**9 + 7 def inv(x): return pow(x, mod - 2, mod) def comb(n, k): res = 1 for i in range(k): res = (res * (n - i) * inv(i + 1)) % mod return res H, W, A, B = list(map(int, input().split())) c1 = comb(H - A - 1 + B, B) c2 = comb(A - 1 + W - B - 1, W - B - 1) ans...
#!/usr/bin/env python3 mod = 10**9 + 7 H, W, A, B = list(map(int, input().split())) fct = [1] inv = [1] for i in range(1, H + W - 1): fct.append((fct[-1] * i) % mod) inv.append(pow(fct[i], mod - 2, mod)) def comb(n, k): return (fct[n] * inv[n - k] * inv[k]) % mod ans = 0 for i in range(B, W): c1 = c...
false
13.043478
[ "-", "-", "-def inv(x):", "- return pow(x, mod - 2, mod)", "+H, W, A, B = list(map(int, input().split()))", "+fct = [1]", "+inv = [1]", "+for i in range(1, H + W - 1):", "+ fct.append((fct[-1] * i) % mod)", "+ inv.append(pow(fct[i], mod - 2, mod))", "- res = 1", "- for i in rang...
false
0.392772
0.498662
0.787652
[ "s473379121", "s985281543" ]
u131811591
p02330
python
s784541697
s874127096
12,000
9,960
48,164
56,304
Accepted
Accepted
17
import sys import bisect def main(): n, K, L, R = list(map(int, sys.stdin.readline().split())) a = tuple(map(int, sys.stdin.readline().split())) m = n//2 ls = [[] for _ in range(m+1)] for i in range(1 << m): ls[bin(i).count("1")].append(sum([a[j] for j in range(m) if i >> j & 1])...
import sys import bisect import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) def main(): n, K, L, R = list(map(int, sys.stdin.readline().split())) a = tuple(map(int, sys.stdin.readline().split())) m = n//2 ls = [[0 for _ ...
25
42
695
1,060
import sys import bisect def main(): n, K, L, R = list(map(int, sys.stdin.readline().split())) a = tuple(map(int, sys.stdin.readline().split())) m = n // 2 ls = [[] for _ in range(m + 1)] for i in range(1 << m): ls[bin(i).count("1")].append(sum([a[j] for j in range(m) if i >> j & 1])) ...
import sys import bisect import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) def main(): n, K, L, R = list(map(int, sys.stdin.readline().split())) a = tuple(map(int, sys.stdin.readline().split())) m = n // 2 ls = [[0 for _ in range(co...
false
40.47619
[ "+import math", "+", "+", "+def combinations_count(n, r):", "+ return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))", "- ls = [[] for _ in range(m + 1)]", "+ ls = [[0 for _ in range(combinations_count(m, i))] for i in range(m + 1)]", "+ index = [0] * (m + 1)", "- ...
false
0.042089
0.045791
0.919145
[ "s784541697", "s874127096" ]
u528793636
p02783
python
s765486534
s472437682
19
17
2,940
2,940
Accepted
Accepted
10.53
H,A = list(map(int, input().split())) count = 0 for i in range(10000): if i*A >= H: break else: i += 1 count += 1 print(count)
H,A = list(map(int, input().split())) print((-(-H//A)))
10
3
162
51
H, A = list(map(int, input().split())) count = 0 for i in range(10000): if i * A >= H: break else: i += 1 count += 1 print(count)
H, A = list(map(int, input().split())) print((-(-H // A)))
false
70
[ "-count = 0", "-for i in range(10000):", "- if i * A >= H:", "- break", "- else:", "- i += 1", "- count += 1", "-print(count)", "+print((-(-H // A)))" ]
false
0.049949
0.049065
1.018015
[ "s765486534", "s472437682" ]
u263830634
p03088
python
s698752690
s744252116
294
129
47,320
3,880
Accepted
Accepted
56.12
N = int(eval(input())) mod = 10 ** 9 + 7 memo = [{} for i in range(N+1)] #print (memo) #4文字を与えて条件に合致するかを判断 def check(last4): for i in range(4): t = list(last4) #4文字をリストに格納 if i >= 1: #最初の文字以外に着目する時 t[i-1], t[i] = t[i], t[i-1] #i番目とi-1番目を交換 if ''.join(t).count('AGC')...
N = int(eval(input())) MOD = 10 ** 9 + 7 memo = [{} for _ in range(N + 1)] def ok(last4): for i in range(4): t = list(last4) if i >= 1: t[i - 1], t[i] = t[i], t[i - 1] if ''.join(t).count('AGC') >= 1: return False return True def dfs(cur, last3)...
32
28
715
604
N = int(eval(input())) mod = 10**9 + 7 memo = [{} for i in range(N + 1)] # print (memo) # 4文字を与えて条件に合致するかを判断 def check(last4): for i in range(4): t = list(last4) # 4文字をリストに格納 if i >= 1: # 最初の文字以外に着目する時 t[i - 1], t[i] = t[i], t[i - 1] # i番目とi-1番目を交換 if "".join(t).count("AGC") >...
N = int(eval(input())) MOD = 10**9 + 7 memo = [{} for _ in range(N + 1)] def ok(last4): for i in range(4): t = list(last4) if i >= 1: t[i - 1], t[i] = t[i], t[i - 1] if "".join(t).count("AGC") >= 1: return False return True def dfs(cur, last3): if last3 in...
false
12.5
[ "-mod = 10**9 + 7", "-memo = [{} for i in range(N + 1)]", "-# print (memo)", "-# 4文字を与えて条件に合致するかを判断", "-def check(last4):", "+MOD = 10**9 + 7", "+memo = [{} for _ in range(N + 1)]", "+", "+", "+def ok(last4):", "- t = list(last4) # 4文字をリストに格納", "- if i >= 1: # 最初の文字以外に着目する時", ...
false
0.080068
0.079062
1.012725
[ "s698752690", "s744252116" ]
u730769327
p03087
python
s725404069
s648267948
1,036
386
56,100
72,500
Accepted
Accepted
62.74
n,q=list(map(int,input().split())) s=eval(input()) a=[] for i in range(len(s)-1): a.append(s[i:i+2]) b=[0] for i in a: b.append(b[-1]) if i=='AC': b[-1]+=1 for i in range(q): l,r=list(map(int,input().split())) print((b[r-1]-b[l-1]))
n,q=list(map(int,input().split())) s=eval(input()) a=[0]*(n+1) for i in range(n-1): if s[i:i+2]=='AC': a[i+1]=1 for i in range(n): a[i+1]+=a[i] for i in range(q): l,r=list(map(int,input().split())) print((a[r-1]-a[l-1]))
14
11
240
222
n, q = list(map(int, input().split())) s = eval(input()) a = [] for i in range(len(s) - 1): a.append(s[i : i + 2]) b = [0] for i in a: b.append(b[-1]) if i == "AC": b[-1] += 1 for i in range(q): l, r = list(map(int, input().split())) print((b[r - 1] - b[l - 1]))
n, q = list(map(int, input().split())) s = eval(input()) a = [0] * (n + 1) for i in range(n - 1): if s[i : i + 2] == "AC": a[i + 1] = 1 for i in range(n): a[i + 1] += a[i] for i in range(q): l, r = list(map(int, input().split())) print((a[r - 1] - a[l - 1]))
false
21.428571
[ "-a = []", "-for i in range(len(s) - 1):", "- a.append(s[i : i + 2])", "-b = [0]", "-for i in a:", "- b.append(b[-1])", "- if i == \"AC\":", "- b[-1] += 1", "+a = [0] * (n + 1)", "+for i in range(n - 1):", "+ if s[i : i + 2] == \"AC\":", "+ a[i + 1] = 1", "+for i in...
false
0.047383
0.086453
0.548077
[ "s725404069", "s648267948" ]
u550488532
p02819
python
s297911038
s298827071
316
29
3,060
3,060
Accepted
Accepted
90.82
X = int(eval(input())) count = 0 for i in range(2, X+1, 1): if X % i == 0: count += 1 if count == 1: print(X) else: while True: count = 0 X += 1 for i in range(2, X+1, 1): if X % i == 0: count += 1 if count == 1: ...
x = int(eval(input())) p = x - 1 prime = False if x == 2: print((2)) else: while prime == False: p += 1 prime = True for i in range(2, p - 1): if p % i == 0: prime = False break print(p)
20
17
351
297
X = int(eval(input())) count = 0 for i in range(2, X + 1, 1): if X % i == 0: count += 1 if count == 1: print(X) else: while True: count = 0 X += 1 for i in range(2, X + 1, 1): if X % i == 0: count += 1 if count == 1: print(X) ...
x = int(eval(input())) p = x - 1 prime = False if x == 2: print((2)) else: while prime == False: p += 1 prime = True for i in range(2, p - 1): if p % i == 0: prime = False break print(p)
false
15
[ "-X = int(eval(input()))", "-count = 0", "-for i in range(2, X + 1, 1):", "- if X % i == 0:", "- count += 1", "-if count == 1:", "- print(X)", "+x = int(eval(input()))", "+p = x - 1", "+prime = False", "+if x == 2:", "+ print((2))", "- while True:", "- count = 0",...
false
0.069662
0.036251
1.921626
[ "s297911038", "s298827071" ]
u714104087
p03473
python
s737900399
s141792486
69
62
61,620
61,696
Accepted
Accepted
10.14
M = int(eval(input())) print((24 - M + 24))
m = int(eval(input())) print((24-m+24))
2
3
37
34
M = int(eval(input())) print((24 - M + 24))
m = int(eval(input())) print((24 - m + 24))
false
33.333333
[ "-M = int(eval(input()))", "-print((24 - M + 24))", "+m = int(eval(input()))", "+print((24 - m + 24))" ]
false
0.039008
0.039521
0.986998
[ "s737900399", "s141792486" ]
u644907318
p02780
python
s401467619
s278861130
236
107
71,792
101,724
Accepted
Accepted
54.66
N,K = list(map(int,input().split())) P = list(map(int,input().split())) cnt = 0 for i in range(K): cnt += P[i] cmax = cnt for i in range(K,N): cnt = cnt+P[i]-P[i-K] cmax = max(cmax,cnt) print(((K+cmax)/2))
N,K = list(map(int,input().split())) P = list(map(int,input().split())) A = [0 for _ in range(N)] for i in range(N): A[i] = (P[i]+1)/2 cmax = sum(A[:K]) a = cmax for i in range(1,N-K+1): a = a+A[i+K-1]-A[i-1] cmax = max(cmax,a) print(cmax)
10
11
218
255
N, K = list(map(int, input().split())) P = list(map(int, input().split())) cnt = 0 for i in range(K): cnt += P[i] cmax = cnt for i in range(K, N): cnt = cnt + P[i] - P[i - K] cmax = max(cmax, cnt) print(((K + cmax) / 2))
N, K = list(map(int, input().split())) P = list(map(int, input().split())) A = [0 for _ in range(N)] for i in range(N): A[i] = (P[i] + 1) / 2 cmax = sum(A[:K]) a = cmax for i in range(1, N - K + 1): a = a + A[i + K - 1] - A[i - 1] cmax = max(cmax, a) print(cmax)
false
9.090909
[ "-cnt = 0", "-for i in range(K):", "- cnt += P[i]", "-cmax = cnt", "-for i in range(K, N):", "- cnt = cnt + P[i] - P[i - K]", "- cmax = max(cmax, cnt)", "-print(((K + cmax) / 2))", "+A = [0 for _ in range(N)]", "+for i in range(N):", "+ A[i] = (P[i] + 1) / 2", "+cmax = sum(A[:K])",...
false
0.037493
0.037437
1.00149
[ "s401467619", "s278861130" ]
u644907318
p03696
python
s761887767
s391397082
172
73
38,256
62,028
Accepted
Accepted
57.56
N = int(eval(input())) S = input().strip() S1 = S cur = 0 for i in range(len(S)): if S[i]=="(": cur += 1 else: cur -= 1 if cur<0: S1 = "("+S1 cur += 1 S1 = S1+")"*cur print(S1)
N = int(eval(input())) S = input().strip() while True: lv = 0 lmin = len(S) for i in range(len(S)): if S[i]=="(": lv += 1 else: lv -= 1 lmin = min(lmin,lv) if lmin<0: S = "("*(-lmin)+S else:break lv = 0 for i in range(len(S)): ...
14
24
227
415
N = int(eval(input())) S = input().strip() S1 = S cur = 0 for i in range(len(S)): if S[i] == "(": cur += 1 else: cur -= 1 if cur < 0: S1 = "(" + S1 cur += 1 S1 = S1 + ")" * cur print(S1)
N = int(eval(input())) S = input().strip() while True: lv = 0 lmin = len(S) for i in range(len(S)): if S[i] == "(": lv += 1 else: lv -= 1 lmin = min(lmin, lv) if lmin < 0: S = "(" * (-lmin) + S else: break lv = 0 for i in range(len(S)):...
false
41.666667
[ "-S1 = S", "-cur = 0", "+while True:", "+ lv = 0", "+ lmin = len(S)", "+ for i in range(len(S)):", "+ if S[i] == \"(\":", "+ lv += 1", "+ else:", "+ lv -= 1", "+ lmin = min(lmin, lv)", "+ if lmin < 0:", "+ S = \"(\" * (-lmin) + S"...
false
0.040021
0.072974
0.54843
[ "s761887767", "s391397082" ]
u886747123
p02990
python
s899606605
s579144050
1,788
1,403
481,020
479,484
Accepted
Accepted
21.53
# D - Blue and Red Balls # 青いボールを並べる→赤いボールを青いボールの間に挿入する→残りの赤いボールを両端に置く N, K = list(map(int, input().split())) MOD = 10**9 + 7 # nCkを漸化式で求め、メモしておく combinations_table = [[0]*(N+1) for _ in range(N+1)] for idx in range(N+1): combinations_table[0][idx] = 1 combinations_table[idx][0] = 1 combinati...
# D - Blue and Red Balls N, K = list(map(int, input().split())) MOD = 10**9 + 7 # nCkを漸化式で求め、メモしておく combinations_table = [[0]*(N+1) for _ in range(N+1)] for idx in range(N+1): combinations_table[0][idx] = 1 combinations_table[idx][0] = 1 combinations_table[idx][1] = idx for n in range(2, N+1): ...
38
32
1,325
967
# D - Blue and Red Balls # 青いボールを並べる→赤いボールを青いボールの間に挿入する→残りの赤いボールを両端に置く N, K = list(map(int, input().split())) MOD = 10**9 + 7 # nCkを漸化式で求め、メモしておく combinations_table = [[0] * (N + 1) for _ in range(N + 1)] for idx in range(N + 1): combinations_table[0][idx] = 1 combinations_table[idx][0] = 1 combinations_tab...
# D - Blue and Red Balls N, K = list(map(int, input().split())) MOD = 10**9 + 7 # nCkを漸化式で求め、メモしておく combinations_table = [[0] * (N + 1) for _ in range(N + 1)] for idx in range(N + 1): combinations_table[0][idx] = 1 combinations_table[idx][0] = 1 combinations_table[idx][1] = idx for n in range(2, N + 1): ...
false
15.789474
[ "-# 青いボールを並べる→赤いボールを青いボールの間に挿入する→残りの赤いボールを両端に置く", "+# 青いボールを先に並べると赤いボールが両端にあるかどうかで場合分けが必要", "+# 赤いボールの隙間か両端から一部を選んで青いボールを挿入すれば場合分けが少なくて済む", "- if N - K < n_separate - 1: # 赤いボール不足でi分割不可", "+ if n_separate > K:", "- elif n_separate == 1:", "- ans_list.append(N - K + 1)", "- tmp_...
false
0.843639
0.488538
1.726863
[ "s899606605", "s579144050" ]
u314050667
p02720
python
s649743868
s546708564
456
239
7,724
17,012
Accepted
Accepted
47.59
import sys k = int(eval(input())) if k <= 9: print(k) sys.exit() def judge(s): for i in range(1,len(s)): if abs(int(s[i-1]) - int(s[i])) > 1: return 0 return 1 q = ['1','2','3','4','5','6','7','8','9'] cnt = 9 cond = False while True: cp = q.pop(0) digit = int(cp[-1]) for d in range(-1...
import sys from collections import deque K = int(eval(input())) if K <= 9: print(K) sys.exit() q = deque(['1', '2','3','4','5','6','7','8','9']) cnt = 0 while True: cp = q.popleft() cnt += 1 if cnt == K: ans = int(cp) break r = int(cp[-1]) for d in [-1,0,1]: dd = r + d if 0 <= dd < 10: ...
31
21
496
353
import sys k = int(eval(input())) if k <= 9: print(k) sys.exit() def judge(s): for i in range(1, len(s)): if abs(int(s[i - 1]) - int(s[i])) > 1: return 0 return 1 q = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] cnt = 9 cond = False while True: cp = q.pop(0) digit = int...
import sys from collections import deque K = int(eval(input())) if K <= 9: print(K) sys.exit() q = deque(["1", "2", "3", "4", "5", "6", "7", "8", "9"]) cnt = 0 while True: cp = q.popleft() cnt += 1 if cnt == K: ans = int(cp) break r = int(cp[-1]) for d in [-1, 0, 1]: ...
false
32.258065
[ "+from collections import deque", "-k = int(eval(input()))", "-if k <= 9:", "- print(k)", "+K = int(eval(input()))", "+if K <= 9:", "+ print(K)", "-", "-", "-def judge(s):", "- for i in range(1, len(s)):", "- if abs(int(s[i - 1]) - int(s[i])) > 1:", "- return 0", ...
false
0.11166
0.093001
1.200634
[ "s649743868", "s546708564" ]
u968166680
p03488
python
s281526285
s169802787
261
210
81,020
75,692
Accepted
Accepted
19.54
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def check(vec, init_pos, target_pos): dp = {init_pos} for nv in vec: dp_next = set() for v in dp: dp_next.a...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def check(vec, init_pos, target_pos): dp = {init_pos} for nv in vec: dp_next = set() for v in dp: dp_next.a...
45
45
827
873
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def check(vec, init_pos, target_pos): dp = {init_pos} for nv in vec: dp_next = set() for v in dp: dp_next.add(v - nv) ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def check(vec, init_pos, target_pos): dp = {init_pos} for nv in vec: dp_next = set() for v in dp: dp_next.add(v - nv) ...
false
0
[ "- x_commands = L[2::2]", "- y_commands = L[1::2]", "+ x_commands = [c for c in L[2::2] if c != 0]", "+ y_commands = [c for c in L[1::2] if c != 0]" ]
false
0.094304
0.126905
0.743106
[ "s281526285", "s169802787" ]
u844005364
p03264
python
s602706549
s478996322
201
17
38,256
2,940
Accepted
Accepted
91.54
n = int(eval(input())) print(((n // 2) * (n - n // 2)))
k = int(eval(input())) even = k // 2 odd = k - even print((even * odd))
3
6
50
70
n = int(eval(input())) print(((n // 2) * (n - n // 2)))
k = int(eval(input())) even = k // 2 odd = k - even print((even * odd))
false
50
[ "-n = int(eval(input()))", "-print(((n // 2) * (n - n // 2)))", "+k = int(eval(input()))", "+even = k // 2", "+odd = k - even", "+print((even * odd))" ]
false
0.035967
0.047477
0.757569
[ "s602706549", "s478996322" ]
u558242240
p02901
python
s181082201
s240457616
480
432
46,424
45,912
Accepted
Accepted
10
n, m = list(map(int, input().split())) c = [] a = [] for _ in range(m): ai, bi = list(map(int, input().split())) ci = list([2 ** (int(x) - 1) for x in input().split()]) a.append(ai) c.append(sum(ci)) INF = 100 ** 18 dp = [INF] * (2**n) dp[0] = 0 for i in range(m): for j in range(0, 2**...
n, m = list(map(int, input().split())) ac = [] for _ in range(m): ai, bi = list(map(int, input().split())) ci = list([2 ** (int(x) - 1) for x in input().split()]) ac.append((ai, sum(ci))) INF = 100 ** 18 dp = [INF] * (2**n) dp[0] = 0 for ai, ci in ac: for j in range(0, 2**n): dp[j |...
22
20
451
426
n, m = list(map(int, input().split())) c = [] a = [] for _ in range(m): ai, bi = list(map(int, input().split())) ci = list([2 ** (int(x) - 1) for x in input().split()]) a.append(ai) c.append(sum(ci)) INF = 100**18 dp = [INF] * (2**n) dp[0] = 0 for i in range(m): for j in range(0, 2**n): dp[j...
n, m = list(map(int, input().split())) ac = [] for _ in range(m): ai, bi = list(map(int, input().split())) ci = list([2 ** (int(x) - 1) for x in input().split()]) ac.append((ai, sum(ci))) INF = 100**18 dp = [INF] * (2**n) dp[0] = 0 for ai, ci in ac: for j in range(0, 2**n): dp[j | ci] = min(dp[j...
false
9.090909
[ "-c = []", "-a = []", "+ac = []", "- a.append(ai)", "- c.append(sum(ci))", "+ ac.append((ai, sum(ci)))", "-for i in range(m):", "+for ai, ci in ac:", "- dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i])", "+ dp[j | ci] = min(dp[j | ci], dp[j] + ai)" ]
false
0.040015
0.041572
0.962538
[ "s181082201", "s240457616" ]
u200887663
p03061
python
s618248576
s044903142
230
208
14,076
14,428
Accepted
Accepted
9.57
n=int(eval(input())) al=list(map(int,input().split())) import fractions ans=0 left=[0] for i in range(1,n): ans=fractions.gcd(ans,al[i-1]) left.append(ans) #print(left) right=[0 for i in range(n+1)] for i in range(1,n+1): right[n-i]=fractions.gcd(right[n-i+1],al[n-i]) #print(right) ans=0 ...
n=int(eval(input())) #n,m=map(int,input().split()) al=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] import fractions #gcd=fractions.gcd(a,b)#最大公約数 left=[0 for i in range(n)] right=[0 for i in range(n)] left[0]=al[0] right[n-1]=al[n-1] for i in range(1,n): left...
21
28
402
601
n = int(eval(input())) al = list(map(int, input().split())) import fractions ans = 0 left = [0] for i in range(1, n): ans = fractions.gcd(ans, al[i - 1]) left.append(ans) # print(left) right = [0 for i in range(n + 1)] for i in range(1, n + 1): right[n - i] = fractions.gcd(right[n - i + 1], al[n - i]) # pr...
n = int(eval(input())) # n,m=map(int,input().split()) al = list(map(int, input().split())) # l=[list(map(int,input().split())) for i in range(n)] import fractions # gcd=fractions.gcd(a,b)#最大公約数 left = [0 for i in range(n)] right = [0 for i in range(n)] left[0] = al[0] right[n - 1] = al[n - 1] for i in range(1, n): ...
false
25
[ "+# n,m=map(int,input().split())", "+# l=[list(map(int,input().split())) for i in range(n)]", "-ans = 0", "-left = [0]", "+# gcd=fractions.gcd(a,b)#最大公約数", "+left = [0 for i in range(n)]", "+right = [0 for i in range(n)]", "+left[0] = al[0]", "+right[n - 1] = al[n - 1]", "- ans = fractions.gcd(...
false
0.046143
0.04391
1.050872
[ "s618248576", "s044903142" ]
u987164499
p02947
python
s514539201
s557481641
681
269
39,040
39,040
Accepted
Accepted
60.5
from sys import stdin from math import factorial def combinations_count(n, r): return factorial(n) // (factorial(n - r) * factorial(r)) n = int(stdin.readline().rstrip()) li = [list(stdin.readline().rstrip()) for _ in range(n)] set_list = {} for i in li: i.sort() s = "".join(i) if s in...
from sys import stdin n = int(stdin.readline().rstrip()) li = [list(stdin.readline().rstrip()) for _ in range(n)] set_list = {} for i in li: i.sort() s = "".join(i) if s in set_list: set_list[s] += 1 else: set_list[s] = 1 point = 0 for i in list(set_list.values()): ...
26
21
510
354
from sys import stdin from math import factorial def combinations_count(n, r): return factorial(n) // (factorial(n - r) * factorial(r)) n = int(stdin.readline().rstrip()) li = [list(stdin.readline().rstrip()) for _ in range(n)] set_list = {} for i in li: i.sort() s = "".join(i) if s in set_list: ...
from sys import stdin n = int(stdin.readline().rstrip()) li = [list(stdin.readline().rstrip()) for _ in range(n)] set_list = {} for i in li: i.sort() s = "".join(i) if s in set_list: set_list[s] += 1 else: set_list[s] = 1 point = 0 for i in list(set_list.values()): point += i * (i -...
false
19.230769
[ "-from math import factorial", "-", "-", "-def combinations_count(n, r):", "- return factorial(n) // (factorial(n - r) * factorial(r))", "-", "- if i >= 2:", "- point += combinations_count(i, 2)", "+ point += i * (i - 1) // 2" ]
false
0.038238
0.037637
1.015977
[ "s514539201", "s557481641" ]
u181295070
p02887
python
s860143315
s819670465
49
43
3,956
3,316
Accepted
Accepted
12.24
n = int(eval(input())) s = eval(input()) l = [s[0]] for i in range(1,n): if s[i-1]!=s[i]: l.append(s[i]) print((len(l)))
n = int(eval(input())) s = eval(input()) cnt = 1 for i in range(1,n): if s[i-1]!=s[i]: cnt += 1 print(cnt)
7
7
124
112
n = int(eval(input())) s = eval(input()) l = [s[0]] for i in range(1, n): if s[i - 1] != s[i]: l.append(s[i]) print((len(l)))
n = int(eval(input())) s = eval(input()) cnt = 1 for i in range(1, n): if s[i - 1] != s[i]: cnt += 1 print(cnt)
false
0
[ "-l = [s[0]]", "+cnt = 1", "- l.append(s[i])", "-print((len(l)))", "+ cnt += 1", "+print(cnt)" ]
false
0.038853
0.041892
0.927462
[ "s860143315", "s819670465" ]
u678167152
p02972
python
s904213575
s305555044
926
148
7,100
97,704
Accepted
Accepted
84.02
N = int(input()) A = list(map(int, input().split())) B = [0]*N for i in range(N,0,-1): s = A[i-1] k = i*2 while k<=N: s ^= B[k-1] k += i if s==1: B[i-1] = s if sum(B)==0: print(0) else: print(sum(B)) for i in range(N): if B[i]==1: print(i+1,end=' ')
N = int(eval(input())) A = list(map(int, input().split())) lis = [0]*(N+1) for i in range(N,0,-1): k = i*2 cnt = 0 while k<=N: cnt ^= lis[k] k += i lis[i] = cnt^A[i-1] print((lis.count(1))) ans = [] for i in range(1,N+1): if lis[i]==1: ans.append(i) if len(ans): print((*ans))
18
17
302
306
N = int(input()) A = list(map(int, input().split())) B = [0] * N for i in range(N, 0, -1): s = A[i - 1] k = i * 2 while k <= N: s ^= B[k - 1] k += i if s == 1: B[i - 1] = s if sum(B) == 0: print(0) else: print(sum(B)) for i in range(N): if B[i] == 1: ...
N = int(eval(input())) A = list(map(int, input().split())) lis = [0] * (N + 1) for i in range(N, 0, -1): k = i * 2 cnt = 0 while k <= N: cnt ^= lis[k] k += i lis[i] = cnt ^ A[i - 1] print((lis.count(1))) ans = [] for i in range(1, N + 1): if lis[i] == 1: ans.append(i) if len(...
false
5.555556
[ "-N = int(input())", "+N = int(eval(input()))", "-B = [0] * N", "+lis = [0] * (N + 1)", "- s = A[i - 1]", "+ cnt = 0", "- s ^= B[k - 1]", "+ cnt ^= lis[k]", "- if s == 1:", "- B[i - 1] = s", "-if sum(B) == 0:", "- print(0)", "-else:", "- print(sum(B))", ...
false
0.037651
0.206353
0.182458
[ "s904213575", "s305555044" ]
u102461423
p02998
python
s858470885
s751208129
427
383
48,416
48,384
Accepted
Accepted
10.3
import numpy as np from scipy.sparse import * U = 10**5 N = int(eval(input())) XY = np.array([input().split() for _ in range(N)], dtype=np.int32) graph = csr_matrix(([1]*N, (XY[:,0], U + XY[:,1])), (2*U+1, 2*U+1)) _, component = csgraph.connected_components(graph) X_cnt = np.bincount(component[:U+1], minle...
import numpy as np from scipy.sparse import * import sys input = sys.stdin.readline U = 10**5 N = int(eval(input())) XY = np.array([input().split() for _ in range(N)], dtype=np.int32) graph = csr_matrix((np.ones(N,dtype=np.bool), (XY[:,0], U + XY[:,1])), (2*U+1, 2*U+1)) _, component = csgraph.connected_comp...
15
17
504
563
import numpy as np from scipy.sparse import * U = 10**5 N = int(eval(input())) XY = np.array([input().split() for _ in range(N)], dtype=np.int32) graph = csr_matrix(([1] * N, (XY[:, 0], U + XY[:, 1])), (2 * U + 1, 2 * U + 1)) _, component = csgraph.connected_components(graph) X_cnt = np.bincount(component[: U + 1], mi...
import numpy as np from scipy.sparse import * import sys input = sys.stdin.readline U = 10**5 N = int(eval(input())) XY = np.array([input().split() for _ in range(N)], dtype=np.int32) graph = csr_matrix( (np.ones(N, dtype=np.bool), (XY[:, 0], U + XY[:, 1])), (2 * U + 1, 2 * U + 1) ) _, component = csgraph.connecte...
false
11.764706
[ "+import sys", "+input = sys.stdin.readline", "-graph = csr_matrix(([1] * N, (XY[:, 0], U + XY[:, 1])), (2 * U + 1, 2 * U + 1))", "+graph = csr_matrix(", "+ (np.ones(N, dtype=np.bool), (XY[:, 0], U + XY[:, 1])), (2 * U + 1, 2 * U + 1)", "+)" ]
false
0.791332
0.801105
0.987802
[ "s858470885", "s751208129" ]
u729217226
p03486
python
s623511175
s209296011
108
18
3,064
2,940
Accepted
Accepted
83.33
S = list(input()) T = list(input()) S.sort() T.sort() S.reverse() T.reverse() for i, s in enumerate(S): for j, t in enumerate(T): if s < t: print('Yes') exit() if s > t: for k, t2 in enumerate(T): if s < t2: print(...
s = eval(input()) t = eval(input()) sl = ''.join(sorted(s)) tl = ''.join(reversed(sorted(t))) if sl < tl: print('Yes') else: print('No')
23
10
506
144
S = list(input()) T = list(input()) S.sort() T.sort() S.reverse() T.reverse() for i, s in enumerate(S): for j, t in enumerate(T): if s < t: print("Yes") exit() if s > t: for k, t2 in enumerate(T): if s < t2: print("Yes") ...
s = eval(input()) t = eval(input()) sl = "".join(sorted(s)) tl = "".join(reversed(sorted(t))) if sl < tl: print("Yes") else: print("No")
false
56.521739
[ "-S = list(input())", "-T = list(input())", "-S.sort()", "-T.sort()", "-S.reverse()", "-T.reverse()", "-for i, s in enumerate(S):", "- for j, t in enumerate(T):", "- if s < t:", "- print(\"Yes\")", "- exit()", "- if s > t:", "- for k, t2 in e...
false
0.045158
0.007545
5.9853
[ "s623511175", "s209296011" ]
u477343425
p03292
python
s146467903
s895233059
19
17
3,060
2,940
Accepted
Accepted
10.53
a,b,c = sorted(map(int, input().split())) ans = c - a print(ans)
L = sorted(map(int, input().split())) ans = max(L) - min(L) print(ans)
5
3
72
72
a, b, c = sorted(map(int, input().split())) ans = c - a print(ans)
L = sorted(map(int, input().split())) ans = max(L) - min(L) print(ans)
false
40
[ "-a, b, c = sorted(map(int, input().split()))", "-ans = c - a", "+L = sorted(map(int, input().split()))", "+ans = max(L) - min(L)" ]
false
0.050798
0.047471
1.070083
[ "s146467903", "s895233059" ]
u894265012
p03160
python
s114892902
s288198000
192
176
13,976
15,512
Accepted
Accepted
8.33
N = int(eval(input())) h = list(map(int, input().split())) INF = 10**9 dp = [INF] * N dp[0] = 0 for i in range(1, N): dp[i] = min(dp[i], dp[i-1]+abs(h[i] - h[i-1])) if i > 1: dp[i] = min(dp[i], dp[i-2]+abs(h[i] - h[i-2])) print((dp[N-1]))
N = int(eval(input())) h = [0] * (2*N) h[:N] = list(map(int, input().split())) INF = 10**9 dp = [INF] * (2*N) dp[0] = 0 for i in range(N): dp[i+1] = min(dp[i+1], dp[i]+abs(h[i] - h[i+1])) dp[i+2] = min(dp[i+2], dp[i]+abs(h[i] - h[i+2])) print((dp[N-1]))
10
10
255
262
N = int(eval(input())) h = list(map(int, input().split())) INF = 10**9 dp = [INF] * N dp[0] = 0 for i in range(1, N): dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) if i > 1: dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[N - 1]))
N = int(eval(input())) h = [0] * (2 * N) h[:N] = list(map(int, input().split())) INF = 10**9 dp = [INF] * (2 * N) dp[0] = 0 for i in range(N): dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1])) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2])) print((dp[N - 1]))
false
0
[ "-h = list(map(int, input().split()))", "+h = [0] * (2 * N)", "+h[:N] = list(map(int, input().split()))", "-dp = [INF] * N", "+dp = [INF] * (2 * N)", "-for i in range(1, N):", "- dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))", "- if i > 1:", "- dp[i] = min(dp[i], dp[i - 2] + abs(...
false
0.03939
0.116189
0.339014
[ "s114892902", "s288198000" ]
u780962115
p03634
python
s271229792
s447239356
1,115
782
134,740
134,328
Accepted
Accepted
29.87
import sys sys.setrecursionlimit(1000000) n=int(eval(input())) visitedlist=[-1 for i in range(n)] kilist=[[] for i in range(n)] anslist=[0 for i in range(n)] searchedlist=[-1 for i in range(n)] for i in range(n-1): a,b,c=list(map(int,input().split())) kilist[a-1].append((b,c)) kilist[...
import sys input=sys.stdin.readline sys.setrecursionlimit(1000000) n=int(eval(input())) visitedlist=[-1 for i in range(n)] kilist=[[] for i in range(n)] anslist=[0 for i in range(n)] searchedlist=[-1 for i in range(n)] for i in range(n-1): a,b,c=list(map(int,input().split())) kilist[a-1].appe...
35
36
975
1,001
import sys sys.setrecursionlimit(1000000) n = int(eval(input())) visitedlist = [-1 for i in range(n)] kilist = [[] for i in range(n)] anslist = [0 for i in range(n)] searchedlist = [-1 for i in range(n)] for i in range(n - 1): a, b, c = list(map(int, input().split())) kilist[a - 1].append((b, c)) kilist[b ...
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) n = int(eval(input())) visitedlist = [-1 for i in range(n)] kilist = [[] for i in range(n)] anslist = [0 for i in range(n)] searchedlist = [-1 for i in range(n)] for i in range(n - 1): a, b, c = list(map(int, input().split())) kilist[a - 1].a...
false
2.777778
[ "+input = sys.stdin.readline" ]
false
0.042829
0.042713
1.002694
[ "s271229792", "s447239356" ]
u411203878
p02960
python
s590133162
s496800502
567
287
61,916
101,040
Accepted
Accepted
49.38
s = eval(input()) mod = 10**9 + 7 n = len(s) dp = [[0] * 13 for i in range(n+1)] dp[0][0] = 1 for i in range(n): ss = s[i] for j in range(13): if ss == '?': for k in range(10): dp[i+1][(j*10+k)%13] += dp[i][j] else: dp[i+1][(j*10+int(ss))%13] +...
mod = 1000000007 S = list(eval(input())) n = len(S) dp = [[0]*13 for _ in range(n+1)] dp[0][0] = 1 for i in range(n): s = S[i] for j in range(13): if s == '?': for k in range(10): dp[i+1][(j*10+k)%13] += dp[i][j] else: dp[i+1][(j*10...
15
19
372
386
s = eval(input()) mod = 10**9 + 7 n = len(s) dp = [[0] * 13 for i in range(n + 1)] dp[0][0] = 1 for i in range(n): ss = s[i] for j in range(13): if ss == "?": for k in range(10): dp[i + 1][(j * 10 + k) % 13] += dp[i][j] else: dp[i + 1][(j * 10 + int(ss)) %...
mod = 1000000007 S = list(eval(input())) n = len(S) dp = [[0] * 13 for _ in range(n + 1)] dp[0][0] = 1 for i in range(n): s = S[i] for j in range(13): if s == "?": for k in range(10): dp[i + 1][(j * 10 + k) % 13] += dp[i][j] else: dp[i + 1][(j * 10 + int(s...
false
21.052632
[ "-s = eval(input())", "-mod = 10**9 + 7", "-n = len(s)", "-dp = [[0] * 13 for i in range(n + 1)]", "+mod = 1000000007", "+S = list(eval(input()))", "+n = len(S)", "+dp = [[0] * 13 for _ in range(n + 1)]", "- ss = s[i]", "+ s = S[i]", "- if ss == \"?\":", "+ if s == \"?\":",...
false
0.038582
0.088184
0.437515
[ "s590133162", "s496800502" ]
u677121387
p02762
python
s552926667
s629076495
1,171
958
11,832
33,032
Accepted
Accepted
18.19
class DisjointSet: def __init__(self,n): self.parent = [i for i in range(n)] self.siz = [1]*n def root(self,x): if x != self.parent[x]: self.parent[x] = self.root(self.parent[x]) return self.parent[x] def same(self,x,y): return self.root(x) ...
from collections import deque,Counter n,m,k = list(map(int,input().split())) G = [[] for _ in range(n)] exc = [0]*n for _ in range(m): a,b = list(map(int,input().split())) a -= 1 b -= 1 G[a].append(b) G[b].append(a) exc[a] += 1 exc[b] += 1 stk = deque() grp = [-1]*n grpnum ...
45
43
1,059
855
class DisjointSet: def __init__(self, n): self.parent = [i for i in range(n)] self.siz = [1] * n def root(self, x): if x != self.parent[x]: self.parent[x] = self.root(self.parent[x]) return self.parent[x] def same(self, x, y): return self.root(x) == self...
from collections import deque, Counter n, m, k = list(map(int, input().split())) G = [[] for _ in range(n)] exc = [0] * n for _ in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 G[a].append(b) G[b].append(a) exc[a] += 1 exc[b] += 1 stk = deque() grp = [-1] * n grpnum = 0 d...
false
4.444444
[ "-class DisjointSet:", "- def __init__(self, n):", "- self.parent = [i for i in range(n)]", "- self.siz = [1] * n", "-", "- def root(self, x):", "- if x != self.parent[x]:", "- self.parent[x] = self.root(self.parent[x])", "- return self.parent[x]", "-",...
false
0.042817
0.086218
0.496612
[ "s552926667", "s629076495" ]
u948911484
p03108
python
s993049333
s473856280
1,109
510
105,560
29,484
Accepted
Accepted
54.01
n,m = list(map(int,input().split())) ab = [list(map(int,input().split())) for i in range(m)] class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] ...
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): ...
60
64
1,564
1,539
n, m = list(map(int, input().split())) ab = [list(map(int, input().split())) for i in range(m)] class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.f...
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = se...
false
6.25
[ "-n, m = list(map(int, input().split()))", "-ab = [list(map(int, input().split())) for i in range(m)]", "-", "-", "+n, m = list(map(int, input().split()))", "-s = n * (n - 1) // 2", "-ans = [0] * m", "+q = []", "+for i in range(m):", "+ a, b = list(map(int, input().split()))", "+ q.append(...
false
0.038539
0.038886
0.991086
[ "s993049333", "s473856280" ]
u281303342
p03148
python
s623887604
s017023042
1,581
299
21,252
19,216
Accepted
Accepted
81.09
N,K = list(map(int,input().split())) X = [] for i in range(N): t,d = list(map(int,input().split())) X.append((d,t)) X.sort(reverse=True) p,v = 0,set([]) pp = [] for i in range(K): p += X[i][0] if X[i][1] not in v: v.add(X[i][1]) else: pp.append((X[i][0],X[i][1])) ...
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # --------------------------------------...
28
50
586
1,201
N, K = list(map(int, input().split())) X = [] for i in range(N): t, d = list(map(int, input().split())) X.append((d, t)) X.sort(reverse=True) p, v = 0, set([]) pp = [] for i in range(K): p += X[i][0] if X[i][1] not in v: v.add(X[i][1]) else: pp.append((X[i][0], X[i][1])) Ans = p + le...
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ---------------------------------------------------...
false
44
[ "+# Python3 (3.4.3)", "+import sys", "+", "+input = sys.stdin.readline", "+# function", "+# main", "-X = []", "-for i in range(N):", "- t, d = list(map(int, input().split()))", "- X.append((d, t))", "-X.sort(reverse=True)", "-p, v = 0, set([])", "-pp = []", "+TD = [tuple(map(int, inp...
false
0.054539
0.035561
1.5337
[ "s623887604", "s017023042" ]
u678505520
p02924
python
s966635345
s841456225
1,362
65
62,820
61,528
Accepted
Accepted
95.23
n = int(eval(input())) ans = 0 for i in range(n): ans += i print(ans)
n = int(eval(input())) print((n*(n-1)//2))
5
2
71
35
n = int(eval(input())) ans = 0 for i in range(n): ans += i print(ans)
n = int(eval(input())) print((n * (n - 1) // 2))
false
60
[ "-ans = 0", "-for i in range(n):", "- ans += i", "-print(ans)", "+print((n * (n - 1) // 2))" ]
false
0.134208
0.032254
4.160987
[ "s966635345", "s841456225" ]
u072717685
p03838
python
s148725842
s480354429
346
29
79,816
9,132
Accepted
Accepted
91.62
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): x, y = list(map(int, input().split())) if x < y: if y == 0: print((-x)) elif x == 0: print(y) elif 0 < x and 0 < y: print((y - x)) elif x < 0 and 0 < y: ...
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): x, y = list(map(int, input().split())) inf = float('inf') r1 = y - x if y - x >= 0 else inf r2 = y - -x + 1 if y - -x >= 0 else inf r3 = -y - x + 1 if -y - x >= 0 else inf r4 = -y - -x + 2 if -y - -x >= 0 else ...
30
15
716
403
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): x, y = list(map(int, input().split())) if x < y: if y == 0: print((-x)) elif x == 0: print(y) elif 0 < x and 0 < y: print((y - x)) elif x < 0 and 0 < y: ...
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): x, y = list(map(int, input().split())) inf = float("inf") r1 = y - x if y - x >= 0 else inf r2 = y - -x + 1 if y - -x >= 0 else inf r3 = -y - x + 1 if -y - x >= 0 else inf r4 = -y - -x + 2 if -y - -x >= 0 else inf ...
false
50
[ "- if x < y:", "- if y == 0:", "- print((-x))", "- elif x == 0:", "- print(y)", "- elif 0 < x and 0 < y:", "- print((y - x))", "- elif x < 0 and 0 < y:", "- print((abs(y - abs(x)) + 1))", "- else:", "- p...
false
0.042238
0.034554
1.222376
[ "s148725842", "s480354429" ]
u459150945
p02725
python
s796703096
s125864759
231
149
26,420
26,444
Accepted
Accepted
35.5
K, N = list(map(int, input().split())) An = list(map(int, input().split())) An_1 = [A for A in An if A <= K/2] An_2 = [A-K for A in An if A > K/2] An_new = An_1 + An_2 ans = 0 for i in range(len(An)-1): ans = max(ans, An[i+1]-An[i]) ans = max(ans, An_new[0] - An_new[-1]) print((K-ans))
K, N = list(map(int, input().split())) An = list(map(int, input().split())) ans = 0 for i in range(len(An)-1): ans = max(ans, An[i+1]-An[i]) ans = max(ans, An[0] - (An[-1]-K)) print((K-ans))
14
12
303
203
K, N = list(map(int, input().split())) An = list(map(int, input().split())) An_1 = [A for A in An if A <= K / 2] An_2 = [A - K for A in An if A > K / 2] An_new = An_1 + An_2 ans = 0 for i in range(len(An) - 1): ans = max(ans, An[i + 1] - An[i]) ans = max(ans, An_new[0] - An_new[-1]) print((K - ans))
K, N = list(map(int, input().split())) An = list(map(int, input().split())) ans = 0 for i in range(len(An) - 1): ans = max(ans, An[i + 1] - An[i]) ans = max(ans, An[0] - (An[-1] - K)) print((K - ans))
false
14.285714
[ "-An_1 = [A for A in An if A <= K / 2]", "-An_2 = [A - K for A in An if A > K / 2]", "-An_new = An_1 + An_2", "-ans = max(ans, An_new[0] - An_new[-1])", "+ans = max(ans, An[0] - (An[-1] - K))" ]
false
0.037663
0.037677
0.999644
[ "s796703096", "s125864759" ]
u125269142
p03308
python
s882139835
s809629226
114
28
27,228
9,160
Accepted
Accepted
75.44
import numpy as np n = int(eval(input())) lists = list(map(int, input().split())) arr = np.array(lists) maximum = arr.max() minimum = arr.min() print((maximum - minimum))
n = int(eval(input())) lists = list(map(int, input().split())) lists.sort() print((lists[-1] - lists[0]))
9
5
172
103
import numpy as np n = int(eval(input())) lists = list(map(int, input().split())) arr = np.array(lists) maximum = arr.max() minimum = arr.min() print((maximum - minimum))
n = int(eval(input())) lists = list(map(int, input().split())) lists.sort() print((lists[-1] - lists[0]))
false
44.444444
[ "-import numpy as np", "-", "-arr = np.array(lists)", "-maximum = arr.max()", "-minimum = arr.min()", "-print((maximum - minimum))", "+lists.sort()", "+print((lists[-1] - lists[0]))" ]
false
0.144977
0.052157
2.779617
[ "s882139835", "s809629226" ]
u608088992
p02954
python
s316277572
s938374658
252
100
54,748
15,296
Accepted
Accepted
60.32
import sys from bisect import bisect_left, bisect def solve(): S = eval(input()) N = len(S) RL = [] B = [0] * N for i in range(N): if S[i] == "R": if i < N - 1 and S[i + 1] == "L": RL.append(i) for i in range(N): j = bisect_left(RL, i) if S[i] ==...
import sys def solve(): input = sys.stdin.readline S = input().strip("\n") N = len(S) nL, nR = [N-1] * N, [0] * N cl, cr = N-1, 0 for i in range(1, N): if S[i] == "R": cr = i nR[i] = cr if S[N-i-1] == "L": cl = N-i-1 nL[N-i-1] = cl sumC = [0] *...
24
32
615
722
import sys from bisect import bisect_left, bisect def solve(): S = eval(input()) N = len(S) RL = [] B = [0] * N for i in range(N): if S[i] == "R": if i < N - 1 and S[i + 1] == "L": RL.append(i) for i in range(N): j = bisect_left(RL, i) if S[i...
import sys def solve(): input = sys.stdin.readline S = input().strip("\n") N = len(S) nL, nR = [N - 1] * N, [0] * N cl, cr = N - 1, 0 for i in range(1, N): if S[i] == "R": cr = i nR[i] = cr if S[N - i - 1] == "L": cl = N - i - 1 nL[N - i ...
false
25
[ "-from bisect import bisect_left, bisect", "- S = eval(input())", "+ input = sys.stdin.readline", "+ S = input().strip(\"\\n\")", "- RL = []", "- B = [0] * N", "+ nL, nR = [N - 1] * N, [0] * N", "+ cl, cr = N - 1, 0", "+ for i in range(1, N):", "+ if S[i] == \"R\":",...
false
0.107971
0.154963
0.69675
[ "s316277572", "s938374658" ]
u562767072
p02684
python
s310004962
s012616915
285
209
51,012
51,080
Accepted
Accepted
26.67
#!/usr/bin/env python3 import numpy as np # def input(): # return sys.stdin.readline().rstrip() def main(): n, k = list(map(int, input().split())) warps = list(map(int, input().split())) warps = [0] + warps warps = np.array(warps, dtype=int) order_num = np.zeros(len(warps)...
#!/usr/bin/env python3 import numpy as np # def input(): # return sys.stdin.readline().rstrip() def main(): n, k = list(map(int, input().split())) warps = list(map(int, input().split())) warps = [0] + warps # warps = np.array(warps, dtype=int) # order_num = np.zeros(len(wa...
43
44
959
1,011
#!/usr/bin/env python3 import numpy as np # def input(): # return sys.stdin.readline().rstrip() def main(): n, k = list(map(int, input().split())) warps = list(map(int, input().split())) warps = [0] + warps warps = np.array(warps, dtype=int) order_num = np.zeros(len(warps) + 1, dtype=int) p...
#!/usr/bin/env python3 import numpy as np # def input(): # return sys.stdin.readline().rstrip() def main(): n, k = list(map(int, input().split())) warps = list(map(int, input().split())) warps = [0] + warps # warps = np.array(warps, dtype=int) # order_num = np.zeros(len(warps) + 1, dtype=int) ...
false
2.272727
[ "- warps = np.array(warps, dtype=int)", "- order_num = np.zeros(len(warps) + 1, dtype=int)", "+ # warps = np.array(warps, dtype=int)", "+ # order_num = np.zeros(len(warps) + 1, dtype=int)", "+ order_num = [0 for i in range(len(warps))]" ]
false
0.187221
0.040199
4.657327
[ "s310004962", "s012616915" ]
u652057333
p03026
python
s605841457
s850187078
1,809
81
14,880
14,752
Accepted
Accepted
95.52
from collections import defaultdict import sys sys.setrecursionlimit(20000000) connection = defaultdict(lambda: []) n = int(eval(input())) ab = [] for i in range(n-1): a, b = list(map(int, input().split())) connection[a].append(b) connection[b].append(a) ab.append((a, b)) c = list(map(i...
from collections import defaultdict import sys sys.setrecursionlimit(20000000) connection = defaultdict(lambda: []) n = int(eval(input())) ab = [] for i in range(n-1): a, b = list(map(int, input().split())) connection[a].append(b) connection[b].append(a) ab.append((a, b)) c = list(map(i...
35
32
684
624
from collections import defaultdict import sys sys.setrecursionlimit(20000000) connection = defaultdict(lambda: []) n = int(eval(input())) ab = [] for i in range(n - 1): a, b = list(map(int, input().split())) connection[a].append(b) connection[b].append(a) ab.append((a, b)) c = list(map(int, input().sp...
from collections import defaultdict import sys sys.setrecursionlimit(20000000) connection = defaultdict(lambda: []) n = int(eval(input())) ab = [] for i in range(n - 1): a, b = list(map(int, input().split())) connection[a].append(b) connection[b].append(a) ab.append((a, b)) c = list(map(int, input().sp...
false
8.571429
[ "-checked_list = []", "- checked_list.append(num)", "- if next_num not in checked_list:", "+ if ans[next_num] == 0:" ]
false
0.135452
0.037715
3.591431
[ "s605841457", "s850187078" ]
u347640436
p03476
python
s915523109
s624427937
867
489
7,156
12,540
Accepted
Accepted
43.6
from math import sqrt max_lr = 10 ** 5 sieve = [True] * (max_lr + 1) sieve[0] = False sieve[1] = False for i in range(2, int(sqrt(max_lr)) + 1): if not sieve[i]: continue for j in range(i * i, max_lr + 1, i): sieve[j] = False cs = [0] * (max_lr + 1) for i in range(3, max_lr + 1,...
# エラトステネスの篩, 累積和 def make_prime_table(N): sieve = [0] * (N + 1) sieve[0] = -1 sieve[1] = -1 for i in range(2, N + 1): if sieve[i] != 0: continue sieve[i] = i for j in range(i * i, N + 1, i): if sieve[j] == 0: sieve[j] = i re...
24
29
550
713
from math import sqrt max_lr = 10**5 sieve = [True] * (max_lr + 1) sieve[0] = False sieve[1] = False for i in range(2, int(sqrt(max_lr)) + 1): if not sieve[i]: continue for j in range(i * i, max_lr + 1, i): sieve[j] = False cs = [0] * (max_lr + 1) for i in range(3, max_lr + 1, 2): if sieve[...
# エラトステネスの篩, 累積和 def make_prime_table(N): sieve = [0] * (N + 1) sieve[0] = -1 sieve[1] = -1 for i in range(2, N + 1): if sieve[i] != 0: continue sieve[i] = i for j in range(i * i, N + 1, i): if sieve[j] == 0: sieve[j] = i return sieve ...
false
17.241379
[ "-from math import sqrt", "+# エラトステネスの篩, 累積和", "+def make_prime_table(N):", "+ sieve = [0] * (N + 1)", "+ sieve[0] = -1", "+ sieve[1] = -1", "+ for i in range(2, N + 1):", "+ if sieve[i] != 0:", "+ continue", "+ sieve[i] = i", "+ for j in range(i * i, ...
false
0.127215
0.166376
0.764622
[ "s915523109", "s624427937" ]
u670961163
p02880
python
s454232989
s345242921
170
17
38,256
2,940
Accepted
Accepted
90
x = int(eval(input())) count =0 for n in range(1, 10): for k in range(1, 10): a = n * k if a == x: print('Yes') exit() else: pass print('No')
x = int(eval(input())) for n in range(1, 10): for k in range(1, 10): a = n * k if a == x: print('Yes') exit() else: pass print('No')
12
11
211
201
x = int(eval(input())) count = 0 for n in range(1, 10): for k in range(1, 10): a = n * k if a == x: print("Yes") exit() else: pass print("No")
x = int(eval(input())) for n in range(1, 10): for k in range(1, 10): a = n * k if a == x: print("Yes") exit() else: pass print("No")
false
8.333333
[ "-count = 0" ]
false
0.091924
0.0359
2.560568
[ "s454232989", "s345242921" ]
u954858867
p02402
python
s502860531
s584880119
30
10
7,056
7,128
Accepted
Accepted
66.67
n = input() x = list(map(int, input().split())) print(('%s %s %s' % (min(x), max(x), sum(x))))
n = list(map(int, input())) x = list(map(int, input().split())) print(('%s %s %s' % (min(x), max(x), sum(x))))
3
3
96
106
n = input() x = list(map(int, input().split())) print(("%s %s %s" % (min(x), max(x), sum(x))))
n = list(map(int, input())) x = list(map(int, input().split())) print(("%s %s %s" % (min(x), max(x), sum(x))))
false
0
[ "-n = input()", "+n = list(map(int, input()))" ]
false
0.162653
0.043778
3.71544
[ "s502860531", "s584880119" ]
u963343620
p03399
python
s328099583
s803549176
19
17
3,060
2,940
Accepted
Accepted
10.53
a, b, c, d = [int(eval(input())) for i in range(4)] print((min(a, b)+min(c, d)))
a,b,c,d = (int(eval(input())) for i in range(4)) print((min(a,b)+min(c,d)))
2
2
73
68
a, b, c, d = [int(eval(input())) for i in range(4)] print((min(a, b) + min(c, d)))
a, b, c, d = (int(eval(input())) for i in range(4)) print((min(a, b) + min(c, d)))
false
0
[ "-a, b, c, d = [int(eval(input())) for i in range(4)]", "+a, b, c, d = (int(eval(input())) for i in range(4))" ]
false
0.047522
0.066075
0.719204
[ "s328099583", "s803549176" ]
u883203948
p02911
python
s713002774
s872617264
304
281
9,420
7,844
Accepted
Accepted
7.57
n,k,q = list(map(int,input().split())) ans = [0] * n data = [k] * n data2 = [0] * n for i in range(q): tmp = int(eval(input())) data2[tmp-1] += 1 for i in range(n): ans[i] = data2[i] + data[i] - q for i in range(n): if ans[i] >0 : print("Yes") else: print("No")
n,k,q = list(map(int,input().split())) data = [k] * n for i in range(q): answer = int(eval(input())) data[answer-1] += 1 for i in range(n): data[i] = data[i] - q for i in range(n): if data[i] >= 1: print('Yes') else: print('No')
18
14
296
257
n, k, q = list(map(int, input().split())) ans = [0] * n data = [k] * n data2 = [0] * n for i in range(q): tmp = int(eval(input())) data2[tmp - 1] += 1 for i in range(n): ans[i] = data2[i] + data[i] - q for i in range(n): if ans[i] > 0: print("Yes") else: print("No")
n, k, q = list(map(int, input().split())) data = [k] * n for i in range(q): answer = int(eval(input())) data[answer - 1] += 1 for i in range(n): data[i] = data[i] - q for i in range(n): if data[i] >= 1: print("Yes") else: print("No")
false
22.222222
[ "-ans = [0] * n", "-data2 = [0] * n", "- tmp = int(eval(input()))", "- data2[tmp - 1] += 1", "+ answer = int(eval(input()))", "+ data[answer - 1] += 1", "- ans[i] = data2[i] + data[i] - q", "+ data[i] = data[i] - q", "- if ans[i] > 0:", "+ if data[i] >= 1:" ]
false
0.046347
0.00786
5.896858
[ "s713002774", "s872617264" ]
u774160580
p02984
python
s068816224
s068000239
858
165
23,120
14,020
Accepted
Accepted
80.77
import numpy as np N = int(eval(input())) A = np.array([int(i) for i in input().split()]) # dif = A1-A2+A3-A4 ... dif = sum([A[i] * pow(-1, i) for i in range(N - 1)]) ans = [0] * N ans[0] = A[-1] + dif ans[-1] = A[-1] - dif for i in range(1, N - 1): ans[i] = 2 * A[i - 1] - ans[i - 1] print((*ans))
N = int(eval(input())) A = [int(i) for i in input().split()] # dif = A1-A2+A3-A4 ... dif = sum([A[i] * pow(-1, i) for i in range(N - 1)]) ans = [0] * N ans[0] = A[-1] + dif ans[-1] = A[-1] - dif for i in range(1, N - 1): ans[i] = 2 * A[i - 1] - ans[i - 1] print((*ans))
12
10
307
275
import numpy as np N = int(eval(input())) A = np.array([int(i) for i in input().split()]) # dif = A1-A2+A3-A4 ... dif = sum([A[i] * pow(-1, i) for i in range(N - 1)]) ans = [0] * N ans[0] = A[-1] + dif ans[-1] = A[-1] - dif for i in range(1, N - 1): ans[i] = 2 * A[i - 1] - ans[i - 1] print((*ans))
N = int(eval(input())) A = [int(i) for i in input().split()] # dif = A1-A2+A3-A4 ... dif = sum([A[i] * pow(-1, i) for i in range(N - 1)]) ans = [0] * N ans[0] = A[-1] + dif ans[-1] = A[-1] - dif for i in range(1, N - 1): ans[i] = 2 * A[i - 1] - ans[i - 1] print((*ans))
false
16.666667
[ "-import numpy as np", "-", "-A = np.array([int(i) for i in input().split()])", "+A = [int(i) for i in input().split()]" ]
false
0.200421
0.036347
5.514137
[ "s068816224", "s068000239" ]
u997641430
p02913
python
s318157600
s120732717
1,147
589
61,660
155,272
Accepted
Accepted
48.65
def zalgo(S): # SとS[i:n]のlcpの長さを記録した配列を返す n = len(S) A = [0] * n j = 0 for i in range(1, n): if i+A[i-j] < j+A[j]: A[i] = A[i-j] else: k = max(0, A[j]-i+j) while i+k < n and S[k] == S[i+k]: k += 1 A[i] = k ...
def ok(l): # 長さlの連続部分列で重ならずに2回以上現れるものがある D = {} for i in range(n-l+1): try: if D[S[i:i+l]]+l <= i: return True except: D[S[i:i+l]] = i return False n = int(eval(input())) S = eval(input()) # 二分探索でTrueになる最大のkを求める l, r = 0, n+1 whil...
26
23
529
403
def zalgo(S): # SとS[i:n]のlcpの長さを記録した配列を返す n = len(S) A = [0] * n j = 0 for i in range(1, n): if i + A[i - j] < j + A[j]: A[i] = A[i - j] else: k = max(0, A[j] - i + j) while i + k < n and S[k] == S[i + k]: k += 1 A[i] = ...
def ok(l): # 長さlの連続部分列で重ならずに2回以上現れるものがある D = {} for i in range(n - l + 1): try: if D[S[i : i + l]] + l <= i: return True except: D[S[i : i + l]] = i return False n = int(eval(input())) S = eval(input()) # 二分探索でTrueになる最大のkを求める l, r = 0, n + 1 whil...
false
11.538462
[ "-def zalgo(S):", "- # SとS[i:n]のlcpの長さを記録した配列を返す", "- n = len(S)", "- A = [0] * n", "- j = 0", "- for i in range(1, n):", "- if i + A[i - j] < j + A[j]:", "- A[i] = A[i - j]", "- else:", "- k = max(0, A[j] - i + j)", "- while i + k < ...
false
0.088563
0.088528
1.000389
[ "s318157600", "s120732717" ]
u492910842
p03493
python
s168895775
s265083483
151
60
61,540
61,724
Accepted
Accepted
60.26
s=list(eval(input())) print((s.count("1")))
s=eval(input()) ans=0 for i in range(3): if s[i]=="1": ans+=1 print(ans)
2
6
36
77
s = list(eval(input())) print((s.count("1")))
s = eval(input()) ans = 0 for i in range(3): if s[i] == "1": ans += 1 print(ans)
false
66.666667
[ "-s = list(eval(input()))", "-print((s.count(\"1\")))", "+s = eval(input())", "+ans = 0", "+for i in range(3):", "+ if s[i] == \"1\":", "+ ans += 1", "+print(ans)" ]
false
0.038973
0.039061
0.997726
[ "s168895775", "s265083483" ]
u332906195
p02631
python
s931261418
s323067046
1,529
137
354,920
33,464
Accepted
Accepted
91.04
N = int(eval(input())) A = list(map(int, input().split())) maxl = len(bin(max(A))[2:]) ans = [['0'] * N for _ in range(maxl)] for n in range(N): for d, a in enumerate(bin(A[n])[2:].zfill(maxl)): ans[d][n] = a for dn in range(maxl): n1 = sum([1 for d in ans[dn] if d == '1']) if n1 % 2 == 1...
N = int(eval(input())) A = list(map(int, input().split())) S = 0 for a in A: S ^= a print((" ".join([str(S ^ a) for a in A])))
16
6
515
128
N = int(eval(input())) A = list(map(int, input().split())) maxl = len(bin(max(A))[2:]) ans = [["0"] * N for _ in range(maxl)] for n in range(N): for d, a in enumerate(bin(A[n])[2:].zfill(maxl)): ans[d][n] = a for dn in range(maxl): n1 = sum([1 for d in ans[dn] if d == "1"]) if n1 % 2 == 1: f...
N = int(eval(input())) A = list(map(int, input().split())) S = 0 for a in A: S ^= a print((" ".join([str(S ^ a) for a in A])))
false
62.5
[ "-maxl = len(bin(max(A))[2:])", "-ans = [[\"0\"] * N for _ in range(maxl)]", "-for n in range(N):", "- for d, a in enumerate(bin(A[n])[2:].zfill(maxl)):", "- ans[d][n] = a", "-for dn in range(maxl):", "- n1 = sum([1 for d in ans[dn] if d == \"1\"])", "- if n1 % 2 == 1:", "- fo...
false
0.087763
0.043132
2.034744
[ "s931261418", "s323067046" ]
u463775490
p03854
python
s943649873
s745161639
71
18
3,316
3,188
Accepted
Accepted
74.65
s = input()[::-1] ans = 'YES' while s: if s[:5] == 'maerd' or s[0:5] == 'esare': s = s[5:] elif s[:6] == 'resare': s = s[6:] elif s[:7] == 'remaerd': s = s[7:] else: ans = 'NO' break print(ans)
s = eval(input()) s = s.replace('eraser', '') s = s.replace('erase', '') s = s.replace('dreamer', '') s = s.replace('dream', '') print(('NO' if s else 'YES'))
13
8
261
159
s = input()[::-1] ans = "YES" while s: if s[:5] == "maerd" or s[0:5] == "esare": s = s[5:] elif s[:6] == "resare": s = s[6:] elif s[:7] == "remaerd": s = s[7:] else: ans = "NO" break print(ans)
s = eval(input()) s = s.replace("eraser", "") s = s.replace("erase", "") s = s.replace("dreamer", "") s = s.replace("dream", "") print(("NO" if s else "YES"))
false
38.461538
[ "-s = input()[::-1]", "-ans = \"YES\"", "-while s:", "- if s[:5] == \"maerd\" or s[0:5] == \"esare\":", "- s = s[5:]", "- elif s[:6] == \"resare\":", "- s = s[6:]", "- elif s[:7] == \"remaerd\":", "- s = s[7:]", "- else:", "- ans = \"NO\"", "- bre...
false
0.034577
0.036608
0.944526
[ "s943649873", "s745161639" ]
u631277801
p02936
python
s886366325
s352741789
1,019
937
125,020
123,120
Accepted
Accepted
8.05
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.r...
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.r...
49
50
1,041
1,261
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
false
2
[ "+class Node(object):", "+ def __init__(self, num: int):", "+ self.num = num", "+ self.cnt = 0", "+ self.visited = False", "+", "+", "+def dfs(init_node: Node, graph: list):", "+ stack = [init_node]", "+ init_node.visited = True", "+ while stack:", "+ cu...
false
0.037947
0.037757
1.005018
[ "s886366325", "s352741789" ]
u970109776
p02577
python
s752493543
s555664320
73
55
9,564
9,076
Accepted
Accepted
24.66
#coding: utf-8 from collections import defaultdict import sys N = eval(input()) s = 0 for c in N: s += int(c) if s % 9 == 0: print("Yes") else: print("No")
N = eval(input()) s = sum(int(x) for x in N) if s % 9 == 0: print("Yes") else: print("No")
16
7
183
99
# coding: utf-8 from collections import defaultdict import sys N = eval(input()) s = 0 for c in N: s += int(c) if s % 9 == 0: print("Yes") else: print("No")
N = eval(input()) s = sum(int(x) for x in N) if s % 9 == 0: print("Yes") else: print("No")
false
56.25
[ "-# coding: utf-8", "-from collections import defaultdict", "-import sys", "-", "-s = 0", "-for c in N:", "- s += int(c)", "+s = sum(int(x) for x in N)" ]
false
0.122792
0.044725
2.745507
[ "s752493543", "s555664320" ]
u941753895
p03695
python
s006587655
s463902124
53
42
6,172
5,416
Accepted
Accepted
20.75
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 def LI(): return list(map(int,input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval(input()) def main(): n=I(...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 def LI(): return list(map(int,input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval(input()) def main(): n=I(...
35
37
605
629
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return list(map(int, input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval...
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return list(map(int, input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval...
false
5.405405
[ "- l2 = []", "+ a = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]", "+ b = [0] * 9", "- if x >= 3200:", "+ for i in range(len(a) - 1):", "+ if a[i] <= x and x < a[i + 1]:", "+ b[i] += 1", "+ if 3200 <= x:", "- l2.append(8)", "-...
false
0.045684
0.036371
1.256054
[ "s006587655", "s463902124" ]
u392319141
p03674
python
s802018310
s001184796
456
401
30,560
32,424
Accepted
Accepted
12.06
from collections import Counter, defaultdict class Combination: def __init__(self, size, mod=10**9 + 7): self.size = size + 2 self.mod = mod self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2,...
from collections import Counter class Combination: def __init__(self, size): self.size = size + 2 self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i...
50
45
1,446
1,289
from collections import Counter, defaultdict class Combination: def __init__(self, size, mod=10**9 + 7): self.size = size + 2 self.mod = mod self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size...
from collections import Counter class Combination: def __init__(self, size): self.size = size + 2 self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i - 1] * i ...
false
10
[ "-from collections import Counter, defaultdict", "+from collections import Counter", "- def __init__(self, size, mod=10**9 + 7):", "+ def __init__(self, size):", "- self.mod = mod", "- self.fact[i] = self.fact[i - 1] * i % self.mod", "- self.inv[i] = -self.inv[self.mod...
false
0.036574
0.0464
0.788224
[ "s802018310", "s001184796" ]
u701644092
p02713
python
s558614691
s024890367
1,418
603
9,144
9,156
Accepted
Accepted
57.48
K=int(eval(input())) import math ans=0 for a in range(1,K+1): for b in range(1,K+1): g=math.gcd(a,b) for c in range(1,K+1): ans += math.gcd(g,c) print(ans)
K=int(eval(input())) import math ans=0 for a in range(1,K+1): for b in range(1,K+1): g=math.gcd(a,b) if g==1: ans += K continue for c in range(1,K+1): ans += math.gcd(g,c) print(ans)
9
12
173
220
K = int(eval(input())) import math ans = 0 for a in range(1, K + 1): for b in range(1, K + 1): g = math.gcd(a, b) for c in range(1, K + 1): ans += math.gcd(g, c) print(ans)
K = int(eval(input())) import math ans = 0 for a in range(1, K + 1): for b in range(1, K + 1): g = math.gcd(a, b) if g == 1: ans += K continue for c in range(1, K + 1): ans += math.gcd(g, c) print(ans)
false
25
[ "+ if g == 1:", "+ ans += K", "+ continue" ]
false
0.249493
0.106416
2.344503
[ "s558614691", "s024890367" ]
u413165887
p03317
python
s331635260
s297391647
47
40
13,880
13,880
Accepted
Accepted
14.89
n, k = list(map(int, input().split())) a = list(map(int, input().split())) if k < n: c = 1 n -= k while n > 0: n -= k-1 c += 1 print(c) else: print((1))
n, k = list(map(int, input().split())) a = list(map(int, input().split())) if k < n: c = 1 n -= k c += -((-n)//(k-1)) print(c) else: print((1))
12
10
192
165
n, k = list(map(int, input().split())) a = list(map(int, input().split())) if k < n: c = 1 n -= k while n > 0: n -= k - 1 c += 1 print(c) else: print((1))
n, k = list(map(int, input().split())) a = list(map(int, input().split())) if k < n: c = 1 n -= k c += -((-n) // (k - 1)) print(c) else: print((1))
false
16.666667
[ "- while n > 0:", "- n -= k - 1", "- c += 1", "+ c += -((-n) // (k - 1))" ]
false
0.071839
0.070444
1.019808
[ "s331635260", "s297391647" ]
u046187684
p03074
python
s976719793
s591360399
105
80
11,188
11,240
Accepted
Accepted
23.81
def solve(string): n, k, s = string.split() n, k = list(map(int, [n, k])) flip = [0] for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1): if s0 != s1: flip.append(i) flip += [n] return str( max([ flip[min(len(flip) - 1, i + 2 * k + (i % 2 ^ int(...
def solve(string): n, k, s = string.split() n, k = list(map(int, [n, k])) flip = [0] for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1): if s0 != s1: flip.append(i) flip += [n] start = int(s[0]) l = len(flip) - 1 return str(max([flip[min(l, i + 2 * k + (i ...
17
15
466
445
def solve(string): n, k, s = string.split() n, k = list(map(int, [n, k])) flip = [0] for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1): if s0 != s1: flip.append(i) flip += [n] return str( max( [ flip[min(len(flip) - 1, i + 2 * k + (i % 2...
def solve(string): n, k, s = string.split() n, k = list(map(int, [n, k])) flip = [0] for i, (s0, s1) in enumerate(zip(s, s[1:]), start=1): if s0 != s1: flip.append(i) flip += [n] start = int(s[0]) l = len(flip) - 1 return str( max([flip[min(l, i + 2 * k + (i %...
false
11.764706
[ "+ start = int(s[0])", "+ l = len(flip) - 1", "- max(", "- [", "- flip[min(len(flip) - 1, i + 2 * k + (i % 2 ^ int(s[0])))] - flip[i]", "- for i in range(len(flip))", "- ]", "- )", "+ max([flip[min(l, i + 2 * k + (i % 2 ^...
false
0.110108
0.037643
2.925035
[ "s976719793", "s591360399" ]
u013756322
p03610
python
s831771023
s270364120
40
17
3,188
3,188
Accepted
Accepted
57.5
s = eval(input()) ans = '' i = 1 for c in s: if (i % 2 == 1): ans += c i += 1 print(ans)
print((input()[0::2]))
9
2
100
23
s = eval(input()) ans = "" i = 1 for c in s: if i % 2 == 1: ans += c i += 1 print(ans)
print((input()[0::2]))
false
77.777778
[ "-s = eval(input())", "-ans = \"\"", "-i = 1", "-for c in s:", "- if i % 2 == 1:", "- ans += c", "- i += 1", "-print(ans)", "+print((input()[0::2]))" ]
false
0.038033
0.044093
0.86256
[ "s831771023", "s270364120" ]
u345966487
p03659
python
s672252159
s595323665
163
144
39,188
31,776
Accepted
Accepted
11.66
import sys from itertools import accumulate sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys...
import sys import itertools sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inl = lambda: [int(x) for x in sys.stdin.readline().split()] ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) N = ini() A = i...
26
25
607
555
import sys from itertools import accumulate sys.setrecursionlimit(10**8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, *...
import sys import itertools sys.setrecursionlimit(10**8) ini = lambda: int(sys.stdin.readline()) inl = lambda: [int(x) for x in sys.stdin.readline().split()] ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) N = ini() A = inl() def so...
false
3.846154
[ "-from itertools import accumulate", "+import itertools", "-inm = lambda: map(int, sys.stdin.readline().split())", "-inl = lambda: list(inm())", "+inl = lambda: [int(x) for x in sys.stdin.readline().split()]", "-n = ini()", "-a = inl()", "+N = ini()", "+A = inl()", "- al = list(accumulate(a))",...
false
0.107112
0.047238
2.267512
[ "s672252159", "s595323665" ]
u729133443
p02889
python
s332252714
s206249493
404
350
40,760
40,864
Accepted
Accepted
13.37
from scipy.sparse import* def main(): f=csgraph.floyd_warshall n,m,l,*t=list(map(int,open(0).read().split())) d=[[0]*(n+1)for _ in range(n+1)] for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c d=f(f(d,0)<=l)-1 d[d>n]=-1 print(('\n'.join(map(str,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)])))) main()
from scipy.sparse import* def main(): f=csgraph.floyd_warshall n,m,l,*t=list(map(int,open(0).read().split())) d=[[0]*(n+1)for _ in range(n+1)] for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c d=f(f(d,0)<=l)-1 d[d>n]=-1 print(('\n'.join(map(str,list(map(int,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)])))...
10
10
308
317
from scipy.sparse import * def main(): f = csgraph.floyd_warshall n, m, l, *t = list(map(int, open(0).read().split())) d = [[0] * (n + 1) for _ in range(n + 1)] for a, b, c in zip(*[iter(t[: m * 3])] * 3): d[a][b] = c d = f(f(d, 0) <= l) - 1 d[d > n] = -1 print(("\n".join(map(str, ...
from scipy.sparse import * def main(): f = csgraph.floyd_warshall n, m, l, *t = list(map(int, open(0).read().split())) d = [[0] * (n + 1) for _ in range(n + 1)] for a, b, c in zip(*[iter(t[: m * 3])] * 3): d[a][b] = c d = f(f(d, 0) <= l) - 1 d[d > n] = -1 print( ( ...
false
0
[ "- print((\"\\n\".join(map(str, [d[i] for i in zip(*[iter(t[m * 3 + 1 :])] * 2)]))))", "+ print(", "+ (", "+ \"\\n\".join(", "+ map(", "+ str,", "+ list(map(int, [d[i] for i in zip(*[iter(t[m * 3 + 1 :])] * 2)])),", "+ ...
false
0.500513
0.81855
0.611463
[ "s332252714", "s206249493" ]
u204842730
p02881
python
s869383380
s781734395
192
151
40,428
3,064
Accepted
Accepted
21.35
import math n = int(eval(input())) b = 0 list = [] sqrt = math.ceil(math.sqrt(n)) for i in range(1,sqrt+1): if(n%i==0): b = i print((b + (n//b) -2))
N = int(eval(input())) ans=1e+18 for i in range(1,int(N**0.5+1)): if(N%i==0): ans = min(ans,int(i+N/i-2)) print(ans)
10
6
153
127
import math n = int(eval(input())) b = 0 list = [] sqrt = math.ceil(math.sqrt(n)) for i in range(1, sqrt + 1): if n % i == 0: b = i print((b + (n // b) - 2))
N = int(eval(input())) ans = 1e18 for i in range(1, int(N**0.5 + 1)): if N % i == 0: ans = min(ans, int(i + N / i - 2)) print(ans)
false
40
[ "-import math", "-", "-n = int(eval(input()))", "-b = 0", "-list = []", "-sqrt = math.ceil(math.sqrt(n))", "-for i in range(1, sqrt + 1):", "- if n % i == 0:", "- b = i", "-print((b + (n // b) - 2))", "+N = int(eval(input()))", "+ans = 1e18", "+for i in range(1, int(N**0.5 + 1)):",...
false
0.036377
0.060176
0.604512
[ "s869383380", "s781734395" ]
u633068244
p00162
python
s091151110
s122582874
2,220
10
35,924
4,244
Accepted
Accepted
99.55
while True: inp = input() if inp == "0": break m,n = list(map(int, inp.split())) ans = 0 for i in range(m,n+1): while i > 1: if i%2 == 0: i /= 2 elif i%3 == 0: i /= 3 elif i%5 == 0: i /= 5 else: break else: ans += 1 print(ans)
def ham2(a): global m,n,count if m <= a: count += 1 a2,a3,a5 = a*2, a*3, a*5 if a2 <= n: ham2(a2) if a3 <= n: ham3(a3) if a5 <= n: ham5(a5) def ham3(a): global m,n,count if m <= a: count += 1 a3,a5 = a*3, a*5 if a3 <= n: ham3(a3) if a5 <= n: ham5(a5) def ham5(a): global m,n,count ...
18
31
281
502
while True: inp = input() if inp == "0": break m, n = list(map(int, inp.split())) ans = 0 for i in range(m, n + 1): while i > 1: if i % 2 == 0: i /= 2 elif i % 3 == 0: i /= 3 elif i % 5 == 0: i /= 5 ...
def ham2(a): global m, n, count if m <= a: count += 1 a2, a3, a5 = a * 2, a * 3, a * 5 if a2 <= n: ham2(a2) if a3 <= n: ham3(a3) if a5 <= n: ham5(a5) def ham3(a): global m, n, count if m <= a: count += 1 a3, a5 = a * 3, a * 5 if a3 <= n: ...
false
41.935484
[ "+def ham2(a):", "+ global m, n, count", "+ if m <= a:", "+ count += 1", "+ a2, a3, a5 = a * 2, a * 3, a * 5", "+ if a2 <= n:", "+ ham2(a2)", "+ if a3 <= n:", "+ ham3(a3)", "+ if a5 <= n:", "+ ham5(a5)", "+", "+", "+def ham3(a):", "+ globa...
false
0.044649
0.046169
0.967076
[ "s091151110", "s122582874" ]
u802234211
p02657
python
s225592060
s300891636
23
20
9,152
9,156
Accepted
Accepted
13.04
a,b = list(map(int,input().split())) print((a*b))
import math a,b = list(map(str,input().split())) a = int(a) print((math.floor(a*int(float(b)*100+0.1)/100)))
2
5
42
105
a, b = list(map(int, input().split())) print((a * b))
import math a, b = list(map(str, input().split())) a = int(a) print((math.floor(a * int(float(b) * 100 + 0.1) / 100)))
false
60
[ "-a, b = list(map(int, input().split()))", "-print((a * b))", "+import math", "+", "+a, b = list(map(str, input().split()))", "+a = int(a)", "+print((math.floor(a * int(float(b) * 100 + 0.1) / 100)))" ]
false
0.038904
0.043588
0.892528
[ "s225592060", "s300891636" ]
u367130284
p03044
python
s764555580
s456475283
954
876
8,924
10,252
Accepted
Accepted
8.18
class UNION_FIND(object): def __init__(self,n): self.parent=[-1 for i in range(n)] def root(self,x): if self.parent[x]<0: return x else: self.parent[x]=self.root(self.parent[x]) return self.parent[x] def size(self,x): ...
class POTENTIAL_UNION_FIND(object): def __init__(self, n): self.parent = [-1 for i in range(n)]#非負なら親ノード,負ならグループの要素数 self.diff_p = [0 for i in range(n)]#親ノードを基準としたポテンシャル def root(self, x): #root(x): xの根ノードを返す if self.parent[x] < 0: return x else: ...
40
47
986
1,664
class UNION_FIND(object): def __init__(self, n): self.parent = [-1 for i in range(n)] def root(self, x): if self.parent[x] < 0: return x else: self.parent[x] = self.root(self.parent[x]) return self.parent[x] def size(self, x): return -sel...
class POTENTIAL_UNION_FIND(object): def __init__(self, n): self.parent = [-1 for i in range(n)] # 非負なら親ノード,負ならグループの要素数 self.diff_p = [0 for i in range(n)] # 親ノードを基準としたポテンシャル def root(self, x): # root(x): xの根ノードを返す if self.parent[x] < 0: return x else: ...
false
14.893617
[ "-class UNION_FIND(object):", "+class POTENTIAL_UNION_FIND(object):", "- self.parent = [-1 for i in range(n)]", "+ self.parent = [-1 for i in range(n)] # 非負なら親ノード,負ならグループの要素数", "+ self.diff_p = [0 for i in range(n)] # 親ノードを基準としたポテンシャル", "- def root(self, x):", "+ def root(se...
false
0.034049
0.037961
0.89694
[ "s764555580", "s456475283" ]
u395117343
p02831
python
s489948698
s539353203
290
150
17,796
12,484
Accepted
Accepted
48.28
# coding:utf-8 import sys import math import time import numpy as np import collections def gcd(m,n): x = max(m,n) y = min(m,n) if x%y == 0: return y else: while x%y != 0: z = x%y x = y y = z else: return z #X = str(raw_input()).split() AB = str(input...
# coding:utf-8 import sys import math import time import numpy as np import collections from collections import deque import queue import copy # 最大公約数 def gcd(m,n): x = max(m,n) y = min(m,n) if x%y == 0: return y else: while x%y != 0: z = x%y x = y y = z els...
29
63
409
1,315
# coding:utf-8 import sys import math import time import numpy as np import collections def gcd(m, n): x = max(m, n) y = min(m, n) if x % y == 0: return y else: while x % y != 0: z = x % y x = y y = z else: return z # X = str(ra...
# coding:utf-8 import sys import math import time import numpy as np import collections from collections import deque import queue import copy # 最大公約数 def gcd(m, n): x = max(m, n) y = min(m, n) if x % y == 0: return y else: while x % y != 0: z = x % y x = y ...
false
53.968254
[ "+from collections import deque", "+import queue", "+import copy", "-", "+# 最大公約数", "-# X = str(raw_input()).split()", "-AB = str(input()).split()", "+# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す", "+def bfs(SS, x, y, H, W): # 入力(座標系(迷路), x, y, xの端, yの端)", "+ x_next = [0, 0, -1, 1]", "+ y_next = [1...
false
0.045553
0.047089
0.967379
[ "s489948698", "s539353203" ]
u825460912
p03434
python
s017289149
s528674138
20
17
3,060
3,060
Accepted
Accepted
15
N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse = True) alice = bob = 0 for i in range(N): if i%2 == 0: alice += A.pop(0) else: bob += A.pop(0) print((alice - bob))
N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse = True) alice = bob = 0 for i in range(N): if i%2 == 0: alice += A[i] else: bob += A[i] print((alice - bob))
11
11
221
213
N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) alice = bob = 0 for i in range(N): if i % 2 == 0: alice += A.pop(0) else: bob += A.pop(0) print((alice - bob))
N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) alice = bob = 0 for i in range(N): if i % 2 == 0: alice += A[i] else: bob += A[i] print((alice - bob))
false
0
[ "- alice += A.pop(0)", "+ alice += A[i]", "- bob += A.pop(0)", "+ bob += A[i]" ]
false
0.077166
0.052003
1.483875
[ "s017289149", "s528674138" ]
u325282913
p03549
python
s136532499
s370732127
19
17
2,940
2,940
Accepted
Accepted
10.53
N, M = list(map(int, input().split())) t = 1900*M + 100*(N-M) p = 1/((1/2)**M) print((int(t*p)))
N, M = list(map(int,input().split())) print(((M * 1900 + (N-M) * 100)*(2 ** M)))
4
2
91
73
N, M = list(map(int, input().split())) t = 1900 * M + 100 * (N - M) p = 1 / ((1 / 2) ** M) print((int(t * p)))
N, M = list(map(int, input().split())) print(((M * 1900 + (N - M) * 100) * (2**M)))
false
50
[ "-t = 1900 * M + 100 * (N - M)", "-p = 1 / ((1 / 2) ** M)", "-print((int(t * p)))", "+print(((M * 1900 + (N - M) * 100) * (2**M)))" ]
false
0.049835
0.049696
1.002798
[ "s136532499", "s370732127" ]
u900139929
p03478
python
s389933214
s602908735
34
29
2,940
2,940
Accepted
Accepted
14.71
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) n, a, b = list(map(int, input().split())) ans = 0 for i in range(n+1): s = str(i) sum = 0 for j in s: sum += int(j) if a <= sum <= b: ans += i print(ans)
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) n, a, b = list(map(int, input().split())) ans = 0 # for i in range(1, n+1): # s = str(i) # sum = 0 # for j in s: # sum += int(j) # if a <= sum <= b: # ans += i for i in range(1, n+1): sum = 0 num...
17
26
263
489
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) n, a, b = list(map(int, input().split())) ans = 0 for i in range(n + 1): s = str(i) sum = 0 for j in s: sum += int(j) if a <= sum <= b: ans += i print(ans)
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) n, a, b = list(map(int, input().split())) ans = 0 # for i in range(1, n+1): # s = str(i) # sum = 0 # for j in s: # sum += int(j) # if a <= sum <= b: # ans += i for i in range(1, n + 1): sum = 0 num = i while num ...
false
34.615385
[ "-for i in range(n + 1):", "- s = str(i)", "+# for i in range(1, n+1):", "+# s = str(i)", "+# sum = 0", "+# for j in s:", "+# sum += int(j)", "+# if a <= sum <= b:", "+# ans += i", "+for i in range(1, n + 1):", "- for j in s:", "- sum += int(j)", ...
false
0.036081
0.036844
0.979268
[ "s389933214", "s602908735" ]
u634208461
p03309
python
s722775299
s153307875
304
215
26,180
26,180
Accepted
Accepted
29.28
N = int(eval(input())) A = list(map(int, input().split())) B = [A[i] - 1 - i for i in range(N)] B.sort() if N % 2 == 0: med = [B[int(N / 2) - 1], int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2), B[int(N / 2)]] else: med = [B[int((N + 1) / 2) - 1]] ans = 10 ** 100 for b in med: S = 0 for i in ran...
N = int(eval(input())) A = list(map(int, input().split())) B = [A[i] - 1 - i for i in range(N)] B.sort() if N % 2 == 0: med = int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2) else: med = B[int((N + 1) / 2) - 1] S = 0 for i in range(N): S += abs(B[i] - med) print(S)
15
12
384
279
N = int(eval(input())) A = list(map(int, input().split())) B = [A[i] - 1 - i for i in range(N)] B.sort() if N % 2 == 0: med = [ B[int(N / 2) - 1], int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2), B[int(N / 2)], ] else: med = [B[int((N + 1) / 2) - 1]] ans = 10**100 for b in med: S = ...
N = int(eval(input())) A = list(map(int, input().split())) B = [A[i] - 1 - i for i in range(N)] B.sort() if N % 2 == 0: med = int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2) else: med = B[int((N + 1) / 2) - 1] S = 0 for i in range(N): S += abs(B[i] - med) print(S)
false
20
[ "- med = [", "- B[int(N / 2) - 1],", "- int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2),", "- B[int(N / 2)],", "- ]", "+ med = int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2)", "- med = [B[int((N + 1) / 2) - 1]]", "-ans = 10**100", "-for b in med:", "- S = 0", "- ...
false
0.093204
0.042266
2.205166
[ "s722775299", "s153307875" ]
u200887663
p03137
python
s660014161
s407627908
120
93
13,964
20,476
Accepted
Accepted
22.5
#x=int(input()) n,m=list(map(int,input().split())) xl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] ans=0 if n>=m: pass else: cum=[] xl.sort() ans=xl[m-1]-xl[0] for i in range(m-1): cum.append(xl[i+1]-xl[i]) cum.sort(reverse=True) ...
#n = int(input()) n, m = list(map(int, input().split())) xl = list(map(int, input().split())) #al=[list(input()) for i in range(n)] xl.sort() difl = [] for i in range(1, m): difl.append(xl[i]-xl[i-1]) difl.sort(reverse=True) if n >= m: ans = 0 else: ans = xl[-1]-xl[0]-sum(difl[:n-1]) prin...
18
17
369
320
# x=int(input()) n, m = list(map(int, input().split())) xl = list(map(int, input().split())) # l=[list(map(int,input().split())) for i in range(n)] ans = 0 if n >= m: pass else: cum = [] xl.sort() ans = xl[m - 1] - xl[0] for i in range(m - 1): cum.append(xl[i + 1] - xl[i]) cum.sort(rever...
# n = int(input()) n, m = list(map(int, input().split())) xl = list(map(int, input().split())) # al=[list(input()) for i in range(n)] xl.sort() difl = [] for i in range(1, m): difl.append(xl[i] - xl[i - 1]) difl.sort(reverse=True) if n >= m: ans = 0 else: ans = xl[-1] - xl[0] - sum(difl[: n - 1]) print(ans)...
false
5.555556
[ "-# x=int(input())", "+# n = int(input())", "-# l=[list(map(int,input().split())) for i in range(n)]", "-ans = 0", "+# al=[list(input()) for i in range(n)]", "+xl.sort()", "+difl = []", "+for i in range(1, m):", "+ difl.append(xl[i] - xl[i - 1])", "+difl.sort(reverse=True)", "- pass", "+...
false
0.045276
0.046035
0.983513
[ "s660014161", "s407627908" ]
u403331159
p02732
python
s658195726
s963799026
525
467
30,916
26,780
Accepted
Accepted
11.05
from collections import Counter def Comb(n,k): comb_ans=1 for i in range(1,k+1): comb_ans*=(n-i+1)/i comb_ans=int(comb_ans) return comb_ans N=int(eval(input())) A=list(map(int,input().split())) C=Counter() C.update(A) ans=0 L=[0]*N for i in range(N): L[A[i]-1]+=1 Most=C.mo...
from collections import Counter def Comb(n,k): comb_ans=1 for i in range(1,k+1): comb_ans*=(n-i+1)/i comb_ans=int(comb_ans) return comb_ans N=int(eval(input())) A=list(map(int,input().split())) C=Counter(A) ans=0 for i in list(C.values()): ans+=Comb(i,2) for i in A: pri...
25
17
467
322
from collections import Counter def Comb(n, k): comb_ans = 1 for i in range(1, k + 1): comb_ans *= (n - i + 1) / i comb_ans = int(comb_ans) return comb_ans N = int(eval(input())) A = list(map(int, input().split())) C = Counter() C.update(A) ans = 0 L = [0] * N for i in range(N): L[A[i] -...
from collections import Counter def Comb(n, k): comb_ans = 1 for i in range(1, k + 1): comb_ans *= (n - i + 1) / i comb_ans = int(comb_ans) return comb_ans N = int(eval(input())) A = list(map(int, input().split())) C = Counter(A) ans = 0 for i in list(C.values()): ans += Comb(i, 2) for i...
false
32
[ "-C = Counter()", "-C.update(A)", "+C = Counter(A)", "-L = [0] * N", "-for i in range(N):", "- L[A[i] - 1] += 1", "-Most = C.most_common()", "-# print(Most)", "-for i in range(len(C)):", "- ans += Comb(Most[i][1], 2)", "-for i in range(N):", "- pri = ans", "- pri = ans - L[A[i] -...
false
0.047327
0.046079
1.027078
[ "s658195726", "s963799026" ]
u875291233
p03566
python
s142255737
s341123009
39
18
5,368
3,064
Accepted
Accepted
53.85
import sys, collections, bisect, math, itertools from fractions import gcd input = sys.stdin.readline #文字列入力のときは注意 n = int(eval(input())) t = [int(i) for i in input().split()] v = [int(i) for i in input().split()] maxspeed = [0]*(n+1) for i in range(n-1,0,-1): maxspeed[i] = min(v[i], v[i-1], t[i] + m...
n = int(eval(input())) t = [int(i) for i in input().split()] v = [int(i) for i in input().split()] maxspeed = [0]*(n+1) for i in range(n-1,0,-1): maxspeed[i] = min(v[i], v[i-1], t[i] + maxspeed[i+1]) def dist(i,first): # distance,lastspeed ta = v[i] - first tb = v[i] - maxspeed[i+1] if ta +...
55
31
1,122
861
import sys, collections, bisect, math, itertools from fractions import gcd input = sys.stdin.readline # 文字列入力のときは注意 n = int(eval(input())) t = [int(i) for i in input().split()] v = [int(i) for i in input().split()] maxspeed = [0] * (n + 1) for i in range(n - 1, 0, -1): maxspeed[i] = min(v[i], v[i - 1], t[i] + max...
n = int(eval(input())) t = [int(i) for i in input().split()] v = [int(i) for i in input().split()] maxspeed = [0] * (n + 1) for i in range(n - 1, 0, -1): maxspeed[i] = min(v[i], v[i - 1], t[i] + maxspeed[i + 1]) def dist(i, first): # distance,lastspeed ta = v[i] - first tb = v[i] - maxspeed[i + 1] if...
false
43.636364
[ "-import sys, collections, bisect, math, itertools", "-from fractions import gcd", "-", "-input = sys.stdin.readline # 文字列入力のときは注意", "-# print(t)", "-# print(v)", "-# print(maxspeed)", "-def dist(first, i): # distance,lastspeed", "- ti = t[i]", "- vi = v[i]", "- mi1 = maxspeed[i + 1]"...
false
0.139663
0.072858
1.91692
[ "s142255737", "s341123009" ]
u312025627
p03324
python
s933115293
s458431335
162
17
38,256
2,940
Accepted
Accepted
89.51
def main(): D, N = (int(i) for i in input().split()) if N == 100: N += 1 print((N * 100**D)) if __name__ == '__main__': main()
def main(): D, N = (int(i) for i in input().split()) if N == 100: N += 1 print((N*(100**D))) if __name__ == '__main__': main()
9
9
159
159
def main(): D, N = (int(i) for i in input().split()) if N == 100: N += 1 print((N * 100**D)) if __name__ == "__main__": main()
def main(): D, N = (int(i) for i in input().split()) if N == 100: N += 1 print((N * (100**D))) if __name__ == "__main__": main()
false
0
[ "- print((N * 100**D))", "+ print((N * (100**D)))" ]
false
0.035801
0.036723
0.974882
[ "s933115293", "s458431335" ]
u224353074
p03164
python
s509295435
s614834520
708
397
124,932
120,812
Accepted
Accepted
43.93
N, W = list(map(int, input().split())) WV = [list(map(int, input().split())) for i in range(N)] INF = 10**9+1000 SUM_V = sum([A[1] for A in WV]) dp = [[INF]*(SUM_V+1) for i in range(N+1)] dp[0][0] = 0 for i in range(N+1): dp[i][0] = 0 for n in range(0, N): for v in range(0, SUM_V+1): if v ...
import bisect N, W = list(map(int, input().split())) w = [0] * (N + 1) v = [0] * (N + 1) for i in range(1, N + 1): w[i], v[i] = list(map(int, input().split())) INF = 1000000010 MAX_V = 100010 dp = [[INF] * MAX_V for _ in range(N + 1)] dp[0][0] = 0 for i in range(1, N + 1): for value in range(MA...
23
21
635
529
N, W = list(map(int, input().split())) WV = [list(map(int, input().split())) for i in range(N)] INF = 10**9 + 1000 SUM_V = sum([A[1] for A in WV]) dp = [[INF] * (SUM_V + 1) for i in range(N + 1)] dp[0][0] = 0 for i in range(N + 1): dp[i][0] = 0 for n in range(0, N): for v in range(0, SUM_V + 1): if v >=...
import bisect N, W = list(map(int, input().split())) w = [0] * (N + 1) v = [0] * (N + 1) for i in range(1, N + 1): w[i], v[i] = list(map(int, input().split())) INF = 1000000010 MAX_V = 100010 dp = [[INF] * MAX_V for _ in range(N + 1)] dp[0][0] = 0 for i in range(1, N + 1): for value in range(MAX_V): if...
false
8.695652
[ "+import bisect", "+", "-WV = [list(map(int, input().split())) for i in range(N)]", "-INF = 10**9 + 1000", "-SUM_V = sum([A[1] for A in WV])", "-dp = [[INF] * (SUM_V + 1) for i in range(N + 1)]", "+w = [0] * (N + 1)", "+v = [0] * (N + 1)", "+for i in range(1, N + 1):", "+ w[i], v[i] = list(map(...
false
0.048406
0.540099
0.089625
[ "s509295435", "s614834520" ]
u714642969
p02586
python
s983790585
s885522322
2,146
1,597
209,028
145,904
Accepted
Accepted
25.58
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 R,C,K=map(int,input().split()) V=[[0...
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 R,C,K=map(int,input().split()) V=[[0...
32
33
902
944
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF = 10**18 MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() YesNo = lambda b: bool([print("Yes")] if b else print("No")) YESNO = lambda b: bool([print("YES")] if b else print("NO")) int1 = lambda x: int(x) - 1 R, C, K = map(int, input().spl...
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF = 10**18 MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() YesNo = lambda b: bool([print("Yes")] if b else print("No")) YESNO = lambda b: bool([print("YES")] if b else print("NO")) int1 = lambda x: int(x) - 1 R, C, K = map(int, input().spl...
false
3.030303
[ "-dp = [[0] * 4 for _ in range(C)]", "-prev_dp = [[0] * 4 for _ in range(C)]", "+dp = [[0] * C for _ in range(4)]", "- dp[x][i + 1] = max(dp[x][i + 1], dp[x][i] + V[y][x])", "+ dp[i + 1][x] = max(dp[i + 1][x], dp[i][x] + V[y][x])", "- dp[x + 1][i] = max(dp[x + 1][i], d...
false
0.044609
0.065151
0.684709
[ "s983790585", "s885522322" ]
u279718559
p03457
python
s856515830
s259454533
403
321
3,060
3,060
Accepted
Accepted
20.35
# https://atcoder.jp/contests/abc086/tasks/arc089_a t0 = 0 x0 = 0 y0 = 0 n = int(eval(input())) result = "Yes" for i in range(n): t1, x1, y1 = list(map(int, input().split())) dt = t1 - t0 dx = x1 - x0 dy = y1 - y0 if ((dx + dy)%2 == dt % 2) and (dx + dy) <= dt: t0 = t1 ...
n = int(eval(input())) for i in range(n): t,x,y=list(map(int,input().split())) if (x + y) > t or (x + y + t) % 2: print("No") exit() print("Yes")
20
7
391
163
# https://atcoder.jp/contests/abc086/tasks/arc089_a t0 = 0 x0 = 0 y0 = 0 n = int(eval(input())) result = "Yes" for i in range(n): t1, x1, y1 = list(map(int, input().split())) dt = t1 - t0 dx = x1 - x0 dy = y1 - y0 if ((dx + dy) % 2 == dt % 2) and (dx + dy) <= dt: t0 = t1 x0 = x1 ...
n = int(eval(input())) for i in range(n): t, x, y = list(map(int, input().split())) if (x + y) > t or (x + y + t) % 2: print("No") exit() print("Yes")
false
65
[ "-# https://atcoder.jp/contests/abc086/tasks/arc089_a", "-t0 = 0", "-x0 = 0", "-y0 = 0", "-result = \"Yes\"", "- t1, x1, y1 = list(map(int, input().split()))", "- dt = t1 - t0", "- dx = x1 - x0", "- dy = y1 - y0", "- if ((dx + dy) % 2 == dt % 2) and (dx + dy) <= dt:", "- t0...
false
0.038896
0.08208
0.47388
[ "s856515830", "s259454533" ]
u969850098
p03804
python
s232693153
s512793934
21
19
4,468
3,064
Accepted
Accepted
9.52
N, M = list(map(int, input().split())) A_list = [eval(input()) for i in range(N)] B_list = [eval(input()) for i in range(M)] all_segment = [] for width in range(N - M + 1): for height in range(N - M + 1): segment = [width_list[width: width + M] for width_list in A_list[height: height + M]] ...
import sys readline = sys.stdin.readline def main(): N, M = list(map(int, readline().rstrip().split())) A = [readline().rstrip() for _ in range(N)] B = [readline().rstrip() for _ in range(M)] if A == B: print('Yes') return for h in range(N-M): for w in range(N-M):...
14
21
401
499
N, M = list(map(int, input().split())) A_list = [eval(input()) for i in range(N)] B_list = [eval(input()) for i in range(M)] all_segment = [] for width in range(N - M + 1): for height in range(N - M + 1): segment = [ width_list[width : width + M] for width_list in A_list[height : height + M] ...
import sys readline = sys.stdin.readline def main(): N, M = list(map(int, readline().rstrip().split())) A = [readline().rstrip() for _ in range(N)] B = [readline().rstrip() for _ in range(M)] if A == B: print("Yes") return for h in range(N - M): for w in range(N - M): ...
false
33.333333
[ "-N, M = list(map(int, input().split()))", "-A_list = [eval(input()) for i in range(N)]", "-B_list = [eval(input()) for i in range(M)]", "-all_segment = []", "-for width in range(N - M + 1):", "- for height in range(N - M + 1):", "- segment = [", "- width_list[width : width + M] f...
false
0.04297
0.041398
1.03797
[ "s232693153", "s512793934" ]