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
u968166680
p02936
python
s899005370
s725935154
907
735
63,504
95,808
Accepted
Accepted
18.96
import sys from collections import deque readline = sys.stdin.readline sys.setrecursionlimit(10 ** 9) def main(): N, Q = list(map(int, readline().split())) G = [[] for _ in range(N)] for _ in range(N - 1): a, b = list(map(int, readline().split())) G[a - 1].append(b - 1) ...
import sys from collections import deque read = sys.stdin.buffer.read def main(): N, Q, *ABPX = list(map(int, read().split())) G = [[] for _ in range(N)] for a, b in zip(ABPX[0 : 2 * N - 2 : 2], ABPX[1 : 2 * N - 2 : 2]): G[a - 1].append(b - 1) G[b - 1].append(a - 1) X = [0...
38
35
800
762
import sys from collections import deque readline = sys.stdin.readline sys.setrecursionlimit(10**9) def main(): N, Q = list(map(int, readline().split())) G = [[] for _ in range(N)] for _ in range(N - 1): a, b = list(map(int, readline().split())) G[a - 1].append(b - 1) G[b - 1].app...
import sys from collections import deque read = sys.stdin.buffer.read def main(): N, Q, *ABPX = list(map(int, read().split())) G = [[] for _ in range(N)] for a, b in zip(ABPX[0 : 2 * N - 2 : 2], ABPX[1 : 2 * N - 2 : 2]): G[a - 1].append(b - 1) G[b - 1].append(a - 1) X = [0] * N fo...
false
7.894737
[ "-readline = sys.stdin.readline", "-sys.setrecursionlimit(10**9)", "+read = sys.stdin.buffer.read", "- N, Q = list(map(int, readline().split()))", "+ N, Q, *ABPX = list(map(int, read().split()))", "- for _ in range(N - 1):", "- a, b = list(map(int, readline().split()))", "+ for a, b...
false
0.04034
0.041022
0.98337
[ "s899005370", "s725935154" ]
u509739538
p02708
python
s714043693
s302011023
141
104
9,180
9,180
Accepted
Accepted
26.24
n,k=list(map(int,input().split())) s=0 for i in range(k,n+2): s+=int(i*(n+n-(i-1))/2)+1-int((i*(i-1))/2) print((s%(1000000007)))
n,k=list(map(int,input().split())) s=0 for i in range(k,n+2): s+=i*(n+n-(i-1))//2+1-(i*(i-1))//2 print((s%(1000000007)))
5
5
131
123
n, k = list(map(int, input().split())) s = 0 for i in range(k, n + 2): s += int(i * (n + n - (i - 1)) / 2) + 1 - int((i * (i - 1)) / 2) print((s % (1000000007)))
n, k = list(map(int, input().split())) s = 0 for i in range(k, n + 2): s += i * (n + n - (i - 1)) // 2 + 1 - (i * (i - 1)) // 2 print((s % (1000000007)))
false
0
[ "- s += int(i * (n + n - (i - 1)) / 2) + 1 - int((i * (i - 1)) / 2)", "+ s += i * (n + n - (i - 1)) // 2 + 1 - (i * (i - 1)) // 2" ]
false
0.051224
0.098326
0.520956
[ "s714043693", "s302011023" ]
u367794409
p02686
python
s973646531
s951113332
1,325
685
212,240
200,192
Accepted
Accepted
48.3
N = int(eval(input())) array1 = [] array2 = [] for i in range(N): s = eval(input()) x1 = 0 x2 = 0 x3 = 0 flag = True for j in range(len(s)): if s[j] == "(": if flag: x3 = 1 else: x3 += 1 flag = False ...
import sys input = sys.stdin.readline N = int(eval(input())) array1 = [] array2 = [] for i in range(N): s = eval(input()) x1 = 0 x2 = 0 x3 = 0 flag = True for j in range(len(s)): if s[j] == "(": if flag: x3 = 1 else: ...
51
54
1,040
1,082
N = int(eval(input())) array1 = [] array2 = [] for i in range(N): s = eval(input()) x1 = 0 x2 = 0 x3 = 0 flag = True for j in range(len(s)): if s[j] == "(": if flag: x3 = 1 else: x3 += 1 flag = False x1 += 1 ...
import sys input = sys.stdin.readline N = int(eval(input())) array1 = [] array2 = [] for i in range(N): s = eval(input()) x1 = 0 x2 = 0 x3 = 0 flag = True for j in range(len(s)): if s[j] == "(": if flag: x3 = 1 else: x3 += 1 ...
false
5.555556
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.044977
0.038263
1.175455
[ "s973646531", "s951113332" ]
u923279197
p02954
python
s344663935
s413153109
306
250
52,456
48,892
Accepted
Accepted
18.3
s = input() n = len(s) ans =[0 for i in range(n)] i = 0 while i < n: le = i while i+1 < n and s[i] == s[i+1]: i += 1 length = i - le + 1 if s[i] == 'L': ans[le]+=(length+1)//2 ans[le-1] += length//2 else: ans[i] += (length+1)//2 ans[i+1] += leng...
s = eval(input()) n = len(s) ans =[0 for i in range(n)] i = 0 while i < n: le = i while i+1 < n and s[i] == s[i+1]: i += 1 length = i - le + 1 if s[i] == 'L': ans[le]+=(length+1)//2 ans[le-1] += length//2 else: ans[i] += (length+1)//2 ans[i+1] +...
21
18
397
352
s = input() n = len(s) ans = [0 for i in range(n)] i = 0 while i < n: le = i while i + 1 < n and s[i] == s[i + 1]: i += 1 length = i - le + 1 if s[i] == "L": ans[le] += (length + 1) // 2 ans[le - 1] += length // 2 else: ans[i] += (length + 1) // 2 ans[i + 1] +...
s = eval(input()) n = len(s) ans = [0 for i in range(n)] i = 0 while i < n: le = i while i + 1 < n and s[i] == s[i + 1]: i += 1 length = i - le + 1 if s[i] == "L": ans[le] += (length + 1) // 2 ans[le - 1] += length // 2 else: ans[i] += (length + 1) // 2 ans[i ...
false
14.285714
[ "-s = input()", "+s = eval(input())", "-for i in range(n):", "- print(ans[i], end=\" \")", "-print()", "+print((*ans))" ]
false
0.06291
0.042167
1.491934
[ "s344663935", "s413153109" ]
u287500079
p03262
python
s178008277
s568146176
360
332
83,820
83,820
Accepted
Accepted
7.78
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import asci...
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10 from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string...
26
36
903
1,172
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowe...
import sys, re, os from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, ) from itertools import permutations, combinations, product, accumulate from operator import it...
false
27.777778
[ "-from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin", "+from math import (", "+ ceil,", "+ sqrt,", "+ hypot,", "+ factorial,", "+ pi,", "+ sin,", "+ cos,", "+ radians,", "+ acos,", "+ atan,", "+ asin,", "+ log,", "+...
false
0.054453
0.144868
0.375878
[ "s178008277", "s568146176" ]
u456353530
p02821
python
s531545797
s170904635
1,029
414
54,912
49,428
Accepted
Accepted
59.77
def nibutan(n, M): ok = 0 ng = M + 1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 #print("value:", mid) if nasu(mid) >= n: ok = mid else: ng = mid return ok def nasu(x): ans = 0 for i in A: #print("L:", i, end = " ") t = N - hogetan(x - i) #print("n:...
import numpy as np from numpy.fft import fft from numpy.fft import ifft class FFT: def exe(s, A, B): N, M = 1, len(A) + len(B) - 1 while N < M: N <<= 1 A, B = s.arrN(N, A), s.arrN(N, B) A = fft(A) * fft(B) A = ifft(A).real[:M] + 0.5 return list(map(int, A)) def arrN(s, N, L): ...
55
35
865
690
def nibutan(n, M): ok = 0 ng = M + 1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 # print("value:", mid) if nasu(mid) >= n: ok = mid else: ng = mid return ok def nasu(x): ans = 0 for i in A: # print("L:", i, end = " ") t =...
import numpy as np from numpy.fft import fft from numpy.fft import ifft class FFT: def exe(s, A, B): N, M = 1, len(A) + len(B) - 1 while N < M: N <<= 1 A, B = s.arrN(N, A), s.arrN(N, B) A = fft(A) * fft(B) A = ifft(A).real[:M] + 0.5 return list(map(int, ...
false
36.363636
[ "-def nibutan(n, M):", "- ok = 0", "- ng = M + 1", "- while abs(ok - ng) > 1:", "- mid = (ok + ng) // 2", "- # print(\"value:\", mid)", "- if nasu(mid) >= n:", "- ok = mid", "- else:", "- ng = mid", "- return ok", "+import numpy as ...
false
0.047672
0.4954
0.09623
[ "s531545797", "s170904635" ]
u264988409
p02713
python
s346919546
s138452720
1,231
732
9,148
9,048
Accepted
Accepted
40.54
from math import gcd n = int(eval(input())) c = 0 for i in range(1, n + 1): for j in range(1, n + 1): a = gcd(i, j) for k in range(1, n + 1): c += gcd(a, k) print(c)
from math import gcd def solve(): K = int(eval(input())) ans = 0 for i in range(1,K+1): for k in range(1,K+1): b = gcd(i, k) for m in range(1,K+1): ans += gcd(b, m) return ans print((solve()))
12
15
205
267
from math import gcd n = int(eval(input())) c = 0 for i in range(1, n + 1): for j in range(1, n + 1): a = gcd(i, j) for k in range(1, n + 1): c += gcd(a, k) print(c)
from math import gcd def solve(): K = int(eval(input())) ans = 0 for i in range(1, K + 1): for k in range(1, K + 1): b = gcd(i, k) for m in range(1, K + 1): ans += gcd(b, m) return ans print((solve()))
false
20
[ "-n = int(eval(input()))", "-c = 0", "-for i in range(1, n + 1):", "- for j in range(1, n + 1):", "- a = gcd(i, j)", "- for k in range(1, n + 1):", "- c += gcd(a, k)", "-print(c)", "+", "+def solve():", "+ K = int(eval(input()))", "+ ans = 0", "+ for i in...
false
0.181532
0.130347
1.39268
[ "s346919546", "s138452720" ]
u729133443
p03173
python
s817566402
s442747856
1,918
1,113
16,356
15,276
Accepted
Accepted
41.97
from numpy import* n,a=open(0) n=int(n) a=cumsum(int64([0]+a.split())) dp=zeros((n,n+1),'i8') for k in range(1,n): l=arange(n-k) r=arange(k+1,n+1) m=array([arange(i+1,i+k+1)for i in range(n-k)]).T dp[l,r]=amin(dp[l,m]+dp[m,r],0)+a[r]-a[l] print((dp[0,n]))
from numpy import* n,a=open(0) n=int(n) a=cumsum(int64([0]+a.split())) dp=zeros((n,n+1),'i8') for k in range(1,n): l=arange(n-k) r=arange(k+1,n+1) m=(arange(1,k+1)+l[:,newaxis]).T dp[l,r]=amin(dp[l,m]+dp[m,r],0)+a[r]-a[l] print((dp[0,n]))
11
11
271
254
from numpy import * n, a = open(0) n = int(n) a = cumsum(int64([0] + a.split())) dp = zeros((n, n + 1), "i8") for k in range(1, n): l = arange(n - k) r = arange(k + 1, n + 1) m = array([arange(i + 1, i + k + 1) for i in range(n - k)]).T dp[l, r] = amin(dp[l, m] + dp[m, r], 0) + a[r] - a[l] print((dp[0,...
from numpy import * n, a = open(0) n = int(n) a = cumsum(int64([0] + a.split())) dp = zeros((n, n + 1), "i8") for k in range(1, n): l = arange(n - k) r = arange(k + 1, n + 1) m = (arange(1, k + 1) + l[:, newaxis]).T dp[l, r] = amin(dp[l, m] + dp[m, r], 0) + a[r] - a[l] print((dp[0, n]))
false
0
[ "- m = array([arange(i + 1, i + k + 1) for i in range(n - k)]).T", "+ m = (arange(1, k + 1) + l[:, newaxis]).T" ]
false
0.225126
0.222021
1.013984
[ "s817566402", "s442747856" ]
u072717685
p03502
python
s927121603
s795315335
176
29
38,256
9,064
Accepted
Accepted
83.52
n = int(eval(input())) n_l = list(map(int,str(n))) if n % sum(n_l) == 0: print('Yes') else: print('No')
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n = int(eval(input())) nc = n ncsum = 0 while nc: ncsum += nc % 10 nc = nc // 10 if n % ncsum == 0: print('Yes') else: print('No') if __name__ == '__main__': main()
7
17
109
312
n = int(eval(input())) n_l = list(map(int, str(n))) if n % sum(n_l) == 0: print("Yes") else: print("No")
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n = int(eval(input())) nc = n ncsum = 0 while nc: ncsum += nc % 10 nc = nc // 10 if n % ncsum == 0: print("Yes") else: print("No") if __name__ == "__main__": main()
false
58.823529
[ "-n = int(eval(input()))", "-n_l = list(map(int, str(n)))", "-if n % sum(n_l) == 0:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+import sys", "+", "+read = sys.stdin.read", "+readlines = sys.stdin.readlines", "+", "+", "+def main():", "+ n = int(eval(input()))", "+ nc...
false
0.126411
0.061171
2.066531
[ "s927121603", "s795315335" ]
u527993431
p02887
python
s968315626
s089087728
45
41
3,316
3,316
Accepted
Accepted
8.89
N = int(eval(input())) S = eval(input()) ans = 1 for i in range(0,N-1): if S[i] != S[i+1]: ans += 1 print(ans)
N=int(eval(input())) L=eval(input()) count=1 for i in range(N-1): if L[i]!=L[i+1]: count+=1 print(count)
8
7
109
101
N = int(eval(input())) S = eval(input()) ans = 1 for i in range(0, N - 1): if S[i] != S[i + 1]: ans += 1 print(ans)
N = int(eval(input())) L = eval(input()) count = 1 for i in range(N - 1): if L[i] != L[i + 1]: count += 1 print(count)
false
12.5
[ "-S = eval(input())", "-ans = 1", "-for i in range(0, N - 1):", "- if S[i] != S[i + 1]:", "- ans += 1", "-print(ans)", "+L = eval(input())", "+count = 1", "+for i in range(N - 1):", "+ if L[i] != L[i + 1]:", "+ count += 1", "+print(count)" ]
false
0.040591
0.038243
1.061386
[ "s968315626", "s089087728" ]
u630511239
p03103
python
s565708461
s898682447
1,985
343
27,884
27,460
Accepted
Accepted
82.72
N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for i in range(N)] AB.sort() cost = 0 while M > 0: if AB[0][1] < M: cost = cost + AB[0][0]*AB[0][1] M=M-AB[0][1] AB.pop(0) else: cost = cost + AB[0][0]*M M = 0 print(cost)
N, M = list(map(int, input().split())) S = [list(map(int, input().split())) for i in range(N)] S.sort() ans = 0 k = M for i in range(N): if k == 0: break elif S[i][1] <= k: k -= S[i][1] ans += S[i][0] * S[i][1] else: ans += S[i][0] * k k = 0 print(ans)
15
15
291
286
N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for i in range(N)] AB.sort() cost = 0 while M > 0: if AB[0][1] < M: cost = cost + AB[0][0] * AB[0][1] M = M - AB[0][1] AB.pop(0) else: cost = cost + AB[0][0] * M M = 0 print(cost)
N, M = list(map(int, input().split())) S = [list(map(int, input().split())) for i in range(N)] S.sort() ans = 0 k = M for i in range(N): if k == 0: break elif S[i][1] <= k: k -= S[i][1] ans += S[i][0] * S[i][1] else: ans += S[i][0] * k k = 0 print(ans)
false
0
[ "-AB = [list(map(int, input().split())) for i in range(N)]", "-AB.sort()", "-cost = 0", "-while M > 0:", "- if AB[0][1] < M:", "- cost = cost + AB[0][0] * AB[0][1]", "- M = M - AB[0][1]", "- AB.pop(0)", "+S = [list(map(int, input().split())) for i in range(N)]", "+S.sort()"...
false
0.044098
0.037203
1.185324
[ "s565708461", "s898682447" ]
u028973125
p02585
python
s069921245
s737987986
2,174
360
220,324
80,884
Accepted
Accepted
83.44
import sys from collections import deque N, K = list(map(int, sys.stdin.readline().split())) P = list(map(int, sys.stdin.readline().split())) C = list(map(int, sys.stdin.readline().split())) # 重み付き有向グラフ # edges = [[] for _ in range(N)] # for i in range(N): # edges[i].append((P[i]-1, C[i])) # DFSで閉路と経...
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) P = list(map(int, input().split())) C = list(map(int, input().split())) ans = -float('inf') for s in range(N): S = [] i = P[s] - 1 S.append(C[i]) while i != s: i = P[i] - 1 S.append(S[-1] + C[i...
68
34
2,254
731
import sys from collections import deque N, K = list(map(int, sys.stdin.readline().split())) P = list(map(int, sys.stdin.readline().split())) C = list(map(int, sys.stdin.readline().split())) # 重み付き有向グラフ # edges = [[] for _ in range(N)] # for i in range(N): # edges[i].append((P[i]-1, C[i])) # DFSで閉路と経路の最大取得スコアを調査 a...
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) P = list(map(int, input().split())) C = list(map(int, input().split())) ans = -float("inf") for s in range(N): S = [] i = P[s] - 1 S.append(C[i]) while i != s: i = P[i] - 1 S.append(S[-1] + C[i]) if K <= le...
false
50
[ "-from collections import deque", "-N, K = list(map(int, sys.stdin.readline().split()))", "-P = list(map(int, sys.stdin.readline().split()))", "-C = list(map(int, sys.stdin.readline().split()))", "-# 重み付き有向グラフ", "-# edges = [[] for _ in range(N)]", "-# for i in range(N):", "-# edges[i].append((P[i...
false
0.107779
0.035179
3.063763
[ "s069921245", "s737987986" ]
u392319141
p02572
python
s652809036
s059128944
137
125
31,552
31,388
Accepted
Accepted
8.76
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 S = sum(A) % MOD ans = 0 for a in A: S -= a ans += S * a ans %= MOD print(ans)
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 S = 0 ans = 0 for a in A: ans = (ans + a * S) % MOD S += a print(ans)
11
10
171
157
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 S = sum(A) % MOD ans = 0 for a in A: S -= a ans += S * a ans %= MOD print(ans)
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 S = 0 ans = 0 for a in A: ans = (ans + a * S) % MOD S += a print(ans)
false
9.090909
[ "-S = sum(A) % MOD", "+S = 0", "- S -= a", "- ans += S * a", "- ans %= MOD", "+ ans = (ans + a * S) % MOD", "+ S += a" ]
false
0.034045
0.071403
0.476803
[ "s652809036", "s059128944" ]
u729133443
p02788
python
s710238366
s339464468
1,112
513
55,880
55,880
Accepted
Accepted
53.87
def main(): def bisect(a,x): ok=len(a) ng=-1 while ok-ng>1: mid=(ok+ng)//2 if a[mid]>x:ok=mid else:ng=mid return ok import sys from operator import itemgetter b=sys.stdin.buffer n,d,a=list(map(int,b.readline().split())) ...
def main(): import sys from bisect import bisect from operator import itemgetter b=sys.stdin.buffer n,d,a=list(map(int,b.readline().split())) m=list(map(int,b.read().split())) c=[0]*(n+1) z=sorted(zip(m,m),key=itemgetter(0)) y=[x for x,_ in z] s=b=0 for i,(x,h)in e...
29
22
651
498
def main(): def bisect(a, x): ok = len(a) ng = -1 while ok - ng > 1: mid = (ok + ng) // 2 if a[mid] > x: ok = mid else: ng = mid return ok import sys from operator import itemgetter b = sys.stdin.buffer...
def main(): import sys from bisect import bisect from operator import itemgetter b = sys.stdin.buffer n, d, a = list(map(int, b.readline().split())) m = list(map(int, b.read().split())) c = [0] * (n + 1) z = sorted(zip(m, m), key=itemgetter(0)) y = [x for x, _ in z] s = b = 0 ...
false
24.137931
[ "- def bisect(a, x):", "- ok = len(a)", "- ng = -1", "- while ok - ng > 1:", "- mid = (ok + ng) // 2", "- if a[mid] > x:", "- ok = mid", "- else:", "- ng = mid", "- return ok", "-", "+ from bisect ...
false
0.044082
0.044172
0.997964
[ "s710238366", "s339464468" ]
u936985471
p03163
python
s684540561
s947944985
328
177
21,700
14,536
Accepted
Accepted
46.04
n,W=list(map(int,input().split())) stones=[None]*n for i in range(n): w,v=list(map(int,input().split())) stones[i]=[w,v] import numpy as np dp=np.zeros(W+1,dtype=int) for i in range(len(stones)): w=stones[i][0] v=stones[i][1] np.maximum(dp[:-w]+v,dp[w:],dp[w:]) print((dp.max()))
N,W=list(map(int,input().split())) import numpy as np dp=np.zeros(W+1,dtype=int) for i in range(N): w,v=list(map(int,input().split())) np.maximum(dp[:-w]+v,dp[w:],out=dp[w:]) print((dp.max()))
15
7
292
189
n, W = list(map(int, input().split())) stones = [None] * n for i in range(n): w, v = list(map(int, input().split())) stones[i] = [w, v] import numpy as np dp = np.zeros(W + 1, dtype=int) for i in range(len(stones)): w = stones[i][0] v = stones[i][1] np.maximum(dp[:-w] + v, dp[w:], dp[w:]) print((dp...
N, W = list(map(int, input().split())) import numpy as np dp = np.zeros(W + 1, dtype=int) for i in range(N): w, v = list(map(int, input().split())) np.maximum(dp[:-w] + v, dp[w:], out=dp[w:]) print((dp.max()))
false
53.333333
[ "-n, W = list(map(int, input().split()))", "-stones = [None] * n", "-for i in range(n):", "- w, v = list(map(int, input().split()))", "- stones[i] = [w, v]", "+N, W = list(map(int, input().split()))", "-for i in range(len(stones)):", "- w = stones[i][0]", "- v = stones[i][1]", "- np...
false
0.379138
0.180313
2.102667
[ "s684540561", "s947944985" ]
u623687794
p03163
python
s861440704
s731546518
728
441
171,656
175,440
Accepted
Accepted
39.42
n,w=list(map(int,input().split())) cost=[[0 for i in range(w+1)] for j in range(n+1)] value=[tuple(map(int,input().split())) for i in range(n)] for i in range(1,n+1): for j in range(w+1): weight_=value[i-1][0] value_=value[i-1][1] if j < weight_: cost[i][j]=cost[i-1][j] else: cos...
n,w=list(map(int,input().split())) cost=[[0 for i in range(w+1)] for j in range(n+1)] #DP配列です value=[tuple(map(int,input().split())) for i in range(n)]#品物の情報を受けとります for i in range(1,n+1): for j in range(w+1): weight_=value[i-1][0] #i-1番目の品物の重さ value_=value[i-1][1] #i-1番目の品物の価値 if j < weight_: ...
12
12
389
434
n, w = list(map(int, input().split())) cost = [[0 for i in range(w + 1)] for j in range(n + 1)] value = [tuple(map(int, input().split())) for i in range(n)] for i in range(1, n + 1): for j in range(w + 1): weight_ = value[i - 1][0] value_ = value[i - 1][1] if j < weight_: cost[i]...
n, w = list(map(int, input().split())) cost = [[0 for i in range(w + 1)] for j in range(n + 1)] # DP配列です value = [tuple(map(int, input().split())) for i in range(n)] # 品物の情報を受けとります for i in range(1, n + 1): for j in range(w + 1): weight_ = value[i - 1][0] # i-1番目の品物の重さ value_ = value[i - 1][1] #...
false
0
[ "-cost = [[0 for i in range(w + 1)] for j in range(n + 1)]", "-value = [tuple(map(int, input().split())) for i in range(n)]", "+cost = [[0 for i in range(w + 1)] for j in range(n + 1)] # DP配列です", "+value = [tuple(map(int, input().split())) for i in range(n)] # 品物の情報を受けとります", "- weight_ = value[i - ...
false
0.0417
0.042426
0.982885
[ "s861440704", "s731546518" ]
u197615397
p02346
python
s271569113
s493752006
3,110
2,630
18,592
18,528
Accepted
Accepted
15.43
import math class SegmentTree: __slots__ = ["elem_size", "tree_size", "tree"] def __init__(self, a: list, default: int): real_size = len(a) self.elem_size = 1 << math.ceil(math.log2(real_size)) self.tree_size = 2 * self.elem_size + 1 self.tree = [default] * (self.ele...
import math class SegmentTree: __slots__ = ["elem_size", "tree_size", "tree"] def __init__(self, a: list, default: int): real_size = len(a) self.elem_size = 1 << math.ceil(math.log2(real_size)) self.tree_size = 2 * self.elem_size + 1 self.tree = [default] * (self.ele...
63
61
1,864
1,845
import math class SegmentTree: __slots__ = ["elem_size", "tree_size", "tree"] def __init__(self, a: list, default: int): real_size = len(a) self.elem_size = 1 << math.ceil(math.log2(real_size)) self.tree_size = 2 * self.elem_size + 1 self.tree = ( [default] * (self...
import math class SegmentTree: __slots__ = ["elem_size", "tree_size", "tree"] def __init__(self, a: list, default: int): real_size = len(a) self.elem_size = 1 << math.ceil(math.log2(real_size)) self.tree_size = 2 * self.elem_size + 1 self.tree = ( [default] * (self...
false
3.174603
[ "- elif not l_end <= x <= y < r_end:", "- return []", "- left = self.get_range_index(x, left_y, 2 * k + 1, l_end, mid)", "- right = self.get_range_index(right_x, y, 2 * k + 2, mid, r_end)", "+ left = (", "+ self.get_range_index(x, left_y, 2 * k + 1, l_end,...
false
0.118077
0.050048
2.359289
[ "s271569113", "s493752006" ]
u827202523
p02948
python
s740500255
s224247712
569
499
70,192
102,892
Accepted
Accepted
12.3
import sys input = sys.stdin.readline sys.setrecursionlimit(100000) def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) import math import heapq n, m = getList() works = [[] for i in range(m+2)] for i in range(n): a, b = getList() try: ...
import sys # from collections import defaultdict, deque # import math # import copy # from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lambda...
37
100
648
2,230
import sys input = sys.stdin.readline sys.setrecursionlimit(100000) def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) import math import heapq n, m = getList() works = [[] for i in range(m + 2)] for i in range(n): a, b = getList() try: works[a].a...
import sys # from collections import defaultdict, deque # import math # import copy # from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lambda: list(map(int, ...
false
63
[ "+# from collections import defaultdict, deque", "+# import math", "+# import copy", "+# from bisect import bisect_left, bisect_right", "+# import heapq", "+# sys.setrecursionlimit(1000000)", "+# input aliases", "-sys.setrecursionlimit(100000)", "+getS = lambda: input().strip()", "+getN = lambda: ...
false
0.039402
0.039578
0.995557
[ "s740500255", "s224247712" ]
u353919145
p03210
python
s379719463
s308361772
17
10
2,940
2,568
Accepted
Accepted
41.18
x = int(eval(input())) if x == 5 or x == 3 or x == 7: print("YES") else: print("NO")
x = int(eval(input())) if x == 3 or x == 5 or x == 7: ans = 'YES' else: ans = 'NO' print(ans)
6
7
93
103
x = int(eval(input())) if x == 5 or x == 3 or x == 7: print("YES") else: print("NO")
x = int(eval(input())) if x == 3 or x == 5 or x == 7: ans = "YES" else: ans = "NO" print(ans)
false
14.285714
[ "-if x == 5 or x == 3 or x == 7:", "- print(\"YES\")", "+if x == 3 or x == 5 or x == 7:", "+ ans = \"YES\"", "- print(\"NO\")", "+ ans = \"NO\"", "+print(ans)" ]
false
0.037318
0.037252
1.001762
[ "s379719463", "s308361772" ]
u516272298
p03644
python
s327501718
s806952980
19
17
3,316
2,940
Accepted
Accepted
10.53
n = int(eval(input())) for i in range(n): if 2**i == n: print((2**i)) break elif 2**i > n: print((2**(i-1))) break
n = int(eval(input())) for i in range(n): if 2**i > n: print((2**(i-1))) break elif n == 1: print((1))
8
7
151
130
n = int(eval(input())) for i in range(n): if 2**i == n: print((2**i)) break elif 2**i > n: print((2 ** (i - 1))) break
n = int(eval(input())) for i in range(n): if 2**i > n: print((2 ** (i - 1))) break elif n == 1: print((1))
false
12.5
[ "- if 2**i == n:", "- print((2**i))", "- break", "- elif 2**i > n:", "+ if 2**i > n:", "+ elif n == 1:", "+ print((1))" ]
false
0.043702
0.043635
1.001535
[ "s327501718", "s806952980" ]
u724687935
p02852
python
s577456934
s179002648
223
134
50,768
7,080
Accepted
Accepted
39.91
N, M = list(map(int, input().split())) S = eval(input()) pos = N step = [] isGoal = 1 while pos > 0: for i in range(M, 0, -1): if pos - i <= 0: step.append(pos) pos = 0 elif S[pos - i] == '0': step.append(i) pos -= i else: ...
N, M = list(map(int, input().split())) S = list(reversed(eval(input()))) ans = [] cur = 0 while cur < N: for m in range(M, 0, -1): ncur = cur + m if ncur <= N and S[ncur] == '0': ans.append(m) cur = ncur break else: print((-1)) e...
25
17
462
337
N, M = list(map(int, input().split())) S = eval(input()) pos = N step = [] isGoal = 1 while pos > 0: for i in range(M, 0, -1): if pos - i <= 0: step.append(pos) pos = 0 elif S[pos - i] == "0": step.append(i) pos -= i else: continue ...
N, M = list(map(int, input().split())) S = list(reversed(eval(input()))) ans = [] cur = 0 while cur < N: for m in range(M, 0, -1): ncur = cur + m if ncur <= N and S[ncur] == "0": ans.append(m) cur = ncur break else: print((-1)) exit() print((*r...
false
32
[ "-S = eval(input())", "-pos = N", "-step = []", "-isGoal = 1", "-while pos > 0:", "- for i in range(M, 0, -1):", "- if pos - i <= 0:", "- step.append(pos)", "- pos = 0", "- elif S[pos - i] == \"0\":", "- step.append(i)", "- pos -= i"...
false
0.041243
0.043222
0.954223
[ "s577456934", "s179002648" ]
u499381410
p03128
python
s833640594
s846705400
273
217
67,676
43,244
Accepted
Accepted
20.51
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate import sys def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LI...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from bisect import bisect_right, bisect_left import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import...
40
69
1,047
1,707
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate import sys def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LIM...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from bisect import bisect_right, bisect_left import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factori...
false
42.028986
[ "-import math", "-import bisect", "+from bisect import bisect_right, bisect_left", "-from itertools import permutations, accumulate", "+from itertools import permutations, accumulate, combinations, product", "+import string", "+from bisect import bisect_left, bisect_right", "+from math import factoria...
false
0.043132
0.037187
1.159867
[ "s833640594", "s846705400" ]
u340781749
p03064
python
s957151824
s273312890
1,358
885
17,992
15,268
Accepted
Accepted
34.83
import sys import numpy as np n = int(eval(input())) aaa = list(map(int, sys.stdin)) MOD = 998244353 s = sum(aaa) dp1 = np.zeros(s + 1, dtype=np.int64) dp2 = np.zeros(s + 1, dtype=np.int64) dp1[0] = 1 dp2[0] = 1 for a in aaa: dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD dp2 = (dp2 + np.roll(dp2, a)) ...
import sys import numpy as np n = int(eval(input())) aaa = list(map(int, sys.stdin)) MOD = 998244353 s = sum(aaa) dp1 = np.zeros(s + 1, dtype=np.uint32) dp2 = np.zeros(s + 1, dtype=np.uint32) dp1[0] = 1 dp2[0] = 1 for a in aaa: dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD dp2 = (dp2 + np.roll(dp2, a)...
21
21
454
461
import sys import numpy as np n = int(eval(input())) aaa = list(map(int, sys.stdin)) MOD = 998244353 s = sum(aaa) dp1 = np.zeros(s + 1, dtype=np.int64) dp2 = np.zeros(s + 1, dtype=np.int64) dp1[0] = 1 dp2[0] = 1 for a in aaa: dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD dp2 = (dp2 + np.roll(dp2, a)) % MOD h = (s + ...
import sys import numpy as np n = int(eval(input())) aaa = list(map(int, sys.stdin)) MOD = 998244353 s = sum(aaa) dp1 = np.zeros(s + 1, dtype=np.uint32) dp2 = np.zeros(s + 1, dtype=np.uint32) dp1[0] = 1 dp2[0] = 1 for a in aaa: dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD dp2 = (dp2 + np.roll(dp2, a)) % MOD h = (s ...
false
0
[ "-dp1 = np.zeros(s + 1, dtype=np.int64)", "-dp2 = np.zeros(s + 1, dtype=np.int64)", "+dp1 = np.zeros(s + 1, dtype=np.uint32)", "+dp2 = np.zeros(s + 1, dtype=np.uint32)", "-print(ans)", "+print((int(ans)))" ]
false
0.283096
0.494976
0.571939
[ "s957151824", "s273312890" ]
u494871759
p03845
python
s603523938
s066164317
21
19
3,060
3,060
Accepted
Accepted
9.52
N = int(eval(input())) Ts = [int(x) for x in input().split()] M = int(eval(input())) for i in range(M): p,x = list(map(int,input().split())) time = 0 for j in range(N): if j == (p-1): time += x else: time += Ts[j] print(time)
eval(input()) T = list(map(int,input().split())) M = int(eval(input())) S = sum(T) for i in range(M): p,x = list(map(int,input().split())) ans = S-T[p-1]+x print(ans)
12
9
281
175
N = int(eval(input())) Ts = [int(x) for x in input().split()] M = int(eval(input())) for i in range(M): p, x = list(map(int, input().split())) time = 0 for j in range(N): if j == (p - 1): time += x else: time += Ts[j] print(time)
eval(input()) T = list(map(int, input().split())) M = int(eval(input())) S = sum(T) for i in range(M): p, x = list(map(int, input().split())) ans = S - T[p - 1] + x print(ans)
false
25
[ "-N = int(eval(input()))", "-Ts = [int(x) for x in input().split()]", "+eval(input())", "+T = list(map(int, input().split()))", "+S = sum(T)", "- time = 0", "- for j in range(N):", "- if j == (p - 1):", "- time += x", "- else:", "- time += Ts[j]", "- ...
false
0.045467
0.044305
1.02624
[ "s603523938", "s066164317" ]
u941407962
p02845
python
s339222959
s660129502
289
98
52,972
18,796
Accepted
Accepted
66.09
n = int(eval(input())) xs = list(map(int, input().split())) A = max(xs) dp = [0] * (A+1) MOD = 1000000007 r = 1 zc = 0 for x in xs: if x == 0: zc += 1 else: r = r * dp[x-1] % MOD dp[x-1] -= 1 dp[x] += 1 if zc == 0 or zc >= 4: rr = 0 elif zc == 1: rr = 3 el...
eval(input()) dp,M,r=[3]+[0]*10**6,10**9+7,1 for x in map(int, input().split()): r=r*dp[x]%M dp[x]-=1 dp[x+1]+=1 print(r)
24
7
383
133
n = int(eval(input())) xs = list(map(int, input().split())) A = max(xs) dp = [0] * (A + 1) MOD = 1000000007 r = 1 zc = 0 for x in xs: if x == 0: zc += 1 else: r = r * dp[x - 1] % MOD dp[x - 1] -= 1 dp[x] += 1 if zc == 0 or zc >= 4: rr = 0 elif zc == 1: rr = 3 else: rr = 6...
eval(input()) dp, M, r = [3] + [0] * 10**6, 10**9 + 7, 1 for x in map(int, input().split()): r = r * dp[x] % M dp[x] -= 1 dp[x + 1] += 1 print(r)
false
70.833333
[ "-n = int(eval(input()))", "-xs = list(map(int, input().split()))", "-A = max(xs)", "-dp = [0] * (A + 1)", "-MOD = 1000000007", "-r = 1", "-zc = 0", "-for x in xs:", "- if x == 0:", "- zc += 1", "- else:", "- r = r * dp[x - 1] % MOD", "- dp[x - 1] -= 1", "- dp...
false
0.043699
0.083323
0.524455
[ "s339222959", "s660129502" ]
u133936772
p02660
python
s390835421
s048239270
394
146
20,088
9,196
Accepted
Accepted
62.94
n=int(eval(input())) M=10**6 l=[] p=[1]*M for i in range(2,M): if p[i]: l+=[i] for j in range(2*i,M,i): p[j]=0 d={} for k in l: while n%k<1: n//=k; d[k]=d.get(k,0)+1 a=0 for i in list(d.values()): t=c=0 while t+c<i: c+=1; t+=c a+=c print((a+(n>1)))
n=int(eval(input())) d={} for k in range(2,10**6): while n%k<1: n//=k; d[k]=d.get(k,0)+1 a=0 for i in list(d.values()): t=c=0 while t+c<i: c+=1; t+=c a+=c print((a+(n>1)))
17
10
268
174
n = int(eval(input())) M = 10**6 l = [] p = [1] * M for i in range(2, M): if p[i]: l += [i] for j in range(2 * i, M, i): p[j] = 0 d = {} for k in l: while n % k < 1: n //= k d[k] = d.get(k, 0) + 1 a = 0 for i in list(d.values()): t = c = 0 while t + c < i: ...
n = int(eval(input())) d = {} for k in range(2, 10**6): while n % k < 1: n //= k d[k] = d.get(k, 0) + 1 a = 0 for i in list(d.values()): t = c = 0 while t + c < i: c += 1 t += c a += c print((a + (n > 1)))
false
41.176471
[ "-M = 10**6", "-l = []", "-p = [1] * M", "-for i in range(2, M):", "- if p[i]:", "- l += [i]", "- for j in range(2 * i, M, i):", "- p[j] = 0", "-for k in l:", "+for k in range(2, 10**6):" ]
false
0.847063
0.165844
5.107596
[ "s390835421", "s048239270" ]
u013582910
p03835
python
s783202919
s115237400
1,806
485
2,940
2,940
Accepted
Accepted
73.15
import sys def input(): return sys.stdin.readline().strip() k,s=list(map(int,input().split())) c=0 for x in range(k+1): if x + 2 * k < s: continue for y in range(k+1): if x + y > s: continue if x + y + k < s: continue c += 1 print(c)
import sys def input(): return sys.stdin.readline().strip() k,s=list(map(int,input().split())) c=0 for x in range(max(0,s-2*k),k+1): for y in range(max(0,s-x-k),min(k,s-x)+1): c += 1 print(c)
14
8
304
204
import sys def input(): return sys.stdin.readline().strip() k, s = list(map(int, input().split())) c = 0 for x in range(k + 1): if x + 2 * k < s: continue for y in range(k + 1): if x + y > s: continue if x + y + k < s: continue c += 1 print(c)
import sys def input(): return sys.stdin.readline().strip() k, s = list(map(int, input().split())) c = 0 for x in range(max(0, s - 2 * k), k + 1): for y in range(max(0, s - x - k), min(k, s - x) + 1): c += 1 print(c)
false
42.857143
[ "-for x in range(k + 1):", "- if x + 2 * k < s:", "- continue", "- for y in range(k + 1):", "- if x + y > s:", "- continue", "- if x + y + k < s:", "- continue", "+for x in range(max(0, s - 2 * k), k + 1):", "+ for y in range(max(0, s - x - k), m...
false
0.036165
0.059766
0.605102
[ "s783202919", "s115237400" ]
u083960235
p03031
python
s690077826
s438719275
91
60
5,844
5,204
Accepted
Accepted
34.07
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii...
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii...
50
49
1,320
1,314
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upper...
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upper...
false
2
[ "- on += bit[s - 1]", "+ on ^= bit[s - 1]", "- if P[i] == on % 2:", "+ if P[i] == on:" ]
false
0.158892
0.095544
1.663033
[ "s690077826", "s438719275" ]
u753803401
p02971
python
s548386201
s994819196
542
413
14,876
59,824
Accepted
Accepted
23.8
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] b = a.copy() b = sorted(b, reverse=True) for i in a: if i == b[0]: print((b[1])) else: print((b[0]))
def main(): import sys import collections input = sys.stdin.readline n = int(input().rstrip('\n')) a = [int(input().rstrip('\n')) for _ in range(n)] b = sorted(a, reverse=True) for i in a: if i == b[0]: print((b[1])) else: print((b[0])) ...
9
16
183
380
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] b = a.copy() b = sorted(b, reverse=True) for i in a: if i == b[0]: print((b[1])) else: print((b[0]))
def main(): import sys import collections input = sys.stdin.readline n = int(input().rstrip("\n")) a = [int(input().rstrip("\n")) for _ in range(n)] b = sorted(a, reverse=True) for i in a: if i == b[0]: print((b[1])) else: print((b[0])) if __name__ ...
false
43.75
[ "-n = int(eval(input()))", "-a = [int(eval(input())) for _ in range(n)]", "-b = a.copy()", "-b = sorted(b, reverse=True)", "-for i in a:", "- if i == b[0]:", "- print((b[1]))", "- else:", "- print((b[0]))", "+def main():", "+ import sys", "+ import collections", "+"...
false
0.04687
0.035421
1.323222
[ "s548386201", "s994819196" ]
u057964173
p03680
python
s315073996
s132886815
257
237
51,760
43,612
Accepted
Accepted
7.78
import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(eval(input())) edge = [[] * n for i in range(n)] # rangeに頂点の数。繋がっている頂点を投入するリスト for i in range(n): # rangeに辺の数 x, y = i,int(eval(input())) y = y - 1 edge[x].append(y) sagasu=0 cnt=0 ...
import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(eval(input())) l=[int(eval(input())) for i in range(n)] light=0 cnt=0 while True: if l[light]==2: cnt+=1 print(cnt) break else: if cnt>n: ...
25
22
582
458
import sys def input(): return sys.stdin.readline().strip() def resolve(): n = int(eval(input())) edge = [[] * n for i in range(n)] # rangeに頂点の数。繋がっている頂点を投入するリスト for i in range(n): # rangeに辺の数 x, y = i, int(eval(input())) y = y - 1 edge[x].append(y) sagasu = 0 cnt =...
import sys def input(): return sys.stdin.readline().strip() def resolve(): n = int(eval(input())) l = [int(eval(input())) for i in range(n)] light = 0 cnt = 0 while True: if l[light] == 2: cnt += 1 print(cnt) break else: if cnt ...
false
12
[ "- edge = [[] * n for i in range(n)] # rangeに頂点の数。繋がっている頂点を投入するリスト", "- for i in range(n): # rangeに辺の数", "- x, y = i, int(eval(input()))", "- y = y - 1", "- edge[x].append(y)", "- sagasu = 0", "+ l = [int(eval(input())) for i in range(n)]", "+ light = 0", "- ...
false
0.045364
0.041078
1.104343
[ "s315073996", "s132886815" ]
u077291787
p03503
python
s300680717
s424680521
203
58
3,188
3,188
Accepted
Accepted
71.43
# ABC080C - Shopping Street import sys input = sys.stdin.readline from itertools import product def main(): N = int(eval(input())) F = tuple(tuple(map(int, input().split())) for _ in range(N)) P = tuple(tuple(map(int, input().split())) for _ in range(N)) ans = [] for b in product((0, 1)...
# ABC080C - Shopping Street import sys input = sys.stdin.readline from itertools import product def main(): N = int(eval(input())) F = tuple(int(input().replace(" ", ""), 2) for _ in range(N)) P = tuple(tuple(map(int, input().split())) for _ in range(N)) ans = [] for i in range(1, 2 *...
24
20
596
474
# ABC080C - Shopping Street import sys input = sys.stdin.readline from itertools import product def main(): N = int(eval(input())) F = tuple(tuple(map(int, input().split())) for _ in range(N)) P = tuple(tuple(map(int, input().split())) for _ in range(N)) ans = [] for b in product((0, 1), repeat=1...
# ABC080C - Shopping Street import sys input = sys.stdin.readline from itertools import product def main(): N = int(eval(input())) F = tuple(int(input().replace(" ", ""), 2) for _ in range(N)) P = tuple(tuple(map(int, input().split())) for _ in range(N)) ans = [] for i in range(1, 2**10): ...
false
16.666667
[ "- F = tuple(tuple(map(int, input().split())) for _ in range(N))", "+ F = tuple(int(input().replace(\" \", \"\"), 2) for _ in range(N))", "- for b in product((0, 1), repeat=10):", "- if 1 not in b:", "- continue", "- cnt = 0", "- for f, p in zip(F, P):", "- ...
false
0.078812
0.069873
1.12792
[ "s300680717", "s424680521" ]
u272028993
p03986
python
s416032650
s117719486
82
51
21,812
3,688
Accepted
Accepted
37.8
s=input() stack=[] for i in range(len(s)): if len(stack)==0 or s[i]=="S": stack.append(s[i]) continue if s[i]=="T": if stack[-1]=="S": stack.pop() else: stack.append(s[i]) print((len(stack)))
x = input() stack = [] ans = 0 for i in range(len(x)): if x[i] == "S": stack.append("S") else: if len(stack) == 0: ans += 1 else: stack.pop() print(ans + len(stack))
12
12
269
237
s = input() stack = [] for i in range(len(s)): if len(stack) == 0 or s[i] == "S": stack.append(s[i]) continue if s[i] == "T": if stack[-1] == "S": stack.pop() else: stack.append(s[i]) print((len(stack)))
x = input() stack = [] ans = 0 for i in range(len(x)): if x[i] == "S": stack.append("S") else: if len(stack) == 0: ans += 1 else: stack.pop() print(ans + len(stack))
false
0
[ "-s = input()", "+x = input()", "-for i in range(len(s)):", "- if len(stack) == 0 or s[i] == \"S\":", "- stack.append(s[i])", "- continue", "- if s[i] == \"T\":", "- if stack[-1] == \"S\":", "+ans = 0", "+for i in range(len(x)):", "+ if x[i] == \"S\":", "+ ...
false
0.042353
0.041673
1.016336
[ "s416032650", "s117719486" ]
u935558307
p03557
python
s909977517
s948280045
445
229
109,796
105,156
Accepted
Accepted
48.54
from bisect import bisect N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) """ 前処理で、中部の祭壇でBi以下のサイズを選べるときの、中段と上段のパーツの組み合わせのパターン数を計算しておく。 """ BPattern = [] for i in range(N): b = B[i] idx = bisect(A...
from bisect import bisect_left N = int(eval(input())) A = list(map(int,input().split())) A.sort() B = list(map(int,input().split())) B.sort() C = list(map(int,input().split())) C.sort() """ 前処理で中部に大きさb以下のパーツを使える場合の組み合わせの数を計算しておく。 """ tmp1 = [0] for b in B: a = bisect_left(A,b) tmp1.append(tm...
26
24
546
413
from bisect import bisect N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) """ 前処理で、中部の祭壇でBi以下のサイズを選べるときの、中段と上段のパーツの組み合わせのパターン数を計算しておく。 """ BPattern = [] for i in range(N): b = B[i] idx = bisect(A, b - 1) ...
from bisect import bisect_left N = int(eval(input())) A = list(map(int, input().split())) A.sort() B = list(map(int, input().split())) B.sort() C = list(map(int, input().split())) C.sort() """ 前処理で中部に大きさb以下のパーツを使える場合の組み合わせの数を計算しておく。 """ tmp1 = [0] for b in B: a = bisect_left(A, b) tmp1.append(tmp1[-1] + a) tmp...
false
7.692308
[ "-from bisect import bisect", "+from bisect import bisect_left", "-A = sorted(list(map(int, input().split())))", "-B = sorted(list(map(int, input().split())))", "-C = sorted(list(map(int, input().split())))", "+A = list(map(int, input().split()))", "+A.sort()", "+B = list(map(int, input().split()))", ...
false
0.042213
0.079235
0.532754
[ "s909977517", "s948280045" ]
u506910932
p02550
python
s173965384
s116357522
52
45
12,488
12,364
Accepted
Accepted
13.46
n, x, m = list(map(int, input().split())) check = [False] * (10**5 + 10) check_list = [x] a = x check[a] = True # ループを見つける for i in range(n): # print('A' + str(i + 1), a) a = (a * a) % m if check[a]: break check[a] = True check_list.append(a) # print(ans) # ループの長さを算出 index =...
n, x, m = list(map(int, input().split())) check = [False] * (10**5 + 10) check_list = [x] a = x # ループを見つける for i in range(n): a = (a * a) % m if check[a]: break check[a] = True check_list.append(a) # ループの長さを算出 index = check_list.index(a) # ループはいる前のやつ roop_bef = check_list[0:index...
32
28
703
631
n, x, m = list(map(int, input().split())) check = [False] * (10**5 + 10) check_list = [x] a = x check[a] = True # ループを見つける for i in range(n): # print('A' + str(i + 1), a) a = (a * a) % m if check[a]: break check[a] = True check_list.append(a) # print(ans) # ループの長さを算出 index = check_list.index...
n, x, m = list(map(int, input().split())) check = [False] * (10**5 + 10) check_list = [x] a = x # ループを見つける for i in range(n): a = (a * a) % m if check[a]: break check[a] = True check_list.append(a) # ループの長さを算出 index = check_list.index(a) # ループはいる前のやつ roop_bef = check_list[0:index] # ループのやつ roop ...
false
12.5
[ "-check[a] = True", "- # print('A' + str(i + 1), a)", "-# print(ans)", "-# print(index)", "+# ループはいる前のやつ", "+# ループのやつ", "-roop_bef_num = len(roop_bef)", "+# ループが何周あるのかと,ループ終わりがいくつ要素あるかを計算", "+# ループ前+ループのsum*ループ数+ループ後のsumが答え", "-# print(roop[:roop_after_num])", "-# print(rooplen)" ]
false
0.050033
0.039366
1.270955
[ "s173965384", "s116357522" ]
u844005364
p04044
python
s916925667
s774160542
19
17
3,060
3,060
Accepted
Accepted
10.53
n, l = map(int, input().split()) a = [input() for i in range(n)] a.sort() for aa in a: print(aa, end="")
n, l = map(int, input().split()) s = sorted([input() for i in range(n)]) print(*s,sep="")
7
3
114
91
n, l = map(int, input().split()) a = [input() for i in range(n)] a.sort() for aa in a: print(aa, end="")
n, l = map(int, input().split()) s = sorted([input() for i in range(n)]) print(*s, sep="")
false
57.142857
[ "-a = [input() for i in range(n)]", "-a.sort()", "-for aa in a:", "- print(aa, end=\"\")", "+s = sorted([input() for i in range(n)])", "+print(*s, sep=\"\")" ]
false
0.077625
0.070763
1.096977
[ "s916925667", "s774160542" ]
u802963389
p03044
python
s028822153
s908670616
907
670
85,204
46,012
Accepted
Accepted
26.13
import sys sys.setrecursionlimit(10 ** 6) def dfs(i): # if all([v != -1 for v in visited]): # return color = visited[i] for nextIdx, wgt in graph[i]: if visited[nextIdx] == -1: if wgt % 2 == 0: visited[nextIdx] = color else: ...
from collections import deque def dfs(start): stack = deque([[start, 0]]) while stack: p, c = stack.popleft() for next, distance in graph[p]: if visited[next] == -1: if distance % 2 == 0: visited[next] = int(c) else: visited[next] = int(not c) s...
27
26
650
616
import sys sys.setrecursionlimit(10**6) def dfs(i): # if all([v != -1 for v in visited]): # return color = visited[i] for nextIdx, wgt in graph[i]: if visited[nextIdx] == -1: if wgt % 2 == 0: visited[nextIdx] = color else: visited[ne...
from collections import deque def dfs(start): stack = deque([[start, 0]]) while stack: p, c = stack.popleft() for next, distance in graph[p]: if visited[next] == -1: if distance % 2 == 0: visited[next] = int(c) else: ...
false
3.703704
[ "-import sys", "-", "-sys.setrecursionlimit(10**6)", "+from collections import deque", "-def dfs(i):", "- # if all([v != -1 for v in visited]):", "- # return", "- color = visited[i]", "- for nextIdx, wgt in graph[i]:", "- if visited[nextIdx] == -1:", "- if wgt %...
false
0.041295
0.041683
0.990677
[ "s028822153", "s908670616" ]
u607563136
p03162
python
s419270458
s951920126
665
543
50,188
50,216
Accepted
Accepted
18.35
N = int(eval(input())) v = [list(map(int,input().split())) for _ in range(N)] dp = [[0]*3 for _ in range(N+1)] for i in range(N): for j in range(3): for k in range(3): if j==k:continue dp[i+1][k] = max(dp[i+1][k],dp[i][j]+v[i][k]) print((max(dp[N][i] for i i...
def main(): N = int(eval(input())) v = [list(map(int,input().split())) for _ in range(N)] dp = [[0]*3 for _ in range(N+1)] for i in range(N): for j in range(3): for k in range(3): if j==k:continue dp[i+1][k] = max(dp[i+1][k],dp[i][j]+v[i][k...
12
13
325
368
N = int(eval(input())) v = [list(map(int, input().split())) for _ in range(N)] dp = [[0] * 3 for _ in range(N + 1)] for i in range(N): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + v[i][k]) print((max(dp[N][i] fo...
def main(): N = int(eval(input())) v = [list(map(int, input().split())) for _ in range(N)] dp = [[0] * 3 for _ in range(N + 1)] for i in range(N): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i + 1...
false
7.692308
[ "-N = int(eval(input()))", "-v = [list(map(int, input().split())) for _ in range(N)]", "-dp = [[0] * 3 for _ in range(N + 1)]", "-for i in range(N):", "- for j in range(3):", "- for k in range(3):", "- if j == k:", "- continue", "- dp[i + 1][k] = max(dp...
false
0.102969
0.087378
1.178443
[ "s419270458", "s951920126" ]
u071680334
p02574
python
s285637345
s408545462
697
337
196,636
188,472
Accepted
Accepted
51.65
from math import gcd, sqrt def Divisor_Set(n): s = set() for i in range(1, int(sqrt(n))+2): if n%i == 0: s.add(i) s.add(n//i) return s def main(): n = int(eval(input())) a = list(map(int, input().split())) f = True divset = set() for v in ...
from math import gcd class Factor: def __init__(self, max_element): self.minFactor = [-1]*(max_element+1) for i in range(2, max_element+1): if self.minFactor[i] == -1: for j in range(i, max_element+1, i): self.minFactor[j] = i def getFactor...
38
60
845
1,735
from math import gcd, sqrt def Divisor_Set(n): s = set() for i in range(1, int(sqrt(n)) + 2): if n % i == 0: s.add(i) s.add(n // i) return s def main(): n = int(eval(input())) a = list(map(int, input().split())) f = True divset = set() for v in a: ...
from math import gcd class Factor: def __init__(self, max_element): self.minFactor = [-1] * (max_element + 1) for i in range(2, max_element + 1): if self.minFactor[i] == -1: for j in range(i, max_element + 1, i): self.minFactor[j] = i def getFac...
false
36.666667
[ "-from math import gcd, sqrt", "+from math import gcd", "-def Divisor_Set(n):", "- s = set()", "- for i in range(1, int(sqrt(n)) + 2):", "- if n % i == 0:", "- s.add(i)", "- s.add(n // i)", "- return s", "+class Factor:", "+ def __init__(self, max_element...
false
0.036998
0.04304
0.859609
[ "s285637345", "s408545462" ]
u078042885
p02397
python
s803560910
s199313831
60
50
7,596
7,664
Accepted
Accepted
16.67
x,y=input().split() while (x!='0'or y!='0'): if(int(x)>int(y)):print(("{} {}".format(y,x))) else:print(("{} {}".format(x,y))) x,y=input().split()
while 1: x,y=map(int,input().split()) if x==0 and y==0:break print(*[y,x] if x>y else [x,y])
5
4
157
107
x, y = input().split() while x != "0" or y != "0": if int(x) > int(y): print(("{} {}".format(y, x))) else: print(("{} {}".format(x, y))) x, y = input().split()
while 1: x, y = map(int, input().split()) if x == 0 and y == 0: break print(*[y, x] if x > y else [x, y])
false
20
[ "-x, y = input().split()", "-while x != \"0\" or y != \"0\":", "- if int(x) > int(y):", "- print((\"{} {}\".format(y, x)))", "- else:", "- print((\"{} {}\".format(x, y)))", "- x, y = input().split()", "+while 1:", "+ x, y = map(int, input().split())", "+ if x == 0 and ...
false
0.099479
0.04417
2.252196
[ "s803560910", "s199313831" ]
u398846051
p03785
python
s167316441
s518257219
691
238
39,868
7,384
Accepted
Accepted
65.56
N, C, K = list(map(int, input().split())) T = [] for _ in range(N): T.append((int(eval(input())), False)) T.append((T[-1][0] + K, True)) T.sort(key=lambda x: (x[0], x[1])) ans = 0 arrived = 0 head = 0 for t, bo in T: if arrived == 0 and not bo: head = t arrived += not bo if (bo ...
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for _ in range(N)] T.sort() ans = 0 first = T[0] arrived = 0 for t in T: if first + K < t or arrived == C: ans += 1 arrived = 0 first = t arrived += 1 print((ans + (arrived > 0)))
20
13
468
275
N, C, K = list(map(int, input().split())) T = [] for _ in range(N): T.append((int(eval(input())), False)) T.append((T[-1][0] + K, True)) T.sort(key=lambda x: (x[0], x[1])) ans = 0 arrived = 0 head = 0 for t, bo in T: if arrived == 0 and not bo: head = t arrived += not bo if (bo and arrived >...
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for _ in range(N)] T.sort() ans = 0 first = T[0] arrived = 0 for t in T: if first + K < t or arrived == C: ans += 1 arrived = 0 first = t arrived += 1 print((ans + (arrived > 0)))
false
35
[ "-T = []", "-for _ in range(N):", "- T.append((int(eval(input())), False))", "- T.append((T[-1][0] + K, True))", "-T.sort(key=lambda x: (x[0], x[1]))", "+T = [int(eval(input())) for _ in range(N)]", "+T.sort()", "+first = T[0]", "-head = 0", "-for t, bo in T:", "- if arrived == 0 and no...
false
0.041043
0.036327
1.129816
[ "s167316441", "s518257219" ]
u123756661
p02991
python
s149023483
s700713786
690
386
78,296
73,692
Accepted
Accepted
44.06
from collections import deque def sol(): n,m=list(map(int,input().split())) d={} for i in range(m): u,v=list(map(int,input().split())) if u in d: d[u].append(v) else: d[u]=[v] s,t=list(map(int,input().split())) ans=chk=0 w=deque([0,s]) ...
from collections import deque import sys input = sys.stdin.readline def sol(): n,m=list(map(int,input().split())) d={} for i in range(m): u,v=list(map(int,input().split())) if u in d: d[u].append(v) else: d[u]=[v] s,t=list(map(int,input().spl...
36
38
831
852
from collections import deque def sol(): n, m = list(map(int, input().split())) d = {} for i in range(m): u, v = list(map(int, input().split())) if u in d: d[u].append(v) else: d[u] = [v] s, t = list(map(int, input().split())) ans = chk = 0 w = d...
from collections import deque import sys input = sys.stdin.readline def sol(): n, m = list(map(int, input().split())) d = {} for i in range(m): u, v = list(map(int, input().split())) if u in d: d[u].append(v) else: d[u] = [v] s, t = list(map(int, input(...
false
5.263158
[ "+import sys", "+", "+input = sys.stdin.readline", "- # tmp=[0]*(n+1)" ]
false
0.047079
0.047894
0.982976
[ "s149023483", "s700713786" ]
u111473084
p02686
python
s311568595
s122378403
1,800
977
91,980
92,156
Accepted
Accepted
45.72
# 折れ線グラフで考えると # ( : +1 # ) : -1 # 0で終わる # 0未満にならない → 各文字列で最下点と和を利用 # 和がマイナスの部分と分けて、マイナス部分は反転して考える n = int(eval(input())) s = [eval(input()) for _ in range(n)] plus = [] minus = [] for i in s: min_v = 0 sum_v = 0 for j in i: sum_v += 1 if j == '(' else -1 min_v = min(min_v, s...
# 折れ線グラフで考えると # ( : +1 # ) : -1 # 0で終わる # 0未満にならない → 各文字列で最下点と和を利用 # 和がマイナスの部分と分けて、マイナス部分は反転して考える import sys input = sys.stdin.readline n = int(eval(input())) s = [input().strip() for _ in range(n)] plus = [] minus = [] for i in s: min_v = 0 sum_v = 0 for j in i: sum_v += 1 if j ...
46
49
864
914
# 折れ線グラフで考えると # ( : +1 # ) : -1 # 0で終わる # 0未満にならない → 各文字列で最下点と和を利用 # 和がマイナスの部分と分けて、マイナス部分は反転して考える n = int(eval(input())) s = [eval(input()) for _ in range(n)] plus = [] minus = [] for i in s: min_v = 0 sum_v = 0 for j in i: sum_v += 1 if j == "(" else -1 min_v = min(min_v, sum_v) if sum_...
# 折れ線グラフで考えると # ( : +1 # ) : -1 # 0で終わる # 0未満にならない → 各文字列で最下点と和を利用 # 和がマイナスの部分と分けて、マイナス部分は反転して考える import sys input = sys.stdin.readline n = int(eval(input())) s = [input().strip() for _ in range(n)] plus = [] minus = [] for i in s: min_v = 0 sum_v = 0 for j in i: sum_v += 1 if j == "(" else -1 ...
false
6.122449
[ "+import sys", "+", "+input = sys.stdin.readline", "-s = [eval(input()) for _ in range(n)]", "+s = [input().strip() for _ in range(n)]" ]
false
0.039963
0.084193
0.474659
[ "s311568595", "s122378403" ]
u932465688
p03608
python
s409652350
s067938023
693
608
19,376
79,064
Accepted
Accepted
12.27
from scipy.sparse.csgraph import floyd_warshall import itertools n,m,r = list(map(int,input().split())) L = list(map(int,input().split())) d = [[float("inf")]*n for i in range(n)] for i in range(n): d[i][i] = 0 for i in range(m): a,b,l = list(map(int,input().split())) d[a-1][b-1] = l d[b-1][a-...
import itertools N,M,R = list(map(int,input().split())) r = list(map(int,input().split())) L = [] ans = float('inf') for i in range(M): L.append(list(map(int,input().split()))) cost = [] for i in range(N): T = [float('inf') for j in range(N)] cost.append(T) for i in range(M): cost[L[i][0]-...
27
29
650
762
from scipy.sparse.csgraph import floyd_warshall import itertools n, m, r = list(map(int, input().split())) L = list(map(int, input().split())) d = [[float("inf")] * n for i in range(n)] for i in range(n): d[i][i] = 0 for i in range(m): a, b, l = list(map(int, input().split())) d[a - 1][b - 1] = l d[b -...
import itertools N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) L = [] ans = float("inf") for i in range(M): L.append(list(map(int, input().split()))) cost = [] for i in range(N): T = [float("inf") for j in range(N)] cost.append(T) for i in range(M): cost[L[i][0] - 1][L[i...
false
6.896552
[ "-from scipy.sparse.csgraph import floyd_warshall", "-n, m, r = list(map(int, input().split()))", "-L = list(map(int, input().split()))", "-d = [[float(\"inf\")] * n for i in range(n)]", "-for i in range(n):", "- d[i][i] = 0", "-for i in range(m):", "- a, b, l = list(map(int, input().split()))",...
false
0.406528
0.041109
9.889074
[ "s409652350", "s067938023" ]
u078349616
p02899
python
s593526937
s201641642
196
86
20,704
15,588
Accepted
Accepted
56.12
N = int(input()) a = list(map(int, input().split())) dict = {} for i in range(len(a)): dict[a[i]] = i+1 for i in range(len(dict)): print(dict[i+1], end =" ")
N = int(eval(input())) A = list(map(int, input().split())) ans = [0]*N for i in range(N): ans[A[i]-1] = str(i+1) print((" ".join(ans)))
9
8
171
140
N = int(input()) a = list(map(int, input().split())) dict = {} for i in range(len(a)): dict[a[i]] = i + 1 for i in range(len(dict)): print(dict[i + 1], end=" ")
N = int(eval(input())) A = list(map(int, input().split())) ans = [0] * N for i in range(N): ans[A[i] - 1] = str(i + 1) print((" ".join(ans)))
false
11.111111
[ "-N = int(input())", "-a = list(map(int, input().split()))", "-dict = {}", "-for i in range(len(a)):", "- dict[a[i]] = i + 1", "-for i in range(len(dict)):", "- print(dict[i + 1], end=\" \")", "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "+ans = [0] * N", "+for i in r...
false
0.038039
0.065815
0.577977
[ "s593526937", "s201641642" ]
u268793453
p03428
python
s180548478
s810623962
261
218
14,476
12,516
Accepted
Accepted
16.48
from numpy import argmax import numpy as np from collections import defaultdict n = int(eval(input())) H = [np.array([int(j) for j in input().split()]) for i in range(n)] if n == 1: print((1)) exit() # else n == 2: # print(0.5) # print(0.5) # exit() convex = [min(H, key=lambda x:x[...
from numpy import argmax import numpy as np from collections import defaultdict def cross(a, b): return a[0]*b[1]-a[1]*b[0] n = int(eval(input())) H = [np.array([int(j) for j in input().split()]) for i in range(n)] if n == 1: print((1)) exit() # else n == 2: # print(0.5) # print(0....
40
43
1,002
1,051
from numpy import argmax import numpy as np from collections import defaultdict n = int(eval(input())) H = [np.array([int(j) for j in input().split()]) for i in range(n)] if n == 1: print((1)) exit() # else n == 2: # print(0.5) # print(0.5) # exit() convex = [min(H, key=lambda x: x[1])] for i in ra...
from numpy import argmax import numpy as np from collections import defaultdict def cross(a, b): return a[0] * b[1] - a[1] * b[0] n = int(eval(input())) H = [np.array([int(j) for j in input().split()]) for i in range(n)] if n == 1: print((1)) exit() # else n == 2: # print(0.5) # print(0.5) # ...
false
6.976744
[ "+", "+", "+def cross(a, b):", "+ return a[0] * b[1] - a[1] * b[0]", "+", "- cross_ = np.cross(ac, bc)", "+ cross_ = cross(ac, bc)" ]
false
0.32079
0.590115
0.543606
[ "s180548478", "s810623962" ]
u191874006
p04013
python
s249528634
s432679055
210
180
125,668
119,388
Accepted
Accepted
14.29
#!/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 n, a = list(map(int, input().split())) x = list(map(int, input().split())) s = sum(x) dp = [[[0] * (s+1) for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 for i in range(1, n+1): xi = x[i-1] for j in range(s+1): for k in range(i): dp[i][k][j] = dp[i-1...
37
21
1,030
537
#!/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 n, a = list(map(int, input().split())) x = list(map(int, input().split())) s = sum(x) dp = [[[0] * (s + 1) for _ in range(n + 1)] for _ in range(n + 1)] dp[0][0][0] = 1 for i in range(1, n + 1): xi = x[i - 1] for j in range(s + 1): for k in range(i): dp[i][k][j] = dp[i...
false
43.243243
[ "-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 coll...
false
0.074724
0.039373
1.897851
[ "s249528634", "s432679055" ]
u407160848
p02686
python
s491839507
s982741188
823
707
208,716
193,700
Accepted
Accepted
14.09
import math from functools import reduce from collections import deque import sys sys.setrecursionlimit(10**7) from heapq import heappush, heappop def input(): return sys.stdin.readline().strip() # スペース区切りの入力を読み込んで数値リストにして返します。 def get_nums_l(): return [ int(s) for s in input().split(" ")] # 改行...
import sys sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline().strip() def log(*args): print("DEBUG:", *args, file=sys.stderr) n = int(input()) S = [ input() for _ in range(n)] left = 0 right = 0 LMR = [0] * n MIN_LMR = [0] * n for i,s in enumerate(S): l = 0 r...
112
68
2,310
1,366
import math from functools import reduce from collections import deque import sys sys.setrecursionlimit(10**7) from heapq import heappush, heappop def input(): return sys.stdin.readline().strip() # スペース区切りの入力を読み込んで数値リストにして返します。 def get_nums_l(): return [int(s) for s in input().split(" ")] # 改行区切りの入力をn行読み...
import sys sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline().strip() def log(*args): print("DEBUG:", *args, file=sys.stderr) n = int(input()) S = [input() for _ in range(n)] left = 0 right = 0 LMR = [0] * n MIN_LMR = [0] * n for i, s in enumerate(S): l = 0 r = 0 lok = True...
false
39.285714
[ "-import math", "-from functools import reduce", "-from collections import deque", "-from heapq import heappush, heappop", "-# スペース区切りの入力を読み込んで数値リストにして返します。", "-def get_nums_l():", "- return [int(s) for s in input().split(\" \")]", "-", "-", "-# 改行区切りの入力をn行読み込んで数値リストにして返します。", "-def get_nums_...
false
0.045217
0.047107
0.959874
[ "s491839507", "s982741188" ]
u137228327
p03712
python
s408665643
s113401206
36
28
9,328
9,180
Accepted
Accepted
22.22
from collections import deque H,W = list(map(int,input().split())) st = [str(eval(input())) for _ in range(H)] #print(st) st = deque(st) for i in range(H): st[i] = '#'+st[i]+'#' st.appendleft('#'*(W+2)) st.append('#'*(W+2)) for i in range(H+2): print((st[i]))
H,W = map(int,input().split()) st = ['#' + str(input()) +'#' for _ in range(H)] st = ['#'*(W+2)] + st + ['#'*(W+2)] print(*st,sep='\n')
12
5
266
140
from collections import deque H, W = list(map(int, input().split())) st = [str(eval(input())) for _ in range(H)] # print(st) st = deque(st) for i in range(H): st[i] = "#" + st[i] + "#" st.appendleft("#" * (W + 2)) st.append("#" * (W + 2)) for i in range(H + 2): print((st[i]))
H, W = map(int, input().split()) st = ["#" + str(input()) + "#" for _ in range(H)] st = ["#" * (W + 2)] + st + ["#" * (W + 2)] print(*st, sep="\n")
false
58.333333
[ "-from collections import deque", "-", "-H, W = list(map(int, input().split()))", "-st = [str(eval(input())) for _ in range(H)]", "-# print(st)", "-st = deque(st)", "-for i in range(H):", "- st[i] = \"#\" + st[i] + \"#\"", "-st.appendleft(\"#\" * (W + 2))", "-st.append(\"#\" * (W + 2))", "-fo...
false
0.00832
0.038038
0.21873
[ "s408665643", "s113401206" ]
u773265208
p02990
python
s420392964
s833429584
1,188
1,053
3,444
70,616
Accepted
Accepted
11.36
def cmb(n, r): if r == 0: return 1 if r == 1: return n if n < r: return 0 if n - r < r: r = n - r numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2,r+1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p fo...
import math def cmb(n, r): if r == 0: return 1 if r == 1: return n if n < r: return 0 return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n,k = list(map(int,input().split())) blue = k red = n-k print((red+1)) for i in range(2,blue+1): print(((cmb(red+1,i)%(10**9+7)) * (cmb...
32
15
722
347
def cmb(n, r): if r == 0: return 1 if r == 1: return n if n < r: return 0 if n - r < r: r = n - r numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivo...
import math def cmb(n, r): if r == 0: return 1 if r == 1: return n if n < r: return 0 return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n, k = list(map(int, input().split())) blue = k red = n - k print((red + 1)) for i in range(2, blue + 1): print( ...
false
53.125
[ "+import math", "+", "+", "- if n - r < r:", "- r = n - r", "- numerator = [n - r + k + 1 for k in range(r)]", "- denominator = [k + 1 for k in range(r)]", "- for p in range(2, r + 1):", "- pivot = denominator[p - 1]", "- if pivot > 1:", "- offset = (n...
false
0.046012
0.045164
1.018783
[ "s420392964", "s833429584" ]
u497952650
p03457
python
s419415334
s699517686
277
254
22,424
9,204
Accepted
Accepted
8.3
N = int(eval(input())) txy = list(tuple(map(int,input().split())) for _ in range(N)) t_0 = 0 x_0 = 0 y_0 = 0 for t,x,y in txy: dt = t - t_0 dx = x - x_0 dy = y - y_0 if (abs(dx) + abs(dy))%2 == dt%2 and (abs(dx)+abs(dy)) <= dt: t_0 = t x_0 = x y_0 = y else:...
N = int(eval(input())) t_0 = 0 x_0 = 0 y_0 = 0 flag = True for _ in range(N): t,x,y = list(map(int,input().split())) if not (abs(x-x_0) + abs(y-y_0) <= abs(t-t_0) and (abs(x-x_0)+abs(y-y_0))%2 == abs(t-t_0)%2): flag = False x_0 = x y_0 = y t_0 = t print(("Yes" if flag els...
21
17
367
314
N = int(eval(input())) txy = list(tuple(map(int, input().split())) for _ in range(N)) t_0 = 0 x_0 = 0 y_0 = 0 for t, x, y in txy: dt = t - t_0 dx = x - x_0 dy = y - y_0 if (abs(dx) + abs(dy)) % 2 == dt % 2 and (abs(dx) + abs(dy)) <= dt: t_0 = t x_0 = x y_0 = y else: p...
N = int(eval(input())) t_0 = 0 x_0 = 0 y_0 = 0 flag = True for _ in range(N): t, x, y = list(map(int, input().split())) if not ( abs(x - x_0) + abs(y - y_0) <= abs(t - t_0) and (abs(x - x_0) + abs(y - y_0)) % 2 == abs(t - t_0) % 2 ): flag = False x_0 = x y_0 = y t_0 = t p...
false
19.047619
[ "-txy = list(tuple(map(int, input().split())) for _ in range(N))", "-for t, x, y in txy:", "- dt = t - t_0", "- dx = x - x_0", "- dy = y - y_0", "- if (abs(dx) + abs(dy)) % 2 == dt % 2 and (abs(dx) + abs(dy)) <= dt:", "- t_0 = t", "- x_0 = x", "- y_0 = y", "- el...
false
0.045891
0.047
0.976408
[ "s419415334", "s699517686" ]
u628285938
p03103
python
s595565186
s191469138
1,017
259
23,908
23,628
Accepted
Accepted
74.53
# -*- coding: utf-8 -*- """ Created on Sun Sep 13 02:42:27 2020 @author: liang """ N, M = list(map(int, input().split())) drinks = list() for i in range(N): a, b = list(map(int,input().split())) drinks.append((a,b)) drinks.sort(key = lambda x: x[0]) #print(drinks) ans = 0 while M > 0: ...
# -*- coding: utf-8 -*- """ Created on Sun Sep 13 02:42:27 2020 @author: liang """ N, M = list(map(int, input().split())) drinks = list() for i in range(N): a, b = list(map(int,input().split())) drinks.append((a,b)) drinks.sort(key = lambda x: x[0]) #print(drinks) ans = 0 i = 0 while M > 0: ...
27
28
457
466
# -*- coding: utf-8 -*- """ Created on Sun Sep 13 02:42:27 2020 @author: liang """ N, M = list(map(int, input().split())) drinks = list() for i in range(N): a, b = list(map(int, input().split())) drinks.append((a, b)) drinks.sort(key=lambda x: x[0]) # print(drinks) ans = 0 while M > 0: a, b = drinks.pop(0) ...
# -*- coding: utf-8 -*- """ Created on Sun Sep 13 02:42:27 2020 @author: liang """ N, M = list(map(int, input().split())) drinks = list() for i in range(N): a, b = list(map(int, input().split())) drinks.append((a, b)) drinks.sort(key=lambda x: x[0]) # print(drinks) ans = 0 i = 0 while M > 0: a, b = drinks[i...
false
3.571429
[ "+i = 0", "- a, b = drinks.pop(0)", "+ a, b = drinks[i]", "+ i += 1" ]
false
0.082831
0.037458
2.211284
[ "s595565186", "s191469138" ]
u560867850
p03546
python
s051462606
s350503692
31
27
5,868
3,188
Accepted
Accepted
12.9
import sys input = sys.stdin.readline from collections import Counter from itertools import chain def readlines(n): for _ in range(n): yield list(map(int, input().split())) def main(): h, w = list(map(int, input().split())) C = [[int(c) for c in input().split()] for _ in range(10)] ...
import sys input = sys.stdin.readline def readlines(n): for _ in range(n): yield list(map(int, input().split())) def main(): h, w = list(map(int, input().split())) C = list(readlines(10)) for k in range(10): for i in range(10): for j in range(10): ...
29
24
599
483
import sys input = sys.stdin.readline from collections import Counter from itertools import chain def readlines(n): for _ in range(n): yield list(map(int, input().split())) def main(): h, w = list(map(int, input().split())) C = [[int(c) for c in input().split()] for _ in range(10)] for k in...
import sys input = sys.stdin.readline def readlines(n): for _ in range(n): yield list(map(int, input().split())) def main(): h, w = list(map(int, input().split())) C = list(readlines(10)) for k in range(10): for i in range(10): for j in range(10): C[i][j]...
false
17.241379
[ "-from collections import Counter", "-from itertools import chain", "- C = [[int(c) for c in input().split()] for _ in range(10)]", "+ C = list(readlines(10))", "- counter = Counter(chain(*readlines(h)))", "- for i in range(10):", "- yield C[i][1] * counter[i]", "+ for line in re...
false
0.039334
0.038892
1.011372
[ "s051462606", "s350503692" ]
u357751375
p03341
python
s178744817
s384803209
162
126
9,732
9,704
Accepted
Accepted
22.22
# E = 右向き, W = 左向き n = int(eval(input())) s = eval(input()) we = s.count('E') ww = s.count('W') ew = 0 ee = 0 ans = 3 * (10 ** 5) for i in range(n): if s[i] == 'W': ww -= 1 else: we -= 1 ans = min(ans,we+ew) if s[i] == 'W': ew += 1 else: ee += 1 prin...
n = int(eval(input())) s = eval(input()) e = s.count('E') w = 0 ans = 3 * (10 ** 5) for i in s: if i == 'E': e -= 1 ans = min(ans,e + w) if i == 'W': w += 1 print(ans)
19
12
314
194
# E = 右向き, W = 左向き n = int(eval(input())) s = eval(input()) we = s.count("E") ww = s.count("W") ew = 0 ee = 0 ans = 3 * (10**5) for i in range(n): if s[i] == "W": ww -= 1 else: we -= 1 ans = min(ans, we + ew) if s[i] == "W": ew += 1 else: ee += 1 print(ans)
n = int(eval(input())) s = eval(input()) e = s.count("E") w = 0 ans = 3 * (10**5) for i in s: if i == "E": e -= 1 ans = min(ans, e + w) if i == "W": w += 1 print(ans)
false
36.842105
[ "-# E = 右向き, W = 左向き", "-we = s.count(\"E\")", "-ww = s.count(\"W\")", "-ew = 0", "-ee = 0", "+e = s.count(\"E\")", "+w = 0", "-for i in range(n):", "- if s[i] == \"W\":", "- ww -= 1", "- else:", "- we -= 1", "- ans = min(ans, we + ew)", "- if s[i] == \"W\":", "...
false
0.106333
0.047979
2.216237
[ "s178744817", "s384803209" ]
u282228874
p03106
python
s275557462
s301397681
37
17
5,048
2,940
Accepted
Accepted
54.05
from fractions import gcd a,b,k = list(map(int,input().split())) g = gcd(a,b) n = [i for i in range(1,g+1) if g%i==0] print((n[-k]))
a,b,k = list(map(int,input().split())) num = [] for i in range(1,101): if a%i == 0 and b%i == 0: num.append(i) print((num[-k]))
5
6
128
137
from fractions import gcd a, b, k = list(map(int, input().split())) g = gcd(a, b) n = [i for i in range(1, g + 1) if g % i == 0] print((n[-k]))
a, b, k = list(map(int, input().split())) num = [] for i in range(1, 101): if a % i == 0 and b % i == 0: num.append(i) print((num[-k]))
false
16.666667
[ "-from fractions import gcd", "-", "-g = gcd(a, b)", "-n = [i for i in range(1, g + 1) if g % i == 0]", "-print((n[-k]))", "+num = []", "+for i in range(1, 101):", "+ if a % i == 0 and b % i == 0:", "+ num.append(i)", "+print((num[-k]))" ]
false
0.052747
0.036694
1.437497
[ "s275557462", "s301397681" ]
u390727364
p02708
python
s986473418
s623809575
67
60
94,864
63,132
Accepted
Accepted
10.45
from sys import stdin, setrecursionlimit def main(): mod = 10 ** 9 + 7 input = stdin.buffer.readline n, k = list(map(int, input().split())) mins = [0] maxs = [n] tmp_min = 0 tmp_max = n for i in range(1, n + 1): tmp_min += i mins.append(tmp_min) ...
from sys import stdin, setrecursionlimit def main(): mod = 10 ** 9 + 7 input = stdin.buffer.readline n, k = list(map(int, input().split())) ans = 0 for i in range(k, n + 2): ans += (n - i + 1) * i + 1 ans %= mod print((ans % mod)) if __name__ == "__main__": ...
27
17
563
350
from sys import stdin, setrecursionlimit def main(): mod = 10**9 + 7 input = stdin.buffer.readline n, k = list(map(int, input().split())) mins = [0] maxs = [n] tmp_min = 0 tmp_max = n for i in range(1, n + 1): tmp_min += i mins.append(tmp_min) tmp_max += n - i ...
from sys import stdin, setrecursionlimit def main(): mod = 10**9 + 7 input = stdin.buffer.readline n, k = list(map(int, input().split())) ans = 0 for i in range(k, n + 2): ans += (n - i + 1) * i + 1 ans %= mod print((ans % mod)) if __name__ == "__main__": setrecursionlimi...
false
37.037037
[ "- mins = [0]", "- maxs = [n]", "- tmp_min = 0", "- tmp_max = n", "- for i in range(1, n + 1):", "- tmp_min += i", "- mins.append(tmp_min)", "- tmp_max += n - i", "- maxs.append(tmp_max)", "- for i in range(k - 1, n + 1):", "- ans += maxs[i] -...
false
0.149196
0.095583
1.560913
[ "s986473418", "s623809575" ]
u606878291
p02882
python
s674645835
s034451861
37
28
9,448
9,348
Accepted
Accepted
24.32
import math a, b, x = list(map(int, input().split(' '))) x = x / a def f(t): tan = math.tan(t) if tan <= b / a: return (a * b) - (a * a * tan / 2) else: return b * (b / tan) / 2 left = 0.0 right = math.pi / 2 for i in range(10000): theta = (left + right) / 2 ...
import math a, b, x = list(map(int, input().split(' '))) x = x / a if x > a * b / 2: print((math.atan2((a * b - x) * 2, a ** 2) * 180 / math.pi)) else: print((math.atan2(b ** 2, x * 2) * 180 / math.pi))
26
10
421
213
import math a, b, x = list(map(int, input().split(" "))) x = x / a def f(t): tan = math.tan(t) if tan <= b / a: return (a * b) - (a * a * tan / 2) else: return b * (b / tan) / 2 left = 0.0 right = math.pi / 2 for i in range(10000): theta = (left + right) / 2 if f(theta) >= x: ...
import math a, b, x = list(map(int, input().split(" "))) x = x / a if x > a * b / 2: print((math.atan2((a * b - x) * 2, a**2) * 180 / math.pi)) else: print((math.atan2(b**2, x * 2) * 180 / math.pi))
false
61.538462
[ "-", "-", "-def f(t):", "- tan = math.tan(t)", "- if tan <= b / a:", "- return (a * b) - (a * a * tan / 2)", "- else:", "- return b * (b / tan) / 2", "-", "-", "-left = 0.0", "-right = math.pi / 2", "-for i in range(10000):", "- theta = (left + right) / 2", "- ...
false
0.043165
0.037576
1.148751
[ "s674645835", "s034451861" ]
u680851063
p02848
python
s311326661
s308781929
35
30
3,956
3,828
Accepted
Accepted
14.29
n = int(eval(input())) s = eval(input()) x = [] import string a = list(string.ascii_uppercase)*2 #print(a) for i in s: j = 0 b = a.index(i) j = b + n x.append(a[j]) print((''.join(x)))
n = int(eval(input())) s = eval(input()) x = [] import string a = list(string.ascii_uppercase)*2 #print(a) for i in s: #j = 0 b = a.index(i) j = b + n x.append(a[j]) print((''.join(x)))
13
13
203
204
n = int(eval(input())) s = eval(input()) x = [] import string a = list(string.ascii_uppercase) * 2 # print(a) for i in s: j = 0 b = a.index(i) j = b + n x.append(a[j]) print(("".join(x)))
n = int(eval(input())) s = eval(input()) x = [] import string a = list(string.ascii_uppercase) * 2 # print(a) for i in s: # j = 0 b = a.index(i) j = b + n x.append(a[j]) print(("".join(x)))
false
0
[ "- j = 0", "+ # j = 0" ]
false
0.044081
0.044807
0.983786
[ "s311326661", "s308781929" ]
u046187684
p03470
python
s812928986
s053763904
41
18
3,060
2,940
Accepted
Accepted
56.1
#!/usr/bin/env python3 # coding=utf-8 import sys n = int(sys.stdin.readline().strip()) d = [] for _ in range(n): d.append(int(sys.stdin.readline().strip())) print((len(set(d))))
#!/usr/bin/env python3 # coding=utf-8 import sys d = list([int(x.strip()) for x in sys.stdin.readlines()]) print((len(set(d[1:]))))
10
7
191
142
#!/usr/bin/env python3 # coding=utf-8 import sys n = int(sys.stdin.readline().strip()) d = [] for _ in range(n): d.append(int(sys.stdin.readline().strip())) print((len(set(d))))
#!/usr/bin/env python3 # coding=utf-8 import sys d = list([int(x.strip()) for x in sys.stdin.readlines()]) print((len(set(d[1:]))))
false
30
[ "-n = int(sys.stdin.readline().strip())", "-d = []", "-for _ in range(n):", "- d.append(int(sys.stdin.readline().strip()))", "-print((len(set(d))))", "+d = list([int(x.strip()) for x in sys.stdin.readlines()])", "+print((len(set(d[1:]))))" ]
false
0.041395
0.112553
0.367781
[ "s812928986", "s053763904" ]
u367701763
p02588
python
s478705393
s953432405
667
526
90,048
86,820
Accepted
Accepted
21.14
def five(x): cnt1 = 0 while x%5==0: cnt1+= 1 x = x//5 cnt2 = 0 while x%2==0: cnt2+= 1 x = x//2 return (min(cnt1,18), min(cnt2,18)) N = int(eval(input())) F = [] for i in range(N): A = float(eval(input())) A = round(A*(10**9)) F.append(fi...
def five(x): cnt1 = 0 while x%5==0: cnt1+= 1 x = x//5 cnt2 = 0 while x%2==0: cnt2+= 1 x = x//2 return (min2(cnt1,18), min2(cnt2,18)) def min2(x,y): return x if x < y else y import sys input = sys.stdin.readline N = int(eval(input())) F = [] f...
47
39
764
714
def five(x): cnt1 = 0 while x % 5 == 0: cnt1 += 1 x = x // 5 cnt2 = 0 while x % 2 == 0: cnt2 += 1 x = x // 2 return (min(cnt1, 18), min(cnt2, 18)) N = int(eval(input())) F = [] for i in range(N): A = float(eval(input())) A = round(A * (10**9)) F.append(f...
def five(x): cnt1 = 0 while x % 5 == 0: cnt1 += 1 x = x // 5 cnt2 = 0 while x % 2 == 0: cnt2 += 1 x = x // 2 return (min2(cnt1, 18), min2(cnt2, 18)) def min2(x, y): return x if x < y else y import sys input = sys.stdin.readline N = int(eval(input())) F = [] f...
false
17.021277
[ "- return (min(cnt1, 18), min(cnt2, 18))", "+ return (min2(cnt1, 18), min2(cnt2, 18))", "+def min2(x, y):", "+ return x if x < y else y", "+", "+", "+import sys", "+", "+input = sys.stdin.readline", "-# print(F)", "- dp[min(F[i][1], 18)] -= 1", "- # print(i, N - j - 1, d...
false
0.044401
0.048762
0.910578
[ "s478705393", "s953432405" ]
u145950990
p03147
python
s575238959
s076801333
171
18
38,384
2,940
Accepted
Accepted
89.47
n = int(eval(input())) h = list(map(int,input().split())) ans = h[0] for i in range(1,n): if h[i-1]<h[i]: ans += h[i]-h[i-1] print(ans)
n = int(eval(input())) h = list(map(int,input().split())) ans = h[0] for i in range(1,n): if h[i]>h[i-1]:ans+=h[i]-h[i-1] print(ans)
6
6
138
135
n = int(eval(input())) h = list(map(int, input().split())) ans = h[0] for i in range(1, n): if h[i - 1] < h[i]: ans += h[i] - h[i - 1] print(ans)
n = int(eval(input())) h = list(map(int, input().split())) ans = h[0] for i in range(1, n): if h[i] > h[i - 1]: ans += h[i] - h[i - 1] print(ans)
false
0
[ "- if h[i - 1] < h[i]:", "+ if h[i] > h[i - 1]:" ]
false
0.038939
0.040366
0.964653
[ "s575238959", "s076801333" ]
u216928054
p02596
python
s354959396
s827015833
267
130
16,740
9,284
Accepted
Accepted
51.31
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) INF = 10 ** 9 + 1 # sys.maxsize # float("inf") MOD = 10 ** 9 + 7 def debug(*x): print(*x, file=sys.stderr) def solve(K): visited = [False] * K p = 7 % K for i in range(K): if p == 0: return i + 1 ...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) INF = 10 ** 9 + 1 # sys.maxsize # float("inf") MOD = 10 ** 9 + 7 def debug(*x): print(*x, file=sys.stderr) def solve(K): visited = [False] * K p = 7 % K for i in range(K): if p == 0: return i + 1 ...
83
92
1,334
1,484
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) INF = 10**9 + 1 # sys.maxsize # float("inf") MOD = 10**9 + 7 def debug(*x): print(*x, file=sys.stderr) def solve(K): visited = [False] * K p = 7 % K for i in range(K): if p == 0: return i + 1 if visited[p]: ...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) INF = 10**9 + 1 # sys.maxsize # float("inf") MOD = 10**9 + 7 def debug(*x): print(*x, file=sys.stderr) def solve(K): visited = [False] * K p = 7 % K for i in range(K): if p == 0: return i + 1 if visited[p]: ...
false
9.782609
[ "+", "+", "+def solve(K):", "+ p = 7 % K", "+ for i in range(K):", "+ if p == 0:", "+ return i + 1", "+ p = (p * 10 + 7) % K", "+ return -1" ]
false
0.117849
0.087112
1.352857
[ "s354959396", "s827015833" ]
u843175622
p03497
python
s783745234
s547615982
154
129
37,456
37,712
Accepted
Accepted
16.23
from collections import defaultdict n, k, *a = list(map(int, open(0).read().split())) d = defaultdict(int) for b in a: d[b] += 1 k = len(d) - k ans = 0 for v in sorted(d.values()): if k <= 0: break ans += v k -= 1 print(ans)
from collections import defaultdict n, k, *a = list(map(int, open(0).read().split())) d = defaultdict(int) for b in a: d[b] += 1 v = sorted(d.values())[::-1] c = 0 for i in range(min(k, len(v))): c += v[i] print((n - c))
15
14
259
238
from collections import defaultdict n, k, *a = list(map(int, open(0).read().split())) d = defaultdict(int) for b in a: d[b] += 1 k = len(d) - k ans = 0 for v in sorted(d.values()): if k <= 0: break ans += v k -= 1 print(ans)
from collections import defaultdict n, k, *a = list(map(int, open(0).read().split())) d = defaultdict(int) for b in a: d[b] += 1 v = sorted(d.values())[::-1] c = 0 for i in range(min(k, len(v))): c += v[i] print((n - c))
false
6.666667
[ "-k = len(d) - k", "-ans = 0", "-for v in sorted(d.values()):", "- if k <= 0:", "- break", "- ans += v", "- k -= 1", "-print(ans)", "+v = sorted(d.values())[::-1]", "+c = 0", "+for i in range(min(k, len(v))):", "+ c += v[i]", "+print((n - c))" ]
false
0.057034
0.042174
1.35235
[ "s783745234", "s547615982" ]
u982594421
p03208
python
s992109016
s674298638
306
281
8,248
9,048
Accepted
Accepted
8.17
import heapq n, k = list(map(int, input().split())) h = [] d = [0 for _ in range(n)] ans = float('inf') for _ in range(n): heapq.heappush(h, int(eval(input()))) h = [heapq.heappop(h) for _ in range(n)] for i in range(n - k + 1): diff = h[i + k - 1] - h[i] ans = min(ans, diff) print(an...
n, k = list(map(int, input().split())) h = [] d = [0 for _ in range(n)] ans = 1e9 for _ in range(n): h.append(int(eval(input()))) h = sorted(h) for i in range(n - k + 1): diff = h[i + k - 1] - h[i] ans = min(ans, diff) print(ans)
18
15
311
248
import heapq n, k = list(map(int, input().split())) h = [] d = [0 for _ in range(n)] ans = float("inf") for _ in range(n): heapq.heappush(h, int(eval(input()))) h = [heapq.heappop(h) for _ in range(n)] for i in range(n - k + 1): diff = h[i + k - 1] - h[i] ans = min(ans, diff) print(ans)
n, k = list(map(int, input().split())) h = [] d = [0 for _ in range(n)] ans = 1e9 for _ in range(n): h.append(int(eval(input()))) h = sorted(h) for i in range(n - k + 1): diff = h[i + k - 1] - h[i] ans = min(ans, diff) print(ans)
false
16.666667
[ "-import heapq", "-", "-ans = float(\"inf\")", "+ans = 1e9", "- heapq.heappush(h, int(eval(input())))", "-h = [heapq.heappop(h) for _ in range(n)]", "+ h.append(int(eval(input())))", "+h = sorted(h)" ]
false
0.078039
0.069621
1.12092
[ "s992109016", "s674298638" ]
u873616440
p02684
python
s987854033
s963198130
154
135
32,292
32,380
Accepted
Accepted
12.34
N, K = list(map(int, input().split())) A = [int(i) for i in input().split()] R = [False]*(N+1) D = [] p = 1 while True: if R[p]: break D.append(p) R[p] = True p = A[p-1] m = D.index(p) c = len(D)-m if K <= m: print((D[K])) else: print((D[m+(K-m) % c]))
N, K = list(map(int, input().split())) A = list(map(int, input().split())) e = [False] * (N+1) idx = 1 move = [] while True: if e[idx]: break move.append(idx) e[idx] = True idx = A[idx-1] m = move.index(idx) c = len(move) - m if K <= m: print((move[K])) else: print((move[m+(K-m) % ...
19
18
295
315
N, K = list(map(int, input().split())) A = [int(i) for i in input().split()] R = [False] * (N + 1) D = [] p = 1 while True: if R[p]: break D.append(p) R[p] = True p = A[p - 1] m = D.index(p) c = len(D) - m if K <= m: print((D[K])) else: print((D[m + (K - m) % c]))
N, K = list(map(int, input().split())) A = list(map(int, input().split())) e = [False] * (N + 1) idx = 1 move = [] while True: if e[idx]: break move.append(idx) e[idx] = True idx = A[idx - 1] m = move.index(idx) c = len(move) - m if K <= m: print((move[K])) else: print((move[m + (K - m) ...
false
5.263158
[ "-A = [int(i) for i in input().split()]", "-R = [False] * (N + 1)", "-D = []", "-p = 1", "+A = list(map(int, input().split()))", "+e = [False] * (N + 1)", "+idx = 1", "+move = []", "- if R[p]:", "+ if e[idx]:", "- D.append(p)", "- R[p] = True", "- p = A[p - 1]", "-m = D.inde...
false
0.044256
0.047251
0.936609
[ "s987854033", "s963198130" ]
u546285759
p00424
python
s435734578
s328873499
280
250
7,776
7,808
Accepted
Accepted
10.71
while True: n = int(eval(input())) if n == 0: break d = {} for _ in range(n): a, b = input().split() d[a] = b m = int(eval(input())) ans = "" for _ in range(m): a = input().strip() try: ans += d[a] except: ...
while True: n = int(eval(input())) if n == 0: break d = {} for _ in range(n): a, b = input().split() d[a] = b m = int(eval(input())) ans = "" for _ in range(m): a = input().strip() ans += d[a] if a in d else a print(ans)
17
14
333
293
while True: n = int(eval(input())) if n == 0: break d = {} for _ in range(n): a, b = input().split() d[a] = b m = int(eval(input())) ans = "" for _ in range(m): a = input().strip() try: ans += d[a] except: ans += a p...
while True: n = int(eval(input())) if n == 0: break d = {} for _ in range(n): a, b = input().split() d[a] = b m = int(eval(input())) ans = "" for _ in range(m): a = input().strip() ans += d[a] if a in d else a print(ans)
false
17.647059
[ "- try:", "- ans += d[a]", "- except:", "- ans += a", "+ ans += d[a] if a in d else a" ]
false
0.04396
0.007183
6.120039
[ "s435734578", "s328873499" ]
u861141787
p03107
python
s515663319
s499142876
187
21
45,936
3,956
Accepted
Accepted
88.77
A = list(eval(input())) N = len(A) C0 = A.count("0") C1 = A.count("1") print((2 * min(C0, C1)))
s = list(eval(input())) n = len(s) c_0 = s.count("0") c_1 = n - c_0 ans = min(c_0, c_1) * 2 print(ans)
7
9
96
107
A = list(eval(input())) N = len(A) C0 = A.count("0") C1 = A.count("1") print((2 * min(C0, C1)))
s = list(eval(input())) n = len(s) c_0 = s.count("0") c_1 = n - c_0 ans = min(c_0, c_1) * 2 print(ans)
false
22.222222
[ "-A = list(eval(input()))", "-N = len(A)", "-C0 = A.count(\"0\")", "-C1 = A.count(\"1\")", "-print((2 * min(C0, C1)))", "+s = list(eval(input()))", "+n = len(s)", "+c_0 = s.count(\"0\")", "+c_1 = n - c_0", "+ans = min(c_0, c_1) * 2", "+print(ans)" ]
false
0.041262
0.084386
0.48897
[ "s515663319", "s499142876" ]
u790710233
p03111
python
s578654588
s860391796
1,273
115
3,316
3,064
Accepted
Accepted
90.97
from collections import Counter n, a, b, c = list(map(int, input().split())) L = [int(eval(input())) for _ in range(n)] def base_n(x, n, zero_padding=8): retval = [[], ['0']][x == 0] while x > 0: x, r = divmod(x, n) retval.append(str(r)) cnt = zero_padding - len(retval) pad ...
n, a, b, c = list(map(int, input().split())) L = [int(eval(input())) for _ in range(n)] INF = 10**8 def dfs(current_index, sum_a, sum_b, sum_c): if current_index == n: if min(sum_a, sum_b, sum_c) > 0: return sum(abs(x-y) for x, y in zip([a, b, c], [sum_a, sum_b,...
29
20
816
725
from collections import Counter n, a, b, c = list(map(int, input().split())) L = [int(eval(input())) for _ in range(n)] def base_n(x, n, zero_padding=8): retval = [[], ["0"]][x == 0] while x > 0: x, r = divmod(x, n) retval.append(str(r)) cnt = zero_padding - len(retval) pad = ["", "0"...
n, a, b, c = list(map(int, input().split())) L = [int(eval(input())) for _ in range(n)] INF = 10**8 def dfs(current_index, sum_a, sum_b, sum_c): if current_index == n: if min(sum_a, sum_b, sum_c) > 0: return ( sum(abs(x - y) for x, y in zip([a, b, c], [sum_a, sum_b, sum_c])) - ...
false
31.034483
[ "-from collections import Counter", "-", "+INF = 10**8", "-def base_n(x, n, zero_padding=8):", "- retval = [[], [\"0\"]][x == 0]", "- while x > 0:", "- x, r = divmod(x, n)", "- retval.append(str(r))", "- cnt = zero_padding - len(retval)", "- pad = [\"\", \"0\" * cnt][cnt ...
false
0.42251
0.138002
3.061615
[ "s578654588", "s860391796" ]
u706929073
p03354
python
s858084803
s807110353
720
650
36,044
36,044
Accepted
Accepted
9.72
n, m = list(map(int, input().split())) p = list([int(x) - 1 for x in input().split()]) xy = [list([int(x) - 1 for x in input().split()]) for _ in range(m)] par = [i for i in range(n)] rank = [0 for _ in range(n)] def root(x): if par[x] == x: return par[x] par[x] = root(par[x]) return ...
n, m = list(map(int, input().split())) p = list([int(x) - 1 for x in input().split()]) xy = [list([int(x) - 1 for x in input().split()]) for _ in range(m)] par = [i for i in range(n)] rank = [0 for _ in range(n)] def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x...
39
39
746
741
n, m = list(map(int, input().split())) p = list([int(x) - 1 for x in input().split()]) xy = [list([int(x) - 1 for x in input().split()]) for _ in range(m)] par = [i for i in range(n)] rank = [0 for _ in range(n)] def root(x): if par[x] == x: return par[x] par[x] = root(par[x]) return par[x] def ...
n, m = list(map(int, input().split())) p = list([int(x) - 1 for x in input().split()]) xy = [list([int(x) - 1 for x in input().split()]) for _ in range(m)] par = [i for i in range(n)] rank = [0 for _ in range(n)] def root(x): if par[x] == x: return x par[x] = root(par[x]) return par[x] def is_sa...
false
0
[ "- return par[x]", "+ return x", "- rank[y] += 1", "+ rank[x] += 1" ]
false
0.048048
0.048049
0.999983
[ "s858084803", "s807110353" ]
u102461423
p02998
python
s751208129
s000753062
383
317
48,384
25,800
Accepted
Accepted
17.23
import numpy as np from scipy.sparse import * import sys input = sys.stdin.readline U = 10**5 N = int(eval(input())) XY = np.array([input().split() for _ in range(N)], dtype=np.int32) graph = csr_matrix((np.ones(N,dtype=np.bool), (XY[:,0], U + XY[:,1])), (2*U+1, 2*U+1)) _, component = csgraph.connected_comp...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import connected_components """ 点(x,y) を、辺x-yと見て二部グラフとみなす """ N = int(readline()) XY = np.array(read().spl...
17
27
563
725
import numpy as np from scipy.sparse import * import sys input = sys.stdin.readline U = 10**5 N = int(eval(input())) XY = np.array([input().split() for _ in range(N)], dtype=np.int32) graph = csr_matrix( (np.ones(N, dtype=np.bool), (XY[:, 0], U + XY[:, 1])), (2 * U + 1, 2 * U + 1) ) _, component = csgraph.connecte...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import connected_components """ 点(x,y) を、辺x-yと見て二部グラフとみなす """ N = int(readline()) XY = np.array(read().split(), np.int32)...
false
37.037037
[ "-import numpy as np", "-from scipy.sparse import *", "-input = sys.stdin.readline", "-U = 10**5", "-N = int(eval(input()))", "-XY = np.array([input().split() for _ in range(N)], dtype=np.int32)", "-graph = csr_matrix(", "- (np.ones(N, dtype=np.bool), (XY[:, 0], U + XY[:, 1])), (2 * U + 1, 2 * U + ...
false
0.801105
0.736115
1.088287
[ "s751208129", "s000753062" ]
u057109575
p02788
python
s745807772
s195598687
938
856
150,468
139,820
Accepted
Accepted
8.74
from bisect import bisect_right N, D, A = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] x = [] h = [] for d, i in sorted(X): x.append(d) h.append(i) ans = 0 k = [-(-v // A) for v in h] y = [0] * (N + 2) for i in range(N): y[i + 1] += y[i] s = ...
from bisect import bisect_right N, D, A = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] X.sort() place = [] hps = [] for x, h in X: place.append(x) hps.append(h) buf = [0] * (N + 2) ans = 0 for i in range(N): # Update buf[i + 1] += buf[i] ...
22
29
436
539
from bisect import bisect_right N, D, A = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] x = [] h = [] for d, i in sorted(X): x.append(d) h.append(i) ans = 0 k = [-(-v // A) for v in h] y = [0] * (N + 2) for i in range(N): y[i + 1] += y[i] s = max(0, k[i] - y[i ...
from bisect import bisect_right N, D, A = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] X.sort() place = [] hps = [] for x, h in X: place.append(x) hps.append(h) buf = [0] * (N + 2) ans = 0 for i in range(N): # Update buf[i + 1] += buf[i] # Calc count t...
false
24.137931
[ "-x = []", "-h = []", "-for d, i in sorted(X):", "- x.append(d)", "- h.append(i)", "+X.sort()", "+place = []", "+hps = []", "+for x, h in X:", "+ place.append(x)", "+ hps.append(h)", "+buf = [0] * (N + 2)", "-k = [-(-v // A) for v in h]", "-y = [0] * (N + 2)", "- y[i + 1] ...
false
0.043899
0.043492
1.009356
[ "s745807772", "s195598687" ]
u945181840
p02803
python
s390456076
s310628725
308
85
3,316
3,316
Accepted
Accepted
72.4
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline H, W = list(map(int, readline().split())) S = tuple(map(tuple, read().split())) def bfs(grid, start): distance = [[-1] * W for _ in range(H)] queue = deque([start]) distance[start[0]][start[1]] = 0 ...
import sys from collections import deque read = sys.stdin.readline H, W = list(map(int, input().split())) S = [list('#' * (W + 2))] + [['#'] + list(read().rstrip()) + ['#'] for _ in range(H)] + [list('#' * (W + 2))] def bfs(grid, start): distance = [[-1] * (W + 2) for _ in range(H + 2)] queue = d...
38
45
979
1,214
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline H, W = list(map(int, readline().split())) S = tuple(map(tuple, read().split())) def bfs(grid, start): distance = [[-1] * W for _ in range(H)] queue = deque([start]) distance[start[0]][start[1]] = 0 while queu...
import sys from collections import deque read = sys.stdin.readline H, W = list(map(int, input().split())) S = ( [list("#" * (W + 2))] + [["#"] + list(read().rstrip()) + ["#"] for _ in range(H)] + [list("#" * (W + 2))] ) def bfs(grid, start): distance = [[-1] * (W + 2) for _ in range(H + 2)] queue...
false
15.555556
[ "-read = sys.stdin.read", "-readline = sys.stdin.readline", "-H, W = list(map(int, readline().split()))", "-S = tuple(map(tuple, read().split()))", "+read = sys.stdin.readline", "+H, W = list(map(int, input().split()))", "+S = (", "+ [list(\"#\" * (W + 2))]", "+ + [[\"#\"] + list(read().rstrip...
false
0.03639
0.035607
1.021985
[ "s390456076", "s310628725" ]
u893063840
p03945
python
s339793396
s002482650
56
18
15,988
3,188
Accepted
Accepted
67.86
# -*- coding: utf-8 -*- from itertools import groupby s = eval(input()) ans = len(list(groupby(s))) - 1 print(ans)
# -*- coding: utf-8 -*- s = eval(input()) ans = s.count("WB") + s.count("BW") print(ans)
8
6
119
90
# -*- coding: utf-8 -*- from itertools import groupby s = eval(input()) ans = len(list(groupby(s))) - 1 print(ans)
# -*- coding: utf-8 -*- s = eval(input()) ans = s.count("WB") + s.count("BW") print(ans)
false
25
[ "-from itertools import groupby", "-", "-ans = len(list(groupby(s))) - 1", "+ans = s.count(\"WB\") + s.count(\"BW\")" ]
false
0.04513
0.037531
1.202469
[ "s339793396", "s002482650" ]
u992541367
p02688
python
s006320531
s133678168
25
20
9,184
9,160
Accepted
Accepted
20
N, K = list(map(int,input().split())) counts = [0 for i in range(N)] for i in range(K): d = int(eval(input())) A = list(map(int,input().split())) for a in A: counts[a-1] += 1 print((counts.count(0)))
N, K = list(map(int,input().split())) counts = [0]*N for i in range(K): d = int(eval(input())) A = list(map(int,input().split())) for a in A: counts[a-1] += 1 print((counts.count(0)))
10
9
220
198
N, K = list(map(int, input().split())) counts = [0 for i in range(N)] for i in range(K): d = int(eval(input())) A = list(map(int, input().split())) for a in A: counts[a - 1] += 1 print((counts.count(0)))
N, K = list(map(int, input().split())) counts = [0] * N for i in range(K): d = int(eval(input())) A = list(map(int, input().split())) for a in A: counts[a - 1] += 1 print((counts.count(0)))
false
10
[ "-counts = [0 for i in range(N)]", "+counts = [0] * N" ]
false
0.038391
0.038562
0.995574
[ "s006320531", "s133678168" ]
u068692021
p02887
python
s733185333
s100164405
62
47
3,316
3,316
Accepted
Accepted
24.19
# -*- coding: utf-8 -*- n = int(eval(input())) s = eval(input()) c = s[0:1] x = 1 for i in range(1,len(s)): # print(i,c,s[i:i+1],x) if s[i:i+1] != c: x = x + 1 c = s[i:i+1] print(x)
N=int(eval(input())) S=eval(input()) count = 0 ans=0 j='' for i in S: count +=1 if (count>=2) & (i==j): continue else: j=i ans += 1 print(ans)
13
14
210
173
# -*- coding: utf-8 -*- n = int(eval(input())) s = eval(input()) c = s[0:1] x = 1 for i in range(1, len(s)): # print(i,c,s[i:i+1],x) if s[i : i + 1] != c: x = x + 1 c = s[i : i + 1] print(x)
N = int(eval(input())) S = eval(input()) count = 0 ans = 0 j = "" for i in S: count += 1 if (count >= 2) & (i == j): continue else: j = i ans += 1 print(ans)
false
7.142857
[ "-# -*- coding: utf-8 -*-", "-n = int(eval(input()))", "-s = eval(input())", "-c = s[0:1]", "-x = 1", "-for i in range(1, len(s)):", "- # print(i,c,s[i:i+1],x)", "- if s[i : i + 1] != c:", "- x = x + 1", "- c = s[i : i + 1]", "-print(x)", "+N = int(eval(input()))", "+S = ...
false
0.123812
0.047127
2.627222
[ "s733185333", "s100164405" ]
u389910364
p03361
python
s092307670
s316691088
320
162
22,764
13,680
Accepted
Accepted
49.38
import bisect import heapq import itertools import math import operator import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator imp...
import bisect import cmath import heapq import itertools import math import operator import os import random import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cac...
48
58
1,039
1,165
import bisect import heapq import itertools import math import operator import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter...
import bisect import cmath import heapq import itertools import math import operator import os import random import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from...
false
17.241379
[ "+import cmath", "+import random", "-sys.setrecursionlimit(2147483647)", "+sys.setrecursionlimit(10**9)", "-H, W = list(map(int, sys.stdin.readline().split()))", "-S = [sys.stdin.readline().rstrip() for _ in range(H)]", "+# MOD = 998244353", "+H, W = list(map(int, sys.stdin.buffer.readline().split()))...
false
0.047308
0.047722
0.991317
[ "s092307670", "s316691088" ]
u968166680
p03682
python
s556530517
s311695654
1,338
1,066
120,652
55,968
Accepted
Accepted
20.33
from sys import stdin, setrecursionlimit from operator import itemgetter setrecursionlimit(10 ** 9) INF = 1 << 60 def input(): return stdin.readline().strip() class UnionFind: # Reference: https://note.nkmk.me/python-union-find/ def __init__(self, n): self.n = n self.pare...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 class UnionFind: # Reference: https://note.nkmk.me/python-union-find/ def __init__(self, n): self.n = n self.parents = [-1] * n def f...
66
70
1,391
1,497
from sys import stdin, setrecursionlimit from operator import itemgetter setrecursionlimit(10**9) INF = 1 << 60 def input(): return stdin.readline().strip() class UnionFind: # Reference: https://note.nkmk.me/python-union-find/ def __init__(self, n): self.n = n self.parents = [-1] * n ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 class UnionFind: # Reference: https://note.nkmk.me/python-union-find/ def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): ...
false
5.714286
[ "-from sys import stdin, setrecursionlimit", "-from operator import itemgetter", "+import sys", "-setrecursionlimit(10**9)", "+read = sys.stdin.read", "+readline = sys.stdin.readline", "+readlines = sys.stdin.readlines", "+sys.setrecursionlimit(10**9)", "-", "-", "-def input():", "- return ...
false
0.10022
0.080078
1.251532
[ "s556530517", "s311695654" ]
u218834617
p02579
python
s687067432
s038496388
1,762
1,251
172,980
226,888
Accepted
Accepted
29
import sys from collections import deque H,W=list(map(int,input().split())) si,sj=[int(x)-1 for x in input().split()] ti,tj=[int(x)-1 for x in input().split()] A=list(sys.stdin) dirs=[-2,-1,0,1,2] dist=[[float('inf')]*W for _ in range(H)] dist[si][sj]=0 dq=deque() dq.append((0,si,sj)) ok=False while dq:...
import sys from collections import deque H,W=list(map(int,input().split())) si,sj=[int(x)-1 for x in input().split()] ti,tj=[int(x)-1 for x in input().split()] A=list(sys.stdin) dirs=[-2,-1,0,1,2] dist=[[float('inf')]*W for _ in range(H)] dist[si][sj]=0 dq=deque() dq.append((0,si,sj)) ok=False while dq:...
45
47
1,015
1,055
import sys from collections import deque H, W = list(map(int, input().split())) si, sj = [int(x) - 1 for x in input().split()] ti, tj = [int(x) - 1 for x in input().split()] A = list(sys.stdin) dirs = [-2, -1, 0, 1, 2] dist = [[float("inf")] * W for _ in range(H)] dist[si][sj] = 0 dq = deque() dq.append((0, si, sj)) o...
import sys from collections import deque H, W = list(map(int, input().split())) si, sj = [int(x) - 1 for x in input().split()] ti, tj = [int(x) - 1 for x in input().split()] A = list(sys.stdin) dirs = [-2, -1, 0, 1, 2] dist = [[float("inf")] * W for _ in range(H)] dist[si][sj] = 0 dq = deque() dq.append((0, si, sj)) o...
false
4.255319
[ "+ if k > dist[i][j]:", "+ continue" ]
false
0.035975
0.093922
0.38303
[ "s687067432", "s038496388" ]
u780025254
p02393
python
s839511367
s736307094
50
20
7,680
5,576
Accepted
Accepted
60
nums = input().split() nums = list(map(int, nums)) nums.sort() print((' '.join(list(map(str, nums)))))
a = sorted(list(map(int, input().split()))) print((' '.join(map(str, a))))
6
2
107
74
nums = input().split() nums = list(map(int, nums)) nums.sort() print((" ".join(list(map(str, nums)))))
a = sorted(list(map(int, input().split()))) print((" ".join(map(str, a))))
false
66.666667
[ "-nums = input().split()", "-nums = list(map(int, nums))", "-nums.sort()", "-print((\" \".join(list(map(str, nums)))))", "+a = sorted(list(map(int, input().split())))", "+print((\" \".join(map(str, a))))" ]
false
0.073548
0.046199
1.591976
[ "s839511367", "s736307094" ]
u929569377
p02918
python
s803426657
s769678324
101
70
4,084
4,084
Accepted
Accepted
30.69
N, K = list(map(int, input().split())) S = list(eval(input())) flag = True for i in range(1, N): if K != 0: if flag: if S[i-1] != S[i]: flag = False if not flag: S[i] = 'L' if S[i] == 'R' else 'R' if i < N - 1: if S[i] ...
N, K = list(map(int, input().split())) S = list(eval(input())) flag = True ans = 0 for i in range(1, N): if S[i] == S[i-1]: ans += 1 if K != 0: if flag: if S[i-1] != S[i]: flag = False ans += 1 else: if S[i-1] != S[i]...
29
19
695
400
N, K = list(map(int, input().split())) S = list(eval(input())) flag = True for i in range(1, N): if K != 0: if flag: if S[i - 1] != S[i]: flag = False if not flag: S[i] = "L" if S[i] == "R" else "R" if i < N - 1: if S[i] == S[i + 1]...
N, K = list(map(int, input().split())) S = list(eval(input())) flag = True ans = 0 for i in range(1, N): if S[i] == S[i - 1]: ans += 1 if K != 0: if flag: if S[i - 1] != S[i]: flag = False ans += 1 else: if S[i - 1] != S[i]: ...
false
34.482759
[ "+ans = 0", "+ if S[i] == S[i - 1]:", "+ ans += 1", "- if not flag:", "- S[i] = \"L\" if S[i] == \"R\" else \"R\"", "- if i < N - 1:", "- if S[i] == S[i + 1]:", "- flag = True", "- K -= 1", "-ans = 0", "-...
false
0.036168
0.069064
0.523691
[ "s803426657", "s769678324" ]
u519227872
p02258
python
s199797129
s355902995
2,600
530
18,452
7,616
Accepted
Accepted
79.62
from sys import stdin n = int(eval(input())) r=[int(eval(input())) for i in range(n)] rv = r[::-1][:-1] m = None p_r_j = None for j,r_j in enumerate(rv): if p_r_j == None or p_r_j < r_j: p_r_j = r_j if p_r_j > r_j: continue r_i = min(r[:-(j+1)]) t = r_j - r_i if m == Non...
n = int(eval(input())) minv = int(eval(input())) maxv = -2*10**9 for i in range(n-1): r = int(eval(input())) maxv = max(maxv,r-minv) minv = min(minv,r) print(maxv)
16
8
344
164
from sys import stdin n = int(eval(input())) r = [int(eval(input())) for i in range(n)] rv = r[::-1][:-1] m = None p_r_j = None for j, r_j in enumerate(rv): if p_r_j == None or p_r_j < r_j: p_r_j = r_j if p_r_j > r_j: continue r_i = min(r[: -(j + 1)]) t = r_j - r_i if m == None or t...
n = int(eval(input())) minv = int(eval(input())) maxv = -2 * 10**9 for i in range(n - 1): r = int(eval(input())) maxv = max(maxv, r - minv) minv = min(minv, r) print(maxv)
false
50
[ "-from sys import stdin", "-", "-r = [int(eval(input())) for i in range(n)]", "-rv = r[::-1][:-1]", "-m = None", "-p_r_j = None", "-for j, r_j in enumerate(rv):", "- if p_r_j == None or p_r_j < r_j:", "- p_r_j = r_j", "- if p_r_j > r_j:", "- continue", "- r_i = min(r[: -...
false
0.061761
0.058033
1.064239
[ "s199797129", "s355902995" ]
u746419473
p02832
python
s029820239
s996038262
102
94
26,268
24,872
Accepted
Accepted
7.84
n = int(eval(input())) *a, = list(map(int, input().split())) ans = 0 current = 1 for i in range(n): if a[i] != current: ans += 1 continue current += 1 print((-1 if ans == n else ans))
n = int(eval(input())) *a, = list(map(int, input().split())) cur = 1 ans = 0 for _a in a: if _a == cur: cur += 1 else: ans += 1 print((-1 if ans == n else ans))
13
12
209
184
n = int(eval(input())) (*a,) = list(map(int, input().split())) ans = 0 current = 1 for i in range(n): if a[i] != current: ans += 1 continue current += 1 print((-1 if ans == n else ans))
n = int(eval(input())) (*a,) = list(map(int, input().split())) cur = 1 ans = 0 for _a in a: if _a == cur: cur += 1 else: ans += 1 print((-1 if ans == n else ans))
false
7.692308
[ "+cur = 1", "-current = 1", "-for i in range(n):", "- if a[i] != current:", "+for _a in a:", "+ if _a == cur:", "+ cur += 1", "+ else:", "- continue", "- current += 1" ]
false
0.091991
0.041204
2.232574
[ "s029820239", "s996038262" ]
u475503988
p03244
python
s793547123
s585886005
796
464
23,368
30,600
Accepted
Accepted
41.71
import numpy as np even = np.zeros(100001, dtype='i') odd = np.zeros(100001, dtype='i') n = int(eval(input())) v = list(map(int, input().split())) for i in range(n): if i % 2 == 0: even[v[i]] += 1 else: odd[v[i]] += 1 e1 = even.argmax() e1n = even.max() o1 = odd.argmax() o1n =...
import numpy as np even = np.zeros(100001, dtype=int) odd = np.zeros(100001, dtype=int) n = int(eval(input())) v = list(map(int, input().split())) for i in range(n): if i % 2 == 0: even[v[i]] += 1 else: odd[v[i]] += 1 e1 = even.argmax() e1n = even.max() o1 = odd.argmax() o1n =...
26
26
527
527
import numpy as np even = np.zeros(100001, dtype="i") odd = np.zeros(100001, dtype="i") n = int(eval(input())) v = list(map(int, input().split())) for i in range(n): if i % 2 == 0: even[v[i]] += 1 else: odd[v[i]] += 1 e1 = even.argmax() e1n = even.max() o1 = odd.argmax() o1n = odd.max() # print...
import numpy as np even = np.zeros(100001, dtype=int) odd = np.zeros(100001, dtype=int) n = int(eval(input())) v = list(map(int, input().split())) for i in range(n): if i % 2 == 0: even[v[i]] += 1 else: odd[v[i]] += 1 e1 = even.argmax() e1n = even.max() o1 = odd.argmax() o1n = odd.max() # print...
false
0
[ "-even = np.zeros(100001, dtype=\"i\")", "-odd = np.zeros(100001, dtype=\"i\")", "+even = np.zeros(100001, dtype=int)", "+odd = np.zeros(100001, dtype=int)" ]
false
0.190922
0.19415
0.983375
[ "s793547123", "s585886005" ]
u705857261
p02936
python
s464618464
s981848928
1,732
1,168
257,752
258,760
Accepted
Accepted
32.56
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10 ** 6) input = sys.stdin.buffer.readline n_nodes, q_query = list(map(int, input().split())) edges = [[] for _ in range(n_nodes)] for _ in range(n_nodes - 1): a, b = list(map(int, input().split())) edges[a - 1].append(b - 1) edges[b...
#!/usr/bin/env python3 from pprint import pprint import sys sys.setrecursionlimit(10 ** 6) input = sys.stdin.buffer.readline INF = float('inf') N, Q = list(map(int, input().split())) graph = [[] for _ in range(N)] for _ in range(N - 1): u, v = list(map(int, input().split())) # undirected, 0-...
39
49
764
966
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) input = sys.stdin.buffer.readline n_nodes, q_query = list(map(int, input().split())) edges = [[] for _ in range(n_nodes)] for _ in range(n_nodes - 1): a, b = list(map(int, input().split())) edges[a - 1].append(b - 1) edges[b - 1].append(a - 1) ...
#!/usr/bin/env python3 from pprint import pprint import sys sys.setrecursionlimit(10**6) input = sys.stdin.buffer.readline INF = float("inf") N, Q = list(map(int, input().split())) graph = [[] for _ in range(N)] for _ in range(N - 1): u, v = list(map(int, input().split())) # undirected, 0-indexed graph[u -...
false
20.408163
[ "+from pprint import pprint", "-n_nodes, q_query = list(map(int, input().split()))", "-edges = [[] for _ in range(n_nodes)]", "-for _ in range(n_nodes - 1):", "- a, b = list(map(int, input().split()))", "- edges[a - 1].append(b - 1)", "- edges[b - 1].append(a - 1)", "-queries = []", "-for _...
false
0.041414
0.041132
1.006856
[ "s464618464", "s981848928" ]
u795733769
p02981
python
s295137981
s158064471
20
17
2,940
2,940
Accepted
Accepted
15
a,b,c = list(map(int, input().split())) if a*b <= c: print((a*b)) else: print(c)
n, a, b = list(map(int, input().split())) if n*a <= b: print((n*a)) else: print(b)
5
7
84
94
a, b, c = list(map(int, input().split())) if a * b <= c: print((a * b)) else: print(c)
n, a, b = list(map(int, input().split())) if n * a <= b: print((n * a)) else: print(b)
false
28.571429
[ "-a, b, c = list(map(int, input().split()))", "-if a * b <= c:", "- print((a * b))", "+n, a, b = list(map(int, input().split()))", "+if n * a <= b:", "+ print((n * a))", "- print(c)", "+ print(b)" ]
false
0.039817
0.041988
0.948286
[ "s295137981", "s158064471" ]
u935558307
p02556
python
s059964889
s880672422
1,194
790
136,344
124,508
Accepted
Accepted
33.84
""" 四隅に仮想の原点をつくり、各座標からその原点へのマンハッタン距離を計測する。 """ N = int(eval(input())) XY = [list(map(int,input().split())) for _ in range(N)] def measure(originX,originY): origin = [originX,originY] XY.sort(key=lambda x: abs(x[0]-origin[0])+abs(x[1]-origin[1])) return abs(XY[-1][0]-origin[0])+abs(XY[-1][1]-orig...
""" 四隅に仮想の原点をつくり、各座標からその原点へのマンハッタン距離を計測する。 """ N = int(eval(input())) XY = [list(map(int,input().split())) for _ in range(N)] def measure(originX,originY): origin = [originX,originY] XY.sort(key=lambda x: abs(x[0]-origin[0])+abs(x[1]-origin[1])) return abs(XY[-1][0]-origin[0])+abs(XY[-1][1]-orig...
18
16
525
455
""" 四隅に仮想の原点をつくり、各座標からその原点へのマンハッタン距離を計測する。 """ N = int(eval(input())) XY = [list(map(int, input().split())) for _ in range(N)] def measure(originX, originY): origin = [originX, originY] XY.sort(key=lambda x: abs(x[0] - origin[0]) + abs(x[1] - origin[1])) return ( abs(XY[-1][0] - origin[0]) ...
""" 四隅に仮想の原点をつくり、各座標からその原点へのマンハッタン距離を計測する。 """ N = int(eval(input())) XY = [list(map(int, input().split())) for _ in range(N)] def measure(originX, originY): origin = [originX, originY] XY.sort(key=lambda x: abs(x[0] - origin[0]) + abs(x[1] - origin[1])) return ( abs(XY[-1][0] - origin[0]) ...
false
11.111111
[ "-ans = max(ans, measure(10**9, 1))", "-ans = max(ans, measure(10**9, 10**9))" ]
false
0.201266
0.087173
2.308812
[ "s059964889", "s880672422" ]
u803848678
p03253
python
s797530634
s683460758
758
23
63,604
3,316
Accepted
Accepted
96.97
mod = 10**9 + 7 def factorize(n): # http://nihaoshijie.hatenadiary.jp/entry/2018/02/03/115759 fct = [] b, e = 2, 0 while b * b <= n: while n % b == 0: n = n // b e = e + 1 if e > 0: fct.append(e) b, e = b + 1, 0 if n > 1: ...
from collections import Counter mod = 10**9 + 7 n, m = list(map(int, input().split())) def fact(m): c = Counter() s = 2 while s**2 <= m: if m % s: s += 1 continue while m % s == 0: c[s] += 1 m //= s if m > 1: c[m] +=...
48
30
1,372
609
mod = 10**9 + 7 def factorize(n): # http://nihaoshijie.hatenadiary.jp/entry/2018/02/03/115759 fct = [] b, e = 2, 0 while b * b <= n: while n % b == 0: n = n // b e = e + 1 if e > 0: fct.append(e) b, e = b + 1, 0 if n > 1: fct.appe...
from collections import Counter mod = 10**9 + 7 n, m = list(map(int, input().split())) def fact(m): c = Counter() s = 2 while s**2 <= m: if m % s: s += 1 continue while m % s == 0: c[s] += 1 m //= s if m > 1: c[m] += 1 return...
false
37.5
[ "+from collections import Counter", "+", "+n, m = list(map(int, input().split()))", "-def factorize(n):", "- # http://nihaoshijie.hatenadiary.jp/entry/2018/02/03/115759", "- fct = []", "- b, e = 2, 0", "- while b * b <= n:", "- while n % b == 0:", "- n = n // b", "-...
false
3.228076
0.035525
90.867932
[ "s797530634", "s683460758" ]
u564589929
p03986
python
s194061378
s807716912
68
50
12,344
10,592
Accepted
Accepted
26.47
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return...
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return...
47
46
1,405
1,354
import sys sys.setrecursionlimit(10**9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())...
import sys sys.setrecursionlimit(10**9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())...
false
2.12766
[ "- R = deque(list(X))", "- # for _ in range(100):", "- while R:", "+ for now in X:", "- L.append(R.popleft())", "+ L.append(now)", "- pre = L.pop()", "- now = R.popleft()", "- if pre == \"S\" and now == \"T\":", "- pass", "- ...
false
0.039069
0.037234
1.049298
[ "s194061378", "s807716912" ]
u415905784
p03286
python
s571431421
s588127721
20
17
3,316
2,940
Accepted
Accepted
15
N = int(eval(input())) str2N = bin(abs(N))[2:] S = '' inc = 0 for i, s in enumerate(str2N[::-1]): S += str((int(s) + inc) % 2) if N > 0: if i % 2 == 0: inc = (int(s) + inc) // 2 else: inc = 1 if (int(s) + inc) else 0 else: if i % 2 == 0: inc = 1 if (int(s) + inc) else 0 ...
N = int(eval(input())) def n_ary_notation(N, n): if N == 0: return '0' else: s = '' while N: s = str(N % abs(n)) + s N -= N % abs(n) N //= n return s print((n_ary_notation(N, -2)))
28
12
566
221
N = int(eval(input())) str2N = bin(abs(N))[2:] S = "" inc = 0 for i, s in enumerate(str2N[::-1]): S += str((int(s) + inc) % 2) if N > 0: if i % 2 == 0: inc = (int(s) + inc) // 2 else: inc = 1 if (int(s) + inc) else 0 else: if i % 2 == 0: inc = 1 if...
N = int(eval(input())) def n_ary_notation(N, n): if N == 0: return "0" else: s = "" while N: s = str(N % abs(n)) + s N -= N % abs(n) N //= n return s print((n_ary_notation(N, -2)))
false
57.142857
[ "-str2N = bin(abs(N))[2:]", "-S = \"\"", "-inc = 0", "-for i, s in enumerate(str2N[::-1]):", "- S += str((int(s) + inc) % 2)", "- if N > 0:", "- if i % 2 == 0:", "- inc = (int(s) + inc) // 2", "- else:", "- inc = 1 if (int(s) + inc) else 0", "+", "+", ...
false
0.051576
0.070365
0.732969
[ "s571431421", "s588127721" ]
u380524497
p03426
python
s958469562
s193739555
996
341
20,724
9,528
Accepted
Accepted
65.76
h, w, d = list(map(int, input().split())) A = [] for _ in range(h): line = list(map(int, input().split())) A.append(line) num_to_xy = [[0, 0] for i in range(h*w + 1)] for y in range(h): for x in range(w): num = A[y][x] num_to_xy[num] = [x, y] costs = [0] * (h*w+1) for st...
import sys input = sys.stdin.readline h, w, d = list(map(int, input().split())) num_to_x = [0] * (h*w+1) num_to_y = [0] * (h*w+1) for y in range(h): line = list(map(int, input().split())) for x, num in enumerate(line): num_to_x[num] = x num_to_y[num] = y costs = [0] * (h*w+1) ...
32
32
674
710
h, w, d = list(map(int, input().split())) A = [] for _ in range(h): line = list(map(int, input().split())) A.append(line) num_to_xy = [[0, 0] for i in range(h * w + 1)] for y in range(h): for x in range(w): num = A[y][x] num_to_xy[num] = [x, y] costs = [0] * (h * w + 1) for start in range(1,...
import sys input = sys.stdin.readline h, w, d = list(map(int, input().split())) num_to_x = [0] * (h * w + 1) num_to_y = [0] * (h * w + 1) for y in range(h): line = list(map(int, input().split())) for x, num in enumerate(line): num_to_x[num] = x num_to_y[num] = y costs = [0] * (h * w + 1) for st...
false
0
[ "+import sys", "+", "+input = sys.stdin.readline", "-A = []", "-for _ in range(h):", "+num_to_x = [0] * (h * w + 1)", "+num_to_y = [0] * (h * w + 1)", "+for y in range(h):", "- A.append(line)", "-num_to_xy = [[0, 0] for i in range(h * w + 1)]", "-for y in range(h):", "- for x in range(w)...
false
0.045994
0.042608
1.079462
[ "s958469562", "s193739555" ]
u694665829
p02555
python
s001276786
s613850294
119
28
9,224
9,240
Accepted
Accepted
76.47
n = int(eval(input())) mod = 10**9 + 7 import math def cnt(n, i): if i == 1: return 1 else: l = n - 3*i m = i-1 return math.factorial(l + m)//(math.factorial(l)*math.factorial(m)) if n == 2 or n == 1: print((0)) exit() if n == 3: print((1)...
s = int(eval(input())) a = [0]*2001 a[3] = 1 for i in range(4,s+1): a[i] = a[i-3] + a[i-1] mod = 10**9+7 print((a[s]%mod))
29
7
517
124
n = int(eval(input())) mod = 10**9 + 7 import math def cnt(n, i): if i == 1: return 1 else: l = n - 3 * i m = i - 1 return math.factorial(l + m) // (math.factorial(l) * math.factorial(m)) if n == 2 or n == 1: print((0)) exit() if n == 3: print((1)) exit() else...
s = int(eval(input())) a = [0] * 2001 a[3] = 1 for i in range(4, s + 1): a[i] = a[i - 3] + a[i - 1] mod = 10**9 + 7 print((a[s] % mod))
false
75.862069
[ "-n = int(eval(input()))", "+s = int(eval(input()))", "+a = [0] * 2001", "+a[3] = 1", "+for i in range(4, s + 1):", "+ a[i] = a[i - 3] + a[i - 1]", "-import math", "-", "-", "-def cnt(n, i):", "- if i == 1:", "- return 1", "- else:", "- l = n - 3 * i", "- m ...
false
0.007129
0.035886
0.198672
[ "s001276786", "s613850294" ]
u391589398
p03478
python
s063407628
s512511615
34
29
3,060
3,060
Accepted
Accepted
14.71
n, a, b = list(map(int, input().split())) ans = 0 for i in range(1, n+1): si = list(str(i)) s = sum(map(int, si)) if a <= s <= b: ans += i print(ans)
n, a, b = list(map(int, input().split())) ans = 0 for i in range(1, n+1): s = 0 i_ = i while i_ > 0: s += i_%10 i_ //= 10 if a <= s <= b: ans += i print(ans)
9
11
173
201
n, a, b = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): si = list(str(i)) s = sum(map(int, si)) if a <= s <= b: ans += i print(ans)
n, a, b = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): s = 0 i_ = i while i_ > 0: s += i_ % 10 i_ //= 10 if a <= s <= b: ans += i print(ans)
false
18.181818
[ "- si = list(str(i))", "- s = sum(map(int, si))", "+ s = 0", "+ i_ = i", "+ while i_ > 0:", "+ s += i_ % 10", "+ i_ //= 10" ]
false
0.084743
0.047377
1.788696
[ "s063407628", "s512511615" ]
u620084012
p04011
python
s395638813
s854675523
171
17
38,384
2,940
Accepted
Accepted
90.06
N = int(eval(input())) K = int(eval(input())) X = int(eval(input())) Y = int(eval(input())) if N <= K: print((N*X)) else: print((K*X + (N-K)*Y))
N = int(eval(input())) K = int(eval(input())) X = int(eval(input())) Y = int(eval(input())) if N <= K: print((N*X)) else: print((K*X+Y*(N-K)))
9
9
134
132
N = int(eval(input())) K = int(eval(input())) X = int(eval(input())) Y = int(eval(input())) if N <= K: print((N * X)) else: print((K * X + (N - K) * Y))
N = int(eval(input())) K = int(eval(input())) X = int(eval(input())) Y = int(eval(input())) if N <= K: print((N * X)) else: print((K * X + Y * (N - K)))
false
0
[ "- print((K * X + (N - K) * Y))", "+ print((K * X + Y * (N - K)))" ]
false
0.042783
0.101412
0.421868
[ "s395638813", "s854675523" ]
u553987207
p02689
python
s294221698
s627578437
377
302
45,356
45,276
Accepted
Accepted
19.89
import sys N, M = list(map(int, input().split())) H = list(map(int, input().split())) G = [set() for _ in range(N)] for _ in range(M): A, B = list(map(int, sys.stdin.readline().split())) A -= 1 B -= 1 G[A].add(B) G[B].add(A) ans = 0 for p in range(N): if not G[p]: ans += 1...
import sys N, M = list(map(int, input().split())) H = tuple(map(int, input().split())) G = [set() for _ in range(N)] for _ in range(M): a, b = list(map(int, sys.stdin.readline().split())) G[a-1].add(b-1) G[b-1].add(a-1) ans = 0 for i in range(N): h = H[i] for j in G[i]: if h <=...
22
18
434
374
import sys N, M = list(map(int, input().split())) H = list(map(int, input().split())) G = [set() for _ in range(N)] for _ in range(M): A, B = list(map(int, sys.stdin.readline().split())) A -= 1 B -= 1 G[A].add(B) G[B].add(A) ans = 0 for p in range(N): if not G[p]: ans += 1 conti...
import sys N, M = list(map(int, input().split())) H = tuple(map(int, input().split())) G = [set() for _ in range(N)] for _ in range(M): a, b = list(map(int, sys.stdin.readline().split())) G[a - 1].add(b - 1) G[b - 1].add(a - 1) ans = 0 for i in range(N): h = H[i] for j in G[i]: if h <= H[j]...
false
18.181818
[ "-H = list(map(int, input().split()))", "+H = tuple(map(int, input().split()))", "- A, B = list(map(int, sys.stdin.readline().split()))", "- A -= 1", "- B -= 1", "- G[A].add(B)", "- G[B].add(A)", "+ a, b = list(map(int, sys.stdin.readline().split()))", "+ G[a - 1].add(b - 1)", ...
false
0.09474
0.076898
1.232022
[ "s294221698", "s627578437" ]
u021548497
p02647
python
s822574758
s275098806
1,952
988
171,788
164,160
Accepted
Accepted
49.39
import sys def main(): input = sys.stdin.readline n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] key = 50 nn = n while nn > 0: key += 1 nn //= 2 for _ in range(min([key, k])): b = [0]*n for i in range(n): ...
import sys def main(): input = sys.stdin.readline n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] key = 30 nn = n while nn > 0: key += 1 nn //= 2 for _ in range(min([key, k])): b = [0]*n for i in range(n): ...
28
29
634
636
import sys def main(): input = sys.stdin.readline n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] key = 50 nn = n while nn > 0: key += 1 nn //= 2 for _ in range(min([key, k])): b = [0] * n for i in range(n): l, r = ma...
import sys def main(): input = sys.stdin.readline n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] key = 30 nn = n while nn > 0: key += 1 nn //= 2 for _ in range(min([key, k])): b = [0] * n for i in range(n): l, r = ma...
false
3.448276
[ "- key = 50", "+ key = 30" ]
false
0.07823
0.100057
0.781853
[ "s822574758", "s275098806" ]
u572193732
p02691
python
s663827734
s109863157
180
158
40,264
40,532
Accepted
Accepted
12.22
N = int(eval(input())) A = list(map(int, input().split())) X = dict() ans = 0 for i in range(N): L = i + A[i] if L not in X: X[L] = 1 else: X[L] += 1 for i in range(N): R = i - A[i] if R in X: ans += X[R] print(ans)
N = int(eval(input())) A = list(map(int, input().split())) X = dict() ans = 0 for i in range(N): L = i + A[i] R = i - A[i] if L not in X: X[L] = 1 else: X[L] += 1 if R in X: ans += X[R] print(ans)
18
16
281
259
N = int(eval(input())) A = list(map(int, input().split())) X = dict() ans = 0 for i in range(N): L = i + A[i] if L not in X: X[L] = 1 else: X[L] += 1 for i in range(N): R = i - A[i] if R in X: ans += X[R] print(ans)
N = int(eval(input())) A = list(map(int, input().split())) X = dict() ans = 0 for i in range(N): L = i + A[i] R = i - A[i] if L not in X: X[L] = 1 else: X[L] += 1 if R in X: ans += X[R] print(ans)
false
11.111111
[ "+ R = i - A[i]", "-for i in range(N):", "- R = i - A[i]" ]
false
0.047371
0.042293
1.120051
[ "s663827734", "s109863157" ]
u128859393
p03339
python
s884516984
s489615038
137
114
5,792
5,964
Accepted
Accepted
16.79
N = int(eval(input())) S = list(eval(input())) numE = S.count('E') numTurn = numE numW = 0 for i in range(N): if S[i] == 'E': numE -= 1 else: numW += 1 if numTurn > numE + numW: numTurn = numE + numW print(numTurn)
N = int(eval(input())) S = list(eval(input())) numE = S.count('E') numTurn = numE numW = 0 for dir in S: if dir == 'E': numE -= 1 else: numW += 1 if numTurn > numE + numW: numTurn = numE + numW print(numTurn)
16
16
257
251
N = int(eval(input())) S = list(eval(input())) numE = S.count("E") numTurn = numE numW = 0 for i in range(N): if S[i] == "E": numE -= 1 else: numW += 1 if numTurn > numE + numW: numTurn = numE + numW print(numTurn)
N = int(eval(input())) S = list(eval(input())) numE = S.count("E") numTurn = numE numW = 0 for dir in S: if dir == "E": numE -= 1 else: numW += 1 if numTurn > numE + numW: numTurn = numE + numW print(numTurn)
false
0
[ "-for i in range(N):", "- if S[i] == \"E\":", "+for dir in S:", "+ if dir == \"E\":" ]
false
0.050089
0.045236
1.107273
[ "s884516984", "s489615038" ]
u373047809
p02796
python
s747554876
s232858584
188
171
25,868
31,460
Accepted
Accepted
9.04
#!/usr/bin/env python3 INF = float("inf") n, *d = list(map(int, open(0).read().split())) p = sorted(zip(*[iter(d)]*2), key=sum) M, a = -INF, 0 for X, L in p: l, r = X-L, X+L if M <= l: a += 1 M = r print(a)
M,a =-float("inf"),0 for X,L in sorted(zip(*[iter(map(int,open(0).read().split()[1:]))]*2),key=sum): l,r=X-L,X+L if M<=l:a+=1;M=r print(a)
11
5
234
144
#!/usr/bin/env python3 INF = float("inf") n, *d = list(map(int, open(0).read().split())) p = sorted(zip(*[iter(d)] * 2), key=sum) M, a = -INF, 0 for X, L in p: l, r = X - L, X + L if M <= l: a += 1 M = r print(a)
M, a = -float("inf"), 0 for X, L in sorted(zip(*[iter(map(int, open(0).read().split()[1:]))] * 2), key=sum): l, r = X - L, X + L if M <= l: a += 1 M = r print(a)
false
54.545455
[ "-#!/usr/bin/env python3", "-INF = float(\"inf\")", "-n, *d = list(map(int, open(0).read().split()))", "-p = sorted(zip(*[iter(d)] * 2), key=sum)", "-M, a = -INF, 0", "-for X, L in p:", "+M, a = -float(\"inf\"), 0", "+for X, L in sorted(zip(*[iter(map(int, open(0).read().split()[1:]))] * 2), key=sum):...
false
0.104298
0.066276
1.573691
[ "s747554876", "s232858584" ]
u747602774
p02773
python
s322592587
s500779656
757
688
47,636
45,036
Accepted
Accepted
9.11
from collections import Counter N = int(eval(input())) S = [eval(input()) for i in range(N)] Sc = Counter(S) Sc1 = Sc.most_common() #print(Sc1) m = Sc1[0][1] ans = [] for s in Sc1: if s[1] == m: ans.append(s[0]) ans.sort() for a in ans: print(a)
from collections import Counter N = int(eval(input())) S = [eval(input()) for i in range(N)] Sc = Counter(S).most_common() m = Sc[0][1] ans = [] for s in Sc: if s[1] == m: ans.append(s[0]) else: break ans.sort() for a in ans: print(a)
15
16
265
268
from collections import Counter N = int(eval(input())) S = [eval(input()) for i in range(N)] Sc = Counter(S) Sc1 = Sc.most_common() # print(Sc1) m = Sc1[0][1] ans = [] for s in Sc1: if s[1] == m: ans.append(s[0]) ans.sort() for a in ans: print(a)
from collections import Counter N = int(eval(input())) S = [eval(input()) for i in range(N)] Sc = Counter(S).most_common() m = Sc[0][1] ans = [] for s in Sc: if s[1] == m: ans.append(s[0]) else: break ans.sort() for a in ans: print(a)
false
6.25
[ "-Sc = Counter(S)", "-Sc1 = Sc.most_common()", "-# print(Sc1)", "-m = Sc1[0][1]", "+Sc = Counter(S).most_common()", "+m = Sc[0][1]", "-for s in Sc1:", "+for s in Sc:", "+ else:", "+ break" ]
false
0.044026
0.036353
1.211073
[ "s322592587", "s500779656" ]
u771634798
p03644
python
s628550232
s685171686
29
26
9,064
9,144
Accepted
Accepted
10.34
pow2 = [2 ** i for i in range(0, 7)] n = int(eval(input())) res = max([i for i in pow2 if i <= n]) print(res)
n = int(eval(input())) ans = 1 while ans * 2 <= n: ans *= 2 print(ans)
4
5
107
73
pow2 = [2**i for i in range(0, 7)] n = int(eval(input())) res = max([i for i in pow2 if i <= n]) print(res)
n = int(eval(input())) ans = 1 while ans * 2 <= n: ans *= 2 print(ans)
false
20
[ "-pow2 = [2**i for i in range(0, 7)]", "-res = max([i for i in pow2 if i <= n])", "-print(res)", "+ans = 1", "+while ans * 2 <= n:", "+ ans *= 2", "+print(ans)" ]
false
0.049057
0.048075
1.020427
[ "s628550232", "s685171686" ]
u441175813
p03014
python
s663867376
s358729542
1,523
1,180
249,920
136,712
Accepted
Accepted
22.52
L = [] H, W = list(map(int, input().split())) for i in range(H): S = list(eval(input())) L.append(S) ans1 = [[0 for i in range(W)] for j in range(H)] ans2 = [[0 for i in range(W)] for j in range(H)] for i in range(H): val = 0 l = [] for j in range(W): if L[i][j] == "#": for k in l: ans1...
H, W = list(map(int, input().split())) S = [[0]*W for _ in range(H)] for i in range(H): Si = list(eval(input())) for j in range(W): if Si[j] == '#': S[i][j] = 1 # row S_row = [[0]*W for _ in range(H)] for i in range(H): c = 0 for j in range(W): if S[i][j] == 1...
49
42
763
982
L = [] H, W = list(map(int, input().split())) for i in range(H): S = list(eval(input())) L.append(S) ans1 = [[0 for i in range(W)] for j in range(H)] ans2 = [[0 for i in range(W)] for j in range(H)] for i in range(H): val = 0 l = [] for j in range(W): if L[i][j] == "#": for k in ...
H, W = list(map(int, input().split())) S = [[0] * W for _ in range(H)] for i in range(H): Si = list(eval(input())) for j in range(W): if Si[j] == "#": S[i][j] = 1 # row S_row = [[0] * W for _ in range(H)] for i in range(H): c = 0 for j in range(W): if S[i][j] == 1: ...
false
14.285714
[ "-L = []", "+S = [[0] * W for _ in range(H)]", "- S = list(eval(input()))", "- L.append(S)", "-ans1 = [[0 for i in range(W)] for j in range(H)]", "-ans2 = [[0 for i in range(W)] for j in range(H)]", "+ Si = list(eval(input()))", "+ for j in range(W):", "+ if Si[j] == \"#\":", "+...
false
0.111659
0.111932
0.997556
[ "s663867376", "s358729542" ]