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

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

d = [None] * (n**2)
for i in range(n):
    for j in range(n):
        d[i*n+j] = min(i, n-1-i, j, n-1-j)
vacant = [False] * (n**2)

def sub(pos):
    v = d[pos]
    q = [(v, pos)]
    while q:
        v,pos = q.pop()
        for diff in (-n, n, -1, 1):
            ppos = pos + diff
            if ppos<0 or ppos>=n*n:
                continue
            if d[ppos]>v:
                d[ppos] = v
                nv = v+1 if not vacant[ppos] else v
                q.append((nv, ppos))
ans = 0
for v in p:
    v -= 1
    ans += d[v]
    sub(v)
    vacant[v] = True
print(ans)


### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

d = [None] * (n**2)
for i in range(n):
    for j in range(n):
        d[i*n+j] = min(i, n-1-i, j, n-1-j)
vacant = [False] * (n**2)

ans = 0
for pos in p:
    pos -= 1
    ans += d[pos]
    vacant[pos] = True
    q = [pos]
    while q:
        pos = q.pop()
        tmp = not vacant[pos]
#         for diff in (-1, 1, -n, n):
#             ppos = diff+pos
#             if ppos<0 or ppos>=n*n:
#                 continue
#             if d[ppos]>d[pos]+tmp:
#                 d[ppos] = d[pos] + tmp
#                 q.append(ppos)
        if pos+n<n*n:
            ppos = pos + n
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos-n>=0:
            ppos = pos - n
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos+1<n*n:
            ppos = pos + 1
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
        if pos-1>=0:
            ppos = pos - 1
            if d[ppos]>d[pos]+tmp:
                d[ppos] = d[pos] + tmp
                q.append(ppos)
print(ans)
### BUGGY CODE ###

def topological_sort(dag):
    n_nodes = len(dag)
    n_ins = [0]*n_nodes
    in_zeros = []
    sorted_nodes = []

    for src in range(n_nodes):
        for dst in dag[src]:
            n_ins[dst] += 1

    for i, v in enumerate(n_ins):
        if v == 0:
            in_zeros.append(i)

    while in_zeros:
        node = in_zeros.pop()
        sorted_nodes.append(node)
        for dst in dag[node]:
            n_ins[dst] -= 1
            if n_ins[dst] == 0:
                in_zeros.append(dst)
    
    return sorted_nodes

def resolve():
    N, M = list(map(int, input().split()))
    LRD = [list(map(int, input().split())) for _ in range(M)]
    adj_list = [[] for _ in range(N)]
    adj_matrix = [[None for _ in range(N)] for __ in range(N)]
    for lrd in LRD:
        l, r, d = lrd
        adj_list[l-1].append(r-1)
        adj_matrix[l-1][r-1] = d
    top_order = topological_sort(adj_list)
    if len(top_order) != len(adj_list):
        print("No")
        return
    
    acc = 0
    start = top_order[0]
    now = top_order[0]
    for i in range(1, len(top_order)):
        nxt = top_order[i]
        if adj_matrix[now][nxt] is not None:
            if adj_matrix[start][nxt] is not None and acc+adj_matrix[now][nxt] != adj_matrix[start][nxt]:
                print("No")
                return
            acc += adj_matrix[now][nxt]
        now = nxt
        
    print("Yes")


if '__main__' == __name__:
    resolve()


### FIXED CODE ###

def resolve():
    N, M = list(map(int, input().split()))
    LRD = [list(map(int, input().split())) for _ in range(M)]
    adj_list = [[] for _ in range(N)]
    for lrd in LRD:
        l, r, d = lrd
        adj_list[l-1].append((l-1, r-1, d))
        adj_list[r-1].append((r-1, l-1, -d))
    
    X = [None]*N
    import collections

    for i in range(N):
        if X[i] is not None:
            continue
        q = collections.deque(adj_list[i])
        X[i] = 0
        while q:
            src, nxt, d = q.pop()
            if X[nxt] is not None:
                if X[nxt] != X[src] + d:
                    print("No")
                    return
            else:
                X[nxt] = X[src] + d
                q.extend(adj_list[nxt])
    print("Yes")

    


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

import copy
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
	b=copy.copy(a)
	del b[i]
	print(max(b))

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a,reverse=True)
x,y=b[0],b[1]
z=a.index(x)
for i in range(n):
	if i==z:
		print(y)
	else:
		print(x)
### BUGGY CODE ###

from collections import deque

# Union Find
class edge:
    def __init__(self, u, v):
        self.u = u
        self.v = v
    def min(self):
        return min(self.u, self.v)
    def max(self):
        return max(self.u, self.v)


# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]


# 初期化
# 根なら-size,子なら親の頂点
N = int(input())

edge_list = []
for i in range(N - 1):
    u, v = map(int, input().split())
    edge_list.append(edge(u - 1, v - 1))

ans_sum = 0
for l in range(N):
    par = [-1] * N
    num_cc = 0
    upper_l_edge_list_copy = [e for e in edge_list if e.min() >= l]
    upper_l_edge_list_copy.append(edge(N, N))
    upper_l_edge_list = sorted(upper_l_edge_list_copy, key=lambda e: -e.max())
    for r in range(l, N):
        # if not upper_l_edge_list:
        #    continue
        size = 0
        # print([(e.u, e.v) for e in upper_l_edge_list])
        # print("aaaa", upper_l_edge_list[-1].max() == r)
        while upper_l_edge_list[-1].max() <= r:
            # print("bbb", upper_l_edge_list[-1].max() == r)
            e = upper_l_edge_list.pop()
            if not same(e.u, e.v):
                size += 1
            unite(e.u, e.v)
            # if not upper_l_edge_list:
            #    break
        num_cc = num_cc - size + 1
        # print(l, r, num_cc, "size_r", size)
        ans_sum += num_cc

print(ans_sum)


### FIXED CODE ###

class edge:
    def __init__(self, u, v):
        self.u = u
        self.v = v
    def min(self):
        return min(self.u, self.v)
    def max(self):
        return max(self.u, self.v)

N = int(input())
 
edge_list = []
for i in range(N - 1):
    u, v = map(int, input().split())
    edge_list.append(edge(u - 1, v - 1))
 
ver_num = int(N * (N + 1) * (N + 2) / 6)
 
edge_num = 0
for e in edge_list:
    edge_num += (N + 1 - (e.max() + 1)) * (e.min() + 1)
    
print(ver_num - edge_num)
### BUGGY CODE ###

N = int(input())
S = str(input())


R = 0
G = 0
B = 0

for i in range(N):
    s = S[i]
    if (s == 'R'):
        R +=1
    if (s == 'G'):
        G +=1
    if (s == 'B'):
        B +=1

count = R * G * B


for i in range(N):
    for j in range(1, N//2 + 1):
        if(i + j*2 >= N):
            break
        if((S[i] != S[i + j]) & (S[i + j] != S[i + 2 * j]) & (S[i + 2 * j] != S[i])):
            count -= 1




print(count)

### FIXED CODE ###

n = int(input())
s = input()
 
r, b, g = 0, 0, 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    if s[i] == 'G':
        g += 1
    if s[i] == 'B':
        b += 1
ans = r * g * b
 
for i in range(n):
    for j in range(1, n // 2 + 1):
        if i + 2 * j >= n:
            break
        if s[i] != s[i+j] and s[i] != s[i+2*j] and s[i+j] != s[i+2*j]:
            ans -= 1
 
print(ans)
### BUGGY CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)


### FIXED CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
### BUGGY CODE ###

from functools import reduce
from operator import mul
N = int(input())
numList = list(map(int, input().split()))
ans = reduce(mul, numList)
print(ans) if ans <= 10**18 else print("-1")

### FIXED CODE ###

import collections

N = int(input())
cNum = collections.Counter(list(map(int, input().split())))
ans = 1
if cNum[0] != 0:
  print("0")
  exit()
for n in cNum.keys():
  ans *= n**cNum[n]
  if ans > 10**18:
    ans = -1
    break
print(ans)
### BUGGY CODE ###

n,a,b = [int(i) for i in input().split()]
mod = 10**9+7
 
def mpow(a,n):
  if n == 0:
    return 1
  x = mpow(a,n//2)
  ans = x*x%mod
  if n%2==1:
    ans *= a
  return ans
  
def comb(n,k):
  ans = 1
  for i in range(k):
    ans = ans*(n-i)%mod
  for i in range(1,k+1):
    ans = ans*mpow(i,mod-2)%mod
  return ans
 
print((mpow(2,n)-1-comb(n,a)-comb(n,b))%mod)
# print(comb(n,a))

### FIXED CODE ###

import math
n,a,b = [int(i) for i in input().split()]
mod = 10**9+7
  
def comb(n,k):
  ans = 1
  for i in range(k):
    ans = ans*(n-i)%mod
  for i in range(1,k+1):
    ans = ans*pow(i,mod-2,mod)%mod
  return ans

print((pow(2,n,mod)-1-comb(n,a)-comb(n,b))%mod)
# print(comb(n,a))
### BUGGY CODE ###

import fractions
from functools import reduce
 
N = int(input())
lst = list(map(int,input().split()))

L = [0]
R = [0]
for i in range(N):
    L.append(fractions.gcd(L[i], lst[i]))
    R.insert(0, fractions.gcd(R[0], lst[N-1-i]))
ans = 0
for i in range(N):
    ans = max(ans, fractions.gcd(L[i], R[i+1]))
print(ans)

### FIXED CODE ###

import fractions
from functools import reduce
 
N = int(input())
lst = list(map(int,input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = fractions.gcd(L[i], lst[i])
    R[N-i-1] = fractions.gcd(R[N-i], lst[N-i-1])
ans = 0
for i in range(N):
    ans = max(ans, fractions.gcd(L[i], R[i+1]))
print(ans)
### BUGGY CODE ###

L,R = list(map(int, input().split()))
M=2019
for i in range(L,R):
  for j in range(i+1,R+1):
    L=(i * j) % 2019
    if L<M:
      M=L
print(M)

### FIXED CODE ###

L,R = list(map(int, input().split()))
if R - L >= 2019:
  print(0)
else:
  M=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      K=i * j % 2019
      if K < M:
        M = K
  print(M)
### BUGGY CODE ###

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

import math


def cmb(n, r):
    o = math.factorial(n)
    u = math.factorial(r) * math.factorial(n - r)
    return o // u


max_val = 0
min_val = 0
val = int(cmb(n - 1, k - 1))
for i in range(n - k + 1):
    if i != 0:
        val = (val * (n - i - k + 1) // (n - i))
    max_val = (max_val + (((a_list[-(i + 1)]) * val))) % (10 ** 9 + 7)
    min_val = (min_val + ((a_list[i]) * val)) % (10 ** 9 + 7)

print(int((max_val - min_val) % (10 ** 9 + 7)))

### FIXED CODE ###

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


mod = 10 ** 9 + 7
f_list = [1]
for i in range(1,n+1):
    f_list.append((f_list[-1] * i) % mod)
def comb(n,r):
    return f_list[n] * (pow(f_list[r], mod-2, mod) * pow(f_list[n-r], mod-2, mod) % mod) % mod


max_val = 0
min_val = 0
for i in range(n - k + 1):
    val = comb(n - i - 1, k - 1)
    max_val = (max_val + (((a_list[-(i + 1)]) * val))) % (10 ** 9 + 7)
    min_val = (min_val + ((a_list[i]) * val)) % (10 ** 9 + 7)

print(int((max_val - min_val) % (10 ** 9 + 7)))
### BUGGY CODE ###

q = int(input())

for k in range(q):
    x = list(input())
    y = list(input())
    lcs = [[0 for i in range(len(x)+1)] for j in range(len(y)+1)]
    for i in range(1,len(y) + 1):
        for j in range(1,len(x) + 1):
            if x[j-1] != y[i-1]:
                lcs[i][j] = max(lcs[i][j-1],lcs[i-1][j])
            else:
                lcs[i][j] = lcs[i-1][j-1] + 1
    print(lcs[len(y)][len(x)])

### FIXED CODE ###

q = int(input())
 
def lcss(x,y):
     
    lcs = [0]*(len(x)+1)
    for i in range(len(y)):
        w1 = y[i]
        lcs_2 = lcs[:]
        for j in range(len(x)):
            if x[j] == w1:
                lcs[j+1] = lcs_2[j] + 1  
            elif lcs[j+1] < lcs[j]:
                lcs[j+1] = lcs[j]
    return lcs[-1]
 
for i in range(q):
    x = input()
    y = input()
    print(lcss(x,y))
### BUGGY CODE ###

import functools
import math

N = input()
A = list(map(int, input().split()))
A = sorted(A)
gcd = functools.reduce(math.gcd, A)
if 2 <= gcd:
  print("not coprime")
else:
  isPC = True
  for i, a in enumerate(A):
    for aa in A[i+1:]:
      if 1 != math.gcd(a, aa):
        isPC = False
        break
    if not isPC:
      break
  if isPC:
    print("pairwise coprime")
  else:
    print("setwise coprime")

### FIXED CODE ###

import functools
import math
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

  divisors.sort()
  divisors.pop(0)
  return divisors

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

N = input()
A = list(map(int, input().split()))
A = sorted(A)
gcd = functools.reduce(math.gcd, A)

dp = []
if 2 <= gcd:
  print("not coprime")
else:
  isPC = True
  for a in A:
    if is_prime(a):
      dp.append(a)
    else:
      divs = make_divisors(a)
      for d in divs:
        if d in dp:
          isPC = False
          break
        dp.append(d)

    if not isPC:
      break
  if isPC:
    print("pairwise coprime")
  else:
    print("setwise coprime")
### BUGGY CODE ###

#入力
N,M=map(int,input().split())
H=list(map(int,input().split()))

#道の行列初期化
road=[[0]*N for l in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    #道行列を入力
    road[a-1][b-1]=(H[b-1]>=H[a-1])*1
    road[b-1][a-1]=(H[a-1]>=H[b-1])*1

result=0

for j in range(N):
    s=sum(road[j])
    if s==0:
        result +=1

print(result)

### FIXED CODE ###

#入力
N,M=map(int,input().split())
H=list(map(int,input().split()))

#隣接展望台の最大標高リスト初期化
road_max=[0 for l in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    if road_max[a-1]<H[b-1]:
        road_max[a-1]=H[b-1]
    if road_max[b-1]<H[a-1]:
        road_max[b-1]=H[a-1]

result=[(road_max[p]<H[p])*1 for p in range(N)]

print(sum(result))
### BUGGY CODE ###

n = int(input())
s = [input() for i in range(n)]
ss = [sorted(s[i]) for i in range(n)]
dic = [''.join(ss[i]) for i in range(n)]
key = [i for i in set(dic)]
cnt = 0
for i in key:
    a = dic.count(i)-1
    cnt += (a * (a+1))/2
print(int(cnt))


### FIXED CODE ###

n = int(input())
s = {}
cnt = 0
for i in range(n):
    j = ''.join(sorted(input()))
    if j in s:
        s[j] += 1
    else:
        s[j] = 0
    cnt += s[j]
print(int(cnt))
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
import os

while True:
    s = input().strip()
    if s == '0':
        break

    N = int(s)
    A = []
    for i in range(N):
        v = int(input())
        A.append(v)

    max_value = 0
    for start_i in range(N):
        for end_i in range(start_i + 1, N):
            sum_value = sum(A[start_i:end_i+1])
            if sum_value > max_value:
                max_value = sum_value
    print(max_value)

        

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import os


def max_seq(A):
    s = []
    s.append(A[0])
    for i in range(1, len(A)):
        v = max(A[i], A[i] + s[i-1])
        s.append(v)
    return max(s)

while True:
    s = input().strip()
    if s == '0':
        break

    N = int(s)
    A = []
    for i in range(N):
        v = int(input())
        A.append(v)

    print(max_seq(A))
### BUGGY CODE ###

import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
import numpy as np
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()

def update(a):
    b = [0]*n
    for i in range(n):
        for j in range(max(i-int(a[i]), 0), min(n, i+int(a[i])+1)):
            b[j] += 1
    return b
end = [n]*n

for i in range(k):
    if a == end:
        break
    a = update(a)
for i in range(n):
    print(str(int(a[i]))+" ",end = "" )

### FIXED CODE ###

import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()


end = [n]*n

for i in range(min(k, 41)):
    b = [0]*(n+1)
    for j in range(n):
        b[max(j-a[j], 0)] +=1
        if j+a[j] <n:
            b[j+a[j]+1] -=1
    for j in range(1,n):
        b[j] += b[j-1]
    a = b[:n]

for i in range(n):
    print(str(int(a[i]))+" ",end = "" )
### BUGGY CODE ###

import itertools, operator
def combinations_with_replacement_counts(n, r):
    size = n + r - 1
    for indices in itertools.combinations(range(size), n-1):
        starts = [0] + [index+1 for index in indices]
        stops = indices + (size,)
        yield tuple(map(operator.sub, stops, starts))

a = input().split(' ')
d = int(a[0])
g = int(a[1])
p = []
c = []
for i in range(d):
	a = input().split(' ')
	p.append(int(a[0]))
	c.append(int(a[1]))

end = False

for i in range(1, 1001):
	for j in list(combinations_with_replacement_counts(d, i)):
		if (g > i*d*100 + sum(c)):
			break
			
		score = 0
		go = True
		for l in range(len(j)):
			if j[l] > p[l]:
				go = False
				break
		if go == True:
			for l in range(len(j)):
				score += j[l] * 100 * (l + 1) + j[l]//p[l]*c[l]
			if score >= g:
				print (i)
				exit()
	

### FIXED CODE ###

d,g = map(int,input().split())
 
p = []
 
for i in range(d):
    p.append(list(map(int,input().split())))

from itertools import product
from math import ceil
 
ans = 1e09
 
for c in product([0,1],repeat=d):
    score = 0
    num = 0
    ind = 0
    for i in range(d):
        if c[i] == 1:
            score += p[i][0]*100*(i+1) + p[i][1]
            num += p[i][0]
        else:
            ind = max(i,ind)
    
    if g - score <= 0:
        ans = min(ans,num)
    elif g - score <= (p[ind][0]-1)*100*(ind+1):
        num += ceil((g-score)/(100*(ind+1)))
        ans = min(ans,num)
print(ans)
### BUGGY CODE ###

n,k,*h=map(int,open(0).read().split())
dp=[0]+[10**18]*~-n
for i in range(1,n):
    for j in range(k):
        if i-k+j<0:continue
        dp[i]=min(dp[i],dp[i-k+j]+abs(h[i]-h[i-k+j]))
print(dp[-1])

### FIXED CODE ###

n,k,*h=map(int,open(0).read().split())
dp=[0]+[10**18]*~-n
for i in range(1,n):
    for j in range(k):
        if i-k+j<0:continue
        dp[i]=min(dp[i],dp[i-k+j]+abs(h[i]-h[i-k+j]))
print(dp[-1])
### BUGGY CODE ###

mod = 1000000007
n, m = map(int, input().split())
dat_m = []
dp = []
for i in range(n + 1):
    dp.append([0] * (n + 1))
for i in range(m):
    dat_m.append(int(input()))
dp[0][0] = 1
#print(dp[0][0])
for i in range(1, n + 1):
    dp[i][:i-1] = dp[i-1][:i - 1]
    dp[i][i-1] = dp[i - 1][i - 1]
    dp[i][i] = dp[i - 1][i - 1]

    if i > 1:
        dp[i][i] += dp[i - 1][i - 2]

    if i in dat_m:
        dp[i][i] = 0

    dp[i][i] = dp[i][i] % mod

import pprint
print(dp[n][n])
#pprint.pprint(dp)


### FIXED CODE ###

mod = 1000000007
n, m = map(int, input().split())
dat_m = []
dp = [0] * (n + 1)
for i in range(m):
    t = int(input())
    dp[t] = -1

dp[0] = 1
for i in range(1, n + 1):
    if dp[i] == -1:
        dp[i] = 0
        continue
    dp[i] = dp[i - 1]
    if i > 1:
        dp[i] += dp[i - 2]
    if i in dat_m:
        dp[i] = 0
    dp[i] = dp[i] % mod

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

N, K, Q = map(int, input().split())
A = []
point = [0] * N

for i in range(Q):
  A.append(int(input()))
  i += 1

for i in A:
    point[i - 1] += 1

for i in range(len(point)):
    ans = K - (sum(point) - point[i])
    if ans > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N, K, Q = map(int, input().split())
point = [0] * N

for i in range(Q):
    point[int(input()) - 1] += 1
    i += 1

sum_point = sum(point)

for i in range(N):
    ans = K - (sum_point - point[i])
    if ans > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N = int(input())
As = [int(input()) for _ in range(N)]
as_tmp = list(As.copy())
for x in As:
  as_tmp.remove(x)
  print(max(as_tmp))
  as_tmp = list(As.copy())

### FIXED CODE ###

N = int(input())
As = [int(input()) for _ in range(N)]
Bs = sorted(As,reverse=True)
for x in As:
  if x == Bs[0] and x != Bs[1]:
    print(Bs[1])
  else:
    print(Bs[0])
### BUGGY CODE ###

import collections

n = int(input())

if n == 1:
    print(0)
else:
    lis = [0 for i in range(n+1)]
    for i in range(2, n+1):
        if lis[i] == 0:
            lis[i] = i
            for j in range(i**2, n+1, i):
                if lis[j] == 0:
                    lis[j] = i

def bunkai(m):
    ans = []
    for i in range(m):
        ans.append(lis[m])
        m = m//lis[m]
        if m == 1:
            break
    return ans

ans = 1

for i in range(2,n):
    tmp = 1
    yaku = collections.Counter(bunkai(i))
    for i in yaku:
        tmp = tmp * (yaku[i] +1)
    ans += tmp

print(ans)




### FIXED CODE ###

from collections import Counter

n = int(input())

if n == 1:
    print(0)
else:
    lis = [i for i in range(n+1)]
    for i in range(2, int(n**0.5) + 1):
        if lis[i] == i:
            lis[i] = i
            for j in range(i**2, n+1, i):
                if lis[j] == j:
                    lis[j] = i
#print(lis)
def bunkai(m):
    ans = []
    now = lis[m]
    cnt = 1
    for i in range(m):
        m = m//lis[m]
        if now == lis[m]:
            cnt += 1
        else:
            ans.append(cnt)
            cnt = 1
            now = lis[m]
        
        if m == 1:
            break
    return ans

ans = 1
for i in range(2,n):
    tmp = 1
    yaku = bunkai(i)
    for i in yaku:
        tmp *= (i +1)
    ans += tmp

print(ans)