user_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
1 value
submission_id_v0
stringlengths
10
10
submission_id_v1
stringlengths
10
10
cpu_time_v0
int64
10
38.3k
cpu_time_v1
int64
0
24.7k
memory_v0
int64
2.57k
1.02M
memory_v1
int64
2.57k
869k
status_v0
stringclasses
1 value
status_v1
stringclasses
1 value
improvement_frac
float64
7.51
100
input
stringlengths
20
4.55k
target
stringlengths
17
3.34k
code_v0_loc
int64
1
148
code_v1_loc
int64
1
184
code_v0_num_chars
int64
13
4.55k
code_v1_num_chars
int64
14
3.34k
code_v0_no_empty_lines
stringlengths
21
6.88k
code_v1_no_empty_lines
stringlengths
20
4.93k
code_same
bool
1 class
relative_loc_diff_percent
float64
0
79.8
diff
list
diff_only_import_comment
bool
1 class
measured_runtime_v0
float64
0.01
4.45
measured_runtime_v1
float64
0.01
4.31
runtime_lift
float64
0
359
key
list
u573900545
p02935
python
s926029389
s137280986
32
25
9,088
9,168
Accepted
Accepted
21.88
N = int(eval(input())) v = list(map(int, input().split())) for i in range(N - 1): v.sort() v[1] = (v[0] + v[1]) / 2 v = v[1:] print((v[0]))
N = int(eval(input())) v = sorted(list(map(int, input().split()))) for i in range(N - 1): v[1] = (v[0] + v[1]) / 2 v = v[1:] print((v[0]))
7
6
149
143
N = int(eval(input())) v = list(map(int, input().split())) for i in range(N - 1): v.sort() v[1] = (v[0] + v[1]) / 2 v = v[1:] print((v[0]))
N = int(eval(input())) v = sorted(list(map(int, input().split()))) for i in range(N - 1): v[1] = (v[0] + v[1]) / 2 v = v[1:] print((v[0]))
false
14.285714
[ "-v = list(map(int, input().split()))", "+v = sorted(list(map(int, input().split())))", "- v.sort()" ]
false
0.047396
0.04663
1.01642
[ "s926029389", "s137280986" ]
u803617136
p02971
python
s150012430
s615265332
878
547
68,696
13,340
Accepted
Accepted
37.7
N = int(eval(input())) a = list() tmp = [0, 0] for _ in range(N): ai = int(eval(input())) a.append(ai) if ai > tmp[1]: tmp[1] = ai elif ai > tmp[0]: tmp[0] = ai m = tmp[1] for ai in a: ans = m if ai == m: ans = tmp[0] print(ans)
n = int(eval(input())) maximums = [0, 0] nums = [int(eval(input())) for _ in range(n)] maximums = sorted(nums, reverse=True)[:2] for num in nums: if num == maximums[0]: print((maximums[1])) else: print((maximums[0]))
19
9
289
232
N = int(eval(input())) a = list() tmp = [0, 0] for _ in range(N): ai = int(eval(input())) a.append(ai) if ai > tmp[1]: tmp[1] = ai elif ai > tmp[0]: tmp[0] = ai m = tmp[1] for ai in a: ans = m if ai == m: ans = tmp[0] print(ans)
n = int(eval(input())) maximums = [0, 0] nums = [int(eval(input())) for _ in range(n)] maximums = sorted(nums, reverse=True)[:2] for num in nums: if num == maximums[0]: print((maximums[1])) else: print((maximums[0]))
false
52.631579
[ "-N = int(eval(input()))", "-a = list()", "-tmp = [0, 0]", "-for _ in range(N):", "- ai = int(eval(input()))", "- a.append(ai)", "- if ai > tmp[1]:", "- tmp[1] = ai", "- elif ai > tmp[0]:", "- tmp[0] = ai", "-m = tmp[1]", "-for ai in a:", "- ans = m", "- if ai == m:", "- ans = tmp[0]", "- print(ans)", "+n = int(eval(input()))", "+maximums = [0, 0]", "+nums = [int(eval(input())) for _ in range(n)]", "+maximums = sorted(nums, reverse=True)[:2]", "+for num in nums:", "+ if num == maximums[0]:", "+ print((maximums[1]))", "+ else:", "+ print((maximums[0]))" ]
false
0.035447
0.007837
4.52306
[ "s150012430", "s615265332" ]
u397496203
p03545
python
s787523008
s272192570
30
26
9,076
9,168
Accepted
Accepted
13.33
def calc(S: str, cur: int, e: str): if S == "": if cur == 7: print((e+"=7")) quit() else: return calc(S[1:], cur + int(S[0]), e + "+" + S[0]) calc(S[1:], cur - int(S[0]), e + "-" + S[0]) S = input().strip() ans = calc(S[1:], int(S[0]), S[0])
S = input().strip() for i in range(2**3): ans = S[0] ## ๆ•ฐๅผใจใชใ‚‹ๆ–‡ๅญ—ๅˆ— _sum = int(S[0]) ## ๅˆ่จˆๅ€ค for j in range(3): if (i>>j)&1: ## ใใ‚Œใžใ‚Œใฎใƒ“ใƒƒใƒˆใ‚’ๅณใ‚ทใƒ•ใƒˆใ—ใฆ่ฉ•ไพกใ™ใ‚‹ """ใƒ“ใƒƒใƒˆใŒ1ใฎใจใ""" ans += "+" + S[j+1] _sum += int(S[j+1]) else: """ใƒ“ใƒƒใƒˆใŒ0ใฎใจใ""" ans += "-" + S[j+1] _sum -= int(S[j+1]) if _sum == 7: ans += "=7" print(ans) quit()
14
19
320
388
def calc(S: str, cur: int, e: str): if S == "": if cur == 7: print((e + "=7")) quit() else: return calc(S[1:], cur + int(S[0]), e + "+" + S[0]) calc(S[1:], cur - int(S[0]), e + "-" + S[0]) S = input().strip() ans = calc(S[1:], int(S[0]), S[0])
S = input().strip() for i in range(2**3): ans = S[0] ## ๆ•ฐๅผใจใชใ‚‹ๆ–‡ๅญ—ๅˆ— _sum = int(S[0]) ## ๅˆ่จˆๅ€ค for j in range(3): if (i >> j) & 1: ## ใใ‚Œใžใ‚Œใฎใƒ“ใƒƒใƒˆใ‚’ๅณใ‚ทใƒ•ใƒˆใ—ใฆ่ฉ•ไพกใ™ใ‚‹ """ใƒ“ใƒƒใƒˆใŒ1ใฎใจใ""" ans += "+" + S[j + 1] _sum += int(S[j + 1]) else: """ใƒ“ใƒƒใƒˆใŒ0ใฎใจใ""" ans += "-" + S[j + 1] _sum -= int(S[j + 1]) if _sum == 7: ans += "=7" print(ans) quit()
false
26.315789
[ "-def calc(S: str, cur: int, e: str):", "- if S == \"\":", "- if cur == 7:", "- print((e + \"=7\"))", "- quit()", "+S = input().strip()", "+for i in range(2**3):", "+ ans = S[0] ## ๆ•ฐๅผใจใชใ‚‹ๆ–‡ๅญ—ๅˆ—", "+ _sum = int(S[0]) ## ๅˆ่จˆๅ€ค", "+ for j in range(3):", "+ if (i >> j) & 1: ## ใใ‚Œใžใ‚Œใฎใƒ“ใƒƒใƒˆใ‚’ๅณใ‚ทใƒ•ใƒˆใ—ใฆ่ฉ•ไพกใ™ใ‚‹", "+ \"\"\"ใƒ“ใƒƒใƒˆใŒ1ใฎใจใ\"\"\"", "+ ans += \"+\" + S[j + 1]", "+ _sum += int(S[j + 1])", "- return", "- calc(S[1:], cur + int(S[0]), e + \"+\" + S[0])", "- calc(S[1:], cur - int(S[0]), e + \"-\" + S[0])", "-", "-", "-S = input().strip()", "-ans = calc(S[1:], int(S[0]), S[0])", "+ \"\"\"ใƒ“ใƒƒใƒˆใŒ0ใฎใจใ\"\"\"", "+ ans += \"-\" + S[j + 1]", "+ _sum -= int(S[j + 1])", "+ if _sum == 7:", "+ ans += \"=7\"", "+ print(ans)", "+ quit()" ]
false
0.039992
0.033476
1.194674
[ "s787523008", "s272192570" ]
u067447457
p02773
python
s461429649
s061981502
577
414
35,824
38,476
Accepted
Accepted
28.25
from collections import Counter n=int(input()) l=[input() for i in range(n)] c=Counter(l) d=max(c.values()) max_list=[k for k,v in c.items() if v==d] max_list.sort() print(*max_list,sep="\n")
from collections import Counter a=open(0) n=int(a.readline()) l=a.read().split() c=Counter(l) d=max(c.values()) max_list=[k for k,v in c.items() if v==d] max_list.sort() print(*max_list,sep="\n")
9
9
200
203
from collections import Counter n = int(input()) l = [input() for i in range(n)] c = Counter(l) d = max(c.values()) max_list = [k for k, v in c.items() if v == d] max_list.sort() print(*max_list, sep="\n")
from collections import Counter a = open(0) n = int(a.readline()) l = a.read().split() c = Counter(l) d = max(c.values()) max_list = [k for k, v in c.items() if v == d] max_list.sort() print(*max_list, sep="\n")
false
0
[ "-n = int(input())", "-l = [input() for i in range(n)]", "+a = open(0)", "+n = int(a.readline())", "+l = a.read().split()" ]
false
0.042774
0.099483
0.429965
[ "s461429649", "s061981502" ]
u263830634
p03200
python
s944209874
s275212123
89
59
12,576
4,840
Accepted
Accepted
33.71
S = list(eval(input())) N = len(S) left = [0] * N ans = 0 if S[0] == 'B': left[0] = 1 for i in range(1, N): if S[i] == 'B': left[i] = left[i - 1] + 1 else: left[i] = left[i - 1] ans += left[i] print (ans)
S = list(eval(input())) N = len(S) ans = 0 # if S[0] == 'B': # tmp = 1 # else: # tmp = 0 tmp = 1 if S[0] == 'B' else 0 for i in range(1, N): if S[i] == 'B': tmp += 1 else: ans += tmp print (ans)
15
18
250
241
S = list(eval(input())) N = len(S) left = [0] * N ans = 0 if S[0] == "B": left[0] = 1 for i in range(1, N): if S[i] == "B": left[i] = left[i - 1] + 1 else: left[i] = left[i - 1] ans += left[i] print(ans)
S = list(eval(input())) N = len(S) ans = 0 # if S[0] == 'B': # tmp = 1 # else: # tmp = 0 tmp = 1 if S[0] == "B" else 0 for i in range(1, N): if S[i] == "B": tmp += 1 else: ans += tmp print(ans)
false
16.666667
[ "-left = [0] * N", "-if S[0] == \"B\":", "- left[0] = 1", "+# if S[0] == 'B':", "+# tmp = 1", "+# else:", "+# tmp = 0", "+tmp = 1 if S[0] == \"B\" else 0", "- left[i] = left[i - 1] + 1", "+ tmp += 1", "- left[i] = left[i - 1]", "- ans += left[i]", "+ ans += tmp" ]
false
0.035016
0.090615
0.386432
[ "s944209874", "s275212123" ]
u186206732
p02983
python
s838864908
s898567950
854
609
2,940
2,940
Accepted
Accepted
28.69
a,b = list(map(int,input().split())) min_mod = 2018 if b-a > 2019: min_mod=0 else: for aa in range(a,b): for bb in range(a+1,b+1): if aa < bb: cc=aa*bb if min_mod > cc%2019: min_mod = cc%2019 print(min_mod)
a,b = list(map(int,input().split())) min_mod = 2018 if b-a > 2019: min_mod=0 else: for aa in range(a,b): for bb in range(aa+1,b+1): if aa < bb: cc=aa*bb if min_mod > cc%2019: min_mod = cc%2019 print(min_mod)
17
16
279
278
a, b = list(map(int, input().split())) min_mod = 2018 if b - a > 2019: min_mod = 0 else: for aa in range(a, b): for bb in range(a + 1, b + 1): if aa < bb: cc = aa * bb if min_mod > cc % 2019: min_mod = cc % 2019 print(min_mod)
a, b = list(map(int, input().split())) min_mod = 2018 if b - a > 2019: min_mod = 0 else: for aa in range(a, b): for bb in range(aa + 1, b + 1): if aa < bb: cc = aa * bb if min_mod > cc % 2019: min_mod = cc % 2019 print(min_mod)
false
5.882353
[ "- for bb in range(a + 1, b + 1):", "+ for bb in range(aa + 1, b + 1):" ]
false
0.040215
0.038451
1.045876
[ "s838864908", "s898567950" ]
u844789719
p03725
python
s144692212
s630247824
838
584
99,416
83,932
Accepted
Accepted
30.31
import itertools, math, collections, sys input = sys.stdin.readline H, W, K = [int(_) for _ in input().split()] A = [eval(input()) for _ in range(H)] for i, j in itertools.product(list(range(H)), list(range(W))): if A[i][j] == 'S': A[i] = A[i][:j] + '.' + A[i][j + 1:] break visited = [[False] * W for _ in range(H)] ans = min([i, H - 1 - i, j, W - 1 - j]) Q = collections.deque([[i, j, K]]) while Q: h, w, res = Q.popleft() if 0 <= h < H and 0 <= w < W and not visited[h][w] and A[h][w] == '.': visited[h][w] = True ans = min([ans, h, H - 1 - h, w, W - 1 - w]) if res: res -= 1 Q += [[h - 1, w, res]] Q += [[h + 1, w, res]] Q += [[h, w - 1, res]] Q += [[h, w + 1, res]] print((1 + math.ceil(ans / K)))
import itertools, math, collections, sys input = sys.stdin.readline H, W, K = [int(_) for _ in input().split()] A = [eval(input()) for _ in range(H)] for h, w in itertools.product(list(range(H)), list(range(W))): if A[h][w] == 'S': break visited = [['.'] * W for _ in range(H)] res = K - 1 Q = collections.deque([[h - 1, w, res], [h + 1, w, res], [h, w - 1, res], [h, w + 1, res]]) sH = set([h]) sW = set([w]) while Q: h, w, res = Q.popleft() if 0 <= h < H and 0 <= w < W and A[h][w] == '.' and visited[h][w] != '#': visited[h][w] = '#' sH.add(h) sW.add(w) if res: res -= 1 Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res], [h, w + 1, res]] print((1 + math.ceil(min([min(sH), H - 1 - max(sH), min(sW), W - 1 - max(sW)]) / K)))
23
26
817
883
import itertools, math, collections, sys input = sys.stdin.readline H, W, K = [int(_) for _ in input().split()] A = [eval(input()) for _ in range(H)] for i, j in itertools.product(list(range(H)), list(range(W))): if A[i][j] == "S": A[i] = A[i][:j] + "." + A[i][j + 1 :] break visited = [[False] * W for _ in range(H)] ans = min([i, H - 1 - i, j, W - 1 - j]) Q = collections.deque([[i, j, K]]) while Q: h, w, res = Q.popleft() if 0 <= h < H and 0 <= w < W and not visited[h][w] and A[h][w] == ".": visited[h][w] = True ans = min([ans, h, H - 1 - h, w, W - 1 - w]) if res: res -= 1 Q += [[h - 1, w, res]] Q += [[h + 1, w, res]] Q += [[h, w - 1, res]] Q += [[h, w + 1, res]] print((1 + math.ceil(ans / K)))
import itertools, math, collections, sys input = sys.stdin.readline H, W, K = [int(_) for _ in input().split()] A = [eval(input()) for _ in range(H)] for h, w in itertools.product(list(range(H)), list(range(W))): if A[h][w] == "S": break visited = [["."] * W for _ in range(H)] res = K - 1 Q = collections.deque( [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res], [h, w + 1, res]] ) sH = set([h]) sW = set([w]) while Q: h, w, res = Q.popleft() if 0 <= h < H and 0 <= w < W and A[h][w] == "." and visited[h][w] != "#": visited[h][w] = "#" sH.add(h) sW.add(w) if res: res -= 1 Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res], [h, w + 1, res]] print((1 + math.ceil(min([min(sH), H - 1 - max(sH), min(sW), W - 1 - max(sW)]) / K)))
false
11.538462
[ "-for i, j in itertools.product(list(range(H)), list(range(W))):", "- if A[i][j] == \"S\":", "- A[i] = A[i][:j] + \".\" + A[i][j + 1 :]", "+for h, w in itertools.product(list(range(H)), list(range(W))):", "+ if A[h][w] == \"S\":", "-visited = [[False] * W for _ in range(H)]", "-ans = min([i, H - 1 - i, j, W - 1 - j])", "-Q = collections.deque([[i, j, K]])", "+visited = [[\".\"] * W for _ in range(H)]", "+res = K - 1", "+Q = collections.deque(", "+ [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res], [h, w + 1, res]]", "+)", "+sH = set([h])", "+sW = set([w])", "- if 0 <= h < H and 0 <= w < W and not visited[h][w] and A[h][w] == \".\":", "- visited[h][w] = True", "- ans = min([ans, h, H - 1 - h, w, W - 1 - w])", "+ if 0 <= h < H and 0 <= w < W and A[h][w] == \".\" and visited[h][w] != \"#\":", "+ visited[h][w] = \"#\"", "+ sH.add(h)", "+ sW.add(w)", "- Q += [[h - 1, w, res]]", "- Q += [[h + 1, w, res]]", "- Q += [[h, w - 1, res]]", "- Q += [[h, w + 1, res]]", "-print((1 + math.ceil(ans / K)))", "+ Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res], [h, w + 1, res]]", "+print((1 + math.ceil(min([min(sH), H - 1 - max(sH), min(sW), W - 1 - max(sW)]) / K)))" ]
false
0.099013
0.077823
1.272285
[ "s144692212", "s630247824" ]
u335038698
p03088
python
s977418490
s417380054
133
42
3,852
3,316
Accepted
Accepted
68.42
N = int(eval(input())) MOD = 10**9 + 7 memo = [{} for _ in range(N + 1)] def isAGC(char4): for i in range(4): tmp = list(char4) if i != 3: tmp[i], tmp[i + 1] = tmp[i + 1], tmp[i] if ''.join(tmp).count('AGC') >= 1: return True return False def dfs(cur, char3): if char3 in memo[cur]: return memo[cur][char3] if cur == N: return 1 ret = 0 for c in ['A', 'C', 'G', 'T']: if not isAGC(char3 + c): ret = (ret + dfs(cur + 1, char3[1:] + c)) % MOD memo[cur][char3] = ret return ret print((dfs(0, 'XXX')))
N = int(eval(input())) MOD = 10**9 + 7 dp = [[[[0] * 4 for ___ in range(4)]for __ in range(4)]for _ in range(N + 1)] for i in range(4): for j in range(4): for k in range(4): dp[0][i][j][k] = 0 dp[1][i][j][k] = 1 dp[2][i][j][k] = 1 if i == 2 and j == 1 and k == 0: continue elif i == 1 and j == 2 and k == 0: continue elif i == 2 and j == 0 and k == 1: continue dp[3][i][j][k] = 1 for n in range(3, N): for i in range(4): for j in range(4): for k in range(4): for c in range(4): if c == 1 and i == 2 and j == 0: continue elif c == 2 and i == 1 and j == 0: continue elif c == 2 and i == 0 and j == 1: continue elif c == 2 and i == 1 and k == 0: continue elif c == 2 and j == 1 and k == 0: continue dp[n + 1][c][i][j] += dp[n][i][j][k] dp[n + 1][c][i][j] %= MOD ans = 0 for i in range(4): for j in range(4): for k in range(4): ans += dp[N][i][j][k] print((ans % MOD))
29
43
643
1,371
N = int(eval(input())) MOD = 10**9 + 7 memo = [{} for _ in range(N + 1)] def isAGC(char4): for i in range(4): tmp = list(char4) if i != 3: tmp[i], tmp[i + 1] = tmp[i + 1], tmp[i] if "".join(tmp).count("AGC") >= 1: return True return False def dfs(cur, char3): if char3 in memo[cur]: return memo[cur][char3] if cur == N: return 1 ret = 0 for c in ["A", "C", "G", "T"]: if not isAGC(char3 + c): ret = (ret + dfs(cur + 1, char3[1:] + c)) % MOD memo[cur][char3] = ret return ret print((dfs(0, "XXX")))
N = int(eval(input())) MOD = 10**9 + 7 dp = [[[[0] * 4 for ___ in range(4)] for __ in range(4)] for _ in range(N + 1)] for i in range(4): for j in range(4): for k in range(4): dp[0][i][j][k] = 0 dp[1][i][j][k] = 1 dp[2][i][j][k] = 1 if i == 2 and j == 1 and k == 0: continue elif i == 1 and j == 2 and k == 0: continue elif i == 2 and j == 0 and k == 1: continue dp[3][i][j][k] = 1 for n in range(3, N): for i in range(4): for j in range(4): for k in range(4): for c in range(4): if c == 1 and i == 2 and j == 0: continue elif c == 2 and i == 1 and j == 0: continue elif c == 2 and i == 0 and j == 1: continue elif c == 2 and i == 1 and k == 0: continue elif c == 2 and j == 1 and k == 0: continue dp[n + 1][c][i][j] += dp[n][i][j][k] dp[n + 1][c][i][j] %= MOD ans = 0 for i in range(4): for j in range(4): for k in range(4): ans += dp[N][i][j][k] print((ans % MOD))
false
32.55814
[ "-memo = [{} for _ in range(N + 1)]", "-", "-", "-def isAGC(char4):", "+dp = [[[[0] * 4 for ___ in range(4)] for __ in range(4)] for _ in range(N + 1)]", "+for i in range(4):", "+ for j in range(4):", "+ for k in range(4):", "+ dp[0][i][j][k] = 0", "+ dp[1][i][j][k] = 1", "+ dp[2][i][j][k] = 1", "+ if i == 2 and j == 1 and k == 0:", "+ continue", "+ elif i == 1 and j == 2 and k == 0:", "+ continue", "+ elif i == 2 and j == 0 and k == 1:", "+ continue", "+ dp[3][i][j][k] = 1", "+for n in range(3, N):", "- tmp = list(char4)", "- if i != 3:", "- tmp[i], tmp[i + 1] = tmp[i + 1], tmp[i]", "- if \"\".join(tmp).count(\"AGC\") >= 1:", "- return True", "- return False", "-", "-", "-def dfs(cur, char3):", "- if char3 in memo[cur]:", "- return memo[cur][char3]", "- if cur == N:", "- return 1", "- ret = 0", "- for c in [\"A\", \"C\", \"G\", \"T\"]:", "- if not isAGC(char3 + c):", "- ret = (ret + dfs(cur + 1, char3[1:] + c)) % MOD", "- memo[cur][char3] = ret", "- return ret", "-", "-", "-print((dfs(0, \"XXX\")))", "+ for j in range(4):", "+ for k in range(4):", "+ for c in range(4):", "+ if c == 1 and i == 2 and j == 0:", "+ continue", "+ elif c == 2 and i == 1 and j == 0:", "+ continue", "+ elif c == 2 and i == 0 and j == 1:", "+ continue", "+ elif c == 2 and i == 1 and k == 0:", "+ continue", "+ elif c == 2 and j == 1 and k == 0:", "+ continue", "+ dp[n + 1][c][i][j] += dp[n][i][j][k]", "+ dp[n + 1][c][i][j] %= MOD", "+ans = 0", "+for i in range(4):", "+ for j in range(4):", "+ for k in range(4):", "+ ans += dp[N][i][j][k]", "+print((ans % MOD))" ]
false
0.083193
0.1105
0.752885
[ "s977418490", "s417380054" ]
u519339498
p03835
python
s046896657
s487990124
1,400
683
9,168
9,052
Accepted
Accepted
51.21
ans=0 K,S=list(map(int,input().split())) for x in range(K+1): for y in range(K+1): if 0<=S-x-y and S-x-y<=K: ans+=1 print(ans)
''' Created on 2020/09/03 @author: harurun ''' def main(): import sys pin=sys.stdin.readline pout=sys.stdout.write perr=sys.stderr.write K,S=list(map(int,pin().split())) ans=0 for x in range(K+1): for y in range(K+1): if 0<=S-x-y<=K: ans+=1 print(ans) return main()
7
20
138
319
ans = 0 K, S = list(map(int, input().split())) for x in range(K + 1): for y in range(K + 1): if 0 <= S - x - y and S - x - y <= K: ans += 1 print(ans)
""" Created on 2020/09/03 @author: harurun """ def main(): import sys pin = sys.stdin.readline pout = sys.stdout.write perr = sys.stderr.write K, S = list(map(int, pin().split())) ans = 0 for x in range(K + 1): for y in range(K + 1): if 0 <= S - x - y <= K: ans += 1 print(ans) return main()
false
65
[ "-ans = 0", "-K, S = list(map(int, input().split()))", "-for x in range(K + 1):", "- for y in range(K + 1):", "- if 0 <= S - x - y and S - x - y <= K:", "- ans += 1", "-print(ans)", "+\"\"\"", "+Created on 2020/09/03", "+@author: harurun", "+\"\"\"", "+", "+", "+def main():", "+ import sys", "+", "+ pin = sys.stdin.readline", "+ pout = sys.stdout.write", "+ perr = sys.stderr.write", "+ K, S = list(map(int, pin().split()))", "+ ans = 0", "+ for x in range(K + 1):", "+ for y in range(K + 1):", "+ if 0 <= S - x - y <= K:", "+ ans += 1", "+ print(ans)", "+ return", "+", "+", "+main()" ]
false
0.069688
0.089724
0.776697
[ "s046896657", "s487990124" ]
u627600101
p02850
python
s522231584
s154654853
643
456
113,484
106,892
Accepted
Accepted
29.08
N = int(eval(input())) inp = [] for k in range(N-1): a, b = list(map(int, input().split())) if a > b: a, b = b-1, a-1 else: a, b = a-1, b-1 inp.append((a, b, k)) inp.sort(key = lambda x: x[0]) mark = [[] for _ in range(N)] ans = [0 for _ in range(N-1)] now = 0 cnt = 0 for item in inp: cnt += 1 if now < item[0]: now = item[0] cnt = 1 while cnt in mark[item[0]] or cnt in mark[item[1]]: cnt += 1 mark[item[1]].append(cnt) mark[item[0]].append(cnt) ans[item[2]] = cnt color = max(ans) print(color) for k in range(N-1): print((ans[k]))
N = int(eval(input())) inp = [] for k in range(N-1): a, b = list(map(int, input().split())) if a > b: a, b = b-1, a-1 else: a, b = a-1, b-1 inp.append((a, b, k)) inp.sort(key = lambda x: x[0]) mark = [[] for _ in range(N)] def binary_search(list, item): low = 0 high = len(list) - 1 while low <= high: mid = (low + high) //2 guess = list[mid] if guess == item: #return mid return True if guess > item: high = mid -1 else: low = mid + 1 #return None return False from bisect import insort ans = [0 for _ in range(N-1)] now = 0 cnt = 0 for item in inp: cnt += 1 if now < item[0]: now = item[0] cnt = 1 while binary_search(mark[item[0]], cnt) or binary_search(mark[item[1]], cnt): cnt += 1 insort(mark[item[1]], cnt) ans[item[2]] = cnt color = max(ans) print(color) for k in range(N-1): print((ans[k]))
30
48
594
986
N = int(eval(input())) inp = [] for k in range(N - 1): a, b = list(map(int, input().split())) if a > b: a, b = b - 1, a - 1 else: a, b = a - 1, b - 1 inp.append((a, b, k)) inp.sort(key=lambda x: x[0]) mark = [[] for _ in range(N)] ans = [0 for _ in range(N - 1)] now = 0 cnt = 0 for item in inp: cnt += 1 if now < item[0]: now = item[0] cnt = 1 while cnt in mark[item[0]] or cnt in mark[item[1]]: cnt += 1 mark[item[1]].append(cnt) mark[item[0]].append(cnt) ans[item[2]] = cnt color = max(ans) print(color) for k in range(N - 1): print((ans[k]))
N = int(eval(input())) inp = [] for k in range(N - 1): a, b = list(map(int, input().split())) if a > b: a, b = b - 1, a - 1 else: a, b = a - 1, b - 1 inp.append((a, b, k)) inp.sort(key=lambda x: x[0]) mark = [[] for _ in range(N)] def binary_search(list, item): low = 0 high = len(list) - 1 while low <= high: mid = (low + high) // 2 guess = list[mid] if guess == item: # return mid return True if guess > item: high = mid - 1 else: low = mid + 1 # return None return False from bisect import insort ans = [0 for _ in range(N - 1)] now = 0 cnt = 0 for item in inp: cnt += 1 if now < item[0]: now = item[0] cnt = 1 while binary_search(mark[item[0]], cnt) or binary_search(mark[item[1]], cnt): cnt += 1 insort(mark[item[1]], cnt) ans[item[2]] = cnt color = max(ans) print(color) for k in range(N - 1): print((ans[k]))
false
37.5
[ "+", "+", "+def binary_search(list, item):", "+ low = 0", "+ high = len(list) - 1", "+ while low <= high:", "+ mid = (low + high) // 2", "+ guess = list[mid]", "+ if guess == item:", "+ # return mid", "+ return True", "+ if guess > item:", "+ high = mid - 1", "+ else:", "+ low = mid + 1", "+ # return None", "+ return False", "+", "+", "+from bisect import insort", "+", "- while cnt in mark[item[0]] or cnt in mark[item[1]]:", "+ while binary_search(mark[item[0]], cnt) or binary_search(mark[item[1]], cnt):", "- mark[item[1]].append(cnt)", "- mark[item[0]].append(cnt)", "+ insort(mark[item[1]], cnt)" ]
false
0.039313
0.040648
0.967157
[ "s522231584", "s154654853" ]
u389910364
p03213
python
s445185147
s126971497
21
18
3,444
3,192
Accepted
Accepted
14.29
import itertools from collections import Counter n = int(eval(input())) # ็ด ๅ› ๆ•ฐๅˆ†่งฃใ—ใŸ็ตๆžœใฎใƒชใ‚นใƒˆ # {1: [], 2: [2], 3: [3], 4: [2, 2], 5: [5]} divs = {} primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] for i in range(1, n + 1): divs[i] = [] x = i while x >= 2: for p in primes: if x % p == 0: x //= p divs[i].append(p) # flatten fdivs = list(itertools.chain.from_iterable(list(divs.values()))) counts = Counter(fdivs) ans = 0 # 75==5*5*3 # https://juken-mikata.net/how-to/mathematics/number-of-divisor.html # 4, 4, 2 ้ธใ‚“ใ ใ‚‰75ๆ•ฐใซใชใ‚‹ ge4 = len([c for c in list(counts.values()) if c >= 4]) ge2 = len([c for c in list(counts.values()) if c >= 2]) ans += ge4 * (ge4 - 1) / 2 * (ge2 - 2) # 75==5*15 # 4, 14 ้ธใถ ge14 = len([c for c in list(counts.values()) if c >= 14]) ans += ge14 * (ge4 - 1) # 75==25*3 # 24, 2 ้ธใถ ge24 = len([c for c in list(counts.values()) if c >= 24]) ans += ge24 * (ge2 - 1) # 75 ==75*1 # 74 ้ธใถ ge74 = len([c for c in list(counts.values()) if c >= 74]) ans += ge74 print((int(ans)))
import itertools import math import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 def get_factors(n): """ ็ด ๅ› ๆ•ฐๅˆ†่งฃ :param int n: :rtype: list of int """ if n <= 1: return [] ret = [] while n > 2 and n % 2 == 0: ret.append(2) n //= 2 i = 3 while i <= math.sqrt(n): if n % i == 0: ret.append(i) n //= i else: i += 2 ret.append(n) return ret N = int(sys.stdin.buffer.readline()) counts = [0] * 101 for n in range(1, N + 1): for f in get_factors(n): counts[f] += 1 t = [] for c in counts: if c >= 2: t.append(c) counts = t # ็ด ๅ› ๆ•ฐใฎไฝฟใ„ๆ–นใฎใƒ‘ใ‚ฟใƒผใƒณๆ•ฐใŒ # 3, 25 ใจ 3, 5, 5 ใจ 15, 5 ใจ 75 ใฎใจใ็ด„ๆ•ฐใŒ75ๅ€‹ ans = 0 for i, j, k in itertools.combinations(list(range(len(counts))), r=3): if counts[i] >= 2 and counts[j] >= 4 and counts[k] >= 4: ans += 1 if counts[i] >= 4 and counts[j] >= 2 and counts[k] >= 4: ans += 1 if counts[i] >= 4 and counts[j] >= 4 and counts[k] >= 2: ans += 1 for i, j in itertools.combinations(list(range(len(counts))), r=2): if counts[i] >= 2 and counts[j] >= 24: ans += 1 if counts[i] >= 24 and counts[j] >= 2: ans += 1 if counts[i] >= 4 and counts[j] >= 14: ans += 1 if counts[i] >= 14 and counts[j] >= 4: ans += 1 for c in counts: if c >= 74: ans += 1 print(ans)
47
77
1,117
1,608
import itertools from collections import Counter n = int(eval(input())) # ็ด ๅ› ๆ•ฐๅˆ†่งฃใ—ใŸ็ตๆžœใฎใƒชใ‚นใƒˆ # {1: [], 2: [2], 3: [3], 4: [2, 2], 5: [5]} divs = {} primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, ] for i in range(1, n + 1): divs[i] = [] x = i while x >= 2: for p in primes: if x % p == 0: x //= p divs[i].append(p) # flatten fdivs = list(itertools.chain.from_iterable(list(divs.values()))) counts = Counter(fdivs) ans = 0 # 75==5*5*3 # https://juken-mikata.net/how-to/mathematics/number-of-divisor.html # 4, 4, 2 ้ธใ‚“ใ ใ‚‰75ๆ•ฐใซใชใ‚‹ ge4 = len([c for c in list(counts.values()) if c >= 4]) ge2 = len([c for c in list(counts.values()) if c >= 2]) ans += ge4 * (ge4 - 1) / 2 * (ge2 - 2) # 75==5*15 # 4, 14 ้ธใถ ge14 = len([c for c in list(counts.values()) if c >= 14]) ans += ge14 * (ge4 - 1) # 75==25*3 # 24, 2 ้ธใถ ge24 = len([c for c in list(counts.values()) if c >= 24]) ans += ge24 * (ge2 - 1) # 75 ==75*1 # 74 ้ธใถ ge74 = len([c for c in list(counts.values()) if c >= 74]) ans += ge74 print((int(ans)))
import itertools import math import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10**9) INF = float("inf") IINF = 10**18 MOD = 10**9 + 7 # MOD = 998244353 def get_factors(n): """ ็ด ๅ› ๆ•ฐๅˆ†่งฃ :param int n: :rtype: list of int """ if n <= 1: return [] ret = [] while n > 2 and n % 2 == 0: ret.append(2) n //= 2 i = 3 while i <= math.sqrt(n): if n % i == 0: ret.append(i) n //= i else: i += 2 ret.append(n) return ret N = int(sys.stdin.buffer.readline()) counts = [0] * 101 for n in range(1, N + 1): for f in get_factors(n): counts[f] += 1 t = [] for c in counts: if c >= 2: t.append(c) counts = t # ็ด ๅ› ๆ•ฐใฎไฝฟใ„ๆ–นใฎใƒ‘ใ‚ฟใƒผใƒณๆ•ฐใŒ # 3, 25 ใจ 3, 5, 5 ใจ 15, 5 ใจ 75 ใฎใจใ็ด„ๆ•ฐใŒ75ๅ€‹ ans = 0 for i, j, k in itertools.combinations(list(range(len(counts))), r=3): if counts[i] >= 2 and counts[j] >= 4 and counts[k] >= 4: ans += 1 if counts[i] >= 4 and counts[j] >= 2 and counts[k] >= 4: ans += 1 if counts[i] >= 4 and counts[j] >= 4 and counts[k] >= 2: ans += 1 for i, j in itertools.combinations(list(range(len(counts))), r=2): if counts[i] >= 2 and counts[j] >= 24: ans += 1 if counts[i] >= 24 and counts[j] >= 2: ans += 1 if counts[i] >= 4 and counts[j] >= 14: ans += 1 if counts[i] >= 14 and counts[j] >= 4: ans += 1 for c in counts: if c >= 74: ans += 1 print(ans)
false
38.961039
[ "-from collections import Counter", "+import math", "+import os", "+import sys", "-n = int(eval(input()))", "-# ็ด ๅ› ๆ•ฐๅˆ†่งฃใ—ใŸ็ตๆžœใฎใƒชใ‚นใƒˆ", "-# {1: [], 2: [2], 3: [3], 4: [2, 2], 5: [5]}", "-divs = {}", "-primes = [", "- 2,", "- 3,", "- 5,", "- 7,", "- 11,", "- 13,", "- 17,", "- 19,", "- 23,", "- 29,", "- 31,", "- 37,", "- 41,", "- 43,", "- 47,", "- 53,", "- 59,", "- 61,", "- 67,", "- 71,", "- 73,", "- 79,", "- 83,", "- 89,", "- 97,", "-]", "-for i in range(1, n + 1):", "- divs[i] = []", "- x = i", "- while x >= 2:", "- for p in primes:", "- if x % p == 0:", "- x //= p", "- divs[i].append(p)", "-# flatten", "-fdivs = list(itertools.chain.from_iterable(list(divs.values())))", "-counts = Counter(fdivs)", "+if os.getenv(\"LOCAL\"):", "+ sys.stdin = open(\"_in.txt\", \"r\")", "+sys.setrecursionlimit(10**9)", "+INF = float(\"inf\")", "+IINF = 10**18", "+MOD = 10**9 + 7", "+# MOD = 998244353", "+def get_factors(n):", "+ \"\"\"", "+ ็ด ๅ› ๆ•ฐๅˆ†่งฃ", "+ :param int n:", "+ :rtype: list of int", "+ \"\"\"", "+ if n <= 1:", "+ return []", "+ ret = []", "+ while n > 2 and n % 2 == 0:", "+ ret.append(2)", "+ n //= 2", "+ i = 3", "+ while i <= math.sqrt(n):", "+ if n % i == 0:", "+ ret.append(i)", "+ n //= i", "+ else:", "+ i += 2", "+ ret.append(n)", "+ return ret", "+", "+", "+N = int(sys.stdin.buffer.readline())", "+counts = [0] * 101", "+for n in range(1, N + 1):", "+ for f in get_factors(n):", "+ counts[f] += 1", "+t = []", "+for c in counts:", "+ if c >= 2:", "+ t.append(c)", "+counts = t", "+# ็ด ๅ› ๆ•ฐใฎไฝฟใ„ๆ–นใฎใƒ‘ใ‚ฟใƒผใƒณๆ•ฐใŒ", "+# 3, 25 ใจ 3, 5, 5 ใจ 15, 5 ใจ 75 ใฎใจใ็ด„ๆ•ฐใŒ75ๅ€‹", "-# 75==5*5*3", "-# https://juken-mikata.net/how-to/mathematics/number-of-divisor.html", "-# 4, 4, 2 ้ธใ‚“ใ ใ‚‰75ๆ•ฐใซใชใ‚‹", "-ge4 = len([c for c in list(counts.values()) if c >= 4])", "-ge2 = len([c for c in list(counts.values()) if c >= 2])", "-ans += ge4 * (ge4 - 1) / 2 * (ge2 - 2)", "-# 75==5*15", "-# 4, 14 ้ธใถ", "-ge14 = len([c for c in list(counts.values()) if c >= 14])", "-ans += ge14 * (ge4 - 1)", "-# 75==25*3", "-# 24, 2 ้ธใถ", "-ge24 = len([c for c in list(counts.values()) if c >= 24])", "-ans += ge24 * (ge2 - 1)", "-# 75 ==75*1", "-# 74 ้ธใถ", "-ge74 = len([c for c in list(counts.values()) if c >= 74])", "-ans += ge74", "-print((int(ans)))", "+for i, j, k in itertools.combinations(list(range(len(counts))), r=3):", "+ if counts[i] >= 2 and counts[j] >= 4 and counts[k] >= 4:", "+ ans += 1", "+ if counts[i] >= 4 and counts[j] >= 2 and counts[k] >= 4:", "+ ans += 1", "+ if counts[i] >= 4 and counts[j] >= 4 and counts[k] >= 2:", "+ ans += 1", "+for i, j in itertools.combinations(list(range(len(counts))), r=2):", "+ if counts[i] >= 2 and counts[j] >= 24:", "+ ans += 1", "+ if counts[i] >= 24 and counts[j] >= 2:", "+ ans += 1", "+ if counts[i] >= 4 and counts[j] >= 14:", "+ ans += 1", "+ if counts[i] >= 14 and counts[j] >= 4:", "+ ans += 1", "+for c in counts:", "+ if c >= 74:", "+ ans += 1", "+print(ans)" ]
false
0.115564
0.066963
1.725784
[ "s445185147", "s126971497" ]
u696886537
p02556
python
s141829623
s895240472
521
324
9,156
9,232
Accepted
Accepted
37.81
n=int(eval(input())) a,b,c,d=-10**9,10**9,-10**9,10**9 for _ in range(n): x,y=list(map(int,input().split())) a=max(a,x+y) b=min(b,x+y) c=max(c,x-y) d=min(d,x-y) print((max(a-b,c-d)))
import sys input=sys.stdin.readline n=int(eval(input())) a,b,c,d=-10**9,10**9,-10**9,10**9 for _ in range(n): x,y=list(map(int,input().split())) a=max(a,x+y) b=min(b,x+y) c=max(c,x-y) d=min(d,x-y) print((max(a-b,c-d)))
9
12
181
221
n = int(eval(input())) a, b, c, d = -(10**9), 10**9, -(10**9), 10**9 for _ in range(n): x, y = list(map(int, input().split())) a = max(a, x + y) b = min(b, x + y) c = max(c, x - y) d = min(d, x - y) print((max(a - b, c - d)))
import sys input = sys.stdin.readline n = int(eval(input())) a, b, c, d = -(10**9), 10**9, -(10**9), 10**9 for _ in range(n): x, y = list(map(int, input().split())) a = max(a, x + y) b = min(b, x + y) c = max(c, x - y) d = min(d, x - y) print((max(a - b, c - d)))
false
25
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.038191
0.038863
0.982704
[ "s141829623", "s895240472" ]
u579699847
p03611
python
s373416217
s322217775
123
81
13,964
14,300
Accepted
Accepted
34.15
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N = I() a = LI() ans = 0 num_count = [0]*(10**5+1) for x in a: num_count[x] += 1 for i in range(10**5+1): if i+2<=10**5: ans = max(ans,sum(num_count[i:i+3])) print(ans)
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N = I() a = LI() ans = 0 num_count = [0]*(10**5+2) for x in a: num_count[x-1] += 1 num_count[x] += 1 num_count[x+1] += 1 print((max(num_count)))
13
12
329
298
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) N = I() a = LI() ans = 0 num_count = [0] * (10**5 + 1) for x in a: num_count[x] += 1 for i in range(10**5 + 1): if i + 2 <= 10**5: ans = max(ans, sum(num_count[i : i + 3])) print(ans)
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) N = I() a = LI() ans = 0 num_count = [0] * (10**5 + 2) for x in a: num_count[x - 1] += 1 num_count[x] += 1 num_count[x + 1] += 1 print((max(num_count)))
false
7.692308
[ "-num_count = [0] * (10**5 + 1)", "+num_count = [0] * (10**5 + 2)", "+ num_count[x - 1] += 1", "-for i in range(10**5 + 1):", "- if i + 2 <= 10**5:", "- ans = max(ans, sum(num_count[i : i + 3]))", "-print(ans)", "+ num_count[x + 1] += 1", "+print((max(num_count)))" ]
false
0.105883
0.113233
0.935085
[ "s373416217", "s322217775" ]
u970197315
p03208
python
s235052816
s888074329
263
241
7,384
7,384
Accepted
Accepted
8.37
n,k=list(map(int,input().split())) h=[] for i in range(n): h.append(int(eval(input()))) h.sort() ans=10**10 for i in range(n-k+1): t=h[i+k-1]-h[i] ans=min(t,ans) print(ans)
n,k=list(map(int,input().split())) h=[int(eval(input())) for i in range(n)] h.sort() ans=10**18 for i in range(n-k+1): ans=min(h[i+k-1]-h[i],ans) print(ans)
10
8
182
155
n, k = list(map(int, input().split())) h = [] for i in range(n): h.append(int(eval(input()))) h.sort() ans = 10**10 for i in range(n - k + 1): t = h[i + k - 1] - h[i] ans = min(t, ans) print(ans)
n, k = list(map(int, input().split())) h = [int(eval(input())) for i in range(n)] h.sort() ans = 10**18 for i in range(n - k + 1): ans = min(h[i + k - 1] - h[i], ans) print(ans)
false
20
[ "-h = []", "-for i in range(n):", "- h.append(int(eval(input())))", "+h = [int(eval(input())) for i in range(n)]", "-ans = 10**10", "+ans = 10**18", "- t = h[i + k - 1] - h[i]", "- ans = min(t, ans)", "+ ans = min(h[i + k - 1] - h[i], ans)" ]
false
0.03699
0.035906
1.030195
[ "s235052816", "s888074329" ]
u991567869
p02695
python
s448245210
s299554157
1,353
1,010
9,212
9,108
Accepted
Accepted
25.35
import itertools n, m, q = list(map(int, input().split())) l = [] ans = 0 ref = 0 for i in range(q): abcd = list(map(int, input().split())) l.append(abcd) for i in itertools.combinations_with_replacement(list(range(1, m + 1)), n): for j in range(q): if i[l[j][1] - 1] - i[l[j][0] - 1] == l[j][2]: ref += l[j][3] ans = max(ans, ref) ref = 0 print(ans)
import itertools n, m, q = list(map(int, input().split())) l = [] ans = 0 ref = 0 for i in range(q): abcd = list(map(int, input().split())) l.append(abcd) for i in itertools.combinations_with_replacement(list(range(1, m + 1)), n): for a, b, c, d in l: if i[b - 1] - i[a - 1] == c: ref += d ans = max(ans, ref) ref = 0 print(ans)
19
19
404
378
import itertools n, m, q = list(map(int, input().split())) l = [] ans = 0 ref = 0 for i in range(q): abcd = list(map(int, input().split())) l.append(abcd) for i in itertools.combinations_with_replacement(list(range(1, m + 1)), n): for j in range(q): if i[l[j][1] - 1] - i[l[j][0] - 1] == l[j][2]: ref += l[j][3] ans = max(ans, ref) ref = 0 print(ans)
import itertools n, m, q = list(map(int, input().split())) l = [] ans = 0 ref = 0 for i in range(q): abcd = list(map(int, input().split())) l.append(abcd) for i in itertools.combinations_with_replacement(list(range(1, m + 1)), n): for a, b, c, d in l: if i[b - 1] - i[a - 1] == c: ref += d ans = max(ans, ref) ref = 0 print(ans)
false
0
[ "- for j in range(q):", "- if i[l[j][1] - 1] - i[l[j][0] - 1] == l[j][2]:", "- ref += l[j][3]", "+ for a, b, c, d in l:", "+ if i[b - 1] - i[a - 1] == c:", "+ ref += d" ]
false
0.052233
0.043102
1.211848
[ "s448245210", "s299554157" ]
u063052907
p03698
python
s238900768
s186294076
25
17
2,940
2,940
Accepted
Accepted
32
# coding: utf-8 import sys S = eval(input()) for s in S: if S.count(s)!=1: print("no") sys.exit() print("yes")
# coding: utf-8 S = eval(input()) print(("yes" if len(S)==len(set(S)) else "no"))
9
3
134
75
# coding: utf-8 import sys S = eval(input()) for s in S: if S.count(s) != 1: print("no") sys.exit() print("yes")
# coding: utf-8 S = eval(input()) print(("yes" if len(S) == len(set(S)) else "no"))
false
66.666667
[ "-import sys", "-", "-for s in S:", "- if S.count(s) != 1:", "- print(\"no\")", "- sys.exit()", "-print(\"yes\")", "+print((\"yes\" if len(S) == len(set(S)) else \"no\"))" ]
false
0.045529
0.045974
0.990302
[ "s238900768", "s186294076" ]
u790012205
p03632
python
s371811804
s485409610
181
18
38,384
2,940
Accepted
Accepted
90.06
import sys A, B, C, D = list(map(int, input().split())) s, g = 0, 0 if A <= C: s = C if B < s: print((0)) sys.exit() else: s = A if D < s: print((0)) sys.exit() if B <= D: g = B else: g = D print((g - s))
A, B, C, D = list(map(int, input().split())) if B <= C or D <= A: print((0)) elif A <= C: if B <= D: print((B - C)) else: print((D - C)) else: if D <= B: print((D - A)) else: print((B - A))
20
13
269
238
import sys A, B, C, D = list(map(int, input().split())) s, g = 0, 0 if A <= C: s = C if B < s: print((0)) sys.exit() else: s = A if D < s: print((0)) sys.exit() if B <= D: g = B else: g = D print((g - s))
A, B, C, D = list(map(int, input().split())) if B <= C or D <= A: print((0)) elif A <= C: if B <= D: print((B - C)) else: print((D - C)) else: if D <= B: print((D - A)) else: print((B - A))
false
35
[ "-import sys", "-", "-s, g = 0, 0", "-if A <= C:", "- s = C", "- if B < s:", "- print((0))", "- sys.exit()", "+if B <= C or D <= A:", "+ print((0))", "+elif A <= C:", "+ if B <= D:", "+ print((B - C))", "+ else:", "+ print((D - C))", "- s = A", "- if D < s:", "- print((0))", "- sys.exit()", "-if B <= D:", "- g = B", "-else:", "- g = D", "-print((g - s))", "+ if D <= B:", "+ print((D - A))", "+ else:", "+ print((B - A))" ]
false
0.083024
0.063684
1.303699
[ "s371811804", "s485409610" ]
u688587139
p02713
python
s455080155
s167472865
1,016
40
9,520
9,092
Accepted
Accepted
96.06
import math from functools import reduce K = int(eval(input())) total = 0 def gcd_list(*numbers): return reduce(math.gcd, numbers) for i in range(1, K+1): for j in range(1, i+1): for k in range(1, j+1): s = [i, j, k] if i == j == k: total += gcd_list(*s) elif i == j and j != k: total += gcd_list(*s) * 3 elif i != j and j == k: total += gcd_list(*s) * 3 else: total += gcd_list(*s) * 6 print(total)
import math K = int(eval(input())) ans = 0 tmp = {} for i in range(201): tmp[i] = 0 for i in range(1, K+1): for j in range(1, K+1): tmp[math.gcd(i, j)] += 1 for k in range(1, K+1): for key in list(tmp.keys()): ans += math.gcd(key, k) * tmp[key] print(ans)
25
17
564
292
import math from functools import reduce K = int(eval(input())) total = 0 def gcd_list(*numbers): return reduce(math.gcd, numbers) for i in range(1, K + 1): for j in range(1, i + 1): for k in range(1, j + 1): s = [i, j, k] if i == j == k: total += gcd_list(*s) elif i == j and j != k: total += gcd_list(*s) * 3 elif i != j and j == k: total += gcd_list(*s) * 3 else: total += gcd_list(*s) * 6 print(total)
import math K = int(eval(input())) ans = 0 tmp = {} for i in range(201): tmp[i] = 0 for i in range(1, K + 1): for j in range(1, K + 1): tmp[math.gcd(i, j)] += 1 for k in range(1, K + 1): for key in list(tmp.keys()): ans += math.gcd(key, k) * tmp[key] print(ans)
false
32
[ "-from functools import reduce", "-total = 0", "-", "-", "-def gcd_list(*numbers):", "- return reduce(math.gcd, numbers)", "-", "-", "+ans = 0", "+tmp = {}", "+for i in range(201):", "+ tmp[i] = 0", "- for j in range(1, i + 1):", "- for k in range(1, j + 1):", "- s = [i, j, k]", "- if i == j == k:", "- total += gcd_list(*s)", "- elif i == j and j != k:", "- total += gcd_list(*s) * 3", "- elif i != j and j == k:", "- total += gcd_list(*s) * 3", "- else:", "- total += gcd_list(*s) * 6", "-print(total)", "+ for j in range(1, K + 1):", "+ tmp[math.gcd(i, j)] += 1", "+for k in range(1, K + 1):", "+ for key in list(tmp.keys()):", "+ ans += math.gcd(key, k) * tmp[key]", "+print(ans)" ]
false
0.122443
0.040667
3.010896
[ "s455080155", "s167472865" ]
u641460756
p03135
python
s621036962
s199680344
19
17
3,060
2,940
Accepted
Accepted
10.53
a=list(input().split()) T=int(a[0]) X=int(a[1]) print(("{:.5f}".format(T/X)))
a,b=list(input().split()) T=int(a) X=int(b) print((T/X))
4
4
78
57
a = list(input().split()) T = int(a[0]) X = int(a[1]) print(("{:.5f}".format(T / X)))
a, b = list(input().split()) T = int(a) X = int(b) print((T / X))
false
0
[ "-a = list(input().split())", "-T = int(a[0])", "-X = int(a[1])", "-print((\"{:.5f}\".format(T / X)))", "+a, b = list(input().split())", "+T = int(a)", "+X = int(b)", "+print((T / X))" ]
false
0.043174
0.043891
0.983677
[ "s621036962", "s199680344" ]
u761529120
p02936
python
s401210280
s321007404
1,780
751
106,132
93,588
Accepted
Accepted
57.81
from collections import deque def bfs(N, d, ans): Q = deque([0]) visited = [False] * N visited[0] = True while Q: q = Q.popleft() for p in d[q]: if visited[p]: continue visited[p] = True Q.append(p) ans[p] += ans[q] return ans def main(): N, Q = list(map(int, input().split())) d = [[] for _ in range(N)] for i in range(N-1): a, b = list(map(int, input().split())) a -= 1 b -= 1 d[a].append(b) d[b].append(a) ans = [0] * N for _ in range(Q): p, x = list(map(int, input().split())) p -= 1 ans[p] += x print((*bfs(N, d, ans))) main()
import sys from collections import deque input = sys.stdin.readline def main(): N, Q = list(map(int, input().split())) edge = [[] for _ in range(N)] for _ in range(N-1): a, b = list(map(int, input().split())) a -= 1 b -= 1 edge[a].append(b) edge[b].append(a) ans = [0] * N for _ in range(Q): p, x = list(map(int, input().split())) p -= 1 ans[p] += x visited = [False] * N Q = deque() Q.append(0) while Q: v = Q.popleft() visited[v] = True for d in edge[v]: if visited[d]: continue Q.append(d) ans[d] += ans[v] print((*ans)) if __name__ == "__main__": main()
40
37
752
772
from collections import deque def bfs(N, d, ans): Q = deque([0]) visited = [False] * N visited[0] = True while Q: q = Q.popleft() for p in d[q]: if visited[p]: continue visited[p] = True Q.append(p) ans[p] += ans[q] return ans def main(): N, Q = list(map(int, input().split())) d = [[] for _ in range(N)] for i in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 d[a].append(b) d[b].append(a) ans = [0] * N for _ in range(Q): p, x = list(map(int, input().split())) p -= 1 ans[p] += x print((*bfs(N, d, ans))) main()
import sys from collections import deque input = sys.stdin.readline def main(): N, Q = list(map(int, input().split())) edge = [[] for _ in range(N)] for _ in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 edge[a].append(b) edge[b].append(a) ans = [0] * N for _ in range(Q): p, x = list(map(int, input().split())) p -= 1 ans[p] += x visited = [False] * N Q = deque() Q.append(0) while Q: v = Q.popleft() visited[v] = True for d in edge[v]: if visited[d]: continue Q.append(d) ans[d] += ans[v] print((*ans)) if __name__ == "__main__": main()
false
7.5
[ "+import sys", "-", "-def bfs(N, d, ans):", "- Q = deque([0])", "- visited = [False] * N", "- visited[0] = True", "- while Q:", "- q = Q.popleft()", "- for p in d[q]:", "- if visited[p]:", "- continue", "- visited[p] = True", "- Q.append(p)", "- ans[p] += ans[q]", "- return ans", "+input = sys.stdin.readline", "- d = [[] for _ in range(N)]", "- for i in range(N - 1):", "+ edge = [[] for _ in range(N)]", "+ for _ in range(N - 1):", "- d[a].append(b)", "- d[b].append(a)", "+ edge[a].append(b)", "+ edge[b].append(a)", "- print((*bfs(N, d, ans)))", "+ visited = [False] * N", "+ Q = deque()", "+ Q.append(0)", "+ while Q:", "+ v = Q.popleft()", "+ visited[v] = True", "+ for d in edge[v]:", "+ if visited[d]:", "+ continue", "+ Q.append(d)", "+ ans[d] += ans[v]", "+ print((*ans))", "-main()", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.035412
0.035447
0.999015
[ "s401210280", "s321007404" ]
u644907318
p03032
python
s788362708
s481489314
101
80
74,644
74,048
Accepted
Accepted
20.79
N,K = list(map(int,input().split())) V = list(map(int,input().split())) vmax = 0 for i in range(K+1): for j in range(K-i+1): cnt = sum(V[:j]) A = V[:j] n = N-(K-i-j) if n>=j: cnt += sum(V[n:]) A += V[n:] else: cnt += sum(V[j:]) A += V[j:] A = sorted(A) B = [] for k in range(i): if k<len(A) and A[k]<0: B.append(k) for k in B: cnt -= A[k] vmax = max(vmax,cnt) print(vmax)
from bisect import bisect_left N,K = list(map(int,input().split())) V = list(map(int,input().split())) vmax = -10**9 for n in range(min(N,K)+1): A = V[:n] for m in range(min(N,K)-n+1): B = V[N-m:] B = sorted(A+B) ind = bisect_left(B,0) k = min(K-m-n,ind) cnt = sum(B[k:]) vmax = max(vmax,cnt) print(vmax)
23
14
559
367
N, K = list(map(int, input().split())) V = list(map(int, input().split())) vmax = 0 for i in range(K + 1): for j in range(K - i + 1): cnt = sum(V[:j]) A = V[:j] n = N - (K - i - j) if n >= j: cnt += sum(V[n:]) A += V[n:] else: cnt += sum(V[j:]) A += V[j:] A = sorted(A) B = [] for k in range(i): if k < len(A) and A[k] < 0: B.append(k) for k in B: cnt -= A[k] vmax = max(vmax, cnt) print(vmax)
from bisect import bisect_left N, K = list(map(int, input().split())) V = list(map(int, input().split())) vmax = -(10**9) for n in range(min(N, K) + 1): A = V[:n] for m in range(min(N, K) - n + 1): B = V[N - m :] B = sorted(A + B) ind = bisect_left(B, 0) k = min(K - m - n, ind) cnt = sum(B[k:]) vmax = max(vmax, cnt) print(vmax)
false
39.130435
[ "+from bisect import bisect_left", "+", "-vmax = 0", "-for i in range(K + 1):", "- for j in range(K - i + 1):", "- cnt = sum(V[:j])", "- A = V[:j]", "- n = N - (K - i - j)", "- if n >= j:", "- cnt += sum(V[n:])", "- A += V[n:]", "- else:", "- cnt += sum(V[j:])", "- A += V[j:]", "- A = sorted(A)", "- B = []", "- for k in range(i):", "- if k < len(A) and A[k] < 0:", "- B.append(k)", "- for k in B:", "- cnt -= A[k]", "+vmax = -(10**9)", "+for n in range(min(N, K) + 1):", "+ A = V[:n]", "+ for m in range(min(N, K) - n + 1):", "+ B = V[N - m :]", "+ B = sorted(A + B)", "+ ind = bisect_left(B, 0)", "+ k = min(K - m - n, ind)", "+ cnt = sum(B[k:])" ]
false
0.03768
0.039342
0.957758
[ "s788362708", "s481489314" ]
u923662841
p03495
python
s681590646
s501788267
98
86
35,332
39,772
Accepted
Accepted
12.24
from collections import Counter N,K = list(map(int, input().split())) A = Counter(list(map(int, input().split()))) B = list(A.values()) k = len(B) - K if k <= 0: print((0)) else: print((sum(sorted(B)[0:k])))
from collections import Counter N,K = list(map(int, input().split())) A = Counter(input().split()) B = list(A.values()) k = len(B) - K if k <= 0: print((0)) else: print((sum(sorted(B)[0:k])))
9
9
207
191
from collections import Counter N, K = list(map(int, input().split())) A = Counter(list(map(int, input().split()))) B = list(A.values()) k = len(B) - K if k <= 0: print((0)) else: print((sum(sorted(B)[0:k])))
from collections import Counter N, K = list(map(int, input().split())) A = Counter(input().split()) B = list(A.values()) k = len(B) - K if k <= 0: print((0)) else: print((sum(sorted(B)[0:k])))
false
0
[ "-A = Counter(list(map(int, input().split())))", "+A = Counter(input().split())" ]
false
0.046792
0.039875
1.173445
[ "s681590646", "s501788267" ]
u391819434
p02939
python
s447194203
s072573181
115
63
6,308
3,500
Accepted
Accepted
45.22
S=list(eval(input())) S=['_']+S i=1 ans=0 while i<=len(S)-3: ans+=1 if S[i-1]==S[i]: S[i+1]='_' i+=1 i+=1 if len(S)==2: ans+=1 elif len(S)-i==1: ans+=1 elif S[i-1]!=S[i] and S[i]!=S[i+1]: ans+=2 else: ans+=1 print(ans)
ans=0 S=T='' for i in eval(input()): S+=i if S!=T: ans+=1 S,T='',S print(ans)
21
8
278
102
S = list(eval(input())) S = ["_"] + S i = 1 ans = 0 while i <= len(S) - 3: ans += 1 if S[i - 1] == S[i]: S[i + 1] = "_" i += 1 i += 1 if len(S) == 2: ans += 1 elif len(S) - i == 1: ans += 1 elif S[i - 1] != S[i] and S[i] != S[i + 1]: ans += 2 else: ans += 1 print(ans)
ans = 0 S = T = "" for i in eval(input()): S += i if S != T: ans += 1 S, T = "", S print(ans)
false
61.904762
[ "-S = list(eval(input()))", "-S = [\"_\"] + S", "-i = 1", "-while i <= len(S) - 3:", "- ans += 1", "- if S[i - 1] == S[i]:", "- S[i + 1] = \"_\"", "- i += 1", "- i += 1", "-if len(S) == 2:", "- ans += 1", "-elif len(S) - i == 1:", "- ans += 1", "-elif S[i - 1] != S[i] and S[i] != S[i + 1]:", "- ans += 2", "-else:", "- ans += 1", "+S = T = \"\"", "+for i in eval(input()):", "+ S += i", "+ if S != T:", "+ ans += 1", "+ S, T = \"\", S" ]
false
0.052427
0.080341
0.652561
[ "s447194203", "s072573181" ]
u585963734
p02608
python
s821205579
s943587324
1,410
753
78,488
78,744
Accepted
Accepted
46.6
import sys import itertools as itr readline = sys.stdin.buffer.readline N=int(readline()) n=int(pow(N,0.5)) chk=list(itr.product(list(range(1,n)),repeat=3)) cnt=[0]*(N+1) for _ in range(len(chk)): i=chk[_][0] j=chk[_][1] k=chk[_][2] if pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i<=N: cnt[pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i]+=1 for i in range(1,N+1): print((cnt[i]))
import sys import itertools as itr readline = sys.stdin.buffer.readline N=int(readline()) n=int(pow(N,0.5)) chk=list(itr.product(list(range(1,n)),repeat=3)) cnt=[0]*(N+1) for c in chk: i=c[0] j=c[1] k=c[2] if i*i+j*j+k*k+i*j+j*k+k*i<=N: cnt[i*i+j*j+k*k+i*j+j*k+k*i]+=1 for i in range(1,N+1): print((cnt[i]))
20
15
404
327
import sys import itertools as itr readline = sys.stdin.buffer.readline N = int(readline()) n = int(pow(N, 0.5)) chk = list(itr.product(list(range(1, n)), repeat=3)) cnt = [0] * (N + 1) for _ in range(len(chk)): i = chk[_][0] j = chk[_][1] k = chk[_][2] if pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + k * i <= N: cnt[pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + k * i] += 1 for i in range(1, N + 1): print((cnt[i]))
import sys import itertools as itr readline = sys.stdin.buffer.readline N = int(readline()) n = int(pow(N, 0.5)) chk = list(itr.product(list(range(1, n)), repeat=3)) cnt = [0] * (N + 1) for c in chk: i = c[0] j = c[1] k = c[2] if i * i + j * j + k * k + i * j + j * k + k * i <= N: cnt[i * i + j * j + k * k + i * j + j * k + k * i] += 1 for i in range(1, N + 1): print((cnt[i]))
false
25
[ "-for _ in range(len(chk)):", "- i = chk[_][0]", "- j = chk[_][1]", "- k = chk[_][2]", "- if pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + k * i <= N:", "- cnt[pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + k * i] += 1", "+for c in chk:", "+ i = c[0]", "+ j = c[1]", "+ k = c[2]", "+ if i * i + j * j + k * k + i * j + j * k + k * i <= N:", "+ cnt[i * i + j * j + k * k + i * j + j * k + k * i] += 1" ]
false
0.049167
0.007013
7.011113
[ "s821205579", "s943587324" ]
u088552457
p03131
python
s468630348
s753187322
142
72
77,168
61,876
Accepted
Accepted
49.3
# import sys # input = sys.stdin.readline # import re import collections import bisect import math import fractions import collections import itertools from functools import reduce def main(): k, a, b = input_list() if b - a > 2: bis = a k -= a - 1 if k % 2 == 1: bis += 1 k -= 1 bis += (k//2)*(b-a) print(bis) else: print((k+1)) def input_list(): return list(map(int, input().split())) def input_list_str(): return list(map(str, input().split())) if __name__ == '__main__': main()
def main(): k, a, b = input_list() # ใŸใŸใใƒซใƒผใƒˆ๏ผ‘ๆ‰‹๏ผ‘ๆžšๅข—ใˆใ‚‹ # ไบคๆ›ใƒซใƒผใƒˆใฏ2ๆ‰‹ๅฟ…่ฆ if b - a > 2: # bisketใ‚’Aๆžšใซใ™ใ‚‹ bis = a k -= a - 1 if k % 2 == 1: bis += 1 k -= 1 bis += (k//2) * (b-a) print(bis) else: print((k+1)) def input_list(): return list(map(int, input().split())) if __name__ == "__main__": main()
36
23
619
419
# import sys # input = sys.stdin.readline # import re import collections import bisect import math import fractions import collections import itertools from functools import reduce def main(): k, a, b = input_list() if b - a > 2: bis = a k -= a - 1 if k % 2 == 1: bis += 1 k -= 1 bis += (k // 2) * (b - a) print(bis) else: print((k + 1)) def input_list(): return list(map(int, input().split())) def input_list_str(): return list(map(str, input().split())) if __name__ == "__main__": main()
def main(): k, a, b = input_list() # ใŸใŸใใƒซใƒผใƒˆ๏ผ‘ๆ‰‹๏ผ‘ๆžšๅข—ใˆใ‚‹ # ไบคๆ›ใƒซใƒผใƒˆใฏ2ๆ‰‹ๅฟ…่ฆ if b - a > 2: # bisketใ‚’Aๆžšใซใ™ใ‚‹ bis = a k -= a - 1 if k % 2 == 1: bis += 1 k -= 1 bis += (k // 2) * (b - a) print(bis) else: print((k + 1)) def input_list(): return list(map(int, input().split())) if __name__ == "__main__": main()
false
36.111111
[ "-# import sys", "-# input = sys.stdin.readline", "-# import re", "-import collections", "-import bisect", "-import math", "-import fractions", "-import collections", "-import itertools", "-from functools import reduce", "-", "-", "+ # ใŸใŸใใƒซใƒผใƒˆ๏ผ‘ๆ‰‹๏ผ‘ๆžšๅข—ใˆใ‚‹", "+ # ไบคๆ›ใƒซใƒผใƒˆใฏ2ๆ‰‹ๅฟ…่ฆ", "+ # bisketใ‚’Aๆžšใซใ™ใ‚‹", "-def input_list_str():", "- return list(map(str, input().split()))", "-", "-" ]
false
0.088467
0.072404
1.221855
[ "s468630348", "s753187322" ]
u644907318
p04020
python
s906903312
s808448293
569
175
55,128
80,752
Accepted
Accepted
69.24
N = int(eval(input())) A = [] a = [] for i in range(N): x = int(eval(input())) if x==0: b = a[:] A.append(b) a = [] else: a.append(x) A.append(a) cnt = 0 for a in A: c = sum(a) cnt += c//2 print(cnt)
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] cnt = 0 for i in range(N): if A[i]%2==1: cnt += A[i]//2 A[i] = 1 else: a = A[i]//2 if a>0: cnt += a-1 A[i] = 2 for i in range(1,N): if A[i-1]!=1: cnt += A[i-1]//2+A[i]//2 A[i-1]=0 A[i]=A[i]%2 elif A[i-1]==1 and A[i]>=1: cnt += 1 A[i-1]=0 A[i] -= 1 if N==1: cnt = A[0]//2 print(cnt)
17
24
255
482
N = int(eval(input())) A = [] a = [] for i in range(N): x = int(eval(input())) if x == 0: b = a[:] A.append(b) a = [] else: a.append(x) A.append(a) cnt = 0 for a in A: c = sum(a) cnt += c // 2 print(cnt)
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] cnt = 0 for i in range(N): if A[i] % 2 == 1: cnt += A[i] // 2 A[i] = 1 else: a = A[i] // 2 if a > 0: cnt += a - 1 A[i] = 2 for i in range(1, N): if A[i - 1] != 1: cnt += A[i - 1] // 2 + A[i] // 2 A[i - 1] = 0 A[i] = A[i] % 2 elif A[i - 1] == 1 and A[i] >= 1: cnt += 1 A[i - 1] = 0 A[i] -= 1 if N == 1: cnt = A[0] // 2 print(cnt)
false
29.166667
[ "-A = []", "-a = []", "+A = [int(eval(input())) for _ in range(N)]", "+cnt = 0", "- x = int(eval(input()))", "- if x == 0:", "- b = a[:]", "- A.append(b)", "- a = []", "+ if A[i] % 2 == 1:", "+ cnt += A[i] // 2", "+ A[i] = 1", "- a.append(x)", "-A.append(a)", "-cnt = 0", "-for a in A:", "- c = sum(a)", "- cnt += c // 2", "+ a = A[i] // 2", "+ if a > 0:", "+ cnt += a - 1", "+ A[i] = 2", "+for i in range(1, N):", "+ if A[i - 1] != 1:", "+ cnt += A[i - 1] // 2 + A[i] // 2", "+ A[i - 1] = 0", "+ A[i] = A[i] % 2", "+ elif A[i - 1] == 1 and A[i] >= 1:", "+ cnt += 1", "+ A[i - 1] = 0", "+ A[i] -= 1", "+if N == 1:", "+ cnt = A[0] // 2" ]
false
0.045911
0.080186
0.572556
[ "s906903312", "s808448293" ]
u724687935
p02596
python
s409039643
s911022944
1,769
188
9,196
9,104
Accepted
Accepted
89.37
K = int(eval(input())) if K % 2 == 0 or K % 5 == 0: print((-1)) exit() i = 0 sevens = 0 while True: sevens += 7 * pow(10, i, K) sevens %= K i += 1 if sevens == 0: break print(i)
K = int(eval(input())) if K % 2 == 0 or K % 5 == 0: print((-1)) exit() i = 0 ai = 0 while True: ai = (ai * 10 + 7) % K i += 1 if ai == 0: break print(i)
15
14
218
188
K = int(eval(input())) if K % 2 == 0 or K % 5 == 0: print((-1)) exit() i = 0 sevens = 0 while True: sevens += 7 * pow(10, i, K) sevens %= K i += 1 if sevens == 0: break print(i)
K = int(eval(input())) if K % 2 == 0 or K % 5 == 0: print((-1)) exit() i = 0 ai = 0 while True: ai = (ai * 10 + 7) % K i += 1 if ai == 0: break print(i)
false
6.666667
[ "-sevens = 0", "+ai = 0", "- sevens += 7 * pow(10, i, K)", "- sevens %= K", "+ ai = (ai * 10 + 7) % K", "- if sevens == 0:", "+ if ai == 0:" ]
false
0.45842
0.074921
6.118666
[ "s409039643", "s911022944" ]
u860829879
p02598
python
s889940192
s097601101
200
182
103,928
104,096
Accepted
Accepted
9
n,k=list(map(int,input().split())) alst=list([int(x)*100 for x in input().split()]) ok=max(alst) ng=0 while abs(ok-ng)>1: cen=(ok+ng)//2 cnt=0 for a in alst: cnt+=(a+cen-1)//cen-1 if cnt<=k: ok=cen else: ng=cen+1 if ok%100==0: print((ok//100)) else: print((ok//100+1))
n,k=list(map(int,input().split())) alst=list(map(int,input().split())) ok=max(alst) ng=0 while abs(ok-ng)>1: cen=(ok+ng)//2 cnt=0 for a in alst: cnt+=(a+cen-1)//cen-1 if cnt<=k: ok=cen else: ng=cen print(ok)
23
20
347
276
n, k = list(map(int, input().split())) alst = list([int(x) * 100 for x in input().split()]) ok = max(alst) ng = 0 while abs(ok - ng) > 1: cen = (ok + ng) // 2 cnt = 0 for a in alst: cnt += (a + cen - 1) // cen - 1 if cnt <= k: ok = cen else: ng = cen + 1 if ok % 100 == 0: print((ok // 100)) else: print((ok // 100 + 1))
n, k = list(map(int, input().split())) alst = list(map(int, input().split())) ok = max(alst) ng = 0 while abs(ok - ng) > 1: cen = (ok + ng) // 2 cnt = 0 for a in alst: cnt += (a + cen - 1) // cen - 1 if cnt <= k: ok = cen else: ng = cen print(ok)
false
13.043478
[ "-alst = list([int(x) * 100 for x in input().split()])", "+alst = list(map(int, input().split()))", "- ng = cen + 1", "-if ok % 100 == 0:", "- print((ok // 100))", "-else:", "- print((ok // 100 + 1))", "+ ng = cen", "+print(ok)" ]
false
0.109889
0.126618
0.867878
[ "s889940192", "s097601101" ]
u644907318
p03672
python
s561674808
s537870608
181
63
38,384
61,384
Accepted
Accepted
65.19
S = input().strip() N = len(S) for i in range(2,N,2): x = S[:-i] y = x[:(N-i)//2] z = x[(N-i)//2:] if y==z: print((N-i)) break
S = input().strip() N = len(S) for i in range(N//2-1,0,-1): if S[:i]==S[i:2*i]: ans = i break print((ans*2))
9
7
164
132
S = input().strip() N = len(S) for i in range(2, N, 2): x = S[:-i] y = x[: (N - i) // 2] z = x[(N - i) // 2 :] if y == z: print((N - i)) break
S = input().strip() N = len(S) for i in range(N // 2 - 1, 0, -1): if S[:i] == S[i : 2 * i]: ans = i break print((ans * 2))
false
22.222222
[ "-for i in range(2, N, 2):", "- x = S[:-i]", "- y = x[: (N - i) // 2]", "- z = x[(N - i) // 2 :]", "- if y == z:", "- print((N - i))", "+for i in range(N // 2 - 1, 0, -1):", "+ if S[:i] == S[i : 2 * i]:", "+ ans = i", "+print((ans * 2))" ]
false
0.147261
0.044018
3.345462
[ "s561674808", "s537870608" ]
u263830634
p02698
python
s010362402
s928877981
1,317
938
99,084
99,516
Accepted
Accepted
28.78
import sys sys.setrecursionlimit(10 ** 9) from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) root = 0 stack = [root] visited = set() visited.add(root) done = set() vs = [] ans = [0] * N memo = [None] * N memo[root] = (0, A[root]) INF = 10 ** 10 dp = [INF] * N while stack: now_ = stack[-1] if now_ in done: j, a = memo[now_] dp[j] = a stack.pop() vs.append(now_) else: for next_ in G[now_][::-1]: if next_ in visited: continue visited.add(next_) stack.append(next_) done.add(now_) tmp = bisect_left(dp, A[now_]) memo[now_] = (tmp, dp[tmp]) dp[tmp] = A[now_] ans[now_] = bisect_left(dp, INF) # print (vs) print (*ans, sep = '\n')
def main(): import sys input = sys.stdin.readline from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) root = 0 stack = [root] visited = set() visited.add(root) done = set() vs = [] ans = [0] * N memo = [None] * N memo[root] = (0, A[root]) INF = 10 ** 10 dp = [INF] * N while stack: now_ = stack[-1] if now_ in done: j, a = memo[now_] dp[j] = a stack.pop() vs.append(now_) else: for next_ in G[now_][::-1]: if next_ in visited: continue visited.add(next_) stack.append(next_) done.add(now_) tmp = bisect_left(dp, A[now_]) memo[now_] = (tmp, dp[tmp]) dp[tmp] = A[now_] ans[now_] = bisect_left(dp, INF) # print (vs) print (*ans, sep = '\n') if __name__ == '__main__': main()
53
57
1,014
1,237
import sys sys.setrecursionlimit(10**9) from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) root = 0 stack = [root] visited = set() visited.add(root) done = set() vs = [] ans = [0] * N memo = [None] * N memo[root] = (0, A[root]) INF = 10**10 dp = [INF] * N while stack: now_ = stack[-1] if now_ in done: j, a = memo[now_] dp[j] = a stack.pop() vs.append(now_) else: for next_ in G[now_][::-1]: if next_ in visited: continue visited.add(next_) stack.append(next_) done.add(now_) tmp = bisect_left(dp, A[now_]) memo[now_] = (tmp, dp[tmp]) dp[tmp] = A[now_] ans[now_] = bisect_left(dp, INF) # print (vs) print(*ans, sep="\n")
def main(): import sys input = sys.stdin.readline from bisect import bisect_left N = int(input()) A = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) root = 0 stack = [root] visited = set() visited.add(root) done = set() vs = [] ans = [0] * N memo = [None] * N memo[root] = (0, A[root]) INF = 10**10 dp = [INF] * N while stack: now_ = stack[-1] if now_ in done: j, a = memo[now_] dp[j] = a stack.pop() vs.append(now_) else: for next_ in G[now_][::-1]: if next_ in visited: continue visited.add(next_) stack.append(next_) done.add(now_) tmp = bisect_left(dp, A[now_]) memo[now_] = (tmp, dp[tmp]) dp[tmp] = A[now_] ans[now_] = bisect_left(dp, INF) # print (vs) print(*ans, sep="\n") if __name__ == "__main__": main()
false
7.017544
[ "-import sys", "+def main():", "+ import sys", "-sys.setrecursionlimit(10**9)", "-from bisect import bisect_left", "+ input = sys.stdin.readline", "+ from bisect import bisect_left", "-N = int(input())", "-A = list(map(int, input().split()))", "-G = [[] for _ in range(N)]", "-for _ in range(N - 1):", "- u, v = map(int, input().split())", "- u -= 1", "- v -= 1", "- G[u].append(v)", "- G[v].append(u)", "-root = 0", "-stack = [root]", "-visited = set()", "-visited.add(root)", "-done = set()", "-vs = []", "-ans = [0] * N", "-memo = [None] * N", "-memo[root] = (0, A[root])", "-INF = 10**10", "-dp = [INF] * N", "-while stack:", "- now_ = stack[-1]", "- if now_ in done:", "- j, a = memo[now_]", "- dp[j] = a", "- stack.pop()", "- vs.append(now_)", "- else:", "- for next_ in G[now_][::-1]:", "- if next_ in visited:", "- continue", "- visited.add(next_)", "- stack.append(next_)", "- done.add(now_)", "- tmp = bisect_left(dp, A[now_])", "- memo[now_] = (tmp, dp[tmp])", "- dp[tmp] = A[now_]", "- ans[now_] = bisect_left(dp, INF)", "-# print (vs)", "-print(*ans, sep=\"\\n\")", "+ N = int(input())", "+ A = list(map(int, input().split()))", "+ G = [[] for _ in range(N)]", "+ for _ in range(N - 1):", "+ u, v = map(int, input().split())", "+ u -= 1", "+ v -= 1", "+ G[u].append(v)", "+ G[v].append(u)", "+ root = 0", "+ stack = [root]", "+ visited = set()", "+ visited.add(root)", "+ done = set()", "+ vs = []", "+ ans = [0] * N", "+ memo = [None] * N", "+ memo[root] = (0, A[root])", "+ INF = 10**10", "+ dp = [INF] * N", "+ while stack:", "+ now_ = stack[-1]", "+ if now_ in done:", "+ j, a = memo[now_]", "+ dp[j] = a", "+ stack.pop()", "+ vs.append(now_)", "+ else:", "+ for next_ in G[now_][::-1]:", "+ if next_ in visited:", "+ continue", "+ visited.add(next_)", "+ stack.append(next_)", "+ done.add(now_)", "+ tmp = bisect_left(dp, A[now_])", "+ memo[now_] = (tmp, dp[tmp])", "+ dp[tmp] = A[now_]", "+ ans[now_] = bisect_left(dp, INF)", "+ # print (vs)", "+ print(*ans, sep=\"\\n\")", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.04957
0.049781
0.995761
[ "s010362402", "s928877981" ]
u532966492
p02867
python
s705788234
s694750264
1,956
1,742
25,136
24,920
Accepted
Accepted
10.94
def main(): n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) ab = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1]) num=1 while num < n: num *= 2 num-=1 inf=10**9+1 m=num+n segtree=[inf]*m for i in range(num,m): segtree[i] = ab[i - num][0] for i in range(num-1,-1,-1): j=2*i+1 if j>=m: segtree[i]=inf elif j+1>=m: segtree[i]=segtree[j] else: segtree[i] = min(segtree[j], segtree[j + 1]) #ๆŽขใ™ def search(i, s): if i >= num: return i - num k = 2 * i + 1 if k+2<=m: if segtree[k+1] <= s: return search(k+1, s) if 2*i+2<=m: if segtree[k] <= s: return search(k, s) return -1 #ๆ›ดๆ–ฐ def update_good(i, s): if segtree[i] > s: segtree[i] = s update_good((i - 1) // 2, s) def update_bad(i): k=(i - 1) // 2 if i % 2 == 1: if m > i + 1: temp=min(segtree[i+1],segtree[i]) if segtree[k]<temp: segtree[k] = temp update_bad(k) else: segtree[k] = segtree[i] update_bad(k) else: if i != 0: temp=min(segtree[i-1],segtree[i]) if segtree[k]<temp: segtree[k] = temp update_bad(k) cnt = 0 for i in range(n): a,b=ab[i][0],ab[i][1] if a > b: t = search(0, b) if t <= i: print("No") return 0 update_good(num + i, a) segtree[num + t] = a update_bad(num + t) ab[i][0], ab[t][0] = ab[t][0], a cnt+=1 if cnt <= n - 2: print("Yes") else: print("No") main()
def main(): n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) ab = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1]) num=1 while num < n: num *= 2 num-=1 inf=10**9+1 m=num+n segtree=[inf]*m for i in range(num,m): segtree[i] = ab[i - num][0] for i in range(num-1,-1,-1): j=2*i+1 if j>=m: segtree[i]=inf elif j+1>=m: segtree[i]=segtree[j] else: segtree[i] = min(segtree[j], segtree[j + 1]) #ๆŽขใ™ def search(s): i=0 while i < num: k = 2 * i + 1 if k+2<=m: if segtree[k+1] <= s: i = k + 1 continue if k+1<=m: if segtree[k] <= s: i = k continue return - 1 return i - num #ๆ›ดๆ–ฐ def update_good(i, s): if segtree[i] > s: segtree[i] = s update_good((i - 1) // 2, s) def update_bad(i): k=(i - 1) // 2 if i % 2 == 1: if m > i + 1: temp=min(segtree[i+1],segtree[i]) if segtree[k]<temp: segtree[k] = temp update_bad(k) else: segtree[k] = segtree[i] update_bad(k) else: if i != 0: temp=min(segtree[i-1],segtree[i]) if segtree[k]<temp: segtree[k] = temp update_bad(k) cnt = 0 for i in range(n): a,b=ab[i][0],ab[i][1] if a > b: t = search(b) if t <= i: print("No") return 0 update_good(num + i, a) segtree[num + t] = a update_bad(num + t) ab[i][0], ab[t][0] = ab[t][0], a cnt+=1 if cnt <= n - 2: print("Yes") else: print("No") main()
81
84
2,064
2,134
def main(): n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) ab = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1]) num = 1 while num < n: num *= 2 num -= 1 inf = 10**9 + 1 m = num + n segtree = [inf] * m for i in range(num, m): segtree[i] = ab[i - num][0] for i in range(num - 1, -1, -1): j = 2 * i + 1 if j >= m: segtree[i] = inf elif j + 1 >= m: segtree[i] = segtree[j] else: segtree[i] = min(segtree[j], segtree[j + 1]) # ๆŽขใ™ def search(i, s): if i >= num: return i - num k = 2 * i + 1 if k + 2 <= m: if segtree[k + 1] <= s: return search(k + 1, s) if 2 * i + 2 <= m: if segtree[k] <= s: return search(k, s) return -1 # ๆ›ดๆ–ฐ def update_good(i, s): if segtree[i] > s: segtree[i] = s update_good((i - 1) // 2, s) def update_bad(i): k = (i - 1) // 2 if i % 2 == 1: if m > i + 1: temp = min(segtree[i + 1], segtree[i]) if segtree[k] < temp: segtree[k] = temp update_bad(k) else: segtree[k] = segtree[i] update_bad(k) else: if i != 0: temp = min(segtree[i - 1], segtree[i]) if segtree[k] < temp: segtree[k] = temp update_bad(k) cnt = 0 for i in range(n): a, b = ab[i][0], ab[i][1] if a > b: t = search(0, b) if t <= i: print("No") return 0 update_good(num + i, a) segtree[num + t] = a update_bad(num + t) ab[i][0], ab[t][0] = ab[t][0], a cnt += 1 if cnt <= n - 2: print("Yes") else: print("No") main()
def main(): n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) ab = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1]) num = 1 while num < n: num *= 2 num -= 1 inf = 10**9 + 1 m = num + n segtree = [inf] * m for i in range(num, m): segtree[i] = ab[i - num][0] for i in range(num - 1, -1, -1): j = 2 * i + 1 if j >= m: segtree[i] = inf elif j + 1 >= m: segtree[i] = segtree[j] else: segtree[i] = min(segtree[j], segtree[j + 1]) # ๆŽขใ™ def search(s): i = 0 while i < num: k = 2 * i + 1 if k + 2 <= m: if segtree[k + 1] <= s: i = k + 1 continue if k + 1 <= m: if segtree[k] <= s: i = k continue return -1 return i - num # ๆ›ดๆ–ฐ def update_good(i, s): if segtree[i] > s: segtree[i] = s update_good((i - 1) // 2, s) def update_bad(i): k = (i - 1) // 2 if i % 2 == 1: if m > i + 1: temp = min(segtree[i + 1], segtree[i]) if segtree[k] < temp: segtree[k] = temp update_bad(k) else: segtree[k] = segtree[i] update_bad(k) else: if i != 0: temp = min(segtree[i - 1], segtree[i]) if segtree[k] < temp: segtree[k] = temp update_bad(k) cnt = 0 for i in range(n): a, b = ab[i][0], ab[i][1] if a > b: t = search(b) if t <= i: print("No") return 0 update_good(num + i, a) segtree[num + t] = a update_bad(num + t) ab[i][0], ab[t][0] = ab[t][0], a cnt += 1 if cnt <= n - 2: print("Yes") else: print("No") main()
false
3.571429
[ "- def search(i, s):", "- if i >= num:", "- return i - num", "- k = 2 * i + 1", "- if k + 2 <= m:", "- if segtree[k + 1] <= s:", "- return search(k + 1, s)", "- if 2 * i + 2 <= m:", "- if segtree[k] <= s:", "- return search(k, s)", "- return -1", "+ def search(s):", "+ i = 0", "+ while i < num:", "+ k = 2 * i + 1", "+ if k + 2 <= m:", "+ if segtree[k + 1] <= s:", "+ i = k + 1", "+ continue", "+ if k + 1 <= m:", "+ if segtree[k] <= s:", "+ i = k", "+ continue", "+ return -1", "+ return i - num", "- t = search(0, b)", "+ t = search(b)" ]
false
0.137596
0.007535
18.260083
[ "s705788234", "s694750264" ]
u667084803
p04015
python
s726937258
s957879083
514
253
95,964
5,740
Accepted
Accepted
50.78
N,A=list(map(int,input().split())) x=list(map(int,input().split())) dp=[[[0 for i in range(50*50+1)] for j in range(N+1) ]for k in range(N+1)] dp[0][0][0]=1 for i in range(1,N+1): for j in range(N+1): for k in range(50*50+1): dp[i][j][k]=dp[i-1][j][k] if x[i-1]<= k and j>0: dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]] ans=0 for j in range(1,N+1): ans+=dp[N][j][j*A] print(ans)
N,A=list(map(int,input().split())) x=list(map(int,input().split())) X=max(max(x),A) y=[x[i]-A for i in range(N)] dp=[[0 for i in range(2*N*X+1)] for j in range(N+1)] dp[0][N*X]=1 for j in range(1,N+1): for k in range(2*N*X+1): dp[j][k]=dp[j-1][k] if 0<= k-y[j-1] and k-y[j-1]<=2*N*X: dp[j][k]+=dp[j-1][k-y[j-1]] print((dp[N][N*X]-1))
13
12
395
352
N, A = list(map(int, input().split())) x = list(map(int, input().split())) dp = [[[0 for i in range(50 * 50 + 1)] for j in range(N + 1)] for k in range(N + 1)] dp[0][0][0] = 1 for i in range(1, N + 1): for j in range(N + 1): for k in range(50 * 50 + 1): dp[i][j][k] = dp[i - 1][j][k] if x[i - 1] <= k and j > 0: dp[i][j][k] += dp[i - 1][j - 1][k - x[i - 1]] ans = 0 for j in range(1, N + 1): ans += dp[N][j][j * A] print(ans)
N, A = list(map(int, input().split())) x = list(map(int, input().split())) X = max(max(x), A) y = [x[i] - A for i in range(N)] dp = [[0 for i in range(2 * N * X + 1)] for j in range(N + 1)] dp[0][N * X] = 1 for j in range(1, N + 1): for k in range(2 * N * X + 1): dp[j][k] = dp[j - 1][k] if 0 <= k - y[j - 1] and k - y[j - 1] <= 2 * N * X: dp[j][k] += dp[j - 1][k - y[j - 1]] print((dp[N][N * X] - 1))
false
7.692308
[ "-dp = [[[0 for i in range(50 * 50 + 1)] for j in range(N + 1)] for k in range(N + 1)]", "-dp[0][0][0] = 1", "-for i in range(1, N + 1):", "- for j in range(N + 1):", "- for k in range(50 * 50 + 1):", "- dp[i][j][k] = dp[i - 1][j][k]", "- if x[i - 1] <= k and j > 0:", "- dp[i][j][k] += dp[i - 1][j - 1][k - x[i - 1]]", "-ans = 0", "+X = max(max(x), A)", "+y = [x[i] - A for i in range(N)]", "+dp = [[0 for i in range(2 * N * X + 1)] for j in range(N + 1)]", "+dp[0][N * X] = 1", "- ans += dp[N][j][j * A]", "-print(ans)", "+ for k in range(2 * N * X + 1):", "+ dp[j][k] = dp[j - 1][k]", "+ if 0 <= k - y[j - 1] and k - y[j - 1] <= 2 * N * X:", "+ dp[j][k] += dp[j - 1][k - y[j - 1]]", "+print((dp[N][N * X] - 1))" ]
false
0.552042
0.055767
9.89907
[ "s726937258", "s957879083" ]
u041382530
p03030
python
s607649251
s385307401
22
20
3,064
3,064
Accepted
Accepted
9.09
from operator import itemgetter n=int(eval(input())) y,s=list(),list() for i in range(1,n+1): S=input().split() S[1]=int(S[1]) S.append(i) s.append(S) y=sorted(s,key=itemgetter(0)) for i in range(n): for j in range(1,n): if((y[j-1][0]==y[j][0])&(y[j-1][1]<y[j][1])): y[j-1],y[j]=y[j],y[j-1] for i in range(n): print((y[i][2]))
from operator import itemgetter n=int(eval(input())) y,s=list(),list() for i in range(1,n+1): S=input().split() S[1]=int(S[1]) S.append(i) s.append(S) y=sorted(s,key=itemgetter(0)) for i in range(n): c=0 for j in range(1,n): if((y[j-1][0]==y[j][0])&(y[j-1][1]<y[j][1])): y[j-1],y[j]=y[j],y[j-1] c=1 if c==0:break for i in range(n): print((y[i][2]))
14
18
339
373
from operator import itemgetter n = int(eval(input())) y, s = list(), list() for i in range(1, n + 1): S = input().split() S[1] = int(S[1]) S.append(i) s.append(S) y = sorted(s, key=itemgetter(0)) for i in range(n): for j in range(1, n): if (y[j - 1][0] == y[j][0]) & (y[j - 1][1] < y[j][1]): y[j - 1], y[j] = y[j], y[j - 1] for i in range(n): print((y[i][2]))
from operator import itemgetter n = int(eval(input())) y, s = list(), list() for i in range(1, n + 1): S = input().split() S[1] = int(S[1]) S.append(i) s.append(S) y = sorted(s, key=itemgetter(0)) for i in range(n): c = 0 for j in range(1, n): if (y[j - 1][0] == y[j][0]) & (y[j - 1][1] < y[j][1]): y[j - 1], y[j] = y[j], y[j - 1] c = 1 if c == 0: break for i in range(n): print((y[i][2]))
false
22.222222
[ "+ c = 0", "+ c = 1", "+ if c == 0:", "+ break" ]
false
0.040173
0.041431
0.969634
[ "s607649251", "s385307401" ]
u152671129
p03416
python
s393456737
s624482474
55
36
3,060
3,060
Accepted
Accepted
34.55
a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): target = str(i) if target == target[::-1]: count += 1 print(count)
a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): if i//10000 == (i//1) % 10 and (i//1000) % 10 == (i//10) % 10: count += 1 print(count)
9
8
159
174
a, b = list(map(int, input().split())) count = 0 for i in range(a, b + 1): target = str(i) if target == target[::-1]: count += 1 print(count)
a, b = list(map(int, input().split())) count = 0 for i in range(a, b + 1): if i // 10000 == (i // 1) % 10 and (i // 1000) % 10 == (i // 10) % 10: count += 1 print(count)
false
11.111111
[ "- target = str(i)", "- if target == target[::-1]:", "+ if i // 10000 == (i // 1) % 10 and (i // 1000) % 10 == (i // 10) % 10:" ]
false
0.114728
0.04389
2.613958
[ "s393456737", "s624482474" ]
u562935282
p02695
python
s529521362
s252833076
433
219
9,144
43,148
Accepted
Accepted
49.42
def main(): from itertools import combinations_with_replacement N, M, Q = list(map(int, input().split())) conds = [] for _ in range(Q): a, b, c, d = list(map(int, input().split())) a -= 1 b -= 1 conds.append((a, b, c, d)) ans = 0 for temp_A in combinations_with_replacement(iterable=list(range(1, M + 1)), r=N): # print(*temp_A) t = 0 for ai, bi, ci, di in conds: c = temp_A[bi] - temp_A[ai] if c == ci: t += di ans = max(ans, t) print(ans) if __name__ == '__main__': main() # def choose(n, r): # ret = 1 # for i in range(r): # ret *= n - i # for i in range(r): # ret //= (i + 1) # print(ret) # # print(choose(20, 10)) # # 184756
# https://atcoder.jp/contests/abc165/submissions/12605117 # ๅ†™็ตŒ def main(): from itertools import combinations_with_replacement import numpy as np N, M, Q = list(map(int, input().split())) abcd = [] for _ in range(Q): a, b, c, d = list(map(int, input().split())) abcd.append((a - 1, b - 1, c, d)) temp_As = np.array( tuple(combinations_with_replacement( iterable=list(range(1, M + 1)), r=N )), dtype=np.int32 ) scores = np.zeros(len(temp_As), dtype=np.int32) for a, b, c, d in abcd: cond = temp_As[:, b] - temp_As[:, a] == c scores += d * cond print((scores.max())) if __name__ == '__main__': main() # a = np.array([0] * 4) # a += range(4) # # array([0, 1, 2, 3])
37
35
822
802
def main(): from itertools import combinations_with_replacement N, M, Q = list(map(int, input().split())) conds = [] for _ in range(Q): a, b, c, d = list(map(int, input().split())) a -= 1 b -= 1 conds.append((a, b, c, d)) ans = 0 for temp_A in combinations_with_replacement(iterable=list(range(1, M + 1)), r=N): # print(*temp_A) t = 0 for ai, bi, ci, di in conds: c = temp_A[bi] - temp_A[ai] if c == ci: t += di ans = max(ans, t) print(ans) if __name__ == "__main__": main() # def choose(n, r): # ret = 1 # for i in range(r): # ret *= n - i # for i in range(r): # ret //= (i + 1) # print(ret) # # print(choose(20, 10)) # # 184756
# https://atcoder.jp/contests/abc165/submissions/12605117 # ๅ†™็ตŒ def main(): from itertools import combinations_with_replacement import numpy as np N, M, Q = list(map(int, input().split())) abcd = [] for _ in range(Q): a, b, c, d = list(map(int, input().split())) abcd.append((a - 1, b - 1, c, d)) temp_As = np.array( tuple(combinations_with_replacement(iterable=list(range(1, M + 1)), r=N)), dtype=np.int32, ) scores = np.zeros(len(temp_As), dtype=np.int32) for a, b, c, d in abcd: cond = temp_As[:, b] - temp_As[:, a] == c scores += d * cond print((scores.max())) if __name__ == "__main__": main() # a = np.array([0] * 4) # a += range(4) # # array([0, 1, 2, 3])
false
5.405405
[ "+# https://atcoder.jp/contests/abc165/submissions/12605117", "+# ๅ†™็ตŒ", "+ import numpy as np", "- conds = []", "+ abcd = []", "- a -= 1", "- b -= 1", "- conds.append((a, b, c, d))", "- ans = 0", "- for temp_A in combinations_with_replacement(iterable=list(range(1, M + 1)), r=N):", "- # print(*temp_A)", "- t = 0", "- for ai, bi, ci, di in conds:", "- c = temp_A[bi] - temp_A[ai]", "- if c == ci:", "- t += di", "- ans = max(ans, t)", "- print(ans)", "+ abcd.append((a - 1, b - 1, c, d))", "+ temp_As = np.array(", "+ tuple(combinations_with_replacement(iterable=list(range(1, M + 1)), r=N)),", "+ dtype=np.int32,", "+ )", "+ scores = np.zeros(len(temp_As), dtype=np.int32)", "+ for a, b, c, d in abcd:", "+ cond = temp_As[:, b] - temp_As[:, a] == c", "+ scores += d * cond", "+ print((scores.max()))", "-# def choose(n, r):", "-# ret = 1", "-# for i in range(r):", "-# ret *= n - i", "-# for i in range(r):", "-# ret //= (i + 1)", "-# print(ret)", "-#", "-# print(choose(20, 10))", "-# # 184756", "+# a = np.array([0] * 4)", "+# a += range(4)", "+# # array([0, 1, 2, 3])" ]
false
0.057812
0.346841
0.166682
[ "s529521362", "s252833076" ]
u987164499
p02642
python
s254279737
s803357139
1,851
535
145,616
63,208
Accepted
Accepted
71.1
from sys import stdin from sys import setrecursionlimit from collections import Counter from numba import jit setrecursionlimit(10 ** 7) n = int(stdin.readline().rstrip()) a = list(map(int,stdin.readline().rstrip().split())) a.sort() b = list(set(a)) b.sort() c = Counter(a) se = set() @jit def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] for i in b: k = make_divisors(i) flag = True for j in k: if j in se: flag = False break if flag: se.add(i) point = len(se) for i in se: if c[i] > 1: point -= 1 print(point)
import numpy as np from collections import Counter n = int(eval(input())) a = list(map(int,input().split())) a.sort() dp = [0]*(a[-1]+1) dp = np.array(dp,int) for i in a: dp[i] = 1 for i in a: if dp[i] == 1: dp[2*i::i] = 0 c = Counter(a) for i,j in list(c.items()): if j > 1: dp[i] = 0 print((dp.sum()))
45
24
876
347
from sys import stdin from sys import setrecursionlimit from collections import Counter from numba import jit setrecursionlimit(10**7) n = int(stdin.readline().rstrip()) a = list(map(int, stdin.readline().rstrip().split())) a.sort() b = list(set(a)) b.sort() c = Counter(a) se = set() @jit def make_divisors(n): lower_divisors, upper_divisors = [], [] i = 1 while i * i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n // i) i += 1 return lower_divisors + upper_divisors[::-1] for i in b: k = make_divisors(i) flag = True for j in k: if j in se: flag = False break if flag: se.add(i) point = len(se) for i in se: if c[i] > 1: point -= 1 print(point)
import numpy as np from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) a.sort() dp = [0] * (a[-1] + 1) dp = np.array(dp, int) for i in a: dp[i] = 1 for i in a: if dp[i] == 1: dp[2 * i :: i] = 0 c = Counter(a) for i, j in list(c.items()): if j > 1: dp[i] = 0 print((dp.sum()))
false
46.666667
[ "-from sys import stdin", "-from sys import setrecursionlimit", "+import numpy as np", "-from numba import jit", "-setrecursionlimit(10**7)", "-n = int(stdin.readline().rstrip())", "-a = list(map(int, stdin.readline().rstrip().split()))", "+n = int(eval(input()))", "+a = list(map(int, input().split()))", "-b = list(set(a))", "-b.sort()", "+dp = [0] * (a[-1] + 1)", "+dp = np.array(dp, int)", "+for i in a:", "+ dp[i] = 1", "+for i in a:", "+ if dp[i] == 1:", "+ dp[2 * i :: i] = 0", "-se = set()", "-", "-", "-@jit", "-def make_divisors(n):", "- lower_divisors, upper_divisors = [], []", "- i = 1", "- while i * i <= n:", "- if n % i == 0:", "- lower_divisors.append(i)", "- if i != n // i:", "- upper_divisors.append(n // i)", "- i += 1", "- return lower_divisors + upper_divisors[::-1]", "-", "-", "-for i in b:", "- k = make_divisors(i)", "- flag = True", "- for j in k:", "- if j in se:", "- flag = False", "- break", "- if flag:", "- se.add(i)", "-point = len(se)", "-for i in se:", "- if c[i] > 1:", "- point -= 1", "-print(point)", "+for i, j in list(c.items()):", "+ if j > 1:", "+ dp[i] = 0", "+print((dp.sum()))" ]
false
0.036963
0.180255
0.205062
[ "s254279737", "s803357139" ]
u022871813
p03073
python
s052261748
s663747698
53
38
3,188
3,188
Accepted
Accepted
28.3
S = eval(input()) if not S[:-1]: print((0)) else: out1 = out2 = 0 for i, j in enumerate(S): xor = (j == '1') ^ (i % 2) out1 += xor print((out1 if out1 < (i + 1) - out1 else (i + 1) - out1))
s = eval(input()) if len(s) == 1: print((0)) else: r = 0 f = s[0] for i in s[1:]: if i == f: r += 1 f = '1' if i == '0' else '0' else: f = i print(r)
12
13
211
222
S = eval(input()) if not S[:-1]: print((0)) else: out1 = out2 = 0 for i, j in enumerate(S): xor = (j == "1") ^ (i % 2) out1 += xor print((out1 if out1 < (i + 1) - out1 else (i + 1) - out1))
s = eval(input()) if len(s) == 1: print((0)) else: r = 0 f = s[0] for i in s[1:]: if i == f: r += 1 f = "1" if i == "0" else "0" else: f = i print(r)
false
7.692308
[ "-S = eval(input())", "-if not S[:-1]:", "+s = eval(input())", "+if len(s) == 1:", "- out1 = out2 = 0", "- for i, j in enumerate(S):", "- xor = (j == \"1\") ^ (i % 2)", "- out1 += xor", "- print((out1 if out1 < (i + 1) - out1 else (i + 1) - out1))", "+ r = 0", "+ f = s[0]", "+ for i in s[1:]:", "+ if i == f:", "+ r += 1", "+ f = \"1\" if i == \"0\" else \"0\"", "+ else:", "+ f = i", "+ print(r)" ]
false
0.007916
0.037626
0.210392
[ "s052261748", "s663747698" ]
u724687935
p02587
python
s455916479
s372573610
364
131
83,384
75,948
Accepted
Accepted
64.01
from collections import deque def isPalindrome(s): L = len(s) return all(s[i] == s[L - 1 - i] for i in range(L // 2)) N = int(eval(input())) S = [] for _ in range(N): s, c = input().split() S.append((s, int(c))) path = [dict() for _ in range(2)] q = deque() # S.sort(key=lambda x: x[1]) for s, c in S: if s not in path[0] or path[0][s] > c: path[0][s] = c q.append((0, s, c)) INF = 10 ** 15 ans = INF while q: side, s0, c0 = q.popleft() if isPalindrome(s0): ans = min(ans, c0) else: for s1, c1 in S: if side == 0: l, r = s0, s1 else: l, r = s1, s0 L = len(l) R = len(r) isCandidate = False if L > R: if all(l[i] == r[-1 - i] for i in range(R)): ns = l[len(r):] nc = c0 + c1 nside = 0 isCandidate |= True elif L < R: if all(l[i] == r[-1 - i] for i in range(L)): ns = r[:-len(l)] nc = c0 + c1 nside = 1 isCandidate |= True else: if all(l[i] == r[-1 - i] for i in range(L)): ns = '' nc = c0 + c1 nside = 0 isCandidate |= True if isCandidate and (ns not in path[nside] or path[nside][ns] > nc): path[nside][ns] = nc q.append((nside, ns, nc)) if ans < INF: print(ans) else: print((-1))
from collections import deque def isPalindrome(s): L = len(s) return all(s[i] == s[L - 1 - i] for i in range(L // 2)) N = int(eval(input())) S = [] for _ in range(N): s, c = input().split() S.append((s, int(c))) path = [dict() for _ in range(2)] q = deque() S.sort(key=lambda x: x[1]) for s, c in S: if s not in path[0] or path[0][s] > c: path[0][s] = c q.append((0, s, c)) INF = 10 ** 15 ans = INF while q: side, s0, c0 = q.popleft() if isPalindrome(s0): ans = min(ans, c0) else: for s1, c1 in S: if side == 0: l, r = s0, s1 else: l, r = s1, s0 L = len(l) R = len(r) isCandidate = False if L > R: if all(l[i] == r[-1 - i] for i in range(R)): ns = l[len(r):] nc = c0 + c1 nside = 0 isCandidate |= True elif L < R: if all(l[i] == r[-1 - i] for i in range(L)): ns = r[:-len(l)] nc = c0 + c1 nside = 1 isCandidate |= True else: if all(l[i] == r[-1 - i] for i in range(L)): ns = '' nc = c0 + c1 nside = 0 isCandidate |= True if isCandidate and (ns not in path[nside] or path[nside][ns] > nc): path[nside][ns] = nc q.append((nside, ns, nc)) if ans < INF: print(ans) else: print((-1))
63
63
1,674
1,672
from collections import deque def isPalindrome(s): L = len(s) return all(s[i] == s[L - 1 - i] for i in range(L // 2)) N = int(eval(input())) S = [] for _ in range(N): s, c = input().split() S.append((s, int(c))) path = [dict() for _ in range(2)] q = deque() # S.sort(key=lambda x: x[1]) for s, c in S: if s not in path[0] or path[0][s] > c: path[0][s] = c q.append((0, s, c)) INF = 10**15 ans = INF while q: side, s0, c0 = q.popleft() if isPalindrome(s0): ans = min(ans, c0) else: for s1, c1 in S: if side == 0: l, r = s0, s1 else: l, r = s1, s0 L = len(l) R = len(r) isCandidate = False if L > R: if all(l[i] == r[-1 - i] for i in range(R)): ns = l[len(r) :] nc = c0 + c1 nside = 0 isCandidate |= True elif L < R: if all(l[i] == r[-1 - i] for i in range(L)): ns = r[: -len(l)] nc = c0 + c1 nside = 1 isCandidate |= True else: if all(l[i] == r[-1 - i] for i in range(L)): ns = "" nc = c0 + c1 nside = 0 isCandidate |= True if isCandidate and (ns not in path[nside] or path[nside][ns] > nc): path[nside][ns] = nc q.append((nside, ns, nc)) if ans < INF: print(ans) else: print((-1))
from collections import deque def isPalindrome(s): L = len(s) return all(s[i] == s[L - 1 - i] for i in range(L // 2)) N = int(eval(input())) S = [] for _ in range(N): s, c = input().split() S.append((s, int(c))) path = [dict() for _ in range(2)] q = deque() S.sort(key=lambda x: x[1]) for s, c in S: if s not in path[0] or path[0][s] > c: path[0][s] = c q.append((0, s, c)) INF = 10**15 ans = INF while q: side, s0, c0 = q.popleft() if isPalindrome(s0): ans = min(ans, c0) else: for s1, c1 in S: if side == 0: l, r = s0, s1 else: l, r = s1, s0 L = len(l) R = len(r) isCandidate = False if L > R: if all(l[i] == r[-1 - i] for i in range(R)): ns = l[len(r) :] nc = c0 + c1 nside = 0 isCandidate |= True elif L < R: if all(l[i] == r[-1 - i] for i in range(L)): ns = r[: -len(l)] nc = c0 + c1 nside = 1 isCandidate |= True else: if all(l[i] == r[-1 - i] for i in range(L)): ns = "" nc = c0 + c1 nside = 0 isCandidate |= True if isCandidate and (ns not in path[nside] or path[nside][ns] > nc): path[nside][ns] = nc q.append((nside, ns, nc)) if ans < INF: print(ans) else: print((-1))
false
0
[ "-# S.sort(key=lambda x: x[1])", "+S.sort(key=lambda x: x[1])" ]
false
0.039249
0.038497
1.019545
[ "s455916479", "s372573610" ]
u699944218
p03494
python
s007564483
s917814050
20
18
3,316
3,060
Accepted
Accepted
10
import math n = eval(input()) a = list(map(int, input().split())) ans = float("inf") for i in a: ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1) print((round(ans)))
N = int(eval(input())) A = list(map(int, input().split())) cout = 0 while all(a % 2 == 0 for a in A): A = [a/2 for a in A] cout += 1 print(cout)
7
7
170
148
import math n = eval(input()) a = list(map(int, input().split())) ans = float("inf") for i in a: ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1) print((round(ans)))
N = int(eval(input())) A = list(map(int, input().split())) cout = 0 while all(a % 2 == 0 for a in A): A = [a / 2 for a in A] cout += 1 print(cout)
false
0
[ "-import math", "-", "-n = eval(input())", "-a = list(map(int, input().split()))", "-ans = float(\"inf\")", "-for i in a:", "- ans = min(ans, len(bin(i)) - bin(i).rfind(\"1\") - 1)", "-print((round(ans)))", "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "+cout = 0", "+while all(a % 2 == 0 for a in A):", "+ A = [a / 2 for a in A]", "+ cout += 1", "+print(cout)" ]
false
0.223204
0.215888
1.033888
[ "s007564483", "s917814050" ]
u638456847
p02624
python
s609986998
s152773863
2,112
584
189,044
109,412
Accepted
Accepted
72.35
from numba import njit from math import sqrt import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines @njit def main(N): table = [1] * (N + 1) for n in range(2,N): for i in range(2*n, N+1, n): table[i] += 1 ans = 0 for i in range(1, N+1): ans += i * (table[i] + 1) print((ans - 1)) if __name__ == "__main__": N = int(readline()) main(N)
from numba import njit import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines @njit def main(N): ans = N * (N + 1) // 2 for n in range(1,N+1): for i in range(2*n, N+1, n): ans += i print(ans) if __name__ == "__main__": N = int(readline()) main(N)
25
20
467
351
from numba import njit from math import sqrt import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines @njit def main(N): table = [1] * (N + 1) for n in range(2, N): for i in range(2 * n, N + 1, n): table[i] += 1 ans = 0 for i in range(1, N + 1): ans += i * (table[i] + 1) print((ans - 1)) if __name__ == "__main__": N = int(readline()) main(N)
from numba import njit import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines @njit def main(N): ans = N * (N + 1) // 2 for n in range(1, N + 1): for i in range(2 * n, N + 1, n): ans += i print(ans) if __name__ == "__main__": N = int(readline()) main(N)
false
20
[ "-from math import sqrt", "- table = [1] * (N + 1)", "- for n in range(2, N):", "+ ans = N * (N + 1) // 2", "+ for n in range(1, N + 1):", "- table[i] += 1", "- ans = 0", "- for i in range(1, N + 1):", "- ans += i * (table[i] + 1)", "- print((ans - 1))", "+ ans += i", "+ print(ans)" ]
false
0.045956
0.046733
0.983372
[ "s609986998", "s152773863" ]
u189806337
p02947
python
s822453316
s859517601
507
412
48,100
26,972
Accepted
Accepted
18.74
import collections import math n = int(eval(input())) s = [0]*n T = [0]*n L = [0]*n ans = 0 for i in range(n): s[i] = eval(input()) T[i] = sorted(list(s[i])) L[i] = ''.join(T[i]) D = collections.Counter(L) for i in list(D.values()): ans += i*(i-1)/2 print((int(ans)))
import collections n = int(eval(input())) s = [0]*n L = [0]*n ans = 0 for i in range(n): s[i] = eval(input()) L[i] = ''.join(sorted(list(s[i]))) D = collections.Counter(L) for i in list(D.values()): ans += i*(i-1)//2 print(ans)
15
12
265
223
import collections import math n = int(eval(input())) s = [0] * n T = [0] * n L = [0] * n ans = 0 for i in range(n): s[i] = eval(input()) T[i] = sorted(list(s[i])) L[i] = "".join(T[i]) D = collections.Counter(L) for i in list(D.values()): ans += i * (i - 1) / 2 print((int(ans)))
import collections n = int(eval(input())) s = [0] * n L = [0] * n ans = 0 for i in range(n): s[i] = eval(input()) L[i] = "".join(sorted(list(s[i]))) D = collections.Counter(L) for i in list(D.values()): ans += i * (i - 1) // 2 print(ans)
false
20
[ "-import math", "-T = [0] * n", "- T[i] = sorted(list(s[i]))", "- L[i] = \"\".join(T[i])", "+ L[i] = \"\".join(sorted(list(s[i])))", "- ans += i * (i - 1) / 2", "-print((int(ans)))", "+ ans += i * (i - 1) // 2", "+print(ans)" ]
false
0.198476
0.088763
2.236005
[ "s822453316", "s859517601" ]
u708255304
p02959
python
s105776222
s712703432
191
156
19,004
19,372
Accepted
Accepted
18.32
N = int(eval(input())) A = list(map(int, input().split())) # N+1ไฝ“ใฎใƒขใƒณใ‚นใ‚ฟใƒผ B = list(map(int, input().split())) # Nไบบใฎๅ‹‡่€… before_A = sum(A) # ไธ€ใค็›ฎใฎ่ก—ใฎๅ‡ฆ็†ใ‚’ๅ…ˆใซ่กŒใ† if A[0] >= B[0]: # ใƒขใƒณใ‚นใ‚ฟใƒผใฎๆ•ฐใฎๅคšใ„ใชใ‚‰ A[0] -= B[0] B[0] = 0 else: # ๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใ‚ทใƒ†ใ‚ฃใฎๆ–นใŒๅคงใใ„ใชใ‚‰ B[0] -= A[0] A[0] = 0 # i็•ช็›ฎใฎ่ก—ใซใคใ„ใฆๅ‡ฆ็†ใ‚’่กŒใชใฃใฆใ„ใ for i in range(1, N): if B[i-1] > 0: # ใพใ ไปฅๅ‰ใฎๅ‹‡่€…ใซใ‚ญใƒฃใƒ‘ใŒๆฎ‹ใฃใฆใ‚‹ใชใ‚‰ tmp = min(A[i], B[i-1]) A[i] -= tmp B[i-1] -= tmp if A[i] > 0: # ใพใ i็•ช็›ฎใฎ่ก—ใซใƒขใƒณใ‚นใ‚ฟใƒผใŒๆฎ‹ใฃใฆใ„ใ‚‹ใชใ‚‰ใฐ tmp = min(A[i], B[i]) A[i] -= tmp B[i] -= tmp if (A[-1] > 0) & (B[-1] > 0): tmp = min(A[-1], B[-1]) A[-1] -= tmp B[-1] -= tmp after_A = sum(A) # # print(A) # print(B) print((before_A - after_A))
N = int(eval(input())) A = list(map(int, input().split())) # N+1ๅ€‹ใฎ่ก— B = list(map(int, input().split())) # Nไบบใฎๅ‹‡่€… total_monster = sum(A) if A[0] >= B[0]: # ๆœ€ๅˆใฎ่ก—ใซใคใ„ใฆใ€ใƒขใƒณใ‚นใ‚ฟใƒผใฎๆ–นใŒๅคšใ‹ใฃใŸใ‚‰ A[0] -= B[0] B[0] = 0 else: # ๆœ€ๅˆใฎ่ก—ใซใคใ„ใฆใ€ๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใฎๆ–นใŒๅคงใใ‹ใฃใŸใ‚‰ B[0] -= A[0] A[0] = 0 for i in range(1, N): # i-1็•ช็›ฎใฎๅ‹‡่€…ใฎๆฎ‹ใ‚Šใฎใ‚ญใƒฃใƒ‘ใซใ‚ˆใฃใฆๅ‡ฆ็†ใ‚’ๅค‰ใˆใฆใ„ใ if B[i-1] > 0: # ใ‚ญใƒฃใƒ‘ใŒๆฎ‹ใฃใฆใ„ใŸๅ ดๅˆ if A[i] >= B[i-1]: A[i] -= B[i-1] B[i-1] = 0 else: # i-1็•ช็›ฎใฎๅ‹‡่€…ใ ใ‘ใงๅ‡ฆ็†ใงใใ‚‹ใชใ‚‰ B[i-1] -= A[i] A[i] = 0 if B[i-1] == 0: # i-1็•ช็›ฎใฎๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใŒ0ใฎๅ ดๅˆ if A[i] >= B[i]: A[i] -= B[i] B[i] = 0 else: B[i] -= A[i] A[i] = 0 # ๆœ€ๅพŒใฎ่ก—ใซใคใ„ใฆๅ‡ฆ็†ใ‚’ใ™ใ‚‹ if A[-1] > 0: A[-1] -= min(B[-1], A[-1]) tmp = sum(A) print((total_monster - tmp))
36
39
738
838
N = int(eval(input())) A = list(map(int, input().split())) # N+1ไฝ“ใฎใƒขใƒณใ‚นใ‚ฟใƒผ B = list(map(int, input().split())) # Nไบบใฎๅ‹‡่€… before_A = sum(A) # ไธ€ใค็›ฎใฎ่ก—ใฎๅ‡ฆ็†ใ‚’ๅ…ˆใซ่กŒใ† if A[0] >= B[0]: # ใƒขใƒณใ‚นใ‚ฟใƒผใฎๆ•ฐใฎๅคšใ„ใชใ‚‰ A[0] -= B[0] B[0] = 0 else: # ๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใ‚ทใƒ†ใ‚ฃใฎๆ–นใŒๅคงใใ„ใชใ‚‰ B[0] -= A[0] A[0] = 0 # i็•ช็›ฎใฎ่ก—ใซใคใ„ใฆๅ‡ฆ็†ใ‚’่กŒใชใฃใฆใ„ใ for i in range(1, N): if B[i - 1] > 0: # ใพใ ไปฅๅ‰ใฎๅ‹‡่€…ใซใ‚ญใƒฃใƒ‘ใŒๆฎ‹ใฃใฆใ‚‹ใชใ‚‰ tmp = min(A[i], B[i - 1]) A[i] -= tmp B[i - 1] -= tmp if A[i] > 0: # ใพใ i็•ช็›ฎใฎ่ก—ใซใƒขใƒณใ‚นใ‚ฟใƒผใŒๆฎ‹ใฃใฆใ„ใ‚‹ใชใ‚‰ใฐ tmp = min(A[i], B[i]) A[i] -= tmp B[i] -= tmp if (A[-1] > 0) & (B[-1] > 0): tmp = min(A[-1], B[-1]) A[-1] -= tmp B[-1] -= tmp after_A = sum(A) # # print(A) # print(B) print((before_A - after_A))
N = int(eval(input())) A = list(map(int, input().split())) # N+1ๅ€‹ใฎ่ก— B = list(map(int, input().split())) # Nไบบใฎๅ‹‡่€… total_monster = sum(A) if A[0] >= B[0]: # ๆœ€ๅˆใฎ่ก—ใซใคใ„ใฆใ€ใƒขใƒณใ‚นใ‚ฟใƒผใฎๆ–นใŒๅคšใ‹ใฃใŸใ‚‰ A[0] -= B[0] B[0] = 0 else: # ๆœ€ๅˆใฎ่ก—ใซใคใ„ใฆใ€ๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใฎๆ–นใŒๅคงใใ‹ใฃใŸใ‚‰ B[0] -= A[0] A[0] = 0 for i in range(1, N): # i-1็•ช็›ฎใฎๅ‹‡่€…ใฎๆฎ‹ใ‚Šใฎใ‚ญใƒฃใƒ‘ใซใ‚ˆใฃใฆๅ‡ฆ็†ใ‚’ๅค‰ใˆใฆใ„ใ if B[i - 1] > 0: # ใ‚ญใƒฃใƒ‘ใŒๆฎ‹ใฃใฆใ„ใŸๅ ดๅˆ if A[i] >= B[i - 1]: A[i] -= B[i - 1] B[i - 1] = 0 else: # i-1็•ช็›ฎใฎๅ‹‡่€…ใ ใ‘ใงๅ‡ฆ็†ใงใใ‚‹ใชใ‚‰ B[i - 1] -= A[i] A[i] = 0 if B[i - 1] == 0: # i-1็•ช็›ฎใฎๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใŒ0ใฎๅ ดๅˆ if A[i] >= B[i]: A[i] -= B[i] B[i] = 0 else: B[i] -= A[i] A[i] = 0 # ๆœ€ๅพŒใฎ่ก—ใซใคใ„ใฆๅ‡ฆ็†ใ‚’ใ™ใ‚‹ if A[-1] > 0: A[-1] -= min(B[-1], A[-1]) tmp = sum(A) print((total_monster - tmp))
false
7.692308
[ "-A = list(map(int, input().split())) # N+1ไฝ“ใฎใƒขใƒณใ‚นใ‚ฟใƒผ", "+A = list(map(int, input().split())) # N+1ๅ€‹ใฎ่ก—", "-before_A = sum(A)", "-# ไธ€ใค็›ฎใฎ่ก—ใฎๅ‡ฆ็†ใ‚’ๅ…ˆใซ่กŒใ†", "-if A[0] >= B[0]: # ใƒขใƒณใ‚นใ‚ฟใƒผใฎๆ•ฐใฎๅคšใ„ใชใ‚‰", "+total_monster = sum(A)", "+if A[0] >= B[0]: # ๆœ€ๅˆใฎ่ก—ใซใคใ„ใฆใ€ใƒขใƒณใ‚นใ‚ฟใƒผใฎๆ–นใŒๅคšใ‹ใฃใŸใ‚‰", "-else: # ๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใ‚ทใƒ†ใ‚ฃใฎๆ–นใŒๅคงใใ„ใชใ‚‰", "+else: # ๆœ€ๅˆใฎ่ก—ใซใคใ„ใฆใ€ๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใฎๆ–นใŒๅคงใใ‹ใฃใŸใ‚‰", "-# i็•ช็›ฎใฎ่ก—ใซใคใ„ใฆๅ‡ฆ็†ใ‚’่กŒใชใฃใฆใ„ใ", "- if B[i - 1] > 0: # ใพใ ไปฅๅ‰ใฎๅ‹‡่€…ใซใ‚ญใƒฃใƒ‘ใŒๆฎ‹ใฃใฆใ‚‹ใชใ‚‰", "- tmp = min(A[i], B[i - 1])", "- A[i] -= tmp", "- B[i - 1] -= tmp", "- if A[i] > 0: # ใพใ i็•ช็›ฎใฎ่ก—ใซใƒขใƒณใ‚นใ‚ฟใƒผใŒๆฎ‹ใฃใฆใ„ใ‚‹ใชใ‚‰ใฐ", "- tmp = min(A[i], B[i])", "- A[i] -= tmp", "- B[i] -= tmp", "-if (A[-1] > 0) & (B[-1] > 0):", "- tmp = min(A[-1], B[-1])", "- A[-1] -= tmp", "- B[-1] -= tmp", "-after_A = sum(A)", "-#", "-# print(A)", "-# print(B)", "-print((before_A - after_A))", "+ # i-1็•ช็›ฎใฎๅ‹‡่€…ใฎๆฎ‹ใ‚Šใฎใ‚ญใƒฃใƒ‘ใซใ‚ˆใฃใฆๅ‡ฆ็†ใ‚’ๅค‰ใˆใฆใ„ใ", "+ if B[i - 1] > 0: # ใ‚ญใƒฃใƒ‘ใŒๆฎ‹ใฃใฆใ„ใŸๅ ดๅˆ", "+ if A[i] >= B[i - 1]:", "+ A[i] -= B[i - 1]", "+ B[i - 1] = 0", "+ else: # i-1็•ช็›ฎใฎๅ‹‡่€…ใ ใ‘ใงๅ‡ฆ็†ใงใใ‚‹ใชใ‚‰", "+ B[i - 1] -= A[i]", "+ A[i] = 0", "+ if B[i - 1] == 0: # i-1็•ช็›ฎใฎๅ‹‡่€…ใฎใ‚ญใƒฃใƒ‘ใŒ0ใฎๅ ดๅˆ", "+ if A[i] >= B[i]:", "+ A[i] -= B[i]", "+ B[i] = 0", "+ else:", "+ B[i] -= A[i]", "+ A[i] = 0", "+# ๆœ€ๅพŒใฎ่ก—ใซใคใ„ใฆๅ‡ฆ็†ใ‚’ใ™ใ‚‹", "+if A[-1] > 0:", "+ A[-1] -= min(B[-1], A[-1])", "+tmp = sum(A)", "+print((total_monster - tmp))" ]
false
0.035251
0.035309
0.998353
[ "s105776222", "s712703432" ]
u627600101
p02536
python
s165289353
s051860881
1,534
210
940,564
81,468
Accepted
Accepted
86.31
import sys sys.setrecursionlimit(10**9) input = sys.stdin.buffer.readline N, M = list(map(int, input().split())) nextcity = [[] for _ in range(N)] sgn = [0 for _ in range(N)] while M: M -= 1 A, B = list(map(int, input().split())) A -= 1 B -= 1 nextcity[A].append(B) nextcity[B].append(A) def dfs(cnt, city): for item in nextcity[city]: if sgn[item] == 0: sgn[item] = cnt dfs(cnt, item) return None cnt = 0 for k in range(N): if sgn[k] == 0: cnt += 1 sgn[k] = cnt dfs(cnt, k) print((cnt -1))
import sys sys.setrecursionlimit(10**9) input = sys.stdin.buffer.readline N, M = list(map(int, input().split())) nextcity = [[] for _ in range(N)] sgn = [0 for _ in range(N)] while M: M -= 1 A, B = list(map(int, input().split())) A -= 1 B -= 1 nextcity[A].append(B) nextcity[B].append(A) def bfs(cnt, lis): nextvisit = [] for j in lis: for item in nextcity[j]: if sgn[item] == 0: nextvisit.append(item) sgn[item] = cnt if nextvisit: bfs(cnt, nextvisit) return None else: return None cnt = 0 for k in range(N): if sgn[k] == 0: cnt += 1 sgn[k] = cnt bfs(cnt, [k]) print((cnt -1))
29
34
530
634
import sys sys.setrecursionlimit(10**9) input = sys.stdin.buffer.readline N, M = list(map(int, input().split())) nextcity = [[] for _ in range(N)] sgn = [0 for _ in range(N)] while M: M -= 1 A, B = list(map(int, input().split())) A -= 1 B -= 1 nextcity[A].append(B) nextcity[B].append(A) def dfs(cnt, city): for item in nextcity[city]: if sgn[item] == 0: sgn[item] = cnt dfs(cnt, item) return None cnt = 0 for k in range(N): if sgn[k] == 0: cnt += 1 sgn[k] = cnt dfs(cnt, k) print((cnt - 1))
import sys sys.setrecursionlimit(10**9) input = sys.stdin.buffer.readline N, M = list(map(int, input().split())) nextcity = [[] for _ in range(N)] sgn = [0 for _ in range(N)] while M: M -= 1 A, B = list(map(int, input().split())) A -= 1 B -= 1 nextcity[A].append(B) nextcity[B].append(A) def bfs(cnt, lis): nextvisit = [] for j in lis: for item in nextcity[j]: if sgn[item] == 0: nextvisit.append(item) sgn[item] = cnt if nextvisit: bfs(cnt, nextvisit) return None else: return None cnt = 0 for k in range(N): if sgn[k] == 0: cnt += 1 sgn[k] = cnt bfs(cnt, [k]) print((cnt - 1))
false
14.705882
[ "-def dfs(cnt, city):", "- for item in nextcity[city]:", "- if sgn[item] == 0:", "- sgn[item] = cnt", "- dfs(cnt, item)", "- return None", "+def bfs(cnt, lis):", "+ nextvisit = []", "+ for j in lis:", "+ for item in nextcity[j]:", "+ if sgn[item] == 0:", "+ nextvisit.append(item)", "+ sgn[item] = cnt", "+ if nextvisit:", "+ bfs(cnt, nextvisit)", "+ return None", "+ else:", "+ return None", "- dfs(cnt, k)", "+ bfs(cnt, [k])" ]
false
0.036134
0.041901
0.862369
[ "s165289353", "s051860881" ]
u869790980
p02536
python
s237989750
s569209353
573
519
94,668
95,424
Accepted
Accepted
9.42
n,m = list(map(int, input().split())) def g(u,parent): if parent[u]!= u: parent[u] = g(parent[u], parent) return parent[u] parent = {u:u for u in range(1, n+1)} for _ in range(m): u,v = list(map(int, input().split())) pu,pv = g(u,parent), g(v,parent) if pu!= pv: parent[pu] = pv ans = 0 for u in parent: if g(u,parent) == u: ans+=1 print(ans -1)
n,m = list(map(int, input().split())) def g(u,parent): if parent[u]!= u: parent[u] = g(parent[u], parent) return parent[u] parent = list(range(n+1)) for _ in range(m): u,v = list(map(int, input().split())) pu,pv = g(u,parent), g(v,parent) if pu!= pv: parent[pu] = pv ans = 0 for u in range(1, n+1): if g(u,parent) == u: ans+=1 print(ans -1)
19
19
409
398
n, m = list(map(int, input().split())) def g(u, parent): if parent[u] != u: parent[u] = g(parent[u], parent) return parent[u] parent = {u: u for u in range(1, n + 1)} for _ in range(m): u, v = list(map(int, input().split())) pu, pv = g(u, parent), g(v, parent) if pu != pv: parent[pu] = pv ans = 0 for u in parent: if g(u, parent) == u: ans += 1 print(ans - 1)
n, m = list(map(int, input().split())) def g(u, parent): if parent[u] != u: parent[u] = g(parent[u], parent) return parent[u] parent = list(range(n + 1)) for _ in range(m): u, v = list(map(int, input().split())) pu, pv = g(u, parent), g(v, parent) if pu != pv: parent[pu] = pv ans = 0 for u in range(1, n + 1): if g(u, parent) == u: ans += 1 print(ans - 1)
false
0
[ "-parent = {u: u for u in range(1, n + 1)}", "+parent = list(range(n + 1))", "-for u in parent:", "+for u in range(1, n + 1):" ]
false
0.037503
0.088266
0.424886
[ "s237989750", "s569209353" ]
u235376569
p03329
python
s417522198
s031307373
691
636
6,296
6,296
Accepted
Accepted
7.96
N=int(eval(input())) dp=[float('inf') for i in range(100001)] dp[0]=0 for i in range(1,N+1): power=1 while(power<=i): dp[i]=min(dp[i],dp[i-power]+1) power*=6 power=1 while(power<=i): dp[i]=min(dp[i],dp[i-power]+1) power*=9 print((dp[N]))
N=int(eval(input())) dp=[float('inf') for i in range(N+1)] dp[0]=0 for i in range(1,N+1): power=1 while(power<=i): dp[i]=min(dp[i],dp[i-power]+1) power*=6 power=1 while(power<=i): dp[i]=min(dp[i],dp[i-power]+1) power*=9 print((dp[N]))
15
15
298
295
N = int(eval(input())) dp = [float("inf") for i in range(100001)] dp[0] = 0 for i in range(1, N + 1): power = 1 while power <= i: dp[i] = min(dp[i], dp[i - power] + 1) power *= 6 power = 1 while power <= i: dp[i] = min(dp[i], dp[i - power] + 1) power *= 9 print((dp[N]))
N = int(eval(input())) dp = [float("inf") for i in range(N + 1)] dp[0] = 0 for i in range(1, N + 1): power = 1 while power <= i: dp[i] = min(dp[i], dp[i - power] + 1) power *= 6 power = 1 while power <= i: dp[i] = min(dp[i], dp[i - power] + 1) power *= 9 print((dp[N]))
false
0
[ "-dp = [float(\"inf\") for i in range(100001)]", "+dp = [float(\"inf\") for i in range(N + 1)]" ]
false
0.167994
0.12449
1.34946
[ "s417522198", "s031307373" ]
u729133443
p03937
python
s298633512
s204587359
164
17
38,512
2,940
Accepted
Accepted
89.63
t=open(0).read();print((('P'*(t.count('#')<sum(map(int,t.split()[:2])))or'Imp')+'ossible'))
t=open(0).read();print(('I mPp'[t.count('#')<int(t[0])+int(t[2])::2]+'ossible'))
1
1
89
78
t = open(0).read() print((("P" * (t.count("#") < sum(map(int, t.split()[:2]))) or "Imp") + "ossible"))
t = open(0).read() print(("I mPp"[t.count("#") < int(t[0]) + int(t[2]) :: 2] + "ossible"))
false
0
[ "-print(((\"P\" * (t.count(\"#\") < sum(map(int, t.split()[:2]))) or \"Imp\") + \"ossible\"))", "+print((\"I mPp\"[t.count(\"#\") < int(t[0]) + int(t[2]) :: 2] + \"ossible\"))" ]
false
0.102015
0.040922
2.49289
[ "s298633512", "s204587359" ]
u189023301
p02990
python
s607954466
s819537050
1,336
275
3,940
3,940
Accepted
Accepted
79.42
from functools import reduce n, k = list(map(int, input().split())) mod = 10**9 + 7 res = [0] * k def ncrf(i, j): num = reduce(lambda x, y: x * y % mod, list(range(i, i - j, -1))) den = reduce(lambda x, y: x * y % mod, list(range(1, j + 1))) return num * pow(den, mod - 2, mod) % mod for d in range(1, k + 1): if d == 1: print((ncrf(n - k + 1, d))) else: print((ncrf(n - k + 1, d) * ncrf(k - 1, d - 1) % mod))
from functools import reduce n, k = list(map(int, input().split())) mod = 10**9 + 7 def ncrf(i, j): num = reduce(lambda x, y: x * y % mod, list(range(i, i - j, -1))) den = reduce(lambda x, y: x * y % mod, list(range(1, j + 1))) return num * pow(den, mod - 2, mod) % mod for d in range(1, k + 1): if d == 1: print((ncrf(n - k + 1, d))) elif d > n - k + 1: print((0)) else: print((ncrf(n - k + 1, d) * ncrf(k - 1, d - 1) % mod))
17
19
444
474
from functools import reduce n, k = list(map(int, input().split())) mod = 10**9 + 7 res = [0] * k def ncrf(i, j): num = reduce(lambda x, y: x * y % mod, list(range(i, i - j, -1))) den = reduce(lambda x, y: x * y % mod, list(range(1, j + 1))) return num * pow(den, mod - 2, mod) % mod for d in range(1, k + 1): if d == 1: print((ncrf(n - k + 1, d))) else: print((ncrf(n - k + 1, d) * ncrf(k - 1, d - 1) % mod))
from functools import reduce n, k = list(map(int, input().split())) mod = 10**9 + 7 def ncrf(i, j): num = reduce(lambda x, y: x * y % mod, list(range(i, i - j, -1))) den = reduce(lambda x, y: x * y % mod, list(range(1, j + 1))) return num * pow(den, mod - 2, mod) % mod for d in range(1, k + 1): if d == 1: print((ncrf(n - k + 1, d))) elif d > n - k + 1: print((0)) else: print((ncrf(n - k + 1, d) * ncrf(k - 1, d - 1) % mod))
false
10.526316
[ "-res = [0] * k", "+ elif d > n - k + 1:", "+ print((0))" ]
false
0.03555
0.071385
0.498005
[ "s607954466", "s819537050" ]
u668503853
p03945
python
s093826059
s303493926
43
18
3,188
3,188
Accepted
Accepted
58.14
S=eval(input()) ans=0 for i in range(1,len(S)): if S[i]!=S[i-1]: ans+=1 print(ans)
s=eval(input()) print((s.count("WB")+s.count("BW")))
6
2
87
45
S = eval(input()) ans = 0 for i in range(1, len(S)): if S[i] != S[i - 1]: ans += 1 print(ans)
s = eval(input()) print((s.count("WB") + s.count("BW")))
false
66.666667
[ "-S = eval(input())", "-ans = 0", "-for i in range(1, len(S)):", "- if S[i] != S[i - 1]:", "- ans += 1", "-print(ans)", "+s = eval(input())", "+print((s.count(\"WB\") + s.count(\"BW\")))" ]
false
0.006338
0.035335
0.179373
[ "s093826059", "s303493926" ]
u391157755
p02708
python
s561146800
s996586478
86
23
9,172
9,172
Accepted
Accepted
73.26
n, k = list(map(int, input().split())) i = n + 1 mod = 10 ** 9 + 7 ans = 0 while i >= k: ans += i * (n - i + 1) + 1 ans %= mod i -= 1 print(ans)
n, k = list(map(int, input().split())) print(((((-2 + k - n)*(-6 + 2* k**2 - n - n**2 - k*(2 + n)))//6)%(10**9+7)))
9
2
158
108
n, k = list(map(int, input().split())) i = n + 1 mod = 10**9 + 7 ans = 0 while i >= k: ans += i * (n - i + 1) + 1 ans %= mod i -= 1 print(ans)
n, k = list(map(int, input().split())) print( ( (((-2 + k - n) * (-6 + 2 * k**2 - n - n**2 - k * (2 + n))) // 6) % (10**9 + 7) ) )
false
77.777778
[ "-i = n + 1", "-mod = 10**9 + 7", "-ans = 0", "-while i >= k:", "- ans += i * (n - i + 1) + 1", "- ans %= mod", "- i -= 1", "-print(ans)", "+print(", "+ (", "+ (((-2 + k - n) * (-6 + 2 * k**2 - n - n**2 - k * (2 + n))) // 6)", "+ % (10**9 + 7)", "+ )", "+)" ]
false
0.047045
0.078118
0.60223
[ "s561146800", "s996586478" ]
u314050667
p02813
python
s259643588
s626704983
146
38
3,064
3,064
Accepted
Accepted
73.97
import sys n = int(eval(input())) p = list(map(int, input().split())) q = list(map(int, input().split())) last = [n-1 for i in range(n)] a,b = 0,0 l = [i+1 for i in range(n)] if l == p: a = 1 if l == q: b = 1 if a == b == 1: print((0)) sys.exit() cnt = 1 while True: cnt += 1 for i in range(n-1,-1,-1): if l[i] < l[i-1]: continue else: obj = l[i-1] tmp = sorted(l[i-1:]) switch = tmp.pop(tmp.index(obj)+1) l = l[:i-1] + [switch] + sorted(tmp) #print(l) break if l == p: a = cnt if l == q: b = cnt if a != 0 and b != 0: break print((abs(a-b)))
import itertools n = int(eval(input())) p = "".join(list(map(str, input().split()))) q = "".join(list(map(str, input().split()))) l = "".join([str(i+1) for i in range(n)]) cnt = 0 a,b = 0,0 for x in itertools.permutations(l): y = "".join(x) cnt += 1 if y == p: a = cnt if y == q: b = cnt if a != 0 and b != 0: break print((abs(a-b)))
46
22
631
362
import sys n = int(eval(input())) p = list(map(int, input().split())) q = list(map(int, input().split())) last = [n - 1 for i in range(n)] a, b = 0, 0 l = [i + 1 for i in range(n)] if l == p: a = 1 if l == q: b = 1 if a == b == 1: print((0)) sys.exit() cnt = 1 while True: cnt += 1 for i in range(n - 1, -1, -1): if l[i] < l[i - 1]: continue else: obj = l[i - 1] tmp = sorted(l[i - 1 :]) switch = tmp.pop(tmp.index(obj) + 1) l = l[: i - 1] + [switch] + sorted(tmp) # print(l) break if l == p: a = cnt if l == q: b = cnt if a != 0 and b != 0: break print((abs(a - b)))
import itertools n = int(eval(input())) p = "".join(list(map(str, input().split()))) q = "".join(list(map(str, input().split()))) l = "".join([str(i + 1) for i in range(n)]) cnt = 0 a, b = 0, 0 for x in itertools.permutations(l): y = "".join(x) cnt += 1 if y == p: a = cnt if y == q: b = cnt if a != 0 and b != 0: break print((abs(a - b)))
false
52.173913
[ "-import sys", "+import itertools", "-p = list(map(int, input().split()))", "-q = list(map(int, input().split()))", "-last = [n - 1 for i in range(n)]", "+p = \"\".join(list(map(str, input().split())))", "+q = \"\".join(list(map(str, input().split())))", "+l = \"\".join([str(i + 1) for i in range(n)])", "+cnt = 0", "-l = [i + 1 for i in range(n)]", "-if l == p:", "- a = 1", "-if l == q:", "- b = 1", "-if a == b == 1:", "- print((0))", "- sys.exit()", "-cnt = 1", "-while True:", "+for x in itertools.permutations(l):", "+ y = \"\".join(x)", "- for i in range(n - 1, -1, -1):", "- if l[i] < l[i - 1]:", "- continue", "- else:", "- obj = l[i - 1]", "- tmp = sorted(l[i - 1 :])", "- switch = tmp.pop(tmp.index(obj) + 1)", "- l = l[: i - 1] + [switch] + sorted(tmp)", "- # print(l)", "- break", "- if l == p:", "+ if y == p:", "- if l == q:", "+ if y == q:" ]
false
0.082747
0.039107
2.115919
[ "s259643588", "s626704983" ]
u098679988
p03073
python
s016178526
s705995549
73
30
3,956
9,140
Accepted
Accepted
58.9
s = list(eval(input())) ans = 0 for i in range(1, len(s)): if s[i-1] == s[i] and s[i-1] == "0": ans += 1 s[i] = "1" if s[i-1] == s[i] and s[i-1] == "1": ans += 1 s[i] = "0" print(ans)
#ๅ‚่€ƒ ๏ผš AtCoder # 14682107 s = eval(input()) len = len(s) if len == 1: print((0)) exit() even = s[::2] odd = s[1::2] #ๅถๆ•ฐ็•ช็›ฎใซ0ใŒไธฆใถใจไปฎๅฎšใ—ใŸใจใใฎ็•ฐ็‰ฉใฎๆ•ฐ # 0101... odd_zero = odd.count("0") even_one = even.count("1") #ๅฅ‡ๆ•ฐ็•ช็›ฎใซ0ใŒไธฆใถใจไปฎๅฎšใ—ใŸใจใใฎ็•ฐ็‰ฉใฎๆ•ฐ # 1010... odd_one = odd.count("1") even_zero = even.count("0") print((min(odd_zero + even_one, odd_one + even_zero)))
11
23
228
367
s = list(eval(input())) ans = 0 for i in range(1, len(s)): if s[i - 1] == s[i] and s[i - 1] == "0": ans += 1 s[i] = "1" if s[i - 1] == s[i] and s[i - 1] == "1": ans += 1 s[i] = "0" print(ans)
# ๅ‚่€ƒ ๏ผš AtCoder # 14682107 s = eval(input()) len = len(s) if len == 1: print((0)) exit() even = s[::2] odd = s[1::2] # ๅถๆ•ฐ็•ช็›ฎใซ0ใŒไธฆใถใจไปฎๅฎšใ—ใŸใจใใฎ็•ฐ็‰ฉใฎๆ•ฐ # 0101... odd_zero = odd.count("0") even_one = even.count("1") # ๅฅ‡ๆ•ฐ็•ช็›ฎใซ0ใŒไธฆใถใจไปฎๅฎšใ—ใŸใจใใฎ็•ฐ็‰ฉใฎๆ•ฐ # 1010... odd_one = odd.count("1") even_zero = even.count("0") print((min(odd_zero + even_one, odd_one + even_zero)))
false
52.173913
[ "-s = list(eval(input()))", "-ans = 0", "-for i in range(1, len(s)):", "- if s[i - 1] == s[i] and s[i - 1] == \"0\":", "- ans += 1", "- s[i] = \"1\"", "- if s[i - 1] == s[i] and s[i - 1] == \"1\":", "- ans += 1", "- s[i] = \"0\"", "-print(ans)", "+# ๅ‚่€ƒ ๏ผš AtCoder # 14682107", "+s = eval(input())", "+len = len(s)", "+if len == 1:", "+ print((0))", "+ exit()", "+even = s[::2]", "+odd = s[1::2]", "+# ๅถๆ•ฐ็•ช็›ฎใซ0ใŒไธฆใถใจไปฎๅฎšใ—ใŸใจใใฎ็•ฐ็‰ฉใฎๆ•ฐ", "+# 0101...", "+odd_zero = odd.count(\"0\")", "+even_one = even.count(\"1\")", "+# ๅฅ‡ๆ•ฐ็•ช็›ฎใซ0ใŒไธฆใถใจไปฎๅฎšใ—ใŸใจใใฎ็•ฐ็‰ฉใฎๆ•ฐ", "+# 1010...", "+odd_one = odd.count(\"1\")", "+even_zero = even.count(\"0\")", "+print((min(odd_zero + even_one, odd_one + even_zero)))" ]
false
0.036843
0.036661
1.004964
[ "s016178526", "s705995549" ]
u341087021
p03459
python
s887553635
s192305971
409
374
11,736
3,064
Accepted
Accepted
8.56
n = int(eval(input())) t,x,y = [],[],[] for _ in range(n): t_,x_,y_ = [int(x) for x in input().split()] t.append(t_) x.append(x_) y.append(y_) t_now = 0 p = (0,0) ans = True for i,z in enumerate(t): td = t[i] - t_now d = abs(p[0]-x[i]) + abs(p[1]-y[i]) tmp = td - d if tmp >= 0 and tmp % 2 == 0: p = (x[i],y[i]) t_now = t[i] continue else: ans = False break if ans: print('Yes') else: print('No')
n = int(eval(input())) t_now = 0 p = (0,0) ans = True for _ in range(n): t,x,y = list(map(int,input().split())) td = t - t_now d = abs(p[0]-x) + abs(p[1]-y) tmp = td - d if tmp >= 0 and tmp % 2 == 0: t_now = t p = (x,y) continue else: ans = False break if ans: print('Yes') else: print('No')
30
23
508
376
n = int(eval(input())) t, x, y = [], [], [] for _ in range(n): t_, x_, y_ = [int(x) for x in input().split()] t.append(t_) x.append(x_) y.append(y_) t_now = 0 p = (0, 0) ans = True for i, z in enumerate(t): td = t[i] - t_now d = abs(p[0] - x[i]) + abs(p[1] - y[i]) tmp = td - d if tmp >= 0 and tmp % 2 == 0: p = (x[i], y[i]) t_now = t[i] continue else: ans = False break if ans: print("Yes") else: print("No")
n = int(eval(input())) t_now = 0 p = (0, 0) ans = True for _ in range(n): t, x, y = list(map(int, input().split())) td = t - t_now d = abs(p[0] - x) + abs(p[1] - y) tmp = td - d if tmp >= 0 and tmp % 2 == 0: t_now = t p = (x, y) continue else: ans = False break if ans: print("Yes") else: print("No")
false
23.333333
[ "-t, x, y = [], [], []", "-for _ in range(n):", "- t_, x_, y_ = [int(x) for x in input().split()]", "- t.append(t_)", "- x.append(x_)", "- y.append(y_)", "-for i, z in enumerate(t):", "- td = t[i] - t_now", "- d = abs(p[0] - x[i]) + abs(p[1] - y[i])", "+for _ in range(n):", "+ t, x, y = list(map(int, input().split()))", "+ td = t - t_now", "+ d = abs(p[0] - x) + abs(p[1] - y)", "- p = (x[i], y[i])", "- t_now = t[i]", "+ t_now = t", "+ p = (x, y)" ]
false
0.048737
0.04713
1.034093
[ "s887553635", "s192305971" ]
u063052907
p03416
python
s974343808
s511344953
61
54
2,940
2,940
Accepted
Accepted
11.48
# coding: utf-8 import sys input = sys.stdin.readline A, B = list(map(int, input().split())) ans = sum(1 for i in range(A, B+1) if str(i)==str(i)[::-1]) print(ans)
# coding: utf-8 import sys input = sys.stdin.readline A, B = list(map(int, input().split())) ans = 0 for i in range(A, B + 1): i = str(i) if i == i[::-1]: ans += 1 print(ans)
7
11
165
196
# coding: utf-8 import sys input = sys.stdin.readline A, B = list(map(int, input().split())) ans = sum(1 for i in range(A, B + 1) if str(i) == str(i)[::-1]) print(ans)
# coding: utf-8 import sys input = sys.stdin.readline A, B = list(map(int, input().split())) ans = 0 for i in range(A, B + 1): i = str(i) if i == i[::-1]: ans += 1 print(ans)
false
36.363636
[ "-ans = sum(1 for i in range(A, B + 1) if str(i) == str(i)[::-1])", "+ans = 0", "+for i in range(A, B + 1):", "+ i = str(i)", "+ if i == i[::-1]:", "+ ans += 1" ]
false
0.07952
0.054614
1.456039
[ "s974343808", "s511344953" ]
u160244242
p03371
python
s351937082
s919083951
21
18
3,060
2,940
Accepted
Accepted
14.29
a, b, c, x, y = list(map(int, input().split())) def f(x,y): return x-y if x>y else 0 if (a+b) > 2*c: ans = min(2*c*x + f(y,x)*b, 2*c*y + f(x,y)*a) else: ans = a*x + b*y print(ans)
a, b, c, x, y = list(map(int, input().split())) def f(x,y): return x-y if x>y else 0 print((min(2*c*x + f(y,x)*b, 2*c*y + f(x,y)*a, a*x+b*y)))
11
6
202
146
a, b, c, x, y = list(map(int, input().split())) def f(x, y): return x - y if x > y else 0 if (a + b) > 2 * c: ans = min(2 * c * x + f(y, x) * b, 2 * c * y + f(x, y) * a) else: ans = a * x + b * y print(ans)
a, b, c, x, y = list(map(int, input().split())) def f(x, y): return x - y if x > y else 0 print((min(2 * c * x + f(y, x) * b, 2 * c * y + f(x, y) * a, a * x + b * y)))
false
45.454545
[ "-if (a + b) > 2 * c:", "- ans = min(2 * c * x + f(y, x) * b, 2 * c * y + f(x, y) * a)", "-else:", "- ans = a * x + b * y", "-print(ans)", "+print((min(2 * c * x + f(y, x) * b, 2 * c * y + f(x, y) * a, a * x + b * y)))" ]
false
0.111106
0.04767
2.330714
[ "s351937082", "s919083951" ]
u407311141
p02989
python
s334230767
s431217567
114
82
14,428
14,120
Accepted
Accepted
28.07
s = int(eval(input())) list = [int(n) for n in input().split()] print((sorted(list)[s//2] - sorted(list)[s//2 - 1]))
s = int(eval(input())) list = [int(n) for n in input().split()] s_l = sorted(list) print((s_l[s//2] - s_l[s//2 - 1]))
4
5
113
115
s = int(eval(input())) list = [int(n) for n in input().split()] print((sorted(list)[s // 2] - sorted(list)[s // 2 - 1]))
s = int(eval(input())) list = [int(n) for n in input().split()] s_l = sorted(list) print((s_l[s // 2] - s_l[s // 2 - 1]))
false
20
[ "-print((sorted(list)[s // 2] - sorted(list)[s // 2 - 1]))", "+s_l = sorted(list)", "+print((s_l[s // 2] - s_l[s // 2 - 1]))" ]
false
0.046852
0.047076
0.995256
[ "s334230767", "s431217567" ]
u077291787
p03425
python
s616813991
s043537056
121
39
10,864
10,864
Accepted
Accepted
67.77
# ABC089C - March from itertools import combinations as comb def main(): N, *S = open(0).read().split() cnt = [sum(s.startswith(i) for s in S) for i in "MARCH"] ans = sum(x * y * z for x, y, z in comb(cnt, 3)) print(ans) if __name__ == "__main__": main()
# ABC089C - March from itertools import combinations as comb def main(): N, *S = open(0).read().split() capitals = [s[0] for s in S] cnt = [capitals.count(i) for i in "MARCH"] ans = sum(x * y * z for x, y, z in comb(cnt, 3)) print(ans) if __name__ == "__main__": main()
13
14
290
310
# ABC089C - March from itertools import combinations as comb def main(): N, *S = open(0).read().split() cnt = [sum(s.startswith(i) for s in S) for i in "MARCH"] ans = sum(x * y * z for x, y, z in comb(cnt, 3)) print(ans) if __name__ == "__main__": main()
# ABC089C - March from itertools import combinations as comb def main(): N, *S = open(0).read().split() capitals = [s[0] for s in S] cnt = [capitals.count(i) for i in "MARCH"] ans = sum(x * y * z for x, y, z in comb(cnt, 3)) print(ans) if __name__ == "__main__": main()
false
7.142857
[ "- cnt = [sum(s.startswith(i) for s in S) for i in \"MARCH\"]", "+ capitals = [s[0] for s in S]", "+ cnt = [capitals.count(i) for i in \"MARCH\"]" ]
false
0.070715
0.037155
1.903239
[ "s616813991", "s043537056" ]
u888092736
p03497
python
s682287327
s879933739
200
102
41,500
34,924
Accepted
Accepted
49
from collections import Counter N, K = list(map(int, input().split())) A = sorted((v, k) for k, v in list(Counter(list(map(int, input().split()))).items())) print((sum(v for v, k in A[: max(0, len(A) - K)])))
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) A_cntr = Counter(A) print((sum(sorted(v for v in list(A_cntr.values()))[:-K])))
6
7
196
181
from collections import Counter N, K = list(map(int, input().split())) A = sorted((v, k) for k, v in list(Counter(list(map(int, input().split()))).items())) print((sum(v for v, k in A[: max(0, len(A) - K)])))
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) A_cntr = Counter(A) print((sum(sorted(v for v in list(A_cntr.values()))[:-K])))
false
14.285714
[ "-A = sorted((v, k) for k, v in list(Counter(list(map(int, input().split()))).items()))", "-print((sum(v for v, k in A[: max(0, len(A) - K)])))", "+A = list(map(int, input().split()))", "+A_cntr = Counter(A)", "+print((sum(sorted(v for v in list(A_cntr.values()))[:-K])))" ]
false
0.035806
0.075611
0.473551
[ "s682287327", "s879933739" ]
u044220565
p03061
python
s239411850
s978208116
176
118
91,848
21,292
Accepted
Accepted
32.95
# coding: utf-8 import sys # from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read printout = sys.stdout.write sprint = sys.stdout.flush # from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10 ** 7) import math # from itertools import product, accumulate, combinations, product #import bisect # import numpy as np # from copy import deepcopy #from collections import deque # from decimal import Decimal # from numba import jit INF = 1 << 50 EPS = 1e-8 mod = 998244353 def intread(): return int(sysread()) def mapline(t=int): return list(map(t, sysread().split())) def mapread(t=int): return list(map(t, read().split())) class segtree: '''init_val : i-indexed (init_val[0] = self.bin[1])''' def __init__(self, n, init = 0, init_val=None): self.n = n self.init = init self.k = math.ceil(math.log2(n)) self.add_val = 1 << self.k self.bins = [self.init] * (1 << (self.k + 1)) if init_val != None: self.update_set(init_val) self.caliculate() def __getitem__(self, idx): # return idx-value return self.bins[idx + self.add_val] def update_set(self, vals): for idx, i in enumerate(range(self.add_val, self.add_val * 2)): if len(vals) > idx: self.bins[i] = vals[idx] else:continue def compare(self, l, r): return math.gcd(l, r) def caliculate(self): k = self.k while k: for i in range(1<<k, 1<<(k+1)): if not i%2: self.bins[i//2] = self.compare(self.bins[i], self.bins[i+1]) else:continue k -= 1 def update(self, idx, val, by=True): '''idx : 0-started index''' k = (1<<self.k) + idx if by: self.bins[k] += val else: self.bins[k] = val while k>1: self.bins[k // 2] = self.compare(self.bins[k // 2 * 2], self.bins[k // 2 * 2 + 1]) k = k//2 def eval(self, l, r): if l == r: return self.bins[self.add_val + l] ret = self.init l = (1 << self.k) + l r = (1 << self.k) + r #print(l, r) while True: #print(l, r) if r - l == 1: ret = self.compare(ret, self.bins[l]) ret = self.compare(ret, self.bins[r]) break elif l == r: ret = self.compare(ret, self.bins[l]) break else: done = False if l % 2: ret = self.compare(ret, self.bins[l]) l += 1 done = True if not r % 2: ret = self.compare(ret, self.bins[r]) r -= 1 done = True if not done: l = l // 2 r = r // 2 #print(ret) return ret def run(): N, *A = mapread() t = segtree(N, init = 0, init_val = A) ans = 0 for i in range(N): if i > 0: a = t.eval(0, i-1) else: a = 0 if i < N-1: b = t.eval(i+1, N-1) else: b = 0 ans = max(ans, math.gcd(a, b)) print(ans) if __name__ == "__main__": #print(math.gcd(0, 10)) run()
# coding: utf-8 import sys # from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read printout = sys.stdout.write sprint = sys.stdout.flush # from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10 ** 7) import math # from itertools import product, accumulate, combinations, product #import bisect # import numpy as np # from copy import deepcopy #from collections import deque # from decimal import Decimal # from numba import jit INF = 1 << 50 EPS = 1e-8 mod = 998244353 def intread(): return int(sysread()) def mapline(t=int): return list(map(t, sysread().split())) def mapread(t=int): return list(map(t, read().split())) def run(): N, *A = mapread() LEFT = [0] * (N+2) RIGHT = [0] * (N+2) for i, a in enumerate(A, 1): LEFT[i] = math.gcd(LEFT[i-1], a) for i in range(N-1, -1, -1): k = i+1# for RIGHT RIGHT[k] = math.gcd(RIGHT[k+1], A[i]) #print(LEFT) #print(RIGHT) ans = 0 for i in range(N): k = i + 1# for LEFT and RIGHT v = math.gcd(LEFT[k-1], RIGHT[k+1]) #print(v) ans = max(ans, v) print(ans) if __name__ == "__main__": #print(math.gcd(0, 10)) run()
133
59
3,570
1,311
# coding: utf-8 import sys # from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read printout = sys.stdout.write sprint = sys.stdout.flush # from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10**7) import math # from itertools import product, accumulate, combinations, product # import bisect # import numpy as np # from copy import deepcopy # from collections import deque # from decimal import Decimal # from numba import jit INF = 1 << 50 EPS = 1e-8 mod = 998244353 def intread(): return int(sysread()) def mapline(t=int): return list(map(t, sysread().split())) def mapread(t=int): return list(map(t, read().split())) class segtree: """init_val : i-indexed (init_val[0] = self.bin[1])""" def __init__(self, n, init=0, init_val=None): self.n = n self.init = init self.k = math.ceil(math.log2(n)) self.add_val = 1 << self.k self.bins = [self.init] * (1 << (self.k + 1)) if init_val != None: self.update_set(init_val) self.caliculate() def __getitem__(self, idx): # return idx-value return self.bins[idx + self.add_val] def update_set(self, vals): for idx, i in enumerate(range(self.add_val, self.add_val * 2)): if len(vals) > idx: self.bins[i] = vals[idx] else: continue def compare(self, l, r): return math.gcd(l, r) def caliculate(self): k = self.k while k: for i in range(1 << k, 1 << (k + 1)): if not i % 2: self.bins[i // 2] = self.compare(self.bins[i], self.bins[i + 1]) else: continue k -= 1 def update(self, idx, val, by=True): """idx : 0-started index""" k = (1 << self.k) + idx if by: self.bins[k] += val else: self.bins[k] = val while k > 1: self.bins[k // 2] = self.compare( self.bins[k // 2 * 2], self.bins[k // 2 * 2 + 1] ) k = k // 2 def eval(self, l, r): if l == r: return self.bins[self.add_val + l] ret = self.init l = (1 << self.k) + l r = (1 << self.k) + r # print(l, r) while True: # print(l, r) if r - l == 1: ret = self.compare(ret, self.bins[l]) ret = self.compare(ret, self.bins[r]) break elif l == r: ret = self.compare(ret, self.bins[l]) break else: done = False if l % 2: ret = self.compare(ret, self.bins[l]) l += 1 done = True if not r % 2: ret = self.compare(ret, self.bins[r]) r -= 1 done = True if not done: l = l // 2 r = r // 2 # print(ret) return ret def run(): N, *A = mapread() t = segtree(N, init=0, init_val=A) ans = 0 for i in range(N): if i > 0: a = t.eval(0, i - 1) else: a = 0 if i < N - 1: b = t.eval(i + 1, N - 1) else: b = 0 ans = max(ans, math.gcd(a, b)) print(ans) if __name__ == "__main__": # print(math.gcd(0, 10)) run()
# coding: utf-8 import sys # from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read printout = sys.stdout.write sprint = sys.stdout.flush # from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10**7) import math # from itertools import product, accumulate, combinations, product # import bisect # import numpy as np # from copy import deepcopy # from collections import deque # from decimal import Decimal # from numba import jit INF = 1 << 50 EPS = 1e-8 mod = 998244353 def intread(): return int(sysread()) def mapline(t=int): return list(map(t, sysread().split())) def mapread(t=int): return list(map(t, read().split())) def run(): N, *A = mapread() LEFT = [0] * (N + 2) RIGHT = [0] * (N + 2) for i, a in enumerate(A, 1): LEFT[i] = math.gcd(LEFT[i - 1], a) for i in range(N - 1, -1, -1): k = i + 1 # for RIGHT RIGHT[k] = math.gcd(RIGHT[k + 1], A[i]) # print(LEFT) # print(RIGHT) ans = 0 for i in range(N): k = i + 1 # for LEFT and RIGHT v = math.gcd(LEFT[k - 1], RIGHT[k + 1]) # print(v) ans = max(ans, v) print(ans) if __name__ == "__main__": # print(math.gcd(0, 10)) run()
false
55.639098
[ "-class segtree:", "- \"\"\"init_val : i-indexed (init_val[0] = self.bin[1])\"\"\"", "-", "- def __init__(self, n, init=0, init_val=None):", "- self.n = n", "- self.init = init", "- self.k = math.ceil(math.log2(n))", "- self.add_val = 1 << self.k", "- self.bins = [self.init] * (1 << (self.k + 1))", "- if init_val != None:", "- self.update_set(init_val)", "- self.caliculate()", "-", "- def __getitem__(self, idx): # return idx-value", "- return self.bins[idx + self.add_val]", "-", "- def update_set(self, vals):", "- for idx, i in enumerate(range(self.add_val, self.add_val * 2)):", "- if len(vals) > idx:", "- self.bins[i] = vals[idx]", "- else:", "- continue", "-", "- def compare(self, l, r):", "- return math.gcd(l, r)", "-", "- def caliculate(self):", "- k = self.k", "- while k:", "- for i in range(1 << k, 1 << (k + 1)):", "- if not i % 2:", "- self.bins[i // 2] = self.compare(self.bins[i], self.bins[i + 1])", "- else:", "- continue", "- k -= 1", "-", "- def update(self, idx, val, by=True):", "- \"\"\"idx : 0-started index\"\"\"", "- k = (1 << self.k) + idx", "- if by:", "- self.bins[k] += val", "- else:", "- self.bins[k] = val", "- while k > 1:", "- self.bins[k // 2] = self.compare(", "- self.bins[k // 2 * 2], self.bins[k // 2 * 2 + 1]", "- )", "- k = k // 2", "-", "- def eval(self, l, r):", "- if l == r:", "- return self.bins[self.add_val + l]", "- ret = self.init", "- l = (1 << self.k) + l", "- r = (1 << self.k) + r", "- # print(l, r)", "- while True:", "- # print(l, r)", "- if r - l == 1:", "- ret = self.compare(ret, self.bins[l])", "- ret = self.compare(ret, self.bins[r])", "- break", "- elif l == r:", "- ret = self.compare(ret, self.bins[l])", "- break", "- else:", "- done = False", "- if l % 2:", "- ret = self.compare(ret, self.bins[l])", "- l += 1", "- done = True", "- if not r % 2:", "- ret = self.compare(ret, self.bins[r])", "- r -= 1", "- done = True", "- if not done:", "- l = l // 2", "- r = r // 2", "- # print(ret)", "- return ret", "-", "-", "- t = segtree(N, init=0, init_val=A)", "+ LEFT = [0] * (N + 2)", "+ RIGHT = [0] * (N + 2)", "+ for i, a in enumerate(A, 1):", "+ LEFT[i] = math.gcd(LEFT[i - 1], a)", "+ for i in range(N - 1, -1, -1):", "+ k = i + 1 # for RIGHT", "+ RIGHT[k] = math.gcd(RIGHT[k + 1], A[i])", "+ # print(LEFT)", "+ # print(RIGHT)", "- if i > 0:", "- a = t.eval(0, i - 1)", "- else:", "- a = 0", "- if i < N - 1:", "- b = t.eval(i + 1, N - 1)", "- else:", "- b = 0", "- ans = max(ans, math.gcd(a, b))", "+ k = i + 1 # for LEFT and RIGHT", "+ v = math.gcd(LEFT[k - 1], RIGHT[k + 1])", "+ # print(v)", "+ ans = max(ans, v)" ]
false
0.123346
0.106903
1.153812
[ "s239411850", "s978208116" ]
u291766461
p03295
python
s849818630
s703700542
670
374
56,920
18,204
Accepted
Accepted
44.18
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = list(map(int, input().split())) AB.append((a, b)) AB.sort(key=lambda x: x[1]) cnt = 1 x = AB[0][1] for a, b in AB: if a <= x - 1 <= b and a <= x <= b: continue else: cnt += 1 x = b print(cnt)
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = list(map(int, input().split())) AB.append((a, b)) AB.sort(key=lambda x: x[1]) # print(AB) base = AB[0][1] ans = 1 for ab in AB[1:]: if ab[0] < base <= ab[1]: continue else: ans += 1 base = ab[1] print(ans)
15
17
306
323
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = list(map(int, input().split())) AB.append((a, b)) AB.sort(key=lambda x: x[1]) cnt = 1 x = AB[0][1] for a, b in AB: if a <= x - 1 <= b and a <= x <= b: continue else: cnt += 1 x = b print(cnt)
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = list(map(int, input().split())) AB.append((a, b)) AB.sort(key=lambda x: x[1]) # print(AB) base = AB[0][1] ans = 1 for ab in AB[1:]: if ab[0] < base <= ab[1]: continue else: ans += 1 base = ab[1] print(ans)
false
11.764706
[ "-cnt = 1", "-x = AB[0][1]", "-for a, b in AB:", "- if a <= x - 1 <= b and a <= x <= b:", "+# print(AB)", "+base = AB[0][1]", "+ans = 1", "+for ab in AB[1:]:", "+ if ab[0] < base <= ab[1]:", "- cnt += 1", "- x = b", "-print(cnt)", "+ ans += 1", "+ base = ab[1]", "+print(ans)" ]
false
0.048414
0.048028
1.00804
[ "s849818630", "s703700542" ]
u146803137
p02789
python
s964633282
s584150804
105
28
61,376
9,148
Accepted
Accepted
73.33
n,m = list(map(int,input().split())) if n == m: print('Yes') else: print('No')
n,m = list(map(int,input().split())) print(('Yes' if n == m else 'No'))
5
2
85
65
n, m = list(map(int, input().split())) if n == m: print("Yes") else: print("No")
n, m = list(map(int, input().split())) print(("Yes" if n == m else "No"))
false
60
[ "-if n == m:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+print((\"Yes\" if n == m else \"No\"))" ]
false
0.043908
0.044232
0.992682
[ "s964633282", "s584150804" ]
u449863068
p03212
python
s993062060
s554907688
82
41
3,064
3,064
Accepted
Accepted
50
import itertools N = int(eval(input())) ans = 0 for i in range(3, len(str(N)) + 1): for ptn in itertools.product((3, 5, 7), repeat=i): if (3 not in ptn) or (5 not in ptn) or (7 not in ptn): continue a = int("".join(list(map(str, ptn)))) if a <= N: ans +=1 print(ans)
import itertools N = int(eval(input())) ans = 0 for i in range(1, 10): for x in itertools.product("753", repeat=i): s= ''.join(x) if int(s) > N: continue if '3' not in s: continue if '5' not in s: continue if '7' not in s: continue ans += 1 print(ans)
13
12
302
282
import itertools N = int(eval(input())) ans = 0 for i in range(3, len(str(N)) + 1): for ptn in itertools.product((3, 5, 7), repeat=i): if (3 not in ptn) or (5 not in ptn) or (7 not in ptn): continue a = int("".join(list(map(str, ptn)))) if a <= N: ans += 1 print(ans)
import itertools N = int(eval(input())) ans = 0 for i in range(1, 10): for x in itertools.product("753", repeat=i): s = "".join(x) if int(s) > N: continue if "3" not in s: continue if "5" not in s: continue if "7" not in s: continue ans += 1 print(ans)
false
7.692308
[ "-for i in range(3, len(str(N)) + 1):", "- for ptn in itertools.product((3, 5, 7), repeat=i):", "- if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):", "+for i in range(1, 10):", "+ for x in itertools.product(\"753\", repeat=i):", "+ s = \"\".join(x)", "+ if int(s) > N:", "- a = int(\"\".join(list(map(str, ptn))))", "- if a <= N:", "- ans += 1", "+ if \"3\" not in s:", "+ continue", "+ if \"5\" not in s:", "+ continue", "+ if \"7\" not in s:", "+ continue", "+ ans += 1" ]
false
0.070141
0.077195
0.908616
[ "s993062060", "s554907688" ]
u836939578
p02579
python
s521393244
s428857289
1,605
868
183,708
165,376
Accepted
Accepted
45.92
import sys from collections import deque input = lambda: sys.stdin.readline().rstrip() H, W = list(map(int, input().split())) ch, cw = list(map(int, input().split())) ch -= 1 cw -= 1 dh, dw = list(map(int, input().split())) dh -= 1 dw -= 1 maze = [] for i in range(H): a = list(eval(input())) maze.append(a) queue = deque([(ch, cw, 0)]) dist = [[float("inf") for _ in range(W)] for _ in range(H)] dist[ch][cw] = 0 while queue: y, x, cnt= queue.popleft() for a, b in ([1, 0], [-1, 0], [0, 1], [0, -1]): new_y, new_x = y+a, x+b if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != '#': if dist[new_y][new_x] == float("inf") or dist[new_y][new_x] > cnt: queue.appendleft((new_y, new_x, cnt)) dist[new_y][new_x] = cnt for a in range(-2, 3): for b in range(-2, 3): new_y, new_x = y + a, x + b if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != '#': if dist[new_y][new_x] == float("inf") or dist[new_y][new_x] > cnt + 1: queue.append((new_y, new_x, cnt+1)) dist[new_y][new_x] = cnt + 1 print((-1 if dist[dh][dw] == float("inf") else dist[dh][dw]))
from collections import deque H, W = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) ch -= 1 cw -= 1 dh -= 1 dw -= 1 maze = [] for i in range(H): h = list(eval(input())) maze.append(h) dist = [[float("inf") for _ in range(W)] for _ in range(H)] dist[ch][cw] = 0 queue = deque([(ch, cw, 0)]) while queue: y, x, d = queue.popleft() if y == dh and x == dw: print(d) exit() for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]): new_y, new_x = y + i, x + j if 0 <= new_y < H and 0 <= new_x < W: if maze[new_y][new_x] != '#': if dist[new_y][new_x] > d: dist[new_y][new_x] = d queue.appendleft((new_y, new_x, d)) for i in range(-2, 3): for j in range(-2, 3): new_y, new_x = y + i, x + j if 0 <= new_y < H and 0 <= new_x < W: if maze[new_y][new_x] != '#': if dist[new_y][new_x] > d+1: dist[new_y][new_x] = d+1 queue.append((new_y, new_x, d+1)) print((-1))
42
47
1,255
1,178
import sys from collections import deque input = lambda: sys.stdin.readline().rstrip() H, W = list(map(int, input().split())) ch, cw = list(map(int, input().split())) ch -= 1 cw -= 1 dh, dw = list(map(int, input().split())) dh -= 1 dw -= 1 maze = [] for i in range(H): a = list(eval(input())) maze.append(a) queue = deque([(ch, cw, 0)]) dist = [[float("inf") for _ in range(W)] for _ in range(H)] dist[ch][cw] = 0 while queue: y, x, cnt = queue.popleft() for a, b in ([1, 0], [-1, 0], [0, 1], [0, -1]): new_y, new_x = y + a, x + b if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != "#": if dist[new_y][new_x] == float("inf") or dist[new_y][new_x] > cnt: queue.appendleft((new_y, new_x, cnt)) dist[new_y][new_x] = cnt for a in range(-2, 3): for b in range(-2, 3): new_y, new_x = y + a, x + b if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != "#": if dist[new_y][new_x] == float("inf") or dist[new_y][new_x] > cnt + 1: queue.append((new_y, new_x, cnt + 1)) dist[new_y][new_x] = cnt + 1 print((-1 if dist[dh][dw] == float("inf") else dist[dh][dw]))
from collections import deque H, W = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) ch -= 1 cw -= 1 dh -= 1 dw -= 1 maze = [] for i in range(H): h = list(eval(input())) maze.append(h) dist = [[float("inf") for _ in range(W)] for _ in range(H)] dist[ch][cw] = 0 queue = deque([(ch, cw, 0)]) while queue: y, x, d = queue.popleft() if y == dh and x == dw: print(d) exit() for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]): new_y, new_x = y + i, x + j if 0 <= new_y < H and 0 <= new_x < W: if maze[new_y][new_x] != "#": if dist[new_y][new_x] > d: dist[new_y][new_x] = d queue.appendleft((new_y, new_x, d)) for i in range(-2, 3): for j in range(-2, 3): new_y, new_x = y + i, x + j if 0 <= new_y < H and 0 <= new_x < W: if maze[new_y][new_x] != "#": if dist[new_y][new_x] > d + 1: dist[new_y][new_x] = d + 1 queue.append((new_y, new_x, d + 1)) print((-1))
false
10.638298
[ "-import sys", "-input = lambda: sys.stdin.readline().rstrip()", "+dh, dw = list(map(int, input().split()))", "-dh, dw = list(map(int, input().split()))", "- a = list(eval(input()))", "- maze.append(a)", "-queue = deque([(ch, cw, 0)])", "+ h = list(eval(input()))", "+ maze.append(h)", "+queue = deque([(ch, cw, 0)])", "- y, x, cnt = queue.popleft()", "- for a, b in ([1, 0], [-1, 0], [0, 1], [0, -1]):", "- new_y, new_x = y + a, x + b", "- if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != \"#\":", "- if dist[new_y][new_x] == float(\"inf\") or dist[new_y][new_x] > cnt:", "- queue.appendleft((new_y, new_x, cnt))", "- dist[new_y][new_x] = cnt", "- for a in range(-2, 3):", "- for b in range(-2, 3):", "- new_y, new_x = y + a, x + b", "- if 0 <= new_y < H and 0 <= new_x < W and maze[new_y][new_x] != \"#\":", "- if dist[new_y][new_x] == float(\"inf\") or dist[new_y][new_x] > cnt + 1:", "- queue.append((new_y, new_x, cnt + 1))", "- dist[new_y][new_x] = cnt + 1", "-print((-1 if dist[dh][dw] == float(\"inf\") else dist[dh][dw]))", "+ y, x, d = queue.popleft()", "+ if y == dh and x == dw:", "+ print(d)", "+ exit()", "+ for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):", "+ new_y, new_x = y + i, x + j", "+ if 0 <= new_y < H and 0 <= new_x < W:", "+ if maze[new_y][new_x] != \"#\":", "+ if dist[new_y][new_x] > d:", "+ dist[new_y][new_x] = d", "+ queue.appendleft((new_y, new_x, d))", "+ for i in range(-2, 3):", "+ for j in range(-2, 3):", "+ new_y, new_x = y + i, x + j", "+ if 0 <= new_y < H and 0 <= new_x < W:", "+ if maze[new_y][new_x] != \"#\":", "+ if dist[new_y][new_x] > d + 1:", "+ dist[new_y][new_x] = d + 1", "+ queue.append((new_y, new_x, d + 1))", "+print((-1))" ]
false
0.066403
0.037399
1.775507
[ "s521393244", "s428857289" ]
u073729602
p02578
python
s095847675
s949904048
178
143
32,180
32,068
Accepted
Accepted
19.66
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 m = a[0] for i in range(1, n): m = max(a[i-1], m) if a[i] - m < 0: ans += abs(a[i] - m) print(ans)
n = int(eval(input())) a = list(map(int, input().split())) m = 1 ans = 0 for i in range(n): if m > a[i]: ans += m - a[i] m = max(a[i], m) print(ans)
9
9
184
166
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 m = a[0] for i in range(1, n): m = max(a[i - 1], m) if a[i] - m < 0: ans += abs(a[i] - m) print(ans)
n = int(eval(input())) a = list(map(int, input().split())) m = 1 ans = 0 for i in range(n): if m > a[i]: ans += m - a[i] m = max(a[i], m) print(ans)
false
0
[ "+m = 1", "-m = a[0]", "-for i in range(1, n):", "- m = max(a[i - 1], m)", "- if a[i] - m < 0:", "- ans += abs(a[i] - m)", "+for i in range(n):", "+ if m > a[i]:", "+ ans += m - a[i]", "+ m = max(a[i], m)" ]
false
0.040609
0.03588
1.131779
[ "s095847675", "s949904048" ]
u729133443
p03593
python
s545214376
s822866298
198
22
38,896
3,188
Accepted
Accepted
88.89
t,_,s=open(0).read().partition('\n') h,w=list(map(int,t.split())) a=b=c=0 if h%2and w%2: a=h//2*(w//2) c=1 b=(h*w-a*4-c)//2 elif h%2or w%2: a=h//2*(w//2) b=(h*w-a*4)//2 else: a=h*w//4 l=[] for i in set(s.replace('\n','')): l.append(s.count(i)) for i in l: if i>3: while i>3and a: i-=4 a-=1 if i>1: while i>1and b: i-=2 b-=1 if i and c: i-=1 c-=1 if all(not t for t in(a,b,c)): print('Yes') else: print('No')
t,_,s=open(0).read().partition('\n') h,w=list(map(int,t.split())) a=h//2*(w//2) c=h%2and w%2 b=(h*w-a*4-c)//2 l=[] for i in set(s.replace('\n','')): l.append(s.count(i)) for i in l: if i>3: while i>3and a: i-=4 a-=1 if i>1: while i>1and b: i-=2 b-=1 if i and c: i-=1 c-=1 if all(not t for t in(a,b,c)): print('Yes') else: print('No')
31
24
559
454
t, _, s = open(0).read().partition("\n") h, w = list(map(int, t.split())) a = b = c = 0 if h % 2 and w % 2: a = h // 2 * (w // 2) c = 1 b = (h * w - a * 4 - c) // 2 elif h % 2 or w % 2: a = h // 2 * (w // 2) b = (h * w - a * 4) // 2 else: a = h * w // 4 l = [] for i in set(s.replace("\n", "")): l.append(s.count(i)) for i in l: if i > 3: while i > 3 and a: i -= 4 a -= 1 if i > 1: while i > 1 and b: i -= 2 b -= 1 if i and c: i -= 1 c -= 1 if all(not t for t in (a, b, c)): print("Yes") else: print("No")
t, _, s = open(0).read().partition("\n") h, w = list(map(int, t.split())) a = h // 2 * (w // 2) c = h % 2 and w % 2 b = (h * w - a * 4 - c) // 2 l = [] for i in set(s.replace("\n", "")): l.append(s.count(i)) for i in l: if i > 3: while i > 3 and a: i -= 4 a -= 1 if i > 1: while i > 1 and b: i -= 2 b -= 1 if i and c: i -= 1 c -= 1 if all(not t for t in (a, b, c)): print("Yes") else: print("No")
false
22.580645
[ "-a = b = c = 0", "-if h % 2 and w % 2:", "- a = h // 2 * (w // 2)", "- c = 1", "- b = (h * w - a * 4 - c) // 2", "-elif h % 2 or w % 2:", "- a = h // 2 * (w // 2)", "- b = (h * w - a * 4) // 2", "-else:", "- a = h * w // 4", "+a = h // 2 * (w // 2)", "+c = h % 2 and w % 2", "+b = (h * w - a * 4 - c) // 2" ]
false
0.040234
0.034727
1.158599
[ "s545214376", "s822866298" ]
u933096856
p02413
python
s588511409
s862698142
50
40
7,708
7,636
Accepted
Accepted
20
r,c=map(int,input().split()) a,b=[],[0]*c for i in range(r): x=list(map(int,input().split())) print(*x, end=' ') print(sum(x)) for j in range(c): b[j]+=x[j] print(*b, end=' ') print(sum(b))
r,c=map(int,input().split()) a=[0]*c for i in range(r): x=list(map(int,input().split())) for j in range(c): a[j]+=x[j] print(*x, end=' ') print(sum(x)) print(*a, end=' ') print(sum(a))
10
10
222
217
r, c = map(int, input().split()) a, b = [], [0] * c for i in range(r): x = list(map(int, input().split())) print(*x, end=" ") print(sum(x)) for j in range(c): b[j] += x[j] print(*b, end=" ") print(sum(b))
r, c = map(int, input().split()) a = [0] * c for i in range(r): x = list(map(int, input().split())) for j in range(c): a[j] += x[j] print(*x, end=" ") print(sum(x)) print(*a, end=" ") print(sum(a))
false
0
[ "-a, b = [], [0] * c", "+a = [0] * c", "+ for j in range(c):", "+ a[j] += x[j]", "- for j in range(c):", "- b[j] += x[j]", "-print(*b, end=\" \")", "-print(sum(b))", "+print(*a, end=\" \")", "+print(sum(a))" ]
false
0.039831
0.044128
0.902616
[ "s588511409", "s862698142" ]
u297574184
p03428
python
s124030705
s559872163
48
19
3,444
3,188
Accepted
Accepted
60.42
from math import atan2, degrees N = int(eval(input())) holes = [tuple(map(int, input().split())) for i in range(N)] for x, y in holes: slopes = [] for x2, y2 in holes: if x == x2 and y == y2: continue slopes += [degrees(atan2(y2 - y, x2 - x))] aRange = [(0, 360)] for slope in slopes: f1 = (slope + 90) % 360 t1 = (slope - 90) % 360 if t1 == 0: t1 = 360 if f1 <= t1: fts = [(f1, t1)] else: fts = [(0, t1), (f1, 360)] aRange2 = [] for f, t in fts: for aFr, aTo in aRange: if aFr <= f: aFr = f if t <= aTo: aTo = t if aFr <= aTo: aRange2 += [(aFr, aTo)] aRange = aRange2 ans = 0 for aFr, aTo in aRange: ans += (aTo - aFr) / 360 print(ans)
import math # ใƒ™ใ‚ฏใƒˆใƒซ[p0->p1]ใซๅฏพใ™ใ‚‹ใ€็‚นp2ใฎไฝ็ฝฎ๏ผˆๅๆ™‚่จˆๅ›žใ‚Šใชใ‚‰ใฐใ€ใƒ—ใƒฉใ‚นใ‚’่ฟ”ใ™๏ผ‰ def ccw(p0, p1, p2): return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p1[1] - p0[1]) * (p2[0] - p0[0]) N = int(eval(input())) pts = [(tuple(map(int, input().split())), i) for i in range(N)] # ๅ‡ธๅŒ…ใ‚’ๆฑ‚ใ‚ใ‚‹ pts.sort() chU = [] # ไธŠๅด for pt, i in pts: while len(chU) >= 2 and ccw(chU[-2][0], chU[-1][0], pt) >= 0: chU.pop() chU.append((pt, i)) chL = [] # ไธ‹ๅด for pt, i in reversed(pts): while len(chL) >= 2 and ccw(chL[-2][0], chL[-1][0], pt) >= 0: chL.pop() chL.append((pt, i)) CH = chU[:-1] + chL[:-1] # ((x, y), i) # ๅ„็‚นใซๅฏพใ—ใฆใ€ๅ‡ธๅŒ…ไธŠใง้šฃๆŽฅใ™ใ‚‹๏ผ’็‚นใจใฎๅž‚็›ดไบŒ็ญ‰ๅˆ†็ทšใŒใชใ™่ง’ๅบฆใ‚’ๆฑ‚ใ‚ใ‚‹๏ผˆ360ยฐใซๅฏพใ—ใฆๅ ใ‚ใ‚‹ๅ‰ฒๅˆใŒ็ญ”ใˆ๏ผ‰ # ๏ผˆ้šฃๆŽฅใ™ใ‚‹๏ผ’่พบใฎๅ‚พๆ–œ่ง’ใฎๅทฎใซ็ญ‰ใ—ใ„ใฎใงใ€ใใ‚Œใ‚’่จˆ็ฎ—ใ™ใ‚‹๏ผ‰ aIn = math.atan2(CH[-1][0][1] - CH[0][0][1], CH[-1][0][0] - CH[0][0][0]) ptNow = CH[-1][0] anss = [0.0] * N for i in reversed(list(range(len(CH)))): iNow = CH[i][1] pt2 = CH[i - 1][0] aOut = math.atan2(pt2[1] - ptNow[1], pt2[0] - ptNow[0]) anss[iNow] = ((aOut - aIn) % (2 * math.pi)) / (2 * math.pi) ptNow = pt2 aIn = aOut for ans in anss: print(ans)
35
44
891
1,100
from math import atan2, degrees N = int(eval(input())) holes = [tuple(map(int, input().split())) for i in range(N)] for x, y in holes: slopes = [] for x2, y2 in holes: if x == x2 and y == y2: continue slopes += [degrees(atan2(y2 - y, x2 - x))] aRange = [(0, 360)] for slope in slopes: f1 = (slope + 90) % 360 t1 = (slope - 90) % 360 if t1 == 0: t1 = 360 if f1 <= t1: fts = [(f1, t1)] else: fts = [(0, t1), (f1, 360)] aRange2 = [] for f, t in fts: for aFr, aTo in aRange: if aFr <= f: aFr = f if t <= aTo: aTo = t if aFr <= aTo: aRange2 += [(aFr, aTo)] aRange = aRange2 ans = 0 for aFr, aTo in aRange: ans += (aTo - aFr) / 360 print(ans)
import math # ใƒ™ใ‚ฏใƒˆใƒซ[p0->p1]ใซๅฏพใ™ใ‚‹ใ€็‚นp2ใฎไฝ็ฝฎ๏ผˆๅๆ™‚่จˆๅ›žใ‚Šใชใ‚‰ใฐใ€ใƒ—ใƒฉใ‚นใ‚’่ฟ”ใ™๏ผ‰ def ccw(p0, p1, p2): return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p1[1] - p0[1]) * (p2[0] - p0[0]) N = int(eval(input())) pts = [(tuple(map(int, input().split())), i) for i in range(N)] # ๅ‡ธๅŒ…ใ‚’ๆฑ‚ใ‚ใ‚‹ pts.sort() chU = [] # ไธŠๅด for pt, i in pts: while len(chU) >= 2 and ccw(chU[-2][0], chU[-1][0], pt) >= 0: chU.pop() chU.append((pt, i)) chL = [] # ไธ‹ๅด for pt, i in reversed(pts): while len(chL) >= 2 and ccw(chL[-2][0], chL[-1][0], pt) >= 0: chL.pop() chL.append((pt, i)) CH = chU[:-1] + chL[:-1] # ((x, y), i) # ๅ„็‚นใซๅฏพใ—ใฆใ€ๅ‡ธๅŒ…ไธŠใง้šฃๆŽฅใ™ใ‚‹๏ผ’็‚นใจใฎๅž‚็›ดไบŒ็ญ‰ๅˆ†็ทšใŒใชใ™่ง’ๅบฆใ‚’ๆฑ‚ใ‚ใ‚‹๏ผˆ360ยฐใซๅฏพใ—ใฆๅ ใ‚ใ‚‹ๅ‰ฒๅˆใŒ็ญ”ใˆ๏ผ‰ # ๏ผˆ้šฃๆŽฅใ™ใ‚‹๏ผ’่พบใฎๅ‚พๆ–œ่ง’ใฎๅทฎใซ็ญ‰ใ—ใ„ใฎใงใ€ใใ‚Œใ‚’่จˆ็ฎ—ใ™ใ‚‹๏ผ‰ aIn = math.atan2(CH[-1][0][1] - CH[0][0][1], CH[-1][0][0] - CH[0][0][0]) ptNow = CH[-1][0] anss = [0.0] * N for i in reversed(list(range(len(CH)))): iNow = CH[i][1] pt2 = CH[i - 1][0] aOut = math.atan2(pt2[1] - ptNow[1], pt2[0] - ptNow[0]) anss[iNow] = ((aOut - aIn) % (2 * math.pi)) / (2 * math.pi) ptNow = pt2 aIn = aOut for ans in anss: print(ans)
false
20.454545
[ "-from math import atan2, degrees", "+import math", "+", "+# ใƒ™ใ‚ฏใƒˆใƒซ[p0->p1]ใซๅฏพใ™ใ‚‹ใ€็‚นp2ใฎไฝ็ฝฎ๏ผˆๅๆ™‚่จˆๅ›žใ‚Šใชใ‚‰ใฐใ€ใƒ—ใƒฉใ‚นใ‚’่ฟ”ใ™๏ผ‰", "+def ccw(p0, p1, p2):", "+ return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p1[1] - p0[1]) * (p2[0] - p0[0])", "+", "-holes = [tuple(map(int, input().split())) for i in range(N)]", "-for x, y in holes:", "- slopes = []", "- for x2, y2 in holes:", "- if x == x2 and y == y2:", "- continue", "- slopes += [degrees(atan2(y2 - y, x2 - x))]", "- aRange = [(0, 360)]", "- for slope in slopes:", "- f1 = (slope + 90) % 360", "- t1 = (slope - 90) % 360", "- if t1 == 0:", "- t1 = 360", "- if f1 <= t1:", "- fts = [(f1, t1)]", "- else:", "- fts = [(0, t1), (f1, 360)]", "- aRange2 = []", "- for f, t in fts:", "- for aFr, aTo in aRange:", "- if aFr <= f:", "- aFr = f", "- if t <= aTo:", "- aTo = t", "- if aFr <= aTo:", "- aRange2 += [(aFr, aTo)]", "- aRange = aRange2", "- ans = 0", "- for aFr, aTo in aRange:", "- ans += (aTo - aFr) / 360", "+pts = [(tuple(map(int, input().split())), i) for i in range(N)]", "+# ๅ‡ธๅŒ…ใ‚’ๆฑ‚ใ‚ใ‚‹", "+pts.sort()", "+chU = [] # ไธŠๅด", "+for pt, i in pts:", "+ while len(chU) >= 2 and ccw(chU[-2][0], chU[-1][0], pt) >= 0:", "+ chU.pop()", "+ chU.append((pt, i))", "+chL = [] # ไธ‹ๅด", "+for pt, i in reversed(pts):", "+ while len(chL) >= 2 and ccw(chL[-2][0], chL[-1][0], pt) >= 0:", "+ chL.pop()", "+ chL.append((pt, i))", "+CH = chU[:-1] + chL[:-1] # ((x, y), i)", "+# ๅ„็‚นใซๅฏพใ—ใฆใ€ๅ‡ธๅŒ…ไธŠใง้šฃๆŽฅใ™ใ‚‹๏ผ’็‚นใจใฎๅž‚็›ดไบŒ็ญ‰ๅˆ†็ทšใŒใชใ™่ง’ๅบฆใ‚’ๆฑ‚ใ‚ใ‚‹๏ผˆ360ยฐใซๅฏพใ—ใฆๅ ใ‚ใ‚‹ๅ‰ฒๅˆใŒ็ญ”ใˆ๏ผ‰", "+# ๏ผˆ้šฃๆŽฅใ™ใ‚‹๏ผ’่พบใฎๅ‚พๆ–œ่ง’ใฎๅทฎใซ็ญ‰ใ—ใ„ใฎใงใ€ใใ‚Œใ‚’่จˆ็ฎ—ใ™ใ‚‹๏ผ‰", "+aIn = math.atan2(CH[-1][0][1] - CH[0][0][1], CH[-1][0][0] - CH[0][0][0])", "+ptNow = CH[-1][0]", "+anss = [0.0] * N", "+for i in reversed(list(range(len(CH)))):", "+ iNow = CH[i][1]", "+ pt2 = CH[i - 1][0]", "+ aOut = math.atan2(pt2[1] - ptNow[1], pt2[0] - ptNow[0])", "+ anss[iNow] = ((aOut - aIn) % (2 * math.pi)) / (2 * math.pi)", "+ ptNow = pt2", "+ aIn = aOut", "+for ans in anss:" ]
false
0.038488
0.038091
1.010405
[ "s124030705", "s559872163" ]
u223663729
p02947
python
s204460973
s381851952
881
204
93,732
21,640
Accepted
Accepted
76.84
N, *S = open(0).read().split() S = [str(sorted(s)) for s in S] D = {} ans = 0 for s in S: if s in D: ans += D[s] D[s] += 1 else: D[s] = 1 print(ans)
from collections import Counter N, *S = open(0).read().split() S = [''.join(sorted(s)) for s in S] C = Counter(S) ans = 0 for k, v in list(C.items()): ans += v*(v-1)//2 print(ans)
11
10
190
189
N, *S = open(0).read().split() S = [str(sorted(s)) for s in S] D = {} ans = 0 for s in S: if s in D: ans += D[s] D[s] += 1 else: D[s] = 1 print(ans)
from collections import Counter N, *S = open(0).read().split() S = ["".join(sorted(s)) for s in S] C = Counter(S) ans = 0 for k, v in list(C.items()): ans += v * (v - 1) // 2 print(ans)
false
9.090909
[ "+from collections import Counter", "+", "-S = [str(sorted(s)) for s in S]", "-D = {}", "+S = [\"\".join(sorted(s)) for s in S]", "+C = Counter(S)", "-for s in S:", "- if s in D:", "- ans += D[s]", "- D[s] += 1", "- else:", "- D[s] = 1", "+for k, v in list(C.items()):", "+ ans += v * (v - 1) // 2" ]
false
0.045883
0.04278
1.072541
[ "s204460973", "s381851952" ]
u670180528
p03761
python
s702642460
s395542432
22
18
3,444
3,060
Accepted
Accepted
18.18
from collections import*;c=eval(("Counter(list(input()))&"*int(eval(input())))[:-1]);print(("".join(sorted(v*k for k,v in list(c.items())))))
_,*s=open(0);print(("".join(sorted(c*min(t.count(c)for t in s)for c in set(s[0])))))
1
1
127
82
from collections import * c = eval(("Counter(list(input()))&" * int(eval(input())))[:-1]) print(("".join(sorted(v * k for k, v in list(c.items())))))
_, *s = open(0) print(("".join(sorted(c * min(t.count(c) for t in s) for c in set(s[0])))))
false
0
[ "-from collections import *", "-", "-c = eval((\"Counter(list(input()))&\" * int(eval(input())))[:-1])", "-print((\"\".join(sorted(v * k for k, v in list(c.items())))))", "+_, *s = open(0)", "+print((\"\".join(sorted(c * min(t.count(c) for t in s) for c in set(s[0])))))" ]
false
0.036636
0.069404
0.527859
[ "s702642460", "s395542432" ]
u659753499
p03401
python
s335874912
s633060163
185
122
20,080
23,536
Accepted
Accepted
34.05
N = int(eval(input())) an = [0] + [int(i) for i in input().split()]+[0] t = sum([abs(an[i+1]-an[i]) for i in range(N+1)]) ts = [] for i in range(N): a,b,c = an[i:i+3] ts.append(t+(0 if 0 <= (a-b)*(b-c) else -2*(min(abs(a-b),abs(b-c))))) print(('\n'.join(map(str,ts))))
N = int(eval(input())) an = [0] + [int(i) for i in input().split()]+[0] cn = [abs(an[i+1]-an[i]) for i in range(N+1)] ct = sum(cn) cs = [ct-cn[i]-cn[i+1]+abs(an[i]-an[i+2]) for i in range(N)] print(('\n'.join(map(str,cs))))
8
6
272
221
N = int(eval(input())) an = [0] + [int(i) for i in input().split()] + [0] t = sum([abs(an[i + 1] - an[i]) for i in range(N + 1)]) ts = [] for i in range(N): a, b, c = an[i : i + 3] ts.append(t + (0 if 0 <= (a - b) * (b - c) else -2 * (min(abs(a - b), abs(b - c))))) print(("\n".join(map(str, ts))))
N = int(eval(input())) an = [0] + [int(i) for i in input().split()] + [0] cn = [abs(an[i + 1] - an[i]) for i in range(N + 1)] ct = sum(cn) cs = [ct - cn[i] - cn[i + 1] + abs(an[i] - an[i + 2]) for i in range(N)] print(("\n".join(map(str, cs))))
false
25
[ "-t = sum([abs(an[i + 1] - an[i]) for i in range(N + 1)])", "-ts = []", "-for i in range(N):", "- a, b, c = an[i : i + 3]", "- ts.append(t + (0 if 0 <= (a - b) * (b - c) else -2 * (min(abs(a - b), abs(b - c)))))", "-print((\"\\n\".join(map(str, ts))))", "+cn = [abs(an[i + 1] - an[i]) for i in range(N + 1)]", "+ct = sum(cn)", "+cs = [ct - cn[i] - cn[i + 1] + abs(an[i] - an[i + 2]) for i in range(N)]", "+print((\"\\n\".join(map(str, cs))))" ]
false
0.038699
0.056852
0.680705
[ "s335874912", "s633060163" ]
u346395915
p02897
python
s576324775
s327074937
20
17
2,940
2,940
Accepted
Accepted
15
n = int(eval(input())) if n%2 == 0: print((0.5)) else: print((1-(n-1)/2/n))
n = int(eval(input())) if n%2 == 0: print((0.5)) #ๆ•ดๆ•ฐNใŒๅถๆ•ฐใฎใจใ else: s = (n-1)/2 #ๅถๆ•ฐใฎๆ•ฐใ‚’็ขบ่ช s /= n #nใงๅ‰ฒใฃใฆๅถๆ•ฐใฎ็ขบ็އใ‚’ๆฑ‚ใ‚ใ‚‹ print((1-s)) #ๅ…จไฝ“ใ‹ใ‚‰ๅถๆ•ฐใฎ็ขบ็އใ‚’ๅผ•ใ„ใฆๅฅ‡ๆ•ฐใฎ็ขบ็އใ‚’ๆฑ‚ใ‚ใ‚‹
6
8
79
173
n = int(eval(input())) if n % 2 == 0: print((0.5)) else: print((1 - (n - 1) / 2 / n))
n = int(eval(input())) if n % 2 == 0: print((0.5)) # ๆ•ดๆ•ฐNใŒๅถๆ•ฐใฎใจใ else: s = (n - 1) / 2 # ๅถๆ•ฐใฎๆ•ฐใ‚’็ขบ่ช s /= n # nใงๅ‰ฒใฃใฆๅถๆ•ฐใฎ็ขบ็އใ‚’ๆฑ‚ใ‚ใ‚‹ print((1 - s)) # ๅ…จไฝ“ใ‹ใ‚‰ๅถๆ•ฐใฎ็ขบ็އใ‚’ๅผ•ใ„ใฆๅฅ‡ๆ•ฐใฎ็ขบ็އใ‚’ๆฑ‚ใ‚ใ‚‹
false
25
[ "- print((0.5))", "+ print((0.5)) # ๆ•ดๆ•ฐNใŒๅถๆ•ฐใฎใจใ", "- print((1 - (n - 1) / 2 / n))", "+ s = (n - 1) / 2 # ๅถๆ•ฐใฎๆ•ฐใ‚’็ขบ่ช", "+ s /= n # nใงๅ‰ฒใฃใฆๅถๆ•ฐใฎ็ขบ็އใ‚’ๆฑ‚ใ‚ใ‚‹", "+ print((1 - s)) # ๅ…จไฝ“ใ‹ใ‚‰ๅถๆ•ฐใฎ็ขบ็އใ‚’ๅผ•ใ„ใฆๅฅ‡ๆ•ฐใฎ็ขบ็އใ‚’ๆฑ‚ใ‚ใ‚‹" ]
false
0.039357
0.03831
1.02734
[ "s576324775", "s327074937" ]
u417220101
p02861
python
s605570398
s937061305
370
218
3,064
42,092
Accepted
Accepted
41.08
import math import itertools N = int(eval(input())) xy = [] for _ in range(N): xy.append(list(map(int, input().split()))) def get_dist(a, b): return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2) ans = 0 n = 0 for p in itertools.permutations(xy, N): d = 0 for i in range(len(p)-1): d += get_dist(p[i], p[i+1]) ans += d n += 1 print((ans / n))
# https://atcoder.jp/contests/abc145/tasks/abc145_c def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) INF = float("inf") import itertools N = INT() xy = [tuple(MAP()) for _ in range(N)] dist_list=[] for i in itertools.permutations(xy, N): dist = 0 for j in range(1, N): dist += ((i[j-1][0]-i[j][0])**2 + (i[j-1][1]-i[j][1])**2)**0.5 dist_list.append(dist) print((sum(dist_list)/len(dist_list)))
21
20
391
513
import math import itertools N = int(eval(input())) xy = [] for _ in range(N): xy.append(list(map(int, input().split()))) def get_dist(a, b): return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ans = 0 n = 0 for p in itertools.permutations(xy, N): d = 0 for i in range(len(p) - 1): d += get_dist(p[i], p[i + 1]) ans += d n += 1 print((ans / n))
# https://atcoder.jp/contests/abc145/tasks/abc145_c def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) INF = float("inf") import itertools N = INT() xy = [tuple(MAP()) for _ in range(N)] dist_list = [] for i in itertools.permutations(xy, N): dist = 0 for j in range(1, N): dist += ((i[j - 1][0] - i[j][0]) ** 2 + (i[j - 1][1] - i[j][1]) ** 2) ** 0.5 dist_list.append(dist) print((sum(dist_list) / len(dist_list)))
false
4.761905
[ "-import math", "+# https://atcoder.jp/contests/abc145/tasks/abc145_c", "+def INT():", "+ return int(eval(input()))", "+", "+", "+def MAP():", "+ return list(map(int, input().split()))", "+", "+", "+def LIST():", "+ return list(map(int, input().split()))", "+", "+", "+INF = float(\"inf\")", "-N = int(eval(input()))", "-xy = []", "-for _ in range(N):", "- xy.append(list(map(int, input().split())))", "-", "-", "-def get_dist(a, b):", "- return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)", "-", "-", "-ans = 0", "-n = 0", "-for p in itertools.permutations(xy, N):", "- d = 0", "- for i in range(len(p) - 1):", "- d += get_dist(p[i], p[i + 1])", "- ans += d", "- n += 1", "-print((ans / n))", "+N = INT()", "+xy = [tuple(MAP()) for _ in range(N)]", "+dist_list = []", "+for i in itertools.permutations(xy, N):", "+ dist = 0", "+ for j in range(1, N):", "+ dist += ((i[j - 1][0] - i[j][0]) ** 2 + (i[j - 1][1] - i[j][1]) ** 2) ** 0.5", "+ dist_list.append(dist)", "+print((sum(dist_list) / len(dist_list)))" ]
false
0.046559
0.045724
1.018251
[ "s605570398", "s937061305" ]
u001272273
p03038
python
s506129813
s469112266
749
613
42,712
42,676
Accepted
Accepted
18.16
import numpy as np N, M = list(map(int,input().split())) As = sorted(list(map(int,input().split()))) BCs = [] for i in range(M): inputs = list(map(int,input().split())) BCs.append(inputs) BCs = sorted(BCs, reverse = True, key=lambda x: x[1]) index = 0 for bc in BCs: b = bc[0] c = bc[1] for n in range(b): try: if As[index] < c: As[index] = c index += 1 else: break except: break print((sum(As)))
import numpy as np def main(): N, M = list(map(int,input().split())) As = sorted(list(map(int,input().split()))) BCs = [] for i in range(M): inputs = list(map(int,input().split())) BCs.append(inputs) BCs = sorted(BCs, reverse = True, key=lambda x: x[1]) index = 0 for bc in BCs: b = bc[0] c = bc[1] for n in range(b): try: if As[index] < c: As[index] = c index += 1 else: print((sum(As))) return except: print((sum(As))) return print((sum(As))) if __name__ == '__main__': main()
27
33
450
565
import numpy as np N, M = list(map(int, input().split())) As = sorted(list(map(int, input().split()))) BCs = [] for i in range(M): inputs = list(map(int, input().split())) BCs.append(inputs) BCs = sorted(BCs, reverse=True, key=lambda x: x[1]) index = 0 for bc in BCs: b = bc[0] c = bc[1] for n in range(b): try: if As[index] < c: As[index] = c index += 1 else: break except: break print((sum(As)))
import numpy as np def main(): N, M = list(map(int, input().split())) As = sorted(list(map(int, input().split()))) BCs = [] for i in range(M): inputs = list(map(int, input().split())) BCs.append(inputs) BCs = sorted(BCs, reverse=True, key=lambda x: x[1]) index = 0 for bc in BCs: b = bc[0] c = bc[1] for n in range(b): try: if As[index] < c: As[index] = c index += 1 else: print((sum(As))) return except: print((sum(As))) return print((sum(As))) if __name__ == "__main__": main()
false
18.181818
[ "-N, M = list(map(int, input().split()))", "-As = sorted(list(map(int, input().split())))", "-BCs = []", "-for i in range(M):", "- inputs = list(map(int, input().split()))", "- BCs.append(inputs)", "-BCs = sorted(BCs, reverse=True, key=lambda x: x[1])", "-index = 0", "-for bc in BCs:", "- b = bc[0]", "- c = bc[1]", "- for n in range(b):", "- try:", "- if As[index] < c:", "- As[index] = c", "- index += 1", "- else:", "- break", "- except:", "- break", "-print((sum(As)))", "+", "+def main():", "+ N, M = list(map(int, input().split()))", "+ As = sorted(list(map(int, input().split())))", "+ BCs = []", "+ for i in range(M):", "+ inputs = list(map(int, input().split()))", "+ BCs.append(inputs)", "+ BCs = sorted(BCs, reverse=True, key=lambda x: x[1])", "+ index = 0", "+ for bc in BCs:", "+ b = bc[0]", "+ c = bc[1]", "+ for n in range(b):", "+ try:", "+ if As[index] < c:", "+ As[index] = c", "+ index += 1", "+ else:", "+ print((sum(As)))", "+ return", "+ except:", "+ print((sum(As)))", "+ return", "+ print((sum(As)))", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.036962
0.037838
0.976857
[ "s506129813", "s469112266" ]
u619458041
p03008
python
s318928504
s954839681
973
897
230,168
230,040
Accepted
Accepted
7.81
import sys def main(): input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) dp = [0] * (N+1) for i in range(1, N+1): gold, silver, copper = 0, 0, 0 if i >= A[0]: gold = dp[i-A[0]] + B[0] if i >= A[1]: silver = dp[i-A[1]] + B[1] if i >= A[2]: copper = dp[i-A[2]] + B[2] dp[i] = max(i, gold, silver, copper) M = dp[N] dp = [0] * (M+1) for i in range(1, M+1): gold, silver, copper = 0, 0, 0 if i >= B[0]: gold = dp[i-B[0]] + A[0] if i >= B[1]: silver = dp[i-B[1]] + A[1] if i >= B[2]: copper = dp[i-B[2]] + A[2] dp[i] = max(i, gold, silver, copper) return dp[M] if __name__ == '__main__': print((main()))
import sys def trade(n, a, b): a0, a1, a2 = a b0, b1, b2 = b dp = [0] * (n+1) for i in range(1, n+1): gold, silver, copper = 0, 0, 0 if i >= a0: gold = dp[i-a0] + b0 if i >= a1: silver = dp[i-a1] + b1 if i >= a2: copper = dp[i-a2] + b2 dp[i] = max(i, gold, silver, copper) return dp[n] def main(): input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) # Trade A -> B M = trade(N, A, B) # Trade B -> A return trade(M, B, A) if __name__ == '__main__': print((main()))
36
33
900
697
import sys def main(): input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) dp = [0] * (N + 1) for i in range(1, N + 1): gold, silver, copper = 0, 0, 0 if i >= A[0]: gold = dp[i - A[0]] + B[0] if i >= A[1]: silver = dp[i - A[1]] + B[1] if i >= A[2]: copper = dp[i - A[2]] + B[2] dp[i] = max(i, gold, silver, copper) M = dp[N] dp = [0] * (M + 1) for i in range(1, M + 1): gold, silver, copper = 0, 0, 0 if i >= B[0]: gold = dp[i - B[0]] + A[0] if i >= B[1]: silver = dp[i - B[1]] + A[1] if i >= B[2]: copper = dp[i - B[2]] + A[2] dp[i] = max(i, gold, silver, copper) return dp[M] if __name__ == "__main__": print((main()))
import sys def trade(n, a, b): a0, a1, a2 = a b0, b1, b2 = b dp = [0] * (n + 1) for i in range(1, n + 1): gold, silver, copper = 0, 0, 0 if i >= a0: gold = dp[i - a0] + b0 if i >= a1: silver = dp[i - a1] + b1 if i >= a2: copper = dp[i - a2] + b2 dp[i] = max(i, gold, silver, copper) return dp[n] def main(): input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) # Trade A -> B M = trade(N, A, B) # Trade B -> A return trade(M, B, A) if __name__ == "__main__": print((main()))
false
8.333333
[ "+", "+", "+def trade(n, a, b):", "+ a0, a1, a2 = a", "+ b0, b1, b2 = b", "+ dp = [0] * (n + 1)", "+ for i in range(1, n + 1):", "+ gold, silver, copper = 0, 0, 0", "+ if i >= a0:", "+ gold = dp[i - a0] + b0", "+ if i >= a1:", "+ silver = dp[i - a1] + b1", "+ if i >= a2:", "+ copper = dp[i - a2] + b2", "+ dp[i] = max(i, gold, silver, copper)", "+ return dp[n]", "- dp = [0] * (N + 1)", "- for i in range(1, N + 1):", "- gold, silver, copper = 0, 0, 0", "- if i >= A[0]:", "- gold = dp[i - A[0]] + B[0]", "- if i >= A[1]:", "- silver = dp[i - A[1]] + B[1]", "- if i >= A[2]:", "- copper = dp[i - A[2]] + B[2]", "- dp[i] = max(i, gold, silver, copper)", "- M = dp[N]", "- dp = [0] * (M + 1)", "- for i in range(1, M + 1):", "- gold, silver, copper = 0, 0, 0", "- if i >= B[0]:", "- gold = dp[i - B[0]] + A[0]", "- if i >= B[1]:", "- silver = dp[i - B[1]] + A[1]", "- if i >= B[2]:", "- copper = dp[i - B[2]] + A[2]", "- dp[i] = max(i, gold, silver, copper)", "- return dp[M]", "+ # Trade A -> B", "+ M = trade(N, A, B)", "+ # Trade B -> A", "+ return trade(M, B, A)" ]
false
0.066741
0.077645
0.859563
[ "s318928504", "s954839681" ]
u639104973
p02952
python
s429868083
s192706956
61
46
11,884
6,720
Accepted
Accepted
24.59
N=int(eval(input())) S=set([]) for i in range(1,N+1): if i<10 or 99<i<1000 or 9999<i<100000 : S.add(i) print((len(S)))
N=int(eval(input())) print((len([x for x in range(1,N+1) if len(str(x))%2==1])))
6
2
121
73
N = int(eval(input())) S = set([]) for i in range(1, N + 1): if i < 10 or 99 < i < 1000 or 9999 < i < 100000: S.add(i) print((len(S)))
N = int(eval(input())) print((len([x for x in range(1, N + 1) if len(str(x)) % 2 == 1])))
false
66.666667
[ "-S = set([])", "-for i in range(1, N + 1):", "- if i < 10 or 99 < i < 1000 or 9999 < i < 100000:", "- S.add(i)", "-print((len(S)))", "+print((len([x for x in range(1, N + 1) if len(str(x)) % 2 == 1])))" ]
false
0.040712
0.068313
0.595973
[ "s429868083", "s192706956" ]
u287500079
p03457
python
s411100611
s029644672
349
263
3,064
5,200
Accepted
Accepted
24.64
import sys n = int(eval(input())) pret = 0 prex = 0 prey = 0 for i in range(n): t,x,y = list(map(int,input().split())) tmp = t - pret - abs(x - prex) - abs(y - prey) #print(t, x, y, tmp) if tmp >= 0 and tmp % 2 == 0: pret = t prex = x prey = y else: print('No') sys.exit() print('Yes')
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_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() pt = 0 px = 0 py = 0 for _ in range(n): t, x, y = MAP() tmp = abs(x - px) + abs(y - py) - (t - pt) if tmp > 0 or tmp % 2 != 0: print('No') exit() px = x py = y pt = t print('Yes')
17
33
349
988
import sys n = int(eval(input())) pret = 0 prex = 0 prey = 0 for i in range(n): t, x, y = list(map(int, input().split())) tmp = t - pret - abs(x - prex) - abs(y - prey) # print(t, x, y, tmp) if tmp >= 0 and tmp % 2 == 0: pret = t prex = x prey = y else: print("No") sys.exit() print("Yes")
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_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() pt = 0 px = 0 py = 0 for _ in range(n): t, x, y = MAP() tmp = abs(x - px) + abs(y - py) - (t - pt) if tmp > 0 or tmp % 2 != 0: print("No") exit() px = x py = y pt = t print("Yes")
false
48.484848
[ "-import sys", "+import sys, re, os", "+from collections import deque, defaultdict, Counter", "+from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians", "+from itertools import permutations, combinations, product, accumulate", "+from operator import itemgetter, mul", "+from copy import deepcopy", "+from string import ascii_lowercase, ascii_uppercase, digits", "+from fractions import gcd", "-n = int(eval(input()))", "-pret = 0", "-prex = 0", "-prey = 0", "-for i in range(n):", "- t, x, y = list(map(int, input().split()))", "- tmp = t - pret - abs(x - prex) - abs(y - prey)", "- # print(t, x, y, tmp)", "- if tmp >= 0 and tmp % 2 == 0:", "- pret = t", "- prex = x", "- prey = y", "- else:", "+", "+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()", "+pt = 0", "+px = 0", "+py = 0", "+for _ in range(n):", "+ t, x, y = MAP()", "+ tmp = abs(x - px) + abs(y - py) - (t - pt)", "+ if tmp > 0 or tmp % 2 != 0:", "- sys.exit()", "+ exit()", "+ px = x", "+ py = y", "+ pt = t" ]
false
0.036483
0.035413
1.030208
[ "s411100611", "s029644672" ]
u777283665
p03612
python
s410021077
s000119486
92
72
14,008
14,008
Accepted
Accepted
21.74
n = int(eval(input())) p = list(map(int, input().split())) x = [] for i in range(n): if p[i] - 1 == i: x.append('x') else: x.append('o') cnt = 0 for i in range(n-1): if x[i] == "x" and x[i+1] == 'o': cnt += 1 elif x[i] == "x" and x[i+1] == 'x': cnt += 1 x[i+1] = 'o' if x[n-1] == "x": cnt += 1 print(cnt)
n = int(eval(input())) p = list(map(int, input().split())) ans = 0 for i in range(n-1): if p[i]-1 == i: p[i], p[i+1] = p[i+1], p[i] ans += 1 if p[-1] == n: ans+=1 print(ans)
23
13
385
206
n = int(eval(input())) p = list(map(int, input().split())) x = [] for i in range(n): if p[i] - 1 == i: x.append("x") else: x.append("o") cnt = 0 for i in range(n - 1): if x[i] == "x" and x[i + 1] == "o": cnt += 1 elif x[i] == "x" and x[i + 1] == "x": cnt += 1 x[i + 1] = "o" if x[n - 1] == "x": cnt += 1 print(cnt)
n = int(eval(input())) p = list(map(int, input().split())) ans = 0 for i in range(n - 1): if p[i] - 1 == i: p[i], p[i + 1] = p[i + 1], p[i] ans += 1 if p[-1] == n: ans += 1 print(ans)
false
43.478261
[ "-x = []", "-for i in range(n):", "+ans = 0", "+for i in range(n - 1):", "- x.append(\"x\")", "- else:", "- x.append(\"o\")", "-cnt = 0", "-for i in range(n - 1):", "- if x[i] == \"x\" and x[i + 1] == \"o\":", "- cnt += 1", "- elif x[i] == \"x\" and x[i + 1] == \"x\":", "- cnt += 1", "- x[i + 1] = \"o\"", "-if x[n - 1] == \"x\":", "- cnt += 1", "-print(cnt)", "+ p[i], p[i + 1] = p[i + 1], p[i]", "+ ans += 1", "+if p[-1] == n:", "+ ans += 1", "+print(ans)" ]
false
0.153208
0.039508
3.877905
[ "s410021077", "s000119486" ]
u678167152
p03172
python
s629238795
s239308071
661
331
175,624
147,588
Accepted
Accepted
49.92
N, K = list(map(int, input().split())) A = list(map(int, input().split())) from itertools import groupby, accumulate, product, permutations, combinations def solve(N,K,A): mod = 10**9+7 dp = [[0]*(K+1) for _ in range(N+1)] #dp[i][j] iไบบ็›ฎใพใงใงjๅ€‹ใ‚’ๅˆ†ใ‘ใ‚‹ๅ ดๅˆใฎๆ•ฐ dp[0][0] = 1 for i in range(1,N+1): cum = list([x%mod for x in accumulate(dp[i-1])]) for j in range(K+1): dp[i][j] = cum[j] k = j-A[i-1] if k>0: dp[i][j] -= cum[k-1] ans = dp[N][K]%mod return ans print((solve(N,K,A)))
def solve(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) mod = 10**9+7 dp = [[0]*(K+2) for _ in range(N+1)] dp[0] = [0]+[1]*(K+1) for n in range(1,N+1): for k in range(1,K+2): dp[n][k] = (dp[n-1][k]-dp[n-1][max(0,k-A[n-1]-1)]+dp[n][k-1])%mod ans = (dp[-1][-1]-dp[-1][-2])%mod return ans print((solve()))
19
12
574
363
N, K = list(map(int, input().split())) A = list(map(int, input().split())) from itertools import groupby, accumulate, product, permutations, combinations def solve(N, K, A): mod = 10**9 + 7 dp = [[0] * (K + 1) for _ in range(N + 1)] # dp[i][j] iไบบ็›ฎใพใงใงjๅ€‹ใ‚’ๅˆ†ใ‘ใ‚‹ๅ ดๅˆใฎๆ•ฐ dp[0][0] = 1 for i in range(1, N + 1): cum = list([x % mod for x in accumulate(dp[i - 1])]) for j in range(K + 1): dp[i][j] = cum[j] k = j - A[i - 1] if k > 0: dp[i][j] -= cum[k - 1] ans = dp[N][K] % mod return ans print((solve(N, K, A)))
def solve(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) mod = 10**9 + 7 dp = [[0] * (K + 2) for _ in range(N + 1)] dp[0] = [0] + [1] * (K + 1) for n in range(1, N + 1): for k in range(1, K + 2): dp[n][k] = ( dp[n - 1][k] - dp[n - 1][max(0, k - A[n - 1] - 1)] + dp[n][k - 1] ) % mod ans = (dp[-1][-1] - dp[-1][-2]) % mod return ans print((solve()))
false
36.842105
[ "-N, K = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-from itertools import groupby, accumulate, product, permutations, combinations", "-", "-", "-def solve(N, K, A):", "+def solve():", "+ N, K = list(map(int, input().split()))", "+ A = list(map(int, input().split()))", "- dp = [[0] * (K + 1) for _ in range(N + 1)] # dp[i][j] iไบบ็›ฎใพใงใงjๅ€‹ใ‚’ๅˆ†ใ‘ใ‚‹ๅ ดๅˆใฎๆ•ฐ", "- dp[0][0] = 1", "- for i in range(1, N + 1):", "- cum = list([x % mod for x in accumulate(dp[i - 1])])", "- for j in range(K + 1):", "- dp[i][j] = cum[j]", "- k = j - A[i - 1]", "- if k > 0:", "- dp[i][j] -= cum[k - 1]", "- ans = dp[N][K] % mod", "+ dp = [[0] * (K + 2) for _ in range(N + 1)]", "+ dp[0] = [0] + [1] * (K + 1)", "+ for n in range(1, N + 1):", "+ for k in range(1, K + 2):", "+ dp[n][k] = (", "+ dp[n - 1][k] - dp[n - 1][max(0, k - A[n - 1] - 1)] + dp[n][k - 1]", "+ ) % mod", "+ ans = (dp[-1][-1] - dp[-1][-2]) % mod", "-print((solve(N, K, A)))", "+print((solve()))" ]
false
0.169011
0.511528
0.330405
[ "s629238795", "s239308071" ]
u983918956
p03559
python
s345044858
s366776395
363
321
23,076
23,240
Accepted
Accepted
11.57
from bisect import bisect_left,bisect N = int(eval(input())) info = [sorted(list(map(int,input().split()))) for i in range(3)] ans = 0 for j in range(N): small = bisect_left(info[0],info[1][j]) large = N - bisect(info[2],info[1][j]) ans += small * large print(ans)
from bisect import bisect,bisect_left N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) ans = 0 for b in B: ca = bisect_left(A,b) cc = N - bisect(C,b) ans += ca*cc print(ans)
9
15
278
300
from bisect import bisect_left, bisect N = int(eval(input())) info = [sorted(list(map(int, input().split()))) for i in range(3)] ans = 0 for j in range(N): small = bisect_left(info[0], info[1][j]) large = N - bisect(info[2], info[1][j]) ans += small * large print(ans)
from bisect import bisect, bisect_left N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans = 0 for b in B: ca = bisect_left(A, b) cc = N - bisect(C, b) ans += ca * cc print(ans)
false
40
[ "-from bisect import bisect_left, bisect", "+from bisect import bisect, bisect_left", "-info = [sorted(list(map(int, input().split()))) for i in range(3)]", "+A = sorted(list(map(int, input().split())))", "+B = sorted(list(map(int, input().split())))", "+C = sorted(list(map(int, input().split())))", "-for j in range(N):", "- small = bisect_left(info[0], info[1][j])", "- large = N - bisect(info[2], info[1][j])", "- ans += small * large", "+for b in B:", "+ ca = bisect_left(A, b)", "+ cc = N - bisect(C, b)", "+ ans += ca * cc" ]
false
0.098475
0.07006
1.405576
[ "s345044858", "s366776395" ]
u750990077
p02690
python
s601200796
s458163886
77
47
63,632
9,036
Accepted
Accepted
38.96
def main(): x = int(eval(input())) for i in range(-120, 121): for j in range(-120, 121): if i**5 - j**5 == x: print((i, j)) return if __name__ == "__main__": main()
def main(): x = int(eval(input())) for a in range(-120, 121): for b in range(-120, 121): if a**5 - b**5 == x: print((a, b)) return if __name__ == "__main__": main()
10
10
230
230
def main(): x = int(eval(input())) for i in range(-120, 121): for j in range(-120, 121): if i**5 - j**5 == x: print((i, j)) return if __name__ == "__main__": main()
def main(): x = int(eval(input())) for a in range(-120, 121): for b in range(-120, 121): if a**5 - b**5 == x: print((a, b)) return if __name__ == "__main__": main()
false
0
[ "- for i in range(-120, 121):", "- for j in range(-120, 121):", "- if i**5 - j**5 == x:", "- print((i, j))", "+ for a in range(-120, 121):", "+ for b in range(-120, 121):", "+ if a**5 - b**5 == x:", "+ print((a, b))" ]
false
0.054566
0.052339
1.042549
[ "s601200796", "s458163886" ]
u697116104
p02376
python
s751852150
s264859394
1,390
30
5,760
6,248
Accepted
Accepted
97.84
import sys sys.setrecursionlimit(200000) n,e = list(map(int,input().split())) g = [[] for i in range(n)] for i in range(e): a,b,c = list(map(int,input().split())) g[a].append([b,c,len(g[b])]) g[b].append([a,0,len(g[a])-1]) def dfs(x,t,f): if x == t: return f global used used[x] = 1 for j in range(len(g[x])): y, cap, rev = g[x][j] if cap and not used[y]: d = dfs(y,t,min(f,cap)) if d: g[x][j][1] -= d g[y][rev][1] += d return d return 0 flow = 0 f = INF = float("inf") while f: used = [0]*n f = dfs(0,n-1,INF) flow += f print(flow)
from collections import deque import sys sys.setrecursionlimit(200000) n,e = list(map(int,input().split())) g = [[] for i in range(n)] for i in range(e): a,b,c = list(map(int,input().split())) g[a].append([b,c,len(g[b])]) g[b].append([a,0,len(g[a])-1]) def bfs(s,t): global level que = deque([s]) level[s] = 0 while que: v = que.popleft() lv = level[v] +1 for y, cap, rev in g[v]: if cap and level[y] is None: level[y] = lv que.append(y) return level[t] if level[t] else 0 def dfs(x,t,f): if x == t: return f for j in range(it[x],len(g[x])): it[x] = j y, cap, rev = g[x][j] if cap and level[x] < level[y]: d = dfs(y,t,min(f,cap)) if d: g[x][j][1] -= d g[y][rev][1] += d return d return 0 flow = 0 f = INF = float("inf") level = [None]*n while bfs(0,n-1): it = [0]* n f = INF while f: f = dfs(0,n-1,INF) flow += f level = [None]*n print(flow)
31
47
625
1,005
import sys sys.setrecursionlimit(200000) n, e = list(map(int, input().split())) g = [[] for i in range(n)] for i in range(e): a, b, c = list(map(int, input().split())) g[a].append([b, c, len(g[b])]) g[b].append([a, 0, len(g[a]) - 1]) def dfs(x, t, f): if x == t: return f global used used[x] = 1 for j in range(len(g[x])): y, cap, rev = g[x][j] if cap and not used[y]: d = dfs(y, t, min(f, cap)) if d: g[x][j][1] -= d g[y][rev][1] += d return d return 0 flow = 0 f = INF = float("inf") while f: used = [0] * n f = dfs(0, n - 1, INF) flow += f print(flow)
from collections import deque import sys sys.setrecursionlimit(200000) n, e = list(map(int, input().split())) g = [[] for i in range(n)] for i in range(e): a, b, c = list(map(int, input().split())) g[a].append([b, c, len(g[b])]) g[b].append([a, 0, len(g[a]) - 1]) def bfs(s, t): global level que = deque([s]) level[s] = 0 while que: v = que.popleft() lv = level[v] + 1 for y, cap, rev in g[v]: if cap and level[y] is None: level[y] = lv que.append(y) return level[t] if level[t] else 0 def dfs(x, t, f): if x == t: return f for j in range(it[x], len(g[x])): it[x] = j y, cap, rev = g[x][j] if cap and level[x] < level[y]: d = dfs(y, t, min(f, cap)) if d: g[x][j][1] -= d g[y][rev][1] += d return d return 0 flow = 0 f = INF = float("inf") level = [None] * n while bfs(0, n - 1): it = [0] * n f = INF while f: f = dfs(0, n - 1, INF) flow += f level = [None] * n print(flow)
false
34.042553
[ "+from collections import deque", "+def bfs(s, t):", "+ global level", "+ que = deque([s])", "+ level[s] = 0", "+ while que:", "+ v = que.popleft()", "+ lv = level[v] + 1", "+ for y, cap, rev in g[v]:", "+ if cap and level[y] is None:", "+ level[y] = lv", "+ que.append(y)", "+ return level[t] if level[t] else 0", "+", "+", "- global used", "- used[x] = 1", "- for j in range(len(g[x])):", "+ for j in range(it[x], len(g[x])):", "+ it[x] = j", "- if cap and not used[y]:", "+ if cap and level[x] < level[y]:", "-while f:", "- used = [0] * n", "- f = dfs(0, n - 1, INF)", "- flow += f", "+level = [None] * n", "+while bfs(0, n - 1):", "+ it = [0] * n", "+ f = INF", "+ while f:", "+ f = dfs(0, n - 1, INF)", "+ flow += f", "+ level = [None] * n" ]
false
0.043415
0.036742
1.181636
[ "s751852150", "s264859394" ]
u744034042
p02713
python
s471213832
s849723536
1,997
1,370
9,044
9,072
Accepted
Accepted
31.4
from math import gcd K = int(eval(input())) c = 0 for i in range(1,K+1): for j in range(1,K+1): for l in range(1,K+1): a = gcd(gcd(i,j), l) c += a print(c)
from math import gcd K = int(eval(input())) c = 0 for i in range(1,K+1): for j in range(1,K+1): k = gcd(i,j) for l in range(1,K+1): a = gcd(k, l) c += a print(c)
11
11
199
211
from math import gcd K = int(eval(input())) c = 0 for i in range(1, K + 1): for j in range(1, K + 1): for l in range(1, K + 1): a = gcd(gcd(i, j), l) c += a print(c)
from math import gcd K = int(eval(input())) c = 0 for i in range(1, K + 1): for j in range(1, K + 1): k = gcd(i, j) for l in range(1, K + 1): a = gcd(k, l) c += a print(c)
false
0
[ "+ k = gcd(i, j)", "- a = gcd(gcd(i, j), l)", "+ a = gcd(k, l)" ]
false
0.057963
0.1412
0.410501
[ "s471213832", "s849723536" ]
u242031676
p03127
python
s858899180
s908922131
331
71
14,052
14,052
Accepted
Accepted
78.55
n, *a = list(map(int, open(0).read().split())) a.sort() ans = 1e10 for i in range(1, n): x, y = a[0], a[i] while y%x: y -= y//x*x x, y = y, x ans = min(ans, x) print(ans)
def gcd(a, b): if(a==0): return b if a<b: a,b=b,a while b: a,b=b,a%b return a n, *a = list(map(int, open(0).read().split())) g = 0 for i in a: g = gcd(g, i) print(g)
10
10
201
185
n, *a = list(map(int, open(0).read().split())) a.sort() ans = 1e10 for i in range(1, n): x, y = a[0], a[i] while y % x: y -= y // x * x x, y = y, x ans = min(ans, x) print(ans)
def gcd(a, b): if a == 0: return b if a < b: a, b = b, a while b: a, b = b, a % b return a n, *a = list(map(int, open(0).read().split())) g = 0 for i in a: g = gcd(g, i) print(g)
false
0
[ "+def gcd(a, b):", "+ if a == 0:", "+ return b", "+ if a < b:", "+ a, b = b, a", "+ while b:", "+ a, b = b, a % b", "+ return a", "+", "+", "-a.sort()", "-ans = 1e10", "-for i in range(1, n):", "- x, y = a[0], a[i]", "- while y % x:", "- y -= y // x * x", "- x, y = y, x", "- ans = min(ans, x)", "-print(ans)", "+g = 0", "+for i in a:", "+ g = gcd(g, i)", "+print(g)" ]
false
0.044377
0.039951
1.110786
[ "s858899180", "s908922131" ]
u532962080
p02402
python
s018267346
s681254888
30
10
7,108
7,040
Accepted
Accepted
66.67
n = eval(input()) xi = list(map(int, input().split())) print(("%d %d %d") %(min(xi), max(xi), sum(xi)))
n = eval(input()) x = list(map(int, input().split())) print(("%d %d %d") %(min(x), max(x), sum(x)))
3
3
96
92
n = eval(input()) xi = list(map(int, input().split())) print(("%d %d %d") % (min(xi), max(xi), sum(xi)))
n = eval(input()) x = list(map(int, input().split())) print(("%d %d %d") % (min(x), max(x), sum(x)))
false
0
[ "-xi = list(map(int, input().split()))", "-print((\"%d %d %d\") % (min(xi), max(xi), sum(xi)))", "+x = list(map(int, input().split()))", "+print((\"%d %d %d\") % (min(x), max(x), sum(x)))" ]
false
0.037168
0.038009
0.977877
[ "s018267346", "s681254888" ]
u888092736
p02862
python
s996891367
s115688217
1,120
162
127,692
9,208
Accepted
Accepted
85.54
def ncr(n, r): return fac[n] * facinv[r] * facinv[n - r] % MOD MOD = 10 ** 9 + 7 X, Y = list(map(int, input().split())) N = 10 ** 6 fac = [1, 1] facinv = [1, 1] inv = [0, 1] for i in range(2, N + 1): fac.append(fac[i - 1] * i % MOD) inv.append((-inv[MOD % i] * (MOD // i)) % MOD) facinv.append((facinv[-1] * inv[-1]) % MOD) if (X + Y) % 3 or Y > 2 * X or Y < X // 2: print((0)) exit() d = (X + Y) // 3 print((ncr(d, X - (X + Y) // 3)))
MOD = 10 ** 9 + 7 X, Y = list(map(int, input().split())) if (X + Y) % 3 or Y > 2 * X or Y < X // 2: print((0)) exit() n = (X + Y) // 3 r = X - (X + Y) // 3 num, den = 1, 1 if n - r < r: r = n - r for i in range(1, r + 1): num *= n - i + 1 num %= MOD den *= i den %= MOD print(((num * pow(den, MOD - 2, MOD)) % MOD))
21
19
474
354
def ncr(n, r): return fac[n] * facinv[r] * facinv[n - r] % MOD MOD = 10**9 + 7 X, Y = list(map(int, input().split())) N = 10**6 fac = [1, 1] facinv = [1, 1] inv = [0, 1] for i in range(2, N + 1): fac.append(fac[i - 1] * i % MOD) inv.append((-inv[MOD % i] * (MOD // i)) % MOD) facinv.append((facinv[-1] * inv[-1]) % MOD) if (X + Y) % 3 or Y > 2 * X or Y < X // 2: print((0)) exit() d = (X + Y) // 3 print((ncr(d, X - (X + Y) // 3)))
MOD = 10**9 + 7 X, Y = list(map(int, input().split())) if (X + Y) % 3 or Y > 2 * X or Y < X // 2: print((0)) exit() n = (X + Y) // 3 r = X - (X + Y) // 3 num, den = 1, 1 if n - r < r: r = n - r for i in range(1, r + 1): num *= n - i + 1 num %= MOD den *= i den %= MOD print(((num * pow(den, MOD - 2, MOD)) % MOD))
false
9.52381
[ "-def ncr(n, r):", "- return fac[n] * facinv[r] * facinv[n - r] % MOD", "-", "-", "-N = 10**6", "-fac = [1, 1]", "-facinv = [1, 1]", "-inv = [0, 1]", "-for i in range(2, N + 1):", "- fac.append(fac[i - 1] * i % MOD)", "- inv.append((-inv[MOD % i] * (MOD // i)) % MOD)", "- facinv.append((facinv[-1] * inv[-1]) % MOD)", "-d = (X + Y) // 3", "-print((ncr(d, X - (X + Y) // 3)))", "+n = (X + Y) // 3", "+r = X - (X + Y) // 3", "+num, den = 1, 1", "+if n - r < r:", "+ r = n - r", "+for i in range(1, r + 1):", "+ num *= n - i + 1", "+ num %= MOD", "+ den *= i", "+ den %= MOD", "+print(((num * pow(den, MOD - 2, MOD)) % MOD))" ]
false
2.227026
0.064688
34.427204
[ "s996891367", "s115688217" ]
u054514819
p03286
python
s020374993
s141340636
116
73
62,484
61,520
Accepted
Accepted
37.07
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) from itertools import accumulate from bisect import bisect_left if N==0: print((0)) elif N>0: even = [0, 1] for i in range(1, 21): even.append(2**(i*2)) cum = list(accumulate(even)) idx = bisect_left(cum, N) maxi = cum[idx]-cum[idx-1] val = N-cum[idx-1] ans = ['1'] up = maxi for i in range(maxi.bit_length()-1): up //= 2 if val>up: if i%2==0: ans.append('0') else: ans.append('1') val -= up else: if i%2==0: ans.append('1') else: ans.append('0') print((''.join(ans))) elif N<0: N = -N even = [0] for i in range(21): even.append(2**(i*2+1)) cum = list(accumulate(even)) idx = bisect_left(cum, N) maxi = cum[idx]-cum[idx-1] val = N-cum[idx-1] ans = ['1'] up = maxi for i in range(maxi.bit_length()-1): up //= 2 if val>up: if i%2==0: ans.append('0') else: ans.append('1') val -= up else: if i%2==0: ans.append('1') else: ans.append('0') print((''.join(ans)))
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) ans = [] for i in range(50): if N%2==1: ans.append('1') if i%2==0: N -= 1 else: N += 1 else: ans.append('0') N //= 2 if N==0: break print((''.join(ans[::-1])))
60
22
1,464
419
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) from itertools import accumulate from bisect import bisect_left if N == 0: print((0)) elif N > 0: even = [0, 1] for i in range(1, 21): even.append(2 ** (i * 2)) cum = list(accumulate(even)) idx = bisect_left(cum, N) maxi = cum[idx] - cum[idx - 1] val = N - cum[idx - 1] ans = ["1"] up = maxi for i in range(maxi.bit_length() - 1): up //= 2 if val > up: if i % 2 == 0: ans.append("0") else: ans.append("1") val -= up else: if i % 2 == 0: ans.append("1") else: ans.append("0") print(("".join(ans))) elif N < 0: N = -N even = [0] for i in range(21): even.append(2 ** (i * 2 + 1)) cum = list(accumulate(even)) idx = bisect_left(cum, N) maxi = cum[idx] - cum[idx - 1] val = N - cum[idx - 1] ans = ["1"] up = maxi for i in range(maxi.bit_length() - 1): up //= 2 if val > up: if i % 2 == 0: ans.append("0") else: ans.append("1") val -= up else: if i % 2 == 0: ans.append("1") else: ans.append("0") print(("".join(ans)))
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) ans = [] for i in range(50): if N % 2 == 1: ans.append("1") if i % 2 == 0: N -= 1 else: N += 1 else: ans.append("0") N //= 2 if N == 0: break print(("".join(ans[::-1])))
false
63.333333
[ "-from itertools import accumulate", "-from bisect import bisect_left", "-", "-if N == 0:", "- print((0))", "-elif N > 0:", "- even = [0, 1]", "- for i in range(1, 21):", "- even.append(2 ** (i * 2))", "- cum = list(accumulate(even))", "- idx = bisect_left(cum, N)", "- maxi = cum[idx] - cum[idx - 1]", "- val = N - cum[idx - 1]", "- ans = [\"1\"]", "- up = maxi", "- for i in range(maxi.bit_length() - 1):", "- up //= 2", "- if val > up:", "- if i % 2 == 0:", "- ans.append(\"0\")", "- else:", "- ans.append(\"1\")", "- val -= up", "+ans = []", "+for i in range(50):", "+ if N % 2 == 1:", "+ ans.append(\"1\")", "+ if i % 2 == 0:", "+ N -= 1", "- if i % 2 == 0:", "- ans.append(\"1\")", "- else:", "- ans.append(\"0\")", "- print((\"\".join(ans)))", "-elif N < 0:", "- N = -N", "- even = [0]", "- for i in range(21):", "- even.append(2 ** (i * 2 + 1))", "- cum = list(accumulate(even))", "- idx = bisect_left(cum, N)", "- maxi = cum[idx] - cum[idx - 1]", "- val = N - cum[idx - 1]", "- ans = [\"1\"]", "- up = maxi", "- for i in range(maxi.bit_length() - 1):", "- up //= 2", "- if val > up:", "- if i % 2 == 0:", "- ans.append(\"0\")", "- else:", "- ans.append(\"1\")", "- val -= up", "- else:", "- if i % 2 == 0:", "- ans.append(\"1\")", "- else:", "- ans.append(\"0\")", "- print((\"\".join(ans)))", "+ N += 1", "+ else:", "+ ans.append(\"0\")", "+ N //= 2", "+ if N == 0:", "+ break", "+print((\"\".join(ans[::-1])))" ]
false
0.070376
0.038062
1.848974
[ "s020374993", "s141340636" ]
u896741788
p03361
python
s351366879
s141586372
25
21
3,064
3,064
Accepted
Accepted
16
gyou,retu=map(int,input().split()) l=[input() for _ in range(gyou)] d=[(0,1),(1,0),(-1,0),(0,-1)] s=0 for g in range(gyou): for r in range(retu): if l[g][r]=="#": k=0 for x,y in d: try: if l[g+x][r+y]=="#" and g+x>=0 and r+y>=0: k+=1 except IndexError: pass if k==0: s+=1 break if s==1: break if s==1: break print("No") if s==1 else print("Yes")
gyou,retu=list(map(int,input().split())) l=[eval(input()) for _ in range(gyou)] d=[(0,1),(1,0),(-1,0),(0,-1)] for g in range(gyou): for r in range(retu): if l[g][r]=="#": k=0 for x,y in d: try: if l[g+x][r+y]=="#" and g+x>=0 and r+y>=0: k+=1 except IndexError: pass if k==0: print("No") exit() print("Yes")
22
17
470
398
gyou, retu = map(int, input().split()) l = [input() for _ in range(gyou)] d = [(0, 1), (1, 0), (-1, 0), (0, -1)] s = 0 for g in range(gyou): for r in range(retu): if l[g][r] == "#": k = 0 for x, y in d: try: if l[g + x][r + y] == "#" and g + x >= 0 and r + y >= 0: k += 1 except IndexError: pass if k == 0: s += 1 break if s == 1: break if s == 1: break print("No") if s == 1 else print("Yes")
gyou, retu = list(map(int, input().split())) l = [eval(input()) for _ in range(gyou)] d = [(0, 1), (1, 0), (-1, 0), (0, -1)] for g in range(gyou): for r in range(retu): if l[g][r] == "#": k = 0 for x, y in d: try: if l[g + x][r + y] == "#" and g + x >= 0 and r + y >= 0: k += 1 except IndexError: pass if k == 0: print("No") exit() print("Yes")
false
22.727273
[ "-gyou, retu = map(int, input().split())", "-l = [input() for _ in range(gyou)]", "+gyou, retu = list(map(int, input().split()))", "+l = [eval(input()) for _ in range(gyou)]", "-s = 0", "- s += 1", "- break", "- if s == 1:", "- break", "- if s == 1:", "- break", "-print(\"No\") if s == 1 else print(\"Yes\")", "+ print(\"No\")", "+ exit()", "+print(\"Yes\")" ]
false
0.043365
0.043893
0.987988
[ "s351366879", "s141586372" ]
u163320134
p02756
python
s238147503
s300124985
679
504
7,268
6,296
Accepted
Accepted
25.77
import collections s=eval(input()) t=collections.deque() t.append(s) q=int(eval(input())) flag=False for _ in range(q): query=list(map(str,input().split())) if query[0]=='1': if flag==False: flag=True else: flag=False elif query[0]=='2': if query[1]=='1': if flag==False: t.appendleft(query[2]) else: t.append(query[2]) else: if flag==False: t.append(query[2]) else: t.appendleft(query[2]) t=''.join(map(str,t)) if flag==False: print(t) else: print((t[::-1]))
s=eval(input()) q=int(eval(input())) head=[] tail=[] rev=False for _ in range(q): tmp=list(input().split()) if tmp[0]=='1': if rev==False: rev=True else: rev=False if tmp[0]=='2': if rev==False: if tmp[1]=='1': head.append(tmp[2]) if tmp[1]=='2': tail.append(tmp[2]) if rev==True: if tmp[1]=='1': tail.append(tmp[2]) if tmp[1]=='2': head.append(tmp[2]) head=''.join(map(str,head)) tail=''.join(map(str,tail)) ans=head[::-1]+s+tail if rev==True: ans=ans[::-1] print(ans)
30
29
569
577
import collections s = eval(input()) t = collections.deque() t.append(s) q = int(eval(input())) flag = False for _ in range(q): query = list(map(str, input().split())) if query[0] == "1": if flag == False: flag = True else: flag = False elif query[0] == "2": if query[1] == "1": if flag == False: t.appendleft(query[2]) else: t.append(query[2]) else: if flag == False: t.append(query[2]) else: t.appendleft(query[2]) t = "".join(map(str, t)) if flag == False: print(t) else: print((t[::-1]))
s = eval(input()) q = int(eval(input())) head = [] tail = [] rev = False for _ in range(q): tmp = list(input().split()) if tmp[0] == "1": if rev == False: rev = True else: rev = False if tmp[0] == "2": if rev == False: if tmp[1] == "1": head.append(tmp[2]) if tmp[1] == "2": tail.append(tmp[2]) if rev == True: if tmp[1] == "1": tail.append(tmp[2]) if tmp[1] == "2": head.append(tmp[2]) head = "".join(map(str, head)) tail = "".join(map(str, tail)) ans = head[::-1] + s + tail if rev == True: ans = ans[::-1] print(ans)
false
3.333333
[ "-import collections", "-", "-t = collections.deque()", "-t.append(s)", "-flag = False", "+head = []", "+tail = []", "+rev = False", "- query = list(map(str, input().split()))", "- if query[0] == \"1\":", "- if flag == False:", "- flag = True", "+ tmp = list(input().split())", "+ if tmp[0] == \"1\":", "+ if rev == False:", "+ rev = True", "- flag = False", "- elif query[0] == \"2\":", "- if query[1] == \"1\":", "- if flag == False:", "- t.appendleft(query[2])", "- else:", "- t.append(query[2])", "- else:", "- if flag == False:", "- t.append(query[2])", "- else:", "- t.appendleft(query[2])", "-t = \"\".join(map(str, t))", "-if flag == False:", "- print(t)", "-else:", "- print((t[::-1]))", "+ rev = False", "+ if tmp[0] == \"2\":", "+ if rev == False:", "+ if tmp[1] == \"1\":", "+ head.append(tmp[2])", "+ if tmp[1] == \"2\":", "+ tail.append(tmp[2])", "+ if rev == True:", "+ if tmp[1] == \"1\":", "+ tail.append(tmp[2])", "+ if tmp[1] == \"2\":", "+ head.append(tmp[2])", "+head = \"\".join(map(str, head))", "+tail = \"\".join(map(str, tail))", "+ans = head[::-1] + s + tail", "+if rev == True:", "+ ans = ans[::-1]", "+print(ans)" ]
false
0.03397
0.035248
0.963752
[ "s238147503", "s300124985" ]
u532966492
p03472
python
s652258273
s027391887
517
441
29,764
29,672
Accepted
Accepted
14.7
N,H=list(map(int,input().split())) ab=sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[1],reverse=True) ab_M=max([ab[i][0] for i in range(N)]) ab_m=min([ab[i][1] for i in range(N) if ab[i][0]==ab_M]) cnt=0 flag=0 for i in range(N): if ab[i][1]<=ab_M: break elif flag==0 and ab[i]==[ab_M,ab_m]: flag=1 else: H-=ab[i][1] cnt+=1 if H<=0: break if H>0: if H<=ab_m: print((cnt+1)) else: print((cnt+1+(H-ab_m+ab_M-1)//ab_M)) else: print(cnt)
N,H=list(map(int,input().split())) ab=sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[1],reverse=True) a_M=max([ab[i][0] for i in range(N)]) ans =0 for a,b in ab: if b <= a_M: break H -= b ans += 1 if H<=0:break if H>0: ans += (H-1)//a_M+1 print(ans)
23
14
563
311
N, H = list(map(int, input().split())) ab = sorted( [list(map(int, input().split())) for _ in range(N)], key=lambda x: x[1], reverse=True, ) ab_M = max([ab[i][0] for i in range(N)]) ab_m = min([ab[i][1] for i in range(N) if ab[i][0] == ab_M]) cnt = 0 flag = 0 for i in range(N): if ab[i][1] <= ab_M: break elif flag == 0 and ab[i] == [ab_M, ab_m]: flag = 1 else: H -= ab[i][1] cnt += 1 if H <= 0: break if H > 0: if H <= ab_m: print((cnt + 1)) else: print((cnt + 1 + (H - ab_m + ab_M - 1) // ab_M)) else: print(cnt)
N, H = list(map(int, input().split())) ab = sorted( [list(map(int, input().split())) for _ in range(N)], key=lambda x: x[1], reverse=True, ) a_M = max([ab[i][0] for i in range(N)]) ans = 0 for a, b in ab: if b <= a_M: break H -= b ans += 1 if H <= 0: break if H > 0: ans += (H - 1) // a_M + 1 print(ans)
false
39.130435
[ "-ab_M = max([ab[i][0] for i in range(N)])", "-ab_m = min([ab[i][1] for i in range(N) if ab[i][0] == ab_M])", "-cnt = 0", "-flag = 0", "-for i in range(N):", "- if ab[i][1] <= ab_M:", "+a_M = max([ab[i][0] for i in range(N)])", "+ans = 0", "+for a, b in ab:", "+ if b <= a_M:", "- elif flag == 0 and ab[i] == [ab_M, ab_m]:", "- flag = 1", "- else:", "- H -= ab[i][1]", "- cnt += 1", "- if H <= 0:", "- break", "+ H -= b", "+ ans += 1", "+ if H <= 0:", "+ break", "- if H <= ab_m:", "- print((cnt + 1))", "- else:", "- print((cnt + 1 + (H - ab_m + ab_M - 1) // ab_M))", "-else:", "- print(cnt)", "+ ans += (H - 1) // a_M + 1", "+print(ans)" ]
false
0.048953
0.088606
0.552483
[ "s652258273", "s027391887" ]
u867826040
p02621
python
s445710059
s640916311
33
27
9,148
9,008
Accepted
Accepted
18.18
a = int(eval(input())) print((a+a**2+a**3))
a = int(eval(input())) print((a+a*a+a*a*a))
2
2
36
37
a = int(eval(input())) print((a + a**2 + a**3))
a = int(eval(input())) print((a + a * a + a * a * a))
false
0
[ "-print((a + a**2 + a**3))", "+print((a + a * a + a * a * a))" ]
false
0.036232
0.031144
1.163393
[ "s445710059", "s640916311" ]
u718949306
p03775
python
s612077017
s761036305
186
30
38,896
3,060
Accepted
Accepted
83.87
import math N = int(eval(input())) ans = float('Inf') sq = int(math.sqrt(N)) + 1 for i in range(1, sq): if N % i == 0: a = len(str(i)) b = len(str(N // i)) if a > b: num = a else: num = b if ans > num: ans = num print(ans)
import math N = int(eval(input())) res = float('Inf') M = int(math.sqrt(N)) for A in range(1, M+1): if N % A == 0: B = int(N / A) a = len(str(A)) b = len(str(B)) c = max(a, b) if res > c: res = c print(res)
15
13
310
268
import math N = int(eval(input())) ans = float("Inf") sq = int(math.sqrt(N)) + 1 for i in range(1, sq): if N % i == 0: a = len(str(i)) b = len(str(N // i)) if a > b: num = a else: num = b if ans > num: ans = num print(ans)
import math N = int(eval(input())) res = float("Inf") M = int(math.sqrt(N)) for A in range(1, M + 1): if N % A == 0: B = int(N / A) a = len(str(A)) b = len(str(B)) c = max(a, b) if res > c: res = c print(res)
false
13.333333
[ "-ans = float(\"Inf\")", "-sq = int(math.sqrt(N)) + 1", "-for i in range(1, sq):", "- if N % i == 0:", "- a = len(str(i))", "- b = len(str(N // i))", "- if a > b:", "- num = a", "- else:", "- num = b", "- if ans > num:", "- ans = num", "-print(ans)", "+res = float(\"Inf\")", "+M = int(math.sqrt(N))", "+for A in range(1, M + 1):", "+ if N % A == 0:", "+ B = int(N / A)", "+ a = len(str(A))", "+ b = len(str(B))", "+ c = max(a, b)", "+ if res > c:", "+ res = c", "+print(res)" ]
false
0.062514
0.038173
1.637638
[ "s612077017", "s761036305" ]
u133936772
p02796
python
s377757831
s754719608
439
291
21,336
21,292
Accepted
Accepted
33.71
n = int(eval(input())) ll = [] for i in range(n): x, l = list(map(int, input().split())) ll.append([x-l, x+l]) ll.sort(key=lambda x:x[1]) ans = 0 tmp = -10**9 for l in ll: if l[0] >= tmp: ans += 1 tmp = l[1] print(ans)
import sys input = sys.stdin.readline n = int(eval(input())) ll = [] for i in range(n): x, l = list(map(int, input().split())) ll.append([x-l, x+l]) ll.sort(key=lambda x:x[1]) ans = 0 tmp = -10**9 for l in ll: if l[0] >= tmp: ans += 1 tmp = l[1] print(ans)
16
19
238
280
n = int(eval(input())) ll = [] for i in range(n): x, l = list(map(int, input().split())) ll.append([x - l, x + l]) ll.sort(key=lambda x: x[1]) ans = 0 tmp = -(10**9) for l in ll: if l[0] >= tmp: ans += 1 tmp = l[1] print(ans)
import sys input = sys.stdin.readline n = int(eval(input())) ll = [] for i in range(n): x, l = list(map(int, input().split())) ll.append([x - l, x + l]) ll.sort(key=lambda x: x[1]) ans = 0 tmp = -(10**9) for l in ll: if l[0] >= tmp: ans += 1 tmp = l[1] print(ans)
false
15.789474
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.036047
0.046101
0.78191
[ "s377757831", "s754719608" ]
u983918956
p03854
python
s555150307
s658075160
67
19
3,188
3,188
Accepted
Accepted
71.64
s = eval(input()) for i in range(len(s) // 5): if s[-5:] == "dream" or s[-5:] == "erase": s = s[:-5] elif s[-6:] == "eraser": s = s[:-6] elif s[-7:] == "dreamer": s = s[:-7] ans = "YES" if s == "" else "NO" print(ans)
s = eval(input()) str_list = ["eraser","erase","dreamer","dream"] for e in str_list: s = s.replace(e,"") ans = "YES" if s == "" else "NO" print(ans)
10
6
256
151
s = eval(input()) for i in range(len(s) // 5): if s[-5:] == "dream" or s[-5:] == "erase": s = s[:-5] elif s[-6:] == "eraser": s = s[:-6] elif s[-7:] == "dreamer": s = s[:-7] ans = "YES" if s == "" else "NO" print(ans)
s = eval(input()) str_list = ["eraser", "erase", "dreamer", "dream"] for e in str_list: s = s.replace(e, "") ans = "YES" if s == "" else "NO" print(ans)
false
40
[ "-for i in range(len(s) // 5):", "- if s[-5:] == \"dream\" or s[-5:] == \"erase\":", "- s = s[:-5]", "- elif s[-6:] == \"eraser\":", "- s = s[:-6]", "- elif s[-7:] == \"dreamer\":", "- s = s[:-7]", "+str_list = [\"eraser\", \"erase\", \"dreamer\", \"dream\"]", "+for e in str_list:", "+ s = s.replace(e, \"\")" ]
false
0.075622
0.035248
2.145429
[ "s555150307", "s658075160" ]
u123745130
p03228
python
s619483804
s934662649
29
22
9,188
9,100
Accepted
Accepted
24.14
a,b,k=list(map(int,input().split())) cnt=k while(k>0): if a %2==1: a-=1 b+=a//2 a//=2 cnt-=1 # print(a,b,k) else: b += a // 2 a//=2 cnt -= 1 if cnt==0: print((a,b)) break if b %2==1: b -= 1 a += b // 2 b//=2 cnt -= 1 # print(a,b,k) else: a += b // 2 b//=2 cnt -= 1 if cnt==0: print((a,b)) break
a,b,k=list(map(int,input().split())) for i in range(k): if i %2==0: b+=a//2 a//=2 else: a += b // 2 b //= 2 print((a,b))
31
9
521
161
a, b, k = list(map(int, input().split())) cnt = k while k > 0: if a % 2 == 1: a -= 1 b += a // 2 a //= 2 cnt -= 1 # print(a,b,k) else: b += a // 2 a //= 2 cnt -= 1 if cnt == 0: print((a, b)) break if b % 2 == 1: b -= 1 a += b // 2 b //= 2 cnt -= 1 # print(a,b,k) else: a += b // 2 b //= 2 cnt -= 1 if cnt == 0: print((a, b)) break
a, b, k = list(map(int, input().split())) for i in range(k): if i % 2 == 0: b += a // 2 a //= 2 else: a += b // 2 b //= 2 print((a, b))
false
70.967742
[ "-cnt = k", "-while k > 0:", "- if a % 2 == 1:", "- a -= 1", "+for i in range(k):", "+ if i % 2 == 0:", "- cnt -= 1", "- # print(a,b,k)", "- else:", "- b += a // 2", "- a //= 2", "- cnt -= 1", "- if cnt == 0:", "- print((a, b))", "- break", "- if b % 2 == 1:", "- b -= 1", "- a += b // 2", "- b //= 2", "- cnt -= 1", "- # print(a,b,k)", "- cnt -= 1", "- if cnt == 0:", "- print((a, b))", "- break", "+print((a, b))" ]
false
0.045486
0.142295
0.319662
[ "s619483804", "s934662649" ]
u263830634
p03599
python
s745373680
s550593148
270
21
12,456
3,064
Accepted
Accepted
92.22
import sys A, B, C, D, E, F = list(map(int, input().split())) def concentration(water, suger): if water * E/100 < suger or water + suger == 0: return 0 return (100 * suger/(water + suger)) lst_w = [] limit_w = (F+A*100-1)//(A*100) for i in range(limit_w): for j in range(limit_w): if 100 * (A * i + B * j) <= F: lst_w += [100 * (A * i + B * j)] lst_s = [] limit_s = (F+C-1)//C for i in range(limit_s): for j in range(limit_s): if C* i + D * j <= F: lst_s += [C * i + D * j] # print (lst_w) # print (lst_s) set_w = set(lst_w) set_s = set(lst_s) # print (set_w) # print (set_s) ans = 0 ans_total = 0 ans_suger = 0 for water in set_w: for suger in set_s: if water + suger <= F: a = concentration(water, suger) if ans < a: ans = a ans_total = water + suger ans_suger = suger if ans == 50: print((ans_total, ans_suger)) sys.exit() if ans == 0: print((A * 100, 0)) else: print((ans_total, ans_suger)) # print (ans)
A, B, C, D, E, F = list(map(int, input().split())) total = 100 * A sugar = 0 for a in range(F// (100 * A) + 1): for b in range((F - (100 * a)) // (100 * B) + 1): tmp_water = 100 * (A * a + B * b) if tmp_water == 0: continue maxC = min(tmp_water // 100 * E, F - tmp_water) #ๆบถใ‘ใ‚‹้‡ใจใƒ“ใƒผใ‚ซใƒผใฎ่ณช้‡ใฎๅ•้กŒ if maxC <= 0: continue # print (tmp_water) for c in range(0, maxC + 1, C): #Cใ‚ฐใƒฉใƒ ๅˆปใฟใงๅข—ใ‚„ใ™ # print ('c', c) left = maxC - c d = (left // D) * D tmp_sugar = c + d tmp_total = tmp_sugar + tmp_water if sugar * tmp_total < tmp_sugar * total: total = tmp_total sugar = tmp_sugar print((total, sugar))
52
30
1,160
818
import sys A, B, C, D, E, F = list(map(int, input().split())) def concentration(water, suger): if water * E / 100 < suger or water + suger == 0: return 0 return 100 * suger / (water + suger) lst_w = [] limit_w = (F + A * 100 - 1) // (A * 100) for i in range(limit_w): for j in range(limit_w): if 100 * (A * i + B * j) <= F: lst_w += [100 * (A * i + B * j)] lst_s = [] limit_s = (F + C - 1) // C for i in range(limit_s): for j in range(limit_s): if C * i + D * j <= F: lst_s += [C * i + D * j] # print (lst_w) # print (lst_s) set_w = set(lst_w) set_s = set(lst_s) # print (set_w) # print (set_s) ans = 0 ans_total = 0 ans_suger = 0 for water in set_w: for suger in set_s: if water + suger <= F: a = concentration(water, suger) if ans < a: ans = a ans_total = water + suger ans_suger = suger if ans == 50: print((ans_total, ans_suger)) sys.exit() if ans == 0: print((A * 100, 0)) else: print((ans_total, ans_suger)) # print (ans)
A, B, C, D, E, F = list(map(int, input().split())) total = 100 * A sugar = 0 for a in range(F // (100 * A) + 1): for b in range((F - (100 * a)) // (100 * B) + 1): tmp_water = 100 * (A * a + B * b) if tmp_water == 0: continue maxC = min(tmp_water // 100 * E, F - tmp_water) # ๆบถใ‘ใ‚‹้‡ใจใƒ“ใƒผใ‚ซใƒผใฎ่ณช้‡ใฎๅ•้กŒ if maxC <= 0: continue # print (tmp_water) for c in range(0, maxC + 1, C): # Cใ‚ฐใƒฉใƒ ๅˆปใฟใงๅข—ใ‚„ใ™ # print ('c', c) left = maxC - c d = (left // D) * D tmp_sugar = c + d tmp_total = tmp_sugar + tmp_water if sugar * tmp_total < tmp_sugar * total: total = tmp_total sugar = tmp_sugar print((total, sugar))
false
42.307692
[ "-import sys", "-", "-", "-", "-def concentration(water, suger):", "- if water * E / 100 < suger or water + suger == 0:", "- return 0", "- return 100 * suger / (water + suger)", "-", "-", "-lst_w = []", "-limit_w = (F + A * 100 - 1) // (A * 100)", "-for i in range(limit_w):", "- for j in range(limit_w):", "- if 100 * (A * i + B * j) <= F:", "- lst_w += [100 * (A * i + B * j)]", "-lst_s = []", "-limit_s = (F + C - 1) // C", "-for i in range(limit_s):", "- for j in range(limit_s):", "- if C * i + D * j <= F:", "- lst_s += [C * i + D * j]", "-# print (lst_w)", "-# print (lst_s)", "-set_w = set(lst_w)", "-set_s = set(lst_s)", "-# print (set_w)", "-# print (set_s)", "-ans = 0", "-ans_total = 0", "-ans_suger = 0", "-for water in set_w:", "- for suger in set_s:", "- if water + suger <= F:", "- a = concentration(water, suger)", "- if ans < a:", "- ans = a", "- ans_total = water + suger", "- ans_suger = suger", "- if ans == 50:", "- print((ans_total, ans_suger))", "- sys.exit()", "-if ans == 0:", "- print((A * 100, 0))", "-else:", "- print((ans_total, ans_suger))", "-# print (ans)", "+total = 100 * A", "+sugar = 0", "+for a in range(F // (100 * A) + 1):", "+ for b in range((F - (100 * a)) // (100 * B) + 1):", "+ tmp_water = 100 * (A * a + B * b)", "+ if tmp_water == 0:", "+ continue", "+ maxC = min(tmp_water // 100 * E, F - tmp_water) # ๆบถใ‘ใ‚‹้‡ใจใƒ“ใƒผใ‚ซใƒผใฎ่ณช้‡ใฎๅ•้กŒ", "+ if maxC <= 0:", "+ continue", "+ # print (tmp_water)", "+ for c in range(0, maxC + 1, C): # Cใ‚ฐใƒฉใƒ ๅˆปใฟใงๅข—ใ‚„ใ™", "+ # print ('c', c)", "+ left = maxC - c", "+ d = (left // D) * D", "+ tmp_sugar = c + d", "+ tmp_total = tmp_sugar + tmp_water", "+ if sugar * tmp_total < tmp_sugar * total:", "+ total = tmp_total", "+ sugar = tmp_sugar", "+print((total, sugar))" ]
false
0.524344
0.03569
14.691457
[ "s745373680", "s550593148" ]
u094191970
p02834
python
s422793678
s570084360
811
614
49,104
29,500
Accepted
Accepted
24.29
from collections import deque def BFS(s): tree=[[] for i in range(n)] for i in list: tree[i[0]-1].append(i[1]-1) tree[i[1]-1].append(i[0]-1) dist=[-1 for i in range(n)] dist[s-1]=0 que=deque() que.append(s-1) while que: x=que.popleft() for p in tree[x]: if dist[p]==-1: que.append(p) dist[p]=dist[x]+1 return dist n,u,v=list(map(int,input().split())) list=[list(map(int,input().split())) for i in range(n-1)] u_dist=BFS(u) v_dist=BFS(v) l=0 for u_d,v_d in zip(u_dist,v_dist): if u_d<v_d: l=max(l,v_d) print((l-1))
from collections import deque n,u,v=list(map(int,input().split())) tree=[[] for i in range(n)] for i in range(n-1): i,j=list(map(int,input().split())) tree[i-1].append(j-1) tree[j-1].append(i-1) def BFS(s): dist=[-1 for i in range(n)] dist[s]=0 que=deque() que.append(s) while que: x=que.popleft() for p in tree[x]: if dist[p]==-1: que.append(p) dist[p]=dist[x]+1 return dist u_dist=BFS(u-1) v_dist=BFS(v-1) l=0 for u_d,v_d in zip(u_dist,v_dist): if u_d<v_d: l=max(l,v_d) print((l-1))
33
35
574
540
from collections import deque def BFS(s): tree = [[] for i in range(n)] for i in list: tree[i[0] - 1].append(i[1] - 1) tree[i[1] - 1].append(i[0] - 1) dist = [-1 for i in range(n)] dist[s - 1] = 0 que = deque() que.append(s - 1) while que: x = que.popleft() for p in tree[x]: if dist[p] == -1: que.append(p) dist[p] = dist[x] + 1 return dist n, u, v = list(map(int, input().split())) list = [list(map(int, input().split())) for i in range(n - 1)] u_dist = BFS(u) v_dist = BFS(v) l = 0 for u_d, v_d in zip(u_dist, v_dist): if u_d < v_d: l = max(l, v_d) print((l - 1))
from collections import deque n, u, v = list(map(int, input().split())) tree = [[] for i in range(n)] for i in range(n - 1): i, j = list(map(int, input().split())) tree[i - 1].append(j - 1) tree[j - 1].append(i - 1) def BFS(s): dist = [-1 for i in range(n)] dist[s] = 0 que = deque() que.append(s) while que: x = que.popleft() for p in tree[x]: if dist[p] == -1: que.append(p) dist[p] = dist[x] + 1 return dist u_dist = BFS(u - 1) v_dist = BFS(v - 1) l = 0 for u_d, v_d in zip(u_dist, v_dist): if u_d < v_d: l = max(l, v_d) print((l - 1))
false
5.714286
[ "+", "+n, u, v = list(map(int, input().split()))", "+tree = [[] for i in range(n)]", "+for i in range(n - 1):", "+ i, j = list(map(int, input().split()))", "+ tree[i - 1].append(j - 1)", "+ tree[j - 1].append(i - 1)", "- tree = [[] for i in range(n)]", "- for i in list:", "- tree[i[0] - 1].append(i[1] - 1)", "- tree[i[1] - 1].append(i[0] - 1)", "- dist[s - 1] = 0", "+ dist[s] = 0", "- que.append(s - 1)", "+ que.append(s)", "-n, u, v = list(map(int, input().split()))", "-list = [list(map(int, input().split())) for i in range(n - 1)]", "-u_dist = BFS(u)", "-v_dist = BFS(v)", "+u_dist = BFS(u - 1)", "+v_dist = BFS(v - 1)" ]
false
0.040921
0.063481
0.644622
[ "s422793678", "s570084360" ]
u186838327
p02939
python
s777719881
s988645590
155
143
81,848
86,772
Accepted
Accepted
7.74
s = str(eval(input())) n = len(s) X = [''] temp = '' for i in range(n): temp += s[i] if temp == X[-1]: continue else: X.append(temp) temp = '' else: if temp != '': if temp == X[-1]: X[-1] += temp else: X.append(temp) #print(X) print((len(X)-1))
s = str(eval(input())) S = [] temp = '' for c in s: temp += c if S: if S[-1] != temp: S.append(temp) temp = '' else: S.append(temp) temp = '' print((len(S)))
21
14
339
224
s = str(eval(input())) n = len(s) X = [""] temp = "" for i in range(n): temp += s[i] if temp == X[-1]: continue else: X.append(temp) temp = "" else: if temp != "": if temp == X[-1]: X[-1] += temp else: X.append(temp) # print(X) print((len(X) - 1))
s = str(eval(input())) S = [] temp = "" for c in s: temp += c if S: if S[-1] != temp: S.append(temp) temp = "" else: S.append(temp) temp = "" print((len(S)))
false
33.333333
[ "-n = len(s)", "-X = [\"\"]", "+S = []", "-for i in range(n):", "- temp += s[i]", "- if temp == X[-1]:", "- continue", "+for c in s:", "+ temp += c", "+ if S:", "+ if S[-1] != temp:", "+ S.append(temp)", "+ temp = \"\"", "- X.append(temp)", "+ S.append(temp)", "-else:", "- if temp != \"\":", "- if temp == X[-1]:", "- X[-1] += temp", "- else:", "- X.append(temp)", "-# print(X)", "-print((len(X) - 1))", "+print((len(S)))" ]
false
0.049361
0.04599
1.073291
[ "s777719881", "s988645590" ]
u197300773
p03660
python
s293976379
s637575128
1,033
925
149,920
138,656
Accepted
Accepted
10.45
import sys sys.setrecursionlimit(10**7) def tree(p): for x in neighbor[p]: if x==par[p]: continue par[x]=p descend[p]+=tree(x) return descend[p] n=int(eval(input())) neighbor=[set() for _ in range(n+1)] descend=[1]*(n+1) par=[0]*(n+1) for _ in range(n-1): a,b=list(map(int,input().split())) neighbor[a].add(b) neighbor[b].add(a) tree(1) x=[descend[n]-1] t=n while t!=1: t,pret=par[t],t x.append(descend[t]-descend[pret]-1) l=len(x) p,q=sum(x[:l//2]),sum(x[l//2:]) if l%2==0: print(("Fennec" if p<q else "Snuke")) else: print(("Fennec" if p<=q else "Snuke"))
import sys sys.setrecursionlimit(10**7) def tree(p): for x in neighbor[p]: if x==par[p]: continue par[x]=p descend[p]+=tree(x) return descend[p] n=int(eval(input())) neighbor=[[] for _ in range(n+1)] descend=[1]*(n+1) par=[0]*(n+1) for _ in range(n-1): a,b=list(map(int,input().split())) neighbor[a].append(b) neighbor[b].append(a) tree(1) x=[descend[n]-1] t=n while t!=1: t,pret=par[t],t x.append(descend[t]-descend[pret]-1) l=len(x) p,q=sum(x[:l//2]),sum(x[l//2:]) if l%2==0: print(("Fennec" if p<q else "Snuke")) else: print(("Fennec" if p<=q else "Snuke"))
31
31
629
632
import sys sys.setrecursionlimit(10**7) def tree(p): for x in neighbor[p]: if x == par[p]: continue par[x] = p descend[p] += tree(x) return descend[p] n = int(eval(input())) neighbor = [set() for _ in range(n + 1)] descend = [1] * (n + 1) par = [0] * (n + 1) for _ in range(n - 1): a, b = list(map(int, input().split())) neighbor[a].add(b) neighbor[b].add(a) tree(1) x = [descend[n] - 1] t = n while t != 1: t, pret = par[t], t x.append(descend[t] - descend[pret] - 1) l = len(x) p, q = sum(x[: l // 2]), sum(x[l // 2 :]) if l % 2 == 0: print(("Fennec" if p < q else "Snuke")) else: print(("Fennec" if p <= q else "Snuke"))
import sys sys.setrecursionlimit(10**7) def tree(p): for x in neighbor[p]: if x == par[p]: continue par[x] = p descend[p] += tree(x) return descend[p] n = int(eval(input())) neighbor = [[] for _ in range(n + 1)] descend = [1] * (n + 1) par = [0] * (n + 1) for _ in range(n - 1): a, b = list(map(int, input().split())) neighbor[a].append(b) neighbor[b].append(a) tree(1) x = [descend[n] - 1] t = n while t != 1: t, pret = par[t], t x.append(descend[t] - descend[pret] - 1) l = len(x) p, q = sum(x[: l // 2]), sum(x[l // 2 :]) if l % 2 == 0: print(("Fennec" if p < q else "Snuke")) else: print(("Fennec" if p <= q else "Snuke"))
false
0
[ "-neighbor = [set() for _ in range(n + 1)]", "+neighbor = [[] for _ in range(n + 1)]", "- neighbor[a].add(b)", "- neighbor[b].add(a)", "+ neighbor[a].append(b)", "+ neighbor[b].append(a)" ]
false
0.084683
0.080758
1.0486
[ "s293976379", "s637575128" ]
u588235520
p02613
python
s197454905
s101640430
159
140
9,040
16,148
Accepted
Accepted
11.95
N = int(eval(input())) R = ["AC", "WA", "TLE", "RE"] C = [0, 0, 0, 0] for i in range(N): S = eval(input()) if S == R[0]: C[0] += 1 elif S == R[1]: C[1] += 1 elif S == R[2]: C[2] += 1 elif S == R[3]: C[3] += 1 for i in range(len(C)): print((R[i], "x", C[i]))
N = int(eval(input())) s = [eval(input()) for v in range(N)] for v in ["AC", "WA", "TLE", "RE"]: print(("{0} x {1}".format(v, s.count(v))))
18
4
319
132
N = int(eval(input())) R = ["AC", "WA", "TLE", "RE"] C = [0, 0, 0, 0] for i in range(N): S = eval(input()) if S == R[0]: C[0] += 1 elif S == R[1]: C[1] += 1 elif S == R[2]: C[2] += 1 elif S == R[3]: C[3] += 1 for i in range(len(C)): print((R[i], "x", C[i]))
N = int(eval(input())) s = [eval(input()) for v in range(N)] for v in ["AC", "WA", "TLE", "RE"]: print(("{0} x {1}".format(v, s.count(v))))
false
77.777778
[ "-R = [\"AC\", \"WA\", \"TLE\", \"RE\"]", "-C = [0, 0, 0, 0]", "-for i in range(N):", "- S = eval(input())", "- if S == R[0]:", "- C[0] += 1", "- elif S == R[1]:", "- C[1] += 1", "- elif S == R[2]:", "- C[2] += 1", "- elif S == R[3]:", "- C[3] += 1", "-for i in range(len(C)):", "- print((R[i], \"x\", C[i]))", "+s = [eval(input()) for v in range(N)]", "+for v in [\"AC\", \"WA\", \"TLE\", \"RE\"]:", "+ print((\"{0} x {1}\".format(v, s.count(v))))" ]
false
0.040057
0.044639
0.897345
[ "s197454905", "s101640430" ]
u754022296
p03164
python
s929795628
s961787199
1,026
296
310,808
22,644
Accepted
Accepted
71.15
n, W = list(map(int, input().split())) wv = [ list(map(int, input().split())) for _ in range(n) ] dp = [ [float("inf")]*(10**5+1) for _ in range(n+1) ] dp[0][0] = 0 for i in range(n): w, v = wv[i] for j in range(10**5+1): if j < v: dp[i+1][j] = dp[i][j] else: dp[i+1][j] = min(dp[i][j], dp[i][j-v]+w) ans = 0 for j in range(10**5+1): if dp[n][j] <= W: ans = j print(ans)
import numpy as np U = 10**5 n, W = list(map(int, input().split())) dp = np.full(U+1, float("inf")) dp[0] = 0 for _ in range(n): w, v = list(map(int, input().split())) np.minimum(dp[v:], dp[:-v]+w, out=dp[v:]) ans = np.where(dp <= W)[0][-1] print(ans)
16
11
409
254
n, W = list(map(int, input().split())) wv = [list(map(int, input().split())) for _ in range(n)] dp = [[float("inf")] * (10**5 + 1) for _ in range(n + 1)] dp[0][0] = 0 for i in range(n): w, v = wv[i] for j in range(10**5 + 1): if j < v: dp[i + 1][j] = dp[i][j] else: dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w) ans = 0 for j in range(10**5 + 1): if dp[n][j] <= W: ans = j print(ans)
import numpy as np U = 10**5 n, W = list(map(int, input().split())) dp = np.full(U + 1, float("inf")) dp[0] = 0 for _ in range(n): w, v = list(map(int, input().split())) np.minimum(dp[v:], dp[:-v] + w, out=dp[v:]) ans = np.where(dp <= W)[0][-1] print(ans)
false
31.25
[ "+import numpy as np", "+", "+U = 10**5", "-wv = [list(map(int, input().split())) for _ in range(n)]", "-dp = [[float(\"inf\")] * (10**5 + 1) for _ in range(n + 1)]", "-dp[0][0] = 0", "-for i in range(n):", "- w, v = wv[i]", "- for j in range(10**5 + 1):", "- if j < v:", "- dp[i + 1][j] = dp[i][j]", "- else:", "- dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w)", "-ans = 0", "-for j in range(10**5 + 1):", "- if dp[n][j] <= W:", "- ans = j", "+dp = np.full(U + 1, float(\"inf\"))", "+dp[0] = 0", "+for _ in range(n):", "+ w, v = list(map(int, input().split()))", "+ np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])", "+ans = np.where(dp <= W)[0][-1]" ]
false
1.218805
0.17395
7.006635
[ "s929795628", "s961787199" ]
u303739137
p02696
python
s640765883
s115302238
24
21
9,092
9,056
Accepted
Accepted
12.5
a, b, n = list(map(int, input().split())) val = (a*n)//b - a*(n//b) m = max(0,(n//b)*b-1) val = max(val, (a*m)//b - a*(m//b)) print(val)
a, b, n = list(map(int, input().split())) m = max(0,(n//b)*b-1) val = max((a*n)//b - a*(n//b), (a*m)//b - a*(m//b)) print(val)
5
4
134
123
a, b, n = list(map(int, input().split())) val = (a * n) // b - a * (n // b) m = max(0, (n // b) * b - 1) val = max(val, (a * m) // b - a * (m // b)) print(val)
a, b, n = list(map(int, input().split())) m = max(0, (n // b) * b - 1) val = max((a * n) // b - a * (n // b), (a * m) // b - a * (m // b)) print(val)
false
20
[ "-val = (a * n) // b - a * (n // b)", "-val = max(val, (a * m) // b - a * (m // b))", "+val = max((a * n) // b - a * (n // b), (a * m) // b - a * (m // b))" ]
false
0.04001
0.043095
0.928416
[ "s640765883", "s115302238" ]