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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u334712262 | p02868 | python | s938760911 | s595219980 | 933 | 832 | 73,368 | 97,632 | Accepted | Accepted | 10.83 | from collections import defaultdict
from heapq import heappop, heappush
class Graph():
def __init__(self):
self.graph = defaultdict(list)
def __len__(self):
return len(self.graph)
def add_edge(self, src, dst, weight=1):
self.graph[src].append((dst, weight))
d... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | 75 | 101 | 1,651 | 1,951 | from collections import defaultdict
from heapq import heappop, heappush
class Graph:
def __init__(self):
self.graph = defaultdict(list)
def __len__(self):
return len(self.graph)
def add_edge(self, src, dst, weight=1):
self.graph[src].append((dst, weight))
def get_nodes(self)... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permut... | false | 25.742574 | [
"-from collections import defaultdict",
"-from heapq import heappop, heappush",
"+# -*- coding: utf-8 -*-",
"+import bisect",
"+import heapq",
"+import math",
"+import random",
"+import sys",
"+from collections import Counter, defaultdict, deque",
"+from decimal import ROUND_CEILING, ROUND_HALF_UP... | false | 0.039431 | 0.057939 | 0.680566 | [
"s938760911",
"s595219980"
] |
u074747865 | p02397 | python | s411552420 | s113048514 | 60 | 50 | 5,608 | 5,604 | Accepted | Accepted | 16.67 | while True:
a=sorted(map(int,input().split()))
if a==[0,0]:
quit()
print((*a))
| while True:
x,y=sorted(map(int,input().split()))
if (x==0) and(y==0):
break
print((x, y))
| 5 | 5 | 101 | 97 | while True:
a = sorted(map(int, input().split()))
if a == [0, 0]:
quit()
print((*a))
| while True:
x, y = sorted(map(int, input().split()))
if (x == 0) and (y == 0):
break
print((x, y))
| false | 0 | [
"- a = sorted(map(int, input().split()))",
"- if a == [0, 0]:",
"- quit()",
"- print((*a))",
"+ x, y = sorted(map(int, input().split()))",
"+ if (x == 0) and (y == 0):",
"+ break",
"+ print((x, y))"
] | false | 0.036088 | 0.036812 | 0.980324 | [
"s411552420",
"s113048514"
] |
u612721349 | p03125 | python | s655421278 | s399763097 | 171 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.06 | a, b = list(map(int, input().split()))
print(((a + b) if b % a == 0 else (b - a)))
| a,b=list(map(int,input().split()));print(([b+a,b-a][b%a>0])) | 2 | 1 | 76 | 52 | a, b = list(map(int, input().split()))
print(((a + b) if b % a == 0 else (b - a)))
| a, b = list(map(int, input().split()))
print(([b + a, b - a][b % a > 0]))
| false | 50 | [
"-print(((a + b) if b % a == 0 else (b - a)))",
"+print(([b + a, b - a][b % a > 0]))"
] | false | 0.093309 | 0.038406 | 2.429559 | [
"s655421278",
"s399763097"
] |
u370331385 | p03575 | python | s943214918 | s977402496 | 27 | 22 | 3,064 | 3,064 | Accepted | Accepted | 18.52 | N,M = list(map(int,input().split()))
graph = [[0]*N for _ in range(N)]
Edge = []
for i in range(M):
a,b = list(map(int,input().split()))
graph[a-1][b-1] = 1
graph[b-1][a-1] = 1
Edge.append([a-1,b-1])
def dfs(x):
if(vis[x] == 1): return
vis[x] = 1
for i in range(N):
if(graph[x][i] == 1)... | class UnionFind():
# 作りたい要素数nで初期化
# 使用するインスタンス変数の初期化
def __init__(self, n):
self.n = n
# root[x]<0ならそのノードが根かつその値が木の要素数
# rootノードでその木の要素数を記録する
self.root = [-1]*(n+1)
# 木をくっつける時にアンバランスにならないように調整する
self.rnk = [0]*(n+1)
# ノードxのrootノードを見つける
def... | 30 | 60 | 619 | 1,631 | N, M = list(map(int, input().split()))
graph = [[0] * N for _ in range(N)]
Edge = []
for i in range(M):
a, b = list(map(int, input().split()))
graph[a - 1][b - 1] = 1
graph[b - 1][a - 1] = 1
Edge.append([a - 1, b - 1])
def dfs(x):
if vis[x] == 1:
return
vis[x] = 1
for i in range(N)... | class UnionFind:
# 作りたい要素数nで初期化
# 使用するインスタンス変数の初期化
def __init__(self, n):
self.n = n
# root[x]<0ならそのノードが根かつその値が木の要素数
# rootノードでその木の要素数を記録する
self.root = [-1] * (n + 1)
# 木をくっつける時にアンバランスにならないように調整する
self.rnk = [0] * (n + 1)
# ノードxのrootノードを見つける
def Find_... | false | 50 | [
"+class UnionFind:",
"+ # 作りたい要素数nで初期化",
"+ # 使用するインスタンス変数の初期化",
"+ def __init__(self, n):",
"+ self.n = n",
"+ # root[x]<0ならそのノードが根かつその値が木の要素数",
"+ # rootノードでその木の要素数を記録する",
"+ self.root = [-1] * (n + 1)",
"+ # 木をくっつける時にアンバランスにならないように調整する",
"+ sel... | false | 0.037437 | 0.073493 | 0.50939 | [
"s943214918",
"s977402496"
] |
u493520238 | p02684 | python | s468712204 | s620283349 | 128 | 111 | 123,132 | 103,344 | Accepted | Accepted | 13.28 | def main():
n, k = list(map(int, input().split()))
al = list(map(int, input().split()))
city_l = [1]
city_s = set([1])
loop_city_l = []
curr_city = 1
cnt = 0
for i in range(1,k+1):
next_c = al[curr_city-1]
if next_c in city_s:
cnt = i
... | n,k = list(map(int, input().split()))
al = list(map(int, input().split()))
cnt = 0
cl = [-1]*(n+1)
cll = [1]
curr = 1
for i in range(min(n,k)):
# print(curr)
next_c = al[curr-1]
if cl[next_c] != -1:
# loop_start = (i+1)
loop_start = cl[next_c]
rem = k - (i+1)
... | 30 | 30 | 745 | 569 | def main():
n, k = list(map(int, input().split()))
al = list(map(int, input().split()))
city_l = [1]
city_s = set([1])
loop_city_l = []
curr_city = 1
cnt = 0
for i in range(1, k + 1):
next_c = al[curr_city - 1]
if next_c in city_s:
cnt = i
first_ci... | n, k = list(map(int, input().split()))
al = list(map(int, input().split()))
cnt = 0
cl = [-1] * (n + 1)
cll = [1]
curr = 1
for i in range(min(n, k)):
# print(curr)
next_c = al[curr - 1]
if cl[next_c] != -1:
# loop_start = (i+1)
loop_start = cl[next_c]
rem = k - (i + 1)
break
... | false | 0 | [
"-def main():",
"- n, k = list(map(int, input().split()))",
"- al = list(map(int, input().split()))",
"- city_l = [1]",
"- city_s = set([1])",
"- loop_city_l = []",
"- curr_city = 1",
"- cnt = 0",
"- for i in range(1, k + 1):",
"- next_c = al[curr_city - 1]",
"- ... | false | 0.047241 | 0.035942 | 1.314362 | [
"s468712204",
"s620283349"
] |
u707498674 | p03583 | python | s053277985 | s315409546 | 1,405 | 1,054 | 3,064 | 3,060 | Accepted | Accepted | 24.98 | def main():
N = int(eval(input()))
for h in range(1, 3501):
for n in range(1, 3501):
if (4*h*n - N*h - N*n)>0 and N*h*n % (4*h*n - N*h - N*n)==0:
w = N*h*n // (4*h*n - N*h - N*n)
print((h, n, w))
exit()
if __name__ == "__main__":
... | def main():
N = int(eval(input()))
for h in range(1, 3501):
for n in range(h, 3501):
if (4*h*n - N*h - N*n)>0 and N*h*n % (4*h*n - N*h - N*n)==0:
w = N*h*n // (4*h*n - N*h - N*n)
print((h, n, w))
exit()
if __name__ == "__main__":
... | 12 | 12 | 321 | 321 | def main():
N = int(eval(input()))
for h in range(1, 3501):
for n in range(1, 3501):
if (4 * h * n - N * h - N * n) > 0 and N * h * n % (
4 * h * n - N * h - N * n
) == 0:
w = N * h * n // (4 * h * n - N * h - N * n)
print((h, n, w)... | def main():
N = int(eval(input()))
for h in range(1, 3501):
for n in range(h, 3501):
if (4 * h * n - N * h - N * n) > 0 and N * h * n % (
4 * h * n - N * h - N * n
) == 0:
w = N * h * n // (4 * h * n - N * h - N * n)
print((h, n, w)... | false | 0 | [
"- for n in range(1, 3501):",
"+ for n in range(h, 3501):"
] | false | 0.469574 | 0.007928 | 59.231162 | [
"s053277985",
"s315409546"
] |
u753803401 | p03061 | python | s677815964 | s800572988 | 391 | 360 | 93,844 | 89,580 | Accepted | Accepted | 7.93 | def slove():
import sys
import fractions
input = sys.stdin.readline
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
g_l = [[0, 0] for _ in range(n + 1)]
for i in range(n):
g_l[i+1][0] = fractions.gcd(g_l[i][0], a[i])
g_l[-i-2][1] = fr... | def slove():
import sys
import fractions
input = sys.stdin.readline
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
ls = [[0] * (n + 1) for _ in range(2)]
for i in range(n):
ls[0][i+1] = fractions.gcd(ls[0][i], a[i])
ls[1][-i-2] = fract... | 19 | 19 | 518 | 537 | def slove():
import sys
import fractions
input = sys.stdin.readline
n = int(input().rstrip("\n"))
a = list(map(int, input().rstrip("\n").split()))
g_l = [[0, 0] for _ in range(n + 1)]
for i in range(n):
g_l[i + 1][0] = fractions.gcd(g_l[i][0], a[i])
g_l[-i - 2][1] = fraction... | def slove():
import sys
import fractions
input = sys.stdin.readline
n = int(input().rstrip("\n"))
a = list(map(int, input().rstrip("\n").split()))
ls = [[0] * (n + 1) for _ in range(2)]
for i in range(n):
ls[0][i + 1] = fractions.gcd(ls[0][i], a[i])
ls[1][-i - 2] = fractions... | false | 0 | [
"- g_l = [[0, 0] for _ in range(n + 1)]",
"+ ls = [[0] * (n + 1) for _ in range(2)]",
"- g_l[i + 1][0] = fractions.gcd(g_l[i][0], a[i])",
"- g_l[-i - 2][1] = fractions.gcd(g_l[-i - 1][1], a[-i - 1])",
"- m_g = 0",
"+ ls[0][i + 1] = fractions.gcd(ls[0][i], a[i])",
"+ ... | false | 0.062822 | 0.060641 | 1.035961 | [
"s677815964",
"s800572988"
] |
u001024152 | p03330 | python | s682797882 | s662724158 | 1,146 | 245 | 7,968 | 8,012 | Accepted | Accepted | 78.62 | from collections import Counter
from itertools import permutations
N,C = list(map(int, input().split()))
cost = [list(map(int, input().split())) for _ in range(C)]
color = [list([int(x)-1 for x in input().split()]) for _ in range(N)]
# 3 groups
mod3 = {0:[], 1:[], 2:[]}
for i in range(N):
for j in range(N... | from collections import Counter
from itertools import permutations
N,C = list(map(int, input().split()))
cost = [list(map(int, input().split())) for _ in range(C)]
color = [list([int(x)-1 for x in input().split()]) for _ in range(N)]
# 3 groups
mod3 = {0:[], 1:[], 2:[]}
for i in range(N):
for j in range(N... | 25 | 31 | 673 | 849 | from collections import Counter
from itertools import permutations
N, C = list(map(int, input().split()))
cost = [list(map(int, input().split())) for _ in range(C)]
color = [list([int(x) - 1 for x in input().split()]) for _ in range(N)]
# 3 groups
mod3 = {0: [], 1: [], 2: []}
for i in range(N):
for j in range(N):
... | from collections import Counter
from itertools import permutations
N, C = list(map(int, input().split()))
cost = [list(map(int, input().split())) for _ in range(C)]
color = [list([int(x) - 1 for x in input().split()]) for _ in range(N)]
# 3 groups
mod3 = {0: [], 1: [], 2: []}
for i in range(N):
for j in range(N):
... | false | 19.354839 | [
"+cost_mod = [[-1] * C for _ in range(3)]",
"+for i in range(3):",
"+ for to_ in range(C):",
"+ cond = 0",
"+ for from_ in list(cnts[i].keys()):",
"+ cond += cnts[i][from_] * cost[from_][to_]",
"+ cost_mod[i][to_] = cond",
"- for col in list(cnts[i].keys()):",... | false | 0.006895 | 0.04128 | 0.167028 | [
"s682797882",
"s662724158"
] |
u905203728 | p03274 | python | s080266509 | s572423974 | 220 | 92 | 62,576 | 14,384 | Accepted | Accepted | 58.18 | n,k=list(map(int,input().split()))
candle=list(map(int,input().split()))
ans=float("inf")
for l in range(n-k+1):
r=l+k-1
ans=min(ans,
abs(candle[l])+abs(candle[l]-candle[r]),
abs(candle[r])+abs(candle[r]-candle[l])
)
print(ans) | n,k=list(map(int,input().split()))
line=list(map(int,input().split()))
ans=float("inf")
for i in range(n-k+1):
left,right=i,i+k-1
ans=min(ans,
abs(line[left])+abs(line[left]-line[right]),
abs(line[right])+abs(line[right]-line[left])
)
print(ans) | 10 | 10 | 274 | 292 | n, k = list(map(int, input().split()))
candle = list(map(int, input().split()))
ans = float("inf")
for l in range(n - k + 1):
r = l + k - 1
ans = min(
ans,
abs(candle[l]) + abs(candle[l] - candle[r]),
abs(candle[r]) + abs(candle[r] - candle[l]),
)
print(ans)
| n, k = list(map(int, input().split()))
line = list(map(int, input().split()))
ans = float("inf")
for i in range(n - k + 1):
left, right = i, i + k - 1
ans = min(
ans,
abs(line[left]) + abs(line[left] - line[right]),
abs(line[right]) + abs(line[right] - line[left]),
)
print(ans)
| false | 0 | [
"-candle = list(map(int, input().split()))",
"+line = list(map(int, input().split()))",
"-for l in range(n - k + 1):",
"- r = l + k - 1",
"+for i in range(n - k + 1):",
"+ left, right = i, i + k - 1",
"- abs(candle[l]) + abs(candle[l] - candle[r]),",
"- abs(candle[r]) + abs(candle[... | false | 0.04447 | 0.041807 | 1.063718 | [
"s080266509",
"s572423974"
] |
u945181840 | p03112 | python | s475860441 | s388539954 | 585 | 514 | 36,320 | 36,320 | Accepted | Accepted | 12.14 | import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
A, B, Q = list(map(int, readline().split()))
stx = list(map(int, read().split()))
s = stx[:A]; t = stx[A:-Q]; x = stx[-Q:]
s = [-10 ** 10] + s + [10 ** 11]
t = [-10 ** 10] + t + [10 *... | import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
A, B, Q = list(map(int, readline().split()))
stx = list(map(int, read().split()))
s = stx[:A]; t = stx[A:-Q]; x = stx[-Q:]
s = [-10 ** 10] + s + [10 ** 1... | 20 | 26 | 630 | 741 | import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
A, B, Q = list(map(int, readline().split()))
stx = list(map(int, read().split()))
s = stx[:A]
t = stx[A:-Q]
x = stx[-Q:]
s = [-(10**10)] + s + [10**11]
t = [-(10**10)] + t + [10**11]
for i in x... | import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
A, B, Q = list(map(int, readline().split()))
stx = list(map(int, read().split()))
s = stx[:A]
t = stx[A:-Q]
x = stx[-Q:]
s = [-(10**10)] + s + [10**11]
... | false | 23.076923 | [
"-A, B, Q = list(map(int, readline().split()))",
"-stx = list(map(int, read().split()))",
"-s = stx[:A]",
"-t = stx[A:-Q]",
"-x = stx[-Q:]",
"-s = [-(10**10)] + s + [10**11]",
"-t = [-(10**10)] + t + [10**11]",
"-for i in x:",
"- ax = bisect_left(s, i)",
"- bx = bisect_left(t, i)",
"- p... | false | 0.108746 | 0.038603 | 2.817021 | [
"s475860441",
"s388539954"
] |
u871841829 | p02631 | python | s850292506 | s045406362 | 204 | 141 | 43,504 | 114,596 | Accepted | Accepted | 30.88 | N = int(eval(input()))
A = list(map(int, input().split()))
A = A + A
ans = [0] * N
a = 0
for i in range(N-1):
a ^= A[i]
ans[N-1] = a
W = N - 1
for i in range(N-1):
remove = A[i]
addition = A[i+W]
a = remove^a^addition
ans[i] = a
print((" ".join([str(i) for i in ans])))
| N = int(eval(input()))
A = list(map(int, input().split()))
t = 0
for c in A:
t ^= c
ans = []
for b in A:
ans.append(t^b)
print((*ans)) | 16 | 12 | 298 | 148 | N = int(eval(input()))
A = list(map(int, input().split()))
A = A + A
ans = [0] * N
a = 0
for i in range(N - 1):
a ^= A[i]
ans[N - 1] = a
W = N - 1
for i in range(N - 1):
remove = A[i]
addition = A[i + W]
a = remove ^ a ^ addition
ans[i] = a
print((" ".join([str(i) for i in ans])))
| N = int(eval(input()))
A = list(map(int, input().split()))
t = 0
for c in A:
t ^= c
ans = []
for b in A:
ans.append(t ^ b)
print((*ans))
| false | 25 | [
"-A = A + A",
"-ans = [0] * N",
"-a = 0",
"-for i in range(N - 1):",
"- a ^= A[i]",
"-ans[N - 1] = a",
"-W = N - 1",
"-for i in range(N - 1):",
"- remove = A[i]",
"- addition = A[i + W]",
"- a = remove ^ a ^ addition",
"- ans[i] = a",
"-print((\" \".join([str(i) for i in ans])... | false | 0.038317 | 0.039323 | 0.97442 | [
"s850292506",
"s045406362"
] |
u008229752 | p02861 | python | s965257023 | s290131050 | 700 | 216 | 12,504 | 3,064 | Accepted | Accepted | 69.14 | import numpy as np
from itertools import permutations
from math import hypot
n = int(eval(input()))
cnt = 0
dis = 0
li = []
for _ in range(n):
i, j = list(map(int, input().split()))
li.append(np.array([i, j]))
ptn = list(range(n))
for a in permutations(ptn):
cnt += 1
for i, j in zip... | from itertools import permutations
from math import hypot
n = int(eval(input()))
cnt = 0
dis = 0
li = []
for i in range(n):
x,y = list(map(int,input().split()))
li.append([x, y])
ptn = list(range(n))
for a in permutations(ptn):
cnt += 1
for i, j in zip(a,a[1:]):
x1, y1 = li[... | 23 | 22 | 420 | 388 | import numpy as np
from itertools import permutations
from math import hypot
n = int(eval(input()))
cnt = 0
dis = 0
li = []
for _ in range(n):
i, j = list(map(int, input().split()))
li.append(np.array([i, j]))
ptn = list(range(n))
for a in permutations(ptn):
cnt += 1
for i, j in zip(a, a[1:]):
... | from itertools import permutations
from math import hypot
n = int(eval(input()))
cnt = 0
dis = 0
li = []
for i in range(n):
x, y = list(map(int, input().split()))
li.append([x, y])
ptn = list(range(n))
for a in permutations(ptn):
cnt += 1
for i, j in zip(a, a[1:]):
x1, y1 = li[i]
x2, y2... | false | 4.347826 | [
"-import numpy as np",
"-for _ in range(n):",
"- i, j = list(map(int, input().split()))",
"- li.append(np.array([i, j]))",
"+for i in range(n):",
"+ x, y = list(map(int, input().split()))",
"+ li.append([x, y])"
] | false | 0.241269 | 0.05758 | 4.190182 | [
"s965257023",
"s290131050"
] |
u956433805 | p03448 | python | s626467884 | s868723804 | 53 | 49 | 3,060 | 3,060 | Accepted | Accepted | 7.55 | A = int (eval(input()))
B = int (eval(input()))
C = int (eval(input()))
X = int (eval(input()))
ans = 0
for x in range(A+1):
for y in range(B+1):
for z in range(C+1):
if 500 * x + 100 * y + 50 * z == X:
ans +=1
print(ans) | A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
cnt = 0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
if 500*a + 100*b + 50*c == X:
cnt+= 1
print(cnt) | 14 | 14 | 253 | 243 | A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
ans = 0
for x in range(A + 1):
for y in range(B + 1):
for z in range(C + 1):
if 500 * x + 100 * y + 50 * z == X:
ans += 1
print(ans)
| A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
cnt = 0
for a in range(A + 1):
for b in range(B + 1):
for c in range(C + 1):
if 500 * a + 100 * b + 50 * c == X:
cnt += 1
print(cnt)
| false | 0 | [
"-ans = 0",
"-for x in range(A + 1):",
"- for y in range(B + 1):",
"- for z in range(C + 1):",
"- if 500 * x + 100 * y + 50 * z == X:",
"- ans += 1",
"-print(ans)",
"+cnt = 0",
"+for a in range(A + 1):",
"+ for b in range(B + 1):",
"+ for c in range(... | false | 0.170289 | 0.069285 | 2.457824 | [
"s626467884",
"s868723804"
] |
u286955577 | p03160 | python | s915084541 | s823860383 | 186 | 102 | 13,924 | 13,976 | Accepted | Accepted | 45.16 | N = int(eval(input()))
H = list(map(int, input().split()))
dp = [10 ** 9] * N
dp[0] = 0
for i in range(N):
if i + 1 < N: dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
if i + 2 < N: dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))
print((dp[-1]))
| def solve():
N = int(eval(input()))
H = [int(i) for i in input().split()]
dp = [float('inf')] * N
dp[0] = 0
dp[1] = abs(H[0] - H[1])
for i in range(2, N):
dp[i] = min(dp[i - 2] + abs(H[i - 2] - H[i]), dp[i - 1] + abs(H[i - 1] - H[i]))
return dp[N - 1]
print((solve()))
| 10 | 14 | 272 | 296 | N = int(eval(input()))
H = list(map(int, input().split()))
dp = [10**9] * N
dp[0] = 0
for i in range(N):
if i + 1 < N:
dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
if i + 2 < N:
dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))
print((dp[-1]))
| def solve():
N = int(eval(input()))
H = [int(i) for i in input().split()]
dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(H[0] - H[1])
for i in range(2, N):
dp[i] = min(dp[i - 2] + abs(H[i - 2] - H[i]), dp[i - 1] + abs(H[i - 1] - H[i]))
return dp[N - 1]
print((solve()))
| false | 28.571429 | [
"-N = int(eval(input()))",
"-H = list(map(int, input().split()))",
"-dp = [10**9] * N",
"-dp[0] = 0",
"-for i in range(N):",
"- if i + 1 < N:",
"- dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))",
"- if i + 2 < N:",
"- dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + ... | false | 0.038227 | 0.061175 | 0.624877 | [
"s915084541",
"s823860383"
] |
u623819879 | p03088 | python | s248442716 | s845877329 | 237 | 204 | 42,480 | 42,480 | Accepted | Accepted | 13.92 | #x=int(input())
n=int(eval(input()))
m=102
chars=['A','T','C','G']
mo=10**9+7
d3=set()
d4=set()
for i in chars:
for j in chars:
for k in chars:
d3.add(i+j+k)
for l in chars:
d4.add(i+j+k+l)
kinsoku4=set()
kinsoku3=['AGC','ACG','GAC']
for y i... | n=int(eval(input()))
m=102
chars=['A','T','C','G']
mo=10**9+7
d4=set()
for i in chars:
for j in chars:
for k in chars:
for l in chars:
d4.add(i+j+k+l)
kinsoku4=set()
kinsoku3=['AGC','ACG','GAC']
for y in chars:
kinsoku4.add('AG'+y+'C')
kinsoku4.a... | 60 | 47 | 1,157 | 1,009 | # x=int(input())
n = int(eval(input()))
m = 102
chars = ["A", "T", "C", "G"]
mo = 10**9 + 7
d3 = set()
d4 = set()
for i in chars:
for j in chars:
for k in chars:
d3.add(i + j + k)
for l in chars:
d4.add(i + j + k + l)
kinsoku4 = set()
kinsoku3 = ["AGC", "ACG", "GAC"]
... | n = int(eval(input()))
m = 102
chars = ["A", "T", "C", "G"]
mo = 10**9 + 7
d4 = set()
for i in chars:
for j in chars:
for k in chars:
for l in chars:
d4.add(i + j + k + l)
kinsoku4 = set()
kinsoku3 = ["AGC", "ACG", "GAC"]
for y in chars:
kinsoku4.add("AG" + y + "C")
kinso... | false | 21.666667 | [
"-# x=int(input())",
"-d3 = set()",
"- d3.add(i + j + k)",
"-t = 101",
"+t = 1 + n",
"-# print(len(kinsoku4),kinsoku4)",
"-# print(dp)",
"-# for x in cnt:",
"-# print(x%mo)"
] | false | 0.233924 | 0.139908 | 1.671979 | [
"s248442716",
"s845877329"
] |
u708255304 | p03162 | python | s474701893 | s986832235 | 718 | 650 | 47,344 | 66,416 | Accepted | Accepted | 9.47 | "C Vacation"
N = int(eval(input()))
summer = []
for i in range(N):
active = list(map(int, input().split()))
summer.append(active)
dp = [[0]*3 for i in range(N+1)]
# dp = [[0, 0, 0]] * (N+1)
# print(dp)
for i in range(N):
dp[i+1][0] = max((max(dp[i][1], dp[i][2])+summer[i][0]), dp[i+1][0])
... | N = int(eval(input()))
S = [list(map(int, input().split())) for _ in range(N)] # N日間の夏休み
dp = [[0]*3 for _ in range(N)] # i日目の状態, (幸福度の合計, 前日の遊んだ内容3種類のテーブル)
# print(S)
# print(dp)
# 初期値
dp[0][0] = (S[0][0], 'a')
dp[0][1] = (S[0][1], 'b')
dp[0][2] = (S[0][2], 'c')
# print(dp)
for i in range(1, N): #... | 17 | 35 | 480 | 914 | "C Vacation"
N = int(eval(input()))
summer = []
for i in range(N):
active = list(map(int, input().split()))
summer.append(active)
dp = [[0] * 3 for i in range(N + 1)]
# dp = [[0, 0, 0]] * (N+1)
# print(dp)
for i in range(N):
dp[i + 1][0] = max((max(dp[i][1], dp[i][2]) + summer[i][0]), dp[i + 1][0])
dp[i... | N = int(eval(input()))
S = [list(map(int, input().split())) for _ in range(N)] # N日間の夏休み
dp = [[0] * 3 for _ in range(N)] # i日目の状態, (幸福度の合計, 前日の遊んだ内容3種類のテーブル)
# print(S)
# print(dp)
# 初期値
dp[0][0] = (S[0][0], "a")
dp[0][1] = (S[0][1], "b")
dp[0][2] = (S[0][2], "c")
# print(dp)
for i in range(1, N): # N日間の遷移
# aの... | false | 51.428571 | [
"-\"C Vacation\"",
"-summer = []",
"-for i in range(N):",
"- active = list(map(int, input().split()))",
"- summer.append(active)",
"-dp = [[0] * 3 for i in range(N + 1)]",
"-# dp = [[0, 0, 0]] * (N+1)",
"+S = [list(map(int, input().split())) for _ in range(N)] # N日間の夏休み",
"+dp = [[0] * 3 for ... | false | 0.056249 | 0.040009 | 1.405882 | [
"s474701893",
"s986832235"
] |
u644778646 | p03569 | python | s439686824 | s637483262 | 197 | 181 | 49,520 | 49,392 | Accepted | Accepted | 8.12 | def main():
s = list(eval(input()))
n = len(s)
ans = 0
l, r = 0, n-1
while l < r:
if s[l] == "x" and s[r] == "x":
l += 1
r -= 1
elif s[l] == "x":
l += 1
ans += 1
elif s[r] == "x":
r -= 1
a... | def main():
s = list(eval(input()))
n = len(s)
ans = 0
l, r = 0, n-1
while l < r:
if s[l] == s[r]:
l += 1
r -= 1
elif s[l] == "x":
l += 1
ans += 1
elif s[r] == "x":
r -= 1
ans += 1
... | 27 | 24 | 508 | 424 | def main():
s = list(eval(input()))
n = len(s)
ans = 0
l, r = 0, n - 1
while l < r:
if s[l] == "x" and s[r] == "x":
l += 1
r -= 1
elif s[l] == "x":
l += 1
ans += 1
elif s[r] == "x":
r -= 1
ans += 1
... | def main():
s = list(eval(input()))
n = len(s)
ans = 0
l, r = 0, n - 1
while l < r:
if s[l] == s[r]:
l += 1
r -= 1
elif s[l] == "x":
l += 1
ans += 1
elif s[r] == "x":
r -= 1
ans += 1
else:
... | false | 11.111111 | [
"- if s[l] == \"x\" and s[r] == \"x\":",
"+ if s[l] == s[r]:",
"- elif s[l] == s[r]:",
"- l += 1",
"- r -= 1"
] | false | 0.036519 | 0.093516 | 0.39051 | [
"s439686824",
"s637483262"
] |
u469953228 | p03251 | python | s566103323 | s294430571 | 20 | 17 | 2,940 | 3,060 | Accepted | Accepted | 15 | n,m,x,y= list(map(int,input().split()))
lix=list(map(int,input().split()))
liy=list(map(int,input().split()))
lix.append(x)
liy.append(y)
if max(lix) < min(liy):
print("No War")
else:
print("War")
| n,m,x,y= list(map(int,input().split()))
lix=list(map(int,input().split()))
liy=list(map(int,input().split()))
lix.append(x)
liy.append(y)
lix.sort()
liy.sort()
if lix[n] < liy[0]:
print("No War")
else:
print("War")
| 9 | 11 | 203 | 223 | n, m, x, y = list(map(int, input().split()))
lix = list(map(int, input().split()))
liy = list(map(int, input().split()))
lix.append(x)
liy.append(y)
if max(lix) < min(liy):
print("No War")
else:
print("War")
| n, m, x, y = list(map(int, input().split()))
lix = list(map(int, input().split()))
liy = list(map(int, input().split()))
lix.append(x)
liy.append(y)
lix.sort()
liy.sort()
if lix[n] < liy[0]:
print("No War")
else:
print("War")
| false | 18.181818 | [
"-if max(lix) < min(liy):",
"+lix.sort()",
"+liy.sort()",
"+if lix[n] < liy[0]:"
] | false | 0.053099 | 0.057278 | 0.92704 | [
"s566103323",
"s294430571"
] |
u642874916 | p03569 | python | s273550161 | s765738299 | 210 | 64 | 47,468 | 4,596 | Accepted | Accepted | 69.52 | from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
def I(): return int(input())
def S(): return input()
def MI... | from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
def I(): return int(input())
def S(): return input()
def MI... | 84 | 84 | 1,531 | 1,519 | from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
def I():
return int(input())
def S():
return input()
def MI():
r... | from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
def I():
return int(input())
def S():
return input()
def MI():
r... | false | 0 | [
"-IINF = 10**10",
"+IINF = 10**19",
"- # print(d)",
"- if d[0] == d[-1]:",
"- d.popleft()",
"- d.pop()",
"- elif d[0] == \"x\":",
"- d.append(\"x\")",
"+ l = d.popleft()",
"+ r = d.pop()",
"+ if l == r:",
"+ cont... | false | 0.041519 | 0.042746 | 0.9713 | [
"s273550161",
"s765738299"
] |
u048945791 | p03240 | python | s492046296 | s311356535 | 105 | 88 | 3,064 | 3,064 | Accepted | Accepted | 16.19 | n = int(eval(input()))
x = []
y = []
h = []
for i in range(n):
xi, yi, hi = list(map(int, input().split()))
x.append(xi)
y.append(yi)
h.append(hi)
isOk = False
i = 0
j = 0
constant = -1
for i in range(101):
for j in range(101):
constant = -1
for k in range(n):... | n = int(eval(input()))
xyh = []
for i in range(n):
xyh.append(list(map(int, input().split())))
isOk = False
i = 0
j = 0
constant = -1
for i in range(101):
for j in range(101):
constant = -1
for xyhTemp in xyh:
if xyhTemp[2] != 0:
temp = xyhTemp[... | 43 | 39 | 839 | 799 | n = int(eval(input()))
x = []
y = []
h = []
for i in range(n):
xi, yi, hi = list(map(int, input().split()))
x.append(xi)
y.append(yi)
h.append(hi)
isOk = False
i = 0
j = 0
constant = -1
for i in range(101):
for j in range(101):
constant = -1
for k in range(n):
if h[k] != ... | n = int(eval(input()))
xyh = []
for i in range(n):
xyh.append(list(map(int, input().split())))
isOk = False
i = 0
j = 0
constant = -1
for i in range(101):
for j in range(101):
constant = -1
for xyhTemp in xyh:
if xyhTemp[2] != 0:
temp = xyhTemp[2] + abs(i - xyhTemp[0]... | false | 9.302326 | [
"-x = []",
"-y = []",
"-h = []",
"+xyh = []",
"- xi, yi, hi = list(map(int, input().split()))",
"- x.append(xi)",
"- y.append(yi)",
"- h.append(hi)",
"+ xyh.append(list(map(int, input().split())))",
"- for k in range(n):",
"- if h[k] != 0:",
"- t... | false | 0.039198 | 0.065279 | 0.600476 | [
"s492046296",
"s311356535"
] |
u364363327 | p02642 | python | s023138681 | s310702910 | 592 | 495 | 55,252 | 55,184 | Accepted | Accepted | 16.39 | import numpy as np
N = int(eval(input()))
A = list(map(int,input().split()))
A = np.array(A)
A.sort()
d = {}
for a in A:
d.setdefault(a,0)
d[a] += 1
sieve = [True] * (A[-1] + 1)
for a in A:
if d[a] > 1:
sieve[a] = False
for i in range(a + a, A[-1] + 1, a):
... | import numpy as np
N = int(eval(input()))
A = list(map(int,input().split()))
A = np.array(A)
A.sort()
d = {}
for a in A:
d.setdefault(a,0)
d[a] += 1
sieve = [True] * (A[-1] + 1)
for a in A:
if sieve[a] == False:
continue
if d[a] > 1:
sieve[a] = False
for ... | 26 | 26 | 371 | 412 | import numpy as np
N = int(eval(input()))
A = list(map(int, input().split()))
A = np.array(A)
A.sort()
d = {}
for a in A:
d.setdefault(a, 0)
d[a] += 1
sieve = [True] * (A[-1] + 1)
for a in A:
if d[a] > 1:
sieve[a] = False
for i in range(a + a, A[-1] + 1, a):
sieve[i] = False
print((sum(... | import numpy as np
N = int(eval(input()))
A = list(map(int, input().split()))
A = np.array(A)
A.sort()
d = {}
for a in A:
d.setdefault(a, 0)
d[a] += 1
sieve = [True] * (A[-1] + 1)
for a in A:
if sieve[a] == False:
continue
if d[a] > 1:
sieve[a] = False
for i in range(a + a, A[-1] + ... | false | 0 | [
"+ if sieve[a] == False:",
"+ continue"
] | false | 0.580555 | 0.225982 | 2.569029 | [
"s023138681",
"s310702910"
] |
u762955009 | p03012 | python | s038081033 | s099171014 | 174 | 18 | 38,384 | 2,940 | Accepted | Accepted | 89.66 | from itertools import accumulate
N = int(eval(input()))
W = list(accumulate([int(x) for x in input().split()]))
ans = 10**9
for i in range(N - 1):
ans = min(ans, abs(W[N - 1] - W[i]*2))
print(ans) | N = int(eval(input()))
W = [int(x) for x in input().split()]
s1 = 0
s2 = sum(W)
ans = 10**9
for w in W:
s1 += w
s2 -= w
ans = min(ans, abs(s1 -s2))
print(ans)
| 9 | 12 | 204 | 178 | from itertools import accumulate
N = int(eval(input()))
W = list(accumulate([int(x) for x in input().split()]))
ans = 10**9
for i in range(N - 1):
ans = min(ans, abs(W[N - 1] - W[i] * 2))
print(ans)
| N = int(eval(input()))
W = [int(x) for x in input().split()]
s1 = 0
s2 = sum(W)
ans = 10**9
for w in W:
s1 += w
s2 -= w
ans = min(ans, abs(s1 - s2))
print(ans)
| false | 25 | [
"-from itertools import accumulate",
"-",
"-W = list(accumulate([int(x) for x in input().split()]))",
"+W = [int(x) for x in input().split()]",
"+s1 = 0",
"+s2 = sum(W)",
"-for i in range(N - 1):",
"- ans = min(ans, abs(W[N - 1] - W[i] * 2))",
"+for w in W:",
"+ s1 += w",
"+ s2 -= w",
... | false | 0.03822 | 0.037353 | 1.023218 | [
"s038081033",
"s099171014"
] |
u977389981 | p03088 | python | s464846112 | s166972737 | 128 | 43 | 3,856 | 3,316 | Accepted | Accepted | 66.41 | N = int(eval(input()))
mod = 10 ** 9 + 7
D = [{} for i in range(N + 1)]
def check(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i - 1], t[i] = t[i], t[i - 1]
if ''.join(t).count('AGC') >= 1:
return False
return True
def dfs(cur, last3)... | N = int(eval(input()))
mod = 10 ** 9 + 7
D = [[[[0] * 4 for i in range(4)] for i in range(4)] for i in range(101)]
D[0][3][3][3] = 1
for i in range(100):
for j in range(4):
for k in range(4):
for l in range(4):
for x in range(4):
if k == 0 and l == ... | 26 | 31 | 601 | 1,016 | N = int(eval(input()))
mod = 10**9 + 7
D = [{} for i in range(N + 1)]
def check(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i - 1], t[i] = t[i], t[i - 1]
if "".join(t).count("AGC") >= 1:
return False
return True
def dfs(cur, last3):
if last3 in... | N = int(eval(input()))
mod = 10**9 + 7
D = [[[[0] * 4 for i in range(4)] for i in range(4)] for i in range(101)]
D[0][3][3][3] = 1
for i in range(100):
for j in range(4):
for k in range(4):
for l in range(4):
for x in range(4):
if k == 0 and l == 1 and x == 2:... | false | 16.129032 | [
"-D = [{} for i in range(N + 1)]",
"-",
"-",
"-def check(last4):",
"- for i in range(4):",
"- t = list(last4)",
"- if i >= 1:",
"- t[i - 1], t[i] = t[i], t[i - 1]",
"- if \"\".join(t).count(\"AGC\") >= 1:",
"- return False",
"- return True",
"-"... | false | 0.103903 | 0.066916 | 1.552739 | [
"s464846112",
"s166972737"
] |
u729133443 | p02708 | python | s746776060 | s983935424 | 55 | 20 | 67,444 | 9,096 | Accepted | Accepted | 63.64 | n,k=list(map(int,input().split()))
print((sum(-~i+i*(n-i)for i in range(k,n+2))%(10**9+7))) | n,k=list(map(int,input().split()))
print(((n-k+2)*((-k-~n)*(n+2*k)+6)//6%(10**9+7))) | 2 | 2 | 84 | 77 | n, k = list(map(int, input().split()))
print((sum(-~i + i * (n - i) for i in range(k, n + 2)) % (10**9 + 7)))
| n, k = list(map(int, input().split()))
print(((n - k + 2) * ((-k - ~n) * (n + 2 * k) + 6) // 6 % (10**9 + 7)))
| false | 0 | [
"-print((sum(-~i + i * (n - i) for i in range(k, n + 2)) % (10**9 + 7)))",
"+print(((n - k + 2) * ((-k - ~n) * (n + 2 * k) + 6) // 6 % (10**9 + 7)))"
] | false | 0.047044 | 0.035355 | 1.330635 | [
"s746776060",
"s983935424"
] |
u547167033 | p03388 | python | s451177323 | s185167188 | 21 | 19 | 3,064 | 3,064 | Accepted | Accepted | 9.52 | q=int(eval(input()))
for _ in range(q):
a,b=list(map(int,input().split()))
if a>b:
a,b=b,a
if a==b:
print((2*a-2))
elif a==b+1:
print((2*a-1))
else:
c=int((a*b)**0.5)
if c*c==a*b:
c-=1
if c*(c+1)>=a*b:
print((2*c-2))
else:
print((2*c-1)) | q=int(eval(input()))
for _ in range(q):
a,b=list(map(int,input().split()))
if a>b:
a,b=b,a
if a==b:
print((2*a-2))
elif b==a+1:
print((2*a-2))
else:
c=int((a*b)**0.5)-1
while (c+1)*(c+1)<a*b:
c+=1
if c*(c+1)>=a*b:
print((2*c-2))
else:
print((2*c-1)... | 17 | 17 | 289 | 301 | q = int(eval(input()))
for _ in range(q):
a, b = list(map(int, input().split()))
if a > b:
a, b = b, a
if a == b:
print((2 * a - 2))
elif a == b + 1:
print((2 * a - 1))
else:
c = int((a * b) ** 0.5)
if c * c == a * b:
c -= 1
if c * (c + 1) ... | q = int(eval(input()))
for _ in range(q):
a, b = list(map(int, input().split()))
if a > b:
a, b = b, a
if a == b:
print((2 * a - 2))
elif b == a + 1:
print((2 * a - 2))
else:
c = int((a * b) ** 0.5) - 1
while (c + 1) * (c + 1) < a * b:
c += 1
... | false | 0 | [
"- elif a == b + 1:",
"- print((2 * a - 1))",
"+ elif b == a + 1:",
"+ print((2 * a - 2))",
"- c = int((a * b) ** 0.5)",
"- if c * c == a * b:",
"- c -= 1",
"+ c = int((a * b) ** 0.5) - 1",
"+ while (c + 1) * (c + 1) < a * b:",
"+ ... | false | 0.097739 | 0.15049 | 0.649476 | [
"s451177323",
"s185167188"
] |
u340781749 | p03283 | python | s709820795 | s593558869 | 937 | 464 | 17,524 | 37,064 | Accepted | Accepted | 50.48 | from itertools import accumulate
n, m, q = list(map(int, input().split()))
rails = [[0] * n for _ in range(n)]
for _ in range(m):
l, r = list(map(int, input().split()))
rails[l - 1][r - 1] += 1
rails = [list(accumulate(s)) for s in rails]
rails = [list(reversed(list(accumulate(reversed(s))))) for s in ... | import sys
from itertools import accumulate
n, m, q = list(map(int, input().split()))
ipt = sys.stdin.readlines()
rails = [[0] * n for _ in range(n)]
for l, r in (list(map(int, line.split())) for line in ipt[:m]):
rails[l - 1][r - 1] += 1
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(... | 14 | 10 | 459 | 443 | from itertools import accumulate
n, m, q = list(map(int, input().split()))
rails = [[0] * n for _ in range(n)]
for _ in range(m):
l, r = list(map(int, input().split()))
rails[l - 1][r - 1] += 1
rails = [list(accumulate(s)) for s in rails]
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*rai... | import sys
from itertools import accumulate
n, m, q = list(map(int, input().split()))
ipt = sys.stdin.readlines()
rails = [[0] * n for _ in range(n)]
for l, r in (list(map(int, line.split())) for line in ipt[:m]):
rails[l - 1][r - 1] += 1
rails = [
list(reversed(list(accumulate(reversed(s)))))
for s in zip... | false | 28.571429 | [
"+import sys",
"+ipt = sys.stdin.readlines()",
"-for _ in range(m):",
"- l, r = list(map(int, input().split()))",
"+for l, r in (list(map(int, line.split())) for line in ipt[:m]):",
"-rails = [list(accumulate(s)) for s in rails]",
"-rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(... | false | 0.03733 | 0.069206 | 0.539411 | [
"s709820795",
"s593558869"
] |
u296518383 | p02804 | python | s590534868 | s390922709 | 299 | 267 | 84,464 | 77,608 | Accepted | Accepted | 10.7 | def cmb(n, r, mod):
if ( r < 0 or r > n ):
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
MOD = 10 ** 9 + 7 #出力の制限
N = 10 ** 5 * 2 + 1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range(2, N + 1 ):
g1.append((g1[-1] * i) % MOD)
inver... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
### Combination Table ###
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
def comb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2... | 29 | 30 | 657 | 693 | def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
MOD = 10**9 + 7 # 出力の制限
N = 10**5 * 2 + 1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
g1.append((g1[-1] * i) % MOD)
inverse.a... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
### Combination Table ###
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
def comb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mo... | false | 3.333333 | [
"-def cmb(n, r, mod):",
"+N, K = list(map(int, input().split()))",
"+A = list(map(int, input().split()))",
"+MOD = 10**9 + 7",
"+### Combination Table ###",
"+g1 = [1, 1] # 元テーブル",
"+g2 = [1, 1] # 逆元テーブル",
"+inverse = [0, 1] # 逆元テーブル計算用テーブル",
"+",
"+",
"+def comb(n, r, mod):",
"-MOD = 10**9... | false | 0.865636 | 0.04766 | 18.162776 | [
"s590534868",
"s390922709"
] |
u499381410 | p02695 | python | s972089015 | s346437192 | 337 | 208 | 82,468 | 77,604 | Accepted | Accepted | 38.28 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, ... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, ... | 51 | 47 | 1,493 | 1,368 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
fro... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
fro... | false | 7.843137 | [
"+from itertools import combinations_with_replacement, combinations",
"-",
"-",
"-def f(arr):",
"- global ans",
"- if len(arr) == n:",
"- ret = 0",
"- for a, b, c, d in L:",
"- if arr[b - 1] - arr[a - 1] == c:",
"- ret += d",
"- ans = max(ans,... | false | 0.148165 | 0.047298 | 3.132591 | [
"s972089015",
"s346437192"
] |
u600402037 | p03673 | python | s806943404 | s586000285 | 210 | 177 | 26,356 | 26,180 | Accepted | Accepted | 15.71 | N = int(eval(input()))
A = list(map(int, input().split()))
right = []
left = []
for i in range(N):
if i % 2 == 0:
right.append(A[i])
else:
left.append(A[i])
answer = left[::-1]
answer += right
if N%2 == 1:
answer = answer[::-1]
print((*answer))
| N=int(input())
A=list(map(int,input().split()))
print(*A[::-2], end=' ')
print(*A[N%2::2])
| 16 | 4 | 295 | 93 | N = int(eval(input()))
A = list(map(int, input().split()))
right = []
left = []
for i in range(N):
if i % 2 == 0:
right.append(A[i])
else:
left.append(A[i])
answer = left[::-1]
answer += right
if N % 2 == 1:
answer = answer[::-1]
print((*answer))
| N = int(input())
A = list(map(int, input().split()))
print(*A[::-2], end=" ")
print(*A[N % 2 :: 2])
| false | 75 | [
"-N = int(eval(input()))",
"+N = int(input())",
"-right = []",
"-left = []",
"-for i in range(N):",
"- if i % 2 == 0:",
"- right.append(A[i])",
"- else:",
"- left.append(A[i])",
"-answer = left[::-1]",
"-answer += right",
"-if N % 2 == 1:",
"- answer = answer[::-1]",
... | false | 0.03743 | 0.038986 | 0.960087 | [
"s806943404",
"s586000285"
] |
u489959379 | p03475 | python | s425247157 | s061619463 | 121 | 55 | 3,064 | 3,188 | Accepted | Accepted | 54.55 | n = int(eval(input()))
C, S, F = [], [], []
for i in range(n - 1):
c, s, f = list(map(int, input().split()))
C.append(c)
S.append(s)
F.append(f)
for i in range(n):
t = 0
for j in range(i, n - 1):
if t <= S[j]:
t = S[j]
elif (t - S[j]) % F[j] == 0:
... | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
CSF = [list(map(int, input().split())) for _ in range(n - 1)]
for i in range(n):
if i == n - 1:
print((0))
brea... | 19 | 33 | 411 | 738 | n = int(eval(input()))
C, S, F = [], [], []
for i in range(n - 1):
c, s, f = list(map(int, input().split()))
C.append(c)
S.append(s)
F.append(f)
for i in range(n):
t = 0
for j in range(i, n - 1):
if t <= S[j]:
t = S[j]
elif (t - S[j]) % F[j] == 0:
pass
... | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
CSF = [list(map(int, input().split())) for _ in range(n - 1)]
for i in range(n):
if i == n - 1:
print((0))
break
c1, s1, _ ... | false | 42.424242 | [
"-n = int(eval(input()))",
"-C, S, F = [], [], []",
"-for i in range(n - 1):",
"- c, s, f = list(map(int, input().split()))",
"- C.append(c)",
"- S.append(s)",
"- F.append(f)",
"-for i in range(n):",
"- t = 0",
"- for j in range(i, n - 1):",
"- if t <= S[j]:",
"- ... | false | 0.048021 | 0.081708 | 0.587712 | [
"s425247157",
"s061619463"
] |
u866769581 | p03069 | python | s273811552 | s785070380 | 102 | 77 | 19,304 | 3,500 | Accepted | Accepted | 24.51 | n = int(eval(input()))
s = eval(input())
lis = []
ws=s.count('.')
lis.append(ws)
bs = 0
for x in s:
if x == '#':
bs += 1
lis.append(bs+ws)
else:
ws -= 1
lis.append(bs+ws)
print((min(lis)))
| n = int(eval(input()))
s = eval(input())
bs = 0
ws = s.count('.')
ans = ws
for c in s:
if c == '.':
ws -= 1
else:
bs += 1
now = ws + bs
if ans > now:
ans = now
print(ans)
| 14 | 14 | 224 | 212 | n = int(eval(input()))
s = eval(input())
lis = []
ws = s.count(".")
lis.append(ws)
bs = 0
for x in s:
if x == "#":
bs += 1
lis.append(bs + ws)
else:
ws -= 1
lis.append(bs + ws)
print((min(lis)))
| n = int(eval(input()))
s = eval(input())
bs = 0
ws = s.count(".")
ans = ws
for c in s:
if c == ".":
ws -= 1
else:
bs += 1
now = ws + bs
if ans > now:
ans = now
print(ans)
| false | 0 | [
"-lis = []",
"+bs = 0",
"-lis.append(ws)",
"-bs = 0",
"-for x in s:",
"- if x == \"#\":",
"+ans = ws",
"+for c in s:",
"+ if c == \".\":",
"+ ws -= 1",
"+ else:",
"- lis.append(bs + ws)",
"- else:",
"- ws -= 1",
"- lis.append(bs + ws)",
"-print((min(... | false | 0.077539 | 0.115731 | 0.669991 | [
"s273811552",
"s785070380"
] |
u046187684 | p02597 | python | s505242071 | s051729062 | 63 | 28 | 10,812 | 9,388 | Accepted | Accepted | 55.56 | def solve(string):
n, c = string.split()
n, c = int(n), list(c)
wi, ri = 0, n - 1
while wi < n and c[wi] == "R":
wi += 1
while ri >= 0 and c[ri] == "W":
ri -= 1
ans = 0
while wi < n and ri >= 0 and wi < ri:
c[wi], c[ri], ans = c[ri], c[wi], ans + 1
... | def solve(string):
_, c = string.split()
r = c.count("R")
return str(c[:r].count("W"))
if __name__ == '__main__':
import sys
print((solve(sys.stdin.read().strip())))
| 22 | 9 | 580 | 194 | def solve(string):
n, c = string.split()
n, c = int(n), list(c)
wi, ri = 0, n - 1
while wi < n and c[wi] == "R":
wi += 1
while ri >= 0 and c[ri] == "W":
ri -= 1
ans = 0
while wi < n and ri >= 0 and wi < ri:
c[wi], c[ri], ans = c[ri], c[wi], ans + 1
wi, ri = wi... | def solve(string):
_, c = string.split()
r = c.count("R")
return str(c[:r].count("W"))
if __name__ == "__main__":
import sys
print((solve(sys.stdin.read().strip())))
| false | 59.090909 | [
"- n, c = string.split()",
"- n, c = int(n), list(c)",
"- wi, ri = 0, n - 1",
"- while wi < n and c[wi] == \"R\":",
"- wi += 1",
"- while ri >= 0 and c[ri] == \"W\":",
"- ri -= 1",
"- ans = 0",
"- while wi < n and ri >= 0 and wi < ri:",
"- c[wi], c[ri], an... | false | 0.036902 | 0.041782 | 0.883213 | [
"s505242071",
"s051729062"
] |
u254871849 | p03731 | python | s132765927 | s582081599 | 156 | 99 | 25,196 | 25,132 | Accepted | Accepted | 36.54 | N, T = [int(i) for i in input().split()]
t = [int(t) for t in input().split()]
total = T
for i in range(N-1):
if t[i+1] - t[i] < T:
total += t[i+1] - t[i]
else:
total += T
print(total)
| import sys
n, T, *t = list(map(int, sys.stdin.read().split()))
def main():
start = 0
will_stop = T
running_time = 0
for i in range(1, n):
cur = t[i]
if cur < will_stop:
running_time += cur - start
else:
running_time += T
start = cur... | 11 | 23 | 221 | 457 | N, T = [int(i) for i in input().split()]
t = [int(t) for t in input().split()]
total = T
for i in range(N - 1):
if t[i + 1] - t[i] < T:
total += t[i + 1] - t[i]
else:
total += T
print(total)
| import sys
n, T, *t = list(map(int, sys.stdin.read().split()))
def main():
start = 0
will_stop = T
running_time = 0
for i in range(1, n):
cur = t[i]
if cur < will_stop:
running_time += cur - start
else:
running_time += T
start = cur
will... | false | 52.173913 | [
"-N, T = [int(i) for i in input().split()]",
"-t = [int(t) for t in input().split()]",
"-total = T",
"-for i in range(N - 1):",
"- if t[i + 1] - t[i] < T:",
"- total += t[i + 1] - t[i]",
"- else:",
"- total += T",
"-print(total)",
"+import sys",
"+",
"+n, T, *t = list(map(i... | false | 0.04214 | 0.042835 | 0.983788 | [
"s132765927",
"s582081599"
] |
u488401358 | p03562 | python | s299818393 | s947434116 | 550 | 254 | 85,416 | 85,184 | Accepted | Accepted | 53.82 | import random
mod=998244353
N,X=input().split()
N=int(N)
A=[]
for i in range(N):
A.append(int(eval(input()),2))
A.sort()
a=A[-1]
M=max(len(X)-1,a.bit_length()-1)
data=[0]*(M+1)
n=a.bit_length()-1
for i in range(M-n,-1,-1):
data[i+n]=a<<i
for i in range(0,N-1):
a=A[i]
flag=True
... | import random
mod=998244353
N,X=input().split()
N=int(N)
A=[]
for i in range(N):
A.append(int(eval(input()),2))
A.sort()
a=A[-1]
M=max(len(X)-1,a.bit_length()-1)
data=[0]*(M+1)
n=a.bit_length()-1
for i in range(M-n,-1,-1):
data[i+n]=a<<i
low=n
for i in range(0,N-1):
a=A[i]
flag=Tr... | 78 | 77 | 1,565 | 1,505 | import random
mod = 998244353
N, X = input().split()
N = int(N)
A = []
for i in range(N):
A.append(int(eval(input()), 2))
A.sort()
a = A[-1]
M = max(len(X) - 1, a.bit_length() - 1)
data = [0] * (M + 1)
n = a.bit_length() - 1
for i in range(M - n, -1, -1):
data[i + n] = a << i
for i in range(0, N - 1):
a = ... | import random
mod = 998244353
N, X = input().split()
N = int(N)
A = []
for i in range(N):
A.append(int(eval(input()), 2))
A.sort()
a = A[-1]
M = max(len(X) - 1, a.bit_length() - 1)
data = [0] * (M + 1)
n = a.bit_length() - 1
for i in range(M - n, -1, -1):
data[i + n] = a << i
low = n
for i in range(0, N - 1):
... | false | 1.282051 | [
"+low = n",
"- for j in range(n - 1, -1, -1):",
"+ for j in range(n - 1, low - 1, -1):",
"+ low = id",
"- if data[id + 1]:",
"- id += 1",
"- else:",
"- flag = False",
"+ id += 1"
] | false | 0.035169 | 0.076764 | 0.458146 | [
"s299818393",
"s947434116"
] |
u321035578 | p03634 | python | s234656581 | s751444979 | 1,467 | 940 | 52,420 | 51,772 | Accepted | Accepted | 35.92 | import queue
def main():
n = int(eval(input()))
a = []
b = []
c = []
lst = [[] for _ in range(n)]
for i in range(n - 1):
aa, bb, cc = list(map(int,input().split()))
lst[aa - 1].append((bb - 1, cc))
lst[bb - 1].append((aa - 1, cc))
q, k = list(map(int,in... | from collections import deque
def main():
n = int(eval(input()))
a = []
b = []
c = []
lst = [[] for _ in range(n)]
for i in range(n - 1):
aa, bb, cc = list(map(int,input().split()))
lst[aa - 1].append((bb - 1, cc))
lst[bb - 1].append((aa - 1, cc))
q, k ... | 40 | 40 | 842 | 861 | import queue
def main():
n = int(eval(input()))
a = []
b = []
c = []
lst = [[] for _ in range(n)]
for i in range(n - 1):
aa, bb, cc = list(map(int, input().split()))
lst[aa - 1].append((bb - 1, cc))
lst[bb - 1].append((aa - 1, cc))
q, k = list(map(int, input().split... | from collections import deque
def main():
n = int(eval(input()))
a = []
b = []
c = []
lst = [[] for _ in range(n)]
for i in range(n - 1):
aa, bb, cc = list(map(int, input().split()))
lst[aa - 1].append((bb - 1, cc))
lst[bb - 1].append((aa - 1, cc))
q, k = list(map(i... | false | 0 | [
"-import queue",
"+from collections import deque",
"- qq = queue.Queue()",
"- qq.put(k - 1)",
"+ qq = deque()",
"+ qq.append(k - 1)",
"- while not qq.empty():",
"- now = qq.get()",
"+ while len(qq) != 0:",
"+ now = qq.popleft()",
"- qq.put(to)",
"+ ... | false | 0.039181 | 0.03764 | 1.040945 | [
"s234656581",
"s751444979"
] |
u764600134 | p03161 | python | s428403427 | s698140173 | 1,947 | 455 | 14,016 | 55,392 | Accepted | Accepted | 76.63 | # -*- coding: utf-8 -*-
"""
B - Frog 2
https://atcoder.jp/contests/dp/tasks/dp_b
"""
import sys
from sys import stdin
def solve(ashiba, N, K):
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, len(ashiba)):
paths = [dp[j]+abs(ashiba[j]-ashiba[i]) for j in range(max(0, i-K), i)]
... | # -*- coding: utf-8 -*-
"""
B - Frog 2
https://atcoder.jp/contests/dp/tasks/dp_b
AC
"""
import sys
from sys import stdin
def solve(ashiba, N, K):
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, len(ashiba)):
paths = [dp[j]+abs(ashiba[j]-ashiba[i]) for j in range(max(0, i-K), i)]
... | 28 | 28 | 575 | 577 | # -*- coding: utf-8 -*-
"""
B - Frog 2
https://atcoder.jp/contests/dp/tasks/dp_b
"""
import sys
from sys import stdin
def solve(ashiba, N, K):
dp = [float("inf")] * N
dp[0] = 0
for i in range(1, len(ashiba)):
paths = [dp[j] + abs(ashiba[j] - ashiba[i]) for j in range(max(0, i - K), i)]
dp[... | # -*- coding: utf-8 -*-
"""
B - Frog 2
https://atcoder.jp/contests/dp/tasks/dp_b
AC
"""
import sys
from sys import stdin
def solve(ashiba, N, K):
dp = [float("inf")] * N
dp[0] = 0
for i in range(1, len(ashiba)):
paths = [dp[j] + abs(ashiba[j] - ashiba[i]) for j in range(max(0, i - K), i)]
... | false | 0 | [
"+AC"
] | false | 0.042241 | 0.041806 | 1.010409 | [
"s428403427",
"s698140173"
] |
u672475305 | p03804 | python | s946173322 | s704440911 | 87 | 26 | 3,064 | 3,060 | Accepted | Accepted | 70.11 | def match(x,y):
ret = True
for i in range(m):
for j in range(m):
if A[y+i][x+j] != B[i][j]:
ret = False
return ret
n,m = list(map(int,input().split()))
A = []
for i in range(n):
A.append(list(eval(input())))
B = []
for i in range(m):
B.append(list... | n,m = list(map(int,input().split()))
A = [list(eval(input())) for _ in range(n)]
B = [list(eval(input())) for _ in range(m)]
ans = False
for i in range(n-m+1):
for j in range(n-m+1):
flg = True
for e, k in enumerate(range(m)):
if A[i+e][j:j+m] != B[k]:
flg = Fals... | 23 | 14 | 464 | 395 | def match(x, y):
ret = True
for i in range(m):
for j in range(m):
if A[y + i][x + j] != B[i][j]:
ret = False
return ret
n, m = list(map(int, input().split()))
A = []
for i in range(n):
A.append(list(eval(input())))
B = []
for i in range(m):
B.append(list(eval(in... | n, m = list(map(int, input().split()))
A = [list(eval(input())) for _ in range(n)]
B = [list(eval(input())) for _ in range(m)]
ans = False
for i in range(n - m + 1):
for j in range(n - m + 1):
flg = True
for e, k in enumerate(range(m)):
if A[i + e][j : j + m] != B[k]:
flg... | false | 39.130435 | [
"-def match(x, y):",
"- ret = True",
"- for i in range(m):",
"- for j in range(m):",
"- if A[y + i][x + j] != B[i][j]:",
"- ret = False",
"- return ret",
"-",
"-",
"-A = []",
"-for i in range(n):",
"- A.append(list(eval(input())))",
"-B = []",
"... | false | 0.036426 | 0.075375 | 0.483261 | [
"s946173322",
"s704440911"
] |
u729133443 | p03740 | python | s474116365 | s499312380 | 38 | 17 | 27,884 | 2,940 | Accepted | Accepted | 55.26 | print('ABlriocwen'[eval(input().replace(' ','-'))**2<2::2]) | print(('ABlriocwen'[-2<eval(input().replace(' ','-'))<2::2])) | 1 | 1 | 61 | 59 | print("ABlriocwen"[eval(input().replace(" ", "-")) ** 2 < 2 :: 2])
| print(("ABlriocwen"[-2 < eval(input().replace(" ", "-")) < 2 :: 2]))
| false | 0 | [
"-print(\"ABlriocwen\"[eval(input().replace(\" \", \"-\")) ** 2 < 2 :: 2])",
"+print((\"ABlriocwen\"[-2 < eval(input().replace(\" \", \"-\")) < 2 :: 2]))"
] | false | 0.038562 | 0.041388 | 0.931717 | [
"s474116365",
"s499312380"
] |
u094815239 | p03244 | python | s404739761 | s232421517 | 124 | 74 | 15,588 | 15,588 | Accepted | Accepted | 40.32 | from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))
cnt1 = Counter(a[::2]).most_common(2)
c11, c12 = (cnt1 if len(cnt1) == 2 else cnt1+[('', 0)])
cnt2 = Counter(a[1::2]).most_common(2)
c21, c22 = (cnt2 if len(cnt2) == 2 else cnt2+[('', 0)])
if c11[0] != c21[0]:
... | from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))
cnt1 = Counter(a[::2]).most_common(2)
c11, c12 = (cnt1 if len(cnt1) == 2 else cnt1+[('', 0)])
cnt2 = Counter(a[1::2]).most_common(2)
c21, c22 = (cnt2 if len(cnt2) == 2 else cnt2+[('', 0)])
if c11[0] != c21[0]:
... | 13 | 12 | 417 | 408 | from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))
cnt1 = Counter(a[::2]).most_common(2)
c11, c12 = cnt1 if len(cnt1) == 2 else cnt1 + [("", 0)]
cnt2 = Counter(a[1::2]).most_common(2)
c21, c22 = cnt2 if len(cnt2) == 2 else cnt2 + [("", 0)]
if c11[0] != c21[0]:
prin... | from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))
cnt1 = Counter(a[::2]).most_common(2)
c11, c12 = cnt1 if len(cnt1) == 2 else cnt1 + [("", 0)]
cnt2 = Counter(a[1::2]).most_common(2)
c21, c22 = cnt2 if len(cnt2) == 2 else cnt2 + [("", 0)]
if c11[0] != c21[0]:
prin... | false | 7.692308 | [
"-print()"
] | false | 0.089468 | 0.099184 | 0.902038 | [
"s404739761",
"s232421517"
] |
u373047809 | p03356 | python | s813383703 | s935754826 | 462 | 353 | 13,876 | 32,072 | Accepted | Accepted | 23.59 | #!/usr/bin/env python3
import sys
input = sys.stdin.readline
class UnionFind():
def __init__(self, n, m = None, read = 0):
self.n = n
self.parents = [-1] * n
if read:
if m is None:
exit(print("Warning: What is M"))
for i in range(m):
... | ##### UnionFind #####
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]
... | 61 | 46 | 1,577 | 1,261 | #!/usr/bin/env python3
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, n, m=None, read=0):
self.n = n
self.parents = [-1] * n
if read:
if m is None:
exit(print("Warning: What is M"))
for i in range(m):
a, b ... | ##### UnionFind #####
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,... | false | 24.590164 | [
"-#!/usr/bin/env python3",
"-import sys",
"-",
"-input = sys.stdin.readline",
"-",
"-",
"+##### UnionFind #####",
"- def __init__(self, n, m=None, read=0):",
"+ def __init__(self, n):",
"- if read:",
"- if m is None:",
"- exit(print(\"Warning: What is M\"... | false | 0.042813 | 0.047157 | 0.907902 | [
"s813383703",
"s935754826"
] |
u111365362 | p02863 | python | s297914379 | s454354413 | 466 | 398 | 52,568 | 46,056 | Accepted | Accepted | 14.59 | #16:25
n,t = list(map(int,input().split()))
wv = []
for _ in range(n):
wv.append(list(map(int,input().split())))
wv.sort(key=lambda x:x[0])
now = [0 for _ in range(t+1)]
for i in range(n):
w,v = wv[i]
last = now
now = []
for f in range(t):
if f >= w:
now.append(max(last[f-w]+v,last[f]))... | n,t = list(map(int,input().split()))
dish = []
for _ in range(n):
a,b = list(map(int,input().split()))
dish.append([a,b])
dish.sort()
now = [0 for _ in range(t+1)]
for i in range(n):
a,b = dish[i]
for d in range(t)[::-1]:
if d + a < t:
now[d+a] = max(now[d+a],now[d]+b)
else:
now... | 18 | 16 | 408 | 367 | # 16:25
n, t = list(map(int, input().split()))
wv = []
for _ in range(n):
wv.append(list(map(int, input().split())))
wv.sort(key=lambda x: x[0])
now = [0 for _ in range(t + 1)]
for i in range(n):
w, v = wv[i]
last = now
now = []
for f in range(t):
if f >= w:
now.append(max(last[f... | n, t = list(map(int, input().split()))
dish = []
for _ in range(n):
a, b = list(map(int, input().split()))
dish.append([a, b])
dish.sort()
now = [0 for _ in range(t + 1)]
for i in range(n):
a, b = dish[i]
for d in range(t)[::-1]:
if d + a < t:
now[d + a] = max(now[d + a], now[d] + b)... | false | 11.111111 | [
"-# 16:25",
"-wv = []",
"+dish = []",
"- wv.append(list(map(int, input().split())))",
"-wv.sort(key=lambda x: x[0])",
"+ a, b = list(map(int, input().split()))",
"+ dish.append([a, b])",
"+dish.sort()",
"- w, v = wv[i]",
"- last = now",
"- now = []",
"- for f in range(t):"... | false | 0.188079 | 0.035665 | 5.273453 | [
"s297914379",
"s454354413"
] |
u046187684 | p02660 | python | s565809652 | s171142448 | 315 | 230 | 20,264 | 20,224 | Accepted | Accepted | 26.98 | def find_primes(n):
ps = []
t = [True] * n
t[0] = t[1] = False
for i in range(2, n):
if not t[i]:
continue
ps.append(i)
for j in range(i, n, i):
t[j] = False
return ps
def solve(string):
n = int(string)
if n == 1:
retu... | def find_primes(n):
ps = []
t = [True] * n
t[0] = t[1] = False
for i in range(2, n):
if not t[i]:
continue
ps.append(i)
for j in range(i, n, i):
t[j] = False
return ps
def solve(string):
n = int(string)
if n == 1:
retu... | 34 | 32 | 703 | 648 | def find_primes(n):
ps = []
t = [True] * n
t[0] = t[1] = False
for i in range(2, n):
if not t[i]:
continue
ps.append(i)
for j in range(i, n, i):
t[j] = False
return ps
def solve(string):
n = int(string)
if n == 1:
return "0"
rn = ... | def find_primes(n):
ps = []
t = [True] * n
t[0] = t[1] = False
for i in range(2, n):
if not t[i]:
continue
ps.append(i)
for j in range(i, n, i):
t[j] = False
return ps
def solve(string):
n = int(string)
if n == 1:
return "0"
rn = ... | false | 5.882353 | [
"- f = True",
"- f = False",
"- return str(ans + 1 if f else ans + (n >= rn))",
"+ return str(ans + (n >= rn))"
] | false | 0.006416 | 0.085063 | 0.075423 | [
"s565809652",
"s171142448"
] |
u143441425 | p02678 | python | s127860335 | s412802695 | 1,314 | 1,068 | 68,516 | 65,152 | Accepted | Accepted | 18.72 | # ダイクストラ法で部屋1から各部屋への最短経路を出す
import queue
n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]
# 隣接行列の作成
edges_dict = {}
for edge in edges:
a, b = edge
if a not in edges_dict:
edges_dict[a] = [b]
else:
edges_dict[a].append(b)
... | # ダイクストラ法で部屋1から各部屋への最短経路を出す
import queue
n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]
# 隣接行列の作成
edges_dict = {}
for edge in edges:
a, b = edge
if a not in edges_dict:
edges_dict[a] = [b]
else:
edges_dict[a].append(b)
... | 59 | 39 | 1,318 | 759 | # ダイクストラ法で部屋1から各部屋への最短経路を出す
import queue
n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]
# 隣接行列の作成
edges_dict = {}
for edge in edges:
a, b = edge
if a not in edges_dict:
edges_dict[a] = [b]
else:
edges_dict[a].append(b)
if b not in edge... | # ダイクストラ法で部屋1から各部屋への最短経路を出す
import queue
n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]
# 隣接行列の作成
edges_dict = {}
for edge in edges:
a, b = edge
if a not in edges_dict:
edges_dict[a] = [b]
else:
edges_dict[a].append(b)
if b not in edge... | false | 33.898305 | [
"-# 定数",
"-COST = 1",
"-INF = 1e10",
"-# i=0は未使用, i>0は部屋iへの最短距離",
"-dist_list = [INF] * (n + 1)",
"-q = queue.PriorityQueue()",
"+q = queue.Queue()",
"-q.put((0, 1)) # (最短経路, 部屋番号)",
"-dist_list[1] = 0",
"+q.put(1)",
"- min_dist, v = q.get()",
"- # print(\"min_dist={}, v={}\".format(min... | false | 0.036988 | 0.085071 | 0.434784 | [
"s127860335",
"s412802695"
] |
u380524497 | p02901 | python | s943152157 | s401920463 | 1,972 | 769 | 3,188 | 3,188 | Accepted | Accepted | 61 | n, m = list(map(int, input().split()))
DP = [10**9] * (2**n)
DP[0] = 0
for _ in range(m):
cost, types = list(map(int, input().split()))
to_open = list(map(int, input().split()))
openable = 0
for open in to_open:
openable += 1 << (open-1)
for opened in range(2 ** n):
p... | def main():
n, m = list(map(int, input().split()))
all_patterns = 2**n
DP = [10**9] * all_patterns
DP[0] = 0
for _ in range(m):
cost, types = list(map(int, input().split()))
to_open = list(map(int, input().split()))
openable = 0
for open in to_open:
... | 23 | 29 | 489 | 714 | n, m = list(map(int, input().split()))
DP = [10**9] * (2**n)
DP[0] = 0
for _ in range(m):
cost, types = list(map(int, input().split()))
to_open = list(map(int, input().split()))
openable = 0
for open in to_open:
openable += 1 << (open - 1)
for opened in range(2**n):
pattern = opened ... | def main():
n, m = list(map(int, input().split()))
all_patterns = 2**n
DP = [10**9] * all_patterns
DP[0] = 0
for _ in range(m):
cost, types = list(map(int, input().split()))
to_open = list(map(int, input().split()))
openable = 0
for open in to_open:
openab... | false | 20.689655 | [
"-n, m = list(map(int, input().split()))",
"-DP = [10**9] * (2**n)",
"-DP[0] = 0",
"-for _ in range(m):",
"- cost, types = list(map(int, input().split()))",
"- to_open = list(map(int, input().split()))",
"- openable = 0",
"- for open in to_open:",
"- openable += 1 << (open - 1)",
... | false | 0.054537 | 0.035374 | 1.541719 | [
"s943152157",
"s401920463"
] |
u714378447 | p03062 | python | s134457982 | s384267524 | 203 | 57 | 25,512 | 14,412 | Accepted | Accepted | 71.92 | N=int(eval(input()))
A=list(map(int,input().split()))
dp=[[0]*2 for i in range(N)]
dp[0][0]=0
dp[0][1]=-3*10**9
for i in range(N-1):
dp[i+1][0]=max(dp[i][0]+A[i], dp[i][1]-A[i])
dp[i+1][1]=max(dp[i][0]-A[i], dp[i][1]+A[i])
print((max(dp[-1][0]+A[-1], dp[-1][1]-A[-1]))) | N=int(eval(input()))
A=list(map(int,input().split()))
if 0 in A:
print((sum(abs(a) for a in A)))
else:
cnt=sum([1 for a in A if a<0])
if cnt%2==0:
print((sum(abs(a) for a in A)))
else:
A=[abs(a) for a in A]
print((sum(A) -2*min(A))) | 13 | 13 | 280 | 245 | N = int(eval(input()))
A = list(map(int, input().split()))
dp = [[0] * 2 for i in range(N)]
dp[0][0] = 0
dp[0][1] = -3 * 10**9
for i in range(N - 1):
dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])
print((max(dp[-1][0] + A[-1], dp[-1][1] - A[-1])))
| N = int(eval(input()))
A = list(map(int, input().split()))
if 0 in A:
print((sum(abs(a) for a in A)))
else:
cnt = sum([1 for a in A if a < 0])
if cnt % 2 == 0:
print((sum(abs(a) for a in A)))
else:
A = [abs(a) for a in A]
print((sum(A) - 2 * min(A)))
| false | 0 | [
"-dp = [[0] * 2 for i in range(N)]",
"-dp[0][0] = 0",
"-dp[0][1] = -3 * 10**9",
"-for i in range(N - 1):",
"- dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])",
"- dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])",
"-print((max(dp[-1][0] + A[-1], dp[-1][1] - A[-1])))",
"+if 0 in A:",
"... | false | 0.04093 | 0.041257 | 0.99209 | [
"s134457982",
"s384267524"
] |
u994521204 | p03045 | python | s979480470 | s938327982 | 1,646 | 610 | 130,648 | 12,780 | Accepted | Accepted | 62.94 | # union-findで行けそう。
n, m = list(map(int, input().split()))
par = [-1] * (n + 1)
def find(a):
if par[a] < 0:
return a
else:
par[a] = find(par[a])
return par[a]
def unite(a, b):
a = find(a)
b = find(b)
if a == b:
return False
else:
if... | n,m=list(map(int,input().split()))
#union-find
par=[-1]*(n+1)
def find(x):
if par[x]<0:
return x
else:
par[x]=find(par[x])
return par[x]
def size(x):
oya=find(x)
return -par[oya]
def unite(x,y):
if find(x)==find(y):
return False
else:
if si... | 35 | 33 | 589 | 722 | # union-findで行けそう。
n, m = list(map(int, input().split()))
par = [-1] * (n + 1)
def find(a):
if par[a] < 0:
return a
else:
par[a] = find(par[a])
return par[a]
def unite(a, b):
a = find(a)
b = find(b)
if a == b:
return False
else:
if par[a] < par[b]:
... | n, m = list(map(int, input().split()))
# union-find
par = [-1] * (n + 1)
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def size(x):
oya = find(x)
return -par[oya]
def unite(x, y):
if find(x) == find(y):
return False
else:
... | false | 5.714286 | [
"-# union-findで行けそう。",
"+# union-find",
"-def find(a):",
"- if par[a] < 0:",
"- return a",
"+def find(x):",
"+ if par[x] < 0:",
"+ return x",
"- par[a] = find(par[a])",
"- return par[a]",
"+ par[x] = find(par[x])",
"+ return par[x]",
"-def unit... | false | 0.034904 | 0.038859 | 0.898225 | [
"s979480470",
"s938327982"
] |
u301624971 | p02996 | python | s289345089 | s833232751 | 1,192 | 929 | 60,472 | 60,524 | Accepted | Accepted | 22.06 | '''
ABC 131 D:Megalomania
Accepted :Yes
difficult :
ペナルティ :5分
実際の回答時間 :9分
WAの回数 :0回
合計時間 :9分
'''
def myAnswer(N:int,A:list,B:list) -> str:
dic = {}
# 締め切り時間をkey、作業時間をvalueにした辞書を作成
for a,b in zip(A,B):
if(b in list(dic.keys())):
dic[b].append(a)
else:
... | '''
ABC 131 D:Megalomania
Accepted :Yes
difficult :
ペナルティ :5分
実際の回答時間 :9分
WAの回数 :0回
合計時間 :9分
'''
import sys
input = sys.stdin.readline
def myAnswer(N:int,A:list,B:list) -> str:
dic = {}
# 締め切り時間をkey、作業時間をvalueにした辞書を作成
for a,b in zip(A,B):
if(b in list(dic.keys())):
... | 56 | 58 | 1,163 | 1,203 | """
ABC 131 D:Megalomania
Accepted :Yes
difficult :
ペナルティ :5分
実際の回答時間 :9分
WAの回数 :0回
合計時間 :9分
"""
def myAnswer(N: int, A: list, B: list) -> str:
dic = {}
# 締め切り時間をkey、作業時間をvalueにした辞書を作成
for a, b in zip(A, B):
if b in list(dic.keys()):
dic[b].append(a)
else:
... | """
ABC 131 D:Megalomania
Accepted :Yes
difficult :
ペナルティ :5分
実際の回答時間 :9分
WAの回数 :0回
合計時間 :9分
"""
import sys
input = sys.stdin.readline
def myAnswer(N: int, A: list, B: list) -> str:
dic = {}
# 締め切り時間をkey、作業時間をvalueにした辞書を作成
for a, b in zip(A, B):
if b in list(dic.keys()):
... | false | 3.448276 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.040137 | 0.044041 | 0.911357 | [
"s289345089",
"s833232751"
] |
u903460784 | p03049 | python | s961364133 | s001532391 | 53 | 42 | 3,828 | 3,828 | Accepted | Accepted | 20.75 | n=int(eval(input()))
s=[eval(input()) for _ in range(n)]
isFinishA=[s[i][-1]=='A' for i in range(n)]
isStartB=[s[i][0]=='B' for i in range(n)]
ans=0
for si in s:
wasA=False
for sij in si:
if sij=='B':
if wasA:
ans+=1
wasA=(sij=='A')
fromBtoA=0
fromB=0
... | n=int(eval(input()))
s=[eval(input()) for _ in range(n)]
isFinishA=[s[i][-1]=='A' for i in range(n)]
isStartB=[s[i][0]=='B' for i in range(n)]
ans=0
for si in s:
wasA=False
for sij in si:
if sij=='B':
if wasA:
ans+=1
wasA=(sij=='A')
cnt=[isFinishA.count(Tr... | 35 | 23 | 697 | 519 | n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
isFinishA = [s[i][-1] == "A" for i in range(n)]
isStartB = [s[i][0] == "B" for i in range(n)]
ans = 0
for si in s:
wasA = False
for sij in si:
if sij == "B":
if wasA:
ans += 1
wasA = sij == "A"
fromBtoA = 0
... | n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
isFinishA = [s[i][-1] == "A" for i in range(n)]
isStartB = [s[i][0] == "B" for i in range(n)]
ans = 0
for si in s:
wasA = False
for sij in si:
if sij == "B":
if wasA:
ans += 1
wasA = sij == "A"
cnt = [isFini... | false | 34.285714 | [
"+cnt = [isFinishA.count(True), isStartB.count(True)]",
"+ans += min(cnt)",
"-fromB = 0",
"-toA = 0",
"- if isFinishA[i]:",
"- if isStartB[i]:",
"- fromBtoA += 1",
"- else:",
"- toA += 1",
"- else:",
"- if isStartB[i]:",
"- fromB += 1... | false | 0.03618 | 0.036689 | 0.986127 | [
"s961364133",
"s001532391"
] |
u077291787 | p03352 | python | s578605260 | s579099236 | 22 | 18 | 3,316 | 2,940 | Accepted | Accepted | 18.18 | # ABC097B - Exponential
def main():
X = int(eval(input()))
cand = {1}
for i in range(2, int(X ** 0.5) + 1):
p = 2
while i ** p <= X:
cand.add(i ** p)
p += 1
ans = max(cand)
print(ans)
if __name__ == "__main__":
main() | # ABC097B - Exponential
def main():
X = int(eval(input()))
cand = [1]
for i in range(2, int(X ** 0.5) + 1):
p = 2
while i ** p <= X:
cand.append(i ** p)
p += 1
ans = max(cand)
print(ans)
if __name__ == "__main__":
main() | 15 | 15 | 291 | 294 | # ABC097B - Exponential
def main():
X = int(eval(input()))
cand = {1}
for i in range(2, int(X**0.5) + 1):
p = 2
while i**p <= X:
cand.add(i**p)
p += 1
ans = max(cand)
print(ans)
if __name__ == "__main__":
main()
| # ABC097B - Exponential
def main():
X = int(eval(input()))
cand = [1]
for i in range(2, int(X**0.5) + 1):
p = 2
while i**p <= X:
cand.append(i**p)
p += 1
ans = max(cand)
print(ans)
if __name__ == "__main__":
main()
| false | 0 | [
"- cand = {1}",
"+ cand = [1]",
"- cand.add(i**p)",
"+ cand.append(i**p)"
] | false | 0.179408 | 0.042653 | 4.206202 | [
"s578605260",
"s579099236"
] |
u614181788 | p02598 | python | s091219925 | s791199889 | 653 | 578 | 59,200 | 59,344 | Accepted | Accepted | 11.49 | n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
s = sum(a)
x = [0]*n
y = 0
r = 0
for i in range(n):
y = int(a[i]/s*k)
x[i] = [i, y, a[i]/(y+1), a[i]]
r += y
x.sort(key= lambda val : val[2],reverse=True)
for i in range(k-r):
x[i][1] += 1
ans = 0
for i in range(n):
... | n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
s = sum(a)
x = [0]*n
t = 0
for i in range(n):
y = int(a[i]/s * k)
x[i] = [i, a[i], y, a[i]/(y+1)]
t += y
x.sort(key= lambda val : val[3],reverse=True)
for i in range(k-t):
x[i][2] += 1
ans = 0
for i in range(n):
an... | 17 | 16 | 377 | 371 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
s = sum(a)
x = [0] * n
y = 0
r = 0
for i in range(n):
y = int(a[i] / s * k)
x[i] = [i, y, a[i] / (y + 1), a[i]]
r += y
x.sort(key=lambda val: val[2], reverse=True)
for i in range(k - r):
x[i][1] += 1
ans = 0
for i in range(n):
... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
s = sum(a)
x = [0] * n
t = 0
for i in range(n):
y = int(a[i] / s * k)
x[i] = [i, a[i], y, a[i] / (y + 1)]
t += y
x.sort(key=lambda val: val[3], reverse=True)
for i in range(k - t):
x[i][2] += 1
ans = 0
for i in range(n):
ans ... | false | 5.882353 | [
"-y = 0",
"-r = 0",
"+t = 0",
"- x[i] = [i, y, a[i] / (y + 1), a[i]]",
"- r += y",
"-x.sort(key=lambda val: val[2], reverse=True)",
"-for i in range(k - r):",
"- x[i][1] += 1",
"+ x[i] = [i, a[i], y, a[i] / (y + 1)]",
"+ t += y",
"+x.sort(key=lambda val: val[3], reverse=True)",
... | false | 0.04954 | 0.105224 | 0.470808 | [
"s091219925",
"s791199889"
] |
u729133443 | p02733 | python | s717090225 | s755453915 | 1,038 | 383 | 51,672 | 44,124 | Accepted | Accepted | 63.1 | r=range
h,*s=open(0)
h,w,k,*m=list(map(int,h.split()))
for i in r(512):
t=[j+1for j in r(h)if i>>j&1]+[h];l=len(t);v=1;c=[0]*l
for i in r(w):
b=f=g=0;u=[]
for j in r(l):d,b=sum(s[j][i]>"0"for j in r(b,t[j])),t[j];u+=d,;g|=d>k;c[j]+=d;f|=c[j]>k
v-=f
if f:c=u
if g<1:m+=l-v,
print((min(m))) | x,*s=open(0)
h,w,k,*m=list(map(int,x.split()))
for b in range(512):
r=t=j=0;d=[0]*h
while w-j:
i=c=0
while h-i:
d[c]+=s[i][j]>'0';x=d[c]>k
if(t<j)&x:r+=1;t=j;d=[0]*h;break
r+=h*w*x;c+=b>>i&1;i+=1
else:j+=1
m+=r+bin(b).count('1'),
print((min(m))) | 12 | 13 | 302 | 267 | r = range
h, *s = open(0)
h, w, k, *m = list(map(int, h.split()))
for i in r(512):
t = [j + 1 for j in r(h) if i >> j & 1] + [h]
l = len(t)
v = 1
c = [0] * l
for i in r(w):
b = f = g = 0
u = []
for j in r(l):
d, b = sum(s[j][i] > "0" for j in r(b, t[j])), t[j]
... | x, *s = open(0)
h, w, k, *m = list(map(int, x.split()))
for b in range(512):
r = t = j = 0
d = [0] * h
while w - j:
i = c = 0
while h - i:
d[c] += s[i][j] > "0"
x = d[c] > k
if (t < j) & x:
r += 1
t = j
d = [... | false | 7.692308 | [
"-r = range",
"-h, *s = open(0)",
"-h, w, k, *m = list(map(int, h.split()))",
"-for i in r(512):",
"- t = [j + 1 for j in r(h) if i >> j & 1] + [h]",
"- l = len(t)",
"- v = 1",
"- c = [0] * l",
"- for i in r(w):",
"- b = f = g = 0",
"- u = []",
"- for j in r... | false | 0.060493 | 0.117842 | 0.513339 | [
"s717090225",
"s755453915"
] |
u952708174 | p02775 | python | s545720449 | s998305038 | 985 | 413 | 5,492 | 26,472 | Accepted | Accepted | 58.07 | def e_payment():
N = eval(input())
dp = (0, 1) # 「最下位桁の 1 つ下の桁」を仮想した場合分けを省くための初期化
for k, ch in enumerate(N[::-1]): # 最下位の桁から見る
n = int(ch)
t1, t2 = dp
a = min(t1 + n, t2 + n + 1)
b = min(t1 + (10 - n), t2 + (10 - (n + 1)))
dp = (a, b)
return min(dp[0]... | def e_payment_greedy():
N = [int(i) for i in list(eval(input()))]
s = N[::-1] + [0] # [-d-1]: 最終的に 10**d 円札を何枚受渡ししたかが格納される
for i in range(len(N)):
if s[i] >= 6 or (s[i] == 5 and s[i + 1] >= 5):
s[i] = 10 - s[i]
s[i + 1] += 1
return sum(s)
print((e_payment_gre... | 13 | 11 | 348 | 319 | def e_payment():
N = eval(input())
dp = (0, 1) # 「最下位桁の 1 つ下の桁」を仮想した場合分けを省くための初期化
for k, ch in enumerate(N[::-1]): # 最下位の桁から見る
n = int(ch)
t1, t2 = dp
a = min(t1 + n, t2 + n + 1)
b = min(t1 + (10 - n), t2 + (10 - (n + 1)))
dp = (a, b)
return min(dp[0], dp[1] + 1... | def e_payment_greedy():
N = [int(i) for i in list(eval(input()))]
s = N[::-1] + [0] # [-d-1]: 最終的に 10**d 円札を何枚受渡ししたかが格納される
for i in range(len(N)):
if s[i] >= 6 or (s[i] == 5 and s[i + 1] >= 5):
s[i] = 10 - s[i]
s[i + 1] += 1
return sum(s)
print((e_payment_greedy()))
| false | 15.384615 | [
"-def e_payment():",
"- N = eval(input())",
"- dp = (0, 1) # 「最下位桁の 1 つ下の桁」を仮想した場合分けを省くための初期化",
"- for k, ch in enumerate(N[::-1]): # 最下位の桁から見る",
"- n = int(ch)",
"- t1, t2 = dp",
"- a = min(t1 + n, t2 + n + 1)",
"- b = min(t1 + (10 - n), t2 + (10 - (n + 1)))",
... | false | 0.143758 | 0.137017 | 1.049203 | [
"s545720449",
"s998305038"
] |
u562935282 | p03045 | python | s110687641 | s581730991 | 1,537 | 731 | 121,476 | 7,940 | Accepted | Accepted | 52.44 | class UnionFind:
def __init__(self, n):
self.v = [-1 for _ in range(n)] # 根(負): 連結頂点数 * (-1) / 子(正): 根の頂点番号(0-indexed)
def find(self, x): # xを含む木における根の頂点番号を返す
if self.v[x] < 0: # (負)は根
return x
else: # 根の頂点番号
self.v[x] = self.find(self.v[x]) # uniteで... | class UnionFind:
def __init__(self, n):
self.v = [-1 for _ in range(n)]
def find(self, x):
if self.v[x] < 0:
return x
else:
self.v[x] = self.find(self.v[x])
return self.v[x]
def unite(self, x, y):
x = self.find(x)
y =... | 51 | 45 | 1,411 | 1,018 | class UnionFind:
def __init__(self, n):
self.v = [-1 for _ in range(n)] # 根(負): 連結頂点数 * (-1) / 子(正): 根の頂点番号(0-indexed)
def find(self, x): # xを含む木における根の頂点番号を返す
if self.v[x] < 0: # (負)は根
return x
else: # 根の頂点番号
self.v[x] = self.find(self.v[x]) # uniteでは, 旧根に属す... | class UnionFind:
def __init__(self, n):
self.v = [-1 for _ in range(n)]
def find(self, x):
if self.v[x] < 0:
return x
else:
self.v[x] = self.find(self.v[x])
return self.v[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)... | false | 11.764706 | [
"- self.v = [-1 for _ in range(n)] # 根(負): 連結頂点数 * (-1) / 子(正): 根の頂点番号(0-indexed)",
"+ self.v = [-1 for _ in range(n)]",
"- def find(self, x): # xを含む木における根の頂点番号を返す",
"- if self.v[x] < 0: # (負)は根",
"+ def find(self, x):",
"+ if self.v[x] < 0:",
"- else: # 根の頂点... | false | 0.049355 | 0.112835 | 0.437408 | [
"s110687641",
"s581730991"
] |
u948524308 | p03379 | python | s809451296 | s573293575 | 575 | 306 | 42,660 | 25,620 | Accepted | Accepted | 46.78 | import collections
N=int(eval(input()))
X=list(map(int,input().split()))
B_dict=collections.Counter(X)
B=sorted(B_dict.items())
cnt=0
for i in range(len(B)):
cnt+=B[i][1]
if cnt==N//2:
ans1=B[i][0]
ans2=B[i+1][0]
break
elif cnt>=N//2+1:
ans1=B[i][0]
... | N=int(eval(input()))
X=list(map(int,input().split()))
Xsorted=sorted(X)
ans1=Xsorted[(N-1)//2]
ans2=Xsorted[(N-1)//2+1]
for i in range(N):
if X[i]<=ans1:
print(ans2)
else:
print(ans1)
| 28 | 14 | 445 | 219 | import collections
N = int(eval(input()))
X = list(map(int, input().split()))
B_dict = collections.Counter(X)
B = sorted(B_dict.items())
cnt = 0
for i in range(len(B)):
cnt += B[i][1]
if cnt == N // 2:
ans1 = B[i][0]
ans2 = B[i + 1][0]
break
elif cnt >= N // 2 + 1:
ans1 = B[... | N = int(eval(input()))
X = list(map(int, input().split()))
Xsorted = sorted(X)
ans1 = Xsorted[(N - 1) // 2]
ans2 = Xsorted[(N - 1) // 2 + 1]
for i in range(N):
if X[i] <= ans1:
print(ans2)
else:
print(ans1)
| false | 50 | [
"-import collections",
"-",
"-B_dict = collections.Counter(X)",
"-B = sorted(B_dict.items())",
"-cnt = 0",
"-for i in range(len(B)):",
"- cnt += B[i][1]",
"- if cnt == N // 2:",
"- ans1 = B[i][0]",
"- ans2 = B[i + 1][0]",
"- break",
"- elif cnt >= N // 2 + 1:",
... | false | 0.04114 | 0.038441 | 1.070197 | [
"s809451296",
"s573293575"
] |
u761320129 | p02844 | python | s761078373 | s972211183 | 1,726 | 1,104 | 5,572 | 5,824 | Accepted | Accepted | 36.04 | N = int(eval(input()))
S = eval(input())
lset = [0]
for c in S:
lset.append(lset[-1] | (1<<int(c)))
rset = [0]
for c in S[::-1]:
rset.append(rset[-1] | (1<<int(c)))
rset.reverse()
ptns = [set() for i in range(10)]
for i,c in enumerate(S):
for j in range(10):
if lset[i] & (1<<j) == ... | N = int(eval(input()))
S = eval(input())
lc = [0]
for c in S:
lc.append(lc[-1] | (1<<int(c)))
rc = [0]
for c in S[::-1]:
rc.append(rc[-1] | (1<<int(c)))
rc.reverse()
mem = [set() for _ in range(10)]
for c,l,r in zip(S,lc,rc[1:]):
c = int(c)
for i in range(10):
if l&(1<<i)==0: co... | 21 | 20 | 474 | 446 | N = int(eval(input()))
S = eval(input())
lset = [0]
for c in S:
lset.append(lset[-1] | (1 << int(c)))
rset = [0]
for c in S[::-1]:
rset.append(rset[-1] | (1 << int(c)))
rset.reverse()
ptns = [set() for i in range(10)]
for i, c in enumerate(S):
for j in range(10):
if lset[i] & (1 << j) == 0:
... | N = int(eval(input()))
S = eval(input())
lc = [0]
for c in S:
lc.append(lc[-1] | (1 << int(c)))
rc = [0]
for c in S[::-1]:
rc.append(rc[-1] | (1 << int(c)))
rc.reverse()
mem = [set() for _ in range(10)]
for c, l, r in zip(S, lc, rc[1:]):
c = int(c)
for i in range(10):
if l & (1 << i) == 0:
... | false | 4.761905 | [
"-lset = [0]",
"+lc = [0]",
"- lset.append(lset[-1] | (1 << int(c)))",
"-rset = [0]",
"+ lc.append(lc[-1] | (1 << int(c)))",
"+rc = [0]",
"- rset.append(rset[-1] | (1 << int(c)))",
"-rset.reverse()",
"-ptns = [set() for i in range(10)]",
"-for i, c in enumerate(S):",
"- for j in rang... | false | 0.040974 | 0.040864 | 1.002697 | [
"s761078373",
"s972211183"
] |
u763881112 | p03416 | python | s549940321 | s105128598 | 219 | 189 | 12,388 | 12,504 | Accepted | Accepted | 13.7 |
import numpy as np
a,b=list(map(int,input().split()))
ans=0
def check(x):
s=str(x)
for i in range(len(s)):
if(s[i]!=s[len(s)-1-i]):return False
return True
for i in range(a,b+1):
if(check(i)):ans+=1
print(ans) |
import numpy as np
a,b=list(map(int,input().split()))
ans=0
def check(x):
s=str(x)
return s==s[::-1]
for i in range(a,b+1):
if(check(i)):ans+=1
print(ans) | 16 | 14 | 247 | 178 | import numpy as np
a, b = list(map(int, input().split()))
ans = 0
def check(x):
s = str(x)
for i in range(len(s)):
if s[i] != s[len(s) - 1 - i]:
return False
return True
for i in range(a, b + 1):
if check(i):
ans += 1
print(ans)
| import numpy as np
a, b = list(map(int, input().split()))
ans = 0
def check(x):
s = str(x)
return s == s[::-1]
for i in range(a, b + 1):
if check(i):
ans += 1
print(ans)
| false | 12.5 | [
"- for i in range(len(s)):",
"- if s[i] != s[len(s) - 1 - i]:",
"- return False",
"- return True",
"+ return s == s[::-1]"
] | false | 0.106968 | 0.116749 | 0.916221 | [
"s549940321",
"s105128598"
] |
u535171899 | p02959 | python | s929763376 | s026984341 | 241 | 185 | 19,156 | 18,624 | Accepted | Accepted | 23.24 | n = int(eval(input()))
a_li = [int(i) for i in input().split()]
b_li = [int(i) for i in input().split()]
if b_li[0]<b_li[-1]:
a_li = a_li[::-1]
b_li = b_li[::-1]
ans = 0
for i in range(0,n):
attack = min(a_li[i],b_li[i])
attack2 = min(a_li[i+1],b_li[i]-min(a_li[i],b_li[i]))
a_li[i]-=at... | n = int(eval(input()))
a_input = list(map(int,input().split()))
b_input = list(map(int,input().split()))
ans=0
for i in range(n):
first_attack=0
second_attack=0
first_attack = min(b_input[i],a_input[i])
a_input[i]-=first_attack
if first_attack<b_input[i]:
second_attack = min(a_... | 19 | 17 | 417 | 439 | n = int(eval(input()))
a_li = [int(i) for i in input().split()]
b_li = [int(i) for i in input().split()]
if b_li[0] < b_li[-1]:
a_li = a_li[::-1]
b_li = b_li[::-1]
ans = 0
for i in range(0, n):
attack = min(a_li[i], b_li[i])
attack2 = min(a_li[i + 1], b_li[i] - min(a_li[i], b_li[i]))
a_li[i] -= atta... | n = int(eval(input()))
a_input = list(map(int, input().split()))
b_input = list(map(int, input().split()))
ans = 0
for i in range(n):
first_attack = 0
second_attack = 0
first_attack = min(b_input[i], a_input[i])
a_input[i] -= first_attack
if first_attack < b_input[i]:
second_attack = min(a_i... | false | 10.526316 | [
"-a_li = [int(i) for i in input().split()]",
"-b_li = [int(i) for i in input().split()]",
"-if b_li[0] < b_li[-1]:",
"- a_li = a_li[::-1]",
"- b_li = b_li[::-1]",
"+a_input = list(map(int, input().split()))",
"+b_input = list(map(int, input().split()))",
"-for i in range(0, n):",
"- attack ... | false | 0.034519 | 0.091271 | 0.378199 | [
"s929763376",
"s026984341"
] |
u905582793 | p03231 | python | s005371668 | s841141506 | 39 | 36 | 5,432 | 5,432 | Accepted | Accepted | 7.69 | from fractions import gcd
n,m = list(map(int,input().split()))
s = eval(input())
t = eval(input())
x = gcd(n,m)
for i in range(x):
if s[i*n//x]!=t[i*m//x]:
print((-1))
break
else:
print((n*m//x)) | from fractions import gcd
n,m = list(map(int,input().split()))
s = eval(input())
t = eval(input())
x = gcd(n,m)
if s[::n//x]==t[::m//x]:
print((n*m//x))
else:
print((-1)) | 11 | 9 | 195 | 160 | from fractions import gcd
n, m = list(map(int, input().split()))
s = eval(input())
t = eval(input())
x = gcd(n, m)
for i in range(x):
if s[i * n // x] != t[i * m // x]:
print((-1))
break
else:
print((n * m // x))
| from fractions import gcd
n, m = list(map(int, input().split()))
s = eval(input())
t = eval(input())
x = gcd(n, m)
if s[:: n // x] == t[:: m // x]:
print((n * m // x))
else:
print((-1))
| false | 18.181818 | [
"-for i in range(x):",
"- if s[i * n // x] != t[i * m // x]:",
"- print((-1))",
"- break",
"+if s[:: n // x] == t[:: m // x]:",
"+ print((n * m // x))",
"- print((n * m // x))",
"+ print((-1))"
] | false | 0.042528 | 0.043443 | 0.97895 | [
"s005371668",
"s841141506"
] |
u609061751 | p03524 | python | s155473217 | s084825790 | 186 | 26 | 39,408 | 3,444 | Accepted | Accepted | 86.02 | import sys
input = sys.stdin.readline
s = input().rstrip()
from collections import Counter
c = Counter(s)
if len(s) == 1:
print("YES")
sys.exit()
if len(list(c.keys())) == 1:
print("NO")
sys.exit()
values = list(c.values())
values.sort()
if len(list(c.keys())) == 2:
if va... | import sys
input = lambda : sys.stdin.readline().rstrip()
mod = 10**9 + 7
s = eval(input())
from collections import Counter
c = Counter(s)
A = c["a"]
B = c["b"]
C = c["c"]
if len(list(c.keys())) == 1:
if len(s) > 1:
print("NO")
else:
print("YES")
sys.exit()
if len(... | 42 | 36 | 736 | 561 | import sys
input = sys.stdin.readline
s = input().rstrip()
from collections import Counter
c = Counter(s)
if len(s) == 1:
print("YES")
sys.exit()
if len(list(c.keys())) == 1:
print("NO")
sys.exit()
values = list(c.values())
values.sort()
if len(list(c.keys())) == 2:
if values[0] == 1 and values[1]... | import sys
input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7
s = eval(input())
from collections import Counter
c = Counter(s)
A = c["a"]
B = c["b"]
C = c["c"]
if len(list(c.keys())) == 1:
if len(s) > 1:
print("NO")
else:
print("YES")
sys.exit()
if len(list(c.keys())) == 2:
... | false | 14.285714 | [
"-input = sys.stdin.readline",
"-s = input().rstrip()",
"+input = lambda: sys.stdin.readline().rstrip()",
"+mod = 10**9 + 7",
"+s = eval(input())",
"-if len(s) == 1:",
"- print(\"YES\")",
"+A = c[\"a\"]",
"+B = c[\"b\"]",
"+C = c[\"c\"]",
"+if len(list(c.keys())) == 1:",
"+ if len(s) > 1... | false | 0.007708 | 0.038586 | 0.199754 | [
"s155473217",
"s084825790"
] |
u546285759 | p00100 | python | s520730711 | s205314062 | 60 | 30 | 7,764 | 7,916 | Accepted | Accepted | 50 | while True:
n = int(eval(input()))
if n == 0: break
d = dict()
order = []
for _ in range(n):
i, p, q = list(map(int, input().split()))
d[i] = d[i]+p*q if i in d else p*q
if i not in order: order.append(i)
b = True
for o in order:
if d[o] > 999999:
... | while True:
n = int(eval(input()))
if n == 0:
break
d = dict()
sep = []
for _ in range(n):
i, p, q = list(map(int, input().split()))
if i in d:
d[i] += p*q
else:
d[i] = p*q
sep.append(i)
tmp = list([x for x in list(... | 15 | 21 | 374 | 502 | while True:
n = int(eval(input()))
if n == 0:
break
d = dict()
order = []
for _ in range(n):
i, p, q = list(map(int, input().split()))
d[i] = d[i] + p * q if i in d else p * q
if i not in order:
order.append(i)
b = True
for o in order:
if d... | while True:
n = int(eval(input()))
if n == 0:
break
d = dict()
sep = []
for _ in range(n):
i, p, q = list(map(int, input().split()))
if i in d:
d[i] += p * q
else:
d[i] = p * q
sep.append(i)
tmp = list([x for x in list(d.items()... | false | 28.571429 | [
"- order = []",
"+ sep = []",
"- d[i] = d[i] + p * q if i in d else p * q",
"- if i not in order:",
"- order.append(i)",
"- b = True",
"- for o in order:",
"- if d[o] > 999999:",
"- print(o)",
"- b = False",
"- if b:",
"+ ... | false | 0.044871 | 0.045336 | 0.989758 | [
"s520730711",
"s205314062"
] |
u021019433 | p02996 | python | s287658912 | s374132524 | 992 | 796 | 45,980 | 31,972 | Accepted | Accepted | 19.76 | from operator import itemgetter
from itertools import accumulate
n = int(eval(input()))
a = sorted((tuple(map(int, input().split())) for _ in range(n)),
key=itemgetter(1))
c, d = list(zip(*a))
print(('YNeos'[any(x > y for x, y in zip(accumulate(c), d))::2])) | from operator import itemgetter
from itertools import accumulate
n = int(eval(input()))
a = sorted((tuple(map(int, input().split())) for _ in range(n)),
key=itemgetter(1))
c, d = (list(map(itemgetter(i), a)) for i in (0, 1))
print(('YNeos'[any(x > y for x, y in zip(accumulate(c), d))::2]))
| 8 | 8 | 264 | 297 | from operator import itemgetter
from itertools import accumulate
n = int(eval(input()))
a = sorted((tuple(map(int, input().split())) for _ in range(n)), key=itemgetter(1))
c, d = list(zip(*a))
print(("YNeos"[any(x > y for x, y in zip(accumulate(c), d)) :: 2]))
| from operator import itemgetter
from itertools import accumulate
n = int(eval(input()))
a = sorted((tuple(map(int, input().split())) for _ in range(n)), key=itemgetter(1))
c, d = (list(map(itemgetter(i), a)) for i in (0, 1))
print(("YNeos"[any(x > y for x, y in zip(accumulate(c), d)) :: 2]))
| false | 0 | [
"-c, d = list(zip(*a))",
"+c, d = (list(map(itemgetter(i), a)) for i in (0, 1))"
] | false | 0.103989 | 0.039864 | 2.608639 | [
"s287658912",
"s374132524"
] |
u798803522 | p00189 | python | s098899166 | s540601375 | 60 | 30 | 8,044 | 7,684 | Accepted | Accepted | 50 | from collections import defaultdict
road = int(eval(input()))
while road > 0:
connect = defaultdict(list)
# weight = defaultdict(defaultdict(float("inf")))
answer = [[float("inf") if n != m else 0 for n in range(10)] for m in range(10)]
for _ in range(road):
c1, c2, w = (int(n) for n in i... | road = int(eval(input()))
while road > 0:
answer = [[float("inf") if n != m else 0 for n in range(10)] for m in range(10)]
city = 0
for _ in range(road):
c1, c2, w = (int(n) for n in input().split(" "))
answer[c1][c2] = w
answer[c2][c1] = w
city = max(city, c1, c2)
... | 23 | 20 | 866 | 704 | from collections import defaultdict
road = int(eval(input()))
while road > 0:
connect = defaultdict(list)
# weight = defaultdict(defaultdict(float("inf")))
answer = [[float("inf") if n != m else 0 for n in range(10)] for m in range(10)]
for _ in range(road):
c1, c2, w = (int(n) for n in input()... | road = int(eval(input()))
while road > 0:
answer = [[float("inf") if n != m else 0 for n in range(10)] for m in range(10)]
city = 0
for _ in range(road):
c1, c2, w = (int(n) for n in input().split(" "))
answer[c1][c2] = w
answer[c2][c1] = w
city = max(city, c1, c2)
city +... | false | 13.043478 | [
"-from collections import defaultdict",
"-",
"- connect = defaultdict(list)",
"- # weight = defaultdict(defaultdict(float(\"inf\")))",
"+ city = 0",
"- connect[c1].append(c2)",
"- connect[c2].append(c1)",
"- city = max(connect.keys()) + 1",
"+ city = max(city, c1, c2... | false | 0.122839 | 0.048587 | 2.528246 | [
"s098899166",
"s540601375"
] |
u961683878 | p03752 | python | s368981158 | s195726289 | 213 | 189 | 12,500 | 12,508 | Accepted | Accepted | 11.27 | import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
N, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
ans = pow(10, 11)
for bit in r... | import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
N, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
ans = pow(10, 11)
for bit in r... | 26 | 31 | 632 | 721 | import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
N, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
ans = pow(10, 11)
for bit in range(1 << (N)):... | import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
N, K = list(map(int, readline().split()))
A = list(map(int, readline().split()))
ans = pow(10, 11)
for bit in range(1 << (N)):... | false | 16.129032 | [
"- pre = 0",
"- for i in range(N):",
"+ pre = A[0] - 1",
"+ for i, a in enumerate(A[:]):",
"- if A[i] <= pre:",
"- acc += max(0, pre + 1 - A[i])",
"- pre += 1",
"- pre = max(pre, A[i])",
"+ if pre < a:",
"+ pre =... | false | 0.10093 | 0.047862 | 2.108758 | [
"s368981158",
"s195726289"
] |
u619144316 | p03048 | python | s750422338 | s137199930 | 1,335 | 509 | 2,940 | 9,176 | Accepted | Accepted | 61.87 | R,G,B,N = list(map(int,input().split()))
cnt = 0
for i in range(N//R+1):
M = N-R*i
for j in range(M//G+1):
L = M-G*j
if L % B == 0:
cnt += 1
print(cnt) | def main():
r,g,b,n = list(map(int,input().split()))
c = 0
for i in range(n//r+1):
m = n - r * i
for j in range(m//g+1):
l = m - g * j
if l % b == 0:
c += 1
print(c)
main() | 10 | 13 | 191 | 264 | R, G, B, N = list(map(int, input().split()))
cnt = 0
for i in range(N // R + 1):
M = N - R * i
for j in range(M // G + 1):
L = M - G * j
if L % B == 0:
cnt += 1
print(cnt)
| def main():
r, g, b, n = list(map(int, input().split()))
c = 0
for i in range(n // r + 1):
m = n - r * i
for j in range(m // g + 1):
l = m - g * j
if l % b == 0:
c += 1
print(c)
main()
| false | 23.076923 | [
"-R, G, B, N = list(map(int, input().split()))",
"-cnt = 0",
"-for i in range(N // R + 1):",
"- M = N - R * i",
"- for j in range(M // G + 1):",
"- L = M - G * j",
"- if L % B == 0:",
"- cnt += 1",
"-print(cnt)",
"+def main():",
"+ r, g, b, n = list(map(int, inp... | false | 0.047439 | 0.051359 | 0.923671 | [
"s750422338",
"s137199930"
] |
u377989038 | p02912 | python | s294971490 | s600439522 | 756 | 160 | 14,380 | 14,380 | Accepted | Accepted | 78.84 | import heapq
import sys
input = sys.stdin.readline
def _heappush_max(heap, item):
heap.append(item)
heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
"""Maxheap version of a heappop."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:... | import heapq
import math
import sys
input = sys.stdin.readline
def main():
n, m = list(map(int, input().split()))
if n == 1:
a = int(eval(input()))
for i in range(m):
a //= 2
print(a)
exit()
a = (list(map(int, input().split())))
a = [-1 * ... | 43 | 28 | 873 | 514 | import heapq
import sys
input = sys.stdin.readline
def _heappush_max(heap, item):
heap.append(item)
heapq._siftdown_max(heap, 0, len(heap) - 1)
def _heappop_max(heap):
"""Maxheap version of a heappop."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
ret... | import heapq
import math
import sys
input = sys.stdin.readline
def main():
n, m = list(map(int, input().split()))
if n == 1:
a = int(eval(input()))
for i in range(m):
a //= 2
print(a)
exit()
a = list(map(int, input().split()))
a = [-1 * i for i in a]
he... | false | 34.883721 | [
"+import math",
"-",
"-",
"-def _heappush_max(heap, item):",
"- heap.append(item)",
"- heapq._siftdown_max(heap, 0, len(heap) - 1)",
"-",
"-",
"-def _heappop_max(heap):",
"- \"\"\"Maxheap version of a heappop.\"\"\"",
"- lastelt = heap.pop() # raises appropriate IndexError if heap i... | false | 0.037922 | 0.03897 | 0.97309 | [
"s294971490",
"s600439522"
] |
u785205215 | p03553 | python | s263310654 | s172789501 | 36 | 24 | 4,336 | 3,444 | Accepted | Accepted | 33.33 | class Dinic:
def __init__(self, v, inf=float("inf")):
self.V = v
self.inf = inf
self.G = [[] for _ in range(v)]
self.level = [0 for _ in range(v)]
self.iter = [0 for _ in range(v)]
def addEdge(self, fm, to, cap):
'''
to:行き先
cap:容量
rev:反対側の辺
'''
self.G[fm].append({'to':to, 'cap':... | class Ford_Fulkerson:
def __init__(self, v, inf=float("inf")):
self.V = v
self.inf = inf
self.G = [[] for _ in range(v)]
self.used = [False for _ in range(v)]
def addEdge(self, fm, to, cap):
'''
to:行き先
cap:容量
rev:反対側の辺
'''
self.G[fm].append({'to':to, 'cap':cap, 'rev':len(self.G[to]... | 85 | 64 | 1,894 | 1,400 | class Dinic:
def __init__(self, v, inf=float("inf")):
self.V = v
self.inf = inf
self.G = [[] for _ in range(v)]
self.level = [0 for _ in range(v)]
self.iter = [0 for _ in range(v)]
def addEdge(self, fm, to, cap):
"""
to:行き先
cap:容量
rev:反対側の... | class Ford_Fulkerson:
def __init__(self, v, inf=float("inf")):
self.V = v
self.inf = inf
self.G = [[] for _ in range(v)]
self.used = [False for _ in range(v)]
def addEdge(self, fm, to, cap):
"""
to:行き先
cap:容量
rev:反対側の辺
"""
self.G[f... | false | 24.705882 | [
"-class Dinic:",
"+class Ford_Fulkerson:",
"- self.level = [0 for _ in range(v)]",
"- self.iter = [0 for _ in range(v)]",
"+ self.used = [False for _ in range(v)]",
"- # sからの最短距離をbfsで計算",
"- def bfs(self, s):",
"- import queue",
"-",
"- self.level = [-1 for... | false | 0.075691 | 0.060337 | 1.254486 | [
"s263310654",
"s172789501"
] |
u119148115 | p03835 | python | s248201557 | s817276977 | 254 | 122 | 41,068 | 66,988 | Accepted | Accepted | 51.97 | import sys
def S(): return sys.stdin.readline().rstrip()
K,S = list(map(int,S().split()))
ans = 0
for i in range(K+1):
for j in range(K+1):
if 0 <= S-i-j <= K:
ans += 1
print(ans) | import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def ... | 13 | 21 | 213 | 629 | import sys
def S():
return sys.stdin.readline().rstrip()
K, S = list(map(int, S().split()))
ans = 0
for i in range(K + 1):
for j in range(K + 1):
if 0 <= S - i - j <= K:
ans += 1
print(ans)
| import sys
sys.setrecursionlimit(10**7)
def I():
return int(sys.stdin.readline().rstrip())
def MI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def LI():
return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり
def LI2():
return list(map(int, sys.stdin.readline().r... | false | 38.095238 | [
"+",
"+sys.setrecursionlimit(10**7)",
"+",
"+",
"+def I():",
"+ return int(sys.stdin.readline().rstrip())",
"+",
"+",
"+def MI():",
"+ return list(map(int, sys.stdin.readline().rstrip().split()))",
"+",
"+",
"+def LI():",
"+ return list(map(int, sys.stdin.readline().rstrip().split... | false | 0.061658 | 0.07355 | 0.838316 | [
"s248201557",
"s817276977"
] |
u476124554 | p03106 | python | s231760647 | s725083388 | 27 | 17 | 3,952 | 3,060 | Accepted | Accepted | 37.04 | import queue
a,b,c = list(map(int,input().split()))
q = queue.LifoQueue()
for i in range(1,101):
if(a%i == 0 and b%i == 0):
q.put(i)
for i in range(c-1):
q.get()
print((q.get())) | a,b,k = list(map(int,input().split()))
ans = []
for i in range(1,101):
if a % i == 0 and b % i == 0:
ans.append(i)
ans = sorted(ans,reverse = True)
print((ans[k-1])) | 9 | 7 | 186 | 175 | import queue
a, b, c = list(map(int, input().split()))
q = queue.LifoQueue()
for i in range(1, 101):
if a % i == 0 and b % i == 0:
q.put(i)
for i in range(c - 1):
q.get()
print((q.get()))
| a, b, k = list(map(int, input().split()))
ans = []
for i in range(1, 101):
if a % i == 0 and b % i == 0:
ans.append(i)
ans = sorted(ans, reverse=True)
print((ans[k - 1]))
| false | 22.222222 | [
"-import queue",
"-",
"-a, b, c = list(map(int, input().split()))",
"-q = queue.LifoQueue()",
"+a, b, k = list(map(int, input().split()))",
"+ans = []",
"- q.put(i)",
"-for i in range(c - 1):",
"- q.get()",
"-print((q.get()))",
"+ ans.append(i)",
"+ans = sorted(ans, reverse=Tr... | false | 0.038631 | 0.034056 | 1.134347 | [
"s231760647",
"s725083388"
] |
u332906195 | p02783 | python | s671820285 | s269381630 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | H, A = list(map(int, input().split()))
print(((H + A - 1) // A))
| H, A = list(map(int, input().split()))
print(((H - 1) // A + 1))
| 2 | 2 | 58 | 58 | H, A = list(map(int, input().split()))
print(((H + A - 1) // A))
| H, A = list(map(int, input().split()))
print(((H - 1) // A + 1))
| false | 0 | [
"-print(((H + A - 1) // A))",
"+print(((H - 1) // A + 1))"
] | false | 0.147118 | 0.134577 | 1.093188 | [
"s671820285",
"s269381630"
] |
u855710796 | p03045 | python | s765847236 | s504246428 | 609 | 351 | 109,620 | 27,948 | Accepted | Accepted | 42.36 | import sys
sys.setrecursionlimit(10**5+1)
N, M = list(map(int, input().split()))
edge = [[] for i in range(N)]
for i in range(M):
x, y, _ = list(map(int, input().split()))
edge[x-1].append(y-1)
edge[y-1].append(x-1)
visited = [False] * N
ans = 0
def dfs(x):
global ans
if not visi... | from collections import deque
N, M = list(map(int, input().split()))
edge = [[] for i in range(N)]
for i in range(M):
x, y, _ = list(map(int, input().split()))
edge[x-1].append(y-1)
edge[y-1].append(x-1)
visited = [False] * N
ans = 0
for i in range(N):
if visited[i]:
continue
... | 30 | 31 | 538 | 591 | import sys
sys.setrecursionlimit(10**5 + 1)
N, M = list(map(int, input().split()))
edge = [[] for i in range(N)]
for i in range(M):
x, y, _ = list(map(int, input().split()))
edge[x - 1].append(y - 1)
edge[y - 1].append(x - 1)
visited = [False] * N
ans = 0
def dfs(x):
global ans
if not visited[x]:... | from collections import deque
N, M = list(map(int, input().split()))
edge = [[] for i in range(N)]
for i in range(M):
x, y, _ = list(map(int, input().split()))
edge[x - 1].append(y - 1)
edge[y - 1].append(x - 1)
visited = [False] * N
ans = 0
for i in range(N):
if visited[i]:
continue
else:
... | false | 3.225806 | [
"-import sys",
"+from collections import deque",
"-sys.setrecursionlimit(10**5 + 1)",
"-",
"-",
"-def dfs(x):",
"- global ans",
"- if not visited[x]:",
"+for i in range(N):",
"+ if visited[i]:",
"+ continue",
"+ else:",
"- visited[x] = True",
"- for x_next in edge[... | false | 0.18045 | 0.049226 | 3.665707 | [
"s765847236",
"s504246428"
] |
u215461917 | p03731 | python | s289569963 | s672147872 | 139 | 85 | 25,200 | 25,200 | Accepted | Accepted | 38.85 | n,t = (int(i) for i in input().split())
ni = [int(i) for i in input().split()]
total = 0
for i in range(1,len(ni)) :
delta = ni[i] - ni[i-1]
if delta < t :
total += delta
else :
total += t
print((total+t)) | def main():
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
s, e = 0, 0
ans = 0
for i in range(N):
if t[i] <= e:
e = t[i] + T
else:
ans += e - s
s = t[i]
e = t[i] + T
ans += e - s
print(an... | 14 | 17 | 238 | 329 | n, t = (int(i) for i in input().split())
ni = [int(i) for i in input().split()]
total = 0
for i in range(1, len(ni)):
delta = ni[i] - ni[i - 1]
if delta < t:
total += delta
else:
total += t
print((total + t))
| def main():
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
s, e = 0, 0
ans = 0
for i in range(N):
if t[i] <= e:
e = t[i] + T
else:
ans += e - s
s = t[i]
e = t[i] + T
ans += e - s
print(ans)
main()
| false | 17.647059 | [
"-n, t = (int(i) for i in input().split())",
"-ni = [int(i) for i in input().split()]",
"-total = 0",
"-for i in range(1, len(ni)):",
"- delta = ni[i] - ni[i - 1]",
"- if delta < t:",
"- total += delta",
"- else:",
"- total += t",
"-print((total + t))",
"+def main():",
"... | false | 0.039794 | 0.039938 | 0.99639 | [
"s289569963",
"s672147872"
] |
u033606236 | p03274 | python | s607337650 | s875965129 | 158 | 122 | 14,564 | 14,568 | Accepted | Accepted | 22.78 | N, K = list(map(int, input().split()))
ary = [0] + list(map(int, input().split()))
ary.sort()
zero = ary.index(0)
a = [abs(i - zero) for i in range(N + 1)]
ary.pop(zero)
ans = float("Inf")
for i in range(N - K + 1):
b = N - i - 1
d = abs(ary[i])
if a[i] >= K:
ans = min(ans, d)
ans = ... | N, K = list(map(int, input().split()))
ary = list(map(int, input().split()))
ary2 = sorted(ary+[0])
zero = ary2.index(0)
k = [abs(i - zero) if i < zero else ((i + 1) - zero)for i in range(N)]
ans = float("Inf")
for i in range(N - K + 1):
if k[i] <= K:
if ans > abs(ary[i]) + abs(ary[i] - ary[i + (K -... | 18 | 15 | 489 | 571 | N, K = list(map(int, input().split()))
ary = [0] + list(map(int, input().split()))
ary.sort()
zero = ary.index(0)
a = [abs(i - zero) for i in range(N + 1)]
ary.pop(zero)
ans = float("Inf")
for i in range(N - K + 1):
b = N - i - 1
d = abs(ary[i])
if a[i] >= K:
ans = min(ans, d)
ans = min(ans, d +... | N, K = list(map(int, input().split()))
ary = list(map(int, input().split()))
ary2 = sorted(ary + [0])
zero = ary2.index(0)
k = [abs(i - zero) if i < zero else ((i + 1) - zero) for i in range(N)]
ans = float("Inf")
for i in range(N - K + 1):
if k[i] <= K:
if ans > abs(ary[i]) + abs(ary[i] - ary[i + (K - 1)])... | false | 16.666667 | [
"-ary = [0] + list(map(int, input().split()))",
"-ary.sort()",
"-zero = ary.index(0)",
"-a = [abs(i - zero) for i in range(N + 1)]",
"-ary.pop(zero)",
"+ary = list(map(int, input().split()))",
"+ary2 = sorted(ary + [0])",
"+zero = ary2.index(0)",
"+k = [abs(i - zero) if i < zero else ((i + 1) - zero... | false | 0.119707 | 0.047557 | 2.517132 | [
"s607337650",
"s875965129"
] |
u852690916 | p03108 | python | s636935258 | s803690611 | 778 | 514 | 100,444 | 71,388 | Accepted | Accepted | 33.93 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
N,M=list(map(int, input().split()))
B=[tuple(map(int, input().split())) for _ in range(M)]
P=list(range(N+1))
C=[1 for _ in range(N+1)]
C[0] = 0
def root(x):
if P[x]==x: return x
P[x] = root(P[x])
return P[x]
def unite(a,... | import sys
def main():
input = sys.stdin.readline
N,M=list(map(int, input().split()))
AB=[tuple([int(x)-1 for x in input().split()]) for _ in range(M)]
uf = UnionFindTree(N)
mx = N*(N-1)//2
ans = [mx]*M
for i in range(M-1,0,-1):
a,b = AB[i]
ans[i-1] = ans[i] - (0 ... | 43 | 37 | 796 | 976 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
N, M = list(map(int, input().split()))
B = [tuple(map(int, input().split())) for _ in range(M)]
P = list(range(N + 1))
C = [1 for _ in range(N + 1)]
C[0] = 0
def root(x):
if P[x] == x:
return x
P[x] = root(P[x])
return P[x]
def ... | import sys
def main():
input = sys.stdin.readline
N, M = list(map(int, input().split()))
AB = [tuple([int(x) - 1 for x in input().split()]) for _ in range(M)]
uf = UnionFindTree(N)
mx = N * (N - 1) // 2
ans = [mx] * M
for i in range(M - 1, 0, -1):
a, b = AB[i]
ans[i - 1] = ... | false | 13.953488 | [
"-input = sys.stdin.readline",
"-sys.setrecursionlimit(10**6)",
"-N, M = list(map(int, input().split()))",
"-B = [tuple(map(int, input().split())) for _ in range(M)]",
"-P = list(range(N + 1))",
"-C = [1 for _ in range(N + 1)]",
"-C[0] = 0",
"+",
"+def main():",
"+ input = sys.stdin.readline",
... | false | 0.036956 | 0.06084 | 0.607429 | [
"s636935258",
"s803690611"
] |
u056599756 | p03377 | python | s781347062 | s908700913 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | a,b,x=list(map(int, input().split()))
print(("YES" if a<=x and a+b>=x else "NO")) | a,b,x=list(map(int, input().split()))
print(("YES" if a<=x<=a+b else "NO")) | 3 | 3 | 76 | 70 | a, b, x = list(map(int, input().split()))
print(("YES" if a <= x and a + b >= x else "NO"))
| a, b, x = list(map(int, input().split()))
print(("YES" if a <= x <= a + b else "NO"))
| false | 0 | [
"-print((\"YES\" if a <= x and a + b >= x else \"NO\"))",
"+print((\"YES\" if a <= x <= a + b else \"NO\"))"
] | false | 0.041235 | 0.040565 | 1.016526 | [
"s781347062",
"s908700913"
] |
u562935282 | p02833 | python | s417787155 | s290461819 | 171 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.06 | def main():
N = int(eval(input()))
if N % 2 == 1:
return 0
ret = 0
for p in range(1, 30 + 1):
ret += N // (2 * pow(5, p))
return ret
if __name__ == '__main__':
print((main()))
| N = int(eval(input()))
if N % 2 == 1:
print((0))
else:
N //= 2
print((sum(N // pow(5, j) for j in range(1, 30))))
| 13 | 6 | 223 | 121 | def main():
N = int(eval(input()))
if N % 2 == 1:
return 0
ret = 0
for p in range(1, 30 + 1):
ret += N // (2 * pow(5, p))
return ret
if __name__ == "__main__":
print((main()))
| N = int(eval(input()))
if N % 2 == 1:
print((0))
else:
N //= 2
print((sum(N // pow(5, j) for j in range(1, 30))))
| false | 53.846154 | [
"-def main():",
"- N = int(eval(input()))",
"- if N % 2 == 1:",
"- return 0",
"- ret = 0",
"- for p in range(1, 30 + 1):",
"- ret += N // (2 * pow(5, p))",
"- return ret",
"-",
"-",
"-if __name__ == \"__main__\":",
"- print((main()))",
"+N = int(eval(input()))... | false | 0.042312 | 0.036592 | 1.156324 | [
"s417787155",
"s290461819"
] |
u259053514 | p02743 | python | s703033060 | s513041273 | 53 | 34 | 5,588 | 5,076 | Accepted | Accepted | 35.85 | from decimal import *
import math
getcontext().prec = 28
a, b, c = list(map(int, input().split()))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
a = Decimal.sqrt(a)
b = Decimal.sqrt(b)
c = Decimal.sqrt(c)
if a + b < c:
print("Yes")
else:
print("No")
| from decimal import *
import math
getcontext().prec = 50
a, b, c = list(map(int, input().split()))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
a = Decimal.sqrt(a)
b = Decimal.sqrt(b)
c = Decimal.sqrt(c)
if a + b < c:
print("Yes")
else:
print("No")
| 18 | 18 | 272 | 272 | from decimal import *
import math
getcontext().prec = 28
a, b, c = list(map(int, input().split()))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
a = Decimal.sqrt(a)
b = Decimal.sqrt(b)
c = Decimal.sqrt(c)
if a + b < c:
print("Yes")
else:
print("No")
| from decimal import *
import math
getcontext().prec = 50
a, b, c = list(map(int, input().split()))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
a = Decimal.sqrt(a)
b = Decimal.sqrt(b)
c = Decimal.sqrt(c)
if a + b < c:
print("Yes")
else:
print("No")
| false | 0 | [
"-getcontext().prec = 28",
"+getcontext().prec = 50"
] | false | 0.044494 | 0.038408 | 1.158465 | [
"s703033060",
"s513041273"
] |
u347640436 | p02793 | python | s798907016 | s282232199 | 277 | 252 | 49,604 | 49,568 | Accepted | Accepted | 9.03 | # エラトステネスの篩, フェルマーの小定理
def make_prime_table(n):
sieve = list(range(n + 1))
sieve[0] = -1
sieve[1] = -1
for i in range(2, int(n ** 0.5) + 1):
if sieve[i] != i:
continue
for j in range(i * i, n + 1, i):
if sieve[j] == j:
sieve[j] = i
r... | def make_prime_table(n):
sieve = list(range(n + 1))
sieve[0] = -1
sieve[1] = -1
for i in range(4, n + 1, 2):
sieve[i] = 2
for i in range(3, int(n ** 0.5) + 1, 2):
if sieve[i] != i:
continue
for j in range(i * i, n + 1, i * 2):
if sieve[j] == ... | 49 | 50 | 1,026 | 1,068 | # エラトステネスの篩, フェルマーの小定理
def make_prime_table(n):
sieve = list(range(n + 1))
sieve[0] = -1
sieve[1] = -1
for i in range(2, int(n**0.5) + 1):
if sieve[i] != i:
continue
for j in range(i * i, n + 1, i):
if sieve[j] == j:
sieve[j] = i
return sieve
... | def make_prime_table(n):
sieve = list(range(n + 1))
sieve[0] = -1
sieve[1] = -1
for i in range(4, n + 1, 2):
sieve[i] = 2
for i in range(3, int(n**0.5) + 1, 2):
if sieve[i] != i:
continue
for j in range(i * i, n + 1, i * 2):
if sieve[j] == j:
... | false | 2 | [
"-# エラトステネスの篩, フェルマーの小定理",
"- for i in range(2, int(n**0.5) + 1):",
"+ for i in range(4, n + 1, 2):",
"+ sieve[i] = 2",
"+ for i in range(3, int(n**0.5) + 1, 2):",
"- for j in range(i * i, n + 1, i):",
"+ for j in range(i * i, n + 1, i * 2):",
"- c = 0",
"+ ... | false | 0.723389 | 1.192445 | 0.606644 | [
"s798907016",
"s282232199"
] |
u867848444 | p03101 | python | s197729558 | s458947371 | 21 | 18 | 3,188 | 2,940 | Accepted | Accepted | 14.29 | H,W=list(map(int,input().split()))
h,w=list(map(int,input().split()))
lw=H*W-(h*W+H*w-h*w)
print(lw) | H,W=list(map(int,input().split()))
h,w=list(map(int,input().split()))
print(((H-h)*(W-w)))
| 4 | 4 | 91 | 81 | H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))
lw = H * W - (h * W + H * w - h * w)
print(lw)
| H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))
print(((H - h) * (W - w)))
| false | 0 | [
"-lw = H * W - (h * W + H * w - h * w)",
"-print(lw)",
"+print(((H - h) * (W - w)))"
] | false | 0.04797 | 0.043544 | 1.101657 | [
"s197729558",
"s458947371"
] |
u644907318 | p04044 | python | s620304410 | s924446334 | 74 | 63 | 62,884 | 62,376 | Accepted | Accepted | 14.86 | N,L = list(map(int,input().split()))
S = sorted([input().strip() for _ in range(N)])
x = ""
for i in range(N):
x += S[i]
print(x) | N,L = list(map(int,input().split()))
print(("".join(sorted([input().strip() for _ in range(N)])))) | 6 | 2 | 132 | 91 | N, L = list(map(int, input().split()))
S = sorted([input().strip() for _ in range(N)])
x = ""
for i in range(N):
x += S[i]
print(x)
| N, L = list(map(int, input().split()))
print(("".join(sorted([input().strip() for _ in range(N)]))))
| false | 66.666667 | [
"-S = sorted([input().strip() for _ in range(N)])",
"-x = \"\"",
"-for i in range(N):",
"- x += S[i]",
"-print(x)",
"+print((\"\".join(sorted([input().strip() for _ in range(N)]))))"
] | false | 0.040403 | 0.040258 | 1.003613 | [
"s620304410",
"s924446334"
] |
u375695365 | p02983 | python | s770517156 | s161315506 | 908 | 528 | 3,064 | 9,172 | Accepted | Accepted | 41.85 | a,b=list(map(int,input().split()))
ans=10000
for i in range(a,b):
for j in range(i+1,b+1):
if i>=2019:
i=i%2019
if j>=2019:
j=j%2019
if i==0 or j==0:
print("0")
exit()
else:
if ans>i*j%2019:
ans=... | l, r = list(map(int, input().split()))
n = r-l+1
ans1 = 0
ans2 = 0
min1 = 1000000000
min2 = 10000000000
for i in range(min(n, 2024)):
# print(l+i)
if (l+i) % 2019 == 0:
print((0))
break
else:
ans = 10000000000
for i in range(min(n, 2019)):
for j in range(i+1, min... | 15 | 22 | 334 | 499 | a, b = list(map(int, input().split()))
ans = 10000
for i in range(a, b):
for j in range(i + 1, b + 1):
if i >= 2019:
i = i % 2019
if j >= 2019:
j = j % 2019
if i == 0 or j == 0:
print("0")
exit()
else:
if ans > i * j % 2019:... | l, r = list(map(int, input().split()))
n = r - l + 1
ans1 = 0
ans2 = 0
min1 = 1000000000
min2 = 10000000000
for i in range(min(n, 2024)):
# print(l+i)
if (l + i) % 2019 == 0:
print((0))
break
else:
ans = 10000000000
for i in range(min(n, 2019)):
for j in range(i + 1, min(n, 2020)... | false | 31.818182 | [
"-a, b = list(map(int, input().split()))",
"-ans = 10000",
"-for i in range(a, b):",
"- for j in range(i + 1, b + 1):",
"- if i >= 2019:",
"- i = i % 2019",
"- if j >= 2019:",
"- j = j % 2019",
"- if i == 0 or j == 0:",
"- print(\"0\")",
"... | false | 0.042389 | 0.094869 | 0.446811 | [
"s770517156",
"s161315506"
] |
u156815136 | p02608 | python | s620714642 | s664781036 | 154 | 132 | 80,180 | 87,088 | Accepted | Accepted | 14.29 | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counte... | #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdi... | 38 | 38 | 954 | 964 | # from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate # (string,3) 3回
# from collections import deque
from collections import deque, defaultdict, Co... | # from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate, product # (string,3) 3回
# from collections import deque
from collections import deque, defaul... | false | 0 | [
"-from itertools import combinations, permutations, accumulate # (string,3) 3回",
"+from itertools import combinations, permutations, accumulate, product # (string,3) 3回",
"-ya = [0] * 100001",
"+n = I()",
"+ya = [0] * 1000001",
"- n = x**2 + y**2 + z**2 + x * y + y * z + z * x",
"- ... | false | 1.355008 | 1.333252 | 1.016318 | [
"s620714642",
"s664781036"
] |
u136090046 | p03779 | python | s204577331 | s696211337 | 31 | 24 | 2,940 | 2,940 | Accepted | Accepted | 22.58 | num = int(eval(input()))
for i in range(45000):
res = i * (i + 1) / 2
if res >= num:
print(i)
break
| x = int(eval(input()))
for i in range(1, 10000000):
x -= i
if x <= 0:
break
print(i) | 7 | 7 | 125 | 101 | num = int(eval(input()))
for i in range(45000):
res = i * (i + 1) / 2
if res >= num:
print(i)
break
| x = int(eval(input()))
for i in range(1, 10000000):
x -= i
if x <= 0:
break
print(i)
| false | 0 | [
"-num = int(eval(input()))",
"-for i in range(45000):",
"- res = i * (i + 1) / 2",
"- if res >= num:",
"- print(i)",
"+x = int(eval(input()))",
"+for i in range(1, 10000000):",
"+ x -= i",
"+ if x <= 0:",
"+print(i)"
] | false | 0.048373 | 0.158938 | 0.304352 | [
"s204577331",
"s696211337"
] |
u729133443 | p02537 | python | s937386273 | s112268341 | 1,289 | 1,115 | 276,100 | 275,712 | Accepted | Accepted | 13.5 | d=[0]*6**8
n,k,*a=list(map(int,open(0).read().split()+d))
while n:n-=1;d[n]=max(d[j]for j in range(n,n+99)if abs(a[n]-a[j])<=k)+1
print((max(d))) | d=[0]*6**8
n,k,*a=list(map(int,open(0).read().split()+d))
while n:n-=1;d[n]=max(d[j]for j in range(n,n+99)if-k<=a[n]-a[j]<=k)+1
print((max(d))) | 4 | 4 | 140 | 138 | d = [0] * 6**8
n, k, *a = list(map(int, open(0).read().split() + d))
while n:
n -= 1
d[n] = max(d[j] for j in range(n, n + 99) if abs(a[n] - a[j]) <= k) + 1
print((max(d)))
| d = [0] * 6**8
n, k, *a = list(map(int, open(0).read().split() + d))
while n:
n -= 1
d[n] = max(d[j] for j in range(n, n + 99) if -k <= a[n] - a[j] <= k) + 1
print((max(d)))
| false | 0 | [
"- d[n] = max(d[j] for j in range(n, n + 99) if abs(a[n] - a[j]) <= k) + 1",
"+ d[n] = max(d[j] for j in range(n, n + 99) if -k <= a[n] - a[j] <= k) + 1"
] | false | 0.532409 | 0.582497 | 0.914011 | [
"s937386273",
"s112268341"
] |
u474212171 | p02572 | python | s717022005 | s118936979 | 267 | 172 | 49,832 | 31,664 | Accepted | Accepted | 35.58 | import numpy as np
MOD = 10 ** 9 + 7
n=int(eval(input())) #3
alst=list(map(int,input().split())) #[1,2,3]
# 累積和を求める
# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,0+1,0+1+2,0+1+2+3,0+1+2+3+4,0+1+2+3+4+5,0+1+2+3+4+5+6]
s=[0]
for i in range(len(alst)):
s.append(s[i]+alst[i])
sum=0
for i in range(len(alst)-1):... | MOD = 10 ** 9 + 7
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]
cumsum=[0]
def my_cumsum(alst):
for i in range(len(alst)):
cumsum.append(cumsum[i]+alst[i])
return cumsum
n=int(eval(input())) #3
alst=list(map(int,input().split()))
# 原因はnp.cumsum関数にある事が判明
# s=np.cumsum(alst)
s=my_cumsum(alst)
... | 22 | 24 | 369 | 408 | import numpy as np
MOD = 10**9 + 7
n = int(eval(input())) # 3
alst = list(map(int, input().split())) # [1,2,3]
# 累積和を求める
# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,0+1,0+1+2,0+1+2+3,0+1+2+3+4,0+1+2+3+4+5,0+1+2+3+4+5+6]
s = [0]
for i in range(len(alst)):
s.append(s[i] + alst[i])
sum = 0
for i in range(len(alst) - 1):
s... | MOD = 10**9 + 7
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]
cumsum = [0]
def my_cumsum(alst):
for i in range(len(alst)):
cumsum.append(cumsum[i] + alst[i])
return cumsum
n = int(eval(input())) # 3
alst = list(map(int, input().split()))
# 原因はnp.cumsum関数にある事が判明
# s=np.cumsum(alst)
s = my_cumsum(alst... | false | 8.333333 | [
"-import numpy as np",
"+MOD = 10**9 + 7",
"+# [1,2,3,4,5,6]の時、累積和は、",
"+# [0,1,3,6,10,15,21]",
"+cumsum = [0]",
"-MOD = 10**9 + 7",
"+",
"+def my_cumsum(alst):",
"+ for i in range(len(alst)):",
"+ cumsum.append(cumsum[i] + alst[i])",
"+ return cumsum",
"+",
"+",
"-alst = list... | false | 0.097936 | 0.056555 | 1.731711 | [
"s717022005",
"s118936979"
] |
u227082700 | p03040 | python | s806037788 | s490860439 | 1,591 | 1,131 | 19,064 | 67,792 | Accepted | Accepted | 28.91 | from heapq import heappop,heappush
l,r=[],[]
ans=0
for _ in range(int(eval(input()))):
a=list(map(int,input().split()))
if a[0]==1:
_,ia,ib=a
heappush(l,-ia)
heappush(r,ia)
ll=heappop(l)
rr=heappop(r)
heappush(l,-rr)
heappush(r,-ll)
ans+=ib+abs(ll+rr)
else:print((-l[0],ans)) | from heapq import heappop,heappush
q=int(eval(input()))
queries=[list(map(int,input().split()))for _ in range(q)]
l=[]
r=[]
ans=0
queonecount=0
mid=-1
for query in queries:
if query[0]==1:
queonecount+=1
_,a,b=query
ans+=b
heappush(l,-a)
heappush(r,a)
midl=-heappop(l)
midr=... | 15 | 24 | 300 | 485 | from heapq import heappop, heappush
l, r = [], []
ans = 0
for _ in range(int(eval(input()))):
a = list(map(int, input().split()))
if a[0] == 1:
_, ia, ib = a
heappush(l, -ia)
heappush(r, ia)
ll = heappop(l)
rr = heappop(r)
heappush(l, -rr)
heappush(r, -ll... | from heapq import heappop, heappush
q = int(eval(input()))
queries = [list(map(int, input().split())) for _ in range(q)]
l = []
r = []
ans = 0
queonecount = 0
mid = -1
for query in queries:
if query[0] == 1:
queonecount += 1
_, a, b = query
ans += b
heappush(l, -a)
heappush(... | false | 37.5 | [
"-l, r = [], []",
"+q = int(eval(input()))",
"+queries = [list(map(int, input().split())) for _ in range(q)]",
"+l = []",
"+r = []",
"-for _ in range(int(eval(input()))):",
"- a = list(map(int, input().split()))",
"- if a[0] == 1:",
"- _, ia, ib = a",
"- heappush(l, -ia)",
"-... | false | 0.037229 | 0.052005 | 0.715879 | [
"s806037788",
"s490860439"
] |
u217627525 | p02888 | python | s661308397 | s354791493 | 1,236 | 906 | 3,188 | 3,188 | Accepted | Accepted | 26.7 | from bisect import bisect_left
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
for j in range(i+1,n-1):
ans+=bisect_left(l,l[i]+l[j])-j-1
print(ans) | def main():
from bisect import bisect_left
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
for j in range(i+1,n-1):
ans+=bisect_left(l,l[i]+l[j])-j-1
print(ans)
if __name__=="__main__":
main() | 9 | 12 | 204 | 291 | from bisect import bisect_left
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n - 2):
for j in range(i + 1, n - 1):
ans += bisect_left(l, l[i] + l[j]) - j - 1
print(ans)
| def main():
from bisect import bisect_left
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n - 2):
for j in range(i + 1, n - 1):
ans += bisect_left(l, l[i] + l[j]) - j - 1
print(ans)
if __name__ == "__main__":
main()
| false | 25 | [
"-from bisect import bisect_left",
"+def main():",
"+ from bisect import bisect_left",
"-n = int(eval(input()))",
"-l = list(map(int, input().split()))",
"-l.sort()",
"-ans = 0",
"-for i in range(n - 2):",
"- for j in range(i + 1, n - 1):",
"- ans += bisect_left(l, l[i] + l[j]) - j - ... | false | 0.046146 | 0.040005 | 1.15352 | [
"s661308397",
"s354791493"
] |
u162893962 | p02700 | python | s721831736 | s552168583 | 24 | 21 | 9,116 | 9,112 | Accepted | Accepted | 12.5 | import math
a, b, c, d = list(map(int, input().split()))
taka = math.ceil(c/b)
ao = math.ceil(a/d)
if taka <= ao:
print('Yes')
else:
print('No')
| # while文を使うパターン(本番では書けず、あとで修正したもの)
a, b, c, d = list(map(int, input().split()))
turn = 0
while a >= 1 and c >= 1:
if turn % 2 == 0:
c -= b
else:
a -= d
turn += 1
# どちらかが0以下になった時点で止まるので最後のターンがどちらかを判別
if turn % 2 != 0:
print('Yes')
else:
print('No')
| 10 | 18 | 158 | 299 | import math
a, b, c, d = list(map(int, input().split()))
taka = math.ceil(c / b)
ao = math.ceil(a / d)
if taka <= ao:
print("Yes")
else:
print("No")
| # while文を使うパターン(本番では書けず、あとで修正したもの)
a, b, c, d = list(map(int, input().split()))
turn = 0
while a >= 1 and c >= 1:
if turn % 2 == 0:
c -= b
else:
a -= d
turn += 1
# どちらかが0以下になった時点で止まるので最後のターンがどちらかを判別
if turn % 2 != 0:
print("Yes")
else:
print("No")
| false | 44.444444 | [
"-import math",
"-",
"+# while文を使うパターン(本番では書けず、あとで修正したもの)",
"-taka = math.ceil(c / b)",
"-ao = math.ceil(a / d)",
"-if taka <= ao:",
"+turn = 0",
"+while a >= 1 and c >= 1:",
"+ if turn % 2 == 0:",
"+ c -= b",
"+ else:",
"+ a -= d",
"+ turn += 1",
"+# どちらかが0以下になった時点で... | false | 0.047685 | 0.047535 | 1.003163 | [
"s721831736",
"s552168583"
] |
u227020436 | p03274 | python | s996445528 | s576345182 | 74 | 60 | 14,388 | 15,020 | Accepted | Accepted | 18.92 | N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
assert len(x) == N
m = min(x[i] - x[i-K+1] + min(abs(x[i]), abs(x[i-K+1])) for i in range(K-1, N))
print(m) | N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
assert len(x) == N
m = min(b - a + min(abs(a), abs(b)) for a, b in zip(x, x[K-1:]))
print(m) | 6 | 6 | 184 | 169 | N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
assert len(x) == N
m = min(
x[i] - x[i - K + 1] + min(abs(x[i]), abs(x[i - K + 1])) for i in range(K - 1, N)
)
print(m)
| N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
assert len(x) == N
m = min(b - a + min(abs(a), abs(b)) for a, b in zip(x, x[K - 1 :]))
print(m)
| false | 0 | [
"-m = min(",
"- x[i] - x[i - K + 1] + min(abs(x[i]), abs(x[i - K + 1])) for i in range(K - 1, N)",
"-)",
"+m = min(b - a + min(abs(a), abs(b)) for a, b in zip(x, x[K - 1 :]))"
] | false | 0.042167 | 0.040921 | 1.03045 | [
"s996445528",
"s576345182"
] |
u102461423 | p03808 | python | s169710999 | s679140673 | 179 | 140 | 25,940 | 33,192 | Accepted | Accepted | 21.79 | import sys
input = sys.stdin.readline
import numpy as np
# Aへの加算は、imos法でまとめて行える。
# +[1,2,3,4,5]
# 階差:[-4,1,1,1,1]
# 総回数と最終的な階差から、回数分布がわかる
N = int(eval(input()))
A = np.array(input().split(), dtype=np.int64)
total_op = A.sum() // (N*(N+1)//2)
diff = np.empty_like(A)
diff[1:] = np.diff(A)
diff[0] = ... | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = np.array(read().split(), np.int64)
def main(N, A):
k = N * (N + 1) // 2
t = A.sum() // k
if k * t != A.sum():
return False
... | 29 | 25 | 537 | 542 | import sys
input = sys.stdin.readline
import numpy as np
# Aへの加算は、imos法でまとめて行える。
# +[1,2,3,4,5]
# 階差:[-4,1,1,1,1]
# 総回数と最終的な階差から、回数分布がわかる
N = int(eval(input()))
A = np.array(input().split(), dtype=np.int64)
total_op = A.sum() // (N * (N + 1) // 2)
diff = np.empty_like(A)
diff[1:] = np.diff(A)
diff[0] = A[0] - A[-1]
#... | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = np.array(read().split(), np.int64)
def main(N, A):
k = N * (N + 1) // 2
t = A.sum() // k
if k * t != A.sum():
return False
B = np.empt... | false | 13.793103 | [
"-",
"-input = sys.stdin.readline",
"-# Aへの加算は、imos法でまとめて行える。",
"-# +[1,2,3,4,5]",
"-# 階差:[-4,1,1,1,1]",
"-# 総回数と最終的な階差から、回数分布がわかる",
"-N = int(eval(input()))",
"-A = np.array(input().split(), dtype=np.int64)",
"-total_op = A.sum() // (N * (N + 1) // 2)",
"-diff = np.empty_like(A)",
"-diff[1:] = ... | false | 0.278547 | 0.361383 | 0.77078 | [
"s169710999",
"s679140673"
] |
u873482706 | p00043 | python | s569962490 | s911071232 | 110 | 60 | 4,336 | 4,328 | Accepted | Accepted | 45.45 | import sys
def pokakito(num_line):
if not num_line and flag == 1:
result_lis.append(check_num)
return True
for num in num_line:
if three(num, num_line): return True
if two(num, num_line): return True
if straight(num, num_line): return True
def three(num, ... | import sys
def pokakito(num_line):
if not num_line and flag == 1:
result_lis.append(check_num)
return True
for num in num_line:
if three(num, num_line): return True
if two(num, num_line): return True
if straight(num, num_line): return True
def three(num, ... | 74 | 70 | 2,062 | 1,875 | import sys
def pokakito(num_line):
if not num_line and flag == 1:
result_lis.append(check_num)
return True
for num in num_line:
if three(num, num_line):
return True
if two(num, num_line):
return True
if straight(num, num_line):
return... | import sys
def pokakito(num_line):
if not num_line and flag == 1:
result_lis.append(check_num)
return True
for num in num_line:
if three(num, num_line):
return True
if two(num, num_line):
return True
if straight(num, num_line):
return... | false | 5.405405 | [
"- num_lis = [num, num + 1, num + 2]",
"- for i in range(3):",
"- for check in num_lis:",
"- if check < 0 or (not check in num_line):",
"- for i in range(3):",
"- num_lis[i] = num_lis[i] - 1",
"- break",
"+ for check in [num, ... | false | 0.085177 | 0.007563 | 11.262654 | [
"s569962490",
"s911071232"
] |
u252828980 | p03329 | python | s376455109 | s152443916 | 600 | 495 | 3,828 | 12,700 | Accepted | Accepted | 17.5 |
n = int(eval(input()))
dp = [10**9]*(n+1)
L = [6**i for i in range(1,7)]
L += [9**i for i in range(1,6)]
dp[0] = 0
for i in range(1,n+1):
dp[i] = dp[i-1]+1
k = 6
while i-k >=0:
dp[i] = min(dp[i],dp[i-k]+1)
k *=6
k = 9
while i-k >=0:
dp[i] = min(dp[i],dp[i-k... | n = int(eval(input()))
dp = [0]*(n+10)
for i in range(n+1):
dp[i+1] = dp[i] +1
for i in range(1,n+1):
k = 6
while k <=n:
if i-k>=0:
dp[i] = min(dp[i],dp[i-k]+1)
#print(dp[i-1],dp[i-k])
k *=6
#print(dp)
k = 9
while k <=n:
... | 22 | 25 | 368 | 415 | n = int(eval(input()))
dp = [10**9] * (n + 1)
L = [6**i for i in range(1, 7)]
L += [9**i for i in range(1, 6)]
dp[0] = 0
for i in range(1, n + 1):
dp[i] = dp[i - 1] + 1
k = 6
while i - k >= 0:
dp[i] = min(dp[i], dp[i - k] + 1)
k *= 6
k = 9
while i - k >= 0:
dp[i] = min(dp[i],... | n = int(eval(input()))
dp = [0] * (n + 10)
for i in range(n + 1):
dp[i + 1] = dp[i] + 1
for i in range(1, n + 1):
k = 6
while k <= n:
if i - k >= 0:
dp[i] = min(dp[i], dp[i - k] + 1)
# print(dp[i-1],dp[i-k])
k *= 6
# print(dp)
k = 9
while k <= n:
... | false | 12 | [
"-dp = [10**9] * (n + 1)",
"-L = [6**i for i in range(1, 7)]",
"-L += [9**i for i in range(1, 6)]",
"-dp[0] = 0",
"+dp = [0] * (n + 10)",
"+for i in range(n + 1):",
"+ dp[i + 1] = dp[i] + 1",
"- dp[i] = dp[i - 1] + 1",
"- while i - k >= 0:",
"- dp[i] = min(dp[i], dp[i - k] + 1)",
... | false | 0.115312 | 0.151844 | 0.759412 | [
"s376455109",
"s152443916"
] |
u754022296 | p03819 | python | s336493654 | s951638556 | 1,919 | 1,762 | 128,336 | 127,784 | Accepted | Accepted | 8.18 | import sys
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(n)]
BIT = [0]*(m+2)
def add(i, a):
while i <= m+1:
BIT[i] += a
i += i&(-i)
def bit_sum(i):
res = 0
while i > 0:
res += BIT[i]... | import sys
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(n)]
BIT = [0]*(m+2)
def add(i, a):
while i <= m+1:
BIT[i] += a
i += i&(-i)
def bit_sum(i):
res = 0
while i > 0:
res += BIT[i]... | 40 | 36 | 781 | 731 | import sys
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(n)]
BIT = [0] * (m + 2)
def add(i, a):
while i <= m + 1:
BIT[i] += a
i += i & (-i)
def bit_sum(i):
res = 0
whil... | import sys
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(n)]
BIT = [0] * (m + 2)
def add(i, a):
while i <= m + 1:
BIT[i] += a
i += i & (-i)
def bit_sum(i):
res = 0
whil... | false | 10 | [
"- for l, r in LR:",
"- add(l, 1)",
"- add(r + 1, -1)",
"- S = sorted([(r - l + 1, l, r) for l, r in LR])",
"- cnt = 0",
"+ S = sorted([(r - l + 1, l, r) for l, r in LR], reverse=True)",
"+ cnt = n",
"- for i in range(m, 0, -1):",
"+ for i in range(1, m + 1):",
"... | false | 0.033706 | 0.041743 | 0.807469 | [
"s336493654",
"s951638556"
] |
u634079249 | p03400 | python | s981361441 | s435546996 | 36 | 31 | 9,740 | 9,744 | Accepted | Accepted | 13.89 | import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip(... | import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip(... | 43 | 39 | 1,207 | 1,118 | import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = la... | import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = la... | false | 9.302326 | [
"- d, m = divmod(D, A)",
"- if m == 0:",
"- ret += D // A",
"- else:",
"- ret += D // A + 1",
"+ ret += (D - 1) // A + 1"
] | false | 0.038339 | 0.069123 | 0.554644 | [
"s981361441",
"s435546996"
] |
u922449550 | p02863 | python | s615489060 | s087773996 | 560 | 323 | 123,864 | 22,292 | Accepted | Accepted | 42.32 | N, T = list(map(int, input().split()))
AB = []
for i in range(N):
A, B = list(map(int, input().split()))
AB.append([A, B])
AB.sort()
dp = [[0 for t in range(T)] for i in range(N+1)]
ans = 0
for i, ab in enumerate(AB):
ans = max(ans, dp[i][T-1] + ab[1])
for t in range(T):
if t < ab[0]:
... | import numpy as np
N, T = list(map(int, input().split()))
AB = []
for i in range(N):
A, B = list(map(int, input().split()))
AB.append([A, B])
AB.sort()
dp = np.zeros(T, dtype=int)
ans = 0
for a, b in AB:
ans = max(ans, dp[-1] + b)
dp[a:] = np.maximum(dp[a:], dp[:-a] + b)
print(ans) | 20 | 18 | 415 | 300 | N, T = list(map(int, input().split()))
AB = []
for i in range(N):
A, B = list(map(int, input().split()))
AB.append([A, B])
AB.sort()
dp = [[0 for t in range(T)] for i in range(N + 1)]
ans = 0
for i, ab in enumerate(AB):
ans = max(ans, dp[i][T - 1] + ab[1])
for t in range(T):
if t < ab[0]:
... | import numpy as np
N, T = list(map(int, input().split()))
AB = []
for i in range(N):
A, B = list(map(int, input().split()))
AB.append([A, B])
AB.sort()
dp = np.zeros(T, dtype=int)
ans = 0
for a, b in AB:
ans = max(ans, dp[-1] + b)
dp[a:] = np.maximum(dp[a:], dp[:-a] + b)
print(ans)
| false | 10 | [
"+import numpy as np",
"+",
"-dp = [[0 for t in range(T)] for i in range(N + 1)]",
"+dp = np.zeros(T, dtype=int)",
"-for i, ab in enumerate(AB):",
"- ans = max(ans, dp[i][T - 1] + ab[1])",
"- for t in range(T):",
"- if t < ab[0]:",
"- dp[i + 1][t] = dp[i][t]",
"- els... | false | 0.061614 | 0.21986 | 0.280242 | [
"s615489060",
"s087773996"
] |
u883048396 | p03379 | python | s902011910 | s244971577 | 382 | 241 | 50,452 | 29,808 | Accepted | Accepted | 36.91 | iN = int(eval(input()))
aX = [int(_) for _ in input().split()]
aXs = sorted(enumerate(aX),key=lambda x:x[1])
iMu = iN//2
iMd = iN//2 -1
iMuV = aXs[iMu][1]
iMdV = aXs[iMd][1]
if iMuV == iMdV:
print(("\n".join([str(iMuV)]*iN)))
else:
print(("\n".join(map(str,[iMuV if aX[x] < iMuV else iMdV for... | iN = int(eval(input()))
aX = [int(_) for _ in input().split()]
aXs = sorted(aX)
iMu = iN//2
iMd = iN//2 -1
iMuV = aXs[iMu]
iMdV = aXs[iMd]
if iMuV == iMdV:
print(("\n".join([str(iMuV)]*iN)))
else:
print(("\n".join(map(str,[iMuV if x < iMuV else iMdV for x in aX]))))
| 15 | 14 | 336 | 288 | iN = int(eval(input()))
aX = [int(_) for _ in input().split()]
aXs = sorted(enumerate(aX), key=lambda x: x[1])
iMu = iN // 2
iMd = iN // 2 - 1
iMuV = aXs[iMu][1]
iMdV = aXs[iMd][1]
if iMuV == iMdV:
print(("\n".join([str(iMuV)] * iN)))
else:
print(("\n".join(map(str, [iMuV if aX[x] < iMuV else iMdV for x in rang... | iN = int(eval(input()))
aX = [int(_) for _ in input().split()]
aXs = sorted(aX)
iMu = iN // 2
iMd = iN // 2 - 1
iMuV = aXs[iMu]
iMdV = aXs[iMd]
if iMuV == iMdV:
print(("\n".join([str(iMuV)] * iN)))
else:
print(("\n".join(map(str, [iMuV if x < iMuV else iMdV for x in aX]))))
| false | 6.666667 | [
"-aXs = sorted(enumerate(aX), key=lambda x: x[1])",
"+aXs = sorted(aX)",
"-iMuV = aXs[iMu][1]",
"-iMdV = aXs[iMd][1]",
"+iMuV = aXs[iMu]",
"+iMdV = aXs[iMd]",
"- print((\"\\n\".join(map(str, [iMuV if aX[x] < iMuV else iMdV for x in range(iN)]))))",
"+ print((\"\\n\".join(map(str, [iMuV if x < iM... | false | 0.064918 | 0.118453 | 0.548047 | [
"s902011910",
"s244971577"
] |
u219417113 | p03371 | python | s761030897 | s202926774 | 209 | 183 | 41,692 | 39,280 | Accepted | Accepted | 12.44 | A, B, C, X, Y = list(map(int, input().split()))
"""
ABピザの購入数(0~2 * max(X, Y)で全探索)
"""
min_price = 10 ** 10
for i in range(2 * max(X, Y) + 1):
c_price = C * i
a_price = A * max(0, (X - i//2))
b_price = B * max(0, (Y - i//2))
min_price = min(min_price, a_price+b_price+c_price)
print(min_price)... | a, b, c, x, y = list(map(int, input().split()))
ans = 10 ** 18
for i in range(0, 2 * max(x, y) + 1, 2):
tmp = i * c
if x - i // 2 > 0:
tmp += (x - i // 2) * a
if y - i // 2 > 0:
tmp += (y - i // 2) * b
ans = min(ans, tmp)
print(ans)
| 12 | 11 | 315 | 270 | A, B, C, X, Y = list(map(int, input().split()))
"""
ABピザの購入数(0~2 * max(X, Y)で全探索)
"""
min_price = 10**10
for i in range(2 * max(X, Y) + 1):
c_price = C * i
a_price = A * max(0, (X - i // 2))
b_price = B * max(0, (Y - i // 2))
min_price = min(min_price, a_price + b_price + c_price)
print(min_price)
| a, b, c, x, y = list(map(int, input().split()))
ans = 10**18
for i in range(0, 2 * max(x, y) + 1, 2):
tmp = i * c
if x - i // 2 > 0:
tmp += (x - i // 2) * a
if y - i // 2 > 0:
tmp += (y - i // 2) * b
ans = min(ans, tmp)
print(ans)
| false | 8.333333 | [
"-A, B, C, X, Y = list(map(int, input().split()))",
"-\"\"\"",
"-ABピザの購入数(0~2 * max(X, Y)で全探索)",
"-\"\"\"",
"-min_price = 10**10",
"-for i in range(2 * max(X, Y) + 1):",
"- c_price = C * i",
"- a_price = A * max(0, (X - i // 2))",
"- b_price = B * max(0, (Y - i // 2))",
"- min_price = ... | false | 0.114389 | 0.063746 | 1.794455 | [
"s761030897",
"s202926774"
] |
u761320129 | p02807 | python | s536938576 | s786714888 | 233 | 199 | 19,972 | 19,984 | Accepted | Accepted | 14.59 | N = int(eval(input()))
X = list(map(int,input().split()))
MOD = 10**9+7
MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
fac[i] = fac[i-1] * i % MOD
inv[i] = -inv[MOD%i] * (MOD // i) % MOD
finv[i] = finv[i-1] * inv[i] % MOD
c = 0
f = ... | N = int(eval(input()))
X = list(map(int,input().split()))
Y = [b-a for a,b in zip(X,X[1:])]
MOD = 10**9+7
MAXN = N+5
fac = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
fac[i] = fac[i-1] * i % MOD
inv[i] = -inv[MOD%i] * (MOD // i) % MOD
ans = m = 0
for i,y in enumerate(Y):
... | 22 | 18 | 449 | 384 | N = int(eval(input()))
X = list(map(int, input().split()))
MOD = 10**9 + 7
MAXN = N + 5
fac = [1, 1] + [0] * MAXN
finv = [1, 1] + [0] * MAXN
inv = [0, 1] + [0] * MAXN
for i in range(2, MAXN + 2):
fac[i] = fac[i - 1] * i % MOD
inv[i] = -inv[MOD % i] * (MOD // i) % MOD
finv[i] = finv[i - 1] * inv[i] % MOD
c =... | N = int(eval(input()))
X = list(map(int, input().split()))
Y = [b - a for a, b in zip(X, X[1:])]
MOD = 10**9 + 7
MAXN = N + 5
fac = [1, 1] + [0] * MAXN
inv = [0, 1] + [0] * MAXN
for i in range(2, MAXN + 2):
fac[i] = fac[i - 1] * i % MOD
inv[i] = -inv[MOD % i] * (MOD // i) % MOD
ans = m = 0
for i, y in enumerate... | false | 18.181818 | [
"+Y = [b - a for a, b in zip(X, X[1:])]",
"-finv = [1, 1] + [0] * MAXN",
"- finv[i] = finv[i - 1] * inv[i] % MOD",
"-c = 0",
"-f = fac[N - 1]",
"-ans = 0",
"-for i in range(1, N):",
"- c += f * inv[i]",
"- c %= MOD",
"- ans += c * (X[i] - X[i - 1])",
"+ans = m = 0",
"+for i, y in e... | false | 0.036796 | 0.035963 | 1.023155 | [
"s536938576",
"s786714888"
] |
u325282913 | p02555 | python | s986233419 | s978785390 | 346 | 300 | 9,216 | 9,292 | Accepted | Accepted | 13.29 | MOD = 10**9 + 7
def comb(n, k):
if n < k or n < 0 or k < 0:
return 0
if k == 0:
return 1
iinv = [1] * (k + 1)
ans = n
for i in range(2, k + 1):
iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
ans *= (n + 1 - i) * iinv[i] % MOD
ans %= MOD
retur... | MOD = 10**9 + 7
S = int(eval(input()))
dp = [0]*(S+4)
dp[0] = 1
dp[3] = 1
for i in range(4,S+1):
for k in range(i-2):
dp[i] += dp[k]
print((dp[S]%MOD)) | 23 | 9 | 499 | 163 | MOD = 10**9 + 7
def comb(n, k):
if n < k or n < 0 or k < 0:
return 0
if k == 0:
return 1
iinv = [1] * (k + 1)
ans = n
for i in range(2, k + 1):
iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
ans *= (n + 1 - i) * iinv[i] % MOD
ans %= MOD
return ans
S ... | MOD = 10**9 + 7
S = int(eval(input()))
dp = [0] * (S + 4)
dp[0] = 1
dp[3] = 1
for i in range(4, S + 1):
for k in range(i - 2):
dp[i] += dp[k]
print((dp[S] % MOD))
| false | 60.869565 | [
"-",
"-",
"-def comb(n, k):",
"- if n < k or n < 0 or k < 0:",
"- return 0",
"- if k == 0:",
"- return 1",
"- iinv = [1] * (k + 1)",
"- ans = n",
"- for i in range(2, k + 1):",
"- iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD",
"- ans *= (n + 1 - i... | false | 0.09706 | 0.105572 | 0.919376 | [
"s986233419",
"s978785390"
] |
u513081876 | p03633 | python | s989920121 | s644831189 | 38 | 18 | 5,432 | 3,064 | Accepted | Accepted | 52.63 | import fractions
N = int(eval(input()))
T = [int(eval(input())) for i in range(N)]
ans = T[0]
for i in range(1, N):
ans = (ans * T[i]) // (fractions.gcd(ans, T[i]))
print(ans)
#https://mathtrain.jp/abequalgl | N = int(eval(input()))
T = sorted([int(eval(input())) for i in range(N)])
def gcd(a, b):
while b != 0:
a, b = b,a%b
return a
if N == 1:
print((T[0]))
else:
ans = T[0]
for i in range(1, N):
ans = (ans*T[i])//(gcd(ans, T[i]))
print(ans) | 10 | 16 | 214 | 282 | import fractions
N = int(eval(input()))
T = [int(eval(input())) for i in range(N)]
ans = T[0]
for i in range(1, N):
ans = (ans * T[i]) // (fractions.gcd(ans, T[i]))
print(ans)
# https://mathtrain.jp/abequalgl
| N = int(eval(input()))
T = sorted([int(eval(input())) for i in range(N)])
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
if N == 1:
print((T[0]))
else:
ans = T[0]
for i in range(1, N):
ans = (ans * T[i]) // (gcd(ans, T[i]))
print(ans)
| false | 37.5 | [
"-import fractions",
"+N = int(eval(input()))",
"+T = sorted([int(eval(input())) for i in range(N)])",
"-N = int(eval(input()))",
"-T = [int(eval(input())) for i in range(N)]",
"-ans = T[0]",
"-for i in range(1, N):",
"- ans = (ans * T[i]) // (fractions.gcd(ans, T[i]))",
"-print(ans)",
"-# http... | false | 0.054723 | 0.04162 | 1.314822 | [
"s989920121",
"s644831189"
] |
u133886644 | p03401 | python | s336752129 | s216785293 | 289 | 247 | 13,540 | 13,540 | Accepted | Accepted | 14.53 | import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline
N, = list(map(int, input().split()))
L = [int(v) for v in input().split()]
# L = [int(input()) for _ in range(Q)]
# S = input().strip()
su = abs(L[0])
a = [0] * N
for i in range(1, ... | import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline
N, = list(map(int, input().split()))
L = [int(v) for v in input().split()]
# L = [int(input()) for _ in range(Q)]
# S = input().strip()
L = [0] + L + [0]
su = 0
for i in range(N +... | 61 | 19 | 1,283 | 467 | import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline
(N,) = list(map(int, input().split()))
L = [int(v) for v in input().split()]
# L = [int(input()) for _ in range(Q)]
# S = input().strip()
su = abs(L[0])
a = [0] * N
for i in range(1, N):
t = ... | import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline
(N,) = list(map(int, input().split()))
L = [int(v) for v in input().split()]
# L = [int(input()) for _ in range(Q)]
# S = input().strip()
L = [0] + L + [0]
su = 0
for i in range(N + 1):
su +=... | false | 68.852459 | [
"-su = abs(L[0])",
"-a = [0] * N",
"-for i in range(1, N):",
"- t = 0",
"- if L[i - 1] * L[i] < 0:",
"- t = abs(L[i - 1]) + abs(L[i])",
"- else:",
"- t = abs(L[i - 1] - L[i])",
"- su += t",
"- a[i] = t",
"-su += abs(L[-1])",
"-if L[0] * L[1] <= 0:",
"- print((... | false | 0.04117 | 0.039385 | 1.045329 | [
"s336752129",
"s216785293"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.