user_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
1 value
submission_id_v0
stringlengths
10
10
submission_id_v1
stringlengths
10
10
cpu_time_v0
int64
10
38.3k
cpu_time_v1
int64
0
24.7k
memory_v0
int64
2.57k
1.02M
memory_v1
int64
2.57k
869k
status_v0
stringclasses
1 value
status_v1
stringclasses
1 value
improvement_frac
float64
7.51
100
input
stringlengths
20
4.55k
target
stringlengths
17
3.34k
code_v0_loc
int64
1
148
code_v1_loc
int64
1
184
code_v0_num_chars
int64
13
4.55k
code_v1_num_chars
int64
14
3.34k
code_v0_no_empty_lines
stringlengths
21
6.88k
code_v1_no_empty_lines
stringlengths
20
4.93k
code_same
bool
1 class
relative_loc_diff_percent
float64
0
79.8
diff
list
diff_only_import_comment
bool
1 class
measured_runtime_v0
float64
0.01
4.45
measured_runtime_v1
float64
0.01
4.31
runtime_lift
float64
0
359
key
list
u775421443
p03160
python
s646649816
s585693691
114
92
14,236
14,108
Accepted
Accepted
19.3
n = int(eval(input())) hs = tuple(map(int, input().split())) a, b = 0, abs(hs[1] - hs[0]) for i in range(2, n): c = hs[i] a, b = b, min(a + abs(c - hs[i-2]), b + abs(c - hs[i-1])) print(b)
def main(): n = int(eval(input())) hs = tuple(map(int, input().split())) a, b = 0, abs(hs[1] - hs[0]) for i in range(2, n): c = hs[i] a, b = b, min(a + abs(c - hs[i-2]), b + abs(c - hs[i-1])) print(b) if __name__ == "__main__": main()
10
14
199
297
n = int(eval(input())) hs = tuple(map(int, input().split())) a, b = 0, abs(hs[1] - hs[0]) for i in range(2, n): c = hs[i] a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1])) print(b)
def main(): n = int(eval(input())) hs = tuple(map(int, input().split())) a, b = 0, abs(hs[1] - hs[0]) for i in range(2, n): c = hs[i] a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1])) print(b) if __name__ == "__main__": main()
false
28.571429
[ "-n = int(eval(input()))", "-hs = tuple(map(int, input().split()))", "-a, b = 0, abs(hs[1] - hs[0])", "-for i in range(2, n):", "- c = hs[i]", "- a, b = b, min(a + abs(c - hs[i - 2]), b + abs(c - hs[i - 1]))", "-print(b)", "+def main():", "+ n = int(eval(input()))", "+ hs = tuple(map(i...
false
0.037641
0.043039
0.874567
[ "s646649816", "s585693691" ]
u047034794
p04006
python
s469308700
s167143295
1,844
1,467
3,188
3,316
Accepted
Accepted
20.44
def mygets(): return list(map(int, input().strip().split(' '))) n, x = mygets() a = mygets() b1 = a ans = sum(a) def f(k, u): j = k - 1 if j < 0: j = n - 1 w = b1[j] if u < w: return u return w for i in range(1, n): b2 = [f(k, u) for k, u in enumerate(a)] ans = min(ans, sum(b2) + i * x) b1 = b2 print(ans)
def mygets(): return [int(v) for v in input().strip().split(' ')] n, x = mygets() a = mygets() b1 = a ans = sum(a) for i in range(1, n): b2 = [u if u < b1[k - 1] else b1[k - 1] for k, u in enumerate(a)] ans = min(ans, sum(b2) + i * x) b1 = b2 print(ans)
25
16
388
289
def mygets(): return list(map(int, input().strip().split(" "))) n, x = mygets() a = mygets() b1 = a ans = sum(a) def f(k, u): j = k - 1 if j < 0: j = n - 1 w = b1[j] if u < w: return u return w for i in range(1, n): b2 = [f(k, u) for k, u in enumerate(a)] ans = min(ans, sum(b2) + i * x) b1 = b2 print(ans)
def mygets(): return [int(v) for v in input().strip().split(" ")] n, x = mygets() a = mygets() b1 = a ans = sum(a) for i in range(1, n): b2 = [u if u < b1[k - 1] else b1[k - 1] for k, u in enumerate(a)] ans = min(ans, sum(b2) + i * x) b1 = b2 print(ans)
false
36
[ "- return list(map(int, input().strip().split(\" \")))", "+ return [int(v) for v in input().strip().split(\" \")]", "-", "-", "-def f(k, u):", "- j = k - 1", "- if j < 0:", "- j = n - 1", "- w = b1[j]", "- if u < w:", "- return u", "- return w", "-", "-",...
false
0.037498
0.044765
0.83765
[ "s469308700", "s167143295" ]
u022979415
p02803
python
s217016350
s917932162
951
664
3,444
3,436
Accepted
Accepted
30.18
from copy import deepcopy def solve(maze, i, j, h, w, count): distance = 0 if maze[i][j] == ".": distance = 0 next_search = [(i, j)] while not next_search == []: now = next_search.pop(0) if maze[now[0]][now[1]] == ".": maze[now[0]][now[1]] = "#" for direction in [(1, 0), (-1, 0), (0, 1), (0, -1)]: search = [direction[0] + now[0], direction[1] + now[1]] if search[0] < 0 or h <= search[0] or search[1] < 0 or w <= search[1] or \ maze[search[0]][search[1]] == "#": continue else: count[search[0]][search[1]] = count[now[0]][now[1]] + 1 next_search.append(tuple(search)) distance = max(distance, count[search[0]][search[1]]) return distance def main(): height, width = map(int, input().split(" ")) maze = [] answer = 0 for _ in range(height): maze.append(list(input())) count = [[0 for _ in range(width)] for _ in range(height)] for i in range(height): for j in range(width): answer = max(answer, solve(deepcopy(maze), i, j, height, width, deepcopy(count))) print(answer) if __name__ == '__main__': main()
from collections import deque from copy import deepcopy def main(): h, w = list(map(int, input().split())) grid = [list(eval(input())) for _ in range(h)] ans = 0 d = [[0, 1], [1, 0], [0, -1], [-1, 0]] for i in range(h): for j in range(w): if grid[i][j] == "#": continue now_grid = deepcopy(grid) answer = [[float("inf") for _ in range(w)] for _ in range(h)] next = deque([[i, j]]) answer[i][j] = 0 while next: y, x = next.popleft() if now_grid[y][x] == ".": now_grid[y][x] = "#" for dx, dy in d: if 0 <= x + dx < w and 0 <= y + dy < h and now_grid[y + dy][x + dx] == ".": answer[y + dy][x + dx] = min(answer[y][x] + 1, answer[y + dy][x + dx]) next.append([y + dy, x + dx]) for k in range(h): for l in range(w): if grid[k][l] == "#": continue ans = max(ans, answer[k][l]) print(ans) if __name__ == '__main__': main()
40
36
1,387
1,212
from copy import deepcopy def solve(maze, i, j, h, w, count): distance = 0 if maze[i][j] == ".": distance = 0 next_search = [(i, j)] while not next_search == []: now = next_search.pop(0) if maze[now[0]][now[1]] == ".": maze[now[0]][now[1]] = "#" for direction in [(1, 0), (-1, 0), (0, 1), (0, -1)]: search = [direction[0] + now[0], direction[1] + now[1]] if ( search[0] < 0 or h <= search[0] or search[1] < 0 or w <= search[1] or maze[search[0]][search[1]] == "#" ): continue else: count[search[0]][search[1]] = count[now[0]][now[1]] + 1 next_search.append(tuple(search)) distance = max(distance, count[search[0]][search[1]]) return distance def main(): height, width = map(int, input().split(" ")) maze = [] answer = 0 for _ in range(height): maze.append(list(input())) count = [[0 for _ in range(width)] for _ in range(height)] for i in range(height): for j in range(width): answer = max( answer, solve(deepcopy(maze), i, j, height, width, deepcopy(count)) ) print(answer) if __name__ == "__main__": main()
from collections import deque from copy import deepcopy def main(): h, w = list(map(int, input().split())) grid = [list(eval(input())) for _ in range(h)] ans = 0 d = [[0, 1], [1, 0], [0, -1], [-1, 0]] for i in range(h): for j in range(w): if grid[i][j] == "#": continue now_grid = deepcopy(grid) answer = [[float("inf") for _ in range(w)] for _ in range(h)] next = deque([[i, j]]) answer[i][j] = 0 while next: y, x = next.popleft() if now_grid[y][x] == ".": now_grid[y][x] = "#" for dx, dy in d: if ( 0 <= x + dx < w and 0 <= y + dy < h and now_grid[y + dy][x + dx] == "." ): answer[y + dy][x + dx] = min( answer[y][x] + 1, answer[y + dy][x + dx] ) next.append([y + dy, x + dx]) for k in range(h): for l in range(w): if grid[k][l] == "#": continue ans = max(ans, answer[k][l]) print(ans) if __name__ == "__main__": main()
false
10
[ "+from collections import deque", "-def solve(maze, i, j, h, w, count):", "- distance = 0", "- if maze[i][j] == \".\":", "- distance = 0", "- next_search = [(i, j)]", "- while not next_search == []:", "- now = next_search.pop(0)", "- if maze[now[0]][n...
false
0.087007
0.039489
2.203297
[ "s217016350", "s917932162" ]
u285891772
p02910
python
s356524406
s908700915
54
38
5,656
5,200
Accepted
Accepted
29.63
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, 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 S = eval(input()) N = len(S) for i in range(-(-N//2)): if S[i*2] == "L": print("No") exit() for i in range(N//2): if S[i*2+1] == "R": print("No") exit() if N%2 == 1: if S[N-1] == "L": print("No") exit() print("Yes")
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, 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 S = eval(input()) N = len(S) for i in range(-(-N//2)): if S[i*2] == "L": print("No") exit() for i in range(N//2): if S[i*2+1] == "R": print("No") exit() print("Yes")
39
35
1,056
988
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, 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 S = eval(input()) N = len(S) for i in range(-(-N // 2)): if S[i * 2] == "L": print("No") exit() for i in range(N // 2): if S[i * 2 + 1] == "R": print("No") exit() if N % 2 == 1: if S[N - 1] == "L": print("No") exit() print("Yes")
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, 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 S = eval(input()) N = len(S) for i in range(-(-N // 2)): if S[i * 2] == "L": print("No") exit() for i in range(N // 2): if S[i * 2 + 1] == "R": print("No") exit() print("Yes")
false
10.25641
[ "-if N % 2 == 1:", "- if S[N - 1] == \"L\":", "- print(\"No\")", "- exit()" ]
false
0.037937
0.037225
1.019111
[ "s356524406", "s908700915" ]
u347640436
p02607
python
s724576702
s197838510
29
26
9,100
8,876
Accepted
Accepted
10.34
N = int(eval(input())) a = list(map(int, input().split())) result = 0 for i in range(N): if (i + 1) % 2 == 1 and a[i] % 2 == 1: result += 1 print(result)
N, *a = list(map(int, open(0).read().split())) print((sum(1 for e in a[::2] if e % 2 == 1)))
8
3
168
88
N = int(eval(input())) a = list(map(int, input().split())) result = 0 for i in range(N): if (i + 1) % 2 == 1 and a[i] % 2 == 1: result += 1 print(result)
N, *a = list(map(int, open(0).read().split())) print((sum(1 for e in a[::2] if e % 2 == 1)))
false
62.5
[ "-N = int(eval(input()))", "-a = list(map(int, input().split()))", "-result = 0", "-for i in range(N):", "- if (i + 1) % 2 == 1 and a[i] % 2 == 1:", "- result += 1", "-print(result)", "+N, *a = list(map(int, open(0).read().split()))", "+print((sum(1 for e in a[::2] if e % 2 == 1)))" ]
false
0.039153
0.040067
0.977207
[ "s724576702", "s197838510" ]
u130900604
p02678
python
s235616395
s588805951
525
404
100,628
95,688
Accepted
Accepted
23.05
def LI():return list(map(int,input().split())) def yes():print("Yes") def no():print("No") from collections import deque def main(): n,m=LI() edge=[[]for i in range(n)] for i in range(m): a,b=LI() edge[a-1]+=b-1, edge[b-1]+=a-1, dq=deque([0]) ans=[-1]*n while dq: g=dq.popleft() for i in edge[g]: if ans[i]==-1: ans[i]=g+1 dq.append(i) yes() print((*ans[1:])) main()
from collections import deque def main(): n,m=list(map(int,input().split())) e=[[] for _ in range(n)] for _ in range(m): a,b=list(map(int,input().split())) a-=1 b-=1 e[a].append(b) e[b].append(a) ans=[-1]*n dq=deque([0]) while dq: g=dq.popleft() for v in e[g]: if ans[v]==-1: ans[v]=g+1 dq.append(v) ans[0]="Yes" print((*ans)) main()
23
21
451
408
def LI(): return list(map(int, input().split())) def yes(): print("Yes") def no(): print("No") from collections import deque def main(): n, m = LI() edge = [[] for i in range(n)] for i in range(m): a, b = LI() edge[a - 1] += (b - 1,) edge[b - 1] += (a - 1,) dq = deque([0]) ans = [-1] * n while dq: g = dq.popleft() for i in edge[g]: if ans[i] == -1: ans[i] = g + 1 dq.append(i) yes() print((*ans[1:])) main()
from collections import deque def main(): n, m = list(map(int, input().split())) e = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 e[a].append(b) e[b].append(a) ans = [-1] * n dq = deque([0]) while dq: g = dq.popleft() for v in e[g]: if ans[v] == -1: ans[v] = g + 1 dq.append(v) ans[0] = "Yes" print((*ans)) main()
false
8.695652
[ "-def LI():", "- return list(map(int, input().split()))", "-", "-", "-def yes():", "- print(\"Yes\")", "-", "-", "-def no():", "- print(\"No\")", "-", "-", "- n, m = LI()", "- edge = [[] for i in range(n)]", "- for i in range(m):", "- a, b = LI()", "- ...
false
0.044144
0.039251
1.124635
[ "s235616395", "s588805951" ]
u923668099
p02241
python
s992055592
s787999177
30
20
7,872
7,804
Accepted
Accepted
33.33
import sys def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def solve(): inf = float('inf') n = int(input()) a = [] for i in range(n): line = [int(i) for i in input().split()] line = [i if i != -1 else inf for i in line] a.append(line) checked = [False] * n d = [inf] * n d[0] = 0 checked[0] = True ans = 0 nxt = 0 for i in range(n - 1): for j in range(n): if a[nxt][j] < d[j]: d[j] = a[nxt][j] min_w = inf min_n = 0 for j in range(n): if not checked[j] and d[j] < min_w: min_n = j min_w = d[j] checked[min_n] = True nxt = min_n ans += min_w # debug(d, locals()) print(ans) if __name__ == '__main__': solve()
import sys inf = float('inf') def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def prim(n, As): checked = [False] * n d = [inf] * n checked[0] = True d[0] = 0 nxt = 0 tot_wgt = 0 for i in range(n - 1): for j in range(n): if As[nxt][j] < d[j]: d[j] = As[nxt][j] min_w = inf min_n = 0 for j in range(n): if not checked[j] and min_w > d[j]: min_w = d[j] min_n = j tot_wgt += min_w nxt = min_n checked[nxt] = True return tot_wgt def solve(): n = int(input()) As = [] for i in range(n): line = [int(j) for j in input().split()] As.append([i if i != -1 else inf for i in line]) ans = prim(n, As) print(ans) if __name__ == '__main__': solve()
50
51
1,006
1,022
import sys def debug(x, table): for name, val in table.items(): if x is val: print("DEBUG:{} -> {}".format(name, val), file=sys.stderr) return None def solve(): inf = float("inf") n = int(input()) a = [] for i in range(n): line = [int(i) for i in input().split()] line = [i if i != -1 else inf for i in line] a.append(line) checked = [False] * n d = [inf] * n d[0] = 0 checked[0] = True ans = 0 nxt = 0 for i in range(n - 1): for j in range(n): if a[nxt][j] < d[j]: d[j] = a[nxt][j] min_w = inf min_n = 0 for j in range(n): if not checked[j] and d[j] < min_w: min_n = j min_w = d[j] checked[min_n] = True nxt = min_n ans += min_w # debug(d, locals()) print(ans) if __name__ == "__main__": solve()
import sys inf = float("inf") def debug(x, table): for name, val in table.items(): if x is val: print("DEBUG:{} -> {}".format(name, val), file=sys.stderr) return None def prim(n, As): checked = [False] * n d = [inf] * n checked[0] = True d[0] = 0 nxt = 0 tot_wgt = 0 for i in range(n - 1): for j in range(n): if As[nxt][j] < d[j]: d[j] = As[nxt][j] min_w = inf min_n = 0 for j in range(n): if not checked[j] and min_w > d[j]: min_w = d[j] min_n = j tot_wgt += min_w nxt = min_n checked[nxt] = True return tot_wgt def solve(): n = int(input()) As = [] for i in range(n): line = [int(j) for j in input().split()] As.append([i if i != -1 else inf for i in line]) ans = prim(n, As) print(ans) if __name__ == "__main__": solve()
false
1.960784
[ "+", "+inf = float(\"inf\")", "-def solve():", "- inf = float(\"inf\")", "- n = int(input())", "- a = []", "- for i in range(n):", "- line = [int(i) for i in input().split()]", "- line = [i if i != -1 else inf for i in line]", "- a.append(line)", "+def prim(n, As...
false
0.081242
0.062463
1.300656
[ "s992055592", "s787999177" ]
u089230684
p02772
python
s317199207
s441912689
170
17
38,256
2,940
Accepted
Accepted
90
n = int(eval(input())) A = list(map(int, input().split())) ret = 'APPROVED' for a in A: if a % 2 == 1: continue if a % 3 == 0 or a % 5 == 0: continue ret = 'DENIED' break print(ret)
n = int (eval(input ())) a = list (map (int, input ().split ())) flag = True for k in a: if (k & 1 == 0 and k % 3 != 0 and k % 5 != 0): flag = False print(("APPROVED" if flag else "DENIED"))
11
8
202
203
n = int(eval(input())) A = list(map(int, input().split())) ret = "APPROVED" for a in A: if a % 2 == 1: continue if a % 3 == 0 or a % 5 == 0: continue ret = "DENIED" break print(ret)
n = int(eval(input())) a = list(map(int, input().split())) flag = True for k in a: if k & 1 == 0 and k % 3 != 0 and k % 5 != 0: flag = False print(("APPROVED" if flag else "DENIED"))
false
27.272727
[ "-A = list(map(int, input().split()))", "-ret = \"APPROVED\"", "-for a in A:", "- if a % 2 == 1:", "- continue", "- if a % 3 == 0 or a % 5 == 0:", "- continue", "- ret = \"DENIED\"", "- break", "-print(ret)", "+a = list(map(int, input().split()))", "+flag = True", "...
false
0.04392
0.037426
1.17352
[ "s317199207", "s441912689" ]
u654470292
p02767
python
s094516202
s217087928
290
77
65,644
70,656
Accepted
Accepted
73.45
import sys from collections import * import heapq import math import bisect from itertools import permutations,accumulate,combinations,product from fractions import gcd def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0]+list(accumulate(lst)) mod=pow(10,9)+7 n=int(eval(input())) x=list(map(int,input().split())) ans=float('inf') for i in range(100): tmp=0 for j in range(n): tmp+=(x[j]-i-1)**2 ans=min(ans,tmp) print(ans)
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())) x=list(map(int,input().split())) ans=float('inf') for i in range(100): tmp=0 for j in range(n): tmp+=(x[j]-i-1)**2 ans=min(ans,tmp) print(ans)
22
25
489
636
import sys from collections import * import heapq import math import bisect from itertools import permutations, accumulate, combinations, product from fractions import gcd def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0] + list(accumulate(lst)) mod = pow(10, 9) + 7 n = int(eval(input())) x = list(map(int, input().split())) ans = float("inf") for i in range(100): tmp = 0 for j in range(n): tmp += (x[j] - i - 1) ** 2 ans = min(ans, tmp) print(ans)
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())) x = list(map(int, input().split())) ans = float("inf") for i in range(100): tmp = 0 for j in range(n): tmp += (x[j] - i - 1) ** 2 ans = min(ans, tmp) print(ans)
false
12
[ "-import sys", "+import bisect, copy, heapq, math, sys", "-import heapq", "-import math", "-import bisect", "-from itertools import permutations, accumulate, combinations, product", "-from fractions import gcd", "+from functools import lru_cache", "+from itertools import accumulate, combinations, pe...
false
0.060884
0.037242
1.634805
[ "s094516202", "s217087928" ]
u747515887
p02952
python
s143133313
s825276696
52
37
2,940
2,940
Accepted
Accepted
28.85
def main(): n = int(eval(input())) c = 0 for i in range(n + 1)[1:]: if len(str(i)) % 2 == 1: c += 1 print(c) if __name__ == '__main__': main()
def main(): n = int(eval(input())) c = 0 for i in range(n + 1)[1:]: if (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999): c += 1 print(c) if __name__ == '__main__': main()
13
13
193
250
def main(): n = int(eval(input())) c = 0 for i in range(n + 1)[1:]: if len(str(i)) % 2 == 1: c += 1 print(c) if __name__ == "__main__": main()
def main(): n = int(eval(input())) c = 0 for i in range(n + 1)[1:]: if ( (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999) ): c += 1 print(c) if __name__ == "__main__": main()
false
0
[ "- if len(str(i)) % 2 == 1:", "+ if (", "+ (1 <= i and i <= 9)", "+ or (100 <= i and i <= 999)", "+ or (10000 <= i and i <= 99999)", "+ ):" ]
false
0.053676
0.050918
1.05417
[ "s143133313", "s825276696" ]
u227550284
p02700
python
s757487105
s106266077
22
20
9,176
9,068
Accepted
Accepted
9.09
import sys input = sys.stdin.readline def main(): a, b, c, d = list(map(int, input().split())) flg = False while a > 0 and b > 0: c -= b if c > 0: a -= d else: flg = True break if flg == False: print('No') else: print('Yes') if __name__ == '__main__': main()
a, b, c, d = list(map(int, input().split())) x = (a+d-1)//d y = (c+b-1)//b print(('Yes' if x >= y else 'No'))
26
7
386
111
import sys input = sys.stdin.readline def main(): a, b, c, d = list(map(int, input().split())) flg = False while a > 0 and b > 0: c -= b if c > 0: a -= d else: flg = True break if flg == False: print("No") else: print("Yes") if __name__ == "__main__": main()
a, b, c, d = list(map(int, input().split())) x = (a + d - 1) // d y = (c + b - 1) // b print(("Yes" if x >= y else "No"))
false
73.076923
[ "-import sys", "-", "-input = sys.stdin.readline", "-", "-", "-def main():", "- a, b, c, d = list(map(int, input().split()))", "- flg = False", "- while a > 0 and b > 0:", "- c -= b", "- if c > 0:", "- a -= d", "- else:", "- flg = True", ...
false
0.16412
0.045525
3.605087
[ "s757487105", "s106266077" ]
u281303342
p03380
python
s369461771
s961854743
92
77
14,428
14,060
Accepted
Accepted
16.3
N = int(eval(input())) A = list(map(int,input().split())) maxA = max(A) half = maxA/2 t = 10000000000 for i in range(N): if A[i] != maxA and abs(A[i]-half) < abs(t-half): t = A[i] print((maxA,t))
N = int(eval(input())) A = list(map(int,input().split())) maxA = max(A) half = maxA/2 diff = 10**10 ans = 0 for i in range(N): if A[i] != maxA and abs(A[i]-half) < diff: diff = abs(A[i]-half) ans = A[i] print((maxA, ans))
9
13
207
247
N = int(eval(input())) A = list(map(int, input().split())) maxA = max(A) half = maxA / 2 t = 10000000000 for i in range(N): if A[i] != maxA and abs(A[i] - half) < abs(t - half): t = A[i] print((maxA, t))
N = int(eval(input())) A = list(map(int, input().split())) maxA = max(A) half = maxA / 2 diff = 10**10 ans = 0 for i in range(N): if A[i] != maxA and abs(A[i] - half) < diff: diff = abs(A[i] - half) ans = A[i] print((maxA, ans))
false
30.769231
[ "-t = 10000000000", "+diff = 10**10", "+ans = 0", "- if A[i] != maxA and abs(A[i] - half) < abs(t - half):", "- t = A[i]", "-print((maxA, t))", "+ if A[i] != maxA and abs(A[i] - half) < diff:", "+ diff = abs(A[i] - half)", "+ ans = A[i]", "+print((maxA, ans))" ]
false
0.042985
0.106392
0.404024
[ "s369461771", "s961854743" ]
u781262926
p03645
python
s873672499
s946589451
664
169
37,168
56,536
Accepted
Accepted
74.55
n, m = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(m)] C, D = set(), set() for a, b in AB: if a == 1: C.add(b) elif b == n: D.add(a) if len(C & D): print('POSSIBLE') else: print('IMPOSSIBLE')
n, m, *AB = list(map(int, open(0).read().split())) C, D = set(), set() for a, b in zip(AB[::2], AB[1::2]): if a == 1: C.add(b) if b == n: D.add(a) if len(C & D): print('POSSIBLE') else: print('IMPOSSIBLE')
14
13
258
229
n, m = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(m)] C, D = set(), set() for a, b in AB: if a == 1: C.add(b) elif b == n: D.add(a) if len(C & D): print("POSSIBLE") else: print("IMPOSSIBLE")
n, m, *AB = list(map(int, open(0).read().split())) C, D = set(), set() for a, b in zip(AB[::2], AB[1::2]): if a == 1: C.add(b) if b == n: D.add(a) if len(C & D): print("POSSIBLE") else: print("IMPOSSIBLE")
false
7.142857
[ "-n, m = list(map(int, input().split()))", "-AB = [tuple(map(int, input().split())) for _ in range(m)]", "+n, m, *AB = list(map(int, open(0).read().split()))", "-for a, b in AB:", "+for a, b in zip(AB[::2], AB[1::2]):", "- elif b == n:", "+ if b == n:" ]
false
0.039699
0.040105
0.989878
[ "s873672499", "s946589451" ]
u459689470
p03087
python
s439884076
s965191711
934
500
7,748
15,788
Accepted
Accepted
46.47
n, q = (int(x) for x in input().split()) s = eval(input()) t = [0]*(n+1) for i in range(n): t[i+1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0) for i in range(q): l,r = (int(x) for x in input().split()) print((t[r-1]-t[l-1]))
n, q = (int(x) for x in input().split()) s = (eval(input())) l = [0]*q r = [0]*q t = [0]*n for i in range(q): l[i], r[i] = (int(x) for x in input().split()) for i in range(n-1): t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0) for i in range(q): print((t[r[i]-1] - t[l[i]-1]))
8
13
229
292
n, q = (int(x) for x in input().split()) s = eval(input()) t = [0] * (n + 1) for i in range(n): t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0) for i in range(q): l, r = (int(x) for x in input().split()) print((t[r - 1] - t[l - 1]))
n, q = (int(x) for x in input().split()) s = eval(input()) l = [0] * q r = [0] * q t = [0] * n for i in range(q): l[i], r[i] = (int(x) for x in input().split()) for i in range(n - 1): t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0) for i in range(q): print((t[r[i] - 1] - t[l[i] - 1]))
false
38.461538
[ "-t = [0] * (n + 1)", "-for i in range(n):", "+l = [0] * q", "+r = [0] * q", "+t = [0] * n", "+for i in range(q):", "+ l[i], r[i] = (int(x) for x in input().split())", "+for i in range(n - 1):", "- l, r = (int(x) for x in input().split())", "- print((t[r - 1] - t[l - 1]))", "+ print(...
false
0.087305
0.075729
1.152862
[ "s439884076", "s965191711" ]
u595375942
p03160
python
s690343811
s594566877
136
124
13,924
13,900
Accepted
Accepted
8.82
n=int(eval(input())) H=list(map(int,input().split())) dp=[10**9]*n dp[0]=0 dp[1]=abs(H[1]-H[0]) for i in range(2,n): step1=dp[i-1]+abs(H[i]-H[i-1]) step2=dp[i-2]+abs(H[i]-H[i-2]) dp[i]=min(step1,step2) print((dp[-1]))
N = int(eval(input())) H = list(map(int, input().split())) DP = [0]*N DP[1] = abs(H[1]-H[0]) for i in range(2, N): two = abs(H[i]-H[i-2]) one = abs(H[i]-H[i-1]) if DP[i-2]+two <= DP[i-1]+one: DP[i] = DP[i-2]+two else: DP[i] = DP[i-1]+one print((DP[-1]))
10
15
230
294
n = int(eval(input())) H = list(map(int, input().split())) dp = [10**9] * n dp[0] = 0 dp[1] = abs(H[1] - H[0]) for i in range(2, n): step1 = dp[i - 1] + abs(H[i] - H[i - 1]) step2 = dp[i - 2] + abs(H[i] - H[i - 2]) dp[i] = min(step1, step2) print((dp[-1]))
N = int(eval(input())) H = list(map(int, input().split())) DP = [0] * N DP[1] = abs(H[1] - H[0]) for i in range(2, N): two = abs(H[i] - H[i - 2]) one = abs(H[i] - H[i - 1]) if DP[i - 2] + two <= DP[i - 1] + one: DP[i] = DP[i - 2] + two else: DP[i] = DP[i - 1] + one print((DP[-1]))
false
33.333333
[ "-n = int(eval(input()))", "+N = int(eval(input()))", "-dp = [10**9] * n", "-dp[0] = 0", "-dp[1] = abs(H[1] - H[0])", "-for i in range(2, n):", "- step1 = dp[i - 1] + abs(H[i] - H[i - 1])", "- step2 = dp[i - 2] + abs(H[i] - H[i - 2])", "- dp[i] = min(step1, step2)", "-print((dp[-1]))", ...
false
0.082922
0.089197
0.929647
[ "s690343811", "s594566877" ]
u508486691
p02821
python
s568343837
s375796945
993
646
55,528
35,928
Accepted
Accepted
34.94
import sys import math from collections import defaultdict sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def II(): return list(map(int, input().split())) def III(): return list(map(int, input().split())) def Line(N,num): if N<=0: return [[] for _ in range(num)] elif num==1: return [I() for _ in range(N)] else: read_all = [tuple(II()) for _ in range(N)] return list(map(list, list(zip(*read_all)))) ################# # FFT # use python3 # a = np.array([a1,a2,a3]), b= np.array([b1,b2,b3]) # c = np.array([a1b1,a1b2+a2b1,a1a3+a2b2+a3b1,a2b3+a3b2,a3b3]) import numpy as np def FFT(a,b): bit = (len(a)+len(b)).bit_length()+1 L = 2**bit fa,fb = np.fft.rfft(a,L), np.fft.rfft(b,L) c = np.rint(np.fft.irfft(fa*fb,L)).astype(np.int64) return c[:len(a)+len(b)-1] N,M = II() A = III() h = [0]*(max(A)) for a in A: h[a-1] += 1 conv = np.append([0,0],FFT(h,h)) ans = 0 count = 0 for k in range(2,2*max(A)+1)[::-1]: if conv[k]: num = min(M-count,conv[k]) count += num ans += k*num if count==M: break print(ans)
import sys import math from collections import defaultdict sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def II(): return list(map(int, input().split())) def III(): return list(map(int, input().split())) def Line(N,num): if N<=0: return [[] for _ in range(num)] elif num==1: return [I() for _ in range(N)] else: read_all = [tuple(II()) for _ in range(N)] return list(map(list, list(zip(*read_all)))) ################# # FFT # use python3 # a = [a1,a2,a3], b= [b1,b2,b3] # return np.array([a1b1,a1b2+a2b1,a1a3+a2b2+a3b1,a2b3+a3b2,a3b3]) import numpy as np def Convolution(a,b): bit = (len(a)+len(b)-2).bit_length() L = 2**bit fa,fb = np.fft.rfft(a,L), np.fft.rfft(b,L) c = np.rint(np.fft.irfft(fa*fb,L)).astype(np.int64) return c[:len(a)+len(b)-1] N,M = II() A = III() h = [0]*(max(A)) for a in A: h[a-1] += 1 conv = np.append([0,0],Convolution(h,h)) ans = 0 for k in range(2,2*max(A)+1)[::-1]: if conv[k]<M: ans += k*conv[k] M -= conv[k] else: ans += k*M break print(ans)
56
54
1,232
1,209
import sys import math from collections import defaultdict sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def II(): return list(map(int, input().split())) def III(): return list(map(int, input().split())) def Line(N, num): if N <= 0: return [[] for _ in range(num)] elif num == 1: return [I() for _ in range(N)] else: read_all = [tuple(II()) for _ in range(N)] return list(map(list, list(zip(*read_all)))) ################# # FFT # use python3 # a = np.array([a1,a2,a3]), b= np.array([b1,b2,b3]) # c = np.array([a1b1,a1b2+a2b1,a1a3+a2b2+a3b1,a2b3+a3b2,a3b3]) import numpy as np def FFT(a, b): bit = (len(a) + len(b)).bit_length() + 1 L = 2**bit fa, fb = np.fft.rfft(a, L), np.fft.rfft(b, L) c = np.rint(np.fft.irfft(fa * fb, L)).astype(np.int64) return c[: len(a) + len(b) - 1] N, M = II() A = III() h = [0] * (max(A)) for a in A: h[a - 1] += 1 conv = np.append([0, 0], FFT(h, h)) ans = 0 count = 0 for k in range(2, 2 * max(A) + 1)[::-1]: if conv[k]: num = min(M - count, conv[k]) count += num ans += k * num if count == M: break print(ans)
import sys import math from collections import defaultdict sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def II(): return list(map(int, input().split())) def III(): return list(map(int, input().split())) def Line(N, num): if N <= 0: return [[] for _ in range(num)] elif num == 1: return [I() for _ in range(N)] else: read_all = [tuple(II()) for _ in range(N)] return list(map(list, list(zip(*read_all)))) ################# # FFT # use python3 # a = [a1,a2,a3], b= [b1,b2,b3] # return np.array([a1b1,a1b2+a2b1,a1a3+a2b2+a3b1,a2b3+a3b2,a3b3]) import numpy as np def Convolution(a, b): bit = (len(a) + len(b) - 2).bit_length() L = 2**bit fa, fb = np.fft.rfft(a, L), np.fft.rfft(b, L) c = np.rint(np.fft.irfft(fa * fb, L)).astype(np.int64) return c[: len(a) + len(b) - 1] N, M = II() A = III() h = [0] * (max(A)) for a in A: h[a - 1] += 1 conv = np.append([0, 0], Convolution(h, h)) ans = 0 for k in range(2, 2 * max(A) + 1)[::-1]: if conv[k] < M: ans += k * conv[k] M -= conv[k] else: ans += k * M break print(ans)
false
3.571429
[ "-# a = np.array([a1,a2,a3]), b= np.array([b1,b2,b3])", "-# c = np.array([a1b1,a1b2+a2b1,a1a3+a2b2+a3b1,a2b3+a3b2,a3b3])", "+# a = [a1,a2,a3], b= [b1,b2,b3]", "+# return np.array([a1b1,a1b2+a2b1,a1a3+a2b2+a3b1,a2b3+a3b2,a3b3])", "-def FFT(a, b):", "- bit = (len(a) + len(b)).bit_length() + 1", "+def C...
false
0.792035
0.27678
2.861602
[ "s568343837", "s375796945" ]
u903005414
p02555
python
s628376238
s369604282
31
28
9,148
9,160
Accepted
Accepted
9.68
S = int(eval(input())) if S == 1: print((0)) exit() MOD = 10**9 + 7 A = [0] * (S + 1) A[0] = 1 A[1] = 0 A[2] = 0 cumsum = 1 for i in range(3, len(A)): A[i] = cumsum cumsum += A[i - 2] cumsum %= MOD print((A[-1]))
S = int(eval(input())) if S == 1: print((0)) exit() MOD = 10**9 + 7 A = [0] * (S + 1) A[0] = 1 A[1] = 0 A[2] = 0 cumsum = 1 for i in range(3, len(A)): A[i] = (A[i - 1] + A[i - 3]) % MOD print((A[-1]))
16
14
239
217
S = int(eval(input())) if S == 1: print((0)) exit() MOD = 10**9 + 7 A = [0] * (S + 1) A[0] = 1 A[1] = 0 A[2] = 0 cumsum = 1 for i in range(3, len(A)): A[i] = cumsum cumsum += A[i - 2] cumsum %= MOD print((A[-1]))
S = int(eval(input())) if S == 1: print((0)) exit() MOD = 10**9 + 7 A = [0] * (S + 1) A[0] = 1 A[1] = 0 A[2] = 0 cumsum = 1 for i in range(3, len(A)): A[i] = (A[i - 1] + A[i - 3]) % MOD print((A[-1]))
false
12.5
[ "- A[i] = cumsum", "- cumsum += A[i - 2]", "- cumsum %= MOD", "+ A[i] = (A[i - 1] + A[i - 3]) % MOD" ]
false
0.046772
0.04896
0.955303
[ "s628376238", "s369604282" ]
u553987207
p02861
python
s378058033
s661603354
381
209
12,080
10,664
Accepted
Accepted
45.14
from itertools import permutations from math import sqrt, fsum N = int(eval(input())) towns = [tuple(map(int, input().split())) for _ in range(N)] ds = [] n = 0 for rt in permutations(towns, N): for i in range(1, N): x1, y1 = rt[i-1] x2, y2 = rt[i] d = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) ds.append(d) n += 1 ans = fsum(ds) / n print(ans)
import math N = int(eval(input())) P = [tuple(map(int, input().split())) for _ in range(N)] DONE = (1 << N) - 1 ds = [] todo = [(0, i, (1 << i)) for i in range(N)] while todo: d, i, state = todo.pop() x, y = P[i] for ni in range(N): if state & (1 << ni): continue nx, ny = P[ni] nd = d + math.sqrt((x - nx) ** 2 + (y - ny) ** 2) nstate = state | (1 << ni) if nstate == DONE: ds.append(nd) else: todo.append((nd, ni, nstate)) ans = math.fsum(ds) / len(ds) print(ans)
16
22
390
577
from itertools import permutations from math import sqrt, fsum N = int(eval(input())) towns = [tuple(map(int, input().split())) for _ in range(N)] ds = [] n = 0 for rt in permutations(towns, N): for i in range(1, N): x1, y1 = rt[i - 1] x2, y2 = rt[i] d = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) ds.append(d) n += 1 ans = fsum(ds) / n print(ans)
import math N = int(eval(input())) P = [tuple(map(int, input().split())) for _ in range(N)] DONE = (1 << N) - 1 ds = [] todo = [(0, i, (1 << i)) for i in range(N)] while todo: d, i, state = todo.pop() x, y = P[i] for ni in range(N): if state & (1 << ni): continue nx, ny = P[ni] nd = d + math.sqrt((x - nx) ** 2 + (y - ny) ** 2) nstate = state | (1 << ni) if nstate == DONE: ds.append(nd) else: todo.append((nd, ni, nstate)) ans = math.fsum(ds) / len(ds) print(ans)
false
27.272727
[ "-from itertools import permutations", "-from math import sqrt, fsum", "+import math", "-towns = [tuple(map(int, input().split())) for _ in range(N)]", "+P = [tuple(map(int, input().split())) for _ in range(N)]", "+DONE = (1 << N) - 1", "-n = 0", "-for rt in permutations(towns, N):", "- for i in ...
false
0.062996
0.039618
1.59011
[ "s378058033", "s661603354" ]
u028973125
p02579
python
s748846312
s397305065
1,506
970
222,784
138,528
Accepted
Accepted
35.59
import sys from collections import deque H, W = list(map(int, sys.stdin.readline().split())) cy, cx = list(map(int, sys.stdin.readline().split())) gy, gx = list(map(int, sys.stdin.readline().split())) cy -= 1 cx -= 1 gy -= 1 gx -= 1 grid = [] for _ in range(H): grid.append(sys.stdin.readline().strip()) q = deque() # x, y, 累積移動距離, ブロック通過数, ワープ利用数 q.append((cx, cy, 0)) # visited = {} visited = [[float("inf") for _ in range(W)] for _ in range(H)] # visited[(cx, cy)] = 0 visited[cy][cx] = 0 ans = float("inf") # 01 BFS while q: x, y, c = q.popleft() # if (x, y) in visited and visited[(x, y)] < c: if visited[y][x] < c: # print("here1") continue # print(x, y, c, d, e) for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)): nx = x + dx ny = y + dy if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#": # if (nx, ny) in visited and visited[(nx, ny)] < c + 1: if visited[ny][nx] <= c: # print("here2") continue # visited[(nx, ny)] = c visited[ny][nx] = c if nx == gx and ny == gy: continue q.appendleft((nx, ny, c)) for dx in range(-2, 3): for dy in range(-2, 3): if abs(dx) == 1 and dy == 0 or abs(dy) == 1 and dx == 0: continue nx = x + dx ny = y + dy # print("warp", dx, dy) if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#": # print("warp append") # if (nx, ny) in visited and visited[(nx, ny)] < c + 1: if visited[ny][nx] < c + 1: # print("here3") continue # visited[(nx, ny)] = c + 1 visited[ny][nx] = c + 1 if nx == gx and ny == gy: continue q.append((nx, ny, c+1)) # print(visited) if visited[gy][gx] == float("inf"): print((-1)) else: print((visited[gy][gx]))
import sys from collections import deque H, W = list(map(int, sys.stdin.readline().split())) cy, cx = list(map(int, sys.stdin.readline().split())) gy, gx = list(map(int, sys.stdin.readline().split())) cy -= 1 cx -= 1 gy -= 1 gx -= 1 grid = [] for _ in range(H): grid.append(sys.stdin.readline().strip()) q = deque() q2 = set() # x, y, 累積移動距離, ブロック通過数, ワープ利用数 q.append((cx, cy, 0)) # visited = {} visited = [[float("inf") for _ in range(W)] for _ in range(H)] # visited[(cx, cy)] = 0 visited[cy][cx] = 0 ans = float("inf") # 01 BFS while q: while q: x, y, c = q.popleft() # if (x, y) in visited and visited[(x, y)] < c: if visited[y][x] < c: # print("here1") continue # print(x, y, c, d, e) for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)): nx = x + dx ny = y + dy if 0 <= nx < W and 0 <= ny < H: if grid[ny][nx] == "#": q2.add((x, y, c)) else: # if (nx, ny) in visited and visited[(nx, ny)] < c + 1: if visited[ny][nx] <= c: # print("here2") continue # visited[(nx, ny)] = c visited[ny][nx] = c if nx == gx and ny == gy: continue q.append((nx, ny, c)) for x, y, c in q2: for dx in range(-2, 3): for dy in range(-2, 3): if abs(dx) == 1 and dy == 0 or abs(dy) == 1 and dx == 0: continue nx = x + dx ny = y + dy # print("warp", dx, dy) if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#": # print("warp append") # if (nx, ny) in visited and visited[(nx, ny)] < c + 1: if visited[ny][nx] < c + 1: # print("here3") continue # visited[(nx, ny)] = c + 1 visited[ny][nx] = c + 1 if nx == gx and ny == gy: continue q.append((nx, ny, c+1)) q2 = set() # print(visited) if visited[gy][gx] == float("inf"): print((-1)) else: print((visited[gy][gx]))
68
77
2,070
2,399
import sys from collections import deque H, W = list(map(int, sys.stdin.readline().split())) cy, cx = list(map(int, sys.stdin.readline().split())) gy, gx = list(map(int, sys.stdin.readline().split())) cy -= 1 cx -= 1 gy -= 1 gx -= 1 grid = [] for _ in range(H): grid.append(sys.stdin.readline().strip()) q = deque() # x, y, 累積移動距離, ブロック通過数, ワープ利用数 q.append((cx, cy, 0)) # visited = {} visited = [[float("inf") for _ in range(W)] for _ in range(H)] # visited[(cx, cy)] = 0 visited[cy][cx] = 0 ans = float("inf") # 01 BFS while q: x, y, c = q.popleft() # if (x, y) in visited and visited[(x, y)] < c: if visited[y][x] < c: # print("here1") continue # print(x, y, c, d, e) for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)): nx = x + dx ny = y + dy if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#": # if (nx, ny) in visited and visited[(nx, ny)] < c + 1: if visited[ny][nx] <= c: # print("here2") continue # visited[(nx, ny)] = c visited[ny][nx] = c if nx == gx and ny == gy: continue q.appendleft((nx, ny, c)) for dx in range(-2, 3): for dy in range(-2, 3): if abs(dx) == 1 and dy == 0 or abs(dy) == 1 and dx == 0: continue nx = x + dx ny = y + dy # print("warp", dx, dy) if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#": # print("warp append") # if (nx, ny) in visited and visited[(nx, ny)] < c + 1: if visited[ny][nx] < c + 1: # print("here3") continue # visited[(nx, ny)] = c + 1 visited[ny][nx] = c + 1 if nx == gx and ny == gy: continue q.append((nx, ny, c + 1)) # print(visited) if visited[gy][gx] == float("inf"): print((-1)) else: print((visited[gy][gx]))
import sys from collections import deque H, W = list(map(int, sys.stdin.readline().split())) cy, cx = list(map(int, sys.stdin.readline().split())) gy, gx = list(map(int, sys.stdin.readline().split())) cy -= 1 cx -= 1 gy -= 1 gx -= 1 grid = [] for _ in range(H): grid.append(sys.stdin.readline().strip()) q = deque() q2 = set() # x, y, 累積移動距離, ブロック通過数, ワープ利用数 q.append((cx, cy, 0)) # visited = {} visited = [[float("inf") for _ in range(W)] for _ in range(H)] # visited[(cx, cy)] = 0 visited[cy][cx] = 0 ans = float("inf") # 01 BFS while q: while q: x, y, c = q.popleft() # if (x, y) in visited and visited[(x, y)] < c: if visited[y][x] < c: # print("here1") continue # print(x, y, c, d, e) for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)): nx = x + dx ny = y + dy if 0 <= nx < W and 0 <= ny < H: if grid[ny][nx] == "#": q2.add((x, y, c)) else: # if (nx, ny) in visited and visited[(nx, ny)] < c + 1: if visited[ny][nx] <= c: # print("here2") continue # visited[(nx, ny)] = c visited[ny][nx] = c if nx == gx and ny == gy: continue q.append((nx, ny, c)) for x, y, c in q2: for dx in range(-2, 3): for dy in range(-2, 3): if abs(dx) == 1 and dy == 0 or abs(dy) == 1 and dx == 0: continue nx = x + dx ny = y + dy # print("warp", dx, dy) if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#": # print("warp append") # if (nx, ny) in visited and visited[(nx, ny)] < c + 1: if visited[ny][nx] < c + 1: # print("here3") continue # visited[(nx, ny)] = c + 1 visited[ny][nx] = c + 1 if nx == gx and ny == gy: continue q.append((nx, ny, c + 1)) q2 = set() # print(visited) if visited[gy][gx] == float("inf"): print((-1)) else: print((visited[gy][gx]))
false
11.688312
[ "+q2 = set()", "- x, y, c = q.popleft()", "- # if (x, y) in visited and visited[(x, y)] < c:", "- if visited[y][x] < c:", "- # print(\"here1\")", "- continue", "- # print(x, y, c, d, e)", "- for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):", "- nx = x + dx", "-...
false
0.037323
0.007116
5.24465
[ "s748846312", "s397305065" ]
u647087591
p02683
python
s534887638
s802346640
140
96
73,748
74,264
Accepted
Accepted
31.43
n, m, x = list(map(int, input().split())) cl = [] al = [] for _ in range(n): c, *a = list(map(int, input().split())) cl.append(c) al.append(a) ans = float('inf') for i in range(2 ** n): sum = 0 l = [0] * m flg = False for j in range(n): if i >> j & 1: sum += cl[j] for k in range(m): l[k] += al[j][k] for e in l: if e < x: flg = True break if not flg: ans = min(ans, sum) print((-1 if ans == float('inf') else ans))
n, m, x = list(map(int, input().split())) cl = [] al = [] for _ in range(n): c, *a = list(map(int, input().split())) cl.append(c) al.append(a) ans = float('inf') for i in range(2 ** n): sum = 0 l = [0] * m for j in range(n): if i >> j & 1: sum += cl[j] for k in range(m): l[k] += al[j][k] flg = all([e >= x for e in l]) if flg: ans = min(ans, sum) print((-1 if ans == float('inf') else ans))
30
26
560
496
n, m, x = list(map(int, input().split())) cl = [] al = [] for _ in range(n): c, *a = list(map(int, input().split())) cl.append(c) al.append(a) ans = float("inf") for i in range(2**n): sum = 0 l = [0] * m flg = False for j in range(n): if i >> j & 1: sum += cl[j] for k in range(m): l[k] += al[j][k] for e in l: if e < x: flg = True break if not flg: ans = min(ans, sum) print((-1 if ans == float("inf") else ans))
n, m, x = list(map(int, input().split())) cl = [] al = [] for _ in range(n): c, *a = list(map(int, input().split())) cl.append(c) al.append(a) ans = float("inf") for i in range(2**n): sum = 0 l = [0] * m for j in range(n): if i >> j & 1: sum += cl[j] for k in range(m): l[k] += al[j][k] flg = all([e >= x for e in l]) if flg: ans = min(ans, sum) print((-1 if ans == float("inf") else ans))
false
13.333333
[ "- flg = False", "- for e in l:", "- if e < x:", "- flg = True", "- break", "- if not flg:", "+ flg = all([e >= x for e in l])", "+ if flg:" ]
false
0.110574
0.095983
1.152023
[ "s534887638", "s802346640" ]
u063052907
p02971
python
s360431752
s216875946
526
295
14,112
14,112
Accepted
Accepted
43.92
N = int(eval(input())) lst_A = [int(eval(input())) for _ in range(N)] srt_A = sorted(lst_A, reverse=True) m1 = srt_A[0] m2 = srt_A[1] for v in lst_A: print((m2 if v == m1 else m1))
import sys input = sys.stdin.readline N = int(eval(input())) lst_A = [int(eval(input())) for _ in range(N)] srt_A = sorted(lst_A, reverse=True) m1 = srt_A[0] m2 = srt_A[1] for v in lst_A: print((m2 if v == m1 else m1))
9
13
180
224
N = int(eval(input())) lst_A = [int(eval(input())) for _ in range(N)] srt_A = sorted(lst_A, reverse=True) m1 = srt_A[0] m2 = srt_A[1] for v in lst_A: print((m2 if v == m1 else m1))
import sys input = sys.stdin.readline N = int(eval(input())) lst_A = [int(eval(input())) for _ in range(N)] srt_A = sorted(lst_A, reverse=True) m1 = srt_A[0] m2 = srt_A[1] for v in lst_A: print((m2 if v == m1 else m1))
false
30.769231
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.034577
0.043635
0.79241
[ "s360431752", "s216875946" ]
u969850098
p03073
python
s965107188
s643852514
65
50
4,652
4,652
Accepted
Accepted
23.08
S = list(map(int, list(eval(input())))) colors = [0, 1] cnt_b, cnt_w = 0, 0 b_list = [colors[i % 2] for i in range(len(S))] for i in range(len(S)): if S[i] == b_list[i]: cnt_w += 1 else: cnt_b += 1 print((min([cnt_w, cnt_b])))
def main(): S = list(map(int, list(eval(input())))) cnt1, cnt2 = 0, 0 for i, s in enumerate(S): if i % 2 == 0: if s: cnt1 += 1 else: cnt2 += 1 else: if s: cnt2 += 1 else: cnt1 += 1 print((min(cnt1, cnt2))) if __name__ == '__main__': main()
12
19
263
399
S = list(map(int, list(eval(input())))) colors = [0, 1] cnt_b, cnt_w = 0, 0 b_list = [colors[i % 2] for i in range(len(S))] for i in range(len(S)): if S[i] == b_list[i]: cnt_w += 1 else: cnt_b += 1 print((min([cnt_w, cnt_b])))
def main(): S = list(map(int, list(eval(input())))) cnt1, cnt2 = 0, 0 for i, s in enumerate(S): if i % 2 == 0: if s: cnt1 += 1 else: cnt2 += 1 else: if s: cnt2 += 1 else: cnt1 += 1 print((min(cnt1, cnt2))) if __name__ == "__main__": main()
false
36.842105
[ "-S = list(map(int, list(eval(input()))))", "-colors = [0, 1]", "-cnt_b, cnt_w = 0, 0", "-b_list = [colors[i % 2] for i in range(len(S))]", "-for i in range(len(S)):", "- if S[i] == b_list[i]:", "- cnt_w += 1", "- else:", "- cnt_b += 1", "-print((min([cnt_w, cnt_b])))", "+def...
false
0.087602
0.104125
0.841321
[ "s965107188", "s643852514" ]
u678505520
p02983
python
s876777221
s267244047
158
68
65,192
65,256
Accepted
Accepted
56.96
l,r=list(map(int,input().split())) if r - l >= 2018: print((0)) exit() l %= 2019 r %= 2019 m=10000 for i in range(l,r): for j in range(i+1,r+1): m = min(m,(i*j)%2019) print(m)
l,r=list(map(int,input().split())) if r - l >= 2018: print((0)) exit() m=10000 for i in range(l,r): for j in range(i+1,r+1): m = min(m,(i*j)%2019) print(m)
13
11
201
179
l, r = list(map(int, input().split())) if r - l >= 2018: print((0)) exit() l %= 2019 r %= 2019 m = 10000 for i in range(l, r): for j in range(i + 1, r + 1): m = min(m, (i * j) % 2019) print(m)
l, r = list(map(int, input().split())) if r - l >= 2018: print((0)) exit() m = 10000 for i in range(l, r): for j in range(i + 1, r + 1): m = min(m, (i * j) % 2019) print(m)
false
15.384615
[ "-l %= 2019", "-r %= 2019" ]
false
0.041605
0.048939
0.850146
[ "s876777221", "s267244047" ]
u191874006
p03273
python
s532469562
s306232098
261
175
44,780
39,408
Accepted
Accepted
32.95
#!/usr/bin/env python3 #ABC107 B h,w = list(map(int,input().split())) a = [list(eval(input())) for _ in range(h)] ans = [['.']*w for _ in range(h)] for i in range(h): for j in range(w): if a[i][j] == '.': for k in range(h): if a[k][j] == '.': continue else: break else: for k in range(h): ans[k][j] = None for k in range(w): if a[i][k] == '.': continue else: break else: for k in range(w): ans[i][k] = None if a[i][j] == '#': ans[i][j] = '#' for i in range(h): ans[i] = [i for i in ans[i] if i] for i in range(h): if len(ans[i]) != 0: print((''.join(ans[i])))
#!/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())) h,w = LI() a = [eval(input()) for _ in range(h)] check_h = [True]*h check_w = [True]*w for i in range(h): for j in range(w): if a[i][j] == '#': break else: check_h[i] = False for i in range(w): for j in range(h): if a[j][i] == '#': break else: check_w[i] = False ans = [] for i in range(h): if check_h[i]: s = '' for j in range(w): if check_w[j]: s += a[i][j] ans.append(s) for i in ans: print(i)
33
46
892
1,109
#!/usr/bin/env python3 # ABC107 B h, w = list(map(int, input().split())) a = [list(eval(input())) for _ in range(h)] ans = [["."] * w for _ in range(h)] for i in range(h): for j in range(w): if a[i][j] == ".": for k in range(h): if a[k][j] == ".": continue else: break else: for k in range(h): ans[k][j] = None for k in range(w): if a[i][k] == ".": continue else: break else: for k in range(w): ans[i][k] = None if a[i][j] == "#": ans[i][j] = "#" for i in range(h): ans[i] = [i for i in ans[i] if i] for i in range(h): if len(ans[i]) != 0: print(("".join(ans[i])))
#!/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())) h, w = LI() a = [eval(input()) for _ in range(h)] check_h = [True] * h check_w = [True] * w for i in range(h): for j in range(w): if a[i][j] == "#": break else: check_h[i] = False for i in range(w): for j in range(h): if a[j][i] == "#": break else: check_w[i] = False ans = [] for i in range(h): if check_h[i]: s = "" for j in range(w): if check_w[j]: s += a[i][j] ans.append(s) for i in ans: print(i)
false
28.26087
[ "-# ABC107 B", "-h, w = list(map(int, input().split()))", "-a = [list(eval(input())) for _ in range(h)]", "-ans = [[\".\"] * w for _ in range(h)]", "+import sys", "+import math", "+from bisect import bisect_right as br", "+from bisect import bisect_left as bl", "+", "+sys.setrecursionlimit(2147483...
false
0.036149
0.044925
0.804648
[ "s532469562", "s306232098" ]
u634873566
p02712
python
s066253490
s943569468
137
95
43,348
9,064
Accepted
Accepted
30.66
print((sum(set(i for i in range(1,int(eval(input()))+1,1) if not(i%3==0 or i%5==0)))))
print((sum((i for i in range(int(eval(input()))+1) if i%3 and i%5))))
1
1
78
61
print( ( sum( set( i for i in range(1, int(eval(input())) + 1, 1) if not (i % 3 == 0 or i % 5 == 0) ) ) ) )
print((sum((i for i in range(int(eval(input())) + 1) if i % 3 and i % 5))))
false
0
[ "-print(", "- (", "- sum(", "- set(", "- i", "- for i in range(1, int(eval(input())) + 1, 1)", "- if not (i % 3 == 0 or i % 5 == 0)", "- )", "- )", "- )", "-)", "+print((sum((i for i in range(int(eval(input(...
false
0.674321
0.316
2.133925
[ "s066253490", "s943569468" ]
u215334265
p02712
python
s532080253
s445627685
67
58
64,696
61,728
Accepted
Accepted
13.43
n = int(eval(input())) s3 = 0 s5 = 0 s15 = 0 count = 0 for i in range(int(n / 3)): s3 += (i+1) * 3 for i in range(int(n / 5)): s5 += (i + 1) * 5 for i in range(int(n / 15)): s15 += (i + 1) * 15 for i in range(n): count += (i+1) print((count-s3-s5+s15))
n = int(eval(input())) Sum = 0.5 * n * (1 + n) # n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし Sum3_5 = 0.5*(int(n/3)*(3+3*int(n/3))+int(n/5)*(5 + 5*int(n/5))) Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15)) # 問題の回答が整数値のため print((int(Sum-Sum3_5+Sum15)))
14
7
273
258
n = int(eval(input())) s3 = 0 s5 = 0 s15 = 0 count = 0 for i in range(int(n / 3)): s3 += (i + 1) * 3 for i in range(int(n / 5)): s5 += (i + 1) * 5 for i in range(int(n / 15)): s15 += (i + 1) * 15 for i in range(n): count += i + 1 print((count - s3 - s5 + s15))
n = int(eval(input())) Sum = 0.5 * n * (1 + n) # n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし Sum3_5 = 0.5 * (int(n / 3) * (3 + 3 * int(n / 3)) + int(n / 5) * (5 + 5 * int(n / 5))) Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15)) # 問題の回答が整数値のため print((int(Sum - Sum3_5 + Sum15)))
false
50
[ "-s3 = 0", "-s5 = 0", "-s15 = 0", "-count = 0", "-for i in range(int(n / 3)):", "- s3 += (i + 1) * 3", "-for i in range(int(n / 5)):", "- s5 += (i + 1) * 5", "-for i in range(int(n / 15)):", "- s15 += (i + 1) * 15", "-for i in range(n):", "- count += i + 1", "-print((count - s3 -...
false
0.444162
0.008118
54.712887
[ "s532080253", "s445627685" ]
u138546245
p02271
python
s952341572
s175132698
6,900
20
609,240
5,780
Accepted
Accepted
99.71
class Tree: class Node: def __init__(self, n, left, right): self.left = left self.right = right self.n = n if left is not None: lt = {t + n for t in left.totals} else: lt = set() if right is not None: rt = right.totals else: rt = set() self.totals = lt | rt | {n} def find(self, total): return total in self.totals def __str__(self): cs = [] if self.left is not None: cs.append(str(self.left)) if self.right is not None: cs.append(str(self.right)) return "{} -> ({})".format(self.n, ",".join(cs)) def __init__(self, ns): self.top = self.build_nodes(sorted(ns)) def has_subset(self, total): return self.top.find(total) def build_nodes(self, ns): if len(ns) == 0: return None left = self.build_nodes(ns[:-1]) right = self.build_nodes(ns[:-1]) node = self.Node(ns[-1], left, right) return node def run_tree(): _ = int(eval(input())) # flake8: noqa ns = [int(i) for i in input().split()] tree = Tree(ns) _ = int(eval(input())) # flake8: noqa for q in (int(j) for j in input().split()): if tree.has_subset(q): print("yes") else: print("no") if __name__ == '__main__': run_tree()
def create_sums(ns): if len(ns) == 0: return set() s = create_sums(ns[1:]) return {e + ns[0] for e in s} | s | {ns[0]} def run_set(): _ = int(eval(input())) # flake8: noqa ns = [int(i) for i in input().split()] sums = create_sums(ns) _ = int(eval(input())) # flake8: noqa for q in (int(j) for j in input().split()): if q in sums: print("yes") else: print("no") if __name__ == '__main__': run_set()
65
26
1,570
506
class Tree: class Node: def __init__(self, n, left, right): self.left = left self.right = right self.n = n if left is not None: lt = {t + n for t in left.totals} else: lt = set() if right is not None: rt = right.totals else: rt = set() self.totals = lt | rt | {n} def find(self, total): return total in self.totals def __str__(self): cs = [] if self.left is not None: cs.append(str(self.left)) if self.right is not None: cs.append(str(self.right)) return "{} -> ({})".format(self.n, ",".join(cs)) def __init__(self, ns): self.top = self.build_nodes(sorted(ns)) def has_subset(self, total): return self.top.find(total) def build_nodes(self, ns): if len(ns) == 0: return None left = self.build_nodes(ns[:-1]) right = self.build_nodes(ns[:-1]) node = self.Node(ns[-1], left, right) return node def run_tree(): _ = int(eval(input())) # flake8: noqa ns = [int(i) for i in input().split()] tree = Tree(ns) _ = int(eval(input())) # flake8: noqa for q in (int(j) for j in input().split()): if tree.has_subset(q): print("yes") else: print("no") if __name__ == "__main__": run_tree()
def create_sums(ns): if len(ns) == 0: return set() s = create_sums(ns[1:]) return {e + ns[0] for e in s} | s | {ns[0]} def run_set(): _ = int(eval(input())) # flake8: noqa ns = [int(i) for i in input().split()] sums = create_sums(ns) _ = int(eval(input())) # flake8: noqa for q in (int(j) for j in input().split()): if q in sums: print("yes") else: print("no") if __name__ == "__main__": run_set()
false
60
[ "-class Tree:", "- class Node:", "- def __init__(self, n, left, right):", "- self.left = left", "- self.right = right", "- self.n = n", "- if left is not None:", "- lt = {t + n for t in left.totals}", "- else:", "- ...
false
0.051214
0.052059
0.98377
[ "s952341572", "s175132698" ]
u208713671
p02696
python
s260519883
s487642640
66
60
61,740
61,716
Accepted
Accepted
9.09
[A,B,N] = list(map(int,input().split())) X = N Y = min(B-1,N) out1 = int(A*X/B) - A*int(X/B) out2 = int(A*Y/B) - A*int(Y/B) print(out2)
[A,B,N] = list(map(int,input().split())) X = N Y = min(B-1,N) out1 = A*X//B - A*(X//B) out2 = A*Y//B - A*(Y//B) print((max(out1,out2)))
8
8
145
144
[A, B, N] = list(map(int, input().split())) X = N Y = min(B - 1, N) out1 = int(A * X / B) - A * int(X / B) out2 = int(A * Y / B) - A * int(Y / B) print(out2)
[A, B, N] = list(map(int, input().split())) X = N Y = min(B - 1, N) out1 = A * X // B - A * (X // B) out2 = A * Y // B - A * (Y // B) print((max(out1, out2)))
false
0
[ "-out1 = int(A * X / B) - A * int(X / B)", "-out2 = int(A * Y / B) - A * int(Y / B)", "-print(out2)", "+out1 = A * X // B - A * (X // B)", "+out2 = A * Y // B - A * (Y // B)", "+print((max(out1, out2)))" ]
false
0.035899
0.034802
1.031512
[ "s260519883", "s487642640" ]
u970197315
p03971
python
s901196556
s002333012
120
102
4,016
4,016
Accepted
Accepted
15
n,a,b=list(map(int,input().split())) s=eval(input()) yosen_ok=0 kaigai=0 for i,ss in enumerate(s): if yosen_ok<a+b: if ss=='a': yosen_ok+=1 print('Yes') elif ss=='b': kaigai+=1 if kaigai<=b: yosen_ok+=1 print('Yes') else: print('No') else: print('No') continue else: print('No')
n,a,b=list(map(int,input().split())) s=eval(input()) yosen=0 kaigai=0 for ss in s: if ss=="a" and yosen<a+b: yosen+=1 print('Yes') elif ss=="b" and yosen<a+b: if kaigai<b: yosen+=1 kaigai+=1 print('Yes') else: print('No') else: print('No')
22
17
457
293
n, a, b = list(map(int, input().split())) s = eval(input()) yosen_ok = 0 kaigai = 0 for i, ss in enumerate(s): if yosen_ok < a + b: if ss == "a": yosen_ok += 1 print("Yes") elif ss == "b": kaigai += 1 if kaigai <= b: yosen_ok += 1 print("Yes") else: print("No") else: print("No") continue else: print("No")
n, a, b = list(map(int, input().split())) s = eval(input()) yosen = 0 kaigai = 0 for ss in s: if ss == "a" and yosen < a + b: yosen += 1 print("Yes") elif ss == "b" and yosen < a + b: if kaigai < b: yosen += 1 kaigai += 1 print("Yes") else: print("No") else: print("No")
false
22.727273
[ "-yosen_ok = 0", "+yosen = 0", "-for i, ss in enumerate(s):", "- if yosen_ok < a + b:", "- if ss == \"a\":", "- yosen_ok += 1", "+for ss in s:", "+ if ss == \"a\" and yosen < a + b:", "+ yosen += 1", "+ print(\"Yes\")", "+ elif ss == \"b\" and yosen < a +...
false
0.044058
0.042929
1.02629
[ "s901196556", "s002333012" ]
u310245677
p02570
python
s897657210
s850651451
33
27
9,156
8,992
Accepted
Accepted
18.18
d,t,s=list(map(int,input().split())) if d/s<=t: print('Yes') else: print('No')
#!/usr/bin/env python3 #誤差対策で掛け算にする d,t,s=list(map(int,input().split())) print(("Yes" if d<=t*s else "No"))
5
4
81
103
d, t, s = list(map(int, input().split())) if d / s <= t: print("Yes") else: print("No")
#!/usr/bin/env python3 # 誤差対策で掛け算にする d, t, s = list(map(int, input().split())) print(("Yes" if d <= t * s else "No"))
false
20
[ "+#!/usr/bin/env python3", "+# 誤差対策で掛け算にする", "-if d / s <= t:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+print((\"Yes\" if d <= t * s else \"No\"))" ]
false
0.044269
0.048104
0.920263
[ "s897657210", "s850651451" ]
u268181283
p02912
python
s972542824
s986521111
190
173
15,044
14,180
Accepted
Accepted
8.95
import heapq N,M = list(map(int,input().split())) original_value = list(map(int,input().split())) value = [] for v in original_value: heapq.heappush(value,v*(-1)) for i in range(M): num = (heapq.heappop(value)*(-1)//2)*(-1) heapq.heappush(value,num) print((sum(list([x*(-1) for x in value]))))
import heapq N,M = list(map(int,input().split())) value = list(map(int,input().split())) value = list([x*(-1) for x in value]) heapq.heapify(value) for i in range(M): num = (heapq.heappop(value)*(-1)//2)*(-1) heapq.heappush(value,num) print((sum(list([x*(-1) for x in value]))))
14
12
314
299
import heapq N, M = list(map(int, input().split())) original_value = list(map(int, input().split())) value = [] for v in original_value: heapq.heappush(value, v * (-1)) for i in range(M): num = (heapq.heappop(value) * (-1) // 2) * (-1) heapq.heappush(value, num) print((sum(list([x * (-1) for x in value]))))
import heapq N, M = list(map(int, input().split())) value = list(map(int, input().split())) value = list([x * (-1) for x in value]) heapq.heapify(value) for i in range(M): num = (heapq.heappop(value) * (-1) // 2) * (-1) heapq.heappush(value, num) print((sum(list([x * (-1) for x in value]))))
false
14.285714
[ "-original_value = list(map(int, input().split()))", "-value = []", "-for v in original_value:", "- heapq.heappush(value, v * (-1))", "+value = list(map(int, input().split()))", "+value = list([x * (-1) for x in value])", "+heapq.heapify(value)" ]
false
0.048683
0.043021
1.131608
[ "s972542824", "s986521111" ]
u833543158
p03044
python
s139993399
s049449250
700
637
56,040
56,020
Accepted
Accepted
9
N = int(eval(input())) nodes = [set() for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u, v = (u - 1, v - 1) nodes[u].add((v, w)) nodes[v].add((u, w)) ans = [-1 for _ in range(N)] q = [(0, 0, -1)] while q: v, dist, parent = q.pop() if dist % 2 == 0: ans[v] = 0 else: ans[v] = 1 for u, w in nodes[v]: if u == parent: continue q.append((u, dist + w, v)) print(("\n".join(map(str, ans))))
N = int(eval(input())) nodes = [set() for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u, v = (u - 1, v - 1) nodes[u].add((v, w)) nodes[v].add((u, w)) ans = [-1] * N q = [(0, 0, -1)] while q: v, dist, parent = q.pop() if dist % 2 == 0: ans[v] = 0 else: ans[v] = 1 for u, w in nodes[v]: if u == parent: continue q.append((u, dist + w, v)) print(("\n".join(map(str, ans))))
27
27
516
502
N = int(eval(input())) nodes = [set() for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u, v = (u - 1, v - 1) nodes[u].add((v, w)) nodes[v].add((u, w)) ans = [-1 for _ in range(N)] q = [(0, 0, -1)] while q: v, dist, parent = q.pop() if dist % 2 == 0: ans[v] = 0 else: ans[v] = 1 for u, w in nodes[v]: if u == parent: continue q.append((u, dist + w, v)) print(("\n".join(map(str, ans))))
N = int(eval(input())) nodes = [set() for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u, v = (u - 1, v - 1) nodes[u].add((v, w)) nodes[v].add((u, w)) ans = [-1] * N q = [(0, 0, -1)] while q: v, dist, parent = q.pop() if dist % 2 == 0: ans[v] = 0 else: ans[v] = 1 for u, w in nodes[v]: if u == parent: continue q.append((u, dist + w, v)) print(("\n".join(map(str, ans))))
false
0
[ "-ans = [-1 for _ in range(N)]", "+ans = [-1] * N" ]
false
0.10501
0.042122
2.492994
[ "s139993399", "s049449250" ]
u955125992
p02659
python
s648552515
s666943276
28
25
10,048
9,968
Accepted
Accepted
10.71
from decimal import Decimal a, b = list(map(Decimal, input().split())) print((int(Decimal(a*b))))
from decimal import Decimal a, b = list(map(str, input().split())) print((int(Decimal(a)*Decimal(b))))
5
5
95
100
from decimal import Decimal a, b = list(map(Decimal, input().split())) print((int(Decimal(a * b))))
from decimal import Decimal a, b = list(map(str, input().split())) print((int(Decimal(a) * Decimal(b))))
false
0
[ "-a, b = list(map(Decimal, input().split()))", "-print((int(Decimal(a * b))))", "+a, b = list(map(str, input().split()))", "+print((int(Decimal(a) * Decimal(b))))" ]
false
0.110232
0.080188
1.374667
[ "s648552515", "s666943276" ]
u892251744
p03044
python
s077767577
s266572390
1,265
1,022
59,668
59,668
Accepted
Accepted
19.21
from collections import deque N = int(eval(input())) branch = [list(map(int, input().split())) for _ in range(N-1)] adj = [[] for _ in range(N+1)] for b in branch: adj[b[0]].append([b[1],b[2]]) adj[b[1]].append([b[0],b[2]]) ans = [-1] * (N+1) deq = deque() deq.appendleft(1) while len(deq) > 0: v = deq.pop() for u, w in adj[v]: if ans[u] == -1: deq.appendleft(u) if ans[v] == -1 and ans[u] == -1: if w % 2 == 0: ans[v] = 0 ans[u] = 0 else: ans[v] = 0 ans[u] = 1 elif ans[v] == 0: if w % 2 == 0: ans[u] = 0 else: ans[u] = 1 else: if w % 2 == 0: ans[u] = 1 else: ans[u] = 0 for i in range(1,N+1): print((ans[i]))
from collections import deque N = int(eval(input())) branch = [list(map(int, input().split())) for _ in range(N-1)] adj = [[] for _ in range(N+1)] for b in branch: adj[b[0]].append([b[1],b[2]]) adj[b[1]].append([b[0],b[2]]) ans = [-1] * (N+1) deq = deque() deq.appendleft(1) while len(deq) > 0: v = deq.pop() for u, w in adj[v]: if ans[u] == -1: deq.appendleft(u) if ans[v] == -1 and ans[u] == -1: if w % 2 == 0: ans[v] = 0 ans[u] = 0 else: ans[v] = 0 ans[u] = 1 elif ans[v] == 0: if w % 2 == 0: ans[u] = 0 else: ans[u] = 1 else: if w % 2 == 0: ans[u] = 1 else: ans[u] = 0 if N == 1: print((0)) else: for i in range(1,N+1): print((ans[i]))
37
40
774
809
from collections import deque N = int(eval(input())) branch = [list(map(int, input().split())) for _ in range(N - 1)] adj = [[] for _ in range(N + 1)] for b in branch: adj[b[0]].append([b[1], b[2]]) adj[b[1]].append([b[0], b[2]]) ans = [-1] * (N + 1) deq = deque() deq.appendleft(1) while len(deq) > 0: v = deq.pop() for u, w in adj[v]: if ans[u] == -1: deq.appendleft(u) if ans[v] == -1 and ans[u] == -1: if w % 2 == 0: ans[v] = 0 ans[u] = 0 else: ans[v] = 0 ans[u] = 1 elif ans[v] == 0: if w % 2 == 0: ans[u] = 0 else: ans[u] = 1 else: if w % 2 == 0: ans[u] = 1 else: ans[u] = 0 for i in range(1, N + 1): print((ans[i]))
from collections import deque N = int(eval(input())) branch = [list(map(int, input().split())) for _ in range(N - 1)] adj = [[] for _ in range(N + 1)] for b in branch: adj[b[0]].append([b[1], b[2]]) adj[b[1]].append([b[0], b[2]]) ans = [-1] * (N + 1) deq = deque() deq.appendleft(1) while len(deq) > 0: v = deq.pop() for u, w in adj[v]: if ans[u] == -1: deq.appendleft(u) if ans[v] == -1 and ans[u] == -1: if w % 2 == 0: ans[v] = 0 ans[u] = 0 else: ans[v] = 0 ans[u] = 1 elif ans[v] == 0: if w % 2 == 0: ans[u] = 0 else: ans[u] = 1 else: if w % 2 == 0: ans[u] = 1 else: ans[u] = 0 if N == 1: print((0)) else: for i in range(1, N + 1): print((ans[i]))
false
7.5
[ "-for i in range(1, N + 1):", "- print((ans[i]))", "+if N == 1:", "+ print((0))", "+else:", "+ for i in range(1, N + 1):", "+ print((ans[i]))" ]
false
0.079305
0.041896
1.892923
[ "s077767577", "s266572390" ]
u437638594
p03289
python
s147361674
s045971910
20
17
3,064
3,064
Accepted
Accepted
15
S = list(eval(input())) ans = "AC" tmp = S[2:-1] if S[0] != "A": ans = "WA" else: S.remove("A") count = 0 for item in tmp: if item == "C": count += 1 if count != 1: ans = "WA" elif count == 1: S.remove("C") if "".join(S).lower() != "".join(S): ans = "WA" print(ans)
S = eval(input()) ans = "AC" tmp = S[2:-1] if S[0] != "A": ans = "WA" else: S = S.replace("A", "") count = 0 for item in tmp: if item == "C": count += 1 if count != 1: ans = "WA" elif count == 1: S = S.replace("C", "") if not S.islower(): ans = "WA" print(ans)
25
24
312
305
S = list(eval(input())) ans = "AC" tmp = S[2:-1] if S[0] != "A": ans = "WA" else: S.remove("A") count = 0 for item in tmp: if item == "C": count += 1 if count != 1: ans = "WA" elif count == 1: S.remove("C") if "".join(S).lower() != "".join(S): ans = "WA" print(ans)
S = eval(input()) ans = "AC" tmp = S[2:-1] if S[0] != "A": ans = "WA" else: S = S.replace("A", "") count = 0 for item in tmp: if item == "C": count += 1 if count != 1: ans = "WA" elif count == 1: S = S.replace("C", "") if not S.islower(): ans = "WA" print(ans)
false
4
[ "-S = list(eval(input()))", "+S = eval(input())", "- S.remove(\"A\")", "+ S = S.replace(\"A\", \"\")", "- S.remove(\"C\")", "-if \"\".join(S).lower() != \"\".join(S):", "+ S = S.replace(\"C\", \"\")", "+if not S.islower():" ]
false
0.049063
0.049773
0.985734
[ "s147361674", "s045971910" ]
u197300260
p03624
python
s949679790
s887455263
41
27
3,316
3,316
Accepted
Accepted
34.15
# Problem: https://atcoder.jp/contests/abc071/tasks/abc071_b # Python 2nd Try import sys # from collections import defaultdict # 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(inputStr): # print("STR={}".format(inputStr)) # バケツを用意する bucket = [0] * 26 result = "None" # print("Bucket:{}".format(bucket)) for j in range(0, len(inputStr), +1): charNo = ord(inputStr[j]) - ord('a') bucket[charNo] = bucket[charNo] + 1 for j in range(0, 26, +1): if bucket[j] == 0: result = chr(ord('a')+j) break # algorithm return result if __name__ == "__main__": S = sys.stdin.readline().split() print(("{}".format(solver(S[0]))))
# Problem: # Python 3rd Try import sys # from collections import defaultdict # 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(inputString): full_set = set() input_set = set() for j in range(ord('a'), ord('z')+1, +1): full_set.add(chr(j)) for j in range(0, len(inputString), +1): input_set.add(inputString[j]) # print("FULLSET:{}".format(full_set)) # print("INPUT:{}".format(input_set)) # set -= other full_set -= input_set # print("NOTFOUND:{}".format(full_set)) fullset_list = list(full_set) fullset_list.sort() # print("NOT in STRING:{}".format(fullset_list)) if 0 == len(fullset_list): result = "None" else: result = fullset_list[0] return result if __name__ == "__main__": S = sys.stdin.readline().split() print(("{}".format(solver(S[0]))))
29
38
970
1,124
# Problem: https://atcoder.jp/contests/abc071/tasks/abc071_b # Python 2nd Try import sys # from collections import defaultdict # 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(inputStr): # print("STR={}".format(inputStr)) # バケツを用意する bucket = [0] * 26 result = "None" # print("Bucket:{}".format(bucket)) for j in range(0, len(inputStr), +1): charNo = ord(inputStr[j]) - ord("a") bucket[charNo] = bucket[charNo] + 1 for j in range(0, 26, +1): if bucket[j] == 0: result = chr(ord("a") + j) break # algorithm return result if __name__ == "__main__": S = sys.stdin.readline().split() print(("{}".format(solver(S[0]))))
# Problem: # Python 3rd Try import sys # from collections import defaultdict # 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(inputString): full_set = set() input_set = set() for j in range(ord("a"), ord("z") + 1, +1): full_set.add(chr(j)) for j in range(0, len(inputString), +1): input_set.add(inputString[j]) # print("FULLSET:{}".format(full_set)) # print("INPUT:{}".format(input_set)) # set -= other full_set -= input_set # print("NOTFOUND:{}".format(full_set)) fullset_list = list(full_set) fullset_list.sort() # print("NOT in STRING:{}".format(fullset_list)) if 0 == len(fullset_list): result = "None" else: result = fullset_list[0] return result if __name__ == "__main__": S = sys.stdin.readline().split() print(("{}".format(solver(S[0]))))
false
23.684211
[ "-# Problem: https://atcoder.jp/contests/abc071/tasks/abc071_b", "-# Python 2nd Try", "+# Problem:", "+# Python 3rd Try", "-def solver(inputStr):", "- # print(\"STR={}\".format(inputStr))", "- # バケツを用意する", "- bucket = [0] * 26", "- result = \"None\"", "- # print(\"Bucket:{}\".format...
false
0.048426
0.04833
1.002004
[ "s949679790", "s887455263" ]
u631025015
p02713
python
s683803627
s786289763
983
605
9,168
9,216
Accepted
Accepted
38.45
def gcd(a, b): while b != 0 : t = a % b a = b b = t return a sum = 0 N=int(eval(input(""))) for a in range(1, N + 1): for b in range(1, N + 1): x = gcd(a, b) if x == 1: sum = sum + N else: for c in range(1, N + 1): sum = sum + gcd(x, c) print(sum)
def gcd(a, b): while b != 0 : t = a % b a = b b = t return a sum = 0 N=int(eval(input(""))) for a in range(1, N + 1): for b in range(1, N + 1): x = gcd(a, b) if x == 1: sum = sum + N elif x == 2: sum = sum + (N + 1) // 2 + N // 2 * 2 else: for c in range(1, N + 1): sum = sum + gcd(x, c) print(sum)
18
20
367
440
def gcd(a, b): while b != 0: t = a % b a = b b = t return a sum = 0 N = int(eval(input(""))) for a in range(1, N + 1): for b in range(1, N + 1): x = gcd(a, b) if x == 1: sum = sum + N else: for c in range(1, N + 1): sum = sum + gcd(x, c) print(sum)
def gcd(a, b): while b != 0: t = a % b a = b b = t return a sum = 0 N = int(eval(input(""))) for a in range(1, N + 1): for b in range(1, N + 1): x = gcd(a, b) if x == 1: sum = sum + N elif x == 2: sum = sum + (N + 1) // 2 + N // 2 * 2 else: for c in range(1, N + 1): sum = sum + gcd(x, c) print(sum)
false
10
[ "+ elif x == 2:", "+ sum = sum + (N + 1) // 2 + N // 2 * 2" ]
false
0.178657
0.134455
1.328748
[ "s683803627", "s786289763" ]
u668503853
p02683
python
s360220729
s860259045
87
58
9,176
9,164
Accepted
Accepted
33.33
N,M,X=list(map(int,input().split())) li=[list(map(int,input().split())) for _ in range(N)] ans=float("inf") for i in range(2**N): price=0 abil=[0]*M for j in range(N): if (i>>j)&1: price+=li[j][0] for k in range(1,M+1): abil[k-1]+=li[j][k] if min(abil)>=X: ans=min(ans,price) if ans==float("inf"): print((-1)) else: print(ans)
N,M,X=list(map(int,input().split())) li=[list(map(int,input().split())) for _ in range(N)] ans=float("inf") for i in range(2**N): PriceAbil=[0]*(M+1) for j in range(N): if (i>>j)&1: PriceAbil=[x+y for (x,y) in zip(PriceAbil,li[j])] if min(PriceAbil[1:])>=X: ans=min(ans,PriceAbil[0]) if ans==float("inf"): print((-1)) else: print(ans)
17
14
375
363
N, M, X = list(map(int, input().split())) li = [list(map(int, input().split())) for _ in range(N)] ans = float("inf") for i in range(2**N): price = 0 abil = [0] * M for j in range(N): if (i >> j) & 1: price += li[j][0] for k in range(1, M + 1): abil[k - 1] += li[j][k] if min(abil) >= X: ans = min(ans, price) if ans == float("inf"): print((-1)) else: print(ans)
N, M, X = list(map(int, input().split())) li = [list(map(int, input().split())) for _ in range(N)] ans = float("inf") for i in range(2**N): PriceAbil = [0] * (M + 1) for j in range(N): if (i >> j) & 1: PriceAbil = [x + y for (x, y) in zip(PriceAbil, li[j])] if min(PriceAbil[1:]) >= X: ans = min(ans, PriceAbil[0]) if ans == float("inf"): print((-1)) else: print(ans)
false
17.647059
[ "- price = 0", "- abil = [0] * M", "+ PriceAbil = [0] * (M + 1)", "- price += li[j][0]", "- for k in range(1, M + 1):", "- abil[k - 1] += li[j][k]", "- if min(abil) >= X:", "- ans = min(ans, price)", "+ PriceAbil = [x + y for (x, y) ...
false
0.107764
0.044649
2.413599
[ "s360220729", "s860259045" ]
u141610915
p02816
python
s461882182
s334831777
1,996
623
263,616
119,632
Accepted
Accepted
68.79
import sys input = sys.stdin.readline N = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) ta = [[0] * N for _ in range(30)] tb = [[0] * N for _ in range(30)] mxl = max(max(a), max(b)).bit_length() for i in range(mxl): x = 1 << i for j in range(N): ta[i][j] = int((a[j] & x) > 0) tb[i][j] = int((b[j] & x) > 0) class KmpSearch: def __init__(self, word): self.word = word self.table = [0] * (len(word) + 1) self.table[0] = -1 i, j = 0, 1 while j < len(self.word): matched = self.word[i] == self.word[j] if not matched and i > 0: i = self.table[i] else: if matched: i += 1 j += 1 self.table[j] = i def search(self, text): table = self.table word = self.word i, p = 0, 0 res = [] while i < len(text): if text[i] == word[p]: i += 1 p += 1 elif p == 0: i += 1 else: p = table[p] if p == len(word): res.append(i - p) p = table[p] return res res = [0] * N vis = [1 for _ in range(N)] for i in range(mxl): kmp = KmpSearch(ta[i]) s = [0] * (2 * N - 1) for j in range(2 * N - 1): s[j] = tb[i][j % N] ^ 1 xs = set(kmp.search(s)) tvis = [0] * N for j in range(N): tvis[j] |= (j in xs) res[j] += (j in xs) << i xs = set(kmp.search(tb[i] + tb[i][: -1])) for j in range(N): tvis[j] |= (j in xs) for j in range(N): vis[j] &= tvis[j] #print(res, vis) rres = [] for i in range(N): if vis[i]: rres.append(((N - i) % N, res[i])) rres.sort(key = lambda x: (x[0], x[1])) for r in rres: print((*r))
import sys input = sys.stdin.readline N = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) class KmpSearch: def __init__(self, word): self.word = word self.table = [0] * (len(word) + 1) self.table[0] = -1 i, j = 0, 1 while j < len(self.word): matched = self.word[i] == self.word[j] if not matched and i > 0: i = self.table[i] else: if matched: i += 1 j += 1 self.table[j] = i def search(self, text): table = self.table word = self.word i, p = 0, 0 res = [] while i < len(text): if text[i] == word[p]: i += 1 p += 1 elif p == 0: i += 1 else: p = table[p] if p == len(word): res.append(i - p) p = table[p] return res xa = [0] * N xb = [0] * N for i in range(N): xa[i] = a[i - 1] ^ a[i] xb[i] = b[i - 1] ^ b[i] kmp = KmpSearch(xa) res = kmp.search(xb + xb[: -1]) rres = [] for x in res: rres.append(((N - x) % N, a[0] ^ b[x])) rres.sort(key = lambda x: (x[0], x[1])) for r in rres: print((*r))
68
51
1,705
1,161
import sys input = sys.stdin.readline N = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) ta = [[0] * N for _ in range(30)] tb = [[0] * N for _ in range(30)] mxl = max(max(a), max(b)).bit_length() for i in range(mxl): x = 1 << i for j in range(N): ta[i][j] = int((a[j] & x) > 0) tb[i][j] = int((b[j] & x) > 0) class KmpSearch: def __init__(self, word): self.word = word self.table = [0] * (len(word) + 1) self.table[0] = -1 i, j = 0, 1 while j < len(self.word): matched = self.word[i] == self.word[j] if not matched and i > 0: i = self.table[i] else: if matched: i += 1 j += 1 self.table[j] = i def search(self, text): table = self.table word = self.word i, p = 0, 0 res = [] while i < len(text): if text[i] == word[p]: i += 1 p += 1 elif p == 0: i += 1 else: p = table[p] if p == len(word): res.append(i - p) p = table[p] return res res = [0] * N vis = [1 for _ in range(N)] for i in range(mxl): kmp = KmpSearch(ta[i]) s = [0] * (2 * N - 1) for j in range(2 * N - 1): s[j] = tb[i][j % N] ^ 1 xs = set(kmp.search(s)) tvis = [0] * N for j in range(N): tvis[j] |= j in xs res[j] += (j in xs) << i xs = set(kmp.search(tb[i] + tb[i][:-1])) for j in range(N): tvis[j] |= j in xs for j in range(N): vis[j] &= tvis[j] # print(res, vis) rres = [] for i in range(N): if vis[i]: rres.append(((N - i) % N, res[i])) rres.sort(key=lambda x: (x[0], x[1])) for r in rres: print((*r))
import sys input = sys.stdin.readline N = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) class KmpSearch: def __init__(self, word): self.word = word self.table = [0] * (len(word) + 1) self.table[0] = -1 i, j = 0, 1 while j < len(self.word): matched = self.word[i] == self.word[j] if not matched and i > 0: i = self.table[i] else: if matched: i += 1 j += 1 self.table[j] = i def search(self, text): table = self.table word = self.word i, p = 0, 0 res = [] while i < len(text): if text[i] == word[p]: i += 1 p += 1 elif p == 0: i += 1 else: p = table[p] if p == len(word): res.append(i - p) p = table[p] return res xa = [0] * N xb = [0] * N for i in range(N): xa[i] = a[i - 1] ^ a[i] xb[i] = b[i - 1] ^ b[i] kmp = KmpSearch(xa) res = kmp.search(xb + xb[:-1]) rres = [] for x in res: rres.append(((N - x) % N, a[0] ^ b[x])) rres.sort(key=lambda x: (x[0], x[1])) for r in rres: print((*r))
false
25
[ "-ta = [[0] * N for _ in range(30)]", "-tb = [[0] * N for _ in range(30)]", "-mxl = max(max(a), max(b)).bit_length()", "-for i in range(mxl):", "- x = 1 << i", "- for j in range(N):", "- ta[i][j] = int((a[j] & x) > 0)", "- tb[i][j] = int((b[j] & x) > 0)", "-res = [0] * N", "-vi...
false
0.036137
0.037391
0.966442
[ "s461882182", "s334831777" ]
u189487046
p02954
python
s883401367
s426097597
130
116
6,400
17,220
Accepted
Accepted
10.77
S = eval(input()) N = len(S) ans = [0]*N cnt = 0 for i in range(N-1): if S[i] == 'R': cnt += 1 if S[i+1] == 'L': ans[i+1] = cnt//2 ans[i] = (cnt+1)//2 else: cnt = 0 cnt = 0 for i in reversed(list(range(1, N))): if S[i] == 'L': cnt += 1 if S[i-1] == 'R': ans[i-1] += cnt//2 ans[i] += (cnt+1)//2 else: cnt = 0 print((*ans))
S = eval(input()) N = len(S) ans = [0]*N lr_idx = 0 for i in range(N-1): if S[i] == 'R' and S[i+1] == 'L': r_odd = 0 # 奇数 r_even = 0 # 偶数 for c, j in enumerate(reversed(list(range(lr_idx, i)))): if S[j] == 'R': if (c+1) % 2 == 0: r_even += 1 else: r_odd += 1 l_odd = 0 l_even = 0 for c, j in enumerate(range(i+2, N)): if S[j] == 'R' and S[j+1] == 'L': break if S[j] == 'L': if (c+1) % 2 == 0: l_even += 1 else: l_odd += 1 ans[i] = 1+r_even+l_odd ans[i+1] = 1+r_odd+l_even lr_idx = i+2 print((' '.join(map(str, ans))))
26
34
449
817
S = eval(input()) N = len(S) ans = [0] * N cnt = 0 for i in range(N - 1): if S[i] == "R": cnt += 1 if S[i + 1] == "L": ans[i + 1] = cnt // 2 ans[i] = (cnt + 1) // 2 else: cnt = 0 cnt = 0 for i in reversed(list(range(1, N))): if S[i] == "L": cnt += 1 if S[i - 1] == "R": ans[i - 1] += cnt // 2 ans[i] += (cnt + 1) // 2 else: cnt = 0 print((*ans))
S = eval(input()) N = len(S) ans = [0] * N lr_idx = 0 for i in range(N - 1): if S[i] == "R" and S[i + 1] == "L": r_odd = 0 # 奇数 r_even = 0 # 偶数 for c, j in enumerate(reversed(list(range(lr_idx, i)))): if S[j] == "R": if (c + 1) % 2 == 0: r_even += 1 else: r_odd += 1 l_odd = 0 l_even = 0 for c, j in enumerate(range(i + 2, N)): if S[j] == "R" and S[j + 1] == "L": break if S[j] == "L": if (c + 1) % 2 == 0: l_even += 1 else: l_odd += 1 ans[i] = 1 + r_even + l_odd ans[i + 1] = 1 + r_odd + l_even lr_idx = i + 2 print((" ".join(map(str, ans))))
false
23.529412
[ "-cnt = 0", "+lr_idx = 0", "- if S[i] == \"R\":", "- cnt += 1", "- if S[i + 1] == \"L\":", "- ans[i + 1] = cnt // 2", "- ans[i] = (cnt + 1) // 2", "- else:", "- cnt = 0", "-cnt = 0", "-for i in reversed(list(range(1, N))):", "- if S[i] == \"L...
false
0.038397
0.037424
1.026001
[ "s883401367", "s426097597" ]
u807772568
p02770
python
s876011269
s894229328
1,538
1,385
90,756
92,292
Accepted
Accepted
9.95
import sys,collections as cl,bisect as bs sys.setrecursionlimit(100000) input = sys.stdin.readline mod = 10**9+7 Max = sys.maxsize def l(): #intのlist return list(map(int,input().split())) def m(): #複数文字 return list(map(int,input().split())) def onem(): #Nとかの取得 return int(eval(input())) def s(x): #圧縮 a = [] aa = x[0] su = 1 for i in range(len(x)-1): if aa != x[i+1]: a.append([aa,su]) aa = x[i+1] su = 1 else: su += 1 a.append([aa,su]) return a def jo(x): #listをスペースごとに分ける return " ".join(map(str,x)) def max2(x): #他のときもどうように作成可能 return max(list(map(max,x))) def In(x,a): #aがリスト(sorted) k = bs.bisect_left(a,x) if k != len(a) and a[k] == x: return True else: return False """ def nibu(x,n,r): ll = 0 rr = r while True: mid = (ll+rr)//2 if rr == mid: return ll if (ここに評価入れる): rr = mid else: ll = mid+1 """ mod = 10**9+7 #出力の制限 N = 10**5 * 2 def cmb(n, r): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod def p(n,r): if ( r<0 or r>n ): return 0 return g1[n] * g2[n-r] % mod g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) # a = cmb(n,r) import fractions from functools import reduce def gcd(*numbers): return reduce(fractions.gcd, numbers) def gcd_list(numbers): return reduce(fractions.gcd, numbers) def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) k,q = m() d = l() for i in range(q): n,x,mm = m() co = 0 po = [] for j in range(k): po.append(d[j] % mm if d[j] % mm > 0 else mm) """ for j in range(k): if po[j] == 0: ccc = ((n-1)//k) if (n-1)%k >= j: ccc += 1 co += ccc """ pp = sum(po) * ((n-1)//k) pp += x for j in range((n-1)%k): pp += po[j] co += (pp//mm) - (x//mm) print((n-co-1))
import sys,collections as cl,bisect as bs sys.setrecursionlimit(100000) input = sys.stdin.readline mod = 10**9+7 Max = sys.maxsize def l(): #intのlist return list(map(int,input().split())) def m(): #複数文字 return list(map(int,input().split())) def onem(): #Nとかの取得 return int(eval(input())) def s(x): #圧縮 a = [] aa = x[0] su = 1 for i in range(len(x)-1): if aa != x[i+1]: a.append([aa,su]) aa = x[i+1] su = 1 else: su += 1 a.append([aa,su]) return a def jo(x): #listをスペースごとに分ける return " ".join(map(str,x)) def max2(x): #他のときもどうように作成可能 return max(list(map(max,x))) def In(x,a): #aがリスト(sorted) k = bs.bisect_left(a,x) if k != len(a) and a[k] == x: return True else: return False """ def nibu(x,n,r): ll = 0 rr = r while True: mid = (ll+rr)//2 if rr == mid: return ll if (ここに評価入れる): rr = mid else: ll = mid+1 """ mod = 10**9+7 #出力の制限 N = 10**5 * 2 def cmb(n, r): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod def p(n,r): if ( r<0 or r>n ): return 0 return g1[n] * g2[n-r] % mod g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) # a = cmb(n,r) import fractions from functools import reduce def gcd(*numbers): return reduce(fractions.gcd, numbers) def gcd_list(numbers): return reduce(fractions.gcd, numbers) def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) k,q = m() d = l() for i in range(q): n,x,mm = m() co = 0 po = [] for j in range(k): #po.append(d[j] % mm if d[j] % mm > 0 else mm) po.append(d[j] % mm) for j in range(k): if po[j] == 0: ccc = ((n-1)//k) if (n-1)%k >= j+1: ccc += 1 co += ccc pp = sum(po) * ((n-1)//k) pp += x for j in range((n-1)%k): pp += po[j] co += (pp//mm) - (x//mm) print((n-co-1))
120
120
2,441
2,458
import sys, collections as cl, bisect as bs sys.setrecursionlimit(100000) input = sys.stdin.readline mod = 10**9 + 7 Max = sys.maxsize def l(): # intのlist return list(map(int, input().split())) def m(): # 複数文字 return list(map(int, input().split())) def onem(): # Nとかの取得 return int(eval(input())) def s(x): # 圧縮 a = [] aa = x[0] su = 1 for i in range(len(x) - 1): if aa != x[i + 1]: a.append([aa, su]) aa = x[i + 1] su = 1 else: su += 1 a.append([aa, su]) return a def jo(x): # listをスペースごとに分ける return " ".join(map(str, x)) def max2(x): # 他のときもどうように作成可能 return max(list(map(max, x))) def In(x, a): # aがリスト(sorted) k = bs.bisect_left(a, x) if k != len(a) and a[k] == x: return True else: return False """ def nibu(x,n,r): ll = 0 rr = r while True: mid = (ll+rr)//2 if rr == mid: return ll if (ここに評価入れる): rr = mid else: ll = mid+1 """ mod = 10**9 + 7 # 出力の制限 N = 10**5 * 2 def cmb(n, r): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - r] % mod def p(n, r): if r < 0 or r > n: return 0 return g1[n] * g2[n - r] % mod g1 = [1, 1] # 元テーブル g2 = [1, 1] # 逆元テーブル inverse = [0, 1] # 逆元テーブル計算用テーブル for i in range(2, N + 1): g1.append((g1[-1] * i) % mod) inverse.append((-inverse[mod % i] * (mod // i)) % mod) g2.append((g2[-1] * inverse[-1]) % mod) # a = cmb(n,r) import fractions from functools import reduce def gcd(*numbers): return reduce(fractions.gcd, numbers) def gcd_list(numbers): return reduce(fractions.gcd, numbers) def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) k, q = m() d = l() for i in range(q): n, x, mm = m() co = 0 po = [] for j in range(k): po.append(d[j] % mm if d[j] % mm > 0 else mm) """ for j in range(k): if po[j] == 0: ccc = ((n-1)//k) if (n-1)%k >= j: ccc += 1 co += ccc """ pp = sum(po) * ((n - 1) // k) pp += x for j in range((n - 1) % k): pp += po[j] co += (pp // mm) - (x // mm) print((n - co - 1))
import sys, collections as cl, bisect as bs sys.setrecursionlimit(100000) input = sys.stdin.readline mod = 10**9 + 7 Max = sys.maxsize def l(): # intのlist return list(map(int, input().split())) def m(): # 複数文字 return list(map(int, input().split())) def onem(): # Nとかの取得 return int(eval(input())) def s(x): # 圧縮 a = [] aa = x[0] su = 1 for i in range(len(x) - 1): if aa != x[i + 1]: a.append([aa, su]) aa = x[i + 1] su = 1 else: su += 1 a.append([aa, su]) return a def jo(x): # listをスペースごとに分ける return " ".join(map(str, x)) def max2(x): # 他のときもどうように作成可能 return max(list(map(max, x))) def In(x, a): # aがリスト(sorted) k = bs.bisect_left(a, x) if k != len(a) and a[k] == x: return True else: return False """ def nibu(x,n,r): ll = 0 rr = r while True: mid = (ll+rr)//2 if rr == mid: return ll if (ここに評価入れる): rr = mid else: ll = mid+1 """ mod = 10**9 + 7 # 出力の制限 N = 10**5 * 2 def cmb(n, r): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - r] % mod def p(n, r): if r < 0 or r > n: return 0 return g1[n] * g2[n - r] % mod g1 = [1, 1] # 元テーブル g2 = [1, 1] # 逆元テーブル inverse = [0, 1] # 逆元テーブル計算用テーブル for i in range(2, N + 1): g1.append((g1[-1] * i) % mod) inverse.append((-inverse[mod % i] * (mod // i)) % mod) g2.append((g2[-1] * inverse[-1]) % mod) # a = cmb(n,r) import fractions from functools import reduce def gcd(*numbers): return reduce(fractions.gcd, numbers) def gcd_list(numbers): return reduce(fractions.gcd, numbers) def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) k, q = m() d = l() for i in range(q): n, x, mm = m() co = 0 po = [] for j in range(k): # po.append(d[j] % mm if d[j] % mm > 0 else mm) po.append(d[j] % mm) for j in range(k): if po[j] == 0: ccc = (n - 1) // k if (n - 1) % k >= j + 1: ccc += 1 co += ccc pp = sum(po) * ((n - 1) // k) pp += x for j in range((n - 1) % k): pp += po[j] co += (pp // mm) - (x // mm) print((n - co - 1))
false
0
[ "- po.append(d[j] % mm if d[j] % mm > 0 else mm)", "- \"\"\"", "+ # po.append(d[j] % mm if d[j] % mm > 0 else mm)", "+ po.append(d[j] % mm)", "- ccc = ((n-1)//k)", "- if (n-1)%k >= j:", "+ ccc = (n - 1) // k", "+ if (n - 1) % k >= j +...
false
0.675411
0.793018
0.851697
[ "s876011269", "s894229328" ]
u932465688
p03611
python
s729443798
s091368811
151
103
14,092
14,008
Accepted
Accepted
31.79
N = int(eval(input())) L = list(map(int,input().split())) L.sort() L.append(1000000) M = [0]*((10**5)+1) c = 0 d = 1 num = L[0] if N == 1: print((1)) elif N == 2: if abs(L[0]-L[1]) <=1 : print((2)) else: print((1)) else: while c <= N-1: if L[c] == L[c+1]: d += 1 c += 1 else: M[num] = d d = 1 c += 1 num = L[c] M.insert(0,0) M.append(0) ans = 0 for i in range(len(M)-2): if M[i]+M[i+1]+M[i+2] >= ans: ans = M[i]+M[i+1]+M[i+2] print(ans)
N = int(eval(input())) A = list(map(int,input().split())) if N == 1: print((1)) elif N == 2: if abs(A[1]-A[0]) <= 2: print((2)) else: print((1)) else: L = [0]*(10**5+1) for i in range(N): L[A[i]+1] += 1 for j in range(1,len(L)): L[j] = L[j-1]+L[j] ans = 0 for k in range(3,len(L)): S = L[k]-L[k-3] if ans <= S: ans = S print(ans)
32
21
535
385
N = int(eval(input())) L = list(map(int, input().split())) L.sort() L.append(1000000) M = [0] * ((10**5) + 1) c = 0 d = 1 num = L[0] if N == 1: print((1)) elif N == 2: if abs(L[0] - L[1]) <= 1: print((2)) else: print((1)) else: while c <= N - 1: if L[c] == L[c + 1]: d += 1 c += 1 else: M[num] = d d = 1 c += 1 num = L[c] M.insert(0, 0) M.append(0) ans = 0 for i in range(len(M) - 2): if M[i] + M[i + 1] + M[i + 2] >= ans: ans = M[i] + M[i + 1] + M[i + 2] print(ans)
N = int(eval(input())) A = list(map(int, input().split())) if N == 1: print((1)) elif N == 2: if abs(A[1] - A[0]) <= 2: print((2)) else: print((1)) else: L = [0] * (10**5 + 1) for i in range(N): L[A[i] + 1] += 1 for j in range(1, len(L)): L[j] = L[j - 1] + L[j] ans = 0 for k in range(3, len(L)): S = L[k] - L[k - 3] if ans <= S: ans = S print(ans)
false
34.375
[ "-L = list(map(int, input().split()))", "-L.sort()", "-L.append(1000000)", "-M = [0] * ((10**5) + 1)", "-c = 0", "-d = 1", "-num = L[0]", "+A = list(map(int, input().split()))", "- if abs(L[0] - L[1]) <= 1:", "+ if abs(A[1] - A[0]) <= 2:", "- while c <= N - 1:", "- if L[c] == L...
false
0.079427
0.0942
0.843171
[ "s729443798", "s091368811" ]
u102461423
p03687
python
s782507901
s740533244
164
136
12,548
27,196
Accepted
Accepted
17.07
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # 目標の文字を決める -> シミュレーション import numpy as np S = np.array(list(read().rstrip())) def F(S,x): A = (S == x) t = 0 while True: if np.all(A): return t A = (A[:-1] | A[1:]) t += 1 answer = min(F(S,x) for x in set(S)) print(answer)
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = np.array(list(read().rstrip().decode())) def f(S, a): S = S == a if not np.any(S): return len(S) for n in range(len(S)): if np.all(S): return n S = S[1:] | S[:-1] x = min(f(S, a) for a in S) print(x)
22
20
413
409
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # 目標の文字を決める -> シミュレーション import numpy as np S = np.array(list(read().rstrip())) def F(S, x): A = S == x t = 0 while True: if np.all(A): return t A = A[:-1] | A[1:] t += 1 answer = min(F(S, x) for x in set(S)) print(answer)
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = np.array(list(read().rstrip().decode())) def f(S, a): S = S == a if not np.any(S): return len(S) for n in range(len(S)): if np.all(S): return n S = S[1:] | S[:-1] x = min(f(S, a) for a in S) print(x)
false
9.090909
[ "+import numpy as np", "-# 目標の文字を決める -> シミュレーション", "-import numpy as np", "-", "-S = np.array(list(read().rstrip()))", "+S = np.array(list(read().rstrip().decode()))", "-def F(S, x):", "- A = S == x", "- t = 0", "- while True:", "- if np.all(A):", "- return t", "- ...
false
0.390391
0.507426
0.769355
[ "s782507901", "s740533244" ]
u882620594
p03329
python
s272158325
s601673190
758
363
3,992
3,992
Accepted
Accepted
52.11
N = int(eval(input())) dp = [0 for i in range(N+1)] dp[1] = 1 roku = 0 kyu = 0 for i in range(2, N+1): if i == 6**(roku+1): roku += 1 if i == 9**(kyu+1): kyu += 1 kouho = [1] for j in range(roku): kouho.append(6**(j+1)) for j in range(kyu): kouho.append(9**(j+1)) size = len(kouho) small = 1000000 for j in range(size): if dp[i - kouho[j]] + 1 < small: small = dp[i - kouho[j]] + 1 dp[i] = small print((str(dp[N])))
N = int(eval(input())) dp = [0 for i in range(N+1)] dp[1] = 1 kazu = [1] i = 6 while i <= N: kazu.append(i) i*=6 i = 9 while i <= N: kazu.append(i) i*=9 kazu.sort() kazulazor = len(kazu) temp = [1] lentemp = 1 index = 1 for i in range(2, N+1): kouho = [] if index < kazulazor and i == kazu[index]: temp.append(i) index += 1 lentemp += 1 for j in range(lentemp): kouho.append(dp[i-temp[j]]+1) dp[i] = min(kouho) print((str(dp[N])))
23
27
518
512
N = int(eval(input())) dp = [0 for i in range(N + 1)] dp[1] = 1 roku = 0 kyu = 0 for i in range(2, N + 1): if i == 6 ** (roku + 1): roku += 1 if i == 9 ** (kyu + 1): kyu += 1 kouho = [1] for j in range(roku): kouho.append(6 ** (j + 1)) for j in range(kyu): kouho.append(9 ** (j + 1)) size = len(kouho) small = 1000000 for j in range(size): if dp[i - kouho[j]] + 1 < small: small = dp[i - kouho[j]] + 1 dp[i] = small print((str(dp[N])))
N = int(eval(input())) dp = [0 for i in range(N + 1)] dp[1] = 1 kazu = [1] i = 6 while i <= N: kazu.append(i) i *= 6 i = 9 while i <= N: kazu.append(i) i *= 9 kazu.sort() kazulazor = len(kazu) temp = [1] lentemp = 1 index = 1 for i in range(2, N + 1): kouho = [] if index < kazulazor and i == kazu[index]: temp.append(i) index += 1 lentemp += 1 for j in range(lentemp): kouho.append(dp[i - temp[j]] + 1) dp[i] = min(kouho) print((str(dp[N])))
false
14.814815
[ "-roku = 0", "-kyu = 0", "+kazu = [1]", "+i = 6", "+while i <= N:", "+ kazu.append(i)", "+ i *= 6", "+i = 9", "+while i <= N:", "+ kazu.append(i)", "+ i *= 9", "+kazu.sort()", "+kazulazor = len(kazu)", "+temp = [1]", "+lentemp = 1", "+index = 1", "- if i == 6 ** (roku ...
false
0.151556
0.00701
21.618453
[ "s272158325", "s601673190" ]
u133936772
p02720
python
s870109108
s447029427
119
108
7,608
7,480
Accepted
Accepted
9.24
n=int(eval(input())) if n<10: print(n); exit() l=[[[] for _ in range(10)] for _ in range(10)] l[0]=[[i] for i in range(10)] c=9 for i in range(9): for j in range(10): for k in (-1,0,1): if 0<=j+k<=9: for h in l[i][j+k]: if j: c+=1 t=j*10**(i+1)+h l[i+1][j]+=[t] if c==n: print(t); exit()
n=int(eval(input())) if n<10: print(n); exit() r=range l=[[[] for _ in r(10)] for _ in r(10)] l[0]=[[i] for i in r(10)] c=9 for i in r(9): for j in r(10): for k in r(-1,2): if 0<=j+k<=9: for h in l[i][j+k]: if j: c+=1 t=j*10**(i+1)+h l[i+1][j]+=[t] if c==n: print(t); exit()
14
15
354
342
n = int(eval(input())) if n < 10: print(n) exit() l = [[[] for _ in range(10)] for _ in range(10)] l[0] = [[i] for i in range(10)] c = 9 for i in range(9): for j in range(10): for k in (-1, 0, 1): if 0 <= j + k <= 9: for h in l[i][j + k]: if j: c += 1 t = j * 10 ** (i + 1) + h l[i + 1][j] += [t] if c == n: print(t) exit()
n = int(eval(input())) if n < 10: print(n) exit() r = range l = [[[] for _ in r(10)] for _ in r(10)] l[0] = [[i] for i in r(10)] c = 9 for i in r(9): for j in r(10): for k in r(-1, 2): if 0 <= j + k <= 9: for h in l[i][j + k]: if j: c += 1 t = j * 10 ** (i + 1) + h l[i + 1][j] += [t] if c == n: print(t) exit()
false
6.666667
[ "-l = [[[] for _ in range(10)] for _ in range(10)]", "-l[0] = [[i] for i in range(10)]", "+r = range", "+l = [[[] for _ in r(10)] for _ in r(10)]", "+l[0] = [[i] for i in r(10)]", "-for i in range(9):", "- for j in range(10):", "- for k in (-1, 0, 1):", "+for i in r(9):", "+ for j in ...
false
0.062316
0.059696
1.043891
[ "s870109108", "s447029427" ]
u554781254
p02659
python
s555687558
s663914619
24
21
9,084
9,048
Accepted
Accepted
12.5
import sys import math sys.setrecursionlimit(10 ** 9) input = sys.stdin.readline A, B = list(map(float, input().split())) A = int(A) B_tmp = int(B * 10**2 + 0.5) total = A * B_tmp total //= 100 # total = math.floor(total) print((int(total)))
import sys sys.setrecursionlimit(10 ** 9) input = sys.stdin.readline A, B = list(map(float, input().split())) A = int(A) B = int(B * 10**2 + 0.5) total = A * B total //= 100 print(total)
14
12
250
195
import sys import math sys.setrecursionlimit(10**9) input = sys.stdin.readline A, B = list(map(float, input().split())) A = int(A) B_tmp = int(B * 10**2 + 0.5) total = A * B_tmp total //= 100 # total = math.floor(total) print((int(total)))
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline A, B = list(map(float, input().split())) A = int(A) B = int(B * 10**2 + 0.5) total = A * B total //= 100 print(total)
false
14.285714
[ "-import math", "-B_tmp = int(B * 10**2 + 0.5)", "-total = A * B_tmp", "+B = int(B * 10**2 + 0.5)", "+total = A * B", "-# total = math.floor(total)", "-print((int(total)))", "+print(total)" ]
false
0.038338
0.044241
0.86657
[ "s555687558", "s663914619" ]
u562935282
p03095
python
s866281002
s799485875
83
33
3,960
3,444
Accepted
Accepted
60.24
import string N = int(eval(input())) s = eval(input()) MOD = 10 ** 9 + 7 d = dict() for ss in s: d[ss] = d.get(ss, 0) + 1 ans = 1 for c in string.ascii_lowercase: ans *= (d.get(c, 0) + 1) ans %= MOD ans -= 1 print(ans)
from collections import defaultdict MOD = 10 ** 9 + 7 N = int(eval(input())) s = eval(input()) d = defaultdict(int) for ss in s: d[ss] += 1 ans = 1 for k, v in list(d.items()): ans *= (v + 1) ans %= MOD # v通りの選び方 + 選ばない1通り ans -= 1 print(ans)
16
18
237
262
import string N = int(eval(input())) s = eval(input()) MOD = 10**9 + 7 d = dict() for ss in s: d[ss] = d.get(ss, 0) + 1 ans = 1 for c in string.ascii_lowercase: ans *= d.get(c, 0) + 1 ans %= MOD ans -= 1 print(ans)
from collections import defaultdict MOD = 10**9 + 7 N = int(eval(input())) s = eval(input()) d = defaultdict(int) for ss in s: d[ss] += 1 ans = 1 for k, v in list(d.items()): ans *= v + 1 ans %= MOD # v通りの選び方 + 選ばない1通り ans -= 1 print(ans)
false
11.111111
[ "-import string", "+from collections import defaultdict", "+MOD = 10**9 + 7", "-MOD = 10**9 + 7", "-d = dict()", "+d = defaultdict(int)", "- d[ss] = d.get(ss, 0) + 1", "+ d[ss] += 1", "-for c in string.ascii_lowercase:", "- ans *= d.get(c, 0) + 1", "+for k, v in list(d.items()):", "+ ...
false
0.0463
0.057241
0.808856
[ "s866281002", "s799485875" ]
u247830763
p02572
python
s132316080
s476422441
130
116
105,356
106,864
Accepted
Accepted
10.77
n = int(eval(input())) ls = list(map(int,input().split())) di = [0]*(n+1) mod = 10**9+7 ans = 0 for i in range(1,n+1): di[i] = di[i-1] + ls[i-1] for j in range(n-1): ans += ls[j]*(di[n]-di[j+1]) % mod print((ans%mod))
n = int(eval(input())) mod = 10**9+7 ls = list(map(int,input().split())) di = [i**2 for i in ls] print(((((sum(ls)**2)-(sum(di)))//2)%mod))
10
5
226
135
n = int(eval(input())) ls = list(map(int, input().split())) di = [0] * (n + 1) mod = 10**9 + 7 ans = 0 for i in range(1, n + 1): di[i] = di[i - 1] + ls[i - 1] for j in range(n - 1): ans += ls[j] * (di[n] - di[j + 1]) % mod print((ans % mod))
n = int(eval(input())) mod = 10**9 + 7 ls = list(map(int, input().split())) di = [i**2 for i in ls] print(((((sum(ls) ** 2) - (sum(di))) // 2) % mod))
false
50
[ "+mod = 10**9 + 7", "-di = [0] * (n + 1)", "-mod = 10**9 + 7", "-ans = 0", "-for i in range(1, n + 1):", "- di[i] = di[i - 1] + ls[i - 1]", "-for j in range(n - 1):", "- ans += ls[j] * (di[n] - di[j + 1]) % mod", "-print((ans % mod))", "+di = [i**2 for i in ls]", "+print(((((sum(ls) ** 2) ...
false
0.067309
0.054398
1.237346
[ "s132316080", "s476422441" ]
u454760747
p02949
python
s558004374
s592324201
1,169
1,027
74,548
74,944
Accepted
Accepted
12.15
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N, M, P = list(map(int, input().split())) edges = [] for _ in range(M): a, b, c = list(map(int, input().split())) edges.append([a-1, b-1, -c+P]) def bellnabFord(edges, src, N): inf = float('inf') dist = [inf for i in range(N)] dist[src] = 0 for i in range(2*N): for s, d, c in edges: if s != inf and dist[d] > dist[s]+c: dist[d] = dist[s]+c if i >= N: #N回目以降の更新では-infに。(数字の大きさに影響されない) dist[d] = -float('inf') if i == N-1: prev = dist[-1] return (prev, dist[-1]) prev, dist = bellnabFord(edges, 0, N) if prev != dist: ans = -1 else: ans = max(0, -dist) print(ans)
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N, M, P = list(map(int, input().split())) edges = [] for _ in range(M): a, b, c = list(map(int, input().split())) edges.append([a-1, b-1, -c+P]) def bellnabFord(edges, src, N): inf = float('inf') dist = [inf for i in range(N)] dist[src] = 0 for i in range(2*N): for s, d, c in edges: if dist[d] > dist[s]+c: dist[d] = dist[s]+c if i >= N: #N回目以降の更新では-infに。(数字の大きさに影響されない) dist[d] = -float('inf') if i == N-1: prev = dist[-1] return (prev, dist[-1]) prev, dist = bellnabFord(edges, 0, N) if prev != dist: ans = -1 else: ans = max(0, -dist) print(ans)
35
35
795
782
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N, M, P = list(map(int, input().split())) edges = [] for _ in range(M): a, b, c = list(map(int, input().split())) edges.append([a - 1, b - 1, -c + P]) def bellnabFord(edges, src, N): inf = float("inf") dist = [inf for i in range(N)] dist[src] = 0 for i in range(2 * N): for s, d, c in edges: if s != inf and dist[d] > dist[s] + c: dist[d] = dist[s] + c if i >= N: # N回目以降の更新では-infに。(数字の大きさに影響されない) dist[d] = -float("inf") if i == N - 1: prev = dist[-1] return (prev, dist[-1]) prev, dist = bellnabFord(edges, 0, N) if prev != dist: ans = -1 else: ans = max(0, -dist) print(ans)
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N, M, P = list(map(int, input().split())) edges = [] for _ in range(M): a, b, c = list(map(int, input().split())) edges.append([a - 1, b - 1, -c + P]) def bellnabFord(edges, src, N): inf = float("inf") dist = [inf for i in range(N)] dist[src] = 0 for i in range(2 * N): for s, d, c in edges: if dist[d] > dist[s] + c: dist[d] = dist[s] + c if i >= N: # N回目以降の更新では-infに。(数字の大きさに影響されない) dist[d] = -float("inf") if i == N - 1: prev = dist[-1] return (prev, dist[-1]) prev, dist = bellnabFord(edges, 0, N) if prev != dist: ans = -1 else: ans = max(0, -dist) print(ans)
false
0
[ "- if s != inf and dist[d] > dist[s] + c:", "+ if dist[d] > dist[s] + c:" ]
false
0.042317
0.007938
5.33128
[ "s558004374", "s592324201" ]
u512212329
p02597
python
s135582402
s474057004
55
34
17,196
9,244
Accepted
Accepted
38.18
def main(): eval(input()) # n stones = eval(input()) white_counter = [] white_stones = 0 red_stones = 0 for color in stones: if color == 'W': white_stones += 1 else: red_stones += 1 white_counter.append(white_stones) if red_stones == 0: print((0)) else: print((white_counter[red_stones - 1])) if __name__ == '__main__': main()
def main(): eval(input()) # n stones = eval(input()) reds = stones.count('R') print((stones[:reds].count('W'))) if __name__ == '__main__': main()
21
8
435
161
def main(): eval(input()) # n stones = eval(input()) white_counter = [] white_stones = 0 red_stones = 0 for color in stones: if color == "W": white_stones += 1 else: red_stones += 1 white_counter.append(white_stones) if red_stones == 0: print((0)) else: print((white_counter[red_stones - 1])) if __name__ == "__main__": main()
def main(): eval(input()) # n stones = eval(input()) reds = stones.count("R") print((stones[:reds].count("W"))) if __name__ == "__main__": main()
false
61.904762
[ "- white_counter = []", "- white_stones = 0", "- red_stones = 0", "- for color in stones:", "- if color == \"W\":", "- white_stones += 1", "- else:", "- red_stones += 1", "- white_counter.append(white_stones)", "- if red_stones == 0:", "-...
false
0.040593
0.040577
1.000398
[ "s135582402", "s474057004" ]
u033606236
p03449
python
s459573837
s392196273
21
17
3,064
3,064
Accepted
Accepted
19.05
nums = int(eval(input())) ary = [0,0] for i in range(2): ary[i] = list(map(int,input().split())) max = 0 for i in range(nums): h = 0 w = 0 count = ary[h][w] for x in range(nums): if i == x : h = 1 count += ary[h][w] continue w += 1 count += ary[h][w] if count > max : max = count print(max)
n = int(eval(input())) a = list(map(int,input().split())) b = list(map(int,input().split()))[::-1] dp = [b[0] for _ in range(n)] for i in range(1,n): dp[i] = dp[i-1]+b[i] dp = dp[::-1] c = 0 dp2 = [0 for _ in range(n)] for i in range(n): c += a[i] dp2[i] = c +dp[i] print((max(dp2)))
21
13
398
299
nums = int(eval(input())) ary = [0, 0] for i in range(2): ary[i] = list(map(int, input().split())) max = 0 for i in range(nums): h = 0 w = 0 count = ary[h][w] for x in range(nums): if i == x: h = 1 count += ary[h][w] continue w += 1 count += ary[h][w] if count > max: max = count print(max)
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split()))[::-1] dp = [b[0] for _ in range(n)] for i in range(1, n): dp[i] = dp[i - 1] + b[i] dp = dp[::-1] c = 0 dp2 = [0 for _ in range(n)] for i in range(n): c += a[i] dp2[i] = c + dp[i] print((max(dp2)))
false
38.095238
[ "-nums = int(eval(input()))", "-ary = [0, 0]", "-for i in range(2):", "- ary[i] = list(map(int, input().split()))", "-max = 0", "-for i in range(nums):", "- h = 0", "- w = 0", "- count = ary[h][w]", "- for x in range(nums):", "- if i == x:", "- h = 1", "- ...
false
0.007359
0.036825
0.199834
[ "s459573837", "s392196273" ]
u374103100
p03013
python
s074976172
s132416912
597
441
471,416
460,404
Accepted
Accepted
26.13
# import itertools from collections import Counter from collections import defaultdict import bisect from heapq import heappush, heappop def main(): MOD = 1000000007 N, M = list(map(int, input().split())) A = set() for _ in range(M): a = int(eval(input())) A.add(a) dp = [0] * (N + 1) dp[0] = 1 for i in range(1, N + 1): if i not in A: if i == 1: dp[i] = dp[i - 1] else: dp[i] = dp[i - 1] + dp[i - 2] # print(dp) print((dp[N] % MOD)) if __name__ == '__main__': main()
# import itertools from collections import Counter from collections import defaultdict import bisect from heapq import heappush, heappop def main(): MOD = 1000000007 N, M = list(map(int, input().split())) A = set() for _ in range(M): a = int(eval(input())) A.add(a) dp = [0] * (N + 1) dp[0] = 1 for i in range(1, N + 1): if i not in A: if i == 1: dp[i] = dp[i - 1] else: dp[i] = dp[i - 1] + dp[i - 2] # print(dp) ans = dp[N] % MOD print(ans) if __name__ == '__main__': main()
32
33
612
627
# import itertools from collections import Counter from collections import defaultdict import bisect from heapq import heappush, heappop def main(): MOD = 1000000007 N, M = list(map(int, input().split())) A = set() for _ in range(M): a = int(eval(input())) A.add(a) dp = [0] * (N + 1) dp[0] = 1 for i in range(1, N + 1): if i not in A: if i == 1: dp[i] = dp[i - 1] else: dp[i] = dp[i - 1] + dp[i - 2] # print(dp) print((dp[N] % MOD)) if __name__ == "__main__": main()
# import itertools from collections import Counter from collections import defaultdict import bisect from heapq import heappush, heappop def main(): MOD = 1000000007 N, M = list(map(int, input().split())) A = set() for _ in range(M): a = int(eval(input())) A.add(a) dp = [0] * (N + 1) dp[0] = 1 for i in range(1, N + 1): if i not in A: if i == 1: dp[i] = dp[i - 1] else: dp[i] = dp[i - 1] + dp[i - 2] # print(dp) ans = dp[N] % MOD print(ans) if __name__ == "__main__": main()
false
3.030303
[ "- print((dp[N] % MOD))", "+ ans = dp[N] % MOD", "+ print(ans)" ]
false
0.048119
0.048644
0.989213
[ "s074976172", "s132416912" ]
u281303342
p03112
python
s316700941
s796628095
961
718
16,128
18,044
Accepted
Accepted
25.29
A,B,Q = list(map(int,input().split())) S = [-float("inf")]+[int(eval(input())) for _ in range(A)]+[float("inf")] T = [-float("inf")]+[int(eval(input())) for _ in range(B)]+[float("inf")] X = [int(eval(input())) for _ in range(Q)] from bisect import bisect_left for x in X: Si,Ti = bisect_left(S,x),bisect_left(T,x) Sw,Se = abs(x-S[Si-1]),abs(x-S[Si]) Tw,Te = abs(x-T[Ti-1]),abs(x-T[Ti]) print((min(max(Sw,Tw),max(Se,Te),2*min(Sw,Te)+max(Sw,Te),2*min(Tw,Se)+max(Tw,Se))))
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- A,B,Q = list(map(int,input().split())) S = [-float("inf")] + [int(eval(input())) for _ in range(A)] + [float("inf")] # 両端にダミーを追加 T = [-float("inf")] + [int(eval(input())) for _ in range(B)] + [float("inf")] # 両端にダミーを追加 X = [int(eval(input())) for _ in range(Q)] from bisect import bisect_left for x in X: Si,Ti = bisect_left(S,x),bisect_left(T,x) Sw,Se = abs(x-S[Si-1]),abs(x-S[Si]) Tw,Te = abs(x-T[Ti-1]),abs(x-T[Ti]) ans = [0]*4 ans[0] = max(Sw,Tw) # 両方ともwest ans[1] = max(Se,Te) # 両方ともeast ans[2] = 2*min(Sw,Te)+max(Sw,Te) # SwとTeの近い方に行き、反転して行ってない方に行く ans[3] = 2*min(Tw,Se)+max(Tw,Se) # TwとSeの近い方に行き、反転して行ってない方に行く print((min(ans)))
12
29
473
1,010
A, B, Q = list(map(int, input().split())) S = [-float("inf")] + [int(eval(input())) for _ in range(A)] + [float("inf")] T = [-float("inf")] + [int(eval(input())) for _ in range(B)] + [float("inf")] X = [int(eval(input())) for _ in range(Q)] from bisect import bisect_left for x in X: Si, Ti = bisect_left(S, x), bisect_left(T, x) Sw, Se = abs(x - S[Si - 1]), abs(x - S[Si]) Tw, Te = abs(x - T[Ti - 1]), abs(x - T[Ti]) print( ( min( max(Sw, Tw), max(Se, Te), 2 * min(Sw, Te) + max(Sw, Te), 2 * min(Tw, Se) + max(Tw, Se), ) ) )
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- A, B, Q = list(map(int, input().split())) S = ( [-float("inf")] + [int(eval(input())) for _ in range(A)] + [float("inf")] ) # 両端にダミーを追加 T = ( [-float("inf")] + [int(eval(input())) for _ in range(B)] + [float("inf")] ) # 両端にダミーを追加 X = [int(eval(input())) for _ in range(Q)] from bisect import bisect_left for x in X: Si, Ti = bisect_left(S, x), bisect_left(T, x) Sw, Se = abs(x - S[Si - 1]), abs(x - S[Si]) Tw, Te = abs(x - T[Ti - 1]), abs(x - T[Ti]) ans = [0] * 4 ans[0] = max(Sw, Tw) # 両方ともwest ans[1] = max(Se, Te) # 両方ともeast ans[2] = 2 * min(Sw, Te) + max(Sw, Te) # SwとTeの近い方に行き、反転して行ってない方に行く ans[3] = 2 * min(Tw, Se) + max(Tw, Se) # TwとSeの近い方に行き、反転して行ってない方に行く print((min(ans)))
false
58.62069
[ "+# Python3 (3.4.3)", "+import sys", "+", "+input = sys.stdin.readline", "+# function", "+# main", "-S = [-float(\"inf\")] + [int(eval(input())) for _ in range(A)] + [float(\"inf\")]", "-T = [-float(\"inf\")] + [int(eval(input())) for _ in range(B)] + [float(\"inf\")]", "+S = (", "+ [-float(\"i...
false
0.082046
0.079863
1.027336
[ "s316700941", "s796628095" ]
u201234972
p03700
python
s759017480
s420923596
1,481
1,276
7,072
7,076
Accepted
Accepted
13.84
N, A, B = list(map( int, input().split())) hmax = 0 H = [ int( eval(input())) for _ in range(N)] #hmax = max(H) L = 0 R = 10**9+1#hmax//B + 1 add = A-B while L != R: now = (L+R)//2 need = 0 for i in range(N): r = H[i] - now*B if r > 0: need += (r-1)//add+1 if need <= now:#うまくいくとき R = now else:#うまくいかないとき L = now+1#うまく行かないので+1している.これがないと無限ループが発生する。 print(L)
N, A, B = list(map( int, input().split())) hmax = 0 H = [ int( eval(input())) for _ in range(N)] hmax = max(H) L = 0 R = hmax//B + 1 add = A-B while R-L != 1:#L != R: now = (L+R)//2 need = 0 for i in range(N): r = H[i] - now*B if r > 0: need += (r-1)//add+1 if need <= now:#うまくいくとき R = now else:#うまくいかないとき L = now#+1#うまく行かないので+1している.これがないと無限ループが発生する。 print(R)
19
19
427
429
N, A, B = list(map(int, input().split())) hmax = 0 H = [int(eval(input())) for _ in range(N)] # hmax = max(H) L = 0 R = 10**9 + 1 # hmax//B + 1 add = A - B while L != R: now = (L + R) // 2 need = 0 for i in range(N): r = H[i] - now * B if r > 0: need += (r - 1) // add + 1 if need <= now: # うまくいくとき R = now else: # うまくいかないとき L = now + 1 # うまく行かないので+1している.これがないと無限ループが発生する。 print(L)
N, A, B = list(map(int, input().split())) hmax = 0 H = [int(eval(input())) for _ in range(N)] hmax = max(H) L = 0 R = hmax // B + 1 add = A - B while R - L != 1: # L != R: now = (L + R) // 2 need = 0 for i in range(N): r = H[i] - now * B if r > 0: need += (r - 1) // add + 1 if need <= now: # うまくいくとき R = now else: # うまくいかないとき L = now # +1#うまく行かないので+1している.これがないと無限ループが発生する。 print(R)
false
0
[ "-# hmax = max(H)", "+hmax = max(H)", "-R = 10**9 + 1 # hmax//B + 1", "+R = hmax // B + 1", "-while L != R:", "+while R - L != 1: # L != R:", "- L = now + 1 # うまく行かないので+1している.これがないと無限ループが発生する。", "-print(L)", "+ L = now # +1#うまく行かないので+1している.これがないと無限ループが発生する。", "+print(R)" ]
false
0.035581
0.057515
0.618646
[ "s759017480", "s420923596" ]
u186838327
p03152
python
s613909121
s919786858
1,755
842
3,316
45,096
Accepted
Accepted
52.02
n, m = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10**9+7 A_ = set(A) B_ = set(B) if len(A) != len(A_) or len(B) != len(B_): print((0)) exit() A.sort() B.sort() import bisect ans = 1 for i in reversed(list(range(1, n*m+1))): if i in A_ and i in B_: ans *= 1 elif i in A_ and i not in B_: ans *= (len(B)-bisect.bisect_left(B, i)) elif i not in A_ and i in B_: ans *= (len(A)-bisect.bisect_left(A, i)) else: a = len(A)-bisect.bisect_left(A, i) b = len(B)-bisect.bisect_left(B, i) ans *= a*b-(len(A)*len(B)-i) ans %= mod print(ans)
n, m = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10**9+7 SA = set(A) SB = set(B) A.sort() B.sort() if len(SA) != len(A) or len(SB) != len(B): print((0)) exit() ans = 1 import bisect for i in reversed(list(range(1, n*m+1))): if i in SA and i in SB: ans *= 1 elif i in SA: j = bisect.bisect_left(B, i) ans *= m-j elif i in SB: j = bisect.bisect_left(A, i) ans *= n-j else: j = bisect.bisect_left(A, i) k = bisect.bisect_left(B, i) ans *= (n-j)*(m-k) - (n*m-i) ans %= mod print(ans)
33
32
700
660
n, m = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10**9 + 7 A_ = set(A) B_ = set(B) if len(A) != len(A_) or len(B) != len(B_): print((0)) exit() A.sort() B.sort() import bisect ans = 1 for i in reversed(list(range(1, n * m + 1))): if i in A_ and i in B_: ans *= 1 elif i in A_ and i not in B_: ans *= len(B) - bisect.bisect_left(B, i) elif i not in A_ and i in B_: ans *= len(A) - bisect.bisect_left(A, i) else: a = len(A) - bisect.bisect_left(A, i) b = len(B) - bisect.bisect_left(B, i) ans *= a * b - (len(A) * len(B) - i) ans %= mod print(ans)
n, m = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10**9 + 7 SA = set(A) SB = set(B) A.sort() B.sort() if len(SA) != len(A) or len(SB) != len(B): print((0)) exit() ans = 1 import bisect for i in reversed(list(range(1, n * m + 1))): if i in SA and i in SB: ans *= 1 elif i in SA: j = bisect.bisect_left(B, i) ans *= m - j elif i in SB: j = bisect.bisect_left(A, i) ans *= n - j else: j = bisect.bisect_left(A, i) k = bisect.bisect_left(B, i) ans *= (n - j) * (m - k) - (n * m - i) ans %= mod print(ans)
false
3.030303
[ "-A_ = set(A)", "-B_ = set(B)", "-if len(A) != len(A_) or len(B) != len(B_):", "+SA = set(A)", "+SB = set(B)", "+A.sort()", "+B.sort()", "+if len(SA) != len(A) or len(SB) != len(B):", "-A.sort()", "-B.sort()", "+ans = 1", "-ans = 1", "- if i in A_ and i in B_:", "+ if i in SA and i i...
false
0.038821
0.048169
0.805931
[ "s613909121", "s919786858" ]
u076917070
p03103
python
s096815961
s438190449
308
284
20,072
16,944
Accepted
Accepted
7.79
import sys input=sys.stdin.readline N,M = list(map(int, input().split())) A = [] for i in range(N): a,b = list(map(int, input().split())) A.append([a,b]) A.sort() x = 0 for a in A: if M == 0: break while a[1] > 0: a[1] -= 1 M -= 1 x += a[0] if M == 0: break print(x)
import sys input=sys.stdin.readline N,M = list(map(int, input().split())) A = [] for i in range(N): a,b = list(map(int, input().split())) A.append((a,b)) A.sort() ans = 0 for a,b in A: if M == 0: break n = M if M <= b else b M -= n ans += n * a print(ans)
22
19
347
303
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = [] for i in range(N): a, b = list(map(int, input().split())) A.append([a, b]) A.sort() x = 0 for a in A: if M == 0: break while a[1] > 0: a[1] -= 1 M -= 1 x += a[0] if M == 0: break print(x)
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = [] for i in range(N): a, b = list(map(int, input().split())) A.append((a, b)) A.sort() ans = 0 for a, b in A: if M == 0: break n = M if M <= b else b M -= n ans += n * a print(ans)
false
13.636364
[ "- A.append([a, b])", "+ A.append((a, b))", "-x = 0", "-for a in A:", "+ans = 0", "+for a, b in A:", "- while a[1] > 0:", "- a[1] -= 1", "- M -= 1", "- x += a[0]", "- if M == 0:", "- break", "-print(x)", "+ n = M if M <= b else b", "+ ...
false
0.040716
0.036404
1.118463
[ "s096815961", "s438190449" ]
u497596438
p03287
python
s896698754
s227579230
367
126
68,332
15,084
Accepted
Accepted
65.67
from math import factorial from math import sqrt from math import ceil from itertools import permutations from heapq import * from collections import defaultdict from copy import deepcopy from math import log N,M=list(map(int,input().split())) def nCr(n,r): a=factorial(n) b=factorial(n-r) c=factorial(r) return int(a//(b*c)) A=[int(i)%M for i in input().split()] L=[0] dic=defaultdict(int) dic[0]+=1 for i in range(N): a=(L[-1]+A[i])%M L.append(a) dic[a]+=1 sum=0 for i in list(dic.keys()): if dic[i]>=2: sum+=nCr(dic[i],2) print(sum)
from collections import defaultdict N,M=list(map(int,input().split())) A=list(map(int,input().split())) B=[0]*(N+1) C=defaultdict(int) C[0]+=1 for i in range(N): B[i+1]=(B[i]+A[i])%M C[B[i+1]]+=1 ans=0 for i in list(C.values()): ans+=i*(i-1)//2 print(ans)
28
14
592
270
from math import factorial from math import sqrt from math import ceil from itertools import permutations from heapq import * from collections import defaultdict from copy import deepcopy from math import log N, M = list(map(int, input().split())) def nCr(n, r): a = factorial(n) b = factorial(n - r) c = factorial(r) return int(a // (b * c)) A = [int(i) % M for i in input().split()] L = [0] dic = defaultdict(int) dic[0] += 1 for i in range(N): a = (L[-1] + A[i]) % M L.append(a) dic[a] += 1 sum = 0 for i in list(dic.keys()): if dic[i] >= 2: sum += nCr(dic[i], 2) print(sum)
from collections import defaultdict N, M = list(map(int, input().split())) A = list(map(int, input().split())) B = [0] * (N + 1) C = defaultdict(int) C[0] += 1 for i in range(N): B[i + 1] = (B[i] + A[i]) % M C[B[i + 1]] += 1 ans = 0 for i in list(C.values()): ans += i * (i - 1) // 2 print(ans)
false
50
[ "-from math import factorial", "-from math import sqrt", "-from math import ceil", "-from itertools import permutations", "-from heapq import *", "-from copy import deepcopy", "-from math import log", "-", "-", "-def nCr(n, r):", "- a = factorial(n)", "- b = factorial(n - r)", "- c ...
false
0.040565
0.039882
1.017113
[ "s896698754", "s227579230" ]
u368249389
p02717
python
s869286067
s373832369
188
168
38,384
38,256
Accepted
Accepted
10.64
# Problem A A, B, C = list(map(int, input().split())) tmp = B B = A A = tmp tmp = A A = C C = tmp # output print(("%d %d %d"%(A, B, C)))
# Problem A - ABC Swap # input X, Y, Z = list(map(int, input().split())) # swap tmp = X X = Y Y = tmp tmp = X X = Z Z = tmp # output print(("%d %d %d"%(X, Y, Z)))
13
15
144
172
# Problem A A, B, C = list(map(int, input().split())) tmp = B B = A A = tmp tmp = A A = C C = tmp # output print(("%d %d %d" % (A, B, C)))
# Problem A - ABC Swap # input X, Y, Z = list(map(int, input().split())) # swap tmp = X X = Y Y = tmp tmp = X X = Z Z = tmp # output print(("%d %d %d" % (X, Y, Z)))
false
13.333333
[ "-# Problem A", "-A, B, C = list(map(int, input().split()))", "-tmp = B", "-B = A", "-A = tmp", "-tmp = A", "-A = C", "-C = tmp", "+# Problem A - ABC Swap", "+# input", "+X, Y, Z = list(map(int, input().split()))", "+# swap", "+tmp = X", "+X = Y", "+Y = tmp", "+tmp = X", "+X = Z", ...
false
0.078676
0.04118
1.910515
[ "s869286067", "s373832369" ]
u250583425
p03274
python
s377118514
s220425643
75
69
15,028
15,028
Accepted
Accepted
8
import sys def input(): return sys.stdin.readline().rstrip() def solve(l, m): if l < m: return l * 2 + m else: return l + m * 2 def main(): N, K = list(map(int, input().split())) x = tuple(map(int, input().split())) right_x = [i for i in x if i >= 0][:K] left_x = [-i for i in x if i < 0][-K:] left_len = len(left_x) right_len = len(right_x) if right_len < K: right_x += [10 ** 9 + 1] * (K - right_len) if left_len < K: left_x = [10 ** 9 + 1] * (K - left_len) + left_x right_x = [0] + right_x left_x += [0] ans = 10 ** 9 for i in range(K + 1): tmp_ans = solve(left_x[i], right_x[i]) if tmp_ans < ans: ans = tmp_ans print(ans) if __name__ == '__main__': main()
import sys def input(): return sys.stdin.readline().rstrip() def solve(l, r): lv = abs(l) rv = abs(r) if (l < 0) ^ (r < 0): return lv + rv + min(lv, rv) else: return max(lv, rv) def main(): N, K = list(map(int, input().split())) x = tuple(map(int, input().split())) ans = 10 ** 9 for i in range(N - K + 1): tmp_ans = solve(x[i], x[i + K - 1]) if tmp_ans < ans: ans = tmp_ans print(ans) if __name__ == '__main__': main()
34
25
817
527
import sys def input(): return sys.stdin.readline().rstrip() def solve(l, m): if l < m: return l * 2 + m else: return l + m * 2 def main(): N, K = list(map(int, input().split())) x = tuple(map(int, input().split())) right_x = [i for i in x if i >= 0][:K] left_x = [-i for i in x if i < 0][-K:] left_len = len(left_x) right_len = len(right_x) if right_len < K: right_x += [10**9 + 1] * (K - right_len) if left_len < K: left_x = [10**9 + 1] * (K - left_len) + left_x right_x = [0] + right_x left_x += [0] ans = 10**9 for i in range(K + 1): tmp_ans = solve(left_x[i], right_x[i]) if tmp_ans < ans: ans = tmp_ans print(ans) if __name__ == "__main__": main()
import sys def input(): return sys.stdin.readline().rstrip() def solve(l, r): lv = abs(l) rv = abs(r) if (l < 0) ^ (r < 0): return lv + rv + min(lv, rv) else: return max(lv, rv) def main(): N, K = list(map(int, input().split())) x = tuple(map(int, input().split())) ans = 10**9 for i in range(N - K + 1): tmp_ans = solve(x[i], x[i + K - 1]) if tmp_ans < ans: ans = tmp_ans print(ans) if __name__ == "__main__": main()
false
26.470588
[ "-def solve(l, m):", "- if l < m:", "- return l * 2 + m", "+def solve(l, r):", "+ lv = abs(l)", "+ rv = abs(r)", "+ if (l < 0) ^ (r < 0):", "+ return lv + rv + min(lv, rv)", "- return l + m * 2", "+ return max(lv, rv)", "- right_x = [i for i in x if i >...
false
0.103451
0.042993
2.40622
[ "s377118514", "s220425643" ]
u970197315
p03834
python
s110030752
s738516650
184
17
38,256
2,940
Accepted
Accepted
90.76
s=eval(input()) print((s.replace(',',' ')))
s=eval(input()) s=s.replace(","," ") print(s)
2
6
36
48
s = eval(input()) print((s.replace(",", " ")))
s = eval(input()) s = s.replace(",", " ") print(s)
false
66.666667
[ "-print((s.replace(\",\", \" \")))", "+s = s.replace(\",\", \" \")", "+print(s)" ]
false
0.035641
0.066776
0.533735
[ "s110030752", "s738516650" ]
u603234915
p04025
python
s450451586
s062214179
25
23
3,064
3,188
Accepted
Accepted
8
def abss(x, y): return abs(x-y)**2 def main(): N = int(eval(input())) l = list(map(int, input().split())) ans = 10000000 min_l = min(l) max_l = max(l) for y in range(min_l, max_l+1): temp = 0 for x in l: temp += abss(x, y) ans = min(ans, temp) print(ans) if __name__ == '__main__': main()
def main(): N = int(eval(input())) l = list(map(int, input().split())) ans = 10000000 min_l = min(l) max_l = max(l) for y in range(min_l, max_l+1): temp = 0 for x in l: temp += (x - y) ** 2 ans = min(ans, temp) print(ans) if __name__ == '__main__': main()
18
15
373
332
def abss(x, y): return abs(x - y) ** 2 def main(): N = int(eval(input())) l = list(map(int, input().split())) ans = 10000000 min_l = min(l) max_l = max(l) for y in range(min_l, max_l + 1): temp = 0 for x in l: temp += abss(x, y) ans = min(ans, temp) print(ans) if __name__ == "__main__": main()
def main(): N = int(eval(input())) l = list(map(int, input().split())) ans = 10000000 min_l = min(l) max_l = max(l) for y in range(min_l, max_l + 1): temp = 0 for x in l: temp += (x - y) ** 2 ans = min(ans, temp) print(ans) if __name__ == "__main__": main()
false
16.666667
[ "-def abss(x, y):", "- return abs(x - y) ** 2", "-", "-", "- temp += abss(x, y)", "+ temp += (x - y) ** 2" ]
false
0.042035
0.032558
1.291068
[ "s450451586", "s062214179" ]
u352394527
p00439
python
s710589448
s886282413
310
280
9,604
9,612
Accepted
Accepted
9.68
while True: n,k = list(map(int,input().split())) if n == 0 and k == 0: break lst = [] for i in range(n): lst.append(int(eval(input()))) count = 0 for i in range(k): count += lst[i] ans = count for i in range(k, n): count += lst[i] count -= lst[i - k] ans = max(ans,count) print(ans)
def main(): while True: n,k = list(map(int,input().split())) if n == 0 and k == 0: break lst = [] for i in range(n): lst.append(int(eval(input()))) count = 0 for i in range(k): count += lst[i] ans = count for i in range(k, n): count += lst[i] count -= lst[i - k] ans = max(ans,count) print(ans) if __name__ == '__main__': main()
17
20
330
415
while True: n, k = list(map(int, input().split())) if n == 0 and k == 0: break lst = [] for i in range(n): lst.append(int(eval(input()))) count = 0 for i in range(k): count += lst[i] ans = count for i in range(k, n): count += lst[i] count -= lst[i - k] ans = max(ans, count) print(ans)
def main(): while True: n, k = list(map(int, input().split())) if n == 0 and k == 0: break lst = [] for i in range(n): lst.append(int(eval(input()))) count = 0 for i in range(k): count += lst[i] ans = count for i in range(k, n): count += lst[i] count -= lst[i - k] ans = max(ans, count) print(ans) if __name__ == "__main__": main()
false
15
[ "-while True:", "- n, k = list(map(int, input().split()))", "- if n == 0 and k == 0:", "- break", "- lst = []", "- for i in range(n):", "- lst.append(int(eval(input())))", "- count = 0", "- for i in range(k):", "- count += lst[i]", "- ans = count", "- ...
false
0.036132
0.036237
0.997115
[ "s710589448", "s886282413" ]
u537782349
p03775
python
s209837606
s373015590
243
33
3,188
3,060
Accepted
Accepted
86.42
def m_c_d(x, y): if x == 0: return y elif y == 0: return x else: return m_c_d(y, x % y) a = int(eval(input())) b = 0 for i in range(int(a ** 0.5 + 1), 1, -1): b = max(m_c_d(a, i), b) print((max(len(str(b)), len(str(a // b)))))
a = int(eval(input())) b = 10 ** 10 for i in range(1, int(a ** 0.5) + 1): if a % i == 0: b = min(b, max(len(str(i)), len(str(a // i)))) print(b)
15
6
276
156
def m_c_d(x, y): if x == 0: return y elif y == 0: return x else: return m_c_d(y, x % y) a = int(eval(input())) b = 0 for i in range(int(a**0.5 + 1), 1, -1): b = max(m_c_d(a, i), b) print((max(len(str(b)), len(str(a // b)))))
a = int(eval(input())) b = 10**10 for i in range(1, int(a**0.5) + 1): if a % i == 0: b = min(b, max(len(str(i)), len(str(a // i)))) print(b)
false
60
[ "-def m_c_d(x, y):", "- if x == 0:", "- return y", "- elif y == 0:", "- return x", "- else:", "- return m_c_d(y, x % y)", "-", "-", "-b = 0", "-for i in range(int(a**0.5 + 1), 1, -1):", "- b = max(m_c_d(a, i), b)", "-print((max(len(str(b)), len(str(a // b))))...
false
0.094036
0.04209
2.234158
[ "s209837606", "s373015590" ]
u339199690
p02981
python
s889882240
s760242832
39
29
5,244
9,092
Accepted
Accepted
25.64
import sys, heapq, bisect, math, fractions from collections import deque N, A, B = list(map(int, input().split())) print((min(A * N, B)))
N, A, B = list(map(int, input().split())) print((min(A * N, B)))
6
3
136
60
import sys, heapq, bisect, math, fractions from collections import deque N, A, B = list(map(int, input().split())) print((min(A * N, B)))
N, A, B = list(map(int, input().split())) print((min(A * N, B)))
false
50
[ "-import sys, heapq, bisect, math, fractions", "-from collections import deque", "-" ]
false
0.077019
0.056594
1.360891
[ "s889882240", "s760242832" ]
u034128150
p02728
python
s772703580
s771507968
1,513
1,344
196,180
185,452
Accepted
Accepted
11.17
from itertools import accumulate MOD = 10 ** 9 + 7 table_len = 2 * 10 ** 5 + 10 fac = [1, 1] for i in range(2, table_len): fac.append(fac[-1] * i % MOD) finv = [0] * table_len finv[-1] = pow(fac[-1], MOD - 2, MOD) for i in range(table_len-1, -1, -1): finv[i-1] = finv[i] * i % MOD N = int(eval(input())) adj = [[] for _ in range(N+1)] for _ in range(N-1): a, b = list(map(int, input().split())) adj[a].append(b) adj[b].append(a) dfs_order = [] parent = [0] * (N+1) root = 1 stack = [root] while stack: node = stack.pop() dfs_order.append(node) for child in adj[node]: if child != parent[node]: parent[child] = node stack.append(child) dp1_size = [1] * (N+1) for node in reversed(dfs_order): for child in adj[node]: if child != parent[node]: dp1_size[node] += dp1_size[child] dp2_size = [0] * (N+1) for node in dfs_order: around = [dp1_size[next_node] if next_node != parent[node] else dp2_size[node] for next_node in adj[node]] from_left = [0] + list(accumulate(around))[:-1] from_right = list(accumulate(reversed(around)))[-2::-1] + [0] without = [l + r for l, r in zip(from_left, from_right)] for next_node, value in zip(adj[node], without): if next_node != parent[node]: dp2_size[next_node] += value + 1 dp1 = [1] * (N+1) for node in reversed(dfs_order): s = 0 for child in adj[node]: if child != parent[node]: s += dp1_size[child] dp1[node] *= dp1[child] dp1[node] %= MOD dp1[node] *= finv[dp1_size[child]] dp1[node] %= MOD dp1[node] *= fac[s] dp1[node] %= MOD def func(t1, t2): size1, value1 = t1 size2, value2 = t2 size = size1 + size2 comb = fac[size] * finv[size1] * finv[size2] % MOD value = comb * value1 * value2 % MOD return (size, value) dp2 = [1] * (N+1) for node in dfs_order: around_size = [dp1_size[next_node] if next_node != parent[node] else dp2_size[node] for next_node in adj[node]] around = [dp1[next_node] if next_node != parent[node] else dp2[node] for next_node in adj[node]] from_left = [(0, 1)] + list(accumulate(list(zip(around_size, around)), func))[:-1] from_right = list(accumulate(reversed(list(zip(around_size, around))), func))[-2::-1] + [(0, 1)] without = [func(l, r) for l, r in zip(from_left, from_right)] for next_node, (_, value) in zip(adj[node], without): if next_node != parent[node]: dp2[next_node] = value for size1, val1, size2, val2 in zip(dp1_size[1:], dp1[1:], dp2_size[1:], dp2[1:]): print((func((size1 - 1, val1), (size2, val2))[1]))
from itertools import accumulate MOD = 10 ** 9 + 7 table_len = 2 * 10 ** 5 + 10 fac = [1, 1] for i in range(2, table_len): fac.append(fac[-1] * i % MOD) finv = [0] * table_len finv[-1] = pow(fac[-1], MOD - 2, MOD) for i in range(table_len-1, -1, -1): finv[i-1] = finv[i] * i % MOD N = int(eval(input())) adj = [[] for _ in range(N+1)] for _ in range(N-1): a, b = list(map(int, input().split())) adj[a].append(b) adj[b].append(a) dfs_order = [] parent = [0] * (N+1) root = 1 stack = [root] while stack: node = stack.pop() dfs_order.append(node) for child in adj[node]: if child != parent[node]: parent[child] = node stack.append(child) def func(t1, t2): size1, value1 = t1 size2, value2 = t2 size = size1 + size2 comb = fac[size] * finv[size1] * finv[size2] % MOD value = comb * value1 * value2 % MOD return (size, value) dp1 = [(0, 1)] * (N+1) for node in reversed(dfs_order): for child in adj[node]: if child != parent[node]: dp1[node] = func(dp1[node], dp1[child]) dp1[node] = (dp1[node][0] + 1, dp1[node][1]) dp2 = [(0, 1)] * (N+1) for node in dfs_order: around = [dp1[next_node] if next_node != parent[node] else dp2[node] for next_node in adj[node]] from_left = [(0, 1)] + list(accumulate(around, func))[:-1] from_right = list(accumulate(reversed(around), func))[-2::-1] + [(0, 1)] without = [func(l, r) for l, r in zip(from_left, from_right)] for next_node, t in zip(adj[node], without): if next_node != parent[node]: dp2[next_node] = (t[0] + 1, t[1]) for t1, t2 in zip(dp1[1:], dp2[1:]): print((func((t1[0] - 1, t1[1]), t2)[1]))
89
64
2,768
1,768
from itertools import accumulate MOD = 10**9 + 7 table_len = 2 * 10**5 + 10 fac = [1, 1] for i in range(2, table_len): fac.append(fac[-1] * i % MOD) finv = [0] * table_len finv[-1] = pow(fac[-1], MOD - 2, MOD) for i in range(table_len - 1, -1, -1): finv[i - 1] = finv[i] * i % MOD N = int(eval(input())) adj = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b = list(map(int, input().split())) adj[a].append(b) adj[b].append(a) dfs_order = [] parent = [0] * (N + 1) root = 1 stack = [root] while stack: node = stack.pop() dfs_order.append(node) for child in adj[node]: if child != parent[node]: parent[child] = node stack.append(child) dp1_size = [1] * (N + 1) for node in reversed(dfs_order): for child in adj[node]: if child != parent[node]: dp1_size[node] += dp1_size[child] dp2_size = [0] * (N + 1) for node in dfs_order: around = [ dp1_size[next_node] if next_node != parent[node] else dp2_size[node] for next_node in adj[node] ] from_left = [0] + list(accumulate(around))[:-1] from_right = list(accumulate(reversed(around)))[-2::-1] + [0] without = [l + r for l, r in zip(from_left, from_right)] for next_node, value in zip(adj[node], without): if next_node != parent[node]: dp2_size[next_node] += value + 1 dp1 = [1] * (N + 1) for node in reversed(dfs_order): s = 0 for child in adj[node]: if child != parent[node]: s += dp1_size[child] dp1[node] *= dp1[child] dp1[node] %= MOD dp1[node] *= finv[dp1_size[child]] dp1[node] %= MOD dp1[node] *= fac[s] dp1[node] %= MOD def func(t1, t2): size1, value1 = t1 size2, value2 = t2 size = size1 + size2 comb = fac[size] * finv[size1] * finv[size2] % MOD value = comb * value1 * value2 % MOD return (size, value) dp2 = [1] * (N + 1) for node in dfs_order: around_size = [ dp1_size[next_node] if next_node != parent[node] else dp2_size[node] for next_node in adj[node] ] around = [ dp1[next_node] if next_node != parent[node] else dp2[node] for next_node in adj[node] ] from_left = [(0, 1)] + list(accumulate(list(zip(around_size, around)), func))[:-1] from_right = list(accumulate(reversed(list(zip(around_size, around))), func))[ -2::-1 ] + [(0, 1)] without = [func(l, r) for l, r in zip(from_left, from_right)] for next_node, (_, value) in zip(adj[node], without): if next_node != parent[node]: dp2[next_node] = value for size1, val1, size2, val2 in zip(dp1_size[1:], dp1[1:], dp2_size[1:], dp2[1:]): print((func((size1 - 1, val1), (size2, val2))[1]))
from itertools import accumulate MOD = 10**9 + 7 table_len = 2 * 10**5 + 10 fac = [1, 1] for i in range(2, table_len): fac.append(fac[-1] * i % MOD) finv = [0] * table_len finv[-1] = pow(fac[-1], MOD - 2, MOD) for i in range(table_len - 1, -1, -1): finv[i - 1] = finv[i] * i % MOD N = int(eval(input())) adj = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b = list(map(int, input().split())) adj[a].append(b) adj[b].append(a) dfs_order = [] parent = [0] * (N + 1) root = 1 stack = [root] while stack: node = stack.pop() dfs_order.append(node) for child in adj[node]: if child != parent[node]: parent[child] = node stack.append(child) def func(t1, t2): size1, value1 = t1 size2, value2 = t2 size = size1 + size2 comb = fac[size] * finv[size1] * finv[size2] % MOD value = comb * value1 * value2 % MOD return (size, value) dp1 = [(0, 1)] * (N + 1) for node in reversed(dfs_order): for child in adj[node]: if child != parent[node]: dp1[node] = func(dp1[node], dp1[child]) dp1[node] = (dp1[node][0] + 1, dp1[node][1]) dp2 = [(0, 1)] * (N + 1) for node in dfs_order: around = [ dp1[next_node] if next_node != parent[node] else dp2[node] for next_node in adj[node] ] from_left = [(0, 1)] + list(accumulate(around, func))[:-1] from_right = list(accumulate(reversed(around), func))[-2::-1] + [(0, 1)] without = [func(l, r) for l, r in zip(from_left, from_right)] for next_node, t in zip(adj[node], without): if next_node != parent[node]: dp2[next_node] = (t[0] + 1, t[1]) for t1, t2 in zip(dp1[1:], dp2[1:]): print((func((t1[0] - 1, t1[1]), t2)[1]))
false
28.089888
[ "-dp1_size = [1] * (N + 1)", "-for node in reversed(dfs_order):", "- for child in adj[node]:", "- if child != parent[node]:", "- dp1_size[node] += dp1_size[child]", "-dp2_size = [0] * (N + 1)", "-for node in dfs_order:", "- around = [", "- dp1_size[next_node] if next_n...
false
0.266589
0.426508
0.625051
[ "s772703580", "s771507968" ]
u461513098
p03031
python
s146263161
s269271720
45
23
3,064
3,444
Accepted
Accepted
48.89
N, M = list(map(int, input().split())) S = [] for _ in range(M): ipt = [int(i) for i in input().split()] S.append([True if i in ipt[1:] else False for i in range(1, N+1)]) P = [int(p) for p in input().split()] ans = 0 for cmb in range(0, 2**N): b = list(str(bin(cmb)))[2:] cmb_b = ["0"]*(N-len(b)) + b cur_cnd = [0]*M for s_cnd, i in zip(reversed(cmb_b), list(range(N))): for s, j in zip(S, list(range(M))): if s_cnd == "1" and s[i]: cur_cnd[j] = (cur_cnd[j]+1) % 2 if P == cur_cnd: ans += 1 print(ans)
import sys input = sys.stdin.readline def make_switch_set(i, s): if i == N: return [s] else: cs = s.copy() cs.add(i+1) return make_switch_set(i+1, s) + make_switch_set(i+1, cs) def main(): ans = 0 for ss in switch_set: count = 0 for switches, p in zip(S, P): match_num = len(ss & switches) if match_num % 2 == p: count += 1 if count == M: ans += 1 print(ans) if __name__ == "__main__": N, M = list(map(int, input().split())) S = [] for _ in range(M): ipts = [int(ipt) for ipt in input().split()] S.append(set(ipts[1:])) P = [int(p) for p in input().split()] switch_set = make_switch_set(0, set()) main()
20
37
577
809
N, M = list(map(int, input().split())) S = [] for _ in range(M): ipt = [int(i) for i in input().split()] S.append([True if i in ipt[1:] else False for i in range(1, N + 1)]) P = [int(p) for p in input().split()] ans = 0 for cmb in range(0, 2**N): b = list(str(bin(cmb)))[2:] cmb_b = ["0"] * (N - len(b)) + b cur_cnd = [0] * M for s_cnd, i in zip(reversed(cmb_b), list(range(N))): for s, j in zip(S, list(range(M))): if s_cnd == "1" and s[i]: cur_cnd[j] = (cur_cnd[j] + 1) % 2 if P == cur_cnd: ans += 1 print(ans)
import sys input = sys.stdin.readline def make_switch_set(i, s): if i == N: return [s] else: cs = s.copy() cs.add(i + 1) return make_switch_set(i + 1, s) + make_switch_set(i + 1, cs) def main(): ans = 0 for ss in switch_set: count = 0 for switches, p in zip(S, P): match_num = len(ss & switches) if match_num % 2 == p: count += 1 if count == M: ans += 1 print(ans) if __name__ == "__main__": N, M = list(map(int, input().split())) S = [] for _ in range(M): ipts = [int(ipt) for ipt in input().split()] S.append(set(ipts[1:])) P = [int(p) for p in input().split()] switch_set = make_switch_set(0, set()) main()
false
45.945946
[ "-N, M = list(map(int, input().split()))", "-S = []", "-for _ in range(M):", "- ipt = [int(i) for i in input().split()]", "- S.append([True if i in ipt[1:] else False for i in range(1, N + 1)])", "-P = [int(p) for p in input().split()]", "-ans = 0", "-for cmb in range(0, 2**N):", "- b = lis...
false
0.051279
0.047925
1.069972
[ "s146263161", "s269271720" ]
u645250356
p02753
python
s914033660
s012486470
171
46
5,676
5,504
Accepted
Accepted
73.1
from collections import Counter,defaultdict,deque from bisect import bisect_left import sys,math,itertools,pprint,fractions,time sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) s = eval(input()) if s[0] != s[1] or s[1] != s[2]: print('Yes') else: print('No')
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) s = eval(input()) print(('No' if s.count('A') == 3 or s.count('B') == 3 else 'Yes'))
13
12
391
439
from collections import Counter, defaultdict, deque from bisect import bisect_left import sys, math, itertools, pprint, fractions, time sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) s = eval(input()) if s[0] != s[1] or s[1] != s[2]: print("Yes") else: print("No")
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify from bisect import bisect_left, bisect_right import sys, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) s = eval(input()) print(("No" if s.count("A") == 3 or s.count("B") == 3 else "Yes"))
false
7.692308
[ "-from bisect import bisect_left", "-import sys, math, itertools, pprint, fractions, time", "+from heapq import heappop, heappush, heapify", "+from bisect import bisect_left, bisect_right", "+import sys, math, itertools, fractions, pprint", "-if s[0] != s[1] or s[1] != s[2]:", "- print(\"Yes\")", "...
false
0.038691
0.047219
0.819389
[ "s914033660", "s012486470" ]
u699089116
p03147
python
s212632981
s401096786
180
164
39,280
38,256
Accepted
Accepted
8.89
n = int(eval(input())) h = list(map(int, input().split())) cnt = 0 while max(set(h)) > 0: flg = False for i in h: if i <= 0: flg = False continue else: if not flg: cnt += 1 flg = True h = list([x-1 for x in h]) print(cnt)
n = int(eval(input())) h = list(map(int, input().split())) ans = h[0] for i in range(n-1): ans += h[i+1] - h[i] if h[i] < h[i+1] else 0 print(ans)
17
8
330
153
n = int(eval(input())) h = list(map(int, input().split())) cnt = 0 while max(set(h)) > 0: flg = False for i in h: if i <= 0: flg = False continue else: if not flg: cnt += 1 flg = True h = list([x - 1 for x in h]) print(cnt)
n = int(eval(input())) h = list(map(int, input().split())) ans = h[0] for i in range(n - 1): ans += h[i + 1] - h[i] if h[i] < h[i + 1] else 0 print(ans)
false
52.941176
[ "-cnt = 0", "-while max(set(h)) > 0:", "- flg = False", "- for i in h:", "- if i <= 0:", "- flg = False", "- continue", "- else:", "- if not flg:", "- cnt += 1", "- flg = True", "- h = list([x - 1 for x in h])", ...
false
0.043882
0.03753
1.169228
[ "s212632981", "s401096786" ]
u503228842
p03700
python
s181439422
s507504802
771
648
76,504
76,504
Accepted
Accepted
15.95
import math N,A,B = list(map(int,input().split())) H = [int(eval(input())) for _ in range(N)] def enough(T): temp = 0 ch = H[:] for h in ch: left = h - B*T if left > 0: #temp += (left + A-B+1)//(A-B) temp += math.ceil(left/(A-B)) #print(temp) if temp > T: return False else: return True #print(enough(2)) ok = 10**15 ng = 0 while ok - ng > 1: mid = (ok + ng)//2 if enough(mid): ok = mid else: ng = mid #print(ok,ng) print(ok)
import math N,A,B = list(map(int,input().split())) H = [int(eval(input())) for _ in range(N)] def enough(T): temp = 0 ch = H[:] for h in ch: left = h - B*T if left > 0: temp += (left + A-B-1)//(A-B) #temp += math.ceil(left/(A-B)) #print(temp) if temp > T: return False else: return True #print(enough(2)) ok = 10**15 ng = 0 while ok - ng > 1: mid = (ok + ng)//2 if enough(mid): ok = mid else: ng = mid #print(ok,ng) print(ok)
32
32
569
569
import math N, A, B = list(map(int, input().split())) H = [int(eval(input())) for _ in range(N)] def enough(T): temp = 0 ch = H[:] for h in ch: left = h - B * T if left > 0: # temp += (left + A-B+1)//(A-B) temp += math.ceil(left / (A - B)) # print(temp) if temp > T: return False else: return True # print(enough(2)) ok = 10**15 ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if enough(mid): ok = mid else: ng = mid # print(ok,ng) print(ok)
import math N, A, B = list(map(int, input().split())) H = [int(eval(input())) for _ in range(N)] def enough(T): temp = 0 ch = H[:] for h in ch: left = h - B * T if left > 0: temp += (left + A - B - 1) // (A - B) # temp += math.ceil(left/(A-B)) # print(temp) if temp > T: return False else: return True # print(enough(2)) ok = 10**15 ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if enough(mid): ok = mid else: ng = mid # print(ok,ng) print(ok)
false
0
[ "- # temp += (left + A-B+1)//(A-B)", "- temp += math.ceil(left / (A - B))", "+ temp += (left + A - B - 1) // (A - B)", "+ # temp += math.ceil(left/(A-B))" ]
false
0.045476
0.048212
0.943268
[ "s181439422", "s507504802" ]
u353797797
p03607
python
s588783923
s751658782
240
85
15,452
12,268
Accepted
Accepted
64.58
from collections import defaultdict import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return 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 main(): n=int(input()) cnt=defaultdict(int) for _ in range(n): a=int(input()) cnt[a]+=1 print(sum(v%2 for v in cnt.values())) main()
from itertools import permutations import sys sys.setrecursionlimit(10 ** 6) from bisect import * from collections import * from heapq import * def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline()[:-1] def LLI(rows_number): return [LI() for _ in range(rows_number)] int1 = lambda x: int(x) - 1 def MI1(): return map(int1, sys.stdin.readline().split()) def LI1(): return list(map(int1, sys.stdin.readline().split())) p2D = lambda x: print(*x, sep="\n") dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] def main(): n=II() s=set() for _ in range(n): a=II() if a in s:s.remove(a) else:s.add(a) print(len(s)) main()
18
29
511
821
from collections import defaultdict import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return 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 main(): n = int(input()) cnt = defaultdict(int) for _ in range(n): a = int(input()) cnt[a] += 1 print(sum(v % 2 for v in cnt.values())) main()
from itertools import permutations import sys sys.setrecursionlimit(10**6) from bisect import * from collections import * from heapq import * def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline()[:-1] def LLI(rows_number): return [LI() for _ in range(rows_number)] int1 = lambda x: int(x) - 1 def MI1(): return map(int1, sys.stdin.readline().split()) def LI1(): return list(map(int1, sys.stdin.readline().split())) p2D = lambda x: print(*x, sep="\n") dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] def main(): n = II() s = set() for _ in range(n): a = II() if a in s: s.remove(a) else: s.add(a) print(len(s)) main()
false
37.931034
[ "-from collections import defaultdict", "+from itertools import permutations", "-int1 = lambda x: int(x) - 1", "-p2D = lambda x: print(*x, sep=\"\\n\")", "+from bisect import *", "+from collections import *", "+from heapq import *", "+", "+", "+def II():", "+ return int(sys.stdin.readline())"...
false
0.042135
0.039115
1.077209
[ "s588783923", "s751658782" ]
u141786930
p02695
python
s008781992
s732856134
958
691
21,304
9,152
Accepted
Accepted
27.87
# C - Many Requirements import itertools N, M, Q = list(map(int, input().split())) TEST = [0] * Q for i in range(Q): TEST[i] = list(int(x) for x in input().split()) nums = [i+1 for i in range(M)] ans = 0 for l in list(itertools.combinations_with_replacement(nums, N)): tmp = 0 for t in TEST: if l[t[1]-1]-l[t[0]-1] ==t[2]: tmp += t[3] else: continue ans = max(ans, tmp) print(ans)
# C - Many Requirements # DFSで解く N, M, Q = list(map(int, input().split())) A = [0] * Q B = [0] * Q C = [0] * Q D = [0] * Q for i in range(Q): A[i], B[i], C[i], D[i] = list(map(int, input().split())) def dfs(L): global ans if len(L)==N+1: tmp = 0 for i in range(Q): if L[B[i]] - L[A[i]] == C[i]: tmp += D[i] ans = max(tmp, ans) return else: for j in range(L[-1], M+1): dfs(L+[j]) return ans ans = 0 print((dfs([1])))
22
27
456
530
# C - Many Requirements import itertools N, M, Q = list(map(int, input().split())) TEST = [0] * Q for i in range(Q): TEST[i] = list(int(x) for x in input().split()) nums = [i + 1 for i in range(M)] ans = 0 for l in list(itertools.combinations_with_replacement(nums, N)): tmp = 0 for t in TEST: if l[t[1] - 1] - l[t[0] - 1] == t[2]: tmp += t[3] else: continue ans = max(ans, tmp) print(ans)
# C - Many Requirements # DFSで解く N, M, Q = list(map(int, input().split())) A = [0] * Q B = [0] * Q C = [0] * Q D = [0] * Q for i in range(Q): A[i], B[i], C[i], D[i] = list(map(int, input().split())) def dfs(L): global ans if len(L) == N + 1: tmp = 0 for i in range(Q): if L[B[i]] - L[A[i]] == C[i]: tmp += D[i] ans = max(tmp, ans) return else: for j in range(L[-1], M + 1): dfs(L + [j]) return ans ans = 0 print((dfs([1])))
false
18.518519
[ "-import itertools", "+# DFSで解く", "+N, M, Q = list(map(int, input().split()))", "+A = [0] * Q", "+B = [0] * Q", "+C = [0] * Q", "+D = [0] * Q", "+for i in range(Q):", "+ A[i], B[i], C[i], D[i] = list(map(int, input().split()))", "-N, M, Q = list(map(int, input().split()))", "-TEST = [0] * Q",...
false
0.047987
0.049231
0.974722
[ "s008781992", "s732856134" ]
u652656291
p03854
python
s340385734
s417595950
23
18
6,516
3,188
Accepted
Accepted
21.74
import re S = eval(input()) ''' メタ文字: ^ = 文字列の先頭、 | = OR + = 直前のパターンを1回以上繰り返し、 $ = 文字列の末尾 ''' if re.match("^(dream|dreamer|erase|eraser)+$", S): print('YES') else: print('NO')
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","") if s: print("NO") else: print("YES")
13
5
189
142
import re S = eval(input()) """ メタ文字: ^ = 文字列の先頭、 | = OR + = 直前のパターンを1回以上繰り返し、 $ = 文字列の末尾 """ if re.match("^(dream|dreamer|erase|eraser)+$", S): print("YES") else: print("NO")
s = ( input() .replace("eraser", "") .replace("erase", "") .replace("dreamer", "") .replace("dream", "") ) if s: print("NO") else: print("YES")
false
61.538462
[ "-import re", "-", "-S = eval(input())", "-\"\"\"", "-メタ文字:", "-^ = 文字列の先頭、", "-| = OR", "-+ = 直前のパターンを1回以上繰り返し、", "-$ = 文字列の末尾", "-\"\"\"", "-if re.match(\"^(dream|dreamer|erase|eraser)+$\", S):", "+s = (", "+ input()", "+ .replace(\"eraser\", \"\")", "+ .replace(\"erase\", \"\...
false
0.043249
0.042027
1.029072
[ "s340385734", "s417595950" ]
u223646582
p03634
python
s437119808
s114705847
1,664
1,523
96,356
145,404
Accepted
Accepted
8.47
from collections import deque N = int(eval(input())) G = [set() for i in range(N)] for _ in range(N-1): a, b, c = list(map(int, input().split())) G[a-1].add((b, c)) G[b-1].add((a, c)) Q, K = list(map(int, input().split())) visited = [False] * N visited[K-1] = True distance = [-1]*N que = deque([(K, 0)]) while que: cur, d = que.popleft() distance[cur-1] = d for nx, nd in G[cur-1]: if visited[nx-1] is False: visited[nx-1] = True que.append((nx, d+nd)) for i in range(Q): x, y = list(map(int, input().split())) print((distance[x-1]+distance[y-1]))
import sys sys.setrecursionlimit(1000000) N = int(eval(input())) G = [set() for i in range(N)] for _ in range(N-1): a, b, c = list(map(int, input().split())) G[a-1].add((b, c)) G[b-1].add((a, c)) Q, K = list(map(int, input().split())) visited = [False] * N visited[K-1] = True distance = [-1]*N def dfs(v, p, d): # 現在の頂点v, vの親p, 現在の距離d distance[v-1] = d for i, c in G[v-1]: if visited[i-1] is False: if i == p: continue dfs(i, v, d+c) return dfs(K, -1, 0) for i in range(Q): x, y = list(map(int, input().split())) print((distance[x-1]+distance[y-1]))
30
34
624
649
from collections import deque N = int(eval(input())) G = [set() for i in range(N)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) G[a - 1].add((b, c)) G[b - 1].add((a, c)) Q, K = list(map(int, input().split())) visited = [False] * N visited[K - 1] = True distance = [-1] * N que = deque([(K, 0)]) while que: cur, d = que.popleft() distance[cur - 1] = d for nx, nd in G[cur - 1]: if visited[nx - 1] is False: visited[nx - 1] = True que.append((nx, d + nd)) for i in range(Q): x, y = list(map(int, input().split())) print((distance[x - 1] + distance[y - 1]))
import sys sys.setrecursionlimit(1000000) N = int(eval(input())) G = [set() for i in range(N)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) G[a - 1].add((b, c)) G[b - 1].add((a, c)) Q, K = list(map(int, input().split())) visited = [False] * N visited[K - 1] = True distance = [-1] * N def dfs(v, p, d): # 現在の頂点v, vの親p, 現在の距離d distance[v - 1] = d for i, c in G[v - 1]: if visited[i - 1] is False: if i == p: continue dfs(i, v, d + c) return dfs(K, -1, 0) for i in range(Q): x, y = list(map(int, input().split())) print((distance[x - 1] + distance[y - 1]))
false
11.764706
[ "-from collections import deque", "+import sys", "+sys.setrecursionlimit(1000000)", "-que = deque([(K, 0)])", "-while que:", "- cur, d = que.popleft()", "- distance[cur - 1] = d", "- for nx, nd in G[cur - 1]:", "- if visited[nx - 1] is False:", "- visited[nx - 1] = True"...
false
0.114344
0.089388
1.279195
[ "s437119808", "s114705847" ]
u138486156
p03945
python
s714308193
s098404288
381
41
3,188
3,188
Accepted
Accepted
89.24
s = eval(input()) ans = 0 while len(s): c = s[0] for i in range(len(s)): if s[i] != c: idx = i break idx2 = i if idx2 == len(s)-1: break s = s[idx:] ans += 1 print(ans)
s = eval(input()) ans = 0 c = s[0] for i in range(len(s)): if s[i] != c: ans += 1 c = s[i] print(ans)
15
8
246
123
s = eval(input()) ans = 0 while len(s): c = s[0] for i in range(len(s)): if s[i] != c: idx = i break idx2 = i if idx2 == len(s) - 1: break s = s[idx:] ans += 1 print(ans)
s = eval(input()) ans = 0 c = s[0] for i in range(len(s)): if s[i] != c: ans += 1 c = s[i] print(ans)
false
46.666667
[ "-while len(s):", "- c = s[0]", "- for i in range(len(s)):", "- if s[i] != c:", "- idx = i", "- break", "- idx2 = i", "- if idx2 == len(s) - 1:", "- break", "- s = s[idx:]", "- ans += 1", "+c = s[0]", "+for i in range(len(s)):", "+ ...
false
0.046753
0.037453
1.248328
[ "s714308193", "s098404288" ]
u678167152
p03045
python
s107213896
s662956869
491
302
109,760
81,484
Accepted
Accepted
38.49
import sys sys.setrecursionlimit(10**8) N, M = list(map(int, input().split())) edge = [[] for _ in range(N)] for i in range(M): a,b,c = list(map(int, input().split())) edge[a-1].append(b-1) edge[b-1].append(a-1) def dfs(v): if len(edge[v])==0: return 0 for u in edge[v]: if visited[u]==False: visited[u]=True dfs(u) return 0 ans = 0 visited = [False]*N for i in range(N): if visited[i]==False: visited[i]=True dfs(i) ans += 1 print(ans)
N, M = list(map(int, input().split())) class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] uf = UnionFind(N) for _ in range(M): x,y,z = list(map(int, input().split())) uf.union(x-1,y-1) ans = len(uf.roots()) print(ans)
26
39
497
756
import sys sys.setrecursionlimit(10**8) N, M = list(map(int, input().split())) edge = [[] for _ in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) edge[a - 1].append(b - 1) edge[b - 1].append(a - 1) def dfs(v): if len(edge[v]) == 0: return 0 for u in edge[v]: if visited[u] == False: visited[u] = True dfs(u) return 0 ans = 0 visited = [False] * N for i in range(N): if visited[i] == False: visited[i] = True dfs(i) ans += 1 print(ans)
N, M = list(map(int, input().split())) class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] uf = UnionFind(N) for _ in range(M): x, y, z = list(map(int, input().split())) uf.union(x - 1, y - 1) ans = len(uf.roots()) print(ans)
false
33.333333
[ "-import sys", "-", "-sys.setrecursionlimit(10**8)", "-edge = [[] for _ in range(N)]", "-for i in range(M):", "- a, b, c = list(map(int, input().split()))", "- edge[a - 1].append(b - 1)", "- edge[b - 1].append(a - 1)", "-def dfs(v):", "- if len(edge[v]) == 0:", "- return 0", ...
false
0.054449
0.041313
1.317966
[ "s107213896", "s662956869" ]
u047796752
p02687
python
s781418957
s088153636
73
61
64,576
61,852
Accepted
Accepted
16.44
from collections import * S = eval(input()) if S=='ABC': print('ARC') else: print('ABC')
S = eval(input()) if S=='ABC': print('ARC') else: print('ABC')
8
6
99
70
from collections import * S = eval(input()) if S == "ABC": print("ARC") else: print("ABC")
S = eval(input()) if S == "ABC": print("ARC") else: print("ABC")
false
25
[ "-from collections import *", "-" ]
false
0.039776
0.1068
0.372435
[ "s781418957", "s088153636" ]
u780025254
p02401
python
s443436509
s526785673
30
20
7,448
5,596
Accepted
Accepted
33.33
while True: data = eval(input()) if '?' in data: break print((eval(data.replace('/', '//'))))
while True: a, op, b = input().split() a = int(a) b = int(b) if op == "?": break elif op == "+": print((a + b)) elif op == "-": print((a - b)) elif op == "*": print((a * b)) elif op == "/": print((a // b))
5
15
109
285
while True: data = eval(input()) if "?" in data: break print((eval(data.replace("/", "//"))))
while True: a, op, b = input().split() a = int(a) b = int(b) if op == "?": break elif op == "+": print((a + b)) elif op == "-": print((a - b)) elif op == "*": print((a * b)) elif op == "/": print((a // b))
false
66.666667
[ "- data = eval(input())", "- if \"?\" in data:", "+ a, op, b = input().split()", "+ a = int(a)", "+ b = int(b)", "+ if op == \"?\":", "- print((eval(data.replace(\"/\", \"//\"))))", "+ elif op == \"+\":", "+ print((a + b))", "+ elif op == \"-\":", "+ prin...
false
0.176145
0.039654
4.442008
[ "s443436509", "s526785673" ]
u644907318
p02888
python
s840392899
s796391884
1,572
638
48,744
75,288
Accepted
Accepted
59.41
from bisect import bisect_left,bisect_right from itertools import combinations N = int(eval(input())) L = sorted(list(map(int,input().split()))) cnt = 0 for x in combinations(list(range(N)),2): i,j = x[0],x[1] if j<i: i,j = j,i indr = bisect_left(L,L[i]+L[j]) indl = bisect_right(L,abs(L[i]-L[j])) if j<indl or i>indr: cnt += indr-indl elif indr>j>=indl and i<indl: cnt += indr-indl-1 elif indr>j and i>=indl: cnt += indr-indl-2 elif j>=indr and indr>i>=indl: cnt += indr-indl-1 print((cnt//3))
from bisect import bisect_right,bisect_left N = int(eval(input())) L = sorted(list(map(int,input().split()))) cnt = 0 for i in range(N-1): for j in range(i+1,N): a = L[i] b = L[j] indU = bisect_left(L,a+b) indL = bisect_right(L,b-a) if j<indU and i>= indL: cnt += indU-indL-2 elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU: cnt += indU-indL-1 elif j<indL or i>=indU: cnt += indU-indL print((cnt//3))
20
17
571
513
from bisect import bisect_left, bisect_right from itertools import combinations N = int(eval(input())) L = sorted(list(map(int, input().split()))) cnt = 0 for x in combinations(list(range(N)), 2): i, j = x[0], x[1] if j < i: i, j = j, i indr = bisect_left(L, L[i] + L[j]) indl = bisect_right(L, abs(L[i] - L[j])) if j < indl or i > indr: cnt += indr - indl elif indr > j >= indl and i < indl: cnt += indr - indl - 1 elif indr > j and i >= indl: cnt += indr - indl - 2 elif j >= indr and indr > i >= indl: cnt += indr - indl - 1 print((cnt // 3))
from bisect import bisect_right, bisect_left N = int(eval(input())) L = sorted(list(map(int, input().split()))) cnt = 0 for i in range(N - 1): for j in range(i + 1, N): a = L[i] b = L[j] indU = bisect_left(L, a + b) indL = bisect_right(L, b - a) if j < indU and i >= indL: cnt += indU - indL - 2 elif indL <= i < indU and j >= indU or i < indL and indL <= j < indU: cnt += indU - indL - 1 elif j < indL or i >= indU: cnt += indU - indL print((cnt // 3))
false
15
[ "-from bisect import bisect_left, bisect_right", "-from itertools import combinations", "+from bisect import bisect_right, bisect_left", "-for x in combinations(list(range(N)), 2):", "- i, j = x[0], x[1]", "- if j < i:", "- i, j = j, i", "- indr = bisect_left(L, L[i] + L[j])", "- ...
false
0.03966
0.035542
1.115871
[ "s840392899", "s796391884" ]
u185896732
p03087
python
s285356478
s479501738
842
289
6,060
6,640
Accepted
Accepted
65.68
n,q=list(map(int,input().split())) s=eval(input()) ac=[0]*(n) for i in range(len(s)-1): if s[i]=="A" and s[i+1]=="C": ac[i+1]=ac[i]+1 else: ac[i+1]=ac[i] #print(ac) # 01122233 # ACACTACG for i in range(q): l,r=list(map(int,input().split())) #print(ac[l:r]) print((ac[r-1]-ac[l-1]))
#import pysnooper #import os,re,sys,operator,math,heapq,string from collections import Counter,deque #from operator import itemgetter #from itertools import accumulate,combinations,groupby,combinations_with_replacement from sys import stdin,setrecursionlimit #from copy import deepcopy setrecursionlimit(10**6) input=stdin.readline n,q=list(map(int,input().split())) s=input().rstrip() ac=[0]*(n+1) for i in range(n-1): if s[i]+s[i+1]=="AC": ac[i+1]=ac[i]+1 else: ac[i+1]=ac[i] for i in range(q): l,r=list(map(int,input().split())) print((ac[r-1]-ac[l-1]))
15
22
311
597
n, q = list(map(int, input().split())) s = eval(input()) ac = [0] * (n) for i in range(len(s) - 1): if s[i] == "A" and s[i + 1] == "C": ac[i + 1] = ac[i] + 1 else: ac[i + 1] = ac[i] # print(ac) # 01122233 # ACACTACG for i in range(q): l, r = list(map(int, input().split())) # print(ac[l:r]) print((ac[r - 1] - ac[l - 1]))
# import pysnooper # import os,re,sys,operator,math,heapq,string from collections import Counter, deque # from operator import itemgetter # from itertools import accumulate,combinations,groupby,combinations_with_replacement from sys import stdin, setrecursionlimit # from copy import deepcopy setrecursionlimit(10**6) input = stdin.readline n, q = list(map(int, input().split())) s = input().rstrip() ac = [0] * (n + 1) for i in range(n - 1): if s[i] + s[i + 1] == "AC": ac[i + 1] = ac[i] + 1 else: ac[i + 1] = ac[i] for i in range(q): l, r = list(map(int, input().split())) print((ac[r - 1] - ac[l - 1]))
false
31.818182
[ "+# import pysnooper", "+# import os,re,sys,operator,math,heapq,string", "+from collections import Counter, deque", "+", "+# from operator import itemgetter", "+# from itertools import accumulate,combinations,groupby,combinations_with_replacement", "+from sys import stdin, setrecursionlimit", "+", "...
false
0.007318
0.03481
0.210241
[ "s285356478", "s479501738" ]
u200887663
p02946
python
s946087374
s708078274
33
18
3,064
3,060
Accepted
Accepted
45.45
k,x=list(map(int,input().split())) right= (1000000)*(-1) left=1000000 al=[] for i in range(x-(k-1),x+1): if i<right or left<i: continue for j in range(k): t=i+j if (i+j in al)!=True and (t<right)==False and (left <t)==False: al.append(i+j) al.sort() print((*al))
#n=int(input()) k,x=map(int,input().split()) #l=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] l=[i for i in range(max(x-k+1,-1000000),min(x+k-1,1000000)+1)] print(*l,sep=" ")
19
8
303
223
k, x = list(map(int, input().split())) right = (1000000) * (-1) left = 1000000 al = [] for i in range(x - (k - 1), x + 1): if i < right or left < i: continue for j in range(k): t = i + j if (i + j in al) != True and (t < right) == False and (left < t) == False: al.append(i + j) al.sort() print((*al))
# n=int(input()) k, x = map(int, input().split()) # l=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] l = [i for i in range(max(x - k + 1, -1000000), min(x + k - 1, 1000000) + 1)] print(*l, sep=" ")
false
57.894737
[ "-k, x = list(map(int, input().split()))", "-right = (1000000) * (-1)", "-left = 1000000", "-al = []", "-for i in range(x - (k - 1), x + 1):", "- if i < right or left < i:", "- continue", "- for j in range(k):", "- t = i + j", "- if (i + j in al) != True and (t < right) ...
false
0.105412
0.046789
2.252912
[ "s946087374", "s708078274" ]
u651235280
p03127
python
s785069670
s059208002
174
142
19,932
22,328
Accepted
Accepted
18.39
import sys from heapq import heapify, heappop, heappush sys.setrecursionlimit(10**7) input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) heapify(a) while len(a) != 1: f = heappop(a) s = heappop(a) s %= f if s != 0: heappush(a, s) heappush(a, f) print((heappop(a)))
import sys from fractions import gcd # from heapq import heapify, heappop, heappush sys.setrecursionlimit(10**7) input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) g = a[0] for i in range(1, n): g = gcd(g, a[i]) print(g) # heapify(a) # while len(a) != 1: # f = heappop(a) # s = heappop(a) # s %= f # if s != 0: # heappush(a, s) # heappush(a, f) # print(heappop(a))
19
23
341
451
import sys from heapq import heapify, heappop, heappush sys.setrecursionlimit(10**7) input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) heapify(a) while len(a) != 1: f = heappop(a) s = heappop(a) s %= f if s != 0: heappush(a, s) heappush(a, f) print((heappop(a)))
import sys from fractions import gcd # from heapq import heapify, heappop, heappush sys.setrecursionlimit(10**7) input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) g = a[0] for i in range(1, n): g = gcd(g, a[i]) print(g) # heapify(a) # while len(a) != 1: # f = heappop(a) # s = heappop(a) # s %= f # if s != 0: # heappush(a, s) # heappush(a, f) # print(heappop(a))
false
17.391304
[ "-from heapq import heapify, heappop, heappush", "+from fractions import gcd", "+# from heapq import heapify, heappop, heappush", "-heapify(a)", "-while len(a) != 1:", "- f = heappop(a)", "- s = heappop(a)", "- s %= f", "- if s != 0:", "- heappush(a, s)", "- heappush(a, f)"...
false
0.04648
0.04932
0.942423
[ "s785069670", "s059208002" ]
u969850098
p02983
python
s676620586
s820168236
752
57
3,064
3,064
Accepted
Accepted
92.42
def main(): L, R = list(map(int, input().split())) if R // 2019 > L // 2019: print((0)) return retval = 2019 for i in range(L, R): for j in range(i+1, R+1): retval = min(retval, (i % 2019 * j % 2019) % 2019) print(retval) return if __name__ == '__main__': main()
def main(): L, R = list(map(int, input().split())) if R // 2019 > L // 2019: print((0)) return retval = 2019 for i in range(L, R): for j in range(i+1, R+1): retval = min(retval, (i % 2019 * j % 2019) % 2019) if retval == 0: print((0)) return print(retval) return if __name__ == '__main__': main()
14
18
336
429
def main(): L, R = list(map(int, input().split())) if R // 2019 > L // 2019: print((0)) return retval = 2019 for i in range(L, R): for j in range(i + 1, R + 1): retval = min(retval, (i % 2019 * j % 2019) % 2019) print(retval) return if __name__ == "__main__": main()
def main(): L, R = list(map(int, input().split())) if R // 2019 > L // 2019: print((0)) return retval = 2019 for i in range(L, R): for j in range(i + 1, R + 1): retval = min(retval, (i % 2019 * j % 2019) % 2019) if retval == 0: print((0)) return print(retval) return if __name__ == "__main__": main()
false
22.222222
[ "+ if retval == 0:", "+ print((0))", "+ return" ]
false
0.068221
0.036404
1.873982
[ "s676620586", "s820168236" ]
u905203728
p02792
python
s841923781
s138330521
200
183
3,064
3,064
Accepted
Accepted
8.5
n=int(eval(input())) A=[[0 for i in range(9)] for j in range(9)] for i in range(1,n+1): if i%10!=0: num=str(i) A[int(num[0])-1][int(num[-1])-1] +=1 cnt=0 for i in range(9): for j in range(9): cnt +=A[i][j]*A[j][i] print(cnt)
n=int(eval(input())) A=[[0 for i in range(10)] for j in range(10)] for i in range(1,n+1): num=str(i) A[int(num[0])][int(num[-1])] +=1 ans=0 for i in range(1,10): for j in range(1,10): ans +=A[i][j]*A[j][i] print(ans)
14
13
266
253
n = int(eval(input())) A = [[0 for i in range(9)] for j in range(9)] for i in range(1, n + 1): if i % 10 != 0: num = str(i) A[int(num[0]) - 1][int(num[-1]) - 1] += 1 cnt = 0 for i in range(9): for j in range(9): cnt += A[i][j] * A[j][i] print(cnt)
n = int(eval(input())) A = [[0 for i in range(10)] for j in range(10)] for i in range(1, n + 1): num = str(i) A[int(num[0])][int(num[-1])] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += A[i][j] * A[j][i] print(ans)
false
7.142857
[ "-A = [[0 for i in range(9)] for j in range(9)]", "+A = [[0 for i in range(10)] for j in range(10)]", "- if i % 10 != 0:", "- num = str(i)", "- A[int(num[0]) - 1][int(num[-1]) - 1] += 1", "-cnt = 0", "-for i in range(9):", "- for j in range(9):", "- cnt += A[i][j] * A[j][i...
false
0.048509
0.046546
1.042165
[ "s841923781", "s138330521" ]
u223646582
p03295
python
s242191062
s049850178
909
681
58,840
57,560
Accepted
Accepted
25.08
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = list(map(int, input().split())) AB.append((a, b)) AB = sorted(AB, key=lambda x: (x[1], x[0])) ans = 1 D = AB[0][1] for i in range(1, M): if AB[i][0] >= D: ans += 1 D = AB[i][1] print(ans)
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = list(map(int, input().split())) AB.append((a, b)) AB = sorted(AB, key=lambda x: x[1]) ans = 1 D = AB[0][1] for i in range(1, M): if AB[i][0] >= D: ans += 1 D = AB[i][1] print(ans)
15
15
293
285
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = list(map(int, input().split())) AB.append((a, b)) AB = sorted(AB, key=lambda x: (x[1], x[0])) ans = 1 D = AB[0][1] for i in range(1, M): if AB[i][0] >= D: ans += 1 D = AB[i][1] print(ans)
N, M = list(map(int, input().split())) AB = [] for _ in range(M): a, b = list(map(int, input().split())) AB.append((a, b)) AB = sorted(AB, key=lambda x: x[1]) ans = 1 D = AB[0][1] for i in range(1, M): if AB[i][0] >= D: ans += 1 D = AB[i][1] print(ans)
false
0
[ "-AB = sorted(AB, key=lambda x: (x[1], x[0]))", "+AB = sorted(AB, key=lambda x: x[1])" ]
false
0.06943
0.048451
1.432997
[ "s242191062", "s049850178" ]
u227082700
p03078
python
s375408106
s088922517
963
805
156,636
152,792
Accepted
Accepted
16.41
x,y,z,k=list(map(int,input().split()));a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split())) aa=[] for i in a: for j in b:aa.append(i+j) aa.sort(reverse=1) aa=aa[:k+1] s=[] for i in aa: for j in c:s.append(i+j) s.sort(reverse=1) for i in range(k):print((s[i]))
from heapq import heappop,heappush;import sys;input=sys.stdin.readline x,y,z,k=list(map(int,input().split()));a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split())) q,h,l=[],[],0 for i in a: for j in b:heappush(q,-(i+j));l+=1 for _ in range(min(l,k)): t=heappop(q) for i in c:heappush(h,t-i) for i in range(k):print((-heappop(h)))
11
9
311
380
x, y, z, k = list(map(int, input().split())) a, b, c = ( list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())), ) aa = [] for i in a: for j in b: aa.append(i + j) aa.sort(reverse=1) aa = aa[: k + 1] s = [] for i in aa: for j in c: s.append(i + j) s.sort(reverse=1) for i in range(k): print((s[i]))
from heapq import heappop, heappush import sys input = sys.stdin.readline x, y, z, k = list(map(int, input().split())) a, b, c = ( list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())), ) q, h, l = [], [], 0 for i in a: for j in b: heappush(q, -(i + j)) l += 1 for _ in range(min(l, k)): t = heappop(q) for i in c: heappush(h, t - i) for i in range(k): print((-heappop(h)))
false
18.181818
[ "+from heapq import heappop, heappush", "+import sys", "+", "+input = sys.stdin.readline", "-aa = []", "+q, h, l = [], [], 0", "- aa.append(i + j)", "-aa.sort(reverse=1)", "-aa = aa[: k + 1]", "-s = []", "-for i in aa:", "- for j in c:", "- s.append(i + j)", "-s.sort(rever...
false
0.039001
0.086449
0.451144
[ "s375408106", "s088922517" ]
u768896740
p02861
python
s243333023
s431804227
351
18
7,972
3,188
Accepted
Accepted
94.87
import itertools import math n = int(eval(input())) li = [] for i in range(n): a = list(map(int, input().split())) li.append(a) p_list = list(itertools.permutations(li, n)) def cal_distance(lis): dis = 0 for i in range(n-1): dis += math.sqrt((lis[i+1][0]-lis[i][0])**2 + (lis[i+1][1] - lis[i][1])**2) return dis total_distance = 0 for i in range(len(p_list)): total_distance += cal_distance(p_list[i]) print((total_distance/len(p_list)))
from itertools import combinations import math n = int(eval(input())) towns = [] for _ in range(n): array = list(map(int, input().split())) towns.append(array) distances = [[0 for _ in range(n)] for _ in range(n)] town_num = list(range(n)) for i, j in combinations(town_num, 2): distance = ((towns[j][0] - towns[i][0])**2 + (towns[j][1] - towns[i][1])**2)**(0.5) distances[i][j] = distance distances[j][i] = distance total_way = math.factorial(n) total = 0 for i in range(n): for j in range(n): total += distances[i][j] * math.factorial(n-1) print((total/total_way))
23
30
489
630
import itertools import math n = int(eval(input())) li = [] for i in range(n): a = list(map(int, input().split())) li.append(a) p_list = list(itertools.permutations(li, n)) def cal_distance(lis): dis = 0 for i in range(n - 1): dis += math.sqrt( (lis[i + 1][0] - lis[i][0]) ** 2 + (lis[i + 1][1] - lis[i][1]) ** 2 ) return dis total_distance = 0 for i in range(len(p_list)): total_distance += cal_distance(p_list[i]) print((total_distance / len(p_list)))
from itertools import combinations import math n = int(eval(input())) towns = [] for _ in range(n): array = list(map(int, input().split())) towns.append(array) distances = [[0 for _ in range(n)] for _ in range(n)] town_num = list(range(n)) for i, j in combinations(town_num, 2): distance = ( (towns[j][0] - towns[i][0]) ** 2 + (towns[j][1] - towns[i][1]) ** 2 ) ** (0.5) distances[i][j] = distance distances[j][i] = distance total_way = math.factorial(n) total = 0 for i in range(n): for j in range(n): total += distances[i][j] * math.factorial(n - 1) print((total / total_way))
false
23.333333
[ "-import itertools", "+from itertools import combinations", "-li = []", "+towns = []", "+for _ in range(n):", "+ array = list(map(int, input().split()))", "+ towns.append(array)", "+distances = [[0 for _ in range(n)] for _ in range(n)]", "+town_num = list(range(n))", "+for i, j in combinatio...
false
0.041257
0.039708
1.039019
[ "s243333023", "s431804227" ]
u894258749
p03207
python
s310417729
s082276144
1,127
18
21,788
2,940
Accepted
Accepted
98.4
import numpy as np N = int(eval(input())) p = np.array([ int(eval(input())) for i in range(N)]) p.sort() print((p.sum() - p[-1]//2))
N = int(eval(input())) p = [] for _ in range(N): p.append(int(eval(input()))) print((sum(p) - max(p)//2))
5
5
122
99
import numpy as np N = int(eval(input())) p = np.array([int(eval(input())) for i in range(N)]) p.sort() print((p.sum() - p[-1] // 2))
N = int(eval(input())) p = [] for _ in range(N): p.append(int(eval(input()))) print((sum(p) - max(p) // 2))
false
0
[ "-import numpy as np", "-", "-p = np.array([int(eval(input())) for i in range(N)])", "-p.sort()", "-print((p.sum() - p[-1] // 2))", "+p = []", "+for _ in range(N):", "+ p.append(int(eval(input())))", "+print((sum(p) - max(p) // 2))" ]
false
0.257978
0.058097
4.440458
[ "s310417729", "s082276144" ]
u729133443
p02936
python
s253941507
s832871604
1,962
863
108,308
94,828
Accepted
Accepted
56.01
I=lambda:list(map(int,input().split())) n,q=I() e=[[]for _ in range(n)] d=[0]*n for _ in range(n-1): a,b=I() e[a-1]+=b-1, e[b-1]+=a-1, for _ in range(q): p,x=I() d[p-1]+=x f=[1]+[0]*n q=[0] while q: v=q.pop() for w in e[v]: if f[w]:continue f[w]=1 d[w]+=d[v] q+=w, print((*d))
n,q,*t=list(map(int,open(0).read().split())) e=[[]for _ in[0]*n] s=[0] d=s*n f=[1]+s*n for a,b in zip(*[iter(t[:-q-q])]*2): e[a-1]+=b-1, e[b-1]+=a-1, for p,x in zip(*[iter(t[-q-q:])]*2):d[p-1]+=x while s: v=s.pop() for w in e[v]: if f[w]:continue f[w]=1 d[w]+=d[v] s+=w, print((*d))
21
17
348
314
I = lambda: list(map(int, input().split())) n, q = I() e = [[] for _ in range(n)] d = [0] * n for _ in range(n - 1): a, b = I() e[a - 1] += (b - 1,) e[b - 1] += (a - 1,) for _ in range(q): p, x = I() d[p - 1] += x f = [1] + [0] * n q = [0] while q: v = q.pop() for w in e[v]: if f[w]: continue f[w] = 1 d[w] += d[v] q += (w,) print((*d))
n, q, *t = list(map(int, open(0).read().split())) e = [[] for _ in [0] * n] s = [0] d = s * n f = [1] + s * n for a, b in zip(*[iter(t[: -q - q])] * 2): e[a - 1] += (b - 1,) e[b - 1] += (a - 1,) for p, x in zip(*[iter(t[-q - q :])] * 2): d[p - 1] += x while s: v = s.pop() for w in e[v]: if f[w]: continue f[w] = 1 d[w] += d[v] s += (w,) print((*d))
false
19.047619
[ "-I = lambda: list(map(int, input().split()))", "-n, q = I()", "-e = [[] for _ in range(n)]", "-d = [0] * n", "-for _ in range(n - 1):", "- a, b = I()", "+n, q, *t = list(map(int, open(0).read().split()))", "+e = [[] for _ in [0] * n]", "+s = [0]", "+d = s * n", "+f = [1] + s * n", "+for a,...
false
0.039235
0.035702
1.09894
[ "s253941507", "s832871604" ]
u238084414
p02952
python
s983107383
s898009625
64
18
3,064
3,060
Accepted
Accepted
71.88
N = int(eval(input())) i = 1 cnt = 0 while i <= N: cnt += 1 i += 1 if len(str(i)) % 2 == 0: i *= 10 print(cnt)
N = int(eval(input())) cnt = 0 i = 0 for i in range(0, 5, 2): m = 10 ** i if len(str(m)) > len(str(N)): break M = int("9" * (i + 1)) if M > N: M = N cnt += M - m + 1 print(cnt)
11
16
126
211
N = int(eval(input())) i = 1 cnt = 0 while i <= N: cnt += 1 i += 1 if len(str(i)) % 2 == 0: i *= 10 print(cnt)
N = int(eval(input())) cnt = 0 i = 0 for i in range(0, 5, 2): m = 10**i if len(str(m)) > len(str(N)): break M = int("9" * (i + 1)) if M > N: M = N cnt += M - m + 1 print(cnt)
false
31.25
[ "-i = 1", "-while i <= N:", "- cnt += 1", "- i += 1", "- if len(str(i)) % 2 == 0:", "- i *= 10", "+i = 0", "+for i in range(0, 5, 2):", "+ m = 10**i", "+ if len(str(m)) > len(str(N)):", "+ break", "+ M = int(\"9\" * (i + 1))", "+ if M > N:", "+ M =...
false
0.073204
0.037582
1.947839
[ "s983107383", "s898009625" ]
u879870653
p03206
python
s277865796
s635913020
20
18
3,316
2,940
Accepted
Accepted
10
N = int(eval(input())) if N == 25 : print("Christmas") elif N == 24 : print("Christmas Eve") elif N == 23 : print("Christmas Eve Eve") elif N == 22 : print("Christmas Eve Eve Eve")
N = int(eval(input())) plus = " Eve" ans = "Christmas" + plus*(25-N) print(ans)
9
4
199
77
N = int(eval(input())) if N == 25: print("Christmas") elif N == 24: print("Christmas Eve") elif N == 23: print("Christmas Eve Eve") elif N == 22: print("Christmas Eve Eve Eve")
N = int(eval(input())) plus = " Eve" ans = "Christmas" + plus * (25 - N) print(ans)
false
55.555556
[ "-if N == 25:", "- print(\"Christmas\")", "-elif N == 24:", "- print(\"Christmas Eve\")", "-elif N == 23:", "- print(\"Christmas Eve Eve\")", "-elif N == 22:", "- print(\"Christmas Eve Eve Eve\")", "+plus = \" Eve\"", "+ans = \"Christmas\" + plus * (25 - N)", "+print(ans)" ]
false
0.036163
0.037116
0.974327
[ "s277865796", "s635913020" ]
u745087332
p03240
python
s951178409
s446653402
1,597
30
3,064
3,064
Accepted
Accepted
98.12
# coding:utf-8 INF = float('inf') def inpl(): return list(map(int, input().split())) def solve(): for x in range(101): for y in range(101): for h in range(h_min, h_min + 201): for i in range(N): if D[i][0] != max(h - abs(D[i][1] - x) - abs(D[i][2] - y), 0): break else: return x, y, h if __name__ == '__main__': N = int(eval(input())) D = [] for i in range(N): x, y, h = inpl() D.append([h, x, y]) h_min = max(D)[0] ans = solve() print((' '.join(map(str, ans))))
# coding:utf-8 INF = float('inf') def inpl(): return list(map(int, input().split())) def solve(): for cx in range(101): for cy in range(101): ch = D[0][0] + abs(D[0][1] - cx) + abs(D[0][2] - cy) for h, x, y in D: if h != max(ch - (abs(x - cx) + abs(y - cy)), 0): break else: return cx, cy, ch if __name__ == '__main__': N = int(eval(input())) D = [] for i in range(N): x, y, h = inpl() D.append([h, x, y]) D.sort() D.reverse() ans = solve() print((' '.join(map(str, ans))))
29
29
651
645
# coding:utf-8 INF = float("inf") def inpl(): return list(map(int, input().split())) def solve(): for x in range(101): for y in range(101): for h in range(h_min, h_min + 201): for i in range(N): if D[i][0] != max(h - abs(D[i][1] - x) - abs(D[i][2] - y), 0): break else: return x, y, h if __name__ == "__main__": N = int(eval(input())) D = [] for i in range(N): x, y, h = inpl() D.append([h, x, y]) h_min = max(D)[0] ans = solve() print((" ".join(map(str, ans))))
# coding:utf-8 INF = float("inf") def inpl(): return list(map(int, input().split())) def solve(): for cx in range(101): for cy in range(101): ch = D[0][0] + abs(D[0][1] - cx) + abs(D[0][2] - cy) for h, x, y in D: if h != max(ch - (abs(x - cx) + abs(y - cy)), 0): break else: return cx, cy, ch if __name__ == "__main__": N = int(eval(input())) D = [] for i in range(N): x, y, h = inpl() D.append([h, x, y]) D.sort() D.reverse() ans = solve() print((" ".join(map(str, ans))))
false
0
[ "- for x in range(101):", "- for y in range(101):", "- for h in range(h_min, h_min + 201):", "- for i in range(N):", "- if D[i][0] != max(h - abs(D[i][1] - x) - abs(D[i][2] - y), 0):", "- break", "- else:", "-...
false
0.701662
0.049644
14.133864
[ "s951178409", "s446653402" ]
u562016607
p03294
python
s504018176
s010164568
55
20
3,316
3,316
Accepted
Accepted
63.64
N=int(eval(input())) A=[int(i) for i in input().split()] ans=0 for i in range(N): ans+=A[i]-1 print(ans)
N=int(eval(input())) A=[int(i) for i in input().split()] print((sum(A)-N))
6
3
108
69
N = int(eval(input())) A = [int(i) for i in input().split()] ans = 0 for i in range(N): ans += A[i] - 1 print(ans)
N = int(eval(input())) A = [int(i) for i in input().split()] print((sum(A) - N))
false
50
[ "-ans = 0", "-for i in range(N):", "- ans += A[i] - 1", "-print(ans)", "+print((sum(A) - N))" ]
false
0.065538
0.04607
1.42258
[ "s504018176", "s010164568" ]
u472696272
p02899
python
s935681296
s615845513
243
201
21,196
13,880
Accepted
Accepted
17.28
n = int(input()) l = list(map(int, input().split())) ans = [0]*n for a in list(enumerate(l)): a = list(a) ans[a[1]-1] = a[0]+1 for _ in ans: print(_, ' ', end='')
n = int(input()) a = list(map(int,input().split())) ans = [0]*n for i,j in enumerate(a,start=1): ans[j-1] = i for i in range(n): print(ans[i],' ', end='')
10
7
179
165
n = int(input()) l = list(map(int, input().split())) ans = [0] * n for a in list(enumerate(l)): a = list(a) ans[a[1] - 1] = a[0] + 1 for _ in ans: print(_, " ", end="")
n = int(input()) a = list(map(int, input().split())) ans = [0] * n for i, j in enumerate(a, start=1): ans[j - 1] = i for i in range(n): print(ans[i], " ", end="")
false
30
[ "-l = list(map(int, input().split()))", "+a = list(map(int, input().split()))", "-for a in list(enumerate(l)):", "- a = list(a)", "- ans[a[1] - 1] = a[0] + 1", "-for _ in ans:", "- print(_, \" \", end=\"\")", "+for i, j in enumerate(a, start=1):", "+ ans[j - 1] = i", "+for i in range(n...
false
0.04563
0.046009
0.991752
[ "s935681296", "s615845513" ]
u252828980
p03286
python
s888951429
s827247519
19
17
3,060
2,940
Accepted
Accepted
10.53
n=int(eval(input())) if n == 0: print((0)) k=-2 bi='' while n!=0: bi+=str(n%abs(k)) if k<0:n=-(-n//k) else:n=n//k print((bi[::-1]))
n=int(eval(input())) if n == 0: print((0)) s = "" while n != 0: if n%2 == 0: s = "0" + s elif n%2 == 1: n -= 1 s = "1" +s n = (n//-2) print(s)
10
15
146
199
n = int(eval(input())) if n == 0: print((0)) k = -2 bi = "" while n != 0: bi += str(n % abs(k)) if k < 0: n = -(-n // k) else: n = n // k print((bi[::-1]))
n = int(eval(input())) if n == 0: print((0)) s = "" while n != 0: if n % 2 == 0: s = "0" + s elif n % 2 == 1: n -= 1 s = "1" + s n = n // -2 print(s)
false
33.333333
[ "-k = -2", "-bi = \"\"", "+s = \"\"", "- bi += str(n % abs(k))", "- if k < 0:", "- n = -(-n // k)", "- else:", "- n = n // k", "-print((bi[::-1]))", "+ if n % 2 == 0:", "+ s = \"0\" + s", "+ elif n % 2 == 1:", "+ n -= 1", "+ s = \"1\" + s",...
false
0.045791
0.046276
0.989525
[ "s888951429", "s827247519" ]
u831244171
p02265
python
s985292989
s845990116
3,890
1,580
71,796
214,284
Accepted
Accepted
59.38
from collections import deque n = int(eval(input())) Q = deque() for i in range(n): command = input().split() if command[0] == "insert": Q.appendleft(command[1]) elif command[0] == "deleteFirst": Q.popleft() elif command[0] == "deleteLast": Q.pop() elif command[0] == "delete": try: Q.remove(command[1]) except: pass print((" ".join(Q)))
import sys from collections import deque n = int(sys.stdin.readline()) lines = sys.stdin.readlines() Q = deque() for i in range(n): command = lines[i].split() if command[0] == "insert": Q.appendleft(command[1]) elif command[0] == "deleteFirst": Q.popleft() elif command[0] == "deleteLast": Q.pop() elif command[0] == "delete": try: Q.remove(command[1]) except: pass print((" ".join(Q)))
18
20
431
488
from collections import deque n = int(eval(input())) Q = deque() for i in range(n): command = input().split() if command[0] == "insert": Q.appendleft(command[1]) elif command[0] == "deleteFirst": Q.popleft() elif command[0] == "deleteLast": Q.pop() elif command[0] == "delete": try: Q.remove(command[1]) except: pass print((" ".join(Q)))
import sys from collections import deque n = int(sys.stdin.readline()) lines = sys.stdin.readlines() Q = deque() for i in range(n): command = lines[i].split() if command[0] == "insert": Q.appendleft(command[1]) elif command[0] == "deleteFirst": Q.popleft() elif command[0] == "deleteLast": Q.pop() elif command[0] == "delete": try: Q.remove(command[1]) except: pass print((" ".join(Q)))
false
10
[ "+import sys", "-n = int(eval(input()))", "+n = int(sys.stdin.readline())", "+lines = sys.stdin.readlines()", "- command = input().split()", "+ command = lines[i].split()" ]
false
0.034834
0.035499
0.981268
[ "s985292989", "s845990116" ]
u318029285
p03785
python
s830596209
s011149463
276
252
13,396
8,036
Accepted
Accepted
8.7
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for _ in range(N)] bus = [] indexes = [i for i in range(N)] sorted_indexes = sorted(indexes, key=lambda i: T[i]) count = 0 for i in range(N): if count == 0: first = T[sorted_indexes[i]] count += 1 else: if T[sorted_indexes[i]] - first <= K: count += 1 else: bus.append(count) first = T[sorted_indexes[i]] count = 1 if count >= C: bus.append(count) count = 0 if count > 0: bus.append(count) print((len(bus)))
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for _ in range(N)] T.sort() bus = [] count = 0 for i in range(N): if count == 0: first = T[i] count += 1 else: if T[i] - first <= K: count += 1 else: bus.append(count) first = T[i] count = 1 if count >= C: bus.append(count) count = 0 if count > 0: bus.append(count) print((len(bus)))
28
27
603
478
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for _ in range(N)] bus = [] indexes = [i for i in range(N)] sorted_indexes = sorted(indexes, key=lambda i: T[i]) count = 0 for i in range(N): if count == 0: first = T[sorted_indexes[i]] count += 1 else: if T[sorted_indexes[i]] - first <= K: count += 1 else: bus.append(count) first = T[sorted_indexes[i]] count = 1 if count >= C: bus.append(count) count = 0 if count > 0: bus.append(count) print((len(bus)))
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for _ in range(N)] T.sort() bus = [] count = 0 for i in range(N): if count == 0: first = T[i] count += 1 else: if T[i] - first <= K: count += 1 else: bus.append(count) first = T[i] count = 1 if count >= C: bus.append(count) count = 0 if count > 0: bus.append(count) print((len(bus)))
false
3.571429
[ "+T.sort()", "-indexes = [i for i in range(N)]", "-sorted_indexes = sorted(indexes, key=lambda i: T[i])", "- first = T[sorted_indexes[i]]", "+ first = T[i]", "- if T[sorted_indexes[i]] - first <= K:", "+ if T[i] - first <= K:", "- first = T[sorted_indexes[i]]", ...
false
0.042551
0.042792
0.994366
[ "s830596209", "s011149463" ]
u720483676
p03107
python
s681696551
s919583115
20
18
3,188
3,188
Accepted
Accepted
10
s=eval(input()) print((min(s.count("1"),s.count("0"))*2))
s=eval(input());print((min(s.count("0"),s.count("1"))*2))
2
1
50
49
s = eval(input()) print((min(s.count("1"), s.count("0")) * 2))
s = eval(input()) print((min(s.count("0"), s.count("1")) * 2))
false
50
[ "-print((min(s.count(\"1\"), s.count(\"0\")) * 2))", "+print((min(s.count(\"0\"), s.count(\"1\")) * 2))" ]
false
0.04
0.041652
0.960327
[ "s681696551", "s919583115" ]
u869265610
p02813
python
s617354512
s424401197
42
38
13,772
9,136
Accepted
Accepted
9.52
import itertools N=int(eval(input())) a=tuple(map(int,input().split())) b=tuple(map(int,input().split())) K=list(itertools.permutations(list(range(1,N+1)))) print((abs(K.index(a)-K.index(b))))
import itertools as it N=int(eval(input())) W=list(range(1,N+1)) c1=-1 c2=-1 c=0 L=tuple(map(int,input().split())) M=tuple(map(int,input().split())) if L==M: print((0)) exit() for i in it.permutations(W,N): c+=1 if i==L: c1=c elif i==M: c2=c print((abs(c1-c2)))
6
18
183
286
import itertools N = int(eval(input())) a = tuple(map(int, input().split())) b = tuple(map(int, input().split())) K = list(itertools.permutations(list(range(1, N + 1)))) print((abs(K.index(a) - K.index(b))))
import itertools as it N = int(eval(input())) W = list(range(1, N + 1)) c1 = -1 c2 = -1 c = 0 L = tuple(map(int, input().split())) M = tuple(map(int, input().split())) if L == M: print((0)) exit() for i in it.permutations(W, N): c += 1 if i == L: c1 = c elif i == M: c2 = c print((abs(c1 - c2)))
false
66.666667
[ "-import itertools", "+import itertools as it", "-a = tuple(map(int, input().split()))", "-b = tuple(map(int, input().split()))", "-K = list(itertools.permutations(list(range(1, N + 1))))", "-print((abs(K.index(a) - K.index(b))))", "+W = list(range(1, N + 1))", "+c1 = -1", "+c2 = -1", "+c = 0", ...
false
0.047815
0.047112
1.014903
[ "s617354512", "s424401197" ]
u325956328
p03163
python
s409828485
s709861328
402
220
118,512
15,464
Accepted
Accepted
45.27
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) def main(): N, W = list(map(int, input().split())) w = [0] v = [0] for i in range(N): weight, value = list(map(int, input().split())) w.append(weight) v.append(value) dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, W + 1): if j - w[i] < 0: dp[i][j] = dp[i - 1][j] else: dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]) # print(w, v, dp) print((dp[N][W])) if __name__ == "__main__": main()
import sys import numpy as np input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) def main(): N, W = list(map(int, input().split())) w = [0] v = [0] for i in range(N): weight, value = list(map(int, input().split())) w.append(weight) v.append(value) # dp = [[0] * (W + 1) for _ in range(N + 1)] dp = np.zeros(W + 1, dtype=np.int64) for i in range(1, N + 1): dp[w[i] :] = np.maximum(dp[w[i] :], dp[: -w[i]] + v[i]) # print(w, v, dp) print((dp.max())) if __name__ == "__main__": main()
30
29
652
584
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) def main(): N, W = list(map(int, input().split())) w = [0] v = [0] for i in range(N): weight, value = list(map(int, input().split())) w.append(weight) v.append(value) dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, W + 1): if j - w[i] < 0: dp[i][j] = dp[i - 1][j] else: dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]) # print(w, v, dp) print((dp[N][W])) if __name__ == "__main__": main()
import sys import numpy as np input = sys.stdin.readline sys.setrecursionlimit(10**7) def main(): N, W = list(map(int, input().split())) w = [0] v = [0] for i in range(N): weight, value = list(map(int, input().split())) w.append(weight) v.append(value) # dp = [[0] * (W + 1) for _ in range(N + 1)] dp = np.zeros(W + 1, dtype=np.int64) for i in range(1, N + 1): dp[w[i] :] = np.maximum(dp[w[i] :], dp[: -w[i]] + v[i]) # print(w, v, dp) print((dp.max())) if __name__ == "__main__": main()
false
3.333333
[ "+import numpy as np", "- dp = [[0] * (W + 1) for _ in range(N + 1)]", "+ # dp = [[0] * (W + 1) for _ in range(N + 1)]", "+ dp = np.zeros(W + 1, dtype=np.int64)", "- for j in range(1, W + 1):", "- if j - w[i] < 0:", "- dp[i][j] = dp[i - 1][j]", "- e...
false
0.049029
0.356341
0.137591
[ "s409828485", "s709861328" ]
u073549161
p03671
python
s075337504
s906740448
165
18
38,384
2,940
Accepted
Accepted
89.09
a,b,c = list(map(int, input().split())) if a == max(a, b, c): print((b + c)) elif b == max(a, b, c): print((a + c)) elif c == max(a, b, c): print((a+b))
a,b,c = list(map(int, input().split())) s = list([a,b,c]) s.sort() print((s[0] + s[1]))
7
4
159
82
a, b, c = list(map(int, input().split())) if a == max(a, b, c): print((b + c)) elif b == max(a, b, c): print((a + c)) elif c == max(a, b, c): print((a + b))
a, b, c = list(map(int, input().split())) s = list([a, b, c]) s.sort() print((s[0] + s[1]))
false
42.857143
[ "-if a == max(a, b, c):", "- print((b + c))", "-elif b == max(a, b, c):", "- print((a + c))", "-elif c == max(a, b, c):", "- print((a + b))", "+s = list([a, b, c])", "+s.sort()", "+print((s[0] + s[1]))" ]
false
0.21752
0.04389
4.95598
[ "s075337504", "s906740448" ]