Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

H, W = map(int, input().split())
S = [None] * H
for i in range(H):
    S[i] = input()

up = [[0 for w in range(W)] for h in range(H)]
down = [[0 for w in range(W)] for h in range(H)]
left = [[0 for w in range(W)] for h in range(H)]
right = [[0 for w in range(W)] for h in range(H)]

# up and left
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            up[h][w] = 0
            left[h][w] = 0
        else:
            # up
            if h == 0:
                up[h][w] = 1
            else:
                up[h][w] = up[h - 1][w] + 1
            # left
            if w == 0:
                left[h][w] = 1
            else:
                left[h][w] = left[h][w - 1] + 1

# down and right
for h in reversed(range(H)):
    for w in reversed(range(W)):
        if S[h][w] == "#":
            down[h][w] = 0
            right[h][w] = 0
        else:
            # down
            if h == H - 1:
                down[h][w] = 1
            else:
                down[h][w] = down[h + 1][w] + 1
            # right
            if w == W - 1:
                right[h][w] = 1
            else:
                right[h][w] = right[h][w + 1] + 1


ans = 0
for h in range(H):
    for w in range(W):
        masu = -3
        masu += up[h][w]
        masu += down[h][w]
        masu += left[h][w]
        masu += right[h][w]
        if masu > ans:
            ans = masu

print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
S = [None] * H
for i in range(H):
    S[i] = input()

up = [[0 for w in range(W)] for h in range(H)]
down = [[0 for w in range(W)] for h in range(H)]
left = [[0 for w in range(W)] for h in range(H)]
right = [[0 for w in range(W)] for h in range(H)]

# up and left
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            up[h][w] = 0
            left[h][w] = 0
        else:
            # up
            if h == 0:
                up[h][w] = 1
            else:
                up[h][w] = up[h - 1][w] + 1
            # left
            if w == 0:
                left[h][w] = 1
            else:
                left[h][w] = left[h][w - 1] + 1

# down and right
for h in reversed(range(H)):
    for w in reversed(range(W)):
        if S[h][w] == "#":
            down[h][w] = 0
            right[h][w] = 0
        else:
            # down
            if h == H - 1:
                down[h][w] = 1
            else:
                down[h][w] = down[h + 1][w] + 1
            # right
            if w == W - 1:
                right[h][w] = 1
            else:
                right[h][w] = right[h][w + 1] + 1


ans = 0
for h in range(H):
    for w in range(W):
        masu = -3
        masu += up[h][w]
        masu += down[h][w]
        masu += left[h][w]
        masu += right[h][w]
        if masu > ans:
            ans = masu

print(ans)
### BUGGY CODE ###

N,K = (int(x) for x in input().split())
S = list(input())
size = [1]
memo = [S[0],0]
for i in range(1,N):
    if S[i] == memo[0]:
        size[memo[1]] += 1
    else:
        memo = [S[i],memo[1]+1]
        size += [1]

if S[0] == '0':
    size = [0] + size
if S[-1] == '0':
    size += [0]

if int((len(size)-1)/2) <= K:
    print(N)
else:
    ans = 0
    for i in range(len(size)-(K*2))[::2]:
        a = sum(size[i:i+K*2+1])
        if ans < a:
            ans = a
    print(ans)


### FIXED CODE ###

N,K = (int(x) for x in input().split())
S = list(input())
size = [1]
memo = S[0]
for i in range(1,N):
    if S[i] == memo:
        size[-1] += 1
    else:
        memo = S[i]
        size += [1]

if S[0] == '0':
    size = [0] + size
if S[-1] == '0':
    size += [0]

if int((len(size)-1)/2) <= K:
    print(N)
else:
    ans = sum(size[0:K*2+1])
    a = ans
    for i in range(2,len(size)-(K*2))[::2]:
        a = a - (size[i-2] + size[i-1]) + (size[i+K*2-1] + size[i+K*2])
        if ans < a:
            ans = a
    print(ans)
### BUGGY CODE ###

n, K = map(int, input().split())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i - k >= 0:
            kouho = dp[i-k] + abs(h[i] - h[i-k])
            dp[i] = min(kouho, dp[i])
        else:
            break
print(dp[-1])

### FIXED CODE ###

n, K = map(int, input().split())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i - k >= 0:
            kouho = dp[i-k] + abs(h[i] - h[i-k])
            dp[i] = min(kouho, dp[i])
        else:
            break
print(dp[-1])
### BUGGY CODE ###

S=input()[::-1]
l=[0]*2019
a=1
d=0

for s in S:
  d=d+int(s)*a
  l[d%2019]+=1
  a*=10
  
ans=l[0]
for i in l:
  if i>=2:
    ans+=i*(i-1)//2
    
print(ans)

### FIXED CODE ###

S=input()[::-1]
l=[0]*2019
a=1
d=0

for s in S:
  d=d+int(s)*a
  l[d%2019]+=1
  a*=10
  a%=2019
  
ans=l[0]
for i in l:
  if i>=2:
    ans+=i*(i-1)//2
    
print(ans)
### BUGGY CODE ###

N, A, B = map(int, input().split())
a = 0
b = 0
C = 0
while N > 0:
    C = N
    N = N - A
    if N > 0:
        a = a + A
    else:
        a = a + C
    N = N - B
print(a)

### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
### BUGGY CODE ###

# coding: utf-8
import sys
sysread = sys.stdin.readline
read = sys.stdin.read
from heapq import heappop, heappush
sys.setrecursionlimit(10**7)
def run():
    N, M = map(int, sysread().split())
    to = [[] for _ in range(N+1)]
    AB = list(map(int, read().split()))
    A = AB[::2]
    B = AB[1::2]
    for a,b in zip(A,B):
        to[a].append(b)
        to[b].append(a)

    seen = [False] * (N+1)
    stack = []
    seen[1] = True
    heappush(stack, (0, 1, 0))# (distance, node, prev)
    mark = [0] * (N+1)
    done = [False] * (N+1)

    while stack:
        dist, current, prev = heappop(stack)
        seen[current] = True
        if not done[current]:
            done[current] = True
            mark[current] = prev
        for next in to[current]:
            if not seen[next]:
                heappush(stack, (dist+1, next, current))

    print('Yes')
    mark = [str(val) for val in mark]
    print('\n'.join(mark[2:]))

if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product#accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
from collections import deque
def run():
    N, M = map(int, sysread().split())
    to = [[] for _ in range(N+1)]
    AB = list(map(int, read().split()))
    A = AB[::2]
    B = AB[1::2]
    for a,b in zip(A,B):
        to[a].append(b)
        to[b].append(a)

    seen = [False] * (N+1)
    queue = deque([])
    seen[1] = True
    queue.append((1, 0))# (node, prev)
    mark = [0] * (N+1)

    while queue:
        current, prev = queue.popleft()
        for next in to[current]:
            if not seen[next]:
                queue.append((next, current))
                mark[next] = current
                seen[next] = True

    print('Yes')
    mark = [str(val) for val in mark]
    print('\n'.join(mark[2:]))

if __name__ == "__main__":
    run()
### BUGGY CODE ###

def euqlid(x,y):
    if x < y:
        tmp = x
        x  = y
        y = tmp
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
k = euqlid(a, b)
data = set([1])
i = 2
while k > 1:
    while k % i == 0:
        k = k // i
        data.add(i)
    i += 1
print(len(data))

### FIXED CODE ###

import math
def euqlid(x,y):
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
if a < b:
    tmp = a
    a = b
    b = tmp
k = euqlid(a, b)
sum = 0
i = 2
if k == 1:
    print(1)
    exit()
while i <= math.sqrt(k):
    flag = False
    while k % i == 0:
        k = k // i
        flag = True
    if flag:
        sum += 1
    i += 1
if i <= k:
    sum += 1
print(sum + 1)
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [10**18] * n
dp[0] = 0

for i in range(1, n):
    if i <= k:
        tmp = 10**18
        for j in range(1, i+1):
            tmp = min(tmp, abs(h[i] - h[i-j]) + dp[i-j])
        dp[i] = tmp
    else:
        tmp = 10**18
        for v in range(1, k+1):
            tmp = min(tmp, abs(h[i] - h[i-v]) + dp[i-v])
        dp[i] = tmp
            
print(dp[-1])

### FIXED CODE ###

n,k = map(int,input().split())
li = [int(x) for x in input().split()]

dp = [10**8] * n

for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i < k-1:
        temp = []
        for j in range(i):
            s = abs(li[i] - li[i-j-1]) + dp[i-j-1]
            temp.append(s)
        else:
            dp[i] = min(temp)
    elif i >= k-1:
        temp = []
        for j in range(k):
            s = abs(li[i] - li[i-j-1]) + dp[i-j-1]
            temp.append(s)
        else:
            dp[i] = min(temp)
            
print(dp[-1])
### BUGGY CODE ###

n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]

for card_set in BC:
    for j in range(card_set[0]):
        A.append(card_set[1])

A = sorted(A, reverse=True)
result = []
for i in range(n):
    result.append(A[i])
print(sum(result))

### FIXED CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

maxi = n*2
extend = A.extend
[extend([ls[1]] * ls[0]) for ls in BC if len(A) <= maxi]
A.sort(reverse=True)

print(sum(A[:n]))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    e = list(map(int, input().split()))
    e.sort()
    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            for k in range(j + 1, n):
                if e[i] + e[j] > e[k]: ans += 1
    print(ans)

main()


### FIXED CODE ###

import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    ll = list(map(int, input().split()))
    ll.sort()
    ans = 0
    for j, l1 in enumerate(ll[:-1]):
        for i, l0 in enumerate(ll[:j]):
            ans += bisect_left(ll, l0 + l1) - (j + 1)
    print(ans)

main()
### BUGGY CODE ###

import math

num=int(input())
target=list(map(int, input().split()))
def comb(N, r):
    return math.factorial(N) // (math.factorial(N - r) * math.factorial(r))

for i in range(num):
    A=target.copy()
    A.pop(i)
    out=0
    for j in set(A):
        try :
            base = comb(A.count(j),2)
        except:
            base=0
        out=out+base
    print(out)

### FIXED CODE ###

import collections
n = int(input())
arr = list(map(int, input().split()))
cnt = collections.Counter(arr)
total = 0
for i in cnt.keys():
  patern = cnt[i]*(cnt[i]-1)//2
  total += patern
for j in range(n):
  tmp = total
  total -= cnt[arr[j]]*(cnt[arr[j]]-1)//2
  total += (cnt[arr[j]]-1)*(cnt[arr[j]]-2)//2
  print(total)
  total = tmp
### BUGGY CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline


def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return table


def main():
    A, B = map(int, input().split())

    P = sieve(gcd(A, B))
    ans = 0
    for p in P:
        if A%p==0 and B%p==0:
            ans += 1
    
    print(ans + 1)
    

 
if __name__ == '__main__':
    main()


### FIXED CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def main():
    A, B = map(int, input().split())

    P = set(prime_decomposition(gcd(A, B)))
    
    print(len(P) + 1)
    

 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

a, b, k = map(int, input().split())

for i in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
print(a, b)


### FIXED CODE ###

a, b, k = map(int, input().split())
c = a
if k >= 1:
    if a >= k:
        a -= k
    elif a < k:
        a = 0
        k -= c
        if b >= k:
            b -= k
        elif b < k:
            b = 0

print(a, b)
### BUGGY CODE ###

s = input()
n = int(input())

# for t in try_list:
#     if t[0] == '1':
#         s = ''.join(list(reversed(s)))
#     if t[0] == '2':
#         if t[1] == '1':
#             s = t[2] + s
#         else:
#             s = s + t[2]

# 反転の処理に時間がかかる

head = 0
for i in range(n):
    t = input().split()
    # 先頭
    if t[0] == '1':
        # 末尾
        head += 1
    else:
        if (head + int(t[1])) % 2 == 1:
            s = t[2] + s
        else:
            s = s + t[2]
if head % 2 == 0:
    print(s)
else:
    print(''.join(list(reversed(s))))

### FIXED CODE ###

s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)
### BUGGY CODE ###

import numpy as np
def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    BC = [list(map(int, input().split())) for _ in range(Q)]


    Adict = dict()
    for a in A:
        Adict[a] = Adict.get(a, 0) + 1
    
    for b, c in BC:
        if b in Adict:
            tmp = Adict[b]
            Adict[c] = Adict.get(c, 0) + tmp
            Adict.pop(b)
        
        goukei = sum([k*v for k, v in Adict.items()])
        
        print(goukei)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def resolver(N, A, Q, BC):
    total = sum(A)
    counter = dict()
    ans = []
    for a in A:
        counter[a] = counter.get(a, 0) + 1
    
    for (b, c) in BC:
        c0 = counter.pop(b) if b in counter else 0
        counter[c] = counter.get(c, 0) + c0
        total -= c0 * b
        total += c0 * c
        ans.append(total)
    
    return ans

def test():
    pass

def main():

    #test()

    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    BC = []
    for _ in range(Q):
        bc = list(map(int, input().split()))
        BC.append(bc)

    ans = resolver(N, A, Q, BC)

    for a in ans:
        print(a)



if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    K = I()

    # メソッドのみ版
    def search(s):
        d = collections.defaultdict(lambda: inf)
        q = [(1,s)]
        qi = 0
        v = [False] * (K+1)
        v[s] = True
        while len(q):
            k, u = q[0]
            q = q[1:]
            t = u*10 % K
            while not v[t]:
                if t == 0:
                    return k
                q.insert(0, (k, t))
                v[t] = True
                t = t*10 % K

            i = 1
            t = (u+i) % K
            while not v[t]:
                if t == 0:
                    return k+1
                q.append((k+1, t))
                v[t] = True
                i = i*10 % K
                t = (u+i) % K

    return search(1)

print(main())




### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    K = I()

    # メソッドのみ版
    def search(s):
        d = collections.defaultdict(lambda: inf)
        q = [(1,s)]
        d[s] = 1
        qi = 0
        v = [False] * (K+1)
        v[s] = True
        while len(q):
            k, u = heapq.heappop(q)
            if u == 0:
                return k
            t = u*10 % K
            v[u] = True
            while not v[t]:
                if t == 0:
                    return k
                if d[t] > k:
                    heapq.heappush(q, (k, t))
                    d[t] = k
                v[t] = True
                t = t*10 % K

            i = 1
            t = (u+i) % K
            while not v[t] and t != u:
                if d[t] > k+1:
                    heapq.heappush(q, (k+1, t))
                    d[t] = k+1
                    i = i*10 % K
                    t = (u+i) % K
                else:
                    break

    return search(1)

print(main())
### BUGGY CODE ###

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**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
MOD = 10**9+7
n = K%N
ans = 0
for i in range(N-K,N+1):
  m = cmb(N,i,MOD)
  m *= cmb(N-1,i-1, MOD)
  ans += m
  ans %= MOD
print(ans)

### FIXED CODE ###

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**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
MOD = 10**9+7
n = min(N,K)
ans = 0
for i in range(max(1,N-n),N+1):
  m = cmb(N,i,MOD)
  m *= cmb(N-1,i-1, MOD)
  ans += m
  ans %= MOD
print(ans)
### BUGGY CODE ###

import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a, b, k = inintm()

cnt = 0
ans = []
for i in range(a,b+1):
    cnt += 1
    if cnt <= k:
        if i not in ans:
            ans.append(i)

cnt = 0
for i in range(a,b+1)[::-1]:
    cnt += 1
    if cnt <= k:
        if i not in ans:
            ans.append(i)

ans = sorted(ans)

for i in ans:
    print(i)

### FIXED CODE ###

import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a, b, k = inintm()

for i in range(a,min(b, a+k-1)+1):
    print(i)
for i in range(max(a+k, b-k+1), b+1):
    print(i)
### BUGGY CODE ###

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

n,m=[int(i) for i in input().split()]
a1=[int(input()) for i in range(m)]
a1.append(n+1)
c1=1
a2=0
for i in range(m+1):
    a3=a1[i]-1-a2
    a4=a3//2
    c2=0
    c3=1
    for j in range(0,a4+1):
        c3=combinations_count(a3-j,j)
        c2+=c3
        #print(c3)
    #print(c2)
    c1=c1*c2%(1000000007)
    a2=a1[i]+1
    if c1==0:
        break



print(c1)


### FIXED CODE ###

#フィボナッチ数列か…
#c問題も解けないのか…
#典型問題なんだろうな
#踏めない段の分は除いて考えれば良い
n,m=input().split()
n,m=int(n),int(m)
ax=[1]*(n+1)
for i in range(m):
    ax[int(input())]=0
bx=[1,1]
for i in range(2,n+1):
    if ax[i-1]==1:
        f1=bx[i-1]
    else:
        f1=0
    if ax[i-2]==1:
        f2=bx[i-2]
    else:
        f2=0
    bx.append((f1+f2)%(10**9+7))

print(bx[n])
### BUGGY CODE ###

n,m = map(int, input().split())
a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
c = []
d = []
for i in range(m):
    
    if a[i] == 1:
        c.append(b[i])
    if b[i] == n:
        d.append(a[i])
ans = False
for i in c:
    if d.count(i) >=1:
        ans = True
        break
if ans:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

n,m = map(int,input().split())
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]

for i in range(m):
    a[i],b[i] = map(int,input().split())

go = []
goal = []

for i in range(len(a)):
    if a[i] == 1:
        go.append(b[i])
    if b[i] == n:
        goal.append(a[i])

count = [0 for i in range(n)]
for i in range(len(go)):
    count[go[i]-1] = 1
for i in range(len(goal)):
    count[goal[i]-1] += 1
for i in range(len(count)):
    if count[i] > 1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
### BUGGY CODE ###

from collections import deque
from math import ceil

N = int(input())
L = [int(input()) for _ in range(5)]

S = [N] + [0] *5
ans = 0
while S[5] != N:
  ans += 1
  for i in range(5,0,-1):
    S[i] += min(S[i-1],L[i-1])
    S[i-1] -= min(S[i-1],L[i-1])
print (ans)

### FIXED CODE ###

from math import ceil

N = int(input())
L = [int(input()) for _ in range(5)]

print (ceil(N / min(L)) + 4)
### BUGGY CODE ###

from collections import deque
n,m=map(int,input().split())
d=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    d[a].append(b)
    d[b].append(a)
l=[-1 for i in range(n)]
q=deque([0])
#print(d)
while len(q)>0:
    x=q.popleft()
    for i in d[x]:
        #print(i)
        if i!=0 and l[i]==-1 and x not in q:
            q.append(i)
            #print(i)
            l[i]=str(x+1)
l=l[1:]
#print(l)
print('No' if 0 in l else 'Yes\n'+'\n'.join(l))


### FIXED CODE ###

from collections import deque
n,m,*inp=map(int,open(0).read().split())
d=[[] for i in range(n)]
for i in range(m):
    j=2*i
    a,b=inp[j:j+2]
    a-=1
    b-=1
    d[a].append(b)
    d[b].append(a)
l=[-1 for i in range(n)]
q=deque([0])
#print(d)
while len(q)>0:
    x=q.popleft()
    for i in d[x]:
        #print(i)
        if l[i]==-1:
            q.append(i)
            #print(i)
            l[i]=str(x+1)
l=l[1:]
#print(l)
print('No' if 0 in l else 'Yes\n'+'\n'.join(l))
### BUGGY CODE ###

n=int(input())
a=[int(i) for i in input().split()]
sa=set(a)
f=True
if n%2==0:
    if sa=={int(i) for i in range(1,n,2)}:
        for i in range(1,n,2):
            if a.count(i)!=2:
                f=False
                break
    else:
        f=False
else:
    if a.count(0)==1:
        for i in range(2,n,2):
            if a.count(i)!=2:
                f=False
                break
    else:
        f=False
print(2**(n//2) if f else 0)


### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
a.sort()
f=True
if n%2==0:
    for i in range(n):
        if a[i]!=i//2*2+1:
            f=False
            break
else:
    for i in range(n):
        if a[i]!=(i+1)//2*2:
            f=False
            break
print(2**(n//2)%(10**9+7) if f else 0)