Harryxun/stf_run huggingface dataset:
n,m = map(int,input().split())
h = list(map(int,input().split()))
ma = [0]*(n)
for i in range(n):
  a,b = map(lambda x: int(x)-1,input().split())
  ma[a] = max(ma[a], h[b])
  ma[b] = max(h[a], ma[b])
ans = 0
for i in range(n):
  if h[i]>ma[i]:
    ans+=1
print(ans)

### FIXED CODE ###

import numpy as np
N,M = map(int,input().split())
H = np.array(list(map(int,input().split())))

adj = [[] for _ in range(N)]

for _ in range(M):
    a,b = map(lambda x: int(x) -1 ,input().split())
    if a in adj[b]:
        continue
    adj[a].append(b)
    adj[b].append(a)

ans = 0 
for i, item in enumerate(adj):
     if item == []:
         ans+=1
         continue
     adj_max = max(H[item])
     if H[i] > adj_max:
         ans += 1
print(ans)
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
S = [0] * N

for i in range(1, N):
  S[i] = min(S[_] + abs(h[i] - h[_]) for range(max(0, i-K), i))

print(S[N-1])


### FIXED CODE ###

from numba import jit
import math
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
@jit
def nya(N, K, h):
    S = [0] * N
    S[0] = 0
 
    for i in range(1, N):
        value = math.inf
        for step in range(1, K + 1):
            if i - step < 0:
                break
            value = min(value, S[i - step] + abs(h[i] - h[i - step]))
        S[i] = value
    return S[N-1]

print(nya(N, K, h))
n = int(input())
h = [int(i) for i in input().split()]
x = 1

if h[1] >= h[0]:
	x += 1

for i in range(2, n):
    hh=h[0:i-1]
    if h[i] >= max(hh):
        x += 1
print(x)

### FIXED CODE ###

n = int(input())
h = [int(i) for i in input().split()]
x = 1
if n == 1:
    print(x)
else:
    if h[1] >= h[0]:
        x += 1

    for i in range(2, n):
            hh = h[0:i]
            if h[i] >= max(hh):
                x += 1
    print(x)
#082_D
s = input()
x, y = map(int, input().split())
xgo, ygo = [], []

flg = True
cnt = 0
for i in range(len(s)):
    if s[i] == 'T':
        if flg and cnt > 0:
            xgo.append(cnt)
        elif cnt > 0:
            ygo.append(cnt)
        flg = (flg + 1) % 2
        cnt = 0
    else:
        cnt += 1
        
if flg and cnt > 0:
    xgo.append(cnt)
elif cnt > 0:
    ygo.append(cnt)
    
def search(L, x):
    dp = [[False for _ in range(20000)] for _ in range(len(L)+1)]
    dp[0][10000] = True
    
    for i in range(1, len(L)+1):
        for j in range(-8000, 8001):
            k = j + 10000
            if dp[i-1][k-L[i-1]]:
                dp[i][k] = True
            if dp[i-1][k+L[i-1]]:
                dp[i][k] = True

    return dp[len(L)][10000+x]

print('Yes' if search(xgo, x) and search(ygo, y) else 'No')

### FIXED CODE ###

#082_D
s = input()
x, y = map(int, input().split())
xgo, ygo = [], []

cnt = 0
flg = True
check = True if s[0] == 'F' else False
for i in range(len(s)):
    if s[i] == 'T':
        if flg and cnt > 0:
            xgo.append(cnt)
        elif cnt > 0:
            ygo.append(cnt)
        cnt = 0
        flg = (flg + 1) % 2
    else:
        cnt += 1

if flg and cnt > 0:
    xgo.append(cnt)
elif cnt > 0:
    ygo.append(cnt)

flg1, flg2 = len(xgo)==0, len(ygo)==0

sum_x, sum_y = sum(xgo), sum(ygo)
dp1 = [[False for _ in range(2*sum_x+1)] for _ in range(len(xgo)+1)]
dp2 = [[False for _ in range(2*sum_y+1)] for _ in range(len(ygo)+1)]

if check:
    dp1[1][sum_x+xgo[0]] = True
    for i in range(2, len(xgo)+1):
        for j in range(-sum_x, sum_x+1):
            if 0 <= j+sum_x-xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x-xgo[i-1]]:
                    dp1[i][j+sum_x] = True
            if 0 <= j+sum_x+xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x+xgo[i-1]]:
                    dp1[i][j+sum_x] = True
else:
    dp1[0][sum_x] = True
    for i in range(1, len(xgo)+1):
        for j in range(-sum_x, sum_x+1):
            if 0 <= j+sum_x-xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x-xgo[i-1]]:
                    dp1[i][j+sum_x] = True
            if 0 <= j+sum_x+xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x+xgo[i-1]]:
                    dp1[i][j+sum_x] = True

dp2[0][sum_y] = True
for i in range(1, len(ygo)+1):
    for j in range(-sum_y, sum_y+1):
        if 0 <= j+sum_y-ygo[i-1] <= 2*sum_y:
            if dp2[i-1][j+sum_y-ygo[i-1]]:
                dp2[i][j+sum_y] = True
        if 0 <= j+sum_y+ygo[i-1] <= 2*sum_y:
            if dp2[i-1][j+sum_y+ygo[i-1]]:
                dp2[i][j+sum_y] = True
                
if flg1:
    flgx = (x == 0)
elif abs(x) > sum_x:
    flgx = False
else:
    flgx = dp1[len(xgo)][sum_x+x]
    
if flg2:
    flgy = (y == 0)
elif abs(y) >sum_y:
    flgy = False
else:
    flgy = dp2[len(ygo)][sum_y+y]
    
print('Yes' if flgx and flgy else 'No')
S, T = map(int, input().split())
A, B = map(int, input().split())
U = input()

if S==U:
    print(A-1)
else:
    print(B-1)

### FIXED CODE ###

S, T = input().split()
A, B = map(int, input().split())
U = input()

if S==U:
    print(A-1,B)
else:
    print(A,B-1)
a,b=map(int,input())
print((3*a+b)//2)


### FIXED CODE ###

a,b=map(int,input().split())
print((3*a+b)//2)
import sys
from collections import deque, defaultdict


def bfs(links, s, limit):
    not_reachable = [True] * len(links)
    q = deque([(0, s, -1)])
    while q:
        cost, v, p = q.popleft()
        if cost > limit:
            break
        not_reachable[v] = False
        cost += 1
        q.extend((cost, u, v) for u in links[v] if u != p)
    return not_reachable


def solve(n, k, ab):
    if k == 1:
        return n - 2

    links = [set() for _ in range(n)]
    for a, b in zip(ab[0::2], ab[1::2]):
        a -= 1
        b -= 1
        links[a].add(b)
        links[b].add(a)

    ans = n
    thr = k // 2
    if k % 2 == 0:
        ans = min(sum(bfs(links, v, thr) for v in range(n)))
    else:
        dists = [bfs(links, v, thr) for v in range(n)]
        for a, b in zip(ab[0::2], ab[1::2]):
            a -= 1
            b -= 1
            ans = min(ans, sum(d1 and d2 for d1, d2 in zip(dists[a], dists[b])))
    return ans


n, k, *ab = map(int, sys.stdin.buffer.read().split())
print(solve(n, k, ab))


### FIXED CODE ###

import sys
from collections import deque


def bfs(links, s, limit):
    not_reachable = [True] * len(links)
    q = deque([(0, s, -1)])
    while q:
        cost, v, p = q.popleft()
        if cost > limit:
            break
        not_reachable[v] = False
        cost += 1
        q.extend((cost, u, v) for u in links[v] if u != p)
    return not_reachable


def solve(n, k, ab):
    if k == 1:
        return n - 2

    links = [set() for _ in range(n)]
    for a, b in zip(ab[0::2], ab[1::2]):
        a -= 1
        b -= 1
        links[a].add(b)
        links[b].add(a)

    ans = n
    thr = k // 2
    if k % 2 == 0:
        ans = min(sum(bfs(links, v, thr)) for v in range(n))
    else:
        dists = [bfs(links, v, thr) for v in range(n)]
        for a, b in zip(ab[0::2], ab[1::2]):
            a -= 1
            b -= 1
            ans = min(ans, sum(d1 and d2 for d1, d2 in zip(dists[a], dists[b])))
    return ans


n, k, *ab = map(int, sys.stdin.buffer.read().split())
print(solve(n, k, ab))
A, B= [int(input() )for _ in range(2)]
S = str(input())

if ((S[:A]+S[A+1:]).isdigit()) &  (S[A]=="-"):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

g = list(map(int,input().split()))
S = str(input())
 
if ((S[:g[0]]+S[g[0]+1:]).isdigit()) &  (S[g[0]]=="-"):
    print("Yes")
else:
    print("No")
pos = 0
curr = 7
k = int(input())
while true:
  pos += 1
  if curr % k == 0:
    break
  else : 
    k *= 10
    k += 7
print(pos)

### FIXED CODE ###

k=int(input())
x=7
for i in range(1,k+1):
  if x%k==0:
    print(i)
    break
  x=(x*10+7)%k
else:
  print(-1)
s = input()
n= len(s)
a=[]

for i in range(n):
    if s[i]!='B':
        a.append(s[i])
    else:
        del a[-1]
print(''.join(a))



### FIXED CODE ###

s = input()
n= len(s)
a=[]

for i in range(n):
    if s[i]!='B':
        a.append(s[i])
    else:
        if a!=[]:
            del a[-1]
print(''.join(a))
n = int(input())
l = []
for i in  range():
    s, p = input().split()
    l.append([s, int(p), i])
l_sorted = sorted(l, key = lambda x: (x[0], -x[1]))
for j in l_sorted:
    print(j[2]+1)

### FIXED CODE ###

n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append([s, int(p), i+1])
l_sorted = sorted(l, key = lambda x: (x[0], -x[1]))
for j in range(n):
    print(l_sorted[j][2])
import math
from functools import reduce

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

print(reduce(lambda x, y: math.gcd(x, y), a))

### FIXED CODE ###

import fractions
from functools import reduce

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

#print(reduce((lambda x, y: math.gcd(x, y)), a))
print(reduce((lambda x, y: fractions.gcd(x, y)), a))
#coding:utf-8
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]

choco = 0

for i in range(n):
    choco += (1 + (d - 1)//(a[i] - 1))

print(choco)

### FIXED CODE ###

#coding:utf-8
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]

choco = 0

for i in range(0, n):
    tmp =  1 + (d - 1)//a[i]
    choco += tmp

print(choco+x)
import sys
N, Y = map(int,input().split())

for i in range (N+1):
    for j in range (N+1):
        if  1000*i + 5000*j + 10000*(N-i-j) == Y:
            print('%d %d %d'%(i,j,(N-i-j)))
            sys.exit()
print('-1 -1 -1')

### FIXED CODE ###

S=input()
S=list(S)
S[3]='8'
S_change=''.join(S)
print(S_change)
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
ans = 0
if a[-2] == a[-1]:
  ans -= 1
for i, num in enumerate(a):
  b = make_divisors(num)
  if set(a[i+1:]).isdisjoint(set(b)):
    ans += 1
print(ans)


### FIXED CODE ###

from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)
b = [0]*(10**6 +1)
ans = 0
for _ in range(n):
  x = a.popleft()
  if b[x] == 0:
    ans += 1
    b[x] = 2
    tmp = 2 * x
    while tmp <= 10**6:
      b[tmp] = 1
      tmp += x
  elif b[x] == 2:
    ans -=1
    b[x] = 1
print(ans)
#! /usr/bin/python
# -*- encoding: utf-8 -*-


if __name__ == '__main__':
    input = list(map(int, input().split()))
    inputA = input[0]
    inputB = input[1]
    
    if inputA < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()
    
    if inputB < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if inputA == inputB:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if (inputA + inputB) % 2 == 0:
        sys.stdout.write(int((inputA + inputB) / 2))
        sys.exit()
      
    sys.stdout.write("IMPOSSIBLE")
    sys.exit()






### FIXED CODE ###

#! /usr/bin/python
# -*- encoding: utf-8 -*-

import sys

if __name__ == '__main__':
    input = list(map(int, input().split()))
    inputA = input[0]
    inputB = input[1]
    
    if inputA < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()
    
    if inputB < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if inputA == inputB:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if (inputA + inputB) % 2 == 0:
        sys.stdout.write(str(int((inputA + inputB) / 2)))
        sys.exit()
      
    sys.stdout.write("IMPOSSIBLE")
    sys.exit()
class UnionFind:
  def __init__(self, n):
    self.parents = list(range(n))
    self.ranks = [1 for _ in range(n)]
  def parent(self, x):
    if x == self.parents[x]:
      return x
    else:
      p = self.parent(self.parents[x])
      self.parents[x] = p
      return p
  def union(self, x, y):
    host = x if self.ranks[x] < self.ranks[y] else y
    guest = x+y-host
    self.ranks[host] += self.ranks[guest]
    self.parents[self.parent(guest)] = host
  def find(self, x, y):
    return self.parent(x)==self.parent(y)
  def numtrees(self):
    return len(set(self.parents))

N, M = map(int, input().split())
E = []
for _ in range(M):
  a, b = map(int, input().split())
  E.append((a-1, b-1))
ans = 0
r = 0
while r < M:
  uf = UnionFind(N)
  i = 0
  while i < M:
    if i != r:
      a, b = E[i]
      uf.union(a, b)
    i += 1
  i = 0
  while i < N:
    _ = uf.parent(i)
    i += 1
  if uf.numtrees() > 1:
    ans += 1
  r += 1
print(ans)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
E = []
for _ in range(M):
  a, b = map(int, input().split())
  E.append((a-1, b-1))
ans = 0
r = 0
while r < M:
  uf = UnionFind(N)
  i = 0
  while i < M:
    if i != r:
      a, b = E[i]
      uf.union(a, b)
    i += 1
  i = 0
  while i < N:
    _ = uf.find(i)
    i += 1
  if uf.group_count() > 1:
    ans += 1
  r += 1
print(ans)
h,w,m = map(int, input().split())

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()

  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  for j in sorted(lh_c, reverse=True):
    lw.pop(j)
  cw = co(lw).most_common()
  ans = ch[0][1]+cw[0][1]

  print(ans)

### FIXED CODE ###

h,w,m = map(int, input().split())

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()
  cw=co(lw).most_common()
  
  ans = 0
  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  lw_tmp = lw[:]
  for j in sorted(lh_c, reverse=True):
    lw_tmp.pop(j)
  if len(lw_tmp) == 0:
    print(ch[0][1])
  else:
    cw_tmp = co(lw_tmp).most_common()
    ans = ch[0][1]+cw_tmp[0][1]
    
    tmp = cw[0][0]
    lw_c = [i for i, x in enumerate(lw) if x == tmp]
    lh_tmp = lh[:]
    for j in sorted(lw_c, reverse=True):
      lh_tmp.pop(j)
    if len(lh_tmp) == 0:
      print(cw[0][1])
    else:
      ch_tmp = co(lh_tmp).most_common()
      ans = max(ans, cw[0][1]+ch_tmp[0][1])
      print(ans)
a,b=map(int, input().split())
print("01"[a%b])

### FIXED CODE ###

a,b=map(int, input().split())
print(0 if a%b==0 else 1)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

W = list(map(int,read().rstrip()))

N = len(W)

def Z_Algorithm(S):
    # 共通接頭辞の長さを返す
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

def find_good_substr(W):
    Z = Z_Algorithm(W)
    is_good = [True]*N
    for n in range(1,N//2+1):
        # n文字での周期をもってくる
        if not is_good[n]:
            continue
        for i in range(n+n-1,Z[n]+n,n):
            is_good[i] = False
    return is_good

def solve():
    G1 = find_good_substr(W)
    G2 = find_good_substr(W[::-1])
    if G1[-1]:
        # 自分自身がoptimal
        return 1,1
    if len(set(W)) == 1:
        return N,1

x,y = solve()
print(x)
print(y)



### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

W = list(map(int,read().rstrip()))

N = len(W)

def Z_Algorithm(S):
    # 共通接頭辞の長さを返す
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

def find_good_substr(W):
    Z = Z_Algorithm(W)
    is_good = [True]*(N+1) # 長さをインデックス
    for n in range(1,N//2+1):
        # n文字での周期をもってくる
        if not is_good[n]:
            continue
        for i in range(n+n,Z[n]+n+1,n):
            is_good[i] = False
    return is_good

def solve():
    G1 = find_good_substr(W)
    G2 = find_good_substr(W[::-1])[::-1]
    if G1[-1]:
        # 自分自身がoptimal
        return 1,1
    if len(set(W)) == 1:
        return N,1
    # 2個にできるはず
    x = sum(x and y for x,y in zip(G1[1:-1],G2[1:-1]))
    return 2,x

x,y = solve()
print(x)
print(y)
def scanf(scanstr,data_format):
    scanstr=scanstr.split(" ")
    if(type(data_format) is not list):
        print("data_format error")
    if(len(scanstr)!=len(data_format)):
        print("Error")
        return -1
    j=0
    for kata in data_format:
        if(kata=="str"):
            scanstr[j]=str(scanstr[j])
        if(kata="int"):
            scanstr[j]=int(scanstr[j])
        j=j+1
    return scanstr
data=mylib.scanf(input(),["int","int"])
if data[0]!=1 and data[1]!=1:
    print(str(round(float(data[0]*data[1])/2.0+0.1)))
else:
    print(1)


### FIXED CODE ###

def scanf(scanstr,data_format):
    scanstr=scanstr.split(" ")
    if(type(data_format) is not list):
        print("data_format error")
    if(len(scanstr)!=len(data_format)):
        print("Error")
        return -1
    j=0
    for kata in data_format:
        if(kata=="str"):
            scanstr[j]=str(scanstr[j])
        if(kata=="int"):
            scanstr[j]=int(scanstr[j])
        j=j+1
    return scanstr
data=scanf(input(),["int","int"])
if data[0]==1 or data[1]==1:
    print(1)
elif (data[0]*data[0])%2==0:
    print(str(round((data[0]*data[1])/2)))
else:
    print(str(round((data[0]*data[1]+1)/2)))
import math
n , x = map(int,input().split())

field = [int(i) for i in input().split()]

tmp = []

for i in field:
    tmp.append(abs(i-x))


ans = tmp[0]

for i in tmp:
    ans = math.gcd(ans,i)

print(ans)

### FIXED CODE ###

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

field = [int(i) for i in input().split()]

diff = list(map(lambda a:abs(a-x),field))

def gcd(x,y):
    # print(x,y)
    if x < y:
        x,y = y,x

    if x % y == 0:
        return y
    else:
        return gcd(y,x%y)

ans = diff[0]


for i in diff[1:]:
    ans = gcd(i,ans)

print(ans)
import queue
import numpy as np

num = list(map(int,input().split()))
field = [list(input()) for i in range(num[0])]
seen = np.zeros((num[0],num[1]))

step_r = [1,0,-1,0]
step_c = [0,1,0,-1]
q_r = queue.Queue()
q_c = queue.Queue()
sign = 0
white = 0
q_r.put(0)
q_c.put(0)

for i in range(num[0]):
  for j in range(num[1]):
    if field[i][j] == ".":
      white = white + 1

while not q_r.empty():
  r = q_r.get()
  c = q_c.get()
  for i in range(4):
    next_r = r + step_r[i]
    next_c = c + step_c[i]
    
    if (next_r<0) or (num[0]<=next_r) or (next_c<0) or (num[1]<=next_c) or (field[next_r][next_c] == "#"):
      continue
      
    if seen[next_r][next_c] == 0:
      q_r.put(next_r)
      q_c.put(next_c)
      seen[next_r][next_c] = seen[r][c] + 1
      if (next_r == num[0]-1) and (next_c == num[1]-1):
        g_r = next_r
        g_c = next_c
        sign = 1
        break
 
  if sign == 1:
    break
    
ans = white - (seen[g_r][g_c] + 1)
print(int(ans))

### FIXED CODE ###

import queue
import numpy as np

num = list(map(int,input().split()))
field = [list(input()) for i in range(num[0])]
seen = np.zeros((num[0],num[1]))

step_r = [1,0,-1,0]
step_c = [0,1,0,-1]
q_r = queue.Queue()
q_c = queue.Queue()
sign = 0
white = 0
q_r.put(0)
q_c.put(0)

for i in range(num[0]):
  for j in range(num[1]):
    if field[i][j] == ".":
      white = white + 1

while not q_r.empty():
  r = q_r.get()
  c = q_c.get()
  for i in range(4):
    next_r = r + step_r[i]
    next_c = c + step_c[i]
    
    if (next_r<0) or (num[0]<=next_r) or (next_c<0) or (num[1]<=next_c) or (field[next_r][next_c] == "#"):
      continue
      
    if seen[next_r][next_c] == 0:
      q_r.put(next_r)
      q_c.put(next_c)
      seen[next_r][next_c] = seen[r][c] + 1
      if (next_r == num[0]-1) and (next_c == num[1]-1):
        g_r = next_r
        g_c = next_c
        sign = 1
        break
 
  if sign == 1:
    break

if sign == 1:
  ans = white - (seen[g_r][g_c] + 1)
elif sign == 0:
  ans = -1

print(int(ans))
1 N = int(input())
2 ans = ''
3 while N > 0:
4 N -= 1
5 ans += chr(ord('a') + N % 26)
6 N //= 26
7 print(ans[::-1])

### FIXED CODE ###

N=int(input())
ans=''
while N>0 :
  N-=1
  ans += chr(ord('a')+N%26)
  N//=26
print(ans[::-1])
H,W = map(int,input().split())
h,w = map(int,input().spilt())

ans = h*W + w*H - h*w
print(ans)

### FIXED CODE ###

H,W = map(int, input().split())
h,w = map(int, input().split())


print(H*W - h*W - w*H + h*w)
import numpy as np
N = input()
A = []
for i in range(N):
	a = input()
	A.append(a)

A = sorted(A)
res = []
begin = 0
end = len(A) - 1
res = deque()
res.append(A[begin])
res.append(A[end])
begin+= 1
end -= 1
for i in range(N - 2):
	cand = np.argmax([abs(res[0] - A[begin]), abs(res[0] - A[end]), abs(res[-1] - A[begin]), abs(res[-1] - A[end])])
	if cand == 0:
		res.appendleft(A[begin])
		begin += 1
	elif cand == 1:
		res.appendleft(A[end])
		end -= 1
	elif cand == 2:
		res.append(A[begin])
		begin += 1
	elif cand == 3:
		res.append(A[end])
		end -= 1
sum_diff = 0
for i in range(N - 1):
	 sum_diff += abs(res[i] - res[i + 1])
print sum_diff


### FIXED CODE ###

from collections import deque
N = input()
A = [int(input()) for i in range(N)]
coef = [2] * N
coef[0] = 1
coef[-1] = 1
coef1 = [coef[i] if i % 2 == 0 else coef[i] * -1 for i in range(N)]
coef2 = [coef[i] if i % 2 != 0 else coef[i] * -1 for i in range(N)]

A = sorted(A)
coef1 = sorted(coef1)
coef2 = sorted(coef2)
res1 = 0
for i in range(N):
	res1 += A[i] * coef1[i]
res2 = 0
for i in range(N):
	res2 += A[i] * coef2[i]
print max(res1, res2)