Harryxun/stf_run huggingface dataset:
import numpy as np
K = input()
print(K)
N = int(K[0])
M = int(K[1])

hairetu = np.ones((N+2, M+2))

for i in range(M+2):
    hairetu[0][i] = 0
    hairetu[N+1][i] = 0
for i in range(N+2):
    hairetu[i][0] = 0
    hairetu[i][M+1] = 0

for i in range(1, N+1):
    for j in range(1, M+1):
        for k in range(-1, 2):
            for l in range(-1, 2):
                hairetu[i+k][j+l] = (-1) * hairetu[i+k][j+l]


print(hairetu)
count = 0

for i in range(1, N+1):
    for j in range(1, M+1):
        if hairetu[i][j] == -1:
            count += 1


print(count)

### FIXED CODE ###

K = input().split()
N = int(K[0])
M = int(K[1])

if N >= 2 and M >= 2:
    print((N-2)*(M-2))
elif N == 1 and M >= 2:
    print(M-2)
elif N >= 2 and M == 1:
    print(N-2)
elif N == 1 and M == 1:
    print(1)
n,k=map(int,input().split())
a=[0]+[int(j) for j in input().split()]
l=[-1]*(n+1)
ll=[]
i=1
idx=0
while True:
    if l[i]==-1:
        l[i]=idx
    else:
        ll.append(i)
        break
    ll.append(i)
    i=a[i]
    idx+=1

p=ll[-1]
nl=ll[p:-1]
print(nl[((k-l[p]+1)%(len(ll)-l[p]-1))-1])


### FIXED CODE ###

n,k=map(int,input().split())
a=[0]+[int(j) for j in input().split()]
l=[-1]*(n+1)
ll=[]
i=1
idx=0
while True:
    if l[i]==-1:
        l[i]=idx
    else:
        ll.append(i)
        break
    ll.append(i)
    i=a[i]
    idx+=1

p=ll[-1]
nl=ll[l[p]:-1]
ml=ll[:l[p]]
n,m=len(nl),len(ml)
if k<m:
    print(ml[k])
elif nl==[]:
    print(p)
    exit()
else:
    print(nl[(k-m)%n])
a,b = map(int,input().split())
if a > b: a,b = b,a
for i in ragne(b):
  print(a,end='')

### FIXED CODE ###

a,b = map(int,input().split())
if a > b: a,b = b,a
for i in range(b):
  print(a,end='')
inp = input()
inp = inp.split()
N = int(inp[0])
M = int(inp[1])
BigM = N+2

E = []
for m in range(M):
    abinp = input()
    abinp = abinp.split()
    a = int(abinp[0])
    b = int(abinp[1])
    E.append(set([a,b]))

output = [0] + [0] + [BigM]*(N-1)
prev_cnt = 0
now = [1]

while len(now) > 0:
    n = now.pop(0)
    print("n=",n)
    prev_cnt += 1
    elist = []
    for e in E:
        if n in e:
            elist.append(e)
    for e in elist:
        next = list(e - set([n]))[0]
        if output[next] == BigM:
            output[next] = n
            now.append(int(next))
            E.remove(e)
            print(E)

if prev_cnt == N:
    print("Yes")
    for n in range(2,N+1):
        print(output[n])
else:
    print("No")




### FIXED CODE ###

num = int(input())%10

honlist = [2,4,5,7,9]
ponlist = [0,1,6,8]
bonlist = [3]

if num in honlist:
    print("hon")
elif num in ponlist:
    print("pon")
else:
    print("bon")
import itertools


N, M = map(int, input().split())
connected_switches = [[int(x) - 1 for x in input().split()[1:]] for x in range(M)]
conditions = list(map(int, input().split()))

is_ok = 0
for patterns in itertools.product((0, 1), repeat=M):
    patterns = list(patterns)
    on_light = 0
    for i, light in enumerate(connected_switches):
        turned_sw = 0
        for switch_id in light:
            turned_sw += patterns[switch_id]
        if turned_sw % 2 == conditions[i] if i in conditions else -1:
            on_light += 1
    if on_light == M:
        is_ok += 1

print(is_ok)


### FIXED CODE ###

import itertools


N, M = map(int, input().split())
connected_switches = [[int(x) - 1 for x in input().split()[1:]] for x in range(M)]
conditions = list(map(int, input().split()))

ok = 0
for patterns in itertools.product((0, 1), repeat=N):
    patterns = list(patterns)
    is_lighting = True
    for i, lights in enumerate(connected_switches):
        turned_sw = sum([patterns[x] for x in lights])
        if turned_sw % 2 != conditions[i]:
            is_lighting = False
            break
    if is_lighting:
        ok += 1

print(ok)
d = { 'a':input(), 'b':input(), 'c':input() }
pointer = 'a'
while True:
    if 0 < len(d[pointer]):
        tmp = d[pointer][0]
        d[pointer] = s[pointer][1:]
        pointer = tmp
    else:
        print(pointer.upper())
        break

### FIXED CODE ###

SA = input()
SB = input()
SC = input()

pointer = SA[0]
SA = SA[1:]
d = {'a': SA, 'b': SB, 'c': SC}

while True:
    if d[pointer] == '':
        ans = pointer
        break
    tmp = d[pointer][0]
    d[pointer] = d[pointer][1:]
    pointer = tmp

print(ans.upper())
# coding: utf-8
# Your code here!

N = int(input())
L,R = map(int,input().split())

if L-R > 672:
    print(0)
else:
    minMod = 100000000
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if minMod > tmp:
                minMod = tmp
                
            elif tmp == 0:
                minMod = 0 
                break
    print(minMod)

### FIXED CODE ###

L,R = map(int,input().split())

if R-L > 672:
    print(0)
else:
    minMod = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp == 0:
                minMod = 0
                break
            minMod = min(tmp,minMod)
    print(minMod)
s = list(input())
for i in range(3):
  	if(s[i]==s[i+1]):
  		print('Bad')
 		exit()
else:
  	print('Good')


### FIXED CODE ###

S = list(input())
for i in range(3):
    if(S[i]==S[i+1]):
        print('Bad')
        exit()
else:
    print('Good')
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a for a in A if a <K]
N = len(A)
dp2 = [1] + [0]*K
dpm = [[0]*(K+1) for _ in range(N+1)]
dpm[0][0] = 1
for i, a in enumerate(A):
    for j in range(K, -1, -1):
        dpm[i+1][j] = dpm[i][max(0, j-a)] + dpm[i][j]
#print(dpm)

r = 0
for i, a in enumerate(A[::-1]):
    f = True
    for j in range(K, -1, -1):
        # 後ろiこの合計がjのもの
        if f and dp2[j] > 0:
            # K-j > x >= K-j-a
            if dpm[N-i-1][max(0, K-j-a)] > dpm[N-i-1][K-j]:
                f = False
        if j-a>=0:
            dp2[j] = dp2[j] + dp2[j-a]
    if f:
        r += 1
#    for j in range(K-1, 0, -1):
#        print("aa", i, N-i-1)
print(r)


### FIXED CODE ###

x = int(input())
for i in range(1, 10**5):
    if x <= i*(i+1)//2:
        break
print(i)
n = int(input())
s = [input() for _ in range(n)]


def is_anagram(s_i, s_j):
    for k in range(10):
        found = False
        for l in range(10):
            if s_i[k] == s_j[l]:
                found = True
                break
        if not found:
            return False
    return True


num = 0
for i in range(n):
    for j in range(i + 1, n):
        if i == j:
            continue
        if is_anagram(s[i], s[j]):
            num += 1
            records[i].append(j)
print(num)


### FIXED CODE ###

n = int(input())
s = [sorted(input()) for _ in range(n)]
sorted_s = sorted(s)

num = 0
num_same = 1
prev = sorted_s[0]
for i in range(1, len(sorted_s)):
    if prev != sorted_s[i]:
        num += int(num_same * (num_same - 1) / 2)
        num_same = 1
        prev = sorted_s[i]
    else:
        num_same += 1
num += int(num_same * (num_same - 1) / 2)
print(num)
while(True):
    a = input()
    b = input()
    a = str(a)
    b = str(b)
    length = len(a)
    if a == b[0:length]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

a = input()
b = input()
a = str(a)
b = str(b)
length = len(a)
if a == b[0:length]:
    print("Yes")
else:
    print("No")
import sys
N, Y = map(int, input().split())
 
for x in range(N+1)[::-1]:
  if x <= N:
    for y in range(N-i+1)[::-1]:
      if x+y <= N:
        z = N-(x+y)
        if 10000*x + 5000*y + 1000*z == Y:
          print(x,y,z)
          sys.exit()
 
print(-1,-1,-1)

### FIXED CODE ###

import sys
N, Y = map(int, input().split())

for x in range(N+1):
  for y in range(N+1):
    z = N-(x+y)
    if z < 0: break
    elif 10000*x + 5000*y + 1000*z == Y:
      print(x,y,z)
      sys.exit()

print(-1,-1,-1)
import math

# 入力
A,B = map(int,input().split())

print(int((A * B) // math.gcd(A, B)))

### FIXED CODE ###

import fractions

# 入力
A,B = map(int,input().split())

print(int((A * B) // fractions.gcd(A, B)))
# 100の位r,10の位g,1の位ｂに整数を入力
r,g,b = map(int,input().split())
# 100r+10g+bが4の倍数ならYES、違うならNO
if (100r + 10g +b) // 4 == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

# 100の位r,10の位g,1の位ｂに整数を入力
r,g,b = map(int,input().split())
# 100r+10g+bが4の倍数ならYES、違うならNO
if (100 * r + 10 * g + b) % 4 == 0:
    print("YES")
else:
    print("NO")
X, Y = map(int, input().split())

if (x+y)%3 != 0 or x*2 < y or y*2 < x:
    print(0)
    exit()

n = (2*X - Y) // 3
m = (2*Y - X) // 3

P = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N+1):
    fact.append((fact[-1]*i)%P)
    inv.append((-inv[P%i] * (P // i)) %P)
    factinv.append((factinv[-1] * inv[-1])%P)
print(fact[n+m]*factinv[n]*factinv[m]%P)


### FIXED CODE ###

X, Y = map(int, input().split())

if (X+Y)%3 != 0 or X*2 < Y or Y*2 < X:
    print(0)
    exit()

n = (2*X - Y) // 3
m = (2*Y - X) // 3

P = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N+1):
    fact.append((fact[-1]*i)%P)
    inv.append((-inv[P%i] * (P // i)) %P)
    factinv.append((factinv[-1] * inv[-1])%P)
print(fact[n+m]*factinv[n]*factinv[m]%P)
def modpow(val, n, mod):
    ret = 1
    while n:
        if n & 1:
            ret = (ret * val) % mod
        val = (val * val) % mod
        n = n >> 1
    return ret


def calc(val, my_dict, cnt):
    num_one = bin(val).count('1')
    if val in my_dict:
        return cnt + my_dict[val]
    else:
        if num_one == 0:
            return cnt
        nex = val % num_one
        ret = calc(nex, my_dict, cnt+1)
        my_dict[val] = ret - cnt
        return ret


n = int(input())
x = input()
tmp = list(x)
my_dict = dict()

num_one = tmp.count('1')
num_one_plus = num_one + 1
num_one_minus = num_one - 1

modsum_plus = 0
modsum_minus = 0
for i in range(1, n+1):
    if tmp[-i] == '1':
        modsum_plus += modpow(2, i-1, num_one_plus) % num_one_plus
        modsum_minus += modpow(2, i-1, num_one_minus) % num_one_minus

for i in range(n):
    if tmp[i] == '0':
        val = (modsum_plus + modpow(2, n-i-1, num_one_plus)) % num_one_plus
    else:
        val = (modsum_minus - modpow(2, n-i-1, num_one_minus)) % num_one_minus
    print(calc(val, my_dict, 1))


### FIXED CODE ###

def modpow(val, n, mod):
    ret = 1
    while n:
        if n & 1:
            ret = (ret * val) % mod
        val = (val * val) % mod
        n = n >> 1
    return ret


def calc(val, my_dict, cnt):
    num_one = bin(val).count('1')
    if val in my_dict:
        return cnt + my_dict[val]
    else:
        if num_one == 0:
            return cnt
        nex = val % num_one
        ret = calc(nex, my_dict, cnt+1)
        my_dict[val] = ret - cnt
        return ret


n = int(input())
x = input()
tmp = list(x)
my_dict = dict()

num_one = tmp.count('1')
num_one_plus = num_one + 1
num_one_minus = num_one - 1

modsum_plus = 0
modsum_minus = 0
for i in range(1, n+1):
    if tmp[-i] == '1':
        modsum_plus += modpow(2, i-1, num_one_plus) % num_one_plus
        if num_one_minus != 0:
            modsum_minus += modpow(2, i-1, num_one_minus) % num_one_minus

for i in range(n):
    if num_one == 1 and tmp[i] == '1':
        print(0)
        continue
    if tmp[i] == '0':
        val = (modsum_plus + modpow(2, n-i-1, num_one_plus)) % num_one_plus
    else:
        if num_one_minus != 0:
            val = (modsum_minus - modpow(2, n-i-1, num_one_minus)) % num_one_minus
        else:
            val = 0
    if val != 0:
        print(calc(val, my_dict, 1))
    else:
        print(1)
n,d= map(int, input().split())
x,y=[int(input()) for i in range(n)]

def distance_count():
  s=0
  for i in range(N)
  　　if (x[i]**2 + y[i]**2)**(1/2)<= d:
     　　s=s+1
  return s
distance_count(x,y)
print(s)


### FIXED CODE ###

N,D = map(int, input().split())
XY = [map(int, input().split()) for _ in range(N)]
X,Y = [list(i) for i in zip(*XY)]

s=0
for i in range (N):
  if X[i]*X[i]+Y[i]*Y[i]<=D*D:
    s=s+1
print(s)
N = int(input())
X = list(map(int, input().split()))
A = 10**10
R = sum(X)
L = 0
for i in range(N-1):
	L += X[i]
	R -= X[i]
	A = min(A, abs(l-r))
print(A)

### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
A = 10**10
R = sum(X)
K = 0
for i in range (N-1):
	K += X[i]
	R -= X[i]
	A = min(A, abs(K-R))
print(A)
K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
    if i%K==0:
        print("OK")
        sys.exit()
print("NG")

### FIXED CODE ###

import sys
K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
    if i%K==0:
        print("OK")
        sys.exit()
print("NG")
array = list(map(int, input().solit()))
array.sort()
if array == [5, 5, 7]:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

array = list(map(int, input().split()))
array.sort()
if array == [5, 5, 7]:
  print('YES')
else:
  print('NO')
n = int(input())

s = list(map(int,input().split()))

if set(s) <= 3:
  print("Three")
  
else: 
  print("Four")
         
         

### FIXED CODE ###

n = int(input())

s = list(input().split())

if len(set(s)) <= 3:
  print("Three")
  
else: 
  print("Four")
N = int(input())
A = list(map(int, input().split()))
A.append(0)
A.append(0)

ans = 0
doubles = set()
singles = set()
if A[0] == A[1]:
  doubles.add(A[0])
  singles.add(A[0])
else:
  singles.add(A[0])
  singles.add(A[1])
  
for i in range(0, N):
  a = A[2+3*i] 
  b = A[2+3*i+1]
  c = A[2+3*i+2]
  #print(ans, doubles, singles, a, b, c)
  if a == b == c:
    ans += 1
    continue
  d = None
  if a == b or b == c:
    d = b
  if  c == a:
    d = a
  #print(d)
  if d == None:
    match = False
    for x in (a, b, c):
      if x in doubles:
        match = True
        break
    if match:
      doubles.clear()
      singles.remove(x)
      for x2 in (a, b, c):
        if x2 != x:
          singles.append(x2)
      
      ans += 1
      continue
    else:
      for x in (a, b, c):
        singles.append(x)
  else:
    for x in (a, b, c):
      if x != d:
        s = x
    if d in singles:
      if s in singles:
        doubles.add(s)
      singles.add(s)
      if d in doubles:
        doubles.clear()
        ans+=1
        continue
      else:
        doubles.clear()
        singles.remove(d)
        ans += 1
        continue
        
    if s in doubles:
        doubles.clear()
        singles.remove(s)
        singles.add(d)
        doubles.add(d)
        ans+=1
        continue
    if s in singles:
        doubles.add(s)
        singles.add(s)
    else:
        singles.add(s)
    singles.add(d)
    doubles.add(d)
#print(doubles)
print(ans)
    
    
        

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
N = len(A) // 3
A = A[:3*N]
#print(N, A)
A.append(0)
A.append(0)

ans = 0
def ind(a, b):
  t = sorted((a, b))
  return t[0] * (N+1) + t[1]
def inv(i):
  b = i % (N+1)
  a = i // (N + 1)
  return a, b

dp = [-1] * (N+1)**2
dp[ind(A[0],A[1])] = 0
current_max = 0
dp1 = [-1] * (N+1)
dp1[A[0]] = 0
dp1[A[1]] = 0

ans = 0
for i in range(0, N):
  a = A[2+3*i] 
  b = A[2+3*i+1]
  c = A[2+3*i+2]
  #print(a,b,c)
  if a == b == c:
    ans+=1
    continue
  dp_new = {}
  for x, y, z in [(a, b, c), (b, c, a), (c, a, b)]:
    # choose 1 (x), leave y, z
    i = ind(y, z)
    if i not in dp_new:
      dp_new[i] = 0
    dp_new[i] = max(dp_new[i], current_max)
    if dp[ind(x, x)] >= 0:
      dp_new[i] = max(dp_new[i], dp[ind(x, x)] + 1)
    
    # choose 2 (x, y), leave t, z
    for t in range(1, N+1):
      i = ind(t,z)
      # Not making three
      if dp1[t] >= 0:
        if i not in dp_new:
          dp_new[i]=0
        dp_new[i] = max(dp_new[i], dp1[t])
      # Making three (x==y)
      if x == y and dp[ind(t, x)] >= 0:
        if i not in dp_new:
          dp_new[i] = 0
        dp_new[i] = max(dp_new[i], dp[ind(t, x)] + 1)
        
  #print(a,b,c)
  #print({inv(i):v for i, v in dp_new.items() })
  for i, s in dp_new.items():
    dp[i] = max(dp[i], s)
    ta, tb = inv(i)
    dp1[ta] = max(dp1[ta], s)
    dp1[tb] = max(dp1[tb], s)
    current_max = max(current_max, s)

#print(doubles)
print(ans + max(dp1))
N, R = map(int, input().split())

if N >= 10:
    ans = R
else:
    ans = R - 100 * (10 - K)

print(ans)

### FIXED CODE ###

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

if N >= 10:
    ans = R
else:
    ans = R + 100 * (10 - N)

print(ans)
import numpy as np
import math

def solve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0]*(n+5)
    for i in range(1,n):
        dp[i] = min([
            [dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i)]
            ])
    print(dp[n-1])
    return 0
 
if __name__ == "__main__":
    solve()


### FIXED CODE ###

def hoge():
  dp = [0] * (n + 5)
  for i in range(1, n):
    p = [dp[j] + abs(h_list[i] - h_list[j]) for j in range(max(0, i - k), i)]
    dp[i] = min(p)
  return dp[n - 1]

def solve():
  global n, k, h_list
  n, k = map(int, input().split())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()
n = int(input())
ki = [[]for j in range(n)]
for i in range(n-1):
	    a,b=map(int,input().split())
	    a-=1
	    b-=1
	    ki[a].append([b,i])
	    ki[b].append([a,i])


a=[0]*n
for i in range(n):
	    a[i]= len(ki[i])
print(max(a))
clist=[-1]*(n-1)
visited=[[0]for i in range(n)]
def dfs(now,last,ban_color=-1):
	    color = 1
	    for next,id in ki[now]:
	    	    if next == last:continue
	    	    if color == ban_color:
	    	    	    color+=1
	    	    clist[id] = color
	    	    dfs(next,now,color)
	    	    
	    	    
	    	    
dfs(0,0)
for i in range(n-1):
    print(clist[i])


		

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n = int(input())
ki = [[]for j in range(n)]
for i in range(n-1):
	    a,b=map(int,input().split())
	    a-=1
	    b-=1
	    ki[a].append([b,i])
	    ki[b].append([a,i])


a=[0]*n
for i in range(n):
	    a[i]= len(ki[i])
print(max(a))
clist=[-1]*(n-1)
visited=[[0]for i in range(n)]
def dfs(now,last,ban_color=-1):
	    color =1
	    for next,id in ki[now]:
	    	    
                     
	    	    if next == last:continue
	    	    if color == ban_color:
	    	    	    color+=1
	    	    clist[id] = color
	    	    dfs(next,now,color)
	    	    
	    	    color+=1
	    	    
dfs(0,-1)
print(*clist)
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n = i()
s = [input() for _ in range(n)]
s.sort()
ss = list(set(s))
ss.sort()
a = [0]*len(ss)
i = 0
j = 0
while n-1 > i:
    if s[i] == s[i+1]:
        a[j] += 1
        i += 1
    else:
        i += 1
        j += 1
m = max(a)
for k in range(len(a)):
    if m == a[k]:
        print(ss[k])


### FIXED CODE ###

import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
a = intl()
a = list(set(a))
if len(a) == 2:
    print("Yes")
else:
    print("No")
N, K = map(int, input().split())
ans = N
if N < K:
    q, mod = divmod(K, N)
    ans = min(N, K - N)
elif N == K:
    ans = 0
else:
    q, mod = divmod(N, K)
    ans = min(mod, abs(K - mod))
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
ans = N
if N < K:
    if N != 0:
        q, mod = divmod(K, N)
        ans = min(N, K - N)
    elif N == 0:
        ans = 0
elif N == K:
    ans = 0
else:
    q, mod = divmod(N, K)
    ans = min(mod, abs(K - mod))
print(ans)
abc = [int(input()) for i in range(3)]
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)

### FIXED CODE ###

abc = [int(input()) for i in range(3)]
x = int(input())

count = 0

for i in range(abc[0] + 1):
    for j in range(abc[1] +1):
        for k in range(abc[2] +1):
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)
N = int(input())
W = map(int, input().split())
 
l = [0] * N
r = [0] * N
 
for i in range(N):
  if i == 0:
    r[i] = W[0]
    l[i] = W[N-1]
  else:
    r[i] = r[i-1] + W[i]
    l[i] = l[i-1] + W[N-i-1]
 
ans = 100000
for i in range(N-1):
  ans = min([abs(r[i] - l[N-i-2]), ans])
print(ans)

### FIXED CODE ###

N = int(input())
W = list(map(int, input().split()))
 
l = [0] * N
r = [0] * N
 
for i in range(N):
  if i == 0:
    r[i] = W[0]
    l[i] = W[N-1]
  else:
    r[i] = r[i-1] + W[i]
    l[i] = l[i-1] + W[N-i-1]
 
ans = 100000
for i in range(N-1):
  ans = min([abs(r[i] - l[N-i-2]), ans])
print(ans)
n, a, b = map(int, input().split())
counter = 0

for i in range(1, n):
    str_i = str(i)
    sum_i = sum(map(int, str_i))
    if a <= sum_i <= b:
        counter += i

print(counter)

### FIXED CODE ###

a,b,c,d = map(int, input().split())

print("Left" if a+b > c+d else "Balanced" if a+b == c+d else "Right")
n = int(input())
x = "abcdefghijklmnopqrstuvwxyz"
a = n
s = ""
if n <= 26:
    print(x[n-1])
else:
    while a > 26:
        s += x[(a % 26) - 1]
        if a // 26 < 26 and a % 26 == 0:
            a = a // 26 - 1
            break
        else:
            a = a // 26
    s += x[a % 26 - 1]
    print(s[::-1]

### FIXED CODE ###

n = int(input())
x = "abcdefghijklmnopqrstuvwxyz"
a = n
s = ""
while a != 0:
    if a % 26 == 0:
        s += x[a % 26 - 1]
        a = a//26 - 1
    else:
        s += x[a % 26 - 1]
        a = a//26
print(s[::-1])
l = ["A", "B", "C", "D", "E", "F"]
x, y = map(int, input().split())
if l.index(x) > l.index(y):
  print(">")
elif l.index(x) < l.index(y):
  print("<")
else:
  print("=")

### FIXED CODE ###

l = ["A", "B", "C", "D", "E", "F"]
x, y = map(str, input().split())
if l.index(x) > l.index(y):
  print(">")
elif l.index(x) < l.index(y):
  print("<")
else:
  print("=")
import math
from functools import reduce
from fractions import gcd

def gcd(*numbers):
    return reduce(gcd, numbers)

def gcd_list(numbers):
    return reduce(gcd, numbers)

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

ans = 0

for i in range(N):
    a = A.pop(0)
    p = gcd_list(A)
    if p > ans:
        ans = p
    A.append(a)
print(ans)
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 20:51:40 2019

@author: makigon
"""

import fractions
from functools import reduce
 
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
 
N = int(input())
a = list(map(int,input().split()))
ans = 0

t_left = [0 for i in range(N)]
t_right = [0 for i in range(N)]

t_left[0] = a[0]
t_left[1] = fractions.gcd(a[0],a[1])

for i in range(2,N):
    t_left[i] = fractions.gcd(t_left[i-1],a[i])

t_right[N-1] = a[N-1]
t_right[N-2] = fractions.gcd(a[N-1],a[N-2])

for j in range(N-3,0,-1):
    t_right[j] = fractions.gcd(t_right[j+1],a[j])
    

for i in range(0,N-2):
    tmp = fractions.gcd(t_left[i],t_right[i+2])
    if tmp > ans:
        ans = tmp
    
print(max(ans,t_right[1],t_left[N-2]))