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
u945181840
p03038
python
s932148382
s959519163
416
304
24,620
27,292
Accepted
Accepted
26.92
from heapq import heapify, heappush, heappop import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() B = [0] * M C = [0] * M for i in range(M): B[i], C[i] = list(map(int, input().split())) cb = sorted(zip(C, B), reverse=True) cnt = 0 ...
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = list(map(int, input().split())) B = [0] * M C = [0] * M for i in range(M): B[i], C[i] = list(map(int, input().split())) cb = sorted(zip(C, B), reverse=True) exchange = [] for c, b in cb: exchange.extend([c] * b) ...
28
22
546
413
from heapq import heapify, heappush, heappop import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() B = [0] * M C = [0] * M for i in range(M): B[i], C[i] = list(map(int, input().split())) cb = sorted(zip(C, B), reverse=True) cnt = 0 exchange = [] f...
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = list(map(int, input().split())) B = [0] * M C = [0] * M for i in range(M): B[i], C[i] = list(map(int, input().split())) cb = sorted(zip(C, B), reverse=True) exchange = [] for c, b in cb: exchange.extend([c] * b) if len(exchang...
false
21.428571
[ "-from heapq import heapify, heappush, heappop", "-A.sort()", "-cnt = 0", "- cnt += b", "- if cnt >= N:", "+ if len(exchange) >= N:", "-exchange.sort()", "-for _ in range(len(exchange)):", "- m = heappop(A)", "- heappush(A, max(m, exchange.pop()))", "-print((sum(A)))", "+A.exten...
false
0.036429
0.040812
0.892603
[ "s932148382", "s959519163" ]
u785578220
p03994
python
s570978170
s687122880
89
60
4,156
4,788
Accepted
Accepted
32.58
s = list(eval(input())) k = int(eval(input())) abc = "abcdefghijklmnopqrstuvwxyz" c = 0 for e,i in enumerate(s): # print(26-abc.index(i)) if k-26+abc.index(i)>=0 and i!='a': s[e] = 'a' k-=26-abc.index(i) # print(k) k+=abc.index(s[-1]) k%=26 s[-1] = abc[k] print(("".join(s)))
s=list(eval(input())) k=int(eval(input())) for e,i in enumerate(s): c=(123-ord(i))%26 if k>=c: s[e]="a" k-=c else:s[e]=i l = chr((ord(s[-1])-97+k)%26+97) print(("".join(s[:-1])+l))
15
10
306
204
s = list(eval(input())) k = int(eval(input())) abc = "abcdefghijklmnopqrstuvwxyz" c = 0 for e, i in enumerate(s): # print(26-abc.index(i)) if k - 26 + abc.index(i) >= 0 and i != "a": s[e] = "a" k -= 26 - abc.index(i) # print(k) k += abc.index(s[-1]) k %= 26 s[-1] = abc[k] print(("".join(s)))...
s = list(eval(input())) k = int(eval(input())) for e, i in enumerate(s): c = (123 - ord(i)) % 26 if k >= c: s[e] = "a" k -= c else: s[e] = i l = chr((ord(s[-1]) - 97 + k) % 26 + 97) print(("".join(s[:-1]) + l))
false
33.333333
[ "-abc = \"abcdefghijklmnopqrstuvwxyz\"", "-c = 0", "- # print(26-abc.index(i))", "- if k - 26 + abc.index(i) >= 0 and i != \"a\":", "+ c = (123 - ord(i)) % 26", "+ if k >= c:", "- k -= 26 - abc.index(i)", "- # print(k)", "-k += abc.index(s[-1])", "-k %= 26", "-s[-1] = abc[k...
false
0.044347
0.044701
0.992089
[ "s570978170", "s687122880" ]
u440566786
p02960
python
s501902527
s315550295
632
570
43,244
44,968
Accepted
Accepted
9.81
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): M=13 S=input()[::-1] n=len(S) dp=[0]*M dp[0]=1 for i in range(n): ndp=[0]*M s=S[i] d=pow(10,i,M) # d=10^i mod 13 if(...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): M=13 S=eval(input()) n=len(S) dp=[0]*M dp[0]=1 for i in range(n): ndp=[0]*M s=S[i] if(s=='?'): for j in range(10...
27
26
634
592
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): M = 13 S = input()[::-1] n = len(S) dp = [0] * M dp[0] = 1 for i in range(n): ndp = [0] * M s = S[i] d = pow(10, i, M) # d=10^i...
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): M = 13 S = eval(input()) n = len(S) dp = [0] * M dp[0] = 1 for i in range(n): ndp = [0] * M s = S[i] if s == "?": fo...
false
3.703704
[ "- S = input()[::-1]", "+ S = eval(input())", "- d = pow(10, i, M) # d=10^i mod 13", "- ndp[(m + j * d) % M] += dp[m]", "- ndp[(m + j * d) % M] %= MOD", "+ ndp[(m * 10 + j) % M] += dp[m]", "+ ndp[(m * 10 + j) % M] ...
false
0.047069
0.03997
1.177605
[ "s501902527", "s315550295" ]
u222668979
p03330
python
s134334355
s790385059
423
279
11,944
77,364
Accepted
Accepted
34.04
from collections import defaultdict from itertools import permutations n, c = list(map(int, input().split())) d = [list(map(int, input().split())) for _ in range(c)] cmat = [list(map(int, input().split())) for _ in range(n)] dcnt = [defaultdict(int) for _ in range(3)] for i, ci in enumerate(cmat, 1): for...
from collections import defaultdict from itertools import permutations n, c = list(map(int, input().split())) d = [list(map(int, input().split())) for _ in range(c)] cmat = [list(map(int, input().split())) for _ in range(n)] dcnt = [defaultdict(int) for _ in range(3)] for i, ci in enumerate(cmat): for j,...
21
20
651
597
from collections import defaultdict from itertools import permutations n, c = list(map(int, input().split())) d = [list(map(int, input().split())) for _ in range(c)] cmat = [list(map(int, input().split())) for _ in range(n)] dcnt = [defaultdict(int) for _ in range(3)] for i, ci in enumerate(cmat, 1): for j, cij in...
from collections import defaultdict from itertools import permutations n, c = list(map(int, input().split())) d = [list(map(int, input().split())) for _ in range(c)] cmat = [list(map(int, input().split())) for _ in range(n)] dcnt = [defaultdict(int) for _ in range(3)] for i, ci in enumerate(cmat): for j, cij in en...
false
4.761905
[ "-for i, ci in enumerate(cmat, 1):", "- for j, cij in enumerate(ci, 1):", "+for i, ci in enumerate(cmat):", "+ for j, cij in enumerate(ci):", "- if len(set(color)) == 3:", "- tmp = 0", "- for i, cnt in enumerate(dcnt):", "- tmp += sum(d[k][color[i]] * cnt[k] for k in ...
false
0.036687
0.054409
0.674287
[ "s134334355", "s790385059" ]
u997521090
p03426
python
s121771573
s614449370
509
468
23,588
17,168
Accepted
Accepted
8.06
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) H, W, D = list(map(int, input().split())) m = [0] * (H * W + 1) for i in range(H): A = list(map(int, input().split())) for j in range(W): m[A[j]] = (i, j) ...
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) H, W, D = list(map(int, input().split())) m = [0] * (H * W + 1) for i in range(H): A = list(map(int, input().split())) for j in range(W): m[A[j]] = (i, j) ...
31
29
663
592
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) H, W, D = list(map(int, input().split())) m = [0] * (H * W + 1) for i in range(H): A = list(map(int, input().split())) for j in range(W): m[A[j]] = (i, j) DP = [[0] for i in ...
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) H, W, D = list(map(int, input().split())) m = [0] * (H * W + 1) for i in range(H): A = list(map(int, input().split())) for j in range(W): m[A[j]] = (i, j) DP = [0] * D for i ...
false
6.451613
[ "-DP = [[0] for i in range(D)]", "+DP = [0] * D", "- ls = DP[i % D]", "- ls.append(ls[-1] + dist)", "+ DP.append(DP[i - D] + dist)", "- ls = DP[(R - 1) % D]", "- print(ls[(R - 1) / D] - ls[(L - 1) / D])", "+ print(DP[R - 1] - DP[L - 1])" ]
false
0.046508
0.114851
0.40494
[ "s121771573", "s614449370" ]
u368796742
p04048
python
s052772062
s073001618
34
26
9,108
9,172
Accepted
Accepted
23.53
n,x = list(map(int,input().split())) ans = n e = n-x count = 0 while True: if x%e == 0: ans += x//e*(e*2)-e break else: ans += (x//e)*e*2 x,e = e,x%e count += 1 print(ans)
n,x = list(map(int,input().split())) ans = n e = n-x while e > 0: if x%e == 0: ans += x//e*(e*2)-e else: ans += (x//e)*e*2 x,e = e,x%e print(ans)
16
10
235
184
n, x = list(map(int, input().split())) ans = n e = n - x count = 0 while True: if x % e == 0: ans += x // e * (e * 2) - e break else: ans += (x // e) * e * 2 x, e = e, x % e count += 1 print(ans)
n, x = list(map(int, input().split())) ans = n e = n - x while e > 0: if x % e == 0: ans += x // e * (e * 2) - e else: ans += (x // e) * e * 2 x, e = e, x % e print(ans)
false
37.5
[ "-count = 0", "-while True:", "+while e > 0:", "- break", "- count += 1" ]
false
0.104646
0.124057
0.843534
[ "s052772062", "s073001618" ]
u572561929
p03274
python
s336089427
s258663434
140
83
16,544
14,384
Accepted
Accepted
40.71
n, k = list(map(int, input().split())) x = list(map(int, input().split())) d = [0 for _ in range(n)] S = [0 for _ in range(n)] for i in range(1, n): d[i] = x[i] - x[i - 1] S[i] = S[i - 1] + d[i] tmp = [0 for _ in range(n - k + 1)] for i in range(n - k + 1): tmp[i] = S[i + k - 1] - S[i] + min(abs(x[...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) ans = abs(x[-1] - x[0]) * 2 for i in range(n - k + 1): l = x[i] r = x[i + k - 1] if r < 0: ans = min(ans, -l) elif l > 0: ans = min(ans, r) else: ans = min(ans, r - l + min(-l, r)) print(an...
11
13
355
317
n, k = list(map(int, input().split())) x = list(map(int, input().split())) d = [0 for _ in range(n)] S = [0 for _ in range(n)] for i in range(1, n): d[i] = x[i] - x[i - 1] S[i] = S[i - 1] + d[i] tmp = [0 for _ in range(n - k + 1)] for i in range(n - k + 1): tmp[i] = S[i + k - 1] - S[i] + min(abs(x[i]), abs(...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) ans = abs(x[-1] - x[0]) * 2 for i in range(n - k + 1): l = x[i] r = x[i + k - 1] if r < 0: ans = min(ans, -l) elif l > 0: ans = min(ans, r) else: ans = min(ans, r - l + min(-l, r)) print(ans)
false
15.384615
[ "-d = [0 for _ in range(n)]", "-S = [0 for _ in range(n)]", "-for i in range(1, n):", "- d[i] = x[i] - x[i - 1]", "- S[i] = S[i - 1] + d[i]", "-tmp = [0 for _ in range(n - k + 1)]", "+ans = abs(x[-1] - x[0]) * 2", "- tmp[i] = S[i + k - 1] - S[i] + min(abs(x[i]), abs(x[i + k - 1]))", "-print...
false
0.037137
0.03409
1.089394
[ "s336089427", "s258663434" ]
u939118618
p01140
python
s193228819
s491145496
6,830
5,840
54,284
54,372
Accepted
Accepted
14.49
from collections import defaultdict as ddict def cal_interval(Num): interval = ddict(int) dp = [int(input()) for i in range(Num)] for i in range(Num): tmp = dp[i] interval[tmp] += 1 for j in range(i): dp[j] += tmp interval[dp[j]] += 1 return interval while 1: N, M = list(map(int,input().spl...
from collections import defaultdict as ddict def cal_interval(Num): interval = ddict(int) dp = [int(input()) for i in range(Num)] for i in range(Num): tmp = dp[i] interval[tmp] += 1 for j in range(i): tmp += dp[i-j-1] interval[tmp] += 1 return interval while 1: N, M = list(map(int,input().s...
18
18
464
466
from collections import defaultdict as ddict def cal_interval(Num): interval = ddict(int) dp = [int(input()) for i in range(Num)] for i in range(Num): tmp = dp[i] interval[tmp] += 1 for j in range(i): dp[j] += tmp interval[dp[j]] += 1 return interval w...
from collections import defaultdict as ddict def cal_interval(Num): interval = ddict(int) dp = [int(input()) for i in range(Num)] for i in range(Num): tmp = dp[i] interval[tmp] += 1 for j in range(i): tmp += dp[i - j - 1] interval[tmp] += 1 return interv...
false
0
[ "- dp[j] += tmp", "- interval[dp[j]] += 1", "+ tmp += dp[i - j - 1]", "+ interval[tmp] += 1" ]
false
0.112168
0.049272
2.2765
[ "s193228819", "s491145496" ]
u711238850
p03845
python
s186810348
s443629327
20
18
3,060
3,060
Accepted
Accepted
10
n = int(eval(input())) t = tuple(map(int,input().split())) m = int(eval(input())) d = [] for _ in range(m): d.append(tuple(map(int,input().split()))) base = sum(t) for i,t_i in d: print((base-t[i-1]+t_i))
n = int(eval(input())) t = tuple(map(int,input().split())) m = int(eval(input())) d = [] for _ in range(m): d.append(tuple(map(int,input().split()))) for i,t_i in d: print((sum(t)-t[i-1]+t_i))
11
10
207
193
n = int(eval(input())) t = tuple(map(int, input().split())) m = int(eval(input())) d = [] for _ in range(m): d.append(tuple(map(int, input().split()))) base = sum(t) for i, t_i in d: print((base - t[i - 1] + t_i))
n = int(eval(input())) t = tuple(map(int, input().split())) m = int(eval(input())) d = [] for _ in range(m): d.append(tuple(map(int, input().split()))) for i, t_i in d: print((sum(t) - t[i - 1] + t_i))
false
9.090909
[ "-base = sum(t)", "- print((base - t[i - 1] + t_i))", "+ print((sum(t) - t[i - 1] + t_i))" ]
false
0.299187
0.048981
6.108271
[ "s186810348", "s443629327" ]
u477977638
p03986
python
s840528866
s203367296
178
40
41,180
9,116
Accepted
Accepted
77.53
#from collections import defaultdict def main(): ans=0 tmp=0 x=eval(input()) for i in x: if tmp==0 and i=="T": ans+=1 elif i=="T": tmp-=1 else: tmp+=1 print((ans*2)) if __name__ == '__main__': main()
import sys input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return input().rstrip().decode() def II(): return int(eval(input())) def FI(): return int(eval(input())) def MI(): return list(map(int,input().split())) def MF(): return list(map(float,input...
18
43
295
685
# from collections import defaultdict def main(): ans = 0 tmp = 0 x = eval(input()) for i in x: if tmp == 0 and i == "T": ans += 1 elif i == "T": tmp -= 1 else: tmp += 1 print((ans * 2)) if __name__ == "__main__": main()
import sys input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**9) # from functools import lru_cache def RD(): return input().rstrip().decode() def II(): return int(eval(input())) def FI(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MF(): return ...
false
58.139535
[ "-# from collections import defaultdict", "+import sys", "+", "+input = sys.stdin.buffer.readline", "+# sys.setrecursionlimit(10**9)", "+# from functools import lru_cache", "+def RD():", "+ return input().rstrip().decode()", "+", "+", "+def II():", "+ return int(eval(input()))", "+", ...
false
0.045526
0.04599
0.989924
[ "s840528866", "s203367296" ]
u465961647
p02594
python
s502994736
s202428645
30
27
9,148
9,136
Accepted
Accepted
10
a = int(eval(input())) if a >= 30: print("Yes") else: print("No")
N= [] N= int(eval(input(" "))) if N>=30: print("Yes") else: print("No")
5
7
71
81
a = int(eval(input())) if a >= 30: print("Yes") else: print("No")
N = [] N = int(eval(input(" "))) if N >= 30: print("Yes") else: print("No")
false
28.571429
[ "-a = int(eval(input()))", "-if a >= 30:", "+N = []", "+N = int(eval(input(\" \")))", "+if N >= 30:" ]
false
0.045197
0.045114
1.001855
[ "s502994736", "s202428645" ]
u653837719
p02838
python
s084651380
s670420422
1,413
674
123,184
122,936
Accepted
Accepted
52.3
def mod_pow(a, n): res = 1 while n > 0: if n & 1: res = res * a % mod a = a * a % mod n >>= 1 return res n = int(eval(input())) a = list(map(int, input().split())) mod = 10 ** 9 + 7 cnt = [0] * 60 for v in a: for i in range(60): if (v >> ...
n = int(eval(input())) a = list(map(int, input().split())) mod = 10 ** 9 + 7 res = 0 two_factor = 1 for i in range(60): cnt_1 = 0 cnt_0 = 0 for v in a: if (v >> i) & 1: cnt_1 += 1 else: cnt_0 += 1 res = (res + cnt_1 * cnt_0 % mod * two_factor % mo...
34
19
673
375
def mod_pow(a, n): res = 1 while n > 0: if n & 1: res = res * a % mod a = a * a % mod n >>= 1 return res n = int(eval(input())) a = list(map(int, input().split())) mod = 10**9 + 7 cnt = [0] * 60 for v in a: for i in range(60): if (v >> i) & 1: cn...
n = int(eval(input())) a = list(map(int, input().split())) mod = 10**9 + 7 res = 0 two_factor = 1 for i in range(60): cnt_1 = 0 cnt_0 = 0 for v in a: if (v >> i) & 1: cnt_1 += 1 else: cnt_0 += 1 res = (res + cnt_1 * cnt_0 % mod * two_factor % mod) % mod two_fa...
false
44.117647
[ "-def mod_pow(a, n):", "- res = 1", "- while n > 0:", "- if n & 1:", "- res = res * a % mod", "- a = a * a % mod", "- n >>= 1", "- return res", "-", "-", "-cnt = [0] * 60", "-for v in a:", "- for i in range(60):", "+res = 0", "+two_factor = 1",...
false
0.106159
0.098866
1.073762
[ "s084651380", "s670420422" ]
u861466636
p03160
python
s066079418
s856337472
196
178
13,928
13,928
Accepted
Accepted
9.18
# 押しだしながらDPする場合 N = int(eval(input())) h = list(map(int, input().split())) h.extend([0,0]) # 要らない足場 dp = [0] + [1e10]*(N+1) # 初期状態だけ定義(cost0) for i in range(N): dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1] - h[i])) dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2] - h[i])) print((dp[N-1]))
# 押しだしながらDPする場合 N = int(eval(input())) h = list(map(int, input().split())) h.extend([0,0]) # 要らない足場 dp = [float("inf")]*(N+2) dp[0] = 0 # 初期足場のコストは0 for i in range(N): dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1] - h[i])) dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2] - h[i])) print((dp[N-1]))
10
11
289
297
# 押しだしながらDPする場合 N = int(eval(input())) h = list(map(int, input().split())) h.extend([0, 0]) # 要らない足場 dp = [0] + [1e10] * (N + 1) # 初期状態だけ定義(cost0) for i in range(N): dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) print((dp[N - 1]))
# 押しだしながらDPする場合 N = int(eval(input())) h = list(map(int, input().split())) h.extend([0, 0]) # 要らない足場 dp = [float("inf")] * (N + 2) dp[0] = 0 # 初期足場のコストは0 for i in range(N): dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) print((dp[N - 1]))
false
9.090909
[ "-dp = [0] + [1e10] * (N + 1) # 初期状態だけ定義(cost0)", "+dp = [float(\"inf\")] * (N + 2)", "+dp[0] = 0 # 初期足場のコストは0" ]
false
0.036433
0.081753
0.445648
[ "s066079418", "s856337472" ]
u860002137
p02936
python
s575987226
s573255582
1,925
1,437
93,512
235,004
Accepted
Accepted
25.35
from collections import defaultdict import sys sys.setrecursionlimit(10**6) n, q = list(map(int, input().split())) graph = defaultdict(set) for i in range(n - 1): a, b = list(map(int, input().split())) graph[a].add(b) graph[b].add(a) arr = [0] * (n + 1) for i in range(q): p, x = lis...
from collections import defaultdict import sys sys.setrecursionlimit(10**7) def dfs(prev, u): if visited[u]: return else: cnt[u] += cnt[prev] visited[u] = True for nu in graph[u]: if visited[nu]: continue else: ...
39
37
725
677
from collections import defaultdict import sys sys.setrecursionlimit(10**6) n, q = list(map(int, input().split())) graph = defaultdict(set) for i in range(n - 1): a, b = list(map(int, input().split())) graph[a].add(b) graph[b].add(a) arr = [0] * (n + 1) for i in range(q): p, x = list(map(int, input().s...
from collections import defaultdict import sys sys.setrecursionlimit(10**7) def dfs(prev, u): if visited[u]: return else: cnt[u] += cnt[prev] visited[u] = True for nu in graph[u]: if visited[nu]: continue else: dfs(u, nu)...
false
5.128205
[ "-sys.setrecursionlimit(10**6)", "-n, q = list(map(int, input().split()))", "-graph = defaultdict(set)", "-for i in range(n - 1):", "- a, b = list(map(int, input().split()))", "- graph[a].add(b)", "- graph[b].add(a)", "-arr = [0] * (n + 1)", "-for i in range(q):", "- p, x = list(map(in...
false
0.046724
0.0363
1.287134
[ "s575987226", "s573255582" ]
u788068140
p02579
python
s936371260
s655693753
764
512
94,500
105,032
Accepted
Accepted
32.98
from collections import deque H, W = list(map(int, input().split())) C0, C1 = list(map(int, input().split())) D0, D1 = list(map(int, input().split())) LARGEST = 999999999 ARR = [] for i in range(H): ARR.append(eval(input())) def calculate(h, w, c0, c1, d0, d1, arr): c0 = c0 - 1 c1 = c1 -...
from collections import deque H, W = list(map(int, input().split())) C0, C1 = list(map(int, input().split())) D0, D1 = list(map(int, input().split())) LARGEST = 999999999 ARR = [] for i in range(H): ARR.append(eval(input())) def calculate(h, w, c0, c1, d0, d1, arr): c0 = c0 - 1 c1 = c1 -...
66
69
1,679
1,740
from collections import deque H, W = list(map(int, input().split())) C0, C1 = list(map(int, input().split())) D0, D1 = list(map(int, input().split())) LARGEST = 999999999 ARR = [] for i in range(H): ARR.append(eval(input())) def calculate(h, w, c0, c1, d0, d1, arr): c0 = c0 - 1 c1 = c1 - 1 d0 = d0 - ...
from collections import deque H, W = list(map(int, input().split())) C0, C1 = list(map(int, input().split())) D0, D1 = list(map(int, input().split())) LARGEST = 999999999 ARR = [] for i in range(H): ARR.append(eval(input())) def calculate(h, w, c0, c1, d0, d1, arr): c0 = c0 - 1 c1 = c1 - 1 d0 = d0 - ...
false
4.347826
[ "- status[c0][c1] = 0", "- q.append((c0, c1))", "+ q.append((c0, c1, 0))", "- hIndex, wIndex = q.popleft()", "+ hIndex, wIndex, index = q.popleft()", "+ if index > status[hIndex][wIndex]:", "+ continue", "- if status[sH][sW] > status[hIndex][wIndex]:...
false
0.042895
0.042874
1.0005
[ "s936371260", "s655693753" ]
u133936772
p02881
python
s914126984
s344808557
169
141
3,060
3,064
Accepted
Accepted
16.57
n = int(eval(input())) import math for i in range(math.floor(n**0.5),0,-1): if n % i == 0: print((i + n//i -2)) break
n = int(eval(input())) for i in range(int(n**0.5)+1,0,-1): if n % i == 0: print((i + n//i -2)) break
6
5
124
106
n = int(eval(input())) import math for i in range(math.floor(n**0.5), 0, -1): if n % i == 0: print((i + n // i - 2)) break
n = int(eval(input())) for i in range(int(n**0.5) + 1, 0, -1): if n % i == 0: print((i + n // i - 2)) break
false
16.666667
[ "-import math", "-", "-for i in range(math.floor(n**0.5), 0, -1):", "+for i in range(int(n**0.5) + 1, 0, -1):" ]
false
0.052637
0.242855
0.216742
[ "s914126984", "s344808557" ]
u375616706
p03805
python
s101633727
s432482125
34
20
3,188
3,064
Accepted
Accepted
41.18
from itertools import permutations N, M = list(map(int, input().split())) edges = [] for i in range(M): a, b = list(map(int, input().split())) edges.append([a-1, b-1]) mat = [[0]*N for _ in range(N)] for s, g in edges: mat[s][g] = 1 mat[g][s] = 1 P = permutations(list(range(N))) ans...
def bit_dp(N, Adj): dp = [[0]*N for i in range(1 << N)] #dp[{0},0] = 1 dp[1][0] = 1 for S in range(1 << N): for v in range(N): # v がSに含まれていないときはパス if (S & (1 << v)) == 0: continue #sub = S - {v} sub = S ^ (1 << v) ...
31
38
649
880
from itertools import permutations N, M = list(map(int, input().split())) edges = [] for i in range(M): a, b = list(map(int, input().split())) edges.append([a - 1, b - 1]) mat = [[0] * N for _ in range(N)] for s, g in edges: mat[s][g] = 1 mat[g][s] = 1 P = permutations(list(range(N))) ans = 0 for route...
def bit_dp(N, Adj): dp = [[0] * N for i in range(1 << N)] # dp[{0},0] = 1 dp[1][0] = 1 for S in range(1 << N): for v in range(N): # v がSに含まれていないときはパス if (S & (1 << v)) == 0: continue # sub = S - {v} sub = S ^ (1 << v) fo...
false
18.421053
[ "-from itertools import permutations", "+def bit_dp(N, Adj):", "+ dp = [[0] * N for i in range(1 << N)]", "+ # dp[{0},0] = 1", "+ dp[1][0] = 1", "+ for S in range(1 << N):", "+ for v in range(N):", "+ # v がSに含まれていないときはパス", "+ if (S & (1 << v)) == 0:", "+ ...
false
0.046218
0.038598
1.197409
[ "s101633727", "s432482125" ]
u970197315
p03352
python
s954629300
s079219337
21
17
3,316
3,064
Accepted
Accepted
19.05
# ABC097 B Exponential x = int(eval(input())) ans = 0 for i in range(1,33): for j in range(2,10): t = i**j if t <= x: ans = max(t,ans) print(ans)
x=int(eval(input())) exp=[0]*(x+1) exp[1]=1 ans=0 for i in range(2,x+1): t=i*i while t<=x: exp[t]=1 t*=i for i in range(1,x+1): if exp[i]: ans=max(i,ans) print(ans)
10
14
182
208
# ABC097 B Exponential x = int(eval(input())) ans = 0 for i in range(1, 33): for j in range(2, 10): t = i**j if t <= x: ans = max(t, ans) print(ans)
x = int(eval(input())) exp = [0] * (x + 1) exp[1] = 1 ans = 0 for i in range(2, x + 1): t = i * i while t <= x: exp[t] = 1 t *= i for i in range(1, x + 1): if exp[i]: ans = max(i, ans) print(ans)
false
28.571429
[ "-# ABC097 B Exponential", "+exp = [0] * (x + 1)", "+exp[1] = 1", "-for i in range(1, 33):", "- for j in range(2, 10):", "- t = i**j", "- if t <= x:", "- ans = max(t, ans)", "+for i in range(2, x + 1):", "+ t = i * i", "+ while t <= x:", "+ exp[t] = 1"...
false
0.044084
0.171736
0.256694
[ "s954629300", "s079219337" ]
u506858457
p02838
python
s720707382
s186125823
1,993
1,790
42,156
42,156
Accepted
Accepted
10.19
'''ika tako bit桁ごとに考える。「XORを取り、その後足し算」という計算過程では 他の桁が影響することはないので、桁毎に独立に考えて問題ない。 N = 5 A = { 1 2 3 4 5 } ↓ { 001 010 011 100 101 } たとえば2桁目を取り出すと 0 1 1 0 0 各ペアでXORを取ると、(0,1)は'1'となり、(0,0)(1,1)は'0'となる。 0はいくら足しても0なので、(0,1)の数だけわかれば良い。 それは、(0の個数)×(1の個数)で計算できる。 0が3個、1が2個 → XORを取っ...
'''ika tako bit桁ごとに考える。「XORを取り、その後足し算」という計算過程では 他の桁が影響することはないので、桁毎に独立に考えて問題ない。 N = 5 A = { 1 2 3 4 5 } ↓ { 001 010 011 100 101 } たとえば2桁目を取り出すと 0 1 1 0 0 各ペアでXORを取ると、(0,1)は'1'となり、(0,0)(1,1)は'0'となる。 0はいくら足しても0なので、(0,1)の数だけわかれば良い。 それは、(0の個数)×(1の個数)で計算できる。 0が3個、1が2個 → XORを取っ...
54
54
1,337
1,347
"""ika tako bit桁ごとに考える。「XORを取り、その後足し算」という計算過程では 他の桁が影響することはないので、桁毎に独立に考えて問題ない。 N = 5 A = { 1 2 3 4 5 } ↓ { 001 010 011 100 101 } たとえば2桁目を取り出すと 0 1 1 0 0 各ペアでXORを取ると、(0,1)は'1'となり、(0,0)(1,1)は'0'となる。 0はいくら足しても0なので、(0,1)の数だけわかれば良い。 それは、(0の個数)×(1の個数)で計算できる。 0が3個、1が2個 → XORを取ったとき、2桁目について'...
"""ika tako bit桁ごとに考える。「XORを取り、その後足し算」という計算過程では 他の桁が影響することはないので、桁毎に独立に考えて問題ない。 N = 5 A = { 1 2 3 4 5 } ↓ { 001 010 011 100 101 } たとえば2桁目を取り出すと 0 1 1 0 0 各ペアでXORを取ると、(0,1)は'1'となり、(0,0)(1,1)は'0'となる。 0はいくら足しても0なので、(0,1)の数だけわかれば良い。 それは、(0の個数)×(1の個数)で計算できる。 0が3個、1が2個 → XORを取ったとき、2桁目について'...
false
0
[ "-for _ in range(60): # 上限は2^60なので、60が上限", "+for i in range(60): # 上限は2^60なので、60が上限", "- bit //= m", "- # bit >>= m これはダメだった。なぜ、だろう?", "+ # bit //= m こっちが原文、下の行は、下のプルグラムに合わせたみた", "+ bit >>= i" ]
false
0.035985
0.037165
0.968246
[ "s720707382", "s186125823" ]
u011621222
p00001
python
s586924443
s747064922
30
20
7,568
5,592
Accepted
Accepted
33.33
a = [] for i in range(10): a.append(int(eval(input()))) a.sort() print(("\n".join(list(map(str,a[9:6:-1])))))
a = [] while True: try: n = int(eval(input())) a.append(n) except: break print((max(a))) a.remove(max(a)) print((max(a))) a.remove(max(a)) print((max(a)))
5
15
109
192
a = [] for i in range(10): a.append(int(eval(input()))) a.sort() print(("\n".join(list(map(str, a[9:6:-1])))))
a = [] while True: try: n = int(eval(input())) a.append(n) except: break print((max(a))) a.remove(max(a)) print((max(a))) a.remove(max(a)) print((max(a)))
false
66.666667
[ "-for i in range(10):", "- a.append(int(eval(input())))", "-a.sort()", "-print((\"\\n\".join(list(map(str, a[9:6:-1])))))", "+while True:", "+ try:", "+ n = int(eval(input()))", "+ a.append(n)", "+ except:", "+ break", "+print((max(a)))", "+a.remove(max(a))", "+...
false
0.038263
0.035883
1.066323
[ "s586924443", "s747064922" ]
u359358631
p02707
python
s420582524
s578380592
180
163
119,156
108,768
Accepted
Accepted
9.44
def main(): n = int(eval(input())) a_lst = list(map(int, input().split())) dic = dict() for i in range(n - 1): if a_lst[i] in dic: dic[a_lst[i]] += 1 else: dic[a_lst[i]] = 1 dic_keys = list(dic.keys()) for i in range(1, n + 1): if i ...
def main(): n = int(eval(input())) a_lst = list(map(int, input().split())) lst = [0 for _ in range(2 * 10 ** 5 + 1)] for a in a_lst: lst[a] += 1 for i in range(1, n + 1): print((lst[i])) if __name__ == "__main__": main()
21
14
429
270
def main(): n = int(eval(input())) a_lst = list(map(int, input().split())) dic = dict() for i in range(n - 1): if a_lst[i] in dic: dic[a_lst[i]] += 1 else: dic[a_lst[i]] = 1 dic_keys = list(dic.keys()) for i in range(1, n + 1): if i in dic_keys: ...
def main(): n = int(eval(input())) a_lst = list(map(int, input().split())) lst = [0 for _ in range(2 * 10**5 + 1)] for a in a_lst: lst[a] += 1 for i in range(1, n + 1): print((lst[i])) if __name__ == "__main__": main()
false
33.333333
[ "- dic = dict()", "- for i in range(n - 1):", "- if a_lst[i] in dic:", "- dic[a_lst[i]] += 1", "- else:", "- dic[a_lst[i]] = 1", "- dic_keys = list(dic.keys())", "+ lst = [0 for _ in range(2 * 10**5 + 1)]", "+ for a in a_lst:", "+ lst[a] +=...
false
0.046155
0.18325
0.25187
[ "s420582524", "s578380592" ]
u312025627
p03150
python
s996412087
s994890318
177
19
39,152
2,940
Accepted
Accepted
89.27
def main(): S = input() N = len(S) ans = "keyence" for i in range(N): for j in range(N+1): T = S[:i] + S[i+j:] # S[i:i+j]を取り除く if T == ans: return print("YES") print("NO") if __name__ == '__main__': main()
def main(): S = input() N = len(S) for i in range(N): for j in range(N+1): T = S[:i] + S[i+j:] # S[i:i+j]を取り除く if T == "keyence": return print("YES") print("NO") if __name__ == '__main__': main()
15
13
296
279
def main(): S = input() N = len(S) ans = "keyence" for i in range(N): for j in range(N + 1): T = S[:i] + S[i + j :] # S[i:i+j]を取り除く if T == ans: return print("YES") print("NO") if __name__ == "__main__": main()
def main(): S = input() N = len(S) for i in range(N): for j in range(N + 1): T = S[:i] + S[i + j :] # S[i:i+j]を取り除く if T == "keyence": return print("YES") print("NO") if __name__ == "__main__": main()
false
13.333333
[ "- ans = \"keyence\"", "- if T == ans:", "+ if T == \"keyence\":" ]
false
0.040979
0.032075
1.277587
[ "s996412087", "s994890318" ]
u020962106
p03060
python
s139121146
s533721109
20
17
3,188
3,060
Accepted
Accepted
15
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) xy = [x-y for (x,y) in zip(v,c)] sm = 0 for x in xy: if x>0: sm += x print(sm)
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) xy = [x-y for (x,y) in zip(v,c)] sm = 0 for x in xy: sm = sm+x if x>0 else sm+0 print(sm)
9
8
185
187
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) xy = [x - y for (x, y) in zip(v, c)] sm = 0 for x in xy: if x > 0: sm += x print(sm)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) xy = [x - y for (x, y) in zip(v, c)] sm = 0 for x in xy: sm = sm + x if x > 0 else sm + 0 print(sm)
false
11.111111
[ "- if x > 0:", "- sm += x", "+ sm = sm + x if x > 0 else sm + 0" ]
false
0.120017
0.139617
0.859619
[ "s139121146", "s533721109" ]
u729133443
p03465
python
s182478689
s148422198
735
448
135,688
5,428
Accepted
Accepted
39.05
_,a=open(0) *a,=list(map(int,a.split())) d=1 for i in a:d|=d<<i s=0--sum(a)//2 print((bin(d)[~s::-1].find('1')+s))
def main(): _,a=open(0) *a,=list(map(int,a.split())) d=1 for i in a:d|=d<<i s=0--sum(a)//2 d>>=s print(((d&-d).bit_length()+s-1)) main()
6
9
111
150
_, a = open(0) (*a,) = list(map(int, a.split())) d = 1 for i in a: d |= d << i s = 0 - -sum(a) // 2 print((bin(d)[~s::-1].find("1") + s))
def main(): _, a = open(0) (*a,) = list(map(int, a.split())) d = 1 for i in a: d |= d << i s = 0 - -sum(a) // 2 d >>= s print(((d & -d).bit_length() + s - 1)) main()
false
33.333333
[ "-_, a = open(0)", "-(*a,) = list(map(int, a.split()))", "-d = 1", "-for i in a:", "- d |= d << i", "-s = 0 - -sum(a) // 2", "-print((bin(d)[~s::-1].find(\"1\") + s))", "+def main():", "+ _, a = open(0)", "+ (*a,) = list(map(int, a.split()))", "+ d = 1", "+ for i in a:", "+ ...
false
0.047762
0.048114
0.992676
[ "s182478689", "s148422198" ]
u659753499
p03326
python
s006353586
s558646379
24
22
3,300
3,316
Accepted
Accepted
8.33
N,M=list(map(int,input().split())) cakes=[] for i in range(N): x,y,z=list(map(int,input().split())) cakes.append([x,y,z]) if M==0: print((0)) quit() score=[0]*8 score[0]=sum(sorted([c[0]+c[1]+c[2] for c in cakes])[-M:]) score[1]=sum(sorted([c[0]+c[1]-c[2] for c in cakes])[-M:]) score[2]=sum(sorted([c...
N,M=list(map(int,input().split())) cakes=[] for i in range(N): x,y,z=list(map(int,input().split())) cakes.append([x,y,z]) if M==0: print((0)) quit() score=[0]*8 s=sorted([c[0]+c[1]+c[2] for c in cakes]) score[0]=sum(s[-M:]) score[1]=-sum(s[:M]) s=sorted([c[0]+c[1]-c[2] for c in cakes]) score[2]=sum...
18
23
702
558
N, M = list(map(int, input().split())) cakes = [] for i in range(N): x, y, z = list(map(int, input().split())) cakes.append([x, y, z]) if M == 0: print((0)) quit() score = [0] * 8 score[0] = sum(sorted([c[0] + c[1] + c[2] for c in cakes])[-M:]) score[1] = sum(sorted([c[0] + c[1] - c[2] for c in cakes])[...
N, M = list(map(int, input().split())) cakes = [] for i in range(N): x, y, z = list(map(int, input().split())) cakes.append([x, y, z]) if M == 0: print((0)) quit() score = [0] * 8 s = sorted([c[0] + c[1] + c[2] for c in cakes]) score[0] = sum(s[-M:]) score[1] = -sum(s[:M]) s = sorted([c[0] + c[1] - c[2]...
false
21.73913
[ "-score[0] = sum(sorted([c[0] + c[1] + c[2] for c in cakes])[-M:])", "-score[1] = sum(sorted([c[0] + c[1] - c[2] for c in cakes])[-M:])", "-score[2] = sum(sorted([c[0] - c[1] + c[2] for c in cakes])[-M:])", "-score[3] = sum(sorted([c[0] - c[1] - c[2] for c in cakes])[-M:])", "-score[4] = sum(sorted([-c[0] +...
false
0.033882
0.036822
0.92015
[ "s006353586", "s558646379" ]
u256031597
p03557
python
s012995725
s236897811
439
338
39,828
23,328
Accepted
Accepted
23.01
import numpy as np N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) An = np.array(A) Bn = np.array(B) Cn = np.array(C) An.sort() Bn.sort() Cn = -Cn Cn.sort() AB = np.searchsorted(An,Bn,side='left') CB = np.searchsorte...
import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() c_len = len(C) cnt = 0 for b in B: a_cnt = bisect.bisect_left(A,b) c_cnt = c_len - bisect.bisect_right(C,b) cnt += a...
20
19
359
340
import numpy as np N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) An = np.array(A) Bn = np.array(B) Cn = np.array(C) An.sort() Bn.sort() Cn = -Cn Cn.sort() AB = np.searchsorted(An, Bn, side="left") CB = np.searchsorted(Cn, -Bn, side="l...
import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() c_len = len(C) cnt = 0 for b in B: a_cnt = bisect.bisect_left(A, b) c_cnt = c_len - bisect.bisect_right(C, b) cnt += a_cnt * c_cnt prin...
false
5
[ "-import numpy as np", "+import bisect", "-An = np.array(A)", "-Bn = np.array(B)", "-Cn = np.array(C)", "-An.sort()", "-Bn.sort()", "-Cn = -Cn", "-Cn.sort()", "-AB = np.searchsorted(An, Bn, side=\"left\")", "-CB = np.searchsorted(Cn, -Bn, side=\"left\")", "-print(((AB * CB).sum()))", "+A.sor...
false
0.310337
0.042676
7.271998
[ "s012995725", "s236897811" ]
u219417113
p02627
python
s953324597
s232741667
64
34
61,576
8,880
Accepted
Accepted
46.88
def main(): import sys input = sys.stdin.readline a = input().rstrip() if a.isupper(): print("A") else: print("a") if __name__ == '__main__': main()
a = eval(input()) if a.isupper(): print("A") else: print("a")
11
5
199
64
def main(): import sys input = sys.stdin.readline a = input().rstrip() if a.isupper(): print("A") else: print("a") if __name__ == "__main__": main()
a = eval(input()) if a.isupper(): print("A") else: print("a")
false
54.545455
[ "-def main():", "- import sys", "-", "- input = sys.stdin.readline", "- a = input().rstrip()", "- if a.isupper():", "- print(\"A\")", "- else:", "- print(\"a\")", "-", "-", "-if __name__ == \"__main__\":", "- main()", "+a = eval(input())", "+if a.isupper()...
false
0.040093
0.065867
0.608689
[ "s953324597", "s232741667" ]
u944390835
p02712
python
s058056674
s334054884
185
22
9,160
9,192
Accepted
Accepted
88.11
N = int(eval(input())) a = 0 for i in range(N): if (i+1)%3 != 0 and (i+1)%5 != 0: a += i+1 print(a)
import math N = int(eval(input())) S = int(N*(N+1)/2) S -= 3*int(math.floor(N/3)*(math.floor(N/3)+1)/2) S -= 5*int(math.floor(N/5)*(math.floor(N/5)+1)/2) S += 15*int(math.floor(N/15)*(math.floor(N/15)+1)/2) print(S)
6
7
105
215
N = int(eval(input())) a = 0 for i in range(N): if (i + 1) % 3 != 0 and (i + 1) % 5 != 0: a += i + 1 print(a)
import math N = int(eval(input())) S = int(N * (N + 1) / 2) S -= 3 * int(math.floor(N / 3) * (math.floor(N / 3) + 1) / 2) S -= 5 * int(math.floor(N / 5) * (math.floor(N / 5) + 1) / 2) S += 15 * int(math.floor(N / 15) * (math.floor(N / 15) + 1) / 2) print(S)
false
14.285714
[ "+import math", "+", "-a = 0", "-for i in range(N):", "- if (i + 1) % 3 != 0 and (i + 1) % 5 != 0:", "- a += i + 1", "-print(a)", "+S = int(N * (N + 1) / 2)", "+S -= 3 * int(math.floor(N / 3) * (math.floor(N / 3) + 1) / 2)", "+S -= 5 * int(math.floor(N / 5) * (math.floor(N / 5) + 1) / 2)...
false
0.249635
0.10627
2.349058
[ "s058056674", "s334054884" ]
u832039789
p03106
python
s566943570
s701460211
31
18
2,940
3,068
Accepted
Accepted
41.94
a,b,k = list(map(int,input().split())) cnt = 0 res = 0 for i in range(100000,-1,-1): if a%i==0 and b%i==0: cnt += 1 if cnt == k: res = i break print(i)
a,b,k = list(map(int,input().split())) l = [] for i in range(1, 101): if a % i == 0 and b % i == 0: l.append(i) print((l[-k]))
10
6
187
136
a, b, k = list(map(int, input().split())) cnt = 0 res = 0 for i in range(100000, -1, -1): if a % i == 0 and b % i == 0: cnt += 1 if cnt == k: res = i break print(i)
a, b, k = list(map(int, input().split())) l = [] for i in range(1, 101): if a % i == 0 and b % i == 0: l.append(i) print((l[-k]))
false
40
[ "-cnt = 0", "-res = 0", "-for i in range(100000, -1, -1):", "+l = []", "+for i in range(1, 101):", "- cnt += 1", "- if cnt == k:", "- res = i", "- break", "-print(i)", "+ l.append(i)", "+print((l[-k]))" ]
false
0.059696
0.039466
1.51257
[ "s566943570", "s701460211" ]
u888092736
p02756
python
s958232528
s195837738
231
184
8,676
16,436
Accepted
Accepted
20.35
from collections import deque import sys input = lambda: sys.stdin.readline().rstrip() s = deque(list(eval(input()))) q = int(eval(input())) is_reverse = False for i in range(q): query = input().split() if query[0] == '2': if (query[1] == '1' and not is_reverse) or (query[1] == '2' and is...
import sys from collections import deque def input(): return sys.stdin.readline().strip() S = eval(input()) Q = int(eval(input())) q = deque(S) flipped = False for _ in range(Q): q_t, *q_d = input().split() if q_t == "1": flipped = not flipped else: F, C = q_d ...
24
28
540
530
from collections import deque import sys input = lambda: sys.stdin.readline().rstrip() s = deque(list(eval(input()))) q = int(eval(input())) is_reverse = False for i in range(q): query = input().split() if query[0] == "2": if (query[1] == "1" and not is_reverse) or (query[1] == "2" and is_reverse): ...
import sys from collections import deque def input(): return sys.stdin.readline().strip() S = eval(input()) Q = int(eval(input())) q = deque(S) flipped = False for _ in range(Q): q_t, *q_d = input().split() if q_t == "1": flipped = not flipped else: F, C = q_d if (not flipped...
false
14.285714
[ "+import sys", "-import sys", "-input = lambda: sys.stdin.readline().rstrip()", "-s = deque(list(eval(input())))", "-q = int(eval(input()))", "-is_reverse = False", "-for i in range(q):", "- query = input().split()", "- if query[0] == \"2\":", "- if (query[1] == \"1\" and not is_rever...
false
0.045156
0.0606
0.745147
[ "s958232528", "s195837738" ]
u952708174
p03244
python
s318333864
s236354326
93
83
21,008
15,588
Accepted
Accepted
10.75
def c_zigzag(N, V): from collections import Counter count_seq_even = Counter(V[::2]) # 数列の(0-indexedで)偶数番目の要素の出現頻度 count_seq_odd = Counter(V[1::2]) # 出現頻度(奇数番目) count_seq_even_s = sorted(list(count_seq_even.items()), key=lambda x: x[1], reverse=True) count_seq_odd_s = sorted(list(count_seq_...
def c_zigzag(): from collections import Counter N = int(eval(input())) V = [int(i) for i in input().split()] # 数列の(偶数|奇数)番目の要素のうち、出現頻度が高いもの上位2つを求める count_seq_even = Counter(V[::2]).most_common(2) count_seq_odd = Counter(V[1::2]).most_common(2) # 偶数番目を抜き出した数列と奇数番目を抜き出した数列のそれぞれについて ...
32
30
1,240
936
def c_zigzag(N, V): from collections import Counter count_seq_even = Counter(V[::2]) # 数列の(0-indexedで)偶数番目の要素の出現頻度 count_seq_odd = Counter(V[1::2]) # 出現頻度(奇数番目) count_seq_even_s = sorted( list(count_seq_even.items()), key=lambda x: x[1], reverse=True ) count_seq_odd_s = sorted( ...
def c_zigzag(): from collections import Counter N = int(eval(input())) V = [int(i) for i in input().split()] # 数列の(偶数|奇数)番目の要素のうち、出現頻度が高いもの上位2つを求める count_seq_even = Counter(V[::2]).most_common(2) count_seq_odd = Counter(V[1::2]).most_common(2) # 偶数番目を抜き出した数列と奇数番目を抜き出した数列のそれぞれについて # 最も出現...
false
6.25
[ "-def c_zigzag(N, V):", "+def c_zigzag():", "- count_seq_even = Counter(V[::2]) # 数列の(0-indexedで)偶数番目の要素の出現頻度", "- count_seq_odd = Counter(V[1::2]) # 出現頻度(奇数番目)", "- count_seq_even_s = sorted(", "- list(count_seq_even.items()), key=lambda x: x[1], reverse=True", "- )", "- count...
false
0.037581
0.038716
0.970682
[ "s318333864", "s236354326" ]
u761989513
p03473
python
s434145653
s061573216
19
17
2,940
2,940
Accepted
Accepted
10.53
print((48 - int(eval(input()))))
m = int(eval(input())) print((24 + 24 - m))
1
2
24
36
print((48 - int(eval(input()))))
m = int(eval(input())) print((24 + 24 - m))
false
50
[ "-print((48 - int(eval(input()))))", "+m = int(eval(input()))", "+print((24 + 24 - m))" ]
false
0.043248
0.042643
1.014183
[ "s434145653", "s061573216" ]
u760248716
p03911
python
s359007790
s173106423
804
742
147,844
147,868
Accepted
Accepted
7.71
from networkx import* print(('NYOE S'[is_connected(Graph((t,j)for t in[*open(0)][1:]for j in t.split()[1:]))::2]))
from networkx import* print(('YES'*is_connected(Graph((i,j)for i in[*open(0)][1:]for j in i.split()[1:]))or'NO'))
2
2
113
112
from networkx import * print( ( "NYOE S"[ is_connected( Graph((t, j) for t in [*open(0)][1:] for j in t.split()[1:]) ) :: 2 ] ) )
from networkx import * print( ( "YES" * is_connected(Graph((i, j) for i in [*open(0)][1:] for j in i.split()[1:])) or "NO" ) )
false
0
[ "- \"NYOE S\"[", "- is_connected(", "- Graph((t, j) for t in [*open(0)][1:] for j in t.split()[1:])", "- ) :: 2", "- ]", "+ \"YES\"", "+ * is_connected(Graph((i, j) for i in [*open(0)][1:] for j in i.split()[1:]))", "+ or \"NO\"" ...
false
0.047537
0.008652
5.494161
[ "s359007790", "s173106423" ]
u670180528
p02863
python
s003421564
s172674753
252
230
40,176
42,068
Accepted
Accepted
8.73
def main(): _, t, *L = list(map(int, open(0).read().split())) d = [0] * (t + max(L[::2])) for w, v in sorted((x, y) for x, y in zip(*[iter(L)] * 2)): for i in range(t + w - 1, w - 1, -1): if d[i - w] + v > d[i]: d[i] = d[i - w] + v print((max(d))) if __name__=="__main__": main() #vs after co...
def main(): _, t, *L = list(map(int, open(0).read().split())) d = [0] * t cand = 0 for w, v in sorted((x, y) for x, y in zip(*[iter(L)] * 2)): if cand < d[-1] + v: cand = d[-1] + v for i in range(t - 1, w - 1, -1): if d[i - w] + v > d[i]: d[i] = d[i - w] + v print((max(cand, max(d)))) if...
13
14
317
344
def main(): _, t, *L = list(map(int, open(0).read().split())) d = [0] * (t + max(L[::2])) for w, v in sorted((x, y) for x, y in zip(*[iter(L)] * 2)): for i in range(t + w - 1, w - 1, -1): if d[i - w] + v > d[i]: d[i] = d[i - w] + v print((max(d))) if __name__ == "__...
def main(): _, t, *L = list(map(int, open(0).read().split())) d = [0] * t cand = 0 for w, v in sorted((x, y) for x, y in zip(*[iter(L)] * 2)): if cand < d[-1] + v: cand = d[-1] + v for i in range(t - 1, w - 1, -1): if d[i - w] + v > d[i]: d[i] = d[...
false
7.142857
[ "- d = [0] * (t + max(L[::2]))", "+ d = [0] * t", "+ cand = 0", "- for i in range(t + w - 1, w - 1, -1):", "+ if cand < d[-1] + v:", "+ cand = d[-1] + v", "+ for i in range(t - 1, w - 1, -1):", "- print((max(d)))", "+ print((max(cand, max(d))))", "-# ...
false
0.075423
0.105831
0.712677
[ "s003421564", "s172674753" ]
u887207211
p03624
python
s819709931
s222033063
50
20
4,280
3,188
Accepted
Accepted
60
S = sorted(eval(input())) dic = "abcdefghijklmnopqrstuvwxyz" for s in S: if(s in dic): dic = dic.replace(s,'') if(dic != ''): print((dic[0])) else: print("None")
S = sorted(set(eval(input()))) dic = "abcdefghijklmnopqrstuvwxyz" for s in S: if(s in dic): dic = dic.replace(s,'') if(dic != ''): print((dic[0])) else: print("None")
9
9
171
176
S = sorted(eval(input())) dic = "abcdefghijklmnopqrstuvwxyz" for s in S: if s in dic: dic = dic.replace(s, "") if dic != "": print((dic[0])) else: print("None")
S = sorted(set(eval(input()))) dic = "abcdefghijklmnopqrstuvwxyz" for s in S: if s in dic: dic = dic.replace(s, "") if dic != "": print((dic[0])) else: print("None")
false
0
[ "-S = sorted(eval(input()))", "+S = sorted(set(eval(input())))" ]
false
0.040503
0.040474
1.000708
[ "s819709931", "s222033063" ]
u347640436
p02550
python
s958745967
s172565727
69
62
68,960
69,160
Accepted
Accepted
10.14
N, X, M = list(map(int, input().split())) used = [0] * M a = [] A = X for i in range(N): if used[A] != 0: break used[A] = 1 a.append(A) A = A * A % M for i in range(len(a)): if a[i] == A: break j = i if a[-1] != 0: result = sum(a[:j]) a = a[j:] l ...
N, X, M = list(map(int, input().split())) existence = [0] * M a = [] A = X for i in range(N): if existence[A] != 0: break existence[A] = 1 a.append(A) A = A * A % M for i in range(len(a)): if a[i] == A: break j = i result = sum(a[:j]) a = a[j:] N -= j x = N // ...
31
24
489
387
N, X, M = list(map(int, input().split())) used = [0] * M a = [] A = X for i in range(N): if used[A] != 0: break used[A] = 1 a.append(A) A = A * A % M for i in range(len(a)): if a[i] == A: break j = i if a[-1] != 0: result = sum(a[:j]) a = a[j:] l = len(a) x = (N - j) ...
N, X, M = list(map(int, input().split())) existence = [0] * M a = [] A = X for i in range(N): if existence[A] != 0: break existence[A] = 1 a.append(A) A = A * A % M for i in range(len(a)): if a[i] == A: break j = i result = sum(a[:j]) a = a[j:] N -= j x = N // len(a) y = N % len(a) r...
false
22.580645
[ "-used = [0] * M", "+existence = [0] * M", "- if used[A] != 0:", "+ if existence[A] != 0:", "- used[A] = 1", "+ existence[A] = 1", "-if a[-1] != 0:", "- result = sum(a[:j])", "- a = a[j:]", "- l = len(a)", "- x = (N - j) // l", "- y = (N - j) - x * l", "- s = su...
false
0.048097
0.039962
1.203576
[ "s958745967", "s172565727" ]
u309141201
p02823
python
s963381332
s915933695
166
28
38,256
9,040
Accepted
Accepted
83.13
n, a, b = list(map(int, input().split())) d = b - a if d % 2 == 0: print((d//2)) else: dd = d//2 ans = min(dd + a, n - b + 1 + dd) print(ans)
n, a, b = list(map(int, input().split())) dist = abs(a-b)-1 if dist % 2 != 0: ans = dist//2+1 else: dist -= 1 ans = min(a+dist//2+1, n-b+1+dist//2+1) print(ans)
8
9
156
176
n, a, b = list(map(int, input().split())) d = b - a if d % 2 == 0: print((d // 2)) else: dd = d // 2 ans = min(dd + a, n - b + 1 + dd) print(ans)
n, a, b = list(map(int, input().split())) dist = abs(a - b) - 1 if dist % 2 != 0: ans = dist // 2 + 1 else: dist -= 1 ans = min(a + dist // 2 + 1, n - b + 1 + dist // 2 + 1) print(ans)
false
11.111111
[ "-d = b - a", "-if d % 2 == 0:", "- print((d // 2))", "+dist = abs(a - b) - 1", "+if dist % 2 != 0:", "+ ans = dist // 2 + 1", "- dd = d // 2", "- ans = min(dd + a, n - b + 1 + dd)", "- print(ans)", "+ dist -= 1", "+ ans = min(a + dist // 2 + 1, n - b + 1 + dist // 2 + 1)", ...
false
0.061875
0.037264
1.660441
[ "s963381332", "s915933695" ]
u979823197
p02572
python
s317134283
s439119443
146
115
31,544
105,228
Accepted
Accepted
21.23
n=int(eval(input())) mod=10**9+7 A=list(map(int,input().split())) a=sum(A) a=(a**2) b=0 for i in range(n): b+=(A[i])**2 if a-b<0: c=a-b while c<=0: c+=mod ans=c//2 ans=ans%mod else: ans=(a-b)//2 ans=ans%mod print(ans)
n=int(eval(input())) A=list(map(int,input().split())) mod=10**9+7 INf=float('inf') Acc=[0]*(n+1) for i in range(1,n+1): Acc[i]=(Acc[i-1]+A[i-1])%mod ans=0 for i in range(n): s=A[i]*(Acc[n]-Acc[i+1]) ans+=s%mod print((ans%mod))
23
15
258
243
n = int(eval(input())) mod = 10**9 + 7 A = list(map(int, input().split())) a = sum(A) a = a**2 b = 0 for i in range(n): b += (A[i]) ** 2 if a - b < 0: c = a - b while c <= 0: c += mod ans = c // 2 ans = ans % mod else: ans = (a - b) // 2 ans = ans % mod print(ans)
n = int(eval(input())) A = list(map(int, input().split())) mod = 10**9 + 7 INf = float("inf") Acc = [0] * (n + 1) for i in range(1, n + 1): Acc[i] = (Acc[i - 1] + A[i - 1]) % mod ans = 0 for i in range(n): s = A[i] * (Acc[n] - Acc[i + 1]) ans += s % mod print((ans % mod))
false
34.782609
[ "+A = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-a = sum(A)", "-a = a**2", "-b = 0", "+INf = float(\"inf\")", "+Acc = [0] * (n + 1)", "+for i in range(1, n + 1):", "+ Acc[i] = (Acc[i - 1] + A[i - 1]) % mod", "+ans = 0", "- b += (A[i]) ** 2", "-if a - b < ...
false
0.058615
0.080919
0.724361
[ "s317134283", "s439119443" ]
u203843959
p03142
python
s276233663
s232427145
421
355
142,436
107,440
Accepted
Accepted
15.68
from collections import defaultdict, deque N,M=list(map(int,input().split())) outs = defaultdict(list) outs_rev = defaultdict(list) ins = defaultdict(int) for _ in range(N+M-1): v1,v2=list(map(int,input().split())) outs[v1].append(v2) outs_rev[v2].append(v1) ins[v2] += 1 #print(outs,ins) #print(out...
from collections import deque N,M=list(map(int,input().split())) outs = [[] for _ in range(N+1)] outs_rev = [[] for _ in range(N+1)] ins = [0]*(N+1) for _ in range(N+M-1): v1,v2=list(map(int,input().split())) outs[v1].append(v2) outs_rev[v2].append(v1) ins[v2] += 1 #print(outs,ins) #print(outs_rev)...
49
49
965
971
from collections import defaultdict, deque N, M = list(map(int, input().split())) outs = defaultdict(list) outs_rev = defaultdict(list) ins = defaultdict(int) for _ in range(N + M - 1): v1, v2 = list(map(int, input().split())) outs[v1].append(v2) outs_rev[v2].append(v1) ins[v2] += 1 # print(outs,ins) #...
from collections import deque N, M = list(map(int, input().split())) outs = [[] for _ in range(N + 1)] outs_rev = [[] for _ in range(N + 1)] ins = [0] * (N + 1) for _ in range(N + M - 1): v1, v2 = list(map(int, input().split())) outs[v1].append(v2) outs_rev[v2].append(v1) ins[v2] += 1 # print(outs,ins)...
false
0
[ "-from collections import defaultdict, deque", "+from collections import deque", "-outs = defaultdict(list)", "-outs_rev = defaultdict(list)", "-ins = defaultdict(int)", "+outs = [[] for _ in range(N + 1)]", "+outs_rev = [[] for _ in range(N + 1)]", "+ins = [0] * (N + 1)", "-q = deque(v1 for v1 in r...
false
0.007502
0.035769
0.209722
[ "s276233663", "s232427145" ]
u760248716
p03751
python
s176200569
s107568243
91
37
75,092
11,020
Accepted
Accepted
59.34
from bisect import* n,*s,t=open(0) print((*list(range(bisect_left(sorted(u.replace(*'?z')for u in s),t)+1,bisect(sorted(u.replace(*'?a')for u in s),t)+2))))
from bisect import* n,*s,t=open(0) x,y=[sorted(u.replace('?',c)for u in s)for c in'za'] print((*list(range(bisect_left(x,t)+1,bisect(y,t)+2))))
3
4
150
138
from bisect import * n, *s, t = open(0) print( ( *list( range( bisect_left(sorted(u.replace(*"?z") for u in s), t) + 1, bisect(sorted(u.replace(*"?a") for u in s), t) + 2, ) ) ) )
from bisect import * n, *s, t = open(0) x, y = [sorted(u.replace("?", c) for u in s) for c in "za"] print((*list(range(bisect_left(x, t) + 1, bisect(y, t) + 2))))
false
25
[ "-print(", "- (", "- *list(", "- range(", "- bisect_left(sorted(u.replace(*\"?z\") for u in s), t) + 1,", "- bisect(sorted(u.replace(*\"?a\") for u in s), t) + 2,", "- )", "- )", "- )", "-)", "+x, y = [sorted(u.replace(\"?\"...
false
0.048624
0.089822
0.541335
[ "s176200569", "s107568243" ]
u729133443
p03262
python
s382537790
s953704397
96
87
13,332
16,076
Accepted
Accepted
9.38
from fractions import gcd from functools import reduce X=int(input().split()[1]);print((reduce(gcd,[abs(int(x)-X) for x in input().split()])))
from fractions import gcd from functools import reduce _,X,*y=list(map(int,open(0).read().split()));print((reduce(gcd,[abs(x-X)for x in y])))
3
3
145
135
from fractions import gcd from functools import reduce X = int(input().split()[1]) print((reduce(gcd, [abs(int(x) - X) for x in input().split()])))
from fractions import gcd from functools import reduce _, X, *y = list(map(int, open(0).read().split())) print((reduce(gcd, [abs(x - X) for x in y])))
false
0
[ "-X = int(input().split()[1])", "-print((reduce(gcd, [abs(int(x) - X) for x in input().split()])))", "+_, X, *y = list(map(int, open(0).read().split()))", "+print((reduce(gcd, [abs(x - X) for x in y])))" ]
false
0.046639
0.047772
0.976287
[ "s382537790", "s953704397" ]
u814781830
p03026
python
s720772405
s088260278
264
142
201,888
82,040
Accepted
Accepted
46.21
import sys sys.setrecursionlimit(10**9) N = int(input()) edge = [[] for _ in range(N)] cnt = [[0,i] for i in range(N)] for i in range(N-1): a, b = map(int, input().split()) a, b = a-1, b-1 edge[a].append(b) edge[b].append(a) cnt[a][0] += 1 cnt[b][0] += 1 cnt.sort(reverse=True...
import sys sys.setrecursionlimit(10**9) N = int(input()) edge = [[] for _ in range(N)] for i in range(N-1): a, b = map(int, input().split()) a, b = a-1, b-1 edge[a].append(b) edge[b].append(a) C = list(map(int, input().split())) C.sort(reverse=True) nodes = [0] * N #print(nodes) cid...
37
31
709
587
import sys sys.setrecursionlimit(10**9) N = int(input()) edge = [[] for _ in range(N)] cnt = [[0, i] for i in range(N)] for i in range(N - 1): a, b = map(int, input().split()) a, b = a - 1, b - 1 edge[a].append(b) edge[b].append(a) cnt[a][0] += 1 cnt[b][0] += 1 cnt.sort(reverse=True) start = cn...
import sys sys.setrecursionlimit(10**9) N = int(input()) edge = [[] for _ in range(N)] for i in range(N - 1): a, b = map(int, input().split()) a, b = a - 1, b - 1 edge[a].append(b) edge[b].append(a) C = list(map(int, input().split())) C.sort(reverse=True) nodes = [0] * N # print(nodes) cidx = -1 ans = ...
false
16.216216
[ "-cnt = [[0, i] for i in range(N)]", "- cnt[a][0] += 1", "- cnt[b][0] += 1", "-cnt.sort(reverse=True)", "-start = cnt[0][1]", "-dfs(start, 0, 0)", "+dfs(0, 0, 0)" ]
false
0.036664
0.036721
0.998449
[ "s720772405", "s088260278" ]
u241159583
p03971
python
s431237144
s716156586
121
111
4,016
4,016
Accepted
Accepted
8.26
N, A, B = list(map(int, input().split())) S = eval(input()) yosen = 0 overseas = 0 for i in range(N): if S[i] == "c": print("No") elif yosen < A + B: if S[i] == "a": print("Yes") yosen += 1 elif S[i] == "b" and overseas < B: print("Yes") yosen += 1 overseas ...
N, A, B = list(map(int, input().split())) S = eval(input()) jp = 0 os = 0 for s in S: ans = "No" if jp + os < A + B: if s == "a": jp += 1 ans = "Yes" if s == "b" and os < B: os += 1 ans = "Yes" print(ans)
18
15
356
245
N, A, B = list(map(int, input().split())) S = eval(input()) yosen = 0 overseas = 0 for i in range(N): if S[i] == "c": print("No") elif yosen < A + B: if S[i] == "a": print("Yes") yosen += 1 elif S[i] == "b" and overseas < B: print("Yes") yo...
N, A, B = list(map(int, input().split())) S = eval(input()) jp = 0 os = 0 for s in S: ans = "No" if jp + os < A + B: if s == "a": jp += 1 ans = "Yes" if s == "b" and os < B: os += 1 ans = "Yes" print(ans)
false
16.666667
[ "-yosen = 0", "-overseas = 0", "-for i in range(N):", "- if S[i] == \"c\":", "- print(\"No\")", "- elif yosen < A + B:", "- if S[i] == \"a\":", "- print(\"Yes\")", "- yosen += 1", "- elif S[i] == \"b\" and overseas < B:", "- print(\"Yes...
false
0.034737
0.043413
0.800169
[ "s431237144", "s716156586" ]
u314050667
p03557
python
s709353019
s675708343
950
517
24,836
33,688
Accepted
Accepted
45.58
import numpy as np N = int(eval(input())) A = list(map(int, input().split())) A.sort() A = np.array(A) B = list(map(int, input().split())) B.sort() B = np.array(B) C = list(map(int, input().split())) C.sort() C = np.array(C) ans = 0 for i in range(N): b = B[i] a_ind = np.searchsorted(A,b,side='left') ...
import numpy as np N = int(eval(input())) A = list(map(int, input().split())) A.sort() A = np.array(A) B = list(map(int, input().split())) B.sort() B = np.array(B) C = list(map(int, input().split())) C.sort() C = np.array(C) cnt_A = np.searchsorted(A,B,side='left') cnt_C = np.searchsorted(C,B,side='right'...
20
18
398
364
import numpy as np N = int(eval(input())) A = list(map(int, input().split())) A.sort() A = np.array(A) B = list(map(int, input().split())) B.sort() B = np.array(B) C = list(map(int, input().split())) C.sort() C = np.array(C) ans = 0 for i in range(N): b = B[i] a_ind = np.searchsorted(A, b, side="left") c_i...
import numpy as np N = int(eval(input())) A = list(map(int, input().split())) A.sort() A = np.array(A) B = list(map(int, input().split())) B.sort() B = np.array(B) C = list(map(int, input().split())) C.sort() C = np.array(C) cnt_A = np.searchsorted(A, B, side="left") cnt_C = np.searchsorted(C, B, side="right") ans = (...
false
10
[ "-ans = 0", "-for i in range(N):", "- b = B[i]", "- a_ind = np.searchsorted(A, b, side=\"left\")", "- c_ind = np.searchsorted(C, b, side=\"right\")", "- ans += a_ind * (N - c_ind)", "+cnt_A = np.searchsorted(A, B, side=\"left\")", "+cnt_C = np.searchsorted(C, B, side=\"right\")", "+ans =...
false
0.179446
0.446554
0.401847
[ "s709353019", "s675708343" ]
u936985471
p02695
python
s231465448
s577248127
623
541
9,228
9,016
Accepted
Accepted
13.16
N,M,Q = list(map(int,input().split())) # 10個の数列で、A_i <= A_i+1となる組み合わせ(最大10)は # [1,1,1,1,1,1,1,1,1,1]のどこに10個のUPを入れるかの組み合わせであり # 20C10 = 184756 # この組み合わせに対して最大50のクエリを試すと、9237800通り # 全探索する query = [None] * Q for i in range(Q): query[i] = list(map(int,input().split())) stack = [] for i in range(1,M + 1): ...
N,M,Q = list(map(int,input().split())) query = [None] * Q for i in range(Q): query[i] = list(map(int,input().split())) def calc(arr,query): res = 0 for a,b,c,d in query: if arr[b-1] - arr[a-1] == c: res += d return res ans = 0 import itertools for arr in itertools.combinations_with...
35
19
690
412
N, M, Q = list(map(int, input().split())) # 10個の数列で、A_i <= A_i+1となる組み合わせ(最大10)は # [1,1,1,1,1,1,1,1,1,1]のどこに10個のUPを入れるかの組み合わせであり # 20C10 = 184756 # この組み合わせに対して最大50のクエリを試すと、9237800通り # 全探索する query = [None] * Q for i in range(Q): query[i] = list(map(int, input().split())) stack = [] for i in range(1, M + 1): stack...
N, M, Q = list(map(int, input().split())) query = [None] * Q for i in range(Q): query[i] = list(map(int, input().split())) def calc(arr, query): res = 0 for a, b, c, d in query: if arr[b - 1] - arr[a - 1] == c: res += d return res ans = 0 import itertools for arr in itertools.co...
false
45.714286
[ "-# 10個の数列で、A_i <= A_i+1となる組み合わせ(最大10)は", "-# [1,1,1,1,1,1,1,1,1,1]のどこに10個のUPを入れるかの組み合わせであり", "-# 20C10 = 184756", "-# この組み合わせに対して最大50のクエリを試すと、9237800通り", "-# 全探索する", "-stack = []", "-for i in range(1, M + 1):", "- stack.append([i])", "- for q in query:", "- a, b, c, d = q", "+ f...
false
0.113391
0.036321
3.121947
[ "s231465448", "s577248127" ]
u718949306
p03087
python
s008753230
s769319447
416
274
10,308
15,416
Accepted
Accepted
34.13
N, Q = list(map(int, input().split())) S = eval(input()) s = [0]*N A = [] for n in range(N-1): if S[n] + S[n+1] == 'AC': s[n+1] = s[n] + 1 else: s[n+1] = s[n] for q in range(Q): l, r = list(map(int, input().split())) A.append(s[r-1] - s[l-1]) for a in A: print(a)
N, Q = list(map(int, input().split())) S = eval(input()) s = [0]*(N+1) for n in range(N): if n + 1 < N and S[n] == 'A' and S[n+1] == 'C': s[n+1] = s[n] + 1 else: s[n+1] = s[n] A = [] for q in range(Q): l, r = list(map(int, input().split())) l -= 1 r -= 1 A.append(s[r...
14
16
294
336
N, Q = list(map(int, input().split())) S = eval(input()) s = [0] * N A = [] for n in range(N - 1): if S[n] + S[n + 1] == "AC": s[n + 1] = s[n] + 1 else: s[n + 1] = s[n] for q in range(Q): l, r = list(map(int, input().split())) A.append(s[r - 1] - s[l - 1]) for a in A: print(a)
N, Q = list(map(int, input().split())) S = eval(input()) s = [0] * (N + 1) for n in range(N): if n + 1 < N and S[n] == "A" and S[n + 1] == "C": s[n + 1] = s[n] + 1 else: s[n + 1] = s[n] A = [] for q in range(Q): l, r = list(map(int, input().split())) l -= 1 r -= 1 A.append(s[r] -...
false
12.5
[ "-s = [0] * N", "-A = []", "-for n in range(N - 1):", "- if S[n] + S[n + 1] == \"AC\":", "+s = [0] * (N + 1)", "+for n in range(N):", "+ if n + 1 < N and S[n] == \"A\" and S[n + 1] == \"C\":", "+A = []", "- A.append(s[r - 1] - s[l - 1])", "+ l -= 1", "+ r -= 1", "+ A.append(s...
false
0.0351
0.046576
0.753599
[ "s008753230", "s769319447" ]
u863370423
p03720
python
s075122313
s471526466
183
18
38,424
3,060
Accepted
Accepted
90.16
n,m = list(map(int, input().split())) adj = [[] for i in range(n)] for i in range(m): a,b = list(map(int, input().split())) a-=1 b-=1 adj[a].append(b) adj[b].append(a) for i in adj: print((len(i)))
N,M = (int(x) for x in input().split()) result = [0]*N for i in range(M): a,b = (int(x) for x in input().split()) result[a-1] += 1 result[b-1] += 1 for i in result: print(i)
10
10
216
188
n, m = list(map(int, input().split())) adj = [[] for i in range(n)] for i in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 adj[a].append(b) adj[b].append(a) for i in adj: print((len(i)))
N, M = (int(x) for x in input().split()) result = [0] * N for i in range(M): a, b = (int(x) for x in input().split()) result[a - 1] += 1 result[b - 1] += 1 for i in result: print(i)
false
0
[ "-n, m = list(map(int, input().split()))", "-adj = [[] for i in range(n)]", "-for i in range(m):", "- a, b = list(map(int, input().split()))", "- a -= 1", "- b -= 1", "- adj[a].append(b)", "- adj[b].append(a)", "-for i in adj:", "- print((len(i)))", "+N, M = (int(x) for x in in...
false
0.099943
0.031253
3.197897
[ "s075122313", "s471526466" ]
u790710233
p03329
python
s456412241
s175110556
645
296
3,060
3,060
Accepted
Accepted
54.11
n = int(eval(input())) INF = 10**5 answer = INF for i in range(n+1): cost = i ans = 0 for p in range(8): ans += (cost // 6**p) % 6 cost = n-i for q in range(7): ans += (cost // 9**q) % 9 if answer > ans: answer = ans print(answer)
n = int(eval(input())) INF = 10**5 answer = INF for i in range(n+1): money = i cnt = 0 while money > 0: cnt += money % 6 money //= 6 money = n-i while money > 0: cnt += money % 9 money //= 9 if answer > cnt: answer = cnt print(answer)
16
17
290
309
n = int(eval(input())) INF = 10**5 answer = INF for i in range(n + 1): cost = i ans = 0 for p in range(8): ans += (cost // 6**p) % 6 cost = n - i for q in range(7): ans += (cost // 9**q) % 9 if answer > ans: answer = ans print(answer)
n = int(eval(input())) INF = 10**5 answer = INF for i in range(n + 1): money = i cnt = 0 while money > 0: cnt += money % 6 money //= 6 money = n - i while money > 0: cnt += money % 9 money //= 9 if answer > cnt: answer = cnt print(answer)
false
5.882353
[ "- cost = i", "- ans = 0", "- for p in range(8):", "- ans += (cost // 6**p) % 6", "- cost = n - i", "- for q in range(7):", "- ans += (cost // 9**q) % 9", "- if answer > ans:", "- answer = ans", "+ money = i", "+ cnt = 0", "+ while money > 0:", ...
false
0.17223
0.061601
2.795918
[ "s456412241", "s175110556" ]
u027929618
p02975
python
s363670362
s209210542
67
56
14,212
14,212
Accepted
Accepted
16.42
n=int(eval(input())) a=[int(x) for x in map(int,input().split()[:n])] ret=a[0] for x in range(1,n): ret= a[x] ^ ret if ret==0: print("Yes") else: print("No")
n=int(eval(input())) a=list(map(int,input().split())) ret=a[0] for x in range(1,n): ret=a[x]^ret if ret==0: print("Yes") else: print("No")
9
9
171
152
n = int(eval(input())) a = [int(x) for x in map(int, input().split()[:n])] ret = a[0] for x in range(1, n): ret = a[x] ^ ret if ret == 0: print("Yes") else: print("No")
n = int(eval(input())) a = list(map(int, input().split())) ret = a[0] for x in range(1, n): ret = a[x] ^ ret if ret == 0: print("Yes") else: print("No")
false
0
[ "-a = [int(x) for x in map(int, input().split()[:n])]", "+a = list(map(int, input().split()))" ]
false
0.082767
0.039049
2.119593
[ "s363670362", "s209210542" ]
u325492232
p02641
python
s529423347
s944215075
31
26
9,156
9,172
Accepted
Accepted
16.13
def abc170_c(): def solve(): x, n = list(map(int, input().split(' '))) if n == 0: return x p = list(map(int, input().split(' '))) search_range_min = min(min(p), x) - 1 search_range_max = max(max(p), x) + 1 search_values = [i for i in range(sear...
def abc170_c_1(): """ もうちょいコンパクトに書いてみる """ def solve(): x, n = list(map(int, input().split(' '))) if n == 0: return x p = list(map(int, input().split(' '))) search_range_min = min(min(p), x) - 1 search_range_max = max(max(p), x) + 1 ...
23
23
625
565
def abc170_c(): def solve(): x, n = list(map(int, input().split(" "))) if n == 0: return x p = list(map(int, input().split(" "))) search_range_min = min(min(p), x) - 1 search_range_max = max(max(p), x) + 1 search_values = [ i for i in range(sea...
def abc170_c_1(): """ もうちょいコンパクトに書いてみる """ def solve(): x, n = list(map(int, input().split(" "))) if n == 0: return x p = list(map(int, input().split(" "))) search_range_min = min(min(p), x) - 1 search_range_max = max(max(p), x) + 1 search_val...
false
0
[ "-def abc170_c():", "+def abc170_c_1():", "+ \"\"\"", "+ もうちょいコンパクトに書いてみる", "+ \"\"\"", "+", "- check_dict = {}", "- for i in search_values:", "- # 絶対値が小さいものを調べるので差の絶対値を格納", "- check_dict[i] = abs(x - i)", "- return min(check_dict, key=check_di...
false
0.052582
0.036421
1.443731
[ "s529423347", "s944215075" ]
u936051377
p02255
python
s217253538
s209390171
30
20
7,688
7,748
Accepted
Accepted
33.33
list_len = int(input().rstrip()) num_list = list(map(int, input().rstrip().split())) for i in range(list_len): v = num_list[i] j = i - 1 while j >= 0 and num_list[j] > v: num_list[j + 1] = num_list[j] j -= 1 num_list[j+1] = v output_str = ' '.join(map(str, num_list...
def insertion_sort(A, N): for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print((' '.join(map(str, A)))) def main(): N = int(input().rstrip()) A = list(map(int, input(...
14
19
345
416
list_len = int(input().rstrip()) num_list = list(map(int, input().rstrip().split())) for i in range(list_len): v = num_list[i] j = i - 1 while j >= 0 and num_list[j] > v: num_list[j + 1] = num_list[j] j -= 1 num_list[j + 1] = v output_str = " ".join(map(str, num_list)) print(outp...
def insertion_sort(A, N): for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print((" ".join(map(str, A)))) def main(): N = int(input().rstrip()) A = list(map(int, input().rstrip().split())) ...
false
26.315789
[ "-list_len = int(input().rstrip())", "-num_list = list(map(int, input().rstrip().split()))", "-for i in range(list_len):", "- v = num_list[i]", "- j = i - 1", "- while j >= 0 and num_list[j] > v:", "- num_list[j + 1] = num_list[j]", "- j -= 1", "- num_list[j + 1] = v", "-...
false
0.050278
0.03813
1.318599
[ "s217253538", "s209390171" ]
u218843509
p02816
python
s055017565
s417771881
1,754
704
100,768
136,296
Accepted
Accepted
59.86
import sys BASE, MOD1, MOD2 = (1<<30), (1<<61)-1, (1<<31)-1 class RollingHash(): def __init__(self, s, base, mod): self.mod = mod self.pw = pw = [1]*(len(s)+1) l = len(s) self.h = h = [0]*(l+1) v = 0 for i in range(l): h[i+1] = v = (v * base + s[i]) % mod v = 1 for i in range(l): ...
import sys BASE, MOD = 80408696819889532, (1<<61)-1 class RollingHash(): def __init__(self, s, base, mod): self.mod = mod self.pw = pw = [1]*(len(s)+1) l = len(s) self.h = h = [0]*(l+1) v = 0 for i in range(l): h[i+1] = v = (v * base + s[i]) % mod v = 1 for i in range(l): pw[i+...
43
42
1,126
984
import sys BASE, MOD1, MOD2 = (1 << 30), (1 << 61) - 1, (1 << 31) - 1 class RollingHash: def __init__(self, s, base, mod): self.mod = mod self.pw = pw = [1] * (len(s) + 1) l = len(s) self.h = h = [0] * (l + 1) v = 0 for i in range(l): h[i + 1] = v = (v ...
import sys BASE, MOD = 80408696819889532, (1 << 61) - 1 class RollingHash: def __init__(self, s, base, mod): self.mod = mod self.pw = pw = [1] * (len(s) + 1) l = len(s) self.h = h = [0] * (l + 1) v = 0 for i in range(l): h[i + 1] = v = (v * base + s[i])...
false
2.325581
[ "-BASE, MOD1, MOD2 = (1 << 30), (1 << 61) - 1, (1 << 31) - 1", "+BASE, MOD = 80408696819889532, (1 << 61) - 1", "-rh1_x, rh1_y = RollingHash(x, BASE, MOD1), RollingHash(y, BASE, MOD1)", "-rh2_x, rh2_y = RollingHash(x, BASE, MOD2), RollingHash(y, BASE, MOD2)", "+rh_x, rh_y = RollingHash(x, BASE, MOD), Rollin...
false
0.077543
0.036244
2.139489
[ "s055017565", "s417771881" ]
u095021077
p02995
python
s149514792
s752628813
184
35
38,384
5,048
Accepted
Accepted
80.98
def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd (a, b) temp=input().split() A=int(temp[0]) B=int(temp[1]) C=int(temp[2]) D=int(temp[3]) x=B//C-(A-1)//C y=B//D-(A-1)//D s=lcm(C, D) z=B//s-(A-1)//s print((int(B-A+1-x-y+z)))
import fractions A, B, C, D=list(map(int, input().split())) x=C*D//fractions.gcd(C, D) p=B//C-(A-1)//C q=B//D-(A-1)//D r=B//x-(A-1)//x print((int(B-(A-1)-(p+q-r))))
20
8
298
164
def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) temp = input().split() A = int(temp[0]) B = int(temp[1]) C = int(temp[2]) D = int(temp[3]) x = B // C - (A - 1) // C y = B // D - (A - 1) // D s = lcm(C, D) z = B // s - (A - 1) // s print((int(B - A + 1 - ...
import fractions A, B, C, D = list(map(int, input().split())) x = C * D // fractions.gcd(C, D) p = B // C - (A - 1) // C q = B // D - (A - 1) // D r = B // x - (A - 1) // x print((int(B - (A - 1) - (p + q - r))))
false
60
[ "-def gcd(a, b):", "- while b:", "- a, b = b, a % b", "- return a", "+import fractions", "-", "-def lcm(a, b):", "- return a * b // gcd(a, b)", "-", "-", "-temp = input().split()", "-A = int(temp[0])", "-B = int(temp[1])", "-C = int(temp[2])", "-D = int(temp[3])", "-x =...
false
0.130225
0.128546
1.013062
[ "s149514792", "s752628813" ]
u016302627
p03557
python
s609023382
s544719635
348
260
23,232
29,364
Accepted
Accepted
25.29
import bisect n = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ct = 0 for j in B: a_max = bisect.bisect_left(A, j) c_min = bisect.bisect_right(C, j) ct += a_max * (n - c_min) print(ct)
import bisect n = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for b in B: a_max = bisect.bisect_left(A, b) c_min = bisect.bisect_right(C ,b) ans += a_max * (n - c_min) print(ans)
14
17
304
313
import bisect n = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ct = 0 for j in B: a_max = bisect.bisect_left(A, j) c_min = bisect.bisect_right(C, j) ct += a_max * (n - c_min) print(ct)
import bisect n = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for b in B: a_max = bisect.bisect_left(A, b) c_min = bisect.bisect_right(C, b) ans += a_max * (n - c_min) print(ans)
false
17.647059
[ "-ct = 0", "-for j in B:", "- a_max = bisect.bisect_left(A, j)", "- c_min = bisect.bisect_right(C, j)", "- ct += a_max * (n - c_min)", "-print(ct)", "+ans = 0", "+for b in B:", "+ a_max = bisect.bisect_left(A, b)", "+ c_min = bisect.bisect_right(C, b)", "+ ans += a_max * (n - c...
false
0.042324
0.040236
1.051898
[ "s609023382", "s544719635" ]
u393512980
p03006
python
s868605651
s644056775
434
22
3,316
3,828
Accepted
Accepted
94.93
import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import defaultdict mod = 10**9+7 N = int(eval(input())) xy = [list(map(int, input().split())) for i in range(N)] xy.sort() Ans = N for i in range(N): for j in range(i+1, N): a, b = xy[j][0]-xy[i][0], xy[j][1]...
import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import defaultdict mod = 10**9+7 N = int(eval(input())) xy = [list(map(int, input().split())) for i in range(N)] cnt = defaultdict(int) for i in range(N): for j in range(i+1, N): a, b = xy[j][0]-xy[i][0], xy[j...
20
18
548
447
import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import defaultdict mod = 10**9 + 7 N = int(eval(input())) xy = [list(map(int, input().split())) for i in range(N)] xy.sort() Ans = N for i in range(N): for j in range(i + 1, N): a, b = xy[j][0] - xy[i][0], xy[j][1] - xy...
import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import defaultdict mod = 10**9 + 7 N = int(eval(input())) xy = [list(map(int, input().split())) for i in range(N)] cnt = defaultdict(int) for i in range(N): for j in range(i + 1, N): a, b = xy[j][0] - xy[i][0], xy[j][1]...
false
10
[ "-xy.sort()", "-Ans = N", "+cnt = defaultdict(int)", "- ans = N", "- for k in range(N):", "- for l in range(k + 1, N):", "- if xy[k][0] + a == xy[l][0] and xy[k][1] + b == xy[l][1]:", "- ans -= 1", "- Ans = min(Ans, ans)", "-print(A...
false
0.035902
0.035559
1.009662
[ "s868605651", "s644056775" ]
u156815136
p04033
python
s641821360
s013808695
40
17
5,272
2,940
Accepted
Accepted
57.5
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] -...
a,b = list(map(int,input().split())) if 0 <= a <= b: print('Positive') elif a <= b <= -1: if abs(a+b-1)%2 == 0: print('Positive') else: print('Negative') elif a <= 0 <= b: print('Zero')
45
10
960
221
from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j...
a, b = list(map(int, input().split())) if 0 <= a <= b: print("Positive") elif a <= b <= -1: if abs(a + b - 1) % 2 == 0: print("Positive") else: print("Negative") elif a <= 0 <= b: print("Zero")
false
77.777778
[ "-from statistics import median", "-", "-# import collections", "-# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]", "-from fractions import gcd", "-from itertools import combinations # (string,3) 3回", "-from collections import deque", "-from collections import defa...
false
0.08199
0.04433
1.849525
[ "s641821360", "s013808695" ]
u143100985
p03285
python
s357714719
s886033044
163
20
38,512
2,940
Accepted
Accepted
87.73
import sys n = int(eval(input())) for i in range(100): for j in range(100): if 7* i + 4 * j == n: print("Yes") sys.exit() print("No")
import sys n = int(eval(input())) i = 0 j = 0 while(i < 100): j = 0 while(j < 100): if 7* i + 4 * j == n: print("Yes") sys.exit() j+= 1 i+= 1 print("No")
9
15
174
226
import sys n = int(eval(input())) for i in range(100): for j in range(100): if 7 * i + 4 * j == n: print("Yes") sys.exit() print("No")
import sys n = int(eval(input())) i = 0 j = 0 while i < 100: j = 0 while j < 100: if 7 * i + 4 * j == n: print("Yes") sys.exit() j += 1 i += 1 print("No")
false
40
[ "-for i in range(100):", "- for j in range(100):", "+i = 0", "+j = 0", "+while i < 100:", "+ j = 0", "+ while j < 100:", "+ j += 1", "+ i += 1" ]
false
0.064265
0.04227
1.520353
[ "s357714719", "s886033044" ]
u179169725
p03854
python
s401648408
s597322143
213
31
47,984
10,448
Accepted
Accepted
85.45
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): ''' H is number of rows ''' ret = [] for _ in range(H): ...
mycode = r''' # distutils: language=c++ # cython: language_level=3 # cython: boundscheck=False # cython: wraparound=False # cython: infer_types=True # cython: cdivision=True # False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらい...
86
59
1,915
1,381
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(tupl...
mycode = r""" # distutils: language=c++ # cython: language_level=3 # cython: boundscheck=False # cython: wraparound=False # cython: infer_types=True # cython: cdivision=True # False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが...
false
31.395349
[ "+mycode = r\"\"\"", "+# distutils: language=c++", "+# cython: language_level=3", "+# cython: boundscheck=False", "+# cython: wraparound=False", "+# cython: infer_types=True", "+# cython: cdivision=True", "+# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZe...
false
0.037357
0.040431
0.923973
[ "s401648408", "s597322143" ]
u883040023
p03574
python
s252473087
s951840460
29
25
3,064
3,572
Accepted
Accepted
13.79
h,w = list(map(int,input().split())) s0 = "."*(w+2) S = [s0] for i in range(h): S.append("."+eval(input())+".") S.append(s0) for i in range(1,h+1): for j in range(1,w+1): if S[i][j] == ".": num = 0 for k in range(3): if S[i-1][j-1+k] == "#": ...
h,w = map(int,input().split()) masume = [list(["."] for _ in range(w+2))] for i in range(h): masume.append(list(["."]+list(input())+["."])) masume.append(list(["."] for _ in range(w+2))) dx = [-1,0,1,-1,1,-1,0,1] dy = [1,1,1,0,0,-1,-1,-1] for i in range(1,h+1): for j in range(1,w+1): ...
29
24
719
621
h, w = list(map(int, input().split())) s0 = "." * (w + 2) S = [s0] for i in range(h): S.append("." + eval(input()) + ".") S.append(s0) for i in range(1, h + 1): for j in range(1, w + 1): if S[i][j] == ".": num = 0 for k in range(3): if S[i - 1][j - 1 + k] == "#": ...
h, w = map(int, input().split()) masume = [list(["."] for _ in range(w + 2))] for i in range(h): masume.append(list(["."] + list(input()) + ["."])) masume.append(list(["."] for _ in range(w + 2))) dx = [-1, 0, 1, -1, 1, -1, 0, 1] dy = [1, 1, 1, 0, 0, -1, -1, -1] for i in range(1, h + 1): for j in range(1, w + 1...
false
17.241379
[ "-h, w = list(map(int, input().split()))", "-s0 = \".\" * (w + 2)", "-S = [s0]", "+h, w = map(int, input().split())", "+masume = [list([\".\"] for _ in range(w + 2))]", "- S.append(\".\" + eval(input()) + \".\")", "-S.append(s0)", "+ masume.append(list([\".\"] + list(input()) + [\".\"]))", "+m...
false
0.042051
0.042891
0.980415
[ "s252473087", "s951840460" ]
u571345655
p02410
python
s718381672
s710334895
30
20
4,564
4,560
Accepted
Accepted
33.33
# coding=utf-8 A = [] n, m = list(map(int, input().split())) for _ in range(n): A.append(list(map(int, input().split()))) # print A b = [] for _ in range(m): b.append(eval(input())) # print b Ab = [sum([A[i][j] * b[j] for j in range(m)]) for i in range(n)] # print Ab for x in Ab: print(x)
# coding=utf-8 n, m = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(n)] b = [eval(input()) for _ in range(m)] Ab = [sum([A[i][j] * b[j] for j in range(m)]) for i in range(n)] for x in Ab: print(x)
17
8
313
239
# coding=utf-8 A = [] n, m = list(map(int, input().split())) for _ in range(n): A.append(list(map(int, input().split()))) # print A b = [] for _ in range(m): b.append(eval(input())) # print b Ab = [sum([A[i][j] * b[j] for j in range(m)]) for i in range(n)] # print Ab for x in Ab: print(x)
# coding=utf-8 n, m = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(n)] b = [eval(input()) for _ in range(m)] Ab = [sum([A[i][j] * b[j] for j in range(m)]) for i in range(n)] for x in Ab: print(x)
false
52.941176
[ "-A = []", "-for _ in range(n):", "- A.append(list(map(int, input().split())))", "-# print A", "-b = []", "-for _ in range(m):", "- b.append(eval(input()))", "-# print b", "+A = [list(map(int, input().split())) for _ in range(n)]", "+b = [eval(input()) for _ in range(m)]", "-# print Ab" ]
false
0.042437
0.050637
0.838062
[ "s718381672", "s710334895" ]
u314050667
p03031
python
s090216324
s810695458
67
37
3,188
3,064
Accepted
Accepted
44.78
n, m = list(map(int,input().split())) k = [] s = [] for i in range(m): temp = list(map(int, input().split())) temp_k = temp[0] temp_s = temp[1:] k.append(temp_k) s.append(temp_s) p = list(map(int, input().split())) ans = 0 for i in range(2**n): on = bin(i)[2:].rjust(n,"0") ...
N, M = list(map(int, input().split())) K = [] S = [] for _ in range(M): tmp = list(map(int ,input().split())) K.append(tmp[0]) tmp.pop(0) S.append(tmp) P = list(map(int, input().split())) ans = 0 for i in range(2**N): flg = [0 for _ in range(M)] for j in range(N): if i & (1 << j): for k...
27
32
538
490
n, m = list(map(int, input().split())) k = [] s = [] for i in range(m): temp = list(map(int, input().split())) temp_k = temp[0] temp_s = temp[1:] k.append(temp_k) s.append(temp_s) p = list(map(int, input().split())) ans = 0 for i in range(2**n): on = bin(i)[2:].rjust(n, "0") cond = 0 for...
N, M = list(map(int, input().split())) K = [] S = [] for _ in range(M): tmp = list(map(int, input().split())) K.append(tmp[0]) tmp.pop(0) S.append(tmp) P = list(map(int, input().split())) ans = 0 for i in range(2**N): flg = [0 for _ in range(M)] for j in range(N): if i & (1 << j): ...
false
15.625
[ "-n, m = list(map(int, input().split()))", "-k = []", "-s = []", "-for i in range(m):", "- temp = list(map(int, input().split()))", "- temp_k = temp[0]", "- temp_s = temp[1:]", "- k.append(temp_k)", "- s.append(temp_s)", "-p = list(map(int, input().split()))", "+N, M = list(map(in...
false
0.044949
0.038611
1.164158
[ "s090216324", "s810695458" ]
u353895424
p02995
python
s202451580
s120073235
35
27
5,076
9,088
Accepted
Accepted
22.86
# n, k = map(int, input().split()) # h = [] # for i in range(n): # h.append(int(input())) # h.sort(reverse=True) # ans = [] # for i in range(k): # if i+k-1 >= n: # break # ans.append(h[i] - h[i+k-1]) # print(min(ans)) from fractions import gcd a, b, c, d = list(map(int, input().split...
import math def lcm(a): LCM = a[0] for i in range(1, len(a)): LCM = LCM * a[i] // math.gcd(LCM, a[i]) return LCM def f(k): return b//k - (a-1)//k a, b, c, d = list(map(int, input().split())) ALL = b - a + 1 ans = ALL - (f(c) + f(d) - f(lcm([c,d]))) print(ans)
38
14
692
292
# n, k = map(int, input().split()) # h = [] # for i in range(n): # h.append(int(input())) # h.sort(reverse=True) # ans = [] # for i in range(k): # if i+k-1 >= n: # break # ans.append(h[i] - h[i+k-1]) # print(min(ans)) from fractions import gcd a, b, c, d = list(map(int, input().split())) def lcm(...
import math def lcm(a): LCM = a[0] for i in range(1, len(a)): LCM = LCM * a[i] // math.gcd(LCM, a[i]) return LCM def f(k): return b // k - (a - 1) // k a, b, c, d = list(map(int, input().split())) ALL = b - a + 1 ans = ALL - (f(c) + f(d) - f(lcm([c, d]))) print(ans)
false
63.157895
[ "-# n, k = map(int, input().split())", "-# h = []", "-# for i in range(n):", "-# h.append(int(input()))", "-# h.sort(reverse=True)", "-# ans = []", "-# for i in range(k):", "-# if i+k-1 >= n:", "-# break", "-# ans.append(h[i] - h[i+k-1])", "-# print(min(ans))", "-from fract...
false
0.049289
0.042604
1.15693
[ "s202451580", "s120073235" ]
u777283665
p03673
python
s589250392
s566739592
223
172
25,540
26,180
Accepted
Accepted
22.87
from collections import deque n = int(eval(input())) a = deque(list(map(int, input().split()))) b = deque() if n % 2 == 1: for i in range(n): if i % 2 == 0: b.appendleft(a.popleft()) else: b.append(a.popleft()) else: for i in range(n): if i % 2 == ...
n = int(eval(input())) a = list(map(int, input().split())) a_odd = a[0::2] a_even = a[1::2] if n % 2 == 0: print((*(a_even[::-1] + a_odd))) else: print((*(a_odd[::-1] + a_even)))
20
8
412
183
from collections import deque n = int(eval(input())) a = deque(list(map(int, input().split()))) b = deque() if n % 2 == 1: for i in range(n): if i % 2 == 0: b.appendleft(a.popleft()) else: b.append(a.popleft()) else: for i in range(n): if i % 2 == 0: ...
n = int(eval(input())) a = list(map(int, input().split())) a_odd = a[0::2] a_even = a[1::2] if n % 2 == 0: print((*(a_even[::-1] + a_odd))) else: print((*(a_odd[::-1] + a_even)))
false
60
[ "-from collections import deque", "-", "-a = deque(list(map(int, input().split())))", "-b = deque()", "-if n % 2 == 1:", "- for i in range(n):", "- if i % 2 == 0:", "- b.appendleft(a.popleft())", "- else:", "- b.append(a.popleft())", "+a = list(map(int, inp...
false
0.086655
0.039162
2.212748
[ "s589250392", "s566739592" ]
u476386869
p02595
python
s362171400
s673684900
467
288
9,632
9,624
Accepted
Accepted
38.33
def main(): n,d = list(map(int, input().split())) res = 0 for _ in range(n): x, y = list(map(int, input().split())) if (x**2+y**2)**.5 <= d: res += 1 print(res) main()
import sys input = sys.stdin.readline def main(): n,d = list(map(int, input().split())) res = 0 for _ in range(n): x, y = list(map(int, input().split())) if (x**2+y**2)**.5 <= d: res += 1 print(res) main()
9
12
207
249
def main(): n, d = list(map(int, input().split())) res = 0 for _ in range(n): x, y = list(map(int, input().split())) if (x**2 + y**2) ** 0.5 <= d: res += 1 print(res) main()
import sys input = sys.stdin.readline def main(): n, d = list(map(int, input().split())) res = 0 for _ in range(n): x, y = list(map(int, input().split())) if (x**2 + y**2) ** 0.5 <= d: res += 1 print(res) main()
false
25
[ "+import sys", "+", "+input = sys.stdin.readline", "+", "+" ]
false
0.034392
0.039501
0.870665
[ "s362171400", "s673684900" ]
u726615467
p03011
python
s476903675
s162299402
19
17
2,940
2,940
Accepted
Accepted
10.53
A = list(map(int, input().split())) print((sum(sorted(A)[:2])))
P, Q, R = list(map(int, input().split())) ans = min((P + Q, Q + R, R + P)) print(ans)
2
4
62
83
A = list(map(int, input().split())) print((sum(sorted(A)[:2])))
P, Q, R = list(map(int, input().split())) ans = min((P + Q, Q + R, R + P)) print(ans)
false
50
[ "-A = list(map(int, input().split()))", "-print((sum(sorted(A)[:2])))", "+P, Q, R = list(map(int, input().split()))", "+ans = min((P + Q, Q + R, R + P))", "+print(ans)" ]
false
0.047341
0.048196
0.982252
[ "s476903675", "s162299402" ]
u312025627
p02989
python
s081266465
s843339335
215
79
52,780
14,396
Accepted
Accepted
63.26
N = int(eval(input())) d = [int(i) for i in input().split()] d.sort() print((d[N//2] - d[(N//2) - 1]))
def main(): N = int(eval(input())) D = [int(i) for i in input().split()] D.sort() print((D[N//2] - D[N//2 - 1])) if __name__ == '__main__': main()
6
9
101
169
N = int(eval(input())) d = [int(i) for i in input().split()] d.sort() print((d[N // 2] - d[(N // 2) - 1]))
def main(): N = int(eval(input())) D = [int(i) for i in input().split()] D.sort() print((D[N // 2] - D[N // 2 - 1])) if __name__ == "__main__": main()
false
33.333333
[ "-N = int(eval(input()))", "-d = [int(i) for i in input().split()]", "-d.sort()", "-print((d[N // 2] - d[(N // 2) - 1]))", "+def main():", "+ N = int(eval(input()))", "+ D = [int(i) for i in input().split()]", "+ D.sort()", "+ print((D[N // 2] - D[N // 2 - 1]))", "+", "+", "+if __n...
false
0.149036
0.077568
1.921354
[ "s081266465", "s843339335" ]
u803848678
p03734
python
s429322918
s043185881
1,492
296
41,376
3,064
Accepted
Accepted
80.16
n, w = list(map(int, input().split())) dp = [[[-1]*4*n for j in range(n+1)] for i in range(n+1)] dp[0][0][0] = 0 w1 = None for i in range(n): ws, vs = list(map(int, input().split())) if i == 0: w1 = ws ws -= w1 for j in range(i+2): for k in range(4*n): if j-1 >= ...
n,w = list(map(int, input().split())) w4 = [[] for i in range(4)] w1 = None for i in range(n): ws, vs = list(map(int,input().split())) if i == 0: w1 = ws ws -= w1 w4[ws].append(vs) for i in range(4): w4[i].sort(reverse=True) tmp = [0] for j in w4[i]: tmp.append...
23
24
626
625
n, w = list(map(int, input().split())) dp = [[[-1] * 4 * n for j in range(n + 1)] for i in range(n + 1)] dp[0][0][0] = 0 w1 = None for i in range(n): ws, vs = list(map(int, input().split())) if i == 0: w1 = ws ws -= w1 for j in range(i + 2): for k in range(4 * n): if j - 1 >=...
n, w = list(map(int, input().split())) w4 = [[] for i in range(4)] w1 = None for i in range(n): ws, vs = list(map(int, input().split())) if i == 0: w1 = ws ws -= w1 w4[ws].append(vs) for i in range(4): w4[i].sort(reverse=True) tmp = [0] for j in w4[i]: tmp.append(tmp[-1] + j)...
false
4.166667
[ "-dp = [[[-1] * 4 * n for j in range(n + 1)] for i in range(n + 1)]", "-dp[0][0][0] = 0", "+w4 = [[] for i in range(4)]", "- for j in range(i + 2):", "- for k in range(4 * n):", "- if j - 1 >= 0 and k - ws >= 0 and dp[i][j - 1][k - ws] >= 0:", "- dp[i + 1][j][k] = max...
false
0.04531
0.037488
1.208665
[ "s429322918", "s043185881" ]
u680851063
p02947
python
s788333443
s512876992
542
440
25,420
11,408
Accepted
Accepted
18.82
# n = int(eval(input())) s = [] for _ in range(n): #s.append(list(input())) # !!! #s.append(sorted(list(input()))) # !!! s.append(sorted(eval(input()))) # !!! #s += [''.join(sorted(input()))] #''.join(sorted((sorted(input())) s = sorted(s) #print(s) a = [] x = 1 for i in range(1,n): ...
# n = int(eval(input())) s = [] for _ in range(n): #s.append(list(input())) # !!! #s.append(sorted(list(input()))) # !!! #s.append(sorted(input())) # !!! s += [''.join(sorted(eval(input())))] #''.join(sorted((sorted(input())) s = sorted(s) #print(s) a = [] x = 1 for i in range(1,n): ...
29
29
488
488
# n = int(eval(input())) s = [] for _ in range(n): # s.append(list(input())) # !!! # s.append(sorted(list(input()))) # !!! s.append(sorted(eval(input()))) # !!! # s += [''.join(sorted(input()))] #''.join(sorted((sorted(input())) s = sorted(s) # print(s) a = [] x = 1 for i in range(1, n): if s[i...
# n = int(eval(input())) s = [] for _ in range(n): # s.append(list(input())) # !!! # s.append(sorted(list(input()))) # !!! # s.append(sorted(input())) # !!! s += ["".join(sorted(eval(input())))] #''.join(sorted((sorted(input())) s = sorted(s) # print(s) a = [] x = 1 for i in range(1, n): if s[i]...
false
0
[ "- s.append(sorted(eval(input()))) # !!!", "- # s += [''.join(sorted(input()))]", "+ # s.append(sorted(input())) # !!!", "+ s += [\"\".join(sorted(eval(input())))]" ]
false
0.110826
0.083606
1.325566
[ "s788333443", "s512876992" ]
u076917070
p02837
python
s507758581
s870166352
263
242
3,064
3,064
Accepted
Accepted
7.98
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = [[set(), set()] for _ in range(N)] for i in range(N): m = int(eval(input())) for j in range(m): x, y = list(map(int, input().split())) A[i][y].add(x) ans = 0 for i in...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = [[set(), set()] for _ in range(N)] for i in range(N): m = int(eval(input())) for j in range(m): x, y = list(map(int, input().split())) A[i][y].add(x) ans = 0 for i in...
31
30
695
672
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = [[set(), set()] for _ in range(N)] for i in range(N): m = int(eval(input())) for j in range(m): x, y = list(map(int, input().split())) A[i][y].add(x) ans = 0 for i in range(1 << N)...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = [[set(), set()] for _ in range(N)] for i in range(N): m = int(eval(input())) for j in range(m): x, y = list(map(int, input().split())) A[i][y].add(x) ans = 0 for i in range(1 << N)...
false
3.225806
[ "+ h |= A[j][1]", "+ u |= A[j][0]", "- for k in list(h):", "- h |= A[k - 1][1]", "- u |= A[k - 1][0]" ]
false
0.047341
0.047245
1.002017
[ "s507758581", "s870166352" ]
u883048396
p03255
python
s346954141
s888136640
719
644
27,244
27,244
Accepted
Accepted
10.43
iN ,iX = [int(x) for x in input().split()] aCum = [0] for x in input().split(): aCum += [aCum[-1] + int(x)] def fCeil(iT,iR): return -1 * iT // iR * -1 def fCalcCost(iN,iX,aCum,iK): iCost = (iN + iK ) * iX + 5 * aCum[iN] for i in range(2,fCeil(iN,iK) ): iCost += 2 * aCum[iN - i * i...
iN ,iX = [int(x) for x in input().split()] aCum = [0] for x in input().split(): aCum += [aCum[-1] + int(x)] def fCeil(iT,iR): return -1 * iT // iR * -1 def fCalcCost(iN,iX,aCum,iK): iCost = (iN + iK ) * iX + 5 * aCum[iN] for i in range(2,fCeil(iN,iK) ): iCost += 2 * aCum[iN - i * i...
36
35
1,109
1,055
iN, iX = [int(x) for x in input().split()] aCum = [0] for x in input().split(): aCum += [aCum[-1] + int(x)] def fCeil(iT, iR): return -1 * iT // iR * -1 def fCalcCost(iN, iX, aCum, iK): iCost = (iN + iK) * iX + 5 * aCum[iN] for i in range(2, fCeil(iN, iK)): iCost += 2 * aCum[iN - i * iK] ...
iN, iX = [int(x) for x in input().split()] aCum = [0] for x in input().split(): aCum += [aCum[-1] + int(x)] def fCeil(iT, iR): return -1 * iT // iR * -1 def fCalcCost(iN, iX, aCum, iK): iCost = (iN + iK) * iX + 5 * aCum[iN] for i in range(2, fCeil(iN, iK)): iCost += 2 * aCum[iN - i * iK] ...
false
2.777778
[ "+def fSearchLowCost(iL, iLCost, iU, iUCost, iN, iX, aCum):", "+ if iU - iL <= iX:", "+ iTotalCost = min(iLCost, iUCost)", "+ for iK in range(iL + 1, iU):", "+ iTotalCost = min(iTotalCost, fCalcCost(iN, iX, aCum, iK))", "+ return iTotalCost", "+ else:", "+ ...
false
0.054711
0.132634
0.412497
[ "s346954141", "s888136640" ]
u566428756
p03475
python
s501567482
s987986122
2,951
114
3,316
3,188
Accepted
Accepted
96.14
N=int(eval(input())) CSF=[list(map(int,input().split())) for _ in range(1,N)] for i,csf in enumerate(CSF): c,s,f=csf[0],csf[1],csf[2] ans=c+s for j in range(i+1,N-1): csf_=CSF[j] c_,s_,f_=csf_[0],csf_[1],csf_[2] while True: if (ans>=s_) and (ans%f_==0): ...
N=int(eval(input())) CSF=[list(map(int,input().split())) for _ in range(1,N)] for i,csf in enumerate(CSF): c,s,f=csf[0],csf[1],csf[2] ans=c+s for j in range(i+1,N-1): csf_=CSF[j] c_,s_,f_=csf_[0],csf_[1],csf_[2] if ans<s_: ans=s_ elif ans%f_!=0: ...
16
16
400
381
N = int(eval(input())) CSF = [list(map(int, input().split())) for _ in range(1, N)] for i, csf in enumerate(CSF): c, s, f = csf[0], csf[1], csf[2] ans = c + s for j in range(i + 1, N - 1): csf_ = CSF[j] c_, s_, f_ = csf_[0], csf_[1], csf_[2] while True: if (ans >= s_) and...
N = int(eval(input())) CSF = [list(map(int, input().split())) for _ in range(1, N)] for i, csf in enumerate(CSF): c, s, f = csf[0], csf[1], csf[2] ans = c + s for j in range(i + 1, N - 1): csf_ = CSF[j] c_, s_, f_ = csf_[0], csf_[1], csf_[2] if ans < s_: ans = s_ ...
false
0
[ "- while True:", "- if (ans >= s_) and (ans % f_ == 0):", "- ans += c_", "- break", "- ans += 1", "+ if ans < s_:", "+ ans = s_", "+ elif ans % f_ != 0:", "+ ans = ans + f_ - ans % f_", "+ ans += ...
false
0.077258
0.036291
2.128842
[ "s501567482", "s987986122" ]
u102461423
p02589
python
s940921575
s934413036
815
457
381,348
301,108
Accepted
Accepted
43.93
import sys import numpy as np import numba from numba import njit, b1, i4, i8, f8 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8[:], ), cache=True) def main(S): S = S.copy() l_ind = np.where(S == -1)[0][:-1] + 1 r_ind = np.wh...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(S): S = S.copy() l_ind = np.where(S == -1)[0][:-1] + 1 r_ind = np.where(S == -1)[0][1:] # 逆順にしておく N = len(l_ind) for i in range(N): ...
58
71
1,482
1,772
import sys import numpy as np import numba from numba import njit, b1, i4, i8, f8 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8[:],), cache=True) def main(S): S = S.copy() l_ind = np.where(S == -1)[0][:-1] + 1 r_ind = np.where(S == -1)[...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(S): S = S.copy() l_ind = np.where(S == -1)[0][:-1] + 1 r_ind = np.where(S == -1)[0][1:] # 逆順にしておく N = len(l_ind) for i in range(N): S[l_ind[i...
false
18.309859
[ "-import numba", "-from numba import njit, b1, i4, i8, f8", "-@njit((i8[:],), cache=True)", "+if sys.argv[-1] == \"ONLINE_JUDGE\":", "+ import numba", "+ from numba import njit, b1, i4, i8, f8", "+ import numba", "+ from numba.pycc import CC", "+", "+ cc = CC(\"my_module\")", "+",...
false
0.269551
0.217133
1.241408
[ "s940921575", "s934413036" ]
u653837719
p02947
python
s395398634
s856550021
1,757
1,145
98,392
130,776
Accepted
Accepted
34.83
n = int(eval(input())) s = sorted([sorted(list(eval(input()))) for _ in range(n)]) res = 0 cnt = 1 for i in range(n-1): if s[i] == s[i+1]: res += cnt cnt += 1 else: cnt = 1 print(res)
n = int(eval(input())) s = [sorted(list(eval(input()))) for _ in range(n)] res = 0 d = dict() for list_ in s: str_ = str(list_) if str_ in d: d[str_] += 1 res += d[str_] - 1 else: d[str_] = 1 print(res)
13
14
217
241
n = int(eval(input())) s = sorted([sorted(list(eval(input()))) for _ in range(n)]) res = 0 cnt = 1 for i in range(n - 1): if s[i] == s[i + 1]: res += cnt cnt += 1 else: cnt = 1 print(res)
n = int(eval(input())) s = [sorted(list(eval(input()))) for _ in range(n)] res = 0 d = dict() for list_ in s: str_ = str(list_) if str_ in d: d[str_] += 1 res += d[str_] - 1 else: d[str_] = 1 print(res)
false
7.142857
[ "-s = sorted([sorted(list(eval(input()))) for _ in range(n)])", "+s = [sorted(list(eval(input()))) for _ in range(n)]", "-cnt = 1", "-for i in range(n - 1):", "- if s[i] == s[i + 1]:", "- res += cnt", "- cnt += 1", "+d = dict()", "+for list_ in s:", "+ str_ = str(list_)", "+ ...
false
0.033932
0.03624
0.936302
[ "s395398634", "s856550021" ]
u692336506
p03478
python
s777673676
s738324430
36
31
9,064
9,052
Accepted
Accepted
13.89
def calc_sum_digits(n): return sum(int(x) for x in str(n)) N, A, B = list(map(int, input().split())) print((sum(n if A <= calc_sum_digits(n) <= B else 0 for n in range(1, N+1))))
def calc_sum_digits(n): sumdigit = 0 while n > 0: sumdigit += n % 10 n //= 10 return sumdigit N, A, B = list(map(int, input().split())) result = 0 for n in range(1, N+1): if A <= calc_sum_digits(n) <= B: result += n print(result)
5
13
179
276
def calc_sum_digits(n): return sum(int(x) for x in str(n)) N, A, B = list(map(int, input().split())) print((sum(n if A <= calc_sum_digits(n) <= B else 0 for n in range(1, N + 1))))
def calc_sum_digits(n): sumdigit = 0 while n > 0: sumdigit += n % 10 n //= 10 return sumdigit N, A, B = list(map(int, input().split())) result = 0 for n in range(1, N + 1): if A <= calc_sum_digits(n) <= B: result += n print(result)
false
61.538462
[ "- return sum(int(x) for x in str(n))", "+ sumdigit = 0", "+ while n > 0:", "+ sumdigit += n % 10", "+ n //= 10", "+ return sumdigit", "-print((sum(n if A <= calc_sum_digits(n) <= B else 0 for n in range(1, N + 1))))", "+result = 0", "+for n in range(1, N + 1):", "+ if...
false
0.038544
0.046144
0.835301
[ "s777673676", "s738324430" ]
u814781830
p02939
python
s321124909
s525931192
118
88
13,856
4,840
Accepted
Accepted
25.42
S = list(eval(input())) N = len(S) ret = 0 pre = "" dpl = [0] * (N+1) dpr = [0] * (N+1) tmp = "" for i in range(1,N+1): tmp += S[i-1] if tmp == pre: dpl[i] = dpl[i-1] else: pre, tmp = tmp, "" dpl[i] = dpl[i-1] + 1 print((dpl[N]))
S = list(eval(input())) N = len(S) ret = 0 pre = "" tmp = "" for i in range(1,N+1): tmp += S[i-1] if tmp != pre: pre, tmp = tmp, "" ret += 1 print(ret)
16
12
273
182
S = list(eval(input())) N = len(S) ret = 0 pre = "" dpl = [0] * (N + 1) dpr = [0] * (N + 1) tmp = "" for i in range(1, N + 1): tmp += S[i - 1] if tmp == pre: dpl[i] = dpl[i - 1] else: pre, tmp = tmp, "" dpl[i] = dpl[i - 1] + 1 print((dpl[N]))
S = list(eval(input())) N = len(S) ret = 0 pre = "" tmp = "" for i in range(1, N + 1): tmp += S[i - 1] if tmp != pre: pre, tmp = tmp, "" ret += 1 print(ret)
false
25
[ "-dpl = [0] * (N + 1)", "-dpr = [0] * (N + 1)", "- if tmp == pre:", "- dpl[i] = dpl[i - 1]", "- else:", "+ if tmp != pre:", "- dpl[i] = dpl[i - 1] + 1", "-print((dpl[N]))", "+ ret += 1", "+print(ret)" ]
false
0.038396
0.037096
1.035029
[ "s321124909", "s525931192" ]
u729133443
p03525
python
s146738898
s408494697
175
17
38,512
3,060
Accepted
Accepted
90.29
n,t=open(0) n=int(n)+1 d=[t if i%2else(24-t)%24for i,t in enumerate([0]+sorted(map(int,t.split())))] print((min(abs(d[i]-d[j])for i in range(n)for j in range(i+1,n))))
_,d=open(0);s=sorted;l=s((24-x,x)[i%2]for i,x in enumerate(s(list(map(int,d.split())))));print((min(j-i for i,j in zip([0]+l,l+[24]))))
4
1
168
127
n, t = open(0) n = int(n) + 1 d = [ t if i % 2 else (24 - t) % 24 for i, t in enumerate([0] + sorted(map(int, t.split()))) ] print((min(abs(d[i] - d[j]) for i in range(n) for j in range(i + 1, n))))
_, d = open(0) s = sorted l = s((24 - x, x)[i % 2] for i, x in enumerate(s(list(map(int, d.split()))))) print((min(j - i for i, j in zip([0] + l, l + [24]))))
false
75
[ "-n, t = open(0)", "-n = int(n) + 1", "-d = [", "- t if i % 2 else (24 - t) % 24", "- for i, t in enumerate([0] + sorted(map(int, t.split())))", "-]", "-print((min(abs(d[i] - d[j]) for i in range(n) for j in range(i + 1, n))))", "+_, d = open(0)", "+s = sorted", "+l = s((24 - x, x)[i % 2] fo...
false
0.042783
0.032905
1.300189
[ "s146738898", "s408494697" ]
u033606236
p03325
python
s376157027
s828326345
179
81
40,560
4,148
Accepted
Accepted
54.75
n = int(eval(input())) ans = 0 for i in map(int,input().split()): a = i while a % 2 == 0: ans += 1 a = a // 2 print(ans)
n = int(eval(input())) ary = list(map(int,input().split())) ans = 0 for i in range(len(ary)): a = ary[i] if a % 2 == 0: while a % 2 == 0: ans += 1 a = a // 2 print(ans)
8
10
145
211
n = int(eval(input())) ans = 0 for i in map(int, input().split()): a = i while a % 2 == 0: ans += 1 a = a // 2 print(ans)
n = int(eval(input())) ary = list(map(int, input().split())) ans = 0 for i in range(len(ary)): a = ary[i] if a % 2 == 0: while a % 2 == 0: ans += 1 a = a // 2 print(ans)
false
20
[ "+ary = list(map(int, input().split()))", "-for i in map(int, input().split()):", "- a = i", "- while a % 2 == 0:", "- ans += 1", "- a = a // 2", "+for i in range(len(ary)):", "+ a = ary[i]", "+ if a % 2 == 0:", "+ while a % 2 == 0:", "+ ans += 1", "...
false
0.127022
0.109697
1.157927
[ "s376157027", "s828326345" ]
u077291787
p03037
python
s301811823
s384885358
383
222
28,100
28,100
Accepted
Accepted
42.04
# ABC127C - Prison # l-max < i < r-min -> count i n, m = list(map(int, input().rstrip().split())) lst = [list(map(int, input().rstrip().split())) for _ in range(m)] l, r = lst[0][0], lst[0][1] for i in lst[1:]: l = max(l, i[0]) r = min(r, i[1]) print((max(0, r - l + 1)))
# ABC127C - Prison # l-max < i < r-min -> max(0, r - l + 1) import sys input = sys.stdin.readline n, m = list(map(int, input().rstrip().split())) lst = [list(map(int, input().rstrip().split())) for _ in range(m)] l, r = lst[0][0], lst[0][1] for i in lst[1:]: l = max(l, i[0]) r = min(r, i[1]) print((...
9
12
285
337
# ABC127C - Prison # l-max < i < r-min -> count i n, m = list(map(int, input().rstrip().split())) lst = [list(map(int, input().rstrip().split())) for _ in range(m)] l, r = lst[0][0], lst[0][1] for i in lst[1:]: l = max(l, i[0]) r = min(r, i[1]) print((max(0, r - l + 1)))
# ABC127C - Prison # l-max < i < r-min -> max(0, r - l + 1) import sys input = sys.stdin.readline n, m = list(map(int, input().rstrip().split())) lst = [list(map(int, input().rstrip().split())) for _ in range(m)] l, r = lst[0][0], lst[0][1] for i in lst[1:]: l = max(l, i[0]) r = min(r, i[1]) print((max(0, r - ...
false
25
[ "-# l-max < i < r-min -> count i", "+# l-max < i < r-min -> max(0, r - l + 1)", "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.044534
0.079348
0.561257
[ "s301811823", "s384885358" ]
u094999522
p02732
python
s907524098
s356209678
376
223
66,216
116,208
Accepted
Accepted
40.69
#!/usr/bin/env python3 from collections import Counter from scipy.special import comb _, *a = list(map(int, open(0).read().split())) c = Counter(a) s = sum(comb(i, 2, exact=True) for i in list(c.values())) for i in a: print((s - c[i] + 1))
#!/usr/bin/env python3 from collections import Counter _, *a = list(map(int, open(0).read().split())) c = Counter(a) s = sum(i * (i - 1) // 2 for i in list(c.values())) for i in a: print((s - c[i] + 1))
10
8
241
201
#!/usr/bin/env python3 from collections import Counter from scipy.special import comb _, *a = list(map(int, open(0).read().split())) c = Counter(a) s = sum(comb(i, 2, exact=True) for i in list(c.values())) for i in a: print((s - c[i] + 1))
#!/usr/bin/env python3 from collections import Counter _, *a = list(map(int, open(0).read().split())) c = Counter(a) s = sum(i * (i - 1) // 2 for i in list(c.values())) for i in a: print((s - c[i] + 1))
false
20
[ "-from scipy.special import comb", "-s = sum(comb(i, 2, exact=True) for i in list(c.values()))", "+s = sum(i * (i - 1) // 2 for i in list(c.values()))" ]
false
0.248567
0.039767
6.250562
[ "s907524098", "s356209678" ]
u860002137
p03013
python
s228912402
s407133606
195
153
8,436
18,984
Accepted
Accepted
21.54
N, M = list(map(int, input().split())) A = [None]*M is_broken = [False] * (N+1) for i in range(M): A[i] = int(eval(input())) is_broken[A[i]] = True dp = [0] * (N+1) dp[0] = 1 for i in range(1, N+1): if is_broken[i]: continue dp[i] = (dp[i-1] + dp[i-2]) % (10**9 + 7) print(...
n, m = list(map(int, input().split())) arr = set([int(eval(input())) for _ in range(m)]) MOD = 10**9 + 7 dp = [0] * (n + 1) dp[0] = 1 for i in range(1, n + 1): if not i in arr: if i == 1: dp[i] = dp[i - 1] % MOD else: dp[i] = (dp[i - 1] + dp[i - 2]) % MOD p...
18
16
315
320
N, M = list(map(int, input().split())) A = [None] * M is_broken = [False] * (N + 1) for i in range(M): A[i] = int(eval(input())) is_broken[A[i]] = True dp = [0] * (N + 1) dp[0] = 1 for i in range(1, N + 1): if is_broken[i]: continue dp[i] = (dp[i - 1] + dp[i - 2]) % (10**9 + 7) print((dp[-1]))
n, m = list(map(int, input().split())) arr = set([int(eval(input())) for _ in range(m)]) MOD = 10**9 + 7 dp = [0] * (n + 1) dp[0] = 1 for i in range(1, n + 1): if not i in arr: if i == 1: dp[i] = dp[i - 1] % MOD else: dp[i] = (dp[i - 1] + dp[i - 2]) % MOD print((dp[-1]))
false
11.111111
[ "-N, M = list(map(int, input().split()))", "-A = [None] * M", "-is_broken = [False] * (N + 1)", "-for i in range(M):", "- A[i] = int(eval(input()))", "- is_broken[A[i]] = True", "-dp = [0] * (N + 1)", "+n, m = list(map(int, input().split()))", "+arr = set([int(eval(input())) for _ in range(m)]...
false
0.044435
0.045703
0.972252
[ "s228912402", "s407133606" ]
u131406572
p03162
python
s017777652
s281048522
634
266
66,008
103,000
Accepted
Accepted
58.04
n=int(eval(input())) a=[list(map(int,input().split())) for i in range(n)] dpa=[0]*n dpb=[0]*n dpc=[0]*n dpa[0]=a[0][0] dpb[0]=a[0][1] dpc[0]=a[0][2] for i in range(1,n): dpa[i]=max(dpb[i-1]+a[i][0],dpc[i-1]+a[i][0]) dpb[i]=max(dpa[i-1]+a[i][1],dpc[i-1]+a[i][1]) dpc[i]=max(dpb[i-1]+a[i][2],dpa[i-1...
n =int(eval(input())) l = [list(map(int,input().split())) for i in range(n)] dp = [[0 for i in range(3)] for j in range(n)] for i in range(n): if i==0: dp[0]=l[0] else: dp[i][0]=max(dp[i][0],dp[i-1][1]+l[i][0],dp[i-1][2]+l[i][0]) dp[i][1]=max(dp[i][1],dp[i-1][0]+l[i][1],dp[i-1][2]+l[i][1]) ...
14
13
382
399
n = int(eval(input())) a = [list(map(int, input().split())) for i in range(n)] dpa = [0] * n dpb = [0] * n dpc = [0] * n dpa[0] = a[0][0] dpb[0] = a[0][1] dpc[0] = a[0][2] for i in range(1, n): dpa[i] = max(dpb[i - 1] + a[i][0], dpc[i - 1] + a[i][0]) dpb[i] = max(dpa[i - 1] + a[i][1], dpc[i - 1] + a[i][1]) ...
n = int(eval(input())) l = [list(map(int, input().split())) for i in range(n)] dp = [[0 for i in range(3)] for j in range(n)] for i in range(n): if i == 0: dp[0] = l[0] else: dp[i][0] = max(dp[i][0], dp[i - 1][1] + l[i][0], dp[i - 1][2] + l[i][0]) dp[i][1] = max(dp[i][1], dp[i - 1][0] + ...
false
7.142857
[ "-a = [list(map(int, input().split())) for i in range(n)]", "-dpa = [0] * n", "-dpb = [0] * n", "-dpc = [0] * n", "-dpa[0] = a[0][0]", "-dpb[0] = a[0][1]", "-dpc[0] = a[0][2]", "-for i in range(1, n):", "- dpa[i] = max(dpb[i - 1] + a[i][0], dpc[i - 1] + a[i][0])", "- dpb[i] = max(dpa[i - 1] ...
false
0.049404
0.046696
1.057982
[ "s017777652", "s281048522" ]
u347600233
p02916
python
s299576237
s214822344
31
25
9,180
9,068
Accepted
Accepted
19.35
n = int(eval(input())) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] a_sp = [c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1] print((sum(b + a_sp)))
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) print((sum(b + [c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1])))
6
5
223
204
n = int(eval(input())) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] a_sp = [c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1] print((sum(b + a_sp)))
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) print((sum(b + [c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1])))
false
16.666667
[ "-a = [int(i) for i in input().split()]", "-b = [int(i) for i in input().split()]", "-c = [int(i) for i in input().split()]", "-a_sp = [c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1]", "-print((sum(b + a_sp)))", "+a = list(map(int, input().split()))", "+b = list(map(int, input().split()))", ...
false
0.045601
0.039485
1.15488
[ "s299576237", "s214822344" ]
u680851063
p02659
python
s018599722
s686263661
26
23
10,064
9,132
Accepted
Accepted
11.54
from decimal import Decimal a, b = list(map(str,input().split())) #print(a,b) print((int(Decimal(a) * Decimal(b))))
a, b = list(map(str, input().split())) b = b[:-3] + b[-2:] print((int(a)*int(b) // 100))
6
3
114
82
from decimal import Decimal a, b = list(map(str, input().split())) # print(a,b) print((int(Decimal(a) * Decimal(b))))
a, b = list(map(str, input().split())) b = b[:-3] + b[-2:] print((int(a) * int(b) // 100))
false
50
[ "-from decimal import Decimal", "-", "-# print(a,b)", "-print((int(Decimal(a) * Decimal(b))))", "+b = b[:-3] + b[-2:]", "+print((int(a) * int(b) // 100))" ]
false
0.109014
0.108154
1.007953
[ "s018599722", "s686263661" ]
u792670114
p02991
python
s944748454
s591967848
564
517
28,212
28,212
Accepted
Accepted
8.33
N, M = list(map(int, input().split())) a = [[] for i in range(N+1)] for i in range(M): u, v = list(map(int, input().split())) a[u].append(v) #print(a) S, T = list(map(int, input().split())) def main(): c = [S] m = [[False, False, False] for i in range(N+1)] for count in range(1, 3*N+1): c2 = ...
N, M = list(map(int, input().split())) a = [[] for i in range(N+1)] for i in range(M): u, v = list(map(int, input().split())) a[u].append(v) #print(a) S, T = list(map(int, input().split())) def main(): c = [S] m = [[False, False, False] for i in range(N+1)] for count in range(1, 3*N+1): c2 =...
24
23
575
539
N, M = list(map(int, input().split())) a = [[] for i in range(N + 1)] for i in range(M): u, v = list(map(int, input().split())) a[u].append(v) # print(a) S, T = list(map(int, input().split())) def main(): c = [S] m = [[False, False, False] for i in range(N + 1)] for count in range(1, 3 * N + 1): ...
N, M = list(map(int, input().split())) a = [[] for i in range(N + 1)] for i in range(M): u, v = list(map(int, input().split())) a[u].append(v) # print(a) S, T = list(map(int, input().split())) def main(): c = [S] m = [[False, False, False] for i in range(N + 1)] for count in range(1, 3 * N + 1): ...
false
4.166667
[ "- m[u][count % 3] = True", "- if not (m[v][(count + 1) % 3]):", "- m[v][(count + 1) % 3] = True", "+ if not (m[v][count % 3]):", "+ m[v][count % 3] = True" ]
false
0.034026
0.036754
0.925785
[ "s944748454", "s591967848" ]
u408260374
p02361
python
s672125182
s191095955
3,590
2,460
143,708
94,944
Accepted
Accepted
31.48
import heapq class Edge: def __init__(self, dst, weight): self.dst, self.weight = dst, weight def __lt__(self, e): return self.weight > e.weight class Graph: def __init__(self, V): self.V = V self.E = [[] for _ in range(V)] def add_edge(self, src, ds...
from heapq import heapify, heappush, heappop from collections import Counter, defaultdict, deque, OrderedDict from sys import setrecursionlimit as setreclim from sys import maxsize from bisect import bisect_left, bisect, insort_left, insort from math import ceil, log, factorial, hypot, pi from fractions import gc...
76
54
2,161
1,901
import heapq class Edge: def __init__(self, dst, weight): self.dst, self.weight = dst, weight def __lt__(self, e): return self.weight > e.weight class Graph: def __init__(self, V): self.V = V self.E = [[] for _ in range(V)] def add_edge(self, src, dst, weight): ...
from heapq import heapify, heappush, heappop from collections import Counter, defaultdict, deque, OrderedDict from sys import setrecursionlimit as setreclim from sys import maxsize from bisect import bisect_left, bisect, insort_left, insort from math import ceil, log, factorial, hypot, pi from fractions import gcd from...
false
28.947368
[ "-import heapq", "+from heapq import heapify, heappush, heappop", "+from collections import Counter, defaultdict, deque, OrderedDict", "+from sys import setrecursionlimit as setreclim", "+from sys import maxsize", "+from bisect import bisect_left, bisect, insort_left, insort", "+from math import ceil, l...
false
0.041001
0.058027
0.706588
[ "s672125182", "s191095955" ]
u340781749
p02770
python
s351778299
s675172364
1,811
352
119,132
27,688
Accepted
Accepted
80.56
import sys from itertools import accumulate def solve(n, x, m): eee = [d % m for d in ddd] acc = list(accumulate(eee)) zero = [int(e == 0) for e in eee] zero_acc = list(accumulate(zero)) loop, rem = divmod(n - 1, k) tot = x % m + acc[-1] * loop tot_zero = zero_acc[-1] * loop ...
import os import sys import numpy as np def solve(inp): k, q = inp[:2] ddd = inp[2:k + 2] nnn = inp[k + 2::3] xxx = inp[k + 3::3] mmm = inp[k + 4::3] buf = [] for n, x, m in zip(nnn, xxx, mmm): eee = ddd % m acc = np.cumsum(eee) zero_acc = np.cumsum...
31
47
779
1,107
import sys from itertools import accumulate def solve(n, x, m): eee = [d % m for d in ddd] acc = list(accumulate(eee)) zero = [int(e == 0) for e in eee] zero_acc = list(accumulate(zero)) loop, rem = divmod(n - 1, k) tot = x % m + acc[-1] * loop tot_zero = zero_acc[-1] * loop if rem > 0...
import os import sys import numpy as np def solve(inp): k, q = inp[:2] ddd = inp[2 : k + 2] nnn = inp[k + 2 :: 3] xxx = inp[k + 3 :: 3] mmm = inp[k + 4 :: 3] buf = [] for n, x, m in zip(nnn, xxx, mmm): eee = ddd % m acc = np.cumsum(eee) zero_acc = np.cumsum(eee == 0...
false
34.042553
[ "+import os", "-from itertools import accumulate", "+import numpy as np", "-def solve(n, x, m):", "- eee = [d % m for d in ddd]", "- acc = list(accumulate(eee))", "- zero = [int(e == 0) for e in eee]", "- zero_acc = list(accumulate(zero))", "- loop, rem = divmod(n - 1, k)", "- to...
false
0.041441
0.18937
0.218838
[ "s351778299", "s675172364" ]
u532031128
p02725
python
s961069475
s305279928
221
179
26,444
26,436
Accepted
Accepted
19
K, N = list(map(int, input().split())) array = list(map(int, input().split())) array_distance = [] for i in range(N): min = 0 if i == N-1: min = abs(array[0] - array[N-1]) if min>=K/2: min = abs(K-min) array_distance.append(min) else: min = abs(array[...
K, N = list(map(int, input().split())) array = list(map(int, input().split())) array_distance = [] for i in range(N): min = 0 if i == N-1: min = abs(array[0] - array[N-1]) if min>=K/2: min = abs(K-min) array_distance.append(min) else: min = abs(array[...
23
22
610
560
K, N = list(map(int, input().split())) array = list(map(int, input().split())) array_distance = [] for i in range(N): min = 0 if i == N - 1: min = abs(array[0] - array[N - 1]) if min >= K / 2: min = abs(K - min) array_distance.append(min) else: min = abs(array[i] ...
K, N = list(map(int, input().split())) array = list(map(int, input().split())) array_distance = [] for i in range(N): min = 0 if i == N - 1: min = abs(array[0] - array[N - 1]) if min >= K / 2: min = abs(K - min) array_distance.append(min) else: min = abs(array[i] ...
false
4.347826
[ "- if min >= K / 2:", "- min = abs(K - min)" ]
false
0.041806
0.042273
0.988958
[ "s961069475", "s305279928" ]
u396495667
p03813
python
s804020952
s907616507
174
17
38,384
2,940
Accepted
Accepted
90.23
x = int(eval(input())) if x <1200: print('ABC') else: print('ARC')
n = int(eval(input())) if n < 1200: print('ABC') else: print('ARC')
6
6
70
71
x = int(eval(input())) if x < 1200: print("ABC") else: print("ARC")
n = int(eval(input())) if n < 1200: print("ABC") else: print("ARC")
false
0
[ "-x = int(eval(input()))", "-if x < 1200:", "+n = int(eval(input()))", "+if n < 1200:" ]
false
0.036502
0.036404
1.002674
[ "s804020952", "s907616507" ]
u588341295
p03488
python
s230379221
s590728760
524
63
269,576
24,308
Accepted
Accepted
87.98
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ...
65
66
1,488
1,514
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in rang...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in rang...
false
1.515152
[ "-dpx = [set() for i in range(M1 + 1)]", "-dpy = [set() for i in range(M2 + 1)]", "-dpx[0].add(0)", "-dpy[0].add(0)", "+# 集合管理をbitset高速化", "+dpx = [0] * (M1 + 1)", "+dpy = [0] * (M2 + 1)", "+# 負数を考慮してずらしてから始める", "+offset = 20000", "+dpx[0] = 1 << offset", "+dpy[0] = 1 << offset", "- for x i...
false
0.046586
0.037001
1.259027
[ "s230379221", "s590728760" ]
u699296734
p02743
python
s593635532
s375282182
57
35
5,588
5,076
Accepted
Accepted
38.6
from decimal import * import math getcontext().prec=100 a,b,c=list(map(int,input().split())) if a+b+2*(Decimal(a).sqrt())*(Decimal(b).sqrt())<c: print("Yes") else: print("No")
from decimal import * import math #getcontext().prec=100 a,b,c=list(map(int,input().split())) if a+b+2*Decimal(a*b).sqrt()<c: print("Yes") else: print("No")
8
8
181
162
from decimal import * import math getcontext().prec = 100 a, b, c = list(map(int, input().split())) if a + b + 2 * (Decimal(a).sqrt()) * (Decimal(b).sqrt()) < c: print("Yes") else: print("No")
from decimal import * import math # getcontext().prec=100 a, b, c = list(map(int, input().split())) if a + b + 2 * Decimal(a * b).sqrt() < c: print("Yes") else: print("No")
false
0
[ "-getcontext().prec = 100", "+# getcontext().prec=100", "-if a + b + 2 * (Decimal(a).sqrt()) * (Decimal(b).sqrt()) < c:", "+if a + b + 2 * Decimal(a * b).sqrt() < c:" ]
false
0.039366
0.142258
0.276723
[ "s593635532", "s375282182" ]
u753803401
p03476
python
s419135830
s900804635
423
378
65,500
53,592
Accepted
Accepted
10.64
def slove(): import sys input = sys.stdin.readline pl = {} p = [True] * (10 ** 5 + 1) p[0] = False p[1] = False cnt = 0 pll = [0] * (10 ** 5 + 1) for i in range(2, len(p)): if p[i]: pl[i] = 1 for j in range(i, len(p), i): p...
def slove(): import sys input = sys.stdin.readline pb = [True] * (10 ** 5 + 1) pb[0] = False pb[1] = False pl = [0] * (10 ** 5 + 1) pc = 0 for i in range(2, len(pb)): if pb[i]: for j in range(i + i, len(pb), i): if pb[j]: ...
26
24
662
612
def slove(): import sys input = sys.stdin.readline pl = {} p = [True] * (10**5 + 1) p[0] = False p[1] = False cnt = 0 pll = [0] * (10**5 + 1) for i in range(2, len(p)): if p[i]: pl[i] = 1 for j in range(i, len(p), i): p[j] = False ...
def slove(): import sys input = sys.stdin.readline pb = [True] * (10**5 + 1) pb[0] = False pb[1] = False pl = [0] * (10**5 + 1) pc = 0 for i in range(2, len(pb)): if pb[i]: for j in range(i + i, len(pb), i): if pb[j]: pb[j] = False...
false
7.692308
[ "- pl = {}", "- p = [True] * (10**5 + 1)", "- p[0] = False", "- p[1] = False", "- cnt = 0", "- pll = [0] * (10**5 + 1)", "- for i in range(2, len(p)):", "- if p[i]:", "- pl[i] = 1", "- for j in range(i, len(p), i):", "- p[j] = Fals...
false
0.129029
0.08547
1.509634
[ "s419135830", "s900804635" ]
u657361950
p02252
python
s644881343
s512473053
750
670
32,556
32,556
Accepted
Accepted
10.67
class Item: def __init__(self,v,w): self.v=v self.w=w self.r=v/w def __str__(self): s='v='+str(self.v) s+=',w='+str(self.w) s+=',r='+str(self.r) return s n,w=list(map(int,input().split())) items=[] for i in range(n): vi,wi=list(map(int,input().split())) items.append(Item(vi,wi)) ...
class Item: def __init__(self,v,w): self.v=v self.w=w self.r=v/w n,w=list(map(int,input().split())) items=[] for i in range(n): vi,wi=list(map(int,input().split())) items.append(Item(vi,wi)) items.sort(key=lambda x:x.r,reverse=True) total=0 remain = w for i in range(n): vi = items[i].v ...
35
30
552
456
class Item: def __init__(self, v, w): self.v = v self.w = w self.r = v / w def __str__(self): s = "v=" + str(self.v) s += ",w=" + str(self.w) s += ",r=" + str(self.r) return s n, w = list(map(int, input().split())) items = [] for i in range(n): vi, ...
class Item: def __init__(self, v, w): self.v = v self.w = w self.r = v / w n, w = list(map(int, input().split())) items = [] for i in range(n): vi, wi = list(map(int, input().split())) items.append(Item(vi, wi)) items.sort(key=lambda x: x.r, reverse=True) total = 0 remain = w for i...
false
14.285714
[ "-", "- def __str__(self):", "- s = \"v=\" + str(self.v)", "- s += \",w=\" + str(self.w)", "- s += \",r=\" + str(self.r)", "- return s", "- v = items[i].v", "- w = items[i].w", "- r = items[i].r", "- if w <= remain:", "- total += v", "- ...
false
0.045285
0.045118
1.003708
[ "s644881343", "s512473053" ]
u853185302
p03325
python
s716683705
s515078917
110
87
4,212
4,148
Accepted
Accepted
20.91
N = int(eval(input())) a_ = list(map(int,input().split())) a_g = [i for i in a_ if i%2 == 0] count = 0 for i in a_g: while(i%2 == 0): count += 1 i = i/2 print(count)
import math n = int(eval(input())) a = list(map(int,input().split())) g_c = sum([1 for i in a if i%2==0]) c = 0 for i in a: if i%2==0: while(i%2==0): i = i//2 c += 1 print(c)
13
11
188
197
N = int(eval(input())) a_ = list(map(int, input().split())) a_g = [i for i in a_ if i % 2 == 0] count = 0 for i in a_g: while i % 2 == 0: count += 1 i = i / 2 print(count)
import math n = int(eval(input())) a = list(map(int, input().split())) g_c = sum([1 for i in a if i % 2 == 0]) c = 0 for i in a: if i % 2 == 0: while i % 2 == 0: i = i // 2 c += 1 print(c)
false
15.384615
[ "-N = int(eval(input()))", "-a_ = list(map(int, input().split()))", "-a_g = [i for i in a_ if i % 2 == 0]", "-count = 0", "-for i in a_g:", "- while i % 2 == 0:", "- count += 1", "- i = i / 2", "-print(count)", "+import math", "+", "+n = int(eval(input()))", "+a = list(map(i...
false
0.03631
0.007537
4.817305
[ "s716683705", "s515078917" ]
u738898077
p02803
python
s340966128
s336413929
809
406
12,440
3,316
Accepted
Accepted
49.81
import numpy as np from collections import deque h,w = list(map(int,input().split())) s =["#"*(w+2)] + ["#" + str(eval(input())) + "#" for i in range(h)] + ["#"*(w+2)] s = np.array(s) opt = [(1,0),(0,1),(-1,0),(0,-1)] ans = 0 for i in range(1,h+1): for j in range(1,w+1): if s[i][j] == ".": ...
from collections import deque h,w = list(map(int,input().split())) s =["#"*(w+2)] + ["#" + str(eval(input())) + "#" for i in range(h)] + ["#"*(w+2)] opt = [(1,0),(0,1),(-1,0),(0,-1)] ans = 0 for i in range(1,h+1): for j in range(1,w+1): if s[i][j] == ".": temp = [[0]*(w+2) for i in ran...
24
22
779
752
import numpy as np from collections import deque h, w = list(map(int, input().split())) s = ( ["#" * (w + 2)] + ["#" + str(eval(input())) + "#" for i in range(h)] + ["#" * (w + 2)] ) s = np.array(s) opt = [(1, 0), (0, 1), (-1, 0), (0, -1)] ans = 0 for i in range(1, h + 1): for j in range(1, w + 1): ...
from collections import deque h, w = list(map(int, input().split())) s = ( ["#" * (w + 2)] + ["#" + str(eval(input())) + "#" for i in range(h)] + ["#" * (w + 2)] ) opt = [(1, 0), (0, 1), (-1, 0), (0, -1)] ans = 0 for i in range(1, h + 1): for j in range(1, w + 1): if s[i][j] == ".": ...
false
8.333333
[ "-import numpy as np", "-s = np.array(s)", "- ans = max(ans, np.max(temp))", "+ ans = max(ans, temp[x1][y1])" ]
false
0.422342
0.048712
8.670128
[ "s340966128", "s336413929" ]
u794173881
p02780
python
s371385275
s097344968
303
234
78,088
71,792
Accepted
Accepted
22.77
n, k = list(map(int, input().split())) p = list(map(int, input().split())) ans = [0] * n for i in range(n): ans[i] = (p[i] + 1) / 2 ruiseki = [0] * (n + 1) for i in range(n): ruiseki[i + 1] = ruiseki[i] + ans[i] res = 0 for i in range(n): if k+i > n: break res = max(res, ru...
n, k = list(map(int, input().split())) p = list(map(int, input().split())) sum_ = sum(p[0:k]) max_ = sum(p[0:k]) for i in range(k, n): sum_ += p[i] - p[i - k] max_ = max(sum_, max_) print(((max_ + k) / 2))
18
10
364
216
n, k = list(map(int, input().split())) p = list(map(int, input().split())) ans = [0] * n for i in range(n): ans[i] = (p[i] + 1) / 2 ruiseki = [0] * (n + 1) for i in range(n): ruiseki[i + 1] = ruiseki[i] + ans[i] res = 0 for i in range(n): if k + i > n: break res = max(res, ruiseki[k + i] - ruise...
n, k = list(map(int, input().split())) p = list(map(int, input().split())) sum_ = sum(p[0:k]) max_ = sum(p[0:k]) for i in range(k, n): sum_ += p[i] - p[i - k] max_ = max(sum_, max_) print(((max_ + k) / 2))
false
44.444444
[ "-ans = [0] * n", "-for i in range(n):", "- ans[i] = (p[i] + 1) / 2", "-ruiseki = [0] * (n + 1)", "-for i in range(n):", "- ruiseki[i + 1] = ruiseki[i] + ans[i]", "-res = 0", "-for i in range(n):", "- if k + i > n:", "- break", "- res = max(res, ruiseki[k + i] - ruiseki[i])", ...
false
0.035003
0.038131
0.917966
[ "s371385275", "s097344968" ]
u622045059
p02873
python
s977709418
s796154674
469
366
31,892
25,644
Accepted
Accepted
21.96
import math import bisect import collections import itertools import heapq import string import sys sys.setrecursionlimit(10**9) def gcd(a,b):return math.gcd #最大公約数 def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数 def iin(): return int(eval(input())) #整数読み込み def isn(): return input().split() #文字列読み込み def i...
import math import fractions import bisect import collections import itertools import heapq import string import sys sys.setrecursionlimit(10**9) def gcd(a,b):return fractions.gcd(a,b) #最大公約数 def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数 def iin(): return int(eval(input())) #整数読み込み def isn(): retur...
66
62
2,104
2,038
import math import bisect import collections import itertools import heapq import string import sys sys.setrecursionlimit(10**9) def gcd(a, b): return math.gcd # 最大公約数 def lcm(a, b): return (a * b) // math.gcd(a, b) # 最小公倍数 def iin(): return int(eval(input())) # 整数読み込み def isn(): return inpu...
import math import fractions import bisect import collections import itertools import heapq import string import sys sys.setrecursionlimit(10**9) def gcd(a, b): return fractions.gcd(a, b) # 最大公約数 def lcm(a, b): return (a * b) // fractions.gcd(a, b) # 最小公倍数 def iin(): return int(eval(input())) # 整数...
false
6.060606
[ "+import fractions", "- return math.gcd # 最大公約数", "+ return fractions.gcd(a, b) # 最大公約数", "- return (a * b) // math.gcd(a, b) # 最小公倍数", "+ return (a * b) // fractions.gcd(a, b) # 最小公倍数", "-l_cnt = [0] * (l + 1)", "-r_cnt = [0] * (l + 1)", "- l_cnt[i + 1] = l_cnt[i] + 1", "+ ...
false
0.038639
0.07973
0.484629
[ "s977709418", "s796154674" ]
u638078488
p03494
python
s271816536
s141789371
21
18
3,064
3,060
Accepted
Accepted
14.29
N = int(eval(input())) l = list(map(int, input().split())) # リストを受け取り、すべてが偶数かどうかチェックする def is_even(a): for i in a: if i % 2 != 0: return False return True # リストを受け取り、すべてを÷2したリストを返却する def divided_list(a): tmp_list = [] for k in a: tmp_list.append(int(k / 2)) ...
N = eval(input()) input_list = list(map(int, input().split())) def cal_division(n): return int(n / 2) flag = False count = 0 while True: # 偶数チェック for i in input_list: if i % 2 != 0: flag = True break if flag: break # リスト内を÷2 count +=...
30
23
565
386
N = int(eval(input())) l = list(map(int, input().split())) # リストを受け取り、すべてが偶数かどうかチェックする def is_even(a): for i in a: if i % 2 != 0: return False return True # リストを受け取り、すべてを÷2したリストを返却する def divided_list(a): tmp_list = [] for k in a: tmp_list.append(int(k / 2)) return tmp_l...
N = eval(input()) input_list = list(map(int, input().split())) def cal_division(n): return int(n / 2) flag = False count = 0 while True: # 偶数チェック for i in input_list: if i % 2 != 0: flag = True break if flag: break # リスト内を÷2 count += 1 input_list =...
false
23.333333
[ "-N = int(eval(input()))", "-l = list(map(int, input().split()))", "-# リストを受け取り、すべてが偶数かどうかチェックする", "-def is_even(a):", "- for i in a:", "- if i % 2 != 0:", "- return False", "- return True", "+N = eval(input())", "+input_list = list(map(int, input().split()))", "-# リストを受け...
false
0.155477
0.047884
3.246949
[ "s271816536", "s141789371" ]
u287132915
p03040
python
s221394849
s670738846
1,407
520
11,184
100,252
Accepted
Accepted
63.04
import heapq q = int(eval(input())) nchange = 0 ming, maxg = [], [] heapq.heapify(ming) heapq.heapify(maxg) a = 0 b = 0 for i in range(q): qi = eval(input()) if qi[0] == '1': _, ai, bi = list(map(int, qi.split())) b += bi nchange += 1 if nchange % 2 == 1: ...
import heapq q = int(eval(input())) ans = [] mini = 0 left, right = [], [] cnt = 0 mid = None for _ in range(q): qi = eval(input()) if qi == '2': if cnt%2 == 0: ans.append([-left[0], mini]) else: ans.append([mid, mini]) else: kind, a, b = list...
44
49
1,198
1,268
import heapq q = int(eval(input())) nchange = 0 ming, maxg = [], [] heapq.heapify(ming) heapq.heapify(maxg) a = 0 b = 0 for i in range(q): qi = eval(input()) if qi[0] == "1": _, ai, bi = list(map(int, qi.split())) b += bi nchange += 1 if nchange % 2 == 1: if nchange ...
import heapq q = int(eval(input())) ans = [] mini = 0 left, right = [], [] cnt = 0 mid = None for _ in range(q): qi = eval(input()) if qi == "2": if cnt % 2 == 0: ans.append([-left[0], mini]) else: ans.append([mid, mini]) else: kind, a, b = list(map(int, qi.s...
false
10.204082
[ "-nchange = 0", "-ming, maxg = [], []", "-heapq.heapify(ming)", "-heapq.heapify(maxg)", "-a = 0", "-b = 0", "-for i in range(q):", "+ans = []", "+mini = 0", "+left, right = [], []", "+cnt = 0", "+mid = None", "+for _ in range(q):", "- if qi[0] == \"1\":", "- _, ai, bi = list(ma...
false
0.068634
0.077385
0.886908
[ "s221394849", "s670738846" ]
u075012704
p03785
python
s709343166
s427443731
1,765
306
8,280
8,284
Accepted
Accepted
82.66
import bisect N, C, K = list(map(int, input().split())) T = sorted([int(eval(input())) for i in range(N)]) i = 0 ans = 0 while T: ans += 1 check = T[0] + K people = bisect.bisect_right(T, check) if people > C: del T[:C] else: del T[:people] print(ans)
import bisect N, C, K =list(map(int, input().split())) T = sorted([int(eval(input())) for i in range(N)]) ans = 0 front = 0 while front < N: standard = T[front] + K front = min(bisect.bisect_right(T, standard), front+C) ans += 1 print(ans)
18
11
296
250
import bisect N, C, K = list(map(int, input().split())) T = sorted([int(eval(input())) for i in range(N)]) i = 0 ans = 0 while T: ans += 1 check = T[0] + K people = bisect.bisect_right(T, check) if people > C: del T[:C] else: del T[:people] print(ans)
import bisect N, C, K = list(map(int, input().split())) T = sorted([int(eval(input())) for i in range(N)]) ans = 0 front = 0 while front < N: standard = T[front] + K front = min(bisect.bisect_right(T, standard), front + C) ans += 1 print(ans)
false
38.888889
[ "-i = 0", "-while T:", "+front = 0", "+while front < N:", "+ standard = T[front] + K", "+ front = min(bisect.bisect_right(T, standard), front + C)", "- check = T[0] + K", "- people = bisect.bisect_right(T, check)", "- if people > C:", "- del T[:C]", "- else:", "- ...
false
0.03973
0.03922
1.012995
[ "s709343166", "s427443731" ]
u057415180
p02953
python
s919665091
s288902769
95
73
14,396
14,396
Accepted
Accepted
23.16
import sys n = int(eval(input())) h = [int(i) for i in input().split()] for k in range(n): if k == n-1: break if h[k+1] > h[k]: h[k+1] -= 1 elif h[k+1] < h[k]: print('No') sys.exit() if k+1 == n-1: break print('Yes')
n = int(eval(input())) h = list(map(int, input().split())) ans ='Yes' mah = 0 for i in h: mah = max(i, mah) if i < mah - 1: ans = 'No' break print(ans)
15
10
281
178
import sys n = int(eval(input())) h = [int(i) for i in input().split()] for k in range(n): if k == n - 1: break if h[k + 1] > h[k]: h[k + 1] -= 1 elif h[k + 1] < h[k]: print("No") sys.exit() if k + 1 == n - 1: break print("Yes")
n = int(eval(input())) h = list(map(int, input().split())) ans = "Yes" mah = 0 for i in h: mah = max(i, mah) if i < mah - 1: ans = "No" break print(ans)
false
33.333333
[ "-import sys", "-", "-h = [int(i) for i in input().split()]", "-for k in range(n):", "- if k == n - 1:", "+h = list(map(int, input().split()))", "+ans = \"Yes\"", "+mah = 0", "+for i in h:", "+ mah = max(i, mah)", "+ if i < mah - 1:", "+ ans = \"No\"", "- if h[k + 1] > h[k...
false
0.041169
0.1106
0.37223
[ "s919665091", "s288902769" ]