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

# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())
h = np.array(input().split(), dtype='int')
bad_tower = np.zeros((), dtype='int')

for i in range(m):
    a, b = map(int, input().split())
    ha = h[a-1]
    hb = h[b-1]

    if ha > hb:
        bad_tower = np.append(bad_tower, b)
    elif ha < hb:
        bad_tower = np.append(bad_tower, a)
    elif ha == hb:
        bad_tower = np.append(bad_tower, a)
        bad_tower = np.append(bad_tower, b)

bad_tower = np.array(list(set(bad_tower)))

ans = n - len(bad_tower) + 1

print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())
h = np.array(input().split(), dtype='int')
bad_tower = np.zeros((n), dtype='int')

for i in range(m):
    a, b = map(int, input().split())
    ha = h[a-1]
    hb = h[b-1]

    if ha > hb:
        bad_tower[b-1] = 1
    elif ha < hb:
        bad_tower[a-1] = 1
    elif ha == hb:
        bad_tower[a-1] = 1
        bad_tower[b-1] = 1

ans = n - np.sum(bad_tower)

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

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

ans = 0
for x in range(K + 1):
    for y in range(x, K + 1):
        for z in range(y, K + 1):
            if x + y + z == S:
                if x == y and y == z:
                    ans += 1
                elif x == y or y == z or z == x:
                    ans += 3
                else:
                    ans += 6

print(ans)

### FIXED CODE ###

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

ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - (x + y)
        if 0 <= z and z <= K:
            ans += 1

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

from scipy.misc import comb

url = "https://atcoder.jp//contests/abc094/tasks/arc095_b"

def main():
    input()
    t = list(map(int, input().split()))
    combs = {}
    for i in range(len(t)):
        for j in range(i + 1, len(t)):
            tmp = sorted([t[i], t[j]], reverse=True)
            combs[comb(tmp[0], tmp[1], exact=True)] = tmp[::]
    key = max(combs.keys())
    print(' '.join([str(v) for v in combs[key]]))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main3():
    input()
    t = sorted(list(map(int, input().split())))
    ma = t.pop(-1)
    r = min(t, key=lambda x: abs(x - ma / 2))
    print(ma, r)

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

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

import numpy as np
P = np.array(P)

answer = 0
for i in range(N):
  if P[i]==min(P[:i+1]):
    answer += 1
    
print(answer)
    

### FIXED CODE ###

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

dummy = 2*10**5
answer = 0

for p in P:
  if p <= dummy:
    answer += 1
    dummy = p

print(answer)
### BUGGY CODE ###

n,m=map(int,input().split())
x=[]
y=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    x.append(b)
  elif b==n:
    y.append(a)

if len(x)==0 or len(y)==0:
  print("IMPOSSIBLE")
  exit()

ans="IMPOSSIBLE"

for i in range(len(y)):
  if y[i] in x:
    ans="POSSIBLE"

print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
data=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data[b-1]+=1
    if data[b-1]==2:
      print('POSSIBLE')
      exit()
  if b==n:
    data[a-1]+=1
    if data[a-1]==2:
      print('POSSIBLE')
      exit()

print('IMPOSSIBLE')
### BUGGY CODE ###

import numpy as np
[N,M] = list(map(int,input().split()))
S = list(map(int,input().split()))
T = list(map(int,input().split()))

ta = np.zeros((N+1,M+1))
ta[0,0]=1
wa = np.zeros((N+1,M+1))
wa[0,:]=1
wa[:,0]=1
output = 1
for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1]==T[j-1]:
            ta[i,j]=wa[i-1,j-1]
            wa[i,j]=wa[i-1,j]+wa[i,j-1]
        else:
            wa[i,j]=wa[i-1,j]+wa[i,j-1]-wa[i-1,j-1]
output = wa[N,M]%(10**9+7)
print(int(output))


### FIXED CODE ###

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

ta = [[0] * (M+1) for i in range(N+1)]
ta[0][0]=1
wa = [[0] * (M+1) for i in range(N+1)]
wa[0][:]=[1]*(M+1)
for i in range(N+1):
    wa[i][0]=1
output = 1
for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1]==T[j-1]:
            ta[i][j]=wa[i-1][j-1]
            wa[i][j]=(wa[i-1][j]+wa[i][j-1])%(10**9+7)
        else:
            wa[i][j]=(wa[i-1][j]+wa[i][j-1]-wa[i-1][j-1]+(10**9+7))%(10**9+7)
output = wa[N][M]
print(int(output))
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
1000000

output:
400000
"""

import sys


def is_prime(n):
    if n == 2:
        return True
    elif n < 2 or not n % 2:
        return False

    return pow(2, n - 1, n) == 1


def min_prime_factor(n):
    if is_prime(n):
        return n
    else:
        k = 2
        while True:
            if not n % k:
                break
            k += 1
    return k


def phi(n):
    ans = n
    while True:
        p = min_prime_factor(n)
        if n == 1:
            break
        while n % p == 0:
            # print(n, p)
            n //= p
        ans *= (1 - 1 / p)
    return int(ans)


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1 = int(_input[0])
    print(phi(n1))

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
1000000

output:
400000
"""

import sys


def min_prime_factor(n):
    k = 2
    while True:
        if pow(k, 2) > n:
            return n
        if not n % k:
            return k
        k += 1


def phi(n):
    ans = n
    while True:
        p = min_prime_factor(n)
        if n == 1:
            break
        while not n % p:
            n //= p
        ans *= (1 - 1 / p)
    return int(ans)


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1 = int(_input[0])
    print(phi(n1))
### BUGGY CODE ###

from math import prod

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

ans = prod(A)
if ans > 10**18:
    ans = -1
print(ans)

### FIXED CODE ###

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

x = 10**18
ans = 1
for a in A:
    if ans != -1:
        ans *= a
    if ans > x:
        ans = -1
    if a == 0:
        ans = 0
        break
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def prime_factorize(n):
    res = []
    i = 2
    while i * i <= n:
        if n % i == 0:
            res.append(i)
            n //= i
        else:
            i += 1 + (i != 2)
    if n != 1:
        res.append(n)
    return res


lcm_factors = Counter()
for ai in a:
    lcm_factors |= Counter(prime_factorize(ai))

lcm = 1
for k, v in lcm_factors.items():
    lcm *= k ** v
    lcm %= MOD

ans = 0
for ai in a:
    ans += lcm * pow(ai, MOD - 2, MOD)
    ans %= MOD

print(ans)

### FIXED CODE ###

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

primes = [
  2,  3,  5,  7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
 71, 73, 79, 83, 89, 97,101,103,107,109,113,127,131,137,139,149,151,157,163,
167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,
271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,
389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,
503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,
631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,
757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,
883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,
1009
]

def prime_factorize(n):
    res = []
    i = 0
    while primes[i] * primes[i] <= n:
        if n % primes[i] == 0:
            res.append(primes[i])
            n //= primes[i]
        else:
            i += 1
    if n != 1:
        res.append(n)
    return res


lcm_factors = Counter()
for ai in a:
    prime_factors = prime_factorize(ai)
    counter = Counter(prime_factors)
    for k, v in counter.items():
        if k in lcm_factors:
            lcm_factors[k] = max(lcm_factors[k], v)
        else:
            lcm_factors[k] = v

lcm = 1
for k, v in lcm_factors.items():
    lcm *= pow(k, v, MOD)
    lcm %= MOD

ans = 0
for ai in a:
    ans += lcm * pow(ai, MOD - 2, MOD)
    ans %= MOD

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

N = int(input())
A = sorted(map(int, input().split()), reverse=False)
dp = [0] * (max(A)+1)

for i in range(N):
    if dp[A[i]] == 0:
        dp[A[i]] = 1
        for j in range(i+1, N):
            if dp[A[j]] != 2 and A[j] % A[i] == 0:
                dp[A[j]] = 2
print(dp.count(1))


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
total = sum(A)
ans = []
for i in range(N):
    t = 0
    for j in range(N//2):
        ind = i+1+j*2
        if ind >= N:
            ind -= N
        t += A[ind]*2
    ans.append(total-t)
print(*ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
# 山1に降った量の半分をxと置くと、山2はA1-x、山3はA2-(A1-x)となり、翻って山1はA3-(A2-(A1-x))
# x = A3-A2+A1+x
# x = (A1+A3-A2) // 2
x = (sum(A[::2]) - sum(A[1::2])) // 2
ans = [x*2]
for i in range(N-1):
    a = A[i] - x
    ans.append(a*2)
    x = a
print(*ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

c = list(input())
c = c[:len(c)-1]
q = int(input())

num = len(c)

q_i =  [list(input()) for _ in range(q)]

#print(q_i)

hantei = 0

for i in range(q):
    #q_i= list(input())
    #print(q_i)
    if q_i[i][0] == '1' and hantei ==0:
        hantei = 1
    elif q_i[i][0] == '1' and hantei == 1:
        hantei = 0
    elif (q_i[i][2] =='1' and hantei == 0) or (q_i[i][2] == '2' and hantei == 1):
            c = [q_i[i][4]] +c
    elif (q_i[i][2] =='2' and hantei == 0) or (q_i[i][2] == '1' and hantei ==1):
            c += [q_i[i][4]]



if hantei == 0:
    ans = ''
    for i in range(len(c)):
        ans += c[i]
else:
    ans = ''
    for i in range(len(c)):
        ans = c[i] + ans


print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

c = input()
c = c[:len(c)-1]
q = int(input())

num = len(c)
c_mae = ''
c_ato = ''

hantei = 1

for i in range(q):
    q_i= list(input())
    #print(q_i)
    if q_i[0] == '1':
        hantei *= -1
    elif (q_i[2] =='1' and hantei == 1) or (q_i[2] == '2' and hantei == -1):
        c_mae = q_i[4] + c_mae
    else:
        c_ato += q_i[4]

print(c_mae+c+c_ato if hantei == 1 else (c_mae+c+c_ato)[::-1])
### BUGGY CODE ###

import sys

def primegen():
  l = [2]
  while True:
    yield max(l)
    n = max(l)
    while True:
      n += 1
      flag = 1
      for i in l:
        if n % i == 0:
          flag = 0
          break
      if flag:
        l.append(n)
        break

for line in sys.stdin:
  n = int(line)
  seq = primegen()
  i1 = 0
  i2 = 0
  while i2 < n:
    i1 = i2
    i2 = seq.__next__()
  if i2 == n:
    i2 = seq.__next__()
  print(str(i1) + " " + str(i2))

### FIXED CODE ###

MAX = 60000
lst = [i for i in range(MAX)]
lst[0] = lst[1] = 0
for i in range(MAX):
  if lst[i] != 0:
    for j in range(i * 2, MAX, i):
      lst[j] = 0
while 0 == 0:
  try:
    n = int(input())
    i = n - 1
    j = n + 1
    while lst[i] == 0:
      i -= 1
    while lst[j] == 0:
      j += 1
    print(lst[i],lst[j])
  except EOFError:
    break
### BUGGY CODE ###

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

res = "YES"

for i in T:
  if i in D:
    D.remove(i)
  else:
    res = "NO"
    break

print(res)

### FIXED CODE ###

from collections import Counter

N = int(input())
D = Counter(list(map(int, input().split())))
M = int(input())
T = Counter(list(map(int, input().split())))

res = "YES"

for i in T:
  if i not in D or T[i] > D[i]:
    res = "NO"
    break

print(res)
### BUGGY CODE ###

def prime(n):
  prime_table = [2]
  for i in range(3,n+1):
    f = 1
    for j in prime_table[:bisect.bisect_right(prime_table,int(i**0.5))]:
      if i % j == 0:
        f = 0
        break
    if f:
      prime_table.append(i)
  return prime_table

import bisect
n = int(input())
prime_table = prime(10**6)
print(prime_table[bisect.bisect_left(prime_table,n)])

### FIXED CODE ###

def prime(n):
  prime_table = [2]
  for i in range(3,n+1):
    f = 1
    for j in prime_table[:bisect.bisect_right(prime_table,int(i**0.5))]:
      if i % j == 0:
        f = 0
        break
    if f:
      prime_table.append(i)
  return prime_table

import bisect
x = int(input())
pt = prime(5*10**5)
print(pt[bisect.bisect_left(pt,x)])
### BUGGY CODE ###

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

flag = True
for t in T:
  if t in D:
    D.remove(t)
  else:
    flag = False
    break
    
if flag:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

from collections import Counter
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

c = Counter(D)
flag = True
for t in T:
  if c[t] > 0:
    c[t] -= 1
  else:
    flag = False
    break
    
if flag:
  print('YES')
else:
  print('NO')
### BUGGY CODE ###

N = int(input())
A = []
count = 0
for _ in range(N):
  item = input()
  if (item in A) == False:
    count = count + 1
    A.append(item)
print(count)


### FIXED CODE ###

N = int(input())
A = set([])
count = 0
for _ in range(N):
  item = input()
  if (item in A) == False:
    count = count + 1
    A.add(item)
print(count)
### BUGGY CODE ###

from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

    def fact(self, n):
        return self.f[n]


MOD = 10**9+7
N = int(input())
S = input()[:-1]
F = FactMod(N+1, MOD)

L = [0]*(2*N)
for i, c in enumerate(S):
    if c == "B":
        L[i] = 1
    if i % 2 == 0:
        L[i] ^= 1
if sum(L) != N:
    ans = 0
else:
    ans = 1
    cnt = 0
    for l in L:
        if l == 0:
            cnt += 1
        else:
            ans *= cnt
            cnt -= 1
ans *= F.fact(N)
ans %= MOD
print(ans)


### FIXED CODE ###

from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

    def fact(self, n):
        return self.f[n]


MOD = 10**9+7
N = int(input())
S = input()[:-1]
F = FactMod(N+1, MOD)

cnt_W = 0
cnt = 0
ans = 1
for i, c in enumerate(S):
    if c == "B":
        tmp = 1
    else:
        tmp = 0
    if i % 2 == 0:
        tmp ^= 1

    if tmp == 0:
        cnt += 1
    else:
        ans *= cnt
        ans %= MOD
        cnt -= 1
        cnt_W += 1
if cnt_W != N:
    ans = 0
else:
    ans *= F.fact(N)
    ans %= MOD
print(ans)
### BUGGY CODE ###

nums = int(input())
direct = list(input())
ary = [0 for i in range(nums)]

for i in range(nums):
    count = 0
    for x in range(nums):
        if x < i and direct[x] == "W":
            count += 1
        elif x > i and direct[x] == "E":
            count += 1
    ary[i] = count

print(min(ary))

### FIXED CODE ###

nums = int(input())
direct = list(input())
ary_w = [0 for i in range(nums)]
ary_e = [0 for i in range(nums)]
count_w = 0
count_e = 0
count = 0
result = 100000000

for i in range(nums):
    if direct[i] == "W":
        count_w += 1
    elif direct[i] == "E":
        count_e += 1

    ary_w[i] = count_w
    ary_e[i] = count_e

for i in range(nums):
    w = ary_w[i-1]
    e = ary_e[-1] - ary_e[i]
    if i == 0:
        w = 0
        e = ary_e[-1]
    count = w+e
    if count < result:
        result = count
print(result)
### BUGGY CODE ###

n, p=map(int, input().split())
b=int(p**(1/n)+1)
c=1
for i in reversed(range(1,b+1)):
  if(p%(i**n)==0):
    c=i
    break
print(c)

### FIXED CODE ###

n, p=map(int, input().split())
b=int(p**(1/n))+1
c=1
for i in reversed(range(1,b+1)):
  if(40<n):
    break
  if(p%i==0):
    if(p%(i**n)==0):
          c=i
          break
print(c)
### BUGGY CODE ###

N, M = map(int, input().split())
A = []
sumcost = 0
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
k = 0
A.sort()
while k < M:
    if A[0][1] >= M-k:
        sumcost += A[0][0]*(M-k)
        break
    else:
        sumcost += A[0][0]*A[0][1]
        k += A[0][1]
        A.pop(0)



print(sumcost)

### FIXED CODE ###

N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)
### BUGGY CODE ###

from collections import defaultdict,deque
import bisect
from copy import deepcopy

N = int(input())
A = list(map(int,input().split()))
graph = defaultdict(deque)
for _ in range(0,N-1):
    u,v = map(int,input().split())
    graph[u].append(v)
    graph[v].append(u)

arrive = [False] * (N+1)
dp_dict = dict()
dp_dict[1] = [A[0]]

ans = [None] *(N+1)
def dfs(s):
    stack = deque([s])
    while stack:
        v = stack[-1]
        arrive[v] = True
        if graph[v]:
            w = graph[v].popleft()
            if arrive[w] == False:
                tar = A[w-1]
                dp = deepcopy(dp_dict[v])
                if tar > dp[-1]:
                    dp.append(tar)
                else:
                    dp[bisect.bisect_left(dp, tar)] = tar
                ans[w] = len(dp)
                dp_dict[w] = dp
                stack.append(w)

        else:
            stack.pop()


dfs(1)
ans[1] = 1

for i in ans[1::]:
    print(i)

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())
A = tuple(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)
 
ans = [-1] * (N + 1)
inf = 10**18
LIS = [inf] * (N + 1)
 
def DFS(s, parent=0):
    a = A[s - 1]
    i = bisect.bisect_left(LIS, a)
    v = LIS[i]
    LIS[i] = a
    ans[s] = bisect.bisect_left(LIS, inf)
    for t in graph[s]:
        if t == parent:
            continue
        DFS(t, s)
    LIS[i] = v
    return
 
DFS(1)
print(*ans[1:], sep="\n")
### BUGGY CODE ###

def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    bn1=[0]*n
    bn2 = [0] * n
    s=0
    t=0
    for _ in range(k):
        for i in range(n):
            b1=max(i-a[i],0)
            b2=min(i+a[i],n-1)
            bn1[b1]+=1
            bn2[b2]+=1
        for i in range(n):
            s+=bn1[i]
            a[i]=s
        s=0
        for i in range(1,n):
            t+=bn2[i-1]
            a[i]-=t
        t=0
        bn1 = [0] * n
        bn2 = [0] * n
    c = [str(x) for x in a]
    L=" ".join(c)
    print(L)
resolve()

### FIXED CODE ###

def resolve():
        n, k = map(int, input().split())
        a = list(map(int, input().split()))
        bn1 = [0] * n
        s = 0
        t = 0
        chec = 0
        for _ in range(k):
            for i in range(n):
                b1 = max(i - a[i], 0)
                b2 = min(i + a[i], n - 1)
                bn1[b1] += 1
                if b2<n-1:
                    bn1[b2+1] -= 1
            for i in range(n):
                s += bn1[i]
                a[i] = s
                if s==n:
                    chec+=1
            s = 0
            if chec == n:
                break
            chec = 0
            bn1 = [0] * n
        c = [str(x) for x in a]
        L = " ".join(c)
        print(L)
resolve()
### BUGGY CODE ###

from collections import Counter


def factorize(n):
    fct = []
    while n % 2 == 0:
        fct.append(2)
        n //=2
    f = 3
    while f * f <= n:
        if n % f == 0:
            fct.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        fct.append(n)
    d = [i+1 for i in list(Counter(fct).values())]
    return d

n = int(input())
cnt = 0
for c in range(1,n):
    tmp = 1
    for i in factorize(n-c):
        tmp *= i
    cnt += tmp
print(cnt)

### FIXED CODE ###

n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)
### BUGGY CODE ###

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

PQ = [TA[0]]

for i in range(1, n):
    p0, q0 = PQ[i-1]
    p1, q1 = TA[i]
    t, a = TA[i]
    while p1 < p0 or q1 < q0:
        p1 += t
        q1 += a
    PQ.append([p1, q1])
    
print(sum(PQ[-1]))

### FIXED CODE ###

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

XY = [TA[0]]

for i in range(1, n):
    x0, y0 = XY[i-1]
    x1, y1 = TA[i]
    xq, xr = divmod(x0, x1)
    yq, yr = divmod(y0, y1)
    if xr != 0:
        xq += 1
    if yr != 0:
        yq += 1
    q = max(xq, yq)
    x1, y1 = x1*q, y1*q
    XY.append([x1, y1])
    
print(sum(XY[-1]))
### BUGGY CODE ###

L, N = map(int, input().split())
X = [0, L]
for i in range(N):
    X.append(int(input()))

X = sorted(X)
dpl = [[0]*(N+1) for i in range(N+1)]
dpr = [[0]*(N+1) for i in range(N+1)]

for k in range(1, N+1):
    for l in range(k + 1):
        r = k - l
        if l > 0:
            dpl[l][r] = max(dpl[l-1][r] + X[l]-X[l-1], dpr[l-1][r] + X[l] + L - X[-r-1])
        if r > 0:
            dpr[l][r] = max(dpr[l][r-1] + X[-r-1]-X[-r], dpl[l][r-1] + X[l] + L - X[-r-1])
        
ma = 0
for l in range(N+1):
    ma = max(ma, dpl[l][N-l], dpr[l][N-l])

print(ma)

### FIXED CODE ###

L, N = map(int, input().split())
X = []
for i in range(N):
    X.append(int(input()))

X = sorted(X)

ma = 0
for k in range(2):
    if k == 1:
        X = [L-X[-i] for i in range(1, N+1)]
    s = X[0]
    for i in range(1, N):
        if i % 2 == 1:
            s += L - X[-(i//2)-1] + X[i//2]
        else:
            s += X[i//2] + (L - X[-(i//2)])

    ma = max(ma, s)
    lt = (N-1) // 2 if N % 2 == 1 else -N//2
    for i in range(1, N):
        if lt > 0:
            if N % 2 == 1:
                s += X[lt] - X[i-1]*2 - (L - X[lt + 1])
            else:
                s += X[lt] - X[i-1] * 2 - (L - X[lt + 1])
            lt = 1 + lt - N
            ma = max(ma, s)
        else:
            if N % 2 == 1:
                s += X[lt] - X[i-1] * 2 - (L - X[lt])
            else:
                s += X[lt]*2 - L - X[i-1] * 2
            lt = N + lt
            ma = max(ma, s)

print(ma)