Harryxun/stf_run huggingface dataset:
impoty sys
sys.setrecursionlimit(10**9)

N,M,P = map(int,input().split())
edges = []
to = [[] for i in range(N)]
rto = [[] for i in range(N)]
for i in range(M) :
    u,v,cost = map(int,input().split())
    u -= 1
    v -= 1
    cost -= P
    cost *= -1
    edges.append([u,v,cost])
    to[u].append(v)
    rto[v].append(u)

canVisitFromS = [False]*N
canVisitFromG = [False]*N

def dfs(u) :
    if canVisitFromS[u] : return
    canVisitFromS[u] = True
    for v in to[u] :
        dfs(v)

def rdfs(v) :
    if canVisitFromG[v] : return
    canVisitFromG[v] = True
    for u in rto[v] :
        rdfs(u)

dfs(0)
rdfs(N-1)

OK = [canVisitFromS[i]*canVisitFromG[i] for i in range(N)]

dist = [float("inf")]*N
dist[0] = 0

ans = 0
step = 0
update = True
while update :
    update = False
    for i in range(M) :
        u,v,cost = edges[i]
        if OK[u]*OK[v] == 0 : continue
        if dist[v] > dist[u] + cost :
            dist[v] = dist[u] + cost
            update = True
    step += 1
    if step > N :
        ans = -1
        break

if ans != -1 :
    ans = max(0, dist[N-1]*(-1))

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N,M,P = map(int,input().split())
edges = []
L = [[] for i in range(N)]
utov = [[] for i in range(N)]
vtou = [[] for i in range(N)]

for i in range(M) :
    u,v,cost = map(int,input().split())
    u -= 1
    v -= 1
    cost -= P
    cost *= -1
    edges.append([u,v,cost])
    utov[u].append(v)
    vtou[v].append(u)

reachableFromS = [False]*N
reachableFromG = [False]*N

def dfs(u) :
    if reachableFromS[u] :
        return
    reachableFromS[u] = True
    for v in utov[u] :
        dfs(v)

def dfs2(v) :
    if reachableFromG[v] :
        return
    reachableFromG[v] = True
    for u in vtou[v] :
        dfs2(u)

dfs(0)
dfs2(N-1)

OK = [reachableFromS[i] * reachableFromG[i] for i in range(N)]

dist = [float("inf")]*N
dist[0] = 0

ans = 0
step = 0
update = True

while update :
    update = False
    for i in range(M) :
        u,v,cost = edges[i]
        if OK[u] * OK[v] == 0 :
            continue
        if dist[v] > dist[u] + cost :
            dist[v] = dist[u] + cost
            update = True
    
    step += 1
    if step > N :
        ans = -1
        break

if ans != -1 :
    ans = max(0, dist[N-1] * (-1))
print(ans)
a=input('a=')
b=input('b=')
c=int(a)*int(b)
if int(a)*int(b)%2 == 0:
    print('Even')
else:
    print('Odd')


### FIXED CODE ###

a,b=map(int,input().split())
if a*b%2 == 0:
    print('Even')
else:
    print('Odd')
l = [int(input()) for i in range(1, 4)]
print(min(l[0], l[1]) + min(l[2], l[3]))


### FIXED CODE ###

l = [int(input()) for i in range(1, 5)]
print(min(l[0], l[1]) + min(l[2], l[3]))
N,T=map(int,input().split())
l=[]
for i in range(N):
    c,t=map(int,input().split())
    if t < T:
        l.append(c)
if l =[]:
    print("TLE")
elif:
    print(min(l))

### FIXED CODE ###

N,T=map(int,input().split())
l=[]
for i in range(N):
    c,t=map(int,input().split())
    if t <= T:
        l.append(c)
if not l:
    print("TLE")
else:
    print(min(l))
#!/usr/bin/env python3
# Daydream
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

tokens = ['dream', 'dreamer', 'erase', 'eraser']

def solve(S: str):
    print(YES if is_valid(S) else NO)
    return

def is_valid(S):
    if S == '':
        return True
    for token in tokens:
        sub = S[-len(token):]
        if sub == token:
            return is_valid(S[:-len(token)])
    return False

def is_valid2(S):
    import re
    x = r"^(dream|dreamer|erase|eraser)*$"
    return True if re.match(x, S) else False

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# Daydream
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

tokens = ['dream', 'dreamer', 'erase', 'eraser']

def solve(S: str):
    print(YES if is_valid2(S) else NO)
    return

def is_valid(S):
    if S == '':
        return True
    for token in tokens:
        sub = S[-len(token):]
        if sub == token:
            return is_valid(S[:-len(token)])
    return False

def is_valid2(S):
    import re
    x = r"^(dream|dreamer|erase|eraser)*$"
    return True if re.match(x, S) else False

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
n = int(input())
ans = 111
print([111*i for i in range(9) if 111*i>=n][0])

### FIXED CODE ###

n = int(input())
ans = 111
print([111*i for i in range(1, 10) if 111*i>=n][0])
X, Y =map(int,input().split())
a = 0
for i in range(X+1):
  if 2*i+4*(X-i)==Y:
    print('Yes')
   
  else:
    a += 1
    
if a==X
    
    
if a   ==1:
  print('No')

### FIXED CODE ###

X, Y =map(int,input().split())
a = 0
for i in range(X+1):
  if 2*i+4*(X-i)==Y:
    print('Yes')
  else:
    a +=1
  
    
if a ==X+1:
  print('No')
from functools import lru_cache

N = int(input())
a = list(map(int, input().split()))

@lru_cache(maxsize=None)
def f(n):
	if n == 0: return 0
	if n == 1: return abs(a[0] - a[1])
	return min(f(n - 1) + abs(a[n - 1] - a[n]), f(n - 2) + abs(a[n - 2] - a[n]))

print(f(N - 1))


### FIXED CODE ###

from functools import lru_cache
from sys import setrecursionlimit

setrecursionlimit(900010)

N = int(input())
a = list(map(int, input().split()))

@lru_cache(maxsize=None)
def f(n):
	if n == 0: return 0
	if n == 1: return abs(a[0] - a[1])
	return min(f(n - 1) + abs(a[n - 1] - a[n]), f(n - 2) + abs(a[n - 2] - a[n]))

print(f(N - 1))
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kind=[]
count=1
for i in range(len(a)-1):
  if(a[i]==a[i+1]):count+=1
  else:
    kind.append(count)
    count=1
kind.append(count)
kind.sort()
change=0
for i in range(k):change+=kind.pop()
print(n-change)


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kind=[]
count=1
for i in range(len(a)-1):
  if(a[i]==a[i+1]):count+=1
  else:
    kind.append(count)
    count=1
kind.append(count)
kind.sort()
change=0
for i in range(k):
  if(len(kind)!=0):change+=kind.pop()
print(n-change)
SHEEP = True
WOLF = False


def print_tree(tree):
    print(''.join(['S' if e else 'W' for e in tree]))


def calc_next_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos - 1]
        else:
            return not tree[cur_pos - 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos - 1]
        else:
            return tree[cur_pos - 1]


def calc_prev_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos + 1]
        else:
            return not tree[cur_pos + 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos + 1]
        else:
            return tree[cur_pos + 1]


def wfs(tree, cur_pos, N) -> bool:
    tree.append(calc_next_animal(tree, cur_pos))
    cur_pos += 1
    if cur_pos == N - 1:
        return tree[0] == calc_next_animal(tree, cur_pos) and tree[-1] == calc_prev_animal(tree, 0)
    else:
        return wfs(tree, cur_pos, N)


N = int(input())
answer = [True if i == 'o' else False for i in input().rstrip()]
a = [WOLF, WOLF]
b = [WOLF, SHEEP]
c = [SHEEP, SHEEP]
d = [SHEEP, WOLF]
if wfs(a, 1, N):
    print_tree(a)
elif wfs(b, 1, N):
    print_tree(b)
elif wfs(c, 1, N):
    print_tree(c)
elif wfs(d, 1, N):
    print_tree(d)
else:
    print(-1)

### FIXED CODE ###

import sys

sys.setrecursionlimit(int(2E5))

SHEEP = True
WOLF = False


def print_tree(tree):
    print(''.join(['S' if e else 'W' for e in tree]))


def calc_next_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos - 1]
        else:
            return not tree[cur_pos - 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos - 1]
        else:
            return tree[cur_pos - 1]


def calc_prev_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos + 1]
        else:
            return not tree[cur_pos + 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos + 1]
        else:
            return tree[cur_pos + 1]


def wfs(tree, cur_pos, N):
    tree[cur_pos + 1] = calc_next_animal(tree, cur_pos)
    cur_pos += 1
    if cur_pos == N - 1:
        return tree[0] == calc_next_animal(tree, cur_pos) and tree[cur_pos] == calc_prev_animal(tree, 0)
    else:
        return wfs(tree, cur_pos, N)


if __name__ == '__main__':
    N = int(input())
    answer = [True if i == 'o' else False for i in input().rstrip()]
    aa = [[WOLF, WOLF]
        , [WOLF, SHEEP]
        , [SHEEP, SHEEP]
        , [SHEEP, WOLF]]
    super_list = [0] * int(2E5)
    for a in aa:
        super_list[:2] = a
        if wfs(super_list, 1, N):
            print_tree(super_list[:N])
            break
    else:
        print(-1)
while True:
  n=int(input())
  if n%7==0:
    print('{}'.format('thu'))
  elif n%7==1:
    print('{}'.format('fri'))
  elif n%7==2:
    print('{}'.format('sat'))
  elif n%7==3:
    print('{}'.format('sun'))
  elif n%7==4:
    print('{}'.format('mon'))
  elif n%7==5:
    print('{}'.format('tue'))  
  else:
    print('{}'.format('wed'))


### FIXED CODE ###

x=int(input())
week=["thu","fri","sat","sun","mon","tue","wed"]
print(week[x%7])
w,h,n = map(int,input().split())
b,c,d,e = 0,w,0,h
for i in range(a):
    x,y,a = map(int,input().split())
    if a == 1:
        b = max(b,x)
    elif a == 2:
        c = min(c,x)
    elif a == 3:
        d = max(d.y)
    else:
        e = min(e,y)
print(max(c-b,0)*max(e-d,0))

### FIXED CODE ###

w,h,n = map(int,input().split())
b,c,d,e = 0,w,0,h
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        b = max(b,x)
    elif a == 2:
        c = min(c,x)
    elif a == 3:
        d = max(d,y)
    else:
        e = min(e,y)
print(max(c-b,0)*max(e-d,0))
H, W = map(int, input().split())

inpt =[]
for h in H:
    i = str(input())
    inpt.append(i)

string = 'No'

for h in range(H):
    for w in range(W):
        if h == H-1 or w == W-1:
            continue
        if inpt[h][w] == '#':
            if inpt[h+1][w] == '#' or inpt[h][w+1] == '#':
                 string = 'Yes'
                 
print(string)


### FIXED CODE ###

class UnionFind:
    def __init__(self, N:int):
        """N: 大きさ
        size: 連結成分の大きさ
        """
        self.par = [i for i in range(N)]
        self.size = [1]*N
        self.rank = [1]*N
        
    def root(self, x:int)->int:
        """根を求める"""
        if self.par[x] == x: # if root
            return x
        else:
            self.par[x] = self.root(self.par[x]) # 経路圧縮
            return self.par[x]
        
    def is_same(self, x:int, y:int)->bool:
        """x と y が同じ集合に属するか否か"""
        return self.root(x)==self.root(y)
    
    def unite(self, x:int, y:int):
        """y を x の属する集合に併合"""
        root_x = self.root(x)
        root_y = self.root(y)
        if root_x == root_y: return
        if self.rank[root_x] == self.rank[root_y]:
            self.rank[root_x] += 1
        elif self.rank[root_x]<self.rank[root_y]:
            root_x,root_y = root_y,root_x
        # 短いほう(y)を長いほう(x)にくっつける
        self.par[root_y] = root_x
        self.size[root_x] += self.size[root_y]
        self.size[root_y] = 0 # もういらない
        
    def get_size(self, x:int)->int:
        """xの属するグループのサイズ"""
        return self.size[self.root(x)]

H,W = map(int, input().split())
grid = [input() for _ in range(H)]
uf = UnionFind(H*W)
for h in range(H):
    for w in range(W):
        for i,j in zip([0,0,1,-1], [1,-1,0,0]):
            if not (0 <= h+i < H and 0 <= w+j < W): 
                continue
            if grid[h][w]=="#" and grid[h+i][w+j]=="#":
                uf.unite(h*W + w, (h+i)*W + w+j) 
                
        #print([uf.root(n) for n in range(H*W)])

ans = "Yes"
for h in range(H):
    for w in range(W):
        if grid[h][w]=="#":
            if uf.get_size(h*W + w)<2:
                ans = "No"
print(ans)
n, k = map(int, input().split())
d = list(input().split())
for i in reversed(range(n, 10001)):
    for j in range(k):
        if d[j] in str(i):
            break
    else:
        ans = i
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
d = list(input().split())
ans = 100000
for i in range(n, 100001):
    for j in range(k):
        if d[j] in str(i):
            break
    else:
        if ans > i:
            ans = i
print(ans)
n, q = map(int, input().split())
n = [0]*(n+1)
maxv = winner = 0
for _ in range(q):
    a, v = map(int, input().split())
    n[a] += v
    if v < 0:
        maxv, winner = max(n), n.index(maxv)
    else:
        if n[a] > maxv:
            maxv, winner = n[a], a
        elif n[a] == maxv:
            winner = n.index(maxv)
    print(winner, maxv)

### FIXED CODE ###

n, q = map(int, input().split())
n = [0]*(n+1)
maxv = winner = 0
for _ in range(q):
    a, v = map(int, input().split())
    n[a] += v
    if v < 0 and a == winner:
        maxv = max(n)
        winner = n.index(maxv)
    elif n[a] > maxv:
            maxv, winner = n[a], a
    elif n[a] == maxv:
            winner = min(winner, a)
    print(winner, maxv)
n,x = map(int,input().split())

l = [int(x) for x in input().split()]
import sys

sys.setrecursionlimit(20000)

def solve(now,ls,x,cnt):
    if now>x:
        return print(cnt)
    else:
        return solve(now+ls[cnt],ls,x,cnt+1)
solve(0,l,x,0)

### FIXED CODE ###

n,x = map(int,input().split())

l = [int(x) for x in input().split()]

cnt = 1
now = 0
for i in l:
    now += i
    if now>x:
        break
    cnt += 1

print(cnt)
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
s=[]
n=int(input())
for i in range(2,55555):
    if is_prime(i)==True:
        if i%5==1:
            s.append(i)
print(' '.join(map(str, s[:n])))

### FIXED CODE ###

import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
s=[]
n=int(input())
for i in range(2,55555):
    if is_prime(i)==True:
        if i%5==1:
            s.append(i)
print(' '.join(map(str, s[:n])))
N = input()
print 800 * N 200 * (N // 15)


### FIXED CODE ###

N = input()
print 800 * N - 200 * (N // 15)
n=int(input())
h=list(map(int,input().split()))
count=flag=0 
for i in range(n): 
      if(h[i]>=h[i+1]):
        flag+=1
      else :
        count=flag if(flag>count) else count
        flag=0
print(count)

### FIXED CODE ###

n = int(input())
values = [float(s) for s in input().split(" ")]

start = 0
ans = 0

for i in range(1,n):
    if values[i] > values[i-1]:
        start = i
    ans = max(ans,i-start)
print(ans)
N = input()
answer_list = []
answer = 0

for i in range(len(N)):
    if N[i] == "A" or N[i] == "T" or N[i] == "C" or N[i] == "G":
        answer += 1
    else:
        answer_list.append(answer)
        answer = 0
print(max(answer_list))


### FIXED CODE ###

N = input()
answer_list = []
answer = 0

for i in range(len(N)):
  if N[i] == "A" or N[i] == "T" or N[i] == "C" or N[i] == "G":
    answer += 1
  else:
    answer_list.append(answer)
    answer = 0
  if i+1 == len(N):
    answer_list.append(answer)
print(max(answer_list))
S = input()
K = int(input())

for i, s in enumerate(S):
    if s != '1':
        f = i
        break

print (1 if K <= f+1 else S[f] )


### FIXED CODE ###

S = input()
K = int(input())

for i, s in enumerate(S):
    if s != '1':
        t = i
        break
    if i == len(S)-1:
        t = 0
print (1 if K <= t else S[t] )
from sympy import factorint

def judge(a):
    primes=factorint(a)
    if 2 in primes.keys():
        return primes[2]
    else:
        return 0

if __name__ == '__main__':
    N=int(input())
    A=list(map(int,input().split()))
    count=0
    for a in A:
        count+=judge(a)

    print(count)



    

### FIXED CODE ###


def judge(a):
    ans=0
    while a%2==0:
        a/=2
        ans+=1
    return ans

if __name__ == '__main__':
    N=int(input())
    A=list(map(int,input().split()))
    count=0
    for a in A:
        count+=judge(a)

    print(count)
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(1000000)

def solve():
    N, X = list(map(int, sys.stdin.readline().split()))

    As = [1]  # レベルiバーガーの厚さ（層の総数）
    Ps = [1]  # レベルiバーガーのパティの総数

    for i in range(N):
        As.append(As[i]*2 + 3)
        Ps.append(Ps[i]*2 + 1)


    def _dfs(depth, x):
        if depth == 0:
            return 0 if x <= 0 else 1
        elif x <= 1 + As[N-1]:
            return _dfs(N-1, x-1)
        else:
            return Ps[N-1] + 1 + _dfs(N-1, x-2-As[N-1])

    ans = _dfs(N, X)

    print(ans)

if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(10000)

"""考え方
L0 : P
L1 : BPPPB
L2 : BBPPPBPBPPPBB
L3 : BBBPPPBPBPPPBBPBBPPPBPBPPPBBB
L4 : ...

・レベルが1上がると、Pの数は2倍+1になる
・レベルが1上がると、総数は2倍+3になる


レベルiバーガーの厚さ（層の総数）をa_iとする
レベルiバーガーに含まれるパティの総数をp_iとする
「レベルNバーガーの下からX層に含まれるパティの枚数」をf(N,X)とする。

・N = 0のとき
f(0,X) = 1

・N >= 1のとき
f(N-1, Y)がわかると仮定すると、

(1) X = 1のとき、f(N,X) = 0 (一番下のバンだけ)

(2) 1 < X <= 1 + a_{i-1} のとき、f(N,X) = f(N-1, X-1)

i=2のとき、L2のときで
BBPPPB PBPPPBB
BPPPBB|ここまでのとき

(3) X = 2 + a_{i-1}のとき、f(N,X) = p_{i-1}+1
???


https://www.youtube.com/watch?v=1ONpCPN-IR8
"""
def solve():
    N, X = list(map(int, sys.stdin.readline().split()))

    As = [1]  # レベルiバーガーの厚さ（層の総数）
    Ps = [1]  # レベルiバーガーのパティの総数

    for i in range(N):
        As.append(As[i]*2 + 3)  # レベルが1上がると、総数は2倍+3になる
        Ps.append(Ps[i]*2 + 1)  # レベルが1上がると、パティの数は2倍+1になる


    def _dfs(depth, x):
        """ レベルdepthバーガーの、下からX層に含まれるパティの枚数を返す """
        if depth == 0:
            return 0 if x <= 0 else 1
        elif x <= 1 + As[depth-1]:
            # 一番下のパン + その上のレベル N-1 バーガー + その上のパティ
            return _dfs(depth-1, x-1)
        else:
            # (前略) + その上のパティ + その上のレベル N-1 バーガーの下から x-2-As[depth-1]層
            return Ps[depth-1] + 1 + _dfs(depth-1, x-2-As[depth-1])

    ans = _dfs(N, X)

    print(ans)


def solve2():
    N, X = list(map(int, sys.stdin.readline().split()))

    As = [1]  # レベルiバーガーの厚さ（層の総数）（必ず奇数）
    Ps = [1]  # レベルiバーガーのパティの総数

    for i in range(N):
        As.append(As[i]*2 + 3)  # レベルが1上がると、総数は2倍+3になる
        Ps.append(Ps[i]*2 + 1)  # レベルが1上がると、パティの数は2倍+1になる

    def f(n, x):
        """レベルnバーガーの下からx層食べたときの、食べたパティの総数"""
        if n == 0:
            return 0 if x <= 0 else 1

        median = (As[n]+1)//2

        if x < median:
            return f(n-1, x-1)
        elif x == median:
            return Ps[n-1] + 1
        elif x > median:
            return Ps[n-1] + 1 + f(n-1, x-median)

    ans = f(N, X)

    print(ans)


def solve3():
    As = [1]  # レベルiバーガーの厚さ（層の総数）（必ず奇数）
    Ps = [1]  # レベルiバーガーのパティの総数

    for i in range(N):
        As.append(As[i]*2 + 3)  # レベルが1上がると、総数は2倍+3になる
        Ps.append(Ps[i]*2 + 1)  # レベルが1上がると、パティの数は2倍+1になる

    # dpでもいけるはず？


if __name__ == "__main__":
    solve2()
a = int(input())
b = int(input())
c = a*b
d = (a*2)+(b*2)
print(c,d)

### FIXED CODE ###

a,b = [int(x) for x in input().split()]
print(a*b,(a+b)*2)
import copy
N,K = map(int,input().split())
A_list = list(map(int,input().split()))	
###########
can_see = [0]
max_building = A_list[0]
for i in range(0,N-1):
  
  if max_building < A_list[i+1]:
    can_see.append(i+1)
    max_building = A_list[i+1]

#print("can_see",can_see)
need_to_build = K-len(can_see)
#print("NTB",need_to_build)

#1つ目のタワーは足すことがないので抜かしてビット全探索。
#need_to_buildと同じフラグが立ったものだけ、Ｂｕｉｌｄして値段を検索
min_money = 100000000000000000
samebuilding_flag = False
for i in range(2**(N-1)):
  #print("roop start")
  bit_box = [0] * (N-1)
  for j in range(N-1):
    if (i>>j)&1:
      bit_box[N-1-1-j] = 1
      if N-1-j in can_see:
        #print("flag apeeard")
        samebuilding_flag = True
        
  #print(bit_box)
  if bit_box.count(1) != need_to_build:
    #print("not match")
    #print(bit_box)
    pass
    
  elif samebuilding_flag == True:
    samebuilding_flag = False
    pass
  
  else:
    #試すものがここに残る。
    #print("try parameters")
    #print(bit_box)
    building_list = copy.deepcopy(A_list)
    use_money = 0
    
    bit_box_start = bit_box.index(1)
   #print("BBS",bit_box_start)
    for _ in range(0,len(can_see))[::-1]:
      if can_see[_] < bit_box_start+1:
        highest_building = building_list[can_see[_]]
        break
    
    
    
    for k in range(0,N-1):
      if bit_box[k] == 1:
        #print("build start building No.",k+2)
        
        if highest_building >= building_list[k+1]:
          #print("make higher")
          use_money += (highest_building-building_list[k+1]+1)
          #print("use_money",use_money)
          #print(f"change {building_list[k+1]} to {highest_building+1} ")
          building_list[k+1] = highest_building+1
          highest_building = building_list[k+1]
          #print("building now",building_list)
        else:
          #print("stay")
          #print("building now",building_list)
          pass
          
    #print("use_money",use_money)
    min_money = min(min_money,use_money)
    #print("result",min_money)
    del building_list
    
print(min_money)

      
      
    

### FIXED CODE ###

def LI(): return list(map(int,input().split()))
N,K = LI()
a = LI()
ans = float('INF')
for i in range(2**(N-1)):
    bit = [i>>j&1 for j in range(N-1)]
    if K-1!=sum(bit):
        continue
    #print("bit",bit)
    cost,kijun = 0,a[0]
    for k in range(N-1):
        if bit[k]==0:
            kijun = max(kijun,a[k+1])
            continue
        if a[k+1]>=kijun+1:
            kijun = a[k+1]
            continue
        cost += (kijun+1)-a[k+1]
        kijun += 1
    ans = min(ans,cost)
print(ans)
N, M = map(int, input().split())

s = [0] * (N+1)

for i in range(M):
    ai = int(input())
    s[ai] = -1

print(s)

s[0] = 1

if N == 1:
    print(1)
else:
    if s[1] == 0:
        s[1] = 1

    for i in range(2,N+1):
        if s[i] >= 0:
            s[i] += (max(0,s[i-1]) + max(0,s[i-2]))
        print(s)

    print(s[N] % 1000000007)

### FIXED CODE ###

N, M = map(int, input().split())

s = [0] * (N+1)

for i in range(M):
    ai = int(input())
    s[ai] = -1

s[0] = 1

if N == 1:
    print(1)
else:
    if s[1] == 0:
        s[1] = 1

    for i in range(2,N+1):
        if s[i] >= 0:
            s[i] += (max(0,s[i-1]) + max(0,s[i-2]))

    print(s[N] % 1000000007)
#X匹Y本の組み合わせが存在するか判定。鶴の数を基準に連立方程式を解いて、鶴の数が正の整数であればYES
X,Y = map(int,input().split())
a = (4 * X - Y) / 2
if a.is_integer() and 0 <= a:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

nums = list(map(int, input().split()))
print(nums.index(0)+1)
# coding: utf-8
N, M = [int(x) for x in input().split(" ")]
prices = [int(x) for x in input().split(" ")]
prices.sort()
for i in range(M):
    prices[-1] //= 2
    if prices[-1] < prices[-2]:
        prices.sort()
sum = 0
for num in prices:
    sum += num
print(sum)

### FIXED CODE ###

# coding: utf-8
import heapq

N, M = [int(x) for x in input().split(" ")]

prices = [-int(x) for x in input().split(" ")]

heapq.heapify(prices)

for i in range(M):
    maxp = heapq.heappop(prices)
    heapq.heappush(prices, -((-maxp) // 2))

total = 0
for x in prices:
    total += -x

print(total)
s=input()
s_len=len(s)
print([:s_len-8])

### FIXED CODE ###

s=input()
s_len=len(s)
print(s[:s_len-8])