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
sequence
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
sequence
u729133443
p03657
python
s252569931
s579542506
107
27
61,008
9,028
Accepted
Accepted
74.77
print(((eval(input().replace(*' *'))%3%2*'Imp'or'P')+'ossible'))
print(f"{eval(input().replace(*' *'))%3%2*'Imp'or'P'}ossible")
1
1
62
62
print(((eval(input().replace(*" *")) % 3 % 2 * "Imp" or "P") + "ossible"))
print(f"{eval(input().replace(*' *'))%3%2*'Imp'or'P'}ossible")
false
0
[ "-print(((eval(input().replace(*\" *\")) % 3 % 2 * \"Imp\" or \"P\") + \"ossible\"))", "+print(f\"{eval(input().replace(*' *'))%3%2*'Imp'or'P'}ossible\")" ]
false
0.046969
0.150594
0.31189
[ "s252569931", "s579542506" ]
u078349616
p02837
python
s425424388
s635043712
280
257
3,064
3,064
Accepted
Accepted
8.21
from itertools import product N = int(eval(input())) A = [] XY = [[] for _ in range(N)] for i in range(N): A.append(int(eval(input()))) for j in range(A[i]): XY[i].append(list(map(int, input().split()))) ans = 0 for pattern in product(list(range(2)), repeat=N): # 0:不正直 1:正直 flag = True for i in range(N): if pattern[i]: # iさんが正直と仮定 # 発言と一致するか? for a in range(A[i]): if pattern[XY[i][a][0]-1] != XY[i][a][1]: flag = False break if flag: ans = max(ans, sum(pattern)) print(ans)
N = int(eval(input())) XY = [] for i in range(N): A = int(eval(input())) XY.append([list(map(int, input().split())) for _ in range(A)]) ans = 0 for bit in range(1 << N): honest_cnt = 0 flag = True for i in range(N): if (bit >> i) & 1 == 0: continue honest_cnt += 1 for x, y in XY[i]: if (bit >> (x-1)) & 1 != y: flag = False break if flag: ans = max(ans, honest_cnt) print(ans)
24
22
547
448
from itertools import product N = int(eval(input())) A = [] XY = [[] for _ in range(N)] for i in range(N): A.append(int(eval(input()))) for j in range(A[i]): XY[i].append(list(map(int, input().split()))) ans = 0 for pattern in product(list(range(2)), repeat=N): # 0:不正直 1:正直 flag = True for i in range(N): if pattern[i]: # iさんが正直と仮定 # 発言と一致するか? for a in range(A[i]): if pattern[XY[i][a][0] - 1] != XY[i][a][1]: flag = False break if flag: ans = max(ans, sum(pattern)) print(ans)
N = int(eval(input())) XY = [] for i in range(N): A = int(eval(input())) XY.append([list(map(int, input().split())) for _ in range(A)]) ans = 0 for bit in range(1 << N): honest_cnt = 0 flag = True for i in range(N): if (bit >> i) & 1 == 0: continue honest_cnt += 1 for x, y in XY[i]: if (bit >> (x - 1)) & 1 != y: flag = False break if flag: ans = max(ans, honest_cnt) print(ans)
false
8.333333
[ "-from itertools import product", "-", "-A = []", "-XY = [[] for _ in range(N)]", "+XY = []", "- A.append(int(eval(input())))", "- for j in range(A[i]):", "- XY[i].append(list(map(int, input().split())))", "+ A = int(eval(input()))", "+ XY.append([list(map(int, input().split())) for _ in range(A)])", "-for pattern in product(list(range(2)), repeat=N): # 0:不正直 1:正直", "+for bit in range(1 << N):", "+ honest_cnt = 0", "- if pattern[i]: # iさんが正直と仮定", "- # 発言と一致するか?", "- for a in range(A[i]):", "- if pattern[XY[i][a][0] - 1] != XY[i][a][1]:", "- flag = False", "- break", "+ if (bit >> i) & 1 == 0:", "+ continue", "+ honest_cnt += 1", "+ for x, y in XY[i]:", "+ if (bit >> (x - 1)) & 1 != y:", "+ flag = False", "+ break", "- ans = max(ans, sum(pattern))", "+ ans = max(ans, honest_cnt)" ]
false
0.09691
0.109525
0.884821
[ "s425424388", "s635043712" ]
u993435350
p03167
python
s152996730
s537488890
781
211
60,504
14,408
Accepted
Accepted
72.98
import sys import numpy as np from functools import lru_cache from collections import deque #input = sys.stdin.readline #sys.setrecursionlimit(10 ** 5) H,W = list(map(int,input().split())) grid = [list(eval(input())) for i in range(H)] dp = [[0] * (W + 1) for i in range(H + 1)] dp[0][0] = 1 mod = (10 ** 9) + 7 for i in range(H): for j in range(W): if i > 0 or j > 0: if grid[i][j] == "#": dp[i][j] = 0 else: dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod print((dp[H - 1][W - 1])) #print(dp)
import sys buf = sys.stdin.buffer import numpy as np MOD = 10 ** 9 + 7 H,W = list(map(int,buf.readline().split())) grid = np.frombuffer(buf.read(),dtype='S1').reshape(H,-1)[:,:W] #print(grid) MOD = 10 ** 9 + 7 dp = np.zeros(W, dtype = np.int64) dp[0] = 1 for row in grid: #print(row == b"#") wall = (row == b'#') # 上から落としてくる dp[wall] = 0 # 左から右に np.cumsum(dp, out = dp) # 壁の補正 sub = np.maximum.accumulate(dp * wall) dp -= sub dp %= MOD answer = dp[-1] print(answer)
24
30
540
515
import sys import numpy as np from functools import lru_cache from collections import deque # input = sys.stdin.readline # sys.setrecursionlimit(10 ** 5) H, W = list(map(int, input().split())) grid = [list(eval(input())) for i in range(H)] dp = [[0] * (W + 1) for i in range(H + 1)] dp[0][0] = 1 mod = (10**9) + 7 for i in range(H): for j in range(W): if i > 0 or j > 0: if grid[i][j] == "#": dp[i][j] = 0 else: dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod print((dp[H - 1][W - 1])) # print(dp)
import sys buf = sys.stdin.buffer import numpy as np MOD = 10**9 + 7 H, W = list(map(int, buf.readline().split())) grid = np.frombuffer(buf.read(), dtype="S1").reshape(H, -1)[:, :W] # print(grid) MOD = 10**9 + 7 dp = np.zeros(W, dtype=np.int64) dp[0] = 1 for row in grid: # print(row == b"#") wall = row == b"#" # 上から落としてくる dp[wall] = 0 # 左から右に np.cumsum(dp, out=dp) # 壁の補正 sub = np.maximum.accumulate(dp * wall) dp -= sub dp %= MOD answer = dp[-1] print(answer)
false
20
[ "+", "+buf = sys.stdin.buffer", "-from functools import lru_cache", "-from collections import deque", "-# input = sys.stdin.readline", "-# sys.setrecursionlimit(10 ** 5)", "-H, W = list(map(int, input().split()))", "-grid = [list(eval(input())) for i in range(H)]", "-dp = [[0] * (W + 1) for i in range(H + 1)]", "-dp[0][0] = 1", "-mod = (10**9) + 7", "-for i in range(H):", "- for j in range(W):", "- if i > 0 or j > 0:", "- if grid[i][j] == \"#\":", "- dp[i][j] = 0", "- else:", "- dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod", "-print((dp[H - 1][W - 1]))", "-# print(dp)", "+MOD = 10**9 + 7", "+H, W = list(map(int, buf.readline().split()))", "+grid = np.frombuffer(buf.read(), dtype=\"S1\").reshape(H, -1)[:, :W]", "+# print(grid)", "+MOD = 10**9 + 7", "+dp = np.zeros(W, dtype=np.int64)", "+dp[0] = 1", "+for row in grid:", "+ # print(row == b\"#\")", "+ wall = row == b\"#\"", "+ # 上から落としてくる", "+ dp[wall] = 0", "+ # 左から右に", "+ np.cumsum(dp, out=dp)", "+ # 壁の補正", "+ sub = np.maximum.accumulate(dp * wall)", "+ dp -= sub", "+ dp %= MOD", "+answer = dp[-1]", "+print(answer)" ]
false
0.044151
0.25937
0.170226
[ "s152996730", "s537488890" ]
u392029857
p03556
python
s273873551
s903554806
65
17
3,188
3,060
Accepted
Accepted
73.85
n = int(eval(input())) for i in range(n,0,-1): if i**0.5 == int(i**0.5): ans = i break print(ans)
n = int(eval(input())) print((int(n**0.5)**2))
6
2
116
39
n = int(eval(input())) for i in range(n, 0, -1): if i**0.5 == int(i**0.5): ans = i break print(ans)
n = int(eval(input())) print((int(n**0.5) ** 2))
false
66.666667
[ "-for i in range(n, 0, -1):", "- if i**0.5 == int(i**0.5):", "- ans = i", "- break", "-print(ans)", "+print((int(n**0.5) ** 2))" ]
false
0.048732
0.038416
1.268549
[ "s273873551", "s903554806" ]
u677096240
p02408
python
s826737558
s865280692
30
20
5,604
5,600
Accepted
Accepted
33.33
n = int(input()) cards, suits = [], ["S", "H", "C", "D"] for suit in suits: for x in range(1, 14): cards.append('{} {}'.format(suit, x)) for _ in range(n): target = ' '.join(input().split()) if target in cards: cards.remove(target) [print(c) for c in cards]
# 2次元配列バージョン # かつ、内包表記バージョン n = int(input()) suits = ["S", "H", "C", "D"] cards = [[s, n] for s in suits for n in range(1, 14)] for i in range(n): target = list(map( lambda a: int(a) if a.isnumeric() else a, input().split() )) if target in cards: cards.remove(target) [print("{} {}".format(c[0], c[1])) for c in cards]
12
13
299
360
n = int(input()) cards, suits = [], ["S", "H", "C", "D"] for suit in suits: for x in range(1, 14): cards.append("{} {}".format(suit, x)) for _ in range(n): target = " ".join(input().split()) if target in cards: cards.remove(target) [print(c) for c in cards]
# 2次元配列バージョン # かつ、内包表記バージョン n = int(input()) suits = ["S", "H", "C", "D"] cards = [[s, n] for s in suits for n in range(1, 14)] for i in range(n): target = list(map(lambda a: int(a) if a.isnumeric() else a, input().split())) if target in cards: cards.remove(target) [print("{} {}".format(c[0], c[1])) for c in cards]
false
7.692308
[ "+# 2次元配列バージョン", "+# かつ、内包表記バージョン", "-cards, suits = [], [\"S\", \"H\", \"C\", \"D\"]", "-for suit in suits:", "- for x in range(1, 14):", "- cards.append(\"{} {}\".format(suit, x))", "-for _ in range(n):", "- target = \" \".join(input().split())", "+suits = [\"S\", \"H\", \"C\", \"D\"]", "+cards = [[s, n] for s in suits for n in range(1, 14)]", "+for i in range(n):", "+ target = list(map(lambda a: int(a) if a.isnumeric() else a, input().split()))", "-[print(c) for c in cards]", "+[print(\"{} {}\".format(c[0], c[1])) for c in cards]" ]
false
0.044207
0.061583
0.717848
[ "s826737558", "s865280692" ]
u150984829
p02315
python
s966994156
s012228070
360
330
5,924
5,928
Accepted
Accepted
8.33
N,W=list(map(int,input().split())) I=[[*list(map(int,input().split()))]for _ in[0]*N] C=[0]*-~W for i in range(1,N+1): v,w=I[~-i] for j in range(W,w-1,-1): t=v+C[j-w] if t>C[j]:C[j]=t print((C[W]))
import sys W=int(input().split()[1]) C=[0]*-~W for e in sys.stdin: v,w=list(map(int,e.split())) for i in range(W,w-1,-1): t=v+C[i-w] if t>C[i]:C[i]=t print((C[W]))
9
9
198
170
N, W = list(map(int, input().split())) I = [[*list(map(int, input().split()))] for _ in [0] * N] C = [0] * -~W for i in range(1, N + 1): v, w = I[~-i] for j in range(W, w - 1, -1): t = v + C[j - w] if t > C[j]: C[j] = t print((C[W]))
import sys W = int(input().split()[1]) C = [0] * -~W for e in sys.stdin: v, w = list(map(int, e.split())) for i in range(W, w - 1, -1): t = v + C[i - w] if t > C[i]: C[i] = t print((C[W]))
false
0
[ "-N, W = list(map(int, input().split()))", "-I = [[*list(map(int, input().split()))] for _ in [0] * N]", "+import sys", "+", "+W = int(input().split()[1])", "-for i in range(1, N + 1):", "- v, w = I[~-i]", "- for j in range(W, w - 1, -1):", "- t = v + C[j - w]", "- if t > C[j]:", "- C[j] = t", "+for e in sys.stdin:", "+ v, w = list(map(int, e.split()))", "+ for i in range(W, w - 1, -1):", "+ t = v + C[i - w]", "+ if t > C[i]:", "+ C[i] = t" ]
false
0.0417
0.067333
0.619305
[ "s966994156", "s012228070" ]
u624475441
p03290
python
s468722663
s706260018
515
23
3,188
3,064
Accepted
Accepted
95.53
D,G = list(map(int,input().split())) P = [] num_p = 0 for i in range(1,D+1): p,c = list(map(int,input().split())) num_p += p for j in range(1,p+1): P += [(j,i*100*j+c*(j==p))] dp = [0]*(num_p+1) for k,pt in P: if k==1: t_dp = dp[:] for cur in range(1,num_p+1): if cur>=k: dp[cur] = max(dp[cur], t_dp[cur-k]+pt) for i in range(num_p+1): if dp[i]>=G: print(i) break
d,g = list(map(int,input().split())) pc = [list(map(int,input().split()))for _ in[0]*d] ans = [] for mask in range(1 << d): s = 0 num = 0 rest_max = -1 for i in range(d): p,c = pc[i] if mask >> i & 1: s += p * 100 * (i + 1) + c num += p else: rest_max = i if s < g: s1 = 100 * (rest_max + 1) need = (g - s + s1 - 1) // s1 if need >= pc[rest_max][0]: continue num += need ans.append(num) print((min(ans)))
19
22
445
545
D, G = list(map(int, input().split())) P = [] num_p = 0 for i in range(1, D + 1): p, c = list(map(int, input().split())) num_p += p for j in range(1, p + 1): P += [(j, i * 100 * j + c * (j == p))] dp = [0] * (num_p + 1) for k, pt in P: if k == 1: t_dp = dp[:] for cur in range(1, num_p + 1): if cur >= k: dp[cur] = max(dp[cur], t_dp[cur - k] + pt) for i in range(num_p + 1): if dp[i] >= G: print(i) break
d, g = list(map(int, input().split())) pc = [list(map(int, input().split())) for _ in [0] * d] ans = [] for mask in range(1 << d): s = 0 num = 0 rest_max = -1 for i in range(d): p, c = pc[i] if mask >> i & 1: s += p * 100 * (i + 1) + c num += p else: rest_max = i if s < g: s1 = 100 * (rest_max + 1) need = (g - s + s1 - 1) // s1 if need >= pc[rest_max][0]: continue num += need ans.append(num) print((min(ans)))
false
13.636364
[ "-D, G = list(map(int, input().split()))", "-P = []", "-num_p = 0", "-for i in range(1, D + 1):", "- p, c = list(map(int, input().split()))", "- num_p += p", "- for j in range(1, p + 1):", "- P += [(j, i * 100 * j + c * (j == p))]", "-dp = [0] * (num_p + 1)", "-for k, pt in P:", "- if k == 1:", "- t_dp = dp[:]", "- for cur in range(1, num_p + 1):", "- if cur >= k:", "- dp[cur] = max(dp[cur], t_dp[cur - k] + pt)", "-for i in range(num_p + 1):", "- if dp[i] >= G:", "- print(i)", "- break", "+d, g = list(map(int, input().split()))", "+pc = [list(map(int, input().split())) for _ in [0] * d]", "+ans = []", "+for mask in range(1 << d):", "+ s = 0", "+ num = 0", "+ rest_max = -1", "+ for i in range(d):", "+ p, c = pc[i]", "+ if mask >> i & 1:", "+ s += p * 100 * (i + 1) + c", "+ num += p", "+ else:", "+ rest_max = i", "+ if s < g:", "+ s1 = 100 * (rest_max + 1)", "+ need = (g - s + s1 - 1) // s1", "+ if need >= pc[rest_max][0]:", "+ continue", "+ num += need", "+ ans.append(num)", "+print((min(ans)))" ]
false
0.045702
0.036726
1.244398
[ "s468722663", "s706260018" ]
u759412327
p03043
python
s846763596
s781343602
60
47
2,940
9,124
Accepted
Accepted
21.67
n,k = list(map(int, input().split())) a = 0 for i in range(n): s=i+1 c=0 while s<=k-1: c+=1 s*=2 a+=1/n*(1/2**c) print(a)
N,K = list(map(int, input().split())) a = 0 for n in range(1,N+1): c = 0 while n<K: c+=1 n*=2 a+=(1/2**c)/N print(a)
12
11
144
136
n, k = list(map(int, input().split())) a = 0 for i in range(n): s = i + 1 c = 0 while s <= k - 1: c += 1 s *= 2 a += 1 / n * (1 / 2**c) print(a)
N, K = list(map(int, input().split())) a = 0 for n in range(1, N + 1): c = 0 while n < K: c += 1 n *= 2 a += (1 / 2**c) / N print(a)
false
8.333333
[ "-n, k = list(map(int, input().split()))", "+N, K = list(map(int, input().split()))", "-for i in range(n):", "- s = i + 1", "+for n in range(1, N + 1):", "- while s <= k - 1:", "+ while n < K:", "- s *= 2", "- a += 1 / n * (1 / 2**c)", "+ n *= 2", "+ a += (1 / 2**c) / N" ]
false
0.054192
0.050734
1.068173
[ "s846763596", "s781343602" ]
u857547702
p02713
python
s207436570
s453701423
1,386
1,011
188,952
69,836
Accepted
Accepted
27.06
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) K=int(eval(input())) ans=[] for i in range(1,K+1): for j in range(1,K+1): for k in range(1,K+1): ans.append(gcd(i,j,k)) print((sum(ans)))
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) K=int(eval(input())) ans=0 for i in range(1,K+1): for j in range(1,K+1): for k in range(1,K+1): ans+=gcd(i,j,k) print(ans)
12
12
265
249
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) K = int(eval(input())) ans = [] for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): ans.append(gcd(i, j, k)) print((sum(ans)))
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): ans += gcd(i, j, k) print(ans)
false
0
[ "-ans = []", "+ans = 0", "- ans.append(gcd(i, j, k))", "-print((sum(ans)))", "+ ans += gcd(i, j, k)", "+print(ans)" ]
false
0.037301
0.044312
0.84178
[ "s207436570", "s453701423" ]
u923668099
p02402
python
s263054226
s318169008
30
20
8,600
8,684
Accepted
Accepted
33.33
# coding: utf-8 # Here your code ! n = int(eval(input())) a = list(map(int, input().split())) print((min(a),max(a),sum(a)))
eval(input()) a = [int(i) for i in input().split()] print((min(a),max(a),sum(a)))
6
4
121
77
# coding: utf-8 # Here your code ! n = int(eval(input())) a = list(map(int, input().split())) print((min(a), max(a), sum(a)))
eval(input()) a = [int(i) for i in input().split()] print((min(a), max(a), sum(a)))
false
33.333333
[ "-# coding: utf-8", "-# Here your code !", "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "+eval(input())", "+a = [int(i) for i in input().split()]" ]
false
0.048757
0.049488
0.985234
[ "s263054226", "s318169008" ]
u414980766
p02913
python
s003301092
s576043624
1,640
1,141
3,060
3,064
Accepted
Accepted
30.43
N = int(eval(input())) S = eval(input()) r = 0 ans = 0 for i in range(N): while True: if S.rfind(S[i : r + 1]) >= r + 1: r += 1 ans = max(ans, r - i) else: break print(ans)
N = int(eval(input())) S = eval(input()) l = 0 k = 1 for i in range(N - 1): while True: if S[i : i + k] in S[i + k :]: k += 1 else: break l = max(l, k - 1) print(l)
12
12
227
211
N = int(eval(input())) S = eval(input()) r = 0 ans = 0 for i in range(N): while True: if S.rfind(S[i : r + 1]) >= r + 1: r += 1 ans = max(ans, r - i) else: break print(ans)
N = int(eval(input())) S = eval(input()) l = 0 k = 1 for i in range(N - 1): while True: if S[i : i + k] in S[i + k :]: k += 1 else: break l = max(l, k - 1) print(l)
false
0
[ "-r = 0", "-ans = 0", "-for i in range(N):", "+l = 0", "+k = 1", "+for i in range(N - 1):", "- if S.rfind(S[i : r + 1]) >= r + 1:", "- r += 1", "- ans = max(ans, r - i)", "+ if S[i : i + k] in S[i + k :]:", "+ k += 1", "-print(ans)", "+ l = max(l, k - 1)", "+print(l)" ]
false
0.007836
0.040879
0.191679
[ "s003301092", "s576043624" ]
u644907318
p02571
python
s681007106
s135795605
81
67
67,456
72,760
Accepted
Accepted
17.28
S = input().strip() T = input().strip() k = len(T) dmin = len(S) for i in range(len(S)-k+1): cnt = 0 for j in range(k): if S[i+j]!=T[j]: cnt += 1 dmin = min(dmin,cnt) print(dmin)
S = input().strip() N = len(S) T = input().strip() k = len(T) cmin = N for i in range(N-k+1): cnt = 0 for j in range(k): if S[i+j]!=T[j]: cnt += 1 cmin = min(cmin,cnt) print(cmin)
11
12
220
222
S = input().strip() T = input().strip() k = len(T) dmin = len(S) for i in range(len(S) - k + 1): cnt = 0 for j in range(k): if S[i + j] != T[j]: cnt += 1 dmin = min(dmin, cnt) print(dmin)
S = input().strip() N = len(S) T = input().strip() k = len(T) cmin = N for i in range(N - k + 1): cnt = 0 for j in range(k): if S[i + j] != T[j]: cnt += 1 cmin = min(cmin, cnt) print(cmin)
false
8.333333
[ "+N = len(S)", "-dmin = len(S)", "-for i in range(len(S) - k + 1):", "+cmin = N", "+for i in range(N - k + 1):", "- dmin = min(dmin, cnt)", "-print(dmin)", "+ cmin = min(cmin, cnt)", "+print(cmin)" ]
false
0.045515
0.044636
1.019685
[ "s681007106", "s135795605" ]
u994988729
p03971
python
s282933097
s312054717
111
88
4,016
6,344
Accepted
Accepted
20.72
n, a, b = list(map(int, input().split())) s = eval(input()) A = 0 B = 0 for i in s: if A + B < a + b: if i == "a": A += 1 print("Yes") elif i == "b" and B < b: B += 1 print("Yes") else: print("No") else: print("No")
N, A, B = map(int, input().split()) S = input() total = 0 tot_b = 0 ans = [] for s in S: if s == "a" and total < A + B: ans.append("Yes") total += 1 elif s == "b" and total < A + B and tot_b < B: ans.append("Yes") tot_b += 1 total += 1 else: ans.append("No") print(*ans, sep="\n")
17
20
321
364
n, a, b = list(map(int, input().split())) s = eval(input()) A = 0 B = 0 for i in s: if A + B < a + b: if i == "a": A += 1 print("Yes") elif i == "b" and B < b: B += 1 print("Yes") else: print("No") else: print("No")
N, A, B = map(int, input().split()) S = input() total = 0 tot_b = 0 ans = [] for s in S: if s == "a" and total < A + B: ans.append("Yes") total += 1 elif s == "b" and total < A + B and tot_b < B: ans.append("Yes") tot_b += 1 total += 1 else: ans.append("No") print(*ans, sep="\n")
false
15
[ "-n, a, b = list(map(int, input().split()))", "-s = eval(input())", "-A = 0", "-B = 0", "-for i in s:", "- if A + B < a + b:", "- if i == \"a\":", "- A += 1", "- print(\"Yes\")", "- elif i == \"b\" and B < b:", "- B += 1", "- print(\"Yes\")", "- else:", "- print(\"No\")", "+N, A, B = map(int, input().split())", "+S = input()", "+total = 0", "+tot_b = 0", "+ans = []", "+for s in S:", "+ if s == \"a\" and total < A + B:", "+ ans.append(\"Yes\")", "+ total += 1", "+ elif s == \"b\" and total < A + B and tot_b < B:", "+ ans.append(\"Yes\")", "+ tot_b += 1", "+ total += 1", "- print(\"No\")", "+ ans.append(\"No\")", "+print(*ans, sep=\"\\n\")" ]
false
0.044473
0.00843
5.275863
[ "s282933097", "s312054717" ]
u245641078
p03860
python
s530712296
s267935931
27
23
8,908
8,924
Accepted
Accepted
14.81
print(("A%sC"%input()[8]))
print(("A"+input()[8]+"C"))
1
1
24
25
print(("A%sC" % input()[8]))
print(("A" + input()[8] + "C"))
false
0
[ "-print((\"A%sC\" % input()[8]))", "+print((\"A\" + input()[8] + \"C\"))" ]
false
0.03998
0.036637
1.091238
[ "s530712296", "s267935931" ]
u745561510
p03161
python
s361970047
s247419321
474
415
55,392
55,264
Accepted
Accepted
12.45
N, K = list(map(int,input().split())) h = list(map(int,input().split())) dp = [float("inf")] * N dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(2,N): for j in range(1,K+1): dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j])) print((dp[-1]))
N, K = list(map(int, input().split())) h = list(map(int, input().split())) ans = [float("inf")] * N ans[0] = 0 for i in range(N-1): for j in range(1, K+1): if i + j > N - 1: continue ans[i+j] = min(ans[i+j], ans[i] + abs(h[i] - h[i+j])) print((ans[-1]))
12
11
257
290
N, K = list(map(int, input().split())) h = list(map(int, input().split())) dp = [float("inf")] * N dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(2, N): for j in range(1, K + 1): dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j])) print((dp[-1]))
N, K = list(map(int, input().split())) h = list(map(int, input().split())) ans = [float("inf")] * N ans[0] = 0 for i in range(N - 1): for j in range(1, K + 1): if i + j > N - 1: continue ans[i + j] = min(ans[i + j], ans[i] + abs(h[i] - h[i + j])) print((ans[-1]))
false
8.333333
[ "-dp = [float(\"inf\")] * N", "-dp[0] = 0", "-dp[1] = abs(h[1] - h[0])", "-for i in range(2, N):", "+ans = [float(\"inf\")] * N", "+ans[0] = 0", "+for i in range(N - 1):", "- dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))", "-print((dp[-1]))", "+ if i + j > N - 1:", "+ continue", "+ ans[i + j] = min(ans[i + j], ans[i] + abs(h[i] - h[i + j]))", "+print((ans[-1]))" ]
false
0.038095
0.092808
0.410475
[ "s361970047", "s247419321" ]
u761320129
p02984
python
s727144591
s802968429
132
118
14,100
14,092
Accepted
Accepted
10.61
N = list(map(int,input().split())) A = list(map(int,input().split())) x = 0 for a in A: x = (a - x//2) * 2 x //= 2 ans = [] for a in A: ans.append(x) x = (a - x//2) * 2 print((*ans))
N = int(eval(input())) A = list(map(int,input().split())) e = sum(A[::2]) o = sum(A[1::2]) ans = [e-o] for a in A: ans.append(2*(a-ans[-1]//2)) ans.pop() print((*ans))
13
9
200
171
N = list(map(int, input().split())) A = list(map(int, input().split())) x = 0 for a in A: x = (a - x // 2) * 2 x //= 2 ans = [] for a in A: ans.append(x) x = (a - x // 2) * 2 print((*ans))
N = int(eval(input())) A = list(map(int, input().split())) e = sum(A[::2]) o = sum(A[1::2]) ans = [e - o] for a in A: ans.append(2 * (a - ans[-1] // 2)) ans.pop() print((*ans))
false
30.769231
[ "-N = list(map(int, input().split()))", "+N = int(eval(input()))", "-x = 0", "+e = sum(A[::2])", "+o = sum(A[1::2])", "+ans = [e - o]", "- x = (a - x // 2) * 2", "-x //= 2", "-ans = []", "-for a in A:", "- ans.append(x)", "- x = (a - x // 2) * 2", "+ ans.append(2 * (a - ans[-1] // 2))", "+ans.pop()" ]
false
0.036201
0.063443
0.570608
[ "s727144591", "s802968429" ]
u607074939
p03644
python
s681260188
s520394499
20
17
3,060
3,060
Accepted
Accepted
15
N=int(eval(input())) n=1 while(2*n<=N): n*=2 print(n)
n = int(eval(input())) count = 0 max = 0 for i in range(1, n+1): while(i%2 ==0): i = i/2 count +=1 if(max < count): max = count count = 0 print((2**max))
7
11
59
191
N = int(eval(input())) n = 1 while 2 * n <= N: n *= 2 print(n)
n = int(eval(input())) count = 0 max = 0 for i in range(1, n + 1): while i % 2 == 0: i = i / 2 count += 1 if max < count: max = count count = 0 print((2**max))
false
36.363636
[ "-N = int(eval(input()))", "-n = 1", "-while 2 * n <= N:", "- n *= 2", "-print(n)", "+n = int(eval(input()))", "+count = 0", "+max = 0", "+for i in range(1, n + 1):", "+ while i % 2 == 0:", "+ i = i / 2", "+ count += 1", "+ if max < count:", "+ max = count", "+ count = 0", "+print((2**max))" ]
false
0.068574
0.073285
0.935717
[ "s681260188", "s520394499" ]
u151785909
p02862
python
s622050824
s337065330
762
122
115,180
3,064
Accepted
Accepted
83.99
MOD=10**9+7 x , y = list(map(int, input().split())) a=(2*x-y)//3 b=(2*y-x)//3 if 2*a+b!=x: print((0)) exit() factorial = [1] inverse = [1] n=a+b r=a for i in range(1, n+2): factorial.append(factorial[-1] * i % MOD) inverse.append(pow(factorial[-1], MOD - 2, MOD)) def combi(n, r): if n < r or r < 0: return 0 elif r == 0: return 1 return factorial[n] * inverse[r] * inverse[n - r] % MOD ans = combi(n,r) print(ans)
N=10**9+7 x , y = list(map(int, input().split())) a=(2*x-y)//3 b=(2*y-x)//3 if 2*a+b!=x: print((0)) exit() n=a+b r=a def fac(n,r,N): ans=1 for i in range(r): ans=ans*(n-i)%N return ans def combi(n,r,N): if n<r or n<0 or r<0: ans = 0 return ans r= min(r, n-r) ans = fac(n,r,N)*pow(fac(r,r,N),N-2,N)%N return ans ans = combi(n,r,N) print(ans)
27
28
482
425
MOD = 10**9 + 7 x, y = list(map(int, input().split())) a = (2 * x - y) // 3 b = (2 * y - x) // 3 if 2 * a + b != x: print((0)) exit() factorial = [1] inverse = [1] n = a + b r = a for i in range(1, n + 2): factorial.append(factorial[-1] * i % MOD) inverse.append(pow(factorial[-1], MOD - 2, MOD)) def combi(n, r): if n < r or r < 0: return 0 elif r == 0: return 1 return factorial[n] * inverse[r] * inverse[n - r] % MOD ans = combi(n, r) print(ans)
N = 10**9 + 7 x, y = list(map(int, input().split())) a = (2 * x - y) // 3 b = (2 * y - x) // 3 if 2 * a + b != x: print((0)) exit() n = a + b r = a def fac(n, r, N): ans = 1 for i in range(r): ans = ans * (n - i) % N return ans def combi(n, r, N): if n < r or n < 0 or r < 0: ans = 0 return ans r = min(r, n - r) ans = fac(n, r, N) * pow(fac(r, r, N), N - 2, N) % N return ans ans = combi(n, r, N) print(ans)
false
3.571429
[ "-MOD = 10**9 + 7", "+N = 10**9 + 7", "-factorial = [1]", "-inverse = [1]", "-for i in range(1, n + 2):", "- factorial.append(factorial[-1] * i % MOD)", "- inverse.append(pow(factorial[-1], MOD - 2, MOD))", "-def combi(n, r):", "- if n < r or r < 0:", "- return 0", "- elif r == 0:", "- return 1", "- return factorial[n] * inverse[r] * inverse[n - r] % MOD", "+def fac(n, r, N):", "+ ans = 1", "+ for i in range(r):", "+ ans = ans * (n - i) % N", "+ return ans", "-ans = combi(n, r)", "+def combi(n, r, N):", "+ if n < r or n < 0 or r < 0:", "+ ans = 0", "+ return ans", "+ r = min(r, n - r)", "+ ans = fac(n, r, N) * pow(fac(r, r, N), N - 2, N) % N", "+ return ans", "+", "+", "+ans = combi(n, r, N)" ]
false
0.005851
0.052494
0.111461
[ "s622050824", "s337065330" ]
u861141787
p02690
python
s545932060
s243235030
47
39
9,172
9,052
Accepted
Accepted
17.02
x = int(eval(input())) for a in range(-118, 120): for b in range(-118, 120): if x == a ** 5 - b ** 5: print((a, b)) exit()
x = int(eval(input())) for a in range(-118, 120): for b in range(-119, 118): if x == a ** 5 - b ** 5: print((a, b)) exit()
7
7
157
157
x = int(eval(input())) for a in range(-118, 120): for b in range(-118, 120): if x == a**5 - b**5: print((a, b)) exit()
x = int(eval(input())) for a in range(-118, 120): for b in range(-119, 118): if x == a**5 - b**5: print((a, b)) exit()
false
0
[ "- for b in range(-118, 120):", "+ for b in range(-119, 118):" ]
false
0.050589
0.055219
0.916157
[ "s545932060", "s243235030" ]
u730769327
p03775
python
s593773936
s337812258
174
63
38,512
64,192
Accepted
Accepted
63.79
n=int(eval(input())) for i in range(int((n**0.5+1)//1),0,-1): if n/i%1==0: f=max(len(str(i)),len(str(n//i))) break print(f)
n=int(eval(input())) s=10**11 for i in range(1,int(n**0.5)+1): if n%i==0: s=min(s,max(i,n//i)) print((len(str(s))))
7
6
140
118
n = int(eval(input())) for i in range(int((n**0.5 + 1) // 1), 0, -1): if n / i % 1 == 0: f = max(len(str(i)), len(str(n // i))) break print(f)
n = int(eval(input())) s = 10**11 for i in range(1, int(n**0.5) + 1): if n % i == 0: s = min(s, max(i, n // i)) print((len(str(s))))
false
14.285714
[ "-for i in range(int((n**0.5 + 1) // 1), 0, -1):", "- if n / i % 1 == 0:", "- f = max(len(str(i)), len(str(n // i)))", "- break", "-print(f)", "+s = 10**11", "+for i in range(1, int(n**0.5) + 1):", "+ if n % i == 0:", "+ s = min(s, max(i, n // i))", "+print((len(str(s))))" ]
false
0.041683
0.086175
0.483702
[ "s593773936", "s337812258" ]
u770698847
p02412
python
s397821258
s405618432
1,870
10
4,716
4,656
Accepted
Accepted
99.47
while(1): comb = [] count =0 inp = input().split(" ") if inp[0] == "0" and inp[1] == "0": break for i in range(1,int(inp[0])+1): for j in range(1,int(inp[0])+1): if i == j: break sum = i + j if sum > int(inp[1]): j = int(inp[0]) break for k in range(1,int(inp[0])+1): if i == j or i == k or j == k: break sum = i + j + k if sum > int(inp[1]): k = int(inp[0]) break if sum == int(inp[1]): if not ([i,j,k] in comb or [i,k,j] in comb or [j,k,i] in comb or [j,i,k] in comb or [k,i,j] in comb or [k,j,i] in comb): comb.append([i,j,k]) count += 1 print(count)
# coding: UTF-8 def find_comb(n,x): count = 0 #探索 for i in range(1,n-1): for j in range(i+1,n): k = x - i - j #←がi < j < k <= nを満たせばその時点で総和がxとなる if j < k <= n: count += 1 print(count) while(1): n,x = list(map(int, input().split(" "))) if(n == 0 and x == 0): break find_comb(n,x)
26
15
911
375
while 1: comb = [] count = 0 inp = input().split(" ") if inp[0] == "0" and inp[1] == "0": break for i in range(1, int(inp[0]) + 1): for j in range(1, int(inp[0]) + 1): if i == j: break sum = i + j if sum > int(inp[1]): j = int(inp[0]) break for k in range(1, int(inp[0]) + 1): if i == j or i == k or j == k: break sum = i + j + k if sum > int(inp[1]): k = int(inp[0]) break if sum == int(inp[1]): if not ( [i, j, k] in comb or [i, k, j] in comb or [j, k, i] in comb or [j, i, k] in comb or [k, i, j] in comb or [k, j, i] in comb ): comb.append([i, j, k]) count += 1 print(count)
# coding: UTF-8 def find_comb(n, x): count = 0 # 探索 for i in range(1, n - 1): for j in range(i + 1, n): k = x - i - j # ←がi < j < k <= nを満たせばその時点で総和がxとなる if j < k <= n: count += 1 print(count) while 1: n, x = list(map(int, input().split(" "))) if n == 0 and x == 0: break find_comb(n, x)
false
42.307692
[ "+# coding: UTF-8", "+def find_comb(n, x):", "+ count = 0", "+ # 探索", "+ for i in range(1, n - 1):", "+ for j in range(i + 1, n):", "+ k = x - i - j # ←がi < j < k <= nを満たせばその時点で総和がxとなる", "+ if j < k <= n:", "+ count += 1", "+ print(count)", "+", "+", "- comb = []", "- count = 0", "- inp = input().split(\" \")", "- if inp[0] == \"0\" and inp[1] == \"0\":", "+ n, x = list(map(int, input().split(\" \")))", "+ if n == 0 and x == 0:", "- for i in range(1, int(inp[0]) + 1):", "- for j in range(1, int(inp[0]) + 1):", "- if i == j:", "- break", "- sum = i + j", "- if sum > int(inp[1]):", "- j = int(inp[0])", "- break", "- for k in range(1, int(inp[0]) + 1):", "- if i == j or i == k or j == k:", "- break", "- sum = i + j + k", "- if sum > int(inp[1]):", "- k = int(inp[0])", "- break", "- if sum == int(inp[1]):", "- if not (", "- [i, j, k] in comb", "- or [i, k, j] in comb", "- or [j, k, i] in comb", "- or [j, i, k] in comb", "- or [k, i, j] in comb", "- or [k, j, i] in comb", "- ):", "- comb.append([i, j, k])", "- count += 1", "- print(count)", "+ find_comb(n, x)" ]
false
0.04929
0.051021
0.966069
[ "s397821258", "s405618432" ]
u296518383
p03127
python
s700386684
s893829381
88
69
14,252
15,020
Accepted
Accepted
21.59
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) N=int(eval(input())) A=list(map(int,input().split())) g=A[0] for i in range(1,N): g=gcd(g,A[i]) print(g)
N = int(eval(input())) A = list(map(int, input().split())) def gcd(x, y): while y: x, y = y, x % y return x answer = A[0] for i in range(1, N): answer = gcd(A[i], answer) print(answer)
14
13
184
205
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) N = int(eval(input())) A = list(map(int, input().split())) g = A[0] for i in range(1, N): g = gcd(g, A[i]) print(g)
N = int(eval(input())) A = list(map(int, input().split())) def gcd(x, y): while y: x, y = y, x % y return x answer = A[0] for i in range(1, N): answer = gcd(A[i], answer) print(answer)
false
7.142857
[ "-def gcd(a, b):", "- if b == 0:", "- return a", "- else:", "- return gcd(b, a % b)", "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-g = A[0]", "+def gcd(x, y):", "+ while y:", "+ x, y = y, x % y", "+ return x", "+", "+", "+answer = A[0]", "- g = gcd(g, A[i])", "-print(g)", "+ answer = gcd(A[i], answer)", "+print(answer)" ]
false
0.035974
0.041412
0.86867
[ "s700386684", "s893829381" ]
u747602774
p03329
python
s181731143
s465995424
245
208
3,064
45,040
Accepted
Accepted
15.1
def nbasesum(value,n): nbasevalue = 0 while value > 0: nbasevalue += value%n value //= n return nbasevalue N = int(eval(input())) ans = nbasesum(N,9) for i in range(N+1): c6 = i c9 = N-i ans = min(ans, nbasesum(c9,9)+nbasesum(c6,6)) print(ans)
n = int(eval(input())) m = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049] dp = [10**6 for i in range(100001)] for mi in m: dp[mi] = 1 for i in range(1,100001): for mi in m: if i+mi <= 100000: dp[i+mi] = min(dp[i+mi],dp[i]+1) else: break print((dp[n]))
16
12
296
316
def nbasesum(value, n): nbasevalue = 0 while value > 0: nbasevalue += value % n value //= n return nbasevalue N = int(eval(input())) ans = nbasesum(N, 9) for i in range(N + 1): c6 = i c9 = N - i ans = min(ans, nbasesum(c9, 9) + nbasesum(c6, 6)) print(ans)
n = int(eval(input())) m = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049] dp = [10**6 for i in range(100001)] for mi in m: dp[mi] = 1 for i in range(1, 100001): for mi in m: if i + mi <= 100000: dp[i + mi] = min(dp[i + mi], dp[i] + 1) else: break print((dp[n]))
false
25
[ "-def nbasesum(value, n):", "- nbasevalue = 0", "- while value > 0:", "- nbasevalue += value % n", "- value //= n", "- return nbasevalue", "-", "-", "-N = int(eval(input()))", "-ans = nbasesum(N, 9)", "-for i in range(N + 1):", "- c6 = i", "- c9 = N - i", "- ans = min(ans, nbasesum(c9, 9) + nbasesum(c6, 6))", "-print(ans)", "+n = int(eval(input()))", "+m = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]", "+dp = [10**6 for i in range(100001)]", "+for mi in m:", "+ dp[mi] = 1", "+for i in range(1, 100001):", "+ for mi in m:", "+ if i + mi <= 100000:", "+ dp[i + mi] = min(dp[i + mi], dp[i] + 1)", "+ else:", "+ break", "+print((dp[n]))" ]
false
0.212186
0.007447
28.494011
[ "s181731143", "s465995424" ]
u094191970
p02866
python
s967116681
s133184286
155
105
21,980
24,316
Accepted
Accepted
32.26
from collections import Counter n=int(eval(input())) d=list(map(int,input().split())) if d[0]!=0: print((0)) exit() c=Counter(d) c=sorted(list(c.items()),key=lambda x:x[0]) if c[0]!=(0,1): print((0)) exit() ans=1 check=1 for i in range(1,len(c)): if c[i][0]!=check: print((0)) exit() check+=1 ans*=c[i-1][1]**c[i][1] ans%=998244353 print((ans%998244353))
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) from collections import Counter n=int(eval(input())) d=lnii() mod=998244353 c=Counter(d) max_key=max(d) if d[0]!=0 or c[0]!=1: print((0)) exit() ans=1 patterns=1 for i in range(max_key+1): p_num=c[i] ans*=patterns**p_num ans%=mod patterns=p_num print(ans)
22
26
404
409
from collections import Counter n = int(eval(input())) d = list(map(int, input().split())) if d[0] != 0: print((0)) exit() c = Counter(d) c = sorted(list(c.items()), key=lambda x: x[0]) if c[0] != (0, 1): print((0)) exit() ans = 1 check = 1 for i in range(1, len(c)): if c[i][0] != check: print((0)) exit() check += 1 ans *= c[i - 1][1] ** c[i][1] ans %= 998244353 print((ans % 998244353))
from sys import stdin nii = lambda: list(map(int, stdin.readline().split())) lnii = lambda: list(map(int, stdin.readline().split())) from collections import Counter n = int(eval(input())) d = lnii() mod = 998244353 c = Counter(d) max_key = max(d) if d[0] != 0 or c[0] != 1: print((0)) exit() ans = 1 patterns = 1 for i in range(max_key + 1): p_num = c[i] ans *= patterns**p_num ans %= mod patterns = p_num print(ans)
false
15.384615
[ "+from sys import stdin", "+", "+nii = lambda: list(map(int, stdin.readline().split()))", "+lnii = lambda: list(map(int, stdin.readline().split()))", "-d = list(map(int, input().split()))", "-if d[0] != 0:", "- print((0))", "- exit()", "+d = lnii()", "+mod = 998244353", "-c = sorted(list(c.items()), key=lambda x: x[0])", "-if c[0] != (0, 1):", "+max_key = max(d)", "+if d[0] != 0 or c[0] != 1:", "-check = 1", "-for i in range(1, len(c)):", "- if c[i][0] != check:", "- print((0))", "- exit()", "- check += 1", "- ans *= c[i - 1][1] ** c[i][1]", "- ans %= 998244353", "-print((ans % 998244353))", "+patterns = 1", "+for i in range(max_key + 1):", "+ p_num = c[i]", "+ ans *= patterns**p_num", "+ ans %= mod", "+ patterns = p_num", "+print(ans)" ]
false
0.040877
0.04086
1.000413
[ "s967116681", "s133184286" ]
u312025627
p03145
python
s630490101
s071084121
184
169
38,384
38,384
Accepted
Accepted
8.15
ab,bc,ca = (int(i) for i in input().split()) print((ab*bc//2))
def main(): a, b, c = (int(i) for i in input().split()) from math import sqrt s = (a + b + c) / 2 print((int(sqrt(s*(s-a)*(s-b)*(s-c))))) if __name__ == '__main__': main()
2
9
61
200
ab, bc, ca = (int(i) for i in input().split()) print((ab * bc // 2))
def main(): a, b, c = (int(i) for i in input().split()) from math import sqrt s = (a + b + c) / 2 print((int(sqrt(s * (s - a) * (s - b) * (s - c))))) if __name__ == "__main__": main()
false
77.777778
[ "-ab, bc, ca = (int(i) for i in input().split())", "-print((ab * bc // 2))", "+def main():", "+ a, b, c = (int(i) for i in input().split())", "+ from math import sqrt", "+", "+ s = (a + b + c) / 2", "+ print((int(sqrt(s * (s - a) * (s - b) * (s - c)))))", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.046442
0.128216
0.362215
[ "s630490101", "s071084121" ]
u887207211
p03779
python
s908696745
s632335997
31
27
3,060
3,060
Accepted
Accepted
12.9
X = int(eval(input())) for i in range(1,X+1): if((i*(i+1))/2 >= X): print(i) break
import sys stdin = sys.stdin ns = lambda : stdin.readline().rstrip() na = lambda : list(map(int, stdin.readline().split())) ni = lambda : int(ns()) def main(): n = ni() f = lambda x: (x * (x+1)) // 2 for i in range(1, n+1): if (f(i) >= n): print(i) return main()
6
15
92
294
X = int(eval(input())) for i in range(1, X + 1): if (i * (i + 1)) / 2 >= X: print(i) break
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() na = lambda: list(map(int, stdin.readline().split())) ni = lambda: int(ns()) def main(): n = ni() f = lambda x: (x * (x + 1)) // 2 for i in range(1, n + 1): if f(i) >= n: print(i) return main()
false
60
[ "-X = int(eval(input()))", "-for i in range(1, X + 1):", "- if (i * (i + 1)) / 2 >= X:", "- print(i)", "- break", "+import sys", "+", "+stdin = sys.stdin", "+ns = lambda: stdin.readline().rstrip()", "+na = lambda: list(map(int, stdin.readline().split()))", "+ni = lambda: int(ns())", "+", "+", "+def main():", "+ n = ni()", "+ f = lambda x: (x * (x + 1)) // 2", "+ for i in range(1, n + 1):", "+ if f(i) >= n:", "+ print(i)", "+ return", "+", "+", "+main()" ]
false
0.03902
0.180077
0.216686
[ "s908696745", "s632335997" ]
u546285759
p02116
python
s599370316
s937955572
70
20
7,696
7,696
Accepted
Accepted
71.43
n = int(eval(input())) print(((n+1) &- (n+1)))
n = int(eval(input())) + 1 print((n &- n))
2
2
39
35
n = int(eval(input())) print(((n + 1) & -(n + 1)))
n = int(eval(input())) + 1 print((n & -n))
false
0
[ "-n = int(eval(input()))", "-print(((n + 1) & -(n + 1)))", "+n = int(eval(input())) + 1", "+print((n & -n))" ]
false
0.043134
0.036368
1.186041
[ "s599370316", "s937955572" ]
u254871849
p03329
python
s160845961
s751283959
1,113
105
20,244
3,064
Accepted
Accepted
90.57
import sys from math import log, floor n = int(sys.stdin.readline().rstrip()) def main(): cand = set() for i in range(floor(log(n, 6)) + 1): if 6 ** i <= n: cand.add(6 ** i) if 9 ** i <= n: cand.add(9 ** i) cand = sorted(cand) res = set([0]) cnt = 0 while True: nex = set() for val in res: for c in cand: if val + c <= n: nex.add(val + c) else: break cnt += 1 if n in nex: return cnt res = nex if __name__ == '__main__': ans = main() print(ans)
import sys n = int(sys.stdin.readline().rstrip()) def main(): bit6 = [0] * 8 bit9 = [0] * 7 b = n for i in range(5, -1, -1): q, r = divmod(b, 9 ** i) bit9[i] = q b = r res = sum(bit6) + sum(bit9) for _ in range(n): i = 0 while True: bit6[i] += 1 if bit6[i] == 6: bit6[i] = 0 i += 1 else: break i = 0 while True: bit9[i] -= 1 if bit9[i] == -1: bit9[i] = 8 i += 1 else: break res = min(res, sum(bit6) + sum(bit9)) return res if __name__ == '__main__': ans = main() print(ans)
32
41
691
797
import sys from math import log, floor n = int(sys.stdin.readline().rstrip()) def main(): cand = set() for i in range(floor(log(n, 6)) + 1): if 6**i <= n: cand.add(6**i) if 9**i <= n: cand.add(9**i) cand = sorted(cand) res = set([0]) cnt = 0 while True: nex = set() for val in res: for c in cand: if val + c <= n: nex.add(val + c) else: break cnt += 1 if n in nex: return cnt res = nex if __name__ == "__main__": ans = main() print(ans)
import sys n = int(sys.stdin.readline().rstrip()) def main(): bit6 = [0] * 8 bit9 = [0] * 7 b = n for i in range(5, -1, -1): q, r = divmod(b, 9**i) bit9[i] = q b = r res = sum(bit6) + sum(bit9) for _ in range(n): i = 0 while True: bit6[i] += 1 if bit6[i] == 6: bit6[i] = 0 i += 1 else: break i = 0 while True: bit9[i] -= 1 if bit9[i] == -1: bit9[i] = 8 i += 1 else: break res = min(res, sum(bit6) + sum(bit9)) return res if __name__ == "__main__": ans = main() print(ans)
false
21.95122
[ "-from math import log, floor", "- cand = set()", "- for i in range(floor(log(n, 6)) + 1):", "- if 6**i <= n:", "- cand.add(6**i)", "- if 9**i <= n:", "- cand.add(9**i)", "- cand = sorted(cand)", "- res = set([0])", "- cnt = 0", "- while True:", "- nex = set()", "- for val in res:", "- for c in cand:", "- if val + c <= n:", "- nex.add(val + c)", "- else:", "- break", "- cnt += 1", "- if n in nex:", "- return cnt", "- res = nex", "+ bit6 = [0] * 8", "+ bit9 = [0] * 7", "+ b = n", "+ for i in range(5, -1, -1):", "+ q, r = divmod(b, 9**i)", "+ bit9[i] = q", "+ b = r", "+ res = sum(bit6) + sum(bit9)", "+ for _ in range(n):", "+ i = 0", "+ while True:", "+ bit6[i] += 1", "+ if bit6[i] == 6:", "+ bit6[i] = 0", "+ i += 1", "+ else:", "+ break", "+ i = 0", "+ while True:", "+ bit9[i] -= 1", "+ if bit9[i] == -1:", "+ bit9[i] = 8", "+ i += 1", "+ else:", "+ break", "+ res = min(res, sum(bit6) + sum(bit9))", "+ return res" ]
false
0.116117
0.039578
2.933913
[ "s160845961", "s751283959" ]
u564902833
p03103
python
s698284681
s513274217
722
564
35,796
58,824
Accepted
Accepted
21.88
from functools import reduce N, M = list(map(int, input().split())) A, B = list(zip(*sorted((list(map(int, input().split())) for _ in range(N))))) ans = reduce(lambda acc, t: (acc[0] + t[0] * min(max(0, M - acc[1]), t[1]), acc[1] + t[1]), list(zip(A, B)), (0, 0))[0] print(ans)
from functools import reduce # 入力 N, M = list(map(int, input().split())) A, B = list(zip(*(list(map(int, input().split())) for _ in range(N)))) # 1本あたりの値段が安い店から順に購入 ans = reduce( lambda acc, t: ( acc[0] + t[0] * min(t[1], M - acc[1]), acc[1] + t[1] ) if acc[1] < M else acc, sorted(zip(A, B)), (0, 0) )[0] # 出力 print(ans)
5
18
264
359
from functools import reduce N, M = list(map(int, input().split())) A, B = list(zip(*sorted((list(map(int, input().split())) for _ in range(N))))) ans = reduce( lambda acc, t: (acc[0] + t[0] * min(max(0, M - acc[1]), t[1]), acc[1] + t[1]), list(zip(A, B)), (0, 0), )[0] print(ans)
from functools import reduce # 入力 N, M = list(map(int, input().split())) A, B = list(zip(*(list(map(int, input().split())) for _ in range(N)))) # 1本あたりの値段が安い店から順に購入 ans = reduce( lambda acc, t: (acc[0] + t[0] * min(t[1], M - acc[1]), acc[1] + t[1]) if acc[1] < M else acc, sorted(zip(A, B)), (0, 0), )[0] # 出力 print(ans)
false
72.222222
[ "+# 入力", "-A, B = list(zip(*sorted((list(map(int, input().split())) for _ in range(N)))))", "+A, B = list(zip(*(list(map(int, input().split())) for _ in range(N))))", "+# 1本あたりの値段が安い店から順に購入", "- lambda acc, t: (acc[0] + t[0] * min(max(0, M - acc[1]), t[1]), acc[1] + t[1]),", "- list(zip(A, B)),", "+ lambda acc, t: (acc[0] + t[0] * min(t[1], M - acc[1]), acc[1] + t[1])", "+ if acc[1] < M", "+ else acc,", "+ sorted(zip(A, B)),", "+# 出力" ]
false
0.041473
0.114701
0.361574
[ "s698284681", "s513274217" ]
u970197315
p03352
python
s134519030
s912468210
33
17
3,060
2,940
Accepted
Accepted
48.48
x=int(eval(input())) a=set() for i in range(1,1001): for j in range(2,34): t=i**j if t<=x: a.add(i**j) a=list(a) a.sort() print((a[-1]))
x=int(eval(input())) ans=0 for i in range(1,35): for j in range(2,10): t=i**j if t<=x: ans=max(ans,t) print(ans)
10
11
153
136
x = int(eval(input())) a = set() for i in range(1, 1001): for j in range(2, 34): t = i**j if t <= x: a.add(i**j) a = list(a) a.sort() print((a[-1]))
x = int(eval(input())) ans = 0 for i in range(1, 35): for j in range(2, 10): t = i**j if t <= x: ans = max(ans, t) print(ans)
false
9.090909
[ "-a = set()", "-for i in range(1, 1001):", "- for j in range(2, 34):", "+ans = 0", "+for i in range(1, 35):", "+ for j in range(2, 10):", "- a.add(i**j)", "-a = list(a)", "-a.sort()", "-print((a[-1]))", "+ ans = max(ans, t)", "+print(ans)" ]
false
0.082466
0.037705
2.187147
[ "s134519030", "s912468210" ]
u077291787
p03608
python
s601519361
s522278264
348
210
9,828
9,836
Accepted
Accepted
39.66
# ABC073D - joisino's travel (218ms) from heapq import heapify, heappop, heappush from itertools import permutations def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list: dist = [float("inf")] * size queue = [(0, start)] heapify(queue) while queue: cost, v = heappop(queue) if cost > dist[v]: continue dist[v] = cost for next_cost, u in G[v]: if cost + next_cost < dist[u]: heappush(queue, (cost + next_cost, u)) return dist def main(): global G, N N, M, R, *RABC = list(map(int, open(0).read().split())) visit, ABC = RABC[:R], RABC[R:] G = [[] for _ in range(N + 1)] for v, u, cost in zip(*[iter(ABC)] * 3): G[v].append((cost, u)), G[u].append((cost, v)) dist = {v: dijkstra(G, N + 1, v) for v in visit} ans = float("inf") for perm in permutations(visit): cur = sum(dist[v][u] for v, u in zip(perm, perm[1:])) ans = min(ans, cur) print(ans) if __name__ == "__main__": main()
# ABC073D - joisino's travel (218ms) from heapq import heapify, heappop, heappush from itertools import permutations def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list: dist = [float("inf")] * size unchecked = size - 1 # vertex_0 won't appear in 1-idx graph queue = [(0, start)] heapify(queue) while queue: cost, v = heappop(queue) if cost > dist[v]: continue dist[v] = cost for next_cost, u in G[v]: if cost + next_cost < dist[u]: heappush(queue, (cost + next_cost, u)) unchecked -= 1 if not unchecked: return dist def main(): global G, N N, M, R, *RABC = list(map(int, open(0).read().split())) visit, ABC = RABC[:R], RABC[R:] G = [[] for _ in range(N + 1)] for v, u, cost in zip(*[iter(ABC)] * 3): G[v].append((cost, u)), G[u].append((cost, v)) dist = {v: dijkstra(G, N + 1, v) for v in visit} ans = float("inf") for perm in permutations(visit): cur = sum(dist[v][u] for v, u in zip(perm, perm[1:])) ans = min(ans, cur) print(ans) if __name__ == "__main__": main()
37
40
1,082
1,207
# ABC073D - joisino's travel (218ms) from heapq import heapify, heappop, heappush from itertools import permutations def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list: dist = [float("inf")] * size queue = [(0, start)] heapify(queue) while queue: cost, v = heappop(queue) if cost > dist[v]: continue dist[v] = cost for next_cost, u in G[v]: if cost + next_cost < dist[u]: heappush(queue, (cost + next_cost, u)) return dist def main(): global G, N N, M, R, *RABC = list(map(int, open(0).read().split())) visit, ABC = RABC[:R], RABC[R:] G = [[] for _ in range(N + 1)] for v, u, cost in zip(*[iter(ABC)] * 3): G[v].append((cost, u)), G[u].append((cost, v)) dist = {v: dijkstra(G, N + 1, v) for v in visit} ans = float("inf") for perm in permutations(visit): cur = sum(dist[v][u] for v, u in zip(perm, perm[1:])) ans = min(ans, cur) print(ans) if __name__ == "__main__": main()
# ABC073D - joisino's travel (218ms) from heapq import heapify, heappop, heappush from itertools import permutations def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list: dist = [float("inf")] * size unchecked = size - 1 # vertex_0 won't appear in 1-idx graph queue = [(0, start)] heapify(queue) while queue: cost, v = heappop(queue) if cost > dist[v]: continue dist[v] = cost for next_cost, u in G[v]: if cost + next_cost < dist[u]: heappush(queue, (cost + next_cost, u)) unchecked -= 1 if not unchecked: return dist def main(): global G, N N, M, R, *RABC = list(map(int, open(0).read().split())) visit, ABC = RABC[:R], RABC[R:] G = [[] for _ in range(N + 1)] for v, u, cost in zip(*[iter(ABC)] * 3): G[v].append((cost, u)), G[u].append((cost, v)) dist = {v: dijkstra(G, N + 1, v) for v in visit} ans = float("inf") for perm in permutations(visit): cur = sum(dist[v][u] for v, u in zip(perm, perm[1:])) ans = min(ans, cur) print(ans) if __name__ == "__main__": main()
false
7.5
[ "+ unchecked = size - 1 # vertex_0 won't appear in 1-idx graph", "- return dist", "+ unchecked -= 1", "+ if not unchecked:", "+ return dist" ]
false
0.045432
0.041117
1.104953
[ "s601519361", "s522278264" ]
u620084012
p03241
python
s278192434
s794318011
181
21
38,640
3,064
Accepted
Accepted
88.4
import math N, M = list(map(int,input().split())) P = [] for k in range(1,math.floor(math.sqrt(M))+1): if M % k == 0: P.append(k) P.append(M//k) ans = 1 for e in P: if e*N <= M: ans = max(ans,e) print(ans)
import math N, M = list(map(int,input().split())) b = 0 P = [1] for k in range(2,math.floor(math.sqrt(M))+1): if M % k == 0: P.append(k) P.append(M//k) P = sorted(P) for e in P: if e >= N: print((M//e)) exit(0) print((1))
13
16
245
269
import math N, M = list(map(int, input().split())) P = [] for k in range(1, math.floor(math.sqrt(M)) + 1): if M % k == 0: P.append(k) P.append(M // k) ans = 1 for e in P: if e * N <= M: ans = max(ans, e) print(ans)
import math N, M = list(map(int, input().split())) b = 0 P = [1] for k in range(2, math.floor(math.sqrt(M)) + 1): if M % k == 0: P.append(k) P.append(M // k) P = sorted(P) for e in P: if e >= N: print((M // e)) exit(0) print((1))
false
18.75
[ "-P = []", "-for k in range(1, math.floor(math.sqrt(M)) + 1):", "+b = 0", "+P = [1]", "+for k in range(2, math.floor(math.sqrt(M)) + 1):", "-ans = 1", "+P = sorted(P)", "- if e * N <= M:", "- ans = max(ans, e)", "-print(ans)", "+ if e >= N:", "+ print((M // e))", "+ exit(0)", "+print((1))" ]
false
0.03574
0.083917
0.425905
[ "s278192434", "s794318011" ]
u047393579
p03745
python
s283415855
s154902661
79
69
14,252
14,252
Accepted
Accepted
12.66
N = int(eval(input())) sub = 0 count = 1 A = [int(i) for i in input().split()] if N > 1: pre_num = A[1] pre_sub = A[1] - A[0] for num in A[2:]: if not pre_num == num: if pre_sub * (num - pre_num) < 0: count += 1 pre_sub = 0 else: pre_sub = num - pre_num pre_num = num print(count)
_ = int(eval(input())) A = [int(a) for a in input().split()] selector = 0 count = 1 pre_a = A[0] for a in A[1:]: if selector == 0: selector = a - pre_a elif selector * (a - pre_a) < 0: count += 1 selector = 0 pre_a = a print(count)
16
13
354
273
N = int(eval(input())) sub = 0 count = 1 A = [int(i) for i in input().split()] if N > 1: pre_num = A[1] pre_sub = A[1] - A[0] for num in A[2:]: if not pre_num == num: if pre_sub * (num - pre_num) < 0: count += 1 pre_sub = 0 else: pre_sub = num - pre_num pre_num = num print(count)
_ = int(eval(input())) A = [int(a) for a in input().split()] selector = 0 count = 1 pre_a = A[0] for a in A[1:]: if selector == 0: selector = a - pre_a elif selector * (a - pre_a) < 0: count += 1 selector = 0 pre_a = a print(count)
false
18.75
[ "-N = int(eval(input()))", "-sub = 0", "+_ = int(eval(input()))", "+A = [int(a) for a in input().split()]", "+selector = 0", "-A = [int(i) for i in input().split()]", "-if N > 1:", "- pre_num = A[1]", "- pre_sub = A[1] - A[0]", "-for num in A[2:]:", "- if not pre_num == num:", "- if pre_sub * (num - pre_num) < 0:", "- count += 1", "- pre_sub = 0", "- else:", "- pre_sub = num - pre_num", "- pre_num = num", "+pre_a = A[0]", "+for a in A[1:]:", "+ if selector == 0:", "+ selector = a - pre_a", "+ elif selector * (a - pre_a) < 0:", "+ count += 1", "+ selector = 0", "+ pre_a = a" ]
false
0.095121
0.060808
1.564294
[ "s283415855", "s154902661" ]
u761320129
p03767
python
s351112470
s308176848
249
207
28,776
37,084
Accepted
Accepted
16.87
N = eval(input()) arr = list(map(int, input().split())) arr.sort() sum = 0 for i in range(3*N-2, N-1, -2): sum += arr[i] print(sum)
N = int(eval(input())) src = list(map(int,input().split())) src.sort(reverse=True) print((sum(src[1:2*N+1:2])))
7
4
130
107
N = eval(input()) arr = list(map(int, input().split())) arr.sort() sum = 0 for i in range(3 * N - 2, N - 1, -2): sum += arr[i] print(sum)
N = int(eval(input())) src = list(map(int, input().split())) src.sort(reverse=True) print((sum(src[1 : 2 * N + 1 : 2])))
false
42.857143
[ "-N = eval(input())", "-arr = list(map(int, input().split()))", "-arr.sort()", "-sum = 0", "-for i in range(3 * N - 2, N - 1, -2):", "- sum += arr[i]", "-print(sum)", "+N = int(eval(input()))", "+src = list(map(int, input().split()))", "+src.sort(reverse=True)", "+print((sum(src[1 : 2 * N + 1 : 2])))" ]
false
0.041651
0.037393
1.113874
[ "s351112470", "s308176848" ]
u312025627
p03371
python
s211564242
s456686847
187
66
38,256
61,904
Accepted
Accepted
64.71
def main(): a, b, c, x, y = (int(i) for i in input().split()) ans = a*x + b*y ans = min(ans, 2*c*max(x, y)) if x < y: d = y - x d *= b else: d = x - y d *= a ans = min(ans, 2*c*min(x, y)+d) print(ans) if __name__ == '__main__': main()
def main(): a, b, c, x, y = (int(i) for i in input().split()) v1 = 2*c*max(x, y) v2 = 2*c*min(x, y) + (y-x if x < y else x-y)*(b if x < y else a) v3 = a*x + b*y print((min(v1, v2, v3))) if __name__ == '__main__': main()
16
10
316
253
def main(): a, b, c, x, y = (int(i) for i in input().split()) ans = a * x + b * y ans = min(ans, 2 * c * max(x, y)) if x < y: d = y - x d *= b else: d = x - y d *= a ans = min(ans, 2 * c * min(x, y) + d) print(ans) if __name__ == "__main__": main()
def main(): a, b, c, x, y = (int(i) for i in input().split()) v1 = 2 * c * max(x, y) v2 = 2 * c * min(x, y) + (y - x if x < y else x - y) * (b if x < y else a) v3 = a * x + b * y print((min(v1, v2, v3))) if __name__ == "__main__": main()
false
37.5
[ "- ans = a * x + b * y", "- ans = min(ans, 2 * c * max(x, y))", "- if x < y:", "- d = y - x", "- d *= b", "- else:", "- d = x - y", "- d *= a", "- ans = min(ans, 2 * c * min(x, y) + d)", "- print(ans)", "+ v1 = 2 * c * max(x, y)", "+ v2 = 2 * c * min(x, y) + (y - x if x < y else x - y) * (b if x < y else a)", "+ v3 = a * x + b * y", "+ print((min(v1, v2, v3)))" ]
false
0.007527
0.034986
0.215155
[ "s211564242", "s456686847" ]
u168578024
p03061
python
s797001049
s291758013
953
504
111,648
56,256
Accepted
Accepted
47.11
from fractions import gcd import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline import copy class SegmentTree: def __init__(self, N, func, I): self.sz = 2**(N-1).bit_length() self.func = func self.I = copy.deepcopy(I) self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)] def assign(self, k, x): self.seg[k + self.sz] = copy.deepcopy(x) def build(self): for i in range(self.sz - 1, 0, -1): self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1]) def update(self, k, x): k += self.sz self.seg[k] = copy.deepcopy(x) while k > 1: k >>= 1 self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1]) def query(self, a, b): L = copy.deepcopy(self.I) R = copy.deepcopy(self.I) a += self.sz b += self.sz while a < b: if a & 1: L = self.func(L, self.seg[a]) a += 1 if b & 1: b -= 1 R = self.func(self.seg[b], R) a >>= 1 b >>= 1 return self.func(L, R) def main(): N = int(readline()) m = list(map(int, read().split())) seg = SegmentTree(N, gcd, 0) for i in range(N): seg.assign(i, next(m)) seg.build() ans = 1 for i in range(N): ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N))) print(ans) main()
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline class SegmentTree: def __init__(self, N, func, I): self.func = func self.I = I self.sz = 2**(N-1).bit_length() self.seg = [I] * (self.sz * 2) def assign(self, k, x): self.seg[k + self.sz] = x def build(self): for i in range(self.sz - 1, 0, -1): self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1]) def update(self, k, x): k += self.sz self.seg[k] = x while k > 1: k >>= 1 self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1]) def query(self, a, b): L = self.I R = self.I a += self.sz b += self.sz while a < b: if a & 1: L = self.func(L, self.seg[a]) a += 1 if b & 1: b -= 1 R = self.func(self.seg[b], R) a >>= 1 b >>= 1 return self.func(L, R) def gcd(a, b): while b: a, b = b, a % b return a def main(): N = int(readline()) m = list(map(int,read().split())) seg = SegmentTree(N , gcd , 0) for i in range(N): seg.assign(i , next(m)) seg.build() ans = 1 for i in range(N): ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N))) print(ans) main()
56
59
1,520
1,452
from fractions import gcd import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline import copy class SegmentTree: def __init__(self, N, func, I): self.sz = 2 ** (N - 1).bit_length() self.func = func self.I = copy.deepcopy(I) self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)] def assign(self, k, x): self.seg[k + self.sz] = copy.deepcopy(x) def build(self): for i in range(self.sz - 1, 0, -1): self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1]) def update(self, k, x): k += self.sz self.seg[k] = copy.deepcopy(x) while k > 1: k >>= 1 self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1]) def query(self, a, b): L = copy.deepcopy(self.I) R = copy.deepcopy(self.I) a += self.sz b += self.sz while a < b: if a & 1: L = self.func(L, self.seg[a]) a += 1 if b & 1: b -= 1 R = self.func(self.seg[b], R) a >>= 1 b >>= 1 return self.func(L, R) def main(): N = int(readline()) m = list(map(int, read().split())) seg = SegmentTree(N, gcd, 0) for i in range(N): seg.assign(i, next(m)) seg.build() ans = 1 for i in range(N): ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N))) print(ans) main()
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline class SegmentTree: def __init__(self, N, func, I): self.func = func self.I = I self.sz = 2 ** (N - 1).bit_length() self.seg = [I] * (self.sz * 2) def assign(self, k, x): self.seg[k + self.sz] = x def build(self): for i in range(self.sz - 1, 0, -1): self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1]) def update(self, k, x): k += self.sz self.seg[k] = x while k > 1: k >>= 1 self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1]) def query(self, a, b): L = self.I R = self.I a += self.sz b += self.sz while a < b: if a & 1: L = self.func(L, self.seg[a]) a += 1 if b & 1: b -= 1 R = self.func(self.seg[b], R) a >>= 1 b >>= 1 return self.func(L, R) def gcd(a, b): while b: a, b = b, a % b return a def main(): N = int(readline()) m = list(map(int, read().split())) seg = SegmentTree(N, gcd, 0) for i in range(N): seg.assign(i, next(m)) seg.build() ans = 1 for i in range(N): ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N))) print(ans) main()
false
5.084746
[ "-from fractions import gcd", "-import copy", "+ self.func = func", "+ self.I = I", "- self.func = func", "- self.I = copy.deepcopy(I)", "- self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]", "+ self.seg = [I] * (self.sz * 2)", "- self.seg[k + self.sz] = copy.deepcopy(x)", "+ self.seg[k + self.sz] = x", "- self.seg[k] = copy.deepcopy(x)", "+ self.seg[k] = x", "- L = copy.deepcopy(self.I)", "- R = copy.deepcopy(self.I)", "+ L = self.I", "+ R = self.I", "+", "+", "+def gcd(a, b):", "+ while b:", "+ a, b = b, a % b", "+ return a" ]
false
0.131856
0.073117
1.803358
[ "s797001049", "s291758013" ]
u216392490
p02596
python
s043772087
s404933136
246
183
9,180
9,180
Accepted
Accepted
25.61
import sys import math import time sys.setrecursionlimit(int(1e6)) if False: dprint = print else: def dprint(*args): pass k = list(map(int, input().split()))[0] am = 7 % k i = 1 for i in range(k): if am==0: print(i+1) exit() else: i+=1 am=(am*10+7)%k print('-1')
import sys import math import time sys.setrecursionlimit(int(1e6)) if False: dprint = print else: def dprint(*args): pass k = list(map(int, input().split()))[0] modk = 7 % k i = 1 for i in range(k): if modk == 0: print(i+1) exit() modk = (modk * 10 + 7) % k else: print(-1)
24
22
347
342
import sys import math import time sys.setrecursionlimit(int(1e6)) if False: dprint = print else: def dprint(*args): pass k = list(map(int, input().split()))[0] am = 7 % k i = 1 for i in range(k): if am == 0: print(i + 1) exit() else: i += 1 am = (am * 10 + 7) % k print("-1")
import sys import math import time sys.setrecursionlimit(int(1e6)) if False: dprint = print else: def dprint(*args): pass k = list(map(int, input().split()))[0] modk = 7 % k i = 1 for i in range(k): if modk == 0: print(i + 1) exit() modk = (modk * 10 + 7) % k else: print(-1)
false
8.333333
[ "-am = 7 % k", "+modk = 7 % k", "- if am == 0:", "+ if modk == 0:", "- else:", "- i += 1", "- am = (am * 10 + 7) % k", "-print(\"-1\")", "+ modk = (modk * 10 + 7) % k", "+else:", "+ print(-1)" ]
false
0.226557
0.336837
0.672602
[ "s043772087", "s404933136" ]
u203843959
p03401
python
s592448494
s547658036
256
229
14,048
14,048
Accepted
Accepted
10.55
N=int(eval(input())) alist=list(map(int,input().split())) a2list=[0]+alist+[0] #print(a2list) alldist=0 for i in range(1,N+2): alldist+=abs(a2list[i]-a2list[i-1]) #print(alldist) for i in range(N): if a2list[i+1]-a2list[i]>=0 and a2list[i+2]-a2list[i+1]>=0: print(alldist) elif a2list[i+1]-a2list[i]<=0 and a2list[i+2]-a2list[i+1]<=0: print(alldist) else: dist=alldist-abs(a2list[i+1]-a2list[i])-abs(a2list[i+2]-a2list[i+1])+abs(a2list[i+2]-a2list[i]) print(dist)
N=int(eval(input())) alist=list(map(int,input().split())) a2list=[0]+alist+[0] #print(a2list) alldist=0 for i in range(1,N+2): alldist+=abs(a2list[i]-a2list[i-1]) #print(alldist) for i in range(N): dist=alldist-abs(a2list[i+1]-a2list[i])-abs(a2list[i+2]-a2list[i+1])+abs(a2list[i+2]-a2list[i]) print(dist)
18
13
500
319
N = int(eval(input())) alist = list(map(int, input().split())) a2list = [0] + alist + [0] # print(a2list) alldist = 0 for i in range(1, N + 2): alldist += abs(a2list[i] - a2list[i - 1]) # print(alldist) for i in range(N): if a2list[i + 1] - a2list[i] >= 0 and a2list[i + 2] - a2list[i + 1] >= 0: print(alldist) elif a2list[i + 1] - a2list[i] <= 0 and a2list[i + 2] - a2list[i + 1] <= 0: print(alldist) else: dist = ( alldist - abs(a2list[i + 1] - a2list[i]) - abs(a2list[i + 2] - a2list[i + 1]) + abs(a2list[i + 2] - a2list[i]) ) print(dist)
N = int(eval(input())) alist = list(map(int, input().split())) a2list = [0] + alist + [0] # print(a2list) alldist = 0 for i in range(1, N + 2): alldist += abs(a2list[i] - a2list[i - 1]) # print(alldist) for i in range(N): dist = ( alldist - abs(a2list[i + 1] - a2list[i]) - abs(a2list[i + 2] - a2list[i + 1]) + abs(a2list[i + 2] - a2list[i]) ) print(dist)
false
27.777778
[ "- if a2list[i + 1] - a2list[i] >= 0 and a2list[i + 2] - a2list[i + 1] >= 0:", "- print(alldist)", "- elif a2list[i + 1] - a2list[i] <= 0 and a2list[i + 2] - a2list[i + 1] <= 0:", "- print(alldist)", "- else:", "- dist = (", "- alldist", "- - abs(a2list[i + 1] - a2list[i])", "- - abs(a2list[i + 2] - a2list[i + 1])", "- + abs(a2list[i + 2] - a2list[i])", "- )", "- print(dist)", "+ dist = (", "+ alldist", "+ - abs(a2list[i + 1] - a2list[i])", "+ - abs(a2list[i + 2] - a2list[i + 1])", "+ + abs(a2list[i + 2] - a2list[i])", "+ )", "+ print(dist)" ]
false
0.049827
0.038745
1.286015
[ "s592448494", "s547658036" ]
u823458368
p03846
python
s273294834
s625398847
93
76
14,008
20,560
Accepted
Accepted
18.28
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 if n%2==1: dummy = [0] for i in range(1, 1+(len(a)-1)//2): dummy.append(2*i) dummy.append(2*i) if sorted(a) == dummy: ans = 2**((len(a)-1)//2) else: dummy = [] for i in range(1, 1+(len(a))//2): dummy.append(2*i - 1) dummy.append(2*i - 1) if sorted(a) == dummy: ans = 2**((len(a))//2) print((ans%(10**9 + 7)))
n = int(eval(input())) a = sorted(list(map(int, input().split()))) if len(a)%2==1: tmp = [0] for i in range((len(a)-1)//2): tmp.append((i+1)*2) tmp.append((i+1)*2) if a == tmp: ans = (2**((len(a)-1)//2))%(10**9+7) else: ans = 0 else: tmp = [] for i in range(len(a)//2): tmp.append(2*i+1) tmp.append(2*i+1) if a == tmp: ans = (2**(len(a)//2))%(10**9+7) else: ans = 0 print(ans)
18
22
457
488
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 if n % 2 == 1: dummy = [0] for i in range(1, 1 + (len(a) - 1) // 2): dummy.append(2 * i) dummy.append(2 * i) if sorted(a) == dummy: ans = 2 ** ((len(a) - 1) // 2) else: dummy = [] for i in range(1, 1 + (len(a)) // 2): dummy.append(2 * i - 1) dummy.append(2 * i - 1) if sorted(a) == dummy: ans = 2 ** ((len(a)) // 2) print((ans % (10**9 + 7)))
n = int(eval(input())) a = sorted(list(map(int, input().split()))) if len(a) % 2 == 1: tmp = [0] for i in range((len(a) - 1) // 2): tmp.append((i + 1) * 2) tmp.append((i + 1) * 2) if a == tmp: ans = (2 ** ((len(a) - 1) // 2)) % (10**9 + 7) else: ans = 0 else: tmp = [] for i in range(len(a) // 2): tmp.append(2 * i + 1) tmp.append(2 * i + 1) if a == tmp: ans = (2 ** (len(a) // 2)) % (10**9 + 7) else: ans = 0 print(ans)
false
18.181818
[ "-a = list(map(int, input().split()))", "-ans = 0", "-if n % 2 == 1:", "- dummy = [0]", "- for i in range(1, 1 + (len(a) - 1) // 2):", "- dummy.append(2 * i)", "- dummy.append(2 * i)", "- if sorted(a) == dummy:", "- ans = 2 ** ((len(a) - 1) // 2)", "+a = sorted(list(map(int, input().split())))", "+if len(a) % 2 == 1:", "+ tmp = [0]", "+ for i in range((len(a) - 1) // 2):", "+ tmp.append((i + 1) * 2)", "+ tmp.append((i + 1) * 2)", "+ if a == tmp:", "+ ans = (2 ** ((len(a) - 1) // 2)) % (10**9 + 7)", "+ else:", "+ ans = 0", "- dummy = []", "- for i in range(1, 1 + (len(a)) // 2):", "- dummy.append(2 * i - 1)", "- dummy.append(2 * i - 1)", "- if sorted(a) == dummy:", "- ans = 2 ** ((len(a)) // 2)", "-print((ans % (10**9 + 7)))", "+ tmp = []", "+ for i in range(len(a) // 2):", "+ tmp.append(2 * i + 1)", "+ tmp.append(2 * i + 1)", "+ if a == tmp:", "+ ans = (2 ** (len(a) // 2)) % (10**9 + 7)", "+ else:", "+ ans = 0", "+print(ans)" ]
false
0.046927
0.047126
0.995797
[ "s273294834", "s625398847" ]
u638456847
p03108
python
s970055270
s723356248
831
490
17,704
32,856
Accepted
Accepted
41.03
class UnionFind_size: def __init__(self, n): self.par = [i for i in range(n+1)] self.size = [1] * (n+1) # 根を検索する関数 def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.find(self.par[x]) # 結合(unite)する関数 def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.size[x] < self.size[y]: self.par[x] = y self.size[y] += self.size[x] else: self.par[y] = x self.size[x] += self.size[y] # 同じグループに属するかを判定する関数 def same_check(self, x, y): return self.find(x) == self.find(y) # 要素が属する木のサイズを返す関数 def get_size(self, x): return self.size[self.find(x)] # グループ数を返す関数 def group_sum(self): c = 0 for i in range(len(self.par)): if self.find(i) == i: c += 1 return c if __name__ == "__main__": N,M = list(map(int, input().split())) uf = UnionFind_size(N) A, B = [0] * M, [0] * M for i in range(M): A[i], B[i] = [int(j) for j in input().split()] total = int(N * (N-1) / 2) ans = [total] for i in range(M-1): if uf.same_check(A[-(i+1)], B[-(i+1)]): ans.append(ans[i]) else: ans.append(ans[i] - uf.get_size(A[-(i+1)]) * uf.get_size(B[-(i+1)])) uf.unite(A[-(i+1)], B[-(i+1)]) for i in (reversed(ans)): print(i)
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class UnionFind: def __init__(self, n): # 初期状態は全要素が根なので、親は自分自身 self.par = [i for i in range(n+1)] # 集団の要素数(size)を格納する(初期は全て1) self.size = [1] * (n+1) # 根を検索する関数 def find(self, x): # 根までたどったらその番号を返す if self.par[x] == x: return x # 根でないなら親の要素で再検索 else: # 検索過程で親を書き換える(圧縮経路) self.par[x] = self.find(self.par[x]) return self.find(self.par[x]) # 結合(unite)する関数 def unite(self, x, y): # 根を探す x = self.find(x) y = self.find(y) if x == y: return # サイズを比較し、小さい方を大きい方に繋げる if self.size[x] < self.size[y]: self.par[x] = y self.size[y] += self.size[x] else: self.par[y] = x self.size[x] += self.size[y] # 同じグループに属するかを判定する関数 def is_same(self, x, y): return self.find(x) == self.find(y) # 要素が属する木のサイズを返す関数 def get_size(self, x): return self.size[self.find(x)] # グループ数を返す関数 def group_sum(self): c = 0 for i in range(len(self.par)): if self.find(i) == i: c += 1 return c def main(): N,M,*ab = list(map(int, read().split())) E = [(a, b) for a, b in zip(*[iter(ab)]*2)] pair = N * (N - 1) // 2 ans = [] uf = UnionFind(N) con = 0 for a, b in reversed(E): ans.append(pair) if not uf.is_same(a, b): n_a = uf.get_size(a) n_b = uf.get_size(b) pair -= n_a * n_b uf.unite(a, b) print(("\n".join(map(str, ans[::-1])))) if __name__ == "__main__": main()
62
79
1,632
1,874
class UnionFind_size: def __init__(self, n): self.par = [i for i in range(n + 1)] self.size = [1] * (n + 1) # 根を検索する関数 def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.find(self.par[x]) # 結合(unite)する関数 def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.size[x] < self.size[y]: self.par[x] = y self.size[y] += self.size[x] else: self.par[y] = x self.size[x] += self.size[y] # 同じグループに属するかを判定する関数 def same_check(self, x, y): return self.find(x) == self.find(y) # 要素が属する木のサイズを返す関数 def get_size(self, x): return self.size[self.find(x)] # グループ数を返す関数 def group_sum(self): c = 0 for i in range(len(self.par)): if self.find(i) == i: c += 1 return c if __name__ == "__main__": N, M = list(map(int, input().split())) uf = UnionFind_size(N) A, B = [0] * M, [0] * M for i in range(M): A[i], B[i] = [int(j) for j in input().split()] total = int(N * (N - 1) / 2) ans = [total] for i in range(M - 1): if uf.same_check(A[-(i + 1)], B[-(i + 1)]): ans.append(ans[i]) else: ans.append(ans[i] - uf.get_size(A[-(i + 1)]) * uf.get_size(B[-(i + 1)])) uf.unite(A[-(i + 1)], B[-(i + 1)]) for i in reversed(ans): print(i)
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class UnionFind: def __init__(self, n): # 初期状態は全要素が根なので、親は自分自身 self.par = [i for i in range(n + 1)] # 集団の要素数(size)を格納する(初期は全て1) self.size = [1] * (n + 1) # 根を検索する関数 def find(self, x): # 根までたどったらその番号を返す if self.par[x] == x: return x # 根でないなら親の要素で再検索 else: # 検索過程で親を書き換える(圧縮経路) self.par[x] = self.find(self.par[x]) return self.find(self.par[x]) # 結合(unite)する関数 def unite(self, x, y): # 根を探す x = self.find(x) y = self.find(y) if x == y: return # サイズを比較し、小さい方を大きい方に繋げる if self.size[x] < self.size[y]: self.par[x] = y self.size[y] += self.size[x] else: self.par[y] = x self.size[x] += self.size[y] # 同じグループに属するかを判定する関数 def is_same(self, x, y): return self.find(x) == self.find(y) # 要素が属する木のサイズを返す関数 def get_size(self, x): return self.size[self.find(x)] # グループ数を返す関数 def group_sum(self): c = 0 for i in range(len(self.par)): if self.find(i) == i: c += 1 return c def main(): N, M, *ab = list(map(int, read().split())) E = [(a, b) for a, b in zip(*[iter(ab)] * 2)] pair = N * (N - 1) // 2 ans = [] uf = UnionFind(N) con = 0 for a, b in reversed(E): ans.append(pair) if not uf.is_same(a, b): n_a = uf.get_size(a) n_b = uf.get_size(b) pair -= n_a * n_b uf.unite(a, b) print(("\n".join(map(str, ans[::-1])))) if __name__ == "__main__": main()
false
21.518987
[ "-class UnionFind_size:", "+import sys", "+", "+read = sys.stdin.read", "+readline = sys.stdin.readline", "+readlines = sys.stdin.readlines", "+", "+", "+class UnionFind:", "+ # 初期状態は全要素が根なので、親は自分自身", "+ # 集団の要素数(size)を格納する(初期は全て1)", "+ # 根までたどったらその番号を返す", "+ # 根でないなら親の要素で再検索", "+ # 検索過程で親を書き換える(圧縮経路)", "+ # 根を探す", "+ # サイズを比較し、小さい方を大きい方に繋げる", "- def same_check(self, x, y):", "+ def is_same(self, x, y):", "+def main():", "+ N, M, *ab = list(map(int, read().split()))", "+ E = [(a, b) for a, b in zip(*[iter(ab)] * 2)]", "+ pair = N * (N - 1) // 2", "+ ans = []", "+ uf = UnionFind(N)", "+ con = 0", "+ for a, b in reversed(E):", "+ ans.append(pair)", "+ if not uf.is_same(a, b):", "+ n_a = uf.get_size(a)", "+ n_b = uf.get_size(b)", "+ pair -= n_a * n_b", "+ uf.unite(a, b)", "+ print((\"\\n\".join(map(str, ans[::-1]))))", "+", "+", "- N, M = list(map(int, input().split()))", "- uf = UnionFind_size(N)", "- A, B = [0] * M, [0] * M", "- for i in range(M):", "- A[i], B[i] = [int(j) for j in input().split()]", "- total = int(N * (N - 1) / 2)", "- ans = [total]", "- for i in range(M - 1):", "- if uf.same_check(A[-(i + 1)], B[-(i + 1)]):", "- ans.append(ans[i])", "- else:", "- ans.append(ans[i] - uf.get_size(A[-(i + 1)]) * uf.get_size(B[-(i + 1)]))", "- uf.unite(A[-(i + 1)], B[-(i + 1)])", "- for i in reversed(ans):", "- print(i)", "+ main()" ]
false
0.047748
0.047919
0.996427
[ "s970055270", "s723356248" ]
u985929170
p03044
python
s370965097
s930312024
759
461
101,192
43,272
Accepted
Accepted
39.26
import sys sys.setrecursionlimit(500*500) n = int(eval(input())) l = [list(map(int,input().split())) for _ in range(n-1)] g = [[] for _ in range(n)] for i in l: v = i[0]-1 y = i[1]-1 w = i[2] g[v].append([y,w]) g[y].append([v,w]) seen = [0] + [-1] * (n-1) def dfs(s): for k in g[s]: v,w = k[0],k[1] if seen[v]!=-1:continue seen[v] = seen[s]^(w%2) dfs(v) dfs(0) for i in seen: print(i)
n = int(eval(input())) g = [[] for _ in range(n)] for _ in range(n-1): u,v,w = list(map(int,input().split())) g[u-1].append((v-1,w)) g[v-1].append((u-1,w)) from collections import deque que = deque() seen = [0] + [-1]*(n-1) que.append(0) while que: s = que.popleft() for v,w in g[s]: if seen[v] != -1:continue seen[v] = seen[s]^(w%2) que.append(v) for i in seen: print(i)
26
22
476
432
import sys sys.setrecursionlimit(500 * 500) n = int(eval(input())) l = [list(map(int, input().split())) for _ in range(n - 1)] g = [[] for _ in range(n)] for i in l: v = i[0] - 1 y = i[1] - 1 w = i[2] g[v].append([y, w]) g[y].append([v, w]) seen = [0] + [-1] * (n - 1) def dfs(s): for k in g[s]: v, w = k[0], k[1] if seen[v] != -1: continue seen[v] = seen[s] ^ (w % 2) dfs(v) dfs(0) for i in seen: print(i)
n = int(eval(input())) g = [[] for _ in range(n)] for _ in range(n - 1): u, v, w = list(map(int, input().split())) g[u - 1].append((v - 1, w)) g[v - 1].append((u - 1, w)) from collections import deque que = deque() seen = [0] + [-1] * (n - 1) que.append(0) while que: s = que.popleft() for v, w in g[s]: if seen[v] != -1: continue seen[v] = seen[s] ^ (w % 2) que.append(v) for i in seen: print(i)
false
15.384615
[ "-import sys", "+n = int(eval(input()))", "+g = [[] for _ in range(n)]", "+for _ in range(n - 1):", "+ u, v, w = list(map(int, input().split()))", "+ g[u - 1].append((v - 1, w))", "+ g[v - 1].append((u - 1, w))", "+from collections import deque", "-sys.setrecursionlimit(500 * 500)", "-n = int(eval(input()))", "-l = [list(map(int, input().split())) for _ in range(n - 1)]", "-g = [[] for _ in range(n)]", "-for i in l:", "- v = i[0] - 1", "- y = i[1] - 1", "- w = i[2]", "- g[v].append([y, w])", "- g[y].append([v, w])", "+que = deque()", "-", "-", "-def dfs(s):", "- for k in g[s]:", "- v, w = k[0], k[1]", "+que.append(0)", "+while que:", "+ s = que.popleft()", "+ for v, w in g[s]:", "- dfs(v)", "-", "-", "-dfs(0)", "+ que.append(v)" ]
false
0.10131
0.130145
0.778439
[ "s370965097", "s930312024" ]
u287500079
p03425
python
s519826505
s486368078
309
148
10,212
5,332
Accepted
Accepted
52.1
from itertools import combinations n = int(eval(input())) s = [eval(input()) for _ in range(n)] s.sort() march = [0, 0, 0, 0, 0] st = ['M', 'A', 'R', 'C', 'H'] for i in range(n): for j in range(5): if s[i][0] == st[j]: march[j] += 1 #print(march) if sum(march) == 0: print((0)) exit() ans = 0 a = list(combinations(list(range(5)), 3)) for i in range(len(a)): tmp = 1 for j in a[i]: tmp *= march[j] ans += tmp print(ans)
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() def STR(): return eval(input()) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def S_MAP(): return list(map(str, input().split())) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) inf = sys.maxsize mod = 10 ** 9 + 7 n = INT() num = [0 for _ in range(5)] arr = ['M', 'A', 'R', 'C', 'H'] for _ in range(n): s = STR() if s[0] in arr: num[arr.index(s[0])] += 1 ans = 0 arr2 = list(combinations(list(range(5)), 3)) for i in range(len(arr2)): tmp = 1 for j in arr2[i]: tmp *= num[j] ans += tmp print(ans)
26
34
480
1,091
from itertools import combinations n = int(eval(input())) s = [eval(input()) for _ in range(n)] s.sort() march = [0, 0, 0, 0, 0] st = ["M", "A", "R", "C", "H"] for i in range(n): for j in range(5): if s[i][0] == st[j]: march[j] += 1 # print(march) if sum(march) == 0: print((0)) exit() ans = 0 a = list(combinations(list(range(5)), 3)) for i in range(len(a)): tmp = 1 for j in a[i]: tmp *= march[j] ans += tmp print(ans)
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() def STR(): return eval(input()) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def S_MAP(): return list(map(str, input().split())) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10**9) inf = sys.maxsize mod = 10**9 + 7 n = INT() num = [0 for _ in range(5)] arr = ["M", "A", "R", "C", "H"] for _ in range(n): s = STR() if s[0] in arr: num[arr.index(s[0])] += 1 ans = 0 arr2 = list(combinations(list(range(5)), 3)) for i in range(len(arr2)): tmp = 1 for j in arr2[i]: tmp *= num[j] ans += tmp print(ans)
false
23.529412
[ "-from itertools import combinations", "+import sys, re, os", "+from collections import deque, defaultdict, Counter", "+from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin", "+from itertools import permutations, combinations, product, accumulate", "+from operator import itemgetter, mul", "+from copy import deepcopy", "+from string import ascii_lowercase, ascii_uppercase, digits", "+from fractions import gcd", "-n = int(eval(input()))", "-s = [eval(input()) for _ in range(n)]", "-s.sort()", "-march = [0, 0, 0, 0, 0]", "-st = [\"M\", \"A\", \"R\", \"C\", \"H\"]", "-for i in range(n):", "- for j in range(5):", "- if s[i][0] == st[j]:", "- march[j] += 1", "-# print(march)", "-if sum(march) == 0:", "- print((0))", "- exit()", "+", "+def input():", "+ return sys.stdin.readline().strip()", "+", "+", "+def STR():", "+ return eval(input())", "+", "+", "+def INT():", "+ return int(eval(input()))", "+", "+", "+def MAP():", "+ return list(map(int, input().split()))", "+", "+", "+def S_MAP():", "+ return list(map(str, input().split()))", "+", "+", "+def LIST():", "+ return list(map(int, input().split()))", "+", "+", "+def S_LIST():", "+ return list(map(str, input().split()))", "+", "+", "+sys.setrecursionlimit(10**9)", "+inf = sys.maxsize", "+mod = 10**9 + 7", "+n = INT()", "+num = [0 for _ in range(5)]", "+arr = [\"M\", \"A\", \"R\", \"C\", \"H\"]", "+for _ in range(n):", "+ s = STR()", "+ if s[0] in arr:", "+ num[arr.index(s[0])] += 1", "-a = list(combinations(list(range(5)), 3))", "-for i in range(len(a)):", "+arr2 = list(combinations(list(range(5)), 3))", "+for i in range(len(arr2)):", "- for j in a[i]:", "- tmp *= march[j]", "+ for j in arr2[i]:", "+ tmp *= num[j]" ]
false
0.06011
0.067933
0.884836
[ "s519826505", "s486368078" ]
u380524497
p02708
python
s064861991
s467270504
176
89
9,188
9,168
Accepted
Accepted
49.43
n, k = list(map(int, input().split())) mod = 10 ** 9 + 7 ans = 0 for t in range(k, n+2): mini = t * (t-1) // 2 % mod residue = n - t + 1 maxim = mini + t * residue maxim %= mod count = maxim - mini + 1 count %= mod ans += count ans %= mod print(ans)
n, k = list(map(int, input().split())) mod = 10 ** 9 + 7 ans = 0 for t in range(k, n+2): pattern = t * (n+1-t) + 1 % mod ans = (ans + pattern) % mod print(ans)
15
9
292
172
n, k = list(map(int, input().split())) mod = 10**9 + 7 ans = 0 for t in range(k, n + 2): mini = t * (t - 1) // 2 % mod residue = n - t + 1 maxim = mini + t * residue maxim %= mod count = maxim - mini + 1 count %= mod ans += count ans %= mod print(ans)
n, k = list(map(int, input().split())) mod = 10**9 + 7 ans = 0 for t in range(k, n + 2): pattern = t * (n + 1 - t) + 1 % mod ans = (ans + pattern) % mod print(ans)
false
40
[ "- mini = t * (t - 1) // 2 % mod", "- residue = n - t + 1", "- maxim = mini + t * residue", "- maxim %= mod", "- count = maxim - mini + 1", "- count %= mod", "- ans += count", "- ans %= mod", "+ pattern = t * (n + 1 - t) + 1 % mod", "+ ans = (ans + pattern) % mod" ]
false
0.073322
0.049552
1.4797
[ "s064861991", "s467270504" ]
u970197315
p03014
python
s958072957
s891294080
1,035
824
181,252
179,588
Accepted
Accepted
20.39
# D -Lamp h,w=list(map(int,input().split())) g=[eval(input()) for i in range(h)] l=[[0]*w for i in range(h)] r=[[0]*w for i in range(h)] u=[[0]*w for i in range(h)] o=[[0]*w for i in range(h)] for i in range(h): if g[i][0]=='.': l[i][0]=1 for i in range(h): for j in range(w-1): if g[i][j+1]=='.': l[i][j+1]=l[i][j]+1 elif g[i][j+1]=='#': l[i][j+1]=0 for i in range(h): if g[i][w-1]=='.': r[i][w-1]=1 for i in range(h): for j in range(w-1,0,-1): if g[i][j-1]=='.': r[i][j-1]=r[i][j]+1 elif g[i][j-1]=='#': r[i][j-1]=0 for i in range(w): if g[0][i]=='.': u[0][i]=1 for i in range(w): for j in range(h-1): if g[j+1][i]=='.': u[j+1][i]=u[j][i]+1 elif g[j+1][i]=='#': u[j+1][i]=0 for i in range(w): if g[h-1][i]=='.': o[h-1][i]=1 for i in range(w): for j in range(h-1,0,-1): if g[j-1][i]=='.': o[j-1][i]=o[j][i]+1 elif g[j-1][i]=='#': o[j-1][i]=0 ans=0 for i in range(h): for j in range(w): ans=max(ans,l[i][j]+r[i][j]+u[i][j]+o[i][j]-3) print(ans)
h,w=list(map(int,input().split())) s=[] s.append("#"*(w+2)) for i in range(h): s.append("#"+eval(input())+"#") s.append("#"*(w+2)) r=[[0]*(w+2) for i in range(h+2)] l=[[0]*(w+2) for i in range(h+2)] d=[[0]*(w+2) for i in range(h+2)] u=[[0]*(w+2) for i in range(h+2)] for i in range(1,h+1): for j in range(w+1,0,-1): if s[i][j]=="#": r[i][j]=0 else: r[i][j]+=r[i][j+1]+1 # print(r) for i in range(1,h+1): for j in range(1,w+1): if s[i][j]=="#": l[i][j]=0 else: l[i][j]+=l[i][j-1]+1 # print(l) for i in range(1,h+1): for j in range(1,w+1): if s[i][j]=="#": u[i][j]=0 else: u[i][j]+=u[i-1][j]+1 # print(u) for i in range(h+1,0,-1): for j in range(1,w+1): if s[i][j]=="#": d[i][j]=0 else: d[i][j]+=d[i+1][j]+1 # print(d) ans=0 for i in range(1,h+1): for j in range(1,w+1): ans=max(r[i][j]+l[i][j]+u[i][j]+d[i][j]-3,ans) print(ans)
58
44
1,237
954
# D -Lamp h, w = list(map(int, input().split())) g = [eval(input()) for i in range(h)] l = [[0] * w for i in range(h)] r = [[0] * w for i in range(h)] u = [[0] * w for i in range(h)] o = [[0] * w for i in range(h)] for i in range(h): if g[i][0] == ".": l[i][0] = 1 for i in range(h): for j in range(w - 1): if g[i][j + 1] == ".": l[i][j + 1] = l[i][j] + 1 elif g[i][j + 1] == "#": l[i][j + 1] = 0 for i in range(h): if g[i][w - 1] == ".": r[i][w - 1] = 1 for i in range(h): for j in range(w - 1, 0, -1): if g[i][j - 1] == ".": r[i][j - 1] = r[i][j] + 1 elif g[i][j - 1] == "#": r[i][j - 1] = 0 for i in range(w): if g[0][i] == ".": u[0][i] = 1 for i in range(w): for j in range(h - 1): if g[j + 1][i] == ".": u[j + 1][i] = u[j][i] + 1 elif g[j + 1][i] == "#": u[j + 1][i] = 0 for i in range(w): if g[h - 1][i] == ".": o[h - 1][i] = 1 for i in range(w): for j in range(h - 1, 0, -1): if g[j - 1][i] == ".": o[j - 1][i] = o[j][i] + 1 elif g[j - 1][i] == "#": o[j - 1][i] = 0 ans = 0 for i in range(h): for j in range(w): ans = max(ans, l[i][j] + r[i][j] + u[i][j] + o[i][j] - 3) print(ans)
h, w = list(map(int, input().split())) s = [] s.append("#" * (w + 2)) for i in range(h): s.append("#" + eval(input()) + "#") s.append("#" * (w + 2)) r = [[0] * (w + 2) for i in range(h + 2)] l = [[0] * (w + 2) for i in range(h + 2)] d = [[0] * (w + 2) for i in range(h + 2)] u = [[0] * (w + 2) for i in range(h + 2)] for i in range(1, h + 1): for j in range(w + 1, 0, -1): if s[i][j] == "#": r[i][j] = 0 else: r[i][j] += r[i][j + 1] + 1 # print(r) for i in range(1, h + 1): for j in range(1, w + 1): if s[i][j] == "#": l[i][j] = 0 else: l[i][j] += l[i][j - 1] + 1 # print(l) for i in range(1, h + 1): for j in range(1, w + 1): if s[i][j] == "#": u[i][j] = 0 else: u[i][j] += u[i - 1][j] + 1 # print(u) for i in range(h + 1, 0, -1): for j in range(1, w + 1): if s[i][j] == "#": d[i][j] = 0 else: d[i][j] += d[i + 1][j] + 1 # print(d) ans = 0 for i in range(1, h + 1): for j in range(1, w + 1): ans = max(r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3, ans) print(ans)
false
24.137931
[ "-# D -Lamp", "-g = [eval(input()) for i in range(h)]", "-l = [[0] * w for i in range(h)]", "-r = [[0] * w for i in range(h)]", "-u = [[0] * w for i in range(h)]", "-o = [[0] * w for i in range(h)]", "+s = []", "+s.append(\"#\" * (w + 2))", "- if g[i][0] == \".\":", "- l[i][0] = 1", "-for i in range(h):", "- for j in range(w - 1):", "- if g[i][j + 1] == \".\":", "- l[i][j + 1] = l[i][j] + 1", "- elif g[i][j + 1] == \"#\":", "- l[i][j + 1] = 0", "-for i in range(h):", "- if g[i][w - 1] == \".\":", "- r[i][w - 1] = 1", "-for i in range(h):", "- for j in range(w - 1, 0, -1):", "- if g[i][j - 1] == \".\":", "- r[i][j - 1] = r[i][j] + 1", "- elif g[i][j - 1] == \"#\":", "- r[i][j - 1] = 0", "-for i in range(w):", "- if g[0][i] == \".\":", "- u[0][i] = 1", "-for i in range(w):", "- for j in range(h - 1):", "- if g[j + 1][i] == \".\":", "- u[j + 1][i] = u[j][i] + 1", "- elif g[j + 1][i] == \"#\":", "- u[j + 1][i] = 0", "-for i in range(w):", "- if g[h - 1][i] == \".\":", "- o[h - 1][i] = 1", "-for i in range(w):", "- for j in range(h - 1, 0, -1):", "- if g[j - 1][i] == \".\":", "- o[j - 1][i] = o[j][i] + 1", "- elif g[j - 1][i] == \"#\":", "- o[j - 1][i] = 0", "+ s.append(\"#\" + eval(input()) + \"#\")", "+s.append(\"#\" * (w + 2))", "+r = [[0] * (w + 2) for i in range(h + 2)]", "+l = [[0] * (w + 2) for i in range(h + 2)]", "+d = [[0] * (w + 2) for i in range(h + 2)]", "+u = [[0] * (w + 2) for i in range(h + 2)]", "+for i in range(1, h + 1):", "+ for j in range(w + 1, 0, -1):", "+ if s[i][j] == \"#\":", "+ r[i][j] = 0", "+ else:", "+ r[i][j] += r[i][j + 1] + 1", "+# print(r)", "+for i in range(1, h + 1):", "+ for j in range(1, w + 1):", "+ if s[i][j] == \"#\":", "+ l[i][j] = 0", "+ else:", "+ l[i][j] += l[i][j - 1] + 1", "+# print(l)", "+for i in range(1, h + 1):", "+ for j in range(1, w + 1):", "+ if s[i][j] == \"#\":", "+ u[i][j] = 0", "+ else:", "+ u[i][j] += u[i - 1][j] + 1", "+# print(u)", "+for i in range(h + 1, 0, -1):", "+ for j in range(1, w + 1):", "+ if s[i][j] == \"#\":", "+ d[i][j] = 0", "+ else:", "+ d[i][j] += d[i + 1][j] + 1", "+# print(d)", "-for i in range(h):", "- for j in range(w):", "- ans = max(ans, l[i][j] + r[i][j] + u[i][j] + o[i][j] - 3)", "+for i in range(1, h + 1):", "+ for j in range(1, w + 1):", "+ ans = max(r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3, ans)" ]
false
0.043372
0.034119
1.271187
[ "s958072957", "s891294080" ]
u844646164
p03401
python
s044278206
s559880212
226
171
13,920
90,468
Accepted
Accepted
24.34
N = int(eval(input())) A = list(map(int, input().split())) A.insert(0, 0) A.append(0) a = 0 cost = 0 for i in A: b = i cost += abs(a-b) a = b cost += abs(A[-1]) ori = cost for i in range(1, len(A)-1): cost += abs(A[i-1]-A[i+1]) cost -= abs(A[i-1]-A[i])+abs(A[i+1]-A[i]) print(cost) cost = ori
N = int(eval(input())) A = list(map(int, input().split())) ans = abs(A[0]) ans += sum([abs(A[i]-A[i-1]) for i in range(1, N)]) ans += abs(A[-1]) for i in range(N): if i == 0: if (0 <= A[i] <= A[i+1]) or (A[i+1] <= A[i] <= 0): tmp = ans else: tmp = ans - abs(A[0]) - abs(A[0]-A[1]) + abs(A[1]) print(tmp) elif i == N-1: if (0 <= A[i] <= A[i-1]) or (A[i-1] <= A[i] <= 0): tmp = ans else: tmp = ans - abs(A[i]-A[i-1]) - abs(A[i]) + abs(A[i-1]) print(tmp) else: if (A[i-1] <= A[i] <= A[i+1]) or (A[i-1] >= A[i] >= A[i+1]): print(ans) else: tmp = ans - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i+1]-A[i-1]) print(tmp)
18
25
333
795
N = int(eval(input())) A = list(map(int, input().split())) A.insert(0, 0) A.append(0) a = 0 cost = 0 for i in A: b = i cost += abs(a - b) a = b cost += abs(A[-1]) ori = cost for i in range(1, len(A) - 1): cost += abs(A[i - 1] - A[i + 1]) cost -= abs(A[i - 1] - A[i]) + abs(A[i + 1] - A[i]) print(cost) cost = ori
N = int(eval(input())) A = list(map(int, input().split())) ans = abs(A[0]) ans += sum([abs(A[i] - A[i - 1]) for i in range(1, N)]) ans += abs(A[-1]) for i in range(N): if i == 0: if (0 <= A[i] <= A[i + 1]) or (A[i + 1] <= A[i] <= 0): tmp = ans else: tmp = ans - abs(A[0]) - abs(A[0] - A[1]) + abs(A[1]) print(tmp) elif i == N - 1: if (0 <= A[i] <= A[i - 1]) or (A[i - 1] <= A[i] <= 0): tmp = ans else: tmp = ans - abs(A[i] - A[i - 1]) - abs(A[i]) + abs(A[i - 1]) print(tmp) else: if (A[i - 1] <= A[i] <= A[i + 1]) or (A[i - 1] >= A[i] >= A[i + 1]): print(ans) else: tmp = ( ans - abs(A[i] - A[i - 1]) - abs(A[i] - A[i + 1]) + abs(A[i + 1] - A[i - 1]) ) print(tmp)
false
28
[ "-A.insert(0, 0)", "-A.append(0)", "-a = 0", "-cost = 0", "-for i in A:", "- b = i", "- cost += abs(a - b)", "- a = b", "-cost += abs(A[-1])", "-ori = cost", "-for i in range(1, len(A) - 1):", "- cost += abs(A[i - 1] - A[i + 1])", "- cost -= abs(A[i - 1] - A[i]) + abs(A[i + 1] - A[i])", "- print(cost)", "- cost = ori", "+ans = abs(A[0])", "+ans += sum([abs(A[i] - A[i - 1]) for i in range(1, N)])", "+ans += abs(A[-1])", "+for i in range(N):", "+ if i == 0:", "+ if (0 <= A[i] <= A[i + 1]) or (A[i + 1] <= A[i] <= 0):", "+ tmp = ans", "+ else:", "+ tmp = ans - abs(A[0]) - abs(A[0] - A[1]) + abs(A[1])", "+ print(tmp)", "+ elif i == N - 1:", "+ if (0 <= A[i] <= A[i - 1]) or (A[i - 1] <= A[i] <= 0):", "+ tmp = ans", "+ else:", "+ tmp = ans - abs(A[i] - A[i - 1]) - abs(A[i]) + abs(A[i - 1])", "+ print(tmp)", "+ else:", "+ if (A[i - 1] <= A[i] <= A[i + 1]) or (A[i - 1] >= A[i] >= A[i + 1]):", "+ print(ans)", "+ else:", "+ tmp = (", "+ ans", "+ - abs(A[i] - A[i - 1])", "+ - abs(A[i] - A[i + 1])", "+ + abs(A[i + 1] - A[i - 1])", "+ )", "+ print(tmp)" ]
false
0.039303
0.074872
0.524933
[ "s044278206", "s559880212" ]
u698868214
p03294
python
s915496348
s616062616
29
25
9,304
9,400
Accepted
Accepted
13.79
N = int(eval(input())) A = list(map(int,input().split())) ans = 0 for i in range(N): ans += A[i] - 1 print(ans)
import math N = int(eval(input())) A = list(map(int,input().split())) A = list([int(math.copysign(x-1, x)) for x in A]) print((sum(A)))
8
7
118
140
N = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(N): ans += A[i] - 1 print(ans)
import math N = int(eval(input())) A = list(map(int, input().split())) A = list([int(math.copysign(x - 1, x)) for x in A]) print((sum(A)))
false
12.5
[ "+import math", "+", "-ans = 0", "-for i in range(N):", "- ans += A[i] - 1", "-print(ans)", "+A = list([int(math.copysign(x - 1, x)) for x in A])", "+print((sum(A)))" ]
false
0.036611
0.043889
0.834153
[ "s915496348", "s616062616" ]
u392319141
p03283
python
s098810067
s854364802
2,989
1,161
45,828
77,680
Accepted
Accepted
61.16
import numpy as np N, M, K = map(int, input().split()) LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32) for _ in range(M): L, R = map(int, input().split()) LR[L, R] += 1 np.cumsum(LR, axis=0, out=LR) np.cumsum(LR, axis=1, out=LR) P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T P -= 1 ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P] print(*ans, sep='\n')
import numpy as np N, M, K = map(int, input().split()) LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32) L, R = np.array([input().split() for _ in range(M)], dtype=np.int32).T np.add.at(LR, (L, R), 1) np.cumsum(LR, axis=0, out=LR) np.cumsum(LR, axis=1, out=LR) P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T P -= 1 ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P] print(*ans, sep='\n')
17
16
410
431
import numpy as np N, M, K = map(int, input().split()) LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32) for _ in range(M): L, R = map(int, input().split()) LR[L, R] += 1 np.cumsum(LR, axis=0, out=LR) np.cumsum(LR, axis=1, out=LR) P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T P -= 1 ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P] print(*ans, sep="\n")
import numpy as np N, M, K = map(int, input().split()) LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32) L, R = np.array([input().split() for _ in range(M)], dtype=np.int32).T np.add.at(LR, (L, R), 1) np.cumsum(LR, axis=0, out=LR) np.cumsum(LR, axis=1, out=LR) P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T P -= 1 ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P] print(*ans, sep="\n")
false
5.882353
[ "-for _ in range(M):", "- L, R = map(int, input().split())", "- LR[L, R] += 1", "+L, R = np.array([input().split() for _ in range(M)], dtype=np.int32).T", "+np.add.at(LR, (L, R), 1)" ]
false
0.198277
0.314233
0.630987
[ "s098810067", "s854364802" ]
u461573913
p03381
python
s157571916
s096569083
1,053
444
34,148
34,196
Accepted
Accepted
57.83
import numpy as np N = int(eval(input())) X = np.array(list(map(int, input().split()))) sort_X = np.sort(X) l = sort_X[int(N/2 - 1)] r = sort_X[int(N/2)] for i in range(N): if (X[i] <= l): print(r) else: print(l)
import numpy as np N = int(eval(input())) X = list(map(int, input().split())) sort_X = sorted(X) l = sort_X[int(N/2 - 1)] r = sort_X[int(N/2)] for i in range(N): if (X[i] <= l): print(r) else: print(l)
14
14
247
236
import numpy as np N = int(eval(input())) X = np.array(list(map(int, input().split()))) sort_X = np.sort(X) l = sort_X[int(N / 2 - 1)] r = sort_X[int(N / 2)] for i in range(N): if X[i] <= l: print(r) else: print(l)
import numpy as np N = int(eval(input())) X = list(map(int, input().split())) sort_X = sorted(X) l = sort_X[int(N / 2 - 1)] r = sort_X[int(N / 2)] for i in range(N): if X[i] <= l: print(r) else: print(l)
false
0
[ "-X = np.array(list(map(int, input().split())))", "-sort_X = np.sort(X)", "+X = list(map(int, input().split()))", "+sort_X = sorted(X)" ]
false
0.261991
0.034813
7.525618
[ "s157571916", "s096569083" ]
u254871849
p03210
python
s149924074
s476541617
20
17
3,060
2,940
Accepted
Accepted
15
import sys cand = [7, 5, 3] x = int(sys.stdin.readline().rstrip()) def main(): return 'YES' if x in cand else 'NO' if __name__ == '__main__': ans = main() print(ans)
import sys u = set('753') x = sys.stdin.readline().rstrip() def main(): ans = 'YES' if x in u else 'NO' print(ans) if __name__ == '__main__': main()
12
11
192
174
import sys cand = [7, 5, 3] x = int(sys.stdin.readline().rstrip()) def main(): return "YES" if x in cand else "NO" if __name__ == "__main__": ans = main() print(ans)
import sys u = set("753") x = sys.stdin.readline().rstrip() def main(): ans = "YES" if x in u else "NO" print(ans) if __name__ == "__main__": main()
false
8.333333
[ "-cand = [7, 5, 3]", "-x = int(sys.stdin.readline().rstrip())", "+u = set(\"753\")", "+x = sys.stdin.readline().rstrip()", "- return \"YES\" if x in cand else \"NO\"", "+ ans = \"YES\" if x in u else \"NO\"", "+ print(ans)", "- ans = main()", "- print(ans)", "+ main()" ]
false
0.043156
0.043189
0.999248
[ "s149924074", "s476541617" ]
u077291787
p03608
python
s998511767
s655951673
208
143
9,836
8,252
Accepted
Accepted
31.25
# ABC073D - joisino's travel (210ms) from heapq import heapify, heappop, heappush from itertools import permutations def dijkstra(source: int) -> list: dist = [float("inf")] * (N + 1) undetermined = N # vertex_0 won't appear in 1-idx graph queue = [(0, source)] heapify(queue) while queue: cost, v = heappop(queue) if cost > dist[v]: continue dist[v] = cost for next_cost, u in G[v]: if cost + next_cost < dist[u]: heappush(queue, (cost + next_cost, u)) undetermined -= 1 if not undetermined: return dist def main(): global G, N N, M, R, *RABC = list(map(int, open(0).read().split())) visit, ABC = RABC[:R], RABC[R:] G = [[] for _ in range(N + 1)] for v, u, cost in zip(*[iter(ABC)] * 3): G[v].append((cost, u)), G[u].append((cost, v)) dist = {v: dijkstra(v) for v in visit} ans = float("inf") for perm in permutations(visit): cur = sum(dist[v][u] for v, u in zip(perm, perm[1:])) ans = min(ans, cur) print(ans) if __name__ == "__main__": main()
# ABC073D - joisino's travel from heapq import heappop, heappush from itertools import permutations def dijkstra(source: int) -> "Array[int]": # compute the distance of the shortest path from V_source to each vertex size = len(G) dist = [float("inf")] * size dist[source] = 0 undetermined = size - 2 # V_0 and V_source are determined in 1-idx graph queue = [(0, source)] while queue: cost, v = heappop(queue) if cost > dist[v]: continue for next_cost, u in G[v]: if cost + next_cost < dist[u]: dist[u] = cost + next_cost heappush(queue, (dist[u], u)) undetermined -= 1 if not undetermined: return dist return dist def main(): global G N, M, R, *RABC = list(map(int, open(0).read().split())) visit, ABC = RABC[:R], RABC[R:] G = [[] for _ in range(N + 1)] for v, u, cost in zip(*[iter(ABC)] * 3): G[v].append((cost, u)), G[u].append((cost, v)) dist = {v: dijkstra(v) for v in visit} ans = float("inf") for perm in permutations(visit): cur = sum(dist[v][u] for v, u in zip(perm, perm[1:])) ans = min(ans, cur) print(ans) if __name__ == "__main__": main()
40
43
1,169
1,298
# ABC073D - joisino's travel (210ms) from heapq import heapify, heappop, heappush from itertools import permutations def dijkstra(source: int) -> list: dist = [float("inf")] * (N + 1) undetermined = N # vertex_0 won't appear in 1-idx graph queue = [(0, source)] heapify(queue) while queue: cost, v = heappop(queue) if cost > dist[v]: continue dist[v] = cost for next_cost, u in G[v]: if cost + next_cost < dist[u]: heappush(queue, (cost + next_cost, u)) undetermined -= 1 if not undetermined: return dist def main(): global G, N N, M, R, *RABC = list(map(int, open(0).read().split())) visit, ABC = RABC[:R], RABC[R:] G = [[] for _ in range(N + 1)] for v, u, cost in zip(*[iter(ABC)] * 3): G[v].append((cost, u)), G[u].append((cost, v)) dist = {v: dijkstra(v) for v in visit} ans = float("inf") for perm in permutations(visit): cur = sum(dist[v][u] for v, u in zip(perm, perm[1:])) ans = min(ans, cur) print(ans) if __name__ == "__main__": main()
# ABC073D - joisino's travel from heapq import heappop, heappush from itertools import permutations def dijkstra(source: int) -> "Array[int]": # compute the distance of the shortest path from V_source to each vertex size = len(G) dist = [float("inf")] * size dist[source] = 0 undetermined = size - 2 # V_0 and V_source are determined in 1-idx graph queue = [(0, source)] while queue: cost, v = heappop(queue) if cost > dist[v]: continue for next_cost, u in G[v]: if cost + next_cost < dist[u]: dist[u] = cost + next_cost heappush(queue, (dist[u], u)) undetermined -= 1 if not undetermined: return dist return dist def main(): global G N, M, R, *RABC = list(map(int, open(0).read().split())) visit, ABC = RABC[:R], RABC[R:] G = [[] for _ in range(N + 1)] for v, u, cost in zip(*[iter(ABC)] * 3): G[v].append((cost, u)), G[u].append((cost, v)) dist = {v: dijkstra(v) for v in visit} ans = float("inf") for perm in permutations(visit): cur = sum(dist[v][u] for v, u in zip(perm, perm[1:])) ans = min(ans, cur) print(ans) if __name__ == "__main__": main()
false
6.976744
[ "-# ABC073D - joisino's travel (210ms)", "-from heapq import heapify, heappop, heappush", "+# ABC073D - joisino's travel", "+from heapq import heappop, heappush", "-def dijkstra(source: int) -> list:", "- dist = [float(\"inf\")] * (N + 1)", "- undetermined = N # vertex_0 won't appear in 1-idx graph", "+def dijkstra(source: int) -> \"Array[int]\":", "+ # compute the distance of the shortest path from V_source to each vertex", "+ size = len(G)", "+ dist = [float(\"inf\")] * size", "+ dist[source] = 0", "+ undetermined = size - 2 # V_0 and V_source are determined in 1-idx graph", "- heapify(queue)", "- dist[v] = cost", "- heappush(queue, (cost + next_cost, u))", "+ dist[u] = cost + next_cost", "+ heappush(queue, (dist[u], u))", "+ return dist", "- global G, N", "+ global G" ]
false
0.035762
0.041096
0.870214
[ "s998511767", "s655951673" ]
u285443936
p03073
python
s338750021
s068466044
71
35
3,188
3,188
Accepted
Accepted
50.7
S = eval(input()) #偶数を0,奇数を1にする場合 count01 = 0 for i in range(len(S)): if i%2 == 0:#偶数番目のとき if S[i] != "0": count01 += 1 else: if S[i] != "1": count01 += 1 #偶数を1,奇数を0にする場合 count10 = 0 for i in range(len(S)): if i%2 == 0:#偶数番目のとき if S[i] != "1": count10 += 1 else: if S[i] != "0": count10 += 1 print((min(count01,count10)))
S = eval(input()) a, b = 0, 0 for i in range(0,len(S),2): if S[i] == "0": a += 1 else: b += 1 for i in range(1,len(S),2): if S[i] == "1": a += 1 else: b += 1 print((min(a, b)))
23
14
392
206
S = eval(input()) # 偶数を0,奇数を1にする場合 count01 = 0 for i in range(len(S)): if i % 2 == 0: # 偶数番目のとき if S[i] != "0": count01 += 1 else: if S[i] != "1": count01 += 1 # 偶数を1,奇数を0にする場合 count10 = 0 for i in range(len(S)): if i % 2 == 0: # 偶数番目のとき if S[i] != "1": count10 += 1 else: if S[i] != "0": count10 += 1 print((min(count01, count10)))
S = eval(input()) a, b = 0, 0 for i in range(0, len(S), 2): if S[i] == "0": a += 1 else: b += 1 for i in range(1, len(S), 2): if S[i] == "1": a += 1 else: b += 1 print((min(a, b)))
false
39.130435
[ "-# 偶数を0,奇数を1にする場合", "-count01 = 0", "-for i in range(len(S)):", "- if i % 2 == 0: # 偶数番目のとき", "- if S[i] != \"0\":", "- count01 += 1", "+a, b = 0, 0", "+for i in range(0, len(S), 2):", "+ if S[i] == \"0\":", "+ a += 1", "- if S[i] != \"1\":", "- count01 += 1", "-# 偶数を1,奇数を0にする場合", "-count10 = 0", "-for i in range(len(S)):", "- if i % 2 == 0: # 偶数番目のとき", "- if S[i] != \"1\":", "- count10 += 1", "+ b += 1", "+for i in range(1, len(S), 2):", "+ if S[i] == \"1\":", "+ a += 1", "- if S[i] != \"0\":", "- count10 += 1", "-print((min(count01, count10)))", "+ b += 1", "+print((min(a, b)))" ]
false
0.041191
0.042819
0.961997
[ "s338750021", "s068466044" ]
u193264896
p02783
python
s771407826
s200714914
36
17
5,076
3,060
Accepted
Accepted
52.78
from collections import deque from collections import Counter from itertools import product, permutations,combinations from operator import itemgetter from heapq import heappop, heappush from bisect import bisect_left, bisect_right, bisect #pypyではscipy, numpyは使えない #from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree #from scipy.sparse import csr_matrix, coo_matrix, lil_matrix #import numpy as np from fractions import gcd from math import ceil,floor, sqrt, cos, sin, pi, factorial import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**8) INF = float('inf') def main(): h, a = list(map(int, readline().split())) print((ceil(h/a))) if __name__ == '__main__': main()
import sys import math readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): H, A = list(map(int, readline().split())) print((math.ceil(H/A))) if __name__ == '__main__': main()
26
13
851
257
from collections import deque from collections import Counter from itertools import product, permutations, combinations from operator import itemgetter from heapq import heappop, heappush from bisect import bisect_left, bisect_right, bisect # pypyではscipy, numpyは使えない # from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree # from scipy.sparse import csr_matrix, coo_matrix, lil_matrix # import numpy as np from fractions import gcd from math import ceil, floor, sqrt, cos, sin, pi, factorial import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**8) INF = float("inf") def main(): h, a = list(map(int, readline().split())) print((ceil(h / a))) if __name__ == "__main__": main()
import sys import math readline = sys.stdin.buffer.readline sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def main(): H, A = list(map(int, readline().split())) print((math.ceil(H / A))) if __name__ == "__main__": main()
false
50
[ "-from collections import deque", "-from collections import Counter", "-from itertools import product, permutations, combinations", "-from operator import itemgetter", "-from heapq import heappop, heappush", "-from bisect import bisect_left, bisect_right, bisect", "+import sys", "+import math", "-# pypyではscipy, numpyは使えない", "-# from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree", "-# from scipy.sparse import csr_matrix, coo_matrix, lil_matrix", "-# import numpy as np", "-from fractions import gcd", "-from math import ceil, floor, sqrt, cos, sin, pi, factorial", "-import sys", "-", "-read = sys.stdin.buffer.read", "-readlines = sys.stdin.buffer.readlines", "+MOD = 10**9 + 7", "- h, a = list(map(int, readline().split()))", "- print((ceil(h / a)))", "+ H, A = list(map(int, readline().split()))", "+ print((math.ceil(H / A)))" ]
false
0.046301
0.038366
1.206803
[ "s771407826", "s200714914" ]
u302789073
p03494
python
s147046463
s951367904
30
26
9,236
9,180
Accepted
Accepted
13.33
n=int(eval(input())) list=[int(i) for i in input().split()] c_list=[] for i in list: count=0 while True: if i%2==0: i=i/2 count+=1 else: break c_list.append(count) print((min(c_list)))
# Your code here! n=int(eval(input())) a_list=[int(i) for i in input().split()] count_list=[] for i in range(n): num=a_list[i] count=0 while True: if num%2==0: num//=2 count+=1 else: break count_list.append(count) #print(count_list) print((min(count_list)))
18
19
282
341
n = int(eval(input())) list = [int(i) for i in input().split()] c_list = [] for i in list: count = 0 while True: if i % 2 == 0: i = i / 2 count += 1 else: break c_list.append(count) print((min(c_list)))
# Your code here! n = int(eval(input())) a_list = [int(i) for i in input().split()] count_list = [] for i in range(n): num = a_list[i] count = 0 while True: if num % 2 == 0: num //= 2 count += 1 else: break count_list.append(count) # print(count_list) print((min(count_list)))
false
5.263158
[ "+# Your code here!", "-list = [int(i) for i in input().split()]", "-c_list = []", "-for i in list:", "+a_list = [int(i) for i in input().split()]", "+count_list = []", "+for i in range(n):", "+ num = a_list[i]", "- if i % 2 == 0:", "- i = i / 2", "+ if num % 2 == 0:", "+ num //= 2", "- c_list.append(count)", "-print((min(c_list)))", "+ count_list.append(count)", "+# print(count_list)", "+print((min(count_list)))" ]
false
0.04649
0.043878
1.059518
[ "s147046463", "s951367904" ]
u017810624
p03077
python
s929265055
s656183320
21
17
2,940
2,940
Accepted
Accepted
19.05
n=int(eval(input())) l=[int(eval(input()))for i in range(5)] print(((n+min(l)-1)//min(l)+4))
n=int(eval(input())) x=min([int(eval(input()))for i in range(5)]) print(((n+x-1)//x+4))
3
3
80
75
n = int(eval(input())) l = [int(eval(input())) for i in range(5)] print(((n + min(l) - 1) // min(l) + 4))
n = int(eval(input())) x = min([int(eval(input())) for i in range(5)]) print(((n + x - 1) // x + 4))
false
0
[ "-l = [int(eval(input())) for i in range(5)]", "-print(((n + min(l) - 1) // min(l) + 4))", "+x = min([int(eval(input())) for i in range(5)])", "+print(((n + x - 1) // x + 4))" ]
false
0.044022
0.042779
1.029043
[ "s929265055", "s656183320" ]
u043236471
p02996
python
s840660391
s288057873
1,178
909
38,104
42,832
Accepted
Accepted
22.84
N = int(eval(input())) li = [] for _ in range(N): a, b = list(map(int,input().split())) li.append([b,a,b]) flag = True now = 0 li = sorted(li) for a, b, c in li: now += b if now > c: print("No") flag = False break if flag: print("Yes")
N = int(eval(input())) ab_list = [] for _ in range(N): ab_list.append([int(x) for x in input().split()]) ab_list = sorted(ab_list, key=lambda x: x[-1]) sum_work = 0 res = 'Yes' for a, b in ab_list: sum_work += a if sum_work > b: res = 'No' break print(res)
19
15
302
298
N = int(eval(input())) li = [] for _ in range(N): a, b = list(map(int, input().split())) li.append([b, a, b]) flag = True now = 0 li = sorted(li) for a, b, c in li: now += b if now > c: print("No") flag = False break if flag: print("Yes")
N = int(eval(input())) ab_list = [] for _ in range(N): ab_list.append([int(x) for x in input().split()]) ab_list = sorted(ab_list, key=lambda x: x[-1]) sum_work = 0 res = "Yes" for a, b in ab_list: sum_work += a if sum_work > b: res = "No" break print(res)
false
21.052632
[ "-li = []", "+ab_list = []", "- a, b = list(map(int, input().split()))", "- li.append([b, a, b])", "-flag = True", "-now = 0", "-li = sorted(li)", "-for a, b, c in li:", "- now += b", "- if now > c:", "- print(\"No\")", "- flag = False", "+ ab_list.append([int(x) for x in input().split()])", "+ab_list = sorted(ab_list, key=lambda x: x[-1])", "+sum_work = 0", "+res = \"Yes\"", "+for a, b in ab_list:", "+ sum_work += a", "+ if sum_work > b:", "+ res = \"No\"", "-if flag:", "- print(\"Yes\")", "+print(res)" ]
false
0.074495
0.047939
1.553952
[ "s840660391", "s288057873" ]
u503228842
p03293
python
s194759069
s580565948
20
17
2,940
2,940
Accepted
Accepted
15
s = eval(input()) t = eval(input()) for _ in range(len(s)): s = s[-1]+s[:-1] #print(s) if s == t: print("Yes") exit() print("No")
s = eval(input()) t = eval(input()) for i in range(len(s)): s = s[-1] + s[:-1] #print(s) if s == t: print('Yes') exit() print('No')
9
10
153
157
s = eval(input()) t = eval(input()) for _ in range(len(s)): s = s[-1] + s[:-1] # print(s) if s == t: print("Yes") exit() print("No")
s = eval(input()) t = eval(input()) for i in range(len(s)): s = s[-1] + s[:-1] # print(s) if s == t: print("Yes") exit() print("No")
false
10
[ "-for _ in range(len(s)):", "+for i in range(len(s)):" ]
false
0.101149
0.040883
2.47411
[ "s194759069", "s580565948" ]
u169350228
p02552
python
s725829576
s626863139
65
58
61,580
62,204
Accepted
Accepted
10.77
print((1-int(eval(input()))))
import math print((1-math.ceil(math.sin(int(eval(input()))))))
1
2
21
55
print((1 - int(eval(input()))))
import math print((1 - math.ceil(math.sin(int(eval(input()))))))
false
50
[ "-print((1 - int(eval(input()))))", "+import math", "+", "+print((1 - math.ceil(math.sin(int(eval(input()))))))" ]
false
0.089206
0.095597
0.933153
[ "s725829576", "s626863139" ]
u116038906
p02660
python
s777757811
s792331764
200
113
9,460
9,380
Accepted
Accepted
43.5
#約数 def make_divisors(n): #約数をリストで返す divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors #素因数分解 def soinsu_bunkai(m): pf={} for i in range(2,int(m**0.5)+1): while m%i==0: pf[i]=pf.get(i,0)+1 m//=i if m>1: pf[m]=1 return pf #初期入力 N = int(eval(input())) div =make_divisors(N) #Nの約数 div.sort() div_1_except=div[1:] count =0 for i in div_1_except: q,mod= divmod(N,i) if mod ==0: ii =soinsu_bunkai(i) #Nの約数を素因数分解 if len(ii) ==1 : count +=1 N =q print(count)
#約数は使わず、素因数分解のみ #素因数分解 def soinsu_bunkai(m): pf={} for i in range(2,int(m**0.5)+1): while m%i==0: pf[i]=pf.get(i,0)+1 m//=i if m>1: pf[m]=1 return pf #初期入力 N = int(eval(input())) xx =[] prime_factorization =soinsu_bunkai(N) count =0 for i in list(prime_factorization.keys()): x=1 while x <= prime_factorization[i]: if N % i**x ==0: xx.append(i**x) count +=1 N //= i**x x +=1 print(count)
39
28
762
521
# 約数 def make_divisors(n): # 約数をリストで返す divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) # divisors.sort() return divisors # 素因数分解 def soinsu_bunkai(m): pf = {} for i in range(2, int(m**0.5) + 1): while m % i == 0: pf[i] = pf.get(i, 0) + 1 m //= i if m > 1: pf[m] = 1 return pf # 初期入力 N = int(eval(input())) div = make_divisors(N) # Nの約数 div.sort() div_1_except = div[1:] count = 0 for i in div_1_except: q, mod = divmod(N, i) if mod == 0: ii = soinsu_bunkai(i) # Nの約数を素因数分解 if len(ii) == 1: count += 1 N = q print(count)
# 約数は使わず、素因数分解のみ # 素因数分解 def soinsu_bunkai(m): pf = {} for i in range(2, int(m**0.5) + 1): while m % i == 0: pf[i] = pf.get(i, 0) + 1 m //= i if m > 1: pf[m] = 1 return pf # 初期入力 N = int(eval(input())) xx = [] prime_factorization = soinsu_bunkai(N) count = 0 for i in list(prime_factorization.keys()): x = 1 while x <= prime_factorization[i]: if N % i**x == 0: xx.append(i**x) count += 1 N //= i**x x += 1 print(count)
false
28.205128
[ "-# 約数", "-def make_divisors(n): # 約数をリストで返す", "- divisors = []", "- for i in range(1, int(n**0.5) + 1):", "- if n % i == 0:", "- divisors.append(i)", "- if i != n // i:", "- divisors.append(n // i)", "- # divisors.sort()", "- return divisors", "-", "-", "+# 約数は使わず、素因数分解のみ", "-div = make_divisors(N) # Nの約数", "-div.sort()", "-div_1_except = div[1:]", "+xx = []", "+prime_factorization = soinsu_bunkai(N)", "-for i in div_1_except:", "- q, mod = divmod(N, i)", "- if mod == 0:", "- ii = soinsu_bunkai(i) # Nの約数を素因数分解", "- if len(ii) == 1:", "+for i in list(prime_factorization.keys()):", "+ x = 1", "+ while x <= prime_factorization[i]:", "+ if N % i**x == 0:", "+ xx.append(i**x)", "- N = q", "+ N //= i**x", "+ x += 1" ]
false
0.139989
0.044985
3.11189
[ "s777757811", "s792331764" ]
u177756077
p03796
python
s346057285
s245903361
34
24
5,764
5,764
Accepted
Accepted
29.41
N = eval(input()) ans = 1 for i in range(1, N + 1): ans = (ans * i) % (1e9 + 7) print(int(ans))
#!/usr/bin/env python n=int(input().strip()) power=1 for i in range(1,n+1): power=power*i%(10**9+7) print(power)
5
9
93
130
N = eval(input()) ans = 1 for i in range(1, N + 1): ans = (ans * i) % (1e9 + 7) print(int(ans))
#!/usr/bin/env python n = int(input().strip()) power = 1 for i in range(1, n + 1): power = power * i % (10**9 + 7) print(power)
false
44.444444
[ "-N = eval(input())", "-ans = 1", "-for i in range(1, N + 1):", "- ans = (ans * i) % (1e9 + 7)", "-print(int(ans))", "+#!/usr/bin/env python", "+n = int(input().strip())", "+power = 1", "+for i in range(1, n + 1):", "+ power = power * i % (10**9 + 7)", "+print(power)" ]
false
0.043831
0.041495
1.056314
[ "s346057285", "s245903361" ]
u790710233
p03126
python
s080113155
s401951758
21
17
3,316
3,060
Accepted
Accepted
19.05
from collections import defaultdict n, m = list(map(int, input().split())) s = [] for _ in range(n): k, *a = list(map(int, input().split())) s.append(a) dd = defaultdict(int) for l in s: for k in l: dd[k] += 1 print((sum(1 if v == n else 0 for k, v in list(dd.items()))))
n, m = list(map(int, input().split())) s = set(range(1, m+1)) for _ in range(n): k, *a = list(map(int, input().split())) s &= set(a) print((len(s)))
12
6
284
147
from collections import defaultdict n, m = list(map(int, input().split())) s = [] for _ in range(n): k, *a = list(map(int, input().split())) s.append(a) dd = defaultdict(int) for l in s: for k in l: dd[k] += 1 print((sum(1 if v == n else 0 for k, v in list(dd.items()))))
n, m = list(map(int, input().split())) s = set(range(1, m + 1)) for _ in range(n): k, *a = list(map(int, input().split())) s &= set(a) print((len(s)))
false
50
[ "-from collections import defaultdict", "-", "-s = []", "+s = set(range(1, m + 1))", "- s.append(a)", "-dd = defaultdict(int)", "-for l in s:", "- for k in l:", "- dd[k] += 1", "-print((sum(1 if v == n else 0 for k, v in list(dd.items()))))", "+ s &= set(a)", "+print((len(s)))" ]
false
0.041324
0.043037
0.960195
[ "s080113155", "s401951758" ]
u347640436
p03379
python
s066617070
s300492470
320
276
26,016
25,052
Accepted
Accepted
13.75
n = int(eval(input())) x = list(map(int, input().split())) y = list(sorted(x)) a = y[n // 2 - 1] b = y[n // 2] for i in range(n): if x[i] >= b: print(a) else: print(b)
import sys n, *x = list(map(int, sys.stdin.read().split())) y = list(sorted(x)) a = y[n // 2 - 1] b = y[n // 2] print((*[a if x[i] >= b else b for i in range(n)]))
10
6
183
167
n = int(eval(input())) x = list(map(int, input().split())) y = list(sorted(x)) a = y[n // 2 - 1] b = y[n // 2] for i in range(n): if x[i] >= b: print(a) else: print(b)
import sys n, *x = list(map(int, sys.stdin.read().split())) y = list(sorted(x)) a = y[n // 2 - 1] b = y[n // 2] print((*[a if x[i] >= b else b for i in range(n)]))
false
40
[ "-n = int(eval(input()))", "-x = list(map(int, input().split()))", "+import sys", "+", "+n, *x = list(map(int, sys.stdin.read().split()))", "-for i in range(n):", "- if x[i] >= b:", "- print(a)", "- else:", "- print(b)", "+print((*[a if x[i] >= b else b for i in range(n)]))" ]
false
0.045912
0.073384
0.625645
[ "s066617070", "s300492470" ]
u994307795
p02784
python
s935418622
s861279192
59
38
13,788
10,528
Accepted
Accepted
35.59
h, n = list(map(int, input().split())) a = [int(i) for i in input().split()] sum = 0 for i in range(n): sum += a[i] print(("Yes" if h <= sum else "No"))
h, n = list(map(int, input().split())) a = list(map(int, input().split())) print(('Yes' if sum(a) >= h else 'No'))
8
4
154
104
h, n = list(map(int, input().split())) a = [int(i) for i in input().split()] sum = 0 for i in range(n): sum += a[i] print(("Yes" if h <= sum else "No"))
h, n = list(map(int, input().split())) a = list(map(int, input().split())) print(("Yes" if sum(a) >= h else "No"))
false
50
[ "-a = [int(i) for i in input().split()]", "-sum = 0", "-for i in range(n):", "- sum += a[i]", "-print((\"Yes\" if h <= sum else \"No\"))", "+a = list(map(int, input().split()))", "+print((\"Yes\" if sum(a) >= h else \"No\"))" ]
false
0.089437
0.069661
1.283891
[ "s935418622", "s861279192" ]
u047102107
p02781
python
s228709820
s565989233
73
67
62,068
67,896
Accepted
Accepted
8.22
# https://atcoder.jp/contests/abc154/tasks/abc154_e # 桁DPっぽいよなぁ => O """ memo dp0[i][j] 上からi桁目まで決めて,0でない桁がj個あり Nより小さいことが確定している (less) dp1[i][j] 上からi桁目まで決めて,0でない桁がj個あり Nより小さいことが確定していない (i桁目まで同じ) 通常の再帰 rec """ S = eval(input()) K = int(eval(input())) N = len(S) def com(N, R): if R < 0 or R > N: return 0 if R == 1: return N elif R == 2: return N * (N - 1) // 2 elif R == 3: return N * (N - 1) * (N - 2) // 6 else: raise NotImplementedError("NIE") # 再帰呼出し def rec(i, k, smaller): if i == N: return 1 if k == 0 else 0 if k == 0: return 1 if smaller: # 残っている桁数からk個を選び,それぞれ9^kのパターンがある return com(N - i, k) * pow(9, k) else: if S[i] == '0': return rec(i + 1, k , False) else: zero = rec(i + 1, k, True) aida = rec(i + 1, k - 1, True) * (int(S[i]) - 1) ichi = rec(i + 1, k - 1, False) return zero + aida + ichi ans = rec(0, K, False) print(ans)
# https://atcoder.jp/contests/abc154/tasks/abc154_e # 桁DPっぽいよなぁ => O """ memo dp0[i][j] 上からi桁目まで決めて,0でない桁がj個あり Nより小さいことが確定している (less) dp1[i][j] 上からi桁目まで決めて,0でない桁がj個あり Nより小さいことが確定していない (i桁目まで同じ) 通常の再帰 rec """ S = eval(input()) K = int(eval(input())) N = len(S) dp0 = [[0] * (K + 2) for _ in range(N + 1)] dp1 = [[0] * (K + 2) for _ in range(N + 1)] dp0[0][0] = 1 # i桁目まで for i in range(N): dig = int(S[i]) # 0でない桁の個数がj個 for j in range(K + 1): # 選ぶ数字がk=0..9 for k in range(10): nj = j if k == 0 else j + 1 if k < dig: dp1[i + 1][nj] += dp0[i][j] + dp1[i][j] elif k == dig: dp1[i + 1][nj] += dp1[i][j] dp0[i + 1][nj] += dp0[i][j] else: dp1[i + 1][nj] += dp1[i][j] ans = dp0[N][K] + dp1[N][K] print(ans)
53
44
1,076
887
# https://atcoder.jp/contests/abc154/tasks/abc154_e # 桁DPっぽいよなぁ => O """ memo dp0[i][j] 上からi桁目まで決めて,0でない桁がj個あり Nより小さいことが確定している (less) dp1[i][j] 上からi桁目まで決めて,0でない桁がj個あり Nより小さいことが確定していない (i桁目まで同じ) 通常の再帰 rec """ S = eval(input()) K = int(eval(input())) N = len(S) def com(N, R): if R < 0 or R > N: return 0 if R == 1: return N elif R == 2: return N * (N - 1) // 2 elif R == 3: return N * (N - 1) * (N - 2) // 6 else: raise NotImplementedError("NIE") # 再帰呼出し def rec(i, k, smaller): if i == N: return 1 if k == 0 else 0 if k == 0: return 1 if smaller: # 残っている桁数からk個を選び,それぞれ9^kのパターンがある return com(N - i, k) * pow(9, k) else: if S[i] == "0": return rec(i + 1, k, False) else: zero = rec(i + 1, k, True) aida = rec(i + 1, k - 1, True) * (int(S[i]) - 1) ichi = rec(i + 1, k - 1, False) return zero + aida + ichi ans = rec(0, K, False) print(ans)
# https://atcoder.jp/contests/abc154/tasks/abc154_e # 桁DPっぽいよなぁ => O """ memo dp0[i][j] 上からi桁目まで決めて,0でない桁がj個あり Nより小さいことが確定している (less) dp1[i][j] 上からi桁目まで決めて,0でない桁がj個あり Nより小さいことが確定していない (i桁目まで同じ) 通常の再帰 rec """ S = eval(input()) K = int(eval(input())) N = len(S) dp0 = [[0] * (K + 2) for _ in range(N + 1)] dp1 = [[0] * (K + 2) for _ in range(N + 1)] dp0[0][0] = 1 # i桁目まで for i in range(N): dig = int(S[i]) # 0でない桁の個数がj個 for j in range(K + 1): # 選ぶ数字がk=0..9 for k in range(10): nj = j if k == 0 else j + 1 if k < dig: dp1[i + 1][nj] += dp0[i][j] + dp1[i][j] elif k == dig: dp1[i + 1][nj] += dp1[i][j] dp0[i + 1][nj] += dp0[i][j] else: dp1[i + 1][nj] += dp1[i][j] ans = dp0[N][K] + dp1[N][K] print(ans)
false
16.981132
[ "-", "-", "-def com(N, R):", "- if R < 0 or R > N:", "- return 0", "- if R == 1:", "- return N", "- elif R == 2:", "- return N * (N - 1) // 2", "- elif R == 3:", "- return N * (N - 1) * (N - 2) // 6", "- else:", "- raise NotImplementedError(\"NIE\")", "-", "-", "-# 再帰呼出し", "-def rec(i, k, smaller):", "- if i == N:", "- return 1 if k == 0 else 0", "- if k == 0:", "- return 1", "- if smaller:", "- # 残っている桁数からk個を選び,それぞれ9^kのパターンがある", "- return com(N - i, k) * pow(9, k)", "- else:", "- if S[i] == \"0\":", "- return rec(i + 1, k, False)", "- else:", "- zero = rec(i + 1, k, True)", "- aida = rec(i + 1, k - 1, True) * (int(S[i]) - 1)", "- ichi = rec(i + 1, k - 1, False)", "- return zero + aida + ichi", "-", "-", "-ans = rec(0, K, False)", "+dp0 = [[0] * (K + 2) for _ in range(N + 1)]", "+dp1 = [[0] * (K + 2) for _ in range(N + 1)]", "+dp0[0][0] = 1", "+# i桁目まで", "+for i in range(N):", "+ dig = int(S[i])", "+ # 0でない桁の個数がj個", "+ for j in range(K + 1):", "+ # 選ぶ数字がk=0..9", "+ for k in range(10):", "+ nj = j if k == 0 else j + 1", "+ if k < dig:", "+ dp1[i + 1][nj] += dp0[i][j] + dp1[i][j]", "+ elif k == dig:", "+ dp1[i + 1][nj] += dp1[i][j]", "+ dp0[i + 1][nj] += dp0[i][j]", "+ else:", "+ dp1[i + 1][nj] += dp1[i][j]", "+ans = dp0[N][K] + dp1[N][K]" ]
false
0.049815
0.11276
0.441784
[ "s228709820", "s565989233" ]
u175111751
p02414
python
s601912576
s086044862
400
180
8,640
8,696
Accepted
Accepted
55
n, m, l = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(n)] B = [list(map(int, input().split())) for _ in range(m)] for i in range(n): r = [] for j in range(l): c = 0 for k in range(m): c += A[i][k] * B[k][j] r.append(c) print((*r))
n, m, l = list(map(int, input().split())) A = [tuple(map(int, input().split())) for _ in range(n)] B = [tuple(map(int, input().split())) for _ in range(m)] B_T = [tuple(r) for r in zip(*B)] for L in ((sum((a*b for a, b in zip(ai, bj))) for bj in B_T) for ai in A): print((*L))
11
6
321
277
n, m, l = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(n)] B = [list(map(int, input().split())) for _ in range(m)] for i in range(n): r = [] for j in range(l): c = 0 for k in range(m): c += A[i][k] * B[k][j] r.append(c) print((*r))
n, m, l = list(map(int, input().split())) A = [tuple(map(int, input().split())) for _ in range(n)] B = [tuple(map(int, input().split())) for _ in range(m)] B_T = [tuple(r) for r in zip(*B)] for L in ((sum((a * b for a, b in zip(ai, bj))) for bj in B_T) for ai in A): print((*L))
false
45.454545
[ "-A = [list(map(int, input().split())) for _ in range(n)]", "-B = [list(map(int, input().split())) for _ in range(m)]", "-for i in range(n):", "- r = []", "- for j in range(l):", "- c = 0", "- for k in range(m):", "- c += A[i][k] * B[k][j]", "- r.append(c)", "- print((*r))", "+A = [tuple(map(int, input().split())) for _ in range(n)]", "+B = [tuple(map(int, input().split())) for _ in range(m)]", "+B_T = [tuple(r) for r in zip(*B)]", "+for L in ((sum((a * b for a, b in zip(ai, bj))) for bj in B_T) for ai in A):", "+ print((*L))" ]
false
0.039752
0.048402
0.821288
[ "s601912576", "s086044862" ]
u197457087
p03221
python
s089206703
s723030110
578
374
110,716
93,788
Accepted
Accepted
35.29
from collections import defaultdict dic = defaultdict(int) N,M = list(map(int,input().split())) A = [] for i in range(M): a,b = list(map(int,input().split())) A.append((a,b,i)) A.sort() #print(A) ans = [-1 for _ in range(M)] for i in range(M): dic[A[i][0]] += 1 #print(dic[A[i][0]]) temp = "0"*(6-len(str(A[i][0])))+str(A[i][0])+"0"*(6-len(str(dic[A[i][0]])))+str(dic[A[i][0]]) ans[A[i][2]] = temp #print(i,temp) for t in ans: print(t)
import bisect N,M = list(map(int,input().split())) A = [[] for _ in range(N)] #重複がある場合にはsetにする? original = [] for i in range(M): a,b = list(map(int,input().split())) a-=1 #県を0indexに直す A[a].append(b) original.append((a,b)) for X in A: X.sort() #print(A) for i in range(M): ken,now = original[i] ID = bisect.bisect_left(A[ken],now) ken += 1; ID+=1 ans = "0"*(6-len(str(ken)))+str(ken)+"0"*(6-len(str(ID)))+str(ID) print(ans)
19
18
460
448
from collections import defaultdict dic = defaultdict(int) N, M = list(map(int, input().split())) A = [] for i in range(M): a, b = list(map(int, input().split())) A.append((a, b, i)) A.sort() # print(A) ans = [-1 for _ in range(M)] for i in range(M): dic[A[i][0]] += 1 # print(dic[A[i][0]]) temp = ( "0" * (6 - len(str(A[i][0]))) + str(A[i][0]) + "0" * (6 - len(str(dic[A[i][0]]))) + str(dic[A[i][0]]) ) ans[A[i][2]] = temp # print(i,temp) for t in ans: print(t)
import bisect N, M = list(map(int, input().split())) A = [[] for _ in range(N)] # 重複がある場合にはsetにする? original = [] for i in range(M): a, b = list(map(int, input().split())) a -= 1 # 県を0indexに直す A[a].append(b) original.append((a, b)) for X in A: X.sort() # print(A) for i in range(M): ken, now = original[i] ID = bisect.bisect_left(A[ken], now) ken += 1 ID += 1 ans = "0" * (6 - len(str(ken))) + str(ken) + "0" * (6 - len(str(ID))) + str(ID) print(ans)
false
5.263158
[ "-from collections import defaultdict", "+import bisect", "-dic = defaultdict(int)", "-A = []", "+A = [[] for _ in range(N)] # 重複がある場合にはsetにする?", "+original = []", "- A.append((a, b, i))", "-A.sort()", "+ a -= 1 # 県を0indexに直す", "+ A[a].append(b)", "+ original.append((a, b))", "+for X in A:", "+ X.sort()", "-ans = [-1 for _ in range(M)]", "- dic[A[i][0]] += 1", "- # print(dic[A[i][0]])", "- temp = (", "- \"0\" * (6 - len(str(A[i][0])))", "- + str(A[i][0])", "- + \"0\" * (6 - len(str(dic[A[i][0]])))", "- + str(dic[A[i][0]])", "- )", "- ans[A[i][2]] = temp", "- # print(i,temp)", "-for t in ans:", "- print(t)", "+ ken, now = original[i]", "+ ID = bisect.bisect_left(A[ken], now)", "+ ken += 1", "+ ID += 1", "+ ans = \"0\" * (6 - len(str(ken))) + str(ken) + \"0\" * (6 - len(str(ID))) + str(ID)", "+ print(ans)" ]
false
0.007004
0.06482
0.108047
[ "s089206703", "s723030110" ]
u729133443
p02735
python
s164489548
s036993432
22
20
3,060
3,188
Accepted
Accepted
9.09
def main(): _,*s=open(0) b,q='.'*101,list(range(101)) for i,s in enumerate(s): a=[] for x,y,z,c in zip(b,'.'+s,s,q): c+=x=='.'>z i+=y=='.'>z if i>c:i=c a+=i, b,q=s,a print((a[-2])) main()
def main(): import sys input=sys.stdin.buffer.readline h,w=list(map(int,input().split())) b,q=b'.'*w,list(range(w)) for i in range(h): s=eval(input()) a=[] for x,y,z,c in zip(b,b'.'+s,s,q): c+=x==46>z i+=y==46>z if i>c:i=c a+=i, b,q=s,a print(i) main()
13
16
235
301
def main(): _, *s = open(0) b, q = "." * 101, list(range(101)) for i, s in enumerate(s): a = [] for x, y, z, c in zip(b, "." + s, s, q): c += x == "." > z i += y == "." > z if i > c: i = c a += (i,) b, q = s, a print((a[-2])) main()
def main(): import sys input = sys.stdin.buffer.readline h, w = list(map(int, input().split())) b, q = b"." * w, list(range(w)) for i in range(h): s = eval(input()) a = [] for x, y, z, c in zip(b, b"." + s, s, q): c += x == 46 > z i += y == 46 > z if i > c: i = c a += (i,) b, q = s, a print(i) main()
false
18.75
[ "- _, *s = open(0)", "- b, q = \".\" * 101, list(range(101))", "- for i, s in enumerate(s):", "+ import sys", "+", "+ input = sys.stdin.buffer.readline", "+ h, w = list(map(int, input().split()))", "+ b, q = b\".\" * w, list(range(w))", "+ for i in range(h):", "+ s = eval(input())", "- for x, y, z, c in zip(b, \".\" + s, s, q):", "- c += x == \".\" > z", "- i += y == \".\" > z", "+ for x, y, z, c in zip(b, b\".\" + s, s, q):", "+ c += x == 46 > z", "+ i += y == 46 > z", "- print((a[-2]))", "+ print(i)" ]
false
0.035999
0.036119
0.996686
[ "s164489548", "s036993432" ]
u163320134
p02933
python
s696282490
s345011007
169
18
38,256
2,940
Accepted
Accepted
89.35
a=int(eval(input())) s=eval(input()) if a>=3200: print(s) else: print('red')
n=int(eval(input())) s=eval(input()) if n>=3200: print(s) else: print('red')
6
6
73
73
a = int(eval(input())) s = eval(input()) if a >= 3200: print(s) else: print("red")
n = int(eval(input())) s = eval(input()) if n >= 3200: print(s) else: print("red")
false
0
[ "-a = int(eval(input()))", "+n = int(eval(input()))", "-if a >= 3200:", "+if n >= 3200:" ]
false
0.038723
0.035964
1.076699
[ "s696282490", "s345011007" ]
u057109575
p02865
python
s124028232
s390979810
162
63
38,384
61,564
Accepted
Accepted
61.11
N = int(eval(input())) print(((N - 1) // 2))
N = int(eval(input())) print((N // 2 - int(N % 2 == 0)))
2
3
37
52
N = int(eval(input())) print(((N - 1) // 2))
N = int(eval(input())) print((N // 2 - int(N % 2 == 0)))
false
33.333333
[ "-print(((N - 1) // 2))", "+print((N // 2 - int(N % 2 == 0)))" ]
false
0.072355
0.038585
1.8752
[ "s124028232", "s390979810" ]
u057415180
p03971
python
s660173629
s239442110
112
92
4,024
4,016
Accepted
Accepted
17.86
n, a, b = list(map(int, input().split())) s = eval(input()) tuka = 0 br = 0 for i in range(n): if s[i] == 'a': if tuka < a+b: print('Yes') tuka += 1 else: print('No') elif s[i] == 'b': if tuka < a+b and br < b: print('Yes') tuka += 1 br += 1 else: print('No') br += 1 else: print('No')
def LI(): return list(map(int, input().split())) def I(): return list(map(int, input().split())) mod = 10**9 + 7 def main(): n, a, b = I() s = eval(input()) yn = [] for i in range(n): if s[i] == 'a': if a + b > 0: print('Yes') if a > 0: a -= 1 else: b -= 1 else: print('No') elif s[i] == 'b': if a + b > 0 and b > 0: print('Yes') else: print('No') if b > 0: b -= 1 else: print('No') if __name__ == '__main__': main()
21
34
441
712
n, a, b = list(map(int, input().split())) s = eval(input()) tuka = 0 br = 0 for i in range(n): if s[i] == "a": if tuka < a + b: print("Yes") tuka += 1 else: print("No") elif s[i] == "b": if tuka < a + b and br < b: print("Yes") tuka += 1 br += 1 else: print("No") br += 1 else: print("No")
def LI(): return list(map(int, input().split())) def I(): return list(map(int, input().split())) mod = 10**9 + 7 def main(): n, a, b = I() s = eval(input()) yn = [] for i in range(n): if s[i] == "a": if a + b > 0: print("Yes") if a > 0: a -= 1 else: b -= 1 else: print("No") elif s[i] == "b": if a + b > 0 and b > 0: print("Yes") else: print("No") if b > 0: b -= 1 else: print("No") if __name__ == "__main__": main()
false
38.235294
[ "-n, a, b = list(map(int, input().split()))", "-s = eval(input())", "-tuka = 0", "-br = 0", "-for i in range(n):", "- if s[i] == \"a\":", "- if tuka < a + b:", "- print(\"Yes\")", "- tuka += 1", "+def LI():", "+ return list(map(int, input().split()))", "+", "+", "+def I():", "+ return list(map(int, input().split()))", "+", "+", "+mod = 10**9 + 7", "+", "+", "+def main():", "+ n, a, b = I()", "+ s = eval(input())", "+ yn = []", "+ for i in range(n):", "+ if s[i] == \"a\":", "+ if a + b > 0:", "+ print(\"Yes\")", "+ if a > 0:", "+ a -= 1", "+ else:", "+ b -= 1", "+ else:", "+ print(\"No\")", "+ elif s[i] == \"b\":", "+ if a + b > 0 and b > 0:", "+ print(\"Yes\")", "+ else:", "+ print(\"No\")", "+ if b > 0:", "+ b -= 1", "- elif s[i] == \"b\":", "- if tuka < a + b and br < b:", "- print(\"Yes\")", "- tuka += 1", "- br += 1", "- else:", "- print(\"No\")", "- br += 1", "- else:", "- print(\"No\")", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.120235
0.051081
2.353795
[ "s660173629", "s239442110" ]
u754022296
p03363
python
s139973444
s322526209
159
133
41,984
37,028
Accepted
Accepted
16.35
from itertools import accumulate from collections import Counter n = int(eval(input())) A = list(map(int, input().split())) L = [0] + list(accumulate(A)) C = Counter(L) ans = 0 for i in list(C.values()): ans += i*(i-1)//2 print(ans)
from itertools import accumulate from collections import Counter n = int(eval(input())) A = [0] + list(map(int, input().split())) A = list(accumulate(A)) C = Counter(A) ans = 0 for v in list(C.values()): ans += v*(v-1)//2 print(ans)
11
11
233
233
from itertools import accumulate from collections import Counter n = int(eval(input())) A = list(map(int, input().split())) L = [0] + list(accumulate(A)) C = Counter(L) ans = 0 for i in list(C.values()): ans += i * (i - 1) // 2 print(ans)
from itertools import accumulate from collections import Counter n = int(eval(input())) A = [0] + list(map(int, input().split())) A = list(accumulate(A)) C = Counter(A) ans = 0 for v in list(C.values()): ans += v * (v - 1) // 2 print(ans)
false
0
[ "-A = list(map(int, input().split()))", "-L = [0] + list(accumulate(A))", "-C = Counter(L)", "+A = [0] + list(map(int, input().split()))", "+A = list(accumulate(A))", "+C = Counter(A)", "-for i in list(C.values()):", "- ans += i * (i - 1) // 2", "+for v in list(C.values()):", "+ ans += v * (v - 1) // 2" ]
false
0.03918
0.048122
0.814176
[ "s139973444", "s322526209" ]
u716043626
p03073
python
s192569809
s812357150
90
44
3,956
3,956
Accepted
Accepted
51.11
S = eval(input()) A = [] ans = 0 for i in range(len(S)): if i % 2 == 0: A.append(1) else: A.append(0) for i in range(len(S)): if int(S[i]) != int(A[i]): ans += 1 print((min(ans, len(S) - ans)))
s = list(eval(input())) count1 = 0 count2 = 0 if s[0] == '0': for i in range(len(s)): if i % 2 == 0: if s[i] == '0': continue else: count1 +=1 else: if s[i] == '1': continue else: count1 += 1 else: for i in range(len(s)): if i % 2 == 0: if s[i] == '1': continue else: count2 += 1 else: if s[i] == '0': continue else: count2 += 1 print((max(count1,count2)))
12
32
232
679
S = eval(input()) A = [] ans = 0 for i in range(len(S)): if i % 2 == 0: A.append(1) else: A.append(0) for i in range(len(S)): if int(S[i]) != int(A[i]): ans += 1 print((min(ans, len(S) - ans)))
s = list(eval(input())) count1 = 0 count2 = 0 if s[0] == "0": for i in range(len(s)): if i % 2 == 0: if s[i] == "0": continue else: count1 += 1 else: if s[i] == "1": continue else: count1 += 1 else: for i in range(len(s)): if i % 2 == 0: if s[i] == "1": continue else: count2 += 1 else: if s[i] == "0": continue else: count2 += 1 print((max(count1, count2)))
false
62.5
[ "-S = eval(input())", "-A = []", "-ans = 0", "-for i in range(len(S)):", "- if i % 2 == 0:", "- A.append(1)", "- else:", "- A.append(0)", "-for i in range(len(S)):", "- if int(S[i]) != int(A[i]):", "- ans += 1", "-print((min(ans, len(S) - ans)))", "+s = list(eval(input()))", "+count1 = 0", "+count2 = 0", "+if s[0] == \"0\":", "+ for i in range(len(s)):", "+ if i % 2 == 0:", "+ if s[i] == \"0\":", "+ continue", "+ else:", "+ count1 += 1", "+ else:", "+ if s[i] == \"1\":", "+ continue", "+ else:", "+ count1 += 1", "+else:", "+ for i in range(len(s)):", "+ if i % 2 == 0:", "+ if s[i] == \"1\":", "+ continue", "+ else:", "+ count2 += 1", "+ else:", "+ if s[i] == \"0\":", "+ continue", "+ else:", "+ count2 += 1", "+print((max(count1, count2)))" ]
false
0.041461
0.074441
0.55696
[ "s192569809", "s812357150" ]
u631277801
p03215
python
s242549350
s353284840
911
348
29,180
92,084
Accepted
Accepted
61.8
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) from itertools import accumulate n,k = li() a = list(li()) a_cum = [0] + list(accumulate(a)) sm_lst = [] for i in range(n+1): for j in range(i+1,n+1): sm_lst.append(a_cum[j] - a_cum[i]) pop = sm_lst ans = 0 for bit in range(40,-1,-1): yes=[] no=[] for s in pop: if s & (1<<bit): yes.append(s) else: no.append(s) if len(yes) >= k: ans += (1<<bit) pop = yes print(ans)
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) from itertools import accumulate n,k = li() a = list(li()) acum = list(accumulate([0]+a)) cand = [] for i in range(n+1): for j in range(i+1,n+1): cand.append(acum[j] - acum[i]) ans = 0 for mask in range(40, -1, -1): satis = sum([bool(ci&(1<<mask)) for ci in cand]) if satis >= k: ans += (1<<mask) nex = [ci for ci in cand if ci & (1<<mask)] cand = nex print(ans)
44
38
965
890
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) from itertools import accumulate n, k = li() a = list(li()) a_cum = [0] + list(accumulate(a)) sm_lst = [] for i in range(n + 1): for j in range(i + 1, n + 1): sm_lst.append(a_cum[j] - a_cum[i]) pop = sm_lst ans = 0 for bit in range(40, -1, -1): yes = [] no = [] for s in pop: if s & (1 << bit): yes.append(s) else: no.append(s) if len(yes) >= k: ans += 1 << bit pop = yes print(ans)
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) from itertools import accumulate n, k = li() a = list(li()) acum = list(accumulate([0] + a)) cand = [] for i in range(n + 1): for j in range(i + 1, n + 1): cand.append(acum[j] - acum[i]) ans = 0 for mask in range(40, -1, -1): satis = sum([bool(ci & (1 << mask)) for ci in cand]) if satis >= k: ans += 1 << mask nex = [ci for ci in cand if ci & (1 << mask)] cand = nex print(ans)
false
13.636364
[ "-a_cum = [0] + list(accumulate(a))", "-sm_lst = []", "+acum = list(accumulate([0] + a))", "+cand = []", "- sm_lst.append(a_cum[j] - a_cum[i])", "-pop = sm_lst", "+ cand.append(acum[j] - acum[i])", "-for bit in range(40, -1, -1):", "- yes = []", "- no = []", "- for s in pop:", "- if s & (1 << bit):", "- yes.append(s)", "- else:", "- no.append(s)", "- if len(yes) >= k:", "- ans += 1 << bit", "- pop = yes", "+for mask in range(40, -1, -1):", "+ satis = sum([bool(ci & (1 << mask)) for ci in cand])", "+ if satis >= k:", "+ ans += 1 << mask", "+ nex = [ci for ci in cand if ci & (1 << mask)]", "+ cand = nex" ]
false
0.036985
0.036081
1.025051
[ "s242549350", "s353284840" ]
u729133443
p02904
python
s201838291
s510625039
1,393
621
25,884
121,020
Accepted
Accepted
55.42
class SWAG(): __slots__=('unit','f','fold_r','fold_l','data_r','data_l') def __init__(self,unit,f,data): self.unit=unit self.f=f self.fold_r=[unit] self.fold_l=[unit] self.data_r=[] self.data_l=[] sep=len(data)//2 for t in data[sep:]: self.append(t) for t in data[sep-1::-1]: self.appendleft(t) def append(self,x): self.fold_r.append(self.f(self.fold_r[-1],x)) self.data_r.append(x) def appendleft(self,x): self.fold_l.append(self.f(self.fold_l[-1],x)) self.data_l.append(x) def pop(self): if not self.data_r: self.__init__(self.unit,self.f,self.data_l[::-1]) self.fold_r.pop() return self.data_r.pop() def popleft(self): if not self.data_l: self.__init__(self.unit,self.f,self.data_r) self.fold_l.pop() return self.data_l.pop() def fold_all(self): return self.f(self.fold_r[-1],self.fold_l[-1]) n,k,*p=list(map(int,open(0).read().split())) c=[0] for a,b in zip(p,p[1:]):c+=c[-1]+(a<b), *c,f=[b-a==k-1for a,b in zip(c,c[k-1:])] x=not f s_min=SWAG(10**18,min,p[:k-1]) s_max=SWAG(0,max,p[1:k]) for i,(a,b,c)in enumerate(zip(p,p[k:],c)): f|=c s_min.append(p[i+k-1]) s_max.append(b) if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1 s_min.popleft() s_max.popleft() print((x+f))
class SWAG(): def __init__(self,unit,f,data): self.unit=unit self.f=f self.construct(data) def construct(self,data): self.fold_r=[self.unit] self.fold_l=[self.unit] self.data_r=[] self.data_l=[] sep=len(data)//2 for t in data[sep:]: self.append(t) for t in data[sep-1::-1]: self.appendleft(t) def append(self,x): self.fold_r.append(self.f(self.fold_r[-1],x)) self.data_r.append(x) def appendleft(self,x): self.fold_l.append(self.f(self.fold_l[-1],x)) self.data_l.append(x) def pop(self): if not self.data_r: self.construct(self.data_l[::-1]) self.fold_r.pop() return self.data_r.pop() def popleft(self): if not self.data_l: self.construct(self.data_r) self.fold_l.pop() return self.data_l.pop() def fold_all(self): return self.f(self.fold_r[-1],self.fold_l[-1]) n,k,*p=list(map(int,open(0).read().split())) c=[0] for a,b in zip(p,p[1:]):c+=c[-1]+(a<b), *c,f=[b-a==k-1for a,b in zip(c,c[k-1:])] x=not f s_min=SWAG(10**18,min,p[:k-1]) s_max=SWAG(0,max,p[1:k]) for i,(a,b,c)in enumerate(zip(p,p[k:],c)): f|=c s_min.append(p[i+k-1]) s_max.append(b) if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1 s_min.popleft() s_max.popleft() print((x+f))
47
48
1,482
1,457
class SWAG: __slots__ = ("unit", "f", "fold_r", "fold_l", "data_r", "data_l") def __init__(self, unit, f, data): self.unit = unit self.f = f self.fold_r = [unit] self.fold_l = [unit] self.data_r = [] self.data_l = [] sep = len(data) // 2 for t in data[sep:]: self.append(t) for t in data[sep - 1 :: -1]: self.appendleft(t) def append(self, x): self.fold_r.append(self.f(self.fold_r[-1], x)) self.data_r.append(x) def appendleft(self, x): self.fold_l.append(self.f(self.fold_l[-1], x)) self.data_l.append(x) def pop(self): if not self.data_r: self.__init__(self.unit, self.f, self.data_l[::-1]) self.fold_r.pop() return self.data_r.pop() def popleft(self): if not self.data_l: self.__init__(self.unit, self.f, self.data_r) self.fold_l.pop() return self.data_l.pop() def fold_all(self): return self.f(self.fold_r[-1], self.fold_l[-1]) n, k, *p = list(map(int, open(0).read().split())) c = [0] for a, b in zip(p, p[1:]): c += (c[-1] + (a < b),) *c, f = [b - a == k - 1 for a, b in zip(c, c[k - 1 :])] x = not f s_min = SWAG(10**18, min, p[: k - 1]) s_max = SWAG(0, max, p[1:k]) for i, (a, b, c) in enumerate(zip(p, p[k:], c)): f |= c s_min.append(p[i + k - 1]) s_max.append(b) if not c and (a != s_min.fold_all() or b != s_max.fold_all()): x += 1 s_min.popleft() s_max.popleft() print((x + f))
class SWAG: def __init__(self, unit, f, data): self.unit = unit self.f = f self.construct(data) def construct(self, data): self.fold_r = [self.unit] self.fold_l = [self.unit] self.data_r = [] self.data_l = [] sep = len(data) // 2 for t in data[sep:]: self.append(t) for t in data[sep - 1 :: -1]: self.appendleft(t) def append(self, x): self.fold_r.append(self.f(self.fold_r[-1], x)) self.data_r.append(x) def appendleft(self, x): self.fold_l.append(self.f(self.fold_l[-1], x)) self.data_l.append(x) def pop(self): if not self.data_r: self.construct(self.data_l[::-1]) self.fold_r.pop() return self.data_r.pop() def popleft(self): if not self.data_l: self.construct(self.data_r) self.fold_l.pop() return self.data_l.pop() def fold_all(self): return self.f(self.fold_r[-1], self.fold_l[-1]) n, k, *p = list(map(int, open(0).read().split())) c = [0] for a, b in zip(p, p[1:]): c += (c[-1] + (a < b),) *c, f = [b - a == k - 1 for a, b in zip(c, c[k - 1 :])] x = not f s_min = SWAG(10**18, min, p[: k - 1]) s_max = SWAG(0, max, p[1:k]) for i, (a, b, c) in enumerate(zip(p, p[k:], c)): f |= c s_min.append(p[i + k - 1]) s_max.append(b) if not c and (a != s_min.fold_all() or b != s_max.fold_all()): x += 1 s_min.popleft() s_max.popleft() print((x + f))
false
2.083333
[ "- __slots__ = (\"unit\", \"f\", \"fold_r\", \"fold_l\", \"data_r\", \"data_l\")", "-", "- self.fold_r = [unit]", "- self.fold_l = [unit]", "+ self.construct(data)", "+", "+ def construct(self, data):", "+ self.fold_r = [self.unit]", "+ self.fold_l = [self.unit]", "- self.__init__(self.unit, self.f, self.data_l[::-1])", "+ self.construct(self.data_l[::-1])", "- self.__init__(self.unit, self.f, self.data_r)", "+ self.construct(self.data_r)" ]
false
0.037176
0.038755
0.959261
[ "s201838291", "s510625039" ]
u638456847
p02844
python
s618464411
s720889794
562
24
41,060
3,188
Accepted
Accepted
95.73
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) S = readline().strip() ans = 0 for p in range(1000): pattern = str(p).zfill(3) key = 0 cnt = 0 for n in pattern: for i in range(key,N): if S[i] == n: key = i+1 cnt += 1 break if cnt == 3: ans += 1 print(ans) if __name__ == "__main__": main()
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) S = readline().strip() ans = 0 for p in range(1000): pattern = str(p).zfill(3) cnt = 0 T = S for n in pattern: i = T.find(n) if i != -1: T = T[i+1:] cnt += 1 if cnt == 3: ans += 1 print(ans) if __name__ == "__main__": main()
28
27
569
519
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) S = readline().strip() ans = 0 for p in range(1000): pattern = str(p).zfill(3) key = 0 cnt = 0 for n in pattern: for i in range(key, N): if S[i] == n: key = i + 1 cnt += 1 break if cnt == 3: ans += 1 print(ans) if __name__ == "__main__": main()
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) S = readline().strip() ans = 0 for p in range(1000): pattern = str(p).zfill(3) cnt = 0 T = S for n in pattern: i = T.find(n) if i != -1: T = T[i + 1 :] cnt += 1 if cnt == 3: ans += 1 print(ans) if __name__ == "__main__": main()
false
3.571429
[ "- key = 0", "+ T = S", "- for i in range(key, N):", "- if S[i] == n:", "- key = i + 1", "- cnt += 1", "- break", "+ i = T.find(n)", "+ if i != -1:", "+ T = T[i + 1 :]", "+ cnt += 1" ]
false
0.110038
0.03725
2.954001
[ "s618464411", "s720889794" ]
u810356688
p02984
python
s490229480
s944136680
268
115
63,984
14,616
Accepted
Accepted
57.09
import sys def input(): return sys.stdin.readline().rstrip() def main(): n=int(eval(input())) A=[int(_) for _ in input().split()] B=[0]*n B[0]=sum(A)-sum(A[1::2])*2 for i in range(1,n): B[i]=(A[i-1]-B[i-1]//2)*2 print((*B)) if __name__=='__main__': main()
import sys def input(): return sys.stdin.readline().rstrip() def main(): n=int(eval(input())) A=list(map(int,input().split())) B=[0]*n B[0]=sum(A)-sum(A[1::2])*2 for i in range(1,n): B[i]=(A[i-1]-B[i-1]//2)*2 print((*B)) if __name__=='__main__': main()
13
13
300
297
import sys def input(): return sys.stdin.readline().rstrip() def main(): n = int(eval(input())) A = [int(_) for _ in input().split()] B = [0] * n B[0] = sum(A) - sum(A[1::2]) * 2 for i in range(1, n): B[i] = (A[i - 1] - B[i - 1] // 2) * 2 print((*B)) if __name__ == "__main__": main()
import sys def input(): return sys.stdin.readline().rstrip() def main(): n = int(eval(input())) A = list(map(int, input().split())) B = [0] * n B[0] = sum(A) - sum(A[1::2]) * 2 for i in range(1, n): B[i] = (A[i - 1] - B[i - 1] // 2) * 2 print((*B)) if __name__ == "__main__": main()
false
0
[ "- A = [int(_) for _ in input().split()]", "+ A = list(map(int, input().split()))" ]
false
0.041117
0.077162
0.532863
[ "s490229480", "s944136680" ]
u608355135
p03557
python
s168039919
s194107014
1,101
961
24,052
24,052
Accepted
Accepted
12.72
N=list(map(int,input().split())) A=sorted(list(map(int,input().split()))) B=list(map(int,input().split())) C=sorted(list(map(int,input().split()))) def countA(target,L): ok=-1 ng=len(L) while abs(ok-ng)>1: mid=(ok+ng)//2 if L[mid]<target: ok=mid else: ng=mid return (ok+1) def countC(target,L): ok=len(L) ng=-1 while abs(ok-ng)>1: mid=(ok+ng)//2 if L[mid]>target: ok=mid else: ng=mid return len(L)-ok ans=0 for i in range(len(B)): data=B[i] ans+=(countA(data,A)*countC(data,C)) print(ans)
def nibu_A(list,item): high=len(list) low=-1 while abs(high-low) > 1: mid=(high+low)//2 if list[mid] < item: low= mid else: high=mid return (low+1) def nibu_c(list,item): high= len(list) low=-1 while abs(high-low)>1: mid=(high+low)//2 if list[mid]>item: high = mid else: low=mid return len(list)-high n=int(eval(input())) A=sorted(list(map(int,input().split()))) B=list(map(int,input().split())) C=sorted(list(map(int,input().split()))) ans=0 for i in range(n): data=B[i] ans+=(nibu_A(A,data)*nibu_c(C,data)) print(ans)
33
33
591
687
N = list(map(int, input().split())) A = sorted(list(map(int, input().split()))) B = list(map(int, input().split())) C = sorted(list(map(int, input().split()))) def countA(target, L): ok = -1 ng = len(L) while abs(ok - ng) > 1: mid = (ok + ng) // 2 if L[mid] < target: ok = mid else: ng = mid return ok + 1 def countC(target, L): ok = len(L) ng = -1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if L[mid] > target: ok = mid else: ng = mid return len(L) - ok ans = 0 for i in range(len(B)): data = B[i] ans += countA(data, A) * countC(data, C) print(ans)
def nibu_A(list, item): high = len(list) low = -1 while abs(high - low) > 1: mid = (high + low) // 2 if list[mid] < item: low = mid else: high = mid return low + 1 def nibu_c(list, item): high = len(list) low = -1 while abs(high - low) > 1: mid = (high + low) // 2 if list[mid] > item: high = mid else: low = mid return len(list) - high n = int(eval(input())) A = sorted(list(map(int, input().split()))) B = list(map(int, input().split())) C = sorted(list(map(int, input().split()))) ans = 0 for i in range(n): data = B[i] ans += nibu_A(A, data) * nibu_c(C, data) print(ans)
false
0
[ "-N = list(map(int, input().split()))", "+def nibu_A(list, item):", "+ high = len(list)", "+ low = -1", "+ while abs(high - low) > 1:", "+ mid = (high + low) // 2", "+ if list[mid] < item:", "+ low = mid", "+ else:", "+ high = mid", "+ return low + 1", "+", "+", "+def nibu_c(list, item):", "+ high = len(list)", "+ low = -1", "+ while abs(high - low) > 1:", "+ mid = (high + low) // 2", "+ if list[mid] > item:", "+ high = mid", "+ else:", "+ low = mid", "+ return len(list) - high", "+", "+", "+n = int(eval(input()))", "-", "-", "-def countA(target, L):", "- ok = -1", "- ng = len(L)", "- while abs(ok - ng) > 1:", "- mid = (ok + ng) // 2", "- if L[mid] < target:", "- ok = mid", "- else:", "- ng = mid", "- return ok + 1", "-", "-", "-def countC(target, L):", "- ok = len(L)", "- ng = -1", "- while abs(ok - ng) > 1:", "- mid = (ok + ng) // 2", "- if L[mid] > target:", "- ok = mid", "- else:", "- ng = mid", "- return len(L) - ok", "-", "-", "-for i in range(len(B)):", "+for i in range(n):", "- ans += countA(data, A) * countC(data, C)", "+ ans += nibu_A(A, data) * nibu_c(C, data)" ]
false
0.043542
0.047074
0.924963
[ "s168039919", "s194107014" ]
u242031676
p02779
python
s445177202
s727753108
81
64
25,192
31,156
Accepted
Accepted
20.99
n, *a = list(map(int, open(0).read().split())) print(("YNEOS"[len(set(a))!=len(a)::2]))
n=int(eval(input()));print(("YNEOS"[n!=len(set(input().split()))::2]))
2
1
80
62
n, *a = list(map(int, open(0).read().split())) print(("YNEOS"[len(set(a)) != len(a) :: 2]))
n = int(eval(input())) print(("YNEOS"[n != len(set(input().split())) :: 2]))
false
50
[ "-n, *a = list(map(int, open(0).read().split()))", "-print((\"YNEOS\"[len(set(a)) != len(a) :: 2]))", "+n = int(eval(input()))", "+print((\"YNEOS\"[n != len(set(input().split())) :: 2]))" ]
false
0.037559
0.037834
0.992733
[ "s445177202", "s727753108" ]
u489959379
p03131
python
s662193689
s988780833
20
18
3,060
3,060
Accepted
Accepted
10
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): k, a, b = list(map(int, input().split())) if b - a < 2: print((k + 1)) else: n = k - a + 1 res = a + n // 2 * (b - a) res += 1 if n % 2 != 0 else 0 print(res) if __name__ == '__main__': resolve()
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): k, a, b = list(map(int, input().split())) if b - a < 2 or k - a < 1: print((k + 1)) else: k -= a - 1 q, k = divmod(k, 2) res = a + q * (b - a) + k print(res) if __name__ == '__main__': resolve()
21
22
366
393
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): k, a, b = list(map(int, input().split())) if b - a < 2: print((k + 1)) else: n = k - a + 1 res = a + n // 2 * (b - a) res += 1 if n % 2 != 0 else 0 print(res) if __name__ == "__main__": resolve()
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): k, a, b = list(map(int, input().split())) if b - a < 2 or k - a < 1: print((k + 1)) else: k -= a - 1 q, k = divmod(k, 2) res = a + q * (b - a) + k print(res) if __name__ == "__main__": resolve()
false
4.545455
[ "+input = sys.stdin.readline", "- if b - a < 2:", "+ if b - a < 2 or k - a < 1:", "- n = k - a + 1", "- res = a + n // 2 * (b - a)", "- res += 1 if n % 2 != 0 else 0", "+ k -= a - 1", "+ q, k = divmod(k, 2)", "+ res = a + q * (b - a) + k" ]
false
0.044205
0.04568
0.967715
[ "s662193689", "s988780833" ]
u396210538
p02696
python
s761574471
s711102825
60
22
61,916
9,156
Accepted
Accepted
63.33
from sys import stdin import sys A, B, N = [int(x) for x in stdin.readline().rstrip().split()] # N, M = [int(x) for x in stdin.readline().rstrip().split()] # U = input().split() ans = int((A*N)/B)-A*int(N/B) ans2=0 if B-1<N: ans = int((A*(B-1))/B)-A*int((B-1)/B) else: ans2=0 print(ans)
from sys import stdin A, B, N = [int(x) for x in stdin.readline().rstrip().split()] ans1 = (A*N)//B-A*(N//B) if B-1<=N: ans2 = (A*(B-1))//B else: ans2=0 print((max(ans1,ans2)))
16
12
316
197
from sys import stdin import sys A, B, N = [int(x) for x in stdin.readline().rstrip().split()] # N, M = [int(x) for x in stdin.readline().rstrip().split()] # U = input().split() ans = int((A * N) / B) - A * int(N / B) ans2 = 0 if B - 1 < N: ans = int((A * (B - 1)) / B) - A * int((B - 1) / B) else: ans2 = 0 print(ans)
from sys import stdin A, B, N = [int(x) for x in stdin.readline().rstrip().split()] ans1 = (A * N) // B - A * (N // B) if B - 1 <= N: ans2 = (A * (B - 1)) // B else: ans2 = 0 print((max(ans1, ans2)))
false
25
[ "-import sys", "-# N, M = [int(x) for x in stdin.readline().rstrip().split()]", "-# U = input().split()", "-ans = int((A * N) / B) - A * int(N / B)", "-ans2 = 0", "-if B - 1 < N:", "- ans = int((A * (B - 1)) / B) - A * int((B - 1) / B)", "+ans1 = (A * N) // B - A * (N // B)", "+if B - 1 <= N:", "+ ans2 = (A * (B - 1)) // B", "-print(ans)", "+print((max(ans1, ans2)))" ]
false
0.03426
0.042776
0.800917
[ "s761574471", "s711102825" ]
u371385198
p02713
python
s341743266
s341413187
1,098
192
9,212
67,768
Accepted
Accepted
82.51
import sys import math input = sys.stdin.readline K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(i, K + 1): n = math.gcd(i, j) for l in range(j, K + 1): if len(set([i, j, l])) == 1: ans += math.gcd(n, l) elif len(set([i, j, l])) == 2: ans += (math.gcd(n, l) * 3) else: ans += (math.gcd(n, l) * 6) print(ans)
import sys import math input = sys.stdin.readline K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): n = math.gcd(i, j) for l in range(1, K + 1): ans += math.gcd(n, l) print(ans)
19
14
452
255
import sys import math input = sys.stdin.readline K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(i, K + 1): n = math.gcd(i, j) for l in range(j, K + 1): if len(set([i, j, l])) == 1: ans += math.gcd(n, l) elif len(set([i, j, l])) == 2: ans += math.gcd(n, l) * 3 else: ans += math.gcd(n, l) * 6 print(ans)
import sys import math input = sys.stdin.readline K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): n = math.gcd(i, j) for l in range(1, K + 1): ans += math.gcd(n, l) print(ans)
false
26.315789
[ "- for j in range(i, K + 1):", "+ for j in range(1, K + 1):", "- for l in range(j, K + 1):", "- if len(set([i, j, l])) == 1:", "- ans += math.gcd(n, l)", "- elif len(set([i, j, l])) == 2:", "- ans += math.gcd(n, l) * 3", "- else:", "- ans += math.gcd(n, l) * 6", "+ for l in range(1, K + 1):", "+ ans += math.gcd(n, l)" ]
false
0.101314
0.037877
2.674799
[ "s341743266", "s341413187" ]
u852690916
p03112
python
s255889925
s054314098
1,748
1,140
152,284
118,108
Accepted
Accepted
34.78
import sys def main(): input = sys.stdin.readline A,B,Q=list(map(int, input().split())) S=[int(eval(input())) for _ in range(A)] T=[int(eval(input())) for _ in range(B)] X=[int(eval(input())) for _ in range(Q)] from bisect import bisect_left INF=10**11 S=[-INF] + S + [INF] T=[-INF] + T + [INF] for x in X: sr = bisect_left(S, x) tr = bisect_left(T, x) sl,tl=sr-1,tr-1 ans=INF ans = min(ans, abs(S[sl]-T[tl]) + min(abs(S[sl]-x), abs(T[tl]-x))) ans = min(ans, abs(S[sl]-T[tr]) + min(abs(S[sl]-x), abs(T[tr]-x))) ans = min(ans, abs(S[sr]-T[tl]) + min(abs(S[sr]-x), abs(T[tl]-x))) ans = min(ans, abs(S[sr]-T[tr]) + min(abs(S[sr]-x), abs(T[tr]-x))) print(ans) if __name__ == '__main__': main()
from bisect import bisect_left import sys def main(): input = sys.stdin.readline A, B, Q = list(map(int, input().split())) S = [int(eval(input())) for _ in range(A)] T = [int(eval(input())) for _ in range(B)] X = [int(eval(input())) for _ in range(Q)] INF = 10 ** 11 S = [-INF] + S + [INF] T = [-INF] + T + [INF] for x in X: i = bisect_left(S, x) ls = x - S[i - 1] rs = S[i] - x j = bisect_left(T, x) lt = x - T[j - 1] rt = T[j] - x print((min(max(ls, lt), max(rs, rt), 2 * ls + rt, ls + 2 * rt, 2 * rs + lt, rs + 2 * lt))) if __name__ == '__main__': main()
24
22
805
650
import sys def main(): input = sys.stdin.readline A, B, Q = list(map(int, input().split())) S = [int(eval(input())) for _ in range(A)] T = [int(eval(input())) for _ in range(B)] X = [int(eval(input())) for _ in range(Q)] from bisect import bisect_left INF = 10**11 S = [-INF] + S + [INF] T = [-INF] + T + [INF] for x in X: sr = bisect_left(S, x) tr = bisect_left(T, x) sl, tl = sr - 1, tr - 1 ans = INF ans = min(ans, abs(S[sl] - T[tl]) + min(abs(S[sl] - x), abs(T[tl] - x))) ans = min(ans, abs(S[sl] - T[tr]) + min(abs(S[sl] - x), abs(T[tr] - x))) ans = min(ans, abs(S[sr] - T[tl]) + min(abs(S[sr] - x), abs(T[tl] - x))) ans = min(ans, abs(S[sr] - T[tr]) + min(abs(S[sr] - x), abs(T[tr] - x))) print(ans) if __name__ == "__main__": main()
from bisect import bisect_left import sys def main(): input = sys.stdin.readline A, B, Q = list(map(int, input().split())) S = [int(eval(input())) for _ in range(A)] T = [int(eval(input())) for _ in range(B)] X = [int(eval(input())) for _ in range(Q)] INF = 10**11 S = [-INF] + S + [INF] T = [-INF] + T + [INF] for x in X: i = bisect_left(S, x) ls = x - S[i - 1] rs = S[i] - x j = bisect_left(T, x) lt = x - T[j - 1] rt = T[j] - x print( ( min( max(ls, lt), max(rs, rt), 2 * ls + rt, ls + 2 * rt, 2 * rs + lt, rs + 2 * lt, ) ) ) if __name__ == "__main__": main()
false
8.333333
[ "+from bisect import bisect_left", "- from bisect import bisect_left", "-", "- sr = bisect_left(S, x)", "- tr = bisect_left(T, x)", "- sl, tl = sr - 1, tr - 1", "- ans = INF", "- ans = min(ans, abs(S[sl] - T[tl]) + min(abs(S[sl] - x), abs(T[tl] - x)))", "- ans = min(ans, abs(S[sl] - T[tr]) + min(abs(S[sl] - x), abs(T[tr] - x)))", "- ans = min(ans, abs(S[sr] - T[tl]) + min(abs(S[sr] - x), abs(T[tl] - x)))", "- ans = min(ans, abs(S[sr] - T[tr]) + min(abs(S[sr] - x), abs(T[tr] - x)))", "- print(ans)", "+ i = bisect_left(S, x)", "+ ls = x - S[i - 1]", "+ rs = S[i] - x", "+ j = bisect_left(T, x)", "+ lt = x - T[j - 1]", "+ rt = T[j] - x", "+ print(", "+ (", "+ min(", "+ max(ls, lt),", "+ max(rs, rt),", "+ 2 * ls + rt,", "+ ls + 2 * rt,", "+ 2 * rs + lt,", "+ rs + 2 * lt,", "+ )", "+ )", "+ )" ]
false
0.038513
0.038004
1.013403
[ "s255889925", "s054314098" ]
u057916330
p03032
python
s203788581
s182782459
614
65
3,064
3,064
Accepted
Accepted
89.41
from heapq import heappush, heappop, heapify N, K = list(map(int, input().split())) V = list(map(int, input().split())) # N jewels in dequeue D # at most K operations # 1 <= N <= 50 # 1 <= K <= 100 # -10000000 <= Vi <= 10000000 # Operation A, B: Remove left or right # Operation C, D: Add to left or right S = 0 for take in range(min(N, K) + 1): for takeL in range(take + 1): for takeR in range(take - takeL + 1): hand = [] for i in range(takeL): heappush(hand, V[i]) for i in range(takeR): if N - i - 1 < takeL: break heappush(hand, V[N- i - 1]) S = max(sum(hand), S) for _ in range(K - take): if not hand or hand[0] >= 0: break heappop(hand) S = max(sum(hand), S) print(S)
from heapq import heappush, heappop, heapify N, K = list(map(int, input().split())) V = list(map(int, input().split())) # N jewels in dequeue D # at most K operations # 1 <= N <= 50 # 1 <= K <= 100 # -10000000 <= Vi <= 10000000 # Operation A, B: Remove left or right # Operation C, D: Add to left or right S = 0 for take in range(min(N, K) + 1): for takeL in range(take + 1): takeR = take - takeL hand = [] for i in range(takeL): heappush(hand, V[i]) for i in range(takeR): if N - i - 1 < takeL: break heappush(hand, V[N- i - 1]) S = max(sum(hand), S) for _ in range(K - take): if not hand or hand[0] >= 0: break heappop(hand) S = max(sum(hand), S) print(S)
33
33
914
845
from heapq import heappush, heappop, heapify N, K = list(map(int, input().split())) V = list(map(int, input().split())) # N jewels in dequeue D # at most K operations # 1 <= N <= 50 # 1 <= K <= 100 # -10000000 <= Vi <= 10000000 # Operation A, B: Remove left or right # Operation C, D: Add to left or right S = 0 for take in range(min(N, K) + 1): for takeL in range(take + 1): for takeR in range(take - takeL + 1): hand = [] for i in range(takeL): heappush(hand, V[i]) for i in range(takeR): if N - i - 1 < takeL: break heappush(hand, V[N - i - 1]) S = max(sum(hand), S) for _ in range(K - take): if not hand or hand[0] >= 0: break heappop(hand) S = max(sum(hand), S) print(S)
from heapq import heappush, heappop, heapify N, K = list(map(int, input().split())) V = list(map(int, input().split())) # N jewels in dequeue D # at most K operations # 1 <= N <= 50 # 1 <= K <= 100 # -10000000 <= Vi <= 10000000 # Operation A, B: Remove left or right # Operation C, D: Add to left or right S = 0 for take in range(min(N, K) + 1): for takeL in range(take + 1): takeR = take - takeL hand = [] for i in range(takeL): heappush(hand, V[i]) for i in range(takeR): if N - i - 1 < takeL: break heappush(hand, V[N - i - 1]) S = max(sum(hand), S) for _ in range(K - take): if not hand or hand[0] >= 0: break heappop(hand) S = max(sum(hand), S) print(S)
false
0
[ "- for takeR in range(take - takeL + 1):", "- hand = []", "- for i in range(takeL):", "- heappush(hand, V[i])", "- for i in range(takeR):", "- if N - i - 1 < takeL:", "- break", "- heappush(hand, V[N - i - 1])", "+ takeR = take - takeL", "+ hand = []", "+ for i in range(takeL):", "+ heappush(hand, V[i])", "+ for i in range(takeR):", "+ if N - i - 1 < takeL:", "+ break", "+ heappush(hand, V[N - i - 1])", "+ S = max(sum(hand), S)", "+ for _ in range(K - take):", "+ if not hand or hand[0] >= 0:", "+ break", "+ heappop(hand)", "- for _ in range(K - take):", "- if not hand or hand[0] >= 0:", "- break", "- heappop(hand)", "- S = max(sum(hand), S)" ]
false
0.0353
0.035187
1.003222
[ "s203788581", "s182782459" ]
u947883560
p02709
python
s900599245
s079359531
1,962
137
378,396
100,144
Accepted
Accepted
93.02
#!/usr/bin/env python3 import sys INF = float("inf") MOD = 10**9+7 N = int(eval(input())) A = list(map(int, input().split())) AA = [(a, i) for i, a in enumerate(A, start=1)] AA.sort(reverse=True) # print(AA) DP = {} DP[(0, 0)] = 0 for wa in range(1, N+1): # AA[:wa]までを考える a, i = AA[wa-1] for x in range(wa+1): y = wa - x DP[(x, y)] = 0 if x - 1 >= 0: DP[(x, y)] = max(DP[(x, y)], DP[(x-1, y)]+a*(i-x)) if y - 1 >= 0: DP[(x, y)] = max(DP[(x, y)], DP[(x, y-1)]+a*(N-y-i+1)) # print(wa, (x, y), (a, i), DP[x][y]) print((max([DP[(x, N-x)] for x in range(N+1)])))
#!/usr/bin/env python3 import sys import itertools sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9+7 N = int(eval(input())) A = list(map(int, input().split())) AA = [(a, i) for i, a in enumerate(A, start=1)] AA.sort(reverse=True) # print(AA) DP = [[0]*(N+1) for _ in range(N+1)] for wa in range(1, N+1): # AA[:wa]までを考える for x in range(wa+1): y = wa - x a, i = AA[wa-1] if x - 1 >= 0: DP[x][y] = max(DP[x][y], DP[x-1][y]+a*(i-x)) if y - 1 >= 0: DP[x][y] = max(DP[x][y], DP[x][y-1]+a*(N-y-i+1)) # print(wa, (x, y), (a, i), DP[x][y]) M = -INF for x in range(N): y = N-x M = max(DP[x][y], M) print(M)
29
34
661
723
#!/usr/bin/env python3 import sys INF = float("inf") MOD = 10**9 + 7 N = int(eval(input())) A = list(map(int, input().split())) AA = [(a, i) for i, a in enumerate(A, start=1)] AA.sort(reverse=True) # print(AA) DP = {} DP[(0, 0)] = 0 for wa in range(1, N + 1): # AA[:wa]までを考える a, i = AA[wa - 1] for x in range(wa + 1): y = wa - x DP[(x, y)] = 0 if x - 1 >= 0: DP[(x, y)] = max(DP[(x, y)], DP[(x - 1, y)] + a * (i - x)) if y - 1 >= 0: DP[(x, y)] = max(DP[(x, y)], DP[(x, y - 1)] + a * (N - y - i + 1)) # print(wa, (x, y), (a, i), DP[x][y]) print((max([DP[(x, N - x)] for x in range(N + 1)])))
#!/usr/bin/env python3 import sys import itertools sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 N = int(eval(input())) A = list(map(int, input().split())) AA = [(a, i) for i, a in enumerate(A, start=1)] AA.sort(reverse=True) # print(AA) DP = [[0] * (N + 1) for _ in range(N + 1)] for wa in range(1, N + 1): # AA[:wa]までを考える for x in range(wa + 1): y = wa - x a, i = AA[wa - 1] if x - 1 >= 0: DP[x][y] = max(DP[x][y], DP[x - 1][y] + a * (i - x)) if y - 1 >= 0: DP[x][y] = max(DP[x][y], DP[x][y - 1] + a * (N - y - i + 1)) # print(wa, (x, y), (a, i), DP[x][y]) M = -INF for x in range(N): y = N - x M = max(DP[x][y], M) print(M)
false
14.705882
[ "+import itertools", "+sys.setrecursionlimit(10**8)", "-DP = {}", "-DP[(0, 0)] = 0", "+DP = [[0] * (N + 1) for _ in range(N + 1)]", "- a, i = AA[wa - 1]", "- DP[(x, y)] = 0", "+ a, i = AA[wa - 1]", "- DP[(x, y)] = max(DP[(x, y)], DP[(x - 1, y)] + a * (i - x))", "+ DP[x][y] = max(DP[x][y], DP[x - 1][y] + a * (i - x))", "- DP[(x, y)] = max(DP[(x, y)], DP[(x, y - 1)] + a * (N - y - i + 1))", "+ DP[x][y] = max(DP[x][y], DP[x][y - 1] + a * (N - y - i + 1))", "-print((max([DP[(x, N - x)] for x in range(N + 1)])))", "+M = -INF", "+for x in range(N):", "+ y = N - x", "+ M = max(DP[x][y], M)", "+print(M)" ]
false
0.055111
0.033973
1.622198
[ "s900599245", "s079359531" ]
u340781749
p03295
python
s854585960
s248052739
424
363
17,016
11,108
Accepted
Accepted
14.39
n, m = list(map(int, input().split())) disputes = [] for i in range(m): a, b = list(map(int, input().split())) disputes.append((b, a)) disputes.sort() ans = 0 most_right_bridge = 0 for b, a in disputes: if most_right_bridge <= a: ans += 1 most_right_bridge = b print(ans)
from collections import defaultdict n, m = list(map(int, input().split())) disputes = defaultdict(int) for i in range(m): a, b = list(map(int, input().split())) disputes[b] = max(disputes[b], a) ans = 0 most_right_bridge = 0 for b in sorted(disputes.keys()): if most_right_bridge <= disputes[b]: ans += 1 most_right_bridge = b print(ans)
13
14
300
368
n, m = list(map(int, input().split())) disputes = [] for i in range(m): a, b = list(map(int, input().split())) disputes.append((b, a)) disputes.sort() ans = 0 most_right_bridge = 0 for b, a in disputes: if most_right_bridge <= a: ans += 1 most_right_bridge = b print(ans)
from collections import defaultdict n, m = list(map(int, input().split())) disputes = defaultdict(int) for i in range(m): a, b = list(map(int, input().split())) disputes[b] = max(disputes[b], a) ans = 0 most_right_bridge = 0 for b in sorted(disputes.keys()): if most_right_bridge <= disputes[b]: ans += 1 most_right_bridge = b print(ans)
false
7.142857
[ "+from collections import defaultdict", "+", "-disputes = []", "+disputes = defaultdict(int)", "- disputes.append((b, a))", "-disputes.sort()", "+ disputes[b] = max(disputes[b], a)", "-for b, a in disputes:", "- if most_right_bridge <= a:", "+for b in sorted(disputes.keys()):", "+ if most_right_bridge <= disputes[b]:" ]
false
0.046002
0.099295
0.463283
[ "s854585960", "s248052739" ]
u165318982
p02658
python
s928698238
s434405461
97
61
21,636
21,628
Accepted
Accepted
37.11
N = int(eval(input())) A = list(map(int, input().split())) A.sort() ans = 1 max_limit = 10 ** 18 for i in range(N): ans *= A[i] if ans > max_limit: ans = -1 break if ans > max_limit: print((str(-1))) else: print((str(ans)))
N = int(eval(input())) A = list(map(int, input().split())) if 0 in A: ans = 0 else: ans = 1 max_limit = 10 ** 18 for i in range(N): if ans * A[i] > max_limit: ans = -1 break else: ans *= A[i] print((str(ans)))
15
16
244
252
N = int(eval(input())) A = list(map(int, input().split())) A.sort() ans = 1 max_limit = 10**18 for i in range(N): ans *= A[i] if ans > max_limit: ans = -1 break if ans > max_limit: print((str(-1))) else: print((str(ans)))
N = int(eval(input())) A = list(map(int, input().split())) if 0 in A: ans = 0 else: ans = 1 max_limit = 10**18 for i in range(N): if ans * A[i] > max_limit: ans = -1 break else: ans *= A[i] print((str(ans)))
false
6.25
[ "-A.sort()", "-ans = 1", "-max_limit = 10**18", "-for i in range(N):", "- ans *= A[i]", "- if ans > max_limit:", "- ans = -1", "- break", "-if ans > max_limit:", "- print((str(-1)))", "+if 0 in A:", "+ ans = 0", "- print((str(ans)))", "+ ans = 1", "+ max_limit = 10**18", "+ for i in range(N):", "+ if ans * A[i] > max_limit:", "+ ans = -1", "+ break", "+ else:", "+ ans *= A[i]", "+print((str(ans)))" ]
false
0.033696
0.041506
0.81184
[ "s928698238", "s434405461" ]
u371763408
p04001
python
s317632487
s502572130
26
20
3,060
3,060
Accepted
Accepted
23.08
import itertools s = eval(input()) n = len(s) ans=0 for op in itertools.product(["+",""],repeat=n-1): tmp="" for i in range(n-1): tmp+=s[i]+op[i] ans+=eval(tmp+s[-1]) print(ans)
s = eval(input()) n = len(s)-1 ans=0 for i in range(1 << n): k=0 # print(bin(i)) for j in range(n): # print("","j=",j,bin(i>>j),True if (i>>j)&1 else False,s[k:j+1]) if i>>j&1 == 0: continue else: ans += int(s[k:j+1]) k=j+1 ans += int(s[k:]) print(ans)
10
15
190
298
import itertools s = eval(input()) n = len(s) ans = 0 for op in itertools.product(["+", ""], repeat=n - 1): tmp = "" for i in range(n - 1): tmp += s[i] + op[i] ans += eval(tmp + s[-1]) print(ans)
s = eval(input()) n = len(s) - 1 ans = 0 for i in range(1 << n): k = 0 # print(bin(i)) for j in range(n): # print("","j=",j,bin(i>>j),True if (i>>j)&1 else False,s[k:j+1]) if i >> j & 1 == 0: continue else: ans += int(s[k : j + 1]) k = j + 1 ans += int(s[k:]) print(ans)
false
33.333333
[ "-import itertools", "-", "-n = len(s)", "+n = len(s) - 1", "-for op in itertools.product([\"+\", \"\"], repeat=n - 1):", "- tmp = \"\"", "- for i in range(n - 1):", "- tmp += s[i] + op[i]", "- ans += eval(tmp + s[-1])", "+for i in range(1 << n):", "+ k = 0", "+ # print(bin(i))", "+ for j in range(n):", "+ # print(\"\",\"j=\",j,bin(i>>j),True if (i>>j)&1 else False,s[k:j+1])", "+ if i >> j & 1 == 0:", "+ continue", "+ else:", "+ ans += int(s[k : j + 1])", "+ k = j + 1", "+ ans += int(s[k:])" ]
false
0.039636
0.043068
0.920296
[ "s317632487", "s502572130" ]
u157379742
p03069
python
s840455502
s642458718
178
157
11,240
11,524
Accepted
Accepted
11.8
from heapq import heappush,heappop def int_raw(): return int(eval(input())) def ss_raw(): return input().split() def ints_raw(): return list(map(int, ss_raw())) INF = 1 << 29 def runLength(in_str): kukan = 1 start = 0 ret = [] for i in range(1,len(in_str)): if in_str[i-1]!=in_str[i]: ret.append([in_str[i-1],kukan,start]) start = i kukan=0 kukan+=1 ret.append([in_str[-1],kukan,start]) return ret N = int_raw() S= eval(input()) dp = {} def rec(ss): return 0 def main(): global S ans = INF numB = [0]*len(S) for i in range(len(S)): if i > 0: numB[i]=numB[i-1] if S[i]=="#": numB[i]+=1 if numB[len(S)-1]==0 or numB[len(S)-1]==len(S): return 0 for i in range(len(S)): buf = numB[i]+len(S)-1-i-(numB[len(S)-1]-numB[i]) ans = min(ans, buf) ans = min(ans, len(S)-numB[len(S)-1]) ans = min(ans, numB[len(S)-1]) return ans print((main()))
from heapq import heappush,heappop import re def int_raw(): return int(eval(input())) def ss_raw(): return input().split() def ints_raw(): return list(map(int, ss_raw())) INF = 1 << 29 def runLength(in_str): kukan = 1 start = 0 ret = [] for i in range(1,len(in_str)): if in_str[i-1]!=in_str[i]: ret.append([in_str[i-1],kukan,start]) start = i kukan=0 kukan+=1 ret.append([in_str[-1],kukan,start]) return ret N = int_raw() S= eval(input()) def main(): ans = INF numB = [0] for c in S: numB.append(numB[-1]) if c=="#": numB[-1]+=1 for i in range(len(S)+1): ans = min(ans, numB[i]+ len(S)-i-(numB[-1]-numB[i])) return ans print((main()))
58
43
1,094
817
from heapq import heappush, heappop def int_raw(): return int(eval(input())) def ss_raw(): return input().split() def ints_raw(): return list(map(int, ss_raw())) INF = 1 << 29 def runLength(in_str): kukan = 1 start = 0 ret = [] for i in range(1, len(in_str)): if in_str[i - 1] != in_str[i]: ret.append([in_str[i - 1], kukan, start]) start = i kukan = 0 kukan += 1 ret.append([in_str[-1], kukan, start]) return ret N = int_raw() S = eval(input()) dp = {} def rec(ss): return 0 def main(): global S ans = INF numB = [0] * len(S) for i in range(len(S)): if i > 0: numB[i] = numB[i - 1] if S[i] == "#": numB[i] += 1 if numB[len(S) - 1] == 0 or numB[len(S) - 1] == len(S): return 0 for i in range(len(S)): buf = numB[i] + len(S) - 1 - i - (numB[len(S) - 1] - numB[i]) ans = min(ans, buf) ans = min(ans, len(S) - numB[len(S) - 1]) ans = min(ans, numB[len(S) - 1]) return ans print((main()))
from heapq import heappush, heappop import re def int_raw(): return int(eval(input())) def ss_raw(): return input().split() def ints_raw(): return list(map(int, ss_raw())) INF = 1 << 29 def runLength(in_str): kukan = 1 start = 0 ret = [] for i in range(1, len(in_str)): if in_str[i - 1] != in_str[i]: ret.append([in_str[i - 1], kukan, start]) start = i kukan = 0 kukan += 1 ret.append([in_str[-1], kukan, start]) return ret N = int_raw() S = eval(input()) def main(): ans = INF numB = [0] for c in S: numB.append(numB[-1]) if c == "#": numB[-1] += 1 for i in range(len(S) + 1): ans = min(ans, numB[i] + len(S) - i - (numB[-1] - numB[i])) return ans print((main()))
false
25.862069
[ "+import re", "-dp = {}", "-", "-", "-def rec(ss):", "- return 0", "- global S", "- numB = [0] * len(S)", "- for i in range(len(S)):", "- if i > 0:", "- numB[i] = numB[i - 1]", "- if S[i] == \"#\":", "- numB[i] += 1", "- if numB[len(S) - 1] == 0 or numB[len(S) - 1] == len(S):", "- return 0", "- for i in range(len(S)):", "- buf = numB[i] + len(S) - 1 - i - (numB[len(S) - 1] - numB[i])", "- ans = min(ans, buf)", "- ans = min(ans, len(S) - numB[len(S) - 1])", "- ans = min(ans, numB[len(S) - 1])", "+ numB = [0]", "+ for c in S:", "+ numB.append(numB[-1])", "+ if c == \"#\":", "+ numB[-1] += 1", "+ for i in range(len(S) + 1):", "+ ans = min(ans, numB[i] + len(S) - i - (numB[-1] - numB[i]))" ]
false
0.038535
0.04202
0.917069
[ "s840455502", "s642458718" ]
u266014018
p02689
python
s268655515
s452283184
630
357
44,640
19,940
Accepted
Accepted
43.33
import numpy as np N,M = list(map(int,input().split())) H = np.array(list(map(int,input().split()))) adj = [[] for _ in range(N)] for _ in range(M): a,b = [int(x) -1 for x in input().split()] if a in adj[b]: continue adj[a].append(b) adj[b].append(a) ans = 0 for i, item in enumerate(adj): if item == []: ans+=1 continue adj_max = max(H[item]) if H[i] > adj_max: ans += 1 print(ans)
n,m = list(map(int,input().split())) h = list(map(int,input().split())) ma = [0]*(n) for i in range(m): a,b = [int(x)-1 for x in input().split()] ma[a] = max(ma[a], h[b]) ma[b] = max(h[a], ma[b]) ans = 0 for i in range(n): if h[i]>ma[i]: ans+=1 print(ans)
22
12
472
277
import numpy as np N, M = list(map(int, input().split())) H = np.array(list(map(int, input().split()))) adj = [[] for _ in range(N)] for _ in range(M): a, b = [int(x) - 1 for x in input().split()] if a in adj[b]: continue adj[a].append(b) adj[b].append(a) ans = 0 for i, item in enumerate(adj): if item == []: ans += 1 continue adj_max = max(H[item]) if H[i] > adj_max: ans += 1 print(ans)
n, m = list(map(int, input().split())) h = list(map(int, input().split())) ma = [0] * (n) for i in range(m): a, b = [int(x) - 1 for x in input().split()] ma[a] = max(ma[a], h[b]) ma[b] = max(h[a], ma[b]) ans = 0 for i in range(n): if h[i] > ma[i]: ans += 1 print(ans)
false
45.454545
[ "-import numpy as np", "-", "-N, M = list(map(int, input().split()))", "-H = np.array(list(map(int, input().split())))", "-adj = [[] for _ in range(N)]", "-for _ in range(M):", "+n, m = list(map(int, input().split()))", "+h = list(map(int, input().split()))", "+ma = [0] * (n)", "+for i in range(m):", "- if a in adj[b]:", "- continue", "- adj[a].append(b)", "- adj[b].append(a)", "+ ma[a] = max(ma[a], h[b])", "+ ma[b] = max(h[a], ma[b])", "-for i, item in enumerate(adj):", "- if item == []:", "- ans += 1", "- continue", "- adj_max = max(H[item])", "- if H[i] > adj_max:", "+for i in range(n):", "+ if h[i] > ma[i]:" ]
false
0.280388
0.046297
6.056267
[ "s268655515", "s452283184" ]
u170201762
p02821
python
s150527023
s440954647
1,236
466
56,120
43,308
Accepted
Accepted
62.3
from bisect import bisect_left as bisect N,M = list(map(int,input().split())) A = list(map(int,input().split())) A.sort() def combination(X): res = 0 for i in range(N): j = bisect(A,X-A[i]) res += N-j return res l = 0 r = 2*10**5+1 m = (l+r)//2 for i in range(20): c = combination(m) if c < M: r = m else: l = m m = (l+r)//2 if combination(m) >= M: m += 1 S = [0]*(N+1) for i in range(N): S[i]=S[i-1]+A[i] ans = 0 for i in range(N): j = bisect(A,m-A[i]) ans += A[i]*(N-j) ans += S[N-1]-S[j-1] ans += (M-combination(m))*(m-1) print(ans)
import numpy as np from numpy.fft import rfft,irfft N,M = list(map(int,input().split())) A = list(map(int,input().split())) a = np.zeros(10**5+1) for i in range(N): a[A[i]] += 1 b = rfft(a,2*10**5+1) b = irfft(b*b,2*10**5+1) b = np.rint(b).astype(np.int64) c = 0 ans = 0 for n in range(2*10**5,1,-1): if c+b[n]<M: c += b[n] ans += b[n]*n else: ans += (M-c)*n c = M break print(ans)
35
21
651
447
from bisect import bisect_left as bisect N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() def combination(X): res = 0 for i in range(N): j = bisect(A, X - A[i]) res += N - j return res l = 0 r = 2 * 10**5 + 1 m = (l + r) // 2 for i in range(20): c = combination(m) if c < M: r = m else: l = m m = (l + r) // 2 if combination(m) >= M: m += 1 S = [0] * (N + 1) for i in range(N): S[i] = S[i - 1] + A[i] ans = 0 for i in range(N): j = bisect(A, m - A[i]) ans += A[i] * (N - j) ans += S[N - 1] - S[j - 1] ans += (M - combination(m)) * (m - 1) print(ans)
import numpy as np from numpy.fft import rfft, irfft N, M = list(map(int, input().split())) A = list(map(int, input().split())) a = np.zeros(10**5 + 1) for i in range(N): a[A[i]] += 1 b = rfft(a, 2 * 10**5 + 1) b = irfft(b * b, 2 * 10**5 + 1) b = np.rint(b).astype(np.int64) c = 0 ans = 0 for n in range(2 * 10**5, 1, -1): if c + b[n] < M: c += b[n] ans += b[n] * n else: ans += (M - c) * n c = M break print(ans)
false
40
[ "-from bisect import bisect_left as bisect", "+import numpy as np", "+from numpy.fft import rfft, irfft", "-A.sort()", "-", "-", "-def combination(X):", "- res = 0", "- for i in range(N):", "- j = bisect(A, X - A[i])", "- res += N - j", "- return res", "-", "-", "-l = 0", "-r = 2 * 10**5 + 1", "-m = (l + r) // 2", "-for i in range(20):", "- c = combination(m)", "- if c < M:", "- r = m", "+a = np.zeros(10**5 + 1)", "+for i in range(N):", "+ a[A[i]] += 1", "+b = rfft(a, 2 * 10**5 + 1)", "+b = irfft(b * b, 2 * 10**5 + 1)", "+b = np.rint(b).astype(np.int64)", "+c = 0", "+ans = 0", "+for n in range(2 * 10**5, 1, -1):", "+ if c + b[n] < M:", "+ c += b[n]", "+ ans += b[n] * n", "- l = m", "- m = (l + r) // 2", "-if combination(m) >= M:", "- m += 1", "-S = [0] * (N + 1)", "-for i in range(N):", "- S[i] = S[i - 1] + A[i]", "-ans = 0", "-for i in range(N):", "- j = bisect(A, m - A[i])", "- ans += A[i] * (N - j)", "- ans += S[N - 1] - S[j - 1]", "-ans += (M - combination(m)) * (m - 1)", "+ ans += (M - c) * n", "+ c = M", "+ break" ]
false
0.095097
0.458379
0.207464
[ "s150527023", "s440954647" ]
u178249601
p03103
python
s430673807
s986338051
508
402
21,984
22,004
Accepted
Accepted
20.87
List = [] N, M = (int(x) for x in input().split()) for i in range(N): a, b = (int(x) for x in input().split()) List.append([a, b]) num_of_drink, total_fee = 0, 0 List = sorted(List, key=lambda x:x[0]) temp_M = M list_of_num = [] for i in range(N): if temp_M <= List[i][1]: list_of_num.append(temp_M) break else: list_of_num.append(List[i][1]) temp_M += -List[i][1] index = 0 for x in list_of_num: total_fee += List[index][0] * x index += 1 print(total_fee)
import sys input = sys.stdin.readline List = [] N, M = (int(x) for x in input().split()) for i in range(N): a, b = (int(x) for x in input().split()) List.append([a, b]) num_of_drink, total_fee = 0, 0 List = sorted(List, key=lambda x:x[0]) temp_M = M list_of_num = [] for i in range(N): if temp_M <= List[i][1]: list_of_num.append(temp_M) break else: list_of_num.append(List[i][1]) temp_M += -List[i][1] index = 0 for x in list_of_num: total_fee += List[index][0] * x index += 1 print(total_fee)
23
25
536
576
List = [] N, M = (int(x) for x in input().split()) for i in range(N): a, b = (int(x) for x in input().split()) List.append([a, b]) num_of_drink, total_fee = 0, 0 List = sorted(List, key=lambda x: x[0]) temp_M = M list_of_num = [] for i in range(N): if temp_M <= List[i][1]: list_of_num.append(temp_M) break else: list_of_num.append(List[i][1]) temp_M += -List[i][1] index = 0 for x in list_of_num: total_fee += List[index][0] * x index += 1 print(total_fee)
import sys input = sys.stdin.readline List = [] N, M = (int(x) for x in input().split()) for i in range(N): a, b = (int(x) for x in input().split()) List.append([a, b]) num_of_drink, total_fee = 0, 0 List = sorted(List, key=lambda x: x[0]) temp_M = M list_of_num = [] for i in range(N): if temp_M <= List[i][1]: list_of_num.append(temp_M) break else: list_of_num.append(List[i][1]) temp_M += -List[i][1] index = 0 for x in list_of_num: total_fee += List[index][0] * x index += 1 print(total_fee)
false
8
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.037473
0.036251
1.033707
[ "s430673807", "s986338051" ]
u516272298
p03610
python
s450174320
s494038118
27
17
3,572
3,188
Accepted
Accepted
37.04
s = str(eval(input())) l = [] for i in range(0,len(s),2): l.append(s[i]) print(("".join(l)))
s = str(eval(input())) print((s[0::2]))
5
2
92
32
s = str(eval(input())) l = [] for i in range(0, len(s), 2): l.append(s[i]) print(("".join(l)))
s = str(eval(input())) print((s[0::2]))
false
60
[ "-l = []", "-for i in range(0, len(s), 2):", "- l.append(s[i])", "-print((\"\".join(l)))", "+print((s[0::2]))" ]
false
0.03818
0.038126
1.001425
[ "s450174320", "s494038118" ]
u606045429
p02861
python
s747361448
s091474483
230
17
43,320
3,060
Accepted
Accepted
92.61
from math import hypot, factorial from itertools import permutations N, *XY = list(map(int, open(0).read().split())) XY = list(zip(*[iter(XY)] * 2)) ans = 0 for p in permutations(XY): ans += sum(hypot(ax - bx, ay - by) for (ax, ay), (bx, by) in zip(p, p[1:])) print(("{:.9f}".format(ans / factorial(N))))
from itertools import combinations from math import hypot N, *XY = list(map(int, open(0).read().split())) print(("{:.9f}".format(sum(hypot(ax - bx, ay - by) for (ax, ay), (bx, by) in combinations(list(zip(*[iter(XY)] * 2)), 2)) * 2 / N)))
11
6
314
231
from math import hypot, factorial from itertools import permutations N, *XY = list(map(int, open(0).read().split())) XY = list(zip(*[iter(XY)] * 2)) ans = 0 for p in permutations(XY): ans += sum(hypot(ax - bx, ay - by) for (ax, ay), (bx, by) in zip(p, p[1:])) print(("{:.9f}".format(ans / factorial(N))))
from itertools import combinations from math import hypot N, *XY = list(map(int, open(0).read().split())) print( ( "{:.9f}".format( sum( hypot(ax - bx, ay - by) for (ax, ay), (bx, by) in combinations(list(zip(*[iter(XY)] * 2)), 2) ) * 2 / N ) ) )
false
45.454545
[ "-from math import hypot, factorial", "-from itertools import permutations", "+from itertools import combinations", "+from math import hypot", "-XY = list(zip(*[iter(XY)] * 2))", "-ans = 0", "-for p in permutations(XY):", "- ans += sum(hypot(ax - bx, ay - by) for (ax, ay), (bx, by) in zip(p, p[1:]))", "-print((\"{:.9f}\".format(ans / factorial(N))))", "+print(", "+ (", "+ \"{:.9f}\".format(", "+ sum(", "+ hypot(ax - bx, ay - by)", "+ for (ax, ay), (bx, by) in combinations(list(zip(*[iter(XY)] * 2)), 2)", "+ )", "+ * 2", "+ / N", "+ )", "+ )", "+)" ]
false
0.074365
0.05187
1.433669
[ "s747361448", "s091474483" ]
u565380863
p03470
python
s370458839
s054254120
154
23
12,464
3,316
Accepted
Accepted
85.06
import sys import numpy as np input = sys.stdin.readline def ii(t: type = int): return t(eval(input())) def il(t: type = int): return list(map(t, input().split())) def iml(N: int, t: type = int): return [t(eval(input())) for _ in range(N)] N = ii() D = iml(N) print((np.unique(D).size))
import sys input = sys.stdin.readline def ii(t: type = int): return t(eval(input())) def il(t: type = int): return list(map(t, input().split())) def iml(N: int, t: type = int): return [t(eval(input())) for _ in range(N)] N = ii() D = iml(N) print((len(set(D))))
23
21
318
289
import sys import numpy as np input = sys.stdin.readline def ii(t: type = int): return t(eval(input())) def il(t: type = int): return list(map(t, input().split())) def iml(N: int, t: type = int): return [t(eval(input())) for _ in range(N)] N = ii() D = iml(N) print((np.unique(D).size))
import sys input = sys.stdin.readline def ii(t: type = int): return t(eval(input())) def il(t: type = int): return list(map(t, input().split())) def iml(N: int, t: type = int): return [t(eval(input())) for _ in range(N)] N = ii() D = iml(N) print((len(set(D))))
false
8.695652
[ "-import numpy as np", "-print((np.unique(D).size))", "+print((len(set(D))))" ]
false
0.191941
0.037001
5.187511
[ "s370458839", "s054254120" ]
u186838327
p02936
python
s840795732
s544715758
1,958
629
106,956
89,164
Accepted
Accepted
67.88
n, q = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(n-1): a, b = list(map(int, input().split())) a, b = a-1, b-1 g[a].append(b) g[b].append(a) X = [0]*n for i in range(q): p, x = list(map(int, input().split())) p -= 1 X[p] += x s = [] visit = [-1]*n s.append(0) visit[0] = 0 while s: v = s.pop() for u in g[v]: if visit[u] == -1: X[u] += X[v] s.append(u) visit[u] = 0 print((*X))
import sys input = sys.stdin.buffer.readline n, q = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(n-1): a,b = list(map(int, input().split())) a, b = a-1, b-1 g[a].append(b) g[b].append(a) X = [0]*n for i in range(q): p, x = list(map(int, input().split())) p = p-1 X[p] += x s = [] visited = [-1]*n s.append(0) visited[0] = 0 while s: v = s.pop() for u in g[v]: if visited[u] == -1: X[u] += X[v] visited[u] = 0 s.append(u) print((*X))
26
29
496
553
n, q = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(n - 1): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 g[a].append(b) g[b].append(a) X = [0] * n for i in range(q): p, x = list(map(int, input().split())) p -= 1 X[p] += x s = [] visit = [-1] * n s.append(0) visit[0] = 0 while s: v = s.pop() for u in g[v]: if visit[u] == -1: X[u] += X[v] s.append(u) visit[u] = 0 print((*X))
import sys input = sys.stdin.buffer.readline n, q = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(n - 1): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 g[a].append(b) g[b].append(a) X = [0] * n for i in range(q): p, x = list(map(int, input().split())) p = p - 1 X[p] += x s = [] visited = [-1] * n s.append(0) visited[0] = 0 while s: v = s.pop() for u in g[v]: if visited[u] == -1: X[u] += X[v] visited[u] = 0 s.append(u) print((*X))
false
10.344828
[ "+import sys", "+", "+input = sys.stdin.buffer.readline", "- p -= 1", "+ p = p - 1", "-visit = [-1] * n", "+visited = [-1] * n", "-visit[0] = 0", "+visited[0] = 0", "- if visit[u] == -1:", "+ if visited[u] == -1:", "+ visited[u] = 0", "- visit[u] = 0" ]
false
0.043177
0.036481
1.183539
[ "s840795732", "s544715758" ]
u970197315
p03241
python
s566933236
s382019705
23
20
3,316
3,064
Accepted
Accepted
13.04
# AGC112 D - Partition from math import floor def divisor(n): i = 1 table = [] while i * i <= n: if n%i == 0: table.append(i) table.append(n//i) i += 1 table = list(set(table)) return table n,m=list(map(int,input().split())) n_max=floor(m/n) div_m=divisor(m) div_m.sort(reverse=True) ans=0 for i in div_m: if i<=n_max: print(i) exit()
def create_divisors(n): divisors=[] for i in range(1,int(n**0.5)+1): if n%i==0: divisors.append(i) if i!=n//i: divisors.append(n//i) divisors.sort(reverse=True) return divisors from math import floor n,m=list(map(int,input().split())) n_max=floor(m/n) d=create_divisors(m) for di in d: if di<=n_max: print(di) exit(0)
24
18
436
371
# AGC112 D - Partition from math import floor def divisor(n): i = 1 table = [] while i * i <= n: if n % i == 0: table.append(i) table.append(n // i) i += 1 table = list(set(table)) return table n, m = list(map(int, input().split())) n_max = floor(m / n) div_m = divisor(m) div_m.sort(reverse=True) ans = 0 for i in div_m: if i <= n_max: print(i) exit()
def create_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) divisors.sort(reverse=True) return divisors from math import floor n, m = list(map(int, input().split())) n_max = floor(m / n) d = create_divisors(m) for di in d: if di <= n_max: print(di) exit(0)
false
25
[ "-# AGC112 D - Partition", "-from math import floor", "+def create_divisors(n):", "+ divisors = []", "+ for i in range(1, int(n**0.5) + 1):", "+ if n % i == 0:", "+ divisors.append(i)", "+ if i != n // i:", "+ divisors.append(n // i)", "+ divisors.sort(reverse=True)", "+ return divisors", "-def divisor(n):", "- i = 1", "- table = []", "- while i * i <= n:", "- if n % i == 0:", "- table.append(i)", "- table.append(n // i)", "- i += 1", "- table = list(set(table))", "- return table", "-", "+from math import floor", "-div_m = divisor(m)", "-div_m.sort(reverse=True)", "-ans = 0", "-for i in div_m:", "- if i <= n_max:", "- print(i)", "- exit()", "+d = create_divisors(m)", "+for di in d:", "+ if di <= n_max:", "+ print(di)", "+ exit(0)" ]
false
0.042292
0.041244
1.025408
[ "s566933236", "s382019705" ]
u411203878
p02573
python
s687892357
s829978675
363
315
113,264
116,284
Accepted
Accepted
13.22
import collections import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) class UnionFindPathCompression(): def __init__(self, n): self.parents = list(range(n)) self.rank = [1]*n self.size = [1]*n def find(self, x): if self.parents[x] == x: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): px = self.find(x) py = self.find(y) if px == py: return else: if self.rank[px] < self.rank[py]: self.parents[px] = py self.size[py] += self.size[px] else: self.parents[py] = px self.size[px] += self.size[py] #ランクの更新 if self.rank[px] == self.rank[py]: self.rank[px] += 1 N,M = list(map(int,input().split())) ufpc = UnionFindPathCompression(N) AB = [list(map(int, input().split())) for _ in range(M)] for a,b in AB: a,b = a-1,b-1 ufpc.union(a,b) for i in range(N): ufpc.find(i) c = collections.Counter(ufpc.parents) score_sorted = sorted(list(c.items()), key=lambda x:-x[1]) print((score_sorted[0][1]))
import collections import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) class UnionFindPathCompression(): def __init__(self, n): self.parents = list(range(n)) self.rank = [1]*n self.size = [1]*n def find(self, x): if self.parents[x] == x: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): px = self.find(x) py = self.find(y) if px == py: return else: if self.rank[px] < self.rank[py]: self.parents[px] = py self.size[py] += self.size[px] else: self.parents[py] = px self.size[px] += self.size[py] #ランクの更新 if self.rank[px] == self.rank[py]: self.rank[px] += 1 n,m = list(map(int,input().split())) ufpc = UnionFindPathCompression(n) for _ in range(m): a,b = list(map(int,input().split())) a,b=a-1,b-1 ufpc.union(a,b) for i in range(n): ufpc.find(i) c = collections.Counter(ufpc.parents) score_sorted = sorted(list(c.items()), key=lambda x:-x[1]) print((score_sorted[0][1]))
51
50
1,307
1,278
import collections import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) class UnionFindPathCompression: def __init__(self, n): self.parents = list(range(n)) self.rank = [1] * n self.size = [1] * n def find(self, x): if self.parents[x] == x: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): px = self.find(x) py = self.find(y) if px == py: return else: if self.rank[px] < self.rank[py]: self.parents[px] = py self.size[py] += self.size[px] else: self.parents[py] = px self.size[px] += self.size[py] # ランクの更新 if self.rank[px] == self.rank[py]: self.rank[px] += 1 N, M = list(map(int, input().split())) ufpc = UnionFindPathCompression(N) AB = [list(map(int, input().split())) for _ in range(M)] for a, b in AB: a, b = a - 1, b - 1 ufpc.union(a, b) for i in range(N): ufpc.find(i) c = collections.Counter(ufpc.parents) score_sorted = sorted(list(c.items()), key=lambda x: -x[1]) print((score_sorted[0][1]))
import collections import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) class UnionFindPathCompression: def __init__(self, n): self.parents = list(range(n)) self.rank = [1] * n self.size = [1] * n def find(self, x): if self.parents[x] == x: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): px = self.find(x) py = self.find(y) if px == py: return else: if self.rank[px] < self.rank[py]: self.parents[px] = py self.size[py] += self.size[px] else: self.parents[py] = px self.size[px] += self.size[py] # ランクの更新 if self.rank[px] == self.rank[py]: self.rank[px] += 1 n, m = list(map(int, input().split())) ufpc = UnionFindPathCompression(n) for _ in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 ufpc.union(a, b) for i in range(n): ufpc.find(i) c = collections.Counter(ufpc.parents) score_sorted = sorted(list(c.items()), key=lambda x: -x[1]) print((score_sorted[0][1]))
false
1.960784
[ "-N, M = list(map(int, input().split()))", "-ufpc = UnionFindPathCompression(N)", "-AB = [list(map(int, input().split())) for _ in range(M)]", "-for a, b in AB:", "+n, m = list(map(int, input().split()))", "+ufpc = UnionFindPathCompression(n)", "+for _ in range(m):", "+ a, b = list(map(int, input().split()))", "-for i in range(N):", "+for i in range(n):" ]
false
0.035251
0.035943
0.980733
[ "s687892357", "s829978675" ]
u129019798
p02601
python
s016070833
s478592370
34
27
9,164
9,172
Accepted
Accepted
20.59
def main(): import sys A,B,C=list(map(int,sys.stdin.readline().split())) K=int(sys.stdin.readline()) for i in range(K+1): if B<=A: B*=2 elif C<=B: C*=2 else: print('Yes') return print('No') main()
A,B,C = list(map(int,input().split())) K = int(eval(input())) i = 0 while True: if B > A: break else: B = B * 2 i += 1 q = 0 while True: if C > B: break else: C = C * 2 q += 1 if (i + q) > K: print("No") else: print("Yes")
16
20
305
295
def main(): import sys A, B, C = list(map(int, sys.stdin.readline().split())) K = int(sys.stdin.readline()) for i in range(K + 1): if B <= A: B *= 2 elif C <= B: C *= 2 else: print("Yes") return print("No") main()
A, B, C = list(map(int, input().split())) K = int(eval(input())) i = 0 while True: if B > A: break else: B = B * 2 i += 1 q = 0 while True: if C > B: break else: C = C * 2 q += 1 if (i + q) > K: print("No") else: print("Yes")
false
20
[ "-def main():", "- import sys", "-", "- A, B, C = list(map(int, sys.stdin.readline().split()))", "- K = int(sys.stdin.readline())", "- for i in range(K + 1):", "- if B <= A:", "- B *= 2", "- elif C <= B:", "- C *= 2", "- else:", "- print(\"Yes\")", "- return", "+A, B, C = list(map(int, input().split()))", "+K = int(eval(input()))", "+i = 0", "+while True:", "+ if B > A:", "+ break", "+ else:", "+ B = B * 2", "+ i += 1", "+q = 0", "+while True:", "+ if C > B:", "+ break", "+ else:", "+ C = C * 2", "+ q += 1", "+if (i + q) > K:", "-", "-", "-main()", "+else:", "+ print(\"Yes\")" ]
false
0.06772
0.04773
1.418826
[ "s016070833", "s478592370" ]
u046592970
p03495
python
s531775637
s851450282
215
187
37,784
37,776
Accepted
Accepted
13.02
from collections import Counter n,k = list(map(int,input().split())) dic = Counter(list(map(int,input().split()))) x = len(dic) - k lis = sorted(list(dic.items()), key = lambda z:z[1]) ans = 0 for i in range(x): ans += lis[i][1] print(ans)
from collections import Counter from operator import itemgetter n,k = list(map(int,input().split())) dic = Counter(list(map(int,input().split()))) x = len(dic) - k lis = sorted(list(dic.items()), key = itemgetter(1)) ans = 0 for i in range(x): ans += lis[i][1] print(ans)
9
10
239
272
from collections import Counter n, k = list(map(int, input().split())) dic = Counter(list(map(int, input().split()))) x = len(dic) - k lis = sorted(list(dic.items()), key=lambda z: z[1]) ans = 0 for i in range(x): ans += lis[i][1] print(ans)
from collections import Counter from operator import itemgetter n, k = list(map(int, input().split())) dic = Counter(list(map(int, input().split()))) x = len(dic) - k lis = sorted(list(dic.items()), key=itemgetter(1)) ans = 0 for i in range(x): ans += lis[i][1] print(ans)
false
10
[ "+from operator import itemgetter", "-lis = sorted(list(dic.items()), key=lambda z: z[1])", "+lis = sorted(list(dic.items()), key=itemgetter(1))" ]
false
0.111012
0.042627
2.604267
[ "s531775637", "s851450282" ]
u596877563
p02711
python
s927836413
s453559013
21
19
9,112
9,176
Accepted
Accepted
9.52
s = int(eval(input()))#入力した数値 t = int(s % 10)#10で割ったあまり=n桁目の数 u = int(s / 10)#10で割ったもの while True: if t == 7: print("Yes") break elif u == 0: print("No") break t = int(u % 10) u = int(u / 10)
s = int(eval(input())) if s%10 == 7: print("Yes") elif int(s/10)%10 == 7: print("Yes") elif int(int(s/10)/10)%10 == 7: print("Yes") else: print("No")
12
9
245
167
s = int(eval(input())) # 入力した数値 t = int(s % 10) # 10で割ったあまり=n桁目の数 u = int(s / 10) # 10で割ったもの while True: if t == 7: print("Yes") break elif u == 0: print("No") break t = int(u % 10) u = int(u / 10)
s = int(eval(input())) if s % 10 == 7: print("Yes") elif int(s / 10) % 10 == 7: print("Yes") elif int(int(s / 10) / 10) % 10 == 7: print("Yes") else: print("No")
false
25
[ "-s = int(eval(input())) # 入力した数値", "-t = int(s % 10) # 10で割ったあまり=n桁目の数", "-u = int(s / 10) # 10で割ったもの", "-while True:", "- if t == 7:", "- print(\"Yes\")", "- break", "- elif u == 0:", "- print(\"No\")", "- break", "- t = int(u % 10)", "- u = int(u / 10)", "+s = int(eval(input()))", "+if s % 10 == 7:", "+ print(\"Yes\")", "+elif int(s / 10) % 10 == 7:", "+ print(\"Yes\")", "+elif int(int(s / 10) / 10) % 10 == 7:", "+ print(\"Yes\")", "+else:", "+ print(\"No\")" ]
false
0.037047
0.111723
0.331593
[ "s927836413", "s453559013" ]
u869790980
p03137
python
s672269059
s380158876
468
388
88,244
89,856
Accepted
Accepted
17.09
import heapq n,m = list(map(int, input().split(' '))) # I am given n pieces if n >= m: print(0) else: xis = list(map(int, input().split())) xis.sort() distances = [v- u for u,v in zip(xis,xis[1:])] distances.sort(key = lambda x:-x) print(sum(distances[n-1:] or [0]))
import heapq n,m = list(map(int, input().split(' '))) xis = list(map(int, input().split())) xis.sort() distances = [v- u for u,v in zip(xis,xis[1:])] distances.sort(key = lambda x:-x) print(sum(distances[n-1:] or [0]))
14
8
282
221
import heapq n, m = list(map(int, input().split(" "))) # I am given n pieces if n >= m: print(0) else: xis = list(map(int, input().split())) xis.sort() distances = [v - u for u, v in zip(xis, xis[1:])] distances.sort(key=lambda x: -x) print(sum(distances[n - 1 :] or [0]))
import heapq n, m = list(map(int, input().split(" "))) xis = list(map(int, input().split())) xis.sort() distances = [v - u for u, v in zip(xis, xis[1:])] distances.sort(key=lambda x: -x) print(sum(distances[n - 1 :] or [0]))
false
42.857143
[ "-# I am given n pieces", "-if n >= m:", "- print(0)", "-else:", "- xis = list(map(int, input().split()))", "- xis.sort()", "- distances = [v - u for u, v in zip(xis, xis[1:])]", "- distances.sort(key=lambda x: -x)", "- print(sum(distances[n - 1 :] or [0]))", "+xis = list(map(int, input().split()))", "+xis.sort()", "+distances = [v - u for u, v in zip(xis, xis[1:])]", "+distances.sort(key=lambda x: -x)", "+print(sum(distances[n - 1 :] or [0]))" ]
false
0.038611
0.036358
1.061953
[ "s672269059", "s380158876" ]