Harryxun/stf_run huggingface dataset:
import numpy as np

N,M = map(int,input().split())
Xlist = np.array([int(_) for _ in input().split()])
Xlist = np.sort(Xlist)
answer = 0
max_difflist = np.array([])
salist = np.array([])
ilist = np.array([])
min_n = -1

for i in range(M-1):
    sa = abs(Xlist[i]-Xlist[i+1])
    salist = np.append(salist,sa)

    if len(max_difflist)+1 < N:
        ilist = np.append(ilist,i)
        max_difflist = np.append(max_difflist,sa)

    elif sa > min_n:
        max_difflist = np.sort(max_difflist)[::-1]
        index = np.where(max_difflist == min_n)[0]
        max_difflist[index] = sa
        ilist[index] = i
    min_n = np.min(max_difflist)

for i_ in ilist:
    salist[int(i_)] = 0

print(int(sum(salist)))


### FIXED CODE ###

N, M = map(int, input().split())
Xlist = sorted(list(map(int, input().split())))
Llist = []
for i in range(M - 1):
    Llist.append(Xlist[i + 1] - Xlist[i])
Llist.sort()
print(sum(Llist[:M - N]) if N < M else 0)
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(lambda x : int(x) - 1, input().split())
Dh, Dw = map(lambda x : int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10**12

#各マスへの移動コスト
path = [[INF] * W for _ in range(H)]

#walk:移動A　warp:移動B
walk = [(0, 1), (0, 1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0,0) + walk]]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q : 
    x, y, s = q.popleft()
    #移動A
    for dx, dy in walk :
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            #移動Aの場合はコスト0, キューの先頭に追加する
            q.appendleft((nx, ny, s))
    #移動B
    for dx, dy in warp : 
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            #移動Bの場合はコスト1, キューの最後尾に追加
            q.appendleft((nx, ny, s+1))
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10 ** 12
path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト

walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:  # 移動A
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
    for dx, dy in warp:  # 移動B
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)
N = int(input())
A_list = list(map(int, input().split()))
ans_list = [0] * (N + 1)
for i in range(N-1):
    ans_list[A_list[i]] += 1
for j in range(N+1):
    print(ans_list[j + 1])


### FIXED CODE ###

N = int(input())
A_list = list(map(int, input().split()))
ans_list = [0] * (N + 1)
for i in range(N-1):
    ans_list[A_list[i]] += 1
for j in range(N):
    print(ans_list[j + 1])
n = int(input())
list = map(int,input().split())

list.sort()

answer = list[-1] - list[0]

print(answer)

### FIXED CODE ###

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

x.sort()

answer = x[-1] - x[0]

print(answer)
S = input()
print(min(len(re.findall('0', S)), len(re.findall('1', S))) * 2 if len(S) > 1 else 0)

### FIXED CODE ###

S = input()
import re
if len(S) > 1:
    print(min(len(re.findall('0', S)), len(re.findall('1', S))) * 2)
else:
    print(0)
import numpy
while True:
    try:
        a,b,c,d,e,f = (int(i) for i in input().split())
        x,y = [numpy.dot(numpy.linalg.inv(numpy.array([[a,b],[d,e]])),numpy.array([c,f]))[0],numpy.dot(numpy.linalg.inv(numpy.array([[a,b],[d,e]])),numpy.array([c,f]))[1]]
        print("{0:.3f} {1:.3f}".format(x,y))
    except EOFError:
        break

### FIXED CODE ###

while True:
    try:
        a,b,c,d,e,f = (int(i) for i in input().split())
        det=a*e-b*d
        x = (c*e-b*f)/det
        y = (a*f-c*d)/det
        if x==0:x=0
        if y==0:y=0
        print("{0:.3f} {1:.3f}".format(x,y))
    except EOFError:
        break
n = int(input())
memo = [{} for i in range(n+1)]
m = 10**9+7

def ppp(l):
    for i in range(4):
        t = list(l)
        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(c,l):
    if l in memo[c]:
        return memo[c][l]
    if c == n:
        return 1
    ret = 0
    for b in "AGCT":
        if ppp(l+b):
            ret = (ret + dfs(c + 1,l[1:] + c)) % m
    memo[c][l] = ret
    return ret
print(dfs(0,"TTT"))

### FIXED CODE ###

n = int(input())
memo = [{} for i in range(n+1)]
m = 10**9+7

def ppp(l):
    for i in range(4):
        t = list(l)
        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(c,l):
    if l in memo[c]:
        return memo[c][l]
    if c == n:
        return 1
    ret = 0
    for b in "AGCT":
        if ppp(l+b):
            ret = (ret + dfs(c + 1,l[1:] + b)) % m
    memo[c][l] = ret
    return ret
print(dfs(0,"TTT"))
N,D=map(int,input().split())
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split())
    X.append(x)
    Y.append(y)
ans=0    
for i in range(N):
    if X[i]**2+Y[i]**2 <= D**2:
    ans += 1

print(ans)


### FIXED CODE ###

N,D=map(int,input().split())
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split())
    X.append(x)
    Y.append(y)
ans=0    
for i in range(N):
    if X[i]**2+Y[i]**2 <= D**2:
        ans += 1

print(ans)
import math
A, B, H, M =map(int, input().split())
Hs = H*30 + M/2
Ms = 6*M
shita = Hs-Ms
print (shita)
shita = abs(shita)
if  shita >= 180:
    shita = shita - 180
shita = math.radians(shita)
C = A*A + B*B - 2*A*B*(math.cos(shita))
print (math.sqrt(C))

### FIXED CODE ###

N = int(input())
N = N % 10
if N in (2, 4, 5, 7, 9):
    print ("hon")
elif N in (0, 1, 6, 8):
    print ("pon")
elif N == 3:
    print ("bon")
while True:
        a,op,b=input().split()
        a=int(a)
        b=int(b)
        op=str(op        
        if op=("+"):
                print(a+b)
        elif op=("-"):
                print(a-b)
        elif op=("*"):
                print(a*b)
        elif op=("/"):
                print(a/b)
        elif op=("?"):
                break

~                                         


### FIXED CODE ###



while 1:
     s=input()
     if '?' in s: break
     print(int(eval(s)))
N = int(input())
if N == 2:
	A = int(input())
  	B = int(input())
    print(A+B)
else:
  	print('Hello World')

### FIXED CODE ###

N = int(input())
if N == 2:
  A = int(input())
  B = int(input())
  print(A + B)
elif N == 1:
  print('Hello World')
from fractions import gcd

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

ans = (a * b) // gcd(a, b)

if ans == N or ans == M:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

from fractions import gcd

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

lcm = (N * M) // gcd(N, M)
gcd = gcd(N, M)

for i in range(gcd):
    if S[i * N // gcd] != T[i * M // gcd]:
        print(-1)
        exit()

print(lcm)
x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
    pirnt('A')
else:
    print('B')


### FIXED CODE ###

x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
    print('A')
else:
    print('B')
X, H, x, y = map(int, input().split())
S = X * H
max_small = S / 2

print(max_small, end=' ')
if x == w/2 and y == H/2:
    print('1')
else:
    print('0')

### FIXED CODE ###

X, H, x, y = map(int, input().split())
S = X * H
max_small = S / 2

print(max_small, end=' ')

if x == (X/2) and y == (H/2):
    print('1')
else:
    print('0')
s, w = input()
s = int(s)
w = int(w)

if s > w :
  print('safe')
else:
  pritn('unsafe')

### FIXED CODE ###

s, w = input().split(' ')
s = int(s)
w = int(w)
 
if s > w :
  print('safe')
else:
  print('unsafe')
a =input()
b =input()
c =input()
d =input()

if a >= c and a <= d or b >= c and b <= d:
  print("Yes")
else:
  print("No")




### FIXED CODE ###

n = int(input())
s = "ACL"
print(s*n)
N, A = input(), input()

if N % 500 < A:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N, A = int(input()), int(input())

if N % 500 <= A:
    print("Yes")
else:
    print("No")
a = list(int(input().split()))
print(sorted(a)[-1] + sorted(a)[-2])


### FIXED CODE ###

a = list(map(int,input().split()))
print(sorted(a)[0] + sorted(a)[1])
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    def dfs(x):
        ans[x] = bisect_left(dp, a[x])
        for e in edg[x]:
            if d[e]:
                d[e] = 0
                i = bisect_left(dp, a[e])
                p = dp[i]
                dp[i] = a[e]
                dfs(e)
                dp[i] = p
    n = II()
    a = LI()
    dp = [0] * n
    edg = [[] for i in range(n)]
    for _ in range(n - 1):
        u, v = LI_()
        edg[u].append(v)
        edg[v].append(u)
    d = [1] * n
    ans = [1] * n
    dfs(0)
    for a in ans:
        print(a)
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    def dfs(x):
        ans[x] = bisect_left(dp, inf)
        for e in edg[x]:
            if d[e]:
                d[e] = 0
                i = bisect_left(dp, a[e])
                p = dp[i]
                dp[i] = a[e]
                dfs(e)
                dp[i] = p
    n = II()
    a = LI()
    dp = [inf] * n
    edg = [[] for i in range(n)]
    for _ in range(n - 1):
        u, v = LI_()
        edg[u].append(v)
        edg[v].append(u)
    d = [1] * n
    ans = [1] * n
    d[0] = 0
    dp[0] = a[0]
    dfs(0)
    for a in ans:
        print(a)
    return


#main
if __name__ == '__main__':
    solve()
import collections,itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
s = [S() for _ in range(H)]
black_count = 0
for i,j in itertools.product(range(H),range(W)):
    if s[i][j]=='#':
        black_count += 1
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
min_dist = [[-1]*W for _ in range(H)]
seen = [[0]*W for _ in range(H)]
queue = collections.deque() #位置[行,列]を入れておく
def bfs():
    seen[0][0] = 1
    queue.append([0,0])
    min_dist[0][0] = 1
    while queue:
        qh,qw = queue.popleft()
        for dh,dw in dhdw:
            nh,nw = qh+dh,qw+dw
            if not(0<=nh<=H-1) or not(0<=nw<=W-1) or seen[nh][nw] or s[nh][nw]=='#':
                continue
            if [nh,nw]==[H-1][W-1]:
                return min_dist[qh][qw]+1
            seen[nh][nw] = 1
            queue.append([nh,nw])
            min_dist[nh][nw] = min_dist[qh][qw]+1
    else:
        return -1
min_dist = dfs()
print(H*W-black_count-min_dist if min_dist!=-1 else -1)


### FIXED CODE ###

import collections,itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
s = [S() for _ in range(H)]
black_count = 0
for i,j in itertools.product(range(H),range(W)):
    if s[i][j]=='#':
        black_count += 1
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
min_dist = [[-1]*W for _ in range(H)]
seen = [[0]*W for _ in range(H)]
queue = collections.deque() #位置[行,列]を入れておく
def bfs():
    seen[0][0] = 1
    queue.append([0,0])
    min_dist[0][0] = 1
    while queue:
        qh,qw = queue.popleft()
        for dh,dw in dhdw:
            nh,nw = qh+dh,qw+dw
            if not(0<=nh<=H-1) or not(0<=nw<=W-1) or seen[nh][nw] or s[nh][nw]=='#':
                continue
            seen[nh][nw] = 1
            queue.append([nh,nw])
            min_dist[nh][nw] = min_dist[qh][qw]+1
bfs()
if min_dist[H-1][W-1]!=-1:
    print(H*W-black_count-min_dist[H-1][W-1])
else:
    print(-1)
N=int(input())
A=sorted(list(map(int,input().split())))
ans=1
if 0 in A:
    print(0)
    return
for i in range(N):
    ans*=A[i]
    if ans>=10**18:
        print(-1)
        break
else:print(ans)

### FIXED CODE ###

def main():
    N=int(input())
    A=sorted(list(map(int,input().split())))
    ans=1
    if 0 in A:
        print(0)
        return
    for i in range(N):
        ans*=A[i]
        if ans>10**18:
            print(-1)
            return
    print(ans)
main()
import sys
n = sys.stdin.readline()
t = 0
for i in range(N):
  if i%3 != 0 or i%5 != 0:
    t += i
print(t)


### FIXED CODE ###

import sys
n = int(sys.stdin.readline())
t = 0
for i in range(n+1):
  if i%3 != 0 and i%5 != 0:
    t += i
print(t)
import sys
input = sys.stdin.readline
import itertools

N, M, X = map(int, input().split())
values_list = []
for i in range(N):
    values = list(map(int, input().split()))
    values_list.append(values)


for i in range(1, N+1):
    for pair in itertools.combinations(values_list, i):
        this_m_dict = {}
        this_cost = 0
        for item in pair:
            for j in range(1, M+1):
                this_m_dict[j] = this_m_dict.get(j, 0) + item[j]
            this_cost += item[0]
        for myvalue in this_m_dict.values():
            if myvalue < X:
                break
        ans = min(this_cost, ans)

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import itertools

# 解けなかった
# N, M, X = map(int, input().split())
# values_list = []
# for i in range(N):
#     values = list(map(int, input().split()))
#     values_list.append(values)

# ans = 0
# for i in range(1, N+1):
#     for pair in itertools.combinations(values_list, i):
#         this_m_dict = {}
#         this_cost = 0
#         for item in pair:
#             for j in range(1, M+1):
#                 this_m_dict[j] = this_m_dict.get(j, 0) + item[j]
#             this_cost += item[0]
#         for myvalue in this_m_dict.values():
#             if myvalue < X:
#                 break
#         ans = min(this_cost, ans)

N, M, X = map(int, input().split())
A = []
C = []

for i in range(N):
    values = list(map(int, input().split()))
    C.append(values[0])
    A.append(values[1:])

INF = float('INF')
min_cost = INF

def dfs(i, cost, learn):
    if i == N:
        if min(learn) >= X: 
            return cost
        else:
            return INF

    else:
        new_learn = [(x+y) for (x, y) in zip(A[i], learn)]
        cost = min(dfs(i+1, cost, learn), dfs(i+1, cost + C[i], new_learn))
        return cost

min_cost = dfs(0, 0, [0] * M)

if min_cost == INF:
    print(-1)
else:
    print(min_cost)
n = int(input())
d, x = map(int, input().split())
a = []
for i in range(n):
    a.appned(int(input())
s = 0
for i in range(d):
    for j in range(n):
        if i % a[j] == 1:
            s +=1
print(s+x)

### FIXED CODE ###

n = int(input())
d, x = map(int, input().split())
a = []
s = 0

for i in range(n):
    a.append(int(input()))

for i in range(1, d + 1):
    for j in range(n):
        if i % a[j] == 1 or a[j] == 1:
            s += 1
print(s + x)
a = int(input())
s = str(input())

if a>=3200:
  print("s")
  else :
    print("'red'")

### FIXED CODE ###

a = int(input())
s = input()

if a>=3200:
	print(s)
else :
	print("red")
h, w = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(h)]

count = 0
ans = []
for i in range(0, h-1, 2):
    for j in range(w):
        if lst[i][j] % 2 == 1:
            count += 1
            if j == w-1:
                lst[i+1][j] += 1
                ans.append((i+1, j+1, i+2, j+1))
            else:
                lst[i][j+1] += 1
                ans.append((i+1, j+1, i+1, j+2))
    for j in reversed(range(w)):
        if lst[i+1][j] % 2 == 1:
            if j == 0 and i == h-1:
                pass
            elif j == 0:
                lst[i+2][j] += 1
                ans.append((i+2, j+1, i+3, j+1))
                count += 1
            else:
                lst[i+1][j-1] += 1
                ans.append((i+2, j+1, i+2, j))
                count += 1
if h % 2 == 1:
    for j in range(w):
        if lst[-1][j] % 2 == 1:
            if j == w-1:
                pass
            else:
                lst[-1][j+1] += 1
                ans.append((h, j+1, h, j+2))
                count += 1
                
print(count)
for a,b,c,d in ans:
    print(a,b,c,d)

### FIXED CODE ###

h, w = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(h)]

count = 0
ans = []
for i in range(0, h-1, 2):
    for j in range(w):
        if lst[i][j] % 2 == 1:
            count += 1
            if j == w-1:
                lst[i+1][j] += 1
                ans.append((i+1, j+1, i+2, j+1))
            else:
                lst[i][j+1] += 1
                ans.append((i+1, j+1, i+1, j+2))
    for j in reversed(range(w)):
        if lst[i+1][j] % 2 == 1:
            if j == 0 and i+1 == h-1:
                pass
            elif j == 0:
                lst[i+2][j] += 1
                ans.append((i+2, j+1, i+3, j+1))
                count += 1
            else:
                lst[i+1][j-1] += 1
                ans.append((i+2, j+1, i+2, j))
                count += 1
if h % 2 == 1:
    for j in range(w):
        if lst[-1][j] % 2 == 1:
            if j == w-1:
                pass
            else:
                lst[-1][j+1] += 1
                ans.append((h, j+1, h, j+2))
                count += 1
                
print(count)
for a,b,c,d in ans:
    print(a,b,c,d)
N,K=map(int,input().split())
S=input()

#K=0
#S="1111111"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0
f=0
if(LIST[0][1]=="1"):
    s+=LIST[0][0]
    l=0
    r=1
    f=1
MAX=0

while(K>0 and N>r ):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        break
    r+=1
MAX=max(s,MAX)

if f==1:
    while(r<len(LIST)):
        if(l<len(LIST)):
            s-=LIST[l][0]
            l+=1
        if(l<len(LIST)):
            s-=LIST[l][0]
            l+=1

        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
else:
    s-=LIST[l][0]
    l+=1

    s+=LIST[r][0]
    MAX=max(s,MAX)
    if(len(LIST)-1==r):
        print(MAX)
        exit()
    r+=1
    s+=LIST[r][0]
    MAX=max(s,MAX)
    if(len(LIST)-1==r):
        print(MAX)
        exit()
    r+=1
    while(r<len(LIST)):
        s-=LIST[l][0]
        l+=1
        s-=LIST[l][0]
        l+=1

        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1

print(MAX)


### FIXED CODE ###

N,K=map(int,input().split())
S=input()

#K=1
#S="01100"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0

if(LIST[r][1]=="1"):
    s+=LIST[r][0]
    r+=1
x=0
while(K>0 and len(LIST)>r):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        x=1
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        x=1
        break
    r+=1

MAX=max(s,MAX)

f=0
if(x==0):
    while(r<len(LIST)):
        if(l< len(LIST)-1):
            s-=LIST[l][0]
            l+=1
            f=1
        if(l<len(LIST)-1 and LIST[l][1]=="0"):
            s-=LIST[l][0]
            l+=1

        if(f==0):
            break
        

        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break
        
        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break

print(MAX)
#Nはノード数、Mはエッジ数
n,m = map(int, input().split())

ab = [list(map(int, input().split())) for i in range(m)]

cnt=0

for x in ab:
  ls=list(range(n))
  for y in ab:
    if y !=x:
      for i in range(n)
        ls=[ls[y[0]-1] if ls[i]==ls[y[1]-1] else ls[i] for i in range(n)] #bの値を根っこ（低い方a）にする
  if len(set(ls)) !=1:
    cnt+=1

print(cnt)

### FIXED CODE ###

#Nはノード数、Mはエッジ数
n,m = map(int, input().split())

ab = [list(map(int, input().split())) for i in range(m)]

cnt=0

for x in ab:
  ls=list(range(n))
  for y in ab:
    if y !=x:
      for i in range(n):
        ls=[ls[y[0]-1] if ls[i]==ls[y[1]-1] else ls[i] for i in range(n)] #bの値を根っこ（低い方a）にする
  if len(set(ls)) !=1:
    cnt+=1

print(cnt)
"""
N段の階段 M個の階段が壊れている
"""

N, M = map(int, input().split())
arr = [int(input()) for _ in range(M)]
no_step =[0]*N

for i in range(M):
    no_step[arr[i]-1]=1

count = [0]*N
if no_step[0]==0:
    count[0]=1

if no_step[1]==1:
    count[1]=0
elif no_step[0]==0 and no_step[1]==0:
    count[1]=2
elif no_step[0]==1 and no_step[1]==0:
    count[1]=1

for i in range(3,N+1,1):
    count[i-1] = count[i-2]+count[i-3]
    if no_step[i-1] == 1:
        count[i-1] = 0

ans =count[N-1]%1000000007
print(ans)

### FIXED CODE ###

"""
N段の階段 M個の階段が壊れている
"""

N, M = map(int, input().split())
arr = [int(input()) for _ in range(M)]
no_step =[0]*N

if N==1:
    print(1)
    exit()

for i in range(M):
    no_step[arr[i]-1]=1

count = [0]*N
if no_step[0]==0:
    count[0]=1

if no_step[1]==1:
    count[1]=0
elif no_step[0]==0 and no_step[1]==0:
    count[1]=2
elif no_step[0]==1 and no_step[1]==0:
    count[1]=1

for i in range(3,N+1,1):
    count[i-1] = count[i-2]+count[i-3]
    if no_step[i-1] == 1:
        count[i-1] = 0

ans =count[N-1]%1000000007
print(ans)
N, K = map(int, input().split())

if N < K:
    print(N)
else:
    a = N % K
    b = abs(a-k)
    if a<b:
      print(a)
    else:
      print(b)
      


### FIXED CODE ###

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

a = N % K
b = abs(a-K)
if a<b:
    print(a)
else:
    print(b)
n = int(input())
if n%2 = 0:
  answer = n/2-1
else:
  answer = (n-1)/2
print(answer)

### FIXED CODE ###

n = int(input())
if n%2 == 0:
  ans = int(n/2 - 1)
else:
  ans = int((n-1)/2)
print(ans)