user_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
1 value
submission_id_v0
stringlengths
10
10
submission_id_v1
stringlengths
10
10
cpu_time_v0
int64
10
38.3k
cpu_time_v1
int64
0
24.7k
memory_v0
int64
2.57k
1.02M
memory_v1
int64
2.57k
869k
status_v0
stringclasses
1 value
status_v1
stringclasses
1 value
improvement_frac
float64
7.51
100
input
stringlengths
20
4.55k
target
stringlengths
17
3.34k
code_v0_loc
int64
1
148
code_v1_loc
int64
1
184
code_v0_num_chars
int64
13
4.55k
code_v1_num_chars
int64
14
3.34k
code_v0_no_empty_lines
stringlengths
21
6.88k
code_v1_no_empty_lines
stringlengths
20
4.93k
code_same
bool
1 class
relative_loc_diff_percent
float64
0
79.8
diff
sequence
diff_only_import_comment
bool
1 class
measured_runtime_v0
float64
0.01
4.45
measured_runtime_v1
float64
0.01
4.31
runtime_lift
float64
0
359
key
sequence
u123756661
p03533
python
s052438311
s186822196
190
172
38,384
38,256
Accepted
Accepted
9.47
w=["AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","KIHBARA", "KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR","KIHBRA","KIHBAR","KIHABR","AKIHBR" ,"KIHBR"] s=eval(input()) ans=0 if s in w: ans=1 print((["NO","YES"][ans]))
w=[ "AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR","KIHBRA","KIHBAR","KIHABR","AKIHBR","KIHBR"] print((["NO","YES"][eval(input()) in w]))
5
2
228
199
w = [ "AKIHABARA", "KIHABARA", "AKIHBARA", "AKIHABRA", "AKIHABAR", "KIHBARA", "KIHABRA", "KIHABAR", "AKIHBRA", "AKIHBAR", "AKIHABR", "KIHBRA", "KIHBAR", "KIHABR", "AKIHBR", "KIHBR", ] s = eval(input()) ans = 0 if s in w: ans = 1 print((["NO", "YES"][ans]))
w = [ "AKIHABARA", "KIHABARA", "AKIHBARA", "AKIHABRA", "AKIHABAR", "KIHBARA", "KIHABRA", "KIHABAR", "AKIHBRA", "AKIHBAR", "AKIHABR", "KIHBRA", "KIHBAR", "KIHABR", "AKIHBR", "KIHBR", ] print((["NO", "YES"][eval(input()) in w]))
false
60
[ "-s = eval(input())", "-ans = 0", "-if s in w:", "- ans = 1", "-print(([\"NO\", \"YES\"][ans]))", "+print(([\"NO\", \"YES\"][eval(input()) in w]))" ]
false
0.04255
0.108758
0.391234
[ "s052438311", "s186822196" ]
u768199898
p02576
python
s157007359
s469163816
31
28
9,088
9,044
Accepted
Accepted
9.68
N,X,T = list(map(int,input().split())) if N %X == 0: print((N//X * T)) else: print(((N // X + 1)*T))
N,X,T = list(map(int,input().split())) num = N//X mode = N%X if mode == 0: print((num * T)) else: print(((num + 1)*T))
5
7
98
123
N, X, T = list(map(int, input().split())) if N % X == 0: print((N // X * T)) else: print(((N // X + 1) * T))
N, X, T = list(map(int, input().split())) num = N // X mode = N % X if mode == 0: print((num * T)) else: print(((num + 1) * T))
false
28.571429
[ "-if N % X == 0:", "- print((N // X * T))", "+num = N // X", "+mode = N % X", "+if mode == 0:", "+ print((num * T))", "- print(((N // X + 1) * T))", "+ print(((num + 1) * T))" ]
false
0.049104
0.048425
1.014023
[ "s157007359", "s469163816" ]
u761320129
p03593
python
s422950993
s470178868
24
22
3,380
3,316
Accepted
Accepted
8.33
H,W = list(map(int,input().split())) A = [eval(input()) for i in range(H)] from collections import Counter ctr = Counter() for row in A: ctr.update(row) if H%2==0 and W%2==0: print(('Yes' if all(v%4==0 for v in list(ctr.values())) else 'No')) elif H%2 and W%2: odd = 0 for k,v in list(ctr.items()): if v%2: odd += 1 ctr[k] -= 1 if odd != 1: print('No') exit() four = 0 for v in list(ctr.values()): four += (v//4)*4 want = (H-H%2)*(W-W%2) print(('Yes' if four >= want else 'No')) else: if any(v%2 for v in list(ctr.values())): print('No') exit() four = 0 for v in list(ctr.values()): four += (v//4)*4 want = (H-H%2)*(W-W%2) print(('Yes' if four >= want else 'No'))
from collections import Counter H,W = list(map(int,input().split())) A = [eval(input()) for i in range(H)] ctr = Counter() for row in A: ctr.update(row) if H%2==0 and W%2==0: print(('Yes' if all(v%4==0 for v in list(ctr.values())) else 'No')) exit() if H%2 and W%2: for k,v in list(ctr.items()): if v%2: ctr[k] -= 1 break if any(v%2 for v in list(ctr.values())): print('No') exit() if H%2 and W%2: two = W+H-1 elif H%2: two = W else: two = H for k,v in list(ctr.items()): if v%4==0: continue if two <= 0: print('No') exit() two -= 2 print(('No' if two%4==2 else 'Yes'))
32
35
783
664
H, W = list(map(int, input().split())) A = [eval(input()) for i in range(H)] from collections import Counter ctr = Counter() for row in A: ctr.update(row) if H % 2 == 0 and W % 2 == 0: print(("Yes" if all(v % 4 == 0 for v in list(ctr.values())) else "No")) elif H % 2 and W % 2: odd = 0 for k, v in list(ctr.items()): if v % 2: odd += 1 ctr[k] -= 1 if odd != 1: print("No") exit() four = 0 for v in list(ctr.values()): four += (v // 4) * 4 want = (H - H % 2) * (W - W % 2) print(("Yes" if four >= want else "No")) else: if any(v % 2 for v in list(ctr.values())): print("No") exit() four = 0 for v in list(ctr.values()): four += (v // 4) * 4 want = (H - H % 2) * (W - W % 2) print(("Yes" if four >= want else "No"))
from collections import Counter H, W = list(map(int, input().split())) A = [eval(input()) for i in range(H)] ctr = Counter() for row in A: ctr.update(row) if H % 2 == 0 and W % 2 == 0: print(("Yes" if all(v % 4 == 0 for v in list(ctr.values())) else "No")) exit() if H % 2 and W % 2: for k, v in list(ctr.items()): if v % 2: ctr[k] -= 1 break if any(v % 2 for v in list(ctr.values())): print("No") exit() if H % 2 and W % 2: two = W + H - 1 elif H % 2: two = W else: two = H for k, v in list(ctr.items()): if v % 4 == 0: continue if two <= 0: print("No") exit() two -= 2 print(("No" if two % 4 == 2 else "Yes"))
false
8.571429
[ "+from collections import Counter", "+", "-from collections import Counter", "-", "-elif H % 2 and W % 2:", "- odd = 0", "+ exit()", "+if H % 2 and W % 2:", "- odd += 1", "- if odd != 1:", "+ break", "+if any(v % 2 for v in list(ctr.values())):", "+ print(\"No\")", "+ exit()", "+if H % 2 and W % 2:", "+ two = W + H - 1", "+elif H % 2:", "+ two = W", "+else:", "+ two = H", "+for k, v in list(ctr.items()):", "+ if v % 4 == 0:", "+ continue", "+ if two <= 0:", "- four = 0", "- for v in list(ctr.values()):", "- four += (v // 4) * 4", "- want = (H - H % 2) * (W - W % 2)", "- print((\"Yes\" if four >= want else \"No\"))", "-else:", "- if any(v % 2 for v in list(ctr.values())):", "- print(\"No\")", "- exit()", "- four = 0", "- for v in list(ctr.values()):", "- four += (v // 4) * 4", "- want = (H - H % 2) * (W - W % 2)", "- print((\"Yes\" if four >= want else \"No\"))", "+ two -= 2", "+print((\"No\" if two % 4 == 2 else \"Yes\"))" ]
false
0.039856
0.10557
0.377532
[ "s422950993", "s470178868" ]
u351586819
p03220
python
s908304110
s181412062
41
18
3,064
3,060
Accepted
Accepted
56.1
N = int(eval(input())) T, A = list(map(int, input().split())) H = list(map(int, input().split())) AveT = [] diff = [] for i in range(N): AveT.append(T - H[i]*0.006) diff.append(abs(AveT[i] - A)) for i in range(N): if diff[i] == min(diff): place = i + 1 print(place)
N = int(eval(input())) T, A = list(map(int, input().split())) H = list(map(int, input().split())) AveT = [T - h*0.006 for h in H] diff = [abs(Ave_t - A) for Ave_t in AveT] print((diff.index(min(diff)) + 1))
15
7
281
205
N = int(eval(input())) T, A = list(map(int, input().split())) H = list(map(int, input().split())) AveT = [] diff = [] for i in range(N): AveT.append(T - H[i] * 0.006) diff.append(abs(AveT[i] - A)) for i in range(N): if diff[i] == min(diff): place = i + 1 print(place)
N = int(eval(input())) T, A = list(map(int, input().split())) H = list(map(int, input().split())) AveT = [T - h * 0.006 for h in H] diff = [abs(Ave_t - A) for Ave_t in AveT] print((diff.index(min(diff)) + 1))
false
53.333333
[ "-AveT = []", "-diff = []", "-for i in range(N):", "- AveT.append(T - H[i] * 0.006)", "- diff.append(abs(AveT[i] - A))", "-for i in range(N):", "- if diff[i] == min(diff):", "- place = i + 1", "-print(place)", "+AveT = [T - h * 0.006 for h in H]", "+diff = [abs(Ave_t - A) for Ave_t in AveT]", "+print((diff.index(min(diff)) + 1))" ]
false
0.098055
0.122886
0.797934
[ "s908304110", "s181412062" ]
u677121387
p02627
python
s597705703
s746831166
29
26
9,020
8,800
Accepted
Accepted
10.34
s = eval(input()) if 0 <= ord(s) - ord("a") <= 25: print("a") else: print("A")
a = eval(input()) print(("A" if a.isupper() else "a"))
5
2
84
47
s = eval(input()) if 0 <= ord(s) - ord("a") <= 25: print("a") else: print("A")
a = eval(input()) print(("A" if a.isupper() else "a"))
false
60
[ "-s = eval(input())", "-if 0 <= ord(s) - ord(\"a\") <= 25:", "- print(\"a\")", "-else:", "- print(\"A\")", "+a = eval(input())", "+print((\"A\" if a.isupper() else \"a\"))" ]
false
0.037987
0.040942
0.927816
[ "s597705703", "s746831166" ]
u888092736
p03162
python
s931372853
s895223117
1,052
955
47,328
47,324
Accepted
Accepted
9.22
n = int(eval(input())) ABC = [list(map(int, input().split())) for i in range(n)] # i日目にjを選択した後の幸福度 dp[i][j] dp = [[0 for j in range(3)] for i in range(n + 1)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + ABC[i][k]) print((max(dp[-1])))
import sys def input(): return sys.stdin.readline().strip() n = int(eval(input())) ABC = [list(map(int, input().split())) for i in range(n)] # i日目にjを選択した後の幸福度 dp[i][j] dp = [[0 for j in range(3)] for i in range(n + 1)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + ABC[i][k]) print((max(dp[-1])))
14
21
372
447
n = int(eval(input())) ABC = [list(map(int, input().split())) for i in range(n)] # i日目にjを選択した後の幸福度 dp[i][j] dp = [[0 for j in range(3)] for i in range(n + 1)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + ABC[i][k]) print((max(dp[-1])))
import sys def input(): return sys.stdin.readline().strip() n = int(eval(input())) ABC = [list(map(int, input().split())) for i in range(n)] # i日目にjを選択した後の幸福度 dp[i][j] dp = [[0 for j in range(3)] for i in range(n + 1)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + ABC[i][k]) print((max(dp[-1])))
false
33.333333
[ "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline().strip()", "+", "+" ]
false
0.047499
0.041085
1.156115
[ "s931372853", "s895223117" ]
u078349616
p03212
python
s086539921
s792476006
99
89
2,940
3,060
Accepted
Accepted
10.1
N = int(eval(input())) def dfs(s): if int(s) > N: return 0 else: if all(s.count(c) > 0 for c in "753"): cnt = 1 else: cnt = 0 for c in "753": cnt += dfs(s+c) return cnt print((dfs("0")))
N = int(eval(input())) ans = 0 def dfs(n): global ans if n > N: return else: if all(str(n).count(c) > 0 for c in "357"): ans += 1 dfs(10*n + 3) dfs(10*n + 5) dfs(10*n + 7) dfs(0) print(ans)
13
16
232
232
N = int(eval(input())) def dfs(s): if int(s) > N: return 0 else: if all(s.count(c) > 0 for c in "753"): cnt = 1 else: cnt = 0 for c in "753": cnt += dfs(s + c) return cnt print((dfs("0")))
N = int(eval(input())) ans = 0 def dfs(n): global ans if n > N: return else: if all(str(n).count(c) > 0 for c in "357"): ans += 1 dfs(10 * n + 3) dfs(10 * n + 5) dfs(10 * n + 7) dfs(0) print(ans)
false
18.75
[ "+ans = 0", "-def dfs(s):", "- if int(s) > N:", "- return 0", "+def dfs(n):", "+ global ans", "+ if n > N:", "+ return", "- if all(s.count(c) > 0 for c in \"753\"):", "- cnt = 1", "- else:", "- cnt = 0", "- for c in \"753\":", "- cnt += dfs(s + c)", "- return cnt", "+ if all(str(n).count(c) > 0 for c in \"357\"):", "+ ans += 1", "+ dfs(10 * n + 3)", "+ dfs(10 * n + 5)", "+ dfs(10 * n + 7)", "-print((dfs(\"0\")))", "+dfs(0)", "+print(ans)" ]
false
0.051533
0.052333
0.984697
[ "s086539921", "s792476006" ]
u801049006
p03161
python
s654995249
s203438212
2,000
456
22,736
55,008
Accepted
Accepted
77.2
import numpy as np N, K = list(map(int, input().split())) h = np.array(list(map(int, input().split()))) dp = np.zeros(N, dtype=int) for i in range(1, N): dp[i] = min(dp[max(0,i-K):i]+abs(h[max(0,i-K):i]-h[i])) print((dp[-1]))
N, K = list(map(int, input().split())) h = list(map(int, input().split())) dp = [float("inf")] * N dp[0] = 0 for i in range(1, N): for j in range(1, K+1): if i - j < 0: break else: step = abs(h[i] - h[i-j]) dp[i] = min(dp[i], dp[i-j]+step) print((dp[N-1]))
10
15
233
324
import numpy as np N, K = list(map(int, input().split())) h = np.array(list(map(int, input().split()))) dp = np.zeros(N, dtype=int) for i in range(1, N): dp[i] = min(dp[max(0, i - K) : i] + abs(h[max(0, i - K) : i] - h[i])) print((dp[-1]))
N, K = list(map(int, input().split())) h = list(map(int, input().split())) dp = [float("inf")] * N dp[0] = 0 for i in range(1, N): for j in range(1, K + 1): if i - j < 0: break else: step = abs(h[i] - h[i - j]) dp[i] = min(dp[i], dp[i - j] + step) print((dp[N - 1]))
false
33.333333
[ "-import numpy as np", "-", "-h = np.array(list(map(int, input().split())))", "-dp = np.zeros(N, dtype=int)", "+h = list(map(int, input().split()))", "+dp = [float(\"inf\")] * N", "+dp[0] = 0", "- dp[i] = min(dp[max(0, i - K) : i] + abs(h[max(0, i - K) : i] - h[i]))", "-print((dp[-1]))", "+ for j in range(1, K + 1):", "+ if i - j < 0:", "+ break", "+ else:", "+ step = abs(h[i] - h[i - j])", "+ dp[i] = min(dp[i], dp[i - j] + step)", "+print((dp[N - 1]))" ]
false
0.290137
0.041626
6.970058
[ "s654995249", "s203438212" ]
u347600233
p02708
python
s029451154
s588187802
76
61
9,144
9,128
Accepted
Accepted
19.74
n, k = list(map(int, input().split())) p = 10**9 + 7 cnt = 0 for i in range(k, n + 2): cnt += (i * (n - (i - 1)) + 1) % p print((cnt % p))
n, k = list(map(int, input().split())) cnt = 0 for i in range(k, n + 2): cnt += i * (n - i + 1) + 1 print((cnt % (10**9 + 7)))
6
5
139
126
n, k = list(map(int, input().split())) p = 10**9 + 7 cnt = 0 for i in range(k, n + 2): cnt += (i * (n - (i - 1)) + 1) % p print((cnt % p))
n, k = list(map(int, input().split())) cnt = 0 for i in range(k, n + 2): cnt += i * (n - i + 1) + 1 print((cnt % (10**9 + 7)))
false
16.666667
[ "-p = 10**9 + 7", "- cnt += (i * (n - (i - 1)) + 1) % p", "-print((cnt % p))", "+ cnt += i * (n - i + 1) + 1", "+print((cnt % (10**9 + 7)))" ]
false
0.057435
0.089114
0.644515
[ "s029451154", "s588187802" ]
u561231954
p03436
python
s290481301
s472660320
47
25
3,948
3,316
Accepted
Accepted
46.81
def main(): from queue import Queue h,w=list(map(int,input().split())) grid=[list(eval(input())) for i in range(h)] dx=[-1,0,1,0] dy=[0,1,0,-1] q=Queue() q.put([0,0]) inf=10**5 ans=[[inf]*w for i in range(h)] ans[0][0]=1 while q.qsize()!=0: p=q.get() ny,nx=p[0],p[1] for i in range(4): y=ny+dy[i] x=nx+dx[i] if 0<=x<w and 0<=y<h and ans[y][x]>10**4: if grid[y][x]=='.': ans[y][x]=ans[ny][nx]+1 q.put([y,x]) if ans[h-1][w-1]>10**4: print((-1)) else: cnt_white=sum([grid[i].count('.') for i in range(h)]) print((cnt_white-ans[h-1][w-1])) if __name__=='__main__': main()
dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque def main(): h,w = list(map(int,input().split())) grid = [eval(input()) for _ in range(h)] cnt_white = sum(row.count('.') for row in grid) dist = [[-1] * w for _ in range(h)] q = deque([(0,0)]) dist[0][0] = 1 while q: i,j = q.popleft() for k in range(4): y = i + dy[k] x = j + dx[k] if y < 0 or y >= h: continue if x < 0 or x >= w: continue if dist[y][x] < 0 and grid[y][x] == '.': dist[y][x] = dist[i][j] + 1 q.append((y,x)) ans = cnt_white - dist[-1][-1] print((ans if dist[-1][-1] >= 0 else -1)) if __name__ == '__main__': main()
30
29
783
809
def main(): from queue import Queue h, w = list(map(int, input().split())) grid = [list(eval(input())) for i in range(h)] dx = [-1, 0, 1, 0] dy = [0, 1, 0, -1] q = Queue() q.put([0, 0]) inf = 10**5 ans = [[inf] * w for i in range(h)] ans[0][0] = 1 while q.qsize() != 0: p = q.get() ny, nx = p[0], p[1] for i in range(4): y = ny + dy[i] x = nx + dx[i] if 0 <= x < w and 0 <= y < h and ans[y][x] > 10**4: if grid[y][x] == ".": ans[y][x] = ans[ny][nx] + 1 q.put([y, x]) if ans[h - 1][w - 1] > 10**4: print((-1)) else: cnt_white = sum([grid[i].count(".") for i in range(h)]) print((cnt_white - ans[h - 1][w - 1])) if __name__ == "__main__": main()
dy = (-1, 0, 1, 0) dx = (0, 1, 0, -1) from collections import deque def main(): h, w = list(map(int, input().split())) grid = [eval(input()) for _ in range(h)] cnt_white = sum(row.count(".") for row in grid) dist = [[-1] * w for _ in range(h)] q = deque([(0, 0)]) dist[0][0] = 1 while q: i, j = q.popleft() for k in range(4): y = i + dy[k] x = j + dx[k] if y < 0 or y >= h: continue if x < 0 or x >= w: continue if dist[y][x] < 0 and grid[y][x] == ".": dist[y][x] = dist[i][j] + 1 q.append((y, x)) ans = cnt_white - dist[-1][-1] print((ans if dist[-1][-1] >= 0 else -1)) if __name__ == "__main__": main()
false
3.333333
[ "+dy = (-1, 0, 1, 0)", "+dx = (0, 1, 0, -1)", "+from collections import deque", "+", "+", "- from queue import Queue", "-", "- grid = [list(eval(input())) for i in range(h)]", "- dx = [-1, 0, 1, 0]", "- dy = [0, 1, 0, -1]", "- q = Queue()", "- q.put([0, 0])", "- inf = 10**5", "- ans = [[inf] * w for i in range(h)]", "- ans[0][0] = 1", "- while q.qsize() != 0:", "- p = q.get()", "- ny, nx = p[0], p[1]", "- for i in range(4):", "- y = ny + dy[i]", "- x = nx + dx[i]", "- if 0 <= x < w and 0 <= y < h and ans[y][x] > 10**4:", "- if grid[y][x] == \".\":", "- ans[y][x] = ans[ny][nx] + 1", "- q.put([y, x])", "- if ans[h - 1][w - 1] > 10**4:", "- print((-1))", "- else:", "- cnt_white = sum([grid[i].count(\".\") for i in range(h)])", "- print((cnt_white - ans[h - 1][w - 1]))", "+ grid = [eval(input()) for _ in range(h)]", "+ cnt_white = sum(row.count(\".\") for row in grid)", "+ dist = [[-1] * w for _ in range(h)]", "+ q = deque([(0, 0)])", "+ dist[0][0] = 1", "+ while q:", "+ i, j = q.popleft()", "+ for k in range(4):", "+ y = i + dy[k]", "+ x = j + dx[k]", "+ if y < 0 or y >= h:", "+ continue", "+ if x < 0 or x >= w:", "+ continue", "+ if dist[y][x] < 0 and grid[y][x] == \".\":", "+ dist[y][x] = dist[i][j] + 1", "+ q.append((y, x))", "+ ans = cnt_white - dist[-1][-1]", "+ print((ans if dist[-1][-1] >= 0 else -1))" ]
false
0.050729
0.038033
1.333814
[ "s290481301", "s472660320" ]
u392319141
p04000
python
s092362183
s983232901
2,054
1,657
180,328
166,868
Accepted
Accepted
19.33
from itertools import product from collections import Counter H, W, N = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N)] D = tuple(product((-1, 0, 1), repeat=2)) cnt = Counter() for a, b in AB: for h, w in D: if 2 <= a + h <= H - 1 and 2 <= b + w <= W - 1: cnt[(a + h, b + w)] += 1 ans = [0] * 10 for c in cnt.values(): ans[c] += 1 ans[0] = (H - 2) * (W - 2) - sum(ans) print(*ans, sep='\n')
from collections import defaultdict from itertools import product H, W, N = map(int, input().split()) cnt = defaultdict(int) D = tuple(product((-1, 0, 1), repeat=2)) for _ in range(N): a, b = map(int, input().split()) for dh, dw in D: h = a + dh w = b + dw if 2 <= h <= H - 1 and 2 <= w <= W - 1: cnt[(h, w)] += 1 ans = [0] * 10 for c in cnt.values(): ans[c] += 1 ans[0] = (H - 2) * (W - 2) - sum(ans) print(*ans, sep='\n')
19
20
477
494
from itertools import product from collections import Counter H, W, N = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N)] D = tuple(product((-1, 0, 1), repeat=2)) cnt = Counter() for a, b in AB: for h, w in D: if 2 <= a + h <= H - 1 and 2 <= b + w <= W - 1: cnt[(a + h, b + w)] += 1 ans = [0] * 10 for c in cnt.values(): ans[c] += 1 ans[0] = (H - 2) * (W - 2) - sum(ans) print(*ans, sep="\n")
from collections import defaultdict from itertools import product H, W, N = map(int, input().split()) cnt = defaultdict(int) D = tuple(product((-1, 0, 1), repeat=2)) for _ in range(N): a, b = map(int, input().split()) for dh, dw in D: h = a + dh w = b + dw if 2 <= h <= H - 1 and 2 <= w <= W - 1: cnt[(h, w)] += 1 ans = [0] * 10 for c in cnt.values(): ans[c] += 1 ans[0] = (H - 2) * (W - 2) - sum(ans) print(*ans, sep="\n")
false
5
[ "+from collections import defaultdict", "-from collections import Counter", "-AB = [tuple(map(int, input().split())) for _ in range(N)]", "+cnt = defaultdict(int)", "-cnt = Counter()", "-for a, b in AB:", "- for h, w in D:", "- if 2 <= a + h <= H - 1 and 2 <= b + w <= W - 1:", "- cnt[(a + h, b + w)] += 1", "+for _ in range(N):", "+ a, b = map(int, input().split())", "+ for dh, dw in D:", "+ h = a + dh", "+ w = b + dw", "+ if 2 <= h <= H - 1 and 2 <= w <= W - 1:", "+ cnt[(h, w)] += 1" ]
false
0.047847
0.046633
1.026018
[ "s092362183", "s983232901" ]
u301624971
p03607
python
s074197767
s651663577
226
88
15,076
15,072
Accepted
Accepted
61.06
def myAnswer(N:int,dic:dict) -> int: ans = 0 for a in list(dic.values()): if(a % 2 == 1): ans += 1 return ans def modelAnswer(): return def main(): N = int(eval(input())) dic = {} for _ in range(N): a = int(eval(input())) if(a in list(dic.keys())): dic[a]+=1 else: dic[a]=1 print((myAnswer(N,dic))) if __name__ == '__main__': main()
import sys input = sys.stdin.readline def myAnswer(N:int,dic:dict) -> int: ans = 0 for a in list(dic.values()): if(a % 2 == 1): ans += 1 return ans def modelAnswer(): return def main(): N = int(eval(input())) dic = {} for _ in range(N): a = int(eval(input())) if(a in list(dic.keys())): dic[a]+=1 else: dic[a]=1 print((myAnswer(N,dic))) if __name__ == '__main__': main()
21
24
405
447
def myAnswer(N: int, dic: dict) -> int: ans = 0 for a in list(dic.values()): if a % 2 == 1: ans += 1 return ans def modelAnswer(): return def main(): N = int(eval(input())) dic = {} for _ in range(N): a = int(eval(input())) if a in list(dic.keys()): dic[a] += 1 else: dic[a] = 1 print((myAnswer(N, dic))) if __name__ == "__main__": main()
import sys input = sys.stdin.readline def myAnswer(N: int, dic: dict) -> int: ans = 0 for a in list(dic.values()): if a % 2 == 1: ans += 1 return ans def modelAnswer(): return def main(): N = int(eval(input())) dic = {} for _ in range(N): a = int(eval(input())) if a in list(dic.keys()): dic[a] += 1 else: dic[a] = 1 print((myAnswer(N, dic))) if __name__ == "__main__": main()
false
12.5
[ "+import sys", "+", "+input = sys.stdin.readline", "+", "+" ]
false
0.036582
0.035941
1.017831
[ "s074197767", "s651663577" ]
u760569096
p02947
python
s165153417
s647212029
1,109
369
23,992
22,444
Accepted
Accepted
66.73
from collections import defaultdict d = defaultdict(int) n = int(eval(input())) for _ in range(n): a = eval(input()) g = [0]*26 for i in a: g[ord(i)-97]+=1 b = '' for i in g: b+=str(i) d[b]+=1 cnt = 0 for k,v in list(d.items()): if v > 1: cnt += v*(v-1)//2 print(cnt)
from collections import defaultdict d = defaultdict(int) n = int(eval(input())) cnt = 0 for _ in range(n): a = eval(input()) b = '' for i in sorted(a): b += i cnt += d[b] d[b] += 1 print(cnt)
17
12
291
204
from collections import defaultdict d = defaultdict(int) n = int(eval(input())) for _ in range(n): a = eval(input()) g = [0] * 26 for i in a: g[ord(i) - 97] += 1 b = "" for i in g: b += str(i) d[b] += 1 cnt = 0 for k, v in list(d.items()): if v > 1: cnt += v * (v - 1) // 2 print(cnt)
from collections import defaultdict d = defaultdict(int) n = int(eval(input())) cnt = 0 for _ in range(n): a = eval(input()) b = "" for i in sorted(a): b += i cnt += d[b] d[b] += 1 print(cnt)
false
29.411765
[ "+cnt = 0", "- g = [0] * 26", "- for i in a:", "- g[ord(i) - 97] += 1", "- for i in g:", "- b += str(i)", "+ for i in sorted(a):", "+ b += i", "+ cnt += d[b]", "-cnt = 0", "-for k, v in list(d.items()):", "- if v > 1:", "- cnt += v * (v - 1) // 2" ]
false
0.03712
0.03758
0.987767
[ "s165153417", "s647212029" ]
u994988729
p03142
python
s190030830
s301288739
1,484
448
53,024
37,468
Accepted
Accepted
69.81
from collections import deque import numpy as np import sys input = sys.stdin.readline N, M = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N + M - 1)] e_from = [[] for _ in range(N+1)] e_to = [[] for _ in range(N+1)] for a, b in AB: e_from[a].append(b) e_to[b].append(a) add = np.zeros(N+1, dtype=int) rank = [-1]*(N+1) # まず根を探す for i in range(1, N+1): add[i] = len(e_to[i]) if len(e_to[i]) == 0: root = i # BFS rank[root] = 0 node = deque([root]) while node: s = node.popleft() add[e_from[s]] -= 1 for t in e_from[s]: if add[t] == 0: rank[t] = s node.append(t) print(*rank[1:], sep="\n")
import sys input = sys.stdin.readline N, M = map(int, input().split()) e_out = [[] for _ in range(N + 1)] e_in = [[] for _ in range(N + 1)] for _ in range(N + M - 1): a, b = map(int, input().split()) e_out[a].append(b) e_in[b].append(a) # 1. 入次数が0のやつが親 # 2. 親が決まれば、そのこの入次数を減らす,1に戻る # 親を決めるよ for i, e in enumerate(e_in[1:], start=1): if len(e) == 0: root = i break node = [root] parent = [-1] * (N + 1) parent[root] = 0 diff = [0] * (N + 1) # 入次数をどれだけ減らすか while node: s = node.pop() for t in e_out[s]: diff[t] += 1 if len(e_in[t]) - diff[t] == 0: parent[t] = s node.append(t) print(*parent[1:], sep="\n")
35
35
732
726
from collections import deque import numpy as np import sys input = sys.stdin.readline N, M = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N + M - 1)] e_from = [[] for _ in range(N + 1)] e_to = [[] for _ in range(N + 1)] for a, b in AB: e_from[a].append(b) e_to[b].append(a) add = np.zeros(N + 1, dtype=int) rank = [-1] * (N + 1) # まず根を探す for i in range(1, N + 1): add[i] = len(e_to[i]) if len(e_to[i]) == 0: root = i # BFS rank[root] = 0 node = deque([root]) while node: s = node.popleft() add[e_from[s]] -= 1 for t in e_from[s]: if add[t] == 0: rank[t] = s node.append(t) print(*rank[1:], sep="\n")
import sys input = sys.stdin.readline N, M = map(int, input().split()) e_out = [[] for _ in range(N + 1)] e_in = [[] for _ in range(N + 1)] for _ in range(N + M - 1): a, b = map(int, input().split()) e_out[a].append(b) e_in[b].append(a) # 1. 入次数が0のやつが親 # 2. 親が決まれば、そのこの入次数を減らす,1に戻る # 親を決めるよ for i, e in enumerate(e_in[1:], start=1): if len(e) == 0: root = i break node = [root] parent = [-1] * (N + 1) parent[root] = 0 diff = [0] * (N + 1) # 入次数をどれだけ減らすか while node: s = node.pop() for t in e_out[s]: diff[t] += 1 if len(e_in[t]) - diff[t] == 0: parent[t] = s node.append(t) print(*parent[1:], sep="\n")
false
0
[ "-from collections import deque", "-import numpy as np", "-AB = [tuple(map(int, input().split())) for _ in range(N + M - 1)]", "-e_from = [[] for _ in range(N + 1)]", "-e_to = [[] for _ in range(N + 1)]", "-for a, b in AB:", "- e_from[a].append(b)", "- e_to[b].append(a)", "-add = np.zeros(N + 1, dtype=int)", "-rank = [-1] * (N + 1)", "-# まず根を探す", "-for i in range(1, N + 1):", "- add[i] = len(e_to[i])", "- if len(e_to[i]) == 0:", "+e_out = [[] for _ in range(N + 1)]", "+e_in = [[] for _ in range(N + 1)]", "+for _ in range(N + M - 1):", "+ a, b = map(int, input().split())", "+ e_out[a].append(b)", "+ e_in[b].append(a)", "+# 1. 入次数が0のやつが親", "+# 2. 親が決まれば、そのこの入次数を減らす,1に戻る", "+# 親を決めるよ", "+for i, e in enumerate(e_in[1:], start=1):", "+ if len(e) == 0:", "-# BFS", "-rank[root] = 0", "-node = deque([root])", "+ break", "+node = [root]", "+parent = [-1] * (N + 1)", "+parent[root] = 0", "+diff = [0] * (N + 1) # 入次数をどれだけ減らすか", "- s = node.popleft()", "- add[e_from[s]] -= 1", "- for t in e_from[s]:", "- if add[t] == 0:", "- rank[t] = s", "+ s = node.pop()", "+ for t in e_out[s]:", "+ diff[t] += 1", "+ if len(e_in[t]) - diff[t] == 0:", "+ parent[t] = s", "-print(*rank[1:], sep=\"\\n\")", "+print(*parent[1:], sep=\"\\n\")" ]
false
0.267524
0.036269
7.376029
[ "s190030830", "s301288739" ]
u696240348
p03494
python
s577940316
s151133935
165
149
38,640
12,508
Accepted
Accepted
9.7
def times_divisible(n): ans = 0 while n%2 ==0: n/=2 ans +=1 return ans n= int(eval(input())) A=[int(a) for a in input().split()] ans = min(times_divisible(a) for a in A) print(ans)
import numpy as np n = eval(input()) a = np.array([int(x) for x in input().split()]) count = 0 x = 0 while x == 0: if np.all(a%2 ==0): count+=1 a = a/2 else: break print(count)
10
15
212
219
def times_divisible(n): ans = 0 while n % 2 == 0: n /= 2 ans += 1 return ans n = int(eval(input())) A = [int(a) for a in input().split()] ans = min(times_divisible(a) for a in A) print(ans)
import numpy as np n = eval(input()) a = np.array([int(x) for x in input().split()]) count = 0 x = 0 while x == 0: if np.all(a % 2 == 0): count += 1 a = a / 2 else: break print(count)
false
33.333333
[ "-def times_divisible(n):", "- ans = 0", "- while n % 2 == 0:", "- n /= 2", "- ans += 1", "- return ans", "+import numpy as np", "-", "-n = int(eval(input()))", "-A = [int(a) for a in input().split()]", "-ans = min(times_divisible(a) for a in A)", "-print(ans)", "+n = eval(input())", "+a = np.array([int(x) for x in input().split()])", "+count = 0", "+x = 0", "+while x == 0:", "+ if np.all(a % 2 == 0):", "+ count += 1", "+ a = a / 2", "+ else:", "+ break", "+print(count)" ]
false
0.069188
0.715129
0.096749
[ "s577940316", "s151133935" ]
u536600145
p03166
python
s069696014
s335113130
1,397
1,164
154,060
154,060
Accepted
Accepted
16.68
import sys sys.setrecursionlimit(10**9) n , m = list(map(int,input().split())) g = [[] for i in range(n+1)] dp = [-1] * (n+1) for _ in range(m): v1 , v2 = list(map(int,input().split())) g[v1].append(v2) # finding longest path for vertice i def dfs(i): if dp[i]!=-1: return dp[i] temp = 0 for nv in g[i]: temp = max(temp, dfs(nv)+1) dp[i]=temp return temp # finding overall longest path res = 0 for i in range(1,n+1): res = max(res, dfs(i)) print(res)
import sys N, M = list(map(int, input().split())) sys.setrecursionlimit(10**9) vertices = [[] for i in range(N+1)] dp = [-1] * (N+1) for _ in range(M): fro, to = list(map(int, input().split())) vertices[fro].append(to) def dfs(i): if dp[i] != -1: return dp[i] temp = 0 for vertex in vertices[i]: temp = max(temp, dfs(vertex)+1) dp[i] = temp return temp for i in range(1,N+1): dfs(i) print((max(dp)))
29
28
531
489
import sys sys.setrecursionlimit(10**9) n, m = list(map(int, input().split())) g = [[] for i in range(n + 1)] dp = [-1] * (n + 1) for _ in range(m): v1, v2 = list(map(int, input().split())) g[v1].append(v2) # finding longest path for vertice i def dfs(i): if dp[i] != -1: return dp[i] temp = 0 for nv in g[i]: temp = max(temp, dfs(nv) + 1) dp[i] = temp return temp # finding overall longest path res = 0 for i in range(1, n + 1): res = max(res, dfs(i)) print(res)
import sys N, M = list(map(int, input().split())) sys.setrecursionlimit(10**9) vertices = [[] for i in range(N + 1)] dp = [-1] * (N + 1) for _ in range(M): fro, to = list(map(int, input().split())) vertices[fro].append(to) def dfs(i): if dp[i] != -1: return dp[i] temp = 0 for vertex in vertices[i]: temp = max(temp, dfs(vertex) + 1) dp[i] = temp return temp for i in range(1, N + 1): dfs(i) print((max(dp)))
false
3.448276
[ "+N, M = list(map(int, input().split()))", "-n, m = list(map(int, input().split()))", "-g = [[] for i in range(n + 1)]", "-dp = [-1] * (n + 1)", "-for _ in range(m):", "- v1, v2 = list(map(int, input().split()))", "- g[v1].append(v2)", "-# finding longest path for vertice i", "+vertices = [[] for i in range(N + 1)]", "+dp = [-1] * (N + 1)", "+for _ in range(M):", "+ fro, to = list(map(int, input().split()))", "+ vertices[fro].append(to)", "+", "+", "- for nv in g[i]:", "- temp = max(temp, dfs(nv) + 1)", "+ for vertex in vertices[i]:", "+ temp = max(temp, dfs(vertex) + 1)", "-# finding overall longest path", "-res = 0", "-for i in range(1, n + 1):", "- res = max(res, dfs(i))", "-print(res)", "+for i in range(1, N + 1):", "+ dfs(i)", "+print((max(dp)))" ]
false
0.036819
0.06415
0.573958
[ "s069696014", "s335113130" ]
u416758623
p03775
python
s634229894
s657702920
58
52
9,092
9,116
Accepted
Accepted
10.34
import math n = int(eval(input())) ans = float('inf') i = 1 while i <= math.sqrt(n): if n % i == 0: a = int(len(str(i))) b = int(len(str(n // i))) ans = min(ans,max(a,b)) i += 1 print(ans)
n = int(eval(input())) i = 1 ans = 0 while i * i <= n: if n % i == 0: ans = max(len(str(i)), len(str(n // i))) i += 1 print(ans)
11
9
224
147
import math n = int(eval(input())) ans = float("inf") i = 1 while i <= math.sqrt(n): if n % i == 0: a = int(len(str(i))) b = int(len(str(n // i))) ans = min(ans, max(a, b)) i += 1 print(ans)
n = int(eval(input())) i = 1 ans = 0 while i * i <= n: if n % i == 0: ans = max(len(str(i)), len(str(n // i))) i += 1 print(ans)
false
18.181818
[ "-import math", "-", "-ans = float(\"inf\")", "-while i <= math.sqrt(n):", "+ans = 0", "+while i * i <= n:", "- a = int(len(str(i)))", "- b = int(len(str(n // i)))", "- ans = min(ans, max(a, b))", "+ ans = max(len(str(i)), len(str(n // i)))" ]
false
0.052308
0.047772
1.094953
[ "s634229894", "s657702920" ]
u021916304
p03048
python
s774247331
s624055409
394
19
40,812
3,064
Accepted
Accepted
95.18
def ii():return int(eval(input())) def iim():return list(map(int,input().split())) def iil():return list(map(int,input().split())) def ism():return list(map(str,input().split())) def isl():return list(map(str,input().split())) r,g,b,n = iim() ans = 0 for i in range(n//r+1): for j in range(n//g+1): num = n-i*r-j*g if num%b == 0 and num//b >= 0: # print(i,j,num//b) ans += 1 print(ans)
def ii():return int(eval(input())) def iim():return list(map(int,input().split())) def iil():return list(map(int,input().split())) def ism():return list(map(str,input().split())) def isl():return list(map(str,input().split())) #pythonだとTLE/pypyだとAC ''' r,g,b,n = iim() ans = 0 for i in range(n//r+1): for j in range(n//g+1): num = n-i*r-j*g if num%b == 0 and num//b >= 0: # print(i,j,num//b) ans += 1 print(ans) ''' #上を受けてpythonでも通るように改良 *num,n = iim() a,b,c = list(map(int,sorted(num))) ans = 0 for i in range(n//c+1): if a!= 1: for j in range(n//b+1): num = n-i*c-j*b if num%a == 0 and num//a >= 0: ans += 1 else: ret = n - i*c ans += ret//b+1 print(ans)
15
33
425
782
def ii(): return int(eval(input())) def iim(): return list(map(int, input().split())) def iil(): return list(map(int, input().split())) def ism(): return list(map(str, input().split())) def isl(): return list(map(str, input().split())) r, g, b, n = iim() ans = 0 for i in range(n // r + 1): for j in range(n // g + 1): num = n - i * r - j * g if num % b == 0 and num // b >= 0: # print(i,j,num//b) ans += 1 print(ans)
def ii(): return int(eval(input())) def iim(): return list(map(int, input().split())) def iil(): return list(map(int, input().split())) def ism(): return list(map(str, input().split())) def isl(): return list(map(str, input().split())) # pythonだとTLE/pypyだとAC """ r,g,b,n = iim() ans = 0 for i in range(n//r+1): for j in range(n//g+1): num = n-i*r-j*g if num%b == 0 and num//b >= 0: # print(i,j,num//b) ans += 1 print(ans) """ # 上を受けてpythonでも通るように改良 *num, n = iim() a, b, c = list(map(int, sorted(num))) ans = 0 for i in range(n // c + 1): if a != 1: for j in range(n // b + 1): num = n - i * c - j * b if num % a == 0 and num // a >= 0: ans += 1 else: ret = n - i * c ans += ret // b + 1 print(ans)
false
54.545455
[ "-r, g, b, n = iim()", "+# pythonだとTLE/pypyだとAC", "+\"\"\"", "+r,g,b,n = iim()", "-for i in range(n // r + 1):", "- for j in range(n // g + 1):", "- num = n - i * r - j * g", "- if num % b == 0 and num // b >= 0:", "- # print(i,j,num//b)", "+for i in range(n//r+1):", "+ for j in range(n//g+1):", "+ num = n-i*r-j*g", "+ if num%b == 0 and num//b >= 0:", "+# print(i,j,num//b)", "+\"\"\"", "+# 上を受けてpythonでも通るように改良", "+*num, n = iim()", "+a, b, c = list(map(int, sorted(num)))", "+ans = 0", "+for i in range(n // c + 1):", "+ if a != 1:", "+ for j in range(n // b + 1):", "+ num = n - i * c - j * b", "+ if num % a == 0 and num // a >= 0:", "+ ans += 1", "+ else:", "+ ret = n - i * c", "+ ans += ret // b + 1", "+print(ans)" ]
false
0.263897
0.036981
7.135986
[ "s774247331", "s624055409" ]
u500376440
p02971
python
s467500583
s502851198
393
303
19,052
92,972
Accepted
Accepted
22.9
N=int(eval(input())) A=[int(eval(input())) for i in range(N)] max_val1=sorted(A)[-1] max_val2=sorted(A)[-2] for x in A: print((max_val2 if x==max_val1 else max_val1))
N=int(eval(input())) A=[int(eval(input())) for _ in range(N)] lmax=[0]*N rmax=[0]*N for i in range(1,N): lmax[i]=max(lmax[i-1],A[i-1]) for i in range(N-2,-1,-1): rmax[i]=max(rmax[i+1],A[i+1]) for i in range(N): print((max(lmax[i],rmax[i])))
6
13
160
248
N = int(eval(input())) A = [int(eval(input())) for i in range(N)] max_val1 = sorted(A)[-1] max_val2 = sorted(A)[-2] for x in A: print((max_val2 if x == max_val1 else max_val1))
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] lmax = [0] * N rmax = [0] * N for i in range(1, N): lmax[i] = max(lmax[i - 1], A[i - 1]) for i in range(N - 2, -1, -1): rmax[i] = max(rmax[i + 1], A[i + 1]) for i in range(N): print((max(lmax[i], rmax[i])))
false
53.846154
[ "-A = [int(eval(input())) for i in range(N)]", "-max_val1 = sorted(A)[-1]", "-max_val2 = sorted(A)[-2]", "-for x in A:", "- print((max_val2 if x == max_val1 else max_val1))", "+A = [int(eval(input())) for _ in range(N)]", "+lmax = [0] * N", "+rmax = [0] * N", "+for i in range(1, N):", "+ lmax[i] = max(lmax[i - 1], A[i - 1])", "+for i in range(N - 2, -1, -1):", "+ rmax[i] = max(rmax[i + 1], A[i + 1])", "+for i in range(N):", "+ print((max(lmax[i], rmax[i])))" ]
false
0.007903
0.037879
0.208628
[ "s467500583", "s502851198" ]
u885634168
p02642
python
s238014064
s577645304
233
182
217,100
195,464
Accepted
Accepted
21.89
N = int(eval(input())) A = list(map(int,input().split())) ma = max(A) Er = [0 for _ in range(ma + 5)] is_c = [0 for _ in range(ma + 5)] for i in range(N): temp = A[i] if Er[temp] != 2: a = 0 while(1): a += 1 tt = a * temp if tt >= ma + 5: break Er[tt] += 1 ans = 0 for i in range(N): temp = A[i] is_c[temp] += 1 if is_c[temp] == 2: continue if Er[temp] == 1: ans += 1 print(ans)
N = int(eval(input())) A = list(map(int,input().split())) ma = max(A) Er = [0 for _ in range(ma + 5)] for i in range(N): temp = A[i] if Er[temp] != 2: a = 0 while(1): a += 1 tt = a * temp if tt >= ma + 5: break Er[tt] += 1 ans = 0 for i in range(N): temp = A[i] if Er[temp] == 1: ans += 1 print(ans)
27
23
533
432
N = int(eval(input())) A = list(map(int, input().split())) ma = max(A) Er = [0 for _ in range(ma + 5)] is_c = [0 for _ in range(ma + 5)] for i in range(N): temp = A[i] if Er[temp] != 2: a = 0 while 1: a += 1 tt = a * temp if tt >= ma + 5: break Er[tt] += 1 ans = 0 for i in range(N): temp = A[i] is_c[temp] += 1 if is_c[temp] == 2: continue if Er[temp] == 1: ans += 1 print(ans)
N = int(eval(input())) A = list(map(int, input().split())) ma = max(A) Er = [0 for _ in range(ma + 5)] for i in range(N): temp = A[i] if Er[temp] != 2: a = 0 while 1: a += 1 tt = a * temp if tt >= ma + 5: break Er[tt] += 1 ans = 0 for i in range(N): temp = A[i] if Er[temp] == 1: ans += 1 print(ans)
false
14.814815
[ "-is_c = [0 for _ in range(ma + 5)]", "- is_c[temp] += 1", "- if is_c[temp] == 2:", "- continue" ]
false
0.037411
0.042908
0.871883
[ "s238014064", "s577645304" ]
u367130284
p03945
python
s928613099
s764024882
56
19
15,860
3,188
Accepted
Accepted
66.07
from itertools import*;print((len(list(groupby(eval(input()))))-1))
print((sum(map(input().count,["WB","BW"]))))
1
1
59
42
from itertools import * print((len(list(groupby(eval(input())))) - 1))
print((sum(map(input().count, ["WB", "BW"]))))
false
0
[ "-from itertools import *", "-", "-print((len(list(groupby(eval(input())))) - 1))", "+print((sum(map(input().count, [\"WB\", \"BW\"]))))" ]
false
0.038933
0.038492
1.01146
[ "s928613099", "s764024882" ]
u246401133
p02627
python
s352582510
s041003808
30
24
9,084
8,968
Accepted
Accepted
20
alpha = str(eval(input())) if alpha in "abcdefghijklmnopqrstuvwxyz": print("a") else: print("A")
alpha = eval(input()) print(("a" if alpha.islower() else "A"))
5
2
102
55
alpha = str(eval(input())) if alpha in "abcdefghijklmnopqrstuvwxyz": print("a") else: print("A")
alpha = eval(input()) print(("a" if alpha.islower() else "A"))
false
60
[ "-alpha = str(eval(input()))", "-if alpha in \"abcdefghijklmnopqrstuvwxyz\":", "- print(\"a\")", "-else:", "- print(\"A\")", "+alpha = eval(input())", "+print((\"a\" if alpha.islower() else \"A\"))" ]
false
0.035947
0.0385
0.933685
[ "s352582510", "s041003808" ]
u584174687
p02996
python
s010024881
s051501423
1,270
646
88,024
83,164
Accepted
Accepted
49.13
from collections import defaultdict def gcd(a, b): while b: a, b = b, a % b return a #a,bの最小公倍数 def lcm(a, b): return a * b // gcd (a, b) def main(): num = int(eval(input())) data = [list(map(int, input().split())) for i in range(num)] data.sort(key=lambda x: x[1]) now_time = 0 flg = 1 for i in range(num): if now_time + data[i][0] <= data[i][1]: now_time += data[i][0] else: flg = 0 break if flg: print('Yes') else: print('No') if __name__ == '__main__': main()
from collections import defaultdict import sys input = sys.stdin.readline def gcd(a, b): while b: a, b = b, a % b return a #a,bの最小公倍数 def lcm(a, b): return a * b // gcd (a, b) def main(): num = int(eval(input())) data = [list(map(int, input().split())) for i in range(num)] data.sort(key=lambda x: x[1]) now_time = 0 flg = 1 for i in range(num): if now_time + data[i][0] <= data[i][1]: now_time += data[i][0] else: flg = 0 break if flg: print('Yes') else: print('No') if __name__ == '__main__': main()
33
34
621
659
from collections import defaultdict def gcd(a, b): while b: a, b = b, a % b return a # a,bの最小公倍数 def lcm(a, b): return a * b // gcd(a, b) def main(): num = int(eval(input())) data = [list(map(int, input().split())) for i in range(num)] data.sort(key=lambda x: x[1]) now_time = 0 flg = 1 for i in range(num): if now_time + data[i][0] <= data[i][1]: now_time += data[i][0] else: flg = 0 break if flg: print("Yes") else: print("No") if __name__ == "__main__": main()
from collections import defaultdict import sys input = sys.stdin.readline def gcd(a, b): while b: a, b = b, a % b return a # a,bの最小公倍数 def lcm(a, b): return a * b // gcd(a, b) def main(): num = int(eval(input())) data = [list(map(int, input().split())) for i in range(num)] data.sort(key=lambda x: x[1]) now_time = 0 flg = 1 for i in range(num): if now_time + data[i][0] <= data[i][1]: now_time += data[i][0] else: flg = 0 break if flg: print("Yes") else: print("No") if __name__ == "__main__": main()
false
2.941176
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.113223
0.110619
1.023537
[ "s010024881", "s051501423" ]
u864013199
p03354
python
s500404191
s533142376
732
564
13,812
14,516
Accepted
Accepted
22.95
class UnionFind(): def __init__(self, n): self.parent = [-1 for _ in range(n)] # 正==子: 根の頂点番号 / 負==根: 連結頂点数 def find(self, x): if self.parent[x] < 0: return x else: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def unite(self, x, y): x, y = self.find(x), self.find(y) if x == y: return False else: if self.size(x) < self.size(y): x, y = y, x self.parent[x] += self.parent[y] self.parent[y] = x def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): x = self.find(x) return -self.parent[x] def is_root(self, x): return self.parent[x] < 0 N,M = list(map(int,input().split())) p = list(map(int,input().split())) uf = UnionFind(N) for i in range(M): x,y = list(map(int,input().split())) uf.unite(x-1,y-1) ans = 0 for i in range(N): if p[i]-1 == i: ans += 1 else: if uf.same(p[i]-1,i): ans += 1 print(ans)
import sys input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.parent = [-1 for _ in range(n)] # 正==子: 根の頂点番号 / 負==根: 連結頂点数 def find(self, x): if self.parent[x] < 0: return x else: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def unite(self, x, y): x, y = self.find(x), self.find(y) if x == y: return False else: if self.size(x) < self.size(y): x, y = y, x self.parent[x] += self.parent[y] self.parent[y] = x def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): x = self.find(x) return -self.parent[x] def is_root(self, x): return self.parent[x] < 0 N,M = list(map(int,input().split())) p = list(map(int,input().split())) uf = UnionFind(N) for i in range(M): x,y = list(map(int,input().split())) uf.unite(x-1,y-1) ans = 0 for i in range(N): if p[i]-1 == i: ans += 1 else: if uf.same(p[i]-1,i): ans += 1 print(ans)
48
51
1,140
1,182
class UnionFind: def __init__(self, n): self.parent = [-1 for _ in range(n)] # 正==子: 根の頂点番号 / 負==根: 連結頂点数 def find(self, x): if self.parent[x] < 0: return x else: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def unite(self, x, y): x, y = self.find(x), self.find(y) if x == y: return False else: if self.size(x) < self.size(y): x, y = y, x self.parent[x] += self.parent[y] self.parent[y] = x def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): x = self.find(x) return -self.parent[x] def is_root(self, x): return self.parent[x] < 0 N, M = list(map(int, input().split())) p = list(map(int, input().split())) uf = UnionFind(N) for i in range(M): x, y = list(map(int, input().split())) uf.unite(x - 1, y - 1) ans = 0 for i in range(N): if p[i] - 1 == i: ans += 1 else: if uf.same(p[i] - 1, i): ans += 1 print(ans)
import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.parent = [-1 for _ in range(n)] # 正==子: 根の頂点番号 / 負==根: 連結頂点数 def find(self, x): if self.parent[x] < 0: return x else: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def unite(self, x, y): x, y = self.find(x), self.find(y) if x == y: return False else: if self.size(x) < self.size(y): x, y = y, x self.parent[x] += self.parent[y] self.parent[y] = x def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): x = self.find(x) return -self.parent[x] def is_root(self, x): return self.parent[x] < 0 N, M = list(map(int, input().split())) p = list(map(int, input().split())) uf = UnionFind(N) for i in range(M): x, y = list(map(int, input().split())) uf.unite(x - 1, y - 1) ans = 0 for i in range(N): if p[i] - 1 == i: ans += 1 else: if uf.same(p[i] - 1, i): ans += 1 print(ans)
false
5.882353
[ "+import sys", "+", "+input = sys.stdin.readline", "+", "+" ]
false
0.037417
0.042705
0.876183
[ "s500404191", "s533142376" ]
u602773379
p02612
python
s596457996
s293129303
32
28
9,148
9,136
Accepted
Accepted
12.5
n=int(eval(input())) for i in range(1000,10001,1000): num=i-n if num >=0: print(num) break
n=int(eval(input())) for i in range(1000,10001,1000): if i>=n: print((i-n)) break
7
5
97
82
n = int(eval(input())) for i in range(1000, 10001, 1000): num = i - n if num >= 0: print(num) break
n = int(eval(input())) for i in range(1000, 10001, 1000): if i >= n: print((i - n)) break
false
28.571429
[ "- num = i - n", "- if num >= 0:", "- print(num)", "+ if i >= n:", "+ print((i - n))" ]
false
0.086904
0.056986
1.525009
[ "s596457996", "s293129303" ]
u014333473
p03997
python
s240896610
s928727964
25
22
9,164
9,156
Accepted
Accepted
12
n=[int(eval(input())) for _ in range(3)] print((((n[0]+n[1])*n[2])//2))
a,b,h=[int(eval(input())) for _ in range(3)];print(((a+b)*h//2))
2
1
64
56
n = [int(eval(input())) for _ in range(3)] print((((n[0] + n[1]) * n[2]) // 2))
a, b, h = [int(eval(input())) for _ in range(3)] print(((a + b) * h // 2))
false
50
[ "-n = [int(eval(input())) for _ in range(3)]", "-print((((n[0] + n[1]) * n[2]) // 2))", "+a, b, h = [int(eval(input())) for _ in range(3)]", "+print(((a + b) * h // 2))" ]
false
0.03685
0.035914
1.026047
[ "s240896610", "s928727964" ]
u708255304
p04001
python
s603661736
s357557277
26
23
2,940
4,140
Accepted
Accepted
11.54
S = list(eval(input())) ans = 0 for state in range(1 << len(S)-1): ans += eval(S[0] + ''.join(('+' if state >> i & 1 else '') + x for i, x in enumerate(S[1:]))) print(ans)
S = str(eval(input())) ans = "" for mask in range(1 << (len(S)-1)): for i in range(len(S)): if ((mask >> i) & 1): ans += str(S[i]) + "+" else: ans += str(S[i]) ans += "+" print((int(eval(ans[:-1]))))
7
13
178
255
S = list(eval(input())) ans = 0 for state in range(1 << len(S) - 1): ans += eval( S[0] + "".join(("+" if state >> i & 1 else "") + x for i, x in enumerate(S[1:])) ) print(ans)
S = str(eval(input())) ans = "" for mask in range(1 << (len(S) - 1)): for i in range(len(S)): if (mask >> i) & 1: ans += str(S[i]) + "+" else: ans += str(S[i]) ans += "+" print((int(eval(ans[:-1]))))
false
46.153846
[ "-S = list(eval(input()))", "-ans = 0", "-for state in range(1 << len(S) - 1):", "- ans += eval(", "- S[0] + \"\".join((\"+\" if state >> i & 1 else \"\") + x for i, x in enumerate(S[1:]))", "- )", "-print(ans)", "+S = str(eval(input()))", "+ans = \"\"", "+for mask in range(1 << (len(S) - 1)):", "+ for i in range(len(S)):", "+ if (mask >> i) & 1:", "+ ans += str(S[i]) + \"+\"", "+ else:", "+ ans += str(S[i])", "+ ans += \"+\"", "+print((int(eval(ans[:-1]))))" ]
false
0.039509
0.037343
1.058004
[ "s603661736", "s357557277" ]
u233720439
p03486
python
s042454177
s550685905
19
17
3,060
2,940
Accepted
Accepted
10.53
S = sorted(eval(input())) T = sorted(eval(input()),reverse=True) if S<T: print("Yes") else: print("No")
S = sorted(eval(input())) N = sorted(eval(input())) N.reverse() print(("Yes" if S < N else "No"))
6
4
104
87
S = sorted(eval(input())) T = sorted(eval(input()), reverse=True) if S < T: print("Yes") else: print("No")
S = sorted(eval(input())) N = sorted(eval(input())) N.reverse() print(("Yes" if S < N else "No"))
false
33.333333
[ "-T = sorted(eval(input()), reverse=True)", "-if S < T:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+N = sorted(eval(input()))", "+N.reverse()", "+print((\"Yes\" if S < N else \"No\"))" ]
false
0.044401
0.047006
0.944582
[ "s042454177", "s550685905" ]
u602740328
p03379
python
s763050637
s531863274
328
211
26,356
29,204
Accepted
Accepted
35.67
N = int(eval(input())) X = [int(i) for i in input().split()] X_sorted = sorted(X) X_med = X_sorted[N//2-1:N//2+1] for xi in X: print((X_med[1] if xi<=X_med[0] else X_med[0]))
N = int(eval(input())) X = [int(i) for i in input().split()] X_med = sorted(X)[N//2-1:N//2+1] print(("\n".join(map(str, [X_med[1] if xi<=X_med[0] else X_med[0] for xi in X]))))
5
4
170
171
N = int(eval(input())) X = [int(i) for i in input().split()] X_sorted = sorted(X) X_med = X_sorted[N // 2 - 1 : N // 2 + 1] for xi in X: print((X_med[1] if xi <= X_med[0] else X_med[0]))
N = int(eval(input())) X = [int(i) for i in input().split()] X_med = sorted(X)[N // 2 - 1 : N // 2 + 1] print(("\n".join(map(str, [X_med[1] if xi <= X_med[0] else X_med[0] for xi in X]))))
false
20
[ "-X_sorted = sorted(X)", "-X_med = X_sorted[N // 2 - 1 : N // 2 + 1]", "-for xi in X:", "- print((X_med[1] if xi <= X_med[0] else X_med[0]))", "+X_med = sorted(X)[N // 2 - 1 : N // 2 + 1]", "+print((\"\\n\".join(map(str, [X_med[1] if xi <= X_med[0] else X_med[0] for xi in X]))))" ]
false
0.04319
0.042313
1.020732
[ "s763050637", "s531863274" ]
u150984829
p00009
python
s242796837
s593003529
320
270
13,848
9,876
Accepted
Accepted
15.62
import sys m=166666;a=[[1]*m for _ in[0]*2] for i in range(m): if a[0][i]: k=6*i+5 a[0][i+k::k]=[0]*len(a[0][i+k::k]) a[1][-2-i+k::k]=[0]*len(a[1][-2-i+k::k]) if a[1][i]: k=6*i+7 a[0][-2-i+k::k]=[0]*len(a[0][-2-i+k::k]) a[1][i+k::k]=[0]*len(a[1][i+k::k]) for e in map(int,sys.stdin): print(([e-1,sum(a[0][:(e+1)//6]+a[1][:(e-1)//6])+2][e>3]))
import sys m=166666;s=[1]*m;t=[1]*m for i in range(m): if s[i]: k=6*i+5 s[i+k::k]=[0]*len(s[i+k::k]) t[-2-i+k::k]=[0]*len(t[-2-i+k::k]) if t[i]: k=6*i+7 s[-2-i+k::k]=[0]*len(s[-2-i+k::k]) t[i+k::k]=[0]*len(t[i+k::k]) for e in map(int,sys.stdin): print(([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3]))
13
13
368
329
import sys m = 166666 a = [[1] * m for _ in [0] * 2] for i in range(m): if a[0][i]: k = 6 * i + 5 a[0][i + k :: k] = [0] * len(a[0][i + k :: k]) a[1][-2 - i + k :: k] = [0] * len(a[1][-2 - i + k :: k]) if a[1][i]: k = 6 * i + 7 a[0][-2 - i + k :: k] = [0] * len(a[0][-2 - i + k :: k]) a[1][i + k :: k] = [0] * len(a[1][i + k :: k]) for e in map(int, sys.stdin): print(([e - 1, sum(a[0][: (e + 1) // 6] + a[1][: (e - 1) // 6]) + 2][e > 3]))
import sys m = 166666 s = [1] * m t = [1] * m for i in range(m): if s[i]: k = 6 * i + 5 s[i + k :: k] = [0] * len(s[i + k :: k]) t[-2 - i + k :: k] = [0] * len(t[-2 - i + k :: k]) if t[i]: k = 6 * i + 7 s[-2 - i + k :: k] = [0] * len(s[-2 - i + k :: k]) t[i + k :: k] = [0] * len(t[i + k :: k]) for e in map(int, sys.stdin): print(([e - 1, sum(s[: (e + 1) // 6]) + sum(t[: (e - 1) // 6]) + 2][e > 3]))
false
0
[ "-a = [[1] * m for _ in [0] * 2]", "+s = [1] * m", "+t = [1] * m", "- if a[0][i]:", "+ if s[i]:", "- a[0][i + k :: k] = [0] * len(a[0][i + k :: k])", "- a[1][-2 - i + k :: k] = [0] * len(a[1][-2 - i + k :: k])", "- if a[1][i]:", "+ s[i + k :: k] = [0] * len(s[i + k :: k])", "+ t[-2 - i + k :: k] = [0] * len(t[-2 - i + k :: k])", "+ if t[i]:", "- a[0][-2 - i + k :: k] = [0] * len(a[0][-2 - i + k :: k])", "- a[1][i + k :: k] = [0] * len(a[1][i + k :: k])", "+ s[-2 - i + k :: k] = [0] * len(s[-2 - i + k :: k])", "+ t[i + k :: k] = [0] * len(t[i + k :: k])", "- print(([e - 1, sum(a[0][: (e + 1) // 6] + a[1][: (e - 1) // 6]) + 2][e > 3]))", "+ print(([e - 1, sum(s[: (e + 1) // 6]) + sum(t[: (e - 1) // 6]) + 2][e > 3]))" ]
false
0.258252
0.244857
1.054704
[ "s242796837", "s593003529" ]
u796942881
p03111
python
s503219812
s022467763
21
19
3,064
3,064
Accepted
Accepted
9.52
from itertools import combinations from itertools import permutations def f(x, lst, rem): d = abs(x - min(lst)) min_lst = min(lst) tpl = None for v in range(len(lst) - rem + 1): for t in combinations(lst, v + 1): if abs(x - sum(t)) + 10 * v < d: d = abs(x - sum(t)) + 10 * v tpl = t if tpl is None: lst.remove(min_lst) else: for v in tpl: lst.remove(v) return d, lst def main(): N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for i in range(N)] ans = int(1e9+7) for ABC in permutations((A, B, C), 3): lst = L[:] accum = 0 for i, v in enumerate(ABC): d, lst = f(v, lst, 3 - i) accum += d ans = min(ans, accum) print(ans) main()
from itertools import combinations from itertools import permutations def f(x, lst, rem): d = int(1e9+7) tpl = () for v in range(len(lst) - rem + 1): for t in combinations(lst, v + 1): if abs(x - sum(t)) + 10 * v < d: d = abs(x - sum(t)) + 10 * v tpl = t for v in tpl: lst.remove(v) return d, lst def main(): N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for i in range(N)] ans = int(1e9+7) for ABC in permutations((A, B, C), 3): lst = L[:] accum = 0 for i, v in enumerate(ABC): d, lst = f(v, lst, 3 - i) accum += d ans = min(ans, accum) print(ans) main()
37
33
864
762
from itertools import combinations from itertools import permutations def f(x, lst, rem): d = abs(x - min(lst)) min_lst = min(lst) tpl = None for v in range(len(lst) - rem + 1): for t in combinations(lst, v + 1): if abs(x - sum(t)) + 10 * v < d: d = abs(x - sum(t)) + 10 * v tpl = t if tpl is None: lst.remove(min_lst) else: for v in tpl: lst.remove(v) return d, lst def main(): N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for i in range(N)] ans = int(1e9 + 7) for ABC in permutations((A, B, C), 3): lst = L[:] accum = 0 for i, v in enumerate(ABC): d, lst = f(v, lst, 3 - i) accum += d ans = min(ans, accum) print(ans) main()
from itertools import combinations from itertools import permutations def f(x, lst, rem): d = int(1e9 + 7) tpl = () for v in range(len(lst) - rem + 1): for t in combinations(lst, v + 1): if abs(x - sum(t)) + 10 * v < d: d = abs(x - sum(t)) + 10 * v tpl = t for v in tpl: lst.remove(v) return d, lst def main(): N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for i in range(N)] ans = int(1e9 + 7) for ABC in permutations((A, B, C), 3): lst = L[:] accum = 0 for i, v in enumerate(ABC): d, lst = f(v, lst, 3 - i) accum += d ans = min(ans, accum) print(ans) main()
false
10.810811
[ "- d = abs(x - min(lst))", "- min_lst = min(lst)", "- tpl = None", "+ d = int(1e9 + 7)", "+ tpl = ()", "- if tpl is None:", "- lst.remove(min_lst)", "- else:", "- for v in tpl:", "- lst.remove(v)", "+ for v in tpl:", "+ lst.remove(v)" ]
false
0.090703
0.050295
1.803415
[ "s503219812", "s022467763" ]
u057109575
p02791
python
s413651449
s764778034
255
108
84,996
99,792
Accepted
Accepted
57.65
N, *P = list(map(int, open(0).read().split())) min_v = 10 ** 6 max_v = 0 ans = 0 for i in range(N): if P[i] < min_v: ans += 1 min_v = P[i] elif P[i] > max_v: max_v = P[i] print(ans)
N = int(eval(input())) X = list(map(int, input().split())) ans = 0 cur = 10 ** 6 for i in range(N): if X[i] <= cur: ans += 1 cur = min(cur, X[i]) print(ans)
13
12
230
181
N, *P = list(map(int, open(0).read().split())) min_v = 10**6 max_v = 0 ans = 0 for i in range(N): if P[i] < min_v: ans += 1 min_v = P[i] elif P[i] > max_v: max_v = P[i] print(ans)
N = int(eval(input())) X = list(map(int, input().split())) ans = 0 cur = 10**6 for i in range(N): if X[i] <= cur: ans += 1 cur = min(cur, X[i]) print(ans)
false
7.692308
[ "-N, *P = list(map(int, open(0).read().split()))", "-min_v = 10**6", "-max_v = 0", "+N = int(eval(input()))", "+X = list(map(int, input().split()))", "+cur = 10**6", "- if P[i] < min_v:", "+ if X[i] <= cur:", "- min_v = P[i]", "- elif P[i] > max_v:", "- max_v = P[i]", "+ cur = min(cur, X[i])" ]
false
0.042232
0.036131
1.168853
[ "s413651449", "s764778034" ]
u619458041
p03037
python
s288880580
s834016347
154
141
3,956
3,060
Accepted
Accepted
8.44
import sys from itertools import accumulate def main(): input = sys.stdin.readline N, M = list(map(int, input().split())) acc = [0] * (N+1) for _ in range(M): left, right = list(map(int, input().split())) acc[left-1] += 1 acc[right] -= 1 cnt = 0 for a in accumulate(acc): if a == M: cnt += 1 return cnt if __name__ == '__main__': print((main()))
import sys def main(): input = sys.stdin.readline N, M = list(map(int, input().split())) L = 0 R = 10**5 + 1 for _ in range(M): left, right = list(map(int, input().split())) L = max(L, left) R = min(R, right) return max(R - L + 1, 0) if __name__ == '__main__': print((main()))
22
17
434
335
import sys from itertools import accumulate def main(): input = sys.stdin.readline N, M = list(map(int, input().split())) acc = [0] * (N + 1) for _ in range(M): left, right = list(map(int, input().split())) acc[left - 1] += 1 acc[right] -= 1 cnt = 0 for a in accumulate(acc): if a == M: cnt += 1 return cnt if __name__ == "__main__": print((main()))
import sys def main(): input = sys.stdin.readline N, M = list(map(int, input().split())) L = 0 R = 10**5 + 1 for _ in range(M): left, right = list(map(int, input().split())) L = max(L, left) R = min(R, right) return max(R - L + 1, 0) if __name__ == "__main__": print((main()))
false
22.727273
[ "-from itertools import accumulate", "- acc = [0] * (N + 1)", "+ L = 0", "+ R = 10**5 + 1", "- acc[left - 1] += 1", "- acc[right] -= 1", "- cnt = 0", "- for a in accumulate(acc):", "- if a == M:", "- cnt += 1", "- return cnt", "+ L = max(L, left)", "+ R = min(R, right)", "+ return max(R - L + 1, 0)" ]
false
0.04464
0.062246
0.717155
[ "s288880580", "s834016347" ]
u353919145
p02784
python
s557928286
s266039868
199
53
52,292
10,584
Accepted
Accepted
73.37
h, n = list(map(int, input().split())) arr = list(map(int, input().split())) if sum(arr) >= h: print('Yes') else: print('No')
In1 = input().split() h = int(In1[0]) n = int(In1[1]) ith = input().split()[0:n] count = 0 for x in ith: h -= int(x) if h <= 0: break if h > 0: print("No") else: print("Yes")
4
13
122
210
h, n = list(map(int, input().split())) arr = list(map(int, input().split())) if sum(arr) >= h: print("Yes") else: print("No")
In1 = input().split() h = int(In1[0]) n = int(In1[1]) ith = input().split()[0:n] count = 0 for x in ith: h -= int(x) if h <= 0: break if h > 0: print("No") else: print("Yes")
false
69.230769
[ "-h, n = list(map(int, input().split()))", "-arr = list(map(int, input().split()))", "-if sum(arr) >= h:", "+In1 = input().split()", "+h = int(In1[0])", "+n = int(In1[1])", "+ith = input().split()[0:n]", "+count = 0", "+for x in ith:", "+ h -= int(x)", "+ if h <= 0:", "+ break", "+if h > 0:", "+ print(\"No\")", "+else:", "-else:", "- print(\"No\")" ]
false
0.036935
0.036533
1.010988
[ "s557928286", "s266039868" ]
u601592822
p03448
python
s971009297
s818307613
83
70
3,064
9,208
Accepted
Accepted
15.66
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) count = 0 def multiple(l,m,n): ans = 500*l + 100*m + 50*n return ans o = 0 p = 0 q = 0 while o <= a: while p <= b: while q <= c: ans_x = multiple(o,p,q) if x == ans_x: count += 1 q += 1 q = 0 p += 1 q = 0 p = 0 o += 1 print(count)
# -*- coding: utf-8 -*- # 整数の入力 A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) i = 0 j = 0 k = 0 cnt = 0 sum = 0 while i <= A: j = 0 if i>50: break while j <= B: k = 0 if j>50: break while k <= C: if k>50: break else: sum = 500*i + 100*j + 50*k if X == sum: cnt += 1 k += 1 sum = 0 j += 1 i += 1 print(cnt)
27
34
427
555
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) count = 0 def multiple(l, m, n): ans = 500 * l + 100 * m + 50 * n return ans o = 0 p = 0 q = 0 while o <= a: while p <= b: while q <= c: ans_x = multiple(o, p, q) if x == ans_x: count += 1 q += 1 q = 0 p += 1 q = 0 p = 0 o += 1 print(count)
# -*- coding: utf-8 -*- # 整数の入力 A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) i = 0 j = 0 k = 0 cnt = 0 sum = 0 while i <= A: j = 0 if i > 50: break while j <= B: k = 0 if j > 50: break while k <= C: if k > 50: break else: sum = 500 * i + 100 * j + 50 * k if X == sum: cnt += 1 k += 1 sum = 0 j += 1 i += 1 print(cnt)
false
20.588235
[ "-a = int(eval(input()))", "-b = int(eval(input()))", "-c = int(eval(input()))", "-x = int(eval(input()))", "-count = 0", "-", "-", "-def multiple(l, m, n):", "- ans = 500 * l + 100 * m + 50 * n", "- return ans", "-", "-", "-o = 0", "-p = 0", "-q = 0", "-while o <= a:", "- while p <= b:", "- while q <= c:", "- ans_x = multiple(o, p, q)", "- if x == ans_x:", "- count += 1", "- q += 1", "- q = 0", "- p += 1", "- q = 0", "- p = 0", "- o += 1", "-print(count)", "+# -*- coding: utf-8 -*-", "+# 整数の入力", "+A = int(eval(input()))", "+B = int(eval(input()))", "+C = int(eval(input()))", "+X = int(eval(input()))", "+i = 0", "+j = 0", "+k = 0", "+cnt = 0", "+sum = 0", "+while i <= A:", "+ j = 0", "+ if i > 50:", "+ break", "+ while j <= B:", "+ k = 0", "+ if j > 50:", "+ break", "+ while k <= C:", "+ if k > 50:", "+ break", "+ else:", "+ sum = 500 * i + 100 * j + 50 * k", "+ if X == sum:", "+ cnt += 1", "+ k += 1", "+ sum = 0", "+ j += 1", "+ i += 1", "+print(cnt)" ]
false
0.240114
0.064388
3.729195
[ "s971009297", "s818307613" ]
u191874006
p03072
python
s386348428
s148285699
170
66
38,256
65,556
Accepted
Accepted
61.18
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n = I() h = LI() ans = 0 for i in range(n): for j in range(i): if h[i] < h[j]: break else: ans += 1 print(ans)
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n = I() h = LI() ans = 0 for i in range(n): x = h[i] for j in range(i): if x < h[j]: break else: ans += 1 print(ans)
29
30
715
727
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float("inf") def I(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) n = I() h = LI() ans = 0 for i in range(n): for j in range(i): if h[i] < h[j]: break else: ans += 1 print(ans)
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float("inf") def I(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) n = I() h = LI() ans = 0 for i in range(n): x = h[i] for j in range(i): if x < h[j]: break else: ans += 1 print(ans)
false
3.333333
[ "+ x = h[i]", "- if h[i] < h[j]:", "+ if x < h[j]:" ]
false
0.036484
0.037054
0.984628
[ "s386348428", "s148285699" ]
u124592621
p03455
python
s815297205
s114670918
22
18
2,940
2,940
Accepted
Accepted
18.18
a,b = list(map(int, input().split())) print(("Even" if (a * b) % 2 == 0 else "Odd"))
a,b = list(map(int, input().split())) if (a * b) % 2 == 0: print("Even") else: print("Odd")
2
5
77
93
a, b = list(map(int, input().split())) print(("Even" if (a * b) % 2 == 0 else "Odd"))
a, b = list(map(int, input().split())) if (a * b) % 2 == 0: print("Even") else: print("Odd")
false
60
[ "-print((\"Even\" if (a * b) % 2 == 0 else \"Odd\"))", "+if (a * b) % 2 == 0:", "+ print(\"Even\")", "+else:", "+ print(\"Odd\")" ]
false
0.132695
0.046129
2.876616
[ "s815297205", "s114670918" ]
u042666758
p03160
python
s668206132
s950676021
164
150
12,784
12,060
Accepted
Accepted
8.54
N = int(input()) h_str = input() h = [] for h_i in h_str.split(" "): h.append(int(h_i)) dp = [10 ** 9 + 1] * N dp[0] = 0 for i in range(N): for j in (i + 1, i + 2): if j < N: dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i])) print((dp[N-1]))
N = int(input()) h = list(map(int, input().split())) dp = [10 ** 9 + 1] * N dp[0] = 0 for i in range(N): for j in (i + 1, i + 2): if j < N: dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i])) print((dp[N-1]))
13
10
283
235
N = int(input()) h_str = input() h = [] for h_i in h_str.split(" "): h.append(int(h_i)) dp = [10**9 + 1] * N dp[0] = 0 for i in range(N): for j in (i + 1, i + 2): if j < N: dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i])) print((dp[N - 1]))
N = int(input()) h = list(map(int, input().split())) dp = [10**9 + 1] * N dp[0] = 0 for i in range(N): for j in (i + 1, i + 2): if j < N: dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i])) print((dp[N - 1]))
false
23.076923
[ "-h_str = input()", "-h = []", "-for h_i in h_str.split(\" \"):", "- h.append(int(h_i))", "+h = list(map(int, input().split()))" ]
false
0.047075
0.047684
0.987228
[ "s668206132", "s950676021" ]
u952656646
p04001
python
s392769137
s175171533
32
26
3,444
3,060
Accepted
Accepted
18.75
import copy S = eval(input()) n = len(S) ans = 0 for i in range(2**(n-1)): temp = "" for s,j in zip(S, list(range(n))): temp += s if i>>j & 1: temp += "+" ans += eval(temp) print(ans)
S = eval(input()) ans = 0 for b in range(2**(len(S)-1)): s = "" for i in range(len(S)): s += S[i] if b >> i & 1: s += "+" ans += eval(s) print(ans)
12
10
222
190
import copy S = eval(input()) n = len(S) ans = 0 for i in range(2 ** (n - 1)): temp = "" for s, j in zip(S, list(range(n))): temp += s if i >> j & 1: temp += "+" ans += eval(temp) print(ans)
S = eval(input()) ans = 0 for b in range(2 ** (len(S) - 1)): s = "" for i in range(len(S)): s += S[i] if b >> i & 1: s += "+" ans += eval(s) print(ans)
false
16.666667
[ "-import copy", "-", "-n = len(S)", "-for i in range(2 ** (n - 1)):", "- temp = \"\"", "- for s, j in zip(S, list(range(n))):", "- temp += s", "- if i >> j & 1:", "- temp += \"+\"", "- ans += eval(temp)", "+for b in range(2 ** (len(S) - 1)):", "+ s = \"\"", "+ for i in range(len(S)):", "+ s += S[i]", "+ if b >> i & 1:", "+ s += \"+\"", "+ ans += eval(s)" ]
false
0.046907
0.049678
0.944208
[ "s392769137", "s175171533" ]
u845573105
p02615
python
s982082099
s106478071
158
142
31,388
31,452
Accepted
Accepted
10.13
N = int(eval(input())) A = list(map(int, input().split())) A.sort() A = A[::-1] ans = A[0] for i in range(N-2): ans += A[1 + i//2] print(ans)
N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) ans = 0 for i in range(N-1): ans += A[(i+1)//2] print(ans)
8
9
144
144
N = int(eval(input())) A = list(map(int, input().split())) A.sort() A = A[::-1] ans = A[0] for i in range(N - 2): ans += A[1 + i // 2] print(ans)
N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) ans = 0 for i in range(N - 1): ans += A[(i + 1) // 2] print(ans)
false
11.111111
[ "-A.sort()", "-A = A[::-1]", "-ans = A[0]", "-for i in range(N - 2):", "- ans += A[1 + i // 2]", "+A.sort(reverse=True)", "+ans = 0", "+for i in range(N - 1):", "+ ans += A[(i + 1) // 2]" ]
false
0.039084
0.039449
0.990768
[ "s982082099", "s106478071" ]
u150984829
p02264
python
s310147176
s847481603
290
250
20,980
20,976
Accepted
Accepted
13.79
import sys import collections s=sys.stdin.readlines() n,q=list(map(int,s[0].split())) d=collections.deque(e.split()for e in s[1:]) t=0 while d: k,v=d.popleft() v=int(v) if v>q: v-=q t+=q d.append([k,v]) else: t+=v print((k,t))
import sys from collections import deque s=sys.stdin.readlines() n,q=list(map(int,s[0].split())) d=deque(e.split()for e in s[1:]) t=0 while d: k,v=d.popleft() v=int(v) if v>q: v-=q t+=q d.append([k,v]) else: t+=v print((k,t))
16
16
248
247
import sys import collections s = sys.stdin.readlines() n, q = list(map(int, s[0].split())) d = collections.deque(e.split() for e in s[1:]) t = 0 while d: k, v = d.popleft() v = int(v) if v > q: v -= q t += q d.append([k, v]) else: t += v print((k, t))
import sys from collections import deque s = sys.stdin.readlines() n, q = list(map(int, s[0].split())) d = deque(e.split() for e in s[1:]) t = 0 while d: k, v = d.popleft() v = int(v) if v > q: v -= q t += q d.append([k, v]) else: t += v print((k, t))
false
0
[ "-import collections", "+from collections import deque", "-d = collections.deque(e.split() for e in s[1:])", "+d = deque(e.split() for e in s[1:])" ]
false
0.038186
0.039432
0.9684
[ "s310147176", "s847481603" ]
u499381410
p04017
python
s558827638
s669576091
598
476
72,916
126,296
Accepted
Accepted
20.4
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor from operator import mul from functools import reduce from operator import mul sys.setrecursionlimit(2147483647) INF = 10 ** 20 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 1000000007 n = I() X = LI() l = I() log_n = (n - 1).bit_length() doubling = [[n] * n for _ in range(log_n)] for i in range(n - 1): doubling[0][i] = bisect_right(X, X[i] + l) - 1 for j in range(1, log_n): for k in range(n): if doubling[j - 1][k] == n: continue doubling[j][k] = doubling[j - 1][doubling[j - 1][k]] q = I() for _ in range(q): a, b = LI() if a > b: a, b = b, a a -= 1 b -= 1 ans = 0 for m in range(log_n - 1, -1, -1): if doubling[m][a] < b: a = doubling[m][a] ans += 2 ** m print((ans + 1))
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor, cos, radians, pi, sin from operator import mul from functools import reduce from operator import mul sys.setrecursionlimit(2147483647) INF = 10 ** 13 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 10 ** 9 + 7 n = I() x = LI() + [INF] l = I() q = I() db = [[0] * n for _ in range(31)] now = 0 for i in range(n): while x[i] + l >= x[now + 1]: now += 1 db[0][i] = now for j in range(1, 31): for k in range(n): db[j][k] = db[j - 1][db[j - 1][k]] for _ in range(q): a, b = LI() if a > b: a, b = b, a a -= 1 b -= 1 ret = 0 for kk in range(30, -1, -1): if db[kk][a] < b: a = db[kk][a] ret += 2 ** kk print((ret + 1))
61
60
1,681
1,603
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor from operator import mul from functools import reduce from operator import mul sys.setrecursionlimit(2147483647) INF = 10**20 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode("utf-8").split() def S(): return sys.stdin.buffer.readline().rstrip().decode("utf-8") def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 1000000007 n = I() X = LI() l = I() log_n = (n - 1).bit_length() doubling = [[n] * n for _ in range(log_n)] for i in range(n - 1): doubling[0][i] = bisect_right(X, X[i] + l) - 1 for j in range(1, log_n): for k in range(n): if doubling[j - 1][k] == n: continue doubling[j][k] = doubling[j - 1][doubling[j - 1][k]] q = I() for _ in range(q): a, b = LI() if a > b: a, b = b, a a -= 1 b -= 1 ans = 0 for m in range(log_n - 1, -1, -1): if doubling[m][a] < b: a = doubling[m][a] ans += 2**m print((ans + 1))
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor, cos, radians, pi, sin from operator import mul from functools import reduce from operator import mul sys.setrecursionlimit(2147483647) INF = 10**13 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode("utf-8").split() def S(): return sys.stdin.buffer.readline().rstrip().decode("utf-8") def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 10**9 + 7 n = I() x = LI() + [INF] l = I() q = I() db = [[0] * n for _ in range(31)] now = 0 for i in range(n): while x[i] + l >= x[now + 1]: now += 1 db[0][i] = now for j in range(1, 31): for k in range(n): db[j][k] = db[j - 1][db[j - 1][k]] for _ in range(q): a, b = LI() if a > b: a, b = b, a a -= 1 b -= 1 ret = 0 for kk in range(30, -1, -1): if db[kk][a] < b: a = db[kk][a] ret += 2**kk print((ret + 1))
false
1.639344
[ "-from math import factorial, ceil, floor", "+from math import factorial, ceil, floor, cos, radians, pi, sin", "-INF = 10**20", "+INF = 10**13", "-mod = 1000000007", "+mod = 10**9 + 7", "-X = LI()", "+x = LI() + [INF]", "-log_n = (n - 1).bit_length()", "-doubling = [[n] * n for _ in range(log_n)]", "-for i in range(n - 1):", "- doubling[0][i] = bisect_right(X, X[i] + l) - 1", "-for j in range(1, log_n):", "+q = I()", "+db = [[0] * n for _ in range(31)]", "+now = 0", "+for i in range(n):", "+ while x[i] + l >= x[now + 1]:", "+ now += 1", "+ db[0][i] = now", "+for j in range(1, 31):", "- if doubling[j - 1][k] == n:", "- continue", "- doubling[j][k] = doubling[j - 1][doubling[j - 1][k]]", "-q = I()", "+ db[j][k] = db[j - 1][db[j - 1][k]]", "- ans = 0", "- for m in range(log_n - 1, -1, -1):", "- if doubling[m][a] < b:", "- a = doubling[m][a]", "- ans += 2**m", "- print((ans + 1))", "+ ret = 0", "+ for kk in range(30, -1, -1):", "+ if db[kk][a] < b:", "+ a = db[kk][a]", "+ ret += 2**kk", "+ print((ret + 1))" ]
false
0.079947
0.077754
1.028205
[ "s558827638", "s669576091" ]
u906769651
p02784
python
s618964436
s888574894
54
49
13,964
20,580
Accepted
Accepted
9.26
H,N=input().split() H=int(H) N=int(N) A=list(map(int, input().split())) count=0 for i in range(N): count+=A[i] if count>=H: print("Yes") else: print("No")
# coding: utf-8 # Your code here! h,a=list(map(int,input().split())) A=list(map(int,input().split())) sum_A=sum(A) if h>sum_A: print("No") else: print("Yes")
14
12
176
173
H, N = input().split() H = int(H) N = int(N) A = list(map(int, input().split())) count = 0 for i in range(N): count += A[i] if count >= H: print("Yes") else: print("No")
# coding: utf-8 # Your code here! h, a = list(map(int, input().split())) A = list(map(int, input().split())) sum_A = sum(A) if h > sum_A: print("No") else: print("Yes")
false
14.285714
[ "-H, N = input().split()", "-H = int(H)", "-N = int(N)", "+# coding: utf-8", "+# Your code here!", "+h, a = list(map(int, input().split()))", "-count = 0", "-for i in range(N):", "- count += A[i]", "-if count >= H:", "+sum_A = sum(A)", "+if h > sum_A:", "+ print(\"No\")", "+else:", "-else:", "- print(\"No\")" ]
false
0.040469
0.105712
0.382825
[ "s618964436", "s888574894" ]
u906501980
p03160
python
s142987373
s381829651
169
127
18,884
13,980
Accepted
Accepted
24.85
n = int(eval(input())) H = list(map(int, input().split())) cost = [None]*n h1 = [None]*(n-1) h2 = [None]*(n-2) one_ago = H[1] two_ago = H[0] h1[0] = abs(two_ago-one_ago) for i in range(2, n): new = H[i] h1[i-1] = abs(one_ago-new) h2[i-2] = abs(two_ago-new) two_ago, one_ago = one_ago, new cost[0], cost[1] = 0, h1[0] for i in range(2, n): cost[i] = min(cost[i-2]+h2[i-2], cost[i-1]+h1[i-1]) print((cost[n-1]))
n = int(eval(input())) h = list(map(int, input().split())) dp = [None]*n dp[0], dp[1] = 0, abs(h[0]-h[1]) for i in range(2, n): dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i])) print((dp[-1]))
17
7
438
209
n = int(eval(input())) H = list(map(int, input().split())) cost = [None] * n h1 = [None] * (n - 1) h2 = [None] * (n - 2) one_ago = H[1] two_ago = H[0] h1[0] = abs(two_ago - one_ago) for i in range(2, n): new = H[i] h1[i - 1] = abs(one_ago - new) h2[i - 2] = abs(two_ago - new) two_ago, one_ago = one_ago, new cost[0], cost[1] = 0, h1[0] for i in range(2, n): cost[i] = min(cost[i - 2] + h2[i - 2], cost[i - 1] + h1[i - 1]) print((cost[n - 1]))
n = int(eval(input())) h = list(map(int, input().split())) dp = [None] * n dp[0], dp[1] = 0, abs(h[0] - h[1]) for i in range(2, n): dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i])) print((dp[-1]))
false
58.823529
[ "-H = list(map(int, input().split()))", "-cost = [None] * n", "-h1 = [None] * (n - 1)", "-h2 = [None] * (n - 2)", "-one_ago = H[1]", "-two_ago = H[0]", "-h1[0] = abs(two_ago - one_ago)", "+h = list(map(int, input().split()))", "+dp = [None] * n", "+dp[0], dp[1] = 0, abs(h[0] - h[1])", "- new = H[i]", "- h1[i - 1] = abs(one_ago - new)", "- h2[i - 2] = abs(two_ago - new)", "- two_ago, one_ago = one_ago, new", "-cost[0], cost[1] = 0, h1[0]", "-for i in range(2, n):", "- cost[i] = min(cost[i - 2] + h2[i - 2], cost[i - 1] + h1[i - 1])", "-print((cost[n - 1]))", "+ dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))", "+print((dp[-1]))" ]
false
0.102695
0.058144
1.76621
[ "s142987373", "s381829651" ]
u363259080
p03086
python
s494326920
s434952037
186
17
38,256
2,940
Accepted
Accepted
90.86
def check(s,i): global count count+=1 if i+1 < len(s): if s[i+1] == 'A' or s[i+1] == 'C' or s[i+1] =='G' or s[i+1] =='T': check(s,i+1) s=eval(input()) count=0 list=[] for i in range(len(s)): count=0 if s[i] == 'A' or s[i] == 'C' or s[i] =='G' or s[i] =='T': check(s,i) list.append(count) print((max(list)))
S = eval(input()) N = len(S) ans = 0 for i in range(N): for j in range(i, N): if all('ACGT'.count(c) == 1 for c in S[i : j + 1]): ans = max(ans, j - i + 1) print(ans)
17
8
364
174
def check(s, i): global count count += 1 if i + 1 < len(s): if s[i + 1] == "A" or s[i + 1] == "C" or s[i + 1] == "G" or s[i + 1] == "T": check(s, i + 1) s = eval(input()) count = 0 list = [] for i in range(len(s)): count = 0 if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T": check(s, i) list.append(count) print((max(list)))
S = eval(input()) N = len(S) ans = 0 for i in range(N): for j in range(i, N): if all("ACGT".count(c) == 1 for c in S[i : j + 1]): ans = max(ans, j - i + 1) print(ans)
false
52.941176
[ "-def check(s, i):", "- global count", "- count += 1", "- if i + 1 < len(s):", "- if s[i + 1] == \"A\" or s[i + 1] == \"C\" or s[i + 1] == \"G\" or s[i + 1] == \"T\":", "- check(s, i + 1)", "-", "-", "-s = eval(input())", "-count = 0", "-list = []", "-for i in range(len(s)):", "- count = 0", "- if s[i] == \"A\" or s[i] == \"C\" or s[i] == \"G\" or s[i] == \"T\":", "- check(s, i)", "- list.append(count)", "-print((max(list)))", "+S = eval(input())", "+N = len(S)", "+ans = 0", "+for i in range(N):", "+ for j in range(i, N):", "+ if all(\"ACGT\".count(c) == 1 for c in S[i : j + 1]):", "+ ans = max(ans, j - i + 1)", "+print(ans)" ]
false
0.089519
0.03717
2.408346
[ "s494326920", "s434952037" ]
u517930510
p02983
python
s539794292
s885949139
719
626
75,332
59,208
Accepted
Accepted
12.93
l,r = list(map(int, input().split())) if r-l+1>2019: print((0)) exit() L = [] for i in range(l,r): for j in range(i+1,r+1): a = i*j b = a%2019 L.append(b) print((min(L)))
l,r = list(map(int, input().split())) if r-l+1>2019: print((0)) exit() L = [] for i in range(l,r): for j in range(i+1,r+1): a = i*j b = a%2019 L.append(b) if b == 0: break print((min(L)))
11
13
189
218
l, r = list(map(int, input().split())) if r - l + 1 > 2019: print((0)) exit() L = [] for i in range(l, r): for j in range(i + 1, r + 1): a = i * j b = a % 2019 L.append(b) print((min(L)))
l, r = list(map(int, input().split())) if r - l + 1 > 2019: print((0)) exit() L = [] for i in range(l, r): for j in range(i + 1, r + 1): a = i * j b = a % 2019 L.append(b) if b == 0: break print((min(L)))
false
15.384615
[ "+ if b == 0:", "+ break" ]
false
0.046807
0.04888
0.957585
[ "s539794292", "s885949139" ]
u241159583
p03733
python
s673847121
s811685792
219
146
26,708
26,708
Accepted
Accepted
33.33
N, T = list(map(int, input().split())) t = list(map(int, input().split())) t.append(t[-1]) ans = 0 for i in range(1, N+1): if t[i] - t[i-1] > T: ans += T elif t[i] == t[i-1]: ans += T elif t[i] - t[i-1] <= T: ans += t[i] - t[i-1] print(ans)
n,t = list(map(int, input().split())) T = list(map(int, input().split())) ans = 0 for i in range(1,n): if T[i] - T[i-1] < t: ans += T[i] - T[i-1] else: ans += t ans += t print(ans)
13
9
267
198
N, T = list(map(int, input().split())) t = list(map(int, input().split())) t.append(t[-1]) ans = 0 for i in range(1, N + 1): if t[i] - t[i - 1] > T: ans += T elif t[i] == t[i - 1]: ans += T elif t[i] - t[i - 1] <= T: ans += t[i] - t[i - 1] print(ans)
n, t = list(map(int, input().split())) T = list(map(int, input().split())) ans = 0 for i in range(1, n): if T[i] - T[i - 1] < t: ans += T[i] - T[i - 1] else: ans += t ans += t print(ans)
false
30.769231
[ "-N, T = list(map(int, input().split()))", "-t = list(map(int, input().split()))", "-t.append(t[-1])", "+n, t = list(map(int, input().split()))", "+T = list(map(int, input().split()))", "-for i in range(1, N + 1):", "- if t[i] - t[i - 1] > T:", "- ans += T", "- elif t[i] == t[i - 1]:", "- ans += T", "- elif t[i] - t[i - 1] <= T:", "- ans += t[i] - t[i - 1]", "+for i in range(1, n):", "+ if T[i] - T[i - 1] < t:", "+ ans += T[i] - T[i - 1]", "+ else:", "+ ans += t", "+ans += t" ]
false
0.043533
0.043267
1.006162
[ "s673847121", "s811685792" ]
u848535504
p02731
python
s706465641
s760678614
28
25
9,324
9,320
Accepted
Accepted
10.71
L = int(eval(input())) print(((L/3)**3))
print(((int(eval(input()))/3)**3))
3
1
35
26
L = int(eval(input())) print(((L / 3) ** 3))
print(((int(eval(input())) / 3) ** 3))
false
66.666667
[ "-L = int(eval(input()))", "-print(((L / 3) ** 3))", "+print(((int(eval(input())) / 3) ** 3))" ]
false
0.068145
0.0379
1.798031
[ "s706465641", "s760678614" ]
u141786930
p03078
python
s736071005
s740206280
46
42
5,500
5,268
Accepted
Accepted
8.7
# D - Cake 123 import heapq import itertools from collections import defaultdict x, y, z, k = list(map(int, input().split())) A = list(int(a) for a in input().split()) B = list(int(b) for b in input().split()) C = list(int(c) for c in input().split()) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) hq = [] hqAns = [] d = defaultdict(int) heapq.heappush(hq, ((A[0]+B[0]+C[0])*-1,(0,0,0))) d[(0,0,0)] = 1 while len(hqAns)<k : val, key = heapq.heappop(hq) heapq.heappush(hqAns, val) if d[(key[0]+1, key[1], key[2])]==0 and key[0]+1 < x: heapq.heappush(hq, ((A[key[0]+1]+B[key[1]]+C[key[2]])*-1, ((key[0]+1, key[1], key[2])))) d[(key[0]+1, key[1], key[2])] = 1 if d[(key[0], key[1]+1, key[2])]==0 and key[1]+1 < y: heapq.heappush(hq, ((A[key[0]]+B[key[1]+1]+C[key[2]])*-1, ((key[0], key[1]+1, key[2])))) d[(key[0], key[1]+1, key[2])] = 1 if d[(key[0], key[1], key[2]+1)]==0 and key[2]+1 < z: heapq.heappush(hq, ((A[key[0]]+B[key[1]]+C[key[2]+1])*-1, ((key[0], key[1], key[2]+1)))) d[(key[0], key[1], key[2]+1)] = 1 for i in range(k): print((heapq.heappop(hqAns)*-1)) ''' # ans.2 # A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) hq = [] for i in range(x): for j in range(y): for l in range(z): if (i+1)*(j+1)*(l+1)<=k: heapq.heappush(hq, (A[i]+B[j]+C[l])*-1) else: break for _ in range(k): print(heapq.heappop(hq)*-1) ''' ''' # ans.1 # hq = [] for i, j in itertools.product(A, B): heapq.heappush(hq, (i+j)*-1) AB = [] while len(hq)>0 and len(AB)<=k: AB.append(heapq.heappop(hq)*-1) hq = [] for i, j in itertools.product(AB, C): heapq.heappush(hq, (i+j)*-1) for _ in range(k): print(heapq.heappop(hq)*-1) '''
# D - Cake 123 import heapq import itertools from collections import defaultdict x, y, z, k = list(map(int, input().split())) A = list(int(a) for a in input().split()) B = list(int(b) for b in input().split()) C = list(int(c) for c in input().split()) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) hq = [] hqAns = [] d = defaultdict(int) heapq.heappush(hq, ((A[0]+B[0]+C[0])*-1, 0, 0, 0)) d[(0,0,0)] = 1 while len(hqAns)<k : val, l, m, n = heapq.heappop(hq) heapq.heappush(hqAns, val) if d[(l+1, m, n)]==0 and l+1 < x: heapq.heappush(hq, ((A[l+1]+B[m]+C[n])*-1, l+1, m, n)) d[(l+1, m, n)] = 1 if d[(l, m+1, n)]==0 and m+1 < y: heapq.heappush(hq, ((A[l]+B[m+1]+C[n])*-1, l, m+1, n)) d[(l, m+1, n)] = 1 if d[(l, m, n+1)]==0 and n+1 < z: heapq.heappush(hq, ((A[l]+B[m]+C[n+1])*-1, l, m, n+1)) d[(l, m, n+1)] = 1 for i in range(k): print((heapq.heappop(hqAns)*-1)) ''' # ans.2 # A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) hq = [] for i in range(x): for j in range(y): for l in range(z): if (i+1)*(j+1)*(l+1)<=k: heapq.heappush(hq, (A[i]+B[j]+C[l])*-1) else: break for _ in range(k): print(heapq.heappop(hq)*-1) ''' ''' # ans.1 # hq = [] for i, j in itertools.product(A, B): heapq.heappush(hq, (i+j)*-1) AB = [] while len(hq)>0 and len(AB)<=k: AB.append(heapq.heappop(hq)*-1) hq = [] for i, j in itertools.product(AB, C): heapq.heappush(hq, (i+j)*-1) for _ in range(k): print(heapq.heappop(hq)*-1) '''
83
83
1,895
1,693
# D - Cake 123 import heapq import itertools from collections import defaultdict x, y, z, k = list(map(int, input().split())) A = list(int(a) for a in input().split()) B = list(int(b) for b in input().split()) C = list(int(c) for c in input().split()) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) hq = [] hqAns = [] d = defaultdict(int) heapq.heappush(hq, ((A[0] + B[0] + C[0]) * -1, (0, 0, 0))) d[(0, 0, 0)] = 1 while len(hqAns) < k: val, key = heapq.heappop(hq) heapq.heappush(hqAns, val) if d[(key[0] + 1, key[1], key[2])] == 0 and key[0] + 1 < x: heapq.heappush( hq, ( (A[key[0] + 1] + B[key[1]] + C[key[2]]) * -1, ((key[0] + 1, key[1], key[2])), ), ) d[(key[0] + 1, key[1], key[2])] = 1 if d[(key[0], key[1] + 1, key[2])] == 0 and key[1] + 1 < y: heapq.heappush( hq, ( (A[key[0]] + B[key[1] + 1] + C[key[2]]) * -1, ((key[0], key[1] + 1, key[2])), ), ) d[(key[0], key[1] + 1, key[2])] = 1 if d[(key[0], key[1], key[2] + 1)] == 0 and key[2] + 1 < z: heapq.heappush( hq, ( (A[key[0]] + B[key[1]] + C[key[2] + 1]) * -1, ((key[0], key[1], key[2] + 1)), ), ) d[(key[0], key[1], key[2] + 1)] = 1 for i in range(k): print((heapq.heappop(hqAns) * -1)) """ # ans.2 # A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) hq = [] for i in range(x): for j in range(y): for l in range(z): if (i+1)*(j+1)*(l+1)<=k: heapq.heappush(hq, (A[i]+B[j]+C[l])*-1) else: break for _ in range(k): print(heapq.heappop(hq)*-1) """ """ # ans.1 # hq = [] for i, j in itertools.product(A, B): heapq.heappush(hq, (i+j)*-1) AB = [] while len(hq)>0 and len(AB)<=k: AB.append(heapq.heappop(hq)*-1) hq = [] for i, j in itertools.product(AB, C): heapq.heappush(hq, (i+j)*-1) for _ in range(k): print(heapq.heappop(hq)*-1) """
# D - Cake 123 import heapq import itertools from collections import defaultdict x, y, z, k = list(map(int, input().split())) A = list(int(a) for a in input().split()) B = list(int(b) for b in input().split()) C = list(int(c) for c in input().split()) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) hq = [] hqAns = [] d = defaultdict(int) heapq.heappush(hq, ((A[0] + B[0] + C[0]) * -1, 0, 0, 0)) d[(0, 0, 0)] = 1 while len(hqAns) < k: val, l, m, n = heapq.heappop(hq) heapq.heappush(hqAns, val) if d[(l + 1, m, n)] == 0 and l + 1 < x: heapq.heappush(hq, ((A[l + 1] + B[m] + C[n]) * -1, l + 1, m, n)) d[(l + 1, m, n)] = 1 if d[(l, m + 1, n)] == 0 and m + 1 < y: heapq.heappush(hq, ((A[l] + B[m + 1] + C[n]) * -1, l, m + 1, n)) d[(l, m + 1, n)] = 1 if d[(l, m, n + 1)] == 0 and n + 1 < z: heapq.heappush(hq, ((A[l] + B[m] + C[n + 1]) * -1, l, m, n + 1)) d[(l, m, n + 1)] = 1 for i in range(k): print((heapq.heappop(hqAns) * -1)) """ # ans.2 # A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) hq = [] for i in range(x): for j in range(y): for l in range(z): if (i+1)*(j+1)*(l+1)<=k: heapq.heappush(hq, (A[i]+B[j]+C[l])*-1) else: break for _ in range(k): print(heapq.heappop(hq)*-1) """ """ # ans.1 # hq = [] for i, j in itertools.product(A, B): heapq.heappush(hq, (i+j)*-1) AB = [] while len(hq)>0 and len(AB)<=k: AB.append(heapq.heappop(hq)*-1) hq = [] for i, j in itertools.product(AB, C): heapq.heappush(hq, (i+j)*-1) for _ in range(k): print(heapq.heappop(hq)*-1) """
false
0
[ "-heapq.heappush(hq, ((A[0] + B[0] + C[0]) * -1, (0, 0, 0)))", "+heapq.heappush(hq, ((A[0] + B[0] + C[0]) * -1, 0, 0, 0))", "- val, key = heapq.heappop(hq)", "+ val, l, m, n = heapq.heappop(hq)", "- if d[(key[0] + 1, key[1], key[2])] == 0 and key[0] + 1 < x:", "- heapq.heappush(", "- hq,", "- (", "- (A[key[0] + 1] + B[key[1]] + C[key[2]]) * -1,", "- ((key[0] + 1, key[1], key[2])),", "- ),", "- )", "- d[(key[0] + 1, key[1], key[2])] = 1", "- if d[(key[0], key[1] + 1, key[2])] == 0 and key[1] + 1 < y:", "- heapq.heappush(", "- hq,", "- (", "- (A[key[0]] + B[key[1] + 1] + C[key[2]]) * -1,", "- ((key[0], key[1] + 1, key[2])),", "- ),", "- )", "- d[(key[0], key[1] + 1, key[2])] = 1", "- if d[(key[0], key[1], key[2] + 1)] == 0 and key[2] + 1 < z:", "- heapq.heappush(", "- hq,", "- (", "- (A[key[0]] + B[key[1]] + C[key[2] + 1]) * -1,", "- ((key[0], key[1], key[2] + 1)),", "- ),", "- )", "- d[(key[0], key[1], key[2] + 1)] = 1", "+ if d[(l + 1, m, n)] == 0 and l + 1 < x:", "+ heapq.heappush(hq, ((A[l + 1] + B[m] + C[n]) * -1, l + 1, m, n))", "+ d[(l + 1, m, n)] = 1", "+ if d[(l, m + 1, n)] == 0 and m + 1 < y:", "+ heapq.heappush(hq, ((A[l] + B[m + 1] + C[n]) * -1, l, m + 1, n))", "+ d[(l, m + 1, n)] = 1", "+ if d[(l, m, n + 1)] == 0 and n + 1 < z:", "+ heapq.heappush(hq, ((A[l] + B[m] + C[n + 1]) * -1, l, m, n + 1))", "+ d[(l, m, n + 1)] = 1" ]
false
0.037958
0.037131
1.022287
[ "s736071005", "s740206280" ]
u263830634
p04000
python
s929603802
s575620067
2,212
1,796
166,912
166,908
Accepted
Accepted
18.81
from collections import defaultdict import sys input = sys.stdin.readline H, W, N = map(int, input().split()) ans = [0] * 10 ans[0] = (H - 2) * (W - 2) # print (ans) tmplst = [-1, 0, 1] dic = defaultdict(int) for _ in range(N): a, b = map(int, input().split()) a -= 1 b -= 1 for i in tmplst: if 0 <= a + i <= H - 1: for j in tmplst: if 0 <= b + j <= W - 1: #範囲に入っている tmp = dic[(a + i, b + j)] dic[(a + i, b + j)] += 1 if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2: ans[tmp] -= 1 ans[tmp + 1] += 1 print (*ans, sep = '\n')
def main(): from collections import defaultdict import sys input = sys.stdin.readline H, W, N = map(int, input().split()) ans = [0] * 10 ans[0] = (H - 2) * (W - 2) # print (ans) tmplst = [-1, 0, 1] dic = defaultdict(int) for _ in range(N): a, b = map(int, input().split()) a -= 1 b -= 1 for i in tmplst: if 0 <= a + i <= H - 1: for j in tmplst: if 0 <= b + j <= W - 1: #範囲に入っている tmp = dic[(a + i, b + j)] dic[(a + i, b + j)] += 1 if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2: ans[tmp] -= 1 ans[tmp + 1] += 1 print (*ans, sep = '\n') if __name__ == '__main__': main()
25
29
708
855
from collections import defaultdict import sys input = sys.stdin.readline H, W, N = map(int, input().split()) ans = [0] * 10 ans[0] = (H - 2) * (W - 2) # print (ans) tmplst = [-1, 0, 1] dic = defaultdict(int) for _ in range(N): a, b = map(int, input().split()) a -= 1 b -= 1 for i in tmplst: if 0 <= a + i <= H - 1: for j in tmplst: if 0 <= b + j <= W - 1: # 範囲に入っている tmp = dic[(a + i, b + j)] dic[(a + i, b + j)] += 1 if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2: ans[tmp] -= 1 ans[tmp + 1] += 1 print(*ans, sep="\n")
def main(): from collections import defaultdict import sys input = sys.stdin.readline H, W, N = map(int, input().split()) ans = [0] * 10 ans[0] = (H - 2) * (W - 2) # print (ans) tmplst = [-1, 0, 1] dic = defaultdict(int) for _ in range(N): a, b = map(int, input().split()) a -= 1 b -= 1 for i in tmplst: if 0 <= a + i <= H - 1: for j in tmplst: if 0 <= b + j <= W - 1: # 範囲に入っている tmp = dic[(a + i, b + j)] dic[(a + i, b + j)] += 1 if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2: ans[tmp] -= 1 ans[tmp + 1] += 1 print(*ans, sep="\n") if __name__ == "__main__": main()
false
13.793103
[ "-from collections import defaultdict", "-import sys", "+def main():", "+ from collections import defaultdict", "+ import sys", "-input = sys.stdin.readline", "-H, W, N = map(int, input().split())", "-ans = [0] * 10", "-ans[0] = (H - 2) * (W - 2)", "-# print (ans)", "-tmplst = [-1, 0, 1]", "-dic = defaultdict(int)", "-for _ in range(N):", "- a, b = map(int, input().split())", "- a -= 1", "- b -= 1", "- for i in tmplst:", "- if 0 <= a + i <= H - 1:", "- for j in tmplst:", "- if 0 <= b + j <= W - 1: # 範囲に入っている", "- tmp = dic[(a + i, b + j)]", "- dic[(a + i, b + j)] += 1", "- if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2:", "- ans[tmp] -= 1", "- ans[tmp + 1] += 1", "-print(*ans, sep=\"\\n\")", "+ input = sys.stdin.readline", "+ H, W, N = map(int, input().split())", "+ ans = [0] * 10", "+ ans[0] = (H - 2) * (W - 2)", "+ # print (ans)", "+ tmplst = [-1, 0, 1]", "+ dic = defaultdict(int)", "+ for _ in range(N):", "+ a, b = map(int, input().split())", "+ a -= 1", "+ b -= 1", "+ for i in tmplst:", "+ if 0 <= a + i <= H - 1:", "+ for j in tmplst:", "+ if 0 <= b + j <= W - 1: # 範囲に入っている", "+ tmp = dic[(a + i, b + j)]", "+ dic[(a + i, b + j)] += 1", "+ if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2:", "+ ans[tmp] -= 1", "+ ans[tmp + 1] += 1", "+ print(*ans, sep=\"\\n\")", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.038826
0.04557
0.852005
[ "s929603802", "s575620067" ]
u024782094
p02614
python
s860405125
s472319259
407
127
74,640
79,000
Accepted
Accepted
68.8
import sys import heapq import math import fractions import bisect import itertools from collections import Counter from collections import deque from operator import itemgetter def input(): return sys.stdin.readline().strip() def mp(): return list(map(int,input().split())) def lmp(): return list(map(int,input().split())) h,w,k=mp() rh=[i for i in range(h)] rw=[i for i in range(w)] grid=[] for i in range(h): grid.append(eval(input())) lh=[] lw=[] for i in range(h): lh.extend(list(itertools.combinations(rh, i))) for i in range(w): lw.extend(list(itertools.combinations(rw, i))) ans=0 for x in lh: for y in lw: ch=[[0]*w for i in range(h)] for i in range(h): for j in range(w): if i in x or j in y: ch[i][j]=1 c=0 for i in range(h): for j in range(w): if ch[i][j]==0 and grid[i][j]=="#": c+=1 if c==k: ans+=1 print(ans)
import sys import heapq import math import fractions import bisect import itertools from collections import Counter from collections import deque from operator import itemgetter def input(): return sys.stdin.readline().strip() def mp(): return list(map(int,input().split())) def lmp(): return list(map(int,input().split())) h,w,k=mp() grid=[] for i in range(h): grid.append(eval(input())) ans=0 for i in range(2**h): for j in range(2**w): c=0 for x in range(h): for y in range(w): if ((i>>x)&1) and ((j>>y)&1) and grid[x][y]=="#": c+=1 if c==k: ans+=1 print(ans)
50
28
1,035
670
import sys import heapq import math import fractions import bisect import itertools from collections import Counter from collections import deque from operator import itemgetter def input(): return sys.stdin.readline().strip() def mp(): return list(map(int, input().split())) def lmp(): return list(map(int, input().split())) h, w, k = mp() rh = [i for i in range(h)] rw = [i for i in range(w)] grid = [] for i in range(h): grid.append(eval(input())) lh = [] lw = [] for i in range(h): lh.extend(list(itertools.combinations(rh, i))) for i in range(w): lw.extend(list(itertools.combinations(rw, i))) ans = 0 for x in lh: for y in lw: ch = [[0] * w for i in range(h)] for i in range(h): for j in range(w): if i in x or j in y: ch[i][j] = 1 c = 0 for i in range(h): for j in range(w): if ch[i][j] == 0 and grid[i][j] == "#": c += 1 if c == k: ans += 1 print(ans)
import sys import heapq import math import fractions import bisect import itertools from collections import Counter from collections import deque from operator import itemgetter def input(): return sys.stdin.readline().strip() def mp(): return list(map(int, input().split())) def lmp(): return list(map(int, input().split())) h, w, k = mp() grid = [] for i in range(h): grid.append(eval(input())) ans = 0 for i in range(2**h): for j in range(2**w): c = 0 for x in range(h): for y in range(w): if ((i >> x) & 1) and ((j >> y) & 1) and grid[x][y] == "#": c += 1 if c == k: ans += 1 print(ans)
false
44
[ "-rh = [i for i in range(h)]", "-rw = [i for i in range(w)]", "-lh = []", "-lw = []", "-for i in range(h):", "- lh.extend(list(itertools.combinations(rh, i)))", "-for i in range(w):", "- lw.extend(list(itertools.combinations(rw, i)))", "-for x in lh:", "- for y in lw:", "- ch = [[0] * w for i in range(h)]", "- for i in range(h):", "- for j in range(w):", "- if i in x or j in y:", "- ch[i][j] = 1", "+for i in range(2**h):", "+ for j in range(2**w):", "- for i in range(h):", "- for j in range(w):", "- if ch[i][j] == 0 and grid[i][j] == \"#\":", "+ for x in range(h):", "+ for y in range(w):", "+ if ((i >> x) & 1) and ((j >> y) & 1) and grid[x][y] == \"#\":" ]
false
0.042879
0.040133
1.068432
[ "s860405125", "s472319259" ]
u145231176
p02662
python
s786111295
s721686945
418
334
151,808
152,452
Accepted
Accepted
20.1
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * import heapq import math from fractions import gcd import random import string import copy from itertools import combinations, permutations, product from operator import mul, itemgetter from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10 ** 9 + 7 ############# # Main Code # ############# N, S = getNM() A = getList() MOD = 998244353 dp = [[0] * (S + 1) for i in range(N + 1)] dp[0][0] = 1 # [3 1 ④] 1 5 [⑨ ② 6] 5 [3]みたいな感じで数えあげる for i in range(N): for j in range(S + 1): # Tに含める通りと含めない通り dp[i + 1][j] += dp[i][j] * 2 dp[i + 1][j] %= MOD if j - A[i] >= 0: # Tに含める通りかつUに含める通り dp[i + 1][j] += dp[i][j - A[i]] dp[i + 1][j] %= MOD print((dp[N][S] % MOD))
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * from heapq import heapify, heappop, heappush from math import sqrt from fractions import gcd import random import string import copy from itertools import combinations, permutations, product from operator import mul, itemgetter from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10 ** 9 + 7 ############# # Main Code # ############# # 集合[a1, a2...an]内で以下2つの条件を満たす部分集合の組(T, U)はいくつあるか問題 # 1: U ⊆ Tである # 2: Uがある条件を満たす # Tの中にUがいくつか含まれる # ①iが進むごとにTの候補がn倍ずつ増えていく # ②その後、Uを組むためのカウントを進める ''' ABC104 D - We Love ABC S = '????C?????B??????A???????' N = len(S) # dp[i][j]: i番目にjまで丸をつけ終えている通り dp = [[0] * 4 for _ in range(N + 1)] dp[0][0] = 1 for i in range(N): # 通りの数を増やす for j in range(4): if S[i] != '?': dp[i + 1][j] += dp[i][j] dp[i + 1][j] %= mod else: dp[i + 1][j] += 3 * dp[i][j] dp[i + 1][j] %= mod # カウントが進むものを加える if S[i] == 'A' or S[i] == '?': dp[i + 1][1] += dp[i][0] dp[i + 1][1] %= mod if S[i] == 'B' or S[i] == '?': dp[i + 1][2] += dp[i][1] dp[i + 1][2] %= mod if S[i] == 'C' or S[i] == '?': dp[i + 1][3] += dp[i][2] dp[i + 1][3] %= mod print(dp[N][3] % mod) ''' # ABC169 F - Knapsack for All Subsets N, S = getNM() A = getList() MOD = 998244353 dp = [[0] * (S + 1) for i in range(N + 1)] dp[0][0] = 1 for i in range(N): # 通りの数を増やす for j in range(S + 1): dp[i + 1][j] += dp[i][j] * 2 dp[i + 1][j] %= MOD # カウントが進むものを加える for j in range(S + 1): if j - A[i] >= 0: dp[i + 1][j] += dp[i][j - A[i]] dp[i + 1][j] %= MOD print((dp[N][S] % MOD))
70
108
1,770
2,727
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * import heapq import math from fractions import gcd import random import string import copy from itertools import combinations, permutations, product from operator import mul, itemgetter from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10**9 + 7 ############# # Main Code # ############# N, S = getNM() A = getList() MOD = 998244353 dp = [[0] * (S + 1) for i in range(N + 1)] dp[0][0] = 1 # [3 1 ④] 1 5 [⑨ ② 6] 5 [3]みたいな感じで数えあげる for i in range(N): for j in range(S + 1): # Tに含める通りと含めない通り dp[i + 1][j] += dp[i][j] * 2 dp[i + 1][j] %= MOD if j - A[i] >= 0: # Tに含める通りかつUに含める通り dp[i + 1][j] += dp[i][j - A[i]] dp[i + 1][j] %= MOD print((dp[N][S] % MOD))
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * from heapq import heapify, heappop, heappush from math import sqrt from fractions import gcd import random import string import copy from itertools import combinations, permutations, product from operator import mul, itemgetter from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10**9 + 7 ############# # Main Code # ############# # 集合[a1, a2...an]内で以下2つの条件を満たす部分集合の組(T, U)はいくつあるか問題 # 1: U ⊆ Tである # 2: Uがある条件を満たす # Tの中にUがいくつか含まれる # ①iが進むごとにTの候補がn倍ずつ増えていく # ②その後、Uを組むためのカウントを進める """ ABC104 D - We Love ABC S = '????C?????B??????A???????' N = len(S) # dp[i][j]: i番目にjまで丸をつけ終えている通り dp = [[0] * 4 for _ in range(N + 1)] dp[0][0] = 1 for i in range(N): # 通りの数を増やす for j in range(4): if S[i] != '?': dp[i + 1][j] += dp[i][j] dp[i + 1][j] %= mod else: dp[i + 1][j] += 3 * dp[i][j] dp[i + 1][j] %= mod # カウントが進むものを加える if S[i] == 'A' or S[i] == '?': dp[i + 1][1] += dp[i][0] dp[i + 1][1] %= mod if S[i] == 'B' or S[i] == '?': dp[i + 1][2] += dp[i][1] dp[i + 1][2] %= mod if S[i] == 'C' or S[i] == '?': dp[i + 1][3] += dp[i][2] dp[i + 1][3] %= mod print(dp[N][3] % mod) """ # ABC169 F - Knapsack for All Subsets N, S = getNM() A = getList() MOD = 998244353 dp = [[0] * (S + 1) for i in range(N + 1)] dp[0][0] = 1 for i in range(N): # 通りの数を増やす for j in range(S + 1): dp[i + 1][j] += dp[i][j] * 2 dp[i + 1][j] %= MOD # カウントが進むものを加える for j in range(S + 1): if j - A[i] >= 0: dp[i + 1][j] += dp[i][j - A[i]] dp[i + 1][j] %= MOD print((dp[N][S] % MOD))
false
35.185185
[ "-import heapq", "-import math", "+from heapq import heapify, heappop, heappush", "+from math import sqrt", "+# 集合[a1, a2...an]内で以下2つの条件を満たす部分集合の組(T, U)はいくつあるか問題", "+# 1: U ⊆ Tである", "+# 2: Uがある条件を満たす", "+# Tの中にUがいくつか含まれる", "+# ①iが進むごとにTの候補がn倍ずつ増えていく", "+# ②その後、Uを組むためのカウントを進める", "+\"\"\" ABC104 D - We Love ABC", "+S = '????C?????B??????A???????'", "+N = len(S)", "+# dp[i][j]: i番目にjまで丸をつけ終えている通り", "+dp = [[0] * 4 for _ in range(N + 1)]", "+dp[0][0] = 1", "+for i in range(N):", "+ # 通りの数を増やす", "+ for j in range(4):", "+ if S[i] != '?':", "+ dp[i + 1][j] += dp[i][j]", "+ dp[i + 1][j] %= mod", "+ else:", "+ dp[i + 1][j] += 3 * dp[i][j]", "+ dp[i + 1][j] %= mod", "+ # カウントが進むものを加える", "+ if S[i] == 'A' or S[i] == '?':", "+ dp[i + 1][1] += dp[i][0]", "+ dp[i + 1][1] %= mod", "+ if S[i] == 'B' or S[i] == '?':", "+ dp[i + 1][2] += dp[i][1]", "+ dp[i + 1][2] %= mod", "+ if S[i] == 'C' or S[i] == '?':", "+ dp[i + 1][3] += dp[i][2]", "+ dp[i + 1][3] %= mod", "+print(dp[N][3] % mod)", "+\"\"\"", "+# ABC169 F - Knapsack for All Subsets", "-# [3 1 ④] 1 5 [⑨ ② 6] 5 [3]みたいな感じで数えあげる", "+ # 通りの数を増やす", "- # Tに含める通りと含めない通り", "+ # カウントが進むものを加える", "+ for j in range(S + 1):", "- # Tに含める通りかつUに含める通り" ]
false
0.115766
0.045122
2.565613
[ "s786111295", "s721686945" ]
u395202850
p02882
python
s268341304
s962832895
20
17
3,316
3,060
Accepted
Accepted
15
import math a, b, x = list(map(int, input().split())) theta = 0 if x * 2 >= a ** 2 * b: ans = (2/a) * (b - x / a**2) else: ans = (a * b ** 2)/(2 * x) print((math.degrees(math.atan(ans))))
import math a, b, x = list(map(int, input().split())) print((math.degrees(math.atan(((2/a) * (b - x / a**2) if x * 2 >= a ** 2 * b else (a * b ** 2)/(2 * x))))))
8
4
195
186
import math a, b, x = list(map(int, input().split())) theta = 0 if x * 2 >= a**2 * b: ans = (2 / a) * (b - x / a**2) else: ans = (a * b**2) / (2 * x) print((math.degrees(math.atan(ans))))
import math a, b, x = list(map(int, input().split())) print( ( math.degrees( math.atan( ( (2 / a) * (b - x / a**2) if x * 2 >= a**2 * b else (a * b**2) / (2 * x) ) ) ) ) )
false
50
[ "-theta = 0", "-if x * 2 >= a**2 * b:", "- ans = (2 / a) * (b - x / a**2)", "-else:", "- ans = (a * b**2) / (2 * x)", "-print((math.degrees(math.atan(ans))))", "+print(", "+ (", "+ math.degrees(", "+ math.atan(", "+ (", "+ (2 / a) * (b - x / a**2)", "+ if x * 2 >= a**2 * b", "+ else (a * b**2) / (2 * x)", "+ )", "+ )", "+ )", "+ )", "+)" ]
false
0.048105
0.047949
1.003256
[ "s268341304", "s962832895" ]
u664373116
p03013
python
s667109594
s065984344
482
200
55,640
8,180
Accepted
Accepted
58.51
mod=10**9+7 n,m=list(map(int,input().split())) a=[int(eval(input())) for _ in range(m)] fib=[1,1] c=0 if m>0 and a[0]==1: fib[1]=0 c+=1 for i in range(2,n+1): if c<m and a[c]==i: fib.append(0) c+=1 else: fib.append((fib[i-2]+fib[i-1])%mod) print((fib[n]))
from collections import Counter from collections import defaultdict from collections import deque import math import itertools import heapq import sys sys.setrecursionlimit(10**6) #n=int(input()) #n,m=list(map(int,input().split())) #a=list(map(int,input().split())) input_list = lambda : list(map(int,input().split())) n,m=input_list() c=[True for _ in range(n+1)] mod=10**9+7 for _ in range(m): num=int(eval(input())) c[num]=False fib=[1,1] if not c[1]: fib[1]=0 for i in range(2,n+1): if c[i]: fib.append((fib[i-1]+fib[i-2])%mod) else: fib.append(0) print((fib[-1]%mod))
19
37
309
656
mod = 10**9 + 7 n, m = list(map(int, input().split())) a = [int(eval(input())) for _ in range(m)] fib = [1, 1] c = 0 if m > 0 and a[0] == 1: fib[1] = 0 c += 1 for i in range(2, n + 1): if c < m and a[c] == i: fib.append(0) c += 1 else: fib.append((fib[i - 2] + fib[i - 1]) % mod) print((fib[n]))
from collections import Counter from collections import defaultdict from collections import deque import math import itertools import heapq import sys sys.setrecursionlimit(10**6) # n=int(input()) # n,m=list(map(int,input().split())) # a=list(map(int,input().split())) input_list = lambda: list(map(int, input().split())) n, m = input_list() c = [True for _ in range(n + 1)] mod = 10**9 + 7 for _ in range(m): num = int(eval(input())) c[num] = False fib = [1, 1] if not c[1]: fib[1] = 0 for i in range(2, n + 1): if c[i]: fib.append((fib[i - 1] + fib[i - 2]) % mod) else: fib.append(0) print((fib[-1] % mod))
false
48.648649
[ "+from collections import Counter", "+from collections import defaultdict", "+from collections import deque", "+import math", "+import itertools", "+import heapq", "+import sys", "+", "+sys.setrecursionlimit(10**6)", "+# n=int(input())", "+# n,m=list(map(int,input().split()))", "+# a=list(map(int,input().split()))", "+input_list = lambda: list(map(int, input().split()))", "+n, m = input_list()", "+c = [True for _ in range(n + 1)]", "-n, m = list(map(int, input().split()))", "-a = [int(eval(input())) for _ in range(m)]", "+for _ in range(m):", "+ num = int(eval(input()))", "+ c[num] = False", "-c = 0", "-if m > 0 and a[0] == 1:", "+if not c[1]:", "- c += 1", "- if c < m and a[c] == i:", "+ if c[i]:", "+ fib.append((fib[i - 1] + fib[i - 2]) % mod)", "+ else:", "- c += 1", "- else:", "- fib.append((fib[i - 2] + fib[i - 1]) % mod)", "-print((fib[n]))", "+print((fib[-1] % mod))" ]
false
0.036891
0.043294
0.852115
[ "s667109594", "s065984344" ]
u729133443
p03958
python
s416801715
s595974228
167
17
38,256
2,940
Accepted
Accepted
89.82
k,t,*a=list(map(int,open(0).read().split()));print((max([i+i-k-1for i in a]+[0])))
k,t,*a=list(map(int,open(0).read().split()));print((max(max(a)*2-sum(a),1)-1))
1
1
74
70
k, t, *a = list(map(int, open(0).read().split())) print((max([i + i - k - 1 for i in a] + [0])))
k, t, *a = list(map(int, open(0).read().split())) print((max(max(a) * 2 - sum(a), 1) - 1))
false
0
[ "-print((max([i + i - k - 1 for i in a] + [0])))", "+print((max(max(a) * 2 - sum(a), 1) - 1))" ]
false
0.035313
0.037988
0.929575
[ "s416801715", "s595974228" ]
u600402037
p03295
python
s094425832
s729971444
675
413
68,584
60,380
Accepted
Accepted
38.81
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() AB = [lr() for _ in range(M)] AB.sort(key=lambda x: [x[0], x[1]]) cur = 0 answer = 0 for a, b in AB: if a >= cur: answer += 1 cur = b if b < cur: cur = b print(answer)
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() AB = [lr() for _ in range(M)] AB.sort(key=lambda x: x[1]) cur = 0 answer = 0 for a, b in AB: if a >= cur: answer += 1 cur = b print(answer)
20
18
369
327
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() AB = [lr() for _ in range(M)] AB.sort(key=lambda x: [x[0], x[1]]) cur = 0 answer = 0 for a, b in AB: if a >= cur: answer += 1 cur = b if b < cur: cur = b print(answer)
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() AB = [lr() for _ in range(M)] AB.sort(key=lambda x: x[1]) cur = 0 answer = 0 for a, b in AB: if a >= cur: answer += 1 cur = b print(answer)
false
10
[ "-AB.sort(key=lambda x: [x[0], x[1]])", "+AB.sort(key=lambda x: x[1])", "- if b < cur:", "- cur = b" ]
false
0.041749
0.12474
0.334687
[ "s094425832", "s729971444" ]
u018679195
p02819
python
s675114760
s217246672
25
17
2,940
3,060
Accepted
Accepted
32
x=int(eval(input())) flag=0 while(1): flag=0 for i in range(2,int(x/2+1)): if x%i==0: flag=1 x+=1 break if flag==0: print(x) break
n=int(eval(input())) flag=1 for i in range(n,10*n): j=2 flag=1 while(j<=int(i**(0.5))): if(i%j==0): flag=0 break j+=1 if(flag==1): print(i) break
12
13
208
193
x = int(eval(input())) flag = 0 while 1: flag = 0 for i in range(2, int(x / 2 + 1)): if x % i == 0: flag = 1 x += 1 break if flag == 0: print(x) break
n = int(eval(input())) flag = 1 for i in range(n, 10 * n): j = 2 flag = 1 while j <= int(i ** (0.5)): if i % j == 0: flag = 0 break j += 1 if flag == 1: print(i) break
false
7.692308
[ "-x = int(eval(input()))", "-flag = 0", "-while 1:", "- flag = 0", "- for i in range(2, int(x / 2 + 1)):", "- if x % i == 0:", "- flag = 1", "- x += 1", "+n = int(eval(input()))", "+flag = 1", "+for i in range(n, 10 * n):", "+ j = 2", "+ flag = 1", "+ while j <= int(i ** (0.5)):", "+ if i % j == 0:", "+ flag = 0", "- if flag == 0:", "- print(x)", "+ j += 1", "+ if flag == 1:", "+ print(i)" ]
false
0.065287
0.037928
1.721334
[ "s675114760", "s217246672" ]
u597374218
p02951
python
s661969540
s255519098
30
27
9,152
9,072
Accepted
Accepted
10
A,B,C=list(map(int,input().split())) print((max(0,C-(A-B))))
A,B,C=list(map(int,input().split())) water=C-(A-B) print((water if water>0 else 0))
2
3
53
77
A, B, C = list(map(int, input().split())) print((max(0, C - (A - B))))
A, B, C = list(map(int, input().split())) water = C - (A - B) print((water if water > 0 else 0))
false
33.333333
[ "-print((max(0, C - (A - B))))", "+water = C - (A - B)", "+print((water if water > 0 else 0))" ]
false
0.037909
0.035229
1.076051
[ "s661969540", "s255519098" ]
u133356863
p02713
python
s618070519
s090041939
1,357
1,177
9,180
9,180
Accepted
Accepted
13.26
import math k=int(eval(input())) ans=0 for i in range(1,k+1): for j in range(1,k+1): ij=math.gcd(i,j) for k in range(1,k+1): ans+=math.gcd(ij,k) print(ans)
from math import gcd k=int(eval(input())) ans=0 for i in range(1,k+1): for j in range(1,k+1): ij=gcd(i,j) for k in range(1,k+1): ans+=gcd(ij,k) print(ans)
9
9
189
188
import math k = int(eval(input())) ans = 0 for i in range(1, k + 1): for j in range(1, k + 1): ij = math.gcd(i, j) for k in range(1, k + 1): ans += math.gcd(ij, k) print(ans)
from math import gcd k = int(eval(input())) ans = 0 for i in range(1, k + 1): for j in range(1, k + 1): ij = gcd(i, j) for k in range(1, k + 1): ans += gcd(ij, k) print(ans)
false
0
[ "-import math", "+from math import gcd", "- ij = math.gcd(i, j)", "+ ij = gcd(i, j)", "- ans += math.gcd(ij, k)", "+ ans += gcd(ij, k)" ]
false
0.201749
0.145721
1.384489
[ "s618070519", "s090041939" ]
u437351386
p03241
python
s700486205
s236678083
1,012
67
62,900
63,860
Accepted
Accepted
93.38
n,m=list(map(int,input().split())) for i in range(n,10**8): if m%i==0: print((m//i)) exit() print((1))
n,m=list(map(int,input().split())) yakusuu=[] import math for i in range(1,int(math.sqrt(m)+1)): if m%i==0: yakusuu.append(i) yakusuu.append(m//i) yakusuu.sort() for num in yakusuu: if num>=n: print((m//num)) exit()
8
15
112
252
n, m = list(map(int, input().split())) for i in range(n, 10**8): if m % i == 0: print((m // i)) exit() print((1))
n, m = list(map(int, input().split())) yakusuu = [] import math for i in range(1, int(math.sqrt(m) + 1)): if m % i == 0: yakusuu.append(i) yakusuu.append(m // i) yakusuu.sort() for num in yakusuu: if num >= n: print((m // num)) exit()
false
46.666667
[ "-for i in range(n, 10**8):", "+yakusuu = []", "+import math", "+", "+for i in range(1, int(math.sqrt(m) + 1)):", "- print((m // i))", "+ yakusuu.append(i)", "+ yakusuu.append(m // i)", "+yakusuu.sort()", "+for num in yakusuu:", "+ if num >= n:", "+ print((m // num))", "-print((1))" ]
false
0.050612
0.039416
1.28406
[ "s700486205", "s236678083" ]
u304630225
p03610
python
s845564917
s427985903
21
17
4,268
3,192
Accepted
Accepted
19.05
A=list(eval(input())) print(("".join(A[::2])))
print((input()[::2]))
2
1
39
19
A = list(eval(input())) print(("".join(A[::2])))
print((input()[::2]))
false
50
[ "-A = list(eval(input()))", "-print((\"\".join(A[::2])))", "+print((input()[::2]))" ]
false
0.044816
0.045064
0.994511
[ "s845564917", "s427985903" ]
u273345915
p02681
python
s339757803
s587951567
60
20
61,832
8,920
Accepted
Accepted
66.67
def main(): S=eval(input()) T=eval(input()) if S==T[:len(S)]: print('Yes') else: print('No') return if __name__=='__main__': main()
def main(): S=eval(input()) T=eval(input()) if S==T[:-1]: print('Yes') else: print('No') return if __name__=='__main__': main()
9
9
152
148
def main(): S = eval(input()) T = eval(input()) if S == T[: len(S)]: print("Yes") else: print("No") return if __name__ == "__main__": main()
def main(): S = eval(input()) T = eval(input()) if S == T[:-1]: print("Yes") else: print("No") return if __name__ == "__main__": main()
false
0
[ "- if S == T[: len(S)]:", "+ if S == T[:-1]:" ]
false
0.064567
0.035889
1.799051
[ "s339757803", "s587951567" ]
u127499732
p03317
python
s659522774
s941755551
40
18
13,940
2,940
Accepted
Accepted
55
def main(): n, k, *a = list(map(int, open(0).read().split())) ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0) print(ans) if __name__ == '__main__': main()
def main(): n, k = list(map(int, input().split())) ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0) print(ans) if __name__ == '__main__': main()
8
8
182
171
def main(): n, k, *a = list(map(int, open(0).read().split())) ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0) print(ans) if __name__ == "__main__": main()
def main(): n, k = list(map(int, input().split())) ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0) print(ans) if __name__ == "__main__": main()
false
0
[ "- n, k, *a = list(map(int, open(0).read().split()))", "+ n, k = list(map(int, input().split()))" ]
false
0.047727
0.088823
0.537324
[ "s659522774", "s941755551" ]
u935558307
p03651
python
s439364888
s894757662
231
92
62,576
86,360
Accepted
Accepted
60.17
""" KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。 """ import sys sys.setrecursionlimit(200000) N,K = list(map(int,input().split())) A = list(map(int,input().split())) def gcd(a,b): return a if b==0 else gcd(b,a%b) if N ==1: g = A[0] else: g = gcd(A[0],A[1]) for i in range(2,N): g = gcd(g,A[2]) if K<=max(A) and K%g == 0: print("POSSIBLE") else: print("IMPOSSIBLE")
import sys sys.setrecursionlimit(200000) N,K = list(map(int,input().split())) A = list(map(int,input().split())) def gcd(a,b): return a if b==0 else gcd(b,a%b) g = A[0] for i in range(1,N): g = gcd(g,A[i]) if K > max(A): print("IMPOSSIBLE") exit() if K % g == 0: print("POSSIBLE") else: print("IMPOSSIBLE")
21
16
402
339
""" KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。 """ import sys sys.setrecursionlimit(200000) N, K = list(map(int, input().split())) A = list(map(int, input().split())) def gcd(a, b): return a if b == 0 else gcd(b, a % b) if N == 1: g = A[0] else: g = gcd(A[0], A[1]) for i in range(2, N): g = gcd(g, A[2]) if K <= max(A) and K % g == 0: print("POSSIBLE") else: print("IMPOSSIBLE")
import sys sys.setrecursionlimit(200000) N, K = list(map(int, input().split())) A = list(map(int, input().split())) def gcd(a, b): return a if b == 0 else gcd(b, a % b) g = A[0] for i in range(1, N): g = gcd(g, A[i]) if K > max(A): print("IMPOSSIBLE") exit() if K % g == 0: print("POSSIBLE") else: print("IMPOSSIBLE")
false
23.809524
[ "-\"\"\"", "-KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。", "-\"\"\"", "-if N == 1:", "- g = A[0]", "-else:", "- g = gcd(A[0], A[1])", "- for i in range(2, N):", "- g = gcd(g, A[2])", "-if K <= max(A) and K % g == 0:", "+g = A[0]", "+for i in range(1, N):", "+ g = gcd(g, A[i])", "+if K > max(A):", "+ print(\"IMPOSSIBLE\")", "+ exit()", "+if K % g == 0:" ]
false
0.047521
0.04681
1.01519
[ "s439364888", "s894757662" ]
u380524497
p03108
python
s223206952
s679345825
797
385
47,584
36,024
Accepted
Accepted
51.69
import sys sys.setrecursionlimit(10**6) class UnionFind: def __init__(self, num): self.parent = list(range(num)) self.size = [1] * num def get_root(self, node): root = self.parent[node] if root == node: return root else: root = self.get_root(root) self.parent[node] = root return root def are_in_same_union(self, node1, node2): root1 = self.get_root(node1) root2 = self.get_root(node2) if root1 == root2: return True else: return False def combine(self, node1, node2): root1 = self.get_root(node1) root2 = self.get_root(node2) self.parent[root2] = root1 self.size[root1] += self.size[root2] n, m = list(map(int, input().split())) pairs = [list(map(int, input().split())) for _ in range(m)] pairs = pairs[::-1] answers = [] UF = UnionFind(n+1) ans = n*(n-1)//2 answers.append(ans) for land1, land2 in pairs: if UF.are_in_same_union(land1, land2): ans = ans else: root1, root2 = UF.get_root(land1), UF.get_root(land2) ans -= UF.size[root1] * UF.size[root2] UF.combine(land1, land2) answers.append(ans) answers.pop() answers = answers[::-1] for x in answers: print(x)
import sys input = sys.stdin.readline class UnionFind: def __init__(self, size): self.parent = [-1] * size self.rank = [1] * size self.groups = size def get_root(self, node): parent = self.parent[node] if parent == -1: root = node else: root = self.get_root(parent) self.parent[node] = root # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく return root def in_same_group(self, node1, node2): root1 = self.get_root(node1) root2 = self.get_root(node2) return root1 == root2 def unite(self, node1, node2): if self.in_same_group(node1, node2): return main_root = self.get_root(node1) sub_root = self.get_root(node2) if self.rank[main_root] < self.rank[sub_root]: # rankの大きい方をmain_rootにする main_root, sub_root = sub_root, main_root self.parent[sub_root] = main_root self.rank[main_root] += self.rank[sub_root] self.groups -= 1 def main(): n, m = map(int, input().split()) bridges = [list(map(int, input().split())) for _ in range(m)] uf = UnionFind(n) inconvenience = n * (n-1) // 2 ans = [inconvenience] for a, b in bridges[::-1]: if uf.in_same_group(a-1, b-1): ans.append(inconvenience) continue root1 = uf.get_root(a-1) root2 = uf.get_root(b-1) pattern = uf.rank[root1] * uf.rank[root2] inconvenience -= pattern ans.append(inconvenience) uf.unite(root1, root2) ans.pop() print(*ans[::-1], sep="\n") if __name__ == "__main__": main()
56
60
1,365
1,727
import sys sys.setrecursionlimit(10**6) class UnionFind: def __init__(self, num): self.parent = list(range(num)) self.size = [1] * num def get_root(self, node): root = self.parent[node] if root == node: return root else: root = self.get_root(root) self.parent[node] = root return root def are_in_same_union(self, node1, node2): root1 = self.get_root(node1) root2 = self.get_root(node2) if root1 == root2: return True else: return False def combine(self, node1, node2): root1 = self.get_root(node1) root2 = self.get_root(node2) self.parent[root2] = root1 self.size[root1] += self.size[root2] n, m = list(map(int, input().split())) pairs = [list(map(int, input().split())) for _ in range(m)] pairs = pairs[::-1] answers = [] UF = UnionFind(n + 1) ans = n * (n - 1) // 2 answers.append(ans) for land1, land2 in pairs: if UF.are_in_same_union(land1, land2): ans = ans else: root1, root2 = UF.get_root(land1), UF.get_root(land2) ans -= UF.size[root1] * UF.size[root2] UF.combine(land1, land2) answers.append(ans) answers.pop() answers = answers[::-1] for x in answers: print(x)
import sys input = sys.stdin.readline class UnionFind: def __init__(self, size): self.parent = [-1] * size self.rank = [1] * size self.groups = size def get_root(self, node): parent = self.parent[node] if parent == -1: root = node else: root = self.get_root(parent) self.parent[node] = root # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく return root def in_same_group(self, node1, node2): root1 = self.get_root(node1) root2 = self.get_root(node2) return root1 == root2 def unite(self, node1, node2): if self.in_same_group(node1, node2): return main_root = self.get_root(node1) sub_root = self.get_root(node2) if self.rank[main_root] < self.rank[sub_root]: # rankの大きい方をmain_rootにする main_root, sub_root = sub_root, main_root self.parent[sub_root] = main_root self.rank[main_root] += self.rank[sub_root] self.groups -= 1 def main(): n, m = map(int, input().split()) bridges = [list(map(int, input().split())) for _ in range(m)] uf = UnionFind(n) inconvenience = n * (n - 1) // 2 ans = [inconvenience] for a, b in bridges[::-1]: if uf.in_same_group(a - 1, b - 1): ans.append(inconvenience) continue root1 = uf.get_root(a - 1) root2 = uf.get_root(b - 1) pattern = uf.rank[root1] * uf.rank[root2] inconvenience -= pattern ans.append(inconvenience) uf.unite(root1, root2) ans.pop() print(*ans[::-1], sep="\n") if __name__ == "__main__": main()
false
6.666667
[ "-sys.setrecursionlimit(10**6)", "+input = sys.stdin.readline", "- def __init__(self, num):", "- self.parent = list(range(num))", "- self.size = [1] * num", "+ def __init__(self, size):", "+ self.parent = [-1] * size", "+ self.rank = [1] * size", "+ self.groups = size", "- root = self.parent[node]", "- if root == node:", "- return root", "+ parent = self.parent[node]", "+ if parent == -1:", "+ root = node", "- root = self.get_root(root)", "- self.parent[node] = root", "- return root", "+ root = self.get_root(parent)", "+ self.parent[node] = root # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく", "+ return root", "- def are_in_same_union(self, node1, node2):", "+ def in_same_group(self, node1, node2):", "- if root1 == root2:", "- return True", "- else:", "- return False", "+ return root1 == root2", "- def combine(self, node1, node2):", "- root1 = self.get_root(node1)", "- root2 = self.get_root(node2)", "- self.parent[root2] = root1", "- self.size[root1] += self.size[root2]", "+ def unite(self, node1, node2):", "+ if self.in_same_group(node1, node2):", "+ return", "+ main_root = self.get_root(node1)", "+ sub_root = self.get_root(node2)", "+ if self.rank[main_root] < self.rank[sub_root]: # rankの大きい方をmain_rootにする", "+ main_root, sub_root = sub_root, main_root", "+ self.parent[sub_root] = main_root", "+ self.rank[main_root] += self.rank[sub_root]", "+ self.groups -= 1", "-n, m = list(map(int, input().split()))", "-pairs = [list(map(int, input().split())) for _ in range(m)]", "-pairs = pairs[::-1]", "-answers = []", "-UF = UnionFind(n + 1)", "-ans = n * (n - 1) // 2", "-answers.append(ans)", "-for land1, land2 in pairs:", "- if UF.are_in_same_union(land1, land2):", "- ans = ans", "- else:", "- root1, root2 = UF.get_root(land1), UF.get_root(land2)", "- ans -= UF.size[root1] * UF.size[root2]", "- UF.combine(land1, land2)", "- answers.append(ans)", "-answers.pop()", "-answers = answers[::-1]", "-for x in answers:", "- print(x)", "+def main():", "+ n, m = map(int, input().split())", "+ bridges = [list(map(int, input().split())) for _ in range(m)]", "+ uf = UnionFind(n)", "+ inconvenience = n * (n - 1) // 2", "+ ans = [inconvenience]", "+ for a, b in bridges[::-1]:", "+ if uf.in_same_group(a - 1, b - 1):", "+ ans.append(inconvenience)", "+ continue", "+ root1 = uf.get_root(a - 1)", "+ root2 = uf.get_root(b - 1)", "+ pattern = uf.rank[root1] * uf.rank[root2]", "+ inconvenience -= pattern", "+ ans.append(inconvenience)", "+ uf.unite(root1, root2)", "+ ans.pop()", "+ print(*ans[::-1], sep=\"\\n\")", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.040974
0.037857
1.082349
[ "s223206952", "s679345825" ]
u010072501
p02657
python
s513086117
s226529871
31
26
9,104
9,064
Accepted
Accepted
16.13
# 169A # A × B を求めてください # 1.入力を受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2.受け取った入力値を使って計算 answer = a * b # atcoder でよく見る変数 # 3.計算した結果を出力 print(answer)
# A - Multiplication 1 # A × B を求める # A B の入力 a, b = list(map(int, input().split())) # print(a) # print(b) # A × B の計算 answer = a * b # 結果の表示 print(answer)
13
13
183
165
# 169A # A × B を求めてください # 1.入力を受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2.受け取った入力値を使って計算 answer = a * b # atcoder でよく見る変数 # 3.計算した結果を出力 print(answer)
# A - Multiplication 1 # A × B を求める # A B の入力 a, b = list(map(int, input().split())) # print(a) # print(b) # A × B の計算 answer = a * b # 結果の表示 print(answer)
false
0
[ "-# 169A", "-# A × B を求めてください", "-# 1.入力を受け取ること", "+# A - Multiplication 1", "+# A × B を求める", "+# A B の入力", "-# print(a, b)", "-# 2.受け取った入力値を使って計算", "-answer = a * b # atcoder でよく見る変数", "-# 3.計算した結果を出力", "+# print(a)", "+# print(b)", "+# A × B の計算", "+answer = a * b", "+# 結果の表示" ]
false
0.037229
0.035863
1.038105
[ "s513086117", "s226529871" ]
u759412327
p03212
python
s480008346
s257460726
629
54
9,180
12,412
Accepted
Accepted
91.41
from itertools import * N = int(eval(input())) ans = 0 for i in product("0357",repeat=10): j = "".join(i) if "0" not in str(int(j)) and "3" in j and "5" in j and "7" in j and int(j)<=N: ans+=1 print(ans)
from itertools import * N = int(eval(input())) S = [] ans = 0 for n in range(10): S+=list(product("357",repeat=n)) for s in S: if len(set(s))==3 and int("".join(s))<=N: ans+=1 print(ans)
10
13
216
203
from itertools import * N = int(eval(input())) ans = 0 for i in product("0357", repeat=10): j = "".join(i) if "0" not in str(int(j)) and "3" in j and "5" in j and "7" in j and int(j) <= N: ans += 1 print(ans)
from itertools import * N = int(eval(input())) S = [] ans = 0 for n in range(10): S += list(product("357", repeat=n)) for s in S: if len(set(s)) == 3 and int("".join(s)) <= N: ans += 1 print(ans)
false
23.076923
[ "+S = []", "-for i in product(\"0357\", repeat=10):", "- j = \"\".join(i)", "- if \"0\" not in str(int(j)) and \"3\" in j and \"5\" in j and \"7\" in j and int(j) <= N:", "+for n in range(10):", "+ S += list(product(\"357\", repeat=n))", "+for s in S:", "+ if len(set(s)) == 3 and int(\"\".join(s)) <= N:" ]
false
1.629201
0.066747
24.40874
[ "s480008346", "s257460726" ]
u814986259
p03435
python
s882998820
s460526369
19
17
3,192
3,064
Accepted
Accepted
10.53
c = [[]]*3 for i in range(3): c[i] = list(map(int, input().split())) ans = 0 for i in range(3): ans += sum(c[i]) if ans % 3 == 0: arr = [[0]* 6]*3 for i in range(3): arr[i][0] = c[i][0] - c[i][1] arr[i][1] = c[i][0] - c[i][2] arr[i][2] = c[i][1] - c[i][0] arr[i][3] = c[i][1] - c[i][2] arr[i][4] = c[i][2] - c[i][0] arr[i][5] = c[i][2] - c[i][1] for i in range(6): if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]: continue else: print("No") exit(0) for i in range(3): arr[i][0] = c[0][i] - c[1][i] arr[i][1] = c[0][i] - c[2][i] arr[i][2] = c[1][i] - c[0][i] arr[i][3] = c[1][i] - c[2][i] arr[i][4] = c[2][i] - c[1][i] arr[i][5] = c[2][i] - c[0][i] for i in range(6): if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]: continue else: print("No") exit(0) arr = [0]*3 sum = 0 for i in range(3): arr[0] += c[i][i] for i in range(3): if i + 1 < 3: arr[1] += c[i][i+1] else: arr[1] += c[i][0] for i in range(3): if i + 2 < 3: arr[2] += c[i][i+2] else: arr[2] += c[i][i-1] if arr[0] != arr[1] or arr[0] != arr[2]: print("No") exit(0) print("Yes") exit(0) print("No")
c = [[]]*3 for i in range(3): c[i] = list(map(int, input().split())) ans = 0 for i in range(3): ans += sum(c[i]) if ans % 3 == 0: arr = [0]*3 sum = 0 for i in range(3): arr[0] += c[i][i] for i in range(3): if i + 1 < 3: arr[1] += c[i][i+1] else: arr[1] += c[i][0] for i in range(3): if i + 2 < 3: arr[2] += c[i][i+2] else: arr[2] += c[i][i-1] if arr[0] != arr[1] or arr[0] != arr[2]: print("No") exit(0) print("Yes") exit(0) print("No")
63
34
1,516
628
c = [[]] * 3 for i in range(3): c[i] = list(map(int, input().split())) ans = 0 for i in range(3): ans += sum(c[i]) if ans % 3 == 0: arr = [[0] * 6] * 3 for i in range(3): arr[i][0] = c[i][0] - c[i][1] arr[i][1] = c[i][0] - c[i][2] arr[i][2] = c[i][1] - c[i][0] arr[i][3] = c[i][1] - c[i][2] arr[i][4] = c[i][2] - c[i][0] arr[i][5] = c[i][2] - c[i][1] for i in range(6): if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]: continue else: print("No") exit(0) for i in range(3): arr[i][0] = c[0][i] - c[1][i] arr[i][1] = c[0][i] - c[2][i] arr[i][2] = c[1][i] - c[0][i] arr[i][3] = c[1][i] - c[2][i] arr[i][4] = c[2][i] - c[1][i] arr[i][5] = c[2][i] - c[0][i] for i in range(6): if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]: continue else: print("No") exit(0) arr = [0] * 3 sum = 0 for i in range(3): arr[0] += c[i][i] for i in range(3): if i + 1 < 3: arr[1] += c[i][i + 1] else: arr[1] += c[i][0] for i in range(3): if i + 2 < 3: arr[2] += c[i][i + 2] else: arr[2] += c[i][i - 1] if arr[0] != arr[1] or arr[0] != arr[2]: print("No") exit(0) print("Yes") exit(0) print("No")
c = [[]] * 3 for i in range(3): c[i] = list(map(int, input().split())) ans = 0 for i in range(3): ans += sum(c[i]) if ans % 3 == 0: arr = [0] * 3 sum = 0 for i in range(3): arr[0] += c[i][i] for i in range(3): if i + 1 < 3: arr[1] += c[i][i + 1] else: arr[1] += c[i][0] for i in range(3): if i + 2 < 3: arr[2] += c[i][i + 2] else: arr[2] += c[i][i - 1] if arr[0] != arr[1] or arr[0] != arr[2]: print("No") exit(0) print("Yes") exit(0) print("No")
false
46.031746
[ "- arr = [[0] * 6] * 3", "- for i in range(3):", "- arr[i][0] = c[i][0] - c[i][1]", "- arr[i][1] = c[i][0] - c[i][2]", "- arr[i][2] = c[i][1] - c[i][0]", "- arr[i][3] = c[i][1] - c[i][2]", "- arr[i][4] = c[i][2] - c[i][0]", "- arr[i][5] = c[i][2] - c[i][1]", "- for i in range(6):", "- if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:", "- continue", "- else:", "- print(\"No\")", "- exit(0)", "- for i in range(3):", "- arr[i][0] = c[0][i] - c[1][i]", "- arr[i][1] = c[0][i] - c[2][i]", "- arr[i][2] = c[1][i] - c[0][i]", "- arr[i][3] = c[1][i] - c[2][i]", "- arr[i][4] = c[2][i] - c[1][i]", "- arr[i][5] = c[2][i] - c[0][i]", "- for i in range(6):", "- if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:", "- continue", "- else:", "- print(\"No\")", "- exit(0)" ]
false
0.069772
0.064406
1.083318
[ "s882998820", "s460526369" ]
u853185302
p03212
python
s218335805
s361349960
109
62
3,064
6,260
Accepted
Accepted
43.12
import itertools def calc_num(S,S_len): result = 0; l = [3,5,7]; i = 3; while i <= S_len: for v in itertools.product(l,repeat=i): if int("".join(map(str,v))) <= S and list(set(v) & set(l)) == l: result = result + 1; i = i + 1; return result S = list(map(int,eval(input()))); S_len = len(S); S = int("".join(map(str, S))); result = calc_num(S,S_len); print(result)
import itertools n = int(eval(input())) target = ["7","5","3"] c = 0 for i in range(1,len(str(n))+1): for p in list(itertools.product(target,repeat=i)): if int("".join(list(p))) <= n and len(set(p))==3: c += 1 print(c)
17
9
408
231
import itertools def calc_num(S, S_len): result = 0 l = [3, 5, 7] i = 3 while i <= S_len: for v in itertools.product(l, repeat=i): if int("".join(map(str, v))) <= S and list(set(v) & set(l)) == l: result = result + 1 i = i + 1 return result S = list(map(int, eval(input()))) S_len = len(S) S = int("".join(map(str, S))) result = calc_num(S, S_len) print(result)
import itertools n = int(eval(input())) target = ["7", "5", "3"] c = 0 for i in range(1, len(str(n)) + 1): for p in list(itertools.product(target, repeat=i)): if int("".join(list(p))) <= n and len(set(p)) == 3: c += 1 print(c)
false
47.058824
[ "-", "-def calc_num(S, S_len):", "- result = 0", "- l = [3, 5, 7]", "- i = 3", "- while i <= S_len:", "- for v in itertools.product(l, repeat=i):", "- if int(\"\".join(map(str, v))) <= S and list(set(v) & set(l)) == l:", "- result = result + 1", "- i = i + 1", "- return result", "-", "-", "-S = list(map(int, eval(input())))", "-S_len = len(S)", "-S = int(\"\".join(map(str, S)))", "-result = calc_num(S, S_len)", "-print(result)", "+n = int(eval(input()))", "+target = [\"7\", \"5\", \"3\"]", "+c = 0", "+for i in range(1, len(str(n)) + 1):", "+ for p in list(itertools.product(target, repeat=i)):", "+ if int(\"\".join(list(p))) <= n and len(set(p)) == 3:", "+ c += 1", "+print(c)" ]
false
0.033332
0.054081
0.616337
[ "s218335805", "s361349960" ]
u858748695
p02861
python
s191653949
s384452688
507
280
3,064
13,848
Accepted
Accepted
44.77
#!/usr/bin/env python3 from itertools import permutations def f(i, j): return ((x[i] - x[j])**2 + (y[i] - y[j])**2)**0.5 n = int(eval(input())) x = [None] * n y = [None] * n for i in range(n): x[i], y[i] = list(map(int, input().split())) ans = 0 for s in permutations(list(range(n))): tmp = 0 for i in range(n - 1): tmp += f(int(s[i + 1]), int(s[i])) ans += tmp for i in range(n): ans /= i + 1 print(ans)
from itertools import permutations def dfs(p, bit): res = 0 for k in range(n): if bit >> k & 1: continue d = ((x[k] - x[p]) ** 2 + (y[k] - y[p]) ** 2) ** 0.5 res += d + dfs(k, bit | (1 << k)) return res n = int(eval(input())) x = [0] * n y = [0] * n for i in range(n): x[i], y[i] = list(map(int, input().split())) ans = 0 # for i in range(n): # ans += dfs(i, 1 << i) # for i in range(n): # ans /= i + 1 for li in list(permutations(list(range(n)), n)): tmp = 0 for i in range(n - 1): p = li[i] k = li[i + 1] tmp += ((x[k] - x[p]) ** 2 + (y[k] - y[p]) ** 2) ** 0.5 ans += tmp for i in range(n): ans /= i + 1 print(ans)
22
35
444
739
#!/usr/bin/env python3 from itertools import permutations def f(i, j): return ((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** 0.5 n = int(eval(input())) x = [None] * n y = [None] * n for i in range(n): x[i], y[i] = list(map(int, input().split())) ans = 0 for s in permutations(list(range(n))): tmp = 0 for i in range(n - 1): tmp += f(int(s[i + 1]), int(s[i])) ans += tmp for i in range(n): ans /= i + 1 print(ans)
from itertools import permutations def dfs(p, bit): res = 0 for k in range(n): if bit >> k & 1: continue d = ((x[k] - x[p]) ** 2 + (y[k] - y[p]) ** 2) ** 0.5 res += d + dfs(k, bit | (1 << k)) return res n = int(eval(input())) x = [0] * n y = [0] * n for i in range(n): x[i], y[i] = list(map(int, input().split())) ans = 0 # for i in range(n): # ans += dfs(i, 1 << i) # for i in range(n): # ans /= i + 1 for li in list(permutations(list(range(n)), n)): tmp = 0 for i in range(n - 1): p = li[i] k = li[i + 1] tmp += ((x[k] - x[p]) ** 2 + (y[k] - y[p]) ** 2) ** 0.5 ans += tmp for i in range(n): ans /= i + 1 print(ans)
false
37.142857
[ "-#!/usr/bin/env python3", "-def f(i, j):", "- return ((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** 0.5", "+def dfs(p, bit):", "+ res = 0", "+ for k in range(n):", "+ if bit >> k & 1:", "+ continue", "+ d = ((x[k] - x[p]) ** 2 + (y[k] - y[p]) ** 2) ** 0.5", "+ res += d + dfs(k, bit | (1 << k))", "+ return res", "-x = [None] * n", "-y = [None] * n", "+x = [0] * n", "+y = [0] * n", "-for s in permutations(list(range(n))):", "+# for i in range(n):", "+# ans += dfs(i, 1 << i)", "+# for i in range(n):", "+# ans /= i + 1", "+for li in list(permutations(list(range(n)), n)):", "- tmp += f(int(s[i + 1]), int(s[i]))", "+ p = li[i]", "+ k = li[i + 1]", "+ tmp += ((x[k] - x[p]) ** 2 + (y[k] - y[p]) ** 2) ** 0.5" ]
false
0.084286
0.041423
2.034755
[ "s191653949", "s384452688" ]
u586662847
p02678
python
s412226451
s309637510
784
633
78,892
85,436
Accepted
Accepted
19.26
n, m = list(map(int, input().split())) ab = [list(map(int, input().split()))for i in range(m)] ans = [0] * n edge = [[]for _ in range(n)] for a, b in ab: edge[a - 1].append(b - 1) edge[b - 1].append(a - 1) visited = {0} stack = [0] for i in stack: for j in edge[i]: if j in visited: continue stack.append(j) visited.add(j) ans[j] = i + 1 print("Yes") print((*ans[1:]))
def resolve(): n, m = list(map(int, input().split())) ab = [list(map(int, input().split()))for i in range(m)] ans = [0] * n edge = [[]for _ in range(n)] for a, b in ab: edge[a - 1].append(b - 1) edge[b - 1].append(a - 1) visited = {0} stack = [0] for i in stack: for j in edge[i]: if j in visited: continue stack.append(j) visited.add(j) ans[j] = i + 1 print("Yes") print(('\n'.join(map(str, ans[1:])))) resolve()
18
22
434
556
n, m = list(map(int, input().split())) ab = [list(map(int, input().split())) for i in range(m)] ans = [0] * n edge = [[] for _ in range(n)] for a, b in ab: edge[a - 1].append(b - 1) edge[b - 1].append(a - 1) visited = {0} stack = [0] for i in stack: for j in edge[i]: if j in visited: continue stack.append(j) visited.add(j) ans[j] = i + 1 print("Yes") print((*ans[1:]))
def resolve(): n, m = list(map(int, input().split())) ab = [list(map(int, input().split())) for i in range(m)] ans = [0] * n edge = [[] for _ in range(n)] for a, b in ab: edge[a - 1].append(b - 1) edge[b - 1].append(a - 1) visited = {0} stack = [0] for i in stack: for j in edge[i]: if j in visited: continue stack.append(j) visited.add(j) ans[j] = i + 1 print("Yes") print(("\n".join(map(str, ans[1:])))) resolve()
false
18.181818
[ "-n, m = list(map(int, input().split()))", "-ab = [list(map(int, input().split())) for i in range(m)]", "-ans = [0] * n", "-edge = [[] for _ in range(n)]", "-for a, b in ab:", "- edge[a - 1].append(b - 1)", "- edge[b - 1].append(a - 1)", "-visited = {0}", "-stack = [0]", "-for i in stack:", "- for j in edge[i]:", "- if j in visited:", "- continue", "- stack.append(j)", "- visited.add(j)", "- ans[j] = i + 1", "-print(\"Yes\")", "-print((*ans[1:]))", "+def resolve():", "+ n, m = list(map(int, input().split()))", "+ ab = [list(map(int, input().split())) for i in range(m)]", "+ ans = [0] * n", "+ edge = [[] for _ in range(n)]", "+ for a, b in ab:", "+ edge[a - 1].append(b - 1)", "+ edge[b - 1].append(a - 1)", "+ visited = {0}", "+ stack = [0]", "+ for i in stack:", "+ for j in edge[i]:", "+ if j in visited:", "+ continue", "+ stack.append(j)", "+ visited.add(j)", "+ ans[j] = i + 1", "+ print(\"Yes\")", "+ print((\"\\n\".join(map(str, ans[1:]))))", "+", "+", "+resolve()" ]
false
0.046173
0.048387
0.954241
[ "s412226451", "s309637510" ]
u601082779
p03210
python
s671868953
s687837314
19
17
2,940
2,940
Accepted
Accepted
10.53
print(("YNEOS"[eval(input())not in'357'::2]))
print(("YNEOS"[eval(input())in'124689'::2]))
1
1
37
36
print(("YNEOS"[eval(input()) not in "357" :: 2]))
print(("YNEOS"[eval(input()) in "124689" :: 2]))
false
0
[ "-print((\"YNEOS\"[eval(input()) not in \"357\" :: 2]))", "+print((\"YNEOS\"[eval(input()) in \"124689\" :: 2]))" ]
false
0.033557
0.037199
0.902103
[ "s671868953", "s687837314" ]
u535803878
p03283
python
s100704103
s288051702
2,188
553
25,764
87,004
Accepted
Accepted
74.73
import numpy as np n, m, q = [int(item) for item in input().split(" ")] # n, m, q = [int(item) for item in lines[0].split(" ")] end = np.zeros((m,2),dtype=int) query = np.zeros((q,2),dtype=int) for i in range(m): end[i] = [int(item) for item in input().split(" ")] # end[i] = [int(item) for item in lines[1+i].split(" ")] for i in range(q): query[i] = [int(item) for item in input().split(" ")] # query[i] = [int(item) for item in lines[1+m+i].split(" ")] a = np.zeros((n,n), dtype=int) np.add.at(a, [end[:,0]-1,end[:,1]-1], 1) b = np.cumsum(a[::-1,:], axis=0)[::-1,:] c = np.cumsum(b, axis=1) result = c[query[:,0]-1, query[:,1]-1] for i in range(q): print((result[i])) # for item in query: # print(c[item[0]-1, item[1]-1]) # print(np.sum(a[(item[0]-1):, :item[1]]))
# ABC105D import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m,q = list(map(int, input().split())) lr = [None] * m qs = [None] * q for i in range(m): lr[i] = tuple([int(x)-1 for x in input().split()]) t = [[0]*(n+1) for _ in range(n+1)] for x,y in lr: t[y][x] += 1 for i in range(n): for j in range(i,n): t[j][j-i] += t[j-1][j-i] + t[j][j-i+1] - t[j-1][j-i+1] ans = [None] * q for i in range(q): l, r = tuple([int(x)-1 for x in input().split()]) ans[i] = t[r][l] write("\n".join(map(str, ans)))
25
28
821
668
import numpy as np n, m, q = [int(item) for item in input().split(" ")] # n, m, q = [int(item) for item in lines[0].split(" ")] end = np.zeros((m, 2), dtype=int) query = np.zeros((q, 2), dtype=int) for i in range(m): end[i] = [int(item) for item in input().split(" ")] # end[i] = [int(item) for item in lines[1+i].split(" ")] for i in range(q): query[i] = [int(item) for item in input().split(" ")] # query[i] = [int(item) for item in lines[1+m+i].split(" ")] a = np.zeros((n, n), dtype=int) np.add.at(a, [end[:, 0] - 1, end[:, 1] - 1], 1) b = np.cumsum(a[::-1, :], axis=0)[::-1, :] c = np.cumsum(b, axis=1) result = c[query[:, 0] - 1, query[:, 1] - 1] for i in range(q): print((result[i])) # for item in query: # print(c[item[0]-1, item[1]-1]) # print(np.sum(a[(item[0]-1):, :item[1]]))
# ABC105D import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x + "\n") n, m, q = list(map(int, input().split())) lr = [None] * m qs = [None] * q for i in range(m): lr[i] = tuple([int(x) - 1 for x in input().split()]) t = [[0] * (n + 1) for _ in range(n + 1)] for x, y in lr: t[y][x] += 1 for i in range(n): for j in range(i, n): t[j][j - i] += t[j - 1][j - i] + t[j][j - i + 1] - t[j - 1][j - i + 1] ans = [None] * q for i in range(q): l, r = tuple([int(x) - 1 for x in input().split()]) ans[i] = t[r][l] write("\n".join(map(str, ans)))
false
10.714286
[ "-import numpy as np", "+# ABC105D", "+import sys", "-n, m, q = [int(item) for item in input().split(\" \")]", "-# n, m, q = [int(item) for item in lines[0].split(\" \")]", "-end = np.zeros((m, 2), dtype=int)", "-query = np.zeros((q, 2), dtype=int)", "+input = lambda: sys.stdin.readline().rstrip()", "+sys.setrecursionlimit(max(1000, 10**9))", "+write = lambda x: sys.stdout.write(x + \"\\n\")", "+n, m, q = list(map(int, input().split()))", "+lr = [None] * m", "+qs = [None] * q", "- end[i] = [int(item) for item in input().split(\" \")]", "-# end[i] = [int(item) for item in lines[1+i].split(\" \")]", "+ lr[i] = tuple([int(x) - 1 for x in input().split()])", "+t = [[0] * (n + 1) for _ in range(n + 1)]", "+for x, y in lr:", "+ t[y][x] += 1", "+for i in range(n):", "+ for j in range(i, n):", "+ t[j][j - i] += t[j - 1][j - i] + t[j][j - i + 1] - t[j - 1][j - i + 1]", "+ans = [None] * q", "- query[i] = [int(item) for item in input().split(\" \")]", "-# query[i] = [int(item) for item in lines[1+m+i].split(\" \")]", "-a = np.zeros((n, n), dtype=int)", "-np.add.at(a, [end[:, 0] - 1, end[:, 1] - 1], 1)", "-b = np.cumsum(a[::-1, :], axis=0)[::-1, :]", "-c = np.cumsum(b, axis=1)", "-result = c[query[:, 0] - 1, query[:, 1] - 1]", "-for i in range(q):", "- print((result[i]))", "-# for item in query:", "-# print(c[item[0]-1, item[1]-1])", "-# print(np.sum(a[(item[0]-1):, :item[1]]))", "+ l, r = tuple([int(x) - 1 for x in input().split()])", "+ ans[i] = t[r][l]", "+write(\"\\n\".join(map(str, ans)))" ]
false
0.92401
0.042106
21.944702
[ "s100704103", "s288051702" ]
u133936772
p02691
python
s584271007
s025835393
267
203
62,540
41,072
Accepted
Accepted
23.97
n,*l=list(map(int,open(0).read().split())) from collections import* d=defaultdict(int) a=0 for i in range(n): d[i+l[i]]+=1; a+=d[i-l[i]]*(i>l[i]) print(a)
n,*l=list(map(int,open(0).read().split()));d,a={},0 for i in range(n):d[i+l[i]]=d.get(i+l[i],0)+1;a+=d.get(i-l[i],0) print(a)
6
3
153
121
n, *l = list(map(int, open(0).read().split())) from collections import * d = defaultdict(int) a = 0 for i in range(n): d[i + l[i]] += 1 a += d[i - l[i]] * (i > l[i]) print(a)
n, *l = list(map(int, open(0).read().split())) d, a = {}, 0 for i in range(n): d[i + l[i]] = d.get(i + l[i], 0) + 1 a += d.get(i - l[i], 0) print(a)
false
50
[ "-from collections import *", "-", "-d = defaultdict(int)", "-a = 0", "+d, a = {}, 0", "- d[i + l[i]] += 1", "- a += d[i - l[i]] * (i > l[i])", "+ d[i + l[i]] = d.get(i + l[i], 0) + 1", "+ a += d.get(i - l[i], 0)" ]
false
0.036807
0.037074
0.99278
[ "s584271007", "s025835393" ]
u401452016
p02953
python
s114010045
s438740319
381
94
23,120
15,284
Accepted
Accepted
75.33
import sys import numpy as np input = sys.stdin.readline n = int(eval(input())) L = np.array(list(map(int, input().split()))) for i in range(n-1, 0, -1): if L[i]-L[i-1] ==-1: L[i-1] -=1 if np.all(L ==sorted(L)): print('Yes') else: print('No')
import sys n, hl = sys.stdin.readlines() n = int(n) hl = list(map(int, hl.split())) for i in range(n-1, 0, -1): if hl[i] - hl[i-1] ==-1: hl[i-1]-=1 if hl == sorted(hl): print('Yes') else: print('No')
15
13
273
233
import sys import numpy as np input = sys.stdin.readline n = int(eval(input())) L = np.array(list(map(int, input().split()))) for i in range(n - 1, 0, -1): if L[i] - L[i - 1] == -1: L[i - 1] -= 1 if np.all(L == sorted(L)): print("Yes") else: print("No")
import sys n, hl = sys.stdin.readlines() n = int(n) hl = list(map(int, hl.split())) for i in range(n - 1, 0, -1): if hl[i] - hl[i - 1] == -1: hl[i - 1] -= 1 if hl == sorted(hl): print("Yes") else: print("No")
false
13.333333
[ "-import numpy as np", "-input = sys.stdin.readline", "-n = int(eval(input()))", "-L = np.array(list(map(int, input().split())))", "+n, hl = sys.stdin.readlines()", "+n = int(n)", "+hl = list(map(int, hl.split()))", "- if L[i] - L[i - 1] == -1:", "- L[i - 1] -= 1", "-if np.all(L == sorted(L)):", "+ if hl[i] - hl[i - 1] == -1:", "+ hl[i - 1] -= 1", "+if hl == sorted(hl):" ]
false
0.207228
0.035068
5.909254
[ "s114010045", "s438740319" ]
u622045059
p03087
python
s397580213
s784151351
564
480
31,512
30,728
Accepted
Accepted
14.89
N,Q = list(map(int, input().split())) S = eval(input()) LR = [list([int(x)-1 for x in input().split()]) for _ in range(Q)] L = [0 for _ in range(N)] R = [0 for _ in range(N)] for i in range(1,N): if S[i-1:i+1] == 'AC': if i == 0: L[i] = 1 else: L[i] = L[i-1] + 1 else: if i > 0: L[i] = L[i-1] for i in range(Q): Li = LR[i][0] Ri = LR[i][1] print((L[Ri] - L[Li]))
N,Q = list(map(int, input().split())) S = eval(input()) lr = [list(map(int, input().split())) for _ in range(Q)] c = [0] * (N+1) for i in range(0, N): if i+1 < N and S[i] == 'A' and S[i+1] == 'C': c[i+1] = c[i] + 1 else: c[i+1] = c[i] for i in range(Q): print((c[lr[i][1]-1] - c[lr[i][0]-1]))
25
14
466
323
N, Q = list(map(int, input().split())) S = eval(input()) LR = [list([int(x) - 1 for x in input().split()]) for _ in range(Q)] L = [0 for _ in range(N)] R = [0 for _ in range(N)] for i in range(1, N): if S[i - 1 : i + 1] == "AC": if i == 0: L[i] = 1 else: L[i] = L[i - 1] + 1 else: if i > 0: L[i] = L[i - 1] for i in range(Q): Li = LR[i][0] Ri = LR[i][1] print((L[Ri] - L[Li]))
N, Q = list(map(int, input().split())) S = eval(input()) lr = [list(map(int, input().split())) for _ in range(Q)] c = [0] * (N + 1) for i in range(0, N): if i + 1 < N and S[i] == "A" and S[i + 1] == "C": c[i + 1] = c[i] + 1 else: c[i + 1] = c[i] for i in range(Q): print((c[lr[i][1] - 1] - c[lr[i][0] - 1]))
false
44
[ "-LR = [list([int(x) - 1 for x in input().split()]) for _ in range(Q)]", "-L = [0 for _ in range(N)]", "-R = [0 for _ in range(N)]", "-for i in range(1, N):", "- if S[i - 1 : i + 1] == \"AC\":", "- if i == 0:", "- L[i] = 1", "- else:", "- L[i] = L[i - 1] + 1", "+lr = [list(map(int, input().split())) for _ in range(Q)]", "+c = [0] * (N + 1)", "+for i in range(0, N):", "+ if i + 1 < N and S[i] == \"A\" and S[i + 1] == \"C\":", "+ c[i + 1] = c[i] + 1", "- if i > 0:", "- L[i] = L[i - 1]", "+ c[i + 1] = c[i]", "- Li = LR[i][0]", "- Ri = LR[i][1]", "- print((L[Ri] - L[Li]))", "+ print((c[lr[i][1] - 1] - c[lr[i][0] - 1]))" ]
false
0.070675
0.069333
1.019353
[ "s397580213", "s784151351" ]
u125505541
p03286
python
s294187512
s558297973
559
471
5,916
5,948
Accepted
Accepted
15.74
import bisect n = int(eval(input())) ps = [0] * (1 << 16) for i in range(1 << 16): temp = 0 for j in range(16): if (i >> j) & 1: temp += (-2) ** (2 *j) ps[i] = temp pattern1 = None pattern2 = None for i in range(1 << 16): temp2 = 0 for j in range(16): if (i >> j) & 1: temp2 += (-2) ** (2 *j + 1) n2 = n - temp2 pattern1 = bisect.bisect_left(ps, n2) if pattern1 != (1 << 16) and ps[pattern1] == n2: pattern2 = bin(i)[2:].zfill(16) pattern1 = bin(pattern1)[2:].zfill(16) break ans = "" for i in range(16): ans += pattern2[i] ans += pattern1[i] true_ans = "" flag = False for i in range(len(ans)): if ans[i]=="1": true_ans += "1" flag = True elif flag: true_ans += "0" if true_ans == "": true_ans = "0" print(true_ans)
import bisect n = int(eval(input())) ps = [0] * (1 << 16) for i in range(1 << 16): temp = 0 x = 1 for j in range(16): if (i >> j) & 1: # temp += (-2) ** (2 *j) temp += x x *= 4 ps[i] = temp pattern1 = None pattern2 = None for i in range(1 << 16): temp2 = 0 x = -2 for j in range(16): if (i >> j) & 1: # temp2 += (-2) ** (2 *j + 1) temp2 += x x *= 4 n2 = n - temp2 pattern1 = bisect.bisect_left(ps, n2) if pattern1 != (1 << 16) and ps[pattern1] == n2: pattern2 = bin(i)[2:].zfill(16) pattern1 = bin(pattern1)[2:].zfill(16) break ans = "" for i in range(16): ans += pattern2[i] ans += pattern1[i] true_ans = "" flag = False for i in range(len(ans)): if ans[i]=="1": true_ans += "1" flag = True elif flag: true_ans += "0" if true_ans == "": true_ans = "0" print(true_ans)
43
49
918
1,026
import bisect n = int(eval(input())) ps = [0] * (1 << 16) for i in range(1 << 16): temp = 0 for j in range(16): if (i >> j) & 1: temp += (-2) ** (2 * j) ps[i] = temp pattern1 = None pattern2 = None for i in range(1 << 16): temp2 = 0 for j in range(16): if (i >> j) & 1: temp2 += (-2) ** (2 * j + 1) n2 = n - temp2 pattern1 = bisect.bisect_left(ps, n2) if pattern1 != (1 << 16) and ps[pattern1] == n2: pattern2 = bin(i)[2:].zfill(16) pattern1 = bin(pattern1)[2:].zfill(16) break ans = "" for i in range(16): ans += pattern2[i] ans += pattern1[i] true_ans = "" flag = False for i in range(len(ans)): if ans[i] == "1": true_ans += "1" flag = True elif flag: true_ans += "0" if true_ans == "": true_ans = "0" print(true_ans)
import bisect n = int(eval(input())) ps = [0] * (1 << 16) for i in range(1 << 16): temp = 0 x = 1 for j in range(16): if (i >> j) & 1: # temp += (-2) ** (2 *j) temp += x x *= 4 ps[i] = temp pattern1 = None pattern2 = None for i in range(1 << 16): temp2 = 0 x = -2 for j in range(16): if (i >> j) & 1: # temp2 += (-2) ** (2 *j + 1) temp2 += x x *= 4 n2 = n - temp2 pattern1 = bisect.bisect_left(ps, n2) if pattern1 != (1 << 16) and ps[pattern1] == n2: pattern2 = bin(i)[2:].zfill(16) pattern1 = bin(pattern1)[2:].zfill(16) break ans = "" for i in range(16): ans += pattern2[i] ans += pattern1[i] true_ans = "" flag = False for i in range(len(ans)): if ans[i] == "1": true_ans += "1" flag = True elif flag: true_ans += "0" if true_ans == "": true_ans = "0" print(true_ans)
false
12.244898
[ "+ x = 1", "- temp += (-2) ** (2 * j)", "+ # temp += (-2) ** (2 *j)", "+ temp += x", "+ x *= 4", "+ x = -2", "- temp2 += (-2) ** (2 * j + 1)", "+ # temp2 += (-2) ** (2 *j + 1)", "+ temp2 += x", "+ x *= 4" ]
false
0.965742
0.689737
1.40016
[ "s294187512", "s558297973" ]
u103341055
p03448
python
s161304365
s892406364
55
31
9,128
9,172
Accepted
Accepted
43.64
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 # これだとダメ # for a in range(A+1): # x = X - a*500 # for b in range(B+1): # x -= b*100 # for c in range(C+1): # x -= c*50 # print(a,b,c,x) # if x == 0: # ans += 1 for a in range(A+1): for b in range(B+1): for c in range(C+1): if 500*a+100*b+50*c == X: ans += 1 print(ans)
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 # これだとダメ # for a in range(A+1): # x = X - a*500 # for b in range(B+1): # x -= b*100 # for c in range(C+1): # x -= c*50 # print(a,b,c,x) # if x == 0: # ans += 1 # これはOK # for a in range(A+1): # for b in range(B+1): # for c in range(C+1): # if 500*a+100*b+50*c == X: # ans += 1 # こう書くとfor文一回省ける for a in range(A+1): for b in range(B+1): x = X - 500*a -100*b if x%50 == 0 and x >=0: if x//50 <= C: ans += 1 print(ans) #
26
39
490
704
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 #  これだとダメ # for a in range(A+1): # x = X - a*500 # for b in range(B+1): # x -= b*100 # for c in range(C+1): # x -= c*50 # print(a,b,c,x) # if x == 0: # ans += 1 for a in range(A + 1): for b in range(B + 1): for c in range(C + 1): if 500 * a + 100 * b + 50 * c == X: ans += 1 print(ans)
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 #  これだとダメ # for a in range(A+1): # x = X - a*500 # for b in range(B+1): # x -= b*100 # for c in range(C+1): # x -= c*50 # print(a,b,c,x) # if x == 0: # ans += 1 # これはOK # for a in range(A+1): # for b in range(B+1): # for c in range(C+1): # if 500*a+100*b+50*c == X: # ans += 1 # こう書くとfor文一回省ける for a in range(A + 1): for b in range(B + 1): x = X - 500 * a - 100 * b if x % 50 == 0 and x >= 0: if x // 50 <= C: ans += 1 print(ans) #
false
33.333333
[ "+# これはOK", "+# for a in range(A+1):", "+# for b in range(B+1):", "+# for c in range(C+1):", "+# if 500*a+100*b+50*c == X:", "+# ans += 1", "+# こう書くとfor文一回省ける", "- for c in range(C + 1):", "- if 500 * a + 100 * b + 50 * c == X:", "+ x = X - 500 * a - 100 * b", "+ if x % 50 == 0 and x >= 0:", "+ if x // 50 <= C:", "+#" ]
false
0.272814
0.083692
3.259728
[ "s161304365", "s892406364" ]
u604839890
p03805
python
s253501400
s043845834
53
46
14,008
13,868
Accepted
Accepted
13.21
import itertools n, m = list(map(int, input().split())) h = [[0]*n for _ in range(n)] for i in range(m): a, b = list(map(int, input().split())) h[a-1][b-1] = 1 h[b-1][a-1] = 1 ans = 0 x = list(itertools.permutations(list(range(1, n+1)))) for i in range(len(x)): if x[i][0] == 1: for j in range(n-1): if h[x[i][j]-1][x[i][j+1]-1] == 0: break else: ans += 1 print(ans)
import itertools n, m = list(map(int, input().split())) g = [[0]*n for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) a, b = a-1, b-1 g[a][b] = 1 g[b][a] = 1 a = list(itertools.permutations(list(range(n)))) ans = 0 for i in a: if i[0] != 0: break for j in range(n-1): if g[i[j]][i[j+1]] == 0: break else: ans += 1 print(ans)
19
21
440
418
import itertools n, m = list(map(int, input().split())) h = [[0] * n for _ in range(n)] for i in range(m): a, b = list(map(int, input().split())) h[a - 1][b - 1] = 1 h[b - 1][a - 1] = 1 ans = 0 x = list(itertools.permutations(list(range(1, n + 1)))) for i in range(len(x)): if x[i][0] == 1: for j in range(n - 1): if h[x[i][j] - 1][x[i][j + 1] - 1] == 0: break else: ans += 1 print(ans)
import itertools n, m = list(map(int, input().split())) g = [[0] * n for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 g[a][b] = 1 g[b][a] = 1 a = list(itertools.permutations(list(range(n)))) ans = 0 for i in a: if i[0] != 0: break for j in range(n - 1): if g[i[j]][i[j + 1]] == 0: break else: ans += 1 print(ans)
false
9.52381
[ "-h = [[0] * n for _ in range(n)]", "-for i in range(m):", "+g = [[0] * n for _ in range(n)]", "+for _ in range(m):", "- h[a - 1][b - 1] = 1", "- h[b - 1][a - 1] = 1", "+ a, b = a - 1, b - 1", "+ g[a][b] = 1", "+ g[b][a] = 1", "+a = list(itertools.permutations(list(range(n))))", "-x = list(itertools.permutations(list(range(1, n + 1))))", "-for i in range(len(x)):", "- if x[i][0] == 1:", "- for j in range(n - 1):", "- if h[x[i][j] - 1][x[i][j + 1] - 1] == 0:", "- break", "- else:", "- ans += 1", "+for i in a:", "+ if i[0] != 0:", "+ break", "+ for j in range(n - 1):", "+ if g[i[j]][i[j + 1]] == 0:", "+ break", "+ else:", "+ ans += 1" ]
false
0.173022
0.16794
1.03026
[ "s253501400", "s043845834" ]
u847467233
p00099
python
s884302893
s018190656
2,070
1,150
122,992
27,724
Accepted
Accepted
44.44
# AOJ 0099 Surf Smelt Fishing Contest II # Python3 2018.6.22 bal4u import heapq MAX = 1000000 SFT = 20 # 2**20 = 1048576 > MAX Q = [] # tbl[0:キー, 1:Magic] tbl = [[0 for j in range(2)] for i in range(MAX+2)] n, q = list(map(int, input().split())) for i in range(q): id, v = list(map(int, input().split())) tbl[id][0] += v tbl[id][1] += 1 heapq.heappush(Q, ((-tbl[id][0] << SFT)|id, id, tbl[id][1])) while 1: f, id, c = Q[0] # 要素の確認のみ if tbl[id][1] == c: print((id, tbl[id][0])) break heapq.heappop(Q)
# AOJ 0099 Surf Smelt Fishing Contest II # Python3 2018.6.22 bal4u import heapq MAX = 1000000 SFT = 20 # 2**20 = 1048576 > MAX Q = [] # tbl[0:キー, 1:Magic] n, q = list(map(int, input().split())) tbl = [0]*(n+1) for i in range(q): id, v = list(map(int, input().split())) tbl[id] += v heapq.heappush(Q, ((-tbl[id] << SFT)|id, id, tbl[id])) while 1: f, id, v = Q[0] # 要素の確認のみ if tbl[id] == v: print((id, v)) break heapq.heappop(Q)
22
21
544
469
# AOJ 0099 Surf Smelt Fishing Contest II # Python3 2018.6.22 bal4u import heapq MAX = 1000000 SFT = 20 # 2**20 = 1048576 > MAX Q = [] # tbl[0:キー, 1:Magic] tbl = [[0 for j in range(2)] for i in range(MAX + 2)] n, q = list(map(int, input().split())) for i in range(q): id, v = list(map(int, input().split())) tbl[id][0] += v tbl[id][1] += 1 heapq.heappush(Q, ((-tbl[id][0] << SFT) | id, id, tbl[id][1])) while 1: f, id, c = Q[0] # 要素の確認のみ if tbl[id][1] == c: print((id, tbl[id][0])) break heapq.heappop(Q)
# AOJ 0099 Surf Smelt Fishing Contest II # Python3 2018.6.22 bal4u import heapq MAX = 1000000 SFT = 20 # 2**20 = 1048576 > MAX Q = [] # tbl[0:キー, 1:Magic] n, q = list(map(int, input().split())) tbl = [0] * (n + 1) for i in range(q): id, v = list(map(int, input().split())) tbl[id] += v heapq.heappush(Q, ((-tbl[id] << SFT) | id, id, tbl[id])) while 1: f, id, v = Q[0] # 要素の確認のみ if tbl[id] == v: print((id, v)) break heapq.heappop(Q)
false
4.545455
[ "-tbl = [[0 for j in range(2)] for i in range(MAX + 2)]", "+tbl = [0] * (n + 1)", "- tbl[id][0] += v", "- tbl[id][1] += 1", "- heapq.heappush(Q, ((-tbl[id][0] << SFT) | id, id, tbl[id][1]))", "+ tbl[id] += v", "+ heapq.heappush(Q, ((-tbl[id] << SFT) | id, id, tbl[id]))", "- f, id, c = Q[0] # 要素の確認のみ", "- if tbl[id][1] == c:", "- print((id, tbl[id][0]))", "+ f, id, v = Q[0] # 要素の確認のみ", "+ if tbl[id] == v:", "+ print((id, v))" ]
false
1.45696
0.037358
39.000402
[ "s884302893", "s018190656" ]
u197300260
p03495
python
s030551009
s867051982
145
106
44,184
36,504
Accepted
Accepted
26.9
# Problem: atcoder.jp/contests/abc081/tasks/arc086_a # Python 1st Try import sys # from collections import defaultdict import collections as col # import pprint # import heapq,copy # from collections import deque def II(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def solver(ALLNUM, KIND, ball_numbers): result = 0 # prp = pprint.pprint counter_result = col.Counter(ball_numbers) ball_num_len = len(counter_result) counter_result_sorted = sorted(list(counter_result.items()), key=lambda x: x[1]) # prp(counter_result_sorted) if ball_num_len <= KIND: return 0 reduce_kind = ball_num_len - KIND # prp(reduce_kind) for _, ballCount in counter_result_sorted: result += ballCount reduce_kind = reduce_kind - 1 # prp(reduce_kind) if reduce_kind <= 0: break return result if __name__ == "__main__": N, K = MI() Ai = list(map(int, sys.stdin.readline().split())) # print(Ai) print(("{}".format(solver(N, K, Ai))))
# Problem: https://atcoder.jp/contests/abc081/tasks/arc086_a # Python 2nd Try import sys from collections import Counter # import heapq,copy # from collections import deque def II(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def solver(givenBall, selectKind, ball_num): result = 0 summary_Ball = Counter(ball_num) # print("{}".format(list(summary_Ball.values()))) sortedCount = sorted(list(summary_Ball.values())) # print(sortedCount) ballAllKind = len(sortedCount) changeNumberKind = ballAllKind - selectKind if changeNumberKind <= 0: result = 0 else: for j in range(0, changeNumberKind, +1): result += sortedCount[j] return result if __name__ == "__main__": N, K = MI() Ai = LI() print(("{}".format(solver(N, K, Ai))))
40
33
1,227
1,009
# Problem: atcoder.jp/contests/abc081/tasks/arc086_a # Python 1st Try import sys # from collections import defaultdict import collections as col # import pprint # import heapq,copy # from collections import deque def II(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def solver(ALLNUM, KIND, ball_numbers): result = 0 # prp = pprint.pprint counter_result = col.Counter(ball_numbers) ball_num_len = len(counter_result) counter_result_sorted = sorted(list(counter_result.items()), key=lambda x: x[1]) # prp(counter_result_sorted) if ball_num_len <= KIND: return 0 reduce_kind = ball_num_len - KIND # prp(reduce_kind) for _, ballCount in counter_result_sorted: result += ballCount reduce_kind = reduce_kind - 1 # prp(reduce_kind) if reduce_kind <= 0: break return result if __name__ == "__main__": N, K = MI() Ai = list(map(int, sys.stdin.readline().split())) # print(Ai) print(("{}".format(solver(N, K, Ai))))
# Problem: https://atcoder.jp/contests/abc081/tasks/arc086_a # Python 2nd Try import sys from collections import Counter # import heapq,copy # from collections import deque def II(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def solver(givenBall, selectKind, ball_num): result = 0 summary_Ball = Counter(ball_num) # print("{}".format(list(summary_Ball.values()))) sortedCount = sorted(list(summary_Ball.values())) # print(sortedCount) ballAllKind = len(sortedCount) changeNumberKind = ballAllKind - selectKind if changeNumberKind <= 0: result = 0 else: for j in range(0, changeNumberKind, +1): result += sortedCount[j] return result if __name__ == "__main__": N, K = MI() Ai = LI() print(("{}".format(solver(N, K, Ai))))
false
17.5
[ "-# Problem: atcoder.jp/contests/abc081/tasks/arc086_a", "-# Python 1st Try", "+# Problem: https://atcoder.jp/contests/abc081/tasks/arc086_a", "+# Python 2nd Try", "+from collections import Counter", "-# from collections import defaultdict", "-import collections as col", "-", "-# import pprint", "-def solver(ALLNUM, KIND, ball_numbers):", "+def solver(givenBall, selectKind, ball_num):", "- # prp = pprint.pprint", "- counter_result = col.Counter(ball_numbers)", "- ball_num_len = len(counter_result)", "- counter_result_sorted = sorted(list(counter_result.items()), key=lambda x: x[1])", "- # prp(counter_result_sorted)", "- if ball_num_len <= KIND:", "- return 0", "- reduce_kind = ball_num_len - KIND", "- # prp(reduce_kind)", "- for _, ballCount in counter_result_sorted:", "- result += ballCount", "- reduce_kind = reduce_kind - 1", "- # prp(reduce_kind)", "- if reduce_kind <= 0:", "- break", "+ summary_Ball = Counter(ball_num)", "+ # print(\"{}\".format(list(summary_Ball.values())))", "+ sortedCount = sorted(list(summary_Ball.values()))", "+ # print(sortedCount)", "+ ballAllKind = len(sortedCount)", "+ changeNumberKind = ballAllKind - selectKind", "+ if changeNumberKind <= 0:", "+ result = 0", "+ else:", "+ for j in range(0, changeNumberKind, +1):", "+ result += sortedCount[j]", "- Ai = list(map(int, sys.stdin.readline().split()))", "- # print(Ai)", "+ Ai = LI()" ]
false
0.05348
0.042039
1.272171
[ "s030551009", "s867051982" ]
u941047297
p03721
python
s739929591
s347931168
630
233
55,640
21,244
Accepted
Accepted
63.02
from collections import defaultdict def main(): n, k = list(map(int, input().split())) d = defaultdict(int) for _ in range(n): a, b = list(map(int, input().split())) d[a] += b A = sorted(list(d.items()), key = lambda x: x[0]) count = 0 for a in A: count += a[1] if count >= k: print((a[0])) exit() if __name__ == '__main__': main()
from collections import defaultdict def main(): n, k = list(map(int, input().split())) D = defaultdict(int) for _ in range(n): a, b = list(map(int, input().split())) D[a] += b for d in sorted(list(D.items()), key = lambda x: x[0]): k -= d[1] if k <= 0: print((d[0])) break if __name__ == '__main__': main()
17
15
425
378
from collections import defaultdict def main(): n, k = list(map(int, input().split())) d = defaultdict(int) for _ in range(n): a, b = list(map(int, input().split())) d[a] += b A = sorted(list(d.items()), key=lambda x: x[0]) count = 0 for a in A: count += a[1] if count >= k: print((a[0])) exit() if __name__ == "__main__": main()
from collections import defaultdict def main(): n, k = list(map(int, input().split())) D = defaultdict(int) for _ in range(n): a, b = list(map(int, input().split())) D[a] += b for d in sorted(list(D.items()), key=lambda x: x[0]): k -= d[1] if k <= 0: print((d[0])) break if __name__ == "__main__": main()
false
11.764706
[ "- d = defaultdict(int)", "+ D = defaultdict(int)", "- d[a] += b", "- A = sorted(list(d.items()), key=lambda x: x[0])", "- count = 0", "- for a in A:", "- count += a[1]", "- if count >= k:", "- print((a[0]))", "- exit()", "+ D[a] += b", "+ for d in sorted(list(D.items()), key=lambda x: x[0]):", "+ k -= d[1]", "+ if k <= 0:", "+ print((d[0]))", "+ break" ]
false
0.057075
0.080415
0.709753
[ "s739929591", "s347931168" ]
u332906195
p03137
python
s842430337
s749573021
119
102
13,960
13,968
Accepted
Accepted
14.29
# -*- coding: utf-8 -*- N, M = list(map(int, input().split())) X = list(map(int, input().split())) X.sort() if N >= M: print((0)) exit() diffX = [X[i + 1] - X[i] for i in range(len(X) - 1)] diffX.sort() ans = X[-1] - X[0] for i in range(N - 1): ans -= diffX[-(i + 1)] print(ans)
N, M = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) D = sorted([X[i + 1] - X[i] for i in range(M - 1)]) print((X[-1] - X[0] - sum(D[-(N - 1):]) if N > 1 else X[-1] - X[0]))
18
4
305
199
# -*- coding: utf-8 -*- N, M = list(map(int, input().split())) X = list(map(int, input().split())) X.sort() if N >= M: print((0)) exit() diffX = [X[i + 1] - X[i] for i in range(len(X) - 1)] diffX.sort() ans = X[-1] - X[0] for i in range(N - 1): ans -= diffX[-(i + 1)] print(ans)
N, M = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) D = sorted([X[i + 1] - X[i] for i in range(M - 1)]) print((X[-1] - X[0] - sum(D[-(N - 1) :]) if N > 1 else X[-1] - X[0]))
false
77.777778
[ "-# -*- coding: utf-8 -*-", "-X = list(map(int, input().split()))", "-X.sort()", "-if N >= M:", "- print((0))", "- exit()", "-diffX = [X[i + 1] - X[i] for i in range(len(X) - 1)]", "-diffX.sort()", "-ans = X[-1] - X[0]", "-for i in range(N - 1):", "- ans -= diffX[-(i + 1)]", "-print(ans)", "+X = sorted(list(map(int, input().split())))", "+D = sorted([X[i + 1] - X[i] for i in range(M - 1)])", "+print((X[-1] - X[0] - sum(D[-(N - 1) :]) if N > 1 else X[-1] - X[0]))" ]
false
0.037176
0.036726
1.012263
[ "s842430337", "s749573021" ]
u312025627
p03545
python
s931096950
s728204631
189
17
38,332
3,064
Accepted
Accepted
91.01
def main(): S = input() a, b, c, d = (int(i) for i in S) ans = 0 sign = [] flag = False #op == 0 : plus, op == 1: minus for op1 in range(2): for op2 in range(2): for op3 in range(2): ans = 0 sign = [] if op1 == 0: ans = a + b sign.append('+') else: ans = a - b sign.append('-') if op2 == 0: ans += c sign.append('+') else: ans -= c sign.append('-') if op3 == 0: ans += d sign.append('+') else: ans -= d sign.append('-') if ans == 7: flag = True break if flag: break if flag: break for n,op in zip(S,sign): print(n+op,end="") else: print(S[-1]+'=7') if __name__ == '__main__': main()
def main(): S = eval(input()) op = ['+', '-'] def calc(cur): ret = int(S[0]) for i in range(3): if cur[i] == "+": ret += int(S[i+1]) else: ret -= int(S[i+1]) return ret for i in range(1 << 3): cur = [] for j in range(3): if i & (1 << j): cur.append(op[0]) else: cur.append(op[1]) if calc(cur) == 7: print(("".join(S[i]+cur[i] for i in range(3)) + S[3] + "=7")) return if __name__ == '__main__': main()
45
26
1,176
626
def main(): S = input() a, b, c, d = (int(i) for i in S) ans = 0 sign = [] flag = False # op == 0 : plus, op == 1: minus for op1 in range(2): for op2 in range(2): for op3 in range(2): ans = 0 sign = [] if op1 == 0: ans = a + b sign.append("+") else: ans = a - b sign.append("-") if op2 == 0: ans += c sign.append("+") else: ans -= c sign.append("-") if op3 == 0: ans += d sign.append("+") else: ans -= d sign.append("-") if ans == 7: flag = True break if flag: break if flag: break for n, op in zip(S, sign): print(n + op, end="") else: print(S[-1] + "=7") if __name__ == "__main__": main()
def main(): S = eval(input()) op = ["+", "-"] def calc(cur): ret = int(S[0]) for i in range(3): if cur[i] == "+": ret += int(S[i + 1]) else: ret -= int(S[i + 1]) return ret for i in range(1 << 3): cur = [] for j in range(3): if i & (1 << j): cur.append(op[0]) else: cur.append(op[1]) if calc(cur) == 7: print(("".join(S[i] + cur[i] for i in range(3)) + S[3] + "=7")) return if __name__ == "__main__": main()
false
42.222222
[ "- S = input()", "- a, b, c, d = (int(i) for i in S)", "- ans = 0", "- sign = []", "- flag = False", "- # op == 0 : plus, op == 1: minus", "- for op1 in range(2):", "- for op2 in range(2):", "- for op3 in range(2):", "- ans = 0", "- sign = []", "- if op1 == 0:", "- ans = a + b", "- sign.append(\"+\")", "- else:", "- ans = a - b", "- sign.append(\"-\")", "- if op2 == 0:", "- ans += c", "- sign.append(\"+\")", "- else:", "- ans -= c", "- sign.append(\"-\")", "- if op3 == 0:", "- ans += d", "- sign.append(\"+\")", "- else:", "- ans -= d", "- sign.append(\"-\")", "- if ans == 7:", "- flag = True", "- break", "- if flag:", "- break", "- if flag:", "- break", "- for n, op in zip(S, sign):", "- print(n + op, end=\"\")", "- else:", "- print(S[-1] + \"=7\")", "+ S = eval(input())", "+ op = [\"+\", \"-\"]", "+", "+ def calc(cur):", "+ ret = int(S[0])", "+ for i in range(3):", "+ if cur[i] == \"+\":", "+ ret += int(S[i + 1])", "+ else:", "+ ret -= int(S[i + 1])", "+ return ret", "+", "+ for i in range(1 << 3):", "+ cur = []", "+ for j in range(3):", "+ if i & (1 << j):", "+ cur.append(op[0])", "+ else:", "+ cur.append(op[1])", "+ if calc(cur) == 7:", "+ print((\"\".join(S[i] + cur[i] for i in range(3)) + S[3] + \"=7\"))", "+ return" ]
false
0.052754
0.052136
1.011856
[ "s931096950", "s728204631" ]
u654470292
p02813
python
s574986672
s941676817
218
102
46,576
80,964
Accepted
Accepted
53.21
import sys import itertools def input(): return sys.stdin.readline()[:-1] n=int(eval(input())) p=list(map(int,input().split())) q=list(map(int,input().split())) li=[] for i in range(n): li.append(i+1) a=list(itertools.permutations(li)) tmp=[0,0] for i in range(len(a)): if list(a[i])==p: tmp[0]=i if list(a[i])==q: tmp[1]=i print((abs(tmp[0]-tmp[1])))
import bisect, copy, heapq, math, sys from collections import * from functools import lru_cache from itertools import accumulate, combinations, permutations, product def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0]+list(accumulate(lst)) def celi(a,b): return -(-a//b) sys.setrecursionlimit(5000000) mod=pow(10,9)+7 al=[chr(ord('a') + i) for i in range(26)] direction=[[1,0],[0,1],[-1,0],[0,-1]] n=int(eval(input())) p=list(map(int,input().split())) q=list(map(int,input().split())) for i in range(n): p[i]-=1 q[i]-=1 com=list(permutations(list(range(n)))) # print(p,q) a=0 b=0 for i in range(len(com)): # print(com[i]) if com[i]==tuple(p): a=i if com[i]==tuple(q): b=i print((abs(a-b)))
19
34
394
782
import sys import itertools def input(): return sys.stdin.readline()[:-1] n = int(eval(input())) p = list(map(int, input().split())) q = list(map(int, input().split())) li = [] for i in range(n): li.append(i + 1) a = list(itertools.permutations(li)) tmp = [0, 0] for i in range(len(a)): if list(a[i]) == p: tmp[0] = i if list(a[i]) == q: tmp[1] = i print((abs(tmp[0] - tmp[1])))
import bisect, copy, heapq, math, sys from collections import * from functools import lru_cache from itertools import accumulate, combinations, permutations, product def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0] + list(accumulate(lst)) def celi(a, b): return -(-a // b) sys.setrecursionlimit(5000000) mod = pow(10, 9) + 7 al = [chr(ord("a") + i) for i in range(26)] direction = [[1, 0], [0, 1], [-1, 0], [0, -1]] n = int(eval(input())) p = list(map(int, input().split())) q = list(map(int, input().split())) for i in range(n): p[i] -= 1 q[i] -= 1 com = list(permutations(list(range(n)))) # print(p,q) a = 0 b = 0 for i in range(len(com)): # print(com[i]) if com[i] == tuple(p): a = i if com[i] == tuple(q): b = i print((abs(a - b)))
false
44.117647
[ "-import sys", "-import itertools", "+import bisect, copy, heapq, math, sys", "+from collections import *", "+from functools import lru_cache", "+from itertools import accumulate, combinations, permutations, product", "+def ruiseki(lst):", "+ return [0] + list(accumulate(lst))", "+", "+", "+def celi(a, b):", "+ return -(-a // b)", "+", "+", "+sys.setrecursionlimit(5000000)", "+mod = pow(10, 9) + 7", "+al = [chr(ord(\"a\") + i) for i in range(26)]", "+direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]", "-li = []", "- li.append(i + 1)", "-a = list(itertools.permutations(li))", "-tmp = [0, 0]", "-for i in range(len(a)):", "- if list(a[i]) == p:", "- tmp[0] = i", "- if list(a[i]) == q:", "- tmp[1] = i", "-print((abs(tmp[0] - tmp[1])))", "+ p[i] -= 1", "+ q[i] -= 1", "+com = list(permutations(list(range(n))))", "+# print(p,q)", "+a = 0", "+b = 0", "+for i in range(len(com)):", "+ # print(com[i])", "+ if com[i] == tuple(p):", "+ a = i", "+ if com[i] == tuple(q):", "+ b = i", "+print((abs(a - b)))" ]
false
0.038606
0.038096
1.013392
[ "s574986672", "s941676817" ]
u186838327
p02837
python
s421488153
s434939341
285
137
43,484
74,216
Accepted
Accepted
51.93
n = int(eval(input())) X = [[] for _ in range(n)] for i in range(n): a = int(eval(input())) for j in range(a): x, y = list(map(int, input().split())) x = x-1 X[i].append((x, y)) ans = 0 for i in range(2**n): cnt = 0 temp = [-1]*n for j in range(n): if (i >> j) & 1: cnt += 1 temp[j] = 1 else: temp[j] = 0 flag = True for j in range(n): if (i >> j) & 1: for x, y in X[j]: if temp[x] != y: flag = False if flag: ans = max(ans, cnt) print(ans)
n = int(eval(input())) g = [[] for _ in range(n)] for i in range(n): a = int(eval(input())) for j in range(a): x, y = list(map(int, input().split())) x -= 1 g[i].append((x, y)) ans = 0 for i in range(2**n): temp = [-1]*n for j in range(n): if (i >> j) & 1: temp[j] = 1 else: temp[j] = 0 flag = True for j in range(n): if temp[j] == 1: for x, y in g[j]: if temp[x] != y: flag = False if flag: ans = max(ans, sum(temp)) print(ans)
28
28
623
597
n = int(eval(input())) X = [[] for _ in range(n)] for i in range(n): a = int(eval(input())) for j in range(a): x, y = list(map(int, input().split())) x = x - 1 X[i].append((x, y)) ans = 0 for i in range(2**n): cnt = 0 temp = [-1] * n for j in range(n): if (i >> j) & 1: cnt += 1 temp[j] = 1 else: temp[j] = 0 flag = True for j in range(n): if (i >> j) & 1: for x, y in X[j]: if temp[x] != y: flag = False if flag: ans = max(ans, cnt) print(ans)
n = int(eval(input())) g = [[] for _ in range(n)] for i in range(n): a = int(eval(input())) for j in range(a): x, y = list(map(int, input().split())) x -= 1 g[i].append((x, y)) ans = 0 for i in range(2**n): temp = [-1] * n for j in range(n): if (i >> j) & 1: temp[j] = 1 else: temp[j] = 0 flag = True for j in range(n): if temp[j] == 1: for x, y in g[j]: if temp[x] != y: flag = False if flag: ans = max(ans, sum(temp)) print(ans)
false
0
[ "-X = [[] for _ in range(n)]", "+g = [[] for _ in range(n)]", "- x = x - 1", "- X[i].append((x, y))", "+ x -= 1", "+ g[i].append((x, y))", "- cnt = 0", "- cnt += 1", "- if (i >> j) & 1:", "- for x, y in X[j]:", "+ if temp[j] == 1:", "+ for x, y in g[j]:", "- ans = max(ans, cnt)", "+ ans = max(ans, sum(temp))" ]
false
0.036844
0.036306
1.014806
[ "s421488153", "s434939341" ]
u271469978
p03137
python
s482946345
s052205963
121
111
13,968
13,968
Accepted
Accepted
8.26
n, m = list(map(int, input().split())) x = sorted(map(int, input().split())) if n >= m: print((0)) else: dif = [] for i in range(m-1): dif.append(x[i + 1] - x[i]) dif = sorted(dif) for _ in range(n-1): dif.pop() print((sum(dif)))
n, m = list(map(int, input().split())) x = sorted(map(int, input().split())) if n >= m: print((0)) else: dif = [] for i in range(m-1): dif.append(x[i + 1] - x[i]) print((sum(dif) if n == 1 else sum(sorted(dif)[:-(n-1)])))
12
9
270
244
n, m = list(map(int, input().split())) x = sorted(map(int, input().split())) if n >= m: print((0)) else: dif = [] for i in range(m - 1): dif.append(x[i + 1] - x[i]) dif = sorted(dif) for _ in range(n - 1): dif.pop() print((sum(dif)))
n, m = list(map(int, input().split())) x = sorted(map(int, input().split())) if n >= m: print((0)) else: dif = [] for i in range(m - 1): dif.append(x[i + 1] - x[i]) print((sum(dif) if n == 1 else sum(sorted(dif)[: -(n - 1)])))
false
25
[ "- dif = sorted(dif)", "- for _ in range(n - 1):", "- dif.pop()", "- print((sum(dif)))", "+ print((sum(dif) if n == 1 else sum(sorted(dif)[: -(n - 1)])))" ]
false
0.040321
0.037169
1.084806
[ "s482946345", "s052205963" ]
u312025627
p02726
python
s207314245
s328961649
461
117
80,348
74,916
Accepted
Accepted
74.62
def main(): from collections import deque N, X, Y = (int(i) for i in input().split()) X -= 1 Y -= 1 edge = [[] for _ in range(N)] for i in range(N-1): edge[i].append(i+1) edge[i+1].append(i) edge[X].append(Y) edge[Y].append(X) def bfs(s): d = [-1 for _ in range(N)] que = deque() d[s] = 0 que.append(s) while que: u = que.popleft() for v in edge[u]: if d[v] != -1: continue d[v] = d[u] + 1 que.append(v) return d dist = [[] for _ in range(N)] for i in range(N): dist[i] = bfs(i) cnt = [0]*N for i in range(N): for j in range(i+1, N): cnt[dist[i][j]] += 1 for c in cnt[1:]: print(c) if __name__ == '__main__': main()
def main(): N, X, Y = (int(i) for i in input().split()) cnt = [0]*N for i in range(1, N+1): for j in range(i+1, N+1): d = min(abs(i-j), abs(i-X)+1+abs(j-Y), abs(i-X)+abs(X-Y)+abs(j-Y)) cnt[d] += 1 for d in cnt[1:]: print(d) if __name__ == '__main__': main()
39
13
910
332
def main(): from collections import deque N, X, Y = (int(i) for i in input().split()) X -= 1 Y -= 1 edge = [[] for _ in range(N)] for i in range(N - 1): edge[i].append(i + 1) edge[i + 1].append(i) edge[X].append(Y) edge[Y].append(X) def bfs(s): d = [-1 for _ in range(N)] que = deque() d[s] = 0 que.append(s) while que: u = que.popleft() for v in edge[u]: if d[v] != -1: continue d[v] = d[u] + 1 que.append(v) return d dist = [[] for _ in range(N)] for i in range(N): dist[i] = bfs(i) cnt = [0] * N for i in range(N): for j in range(i + 1, N): cnt[dist[i][j]] += 1 for c in cnt[1:]: print(c) if __name__ == "__main__": main()
def main(): N, X, Y = (int(i) for i in input().split()) cnt = [0] * N for i in range(1, N + 1): for j in range(i + 1, N + 1): d = min( abs(i - j), abs(i - X) + 1 + abs(j - Y), abs(i - X) + abs(X - Y) + abs(j - Y), ) cnt[d] += 1 for d in cnt[1:]: print(d) if __name__ == "__main__": main()
false
66.666667
[ "- from collections import deque", "-", "- X -= 1", "- Y -= 1", "- edge = [[] for _ in range(N)]", "- for i in range(N - 1):", "- edge[i].append(i + 1)", "- edge[i + 1].append(i)", "- edge[X].append(Y)", "- edge[Y].append(X)", "-", "- def bfs(s):", "- d = [-1 for _ in range(N)]", "- que = deque()", "- d[s] = 0", "- que.append(s)", "- while que:", "- u = que.popleft()", "- for v in edge[u]:", "- if d[v] != -1:", "- continue", "- d[v] = d[u] + 1", "- que.append(v)", "- return d", "-", "- dist = [[] for _ in range(N)]", "- for i in range(N):", "- dist[i] = bfs(i)", "- for i in range(N):", "- for j in range(i + 1, N):", "- cnt[dist[i][j]] += 1", "- for c in cnt[1:]:", "- print(c)", "+ for i in range(1, N + 1):", "+ for j in range(i + 1, N + 1):", "+ d = min(", "+ abs(i - j),", "+ abs(i - X) + 1 + abs(j - Y),", "+ abs(i - X) + abs(X - Y) + abs(j - Y),", "+ )", "+ cnt[d] += 1", "+ for d in cnt[1:]:", "+ print(d)" ]
false
0.036257
0.035799
1.012802
[ "s207314245", "s328961649" ]
u790710233
p02927
python
s886833902
s578361756
23
19
2,940
3,060
Accepted
Accepted
17.39
M, D = list(map(int, input().split())) ans = 0 for m in range(1, M+1): for d in range(20, D + 1): a, b = list(map(int, str(d))) if b < 2: continue elif m == a*b: ans += 1 print(ans)
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) M, D = list(map(int, input().split())) ans = 0 for d in range(20, D + 1): for m in range(1, M+1): a, b = d//10, d % 10 if m == a*b and b >= 2: ans += 1 print(ans)
13
16
237
276
M, D = list(map(int, input().split())) ans = 0 for m in range(1, M + 1): for d in range(20, D + 1): a, b = list(map(int, str(d))) if b < 2: continue elif m == a * b: ans += 1 print(ans)
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) M, D = list(map(int, input().split())) ans = 0 for d in range(20, D + 1): for m in range(1, M + 1): a, b = d // 10, d % 10 if m == a * b and b >= 2: ans += 1 print(ans)
false
18.75
[ "+import sys", "+", "+input = sys.stdin.readline", "+sys.setrecursionlimit(10**7)", "-for m in range(1, M + 1):", "- for d in range(20, D + 1):", "- a, b = list(map(int, str(d)))", "- if b < 2:", "- continue", "- elif m == a * b:", "+for d in range(20, D + 1):", "+ for m in range(1, M + 1):", "+ a, b = d // 10, d % 10", "+ if m == a * b and b >= 2:" ]
false
0.037347
0.03736
0.999671
[ "s886833902", "s578361756" ]
u641722141
p02687
python
s237830948
s526958458
23
20
9,020
8,972
Accepted
Accepted
13.04
s = eval(input()) print(("ABC" if s == "ARC" else "ARC"))
print(("ABC" if eval(input())=="ARC" else "ARC"))
2
1
50
41
s = eval(input()) print(("ABC" if s == "ARC" else "ARC"))
print(("ABC" if eval(input()) == "ARC" else "ARC"))
false
50
[ "-s = eval(input())", "-print((\"ABC\" if s == \"ARC\" else \"ARC\"))", "+print((\"ABC\" if eval(input()) == \"ARC\" else \"ARC\"))" ]
false
0.046648
0.008242
5.659642
[ "s237830948", "s526958458" ]
u595289165
p02948
python
s952656901
s481089316
643
318
31,676
24,044
Accepted
Accepted
50.54
import heapq n, m = list(map(int, input().split())) work = [list(map(int, input().split())) for _ in range(n)] work.sort() cd = [] heapq.heapify(cd) cnt = 0 ans = 0 # b, a # aの条件 for k in range(m+1): # a = kの仕事をheappush for i in range(cnt, n): a, b = work[i] if a == k: heapq.heappush(cd, -b) else: cnt = i break if i == n-1: cnt = n-1 if not cd: continue ans -= heapq.heappop(cd) print(ans)
import heapq n, m = list(map(int, input().split())) byte = [[] for _ in range(100001)] for _ in range(n): a, b = list(map(int, input().split())) byte[a].append(b) search = [] day = 1 ans = 0 while day-1 != m: for b in byte[day]: heapq.heappush(search, -b) if not search: day += 1 continue tmp = -heapq.heappop(search) ans += tmp day += 1 print(ans)
32
24
528
417
import heapq n, m = list(map(int, input().split())) work = [list(map(int, input().split())) for _ in range(n)] work.sort() cd = [] heapq.heapify(cd) cnt = 0 ans = 0 # b, a # aの条件 for k in range(m + 1): # a = kの仕事をheappush for i in range(cnt, n): a, b = work[i] if a == k: heapq.heappush(cd, -b) else: cnt = i break if i == n - 1: cnt = n - 1 if not cd: continue ans -= heapq.heappop(cd) print(ans)
import heapq n, m = list(map(int, input().split())) byte = [[] for _ in range(100001)] for _ in range(n): a, b = list(map(int, input().split())) byte[a].append(b) search = [] day = 1 ans = 0 while day - 1 != m: for b in byte[day]: heapq.heappush(search, -b) if not search: day += 1 continue tmp = -heapq.heappop(search) ans += tmp day += 1 print(ans)
false
25
[ "-work = [list(map(int, input().split())) for _ in range(n)]", "-work.sort()", "-cd = []", "-heapq.heapify(cd)", "-cnt = 0", "+byte = [[] for _ in range(100001)]", "+for _ in range(n):", "+ a, b = list(map(int, input().split()))", "+ byte[a].append(b)", "+search = []", "+day = 1", "-# b, a", "-# aの条件", "-for k in range(m + 1):", "- # a = kの仕事をheappush", "- for i in range(cnt, n):", "- a, b = work[i]", "- if a == k:", "- heapq.heappush(cd, -b)", "- else:", "- cnt = i", "- break", "- if i == n - 1:", "- cnt = n - 1", "- if not cd:", "+while day - 1 != m:", "+ for b in byte[day]:", "+ heapq.heappush(search, -b)", "+ if not search:", "+ day += 1", "- ans -= heapq.heappop(cd)", "+ tmp = -heapq.heappop(search)", "+ ans += tmp", "+ day += 1" ]
false
0.041369
0.098985
0.417933
[ "s952656901", "s481089316" ]
u850491413
p02889
python
s965956137
s336735726
1,156
1,023
19,940
19,940
Accepted
Accepted
11.51
from scipy.sparse import csr_matrix #pypyだとエラーになるので、pythonを使うこと from scipy.sparse.csgraph import shortest_path, floyd_warshall import numpy as np import sys def input(): return sys.stdin.readline().strip() N, M, L = list(map(int, input().split())) A = np.zeros(M) B = np.zeros(M) C = np.zeros(M) for i in range(M): Ai, Bi, Ci = list(map(int, input().split())) A[i] = Ai - 1 B[i] = Bi - 1 C[i] = Ci graph = csr_matrix((C, (A, B)), shape=(N, N)) #print(graph) dist = floyd_warshall(graph, directed=False) graph2 = np.full((N, N), np.inf) for i in range(N): for j in range(N): if dist[i, j] <= L: graph2[i, j] = 1 graph2 = csr_matrix(graph2) num = shortest_path(graph2, directed=False) Q = int(eval(input())) for q in range(Q): s, t = list(map(int, input().split())) if num[s - 1][t - 1] < 10000000: print((int(num[s - 1][t - 1] - 1))) else: print((-1))
from scipy.sparse import csr_matrix #pypyだとエラーになるので、pythonを使うこと from scipy.sparse.csgraph import shortest_path, floyd_warshall import numpy as np import sys def input(): return sys.stdin.readline().strip() N, M, L = list(map(int, input().split())) A = np.zeros(M) B = np.zeros(M) C = np.zeros(M) for i in range(M): Ai, Bi, Ci = list(map(int, input().split())) A[i] = Ai - 1 B[i] = Bi - 1 C[i] = Ci graph = csr_matrix((C, (A, B)), shape=(N, N)) #print(graph) dist = floyd_warshall(graph, directed=False) graph2 = np.full((N, N), np.inf) graph2[dist <= L] = 1 graph2 = csr_matrix(graph2) num = floyd_warshall(graph2, directed=False) Q = int(eval(input())) for q in range(Q): s, t = list(map(int, input().split())) if num[s - 1][t - 1] < 10000000: print((int(num[s - 1][t - 1] - 1))) else: print((-1))
38
36
901
842
from scipy.sparse import csr_matrix # pypyだとエラーになるので、pythonを使うこと from scipy.sparse.csgraph import shortest_path, floyd_warshall import numpy as np import sys def input(): return sys.stdin.readline().strip() N, M, L = list(map(int, input().split())) A = np.zeros(M) B = np.zeros(M) C = np.zeros(M) for i in range(M): Ai, Bi, Ci = list(map(int, input().split())) A[i] = Ai - 1 B[i] = Bi - 1 C[i] = Ci graph = csr_matrix((C, (A, B)), shape=(N, N)) # print(graph) dist = floyd_warshall(graph, directed=False) graph2 = np.full((N, N), np.inf) for i in range(N): for j in range(N): if dist[i, j] <= L: graph2[i, j] = 1 graph2 = csr_matrix(graph2) num = shortest_path(graph2, directed=False) Q = int(eval(input())) for q in range(Q): s, t = list(map(int, input().split())) if num[s - 1][t - 1] < 10000000: print((int(num[s - 1][t - 1] - 1))) else: print((-1))
from scipy.sparse import csr_matrix # pypyだとエラーになるので、pythonを使うこと from scipy.sparse.csgraph import shortest_path, floyd_warshall import numpy as np import sys def input(): return sys.stdin.readline().strip() N, M, L = list(map(int, input().split())) A = np.zeros(M) B = np.zeros(M) C = np.zeros(M) for i in range(M): Ai, Bi, Ci = list(map(int, input().split())) A[i] = Ai - 1 B[i] = Bi - 1 C[i] = Ci graph = csr_matrix((C, (A, B)), shape=(N, N)) # print(graph) dist = floyd_warshall(graph, directed=False) graph2 = np.full((N, N), np.inf) graph2[dist <= L] = 1 graph2 = csr_matrix(graph2) num = floyd_warshall(graph2, directed=False) Q = int(eval(input())) for q in range(Q): s, t = list(map(int, input().split())) if num[s - 1][t - 1] < 10000000: print((int(num[s - 1][t - 1] - 1))) else: print((-1))
false
5.263158
[ "-for i in range(N):", "- for j in range(N):", "- if dist[i, j] <= L:", "- graph2[i, j] = 1", "+graph2[dist <= L] = 1", "-num = shortest_path(graph2, directed=False)", "+num = floyd_warshall(graph2, directed=False)" ]
false
0.436671
0.52416
0.833088
[ "s965956137", "s336735726" ]
u106797249
p03074
python
s375633478
s349382943
225
61
61,552
7,924
Accepted
Accepted
72.89
def resolve(): N, K = list(map(int, input().split())) S = eval(input()) seq = [] cnt = 0 for i in range(len(S)): if i == N-1 or S[i] != S[i+1]: seq.append([cnt+1, S[i]]) cnt = 0 else: cnt += 1 #print(seq) left = 0 right = 0 maxlen = 0 val = 0 n_rev = 0 for left in range(0, len(seq)): while (right < len(seq) and (n_rev < K or seq[right][1]=="1")): #print("left={}, right={}, n_rev={}".format(left, right, n_rev)) cnt, state = seq[right] val += cnt if state == "0": n_rev += 1 right += 1 maxlen = max(maxlen, val) cnt, state = seq[left] val -= cnt if state == "0": n_rev -= 1 if left == right: right += 1 print(maxlen) if '__main__' == __name__: resolve()
# 累積和による解法 def resolve(): N, K = list(map(int, input().split())) S = eval(input()) seq = [] cnt = 0 if S[0] != "1": seq.append(0) for i in range(len(S)-1): if S[i] != S[i+1]: seq.append(cnt+1) cnt = 0 else: cnt += 1 seq.append(cnt+1) if S[-1] != "1": seq.append(0) #print(seq) cum = [0] cur = 0 for c in seq: cur += c cum.append(cur) #print(cum) maxlen = len(S) if len(cum) <= (2*K+1) else 0 for i in range(0, len(cum)-(2*K+1), 2): l = cum[i+(2*K+1)] - cum[i] maxlen = max(maxlen, l) print(maxlen) if '__main__' == __name__: resolve()
37
35
947
742
def resolve(): N, K = list(map(int, input().split())) S = eval(input()) seq = [] cnt = 0 for i in range(len(S)): if i == N - 1 or S[i] != S[i + 1]: seq.append([cnt + 1, S[i]]) cnt = 0 else: cnt += 1 # print(seq) left = 0 right = 0 maxlen = 0 val = 0 n_rev = 0 for left in range(0, len(seq)): while right < len(seq) and (n_rev < K or seq[right][1] == "1"): # print("left={}, right={}, n_rev={}".format(left, right, n_rev)) cnt, state = seq[right] val += cnt if state == "0": n_rev += 1 right += 1 maxlen = max(maxlen, val) cnt, state = seq[left] val -= cnt if state == "0": n_rev -= 1 if left == right: right += 1 print(maxlen) if "__main__" == __name__: resolve()
# 累積和による解法 def resolve(): N, K = list(map(int, input().split())) S = eval(input()) seq = [] cnt = 0 if S[0] != "1": seq.append(0) for i in range(len(S) - 1): if S[i] != S[i + 1]: seq.append(cnt + 1) cnt = 0 else: cnt += 1 seq.append(cnt + 1) if S[-1] != "1": seq.append(0) # print(seq) cum = [0] cur = 0 for c in seq: cur += c cum.append(cur) # print(cum) maxlen = len(S) if len(cum) <= (2 * K + 1) else 0 for i in range(0, len(cum) - (2 * K + 1), 2): l = cum[i + (2 * K + 1)] - cum[i] maxlen = max(maxlen, l) print(maxlen) if "__main__" == __name__: resolve()
false
5.405405
[ "+# 累積和による解法", "- for i in range(len(S)):", "- if i == N - 1 or S[i] != S[i + 1]:", "- seq.append([cnt + 1, S[i]])", "+ if S[0] != \"1\":", "+ seq.append(0)", "+ for i in range(len(S) - 1):", "+ if S[i] != S[i + 1]:", "+ seq.append(cnt + 1)", "+ seq.append(cnt + 1)", "+ if S[-1] != \"1\":", "+ seq.append(0)", "- left = 0", "- right = 0", "- maxlen = 0", "- val = 0", "- n_rev = 0", "- for left in range(0, len(seq)):", "- while right < len(seq) and (n_rev < K or seq[right][1] == \"1\"):", "- # print(\"left={}, right={}, n_rev={}\".format(left, right, n_rev))", "- cnt, state = seq[right]", "- val += cnt", "- if state == \"0\":", "- n_rev += 1", "- right += 1", "- maxlen = max(maxlen, val)", "- cnt, state = seq[left]", "- val -= cnt", "- if state == \"0\":", "- n_rev -= 1", "- if left == right:", "- right += 1", "+ cum = [0]", "+ cur = 0", "+ for c in seq:", "+ cur += c", "+ cum.append(cur)", "+ # print(cum)", "+ maxlen = len(S) if len(cum) <= (2 * K + 1) else 0", "+ for i in range(0, len(cum) - (2 * K + 1), 2):", "+ l = cum[i + (2 * K + 1)] - cum[i]", "+ maxlen = max(maxlen, l)" ]
false
0.036532
0.033462
1.091738
[ "s375633478", "s349382943" ]
u717626627
p02911
python
s095769234
s661768333
392
258
20,116
6,596
Accepted
Accepted
34.18
import numpy as np n, k, q = list(map(int, input().split())) a = [int(eval(input())) for i in range(q)] score = [k - q]*(n+1) for i in range(q): score[a[i]] += 1 for i in range(1,n+1): if score[i] > 0: print('Yes') else: print('No')
n,k,q = list(map(int, input().split())) score = [k - q]*(n+1) for _ in range(q): score[int(eval(input()))] += 1 for i in range(1, n+1): if score[i] > 0: print('Yes') else: print('No')
15
12
252
199
import numpy as np n, k, q = list(map(int, input().split())) a = [int(eval(input())) for i in range(q)] score = [k - q] * (n + 1) for i in range(q): score[a[i]] += 1 for i in range(1, n + 1): if score[i] > 0: print("Yes") else: print("No")
n, k, q = list(map(int, input().split())) score = [k - q] * (n + 1) for _ in range(q): score[int(eval(input()))] += 1 for i in range(1, n + 1): if score[i] > 0: print("Yes") else: print("No")
false
20
[ "-import numpy as np", "-", "-a = [int(eval(input())) for i in range(q)]", "-for i in range(q):", "- score[a[i]] += 1", "+for _ in range(q):", "+ score[int(eval(input()))] += 1" ]
false
0.037486
0.038078
0.984456
[ "s095769234", "s661768333" ]
u893063840
p03700
python
s756997784
s813200713
1,391
374
7,192
17,024
Accepted
Accepted
73.11
from math import ceil n, a, b = list(map(int, input().split())) h = [int(eval(input())) for _ in range(n)] def f(x): cnt = 0 for e in h: cnt += max(0, ceil((e - b * x) / (a - b))) if cnt > x: return False return True l = 0 r = ceil(max(h) / b) while r - l > 1: mid = (l + r) // 2 if f(mid): r = mid else: l = mid print(r)
import numpy as np n, a, b = list(map(int, input().split())) h = np.array([int(eval(input())) for _ in range(n)], dtype=np.int64) def f(x): li = h - b * x li[li < 0] = 0 cnt = np.ceil(li / (a - b)) ret = cnt.sum() <= x return ret l = 0 r = np.ceil(max(h) / b).astype(np.int64) while r - l > 1: mid = (l + r) // 2 if f(mid): r = mid else: l = mid print(r)
27
24
404
420
from math import ceil n, a, b = list(map(int, input().split())) h = [int(eval(input())) for _ in range(n)] def f(x): cnt = 0 for e in h: cnt += max(0, ceil((e - b * x) / (a - b))) if cnt > x: return False return True l = 0 r = ceil(max(h) / b) while r - l > 1: mid = (l + r) // 2 if f(mid): r = mid else: l = mid print(r)
import numpy as np n, a, b = list(map(int, input().split())) h = np.array([int(eval(input())) for _ in range(n)], dtype=np.int64) def f(x): li = h - b * x li[li < 0] = 0 cnt = np.ceil(li / (a - b)) ret = cnt.sum() <= x return ret l = 0 r = np.ceil(max(h) / b).astype(np.int64) while r - l > 1: mid = (l + r) // 2 if f(mid): r = mid else: l = mid print(r)
false
11.111111
[ "-from math import ceil", "+import numpy as np", "-h = [int(eval(input())) for _ in range(n)]", "+h = np.array([int(eval(input())) for _ in range(n)], dtype=np.int64)", "- cnt = 0", "- for e in h:", "- cnt += max(0, ceil((e - b * x) / (a - b)))", "- if cnt > x:", "- return False", "- return True", "+ li = h - b * x", "+ li[li < 0] = 0", "+ cnt = np.ceil(li / (a - b))", "+ ret = cnt.sum() <= x", "+ return ret", "-r = ceil(max(h) / b)", "+r = np.ceil(max(h) / b).astype(np.int64)" ]
false
0.061501
0.187408
0.328168
[ "s756997784", "s813200713" ]
u556358547
p02989
python
s593286335
s573129025
469
96
81,132
80,976
Accepted
Accepted
79.53
#!/usr/bin/env python3 import sys def solve(N: int, d: "List[int]"): b = [0] * (10**5 +1) for i in range(N): b[d[i]] += 1 t = 0 f = False ans = 0 for i in range(1, 10 ** 5 + 1): if not f: t += b[i] if t == N / 2: f = True elif t > N / 2: ans = 0 break else: ans += 1 if b[i] != 0: break print(ans) return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int d = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, d) if __name__ == '__main__': main()
#!/usr/bin/env python3 import sys def solve(N: int, d: "List[int]"): d.sort() abc = d[int(N/2)-1] arc = d[int(N/2)] print((arc-abc)) return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int d = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, d) if __name__ == '__main__': main()
43
26
1,027
681
#!/usr/bin/env python3 import sys def solve(N: int, d: "List[int]"): b = [0] * (10**5 + 1) for i in range(N): b[d[i]] += 1 t = 0 f = False ans = 0 for i in range(1, 10**5 + 1): if not f: t += b[i] if t == N / 2: f = True elif t > N / 2: ans = 0 break else: ans += 1 if b[i] != 0: break print(ans) return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int d = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, d) if __name__ == "__main__": main()
#!/usr/bin/env python3 import sys def solve(N: int, d: "List[int]"): d.sort() abc = d[int(N / 2) - 1] arc = d[int(N / 2)] print((arc - abc)) return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int d = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, d) if __name__ == "__main__": main()
false
39.534884
[ "- b = [0] * (10**5 + 1)", "- for i in range(N):", "- b[d[i]] += 1", "- t = 0", "- f = False", "- ans = 0", "- for i in range(1, 10**5 + 1):", "- if not f:", "- t += b[i]", "- if t == N / 2:", "- f = True", "- elif t > N / 2:", "- ans = 0", "- break", "- else:", "- ans += 1", "- if b[i] != 0:", "- break", "- print(ans)", "+ d.sort()", "+ abc = d[int(N / 2) - 1]", "+ arc = d[int(N / 2)]", "+ print((arc - abc))" ]
false
0.107501
0.037534
2.864108
[ "s593286335", "s573129025" ]
u294385082
p02780
python
s088823202
s794954335
224
120
24,804
25,148
Accepted
Accepted
46.43
#for内でその都度sumをとるのはまずいらしい n,k = list(map(int,input().split())) p = list(map(int,input().split())) ave = [] ans = 0 tmp = 0 for i in range(n): ave.append((p[i]+1)/2) for j in range(n): tmp += ave[j] if j >= k: tmp -= ave[j-k] ans = max(ans,tmp) print(ans)
#累積和 都度sum(O(n))を取っていると,O(n^2)になってしまう import itertools n, k = list(map(int, input().split())) p = list(map(int, input().split())) acc = [0] + list(itertools.accumulate([(x+1)/2 for x in p])) ans = max(acc[i+k]-acc[i] for i in range(n-k+1)) print(ans)
19
9
286
258
# for内でその都度sumをとるのはまずいらしい n, k = list(map(int, input().split())) p = list(map(int, input().split())) ave = [] ans = 0 tmp = 0 for i in range(n): ave.append((p[i] + 1) / 2) for j in range(n): tmp += ave[j] if j >= k: tmp -= ave[j - k] ans = max(ans, tmp) print(ans)
# 累積和 都度sum(O(n))を取っていると,O(n^2)になってしまう import itertools n, k = list(map(int, input().split())) p = list(map(int, input().split())) acc = [0] + list(itertools.accumulate([(x + 1) / 2 for x in p])) ans = max(acc[i + k] - acc[i] for i in range(n - k + 1)) print(ans)
false
52.631579
[ "-# for内でその都度sumをとるのはまずいらしい", "+# 累積和 都度sum(O(n))を取っていると,O(n^2)になってしまう", "+import itertools", "+", "-ave = []", "-ans = 0", "-tmp = 0", "-for i in range(n):", "- ave.append((p[i] + 1) / 2)", "-for j in range(n):", "- tmp += ave[j]", "- if j >= k:", "- tmp -= ave[j - k]", "- ans = max(ans, tmp)", "+acc = [0] + list(itertools.accumulate([(x + 1) / 2 for x in p]))", "+ans = max(acc[i + k] - acc[i] for i in range(n - k + 1))" ]
false
0.037621
0.037934
0.991754
[ "s088823202", "s794954335" ]
u135116520
p03103
python
s162905619
s879200830
489
451
29,792
29,796
Accepted
Accepted
7.77
N,M=list(map(int,input().split())) k=M s=0 A=[list(map(int,input().split())) for i in range(N)] A=sorted(A,key=lambda x:x[0]) while k>0: for i in range(N): if k>A[i][1]: s+=A[i][0]*A[i][1] k=k-A[i][1] else: s+=A[i][0]*k k=0 print(s)
N,M=list(map(int,input().split())) A=[list(map(int,input().split())) for i in range(N)] A=sorted(A,key=lambda x:x[0]) s=0 #本数 t=0 #値段 for i in range(N): s+=A[i][1] if M>s: t+=A[i][0]*A[i][1] else: over=s-M t+=A[i][0]*A[i][1]-A[i][0]*over break print(t)
14
14
273
281
N, M = list(map(int, input().split())) k = M s = 0 A = [list(map(int, input().split())) for i in range(N)] A = sorted(A, key=lambda x: x[0]) while k > 0: for i in range(N): if k > A[i][1]: s += A[i][0] * A[i][1] k = k - A[i][1] else: s += A[i][0] * k k = 0 print(s)
N, M = list(map(int, input().split())) A = [list(map(int, input().split())) for i in range(N)] A = sorted(A, key=lambda x: x[0]) s = 0 # 本数 t = 0 # 値段 for i in range(N): s += A[i][1] if M > s: t += A[i][0] * A[i][1] else: over = s - M t += A[i][0] * A[i][1] - A[i][0] * over break print(t)
false
0
[ "-k = M", "-s = 0", "-while k > 0:", "- for i in range(N):", "- if k > A[i][1]:", "- s += A[i][0] * A[i][1]", "- k = k - A[i][1]", "- else:", "- s += A[i][0] * k", "- k = 0", "-print(s)", "+s = 0 # 本数", "+t = 0 # 値段", "+for i in range(N):", "+ s += A[i][1]", "+ if M > s:", "+ t += A[i][0] * A[i][1]", "+ else:", "+ over = s - M", "+ t += A[i][0] * A[i][1] - A[i][0] * over", "+ break", "+print(t)" ]
false
0.039309
0.038041
1.033343
[ "s162905619", "s879200830" ]
u145950990
p03244
python
s164447699
s720017273
253
179
65,004
27,292
Accepted
Accepted
29.25
from collections import Counter n = int(eval(input())) v = list(map(int,input().split())) v1 = Counter(v[::2]).most_common() v2 = Counter(v[1::2]).most_common() v1.append((0,0)) v2.append((0,0)) ans = n if v1[0][0]==v2[0][0]: ans -= max(v1[0][1]+v2[1][1],v1[1][1]+v2[0][1]) else: ans -= v1[0][1]+v2[0][1] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) a1 = a[::2] a2 = a[1::2] from collections import Counter c = Counter(a1) c1 = [] for i in c: c1.append([c[i],i]) c1.sort(reverse = True) c = Counter(a2) c2 = [] for i in c: c2.append([c[i],i]) c2.sort(reverse = True) ans = n if c1[0][1] != c2[0][1]: ans -= c1[0][0] ans -= c2[0][0] else: buf1 = 0 buf1 += c1[0][0] if len(c2) > 1: buf1 += c2[1][0] buf2 = 0 buf2 += c2[0][0] if len(c1) > 1: buf2 += c1[1][0] ans -= max(buf1,buf2) print(ans)
13
31
329
568
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1 = Counter(v[::2]).most_common() v2 = Counter(v[1::2]).most_common() v1.append((0, 0)) v2.append((0, 0)) ans = n if v1[0][0] == v2[0][0]: ans -= max(v1[0][1] + v2[1][1], v1[1][1] + v2[0][1]) else: ans -= v1[0][1] + v2[0][1] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) a1 = a[::2] a2 = a[1::2] from collections import Counter c = Counter(a1) c1 = [] for i in c: c1.append([c[i], i]) c1.sort(reverse=True) c = Counter(a2) c2 = [] for i in c: c2.append([c[i], i]) c2.sort(reverse=True) ans = n if c1[0][1] != c2[0][1]: ans -= c1[0][0] ans -= c2[0][0] else: buf1 = 0 buf1 += c1[0][0] if len(c2) > 1: buf1 += c2[1][0] buf2 = 0 buf2 += c2[0][0] if len(c1) > 1: buf2 += c1[1][0] ans -= max(buf1, buf2) print(ans)
false
58.064516
[ "+n = int(eval(input()))", "+a = list(map(int, input().split()))", "+a1 = a[::2]", "+a2 = a[1::2]", "-n = int(eval(input()))", "-v = list(map(int, input().split()))", "-v1 = Counter(v[::2]).most_common()", "-v2 = Counter(v[1::2]).most_common()", "-v1.append((0, 0))", "-v2.append((0, 0))", "+c = Counter(a1)", "+c1 = []", "+for i in c:", "+ c1.append([c[i], i])", "+c1.sort(reverse=True)", "+c = Counter(a2)", "+c2 = []", "+for i in c:", "+ c2.append([c[i], i])", "+c2.sort(reverse=True)", "-if v1[0][0] == v2[0][0]:", "- ans -= max(v1[0][1] + v2[1][1], v1[1][1] + v2[0][1])", "+if c1[0][1] != c2[0][1]:", "+ ans -= c1[0][0]", "+ ans -= c2[0][0]", "- ans -= v1[0][1] + v2[0][1]", "+ buf1 = 0", "+ buf1 += c1[0][0]", "+ if len(c2) > 1:", "+ buf1 += c2[1][0]", "+ buf2 = 0", "+ buf2 += c2[0][0]", "+ if len(c1) > 1:", "+ buf2 += c1[1][0]", "+ ans -= max(buf1, buf2)" ]
false
0.054089
0.079129
0.683552
[ "s164447699", "s720017273" ]
u285891772
p04043
python
s144040343
s466803032
43
38
5,452
5,144
Accepted
Accepted
11.63
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from fractions import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return list(zip(*(MAP() for _ in range(n)))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 A = LIST() if all(x in A for x in [5,7]) and sum(A) == 17: print("YES") else: print("NO")
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from fractions import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return list(zip(*(MAP() for _ in range(n)))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 A = LIST() A.sort() if A == [5, 5, 7]: print("YES") else: print("NO")
26
29
951
934
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, ) from itertools import ( accumulate, permutations, combinations, combinations_with_replacement, product, groupby, ) from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from fractions import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return list(zip(*(MAP() for _ in range(n)))) sys.setrecursionlimit(10**9) INF = float("inf") mod = 10**9 + 7 A = LIST() if all(x in A for x in [5, 7]) and sum(A) == 17: print("YES") else: print("NO")
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, ) from itertools import ( accumulate, permutations, combinations, combinations_with_replacement, product, groupby, ) from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from fractions import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return list(zip(*(MAP() for _ in range(n)))) sys.setrecursionlimit(10**9) INF = float("inf") mod = 10**9 + 7 A = LIST() A.sort() if A == [5, 5, 7]: print("YES") else: print("NO")
false
10.344828
[ "-if all(x in A for x in [5, 7]) and sum(A) == 17:", "+A.sort()", "+if A == [5, 5, 7]:" ]
false
0.034771
0.042414
0.819813
[ "s144040343", "s466803032" ]