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
u133936772
p02762
python
s231250874
s629346565
1,054
668
11,456
15,720
Accepted
Accepted
36.62
f=lambda:list(map(int,input().split())) def r(x): while p[x]>=0: x=p[x] return x def u(x,y): x,y=r(x),r(y) if x==y: return if x>y: x,y=y,x p[x]+=p[y]; p[y]=x n,m,k=f() l,p=[0]*-~n,[-1]*-~n for _ in range(m): a,b=f() u(a,b); l[a]-=1; l[b]-=1 for _ in range(k): c,d=f() if r(c)==r(d): l...
f=lambda:list(map(int,input().split())) n,m,k=f() # Union_Find p=[-1]*n def root(x): while p[x]>=0: x=p[x] return x def unite(x,y): x,y=root(x),root(y) if x==y: return if x>y: x,y=y,x p[x]+=p[y] p[y]=x def same(x,y): return root(x)==root(y) def size(x): return -p[root(x)] l=[-1]*n...
19
33
382
519
f = lambda: list(map(int, input().split())) def r(x): while p[x] >= 0: x = p[x] return x def u(x, y): x, y = r(x), r(y) if x == y: return if x > y: x, y = y, x p[x] += p[y] p[y] = x n, m, k = f() l, p = [0] * -~n, [-1] * -~n for _ in range(m): a, b = f() ...
f = lambda: list(map(int, input().split())) n, m, k = f() # Union_Find p = [-1] * n def root(x): while p[x] >= 0: x = p[x] return x def unite(x, y): x, y = root(x), root(y) if x == y: return if x > y: x, y = y, x p[x] += p[y] p[y] = x def same(x, y): return ...
false
42.424242
[ "+n, m, k = f()", "+# Union_Find", "+p = [-1] * n", "-def r(x):", "+def root(x):", "-def u(x, y):", "- x, y = r(x), r(y)", "+def unite(x, y):", "+ x, y = root(x), root(y)", "-n, m, k = f()", "-l, p = [0] * -~n, [-1] * -~n", "+def same(x, y):", "+ return root(x) == root(y)", "+", ...
false
0.039638
0.008192
4.838505
[ "s231250874", "s629346565" ]
u062147869
p03703
python
s377444902
s461697229
1,286
942
81,956
90,372
Accepted
Accepted
26.75
from itertools import accumulate import sys sys.setrecursionlimit(10**8) class BIT(): def __init__(self,number): self.n=number self.list=[0]*(number+1) def add(self,i,x):#ith added x 1indexed while i<=self.n: self.list[i]+=x i+=i&-i ...
from itertools import accumulate import sys sys.setrecursionlimit(10**8) class BIT(): def __init__(self,number): self.n=number self.list=[0]*(number+1) def add(self,i,x):#ith added x 1indexed while i<=self.n: self.list[i]+=x i+=i&-i ...
46
37
1,007
855
from itertools import accumulate import sys sys.setrecursionlimit(10**8) class BIT: def __init__(self, number): self.n = number self.list = [0] * (number + 1) def add(self, i, x): # ith added x 1indexed while i <= self.n: self.list[i] += x i += i & -i d...
from itertools import accumulate import sys sys.setrecursionlimit(10**8) class BIT: def __init__(self, number): self.n = number self.list = [0] * (number + 1) def add(self, i, x): # ith added x 1indexed while i <= self.n: self.list[i] += x i += i & -i d...
false
19.565217
[ "-C = sorted((B[i], i) for i in range(N + 1))", "-D = [-1] * (N + 1)", "-D[C[0][1]] = 0", "-s = C[0][0]", "-t = 0", "-for i in range(1, N + 1):", "- if s < C[i][0]:", "- s = C[i][0]", "- t += 1", "- D[C[i][1]] = t", "- else:", "- D[C[i][1]] = t", "-tree = BI...
false
0.11694
0.035895
3.25786
[ "s377444902", "s461697229" ]
u628707847
p02761
python
s648603241
s751570252
30
27
9,140
9,128
Accepted
Accepted
10
n,m = list(map(int,input().split())) s,c = [0]*m,[0]*m for i in range(m): s[i],c[i] = list(map(int,input().split())) s[i] -= 1 number = ['0']*n for j in range(m): if number[s[j]] != '0' and number[s[j]] != str(c[j]): print('-1') quit() elif s[j] == 0 and c[j] == 0 and n != 1: ...
n,m = list(map(int,input().split())) s,c = [0]*m,[0]*m for i in range(m): s[i],c[i] = list(map(int,input().split())) s[i] -= 1 ans = '' number = ['0']*n for j in range(m): flag_1 = (number[s[j]] != '0' and number[s[j]] != str(c[j])) flag_2 = (s[j] == 0 and c[j] == 0 and n != 1) if flag_1 o...
20
21
485
509
n, m = list(map(int, input().split())) s, c = [0] * m, [0] * m for i in range(m): s[i], c[i] = list(map(int, input().split())) s[i] -= 1 number = ["0"] * n for j in range(m): if number[s[j]] != "0" and number[s[j]] != str(c[j]): print("-1") quit() elif s[j] == 0 and c[j] == 0 and n != 1:...
n, m = list(map(int, input().split())) s, c = [0] * m, [0] * m for i in range(m): s[i], c[i] = list(map(int, input().split())) s[i] -= 1 ans = "" number = ["0"] * n for j in range(m): flag_1 = number[s[j]] != "0" and number[s[j]] != str(c[j]) flag_2 = s[j] == 0 and c[j] == 0 and n != 1 if flag_1 or ...
false
4.761905
[ "+ans = \"\"", "- if number[s[j]] != \"0\" and number[s[j]] != str(c[j]):", "- print(\"-1\")", "- quit()", "- elif s[j] == 0 and c[j] == 0 and n != 1:", "- print(\"-1\")", "- quit()", "+ flag_1 = number[s[j]] != \"0\" and number[s[j]] != str(c[j])", "+ flag_2 ...
false
0.046784
0.048538
0.963866
[ "s648603241", "s751570252" ]
u419760455
p02393
python
s552683248
s945226550
40
20
7,472
7,632
Accepted
Accepted
50
data = input().split() data.sort() print((data[0], data[1], data[2]))
num = list(map(int, input().split())) num.sort() print((num[0], num[1], num[2]))
3
4
70
82
data = input().split() data.sort() print((data[0], data[1], data[2]))
num = list(map(int, input().split())) num.sort() print((num[0], num[1], num[2]))
false
25
[ "-data = input().split()", "-data.sort()", "-print((data[0], data[1], data[2]))", "+num = list(map(int, input().split()))", "+num.sort()", "+print((num[0], num[1], num[2]))" ]
false
0.051889
0.052704
0.98455
[ "s552683248", "s945226550" ]
u814387366
p02397
python
s864354847
s820948651
30
20
4,196
4,192
Accepted
Accepted
33.33
while(True): x,y=list(map(int,input().split())) if(x==0 and y==0):break if(x>y): tmp=x x=y y=tmp print(x,y)
while True: x,y=list(map(int,input().split())) if x==0 and y==0:break if x>y: tmp=x x=y y=tmp print(str(x)+" "+str(y))
8
8
121
132
while True: x, y = list(map(int, input().split())) if x == 0 and y == 0: break if x > y: tmp = x x = y y = tmp print(x, y)
while True: x, y = list(map(int, input().split())) if x == 0 and y == 0: break if x > y: tmp = x x = y y = tmp print(str(x) + " " + str(y))
false
0
[ "- print(x, y)", "+ print(str(x) + \" \" + str(y))" ]
false
0.069994
0.052628
1.329968
[ "s864354847", "s820948651" ]
u050428930
p03329
python
s316764237
s578606592
1,472
1,007
7,832
3,828
Accepted
Accepted
31.59
n=int(eval(input())) s=[] t=1000 p=0 def f9(n,p): while n>=9: n//=9 p+=1 f9(n,p) return p def f6(n,p): while n>=6: n//=6 p+=1 f6(n,p) return p s.append((n,0)) while s: a=s[0][0] b=s[0][1] if a<6: t=min(t,b+a) ...
N=int(eval(input())) dp=[0]*(N+1) def f(n): p=0 q=0 m=n while n>=1: n//=9 p+=1 while m>=1: m//=6 q+=1 s=[] for i in range(p): s.append(9**i) for j in range(q): s.append(6**j) s.pop(0) return s for i in ran...
31
25
462
433
n = int(eval(input())) s = [] t = 1000 p = 0 def f9(n, p): while n >= 9: n //= 9 p += 1 f9(n, p) return p def f6(n, p): while n >= 6: n //= 6 p += 1 f6(n, p) return p s.append((n, 0)) while s: a = s[0][0] b = s[0][1] if a < 6: t =...
N = int(eval(input())) dp = [0] * (N + 1) def f(n): p = 0 q = 0 m = n while n >= 1: n //= 9 p += 1 while m >= 1: m //= 6 q += 1 s = [] for i in range(p): s.append(9**i) for j in range(q): s.append(6**j) s.pop(0) return s for i i...
false
19.354839
[ "-n = int(eval(input()))", "-s = []", "-t = 1000", "-p = 0", "+N = int(eval(input()))", "+dp = [0] * (N + 1)", "-def f9(n, p):", "- while n >= 9:", "+def f(n):", "+ p = 0", "+ q = 0", "+ m = n", "+ while n >= 1:", "- f9(n, p)", "- return p", "+ while m >= 1:...
false
0.523381
0.266146
1.966518
[ "s316764237", "s578606592" ]
u736479342
p03556
python
s406062679
s391213064
41
27
10,112
9,348
Accepted
Accepted
34.15
n = int(eval(input())) c=[] for i in range(n+1): a = i**2 if a <= n: c.append(a) else: break print((max(c)))
n = int(eval(input())) print((int(n**(1/2))**2))
9
2
122
41
n = int(eval(input())) c = [] for i in range(n + 1): a = i**2 if a <= n: c.append(a) else: break print((max(c)))
n = int(eval(input())) print((int(n ** (1 / 2)) ** 2))
false
77.777778
[ "-c = []", "-for i in range(n + 1):", "- a = i**2", "- if a <= n:", "- c.append(a)", "- else:", "- break", "-print((max(c)))", "+print((int(n ** (1 / 2)) ** 2))" ]
false
0.055446
0.044325
1.2509
[ "s406062679", "s391213064" ]
u392319141
p02804
python
s478051668
s581202590
328
270
19,796
25,496
Accepted
Accepted
17.68
MOD = 10**9 + 7 class Combination: def __init__(self, size): self.size = size + 2 self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i - 1] * i % MOD ...
MOD = 10**9 + 7 class Combination: def __init__(self, size): self.size = size + 2 self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i - 1] * i % MOD ...
40
38
1,157
1,127
MOD = 10**9 + 7 class Combination: def __init__(self, size): self.size = size + 2 self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i - 1] * i % MOD ...
MOD = 10**9 + 7 class Combination: def __init__(self, size): self.size = size + 2 self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i - 1] * i % MOD ...
false
5
[ "-MOD = 10**9 + 7", "-comb = Combination(N + 10)", "+comb = Combination(N + 100)", "- mi = comb.ncr(N - i - 1, K - 1)", "- mx = comb.ncr(i, K - 1)", "- ans += (mx - mi) * a", "+ ans += a * comb.ncr(i, K - 1)", "+ ans -= a * comb.ncr(N - i - 1, K - 1)" ]
false
0.044775
0.113979
0.392838
[ "s478051668", "s581202590" ]
u367965715
p02720
python
s667303875
s558110506
1,072
128
12,452
11,908
Accepted
Accepted
88.06
from queue import Queue k = int(eval(input())) q = Queue() for i in range(1, 10): q.put(i) for _ in range(k): x = q.get() if x % 10 != 0: q.put(x*10 + x%10 - 1) q.put(x*10 + x%10) if x % 10 != 9: q.put(x*10 + x%10 + 1) print(x)
from collections import deque k = int(eval(input())) q = deque(list(range(1, 10))) for _ in range(k): x = q.popleft() if x % 10 != 0: q.append(x*10 + x%10 - 1) q.append(x*10 + x%10) if x % 10 != 9: q.append(x*10 + x%10 + 1) print(x)
17
14
278
268
from queue import Queue k = int(eval(input())) q = Queue() for i in range(1, 10): q.put(i) for _ in range(k): x = q.get() if x % 10 != 0: q.put(x * 10 + x % 10 - 1) q.put(x * 10 + x % 10) if x % 10 != 9: q.put(x * 10 + x % 10 + 1) print(x)
from collections import deque k = int(eval(input())) q = deque(list(range(1, 10))) for _ in range(k): x = q.popleft() if x % 10 != 0: q.append(x * 10 + x % 10 - 1) q.append(x * 10 + x % 10) if x % 10 != 9: q.append(x * 10 + x % 10 + 1) print(x)
false
17.647059
[ "-from queue import Queue", "+from collections import deque", "-q = Queue()", "-for i in range(1, 10):", "- q.put(i)", "+q = deque(list(range(1, 10)))", "- x = q.get()", "+ x = q.popleft()", "- q.put(x * 10 + x % 10 - 1)", "- q.put(x * 10 + x % 10)", "+ q.append(x * 10 ...
false
0.170942
0.046963
3.639909
[ "s667303875", "s558110506" ]
u746419473
p02802
python
s172153827
s745877117
452
378
29,492
23,540
Accepted
Accepted
16.37
n, m = list(map(int, input().split())) ps = {} for _ in range(m): _p, _s = list(map(str, input().split())) _p = int(_p) ps.setdefault(_p, []) ps[_p].append(_s) ac = 0 wa = 0 for v in list(ps.values()): for i, _v in enumerate(v): if _v == "AC": ac += 1 w...
n, m = list(map(int, input().split())) ps = [] for _ in range(m): _p, _s = list(map(str, input().split())) _p = int(_p) ps.append([_p, _s]) ac = [False]*n wa = [0]*n for _p, _s in ps: if ac[_p-1]: continue if _s == "AC": ac[_p-1] = True elif _s == "WA": ...
18
26
345
442
n, m = list(map(int, input().split())) ps = {} for _ in range(m): _p, _s = list(map(str, input().split())) _p = int(_p) ps.setdefault(_p, []) ps[_p].append(_s) ac = 0 wa = 0 for v in list(ps.values()): for i, _v in enumerate(v): if _v == "AC": ac += 1 wa += i ...
n, m = list(map(int, input().split())) ps = [] for _ in range(m): _p, _s = list(map(str, input().split())) _p = int(_p) ps.append([_p, _s]) ac = [False] * n wa = [0] * n for _p, _s in ps: if ac[_p - 1]: continue if _s == "AC": ac[_p - 1] = True elif _s == "WA": wa[_p - 1]...
false
30.769231
[ "-ps = {}", "+ps = []", "- ps.setdefault(_p, [])", "- ps[_p].append(_s)", "-ac = 0", "-wa = 0", "-for v in list(ps.values()):", "- for i, _v in enumerate(v):", "- if _v == \"AC\":", "- ac += 1", "- wa += i", "- break", "-print((ac, wa))", "+...
false
0.034496
0.036871
0.935576
[ "s172153827", "s745877117" ]
u296150111
p02821
python
s911052146
s361616883
1,549
1,432
14,536
14,204
Accepted
Accepted
7.55
import sys input=sys.stdin.readline import bisect n,k=list(map(int,input().split())) a=list(map(int,input().split())) a.sort() r=a[n-1]*2+1 l=0 while r-l>=2: mid=(l+r)//2 #mid以上はいくつあるか #答えはl以上r未満 cnt=0 for i in range(n): cnt+=n-bisect.bisect_left(a,mid-a[i]) if cnt>=k: l=mid else: r=mid ...
import bisect n,k=list(map(int,input().split())) a=list(map(int,input().split())) a.sort() r=a[n-1]*2+1 l=0 while r-l>=2: mid=(l+r)//2 #mid以上はいくつあるか #答えはl以上r未満 cnt=0 for i in range(n): cnt+=n-bisect.bisect_left(a,mid-a[i]) if cnt>=k: l=mid else: r=mid #lだとk個以上 rだとk個未満 ans,p,=0,0 b=[0] f...
32
30
513
475
import sys input = sys.stdin.readline import bisect n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() r = a[n - 1] * 2 + 1 l = 0 while r - l >= 2: mid = (l + r) // 2 # mid以上はいくつあるか # 答えはl以上r未満 cnt = 0 for i in range(n): cnt += n - bisect.bisect_left(a, mid...
import bisect n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() r = a[n - 1] * 2 + 1 l = 0 while r - l >= 2: mid = (l + r) // 2 # mid以上はいくつあるか # 答えはl以上r未満 cnt = 0 for i in range(n): cnt += n - bisect.bisect_left(a, mid - a[i]) if cnt >= k: l = m...
false
6.25
[ "-import sys", "-", "-input = sys.stdin.readline" ]
false
0.044638
0.044328
1.007003
[ "s911052146", "s361616883" ]
u933096856
p00006
python
s932505002
s498118603
20
10
7,420
6,396
Accepted
Accepted
50
print((input()[::-1]))
print(input()[::-1])
1
1
20
23
print((input()[::-1]))
print(input()[::-1])
false
0
[ "-print((input()[::-1]))", "+print(input()[::-1])" ]
false
0.04569
0.065304
0.699661
[ "s932505002", "s498118603" ]
u145950990
p03136
python
s174350394
s866965884
171
18
38,384
2,940
Accepted
Accepted
89.47
n = int(eval(input())) l = list(map(int,input().split())) l = sorted(l) print(( 'Yes' if l[-1]<sum(l[:-1]) else 'No' ))
n = int(eval(input())) l = sorted(list(map(int,input().split())),reverse=True) if l[0]<sum(l[1:]): print('Yes') else: print('No')
4
6
114
136
n = int(eval(input())) l = list(map(int, input().split())) l = sorted(l) print(("Yes" if l[-1] < sum(l[:-1]) else "No"))
n = int(eval(input())) l = sorted(list(map(int, input().split())), reverse=True) if l[0] < sum(l[1:]): print("Yes") else: print("No")
false
33.333333
[ "-l = list(map(int, input().split()))", "-l = sorted(l)", "-print((\"Yes\" if l[-1] < sum(l[:-1]) else \"No\"))", "+l = sorted(list(map(int, input().split())), reverse=True)", "+if l[0] < sum(l[1:]):", "+ print(\"Yes\")", "+else:", "+ print(\"No\")" ]
false
0.055842
0.035051
1.593165
[ "s174350394", "s866965884" ]
u782930273
p03993
python
s103675847
s574669385
156
75
39,128
20,612
Accepted
Accepted
51.92
N = int(eval(input())) A = [int(a) - 1 for a in input().split()] liked = [set() for _ in range(N)] for i in range(N): liked[A[i]].add(i) count = 0 for i in range(N): if A[i] in liked[i]: count += 1 print((count // 2))
N = int(eval(input())) A = [int(a) - 1 for a in input().split()] count = 0 for i in range(N): if i == A[A[i]]: count += 1 print((count // 2))
12
8
238
154
N = int(eval(input())) A = [int(a) - 1 for a in input().split()] liked = [set() for _ in range(N)] for i in range(N): liked[A[i]].add(i) count = 0 for i in range(N): if A[i] in liked[i]: count += 1 print((count // 2))
N = int(eval(input())) A = [int(a) - 1 for a in input().split()] count = 0 for i in range(N): if i == A[A[i]]: count += 1 print((count // 2))
false
33.333333
[ "-liked = [set() for _ in range(N)]", "-for i in range(N):", "- liked[A[i]].add(i)", "- if A[i] in liked[i]:", "+ if i == A[A[i]]:" ]
false
0.04433
0.043314
1.023456
[ "s103675847", "s574669385" ]
u970899068
p02787
python
s619781842
s776765079
501
440
43,116
48,860
Accepted
Accepted
12.18
h,n = list(map(int, input().split())) x = [list(map(int, input().split())) for i in range(n)] #dp[v]:体力をv減らす時の最小魔力 dp=[10**20 for i in range(h+1)] dp[0]=0 for i in range(h+1): for j in range(n): if i-x[j][0]<0: dp[i] = min(dp[i], dp[0] + x[j][1]) else: dp[i]=m...
h,n= list(map(int, input().split())) a= [list(map(int, input().split())) for i in range(n)] dp=[float('inf')]*(h+1) dp[0]=0 for i in range(n): x=a[i][0] y=a[i][1] for j in range(h+1): if j>=x: dp[j]=min(dp[j-x]+y,dp[j]) else: dp[j]=min(y,dp[j]) print((...
15
15
361
320
h, n = list(map(int, input().split())) x = [list(map(int, input().split())) for i in range(n)] # dp[v]:体力をv減らす時の最小魔力 dp = [10**20 for i in range(h + 1)] dp[0] = 0 for i in range(h + 1): for j in range(n): if i - x[j][0] < 0: dp[i] = min(dp[i], dp[0] + x[j][1]) else: dp[i] = m...
h, n = list(map(int, input().split())) a = [list(map(int, input().split())) for i in range(n)] dp = [float("inf")] * (h + 1) dp[0] = 0 for i in range(n): x = a[i][0] y = a[i][1] for j in range(h + 1): if j >= x: dp[j] = min(dp[j - x] + y, dp[j]) else: dp[j] = min(y, d...
false
0
[ "-x = [list(map(int, input().split())) for i in range(n)]", "-# dp[v]:体力をv減らす時の最小魔力", "-dp = [10**20 for i in range(h + 1)]", "+a = [list(map(int, input().split())) for i in range(n)]", "+dp = [float(\"inf\")] * (h + 1)", "-for i in range(h + 1):", "- for j in range(n):", "- if i - x[j][0] <...
false
0.147727
0.142022
1.040169
[ "s619781842", "s776765079" ]
u028973125
p03837
python
s944361216
s342768527
492
239
55,900
44,140
Accepted
Accepted
51.42
import sys #O(ElogV) import heapq def dijkstra_heap(s, n, edges): # 始点sから各頂点への最短距離 dist = [float("inf")] * n used = [True] * n # True:未確定 dist[s] = 0 used[s] = False used_edges = set() edgelist = [] for (d, e) in edges[s]: # 利用した辺を管理するため、sも入れていることに注意 heapq....
import sys N, M = list(map(int, sys.stdin.readline().strip().split())) def warshall_floyd(d): # d[i][j]: iからjへの最短距離 for k in range(size_v): for i in range(size_v): for j in range(size_v): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) return d edges = [] for i ...
59
35
1,482
805
import sys # O(ElogV) import heapq def dijkstra_heap(s, n, edges): # 始点sから各頂点への最短距離 dist = [float("inf")] * n used = [True] * n # True:未確定 dist[s] = 0 used[s] = False used_edges = set() edgelist = [] for (d, e) in edges[s]: # 利用した辺を管理するため、sも入れていることに注意 heapq.heappush(e...
import sys N, M = list(map(int, sys.stdin.readline().strip().split())) def warshall_floyd(d): # d[i][j]: iからjへの最短距離 for k in range(size_v): for i in range(size_v): for j in range(size_v): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) return d edges = [] for i in range(M)...
false
40.677966
[ "-# O(ElogV)", "-import heapq", "+N, M = list(map(int, sys.stdin.readline().strip().split()))", "-def dijkstra_heap(s, n, edges):", "- # 始点sから各頂点への最短距離", "- dist = [float(\"inf\")] * n", "- used = [True] * n # True:未確定", "- dist[s] = 0", "- used[s] = False", "- used_edges = set(...
false
0.064916
0.037745
1.719855
[ "s944361216", "s342768527" ]
u604398799
p03074
python
s032524216
s238652999
253
228
14,676
18,484
Accepted
Accepted
9.88
# -*- coding: utf-8 -*- """ Created on Sat Apr 13 09:53:12 2019 @author: Owner """ import collections import scipy.misc import sys import numpy as np import math from operator import itemgetter import itertools import copy import bisect #素因数を並べる def prime_decomposition(n): i = 2 table = [] ...
# -*- coding: utf-8 -*- """ Created on Sat Apr 13 09:53:12 2019 @author: Owner """ import collections import scipy.misc import sys import numpy as np import math from operator import itemgetter import itertools import copy import bisect #素因数を並べる def prime_decomposition(n): i = 2 table = [] ...
135
147
2,579
2,885
# -*- coding: utf-8 -*- """ Created on Sat Apr 13 09:53:12 2019 @author: Owner """ import collections import scipy.misc import sys import numpy as np import math from operator import itemgetter import itertools import copy import bisect # 素因数を並べる def prime_decomposition(n): i = 2 table = [] while i * i <= ...
# -*- coding: utf-8 -*- """ Created on Sat Apr 13 09:53:12 2019 @author: Owner """ import collections import scipy.misc import sys import numpy as np import math from operator import itemgetter import itertools import copy import bisect # 素因数を並べる def prime_decomposition(n): i = 2 table = [] while i * i <= ...
false
8.163265
[ "+ # 累積和", "+ sums = [0] * (len(nums) + 1)", "+ for i in range(len(nums)):", "+ sums[i + 1] = sums[i] + nums[i]", "+ for i in range(0, len(nums), 2):", "+ left = i", "+ right = min(i + add, len(nums))", "+ tmp = sums[right] - sums[left]", "+ res = max(t...
false
0.239576
0.299153
0.800849
[ "s032524216", "s238652999" ]
u424768586
p02734
python
s026215856
s781146167
121
111
75,152
74,448
Accepted
Accepted
8.26
import sys sys.setrecursionlimit(10**6) #再帰関数の上限 import math from copy import copy, deepcopy from operator import itemgetter from bisect import bisect_left, bisect, bisect_right#2分探索 #bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collections import deque #deque(l), pop(), append...
import sys def input(): return sys.stdin.readline()[:-1] #mod = 10**9+7 #w.sort(key=itemgetter(1),reversed=True) #二個目の要素で降順並び替え #N = int(input()) N, S = list(map(int, input().split())) #L = [int(input()) for i in range(N)] A = tuple(map(int, input().split())) #S = [list(map(int, input().split())) for i i...
48
26
1,427
534
import sys sys.setrecursionlimit(10**6) # 再帰関数の上限 import math from copy import copy, deepcopy from operator import itemgetter from bisect import bisect_left, bisect, bisect_right # 2分探索 # bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collections import deque # deque(l), pop(), append(...
import sys def input(): return sys.stdin.readline()[:-1] # mod = 10**9+7 # w.sort(key=itemgetter(1),reversed=True) #二個目の要素で降順並び替え # N = int(input()) N, S = list(map(int, input().split())) # L = [int(input()) for i in range(N)] A = tuple(map(int, input().split())) # S = [list(map(int, input().split())) for i in...
false
45.833333
[ "-sys.setrecursionlimit(10**6) # 再帰関数の上限", "-import math", "-from copy import copy, deepcopy", "-from operator import itemgetter", "-from bisect import bisect_left, bisect, bisect_right # 2分探索", "-# bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下", "-from collections import dequ...
false
0.115896
0.136742
0.847547
[ "s026215856", "s781146167" ]
u426649993
p03680
python
s065979204
s453484507
184
152
7,084
12,960
Accepted
Accepted
17.39
def main(): N = int(eval(input())) a = [int(eval(input())) for _ in range(N)] ans = 0 nxt = 1 while True: if ans > N: print((-1)) exit() elif nxt == 2: break nxt = a[nxt-1] ans += 1 print(ans) if __name__ == ...
def main(): N = int(eval(input())) a = [int(eval(input())) for _ in range(N)] tmp = 0 for i in range(N): if a[tmp] == 2: print((i+1)) exit() else: tmp = a[tmp]-1 print((-1)) if __name__ == "__main__": main()
19
18
330
290
def main(): N = int(eval(input())) a = [int(eval(input())) for _ in range(N)] ans = 0 nxt = 1 while True: if ans > N: print((-1)) exit() elif nxt == 2: break nxt = a[nxt - 1] ans += 1 print(ans) if __name__ == "__main__": ...
def main(): N = int(eval(input())) a = [int(eval(input())) for _ in range(N)] tmp = 0 for i in range(N): if a[tmp] == 2: print((i + 1)) exit() else: tmp = a[tmp] - 1 print((-1)) if __name__ == "__main__": main()
false
5.263158
[ "- ans = 0", "- nxt = 1", "- while True:", "- if ans > N:", "- print((-1))", "+ tmp = 0", "+ for i in range(N):", "+ if a[tmp] == 2:", "+ print((i + 1))", "- elif nxt == 2:", "- break", "- nxt = a[nxt - 1]", "- ...
false
0.085526
0.03849
2.222024
[ "s065979204", "s453484507" ]
u788137651
p03660
python
s836352206
s986346663
796
487
106,332
87,068
Accepted
Accepted
38.82
#高速化heapqダイクストラ from collections import * from heapq import* import sys input=lambda:sys.stdin.readline() def BFS(point,d): cost=[1e7]*(n+1) cost[point]=0 Q=[] heappush(Q,(0,point)) while Q: c,p=heappop(Q) for np in d[p]: if cost[np]==1e7: ...
# #    ⋀_⋀  #   (・ω・) # ./ U ∽ U\ # │* 合 *│ # │* 格 *│ # │* 祈 *│ # │* 願 *│ # │*   *│ #  ̄ # import sys sys.setrecursionlimit(10**6) input=sys.stdin.readline from math import floor,sqrt,factorial,hypot,log #log2ないyp from heapq import heappop, heappush, heappushpop from collections import...
52
82
820
2,141
# 高速化heapqダイクストラ from collections import * from heapq import * import sys input = lambda: sys.stdin.readline() def BFS(point, d): cost = [1e7] * (n + 1) cost[point] = 0 Q = [] heappush(Q, (0, point)) while Q: c, p = heappop(Q) for np in d[p]: if cost[np] == 1e7: ...
# #    ⋀_⋀ #    (・ω・) # ./ U ∽ U\ # │* 合 *│ # │* 格 *│ # │* 祈 *│ # │* 願 *│ # │*   *│ #  ̄ # import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline from math import floor, sqrt, factorial, hypot, log # log2ないyp from heapq import heappop, heappush, heappushpop from collections import Counter, defa...
false
36.585366
[ "-# 高速化heapqダイクストラ", "-from collections import *", "-from heapq import *", "+#", "+#    ⋀_⋀", "+#    (・ω・)", "+# ./ U ∽ U\", "+# │* 合 *│", "+# │* 格 *│", "+# │* 祈 *│", "+# │* 願 *│", "+# │*   *│", "+#  ̄", "+#", "-input = lambda: sys.stdin.readline()", "+sys.setrecursionlimit(...
false
0.039641
0.038425
1.031655
[ "s836352206", "s986346663" ]
u193264896
p03076
python
s452285120
s878456009
148
17
12,492
3,060
Accepted
Accepted
88.51
import numpy as np import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**8) INF = float('inf') MOD = 10**9+7 def main(): A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) D = int(eval(input...
def main(): A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) D = int(eval(input())) E = int(eval(input())) a = (10 - A) % 10 b = (10 - B) % 10 c = (10 - C) % 10 d = (10 - D) % 10 e = (10 - E) % 10 print((A+B+C+D+E+a+b+c+d+e-max([a,b,c,d,e]))) if _...
29
19
529
320
import numpy as np import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def main(): A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) D = int(eval(input())...
def main(): A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) D = int(eval(input())) E = int(eval(input())) a = (10 - A) % 10 b = (10 - B) % 10 c = (10 - C) % 10 d = (10 - D) % 10 e = (10 - E) % 10 print((A + B + C + D + E + a + b + c + d + e - max([a, b, c...
false
34.482759
[ "-import numpy as np", "-import sys", "-", "-read = sys.stdin.buffer.read", "-readline = sys.stdin.buffer.readline", "-readlines = sys.stdin.buffer.readlines", "-sys.setrecursionlimit(10**8)", "-INF = float(\"inf\")", "-MOD = 10**9 + 7", "-", "-" ]
false
0.035237
0.081543
0.432131
[ "s452285120", "s878456009" ]
u609307781
p02688
python
s986209722
s709436509
22
20
9,192
9,200
Accepted
Accepted
9.09
# B inp = input().split(' ') N, K = int(inp[0]), int(inp[1]) sunuke = [1] * N for i in range(K): di = int(eval(input())) tmp = list(map(int, input().split())) for t in tmp: sunuke[t-1] = 0 print((sum(sunuke)))
# B N, K = list(map(int, input().split())) sunuke = [1] * N for i in range(K): di = int(eval(input())) tmp = list(map(int, input().split())) for t in tmp: sunuke[t-1] = 0 print((sum(sunuke)))
13
12
230
205
# B inp = input().split(" ") N, K = int(inp[0]), int(inp[1]) sunuke = [1] * N for i in range(K): di = int(eval(input())) tmp = list(map(int, input().split())) for t in tmp: sunuke[t - 1] = 0 print((sum(sunuke)))
# B N, K = list(map(int, input().split())) sunuke = [1] * N for i in range(K): di = int(eval(input())) tmp = list(map(int, input().split())) for t in tmp: sunuke[t - 1] = 0 print((sum(sunuke)))
false
7.692308
[ "-inp = input().split(\" \")", "-N, K = int(inp[0]), int(inp[1])", "+N, K = list(map(int, input().split()))" ]
false
0.035514
0.036447
0.974385
[ "s986209722", "s709436509" ]
u994521204
p03013
python
s862214332
s878082413
598
135
462,744
6,900
Accepted
Accepted
77.42
n,m=list(map(int,input().split())) A=[int(eval(input())) for i in range(m)] mod=10**9+7 flag=1 S=[0 for i in range(n+3)] S[0]=1 SET=set(A) for i in range(n): if i in SET: S[i]=0 if i+1 in SET: flag=0 S[i+1]+=S[i] S[i+2]+=S[i] print((S[n]%mod if flag==1 else 0)...
import sys input=sys.stdin.buffer.readline n,m=list(map(int,input().split())) mod=10**9+7 dp=[0]*(n+1) for _ in range(m): a=int(eval(input())) dp[a]=-1 dp[0]=1 for i in range(n): if dp[i]>=0: if i+1<=n: if dp[i+1]>=0: dp[i+1]+=dp[i] dp[i+1]%=...
17
20
320
453
n, m = list(map(int, input().split())) A = [int(eval(input())) for i in range(m)] mod = 10**9 + 7 flag = 1 S = [0 for i in range(n + 3)] S[0] = 1 SET = set(A) for i in range(n): if i in SET: S[i] = 0 if i + 1 in SET: flag = 0 S[i + 1] += S[i] S[i + 2] += S[i] print((S[n] % mod if...
import sys input = sys.stdin.buffer.readline n, m = list(map(int, input().split())) mod = 10**9 + 7 dp = [0] * (n + 1) for _ in range(m): a = int(eval(input())) dp[a] = -1 dp[0] = 1 for i in range(n): if dp[i] >= 0: if i + 1 <= n: if dp[i + 1] >= 0: dp[i + 1] += dp[i] ...
false
15
[ "+import sys", "+", "+input = sys.stdin.buffer.readline", "-A = [int(eval(input())) for i in range(m)]", "-flag = 1", "-S = [0 for i in range(n + 3)]", "-S[0] = 1", "-SET = set(A)", "+dp = [0] * (n + 1)", "+for _ in range(m):", "+ a = int(eval(input()))", "+ dp[a] = -1", "+dp[0] = 1", ...
false
0.042231
0.039006
1.08268
[ "s862214332", "s878082413" ]
u077291787
p02732
python
s719316503
s160212711
226
198
48,268
48,276
Accepted
Accepted
12.39
# D - Banned K from collections import Counter def main(): N, *A = list(map(int, open(0).read().split())) counter = Counter(A) total = 0 dif = {} for k, v in list(counter.items()): total += max(0, v * (v - 1) // 2) dif[k] = max(0, v - 1) ans = [total - dif[a] for a ...
# D - Banned K from collections import Counter def main(): N, *A = list(map(int, open(0).read().split())) counter = Counter(A) total = 0 dif = {} for k, v in list(counter.items()): total += v * (v - 1) // 2 dif[k] = v - 1 ans = [total - dif[a] for a in A] print...
18
18
395
379
# D - Banned K from collections import Counter def main(): N, *A = list(map(int, open(0).read().split())) counter = Counter(A) total = 0 dif = {} for k, v in list(counter.items()): total += max(0, v * (v - 1) // 2) dif[k] = max(0, v - 1) ans = [total - dif[a] for a in A] pr...
# D - Banned K from collections import Counter def main(): N, *A = list(map(int, open(0).read().split())) counter = Counter(A) total = 0 dif = {} for k, v in list(counter.items()): total += v * (v - 1) // 2 dif[k] = v - 1 ans = [total - dif[a] for a in A] print(("\n".join(m...
false
0
[ "- total += max(0, v * (v - 1) // 2)", "- dif[k] = max(0, v - 1)", "+ total += v * (v - 1) // 2", "+ dif[k] = v - 1" ]
false
0.041531
0.042515
0.976846
[ "s719316503", "s160212711" ]
u367130284
p03061
python
s826778344
s797092484
415
137
24,080
16,124
Accepted
Accepted
66.99
from fractions import* from numpy import* def dv(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors n,*a=list(map(int,open(0).read().split())) a=array(a) l...
from itertools import* from fractions import* n,*a=list(map(int,open(0).read().split())) b=list(accumulate([0]+a,gcd)) c=list(accumulate([0]+a[::-1],gcd)) print((max(gcd(s,t)for s,t in zip(b,c[::-1][1:]))))
19
6
414
203
from fractions import * from numpy import * def dv(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors n, *a = list(map(int, open(0).read().split())) a = array(a) l...
from itertools import * from fractions import * n, *a = list(map(int, open(0).read().split())) b = list(accumulate([0] + a, gcd)) c = list(accumulate([0] + a[::-1], gcd)) print((max(gcd(s, t) for s, t in zip(b, c[::-1][1:]))))
false
68.421053
[ "+from itertools import *", "-from numpy import *", "-", "-", "-def dv(n):", "- divisors = []", "- for i in range(1, int(n**0.5) + 1):", "- if n % i == 0:", "- divisors.append(i)", "- if i != n // i:", "- divisors.append(n // i)", "- return ...
false
0.232355
0.058294
3.985935
[ "s826778344", "s797092484" ]
u599669731
p02922
python
s339779782
s353669251
74
60
62,024
61,652
Accepted
Accepted
18.92
import math a,b=list(map(int,input().split())) print((math.ceil((b-1)/(a-1))))
a,b=list(map(int,input().split())) print((-(-(b-1)//(a-1))))
3
2
72
53
import math a, b = list(map(int, input().split())) print((math.ceil((b - 1) / (a - 1))))
a, b = list(map(int, input().split())) print((-(-(b - 1) // (a - 1))))
false
33.333333
[ "-import math", "-", "-print((math.ceil((b - 1) / (a - 1))))", "+print((-(-(b - 1) // (a - 1))))" ]
false
0.047377
0.046115
1.027361
[ "s339779782", "s353669251" ]
u089230684
p03059
python
s695065796
s897287227
21
17
3,316
2,940
Accepted
Accepted
19.05
a, b, t = [int(x) for x in input().split()] s = 0 x = a while x <= t + 0.5: s += b x += a print(s)
A, B, C = list(map(int, input().split())) ans = (int(C/A))*B print(ans)
9
4
117
69
a, b, t = [int(x) for x in input().split()] s = 0 x = a while x <= t + 0.5: s += b x += a print(s)
A, B, C = list(map(int, input().split())) ans = (int(C / A)) * B print(ans)
false
55.555556
[ "-a, b, t = [int(x) for x in input().split()]", "-s = 0", "-x = a", "-while x <= t + 0.5:", "- s += b", "- x += a", "-print(s)", "+A, B, C = list(map(int, input().split()))", "+ans = (int(C / A)) * B", "+print(ans)" ]
false
0.047146
0.045749
1.030523
[ "s695065796", "s897287227" ]
u067299340
p00009
python
s127450474
s380950233
230
200
44,452
44,452
Accepted
Accepted
13.04
#coding: UTF-8 from bisect import bisect_right max_number = 1000000 prime_flag_list = [1] * max_number prime_flag_list[0] = 0 prime_flag_list[1] = 0 prime_flag_list[4::2] = [0] * len(prime_flag_list[4::2]) for i in range(3, int(max_number**0.5) + 1, 2): prime_flag_list[i*i::i] = [0] * len(prime_fl...
#coding: UTF-8 from bisect import bisect_right max_number = 1000000 prime_flag_list = [True] * max_number prime_flag_list[0] = False prime_flag_list[1] = False prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2]) for i in range(3, int(max_number**0.5) + 1, 2): prime_flag_list[i*i::i] = [Fa...
23
24
547
568
# coding: UTF-8 from bisect import bisect_right max_number = 1000000 prime_flag_list = [1] * max_number prime_flag_list[0] = 0 prime_flag_list[1] = 0 prime_flag_list[4::2] = [0] * len(prime_flag_list[4::2]) for i in range(3, int(max_number**0.5) + 1, 2): prime_flag_list[i * i :: i] = [0] * len(prime_flag_list[i * ...
# coding: UTF-8 from bisect import bisect_right max_number = 1000000 prime_flag_list = [True] * max_number prime_flag_list[0] = False prime_flag_list[1] = False prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2]) for i in range(3, int(max_number**0.5) + 1, 2): prime_flag_list[i * i :: i] = [False] * len(p...
false
4.166667
[ "-prime_flag_list = [1] * max_number", "-prime_flag_list[0] = 0", "-prime_flag_list[1] = 0", "-prime_flag_list[4::2] = [0] * len(prime_flag_list[4::2])", "+prime_flag_list = [True] * max_number", "+prime_flag_list[0] = False", "+prime_flag_list[1] = False", "+prime_flag_list[4::2] = [False] * len(prim...
false
0.458586
0.631035
0.72672
[ "s127450474", "s380950233" ]
u677121387
p02743
python
s895210950
s132951772
38
35
5,076
5,076
Accepted
Accepted
7.89
from decimal import Decimal as d a,b,c = list(map(int,input().split())) if a**d(0.5) + b**d(0.5) < c**d(0.5): ans = "Yes" else: ans = "No" print(ans)
from decimal import Decimal a,b,c = list(map(int,input().split())) d = Decimal(0.5) ans = "Yes" if a**d + b**d < c**d else "No" print(ans)
7
5
157
137
from decimal import Decimal as d a, b, c = list(map(int, input().split())) if a ** d(0.5) + b ** d(0.5) < c ** d(0.5): ans = "Yes" else: ans = "No" print(ans)
from decimal import Decimal a, b, c = list(map(int, input().split())) d = Decimal(0.5) ans = "Yes" if a**d + b**d < c**d else "No" print(ans)
false
28.571429
[ "-from decimal import Decimal as d", "+from decimal import Decimal", "-if a ** d(0.5) + b ** d(0.5) < c ** d(0.5):", "- ans = \"Yes\"", "-else:", "- ans = \"No\"", "+d = Decimal(0.5)", "+ans = \"Yes\" if a**d + b**d < c**d else \"No\"" ]
false
0.050223
0.047398
1.059615
[ "s895210950", "s132951772" ]
u263830634
p02698
python
s713773428
s010362402
1,491
1,317
242,792
99,084
Accepted
Accepted
11.67
import sys sys.setrecursionlimit(10 ** 9) from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) root = 0 ans = [0] *...
import sys sys.setrecursionlimit(10 ** 9) from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) root = 0 stack = [root] ...
46
53
751
1,014
import sys sys.setrecursionlimit(10**9) from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) root = 0 ans = [0] * N check = [False] * N chec...
import sys sys.setrecursionlimit(10**9) from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) root = 0 stack = [root] visited = set() visited...
false
13.207547
[ "+stack = [root]", "+visited = set()", "+visited.add(root)", "+done = set()", "+vs = []", "-check = [False] * N", "-check[root] = True", "+memo[root] = (0, A[root])", "-", "-", "-def dfs(x):", "- tmp = bisect_left(dp, A[x])", "- memo[x] = (tmp, dp[tmp])", "- dp[tmp] = A[x]", "- ...
false
0.037434
0.04957
0.755177
[ "s713773428", "s010362402" ]
u994521204
p03045
python
s938327982
s120205306
610
516
12,780
66,544
Accepted
Accepted
15.41
n,m=list(map(int,input().split())) #union-find par=[-1]*(n+1) def find(x): if par[x]<0: return x else: par[x]=find(par[x]) return par[x] def size(x): oya=find(x) return -par[oya] def unite(x,y): if find(x)==find(y): return False else: if si...
import sys input = sys.stdin.buffer.readline n, m = list(map(int, input().split())) # union-find # xの根を求める def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] # xとyの属する集合の併合 def unite(x, y): x = find(x) y = find(y) if x ...
33
54
722
835
n, m = list(map(int, input().split())) # union-find par = [-1] * (n + 1) def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] def size(x): oya = find(x) return -par[oya] def unite(x, y): if find(x) == find(y): return False else: ...
import sys input = sys.stdin.buffer.readline n, m = list(map(int, input().split())) # union-find # xの根を求める def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] # xとyの属する集合の併合 def unite(x, y): x = find(x) y = find(y) if x == y: return False...
false
38.888889
[ "+import sys", "+", "+input = sys.stdin.buffer.readline", "-par = [-1] * (n + 1)", "-", "-", "+# xの根を求める", "-def size(x):", "- oya = find(x)", "- return -par[oya]", "-", "-", "+# xとyの属する集合の併合", "- if find(x) == find(y):", "+ x = find(x)", "+ y = find(y)", "+ if x ==...
false
0.038859
0.039055
0.994999
[ "s938327982", "s120205306" ]
u021548497
p02632
python
s766842827
s202723070
1,256
1,117
70,640
75,224
Accepted
Accepted
11.07
mod = pow(10, 9)+7 k = int(eval(input())) s = eval(input()) n = len(s) ans = 0 key = pow(26, k, mod) sub = 1 c = 1 for i in range(k+1): ans += key*sub*c ans %= mod sub *= 25 sub %= mod key = key*pow(26, mod-2, mod)%mod c *= (n+i) c *= pow(i+1, mod-2, mod) c %= mod print(...
def main(): mod = pow(10, 9)+7 k = int(eval(input())) s = eval(input()) n = len(s) ans = 0 key = pow(26, k, mod) sub = 1 c = 1 for i in range(k+1): ans += key*sub*c ans %= mod sub *= 25 sub %= mod key = key*pow(26, mod-2, mod)%mod...
18
22
312
440
mod = pow(10, 9) + 7 k = int(eval(input())) s = eval(input()) n = len(s) ans = 0 key = pow(26, k, mod) sub = 1 c = 1 for i in range(k + 1): ans += key * sub * c ans %= mod sub *= 25 sub %= mod key = key * pow(26, mod - 2, mod) % mod c *= n + i c *= pow(i + 1, mod - 2, mod) c %= mod print...
def main(): mod = pow(10, 9) + 7 k = int(eval(input())) s = eval(input()) n = len(s) ans = 0 key = pow(26, k, mod) sub = 1 c = 1 for i in range(k + 1): ans += key * sub * c ans %= mod sub *= 25 sub %= mod key = key * pow(26, mod - 2, mod) % mod...
false
18.181818
[ "-mod = pow(10, 9) + 7", "-k = int(eval(input()))", "-s = eval(input())", "-n = len(s)", "-ans = 0", "-key = pow(26, k, mod)", "-sub = 1", "-c = 1", "-for i in range(k + 1):", "- ans += key * sub * c", "- ans %= mod", "- sub *= 25", "- sub %= mod", "- key = key * pow(26, mod...
false
0.047997
0.047436
1.011831
[ "s766842827", "s202723070" ]
u123756661
p03546
python
s186228848
s487639897
202
33
41,308
3,444
Accepted
Accepted
83.66
h,w=list(map(int,input().split())) c=[] for i in range(10): l=[int(i) for i in input().split()] c.append(l) a=[] for i in range(h): l=[int(i) for i in input().split()] a.append(l) p=[0]*10 for i in range(10): if i==1: continue d=[1003]*10 d[i]=0 q=set([i]) while 1: ...
def sol(): h,w=list(map(int,input().split())) c=[] for i in range(10): l=[int(i) for i in input().split()] c.append(l) a=[] for i in range(h): l=[int(i) for i in input().split()] a.append(l) p=[0]*10 for i in range(10): if i==1: continue ...
30
34
655
827
h, w = list(map(int, input().split())) c = [] for i in range(10): l = [int(i) for i in input().split()] c.append(l) a = [] for i in range(h): l = [int(i) for i in input().split()] a.append(l) p = [0] * 10 for i in range(10): if i == 1: continue d = [1003] * 10 d[i] = 0 q = set([i...
def sol(): h, w = list(map(int, input().split())) c = [] for i in range(10): l = [int(i) for i in input().split()] c.append(l) a = [] for i in range(h): l = [int(i) for i in input().split()] a.append(l) p = [0] * 10 for i in range(10): if i == 1: ...
false
11.764706
[ "-h, w = list(map(int, input().split()))", "-c = []", "-for i in range(10):", "- l = [int(i) for i in input().split()]", "- c.append(l)", "-a = []", "-for i in range(h):", "- l = [int(i) for i in input().split()]", "- a.append(l)", "-p = [0] * 10", "-for i in range(10):", "- if ...
false
0.037938
0.185817
0.204171
[ "s186228848", "s487639897" ]
u260216890
p02573
python
s359305512
s060855628
346
306
113,192
115,500
Accepted
Accepted
11.56
import sys input = sys.stdin.readline n,m=list(map(int, input().split())) es=[[] for _ in range(n)] for i in range(m): a,b=list(map(int, input().split())) es[a-1].append(b-1) es[b-1].append(a-1) ans=0 from collections import deque used=[0 for _ in range(n)] for i in range(n): if used[i]=...
import sys input = sys.stdin.readline n,m=list(map(int, input().split())) class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] def find(self, x): if self.par[x] == x: return x else: ...
27
41
605
997
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) es = [[] for _ in range(n)] for i in range(m): a, b = list(map(int, input().split())) es[a - 1].append(b - 1) es[b - 1].append(a - 1) ans = 0 from collections import deque used = [0 for _ in range(n)] for i in range(n): if us...
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] def find(self, x): if self.par[x] == x: return x else: sel...
false
34.146341
[ "-es = [[] for _ in range(n)]", "+", "+", "+class UnionFind(object):", "+ def __init__(self, n=1):", "+ self.par = [i for i in range(n)]", "+ self.rank = [0 for _ in range(n)]", "+", "+ def find(self, x):", "+ if self.par[x] == x:", "+ return x", "+ ...
false
0.036808
0.036948
0.996214
[ "s359305512", "s060855628" ]
u498487134
p03039
python
s552898343
s204568178
245
102
81,904
109,780
Accepted
Accepted
58.37
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N,M,K=MI() #2この組み合わせを全部足して,平均ぽく考える def sum2(x): return ((x*(x+1))//2)%mod ...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 """ まず,xとyを分離する=>xだけを考えるので1行とみなす. いっぺんにいくつも考えられないので,コマを2つだけ置いた時を考える. 2この組み合わせで距離が1=>M-1通り,2...
51
56
1,209
1,279
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 N, M, K = MI() # 2この組み合わせを全部足して,平均ぽく考える def sum2(x): return ((x * (x + 1)) /...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 """ まず,xとyを分離する=>xだけを考えるので1行とみなす. いっぺんにいくつも考えられないので,コマを2つだけ置いた時を考える. 2この組み合わせで距離...
false
8.928571
[ "+ \"\"\"", "+ まず,xとyを分離する=>xだけを考えるので1行とみなす.", "+ いっぺんにいくつも考えられないので,コマを2つだけ置いた時を考える.", "+ 2この組み合わせで距離が1=>M-1通り,2=>M-2通り,...,M-1=>1通り", "+ (以下のように考えてΣしても良いがやや面倒", "+ (j列目にコマを固定すると,相手との距離はj,j-1,...,1,0,1,2,...,M-j))", "+ 実際にはN列あるので,選び方がN^2", "+ 同じ行・列を選んだ場合は不可能だけど,どうせ距離も0な...
false
0.05295
0.054646
0.968953
[ "s552898343", "s204568178" ]
u643840641
p02984
python
s489292499
s082217810
250
180
14,092
14,032
Accepted
Accepted
28
n = int(input()) a = list(map(int, input().split())) b = 0 for i in range(n): b += a[i] * (1-i%2*2) print(b, end="") for i in range(n-1): b = (a[i] - b//2) * 2 print(" {}".format(b), end="") print("")
n = int(input()) a = list(map(int, input().split())) x = sum(a) - sum(a[1::2])*2 for i in range(n): print(x, end=' ') x = a[i]*2 - x
10
6
221
145
n = int(input()) a = list(map(int, input().split())) b = 0 for i in range(n): b += a[i] * (1 - i % 2 * 2) print(b, end="") for i in range(n - 1): b = (a[i] - b // 2) * 2 print(" {}".format(b), end="") print("")
n = int(input()) a = list(map(int, input().split())) x = sum(a) - sum(a[1::2]) * 2 for i in range(n): print(x, end=" ") x = a[i] * 2 - x
false
40
[ "-b = 0", "+x = sum(a) - sum(a[1::2]) * 2", "- b += a[i] * (1 - i % 2 * 2)", "-print(b, end=\"\")", "-for i in range(n - 1):", "- b = (a[i] - b // 2) * 2", "- print(\" {}\".format(b), end=\"\")", "-print(\"\")", "+ print(x, end=\" \")", "+ x = a[i] * 2 - x" ]
false
0.043569
0.090648
0.480639
[ "s489292499", "s082217810" ]
u905203728
p03090
python
s370708486
s015659667
217
84
43,376
69,004
Accepted
Accepted
61.29
from itertools import combinations n=int(eval(input())) A,B=[i+1 for i in range(n)],[] num=n if n%2==1 else n+1 for a,b in combinations(A,2): if a+b!=num:B.append([a,b]) print((len(B))) for i in B:print((*i))
from itertools import combinations n=int(eval(input())) A=[] num=n if n%2==1 else n+1 for a,b in combinations([j+1 for j in range(n)],2): if a+b!=num:A.append([a,b]) print((len(A))) for i in A:print((*i))
8
8
209
205
from itertools import combinations n = int(eval(input())) A, B = [i + 1 for i in range(n)], [] num = n if n % 2 == 1 else n + 1 for a, b in combinations(A, 2): if a + b != num: B.append([a, b]) print((len(B))) for i in B: print((*i))
from itertools import combinations n = int(eval(input())) A = [] num = n if n % 2 == 1 else n + 1 for a, b in combinations([j + 1 for j in range(n)], 2): if a + b != num: A.append([a, b]) print((len(A))) for i in A: print((*i))
false
0
[ "-A, B = [i + 1 for i in range(n)], []", "+A = []", "-for a, b in combinations(A, 2):", "+for a, b in combinations([j + 1 for j in range(n)], 2):", "- B.append([a, b])", "-print((len(B)))", "-for i in B:", "+ A.append([a, b])", "+print((len(A)))", "+for i in A:" ]
false
0.045699
0.056037
0.815524
[ "s370708486", "s015659667" ]
u179169725
p03854
python
s988434356
s074330243
923
196
134,664
40,432
Accepted
Accepted
78.76
# https://atcoder.jp/contests/abc049/tasks/arc065_a # なんかこの問題知ってる気がする # 前方向から貪欲にマッチしようとすると,dreamer なのか dream eraser なのかわかりにくい # しかし後ろ三文字を見ると、eam,mer,ase,serと一意に決定できる。よって逆方向から貪欲にマッチングさせると即座に構成可能か判別できる S = eval(input()) i = len(S) T = '' while i - 3 > 0: tri = S[i - 3:i] if tri == 'eam': T +...
# https://atcoder.jp/contests/abc049/tasks/arc065_a # なんかこの問題知ってる気がする # 前方向から貪欲にマッチしようとすると,dreamer なのか dream eraser なのかわかりにくい # しかし後ろ三文字を見ると、eam,mer,ase,serと一意に決定できる。よって逆方向から貪欲にマッチングさせると即座に構成可能か判別できる S = eval(input()) i = len(S) while i - 3 > 0: tri = S[i - 3:i] if tri == 'eam': is_ok = S[i...
31
32
639
713
# https://atcoder.jp/contests/abc049/tasks/arc065_a # なんかこの問題知ってる気がする # 前方向から貪欲にマッチしようとすると,dreamer なのか dream eraser なのかわかりにくい # しかし後ろ三文字を見ると、eam,mer,ase,serと一意に決定できる。よって逆方向から貪欲にマッチングさせると即座に構成可能か判別できる S = eval(input()) i = len(S) T = "" while i - 3 > 0: tri = S[i - 3 : i] if tri == "eam": T += "maerd" ...
# https://atcoder.jp/contests/abc049/tasks/arc065_a # なんかこの問題知ってる気がする # 前方向から貪欲にマッチしようとすると,dreamer なのか dream eraser なのかわかりにくい # しかし後ろ三文字を見ると、eam,mer,ase,serと一意に決定できる。よって逆方向から貪欲にマッチングさせると即座に構成可能か判別できる S = eval(input()) i = len(S) while i - 3 > 0: tri = S[i - 3 : i] if tri == "eam": is_ok = S[i - 5 : i] =...
false
3.125
[ "-T = \"\"", "- T += \"maerd\"", "+ is_ok = S[i - 5 : i] == \"dream\"", "- T += \"esare\"", "+ is_ok = S[i - 5 : i] == \"erase\"", "- T += \"remaerd\"", "+ is_ok = S[i - 7 : i] == \"dreamer\"", "- T += \"resare\"", "+ is_ok = S[i - 6 : i] == \"...
false
0.035082
0.037313
0.940199
[ "s988434356", "s074330243" ]
u392319141
p03007
python
s682330595
s101346731
269
224
20,152
14,324
Accepted
Accepted
16.73
N = int(eval(input())) A = list(map(int, input().split())) positive = 0 negative = 0 for a in A: if a > 0: positive += a else: negative += a if positive == 0: # 全部負 # 一番大きい数から残りをすべて引く A.sort(reverse=True) now = A[0] ans = [] for a in A[1:]: ans.a...
N = int(eval(input())) A = list(map(int, input().split())) A.sort() if A[0] < 0 and A[-1] > 0: ans = 0 for a in A: ans += abs(a) print(ans) now = A[0] for a in A[1:N - 1]: if a >= 0: print((now, a)) now -= a print((A[-1], now)) now = A[...
52
35
1,017
712
N = int(eval(input())) A = list(map(int, input().split())) positive = 0 negative = 0 for a in A: if a > 0: positive += a else: negative += a if positive == 0: # 全部負 # 一番大きい数から残りをすべて引く A.sort(reverse=True) now = A[0] ans = [] for a in A[1:]: ans.append((now, a)) ...
N = int(eval(input())) A = list(map(int, input().split())) A.sort() if A[0] < 0 and A[-1] > 0: ans = 0 for a in A: ans += abs(a) print(ans) now = A[0] for a in A[1 : N - 1]: if a >= 0: print((now, a)) now -= a print((A[-1], now)) now = A[-1] - now ...
false
32.692308
[ "-positive = 0", "-negative = 0", "-for a in A:", "- if a > 0:", "- positive += a", "- else:", "- negative += a", "-if positive == 0: # 全部負", "- # 一番大きい数から残りをすべて引く", "- A.sort(reverse=True)", "+A.sort()", "+if A[0] < 0 and A[-1] > 0:", "+ ans = 0", "+ for a...
false
0.045309
0.131087
0.34564
[ "s682330595", "s101346731" ]
u970449052
p02801
python
s112793645
s555648440
32
17
3,960
2,940
Accepted
Accepted
46.88
import string letters=string.ascii_lowercase c=eval(input()) print((letters[letters.index(c)+1]))
print((chr(ord(eval(input()))+1)))
4
1
92
26
import string letters = string.ascii_lowercase c = eval(input()) print((letters[letters.index(c) + 1]))
print((chr(ord(eval(input())) + 1)))
false
75
[ "-import string", "-", "-letters = string.ascii_lowercase", "-c = eval(input())", "-print((letters[letters.index(c) + 1]))", "+print((chr(ord(eval(input())) + 1)))" ]
false
0.042666
0.038534
1.107236
[ "s112793645", "s555648440" ]
u303739137
p02624
python
s267315261
s665706859
1,467
964
27,040
206,860
Accepted
Accepted
34.29
import numpy as np n = int(eval(input())) cnt = 0 for k in range(1,n+1): d = n//k if d == 1: cnt += (k+n)*(n-k+1)//2 break cnt += k*d*(d+1)//2 print(cnt)
n = int(eval(input())) cnts = [k*(n//k)*((n//k)+1)//2 for k in range(1,n//2+1)] print((sum(cnts)+ ((n//2+1)+n)*(n-(n//2+1)+1)//2))
11
3
186
124
import numpy as np n = int(eval(input())) cnt = 0 for k in range(1, n + 1): d = n // k if d == 1: cnt += (k + n) * (n - k + 1) // 2 break cnt += k * d * (d + 1) // 2 print(cnt)
n = int(eval(input())) cnts = [k * (n // k) * ((n // k) + 1) // 2 for k in range(1, n // 2 + 1)] print((sum(cnts) + ((n // 2 + 1) + n) * (n - (n // 2 + 1) + 1) // 2))
false
72.727273
[ "-import numpy as np", "-", "-cnt = 0", "-for k in range(1, n + 1):", "- d = n // k", "- if d == 1:", "- cnt += (k + n) * (n - k + 1) // 2", "- break", "- cnt += k * d * (d + 1) // 2", "-print(cnt)", "+cnts = [k * (n // k) * ((n // k) + 1) // 2 for k in range(1, n // 2 + 1...
false
1.126681
0.405417
2.779067
[ "s267315261", "s665706859" ]
u562016607
p03473
python
s486481934
s973752472
19
17
3,316
2,940
Accepted
Accepted
10.53
N=int(eval(input())) print((48-N))
print((48-int(eval(input()))))
2
1
28
22
N = int(eval(input())) print((48 - N))
print((48 - int(eval(input()))))
false
50
[ "-N = int(eval(input()))", "-print((48 - N))", "+print((48 - int(eval(input()))))" ]
false
0.040889
0.040505
1.009484
[ "s486481934", "s973752472" ]
u170201762
p03612
python
s195371376
s116320335
1,064
210
14,008
52,908
Accepted
Accepted
80.26
N = int(eval(input())) p = list(map(int,input().split())) import queue from math import ceil que = queue.Queue() ans = 0 for i in range(N): if p[i]==i+1: que.put(i) else: ans+=ceil(que.qsize()/2) que = queue.Queue() ans+=ceil(que.qsize()/2) print(ans)
N = int(eval(input())) p = list(map(int,input().split())) ans = 0 i = 0 while i < N: if p[i] == i+1: ans += 1 if i+1 < N and p[i+1]==i+2: i += 1 i += 1 print(ans)
14
12
290
204
N = int(eval(input())) p = list(map(int, input().split())) import queue from math import ceil que = queue.Queue() ans = 0 for i in range(N): if p[i] == i + 1: que.put(i) else: ans += ceil(que.qsize() / 2) que = queue.Queue() ans += ceil(que.qsize() / 2) print(ans)
N = int(eval(input())) p = list(map(int, input().split())) ans = 0 i = 0 while i < N: if p[i] == i + 1: ans += 1 if i + 1 < N and p[i + 1] == i + 2: i += 1 i += 1 print(ans)
false
14.285714
[ "-import queue", "-from math import ceil", "-", "-que = queue.Queue()", "-for i in range(N):", "+i = 0", "+while i < N:", "- que.put(i)", "- else:", "- ans += ceil(que.qsize() / 2)", "- que = queue.Queue()", "-ans += ceil(que.qsize() / 2)", "+ ans += 1", "+ ...
false
0.03981
0.036043
1.104499
[ "s195371376", "s116320335" ]
u814986259
p02887
python
s182075719
s129163553
42
37
3,316
7,108
Accepted
Accepted
11.9
N = int(eval(input())) S = eval(input()) ans = 1 for i in range(1, N): if S[i] != S[i-1]: ans += 1 print(ans)
N=int(eval(input())) S=eval(input()) S=[i for i in range(N) if i==0 or S[i]!=S[i-1]] print((len(S)))
9
4
120
89
N = int(eval(input())) S = eval(input()) ans = 1 for i in range(1, N): if S[i] != S[i - 1]: ans += 1 print(ans)
N = int(eval(input())) S = eval(input()) S = [i for i in range(N) if i == 0 or S[i] != S[i - 1]] print((len(S)))
false
55.555556
[ "-ans = 1", "-for i in range(1, N):", "- if S[i] != S[i - 1]:", "- ans += 1", "-print(ans)", "+S = [i for i in range(N) if i == 0 or S[i] != S[i - 1]]", "+print((len(S)))" ]
false
0.046114
0.065509
0.70394
[ "s182075719", "s129163553" ]
u966695319
p02973
python
s736223382
s111865021
555
371
53,876
77,028
Accepted
Accepted
33.15
import bisect from collections import deque N = int(eval(input())) nums = [int(eval(input())) for _ in range(N)] # i<jで、 AiとAjが同じ色で塗られている場合、Ai < Ajが成り立つ. # その際に、色の最小数をだす。 LIS = deque([nums[0]]) count = 0 for index, num in enumerate(nums): if index == 0: continue if num <= LIS[0]: LIS...
import bisect from collections import deque N = int(eval(input())) nums = deque([]) for i in range(N): num = int(eval(input())) if i == 0: nums.append(num) else: if nums[-1] < num: nums[-1] = num else: insert_index = bisect.bisect_left(nums, num)...
17
21
443
499
import bisect from collections import deque N = int(eval(input())) nums = [int(eval(input())) for _ in range(N)] # i<jで、 AiとAjが同じ色で塗られている場合、Ai < Ajが成り立つ. # その際に、色の最小数をだす。 LIS = deque([nums[0]]) count = 0 for index, num in enumerate(nums): if index == 0: continue if num <= LIS[0]: LIS.appendleft...
import bisect from collections import deque N = int(eval(input())) nums = deque([]) for i in range(N): num = int(eval(input())) if i == 0: nums.append(num) else: if nums[-1] < num: nums[-1] = num else: insert_index = bisect.bisect_left(nums, num) ...
false
19.047619
[ "-nums = [int(eval(input())) for _ in range(N)]", "-# i<jで、 AiとAjが同じ色で塗られている場合、Ai < Ajが成り立つ.", "-# その際に、色の最小数をだす。", "-LIS = deque([nums[0]])", "-count = 0", "-for index, num in enumerate(nums):", "- if index == 0:", "- continue", "- if num <= LIS[0]:", "- LIS.appendleft(num)", ...
false
0.048643
0.049162
0.989438
[ "s736223382", "s111865021" ]
u367701763
p03409
python
s163956950
s687472445
102
79
75,300
73,664
Accepted
Accepted
22.55
# https://atcoder.jp/contests/abc091/tasks/arc092_a import sys input = sys.stdin.readline from collections import deque class MaxFlow: class Edge: def __init__(self, to, cap, rev): """ :param to: 終点ノード :param cap: 残された容量 :param rev: 遂になる逆向きのエッ...
class Dinic: def __init__(self, len_X, len_Y): self.len_X, self.len_Y = len_X, len_Y self.edges = [[] for _ in range(len_X)] self.matched = [-1] * len_Y self.visited = set() def add_edge(self, x, y): self.edges[x].append(y) def dfs(self, x): """ ...
120
53
3,921
1,398
# https://atcoder.jp/contests/abc091/tasks/arc092_a import sys input = sys.stdin.readline from collections import deque class MaxFlow: class Edge: def __init__(self, to, cap, rev): """ :param to: 終点ノード :param cap: 残された容量 :param rev: 遂になる逆向きのエッジ(ノード to の re...
class Dinic: def __init__(self, len_X, len_Y): self.len_X, self.len_Y = len_X, len_Y self.edges = [[] for _ in range(len_X)] self.matched = [-1] * len_Y self.visited = set() def add_edge(self, x, y): self.edges[x].append(y) def dfs(self, x): """ :par...
false
55.833333
[ "-# https://atcoder.jp/contests/abc091/tasks/arc092_a", "-import sys", "+class Dinic:", "+ def __init__(self, len_X, len_Y):", "+ self.len_X, self.len_Y = len_X, len_Y", "+ self.edges = [[] for _ in range(len_X)]", "+ self.matched = [-1] * len_Y", "+ self.visited = set()...
false
0.036114
0.034884
1.035265
[ "s163956950", "s687472445" ]
u423585790
p02949
python
s769505152
s448174476
1,237
927
48,604
77,596
Accepted
Accepted
25.06
#!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(...
#!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): retur...
107
86
2,384
2,042
#!/usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF...
#!/usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): ...
false
19.626168
[ "-import sys, random, itertools, math", "+import sys, itertools, math", "-def LS():", "- return list(map(list, input().split()))", "+def S():", "+ return input().rstrip()", "-def S():", "- return list(input().rstrip())", "+def LS():", "+ return S().split()", "- return [II() for _ ...
false
0.045017
0.088432
0.509054
[ "s769505152", "s448174476" ]
u771804983
p03048
python
s826984954
s857937369
1,996
19
2,940
3,060
Accepted
Accepted
99.05
R,G,B,N=list(map(int,input().split())) counter=0 for r in range(N//R+1): for g in range((N-r*R)//G+1): b=(N-r*R-g*G)/B if b.is_integer() and b>=0: counter += 1 print(counter)
R,G,B,N=list(map(int,input().split())) a=[0]*(N+1) a[0]=1 for i in [R,G,B]: for j in range(N+1-i): a[j+i]+=a[j] print((a[N]))
10
9
213
141
R, G, B, N = list(map(int, input().split())) counter = 0 for r in range(N // R + 1): for g in range((N - r * R) // G + 1): b = (N - r * R - g * G) / B if b.is_integer() and b >= 0: counter += 1 print(counter)
R, G, B, N = list(map(int, input().split())) a = [0] * (N + 1) a[0] = 1 for i in [R, G, B]: for j in range(N + 1 - i): a[j + i] += a[j] print((a[N]))
false
10
[ "-counter = 0", "-for r in range(N // R + 1):", "- for g in range((N - r * R) // G + 1):", "- b = (N - r * R - g * G) / B", "- if b.is_integer() and b >= 0:", "- counter += 1", "-print(counter)", "+a = [0] * (N + 1)", "+a[0] = 1", "+for i in [R, G, B]:", "+ for j i...
false
0.095875
0.05093
1.882495
[ "s826984954", "s857937369" ]
u166306121
p03221
python
s332793820
s292307317
1,013
862
44,032
44,040
Accepted
Accepted
14.91
N,M = map(int,input().split()) data = [[i,list(map(int,input().split()))] for i in range(M)] # print(data) sortdata = sorted(data, key=lambda data:data[1]) # print(sortdata) cnt = 1 sortdata[0].append(1) for i in range(1,M): if sortdata[i][1][0] == sortdata[i-1][1][0]: cnt += 1 else: ...
import sys N,M = map(int,input().split()) data = [[i,list(map(int,sys.stdin.readline().rstrip().split()))] for i in range(M)] # print(data) sortdata = sorted(data, key=lambda data:data[1]) # print(sortdata) cnt = 1 sortdata[0].append(1) for i in range(1,M): if sortdata[i][1][0] == sortdata[i-1][1][0]: ...
20
21
538
573
N, M = map(int, input().split()) data = [[i, list(map(int, input().split()))] for i in range(M)] # print(data) sortdata = sorted(data, key=lambda data: data[1]) # print(sortdata) cnt = 1 sortdata[0].append(1) for i in range(1, M): if sortdata[i][1][0] == sortdata[i - 1][1][0]: cnt += 1 else: cnt...
import sys N, M = map(int, input().split()) data = [[i, list(map(int, sys.stdin.readline().rstrip().split()))] for i in range(M)] # print(data) sortdata = sorted(data, key=lambda data: data[1]) # print(sortdata) cnt = 1 sortdata[0].append(1) for i in range(1, M): if sortdata[i][1][0] == sortdata[i - 1][1][0]: ...
false
4.761905
[ "+import sys", "+", "-data = [[i, list(map(int, input().split()))] for i in range(M)]", "+data = [[i, list(map(int, sys.stdin.readline().rstrip().split()))] for i in range(M)]" ]
false
0.070273
0.072538
0.968767
[ "s332793820", "s292307317" ]
u562935282
p03221
python
s641384715
s353532890
802
729
35,940
46,384
Accepted
Accepted
9.1
N, M = list(map(int, input().split())) a = [[] for _ in range(N + 1)] for i in range(M): p, y = list(map(int, input().split())) a[p].append((y, i)) ans = [None for _ in range(M)] for p in range(1, N + 1): for e, (y, i) in enumerate(sorted(a[p], key=lambda x: x[0]), 1): ans[i] = str(p).zf...
from collections import defaultdict from operator import itemgetter n, m = map(int, input().split()) d = defaultdict(list) for query_idx in range(m): pref_idx, year = map(int, input().split()) d[pref_idx].append((year, query_idx)) ans = [None] * m for pref_idx in d.keys(): d[pref_idx].sort(ke...
14
17
374
513
N, M = list(map(int, input().split())) a = [[] for _ in range(N + 1)] for i in range(M): p, y = list(map(int, input().split())) a[p].append((y, i)) ans = [None for _ in range(M)] for p in range(1, N + 1): for e, (y, i) in enumerate(sorted(a[p], key=lambda x: x[0]), 1): ans[i] = str(p).zfill(6) + str...
from collections import defaultdict from operator import itemgetter n, m = map(int, input().split()) d = defaultdict(list) for query_idx in range(m): pref_idx, year = map(int, input().split()) d[pref_idx].append((year, query_idx)) ans = [None] * m for pref_idx in d.keys(): d[pref_idx].sort(key=itemgetter(0...
false
17.647059
[ "-N, M = list(map(int, input().split()))", "-a = [[] for _ in range(N + 1)]", "-for i in range(M):", "- p, y = list(map(int, input().split()))", "- a[p].append((y, i))", "-ans = [None for _ in range(M)]", "-for p in range(1, N + 1):", "- for e, (y, i) in enumerate(sorted(a[p], key=lambda x: x...
false
0.046263
0.046541
0.994023
[ "s641384715", "s353532890" ]
u768896740
p03274
python
s096028414
s740261095
96
85
14,512
15,628
Accepted
Accepted
11.46
n, k = list(map(int, input().split())) x = list(map(int, input().split())) num = 1000000000 def cal_num(a, b): if x[a] * x[b] < 0: return min(abs(x[a]), abs(x[b])) * 2 + max(abs(x[a]), abs(x[b])) else: return max(abs(x[a]), abs(x[b])) for i in range(n-k+1): c = cal_num(i, i+k-...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) if k == 1: min_num = 10**20 for i in x: if abs(i) < min_num: min_num = abs(i) print(min_num) exit() min_dist = 10**20 dist = 0 for i in range(n-k+1): dist = (x[i+k-1] - x[i]) dis...
17
23
366
417
n, k = list(map(int, input().split())) x = list(map(int, input().split())) num = 1000000000 def cal_num(a, b): if x[a] * x[b] < 0: return min(abs(x[a]), abs(x[b])) * 2 + max(abs(x[a]), abs(x[b])) else: return max(abs(x[a]), abs(x[b])) for i in range(n - k + 1): c = cal_num(i, i + k - 1) ...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) if k == 1: min_num = 10**20 for i in x: if abs(i) < min_num: min_num = abs(i) print(min_num) exit() min_dist = 10**20 dist = 0 for i in range(n - k + 1): dist = x[i + k - 1] - x[i] dist += min(abs(x[i ...
false
26.086957
[ "-num = 1000000000", "-", "-", "-def cal_num(a, b):", "- if x[a] * x[b] < 0:", "- return min(abs(x[a]), abs(x[b])) * 2 + max(abs(x[a]), abs(x[b]))", "- else:", "- return max(abs(x[a]), abs(x[b]))", "-", "-", "+if k == 1:", "+ min_num = 10**20", "+ for i in x:", "+...
false
0.045142
0.035646
1.266405
[ "s096028414", "s740261095" ]
u711539583
p02919
python
s659099944
s076931289
1,676
1,302
129,388
100,520
Accepted
Accepted
22.32
class SegTree(): def __init__(self, A): n_ = len(A) self.n = 1 while self.n < n_: self.n *= 2 self.tree = [float('inf') for _ in range(2 * self.n - 1)] for k, a in enumerate(A): self.update(k, a) def update(self, k, a): k += sel...
INF = 10 ** 6 class SegTree(): def __init__(self, A): n_ = len(A) self.n = 1 while self.n < n_: self.n *= 2 self.tree = [INF for _ in range(2 * self.n - 1)] for k, a in enumerate(A): self.update(k, a) def update(self, k, a): ...
76
77
1,782
1,767
class SegTree: def __init__(self, A): n_ = len(A) self.n = 1 while self.n < n_: self.n *= 2 self.tree = [float("inf") for _ in range(2 * self.n - 1)] for k, a in enumerate(A): self.update(k, a) def update(self, k, a): k += self.n - 1 ...
INF = 10**6 class SegTree: def __init__(self, A): n_ = len(A) self.n = 1 while self.n < n_: self.n *= 2 self.tree = [INF for _ in range(2 * self.n - 1)] for k, a in enumerate(A): self.update(k, a) def update(self, k, a): k += self.n - 1 ...
false
1.298701
[ "+INF = 10**6", "+", "+", "- self.tree = [float(\"inf\") for _ in range(2 * self.n - 1)]", "+ self.tree = [INF for _ in range(2 * self.n - 1)]", "- res = float(\"inf\")", "+ res = INF", "-INF = 10 * n" ]
false
0.046598
0.045803
1.017345
[ "s659099944", "s076931289" ]
u519922200
p02681
python
s940326209
s604360850
92
72
61,720
61,488
Accepted
Accepted
21.74
S=str(eval(input())) B=str(eval(input())) if B[:-1:]==S: print('Yes') else: print('No')
S1=str(eval(input())) S2=str(eval(input())) ans=0 for i in range(len(S1)): if S1[i]!=S2[i]: ans=1 if ans==1: print('No') else: print('Yes')
6
10
88
146
S = str(eval(input())) B = str(eval(input())) if B[:-1:] == S: print("Yes") else: print("No")
S1 = str(eval(input())) S2 = str(eval(input())) ans = 0 for i in range(len(S1)): if S1[i] != S2[i]: ans = 1 if ans == 1: print("No") else: print("Yes")
false
40
[ "-S = str(eval(input()))", "-B = str(eval(input()))", "-if B[:-1:] == S:", "+S1 = str(eval(input()))", "+S2 = str(eval(input()))", "+ans = 0", "+for i in range(len(S1)):", "+ if S1[i] != S2[i]:", "+ ans = 1", "+if ans == 1:", "+ print(\"No\")", "+else:", "-else:", "- print(...
false
0.097497
0.036276
2.687656
[ "s940326209", "s604360850" ]
u077291787
p03273
python
s127416974
s552012941
30
20
4,468
3,064
Accepted
Accepted
33.33
# ABC107B - Grid Compression h, w = list(map(int, input().rstrip().split())) data = [input().rstrip() for _ in range(h)] row = [False] * h col = [False] * w for i in range(h): for j in range(w): if data[i][j] == "#": row[i] = True col[j] = True for i in range(h): i...
# ABC107B - Grid Compression def main(): H, W, *A = open(0).read().split() H, W = int(H), int(W) X, Y = [0] * H, [0] * W for i, a in enumerate(A): for j, x in enumerate(a): if x == "#": X[i], Y[j] = 1, 1 ans = [] for i, x in enumerate(X): cu...
18
22
457
535
# ABC107B - Grid Compression h, w = list(map(int, input().rstrip().split())) data = [input().rstrip() for _ in range(h)] row = [False] * h col = [False] * w for i in range(h): for j in range(w): if data[i][j] == "#": row[i] = True col[j] = True for i in range(h): if row[i] == Tru...
# ABC107B - Grid Compression def main(): H, W, *A = open(0).read().split() H, W = int(H), int(W) X, Y = [0] * H, [0] * W for i, a in enumerate(A): for j, x in enumerate(a): if x == "#": X[i], Y[j] = 1, 1 ans = [] for i, x in enumerate(X): cur = "" ...
false
18.181818
[ "-h, w = list(map(int, input().rstrip().split()))", "-data = [input().rstrip() for _ in range(h)]", "-row = [False] * h", "-col = [False] * w", "-for i in range(h):", "- for j in range(w):", "- if data[i][j] == \"#\":", "- row[i] = True", "- col[j] = True", "-for i ...
false
0.035389
0.054486
0.649516
[ "s127416974", "s552012941" ]
u623819879
p03389
python
s937964868
s281952062
186
171
38,256
38,384
Accepted
Accepted
8.06
a=list(map(int,input().split())) m=max(a) t=0 if (m*3-sum(a))%2==1:t=3 print(((m*3-sum(a)+t)//2))
a=list(map(int,input().split())) m=max(a) t=m*3-sum(a) if t%2==1:t+=3 print((t//2))
5
5
100
86
a = list(map(int, input().split())) m = max(a) t = 0 if (m * 3 - sum(a)) % 2 == 1: t = 3 print(((m * 3 - sum(a) + t) // 2))
a = list(map(int, input().split())) m = max(a) t = m * 3 - sum(a) if t % 2 == 1: t += 3 print((t // 2))
false
0
[ "-t = 0", "-if (m * 3 - sum(a)) % 2 == 1:", "- t = 3", "-print(((m * 3 - sum(a) + t) // 2))", "+t = m * 3 - sum(a)", "+if t % 2 == 1:", "+ t += 3", "+print((t // 2))" ]
false
0.046741
0.081341
0.574626
[ "s937964868", "s281952062" ]
u309120194
p02790
python
s523966113
s182397998
27
23
8,984
9,020
Accepted
Accepted
14.81
a_str, b_str = input().split() a = int(a_str) b = int(b_str) A = a_str*b B = b_str*a print((min(A, B)))
a, b = list(map(int, input().split())) if a > b: print((str(b) * a)) elif a < b: print((str(a) * b)) else: print((str(a) * a))
8
8
111
128
a_str, b_str = input().split() a = int(a_str) b = int(b_str) A = a_str * b B = b_str * a print((min(A, B)))
a, b = list(map(int, input().split())) if a > b: print((str(b) * a)) elif a < b: print((str(a) * b)) else: print((str(a) * a))
false
0
[ "-a_str, b_str = input().split()", "-a = int(a_str)", "-b = int(b_str)", "-A = a_str * b", "-B = b_str * a", "-print((min(A, B)))", "+a, b = list(map(int, input().split()))", "+if a > b:", "+ print((str(b) * a))", "+elif a < b:", "+ print((str(a) * b))", "+else:", "+ print((str(a) *...
false
0.044748
0.045725
0.978614
[ "s523966113", "s182397998" ]
u647656433
p02899
python
s307037141
s268995870
506
247
70,444
22,848
Accepted
Accepted
51.19
n=int(eval(input())) a=[int(_) for _ in input().split()] aa=[[a[i],i+1] for i in range(n)] aa.sort() b=[str(aa[i][1]) for i in range(n)] print((' '.join(b)))
n=int(eval(input())) a=[int(_) for _ in input().split()] b=[[a[i],i+1] for i in range(n)] b.sort() print((*[b[i][1] for i in range(n)]))
6
5
155
132
n = int(eval(input())) a = [int(_) for _ in input().split()] aa = [[a[i], i + 1] for i in range(n)] aa.sort() b = [str(aa[i][1]) for i in range(n)] print((" ".join(b)))
n = int(eval(input())) a = [int(_) for _ in input().split()] b = [[a[i], i + 1] for i in range(n)] b.sort() print((*[b[i][1] for i in range(n)]))
false
16.666667
[ "-aa = [[a[i], i + 1] for i in range(n)]", "-aa.sort()", "-b = [str(aa[i][1]) for i in range(n)]", "-print((\" \".join(b)))", "+b = [[a[i], i + 1] for i in range(n)]", "+b.sort()", "+print((*[b[i][1] for i in range(n)]))" ]
false
0.048023
0.09616
0.499402
[ "s307037141", "s268995870" ]
u150984829
p02265
python
s788453944
s957100126
1,200
1,090
69,728
69,732
Accepted
Accepted
9.17
import collections,sys d=collections.deque() eval(input()) for e in sys.stdin: if'i'==e[0]:d.appendleft(e.split()[1]) else: if' '==e[6]: m=e.split()[1] if m in d:d.remove(m) elif len(e)%2:d.pop() else:d.popleft() print((*d))
import collections,sys def s(): d=collections.deque() eval(input()) for e in sys.stdin: if'i'==e[0]:d.appendleft(e.split()[1]) else: if' '==e[6]: m=e.split()[1] if m in d:d.remove(m) elif len(e)%2:d.pop() else:d.popleft() print((*d)) if'__main__'==__name__:s()
12
14
242
291
import collections, sys d = collections.deque() eval(input()) for e in sys.stdin: if "i" == e[0]: d.appendleft(e.split()[1]) else: if " " == e[6]: m = e.split()[1] if m in d: d.remove(m) elif len(e) % 2: d.pop() else: ...
import collections, sys def s(): d = collections.deque() eval(input()) for e in sys.stdin: if "i" == e[0]: d.appendleft(e.split()[1]) else: if " " == e[6]: m = e.split()[1] if m in d: d.remove(m) elif l...
false
14.285714
[ "-d = collections.deque()", "-eval(input())", "-for e in sys.stdin:", "- if \"i\" == e[0]:", "- d.appendleft(e.split()[1])", "- else:", "- if \" \" == e[6]:", "- m = e.split()[1]", "- if m in d:", "- d.remove(m)", "- elif len(e) % 2...
false
0.041902
0.03915
1.070299
[ "s788453944", "s957100126" ]
u744920373
p02659
python
s087997526
s577449445
27
24
9,892
9,920
Accepted
Accepted
11.11
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(str, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): ret...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): ret...
19
24
772
917
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(str, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] de...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] de...
false
20.833333
[ "- return list(map(str, sys.stdin.readline().split()))", "+ return list(map(int, sys.stdin.readline().split()))", "-A, B = mi()", "+\"\"\"", "+A, B = map(str, sys.stdin.readline().split())", "-print((A * B // 1))", "+print(A * B//1)", "+\"\"\"", "+A, B = list(map(str, sys.stdin.readline().spli...
false
0.045028
0.042139
1.068539
[ "s087997526", "s577449445" ]
u407160848
p02694
python
s667033507
s276343819
95
62
68,648
63,556
Accepted
Accepted
34.74
import math from functools import reduce from collections import deque import sys sys.setrecursionlimit(10**7) # スペース区切りの入力を読み込んで数値リストにして返します。 def get_nums_l(): return [ int(s) for s in input().split(" ")] # 改行区切りの入力をn行読み込んで数値リストにして返します。 def get_nums_n(n): return [ int(input()) for _ in range(n)] ...
x = int(eval(input())) a = 100 count = 0 while a < x: a = int(a*101//100) count += 1 print(count)
39
9
759
111
import math from functools import reduce from collections import deque import sys sys.setrecursionlimit(10**7) # スペース区切りの入力を読み込んで数値リストにして返します。 def get_nums_l(): return [int(s) for s in input().split(" ")] # 改行区切りの入力をn行読み込んで数値リストにして返します。 def get_nums_n(n): return [int(input()) for _ in range(n)] # 改行またはスペース...
x = int(eval(input())) a = 100 count = 0 while a < x: a = int(a * 101 // 100) count += 1 print(count)
false
76.923077
[ "-import math", "-from functools import reduce", "-from collections import deque", "-import sys", "-", "-sys.setrecursionlimit(10**7)", "-# スペース区切りの入力を読み込んで数値リストにして返します。", "-def get_nums_l():", "- return [int(s) for s in input().split(\" \")]", "-", "-", "-# 改行区切りの入力をn行読み込んで数値リストにして返します。", ...
false
0.036243
0.035631
1.017179
[ "s667033507", "s276343819" ]
u329455846
p03001
python
s611734933
s935798366
20
17
3,060
2,940
Accepted
Accepted
15
w,h,x,y = list(map(int,input().split())) flag = 0 if ((x/w) ==0.5) and ((y/h) == 0.5): flag = 1 print(((w*h)/2,flag))
w,h,x,y = list(map(int,input().split())) flag = 0 if (2*x == w) and (2 * y == h): flag = 1 print(((w*h)/2,flag))
5
5
115
110
w, h, x, y = list(map(int, input().split())) flag = 0 if ((x / w) == 0.5) and ((y / h) == 0.5): flag = 1 print(((w * h) / 2, flag))
w, h, x, y = list(map(int, input().split())) flag = 0 if (2 * x == w) and (2 * y == h): flag = 1 print(((w * h) / 2, flag))
false
0
[ "-if ((x / w) == 0.5) and ((y / h) == 0.5):", "+if (2 * x == w) and (2 * y == h):" ]
false
0.047832
0.048068
0.995091
[ "s611734933", "s935798366" ]
u535423069
p02695
python
s690888836
s349332377
1,589
613
9,288
9,204
Accepted
Accepted
61.42
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range...
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range...
36
41
964
1,058
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdi...
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdi...
false
12.195122
[ "-from itertools import combinations_with_replacement", "-", "+sys.setrecursionlimit(10**6)", "-for p in combinations_with_replacement(list(range(1, m + 1)), n):", "- t = 0", "- for i in range(q):", "- a, b, c, d = abcd[i]", "- a -= 1", "- b -= 1", "- if p[b] - p[...
false
0.069683
0.136398
0.51088
[ "s690888836", "s349332377" ]
u926412290
p03170
python
s319453955
s640201708
161
142
74,240
72,520
Accepted
Accepted
11.8
N, K = list(map(int, input().split())) a = list(map(int, input().split())) dp = [0] * (K + 1) for i in range(1, K + 1): for j in range(N): if i - a[j] >= 0 and dp[i - a[j]] == 0: dp[i] = 1 print(('First' if dp[K] else 'Second'))
N, K = list(map(int, input().split())) a = list(map(int, input().split())) dp = [0] * (K + 1) for i in range(1, K + 1): for j in a: if i - j >= 0 and dp[i - j] == 0: dp[i] = 1 print(('First' if dp[K] else 'Second'))
11
11
258
245
N, K = list(map(int, input().split())) a = list(map(int, input().split())) dp = [0] * (K + 1) for i in range(1, K + 1): for j in range(N): if i - a[j] >= 0 and dp[i - a[j]] == 0: dp[i] = 1 print(("First" if dp[K] else "Second"))
N, K = list(map(int, input().split())) a = list(map(int, input().split())) dp = [0] * (K + 1) for i in range(1, K + 1): for j in a: if i - j >= 0 and dp[i - j] == 0: dp[i] = 1 print(("First" if dp[K] else "Second"))
false
0
[ "- for j in range(N):", "- if i - a[j] >= 0 and dp[i - a[j]] == 0:", "+ for j in a:", "+ if i - j >= 0 and dp[i - j] == 0:" ]
false
0.051867
0.048482
1.069813
[ "s319453955", "s640201708" ]
u997641430
p02623
python
s558706589
s560896346
374
206
47,356
144,136
Accepted
Accepted
44.92
n, m, k = list(map(int, input().split())) *A, = list(map(int, input().split())) *B, = list(map(int, input().split())) SA, SB = [0], [0] for i in range(n): SA.append(SA[i] + A[i]) for j in range(m): SB.append(SB[j] + B[j]) ans, tmp = 0, m for i in range(n + 1): if SA[i] > k: break for...
import bisect n, m, k = list(map(int, input().split())) *A, = list(map(int, input().split())) *B, = list(map(int, input().split())) SA, SB = [0], [0] for i in range(n): SA.append(SA[i] + A[i]) for j in range(m): SB.append(SB[j] + B[j]) ans = 0 for i in range(n + 1): if SA[i] <= k: j = bi...
18
15
433
382
n, m, k = list(map(int, input().split())) (*A,) = list(map(int, input().split())) (*B,) = list(map(int, input().split())) SA, SB = [0], [0] for i in range(n): SA.append(SA[i] + A[i]) for j in range(m): SB.append(SB[j] + B[j]) ans, tmp = 0, m for i in range(n + 1): if SA[i] > k: break for j in ra...
import bisect n, m, k = list(map(int, input().split())) (*A,) = list(map(int, input().split())) (*B,) = list(map(int, input().split())) SA, SB = [0], [0] for i in range(n): SA.append(SA[i] + A[i]) for j in range(m): SB.append(SB[j] + B[j]) ans = 0 for i in range(n + 1): if SA[i] <= k: j = bisect.bi...
false
16.666667
[ "+import bisect", "+", "-ans, tmp = 0, m", "+ans = 0", "- if SA[i] > k:", "- break", "- for j in range(tmp + 1)[::-1]:", "- if SA[i] + SB[j] <= k:", "- break", "- ans = max(ans, i + j)", "- tmp = j", "+ if SA[i] <= k:", "+ j = bisect.bisect_righ...
false
0.083397
0.084899
0.982306
[ "s558706589", "s560896346" ]
u968166680
p02856
python
s308272281
s633760547
308
262
112,172
96,068
Accepted
Accepted
14.94
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): M, *DC = list(map(int, read().split())) total = digits = 0 for d, c in zip(DC[::2], DC[1::2]): total += d * c digits += c...
import sys read = sys.stdin.buffer.read def main(): M, *DC = list(map(int, read().split())) total = digits = 0 for d, c in zip(DC[::2], DC[1::2]): total += d * c digits += c print((digits - 1 + (total - 1) // 9)) return if __name__ == '__main__': main()
25
19
432
311
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def main(): M, *DC = list(map(int, read().split())) total = digits = 0 for d, c in zip(DC[::2], DC[1::2]): total += d * c digits += c ans = digits ...
import sys read = sys.stdin.buffer.read def main(): M, *DC = list(map(int, read().split())) total = digits = 0 for d, c in zip(DC[::2], DC[1::2]): total += d * c digits += c print((digits - 1 + (total - 1) // 9)) return if __name__ == "__main__": main()
false
24
[ "-read = sys.stdin.read", "-readline = sys.stdin.readline", "-readlines = sys.stdin.readlines", "-sys.setrecursionlimit(10**9)", "-INF = 1 << 60", "+read = sys.stdin.buffer.read", "- ans = digits - 1 + (total - 1) // 9", "- print(ans)", "+ print((digits - 1 + (total - 1) // 9))" ]
false
0.075095
0.077489
0.969111
[ "s308272281", "s633760547" ]
u257162238
p03346
python
s729304282
s258893438
532
149
37,560
24,784
Accepted
Accepted
71.99
import sys input = sys.stdin.readline import heapq def read(): N = int(input().strip()) P = [] for i in range(N): p = int(input().strip()) P.append(p) return N, P def solve(N, P): h = [] for i in range(N): heapq.heappush(h, (P[i], i+1)) max_count...
import sys input = sys.stdin.readline import heapq def read(): N = int(input().strip()) P = [] for i in range(N): p = int(input().strip()) P.append(p) return N, P def solve(N, P): Q = [0 for i in range(N)] for i in range(N): Q[P[i]-1] = i max_cou...
37
37
739
726
import sys input = sys.stdin.readline import heapq def read(): N = int(input().strip()) P = [] for i in range(N): p = int(input().strip()) P.append(p) return N, P def solve(N, P): h = [] for i in range(N): heapq.heappush(h, (P[i], i + 1)) max_count = 0 count ...
import sys input = sys.stdin.readline import heapq def read(): N = int(input().strip()) P = [] for i in range(N): p = int(input().strip()) P.append(p) return N, P def solve(N, P): Q = [0 for i in range(N)] for i in range(N): Q[P[i] - 1] = i max_count = 0 coun...
false
0
[ "- h = []", "+ Q = [0 for i in range(N)]", "- heapq.heappush(h, (P[i], i + 1))", "+ Q[P[i] - 1] = i", "- for _ in range(N):", "- p, i = heapq.heappop(h)", "- if prev < i:", "+ for i in range(N):", "+ q = Q[i]", "+ if prev < q:", "- ...
false
0.067114
0.038563
1.740365
[ "s729304282", "s258893438" ]
u626891113
p02572
python
s905468325
s445922869
140
124
103,804
105,120
Accepted
Accepted
11.43
n = int(eval(input())) a = list(map(int, input().split())) a = [i % (10**9 + 7) for i in a] val = sum(a[1:]) ans = 0 for i in range(n - 1): ans += a[i]*val ans %= 10**9 + 7 val -= a[i + 1] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) val = sum(a[1:]) ans = 0 for i in range(n - 1): ans += a[i]*val ans %= 10**9 + 7 val -= a[i + 1] print(ans)
11
10
216
182
n = int(eval(input())) a = list(map(int, input().split())) a = [i % (10**9 + 7) for i in a] val = sum(a[1:]) ans = 0 for i in range(n - 1): ans += a[i] * val ans %= 10**9 + 7 val -= a[i + 1] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) val = sum(a[1:]) ans = 0 for i in range(n - 1): ans += a[i] * val ans %= 10**9 + 7 val -= a[i + 1] print(ans)
false
9.090909
[ "-a = [i % (10**9 + 7) for i in a]" ]
false
0.060493
0.036753
1.645926
[ "s905468325", "s445922869" ]
u878849567
p02880
python
s366376652
s875381898
188
17
38,416
2,940
Accepted
Accepted
90.96
n = int(eval(input())) t = 0 for i in range(9): for j in range(9): if n == (i + 1) * (j + 1): t += 1 if t == 0: print('No') else: print('Yes')
n = int(eval(input())) for i in range(1, 10): if n % i == 0: if n / i <= 9: print("Yes") break else: print("No")
12
8
171
154
n = int(eval(input())) t = 0 for i in range(9): for j in range(9): if n == (i + 1) * (j + 1): t += 1 if t == 0: print("No") else: print("Yes")
n = int(eval(input())) for i in range(1, 10): if n % i == 0: if n / i <= 9: print("Yes") break else: print("No")
false
33.333333
[ "-t = 0", "-for i in range(9):", "- for j in range(9):", "- if n == (i + 1) * (j + 1):", "- t += 1", "-if t == 0:", "+for i in range(1, 10):", "+ if n % i == 0:", "+ if n / i <= 9:", "+ print(\"Yes\")", "+ break", "+else:", "-else:", "- ...
false
0.075509
0.034448
2.191966
[ "s366376652", "s875381898" ]
u111365362
p02814
python
s758310232
s281229830
263
133
63,856
14,400
Accepted
Accepted
49.43
n,m = list(map(int,input().split())) a = list(map(int,input().split())) cnt = 0 while True: if a[0] % 2 == 0: a[0] //= 2 cnt += 1 else: break div = 2 ** cnt if div != 1: m //= (div//2) for i in range(1,n): if a[i] % div == 0: a[i] //= div if a[i] % 2 == 0: print((0)) ...
n,m = list(map(int,input().split())) a = list(map(int,input().split())) b = 1 while a[0] % 2 == 0: a[0] //= 2 b *= 2 if b == 0: print((0)) else: for i in range(1,n): a[i] //= b if a[i] % 2 == 0: print((0)) break else: m //= b//2 lcm = a[0] for i in range(1,n): ...
38
31
659
566
n, m = list(map(int, input().split())) a = list(map(int, input().split())) cnt = 0 while True: if a[0] % 2 == 0: a[0] //= 2 cnt += 1 else: break div = 2**cnt if div != 1: m //= div // 2 for i in range(1, n): if a[i] % div == 0: a[i] //= div if a[i] % 2 == 0: ...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) b = 1 while a[0] % 2 == 0: a[0] //= 2 b *= 2 if b == 0: print((0)) else: for i in range(1, n): a[i] //= b if a[i] % 2 == 0: print((0)) break else: m //= b // 2 lcm = a[0...
false
18.421053
[ "-cnt = 0", "-while True:", "- if a[0] % 2 == 0:", "- a[0] //= 2", "- cnt += 1", "- else:", "- break", "-div = 2**cnt", "-if div != 1:", "- m //= div // 2", "-for i in range(1, n):", "- if a[i] % div == 0:", "- a[i] //= div", "+b = 1", "+while a[0]...
false
0.040875
0.090826
0.450041
[ "s758310232", "s281229830" ]
u340781749
p03491
python
s577551519
s915932952
1,517
409
4,204
3,836
Accepted
Accepted
73.04
from collections import defaultdict def solve(n, l, nums): xor = 0 if n == 1: for i in range(min(nums), l + 1): xor ^= i & -i return xor for i in range(min(nums), l + 1): ni = nums[i] for k in ni: if k ^ 1 not in ni: ...
from collections import defaultdict def solve(l, ss): xor = 0 for d in range(min(ss), l + 1): sl = ss[d] sl.sort() while sl: s = sl.pop() ps = s[:-1] ss[d + 1].append(ps) if s[-1] == '1' and sl and sl[-1][:-1] == ps: ...
27
26
617
602
from collections import defaultdict def solve(n, l, nums): xor = 0 if n == 1: for i in range(min(nums), l + 1): xor ^= i & -i return xor for i in range(min(nums), l + 1): ni = nums[i] for k in ni: if k ^ 1 not in ni: xor ^= i & -i ...
from collections import defaultdict def solve(l, ss): xor = 0 for d in range(min(ss), l + 1): sl = ss[d] sl.sort() while sl: s = sl.pop() ps = s[:-1] ss[d + 1].append(ps) if s[-1] == "1" and sl and sl[-1][:-1] == ps: sl.po...
false
3.703704
[ "-def solve(n, l, nums):", "+def solve(l, ss):", "- if n == 1:", "- for i in range(min(nums), l + 1):", "- xor ^= i & -i", "- return xor", "- for i in range(min(nums), l + 1):", "- ni = nums[i]", "- for k in ni:", "- if k ^ 1 not in ni:", "...
false
0.044403
0.036565
1.21435
[ "s577551519", "s915932952" ]
u628285938
p02623
python
s482934980
s185461668
317
283
40,136
47,452
Accepted
Accepted
10.73
# -*- coding: utf-8 -*- """ Created on Mon Sep 7 11:05:00 2020 @author: liang """ """ 片側を固定して、それぞれのケースに対して最適解を求める それぞれのケースについて index(b_i) =< index(b_i-1) であるから、bの最大値bestを保存して探索することで重複探索を回避できる """ N, M, K = list(map(int, input().split())) A = [0] + [int(x) for x in input().split()] B = [0] + [int(x) ...
N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) a, b = [0], [0] for i in range(N): a.append(a[i] + A[i]) for i in range(M): b.append(b[i] + B[i]) ans, j = 0, M for i in range(N + 1): if a[i] > K: break while b[j] > K - a[i]: j -= 1...
47
17
897
350
# -*- coding: utf-8 -*- """ Created on Mon Sep 7 11:05:00 2020 @author: liang """ """ 片側を固定して、それぞれのケースに対して最適解を求める それぞれのケースについて index(b_i) =< index(b_i-1) であるから、bの最大値bestを保存して探索することで重複探索を回避できる """ N, M, K = list(map(int, input().split())) A = [0] + [int(x) for x in input().split()] B = [0] + [int(x) for x in input().sp...
N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) a, b = [0], [0] for i in range(N): a.append(a[i] + A[i]) for i in range(M): b.append(b[i] + B[i]) ans, j = 0, M for i in range(N + 1): if a[i] > K: break while b[j] > K - a[i]: ...
false
63.829787
[ "-# -*- coding: utf-8 -*-", "-\"\"\"", "-Created on Mon Sep 7 11:05:00 2020", "-@author: liang", "-\"\"\"", "-\"\"\"", "-片側を固定して、それぞれのケースに対して最適解を求める", "-それぞれのケースについて", "-index(b_i) =< index(b_i-1)", "-であるから、bの最大値bestを保存して探索することで重複探索を回避できる", "-\"\"\"", "-A = [0] + [int(x) for x in input().spli...
false
0.037427
0.037509
0.997815
[ "s482934980", "s185461668" ]
u998741086
p02582
python
s622653690
s455107259
32
27
8,964
9,072
Accepted
Accepted
15.62
#!/usr/bin/env python3 s = eval(input()) if s == 'RRR': print((3)) exit() elif s == 'RRS' or s == 'SRR': print((2)) exit() elif s == 'RSR' or s == 'SRS' or s == 'RSS' or s == 'SSR': print((1)) exit() else: print((0)) exit()
#!/usr/bin/env python3 s = eval(input()) if 'RRR' in s: print((3)) elif 'RR' in s: print((2)) elif 'R' in s: print((1)) else: print((0))
16
12
259
152
#!/usr/bin/env python3 s = eval(input()) if s == "RRR": print((3)) exit() elif s == "RRS" or s == "SRR": print((2)) exit() elif s == "RSR" or s == "SRS" or s == "RSS" or s == "SSR": print((1)) exit() else: print((0)) exit()
#!/usr/bin/env python3 s = eval(input()) if "RRR" in s: print((3)) elif "RR" in s: print((2)) elif "R" in s: print((1)) else: print((0))
false
25
[ "-if s == \"RRR\":", "+if \"RRR\" in s:", "- exit()", "-elif s == \"RRS\" or s == \"SRR\":", "+elif \"RR\" in s:", "- exit()", "-elif s == \"RSR\" or s == \"SRS\" or s == \"RSS\" or s == \"SSR\":", "+elif \"R\" in s:", "- exit()", "- exit()" ]
false
0.165628
0.052052
3.181984
[ "s622653690", "s455107259" ]
u254871849
p03037
python
s579054145
s133611442
158
105
11,012
25,076
Accepted
Accepted
33.54
# 2019-11-13 08:30:54(JST) import sys # import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce # import operator as op # from scipy.misc import comb # float ...
import sys n, m, *lr = list(map(int, sys.stdin.read().split())) lr = list(zip(*[iter(lr)] * 2)) def main(): cnt = [0] * (n + 1) for l, r in lr: cnt[l-1] += 1 cnt[r] -= 1 for i in range(n): cnt[i+1] += cnt[i] res = 0 for i in range(n): res +...
27
23
681
413
# 2019-11-13 08:30:54(JST) import sys # import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce # import operator as op # from scipy.misc import comb # float # import ...
import sys n, m, *lr = list(map(int, sys.stdin.read().split())) lr = list(zip(*[iter(lr)] * 2)) def main(): cnt = [0] * (n + 1) for l, r in lr: cnt[l - 1] += 1 cnt[r] -= 1 for i in range(n): cnt[i + 1] += cnt[i] res = 0 for i in range(n): res += (cnt[i] == m) & 1 ...
false
14.814815
[ "-# 2019-11-13 08:30:54(JST)", "-# import collections", "-# import math", "-# from string import ascii_lowercase, ascii_uppercase, digits", "-# from bisect import bisect_left as bi_l, bisect_right as bi_r", "-# import itertools", "-# from functools import reduce", "-# import operator as op", "-# fro...
false
0.042982
0.060179
0.714239
[ "s579054145", "s133611442" ]
u072717685
p03645
python
s341276049
s731895365
558
379
21,856
26,540
Accepted
Accepted
32.08
def main(): n, m = list(map(int, input().split())) g1 = [] g2 = [] for _ in range(m): x, y = list(map(int, input().split())) if x == 1: g1.append(y) elif y == n: g2.append(x) sx = set(g1) sy = set(g2) sxy = sx.intersection(sy) ...
def main(): n, m = input().split() g1 = [] g2 = [] for _ in range(int(m)): x, y = input().split() if x == '1': g1.append(y) elif y == n: g2.append(x) sx = set(g1) sy = set(g2) sxy = sx.intersection(sy) if len(sxy): pri...
20
20
430
416
def main(): n, m = list(map(int, input().split())) g1 = [] g2 = [] for _ in range(m): x, y = list(map(int, input().split())) if x == 1: g1.append(y) elif y == n: g2.append(x) sx = set(g1) sy = set(g2) sxy = sx.intersection(sy) if len(sxy): ...
def main(): n, m = input().split() g1 = [] g2 = [] for _ in range(int(m)): x, y = input().split() if x == "1": g1.append(y) elif y == n: g2.append(x) sx = set(g1) sy = set(g2) sxy = sx.intersection(sy) if len(sxy): print("POSSIBLE")...
false
0
[ "- n, m = list(map(int, input().split()))", "+ n, m = input().split()", "- for _ in range(m):", "- x, y = list(map(int, input().split()))", "- if x == 1:", "+ for _ in range(int(m)):", "+ x, y = input().split()", "+ if x == \"1\":" ]
false
0.038372
0.040608
0.94493
[ "s341276049", "s731895365" ]
u077291787
p02579
python
s877240866
s638396980
370
245
96,600
91,912
Accepted
Accepted
33.78
# D - Wizard in Maze import sys from collections import deque from typing import List, Tuple class WarpableMaze: __slots__ = ["height", "width", "road", "wall", "unsearched", "dist"] def __init__( self, height: int, width: int, grid: List[bytes], road: st...
# D - Wizard in Maze import sys from collections import deque from typing import List, Tuple class WarpableMaze: __slots__ = ["height", "width", "unsearched", "dist"] def __init__( self, height: int, width: int, grid: List[bytes], road: str = ".", ) ...
99
90
3,030
2,687
# D - Wizard in Maze import sys from collections import deque from typing import List, Tuple class WarpableMaze: __slots__ = ["height", "width", "road", "wall", "unsearched", "dist"] def __init__( self, height: int, width: int, grid: List[bytes], road: str = ".", ...
# D - Wizard in Maze import sys from collections import deque from typing import List, Tuple class WarpableMaze: __slots__ = ["height", "width", "unsearched", "dist"] def __init__( self, height: int, width: int, grid: List[bytes], road: str = ".", ) -> None: ...
false
9.090909
[ "- __slots__ = [\"height\", \"width\", \"road\", \"wall\", \"unsearched\", \"dist\"]", "+ __slots__ = [\"height\", \"width\", \"unsearched\", \"dist\"]", "- wall: str = \"#\",", "- self.road = road", "- self.wall = wall", "- self.dist = self._convert_grid_to_dist(grid)", ...
false
0.043201
0.051344
0.841386
[ "s877240866", "s638396980" ]
u073549161
p03048
python
s304579054
s386771702
260
213
40,300
40,944
Accepted
Accepted
18.08
r, g, b, n = list(map(int,input().split())) res = 0 for i in range(n // r + 1): for j in range((n-r*i) // g + 1): if (n - (i * r) - (g * j) ) % b == 0: #print("{0}, {1}, {2}".format(i, j, (n - (i * r) - (g * j) ) % g)) res += 1 print(res)
r,g,b,n = list(map(int,input().split())) res = 0 for rr in range(0, n // r + 1): for gg in range(0, (n - rr) // g + 1): if (n - r*rr - g*gg) < 0: break if (n - r*rr - g*gg) % b == 0: res += 1 print(res)
9
9
278
249
r, g, b, n = list(map(int, input().split())) res = 0 for i in range(n // r + 1): for j in range((n - r * i) // g + 1): if (n - (i * r) - (g * j)) % b == 0: # print("{0}, {1}, {2}".format(i, j, (n - (i * r) - (g * j) ) % g)) res += 1 print(res)
r, g, b, n = list(map(int, input().split())) res = 0 for rr in range(0, n // r + 1): for gg in range(0, (n - rr) // g + 1): if (n - r * rr - g * gg) < 0: break if (n - r * rr - g * gg) % b == 0: res += 1 print(res)
false
0
[ "-for i in range(n // r + 1):", "- for j in range((n - r * i) // g + 1):", "- if (n - (i * r) - (g * j)) % b == 0:", "- # print(\"{0}, {1}, {2}\".format(i, j, (n - (i * r) - (g * j) ) % g))", "+for rr in range(0, n // r + 1):", "+ for gg in range(0, (n - rr) // g + 1):", "+ ...
false
0.084886
0.11079
0.766191
[ "s304579054", "s386771702" ]
u077291787
p03231
python
s970172410
s495529374
38
17
5,340
3,316
Accepted
Accepted
55.26
# AGC028A - Two Abbreviations from fractions import gcd def main(): n, m = tuple(map(int, input().rstrip().split())) S, T = tuple(input().rstrip() for _ in range(2)) g = gcd(n, m) flg = S[:: n // g] == T[:: m // g] print((n // g * m if flg else -1)) if __name__ == "__main__": ma...
# AGC028A - Two Abbreviations def gcd(a, b): while b > 0: a, b = b, a % b return a def main(): n, m = tuple(map(int, input().rstrip().split())) S, T = tuple(input().rstrip() for _ in range(2)) g = gcd(n, m) flg = S[:: n // g] == T[:: m // g] print((n // g * m if flg els...
14
17
322
368
# AGC028A - Two Abbreviations from fractions import gcd def main(): n, m = tuple(map(int, input().rstrip().split())) S, T = tuple(input().rstrip() for _ in range(2)) g = gcd(n, m) flg = S[:: n // g] == T[:: m // g] print((n // g * m if flg else -1)) if __name__ == "__main__": main()
# AGC028A - Two Abbreviations def gcd(a, b): while b > 0: a, b = b, a % b return a def main(): n, m = tuple(map(int, input().rstrip().split())) S, T = tuple(input().rstrip() for _ in range(2)) g = gcd(n, m) flg = S[:: n // g] == T[:: m // g] print((n // g * m if flg else -1)) if ...
false
17.647059
[ "-from fractions import gcd", "+def gcd(a, b):", "+ while b > 0:", "+ a, b = b, a % b", "+ return a" ]
false
0.179969
0.085688
2.100295
[ "s970172410", "s495529374" ]
u703950586
p03173
python
s255977742
s647931065
465
429
45,160
44,908
Accepted
Accepted
7.74
import sys,queue,math,copy,itertools,bisect,collections,heapq INF = 10**18 LI = lambda : [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) N = NI() a = LI() sn = [[0 for _ in range(N)] for _ in range(N)] dp = [[INF for _ in range(N)] for _ in range(N)] for i in range(N): ...
import sys INF = 10**14 LI = lambda : [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) N = NI() a = LI() sn = [[0 for _ in range(N)] for _ in range(N)] dp = [[INF for _ in range(N)] for _ in range(N)] for i in range(N): x = 0 for j in range(i,N): x += a...
24
22
665
563
import sys, queue, math, copy, itertools, bisect, collections, heapq INF = 10**18 LI = lambda: [int(x) for x in sys.stdin.readline().split()] NI = lambda: int(sys.stdin.readline()) N = NI() a = LI() sn = [[0 for _ in range(N)] for _ in range(N)] dp = [[INF for _ in range(N)] for _ in range(N)] for i in range(N): x...
import sys INF = 10**14 LI = lambda: [int(x) for x in sys.stdin.readline().split()] NI = lambda: int(sys.stdin.readline()) N = NI() a = LI() sn = [[0 for _ in range(N)] for _ in range(N)] dp = [[INF for _ in range(N)] for _ in range(N)] for i in range(N): x = 0 for j in range(i, N): x += a[j] s...
false
8.333333
[ "-import sys, queue, math, copy, itertools, bisect, collections, heapq", "+import sys", "-INF = 10**18", "+INF = 10**14", "- if i < N - 1:", "- dp[i][i + 1] = sn[i][i + 1]", "-for j in range(2, N):", "- for i in range(j - 2, -1, -1):", "+for j in range(1, N):", "+ for i in range(j ...
false
0.03893
0.04561
0.853525
[ "s255977742", "s647931065" ]
u983853152
p03319
python
s286652296
s621789221
42
18
13,880
4,724
Accepted
Accepted
57.14
N,K = list(map(int, input().split())) A=list(map(int, input().split())) print((-(-(N-1)//(K-1))))
N,K = list(map(int, input().split())) _ = eval(input()) print((-(-(N-1)//(K-1))))
3
3
92
69
N, K = list(map(int, input().split())) A = list(map(int, input().split())) print((-(-(N - 1) // (K - 1))))
N, K = list(map(int, input().split())) _ = eval(input()) print((-(-(N - 1) // (K - 1))))
false
0
[ "-A = list(map(int, input().split()))", "+_ = eval(input())" ]
false
0.041866
0.104696
0.399883
[ "s286652296", "s621789221" ]
u812354010
p02971
python
s599234374
s899548369
373
320
102,908
102,316
Accepted
Accepted
14.21
n=int(eval(input())) import heapq a=[] a_heap=[] for i in range(n): tmp=int(eval(input())) a.append(tmp) heapq.heappush(a_heap,(-1)*tmp) for i in range(n): max_1=heapq.heappop(a_heap) if max_1==(-1)*a[i]: max_2=heapq.heappop(a_heap) print(((-1)*max_2)) heapq....
n=int(eval(input())) a=[] a_sort=[] for i in range(n): tmp=int(eval(input())) a.append(tmp) a_sort.append(tmp) a_sort.sort(reverse=True) for i in range(n): if a_sort[0]==a[i]:print((a_sort[1])) else:print((a_sort[0]))
18
13
390
235
n = int(eval(input())) import heapq a = [] a_heap = [] for i in range(n): tmp = int(eval(input())) a.append(tmp) heapq.heappush(a_heap, (-1) * tmp) for i in range(n): max_1 = heapq.heappop(a_heap) if max_1 == (-1) * a[i]: max_2 = heapq.heappop(a_heap) print(((-1) * max_2)) h...
n = int(eval(input())) a = [] a_sort = [] for i in range(n): tmp = int(eval(input())) a.append(tmp) a_sort.append(tmp) a_sort.sort(reverse=True) for i in range(n): if a_sort[0] == a[i]: print((a_sort[1])) else: print((a_sort[0]))
false
27.777778
[ "-import heapq", "-", "-a_heap = []", "+a_sort = []", "- heapq.heappush(a_heap, (-1) * tmp)", "+ a_sort.append(tmp)", "+a_sort.sort(reverse=True)", "- max_1 = heapq.heappop(a_heap)", "- if max_1 == (-1) * a[i]:", "- max_2 = heapq.heappop(a_heap)", "- print(((-1) * max_2...
false
0.045235
0.043575
1.0381
[ "s599234374", "s899548369" ]
u075012704
p03418
python
s781189577
s176433656
94
82
2,940
2,940
Accepted
Accepted
12.77
N, K = list(map(int, input().split())) ans = 0 for b in range(1, N + 1): ans += (N // b) * max(0, b - K) + max(0, (N % b) - K + 1) print((ans - (N if K == 0 else 0)))
N, K = list(map(int, input().split())) ans = 0 for b in range(K + 1, N + 1): ans += (b - K) * (N // b) ans += max(0, N % b - K + 1) if K == 0: ans -= N print(ans)
5
11
167
186
N, K = list(map(int, input().split())) ans = 0 for b in range(1, N + 1): ans += (N // b) * max(0, b - K) + max(0, (N % b) - K + 1) print((ans - (N if K == 0 else 0)))
N, K = list(map(int, input().split())) ans = 0 for b in range(K + 1, N + 1): ans += (b - K) * (N // b) ans += max(0, N % b - K + 1) if K == 0: ans -= N print(ans)
false
54.545455
[ "-for b in range(1, N + 1):", "- ans += (N // b) * max(0, b - K) + max(0, (N % b) - K + 1)", "-print((ans - (N if K == 0 else 0)))", "+for b in range(K + 1, N + 1):", "+ ans += (b - K) * (N // b)", "+ ans += max(0, N % b - K + 1)", "+if K == 0:", "+ ans -= N", "+print(ans)" ]
false
0.127558
0.046135
2.764873
[ "s781189577", "s176433656" ]
u600402037
p02999
python
s827312300
s361631028
20
18
3,060
2,940
Accepted
Accepted
10
X, A = list(map(int,input().split())) print((0 if X < A else 10))
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) X, A = lr() print((0 if X < A else 10)) #
2
9
58
169
X, A = list(map(int, input().split())) print((0 if X < A else 10))
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) X, A = lr() print((0 if X < A else 10)) #
false
77.777778
[ "-X, A = list(map(int, input().split()))", "+import sys", "+", "+sr = lambda: sys.stdin.readline().rstrip()", "+ir = lambda: int(sr())", "+lr = lambda: list(map(int, sr().split()))", "+X, A = lr()", "+#" ]
false
0.039611
0.039676
0.998362
[ "s827312300", "s361631028" ]
u811733736
p00508
python
s398162663
s245200254
20,600
16,990
88,492
84,488
Accepted
Accepted
17.52
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585 """ import sys from sys import stdin from collections import namedtuple input = stdin.readline def closest_part(points, n): # ?????¬???p324??? if n <= 1: return float('inf') m = n // 2 x ...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585 """ import sys from sys import stdin from collections import namedtuple input = stdin.readline def closest_part(points, n): # ?????¬???p324??? if n <= 1: return float('inf') m = n // 2 x ...
45
46
1,088
1,111
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585 """ import sys from sys import stdin from collections import namedtuple input = stdin.readline def closest_part(points, n): # ?????¬???p324??? if n <= 1: return float("inf") m = n // 2 x = points[m].x ...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585 """ import sys from sys import stdin from collections import namedtuple input = stdin.readline def closest_part(points, n): # ?????¬???p324??? if n <= 1: return float("inf") m = n // 2 x = points[m][0] ...
false
2.173913
[ "- x = points[m].x", "+ x = points[m][0]", "- points.sort(key=lambda p: p.y)", "+ points.sort(key=lambda p: p[1])", "- if (p.x - x) ** 2 >= d:", "+ if (p[0] - x) ** 2 >= d:", "- for j in range(len(b)):", "- dx = p.x - b[-j - 1].x", "- dy = p.y -...
false
0.044238
0.044355
0.997358
[ "s398162663", "s245200254" ]
u360116509
p03262
python
s880248267
s157858381
215
184
14,252
14,252
Accepted
Accepted
14.42
def main(): N, X = list(map(int, input().split())) dx = [abs(X - x) for x in map(int, input().split())] if N == 1: ans = dx[0] else: ans = 10 ** 9 for i in range(N - 1): nm = max(dx[i], dx[i + 1]) dm = min(dx[i], dx[i + 1]) while True: m...
def main(): N, X = list(map(int, input().split())) dx = [abs(X - x) for x in map(int, input().split())] if N == 1: ans = dx[0] else: ans = 10 ** 9 for i in range(N - 1): nm = dx[i] dm = dx[i + 1] while True: mod = nm % dm if...
21
21
475
447
def main(): N, X = list(map(int, input().split())) dx = [abs(X - x) for x in map(int, input().split())] if N == 1: ans = dx[0] else: ans = 10**9 for i in range(N - 1): nm = max(dx[i], dx[i + 1]) dm = min(dx[i], dx[i + 1]) while True: mod = nm % dm ...
def main(): N, X = list(map(int, input().split())) dx = [abs(X - x) for x in map(int, input().split())] if N == 1: ans = dx[0] else: ans = 10**9 for i in range(N - 1): nm = dx[i] dm = dx[i + 1] while True: mod = nm % dm if mod == 0: ...
false
0
[ "- nm = max(dx[i], dx[i + 1])", "- dm = min(dx[i], dx[i + 1])", "+ nm = dx[i]", "+ dm = dx[i + 1]" ]
false
0.044165
0.045431
0.97213
[ "s880248267", "s157858381" ]
u380412651
p03044
python
s184433387
s443015801
564
500
79,428
38,840
Accepted
Accepted
11.35
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 5) def dfs(v, p, c): color[v] = c for e in graph[v]: if e[0] == p: continue if e[1] % 2: dfs(e[0], v, 1-c) else: dfs(e[0], v, c) n = int(eval(input())) color = [-1] * n graph = [[] for _ in range(n)] fo...
import sys input = sys.stdin.readline def dfs(s): stack = [(s, -1, 1)] while(len(stack)): v, p, c = stack[-1] stack.pop() color[v] = c for e in graph[v]: if e[0] == p: continue stack.append((e[0], v, abs(c - e[1] % 2))) n = int(eval(input(...
24
26
503
555
import sys input = sys.stdin.readline sys.setrecursionlimit(10**5) def dfs(v, p, c): color[v] = c for e in graph[v]: if e[0] == p: continue if e[1] % 2: dfs(e[0], v, 1 - c) else: dfs(e[0], v, c) n = int(eval(input())) color = [-1] * n graph = [[] ...
import sys input = sys.stdin.readline def dfs(s): stack = [(s, -1, 1)] while len(stack): v, p, c = stack[-1] stack.pop() color[v] = c for e in graph[v]: if e[0] == p: continue stack.append((e[0], v, abs(c - e[1] % 2))) n = int(eval(inp...
false
7.692308
[ "-sys.setrecursionlimit(10**5)", "-def dfs(v, p, c):", "- color[v] = c", "- for e in graph[v]:", "- if e[0] == p:", "- continue", "- if e[1] % 2:", "- dfs(e[0], v, 1 - c)", "- else:", "- dfs(e[0], v, c)", "+def dfs(s):", "+ stack =...
false
0.073654
0.047922
1.536971
[ "s184433387", "s443015801" ]
u869919400
p03634
python
s252322648
s976195592
1,959
1,351
226,848
217,264
Accepted
Accepted
31.04
import sys sys.setrecursionlimit(500000) N = int(eval(input())) tree = [[] for _ in range(N+1)] for _ in range(N-1): a, b, c = list(map(int, input().split())) tree[a].append((b, c)) tree[b].append((a, c)) Q, K = list(map(int, input().split())) def dfs(start, dist, dists, f=None): for n...
import sys sys.setrecursionlimit(500000) import sys def input(): return sys.stdin.readline()[:-1] N = int(eval(input())) tree = [[] for _ in range(N+1)] for _ in range(N-1): a, b, c = list(map(int, input().split())) tree[a].append((b, c)) tree[b].append((a, c)) Q, K = list(map(int, in...
28
32
604
670
import sys sys.setrecursionlimit(500000) N = int(eval(input())) tree = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) tree[a].append((b, c)) tree[b].append((a, c)) Q, K = list(map(int, input().split())) def dfs(start, dist, dists, f=None): for n, d in tree...
import sys sys.setrecursionlimit(500000) import sys def input(): return sys.stdin.readline()[:-1] N = int(eval(input())) tree = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) tree[a].append((b, c)) tree[b].append((a, c)) Q, K = list(map(int, input().spli...
false
12.5
[ "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline()[:-1]", "+", "+" ]
false
0.045108
0.037408
1.205844
[ "s252322648", "s976195592" ]
u252828980
p02614
python
s856196421
s549209444
65
55
9,116
9,108
Accepted
Accepted
15.38
H,W,K =list(map(int,input().split())) L = [list(eval(input())) for i in range(H)] ans = 0 for h in range(1<<H): for w in range(1<<W): cnt = 0 for j in range(H): for i in range(W): if h>>j&1 == 0 and w>>i&1 == 0: if L[j][i] == "#": ...
H,W,K =list(map(int,input().split())) L = [list(eval(input())) for i in range(H)] from itertools import product li = [0,1] ans = 0 for h in product(li,repeat = H): for w in product(li,repeat = W): cnt = 0 for j in range(H): for i in range(W): if h[j] == 0 and w...
14
16
384
445
H, W, K = list(map(int, input().split())) L = [list(eval(input())) for i in range(H)] ans = 0 for h in range(1 << H): for w in range(1 << W): cnt = 0 for j in range(H): for i in range(W): if h >> j & 1 == 0 and w >> i & 1 == 0: if L[j][i] == "#": ...
H, W, K = list(map(int, input().split())) L = [list(eval(input())) for i in range(H)] from itertools import product li = [0, 1] ans = 0 for h in product(li, repeat=H): for w in product(li, repeat=W): cnt = 0 for j in range(H): for i in range(W): if h[j] == 0 and w[i] == ...
false
12.5
[ "+from itertools import product", "+", "+li = [0, 1]", "-for h in range(1 << H):", "- for w in range(1 << W):", "+for h in product(li, repeat=H):", "+ for w in product(li, repeat=W):", "- if h >> j & 1 == 0 and w >> i & 1 == 0:", "+ if h[j] == 0 and w[i] == 0:" ]
false
0.038322
0.034847
1.099739
[ "s856196421", "s549209444" ]
u268554510
p02803
python
s891937895
s732023092
765
648
12,452
3,316
Accepted
Accepted
15.29
H,W = list(map(int,input().split())) S = [list(eval(input())) for _ in range(H)] from collections import deque import numpy as np ans = 0 for i in range(H): for j in range(W): if S[i][j]=='#': continue inf = 10**5 A = [[inf]*W for _ in range(H)] A[i][j]=0 q = deque([[i,j]]) ...
H,W = list(map(int,input().split())) S = [list(eval(input())) for _ in range(H)] from collections import deque ans = 0 for i in range(H): for j in range(W): if S[i][j]=='#': continue inf = 10**5 A = [[inf]*W for _ in range(H)] A[i][j]=0 q = deque([[i,j]]) while q: a = ...
35
35
771
789
H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] from collections import deque import numpy as np ans = 0 for i in range(H): for j in range(W): if S[i][j] == "#": continue inf = 10**5 A = [[inf] * W for _ in range(H)] A[i][j] = 0 ...
H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] from collections import deque ans = 0 for i in range(H): for j in range(W): if S[i][j] == "#": continue inf = 10**5 A = [[inf] * W for _ in range(H)] A[i][j] = 0 q = deque([[i, j]]...
false
0
[ "-import numpy as np", "+ A[h][w] = 0", "- A = np.array(A)", "- ans = max(ans, max(A[A < 10**5]))", "+ A = [a for b in A for a in b if a != inf]", "+ ans = max(ans, max(A))" ]
false
0.182815
0.147623
1.238389
[ "s891937895", "s732023092" ]
u002459665
p03617
python
s282761251
s417430787
20
17
3,064
3,060
Accepted
Accepted
15
Q, H, S, D = list(map(int, input().split())) N = int(eval(input())) ans1 = 4 * Q * N ans2 = 2 * H * N ans3 = S * N if N < 2: ans4 = float('INF') elif N % 2 == 0: ans4 = (N // 2) * D else: t = (N // 2) * D ans4 = t + min(4 * Q, 2 * H, 1 * S) # print(ans1, ans2, ans3, ans4) ans = min(an...
Q, H, S, D = list(map(int, input().split())) N = int(eval(input())) t = min(4*Q, 2*H, S) if D < 2 * t: if N % 2 == 0: ans = (N // 2) * D else: ans = (N // 2) * D + t else: ans = N * t print(ans)
18
14
347
233
Q, H, S, D = list(map(int, input().split())) N = int(eval(input())) ans1 = 4 * Q * N ans2 = 2 * H * N ans3 = S * N if N < 2: ans4 = float("INF") elif N % 2 == 0: ans4 = (N // 2) * D else: t = (N // 2) * D ans4 = t + min(4 * Q, 2 * H, 1 * S) # print(ans1, ans2, ans3, ans4) ans = min(ans1, ans2, ans3, ans...
Q, H, S, D = list(map(int, input().split())) N = int(eval(input())) t = min(4 * Q, 2 * H, S) if D < 2 * t: if N % 2 == 0: ans = (N // 2) * D else: ans = (N // 2) * D + t else: ans = N * t print(ans)
false
22.222222
[ "-ans1 = 4 * Q * N", "-ans2 = 2 * H * N", "-ans3 = S * N", "-if N < 2:", "- ans4 = float(\"INF\")", "-elif N % 2 == 0:", "- ans4 = (N // 2) * D", "+t = min(4 * Q, 2 * H, S)", "+if D < 2 * t:", "+ if N % 2 == 0:", "+ ans = (N // 2) * D", "+ else:", "+ ans = (N // 2) ...
false
0.051417
0.051008
1.008036
[ "s282761251", "s417430787" ]
u861141787
p03290
python
s019808706
s346737110
200
22
41,328
3,064
Accepted
Accepted
89
D, G = list(map(int, input().split())) p = [0 for _ in range(11)] c = [0 for _ in range(11)] for i in range(D): p[i], c[i] = list(map(int, input().split())) ans = 1e9 for mask in range(1 << D): s = 0 num = 0 rest_max = -1 for i in range(D): if (mask >> i) & 1: s +...
D, G = list(map(int, input().split())) p = [0] * 11 c = [0] * 11 for i in range(D): p[i], c[i] = list(map(int, input().split())) ans = 1e9 for mask in range(1<<D): s = 0 num = 0 rest_mask = -1 for i in range(D): if mask >> i & 1: s += 100 * (i+1) * p[i] + c[i] ...
28
28
612
578
D, G = list(map(int, input().split())) p = [0 for _ in range(11)] c = [0 for _ in range(11)] for i in range(D): p[i], c[i] = list(map(int, input().split())) ans = 1e9 for mask in range(1 << D): s = 0 num = 0 rest_max = -1 for i in range(D): if (mask >> i) & 1: s += 100 * (i + 1) ...
D, G = list(map(int, input().split())) p = [0] * 11 c = [0] * 11 for i in range(D): p[i], c[i] = list(map(int, input().split())) ans = 1e9 for mask in range(1 << D): s = 0 num = 0 rest_mask = -1 for i in range(D): if mask >> i & 1: s += 100 * (i + 1) * p[i] + c[i] num...
false
0
[ "-p = [0 for _ in range(11)]", "-c = [0 for _ in range(11)]", "+p = [0] * 11", "+c = [0] * 11", "- rest_max = -1", "+ rest_mask = -1", "- if (mask >> i) & 1:", "+ if mask >> i & 1:", "- rest_max = i", "+ rest_mask = i", "- s1 = 100 * (rest_max + 1...
false
0.043774
0.039512
1.107867
[ "s019808706", "s346737110" ]
u644907318
p03958
python
s312952545
s378796399
176
67
38,256
61,536
Accepted
Accepted
61.93
K,T = list(map(int,input().split())) A = sorted(list(map(int,input().split())),reverse=True) a = A[0] if a<=(K+1)//2: ans = 0 elif K%2==1: ans = (a-(K+1)//2)*2 else: ans = (a-(K+1)//2)*2-1 print(ans)
K,T = list(map(int,input().split())) A = list(map(int,input().split())) a = max(A) if a<=(K+1)//2: print((0)) else: print((2*a-K-1))
10
7
214
136
K, T = list(map(int, input().split())) A = sorted(list(map(int, input().split())), reverse=True) a = A[0] if a <= (K + 1) // 2: ans = 0 elif K % 2 == 1: ans = (a - (K + 1) // 2) * 2 else: ans = (a - (K + 1) // 2) * 2 - 1 print(ans)
K, T = list(map(int, input().split())) A = list(map(int, input().split())) a = max(A) if a <= (K + 1) // 2: print((0)) else: print((2 * a - K - 1))
false
30
[ "-A = sorted(list(map(int, input().split())), reverse=True)", "-a = A[0]", "+A = list(map(int, input().split()))", "+a = max(A)", "- ans = 0", "-elif K % 2 == 1:", "- ans = (a - (K + 1) // 2) * 2", "+ print((0))", "- ans = (a - (K + 1) // 2) * 2 - 1", "-print(ans)", "+ print((2 * ...
false
0.047103
0.040642
1.158988
[ "s312952545", "s378796399" ]
u596276291
p03962
python
s300954397
s175595587
23
20
3,064
3,316
Accepted
Accepted
13.04
def main(): a, b, c = list(map(int, input().split())) print((len(set([a, b, c])))) if __name__ == '__main__': main()
from collections import defaultdict def main(): print((len(set(map(int, input().split()))))) if __name__ == '__main__': main()
7
9
129
145
def main(): a, b, c = list(map(int, input().split())) print((len(set([a, b, c])))) if __name__ == "__main__": main()
from collections import defaultdict def main(): print((len(set(map(int, input().split()))))) if __name__ == "__main__": main()
false
22.222222
[ "+from collections import defaultdict", "+", "+", "- a, b, c = list(map(int, input().split()))", "- print((len(set([a, b, c]))))", "+ print((len(set(map(int, input().split())))))" ]
false
0.037763
0.036746
1.027686
[ "s300954397", "s175595587" ]
u912237403
p00145
python
s033572475
s987889856
80
70
4,480
4,476
Accepted
Accepted
12.5
n = int(input()) Card = [[] for _ in [0]*n] Cost = {} for i in range(n): Card[i] = list(map(int, input().split())) Cost[(i, i)] = 0 for i in range(1, n): for j in range(0, n-i): a = j+i Cost[(j, a)] = min([Card[j][0] * Card[k][1] * Card[k+1][0] * Card[a][1] + Cost[(j, k)] + Cost[(k+1, a)] for k i...
n = int(input()) C = [[] for _ in [0]*n] W = {} for i in range(n): C[i] = list(map(int, input().split())) W[(i, i)] = 0 for i in range(1, n): for j in range(0, n-i): a = j+i W[(j, a)] = min([C[j][0] * C[k][1] * C[k+1][0] * C[a][1] + W[(j, k)] + W[(k+1, a)] for k in range(j, j+i)]) print(W[0, n-1...
11
11
359
323
n = int(input()) Card = [[] for _ in [0] * n] Cost = {} for i in range(n): Card[i] = list(map(int, input().split())) Cost[(i, i)] = 0 for i in range(1, n): for j in range(0, n - i): a = j + i Cost[(j, a)] = min( [ Card[j][0] * Card[k][1] * Card[k + 1][0] * Card[a]...
n = int(input()) C = [[] for _ in [0] * n] W = {} for i in range(n): C[i] = list(map(int, input().split())) W[(i, i)] = 0 for i in range(1, n): for j in range(0, n - i): a = j + i W[(j, a)] = min( [ C[j][0] * C[k][1] * C[k + 1][0] * C[a][1] + W[(j, k)] + W[(k + 1,...
false
0
[ "-Card = [[] for _ in [0] * n]", "-Cost = {}", "+C = [[] for _ in [0] * n]", "+W = {}", "- Card[i] = list(map(int, input().split()))", "- Cost[(i, i)] = 0", "+ C[i] = list(map(int, input().split()))", "+ W[(i, i)] = 0", "- Cost[(j, a)] = min(", "+ W[(j, a)] = min(", "- ...
false
0.043936
0.038535
1.140163
[ "s033572475", "s987889856" ]
u623231048
p03295
python
s950260557
s757800565
435
279
29,084
29,152
Accepted
Accepted
35.86
n,m = list(map(int,input().split())) li = [list(map(int,input().split())) for _ in range(m)] ans = 0 now = -1 li.sort(key = lambda x:x[1]) for i in range(m): if li[i][0] <= now and li[i][1] > now: pass else: ans += 1 now = li[i][1] - 1 print(ans)
import sys input = sys.stdin.readline n,m = list(map(int,input().split())) li = [list(map(int,input().split())) for _ in range(m)] ans = 0 now = -1 li.sort(key = lambda x:x[1]) for i in range(m): if li[i][0] <= now and li[i][1] > now: pass else: ans += 1 now = li[i][1...
16
19
292
334
n, m = list(map(int, input().split())) li = [list(map(int, input().split())) for _ in range(m)] ans = 0 now = -1 li.sort(key=lambda x: x[1]) for i in range(m): if li[i][0] <= now and li[i][1] > now: pass else: ans += 1 now = li[i][1] - 1 print(ans)
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) li = [list(map(int, input().split())) for _ in range(m)] ans = 0 now = -1 li.sort(key=lambda x: x[1]) for i in range(m): if li[i][0] <= now and li[i][1] > now: pass else: ans += 1 now = li[i][1] - 1 print(ans)
false
15.789474
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.0787
0.03615
2.177037
[ "s950260557", "s757800565" ]
u191874006
p02890
python
s758230395
s264364381
697
535
120,496
118,320
Accepted
Accepted
23.24
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
51
58
1,310
1,452
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
false
12.068966
[ "+⇒Ciの個数のリストdを用意してdの累積和を用意しておくとO(n)", "+⇒変形すると,Sx/x >= kであり、各kに対してSx/xは単調減少なのでO(n)", "-cnt.sort()", "-m = len(cnt)", "+d = [0] * (n + 1)", "+for i in cnt:", "+ d[i] += 1", "+d = list(accumulate(d))", "+m = d[-1]", "-for x in range(1, n + 1):", "- l = bl(cnt, x)", "- S[x] = S[x - 1] + ...
false
0.037254
0.096807
0.384823
[ "s758230395", "s264364381" ]
u856775981
p03062
python
s605629762
s413979205
72
65
19,968
20,136
Accepted
Accepted
9.72
n = int(eval(input())) a = list(map(int, input().split())) b = [abs(i) for i in a] if (sum([i < 0 for i in a]) + sum([i == 0 for i in a])) % 2 == 0: print((sum(b))) else: print((sum(b) - min(b) * 2))
n = int(eval(input())) a = list(map(int, input().split())) b = [abs(i) for i in a] if sum([i <= 0 for i in a]) % 2 == 0: print((sum(b))) else: print((sum(b) - min(b) * 2))
9
9
207
179
n = int(eval(input())) a = list(map(int, input().split())) b = [abs(i) for i in a] if (sum([i < 0 for i in a]) + sum([i == 0 for i in a])) % 2 == 0: print((sum(b))) else: print((sum(b) - min(b) * 2))
n = int(eval(input())) a = list(map(int, input().split())) b = [abs(i) for i in a] if sum([i <= 0 for i in a]) % 2 == 0: print((sum(b))) else: print((sum(b) - min(b) * 2))
false
0
[ "-if (sum([i < 0 for i in a]) + sum([i == 0 for i in a])) % 2 == 0:", "+if sum([i <= 0 for i in a]) % 2 == 0:" ]
false
0.036451
0.035894
1.015531
[ "s605629762", "s413979205" ]
u873482706
p00093
python
s884062065
s969760043
60
30
7,876
7,728
Accepted
Accepted
50
def get_data(): while True: a, b = list(map(int, input().split())) if a == b == 0: break yield a, b input_data = list(get_data()) for i, data in enumerate(input_data): a, b = data flg = False for x in range(a, b + 1): if (x % 4 == 0 and x % 100 ...
# -*- coding: utf-8 -*- i = 0 while True: a, b = list(map(int, input().split())) if a == 0 and b == 0: break elif i != 0: print() found = False for y in range(a, b + 1): if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0): found = True pri...
21
19
500
381
def get_data(): while True: a, b = list(map(int, input().split())) if a == b == 0: break yield a, b input_data = list(get_data()) for i, data in enumerate(input_data): a, b = data flg = False for x in range(a, b + 1): if (x % 4 == 0 and x % 100 != 0) or x % ...
# -*- coding: utf-8 -*- i = 0 while True: a, b = list(map(int, input().split())) if a == 0 and b == 0: break elif i != 0: print() found = False for y in range(a, b + 1): if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0): found = True print(y) if not...
false
9.52381
[ "-def get_data():", "- while True:", "- a, b = list(map(int, input().split()))", "- if a == b == 0:", "- break", "- yield a, b", "-", "-", "-input_data = list(get_data())", "-for i, data in enumerate(input_data):", "- a, b = data", "- flg = False", "-...
false
0.1536
0.104534
1.46938
[ "s884062065", "s969760043" ]
u145231176
p02833
python
s686833085
s316094548
172
64
38,256
61,832
Accepted
Accepted
62.79
N = int(eval(input())) n = N // 10 lista = [] while n != 0: lista.append(n) n //= 5 print((sum(lista) if N % 2 == 0 else 0))
N = int(eval(input())) n = N // 10 cnt = 0 while n != 0: cnt += n n //= 5 print((cnt if N % 2 == 0 else 0))
8
8
132
115
N = int(eval(input())) n = N // 10 lista = [] while n != 0: lista.append(n) n //= 5 print((sum(lista) if N % 2 == 0 else 0))
N = int(eval(input())) n = N // 10 cnt = 0 while n != 0: cnt += n n //= 5 print((cnt if N % 2 == 0 else 0))
false
0
[ "-lista = []", "+cnt = 0", "- lista.append(n)", "+ cnt += n", "-print((sum(lista) if N % 2 == 0 else 0))", "+print((cnt if N % 2 == 0 else 0))" ]
false
0.039412
0.039017
1.010108
[ "s686833085", "s316094548" ]
u633068244
p00179
python
s985628288
s095322411
2,830
2,010
4,976
6,764
Accepted
Accepted
28.98
rgb = set(["r","g","b"]) while 1: worm = input() if worm == "0": break n = len(worm) L = 1 cnt = flag = 0 queset = set([worm]) while 1: que = list(queset) queset = set() for r in range(L): Worm = que.pop(0) if len(set(Worm)) == 1: flag = 1 break for i in range(n-1): if...
rgb = set(["r","g","b"]) while 1: worm = input() if worm == "0": break n = len(worm) L = 1 cnt = flag = 0 queset = set([worm]) ref = set() while 1: que = list(queset) queset = set() for Worm in que: if len(set(Worm)) == 1: flag = 1 break for i in range(n-1): if Worm[i] !...
26
28
563
598
rgb = set(["r", "g", "b"]) while 1: worm = input() if worm == "0": break n = len(worm) L = 1 cnt = flag = 0 queset = set([worm]) while 1: que = list(queset) queset = set() for r in range(L): Worm = que.pop(0) if len(set(Worm)) == 1: ...
rgb = set(["r", "g", "b"]) while 1: worm = input() if worm == "0": break n = len(worm) L = 1 cnt = flag = 0 queset = set([worm]) ref = set() while 1: que = list(queset) queset = set() for Worm in que: if len(set(Worm)) == 1: fla...
false
7.142857
[ "+ ref = set()", "- for r in range(L):", "- Worm = que.pop(0)", "+ for Worm in que:", "+ queset = queset - ref", "+ ref = ref | queset" ]
false
0.306181
0.254494
1.203098
[ "s985628288", "s095322411" ]
u200887663
p03680
python
s239764755
s705750118
199
168
7,084
12,984
Accepted
Accepted
15.58
n=int(eval(input())) l=[int(eval(input())) for i in range(n)] count=0 flag=False push_num=1 for i in range(n): count+=1 light_num=l[push_num-1] if light_num==2: flag=True break push_num=light_num if flag: print(count) else: print((-1))
n = int(eval(input())) #x, a, b = map(int, input().split()) #l = list(map(int,input().split())) #l = [list(map(int,input().split())) for i in range(n)] al = [] for i in range(n): a = int(eval(input())) al.append(a) al.insert(0, 0) ans = -1 push = 1 for i in range(1, n+2): light = al[push] ...
18
19
261
386
n = int(eval(input())) l = [int(eval(input())) for i in range(n)] count = 0 flag = False push_num = 1 for i in range(n): count += 1 light_num = l[push_num - 1] if light_num == 2: flag = True break push_num = light_num if flag: print(count) else: print((-1))
n = int(eval(input())) # x, a, b = map(int, input().split()) # l = list(map(int,input().split())) # l = [list(map(int,input().split())) for i in range(n)] al = [] for i in range(n): a = int(eval(input())) al.append(a) al.insert(0, 0) ans = -1 push = 1 for i in range(1, n + 2): light = al[push] push = li...
false
5.263158
[ "-l = [int(eval(input())) for i in range(n)]", "-count = 0", "-flag = False", "-push_num = 1", "+# x, a, b = map(int, input().split())", "+# l = list(map(int,input().split()))", "+# l = [list(map(int,input().split())) for i in range(n)]", "+al = []", "- count += 1", "- light_num = l[push_num...
false
0.112314
0.074635
1.504839
[ "s239764755", "s705750118" ]