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
u373047809
p03252
python
s455351710
s400357765
42
34
3,888
3,504
Accepted
Accepted
19.05
from collections import* c = Counter f = lambda: c(list(c(eval(input())).values())) print(("YNeos"[f()!=f()::2]))
def f(): i = eval(input()) return sorted(i.count(j) for j in set(i)) print(("YNeos"[f()!=f()::2]))
4
4
102
97
from collections import * c = Counter f = lambda: c(list(c(eval(input())).values())) print(("YNeos"[f() != f() :: 2]))
def f(): i = eval(input()) return sorted(i.count(j) for j in set(i)) print(("YNeos"[f() != f() :: 2]))
false
0
[ "-from collections import *", "+def f():", "+ i = eval(input())", "+ return sorted(i.count(j) for j in set(i))", "-c = Counter", "-f = lambda: c(list(c(eval(input())).values()))", "+" ]
false
0.05216
0.046264
1.127446
[ "s455351710", "s400357765" ]
u594862874
p02711
python
s778311138
s092536003
22
19
9,112
9,076
Accepted
Accepted
13.64
N = eval(input()) print(('Yes' if '7' in str(N) else 'No'))
N = eval(input()) if len(str(N)) == 3: print(('Yes' if '7' in str(N) else 'No'))
3
4
54
80
N = eval(input()) print(("Yes" if "7" in str(N) else "No"))
N = eval(input()) if len(str(N)) == 3: print(("Yes" if "7" in str(N) else "No"))
false
25
[ "-print((\"Yes\" if \"7\" in str(N) else \"No\"))", "+if len(str(N)) == 3:", "+ print((\"Yes\" if \"7\" in str(N) else \"No\"))" ]
false
0.08119
0.041727
1.945733
[ "s778311138", "s092536003" ]
u729133443
p02845
python
s171224249
s621041700
286
100
60,068
19,368
Accepted
Accepted
65.03
n,*a=list(map(int,open(0).read().split())) c=1 d=[0]*3 for b in a: c=c*sum(t==b for t in d)%(10**9+7) for i,t in enumerate(d): if t==b: d[i]+=1 break print(c)
_,a=open(0) c=1 d=[3]+[0]*10**6 for a in map(int,a.split()): c=c*d[a]%(10**9+7) d[a]-=1 d[a+1]+=1 print(c)
10
8
181
119
n, *a = list(map(int, open(0).read().split())) c = 1 d = [0] * 3 for b in a: c = c * sum(t == b for t in d) % (10**9 + 7) for i, t in enumerate(d): if t == b: d[i] += 1 break print(c)
_, a = open(0) c = 1 d = [3] + [0] * 10**6 for a in map(int, a.split()): c = c * d[a] % (10**9 + 7) d[a] -= 1 d[a + 1] += 1 print(c)
false
20
[ "-n, *a = list(map(int, open(0).read().split()))", "+_, a = open(0)", "-d = [0] * 3", "-for b in a:", "- c = c * sum(t == b for t in d) % (10**9 + 7)", "- for i, t in enumerate(d):", "- if t == b:", "- d[i] += 1", "- break", "+d = [3] + [0] * 10**6", "+for a in...
false
0.035581
0.104717
0.339786
[ "s171224249", "s621041700" ]
u251515715
p03160
python
s201815988
s430194070
323
127
22,700
13,980
Accepted
Accepted
60.68
import numpy as np n = int(eval(input())) h = list(map(int,input().split())) dp=[np.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[-1]))
n=int(eval(input())) h=list(map(int,input().split())) if n==2: print((abs(h[1]-h[0]))) else: dp=[0]*(n-1) dp[0]=abs(h[1]-h[0]) dp[1]=min(dp[0]+abs(h[2]-h[1]),abs(h[2]-h[0])) for i in range(2,n-1): dp[i]=min(dp[i-1]+abs(h[i+1]-h[i]),dp[i-2]+abs(h[i+1]-h[i-1])) ...
10
13
242
333
import numpy as np n = int(eval(input())) h = list(map(int, input().split())) dp = [np.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[-1]))
n = int(eval(input())) h = list(map(int, input().split())) if n == 2: print((abs(h[1] - h[0]))) else: dp = [0] * (n - 1) dp[0] = abs(h[1] - h[0]) dp[1] = min(dp[0] + abs(h[2] - h[1]), abs(h[2] - h[0])) for i in range(2, n - 1): dp[i] = min( dp[i - 1] + abs(h[i + 1] - h[i]), dp[i ...
false
23.076923
[ "-import numpy as np", "-", "-dp = [np.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[-1]))", "+if n == 2:", "+ print((abs(h[1] - h[0...
false
0.177169
0.035661
4.968204
[ "s201815988", "s430194070" ]
u835283937
p03774
python
s099864719
s625364094
188
20
39,792
3,064
Accepted
Accepted
89.36
def main(): N, M = list(map(int, input().split())) students = [input().split() for _ in range(N)] checkpoints = [input().split() for _ in range(M) ] nearest = [None]*N for i, s in enumerate(students) : min_d = 10**9 index = 0 for j, p in enumerate(checkpoints, 1) ...
def main(): N, M = list(map(int, input().split())) students = [input().split() for _ in range(N)] checkpoints = [input().split() for _ in range(M) ] nearest = [None]*N for i, s in enumerate(students) : min_d = 10**9 for j, p in enumerate(checkpoints, 1) : a, b...
24
21
598
553
def main(): N, M = list(map(int, input().split())) students = [input().split() for _ in range(N)] checkpoints = [input().split() for _ in range(M)] nearest = [None] * N for i, s in enumerate(students): min_d = 10**9 index = 0 for j, p in enumerate(checkpoints, 1): ...
def main(): N, M = list(map(int, input().split())) students = [input().split() for _ in range(N)] checkpoints = [input().split() for _ in range(M)] nearest = [None] * N for i, s in enumerate(students): min_d = 10**9 for j, p in enumerate(checkpoints, 1): a, b = list(map(i...
false
12.5
[ "- index = 0", "- index = j", "- nearest[i] = index", "+ nearest[i] = j" ]
false
0.088837
0.038049
2.334794
[ "s099864719", "s625364094" ]
u077291787
p03472
python
s198491194
s288837754
230
109
25,176
25,124
Accepted
Accepted
52.61
# ABC085D - Katana Thrower import sys input = sys.stdin.readline def main(): N, H = tuple(map(int, input().split())) AB = tuple(tuple(map(int, input().split())) for _ in range(N)) A, B = list(zip(*AB)) x = max(A) B = sorted([i for i in B if i > x], reverse=1) ans = 0 for i in B: ...
# ABC085D - Katana Thrower def main(): N, H, *AB = list(map(int, open(0).read().split())) A = AB[::2] x = max(A) B = sorted([i for i in AB[1::2] if i > x], reverse=1) ans = 0 for i in B: ans += 1 H -= i if H <= 0: break else: ans += (H...
23
19
490
388
# ABC085D - Katana Thrower import sys input = sys.stdin.readline def main(): N, H = tuple(map(int, input().split())) AB = tuple(tuple(map(int, input().split())) for _ in range(N)) A, B = list(zip(*AB)) x = max(A) B = sorted([i for i in B if i > x], reverse=1) ans = 0 for i in B: a...
# ABC085D - Katana Thrower def main(): N, H, *AB = list(map(int, open(0).read().split())) A = AB[::2] x = max(A) B = sorted([i for i in AB[1::2] if i > x], reverse=1) ans = 0 for i in B: ans += 1 H -= i if H <= 0: break else: ans += (H + x - 1) // ...
false
17.391304
[ "-import sys", "-", "-input = sys.stdin.readline", "-", "-", "- N, H = tuple(map(int, input().split()))", "- AB = tuple(tuple(map(int, input().split())) for _ in range(N))", "- A, B = list(zip(*AB))", "+ N, H, *AB = list(map(int, open(0).read().split()))", "+ A = AB[::2]", "- B...
false
0.040732
0.046624
0.873613
[ "s198491194", "s288837754" ]
u102461423
p03653
python
s315859455
s362043633
554
488
127,464
110,540
Accepted
Accepted
11.91
import sys import numpy as np import heapq as hp from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit('i8[:],i8[:],i8', cache=True) def compute(A, B, X): """左からn番の人まで。AからX人とる。ときの最大スコアを返す。""" result = np.zeros(len(A), ...
import sys import numpy as np import heapq as hp from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def compute(A, B, X): """左からn番の人まで。AからX人とる。ときの最大スコアを返す。""" result = np.zeros(len(A), np.int64) result[X - 1] = A[:X]....
43
57
1,123
1,464
import sys import numpy as np import heapq as hp from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit("i8[:],i8[:],i8", cache=True) def compute(A, B, X): """左からn番の人まで。AからX人とる。ときの最大スコアを返す。""" result = np.zeros(len(A), np.int64) ...
import sys import numpy as np import heapq as hp from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def compute(A, B, X): """左からn番の人まで。AからX人とる。ときの最大スコアを返す。""" result = np.zeros(len(A), np.int64) result[X - 1] = A[:X].sum() q...
false
24.561404
[ "-@njit(\"i8[:],i8[:],i8\", cache=True)", "-@njit(\"(i8[:],i8,i8,i8)\", cache=True)", "+if sys.argv[-1] == \"ONLINE_JUDGE\":", "+ import numba", "+ from numba.pycc import CC", "+", "+ i8 = numba.from_dtype(np.int64)", "+ u1 = numba.from_dtype(np.dtype(\"U1\"))", "+ sig1 = (i8[:], i8[:...
false
0.257926
0.272199
0.947565
[ "s315859455", "s362043633" ]
u671861352
p02972
python
s557103313
s869355125
418
356
8,784
13,108
Accepted
Accepted
14.83
N = int(input()) A = list(map(int, input().split())) b = [0] * (N + 1) half = N // 2 b[half + 1:] = A[half:] for i in range(half, 1, -1): s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2 if s != A[i - 1]: b[i] = 1 s = sum(b) if s % 2 != A[0]: b[1] = 1 s += 1 print(s) for i, b_...
N = int(eval(input())) A = list(map(int, input().split())) b = [0] * (N + 1) half = N // 2 b[half + 1:] = A[half:] for i in range(half, 1, -1): s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2 if s != A[i - 1]: b[i] = 1 s = sum(b) if s % 2 != A[0]: b[1] = 1 s += 1 print(s) pri...
18
16
384
360
N = int(input()) A = list(map(int, input().split())) b = [0] * (N + 1) half = N // 2 b[half + 1 :] = A[half:] for i in range(half, 1, -1): s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2 if s != A[i - 1]: b[i] = 1 s = sum(b) if s % 2 != A[0]: b[1] = 1 s += 1 print(s) for i, b_ in enumerate(b...
N = int(eval(input())) A = list(map(int, input().split())) b = [0] * (N + 1) half = N // 2 b[half + 1 :] = A[half:] for i in range(half, 1, -1): s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2 if s != A[i - 1]: b[i] = 1 s = sum(b) if s % 2 != A[0]: b[1] = 1 s += 1 print(s) print((*[i for i i...
false
11.111111
[ "-N = int(input())", "+N = int(eval(input()))", "-for i, b_ in enumerate(b[:]):", "- if b_ == 1:", "- print(i, end=\" \")", "+print((*[i for i in range(1, N + 1) if b[i] == 1]))" ]
false
0.044675
0.043494
1.027143
[ "s557103313", "s869355125" ]
u156815136
p03721
python
s433177087
s242225512
446
294
24,568
19,880
Accepted
Accepted
34.08
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] -...
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counte...
42
42
870
915
from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j...
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3回 # from collections import deque from collections import deque, defaultdict, Co...
false
0
[ "-from statistics import median", "-", "+# from statistics import median", "-from itertools import combinations # (string,3) 3回", "-from collections import deque", "-from collections import defaultdict", "-import bisect", "+from itertools import combinations, permutations, accumulate # (string,3) 3回...
false
0.033157
0.035377
0.937249
[ "s433177087", "s242225512" ]
u724687935
p02793
python
s468983813
s891032918
1,866
915
6,200
67,416
Accepted
Accepted
50.96
from fractions import gcd MOD = 10 ** 9 + 7 N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) lcm = A[0] for a in A: lcm = (lcm * a) // gcd(lcm, a) ans = 0 for a in A: ans += (lcm % MOD) * pow(a, MOD - 2, MOD) ans %= MOD print(ans)
from fractions import gcd MOD = 10 ** 9 + 7 N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) lcm = A[0] for a in A: lcm = (lcm * a) // gcd(lcm, a) ans = 0 lcm %= MOD for a in A: ans += lcm * pow(a, MOD - 2, MOD) ans %= MOD print(ans)
19
20
292
296
from fractions import gcd MOD = 10**9 + 7 N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) lcm = A[0] for a in A: lcm = (lcm * a) // gcd(lcm, a) ans = 0 for a in A: ans += (lcm % MOD) * pow(a, MOD - 2, MOD) ans %= MOD print(ans)
from fractions import gcd MOD = 10**9 + 7 N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) lcm = A[0] for a in A: lcm = (lcm * a) // gcd(lcm, a) ans = 0 lcm %= MOD for a in A: ans += lcm * pow(a, MOD - 2, MOD) ans %= MOD print(ans)
false
5
[ "+lcm %= MOD", "- ans += (lcm % MOD) * pow(a, MOD - 2, MOD)", "+ ans += lcm * pow(a, MOD - 2, MOD)" ]
false
0.043882
0.108999
0.402592
[ "s468983813", "s891032918" ]
u312025627
p02788
python
s662527468
s645686195
1,899
1,711
102,692
100,772
Accepted
Accepted
9.9
def main(): N, D, A = (int(i) for i in input().split()) P = [[int(i) for i in input().split()] for j in range(N)] P.sort() X = [x[0] for x in P] H = [h[1] for h in P] diff = [H[0]] + [H[i+1] - H[i] for i in range(N-1)] BIT = [0] * (N+1) def BIT_query(idx): """ A1 ~ Aiま...
def main(): N, D, A = (int(i) for i in input().split()) P = [[int(i) for i in input().split()] for j in range(N)] P.sort() X = [x[0] for x in P] H = [h[1] for h in P] diff = [H[0]] + [H[i+1] - H[i] for i in range(N-1)] BIT = [0] * (N+1) def BIT_query(idx): """ A1 ~ Aiま...
46
47
1,176
1,185
def main(): N, D, A = (int(i) for i in input().split()) P = [[int(i) for i in input().split()] for j in range(N)] P.sort() X = [x[0] for x in P] H = [h[1] for h in P] diff = [H[0]] + [H[i + 1] - H[i] for i in range(N - 1)] BIT = [0] * (N + 1) def BIT_query(idx): """A1 ~ Aiまでの和(1...
def main(): N, D, A = (int(i) for i in input().split()) P = [[int(i) for i in input().split()] for j in range(N)] P.sort() X = [x[0] for x in P] H = [h[1] for h in P] diff = [H[0]] + [H[i + 1] - H[i] for i in range(N - 1)] BIT = [0] * (N + 1) def BIT_query(idx): """A1 ~ Aiまでの和(1...
false
2.12766
[ "- from bisect import bisect_right", "-", "+ right = 0", "+ while right < N and P[right][0] <= x + 2 * D:", "+ right += 1", "- right = bisect_right(X, x + 2 * D)" ]
false
0.050373
0.044764
1.125305
[ "s662527468", "s645686195" ]
u729133443
p03703
python
s084497565
s107603535
1,388
420
45,008
113,552
Accepted
Accepted
69.74
class BIT: def __init__(self,n): self.size=n self.tree=[0]*-~n def sum(self,i): s=0 while i: s+=self.tree[i] i-=i&-i return s def add(self,i,x): while i<=self.size: self.tree[i]+=x i+=i&-i n,k,*a=li...
class BIT: def __init__(self,n): self.size=n self.tree=[0]*-~n def sum(self,i): s=0 while i: s+=self.tree[i] i-=i&-i return s def add(self,i,x): while i<=self.size: self.tree[i]+=x i+=i&-i n,k,*a=li...
30
30
614
601
class BIT: def __init__(self, n): self.size = n self.tree = [0] * -~n def sum(self, i): s = 0 while i: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i ...
class BIT: def __init__(self, n): self.size = n self.tree = [0] * -~n def sum(self, i): s = 0 while i: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i ...
false
0
[ "-for i, p in enumerate(a):", "+for p in a:" ]
false
0.092201
0.087622
1.052264
[ "s084497565", "s107603535" ]
u983918956
p03069
python
s391020141
s208593929
239
132
12,776
3,500
Accepted
Accepted
44.77
N = int(eval(input())) S = eval(input()) b = [0] * (N+1) w = [0] * (N+1) for i, s in enumerate(S): b[i+1] = b[i] w[i+1] = w[i] if s == "#": b[i+1] += 1 if s == ".": w[i+1] += 1 ans = float('inf') for i in range(N+1): ans = min(ans, b[i] + w[N] - w[i]) print(an...
N = int(eval(input())) S = eval(input()) w_N = S.count(".") ans = w_N b = 0 w = 0 for i, s in enumerate(S): if s == "#": b += 1 if s == ".": w += 1 ans = min(ans,b + w_N - w) print(ans)
20
16
310
219
N = int(eval(input())) S = eval(input()) b = [0] * (N + 1) w = [0] * (N + 1) for i, s in enumerate(S): b[i + 1] = b[i] w[i + 1] = w[i] if s == "#": b[i + 1] += 1 if s == ".": w[i + 1] += 1 ans = float("inf") for i in range(N + 1): ans = min(ans, b[i] + w[N] - w[i]) print(ans)
N = int(eval(input())) S = eval(input()) w_N = S.count(".") ans = w_N b = 0 w = 0 for i, s in enumerate(S): if s == "#": b += 1 if s == ".": w += 1 ans = min(ans, b + w_N - w) print(ans)
false
20
[ "-b = [0] * (N + 1)", "-w = [0] * (N + 1)", "+w_N = S.count(\".\")", "+ans = w_N", "+b = 0", "+w = 0", "- b[i + 1] = b[i]", "- w[i + 1] = w[i]", "- b[i + 1] += 1", "+ b += 1", "- w[i + 1] += 1", "-ans = float(\"inf\")", "-for i in range(N + 1):", "- ans = min(...
false
0.046421
0.037132
1.250152
[ "s391020141", "s208593929" ]
u217303170
p03698
python
s106366961
s901405935
29
26
8,984
9,088
Accepted
Accepted
10.34
s = eval(input()) n = len(s) rs = sorted(s) cnt = 0 ans = 'no' for i in range(0, n-1): if rs[i] != rs[i+1]: cnt += 1 if cnt == n-1: ans = 'yes' print(ans) exit() print(ans)
s = eval(input()) rs = set(s) if len(s) == len(rs): print('yes') else: print('no')
13
6
235
90
s = eval(input()) n = len(s) rs = sorted(s) cnt = 0 ans = "no" for i in range(0, n - 1): if rs[i] != rs[i + 1]: cnt += 1 if cnt == n - 1: ans = "yes" print(ans) exit() print(ans)
s = eval(input()) rs = set(s) if len(s) == len(rs): print("yes") else: print("no")
false
53.846154
[ "-n = len(s)", "-rs = sorted(s)", "-cnt = 0", "-ans = \"no\"", "-for i in range(0, n - 1):", "- if rs[i] != rs[i + 1]:", "- cnt += 1", "- if cnt == n - 1:", "- ans = \"yes\"", "- print(ans)", "- exit()", "-print(ans)", "+rs = set(s)", "+if ...
false
0.068178
0.078683
0.866486
[ "s106366961", "s901405935" ]
u192154323
p03160
python
s001004073
s433255267
171
141
18,836
13,928
Accepted
Accepted
17.54
n = int(eval(input())) h_ls = list(map(int, input().split())) h_ls = h_ls # ここからはh_lsのインデックスを基準に one_cost = [0] * (n) for i in range(n-1): one_cost[i+1] = abs(h_ls[i+1] - h_ls[i]) two_cost = [0] * (n) for i in range(n-2): two_cost[i+2] = abs(h_ls[i+2] - h_ls[i]) mincost_ls = [0] * (n) mincost_ls[...
n = int(eval(input())) h_ls = list(map(int, input().split())) h_ls = h_ls mincost_ls = [float('inf')] * n mincost_ls[0] = 0 mincost_ls[1] = abs(h_ls[1] - h_ls[0]) for i in range(n-2): mincost_ls[i+2] = min(mincost_ls[i+1] + abs(h_ls[i+2] - h_ls[i+1]), mincost_ls[i] + abs(h_ls[i+2] - h_ls[i])) pr...
17
11
467
333
n = int(eval(input())) h_ls = list(map(int, input().split())) h_ls = h_ls # ここからはh_lsのインデックスを基準に one_cost = [0] * (n) for i in range(n - 1): one_cost[i + 1] = abs(h_ls[i + 1] - h_ls[i]) two_cost = [0] * (n) for i in range(n - 2): two_cost[i + 2] = abs(h_ls[i + 2] - h_ls[i]) mincost_ls = [0] * (n) mincost_ls[1] ...
n = int(eval(input())) h_ls = list(map(int, input().split())) h_ls = h_ls mincost_ls = [float("inf")] * n mincost_ls[0] = 0 mincost_ls[1] = abs(h_ls[1] - h_ls[0]) for i in range(n - 2): mincost_ls[i + 2] = min( mincost_ls[i + 1] + abs(h_ls[i + 2] - h_ls[i + 1]), mincost_ls[i] + abs(h_ls[i + 2] - h_l...
false
35.294118
[ "-# ここからはh_lsのインデックスを基準に", "-one_cost = [0] * (n)", "-for i in range(n - 1):", "- one_cost[i + 1] = abs(h_ls[i + 1] - h_ls[i])", "-two_cost = [0] * (n)", "-for i in range(n - 2):", "- two_cost[i + 2] = abs(h_ls[i + 2] - h_ls[i])", "-mincost_ls = [0] * (n)", "-mincost_ls[1] = one_cost[1]", "+...
false
0.048358
0.048444
0.998218
[ "s001004073", "s433255267" ]
u287500079
p02885
python
s103570675
s003268080
20
17
3,316
2,940
Accepted
Accepted
15
a,b = list(map(int,input().split())) if b * 2 >= a: print((0)) else: print((a-2*b))
a,b = list(map(int,input().split())) print((max(0,a-2*b))) ''' if b * 2 >= a: print(0) else: print(a-2*b) '''
7
9
93
118
a, b = list(map(int, input().split())) if b * 2 >= a: print((0)) else: print((a - 2 * b))
a, b = list(map(int, input().split())) print((max(0, a - 2 * b))) """ if b * 2 >= a: print(0) else: print(a-2*b) """
false
22.222222
[ "+print((max(0, a - 2 * b)))", "+\"\"\"", "- print((0))", "+ print(0)", "- print((a - 2 * b))", "+ print(a-2*b)", "+\"\"\"" ]
false
0.057932
0.070663
0.819834
[ "s103570675", "s003268080" ]
u952708174
p03828
python
s541323929
s921301460
52
39
3,064
3,316
Accepted
Accepted
25
def c_factors_of_factorial(N): def exponential_list(n): # ret[k]: n!を素因数分解したときのkの指数 ret = {} for j in range(2, n + 1): current = j ret[j] = 0 for k in range(2, j + 1): while current % k == 0: ret[k] += 1 ...
def c_factors_of_factorial(N): import math def prime_decomposition(n): # nを素因数分解 from collections import defaultdict i = 2 table = defaultdict(int) while i**2 <= n: while n % i == 0: n //= i table[i] += 1 ...
24
25
626
614
def c_factors_of_factorial(N): def exponential_list(n): # ret[k]: n!を素因数分解したときのkの指数 ret = {} for j in range(2, n + 1): current = j ret[j] = 0 for k in range(2, j + 1): while current % k == 0: ret[k] += 1 ...
def c_factors_of_factorial(N): import math def prime_decomposition(n): # nを素因数分解 from collections import defaultdict i = 2 table = defaultdict(int) while i**2 <= n: while n % i == 0: n //= i table[i] += 1 i += 1 ...
false
4
[ "- def exponential_list(n):", "- # ret[k]: n!を素因数分解したときのkの指数", "- ret = {}", "- for j in range(2, n + 1):", "- current = j", "- ret[j] = 0", "- for k in range(2, j + 1):", "- while current % k == 0:", "- ret[k...
false
0.140047
0.197674
0.708476
[ "s541323929", "s921301460" ]
u836939578
p03855
python
s497118646
s922031916
1,471
899
119,256
108,888
Accepted
Accepted
38.89
from collections import* class UnionFind: def __init__(self, n): self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = s...
from collections import defaultdict import sys input = lambda: sys.stdin.readline().rstrip() class UnionFind: def __init__(self, n): self.parents = [-1]*n def find(self, x): if self.parents[x] < 0: return x self.parents[x] = self.find(self.parents[x]) ...
42
54
959
1,116
from collections import * class UnionFind: def __init__(self, n): self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) ...
from collections import defaultdict import sys input = lambda: sys.stdin.readline().rstrip() class UnionFind: def __init__(self, n): self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x self.parents[x] = self.find(self.parents[x]) return sel...
false
22.222222
[ "-from collections import *", "+from collections import defaultdict", "+import sys", "+", "+input = lambda: sys.stdin.readline().rstrip()", "-road = UnionFind(N)", "-rail = UnionFind(N)", "+road_union = UnionFind(N)", "+rails_union = UnionFind(N)", "- road.union(p - 1, q - 1)", "+ p -= 1",...
false
0.104544
0.039441
2.650674
[ "s497118646", "s922031916" ]
u387562669
p03775
python
s693678421
s888914189
53
28
3,060
3,060
Accepted
Accepted
47.17
import math def main(): #infile = open("compprog.txt", mode="r") n = int(eval(input())) res = f(1, n) i = 2 while i <= math.sqrt(n): if n % i == 0: this_f = f(i, n // i) res = this_f if this_f < res else res i += 1 print(res) #infile.cl...
import math def main(): n = int(eval(input())) res = f(1, n) for i in range(1, int(math.sqrt(n)) + 1): if n % i == 0: res = min(res, f(i, n // i)) print(res) def f(a, b): return max(len(str(a)), len(str(b))) if __name__ == "__main__": main()
23
18
424
303
import math def main(): # infile = open("compprog.txt", mode="r") n = int(eval(input())) res = f(1, n) i = 2 while i <= math.sqrt(n): if n % i == 0: this_f = f(i, n // i) res = this_f if this_f < res else res i += 1 print(res) # infile.close() def ...
import math def main(): n = int(eval(input())) res = f(1, n) for i in range(1, int(math.sqrt(n)) + 1): if n % i == 0: res = min(res, f(i, n // i)) print(res) def f(a, b): return max(len(str(a)), len(str(b))) if __name__ == "__main__": main()
false
21.73913
[ "- # infile = open(\"compprog.txt\", mode=\"r\")", "- i = 2", "- while i <= math.sqrt(n):", "+ for i in range(1, int(math.sqrt(n)) + 1):", "- this_f = f(i, n // i)", "- res = this_f if this_f < res else res", "- i += 1", "+ res = min(res, f(i, n // i...
false
0.044923
0.079426
0.565598
[ "s693678421", "s888914189" ]
u708255304
p02990
python
s122306937
s628042963
329
23
5,748
3,696
Accepted
Accepted
93.01
def culc_factrial(n): factrial = [1] * (n+1) for i in range(1, n+1): factrial[i] = factrial[i-1] * i return factrial N, K = list(map(int, input().split())) factrial = culc_factrial(2000) for i in range(1, K+1): hoge = factrial[N-K+1] // (factrial[i]*factrial[N-K+1-i]) fuga =...
# 二項係数を"やるだけ"にしてくれるライブラリ MAX = 3000 MOD = 1000000007 factrial = [0]*MAX inverse = [0]*MAX factrial_inverse = [0]*MAX # テーブルを作る前処理 def COMinit(): global factrial, inverse, factrial_inverse factrial[0] = 1 factrial[1] = 1 inverse[1] = 1 factrial_inverse[0] = 1 factrial_inverse[1] ...
15
39
399
940
def culc_factrial(n): factrial = [1] * (n + 1) for i in range(1, n + 1): factrial[i] = factrial[i - 1] * i return factrial N, K = list(map(int, input().split())) factrial = culc_factrial(2000) for i in range(1, K + 1): hoge = factrial[N - K + 1] // (factrial[i] * factrial[N - K + 1 - i]) f...
# 二項係数を"やるだけ"にしてくれるライブラリ MAX = 3000 MOD = 1000000007 factrial = [0] * MAX inverse = [0] * MAX factrial_inverse = [0] * MAX # テーブルを作る前処理 def COMinit(): global factrial, inverse, factrial_inverse factrial[0] = 1 factrial[1] = 1 inverse[1] = 1 factrial_inverse[0] = 1 factrial_inverse[1] = 1 for...
false
61.538462
[ "-def culc_factrial(n):", "- factrial = [1] * (n + 1)", "- for i in range(1, n + 1):", "- factrial[i] = factrial[i - 1] * i", "- return factrial", "+# 二項係数を\"やるだけ\"にしてくれるライブラリ", "+MAX = 3000", "+MOD = 1000000007", "+factrial = [0] * MAX", "+inverse = [0] * MAX", "+factrial_invers...
false
0.270071
0.039335
6.865834
[ "s122306937", "s628042963" ]
u774160580
p02983
python
s251641335
s150098514
966
768
2,940
2,940
Accepted
Accepted
20.5
L, R = list(map(int, input().split())) ans = 2018 for i in range(L, min(R, L + 2019) + 1): for j in range(i + 1, min(R, L + 2019) + 1): ans = min(ans, ((i % 2019) * (j % 2019)) % 2019) print(ans)
L, R = list(map(int, input().split())) ans = 2018 for i in range(L, min(L + 2019, R) + 1): for j in range(i + 1, min(L + 2019, R) + 1): ans = min(ans, (i * j) % 2019) print(ans)
6
6
213
189
L, R = list(map(int, input().split())) ans = 2018 for i in range(L, min(R, L + 2019) + 1): for j in range(i + 1, min(R, L + 2019) + 1): ans = min(ans, ((i % 2019) * (j % 2019)) % 2019) print(ans)
L, R = list(map(int, input().split())) ans = 2018 for i in range(L, min(L + 2019, R) + 1): for j in range(i + 1, min(L + 2019, R) + 1): ans = min(ans, (i * j) % 2019) print(ans)
false
0
[ "-for i in range(L, min(R, L + 2019) + 1):", "- for j in range(i + 1, min(R, L + 2019) + 1):", "- ans = min(ans, ((i % 2019) * (j % 2019)) % 2019)", "+for i in range(L, min(L + 2019, R) + 1):", "+ for j in range(i + 1, min(L + 2019, R) + 1):", "+ ans = min(ans, (i * j) % 2019)" ]
false
0.105298
0.14094
0.747112
[ "s251641335", "s150098514" ]
u432356156
p03075
python
s982072334
s330959127
308
19
21,368
3,060
Accepted
Accepted
93.83
import numpy as np num = [] #5このアンテナ for i in range(5): #入力 a = eval(input()) num.append(int(a)) k=int(eval(input())) num.sort() ran=num[4]-num[0] if ran > k: print(":(") else: print("Yay!")
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) d = int(eval(input())) e = int(eval(input())) k = int(eval(input())) if(e-a <= k): print("Yay!") else: print(":(")
18
11
217
167
import numpy as np num = [] # 5このアンテナ for i in range(5): # 入力 a = eval(input()) num.append(int(a)) k = int(eval(input())) num.sort() ran = num[4] - num[0] if ran > k: print(":(") else: print("Yay!")
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) d = int(eval(input())) e = int(eval(input())) k = int(eval(input())) if e - a <= k: print("Yay!") else: print(":(")
false
38.888889
[ "-import numpy as np", "-", "-num = [] # 5このアンテナ", "-for i in range(5): # 入力", "- a = eval(input())", "- num.append(int(a))", "+a = int(eval(input()))", "+b = int(eval(input()))", "+c = int(eval(input()))", "+d = int(eval(input()))", "+e = int(eval(input()))", "-num.sort()", "-ran = ...
false
0.043838
0.036314
1.207204
[ "s982072334", "s330959127" ]
u222801992
p03163
python
s212495429
s976993052
301
276
41,452
43,184
Accepted
Accepted
8.31
n,W=list(map(int,input().split())) w=[0]*n v=[0]*n for i in range(n): w[i],v[i]=list(map(int,input().split())) dp=[0]*(W+1) for i in range(n): j=W while j>=w[i]: dp[j]=max(dp[j],dp[j-w[i]]+v[i]) j-=1 print((dp[W]))
""" 【01ナップザック問題】 重さと価値がそれぞれw_i,v_iであるようなn個の品物がある. これらの品物の中から, 重さの総和がWを超えないように選んだ時の, 価値の総和の最大値を求めよ. 1<=n<=100, 1<=w_i,v_i<=100, 1<=W<=10000 """ #------------------------------------------------------------------------------ #入力,準備 n,W= list(map(int,input().split())) w=[0]*n v=[0]*n for i in range(n): ...
13
26
241
531
n, W = list(map(int, input().split())) w = [0] * n v = [0] * n for i in range(n): w[i], v[i] = list(map(int, input().split())) dp = [0] * (W + 1) for i in range(n): j = W while j >= w[i]: dp[j] = max(dp[j], dp[j - w[i]] + v[i]) j -= 1 print((dp[W]))
""" 【01ナップザック問題】 重さと価値がそれぞれw_i,v_iであるようなn個の品物がある. これらの品物の中から, 重さの総和がWを超えないように選んだ時の, 価値の総和の最大値を求めよ. 1<=n<=100, 1<=w_i,v_i<=100, 1<=W<=10000 """ # ------------------------------------------------------------------------------ # 入力,準備 n, W = list(map(int, input().split())) w = [0] * n v = [0] * n for i in range(n): w[...
false
50
[ "+\"\"\"", "+【01ナップザック問題】", "+重さと価値がそれぞれw_i,v_iであるようなn個の品物がある.", "+これらの品物の中から, 重さの総和がWを超えないように選んだ時の,", "+価値の総和の最大値を求めよ.", "+1<=n<=100, 1<=w_i,v_i<=100, 1<=W<=10000", "+\"\"\"", "+# 入力,準備", "+# メイン", "+# dp[j] : 重さの総和がjを超えないように選んだ時の価値の総和の最大値" ]
false
0.008097
0.038942
0.207934
[ "s212495429", "s976993052" ]
u505420467
p02767
python
s460952740
s317423987
19
17
3,064
2,940
Accepted
Accepted
10.53
n = int(eval(input())) x = list(map(int, input().split())) avg = round(sum(x) / n) ans = 0 for i in x: ans += (i - avg) ** 2 print(ans)
if __name__ == '__main__': n = int(eval(input())) x = list(map(int, input().split())) p = round(sum(x) / n) ans = 0 for i in x: ans += (i - p) ** 2 print(ans)
11
8
147
192
n = int(eval(input())) x = list(map(int, input().split())) avg = round(sum(x) / n) ans = 0 for i in x: ans += (i - avg) ** 2 print(ans)
if __name__ == "__main__": n = int(eval(input())) x = list(map(int, input().split())) p = round(sum(x) / n) ans = 0 for i in x: ans += (i - p) ** 2 print(ans)
false
27.272727
[ "-n = int(eval(input()))", "-x = list(map(int, input().split()))", "-avg = round(sum(x) / n)", "-ans = 0", "-for i in x:", "- ans += (i - avg) ** 2", "-print(ans)", "+if __name__ == \"__main__\":", "+ n = int(eval(input()))", "+ x = list(map(int, input().split()))", "+ p = round(sum(...
false
0.069813
0.070244
0.993863
[ "s460952740", "s317423987" ]
u740284863
p03807
python
s012139535
s004256300
50
44
14,112
14,112
Accepted
Accepted
12
n = int(eval(input())) A = list(map(int,input().split())) A = [_ % 2 for _ in A] if sum(A) % 2 == 0: print("YES") else: print("NO")
n = int(eval(input())) A = list(map(int,input().split())) if sum(A) % 2 == 0: print("YES") else: print("NO")
7
6
140
116
n = int(eval(input())) A = list(map(int, input().split())) A = [_ % 2 for _ in A] if sum(A) % 2 == 0: print("YES") else: print("NO")
n = int(eval(input())) A = list(map(int, input().split())) if sum(A) % 2 == 0: print("YES") else: print("NO")
false
14.285714
[ "-A = [_ % 2 for _ in A]" ]
false
0.048963
0.035481
1.379984
[ "s012139535", "s004256300" ]
u345966487
p03674
python
s335102653
s591118230
511
408
75,060
62,772
Accepted
Accepted
20.16
n,*a=list(map(int,open(0).read().split()));b={};M=10**9+7 for i,x in enumerate(a):b.setdefault(x,[]).append(i) p=n+1;q=r=1;d=[abs(j[0]-j[1])for x,j in list(b.items())if len(j)>1][0] for k in range(n+1):print(((p-q)%M));q=q*(n-d-k)*r%M;r=pow(k+2,M-2,M);p=p*(n-k)*r%M
n,*a=list(map(int,open(0).read().split()));b={};M=10**9+7;p=n+1;q=r=1 for i,x in enumerate(a): if x in b:d=i-b[x];break b[x]=i for k in range(n+1):print(((p-q)%M));q=q*(n-d-k)*r%M;r=pow(k+2,M-2,M);p=p*(n-k)*r%M
4
5
254
208
n, *a = list(map(int, open(0).read().split())) b = {} M = 10**9 + 7 for i, x in enumerate(a): b.setdefault(x, []).append(i) p = n + 1 q = r = 1 d = [abs(j[0] - j[1]) for x, j in list(b.items()) if len(j) > 1][0] for k in range(n + 1): print(((p - q) % M)) q = q * (n - d - k) * r % M r = pow(k + 2, M - 2...
n, *a = list(map(int, open(0).read().split())) b = {} M = 10**9 + 7 p = n + 1 q = r = 1 for i, x in enumerate(a): if x in b: d = i - b[x] break b[x] = i for k in range(n + 1): print(((p - q) % M)) q = q * (n - d - k) * r % M r = pow(k + 2, M - 2, M) p = p * (n - k) * r % M
false
20
[ "-for i, x in enumerate(a):", "- b.setdefault(x, []).append(i)", "-d = [abs(j[0] - j[1]) for x, j in list(b.items()) if len(j) > 1][0]", "+for i, x in enumerate(a):", "+ if x in b:", "+ d = i - b[x]", "+ break", "+ b[x] = i" ]
false
0.053086
0.040951
1.296345
[ "s335102653", "s591118230" ]
u980205854
p03053
python
s134236156
s820246499
439
342
83,928
122,008
Accepted
Accepted
22.1
# A - Darker and Darker from collections import deque H,W = list(map(int,input().split())) B = [[-1] * W for _ in range(H)] queue = deque([]) for i in range(H): A = eval(input()) for j in range(W): if A[j]=='#': B[i][j] = 0 queue.append((i,j)) ans = 0 while ...
import sys from sys import exit from collections import deque from copy import deepcopy from bisect import bisect_left, bisect_right, insort_left, insort_right from heapq import heapify, heappop, heappush from itertools import product, permutations, combinations, combinations_with_replacement from functools impo...
28
108
599
2,994
# A - Darker and Darker from collections import deque H, W = list(map(int, input().split())) B = [[-1] * W for _ in range(H)] queue = deque([]) for i in range(H): A = eval(input()) for j in range(W): if A[j] == "#": B[i][j] = 0 queue.append((i, j)) ans = 0 while queue: I, J ...
import sys from sys import exit from collections import deque from copy import deepcopy from bisect import bisect_left, bisect_right, insort_left, insort_right from heapq import heapify, heappop, heappush from itertools import product, permutations, combinations, combinations_with_replacement from functools import redu...
false
74.074074
[ "-# A - Darker and Darker", "+import sys", "+from sys import exit", "+from copy import deepcopy", "+from bisect import bisect_left, bisect_right, insort_left, insort_right", "+from heapq import heapify, heappop, heappush", "+from itertools import product, permutations, combinations, combinations_with_re...
false
0.048462
0.168927
0.286882
[ "s134236156", "s820246499" ]
u698868214
p03612
python
s598980282
s089409202
81
74
20,436
20,520
Accepted
Accepted
8.64
N = int(eval(input())) P = list(map(int,input().split())) ls = [""] * N cnt = 0 for i in range(N): if P[i] == i + 1: ls[i] = "#" else: ls[i] = "." if ls[-1] == "#": if ls[-2] == "#": ls[-1], ls[-2] = ".", "." else: ls[-1] = "." cnt += 1 for j in range(N-1): if ls[...
N = int(eval(input())) P = list(map(int,input().split())) ans = 0 if P[-1] == N: ans += 1 P[-1] = -1 if P[-2] == N - 1: P[-2] = -1 for i in range(N-1): if P[i] == i + 1: ans += 1 if P[i+1] == i + 2: P[i+1] = -1 print(ans)
26
18
401
268
N = int(eval(input())) P = list(map(int, input().split())) ls = [""] * N cnt = 0 for i in range(N): if P[i] == i + 1: ls[i] = "#" else: ls[i] = "." if ls[-1] == "#": if ls[-2] == "#": ls[-1], ls[-2] = ".", "." else: ls[-1] = "." cnt += 1 for j in range(N - 1): if ...
N = int(eval(input())) P = list(map(int, input().split())) ans = 0 if P[-1] == N: ans += 1 P[-1] = -1 if P[-2] == N - 1: P[-2] = -1 for i in range(N - 1): if P[i] == i + 1: ans += 1 if P[i + 1] == i + 2: P[i + 1] = -1 print(ans)
false
30.769231
[ "-ls = [\"\"] * N", "-cnt = 0", "-for i in range(N):", "+ans = 0", "+if P[-1] == N:", "+ ans += 1", "+ P[-1] = -1", "+ if P[-2] == N - 1:", "+ P[-2] = -1", "+for i in range(N - 1):", "- ls[i] = \"#\"", "- else:", "- ls[i] = \".\"", "-if ls[-1] == \"#\":", ...
false
0.0423
0.04264
0.992011
[ "s598980282", "s089409202" ]
u372550522
p03476
python
s727515292
s873232165
1,835
1,128
3,572
9,172
Accepted
Accepted
38.53
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True def bisect(lst, isok, ok, ng): while(abs(ok-ng)>1): mid = (ok+ng)//2 if isok(lst[mid]): ok = mid else: ...
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True s = [0] * (100001) for i in range(1, 10**5+1): if i%2 == 1 and is_prime(i) and is_prime((i+1)//2): s[i-1] = 1 lst = [0] * (100001) for i ...
30
21
675
472
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def bisect(lst, isok, ok, ng): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if isok(lst[mid]): ok = mid else: ...
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True s = [0] * (100001) for i in range(1, 10**5 + 1): if i % 2 == 1 and is_prime(i) and is_prime((i + 1) // 2): s[i - 1] = 1 lst = [0] * (100001) for i in ...
false
30
[ "-def bisect(lst, isok, ok, ng):", "- while abs(ok - ng) > 1:", "- mid = (ok + ng) // 2", "- if isok(lst[mid]):", "- ok = mid", "- else:", "- ng = mid", "- return ok", "-", "-", "-s = []", "+s = [0] * (100001)", "+for i in range(1, 10**5 + 1):...
false
0.386831
1.435529
0.269469
[ "s727515292", "s873232165" ]
u708019102
p03160
python
s336628059
s329185894
183
133
13,924
13,928
Accepted
Accepted
27.32
N = int(eval(input())) h = [int(x) for x in input().split()] DP = [10000] * N DP[0] = 0 DP[1] = max(h[0]-h[1],h[1]-h[0]) for i in range(2,N): DP[i] = min(DP[i-2] + max(h[i]-h[i-2],h[i-2]-h[i]),DP[i-1] + max(h[i]-h[i-1],h[i-1]-h[i])) print((DP[N-1]))
N = int(eval(input())) h = [int(x) for x in input().split()] DP=[0]*(N+1) DP[2] = DP[1] + abs(h[0]-h[1]) for i in range(3,N+1): DP[i] = min(DP[i-2] + abs(h[i-3]-h[i-1]),DP[i-1] + abs(h[i-2]-h[i-1])) print((DP[N]))
8
7
250
215
N = int(eval(input())) h = [int(x) for x in input().split()] DP = [10000] * N DP[0] = 0 DP[1] = max(h[0] - h[1], h[1] - h[0]) for i in range(2, N): DP[i] = min( DP[i - 2] + max(h[i] - h[i - 2], h[i - 2] - h[i]), DP[i - 1] + max(h[i] - h[i - 1], h[i - 1] - h[i]), ) print((DP[N - 1]))
N = int(eval(input())) h = [int(x) for x in input().split()] DP = [0] * (N + 1) DP[2] = DP[1] + abs(h[0] - h[1]) for i in range(3, N + 1): DP[i] = min( DP[i - 2] + abs(h[i - 3] - h[i - 1]), DP[i - 1] + abs(h[i - 2] - h[i - 1]) ) print((DP[N]))
false
12.5
[ "-DP = [10000] * N", "-DP[0] = 0", "-DP[1] = max(h[0] - h[1], h[1] - h[0])", "-for i in range(2, N):", "+DP = [0] * (N + 1)", "+DP[2] = DP[1] + abs(h[0] - h[1])", "+for i in range(3, N + 1):", "- DP[i - 2] + max(h[i] - h[i - 2], h[i - 2] - h[i]),", "- DP[i - 1] + max(h[i] - h[i - 1], h...
false
0.052003
0.037023
1.404587
[ "s336628059", "s329185894" ]
u610120522
p02694
python
s405904470
s397496632
24
21
9,112
9,108
Accepted
Accepted
12.5
X = int(eval(input())) count = 0 money = int(100) while True: money = int(money * 1.01) count += 1 if money >= X: print(count) break
X = int(eval(input())) count = 0 money = 100 while True: money = int(money * 1.01) count += 1 if money >= X: print(count) break
10
10
151
146
X = int(eval(input())) count = 0 money = int(100) while True: money = int(money * 1.01) count += 1 if money >= X: print(count) break
X = int(eval(input())) count = 0 money = 100 while True: money = int(money * 1.01) count += 1 if money >= X: print(count) break
false
0
[ "-money = int(100)", "+money = 100" ]
false
0.038759
0.060177
0.644087
[ "s405904470", "s397496632" ]
u203843959
p03030
python
s029105575
s220289426
20
17
3,064
3,060
Accepted
Accepted
15
N=int(eval(input())) rest_list = [] for i in range(N): Si, Pi = input().split() Pi = int(Pi) rest_list.append((i+1,Si,Pi)) for i in range(N-1): for j in range(i+1,N): ii,Si,Pi = rest_list[i] jj,Sj,Pj = rest_list[j] if Si > Sj or (Si == Sj and Pi < Pj): rest_list[i], rest_l...
N=int(eval(input())) rest_list=[] for i in range(N): S,P=input().split() rest_list.append((S,-int(P),i+1)) rest_list.sort() for s,p,i in rest_list: print(i)
19
9
420
165
N = int(eval(input())) rest_list = [] for i in range(N): Si, Pi = input().split() Pi = int(Pi) rest_list.append((i + 1, Si, Pi)) for i in range(N - 1): for j in range(i + 1, N): ii, Si, Pi = rest_list[i] jj, Sj, Pj = rest_list[j] if Si > Sj or (Si == Sj and Pi < Pj): ...
N = int(eval(input())) rest_list = [] for i in range(N): S, P = input().split() rest_list.append((S, -int(P), i + 1)) rest_list.sort() for s, p, i in rest_list: print(i)
false
52.631579
[ "- Si, Pi = input().split()", "- Pi = int(Pi)", "- rest_list.append((i + 1, Si, Pi))", "-for i in range(N - 1):", "- for j in range(i + 1, N):", "- ii, Si, Pi = rest_list[i]", "- jj, Sj, Pj = rest_list[j]", "- if Si > Sj or (Si == Sj and Pi < Pj):", "- res...
false
0.091459
0.046414
1.970523
[ "s029105575", "s220289426" ]
u731368968
p02702
python
s866087201
s415697491
138
79
76,532
75,768
Accepted
Accepted
42.75
S = eval(input()) mod = [0] for d, c in enumerate(S[::-1]): mod.append((int(c) * pow(10, d, 2019) + mod[-1]) % 2019) from collections import * print((sum(v * (v - 1) // 2 for v in list(Counter(mod).values()))))
mod = [0] pw = 1 for c in input()[::-1]: mod.append((int(c) * pw + mod[-1]) % 2019) pw = pw * 10 % 2019 from collections import * print((sum(v * (v - 1) // 2 for v in list(Counter(mod).values()))))
6
7
206
204
S = eval(input()) mod = [0] for d, c in enumerate(S[::-1]): mod.append((int(c) * pow(10, d, 2019) + mod[-1]) % 2019) from collections import * print((sum(v * (v - 1) // 2 for v in list(Counter(mod).values()))))
mod = [0] pw = 1 for c in input()[::-1]: mod.append((int(c) * pw + mod[-1]) % 2019) pw = pw * 10 % 2019 from collections import * print((sum(v * (v - 1) // 2 for v in list(Counter(mod).values()))))
false
14.285714
[ "-S = eval(input())", "-for d, c in enumerate(S[::-1]):", "- mod.append((int(c) * pow(10, d, 2019) + mod[-1]) % 2019)", "+pw = 1", "+for c in input()[::-1]:", "+ mod.append((int(c) * pw + mod[-1]) % 2019)", "+ pw = pw * 10 % 2019" ]
false
0.093849
0.068446
1.371141
[ "s866087201", "s415697491" ]
u944886577
p02639
python
s603907984
s945990510
29
26
8,952
9,064
Accepted
Accepted
10.34
a=[] a=input().split() for i in range(5): if a[i]=='0': print((str(i+1))) else: pass
s=list(map(int,input().split())) for i in range(5): if s[i]==0: print((i+1)) exit() else: pass
7
7
95
117
a = [] a = input().split() for i in range(5): if a[i] == "0": print((str(i + 1))) else: pass
s = list(map(int, input().split())) for i in range(5): if s[i] == 0: print((i + 1)) exit() else: pass
false
0
[ "-a = []", "-a = input().split()", "+s = list(map(int, input().split()))", "- if a[i] == \"0\":", "- print((str(i + 1)))", "+ if s[i] == 0:", "+ print((i + 1))", "+ exit()" ]
false
0.128784
0.118469
1.087065
[ "s603907984", "s945990510" ]
u514401521
p02689
python
s526872231
s553332078
424
362
29,512
29,532
Accepted
Accepted
14.62
N, M = list(map(int, input().split())) H = list(map(int, input().split())) ten = [[] for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 ten[a].append(b) ten[b].append(a) ans = 0 for i in range(N): flag = True for j in ten[i]: if ...
N, M = list(map(int, input().split())) H = list(map(int, input().split())) l = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 l[a].append(b) l[b].append(a) ng = 0 for i in range(N): for other in l[i]: if H[i] <= H[other]...
19
21
391
375
N, M = list(map(int, input().split())) H = list(map(int, input().split())) ten = [[] for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 ten[a].append(b) ten[b].append(a) ans = 0 for i in range(N): flag = True for j in ten[i]: if H[i] <= H[j]: ...
N, M = list(map(int, input().split())) H = list(map(int, input().split())) l = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 l[a].append(b) l[b].append(a) ng = 0 for i in range(N): for other in l[i]: if H[i] <= H[other]: ng += ...
false
9.52381
[ "-ten = [[] for _ in range(N)]", "-for i in range(M):", "+l = [[] for _ in range(N)]", "+for _ in range(M):", "- ten[a].append(b)", "- ten[b].append(a)", "-ans = 0", "+ l[a].append(b)", "+ l[b].append(a)", "+ng = 0", "- flag = True", "- for j in ten[i]:", "- if H[i] ...
false
0.03694
0.048074
0.768398
[ "s526872231", "s553332078" ]
u766926358
p00481
python
s394990781
s421965666
15,090
11,990
36,500
42,372
Accepted
Accepted
20.54
h,w,n = list(map(int, input().split())) stage = [eval(input()) for i in range(h)] starts = [str(i) for i in range(n)] goals = [str(i+1) for i in range(n)] starts_y = [0 for i in range(n)] starts_x = [0 for i in range(n)] goals_y = [0 for i in range(n)] goals_x = [0 for i in range(n)] starts[0] = "S" for y in...
#import time, sys# from collections import deque H, W, N = list(map(int, input().split())) field = [list(eval(input())) for i in range(H)] ''' 20 30 9 .......X..8.XXXX.XX..XX.X.XX.. X.XX....X.XX..X.X.X....XXXX..X ..X.X..XX..X.....XX.X..X.XX... ....X.X.X.XXX.X..X..X.X..XX.X. ..XXX.XX...X.X....X.X..X..X... ....
49
78
1,298
2,067
h, w, n = list(map(int, input().split())) stage = [eval(input()) for i in range(h)] starts = [str(i) for i in range(n)] goals = [str(i + 1) for i in range(n)] starts_y = [0 for i in range(n)] starts_x = [0 for i in range(n)] goals_y = [0 for i in range(n)] goals_x = [0 for i in range(n)] starts[0] = "S" for y in range(...
# import time, sys# from collections import deque H, W, N = list(map(int, input().split())) field = [list(eval(input())) for i in range(H)] """ 20 30 9 .......X..8.XXXX.XX..XX.X.XX.. X.XX....X.XX..X.X.X....XXXX..X ..X.X..XX..X.....XX.X..X.XX... ....X.X.X.XXX.X..X..X.X..XX.X. ..XXX.XX...X.X....X.X..X..X... ..X............
false
37.179487
[ "-h, w, n = list(map(int, input().split()))", "-stage = [eval(input()) for i in range(h)]", "-starts = [str(i) for i in range(n)]", "-goals = [str(i + 1) for i in range(n)]", "-starts_y = [0 for i in range(n)]", "-starts_x = [0 for i in range(n)]", "-goals_y = [0 for i in range(n)]", "-goals_x = [0 fo...
false
0.040693
0.039144
1.03958
[ "s394990781", "s421965666" ]
u279460955
p03221
python
s395238631
s666115027
928
717
109,400
122,584
Accepted
Accepted
22.74
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from itertools import permutations, accumulate, combinations, combinations_with_replacement from math import sqrt, ceil, floor, factorial from bisect import bisect_left, bisect_right, insort_left, insort_right from cop...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from itertools import permutations, accumulate, combinations, combinations_with_replacement from math import sqrt, ceil, floor, factorial from bisect import bisect_left, bisect_right, insort_left, insort_right from cop...
48
42
1,546
1,446
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from itertools import ( permutations, accumulate, combinations, combinations_with_replacement, ) from math import sqrt, ceil, floor, factorial from bisect import bisect_left, bisect_right, insort_left, insor...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from itertools import ( permutations, accumulate, combinations, combinations_with_replacement, ) from math import sqrt, ceil, floor, factorial from bisect import bisect_left, bisect_right, insort_left, insor...
false
12.5
[ "-from functools import reduce", "+from functools import reduce, lru_cache # @lru_cache(None)", "- return list(map(int, input().split()))", "+ return (int(x) for x in input().split())", "- return list(map(int, input().split()))", "+ return list(Is())", "- return tuple(map(int, input().sp...
false
0.033288
0.035546
0.936481
[ "s395238631", "s666115027" ]
u952708174
p03504
python
s165570876
s578627189
1,518
1,289
26,808
24,336
Accepted
Accepted
15.09
def d_recording(N, C, R): # N:録画する番組の数 # C:テレビが受信できるチャンネルの数 # R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc] from itertools import accumulate start = [row[0] for row in R] end = [row[1] for row in R] channel_num = [row[2] for row in R] # いつまで録画機を動かすか。0.5を単位時間とするので*2 # 時刻を0からスタートさせるので+2 ...
def d_recording(N, C, R): # N:録画する番組の数 # C:テレビが受信できるチャンネルの数 # R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc] from itertools import accumulate # いつまで録画機を動かすか。終了時刻の最大値10**5, 単位時間を0.5とするので*2 # 時刻を0からスタートさせるので+1, 累積和のために+1 l = 10**5 * 2 + 2 running_recorder = [0] * l # [k]:ある時刻に動作中の録画機の数 ...
34
31
1,149
1,008
def d_recording(N, C, R): # N:録画する番組の数 # C:テレビが受信できるチャンネルの数 # R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc] from itertools import accumulate start = [row[0] for row in R] end = [row[1] for row in R] channel_num = [row[2] for row in R] # いつまで録画機を動かすか。0.5を単位時間とするので*2 # 時刻を0からスタートさせるので+2 l = ma...
def d_recording(N, C, R): # N:録画する番組の数 # C:テレビが受信できるチャンネルの数 # R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc] from itertools import accumulate # いつまで録画機を動かすか。終了時刻の最大値10**5, 単位時間を0.5とするので*2 # 時刻を0からスタートさせるので+1, 累積和のために+1 l = 10**5 * 2 + 2 running_recorder = [0] * l # [k]:ある時刻に動作中の録画機の数 for channel...
false
8.823529
[ "- start = [row[0] for row in R]", "- end = [row[1] for row in R]", "- channel_num = [row[2] for row in R]", "- # いつまで録画機を動かすか。0.5を単位時間とするので*2", "- # 時刻を0からスタートさせるので+2", "- l = max(end) * 2 + 2", "- running_recorder = [0 for _ in range(l)] # [k]:ある時刻に動作中の録画機の数", "+ # いつまで録画機を動...
false
0.061845
0.120092
0.514979
[ "s165570876", "s578627189" ]
u753803401
p04000
python
s744081603
s431276712
1,543
1,010
189,996
191,996
Accepted
Accepted
34.54
import sys import bisect import collections import fractions import heapq import math from operator import mul from functools import reduce from functools import lru_cache def slove(): input = sys.stdin.readline mod = 10 ** 9 + 7 h, w, n = list(map(int, input().rstrip('\n').split())) d ...
import sys import collections def solve(): sys.setrecursionlimit(2000) input = sys.stdin.readline mod = 10 ** 9 + 7 h, w, n = list(map(int, input().rstrip('\n').split())) d = collections.defaultdict(int) for _ in range(n): a, b = list(map(int, input().rstrip('\n').split())) ...
33
27
852
730
import sys import bisect import collections import fractions import heapq import math from operator import mul from functools import reduce from functools import lru_cache def slove(): input = sys.stdin.readline mod = 10**9 + 7 h, w, n = list(map(int, input().rstrip("\n").split())) d = collections.def...
import sys import collections def solve(): sys.setrecursionlimit(2000) input = sys.stdin.readline mod = 10**9 + 7 h, w, n = list(map(int, input().rstrip("\n").split())) d = collections.defaultdict(int) for _ in range(n): a, b = list(map(int, input().rstrip("\n").split())) for i...
false
18.181818
[ "-import bisect", "-import fractions", "-import heapq", "-import math", "-from operator import mul", "-from functools import reduce", "-from functools import lru_cache", "-def slove():", "+def solve():", "+ sys.setrecursionlimit(2000)", "- for i in range(n):", "+ for _ in range(n):", ...
false
0.037357
0.061412
0.608306
[ "s744081603", "s431276712" ]
u753803401
p02918
python
s866543205
s134990353
195
175
41,072
45,296
Accepted
Accepted
10.26
def slove(): import sys input = sys.stdin.readline n, k = list(map(int, input().rstrip('\n').split())) s = str(input().rstrip('\n')) c = 0 cl = 0 mcl = 0 cr = 0 mcr = 0 for i in range(n): if i != 0: if s[i] != s[i-1]: c += 1 ...
import sys def solve(): input = sys.stdin.readline mod = 10 ** 9 + 7 n, k = list(map(int, input().rstrip('\n').split())) s = str(input().rstrip('\n')) ls = [] cnt = 1 for i in range(1, n): if s[i] != s[i-1]: ls.append(cnt-1) cnt = 1 els...
33
22
717
450
def slove(): import sys input = sys.stdin.readline n, k = list(map(int, input().rstrip("\n").split())) s = str(input().rstrip("\n")) c = 0 cl = 0 mcl = 0 cr = 0 mcr = 0 for i in range(n): if i != 0: if s[i] != s[i - 1]: c += 1 if s[i] ...
import sys def solve(): input = sys.stdin.readline mod = 10**9 + 7 n, k = list(map(int, input().rstrip("\n").split())) s = str(input().rstrip("\n")) ls = [] cnt = 1 for i in range(1, n): if s[i] != s[i - 1]: ls.append(cnt - 1) cnt = 1 else: ...
false
33.333333
[ "-def slove():", "- import sys", "+import sys", "+", "+def solve():", "+ mod = 10**9 + 7", "- c = 0", "- cl = 0", "- mcl = 0", "- cr = 0", "- mcr = 0", "- for i in range(n):", "- if i != 0:", "- if s[i] != s[i - 1]:", "- c += 1", ...
false
0.046916
0.085812
0.546736
[ "s866543205", "s134990353" ]
u968166680
p02727
python
s285455095
s424531344
187
153
121,668
29,020
Accepted
Accepted
18.18
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): X, Y, A, B, C, *PQR = list(map(int, read().split())) P = PQR[:A] Q = PQR[A : A + B] R = PQR[A + B :] P.sort(rev...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): X, Y, A, B, C = list(map(int, readline().split())) P = list(map(int, readline().split())) Q = list(map(int, readline().spli...
29
29
513
573
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): X, Y, A, B, C, *PQR = list(map(int, read().split())) P = PQR[:A] Q = PQR[A : A + B] R = PQR[A + B :] P.sort(reverse=True) Q.so...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): X, Y, A, B, C = list(map(int, readline().split())) P = list(map(int, readline().split())) Q = list(map(int, readline().split())) R = l...
false
0
[ "- X, Y, A, B, C, *PQR = list(map(int, read().split()))", "- P = PQR[:A]", "- Q = PQR[A : A + B]", "- R = PQR[A + B :]", "+ X, Y, A, B, C = list(map(int, readline().split()))", "+ P = list(map(int, readline().split()))", "+ Q = list(map(int, readline().split()))", "+ R = list(m...
false
0.078385
0.036624
2.140287
[ "s285455095", "s424531344" ]
u533713111
p02969
python
s744971854
s206943146
19
17
3,316
2,940
Accepted
Accepted
10.53
r = int(eval(input())) print((3 * r ** 2))
r = int(eval(input())) print((3 * r * r))
2
2
35
34
r = int(eval(input())) print((3 * r**2))
r = int(eval(input())) print((3 * r * r))
false
0
[ "-print((3 * r**2))", "+print((3 * r * r))" ]
false
0.046779
0.048047
0.973604
[ "s744971854", "s206943146" ]
u084320347
p02946
python
s650986051
s317280452
169
17
38,256
3,060
Accepted
Accepted
89.94
k,x=map(int,input().split()) a=list(range(-k+1,k)) for b in a: print(x+b,"",end="")
k,x = list(map(int,input().split())) l = [] cnt = -(k-1) for i in range(k+k-1): l.append(x+cnt) cnt+=1 for i in l: print(i,end=" ")
6
11
94
156
k, x = map(int, input().split()) a = list(range(-k + 1, k)) for b in a: print(x + b, "", end="")
k, x = list(map(int, input().split())) l = [] cnt = -(k - 1) for i in range(k + k - 1): l.append(x + cnt) cnt += 1 for i in l: print(i, end=" ")
false
45.454545
[ "-k, x = map(int, input().split())", "-a = list(range(-k + 1, k))", "-for b in a:", "- print(x + b, \"\", end=\"\")", "+k, x = list(map(int, input().split()))", "+l = []", "+cnt = -(k - 1)", "+for i in range(k + k - 1):", "+ l.append(x + cnt)", "+ cnt += 1", "+for i in l:", "+ prin...
false
0.07618
0.034595
2.202089
[ "s650986051", "s317280452" ]
u918601425
p03043
python
s440554231
s234474826
109
49
2,940
3,060
Accepted
Accepted
55.05
import math N,K=[int(s) for s in input().split()] a=0 for i in range(N): a+=2**(-max([0,math.ceil(math.log2(K/(i+1)))])) print((a/N))
N,K=[int(s) for s in input().split()] a=0 for i in range(N): x=i+1 n=0 while x<K: n+=1 x*=2 a+=2**(-n) print((a/N))
6
10
138
138
import math N, K = [int(s) for s in input().split()] a = 0 for i in range(N): a += 2 ** (-max([0, math.ceil(math.log2(K / (i + 1)))])) print((a / N))
N, K = [int(s) for s in input().split()] a = 0 for i in range(N): x = i + 1 n = 0 while x < K: n += 1 x *= 2 a += 2 ** (-n) print((a / N))
false
40
[ "-import math", "-", "- a += 2 ** (-max([0, math.ceil(math.log2(K / (i + 1)))]))", "+ x = i + 1", "+ n = 0", "+ while x < K:", "+ n += 1", "+ x *= 2", "+ a += 2 ** (-n)" ]
false
0.17448
0.057405
3.039432
[ "s440554231", "s234474826" ]
u903005414
p03370
python
s211703548
s725013593
30
26
9,116
9,004
Accepted
Accepted
13.33
N, X = list(map(int, input().split())) M = sorted([int(eval(input())) for _ in range(N)]) if X >= sum(M): min_M = min(M) ans = (X - sum(M)) // min_M + N else: current = 0 for i, m in enumerate(M, start=1): current += m if current > X: ans = i print(ans)
N, X = list(map(int, input().split())) M = sorted([int(eval(input())) for _ in range(N)]) ans = (X - sum(M)) // min(M) + N print(ans)
13
4
299
125
N, X = list(map(int, input().split())) M = sorted([int(eval(input())) for _ in range(N)]) if X >= sum(M): min_M = min(M) ans = (X - sum(M)) // min_M + N else: current = 0 for i, m in enumerate(M, start=1): current += m if current > X: ans = i print(ans)
N, X = list(map(int, input().split())) M = sorted([int(eval(input())) for _ in range(N)]) ans = (X - sum(M)) // min(M) + N print(ans)
false
69.230769
[ "-if X >= sum(M):", "- min_M = min(M)", "- ans = (X - sum(M)) // min_M + N", "-else:", "- current = 0", "- for i, m in enumerate(M, start=1):", "- current += m", "- if current > X:", "- ans = i", "+ans = (X - sum(M)) // min(M) + N" ]
false
0.037293
0.041638
0.895656
[ "s211703548", "s725013593" ]
u075012704
p03253
python
s646068980
s844747775
28
24
3,444
3,444
Accepted
Accepted
14.29
from collections import Counter from itertools import combinations_with_replacement N, M = list(map(int, input().split())) mod = 10 ** 9 + 7 # 重複組み合わせ def nHk(n, k): value = 1 nk = n + k - 1 k = min(nk-k, k) for i in range(k): value = (value * nk) % mod nk -= 1 for x in...
from collections import Counter N, M = list(map(int, input().split())) mod = 10 ** 9 + 7 # 素因数分解 def prime_factorization(n): table = [] for x in range(2, int(n ** 0.5) + 1): while n % x == 0: table.append(x) n //= x if n > 1: table.append(n) return...
37
39
760
720
from collections import Counter from itertools import combinations_with_replacement N, M = list(map(int, input().split())) mod = 10**9 + 7 # 重複組み合わせ def nHk(n, k): value = 1 nk = n + k - 1 k = min(nk - k, k) for i in range(k): value = (value * nk) % mod nk -= 1 for x in range(1, k +...
from collections import Counter N, M = list(map(int, input().split())) mod = 10**9 + 7 # 素因数分解 def prime_factorization(n): table = [] for x in range(2, int(n**0.5) + 1): while n % x == 0: table.append(x) n //= x if n > 1: table.append(n) return table # 重複組み合わせ ...
false
5.128205
[ "-from itertools import combinations_with_replacement", "+# 素因数分解", "+def prime_factorization(n):", "+ table = []", "+ for x in range(2, int(n**0.5) + 1):", "+ while n % x == 0:", "+ table.append(x)", "+ n //= x", "+ if n > 1:", "+ table.append(n)", "...
false
0.04609
0.123877
0.372066
[ "s646068980", "s844747775" ]
u150984829
p00076
python
s921499806
s341604292
30
20
5,636
5,628
Accepted
Accepted
33.33
import sys for e in sys.stdin: n=int(e) if n<0:break z=1 for _ in range(n-1): d=z*1j d/=abs(d) z+=d print(f'{z.real}\n{z.imag}')
import sys for e in sys.stdin: n=int(e) if n<0:break z=1 for _ in range(n-1): d=z*1j d/=abs(d) z+=d print((z.real)) print((z.imag))
10
11
149
150
import sys for e in sys.stdin: n = int(e) if n < 0: break z = 1 for _ in range(n - 1): d = z * 1j d /= abs(d) z += d print(f"{z.real}\n{z.imag}")
import sys for e in sys.stdin: n = int(e) if n < 0: break z = 1 for _ in range(n - 1): d = z * 1j d /= abs(d) z += d print((z.real)) print((z.imag))
false
9.090909
[ "- print(f\"{z.real}\\n{z.imag}\")", "+ print((z.real))", "+ print((z.imag))" ]
false
0.074735
0.046188
1.618055
[ "s921499806", "s341604292" ]
u577415482
p02678
python
s762545482
s332646188
922
842
34,860
34,860
Accepted
Accepted
8.68
from collections import deque N,M = list(map(int, input().split())) root = [[] for _ in range(N)] for _ in range(M): a,b = list(map(int,input().split())) root[a - 1].append(b) root[b - 1].append(a) q = deque() q.append(1) ans = [0 for _ in range(N)] while len(q) > 0: v = q.popleft() for ike in...
from collections import deque N,M = list(map(int, input().split())) root = [[] for _ in range(N)] for _ in range(M): a,b = list(map(int,input().split())) root[a - 1].append(b) root[b - 1].append(a) q = deque() q.append(1) ans = [0]*N while len(q) > 0: v = q.popleft() for ike in root[v - 1]: ...
26
26
454
438
from collections import deque N, M = list(map(int, input().split())) root = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) root[a - 1].append(b) root[b - 1].append(a) q = deque() q.append(1) ans = [0 for _ in range(N)] while len(q) > 0: v = q.popleft() for ike in r...
from collections import deque N, M = list(map(int, input().split())) root = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) root[a - 1].append(b) root[b - 1].append(a) q = deque() q.append(1) ans = [0] * N while len(q) > 0: v = q.popleft() for ike in root[v - 1]: ...
false
0
[ "-ans = [0 for _ in range(N)]", "+ans = [0] * N" ]
false
0.037439
0.036234
1.033269
[ "s762545482", "s332646188" ]
u875291233
p02625
python
s625140458
s077423326
898
356
68,144
28,560
Accepted
Accepted
60.36
SIZE=5*10**5; MOD=10**9+7 #998244353 #ここを変更する SIZE += 1 inv = [0]*SIZE # inv[j] = j^{-1} mod MOD fac = [0]*SIZE # fac[j] = j! mod MOD finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 for i in range(2,SIZE): fac[i] = fac[i-1]*i%MOD finv[-1] = pow(fac[-1],MOD-2,MOD)...
# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n,m = list(map(int,readline().split())) """ 漸化式は f(m,n) = (m-1)f(m-1,n-1) + (n-1)f(m-2,n-2) 初期条件 f(m-n,0)=1, f(m-n+1,1)=m-n """ MOD = 10**9+7 res = [0]*(n+1) res[0] = 1 res[1] = m-n for i in range(2,n+1): ...
44
26
896
481
SIZE = 5 * 10**5 MOD = 10**9 + 7 # 998244353 #ここを変更する SIZE += 1 inv = [0] * SIZE # inv[j] = j^{-1} mod MOD fac = [0] * SIZE # fac[j] = j! mod MOD finv = [0] * SIZE # finv[j] = (j!)^{-1} mod MOD fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 for i in range(2, SIZE): fac[i] = fac[i - 1] * i % MOD finv[-1] = pow(fac[-1...
# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n, m = list(map(int, readline().split())) """ 漸化式は f(m,n) = (m-1)f(m-1,n-1) + (n-1)f(m-2,n-2) 初期条件 f(m-n,0)=1, f(m-n+1,1)=m-n """ MOD = 10**9 + 7 res = [0] * (n + 1) res[0] = 1 res[1] = m - n for i in range(2, n + 1): ...
false
40.909091
[ "-SIZE = 5 * 10**5", "-MOD = 10**9 + 7 # 998244353 #ここを変更する", "-SIZE += 1", "-inv = [0] * SIZE # inv[j] = j^{-1} mod MOD", "-fac = [0] * SIZE # fac[j] = j! mod MOD", "-finv = [0] * SIZE # finv[j] = (j!)^{-1} mod MOD", "-fac[0] = fac[1] = 1", "-finv[0] = finv[1] = 1", "-for i in range(2, SIZE):",...
false
0.957659
0.187835
5.098402
[ "s625140458", "s077423326" ]
u835534360
p03161
python
s467011612
s684557878
516
225
92,684
92,780
Accepted
Accepted
56.4
import sys def main(): INF=sys.maxsize N,K=tuple(map(int,sys.stdin.readline().split())) h=tuple(map(int,sys.stdin.readline().split())) dp=[INF for _ in range(N)] dp[0]=0 for i in range(N-1): for j in range(1,K+1): if i+j<N:dp[i+j]=min([dp[i+j],dp[i]+abs(h[i+j]-h[i])]...
import sys def main(): INF=sys.maxsize N,K=tuple(map(int,sys.stdin.readline().split())) h=tuple(map(int,sys.stdin.readline().split())) dp=[INF for _ in range(N)] dp[0]=0 for i in range(1,N): for j in range(1,K+1): if i-j>=0: dij=dp[i-j]+abs(h[i]-h[i-...
12
14
373
417
import sys def main(): INF = sys.maxsize N, K = tuple(map(int, sys.stdin.readline().split())) h = tuple(map(int, sys.stdin.readline().split())) dp = [INF for _ in range(N)] dp[0] = 0 for i in range(N - 1): for j in range(1, K + 1): if i + j < N: dp[i + j] = ...
import sys def main(): INF = sys.maxsize N, K = tuple(map(int, sys.stdin.readline().split())) h = tuple(map(int, sys.stdin.readline().split())) dp = [INF for _ in range(N)] dp[0] = 0 for i in range(1, N): for j in range(1, K + 1): if i - j >= 0: dij = dp[i -...
false
14.285714
[ "- for i in range(N - 1):", "+ for i in range(1, N):", "- if i + j < N:", "- dp[i + j] = min([dp[i + j], dp[i] + abs(h[i + j] - h[i])])", "+ if i - j >= 0:", "+ dij = dp[i - j] + abs(h[i] - h[i - j])", "+ if dij < dp[i]:", "+ ...
false
0.039925
0.076056
0.524943
[ "s467011612", "s684557878" ]
u197955752
p02713
python
s871084152
s876046185
1,306
515
9,180
9,208
Accepted
Accepted
60.57
import math K = int(eval(input())) ans = 0 for a in range(1, K + 1): for b in range(1, K + 1): d = math.gcd(a, b) for c in range(1, K + 1): ans += math.gcd(d, c) print(ans)
import math K = int(eval(input())) ans = 0 for a in range(1, K + 1): for b in range(a, K + 1): ab = math.gcd(a, b) for c in range(b, K + 1): abc = math.gcd(ab, c) if a == b == c: m = 1 elif a == b or b == c or c == a: ...
11
19
210
404
import math K = int(eval(input())) ans = 0 for a in range(1, K + 1): for b in range(1, K + 1): d = math.gcd(a, b) for c in range(1, K + 1): ans += math.gcd(d, c) print(ans)
import math K = int(eval(input())) ans = 0 for a in range(1, K + 1): for b in range(a, K + 1): ab = math.gcd(a, b) for c in range(b, K + 1): abc = math.gcd(ab, c) if a == b == c: m = 1 elif a == b or b == c or c == a: m = 3 ...
false
42.105263
[ "- for b in range(1, K + 1):", "- d = math.gcd(a, b)", "- for c in range(1, K + 1):", "- ans += math.gcd(d, c)", "+ for b in range(a, K + 1):", "+ ab = math.gcd(a, b)", "+ for c in range(b, K + 1):", "+ abc = math.gcd(ab, c)", "+ if ...
false
0.130506
0.067808
1.924637
[ "s871084152", "s876046185" ]
u026788530
p02685
python
s825227000
s735250100
1,965
1,563
32,672
26,324
Accepted
Accepted
20.46
MOD = 10000000007 lim = 200000 MOD = 998244353 inv_t = [-1 for i in range(lim+1)] factrial = [-1 for i in range(lim+1)] factrial_inv = [-1 for i in range(lim+1)] def set_inv(max=lim): inv_t[0] = 0 for i in range(1, max): if inv_t[i] == -1: _ = mod_inv(i) inv_t[i]...
MOD = 998244353 lim = 200000 inv_t = [-1 for i in range(lim+1)] factrial = [-1 for i in range(lim+1)] factrial_inv = [-1 for i in range(lim+1)] def set_inv(max=lim): inv_t[0] = 0 for i in range(1, max): inv_t[i] == mod_inv(i) def mod_inv(x, mod=MOD): y, u, v, _x = mod, 1, 0, x ...
66
61
1,296
1,203
MOD = 10000000007 lim = 200000 MOD = 998244353 inv_t = [-1 for i in range(lim + 1)] factrial = [-1 for i in range(lim + 1)] factrial_inv = [-1 for i in range(lim + 1)] def set_inv(max=lim): inv_t[0] = 0 for i in range(1, max): if inv_t[i] == -1: _ = mod_inv(i) inv_t[i] = _ de...
MOD = 998244353 lim = 200000 inv_t = [-1 for i in range(lim + 1)] factrial = [-1 for i in range(lim + 1)] factrial_inv = [-1 for i in range(lim + 1)] def set_inv(max=lim): inv_t[0] = 0 for i in range(1, max): inv_t[i] == mod_inv(i) def mod_inv(x, mod=MOD): y, u, v, _x = mod, 1, 0, x while y:...
false
7.575758
[ "-MOD = 10000000007", "+MOD = 998244353", "-MOD = 998244353", "- if inv_t[i] == -1:", "- _ = mod_inv(i)", "- inv_t[i] = _", "+ inv_t[i] == mod_inv(i)", "- if factrial == -1:", "+ if factrial[0] == -1:", "- return (factrial[a] * factrial_inv[b] * factria...
false
2.052804
1.047779
1.959196
[ "s825227000", "s735250100" ]
u606045429
p03297
python
s578857468
s154514849
41
20
5,472
3,064
Accepted
Accepted
51.22
from fractions import gcd T = int(eval(input())) for _ in range(T): a, b, c, d = list(map(int, input().split())) if a < b or d < b: flag = False elif c >= b - 1: flag = True else: g = gcd(b, d) flag = (b + a % g - g) <= c if flag: print("Y...
def gcd(a, b): return a if b == 0 else gcd(b, a % b) T = int(eval(input())) for _ in range(T): a, b, c, d = list(map(int, input().split())) if a < b or d < b: flag = False elif c >= b - 1: flag = True else: g = gcd(b, d) flag = (b + a % g - g) <= c ...
19
20
345
376
from fractions import gcd T = int(eval(input())) for _ in range(T): a, b, c, d = list(map(int, input().split())) if a < b or d < b: flag = False elif c >= b - 1: flag = True else: g = gcd(b, d) flag = (b + a % g - g) <= c if flag: print("Yes") else: ...
def gcd(a, b): return a if b == 0 else gcd(b, a % b) T = int(eval(input())) for _ in range(T): a, b, c, d = list(map(int, input().split())) if a < b or d < b: flag = False elif c >= b - 1: flag = True else: g = gcd(b, d) flag = (b + a % g - g) <= c if flag: ...
false
5
[ "-from fractions import gcd", "+def gcd(a, b):", "+ return a if b == 0 else gcd(b, a % b)", "+" ]
false
0.043826
0.036388
1.204421
[ "s578857468", "s154514849" ]
u533039576
p02913
python
s955930290
s289417136
694
407
49,244
42,204
Accepted
Accepted
41.35
def z_algorithm(s): n = len(s) z = [0] * n z[0] = n i = 1 lcp = 0 while i < n: while i+lcp < n and s[i+lcp] == s[lcp]: lcp += 1 z[i] = lcp if lcp == 0: i += 1 continue k = 1 while i+k < n and k+z[k] <...
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1, n): cnt = 0 for j in range(n-i): if s[i+j] == s[j]: cnt += 1 else: ans = max(ans, min(cnt, i)) cnt = 0 ans = max(ans, min(cnt, i)) print(ans)
37
15
600
277
def z_algorithm(s): n = len(s) z = [0] * n z[0] = n i = 1 lcp = 0 while i < n: while i + lcp < n and s[i + lcp] == s[lcp]: lcp += 1 z[i] = lcp if lcp == 0: i += 1 continue k = 1 while i + k < n and k + z[k] < lcp: ...
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1, n): cnt = 0 for j in range(n - i): if s[i + j] == s[j]: cnt += 1 else: ans = max(ans, min(cnt, i)) cnt = 0 ans = max(ans, min(cnt, i)) print(ans)
false
59.459459
[ "-def z_algorithm(s):", "- n = len(s)", "- z = [0] * n", "- z[0] = n", "- i = 1", "- lcp = 0", "- while i < n:", "- while i + lcp < n and s[i + lcp] == s[lcp]:", "- lcp += 1", "- z[i] = lcp", "- if lcp == 0:", "- i += 1", "- ...
false
0.036625
0.038311
0.955984
[ "s955930290", "s289417136" ]
u200916944
p02861
python
s316338225
s220458831
324
273
14,376
9,408
Accepted
Accepted
15.74
N = int(eval(input())) XYS = [list(map(int, input().split())) for _ in range(N)] s = 0 def perm(ns): acc = [] def fill(ms, remains): if remains: for m in remains: fill(ms + [m], [x for x in remains if x != m]) else: acc.append(ms) fill([], n...
from itertools import permutations as perm N = int(eval(input())) XYS = [list(map(int, input().split())) for _ in range(N)] s = 0 for indexes in perm(list(range(N))): xys = [XYS[i] for i in indexes] x0, y0 = xys[0] for x1, y1 in xys: s += ((x0 - x1)**2 + (y0 - y1)**2) ** 0.5 x0 = ...
29
19
622
409
N = int(eval(input())) XYS = [list(map(int, input().split())) for _ in range(N)] s = 0 def perm(ns): acc = [] def fill(ms, remains): if remains: for m in remains: fill(ms + [m], [x for x in remains if x != m]) else: acc.append(ms) fill([], ns) ...
from itertools import permutations as perm N = int(eval(input())) XYS = [list(map(int, input().split())) for _ in range(N)] s = 0 for indexes in perm(list(range(N))): xys = [XYS[i] for i in indexes] x0, y0 = xys[0] for x1, y1 in xys: s += ((x0 - x1) ** 2 + (y0 - y1) ** 2) ** 0.5 x0 = x1 ...
false
34.482759
[ "+from itertools import permutations as perm", "+", "-s = 0", "-", "-", "-def perm(ns):", "- acc = []", "-", "- def fill(ms, remains):", "- if remains:", "- for m in remains:", "- fill(ms + [m], [x for x in remains if x != m])", "- else:", "- ...
false
0.091496
0.006827
13.401497
[ "s316338225", "s220458831" ]
u130900604
p02832
python
s820179351
s125862290
158
113
26,012
24,900
Accepted
Accepted
28.48
n=int(eval(input())) a=list(map(int,input().split())) cnt=0 #n=200000 if 1 not in a: print((-1));exit() from collections import* b=deque(a) #print(b) i=1 while True: if len(b)==0: break if b[0]==i: cnt+=0 b.popleft() i+=1 else: cnt+=1 b.popleft() #print(b,cnt) ...
from collections import* n,*a=list(map(int,open(0).read().split())) def main(): if 1 not in a: print((-1));exit() b=deque(a) #print(b) i=1 cnt=0 while True: if len(b)==0: break if b[0]!=i: cnt+=1 b.popleft() else:#b[0]==i cnt+=0 ...
23
34
327
388
n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 # n=200000 if 1 not in a: print((-1)) exit() from collections import * b = deque(a) # print(b) i = 1 while True: if len(b) == 0: break if b[0] == i: cnt += 0 b.popleft() i += 1 else: cnt += 1 ...
from collections import * n, *a = list(map(int, open(0).read().split())) def main(): if 1 not in a: print((-1)) exit() b = deque(a) # print(b) i = 1 cnt = 0 while True: if len(b) == 0: break if b[0] != i: cnt += 1 b.popleft()...
false
32.352941
[ "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "-cnt = 0", "-# n=200000", "-if 1 not in a:", "- print((-1))", "- exit()", "-b = deque(a)", "-# print(b)", "-i = 1", "-while True:", "- if len(b) == 0:", "- break", "- if b[0] == i:", "- cnt += 0...
false
0.081713
0.085115
0.960026
[ "s820179351", "s125862290" ]
u145950990
p02996
python
s388078214
s150165657
940
589
53,728
112,688
Accepted
Accepted
37.34
n = int(eval(input())) d = [list(map(int,input().split())) for i in range(n)] d.sort(key=lambda x: x[1]) ans = 'Yes' t = 0 for i in d: t += i[0] if t>i[1]:ans='No' print(ans)
n = int(eval(input())) from bisect import bisect ab = [list(map(int,input().split())) for i in range(n)] ab.sort(key = lambda x: x[1]) ok = True last = 0 for a,b in ab: if b-a>=last: last += a else: ok = not ok break print(('Yes' if ok else 'No'))
9
14
184
286
n = int(eval(input())) d = [list(map(int, input().split())) for i in range(n)] d.sort(key=lambda x: x[1]) ans = "Yes" t = 0 for i in d: t += i[0] if t > i[1]: ans = "No" print(ans)
n = int(eval(input())) from bisect import bisect ab = [list(map(int, input().split())) for i in range(n)] ab.sort(key=lambda x: x[1]) ok = True last = 0 for a, b in ab: if b - a >= last: last += a else: ok = not ok break print(("Yes" if ok else "No"))
false
35.714286
[ "-d = [list(map(int, input().split())) for i in range(n)]", "-d.sort(key=lambda x: x[1])", "-ans = \"Yes\"", "-t = 0", "-for i in d:", "- t += i[0]", "- if t > i[1]:", "- ans = \"No\"", "-print(ans)", "+from bisect import bisect", "+", "+ab = [list(map(int, input().split())) for i...
false
0.042335
0.0372
1.138044
[ "s388078214", "s150165657" ]
u282676559
p03545
python
s456240074
s076815411
20
17
3,060
3,060
Accepted
Accepted
15
A = eval(input()) for i in range(8): B = format(i, '03b').replace('0','-').replace('1','+') ans = ''.join([a+b for b,a in zip(B,A)]) + A[-1] if eval(ans) == 7: print((ans+'=7')) exit()
A = eval(input()) for i in range(8): B = format(i, '03b').replace('0','+').replace('1','-') ans = ''.join([a+b for b,a in zip(B,A)]) + A[-1] if eval(ans) == 7: print((ans+'=7')) exit()
7
7
196
196
A = eval(input()) for i in range(8): B = format(i, "03b").replace("0", "-").replace("1", "+") ans = "".join([a + b for b, a in zip(B, A)]) + A[-1] if eval(ans) == 7: print((ans + "=7")) exit()
A = eval(input()) for i in range(8): B = format(i, "03b").replace("0", "+").replace("1", "-") ans = "".join([a + b for b, a in zip(B, A)]) + A[-1] if eval(ans) == 7: print((ans + "=7")) exit()
false
0
[ "- B = format(i, \"03b\").replace(\"0\", \"-\").replace(\"1\", \"+\")", "+ B = format(i, \"03b\").replace(\"0\", \"+\").replace(\"1\", \"-\")" ]
false
0.072286
0.074137
0.975026
[ "s456240074", "s076815411" ]
u017810624
p02720
python
s315669496
s360679608
377
289
78,092
65,500
Accepted
Accepted
23.34
k=int(eval(input())) l=[] for i1 in range(10): l.append(i1) for i2 in range(max(i1-1,0),min(i1+2,10)): l.append(i1*(10**1)+i2) for i3 in range(max(i2-1,0),min(i2+2,10)): l.append(i1*(10**2)+i2*(10**1)+i3) for i4 in range(max(i3-1,0),min(i3+2,10)): l.append(i1*(10**3)+i2*(10**2)+...
import copy k=int(eval(input())) ans=[[str(i+1) for i in range(9)]] l2=[] for i in range(9): l=ans[-1] l2=[] for j in range(len(l)): if int(l[j][-1])!=0: l2.append(l[j]+str(int(l[j][-1])-1)) l2.append(l[j]+str(int(l[j][-1]))) if int(l[j][-1])!=9: l2.append(l[j]+str(int(l[j][-1]...
26
19
1,316
412
k = int(eval(input())) l = [] for i1 in range(10): l.append(i1) for i2 in range(max(i1 - 1, 0), min(i1 + 2, 10)): l.append(i1 * (10**1) + i2) for i3 in range(max(i2 - 1, 0), min(i2 + 2, 10)): l.append(i1 * (10**2) + i2 * (10**1) + i3) for i4 in range(max(i3 - 1, 0), min(i...
import copy k = int(eval(input())) ans = [[str(i + 1) for i in range(9)]] l2 = [] for i in range(9): l = ans[-1] l2 = [] for j in range(len(l)): if int(l[j][-1]) != 0: l2.append(l[j] + str(int(l[j][-1]) - 1)) l2.append(l[j] + str(int(l[j][-1]))) if int(l[j][-1]) != 9: ...
false
26.923077
[ "+import copy", "+", "-l = []", "-for i1 in range(10):", "- l.append(i1)", "- for i2 in range(max(i1 - 1, 0), min(i1 + 2, 10)):", "- l.append(i1 * (10**1) + i2)", "- for i3 in range(max(i2 - 1, 0), min(i2 + 2, 10)):", "- l.append(i1 * (10**2) + i2 * (10**1) + i3)", "...
false
0.007743
0.340352
0.022751
[ "s315669496", "s360679608" ]
u243714267
p02691
python
s703782309
s351112832
314
265
32,244
32,284
Accepted
Accepted
15.61
n = int(eval(input())) a = list(map(int, input().split())) fromLeft = [-1]*n for i in range(n): fromLeft[i] = a[i] - i ans = 0 ldList = [0]*(n*2+5) for i in reversed(list(range(n))): if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5: ldList[fromLeft[i]+n+1] += 1 if 0 <= -1*a[i]...
n = int(eval(input())) a = list(map(int, input().split())) fromLeftA = [-1]*n for i in range(n): fromLeftA[i] = a[i] - i ans = 0 ldList = [0]*(n*2) for i in reversed(list(range(n))): if 0 <= fromLeftA[i]+n and fromLeftA[i]+n < n*2: ldList[fromLeftA[i]+n] += 1 if 0 <= -1*a[i]-i+n an...
19
18
393
378
n = int(eval(input())) a = list(map(int, input().split())) fromLeft = [-1] * n for i in range(n): fromLeft[i] = a[i] - i ans = 0 ldList = [0] * (n * 2 + 5) for i in reversed(list(range(n))): if 0 <= fromLeft[i] + n + 1 and fromLeft[i] + n + 1 < n * 2 + 5: ldList[fromLeft[i] + n + 1] += 1 if 0 <= -1 ...
n = int(eval(input())) a = list(map(int, input().split())) fromLeftA = [-1] * n for i in range(n): fromLeftA[i] = a[i] - i ans = 0 ldList = [0] * (n * 2) for i in reversed(list(range(n))): if 0 <= fromLeftA[i] + n and fromLeftA[i] + n < n * 2: ldList[fromLeftA[i] + n] += 1 if 0 <= -1 * a[i] - i + n ...
false
5.263158
[ "-fromLeft = [-1] * n", "+fromLeftA = [-1] * n", "- fromLeft[i] = a[i] - i", "+ fromLeftA[i] = a[i] - i", "-ldList = [0] * (n * 2 + 5)", "+ldList = [0] * (n * 2)", "- if 0 <= fromLeft[i] + n + 1 and fromLeft[i] + n + 1 < n * 2 + 5:", "- ldList[fromLeft[i] + n + 1] += 1", "- if 0 <...
false
0.121035
0.051473
2.351438
[ "s703782309", "s351112832" ]
u018679195
p03264
python
s543546618
s972446675
19
17
3,188
3,064
Accepted
Accepted
10.53
n=int(eval(input())) even=[] odd=[] for i in range (1,n+1,1): if i%2==0: even.append(i) else: odd.append(i) result=[(x,y) for x in even for y in odd] print((len(result)))
#hemasaidthatispair k=int(eval(input())) z=k**2//4 print(z)
10
4
195
56
n = int(eval(input())) even = [] odd = [] for i in range(1, n + 1, 1): if i % 2 == 0: even.append(i) else: odd.append(i) result = [(x, y) for x in even for y in odd] print((len(result)))
# hemasaidthatispair k = int(eval(input())) z = k**2 // 4 print(z)
false
60
[ "-n = int(eval(input()))", "-even = []", "-odd = []", "-for i in range(1, n + 1, 1):", "- if i % 2 == 0:", "- even.append(i)", "- else:", "- odd.append(i)", "-result = [(x, y) for x in even for y in odd]", "-print((len(result)))", "+# hemasaidthatispair", "+k = int(eval(inp...
false
0.052501
0.050697
1.035584
[ "s543546618", "s972446675" ]
u571969099
p03371
python
s280321600
s392779179
228
209
3,060
3,060
Accepted
Accepted
8.33
a, b, c, x, y = [int(i) for i in input().split()] ans = 10**18 for i in range(max(x, y)*2 + 1): ans = min(ans, c * i + max(0,(x - i//2)) * a + max(0,(y - i//2)) * b) print(ans)
a, b, c, x, y = list(map(int, input().split())) ans = 10 ** 18 for i in range(10 ** 5 * 2): ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b) print(ans)
5
5
185
171
a, b, c, x, y = [int(i) for i in input().split()] ans = 10**18 for i in range(max(x, y) * 2 + 1): ans = min(ans, c * i + max(0, (x - i // 2)) * a + max(0, (y - i // 2)) * b) print(ans)
a, b, c, x, y = list(map(int, input().split())) ans = 10**18 for i in range(10**5 * 2): ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b) print(ans)
false
0
[ "-a, b, c, x, y = [int(i) for i in input().split()]", "+a, b, c, x, y = list(map(int, input().split()))", "-for i in range(max(x, y) * 2 + 1):", "- ans = min(ans, c * i + max(0, (x - i // 2)) * a + max(0, (y - i // 2)) * b)", "+for i in range(10**5 * 2):", "+ ans = min(ans, i * 2 * c + max(0, x - i)...
false
0.112095
0.419245
0.267374
[ "s280321600", "s392779179" ]
u152417130
p02537
python
s306600743
s422905535
1,385
520
140,164
94,712
Accepted
Accepted
62.45
class LazySegmentTree: def __init__(self, data, default=0, func=max): """initialize the lazy segment tree with data""" self._default = default self._func = func self._len = len(data) self._size = _size = 1 << (self._len - 1).bit_length() self._lazy = [0] * (2...
class SegmentTree: def __init__(self, data, default=0, func=max): """initialize the segment tree with data""" self._default = default self._func = func self._len = len(data) self._size = _size = 1 << (self._len - 1).bit_length() self.data = [default] * (2 * _...
99
61
3,351
1,836
class LazySegmentTree: def __init__(self, data, default=0, func=max): """initialize the lazy segment tree with data""" self._default = default self._func = func self._len = len(data) self._size = _size = 1 << (self._len - 1).bit_length() self._lazy = [0] * (2 * _size)...
class SegmentTree: def __init__(self, data, default=0, func=max): """initialize the segment tree with data""" self._default = default self._func = func self._len = len(data) self._size = _size = 1 << (self._len - 1).bit_length() self.data = [default] * (2 * _size) ...
false
38.383838
[ "-class LazySegmentTree:", "+class SegmentTree:", "- \"\"\"initialize the lazy segment tree with data\"\"\"", "+ \"\"\"initialize the segment tree with data\"\"\"", "- self._lazy = [0] * (2 * _size)", "+ def __delitem__(self, idx):", "+ self[idx] = self._default", "+", ...
false
2.077542
1.049005
1.980487
[ "s306600743", "s422905535" ]
u997648604
p02720
python
s320392777
s678204350
175
151
46,064
77,288
Accepted
Accepted
13.71
import sys sys.setrecursionlimit(10**9) def main(): K = int(eval(input())) if 0<=K<=10: print(K) exit() lunlun = [i for i in range(1,10)] m = 0 while len(lunlun) < K: x = lunlun[m] btm = x % 10 if btm - 1 >= 0: lunlun.append(10...
import sys sys.setrecursionlimit(10**9) def mi(): return list(map(int,input().split())) def ii(): return int(eval(input())) def isp(): return input().split() def deb(text): print(("-------\n{}\n-------".format(text))) INF=10**20 def main(): K=ii() L=list(range(10)) if K <= 9: print(...
30
40
526
833
import sys sys.setrecursionlimit(10**9) def main(): K = int(eval(input())) if 0 <= K <= 10: print(K) exit() lunlun = [i for i in range(1, 10)] m = 0 while len(lunlun) < K: x = lunlun[m] btm = x % 10 if btm - 1 >= 0: lunlun.append(10 * x + btm - ...
import sys sys.setrecursionlimit(10**9) def mi(): return list(map(int, input().split())) def ii(): return int(eval(input())) def isp(): return input().split() def deb(text): print(("-------\n{}\n-------".format(text))) INF = 10**20 def main(): K = ii() L = list(range(10)) if K <...
false
25
[ "+def mi():", "+ return list(map(int, input().split()))", "+", "+", "+def ii():", "+ return int(eval(input()))", "+", "+", "+def isp():", "+ return input().split()", "+", "+", "+def deb(text):", "+", "+", "+INF = 10**20", "+", "+", "- K = int(eval(input()))", "- ...
false
0.045945
0.091999
0.499406
[ "s320392777", "s678204350" ]
u691018832
p03607
python
s889534537
s891755913
136
82
21,356
16,612
Accepted
Accepted
39.71
import collections import sys input = sys.stdin.readline n = int(eval(input())) a = [0]*n ans = 0 for i in range(n): a[i] = int(eval(input())) count_a = collections.Counter(a).most_common() for i in range(len(count_a)): if count_a[i][1]%2 != 0: ans += 1 print(ans)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from collections import Counter n = int(readline()) a = [int(readline()) for _ in range(n)] ans = 0 for v in list(Counter(a).values()): ans += 1 if v % 2 =...
14
14
282
337
import collections import sys input = sys.stdin.readline n = int(eval(input())) a = [0] * n ans = 0 for i in range(n): a[i] = int(eval(input())) count_a = collections.Counter(a).most_common() for i in range(len(count_a)): if count_a[i][1] % 2 != 0: ans += 1 print(ans)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) from collections import Counter n = int(readline()) a = [int(readline()) for _ in range(n)] ans = 0 for v in list(Counter(a).values()): ans += 1 if v % 2 == 1 else 0 pri...
false
0
[ "-import collections", "-input = sys.stdin.readline", "-n = int(eval(input()))", "-a = [0] * n", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "+sys.setrecursionlimit(10**7)", "+from collections import Counter", "+", "+n = in...
false
0.036287
0.043153
0.840905
[ "s889534537", "s891755913" ]
u086503932
p03013
python
s436104592
s818353211
211
178
13,216
94,516
Accepted
Accepted
15.64
N, M = list(map(int, input().split())) a = set([int(eval(input())) for _ in range(M)]) p = 10**9+7 # F[N+1]: 0 ~ N 段目にたどり着く移動方法の場合の数 F = [None] * (N+1) F[0] = 1 F[1] = 1 for i in range(2, N+1): if i-1 in a: tmp1 = 0 else: tmp1 = F[i-1] if i-2 in a: tmp2 = 0 else: tmp2 = F[...
N, M = list(map(int, input().split())) a = [int(eval(input())) for _ in range(M)] a = set(a) m = 10**9+7 dp = [0] * (N+1) dp[0] = 1 for i in range(N): if i+1 not in a: dp[i+1] = (dp[i+1] + dp[i]) % m if i < N-1 and i+2 not in a: dp[i+2] = (dp[i+2] + dp[i]) % m print((dp[N]))
25
12
430
296
N, M = list(map(int, input().split())) a = set([int(eval(input())) for _ in range(M)]) p = 10**9 + 7 # F[N+1]: 0 ~ N 段目にたどり着く移動方法の場合の数 F = [None] * (N + 1) F[0] = 1 F[1] = 1 for i in range(2, N + 1): if i - 1 in a: tmp1 = 0 else: tmp1 = F[i - 1] if i - 2 in a: tmp2 = 0 else: ...
N, M = list(map(int, input().split())) a = [int(eval(input())) for _ in range(M)] a = set(a) m = 10**9 + 7 dp = [0] * (N + 1) dp[0] = 1 for i in range(N): if i + 1 not in a: dp[i + 1] = (dp[i + 1] + dp[i]) % m if i < N - 1 and i + 2 not in a: dp[i + 2] = (dp[i + 2] + dp[i]) % m print((dp[N]))
false
52
[ "-a = set([int(eval(input())) for _ in range(M)])", "-p = 10**9 + 7", "-# F[N+1]: 0 ~ N 段目にたどり着く移動方法の場合の数", "-F = [None] * (N + 1)", "-F[0] = 1", "-F[1] = 1", "-for i in range(2, N + 1):", "- if i - 1 in a:", "- tmp1 = 0", "- else:", "- tmp1 = F[i - 1]", "- if i - 2 in a...
false
0.036356
0.035041
1.037535
[ "s436104592", "s818353211" ]
u619458041
p02983
python
s327802265
s890129861
625
50
3,060
3,060
Accepted
Accepted
92
import sys def main(): input = sys.stdin.readline L, R = list(map(int, input().split())) R = min(R, L + 2019) ans = 2019 for i in range(L, R): for j in range(i+1, R+1): ans = min(ans, (i*j)%2019) return ans if __name__ == '__main__': print((main()))
import sys def main(): input = sys.stdin.readline L, R = list(map(int, input().split())) R = min(R, L + 2019) ans = 2019 for i in range(L, R): for j in range(i+1, R+1): ans = min(ans, (i*j)%2019) if ans == 0: return 0 return ans ...
17
19
311
363
import sys def main(): input = sys.stdin.readline L, R = list(map(int, input().split())) R = min(R, L + 2019) ans = 2019 for i in range(L, R): for j in range(i + 1, R + 1): ans = min(ans, (i * j) % 2019) return ans if __name__ == "__main__": print((main()))
import sys def main(): input = sys.stdin.readline L, R = list(map(int, input().split())) R = min(R, L + 2019) ans = 2019 for i in range(L, R): for j in range(i + 1, R + 1): ans = min(ans, (i * j) % 2019) if ans == 0: return 0 return ans if __na...
false
10.526316
[ "+ if ans == 0:", "+ return 0" ]
false
0.12976
0.053189
2.439618
[ "s327802265", "s890129861" ]
u461993794
p02689
python
s893405714
s404123167
421
303
93,936
95,224
Accepted
Accepted
28.03
n, m = list(map(int, input().split())) h = list(map(int, input().split())) eg = [[] for _ in range(n + 1)] for _ in range(m): a, b = list(map(int, input().split())) eg[a].append(b) eg[b].append(a) ans = 0 for i in range(1, n + 1): high = True for to in eg[i]: if h[i - 1] <= h[...
n, m = list(map(int, input().split())) h = [0] + list(map(int, input().split())) eg = [[] for _ in range(n + 1)] for _ in range(m): a, b = list(map(int, input().split())) eg[a].append(b) eg[b].append(a) ans = 0 for i in range(1, n + 1): high = True for t in eg[i]: if h[t] >= h[i...
18
18
387
400
n, m = list(map(int, input().split())) h = list(map(int, input().split())) eg = [[] for _ in range(n + 1)] for _ in range(m): a, b = list(map(int, input().split())) eg[a].append(b) eg[b].append(a) ans = 0 for i in range(1, n + 1): high = True for to in eg[i]: if h[i - 1] <= h[to - 1]: ...
n, m = list(map(int, input().split())) h = [0] + list(map(int, input().split())) eg = [[] for _ in range(n + 1)] for _ in range(m): a, b = list(map(int, input().split())) eg[a].append(b) eg[b].append(a) ans = 0 for i in range(1, n + 1): high = True for t in eg[i]: if h[t] >= h[i]: ...
false
0
[ "-h = list(map(int, input().split()))", "+h = [0] + list(map(int, input().split()))", "- for to in eg[i]:", "- if h[i - 1] <= h[to - 1]:", "+ for t in eg[i]:", "+ if h[t] >= h[i]:", "+ break" ]
false
0.098731
0.077462
1.274576
[ "s893405714", "s404123167" ]
u580362735
p03160
python
s218489972
s732737299
223
138
94,100
13,928
Accepted
Accepted
38.12
import sys sys.setrecursionlimit(10**6) N = int(eval(input())) h = list(map(int,input().split())) memo = [-1]*N def calc_cost(i): if memo[i] != -1: return memo[i] if i == 0: return 0 elif i == 1: return abs(h[0]-h[1]) a = calc_cost(i-1)+abs(h[i]-h[i-1]) b = calc_cost(i-2...
N = int(eval(input())) h = list(map(int,input().split())) memo = [0]*N memo[0] = 0 memo[1] = abs(h[0]-h[1]) for i in range(2,N): a = memo[i-1] + abs(h[i]-h[i-1]) b = memo[i-2] + abs(h[i]-h[i-2]) memo[i] = min(a,b) print((memo[N-1]))
24
12
402
243
import sys sys.setrecursionlimit(10**6) N = int(eval(input())) h = list(map(int, input().split())) memo = [-1] * N def calc_cost(i): if memo[i] != -1: return memo[i] if i == 0: return 0 elif i == 1: return abs(h[0] - h[1]) a = calc_cost(i - 1) + abs(h[i] - h[i - 1]) b = ca...
N = int(eval(input())) h = list(map(int, input().split())) memo = [0] * N memo[0] = 0 memo[1] = abs(h[0] - h[1]) for i in range(2, N): a = memo[i - 1] + abs(h[i] - h[i - 1]) b = memo[i - 2] + abs(h[i] - h[i - 2]) memo[i] = min(a, b) print((memo[N - 1]))
false
50
[ "-import sys", "-", "-sys.setrecursionlimit(10**6)", "-memo = [-1] * N", "-", "-", "-def calc_cost(i):", "- if memo[i] != -1:", "- return memo[i]", "- if i == 0:", "- return 0", "- elif i == 1:", "- return abs(h[0] - h[1])", "- a = calc_cost(i - 1) + abs(h[...
false
0.035579
0.054032
0.658472
[ "s218489972", "s732737299" ]
u450983668
p03160
python
s471754693
s913500056
136
120
13,928
13,716
Accepted
Accepted
11.76
# 検証のためのACの人のパクリですごめんなさい N = int(eval(input())) hs = [i for i in map(int, input().split())] INF = 10*12 dp = [INF]*N dp[0] = 0 dp[1] = abs(hs[0]-hs[1]) for i in range(2, N): dp[i] = min(dp[i-1] +abs(hs[i]-hs[i-1]), dp[i-2] +abs(hs[i]-hs[i-2])) print((dp[-1]))
def chmin(a, b): if a > b: return b return a def main(): N = int(eval(input())) hs = [i for i in map(int, input().split())] INF = 1e12 dp = [INF]*N dp[0] = 0 for i in range(1, N): dp[i] = chmin(dp[i], dp[i-1] + abs(hs[i]-hs[i-1])) if i > 1: dp[i] = chmin(dp[i], dp[i-...
12
21
266
406
# 検証のためのACの人のパクリですごめんなさい N = int(eval(input())) hs = [i for i in map(int, input().split())] INF = 10 * 12 dp = [INF] * N dp[0] = 0 dp[1] = abs(hs[0] - hs[1]) for i in range(2, N): dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2])) print((dp[-1]))
def chmin(a, b): if a > b: return b return a def main(): N = int(eval(input())) hs = [i for i in map(int, input().split())] INF = 1e12 dp = [INF] * N dp[0] = 0 for i in range(1, N): dp[i] = chmin(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1])) if i > 1: d...
false
42.857143
[ "-# 検証のためのACの人のパクリですごめんなさい", "-N = int(eval(input()))", "-hs = [i for i in map(int, input().split())]", "-INF = 10 * 12", "-dp = [INF] * N", "-dp[0] = 0", "-dp[1] = abs(hs[0] - hs[1])", "-for i in range(2, N):", "- dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2])...
false
0.115103
0.037186
3.095357
[ "s471754693", "s913500056" ]
u514894322
p02947
python
s482528412
s510731695
334
189
19,400
21,128
Accepted
Accepted
43.41
n = int(eval(input())) sl = [''.join(sorted(eval(input()))) for _ in [0]*n] count = 0 dict = {} for s in sl: if s in dict: count += dict[s] dict[s] += 1 else: dict[s] = 1 print(count)
n,*sl, = [''.join(sorted(x)) for x in open(0).read().split()] count = 0 dict = {} for s in sl: if s in dict: count += dict[s] dict[s] += 1 else: dict[s] = 1 print(count)
11
10
198
198
n = int(eval(input())) sl = ["".join(sorted(eval(input()))) for _ in [0] * n] count = 0 dict = {} for s in sl: if s in dict: count += dict[s] dict[s] += 1 else: dict[s] = 1 print(count)
( n, *sl, ) = ["".join(sorted(x)) for x in open(0).read().split()] count = 0 dict = {} for s in sl: if s in dict: count += dict[s] dict[s] += 1 else: dict[s] = 1 print(count)
false
9.090909
[ "-n = int(eval(input()))", "-sl = [\"\".join(sorted(eval(input()))) for _ in [0] * n]", "+(", "+ n,", "+ *sl,", "+) = [\"\".join(sorted(x)) for x in open(0).read().split()]" ]
false
0.036183
0.031953
1.132398
[ "s482528412", "s510731695" ]
u440566786
p02913
python
s519133303
s349674305
1,674
1,038
53,572
51,164
Accepted
Accepted
37.99
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() class SuffixArray: """ construct: suffix array: O(N(logN)^2) lcp array: O(N) sparse table: O(NlogN) query: get_lcp: O(1) """ def __init_...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() class SuffixArray: """ construct: suffix array: O(N(logN)^2) lcp array: O(N) sparse table: O(NlogN) query: get_lcp: O(1) """ def __init_...
99
99
2,831
2,835
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() class SuffixArray: """ construct: suffix array: O(N(logN)^2) lcp array: O(N) sparse table: O(NlogN) query: get_lcp: O(1) """ def __init__(...
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() class SuffixArray: """ construct: suffix array: O(N(logN)^2) lcp array: O(N) sparse table: O(NlogN) query: get_lcp: O(1) """ def __init__(...
false
0
[ "- for j in range(n):", "+ for j in range(i + 1, n):" ]
false
0.036106
0.049884
0.723793
[ "s519133303", "s349674305" ]
u827202523
p02838
python
s138635366
s291742763
1,172
287
123,592
110,608
Accepted
Accepted
75.51
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) from collections import defaultdict, deque from sys import exit import math import copy from bisect import bisect_left, bisect_right from hea...
import sys from collections import defaultdict, deque, Counter import math # import copy from bisect import bisect_left, bisect_right import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lam...
76
73
1,404
1,401
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) from collections import defaultdict, deque from sys import exit import math import copy from bisect import bisect_left, bisect_right from heapq import * impor...
import sys from collections import defaultdict, deque, Counter import math # import copy from bisect import bisect_left, bisect_right import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lambda: list(map(int...
false
3.947368
[ "-def getN():", "- return int(eval(input()))", "+import sys", "+from collections import defaultdict, deque, Counter", "+import math", "+", "+# import copy", "+from bisect import bisect_left, bisect_right", "+import heapq", "+", "+# sys.setrecursionlimit(1000000)", "+# input aliases", "+in...
false
0.038097
0.036367
1.047584
[ "s138635366", "s291742763" ]
u815763296
p02727
python
s808334110
s220448157
366
186
29,820
29,276
Accepted
Accepted
49.18
import heapq import sys X, Y, A, B, C = list(map(int, input().split())) Av = list(map(int, input().split())) Bv = list(map(int, input().split())) Cv = list(map(int, input().split())) heapq.heapify(Av) heapq.heapify(Bv) heapq.heapify(Cv) for i in range(A-X): heapq.heappop(Av) for i in range(B-Y): hea...
def LI(): return list(map(int, input().split())) X, Y, A, B, C = LI() red = LI() green = LI() mu = LI() red.sort(reverse=True) green.sort(reverse=True) ans = red[:X]+green[:Y]+mu ans.sort(reverse=True) total = 0 for i in range(X+Y): total += ans[i] print(total)
67
16
1,525
287
import heapq import sys X, Y, A, B, C = list(map(int, input().split())) Av = list(map(int, input().split())) Bv = list(map(int, input().split())) Cv = list(map(int, input().split())) heapq.heapify(Av) heapq.heapify(Bv) heapq.heapify(Cv) for i in range(A - X): heapq.heappop(Av) for i in range(B - Y): heapq.heap...
def LI(): return list(map(int, input().split())) X, Y, A, B, C = LI() red = LI() green = LI() mu = LI() red.sort(reverse=True) green.sort(reverse=True) ans = red[:X] + green[:Y] + mu ans.sort(reverse=True) total = 0 for i in range(X + Y): total += ans[i] print(total)
false
76.119403
[ "-import heapq", "-import sys", "+def LI():", "+ return list(map(int, input().split()))", "-X, Y, A, B, C = list(map(int, input().split()))", "-Av = list(map(int, input().split()))", "-Bv = list(map(int, input().split()))", "-Cv = list(map(int, input().split()))", "-heapq.heapify(Av)", "-heapq....
false
0.036734
0.03851
0.953868
[ "s808334110", "s220448157" ]
u301624971
p02947
python
s986517644
s755603164
468
372
20,200
19,500
Accepted
Accepted
20.51
N=int(eval(input())) s=[] cnt=dict() for _ in range(N): tmp=list(eval(input())) sotmp=sorted(tmp) stmp=''.join(sotmp) s.append(stmp) ss=sorted(s) for word in ss: if((word in list(cnt.keys()))==False): cnt[word]=0 else: cnt[word]+=1 total=0 for value in ...
def myAnswer(N:int,S:list) -> int: counter = 0 dic = {} for s in S: if(s in list(dic.keys())): dic[s]+=1 else: dic[s] = 0 for value in list(dic.values()): counter += (value * (value + 1)) // 2 return counter def modelAnswer(): return def main(): N...
25
20
363
446
N = int(eval(input())) s = [] cnt = dict() for _ in range(N): tmp = list(eval(input())) sotmp = sorted(tmp) stmp = "".join(sotmp) s.append(stmp) ss = sorted(s) for word in ss: if (word in list(cnt.keys())) == False: cnt[word] = 0 else: cnt[word] += 1 total = 0 for value in list(c...
def myAnswer(N: int, S: list) -> int: counter = 0 dic = {} for s in S: if s in list(dic.keys()): dic[s] += 1 else: dic[s] = 0 for value in list(dic.values()): counter += (value * (value + 1)) // 2 return counter def modelAnswer(): return def ma...
false
20
[ "-N = int(eval(input()))", "-s = []", "-cnt = dict()", "-for _ in range(N):", "- tmp = list(eval(input()))", "- sotmp = sorted(tmp)", "- stmp = \"\".join(sotmp)", "- s.append(stmp)", "-ss = sorted(s)", "-for word in ss:", "- if (word in list(cnt.keys())) == False:", "- cn...
false
0.060908
0.107708
0.565491
[ "s986517644", "s755603164" ]
u054514819
p02703
python
s236090066
s526658470
1,151
676
177,904
97,040
Accepted
Accepted
41.27
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N, M, S = mapint() S = min(S, N*50) query = [[[] for _ in range(N*50+1)] for _ in range(N)] for _ in range(M): u, v, a, b = mapint() for coin in range(a, N*50+...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N, M, S = mapint() graph = [{} for _ in range(N)] for _ in range(M): u, v, a, t = mapint() graph[u-1][v-1] = (a, t) graph[v-1][u-1] = (a, t) change = [l...
44
32
1,115
1,000
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N, M, S = mapint() S = min(S, N * 50) query = [[[] for _ in range(N * 50 + 1)] for _ in range(N)] for _ in range(M): u, v, a, b = mapint() for coin in range...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N, M, S = mapint() graph = [{} for _ in range(N)] for _ in range(M): u, v, a, t = mapint() graph[u - 1][v - 1] = (a, t) graph[v - 1][u - 1] = (a, t) cha...
false
27.272727
[ "-S = min(S, N * 50)", "-query = [[[] for _ in range(N * 50 + 1)] for _ in range(N)]", "+graph = [{} for _ in range(N)]", "- u, v, a, b = mapint()", "- for coin in range(a, N * 50 + 1):", "- query[u - 1][coin].append((v - 1, a, b))", "- query[v - 1][coin].append((u - 1, a, b))", "-...
false
0.038061
0.183804
0.207073
[ "s236090066", "s526658470" ]
u018679195
p03272
python
s149240920
s170059315
20
18
2,940
2,940
Accepted
Accepted
10
val1,val2=input().split(" ") val3=int(val1)-int(val2)+1 print(val3)
def main(): N, i = list(map(int, input().strip().split())) print((N - i + 1)) if __name__ == "__main__": main()
3
6
69
122
val1, val2 = input().split(" ") val3 = int(val1) - int(val2) + 1 print(val3)
def main(): N, i = list(map(int, input().strip().split())) print((N - i + 1)) if __name__ == "__main__": main()
false
50
[ "-val1, val2 = input().split(\" \")", "-val3 = int(val1) - int(val2) + 1", "-print(val3)", "+def main():", "+ N, i = list(map(int, input().strip().split()))", "+ print((N - i + 1))", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.037074
0.065739
0.563953
[ "s149240920", "s170059315" ]
u048945791
p03339
python
s802334363
s905637690
93
77
5,916
5,928
Accepted
Accepted
17.2
N = int(eval(input())) S = eval(input()) cost = list(S).count("E") ans = 1000000 for si in S: if si == "E": cost -= 1 elif si == "W": if cost < ans: ans = cost cost += 1 else: if cost < ans: ans = cost print(ans)
N = int(eval(input())) S = eval(input()) cost = list(S).count("E") ans = 1000000 for si in S: if si == "E": cost -= 1 else: if cost < ans: ans = cost cost += 1 else: if cost < ans: ans = cost print(ans)
17
17
274
264
N = int(eval(input())) S = eval(input()) cost = list(S).count("E") ans = 1000000 for si in S: if si == "E": cost -= 1 elif si == "W": if cost < ans: ans = cost cost += 1 else: if cost < ans: ans = cost print(ans)
N = int(eval(input())) S = eval(input()) cost = list(S).count("E") ans = 1000000 for si in S: if si == "E": cost -= 1 else: if cost < ans: ans = cost cost += 1 else: if cost < ans: ans = cost print(ans)
false
0
[ "- elif si == \"W\":", "+ else:" ]
false
0.043246
0.108858
0.397268
[ "s802334363", "s905637690" ]
u621935300
p03714
python
s888135886
s226856276
1,041
346
34,208
72,528
Accepted
Accepted
66.76
n=int(eval(input())) import heapq a=list(map(int, input().split())) q=a[:n] heapq.heapify(q) x=[sum(q)] for k in range(n,2*n): v=heapq.heappushpop(q,a[k]) x.append(x[-1]+a[k]-v) a=a[::-1] q=[-v for v in a[:n]] heapq.heapify(q) y=[-sum(q)] for k in range(n,2*n): v=-heapq.heappushpop(q,-a[k]) ...
from heapq import heapify,heappush, heappop N=eval(input()) A=list(map( int, input().split() )) q=A[:N] heapify(q) q_sum=sum(q) B=[ float("-inf") for i in range(3*N)] B[N-1]=q_sum for i in range(N,2*N): x=A[i] if x>q[0]: tmp=heappop(q) q_sum-=tmp q_sum+=x heappush(q,x) B[i]=q_sum q...
17
37
380
547
n = int(eval(input())) import heapq a = list(map(int, input().split())) q = a[:n] heapq.heapify(q) x = [sum(q)] for k in range(n, 2 * n): v = heapq.heappushpop(q, a[k]) x.append(x[-1] + a[k] - v) a = a[::-1] q = [-v for v in a[:n]] heapq.heapify(q) y = [-sum(q)] for k in range(n, 2 * n): v = -heapq.heappus...
from heapq import heapify, heappush, heappop N = eval(input()) A = list(map(int, input().split())) q = A[:N] heapify(q) q_sum = sum(q) B = [float("-inf") for i in range(3 * N)] B[N - 1] = q_sum for i in range(N, 2 * N): x = A[i] if x > q[0]: tmp = heappop(q) q_sum -= tmp q_sum += x ...
false
54.054054
[ "-n = int(eval(input()))", "-import heapq", "+from heapq import heapify, heappush, heappop", "-a = list(map(int, input().split()))", "-q = a[:n]", "-heapq.heapify(q)", "-x = [sum(q)]", "-for k in range(n, 2 * n):", "- v = heapq.heappushpop(q, a[k])", "- x.append(x[-1] + a[k] - v)", "-a = a...
false
0.04332
0.105484
0.410683
[ "s888135886", "s226856276" ]
u499381410
p03700
python
s398252081
s079000735
346
310
46,172
45,404
Accepted
Accepted
10.4
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, ...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys from copy import deepcopy import string from bisect import bisect_left, bisect_right from ma...
48
47
1,304
1,304
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor fro...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys from copy import deepcopy import string from bisect import bisect_left, bisect_right from math import ...
false
2.083333
[ "+from copy import deepcopy", "-INF = float(\"inf\")", "+INF = 10**20", "- return list(map(int, sys.stdin.readline().split()))", "+ return list(map(int, sys.stdin.buffer.readline().split()))", "- return int(sys.stdin.readline())", "+ return int(sys.stdin.buffer.readline())", "- return s...
false
0.041114
0.05019
0.819176
[ "s398252081", "s079000735" ]
u156815136
p03821
python
s224569634
s959062183
387
275
17,120
23,684
Accepted
Accepted
28.94
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] -...
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counte...
47
39
1,071
864
from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j...
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3回 # from collections import deque from collections import deque, defaultdict, Co...
false
17.021277
[ "-from statistics import median", "-", "+# from statistics import median", "-from itertools import combinations # (string,3) 3回", "-from collections import deque", "-from collections import defaultdict", "-import bisect", "+from itertools import combinations, permutations, accumulate # (string,3) 3回...
false
0.124104
0.078645
1.578036
[ "s224569634", "s959062183" ]
u018679195
p02629
python
s697020465
s585832089
362
29
85,032
9,200
Accepted
Accepted
91.99
s = input() n = int(s) def main(n): d = 1 n -= 1 while n - 26**d >= 0: n -= 26**d d += 1 ret = '' for i in range(d): ret += chr((n%26)+ord('a')) n //= 26 return ret[::-1] print(main(n))
a = int(eval(input())) s = [] ret = ['z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ] while a > 0: a -= 1 shang = int(a / 26) yushu = int(a % 26) # print(shang, yushu) s.append(yushu+1) ...
16
19
220
417
s = input() n = int(s) def main(n): d = 1 n -= 1 while n - 26**d >= 0: n -= 26**d d += 1 ret = "" for i in range(d): ret += chr((n % 26) + ord("a")) n //= 26 return ret[::-1] print(main(n))
a = int(eval(input())) s = [] ret = [ "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ] while a > 0: a -= 1 shang = i...
false
15.789474
[ "-s = input()", "-n = int(s)", "-", "-", "-def main(n):", "- d = 1", "- n -= 1", "- while n - 26**d >= 0:", "- n -= 26**d", "- d += 1", "- ret = \"\"", "- for i in range(d):", "- ret += chr((n % 26) + ord(\"a\"))", "- n //= 26", "- return ret...
false
0.055941
0.063207
0.885049
[ "s697020465", "s585832089" ]
u787456042
p02888
python
s338805184
s100054693
1,978
1,498
3,188
3,188
Accepted
Accepted
24.27
from bisect import* N,*L=list(map(int,open(0).read().split()));L.sort() a=0 l=[] r=[] for i in range(1001): l.append(bisect_left(L,i)) r.append(bisect(L,i)) for p in L: for q in L: x=p+q y=abs(p-q) a+=(l[x]if x<1001else N)-(r[y]if 0<y<1001else(y>1000)*N) for p in L: ...
from bisect import* N,*L=list(map(int,open(0).read().split()));L.sort() a=0 for i in range(N): for j in range(i+1,N): a+=bisect_left(L,L[i]+L[j],j+1)-j-1 print(a)
17
7
371
173
from bisect import * N, *L = list(map(int, open(0).read().split())) L.sort() a = 0 l = [] r = [] for i in range(1001): l.append(bisect_left(L, i)) r.append(bisect(L, i)) for p in L: for q in L: x = p + q y = abs(p - q) a += (l[x] if x < 1001 else N) - (r[y] if 0 < y < 1001 else (y >...
from bisect import * N, *L = list(map(int, open(0).read().split())) L.sort() a = 0 for i in range(N): for j in range(i + 1, N): a += bisect_left(L, L[i] + L[j], j + 1) - j - 1 print(a)
false
58.823529
[ "-l = []", "-r = []", "-for i in range(1001):", "- l.append(bisect_left(L, i))", "- r.append(bisect(L, i))", "-for p in L:", "- for q in L:", "- x = p + q", "- y = abs(p - q)", "- a += (l[x] if x < 1001 else N) - (r[y] if 0 < y < 1001 else (y > 1000) * N)", "-for p ...
false
0.041011
0.082904
0.494682
[ "s338805184", "s100054693" ]
u780342333
p02388
python
s309875639
s941075251
30
20
7,644
5,572
Accepted
Accepted
33.33
x = int(eval(input())) print((x ** 3))
n = eval(input()) print(("{}".format(int(n) ** 3)))
2
2
31
46
x = int(eval(input())) print((x**3))
n = eval(input()) print(("{}".format(int(n) ** 3)))
false
0
[ "-x = int(eval(input()))", "-print((x**3))", "+n = eval(input())", "+print((\"{}\".format(int(n) ** 3)))" ]
false
0.046314
0.046713
0.991462
[ "s309875639", "s941075251" ]
u875291233
p03857
python
s851911857
s454042607
727
401
101,204
131,156
Accepted
Accepted
44.84
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n): self.parent = list(range(n)) #親ノード self.size = [1]*n #グループの要素数 def root(self, x): #root(x): xの根ノードを返す. while self.parent[x] != x: self.parent[x] = self.parent[self.parent[x]] x =...
class UnionFind: def __init__(self, n): self.parent = list(range(n)) #親ノード self.size = [1]*n #グループの要素数 def root(self, x): #root(x): xの根ノードを返す. while self.parent[x] != x: self.parent[x] = self.parent[self.parent[x]] x = self.parent[x] return x ...
53
58
1,394
1,438
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n): self.parent = list(range(n)) # 親ノード self.size = [1] * n # グループの要素数 def root(self, x): # root(x): xの根ノードを返す. while self.parent[x] != x: self.parent[x] = self.parent[self.parent[x]] x = se...
class UnionFind: def __init__(self, n): self.parent = list(range(n)) # 親ノード self.size = [1] * n # グループの要素数 def root(self, x): # root(x): xの根ノードを返す. while self.parent[x] != x: self.parent[x] = self.parent[self.parent[x]] x = self.parent[x] return x ...
false
8.62069
[ "-# coding: utf-8", "-# Your code here!", "+# coding: utf-8", "+# Your code here!", "-input = sys.stdin.readline", "-n, k, l = [int(i) for i in input().split()]", "+read = sys.stdin.read", "+readline = sys.stdin.readline", "+n, k, l = list(map(int, readline().split()))", "+UF2 = UnionFind(n)", "...
false
0.037657
0.037293
1.009765
[ "s851911857", "s454042607" ]
u506858457
p02689
python
s289273879
s460771955
402
351
31,636
30,240
Accepted
Accepted
12.69
def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) N,M=MI() Ten=[1 for _ in range(N)] Michi=[[] for _ in range(N)] H=LI() for i in range(M): a,b=MI() a-=1 b-=1 Michi[a].append(b) Michi[b].append(a) for i in range(N): for j in Michi[i]: if H[...
def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) N,M=MI() H=LI() ans=0 Michi=[[] for i in range(N)] Ten=[1] *N for i in range(M): a,b=MI() a-=1 b-=1 Michi[a].append(b) Michi[b].append(a) for j in range(N): ...
19
22
378
403
def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) N, M = MI() Ten = [1 for _ in range(N)] Michi = [[] for _ in range(N)] H = LI() for i in range(M): a, b = MI() a -= 1 b -= 1 Michi[a].append(b) Michi[b].append(a) for i in range(N): for ...
def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) N, M = MI() H = LI() ans = 0 Michi = [[] for i in range(N)] Ten = [1] * N for i in range(M): a, b = MI() a -= 1 b -= 1 Michi[a].append(b) Michi[b].a...
false
13.636364
[ "+def II():", "+ return int(eval(input()))", "+", "+", "-Ten = [1 for _ in range(N)]", "-Michi = [[] for _ in range(N)]", "+ans = 0", "+Michi = [[] for i in range(N)]", "+Ten = [1] * N", "-for i in range(N):", "- for j in Michi[i]:", "- if H[i] <= H[j]:", "- Ten[i] = ...
false
0.033192
0.033786
0.982406
[ "s289273879", "s460771955" ]
u859897687
p03000
python
s278869029
s433514861
180
17
38,384
3,060
Accepted
Accepted
90.56
n,x=list(map(int,input().split())) l=list(map(int,input().split())) m=[0] ans=1 for i in range(n): m+=[m[i]+l[i]] if m[i]+l[i]<=x: ans+=1 print(ans)
n,x=list(map(int,input().split())) l=list(map(int,input().split())) ans=1 d=0 for i in range(n): d+=l[i] if d<=x: ans+=1 print(ans)
9
9
158
141
n, x = list(map(int, input().split())) l = list(map(int, input().split())) m = [0] ans = 1 for i in range(n): m += [m[i] + l[i]] if m[i] + l[i] <= x: ans += 1 print(ans)
n, x = list(map(int, input().split())) l = list(map(int, input().split())) ans = 1 d = 0 for i in range(n): d += l[i] if d <= x: ans += 1 print(ans)
false
0
[ "-m = [0]", "+d = 0", "- m += [m[i] + l[i]]", "- if m[i] + l[i] <= x:", "+ d += l[i]", "+ if d <= x:" ]
false
0.047569
0.091494
0.519907
[ "s278869029", "s433514861" ]
u454557108
p02690
python
s359852925
s699454623
160
71
67,808
67,448
Accepted
Accepted
55.62
x = int(eval(input())) for i in range(-4000,4000) : flag = 0 for j in range(-4000,i) : if x%(i-j) != 0 : continue v = x//(i-j) c = i**4+j**4+i*j*(i**2+i*j+j**2) if v == c : print((i,j)) flag = 1 break if flag == 1 ...
x = int(eval(input())) for i in range(-1000,1000) : flag = 0 for j in range(-1000,i) : if x%(i-j) != 0 : continue v = x//(i-j) c = i**4+j**4+i*j*(i**2+i*j+j**2) if v == c : print((i,j)) flag = 1 break if flag == 1 ...
15
15
328
328
x = int(eval(input())) for i in range(-4000, 4000): flag = 0 for j in range(-4000, i): if x % (i - j) != 0: continue v = x // (i - j) c = i**4 + j**4 + i * j * (i**2 + i * j + j**2) if v == c: print((i, j)) flag = 1 break if fla...
x = int(eval(input())) for i in range(-1000, 1000): flag = 0 for j in range(-1000, i): if x % (i - j) != 0: continue v = x // (i - j) c = i**4 + j**4 + i * j * (i**2 + i * j + j**2) if v == c: print((i, j)) flag = 1 break if fla...
false
0
[ "-for i in range(-4000, 4000):", "+for i in range(-1000, 1000):", "- for j in range(-4000, i):", "+ for j in range(-1000, i):" ]
false
2.116106
0.262995
8.046179
[ "s359852925", "s699454623" ]
u600402037
p02838
python
s367198627
s790985805
620
329
124,568
48,784
Accepted
Accepted
46.94
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10 ** 9 + 7 N = ir() A = lr() bit = [0 for _ in range(60)] for a in A: for i in range(a.bit_length()): if (a >> i) & 1: bit[i] += 1 answer = 0 for i, x ...
import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10 ** 9 + 7 N = ir() A = np.array(lr(), np.int64) answer = 0 limit = int(A.max()).bit_length() for i in range(limit): B = (A >> i) & 1 x = np.count_nonz...
21
20
399
414
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10**9 + 7 N = ir() A = lr() bit = [0 for _ in range(60)] for a in A: for i in range(a.bit_length()): if (a >> i) & 1: bit[i] += 1 answer = 0 for i, x in enumerate(bit): ...
import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10**9 + 7 N = ir() A = np.array(lr(), np.int64) answer = 0 limit = int(A.max()).bit_length() for i in range(limit): B = (A >> i) & 1 x = np.count_nonzero(B) y = N ...
false
4.761905
[ "+import numpy as np", "-A = lr()", "-bit = [0 for _ in range(60)]", "-for a in A:", "- for i in range(a.bit_length()):", "- if (a >> i) & 1:", "- bit[i] += 1", "+A = np.array(lr(), np.int64)", "-for i, x in enumerate(bit):", "- answer += x * (N - x) * 2**i", "+limit = in...
false
0.044001
0.285064
0.154354
[ "s367198627", "s790985805" ]
u296518383
p02850
python
s498556046
s557757074
777
423
85,976
80,348
Accepted
Accepted
45.56
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N - 1)] graph = [[] for _ in range(N + 1)] for a, b in AB: graph[a].append(b) graph[b].append(a) #print("graph:", graph) order = [] stack = [1] parent = [0] * (N + 1) while stack: s = stack.pop() order.append(s) for...
import sys input = sys.stdin.buffer.readline N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N - 1)] graph = [[] for _ in range(N + 1)] for a, b in AB: graph[a].append(b) graph[b].append(a) def make_tree(graph, root) -> (list, list, list): INF = 10 ** 15 dis...
45
53
810
1,181
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N - 1)] graph = [[] for _ in range(N + 1)] for a, b in AB: graph[a].append(b) graph[b].append(a) # print("graph:", graph) order = [] stack = [1] parent = [0] * (N + 1) while stack: s = stack.pop() order.append(s) for g in gr...
import sys input = sys.stdin.buffer.readline N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N - 1)] graph = [[] for _ in range(N + 1)] for a, b in AB: graph[a].append(b) graph[b].append(a) def make_tree(graph, root) -> (list, list, list): INF = 10**15 dist = [INF] * len(g...
false
15.09434
[ "+import sys", "+", "+input = sys.stdin.buffer.readline", "-# print(\"graph:\", graph)", "-order = []", "-stack = [1]", "-parent = [0] * (N + 1)", "-while stack:", "- s = stack.pop()", "- order.append(s)", "+", "+", "+def make_tree(graph, root) -> (list, list, list):", "+ INF = 10...
false
0.065375
0.006579
9.937453
[ "s498556046", "s557757074" ]
u595289165
p02973
python
s779804047
s416042011
263
206
8,828
12,664
Accepted
Accepted
21.67
from collections import deque from bisect import bisect_left n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] ans = deque([a[0]]) for a_i in a[1:]: if ans[0] < a_i: i = bisect_left(ans, a_i) ans[i-1] = a_i else: ans.appendleft(a_i) print((len(ans)))
from bisect import bisect_right n = int(eval(input())) color = [0] * (n+1) for i in range(n): a = int(eval(input())) j = bisect_right(color, a) color[j-1] = a+1 ans = 0 for t in color: if t != 0: ans += 1 print(ans)
15
16
302
247
from collections import deque from bisect import bisect_left n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] ans = deque([a[0]]) for a_i in a[1:]: if ans[0] < a_i: i = bisect_left(ans, a_i) ans[i - 1] = a_i else: ans.appendleft(a_i) print((len(ans)))
from bisect import bisect_right n = int(eval(input())) color = [0] * (n + 1) for i in range(n): a = int(eval(input())) j = bisect_right(color, a) color[j - 1] = a + 1 ans = 0 for t in color: if t != 0: ans += 1 print(ans)
false
6.25
[ "-from collections import deque", "-from bisect import bisect_left", "+from bisect import bisect_right", "-a = [int(eval(input())) for _ in range(n)]", "-ans = deque([a[0]])", "-for a_i in a[1:]:", "- if ans[0] < a_i:", "- i = bisect_left(ans, a_i)", "- ans[i - 1] = a_i", "- el...
false
0.049974
0.045399
1.10076
[ "s779804047", "s416042011" ]
u489959379
p03372
python
s337543624
s023532801
1,285
236
41,484
39,672
Accepted
Accepted
81.63
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 class SegTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(N) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, init_val,...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, c = list(map(int, input().split())) XY = [list(map(int, input().split())) for _ in range(n)] R1, R2 = [0], [0] max1, max2 = [0], [0] ma = 0 prev = 0 ...
98
41
2,658
950
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 class SegTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(N) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, init_val, segfunc, ide_ele...
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): n, c = list(map(int, input().split())) XY = [list(map(int, input().split())) for _ in range(n)] R1, R2 = [0], [0] max1, max2 = [0], [0] ma = 0 prev = 0 for x, y in XY: ...
false
58.163265
[ "-class SegTree:", "- \"\"\"", "- init(init_val, ide_ele): 配列init_valで初期化 O(N)", "- update(k, x): k番目の値をxに更新 O(N)", "- query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)", "- \"\"\"", "-", "- def __init__(self, init_val, segfunc, ide_ele):", "- \"\"\"", "- init_val: 配列の初期...
false
0.068071
0.089813
0.757915
[ "s337543624", "s023532801" ]
u416011173
p02548
python
s321262498
s978800190
248
185
9,148
9,184
Accepted
Accepted
25.4
# -*- coding: utf-8 -*- # モジュールのインポート import math # 標準入力を取得 N = int(eval(input())) # 求解処理 ans = 0 for a in range(1, N): ans += math.ceil(N / a) - 1 # 結果出力 print(ans)
# -*- coding: utf-8 -*- # モジュールのインポート import math def get_input() -> int: """ 標準入力を取得する. Returns:\n int: 標準入力 """ N = int(eval(input())) return N def main(N: int) -> None: """ メイン処理. Args:\n N (int): 正整数(2 <= N <= 10**6) """ # 求解...
14
39
180
523
# -*- coding: utf-8 -*- # モジュールのインポート import math # 標準入力を取得 N = int(eval(input())) # 求解処理 ans = 0 for a in range(1, N): ans += math.ceil(N / a) - 1 # 結果出力 print(ans)
# -*- coding: utf-8 -*- # モジュールのインポート import math def get_input() -> int: """ 標準入力を取得する. Returns:\n int: 標準入力 """ N = int(eval(input())) return N def main(N: int) -> None: """ メイン処理. Args:\n N (int): 正整数(2 <= N <= 10**6) """ # 求解処理 ans = 0 for a in...
false
64.102564
[ "-# 標準入力を取得", "-N = int(eval(input()))", "-# 求解処理", "-ans = 0", "-for a in range(1, N):", "- ans += math.ceil(N / a) - 1", "-# 結果出力", "-print(ans)", "+", "+def get_input() -> int:", "+ \"\"\"", "+ 標準入力を取得する.", "+ Returns:\\n", "+ int: 標準入力", "+ \"\"\"", "+ N = ...
false
0.316575
0.158123
2.002084
[ "s321262498", "s978800190" ]
u906428167
p03682
python
s499967305
s765540655
1,879
1,509
124,192
123,224
Accepted
Accepted
19.69
import sys input = sys.stdin.readline from heapq import heappop,heappush n = int(eval(input())) p = [] for i in range(n): x,y = list(map(int,input().split())) p.append((i,x,y)) e = [[] for _ in range(n)] p = sorted(p,key=lambda x:x[1]) n0,x0,y0 = p[0] for i in range(n-1): n1,x1,y1 = p[i+...
from heapq import heappop,heappush n = int(eval(input())) p = [] for i in range(n): x,y = list(map(int,input().split())) p.append((i,x,y)) e = [[] for _ in range(n)] p = sorted(p,key=lambda x:x[1]) n0,x0,y0 = p[0] for i in range(n-1): n1,x1,y1 = p[i+1] e[n0].append((min(abs(x1-x0),abs(y...
50
47
1,135
1,093
import sys input = sys.stdin.readline from heapq import heappop, heappush n = int(eval(input())) p = [] for i in range(n): x, y = list(map(int, input().split())) p.append((i, x, y)) e = [[] for _ in range(n)] p = sorted(p, key=lambda x: x[1]) n0, x0, y0 = p[0] for i in range(n - 1): n1, x1, y1 = p[i + 1] ...
from heapq import heappop, heappush n = int(eval(input())) p = [] for i in range(n): x, y = list(map(int, input().split())) p.append((i, x, y)) e = [[] for _ in range(n)] p = sorted(p, key=lambda x: x[1]) n0, x0, y0 = p[0] for i in range(n - 1): n1, x1, y1 = p[i + 1] e[n0].append((min(abs(x1 - x0), abs...
false
6
[ "-import sys", "-", "-input = sys.stdin.readline", "- e[n0].append([min(abs(x1 - x0), abs(y1 - y0)), n1])", "- e[n1].append([min(abs(x1 - x0), abs(y1 - y0)), n0])", "+ e[n0].append((min(abs(x1 - x0), abs(y1 - y0)), n1))", "+ e[n1].append((min(abs(x1 - x0), abs(y1 - y0)), n0))", "- e[n0]...
false
0.042328
0.231265
0.183029
[ "s499967305", "s765540655" ]
u423966555
p02574
python
s900229078
s635679548
638
556
127,784
127,744
Accepted
Accepted
12.85
from math import gcd from functools import reduce N = int(eval(input())) A = list(map(int, input().split())) M = 10**6+1 mp = [0]*M for a in A: mp[a] += 1 pairwise = 1 for i in range(2,M): if sum(mp[i::i])>1: pairwise = 0 break if pairwise: print('pairwise coprime') el...
from math import gcd from functools import reduce def main(): N = int(eval(input())) A = list(map(int, input().split())) M = 10**6+1 mp = [0]*M for a in A: mp[a] += 1 pairwise = 1 for i in range(2,M): if sum(mp[i::i])>1: pairwise = 0 b...
24
26
403
522
from math import gcd from functools import reduce N = int(eval(input())) A = list(map(int, input().split())) M = 10**6 + 1 mp = [0] * M for a in A: mp[a] += 1 pairwise = 1 for i in range(2, M): if sum(mp[i::i]) > 1: pairwise = 0 break if pairwise: print("pairwise coprime") elif reduce(gcd, ...
from math import gcd from functools import reduce def main(): N = int(eval(input())) A = list(map(int, input().split())) M = 10**6 + 1 mp = [0] * M for a in A: mp[a] += 1 pairwise = 1 for i in range(2, M): if sum(mp[i::i]) > 1: pairwise = 0 break ...
false
7.692308
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-M = 10**6 + 1", "-mp = [0] * M", "-for a in A:", "- mp[a] += 1", "-pairwise = 1", "-for i in range(2, M):", "- if sum(mp[i::i]) > 1:", "- pairwise = 0", "- break", "-if pairwise:", "- print(\"pairwise...
false
0.69423
0.007982
86.976058
[ "s900229078", "s635679548" ]
u133936772
p02623
python
s437308284
s326740848
263
242
48,444
48,368
Accepted
Accepted
7.98
import itertools as it, bisect as bs f=lambda:list(map(int,input().split())) g=lambda:[0]+[*it.accumulate(f())] n,m,k=f() A,B=g(),g() a,j=0,m for i in range(n+1): t=bs.bisect(B,k-A[i]) if t: a=max(a,i+t-1) print(a)
from itertools import * f=lambda:list(map(int,input().split())) g=lambda:[0]+[*accumulate(f())] n,m,k=f() A,B=g(),g() c,j=0,m for i,a in enumerate(A): while j and a+B[j]>k: j-=1 if a+B[j]<=k: c=max(c,i+j) print(c)
10
10
221
220
import itertools as it, bisect as bs f = lambda: list(map(int, input().split())) g = lambda: [0] + [*it.accumulate(f())] n, m, k = f() A, B = g(), g() a, j = 0, m for i in range(n + 1): t = bs.bisect(B, k - A[i]) if t: a = max(a, i + t - 1) print(a)
from itertools import * f = lambda: list(map(int, input().split())) g = lambda: [0] + [*accumulate(f())] n, m, k = f() A, B = g(), g() c, j = 0, m for i, a in enumerate(A): while j and a + B[j] > k: j -= 1 if a + B[j] <= k: c = max(c, i + j) print(c)
false
0
[ "-import itertools as it, bisect as bs", "+from itertools import *", "-g = lambda: [0] + [*it.accumulate(f())]", "+g = lambda: [0] + [*accumulate(f())]", "-a, j = 0, m", "-for i in range(n + 1):", "- t = bs.bisect(B, k - A[i])", "- if t:", "- a = max(a, i + t - 1)", "-print(a)", "+c...
false
0.049464
0.04675
1.05805
[ "s437308284", "s326740848" ]
u970449052
p03043
python
s453327737
s543991552
40
32
3,060
3,060
Accepted
Accepted
20
n,k=list(map(int,input().split())) ans=0 for i in range(1,n+1): tmp=1/n if i<k: now=i while now<k: now*=2 tmp/=2 ans+=tmp print(ans)
import math n,k=list(map(int,input().split())) ans=0 for i in range(1,n+1): if i<k: ans+=(0.5**math.ceil(math.log2(k/i)))/n else: ans+=1/n print(ans)
11
9
188
175
n, k = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): tmp = 1 / n if i < k: now = i while now < k: now *= 2 tmp /= 2 ans += tmp print(ans)
import math n, k = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): if i < k: ans += (0.5 ** math.ceil(math.log2(k / i))) / n else: ans += 1 / n print(ans)
false
18.181818
[ "+import math", "+", "- tmp = 1 / n", "- now = i", "- while now < k:", "- now *= 2", "- tmp /= 2", "- ans += tmp", "+ ans += (0.5 ** math.ceil(math.log2(k / i))) / n", "+ else:", "+ ans += 1 / n" ]
false
0.050317
0.050083
1.004677
[ "s453327737", "s543991552" ]
u075012704
p03732
python
s096093570
s145410736
273
220
3,188
42,860
Accepted
Accepted
19.41
from itertools import accumulate N, W = list(map(int, input().split())) w0, w1, w2, w3 = [], [], [], [] base_w = -1 for i in range(N): w, v = list(map(int, input().split())) if base_w < 0: base_w = w # 重みごとの箱にいれる w -= base_w if w == 0: w0.append(v) elif w == 1: ...
from itertools import accumulate N, W_limit = list(map(int, input().split())) W, V = [], [] for i in range(N): w, v = list(map(int, input().split())) W.append(w) V.append(v) # 基準となるW base_W = W[0] # 0 ~ 3の範囲に調節 W = [w - base_W for w in W] # 重みごとに商品を分ける Items = [[] for i in range(4)] for w, ...
42
35
994
969
from itertools import accumulate N, W = list(map(int, input().split())) w0, w1, w2, w3 = [], [], [], [] base_w = -1 for i in range(N): w, v = list(map(int, input().split())) if base_w < 0: base_w = w # 重みごとの箱にいれる w -= base_w if w == 0: w0.append(v) elif w == 1: w1.append...
from itertools import accumulate N, W_limit = list(map(int, input().split())) W, V = [], [] for i in range(N): w, v = list(map(int, input().split())) W.append(w) V.append(v) # 基準となるW base_W = W[0] # 0 ~ 3の範囲に調節 W = [w - base_W for w in W] # 重みごとに商品を分ける Items = [[] for i in range(4)] for w, v in zip(W, V): ...
false
16.666667
[ "-N, W = list(map(int, input().split()))", "-w0, w1, w2, w3 = [], [], [], []", "-base_w = -1", "+N, W_limit = list(map(int, input().split()))", "+W, V = [], []", "- if base_w < 0:", "- base_w = w", "- # 重みごとの箱にいれる", "- w -= base_w", "- if w == 0:", "- w0.append(v)", "...
false
0.040132
0.042547
0.943231
[ "s096093570", "s145410736" ]
u623819879
p03264
python
s974290369
s821225432
172
60
38,412
61,624
Accepted
Accepted
65.12
n=int(eval(input())) print(((n//2)**2 if n%2==0 else (n//2)*(n//2+1)))
k=int(eval(input()));print((-~k//2*(k//2)))
2
1
63
35
n = int(eval(input())) print(((n // 2) ** 2 if n % 2 == 0 else (n // 2) * (n // 2 + 1)))
k = int(eval(input())) print((-~k // 2 * (k // 2)))
false
50
[ "-n = int(eval(input()))", "-print(((n // 2) ** 2 if n % 2 == 0 else (n // 2) * (n // 2 + 1)))", "+k = int(eval(input()))", "+print((-~k // 2 * (k // 2)))" ]
false
0.046448
0.036028
1.289217
[ "s974290369", "s821225432" ]
u379629675
p02850
python
s040534220
s399839466
689
434
79,388
74,272
Accepted
Accepted
37.01
# -*- coding: utf-8 -*- import sys import queue input = sys.stdin.readline def ii(): return int(input().rstrip()) def mi(): return map(int, input().rstrip().split()) def lmi(): return list(map(int, input().rstrip().split())) def fi(): return float(input()) def mfi(): return map(float, input().rstrip().split()) ...
# -*- coding: utf-8 -*- import sys import collections input = sys.stdin.readline def ii(): return int(input().rstrip()) def mi(): return map(int, input().rstrip().split()) def lmi(): return list(map(int, input().rstrip().split())) def fi(): return float(input().rstrip()) def mfi(): return map(float, input().rst...
42
42
1,153
1,177
# -*- coding: utf-8 -*- import sys import queue input = sys.stdin.readline def ii(): return int(input().rstrip()) def mi(): return map(int, input().rstrip().split()) def lmi(): return list(map(int, input().rstrip().split())) def fi(): return float(input()) def mfi(): return map(float, inp...
# -*- coding: utf-8 -*- import sys import collections input = sys.stdin.readline def ii(): return int(input().rstrip()) def mi(): return map(int, input().rstrip().split()) def lmi(): return list(map(int, input().rstrip().split())) def fi(): return float(input().rstrip()) def mfi(): return...
false
0
[ "-import queue", "+import collections", "- return float(input())", "+ return float(input().rstrip())", "- q = queue.Queue()", "+ q = collections.deque()", "- q.put((0, 0))", "- while not q.empty():", "- t, idx = q.get()", "+ q.append((0, 0))", "+ while len(q):", ...
false
0.074393
0.041851
1.777568
[ "s040534220", "s399839466" ]