Harryxun/stf_run huggingface dataset:
s,t=input(),input()
ss,ts=[set()for i in range(26)],[set()for i in range(26)]
sc={}
tc={}
for i in range(len(s)):
    if s[i]not in sc:
        if t[i] in tc:print("No");exit()
        else:
            d=len(sc)
            ss[d].add(i)
            ts[d].add(i)
            tc[t[i]]=d
            sc[s[i]]=d
    else:
        if sc[s[i]]!=tc[t[i]]:print("No");exit()
        else:
            ss[sc[s[i]]].add(i)
            ts[sc[s[i]]].add(i)
for i in range(26):
    if ss[i]!=ts[i]:print("No");break
else:print("Yes")

### FIXED CODE ###

s=input();d=input();n=len(s)
di={"abcdefghijklmnopqrstuvwxyz"[i]:i for i in range(26)}
sl,dl=[set() for _ in range(26)],[set() for _ in range(26)]
for i,(x,y) in enumerate(zip(s,d)):
  sl[di[x]].add(i);dl[di[y]].add(i)
for i in dl:
  if i and i not in sl :print("No");exit() 
print("Yes")
import fractions

n_str = input()
n = int(n_str)
a_str = input().split()
a = []
for i in range(n):
    a.append(int(a_str[i]))
tmp1 = [0] * (n + 1)
tmp2 = [0] * (n + 1)
tmp = []
for i in range(n + 1):
    for j in range(i):
        if j == 0:
            tmp1[j + 1] = fractions.gcd(0, a[j])
        else:
            tmp1[j + 1] = fractions.gcd(tmp1[j], a[j])
    for j in range(n - 1, i, -1):
        if j == n - 1:
            tmp2[j] = fractions.gcd(0, a[j])
        else:
            tmp2[j] = fractions.gcd(tmp2[j + 1], a[j])
    if i == 0:
        tmp.append(fractions.gcd(0, tmp2[i + 1]))
    elif i == n:
        tmp.append(fractions.gcd(tmp1[i], 0))
    else:
        tmp.append(fractions.gcd(tmp1[i], tmp2[i + 1]))
print(max(tmp))


### FIXED CODE ###

in_str = input()
str_num = in_str.split()
num = []
for i in range(3):
    num.append(int(str_num[i]))

bis = 0
i = 1

while True:
    if num[0] * i > num[2] + 0.5:
        break
    bis += num[1]
    i += 1

print(bis)
N = input()
print(N**3)

### FIXED CODE ###

x = int(input())
y = x**3
print(y)
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,X,M = map(int,input().split())

    A = [-1 for i in range(M)]
    A[0] = X

    for i in range(1,M):
        temp = A[i-1] ** 2
        temp %= M
        if temp in A:
            start = A.index(temp)
            end = i - 1
            break
        A[i] = temp

    # print(start,end)
    # print(A[start],temp)

    L = end - start + 1
    straight = [0 for i in range(start+1)]
    loop = [0 for i in range(L)]

    for i in range(start):
        straight[i] = straight[i-1] + A[i]

    for i in range(L):
        loop[i] = loop[i-1] + A[start+i]

    res = 0

    if start != 0:
        if N >= start:
            res += straight[-1]
            N -= start
        else:
            res += straight[N-1]
            N = 0

    res += (N // L) * loop[-1]

    if N % L != 0:
        res += loop[N % L - 1]

    print(res)



main()


### FIXED CODE ###

import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
from numba import njit,i8


@njit(i8[:](i8,i8[:],i8[:],i8,i8,i8))
def SerchLoop(M,A,cnt,start,end,temp):
    for i in range(1,M+2):
        temp = A[i-1] ** 2
        temp %= M
        if cnt[temp] != 0:
            start = cnt[temp]
            end = i - 1
            break
        A[i] = temp
        cnt[temp] = i
    return np.append(np.append(A,start),end)


def main():
    N,X,M = map(int,input().split())

    A = [-1 for i in range(M+2)]
    A[0] = X
    A = np.array(A)

    start = -1
    end = -1

    cnt = [0 for i in range(M)]
    cnt[X] = 0
    cnt = np.array(cnt)

    C = SerchLoop(M,A,cnt,start,end,0)
    A = C[:-2]
    start = C[-2]
    end = C[-1]

    L = end - start + 1

    if start == -1:
        straight = [0 for i in range(N)]
        for i in range(N):
            straight[i] = straight[i-1] + A[i]
        res = straight[-1]
    elif start == 0:
        loop = [0 for i in range(L)]
        for i in range(L):
            loop[i] = loop[i-1] + A[start+i]
        res = (N // L) * loop[-1]
        if N % L != 0:
            res += loop[N % L - 1]
    else:
        straight = [0 for i in range(start)]
        for i in range(start):
            straight[i] = straight[i-1] + A[i]
        loop = [0 for i in range(L)]
        for i in range(L):
            loop[i] = loop[i-1] + A[start+i]
        if N >= start:
            res = straight[-1]
            N -= start
        else:
            res = straight[N-1]
            N = 0
        res += (N // L) * loop[-1]
        if N % L != 0:
            res += loop[N % L - 1]

    print(res)



main()
n = int(input())
nums = list(map(int,input().split()))
ans = 0
while sum(nums)%2 == 0:
    for i in range(n):
        nums[i]=nums[i]//2
    ans +=1
print(ans)

### FIXED CODE ###

print(sum(list(map(int,str(input())))))
S1 = raw.input()
S = int(S1)
if 0 <= S and S <= 86400:
   a = S / 3600
   b = S % 3600
   c = b / 60
   d = b % 60
else:
   print Error
print a + ":" + c + ":" + d

### FIXED CODE ###

S = input()
if S >= 0 and S <= 86400:
   a = S // 3600
   b = S % 3600
   c = b // 60
   d = b % 60
   print "%d:%d:%d" % (a, c, d)
N = int(input())
P = [[int(i) for i in input().split()] for _ in range(N)]

P.sort(key=lambda x: x[2])
array = []
p = P.pop()

for x in range(0, 101):
    for y in range(0, 101):
        H = p[2]+abs(p[0]-x)+abs(p[1]-y)
        if H > 0:
            array.append((x, y, H))

for x, y, h in P:
    ary = []
    for cx, cy, H in array:
        if h == (H-abs(x-cx)-abs(y-cy)):
            ary.append((cx, cy, H))
    array = ary

print(*array[0])


### FIXED CODE ###

N = int(input())
P = [[int(i) for i in input().split()] for _ in range(N)]

P.sort(key=lambda x: x[2])
array = []
p = P.pop()

for x in range(0, 101):
    for y in range(0, 101):
        H = p[2]+abs(p[0]-x)+abs(p[1]-y)
        if H > 0:
            array.append((x, y, H))

for x, y, h in P:
    ary = []
    for cx, cy, H in array:
        if h == 0:
            if h >= (H-abs(x-cx)-abs(y-cy)):
                ary.append((cx, cy, H))
        else:
            if h == (H-abs(x-cx)-abs(y-cy)):
                ary.append((cx, cy, H))
    array = ary

print(*array[0])
N, X, Y = map(int,input().split())
l = [0]*(N-1)
for i in range(1,N):
    for j in range(i+1,N+1):
        d=min(j-i,abs(X-i)+1+abs(Y-j),abs(Y-i)+1+abs(X-j))
        l[d-1] += 1
for k in range(N-1):
    print(l[k])

### FIXED CODE ###

S = input()
if S[2] != S[3] or S[4] != S[5]:
  print("No")
else:
  print("Yes")
x, y = map(ord(), input().split())
if x == y:
    print("=")
elif x < y:
    print("<")
else:
    print(">")


### FIXED CODE ###

x, y = map(ord, input().split())
if x == y:
    print("=")
elif x < y:
    print("<")
else:
    print(">")
from collections import*
from copy import *
n=int(input())
d=defaultdict(list)

q=[]
for i in range(n-1):
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)
    q.append(tuple(sorted([a,b])))
    
#print(d)
m=max(map(len,d.values()))
print(m)

dcolars={}

def BFS(d,point,c):
    colar=0
    for i in d[point]:
        if tuple(sorted([point,i])) not in dcolars:
            if c==colar:
                colar+=1
            dcolars[tuple(sorted([point,i]))]=colar
            dcolars[tuple(sorted([point,i])[::-1])]=colar
            BFS(d,i,colar)
        colar+=1
    return dcolars

ans=BFS(d,1,0)

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

### FIXED CODE ###

from collections import*
import sys
sys.setrecursionlimit(10**8)
input=sys.stdin.readline

n=int(input())
d={}

q=[]
for i in range(n-1):
    a,b=map(int,input().split())
    if a not in d:
        d[a]=[]
    if b not in d:
        d[b]=[]
    d[b].append(a)
    d[a].append(b)        
    q.append(tuple(sorted([a,b])))

m=max(map(len,d.values()))
print(m)

dcolars={}

def BFS(d,point,c):
    for i in d[point]:
        if tuple(sorted([point,i])) not in dcolars:
            c+=1
            if c==m+1:
                c=1
            dcolars[tuple(sorted([point,i]))]=c
            BFS(d,i,c)
    return dcolars

ans=BFS(d,1,0)

for i in q:
    print(ans[i])
s = list(input())
l = ["A", "C", "G", "T"]
l2 = []
cnt = 0
for i in range(len(s)):
    if s[i] in l:
        cnt += 1
    else:
        l2.append(cnt)
        cnt = 0
print(max(l2))

### FIXED CODE ###

s = list(input())
l = ["A", "C", "G", "T"]
l2 = []
cnt = 0
for i in range(len(s)):
    if s[i] in l:
        cnt += 1
    else:
        l2.append(cnt)
        cnt = 0
l2.append(cnt)
print(max(l2))
#最初に入力される情報を整理する
str_input_list = input().rstrip().split(' ')

int_input_list = []
for a in str_input_list:
    int_input_list.append(int(a))

length = int_input_list[0]
amount = int_input_list[1]

#文字列を受け取りリストに格納
mojiretu_list = []
for a in range(amount):
    mojiretu_list.append(input())


#文字列を小さい順に並べ、結合
sorted_list = sorted(mojiretu_list)
min_mojiretu = ''
for a in range(amount):
    min_mojiretu += sorted_list[a]

#出力
print(min_mojiretu)
print()

### FIXED CODE ###

haiku_list = ['5', '7', '5']

str_input_list = input().rstrip().split(' ')

for a in range(3):
    if haiku_list[a] in str_input_list:
        str_input_list.remove(haiku_list[a])
        haiku_list[a] = '*'

if haiku_list == ['*', '*', '*']:
    print('YES')
else:
    print('NO')
S = str(input())
list = lisr(S)
num = list.count('+')
print(num - (4-num))

### FIXED CODE ###

S = str(input())
list = list(S)
num = list.count('+')
print(num - (4-num))
import collections

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

G = [[] for i in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    G[b-1].append(a-1)
    G[a-1].append(b-1)

queue = collections.deque([0])
visited = [0]*N
visited[0] = 1
while queue:
    x = queue.popleft()
    for i in G[x]:
        if visited[i] == 0:
            visited[i] = x + 1
            queue.append(i)
print("Yes")
print(*visited[1:], sep="\n")

### FIXED CODE ###

import collections

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

G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[b-1].append(a-1)
    G[a-1].append(b-1)

queue = collections.deque([0])
visited = [0]*N
visited[0] = 1
while queue:
    x = queue.popleft()
    for i in G[x]:
        if visited[i] == 0:
            visited[i] = x + 1
            queue.append(i)

print("Yes")
print(*visited[1:], sep="\n")
li = [0]*26
alpha2num = lambda c: ord(c) - ord("A") + 1
w = input().upper()
for i in range(len(w)):
  k = alpha2num(w[i])
  li[k] += 1
else:
  for j in li:
    if(not j %= 2):
      print("No")
      break
  else:
    print("Yes")

### FIXED CODE ###

li = [0]*26
alpha2num = lambda c: ord(c) - ord('A')
w = input().upper()
for i in range(len(w)):
  k = alpha2num(w[i])
  li[k] += 1
for j in li:
  if j % 2:
    print("No")
    break
else:
  print("Yes")
N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
if(len(X)>=K):
  for i in range(len(X)-K):
    ans=max(ans,Y[i+K]-X[i]+1)
else:
  ans=len(S)
ans=max(ans,Y[min(K-1,len(X))]+1)
ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
S=input()
X,Y=[],[]
M=0
for i in range(len(S)):
  if(S[i]=='1' and M==0):
    X.append(i)
    M+=1
  elif(S[i]=='1'):
    M+=1
  else:
    if(M):
      Y.append(i-1)
    M=0
if(M):
  Y.append(len(S)-1)
ans=0
if(len(X)>=K):
  for i in range(len(X)-K):
    ans=max(ans,Y[i+K]-X[i]+1)
else:
  ans=len(S)
if(len(X)):
  ans=max(ans,Y[min(K-1,len(X)-1)]+1)
  ans=max(ans,len(S)-X[max(len(X)-K,0)])
print(ans)
S=input()
T=input()
i=0
x=0
while i<=2:
  i+=1
  if S[i]==T[i]:
    X+=1
        
print(x)    
    


### FIXED CODE ###

s=input()
t=input()
c=0
for i in range(3):
    if s[i]==t[i]:
        c+=1

print(c)
# -*- coding: utf-8 -*-
s = input()

while len(s) > 4:
    if s[-5:] == 'deram' or s[-5:] == 'erase:
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    else:
        break
    
if len(s) == 0:
    print('YES')
else:
    print('NO')



### FIXED CODE ###

s = input()

while len(s) > 4:
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    else:
        break
        
if len(s) == 0:
    print('YES')
else:
    print('NO')
from collections import deque

H, W = map(int,input().split())
maze = list(list(input()) for i in range(H))



def bfs(maze,maze_s,sy,sx):
  maze_s[sy][sx] = 0
  queue = deque([[sy,sx]])
  while queue:
    y,x = queue.popleft()
    if maze[y][x] == "g":
      return maze_s[y][x]
    else:
      for j,k in [(0,1),(0,-1),(1,0),(-1,0)]:
        new_y,new_x = y+j, x+k
        if 0 <= new_y <= H-1 and 0 <= new_x <= W-1:
          if maze[new_y][new_x] != "#" and maze_s[new_y][new_x] == -1:
            maze_s[new_y][new_x] = maze_s[y][x] + 1
            queue.append([new_y,new_x])

maze_s = list([-1] * W for i in range(H))
count = 0
for row in maze:
  count += row.count(".")

maze[H-1][W-1] = "g"

ans = count - bfs(maze,maze_s,0,0) -1
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int,input().split())
maze = list(list(input()) for i in range(H))



def bfs(maze,maze_s,sy,sx):
  maze_s[sy][sx] = 0
  queue = deque([[sy,sx]])
  while queue:
    y,x = queue.popleft()
    if maze[y][x] == "g":
      return maze_s[y][x]
    else:
      for j,k in [(0,1),(0,-1),(1,0),(-1,0)]:
        new_y,new_x = y+j, x+k
        if 0 <= new_y <= H-1 and 0 <= new_x <= W-1:
          if maze[new_y][new_x] != "#" and maze_s[new_y][new_x] == -1:
            maze_s[new_y][new_x] = maze_s[y][x] + 1
            queue.append([new_y,new_x])
  else:
    print(-1)
    exit()

maze_s = list([-1] * W for i in range(H))
count = 0
for row in maze:
  count += row.count(".")

maze[H-1][W-1] = "g"

ans = count - bfs(maze,maze_s,0,0) -1
print(ans)
import operator as op
n=int(input())
a=list(map(int,input().split()))
ans=reduce(operator.mul,a,1)
if ans>10**18:
    anscheck=False
else:
    anscheck=True
print(ans if anscheck else -1)

### FIXED CODE ###

import numpy as np
n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans=ans*a[i]
    if ans>10**18 and not 0 in a:
      print(-1)
      exit()
if ans>10**18:
    anscheck=False
else:
    anscheck=True
print(ans if anscheck else -1)
from itertools import product as pro

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

r = [i for i in range(n) if s[i] == 'R']
g = [i for i in range(n) if s[i] == 'G']
b = [i for i in range(n) if s[i] == 'B']
cnt = len(r)*len(g)*len(b)

len = max(len(r), len(g), len(b))
if len == len(r):
    max1 = set(r)
    min1 = g
    min2 = b

if len == len(g):
    max1 = set(g)
    min1 = r
    min2 = b

if len == len(b):
    max1 = set(b)
    min1 = g
    min2 = r

for i, j in pro(min1, min2):
    if 2*j-i in max1:
        cnt -= 1
    if 2*i-j in max1:
        cnt -= 1
    if (i+j)/2 in max1:
        cnt -= 1

print(cnt)


### FIXED CODE ###

from itertools import product as pro

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

r = [i for i in range(n) if s[i] == 'R']
g = [i for i in range(n) if s[i] == 'G']
b = [i for i in range(n) if s[i] == 'B']
cnt = len(r)*len(g)*len(b)

length = max(len(r), len(g), len(b))
if length == len(r):
    max1 = set(r)
    min1 = g
    min2 = b

if length == len(g):
    max1 = set(g)
    min1 = r
    min2 = b

if length == len(b):
    max1 = set(b)
    min1 = g
    min2 = r

for i, j in pro(min1, min2):
    if 2*j-i in max1:
        cnt -= 1
    if 2*i-j in max1:
        cnt -= 1
    if (i+j)/2 in max1:
        cnt -= 1

print(cnt)
N = int(input())
A = list(map(int, input().split()))
A.sort()
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

B = []
for i in range(N-1):
    a = A[i]
    if a != A[i+1]:
        B.append(a)
if A[-1] != A[-2]:
    B.append(A[-1])
if len(B) == 0:
    print(0)
    quit()
b = B[-1]
X = set(primes(b))
A = set(B)
B = list(A&X)
A = list(A-X)
A.sort()
B.sort()
ans = []
while len(A) > 1:
    a = A[0]
    C = []
    if a != A[1]:
        ans.append(a)
    for aa in A:
        if aa % a != 0:
            C.append(aa)
    A = C
ans1 = []
for gen in ans:
    for b in B:
        if gen % b == 0:
            break
        if b > gen:
            ans1.append(gen)
            break
print(len(ans1)+len(B))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = set()
C = set()
for a in A:
    if a in B:
        C.add(a)
    else:
        B.add(a)
M = max(B)
bool = [1]*(M+1)
for c in C:
    bool[c] = 0
for b in B:
    for i in range(b*2, M+1, b):
        bool[i] = 0
ans = 0
for a in A:
    if bool[a] == 1:
        ans += 1
print(ans)
X = input()
X = range(-40,40)
if X > 30:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

X = int(input())
if X >= 30:
    print("Yes")
else:
    print("No")
input = [input() for i in range(5)]
num = input[0]
list = list(map(input[1].split()))

def hoge(list):
  new_list = []
  for i in list:
    if i % 2 == 0:
      new_list.append(i)
    else:
      return False
  return new_list

count = 0
while True;
  list = hoge(list)
  if list == False:
    break
  count += 1

print(count)

### FIXED CODE ###

num = input()
listt = input().split()

def hoge(fuga):
    new_list = []
    for i in fuga:
        if int(i) % 2 == 0:
            new_list.append(int(i)/2)
        else:
            return False
    return new_list


count = 0
while True:
    listt = hoge(listt)
    if listt == False:
        break
    count += 1

print(count)
import math
xa,ya,xb,yb=map(int, input().split())
print("{0:.8f}".format(math.sqrt( (xa-xb)**2 + (ya-yb)**2 )))

### FIXED CODE ###

import math
xa,ya,xb,yb=map(float, input().split())
print("{0:.8f}".format(math.sqrt( (xa-xb)**2 + (ya-yb)**2 )))
N, K = map(int, input().split())
D = list(map(int, input(split())))

i = N
while True:
  flg = True
  for j in str(i):
    if int(j) in D:
      flg = False
      break

  if flg == True:
    print(i)
    exit()

  i += 1

### FIXED CODE ###

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

i = N
while True:
  flg = True
  for j in str(i):
    if int(j) in D:
      flg = False
      break

  if flg == True:
    print(i)
    exit()

  i += 1
n = int(input())
A = list(map(int,input().split()))
m = max(A)
B = [0] * (m+1)
for i in range(n):
    B[A[i]] += 1
for i in range(1, m+1):
    B[i] = B[i-1] + B[i] * i

# print(B)

ans = 0
for i in range(n):
    ma = -1
    mm = A[i]
    while mm <= m and ma != mm:
        ma = mm
        mm = B[mm]
    if mm > m:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
m = A[0]
for i in range(n-1):
    if A[i+1] <= 2*m:
        ans += 1
    else:
        ans = 1
    m += A[i+1]
print(ans)
N / 2 + (N % 2)

### FIXED CODE ###

N = int(input())
num = N + (N % 2)
print(int(num/2))
input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

flag = true
for i in range(N-3):
	if abs(A[i]-A[i+1]) != abs(A[i+2]-A[i+1]):
		flag = false
		break

if flag:
	print(POSSIBLE)
else:
	print(IMPOSSIBLE)

### FIXED CODE ###

def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)

input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

temp = A[0]
for i in range(1,N):
	temp = gcd(temp,A[i])

if K <= max(A) and K % temp == 0:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')
S = input()
Q = int(input())
flg = 0
senntou = ''
ushiro = ''
for i in range(Q):
    A = list(input().split())
    if int(A[0]) == 1 and flg == 0:
        flg = 1
        continue
    elif int(A[0]) == 1 and flg == 1:
        flg = 0
        continue
    if (int(A[1]) == 1 and if flg == 0) or (int(A[1]) == 2 and if flg == 1):
        senntou = A[2] + senntou
    else:
        ushiro = ushiro + A[2]
if flg == 0:
    print(senntou + S + ushiro)
if flg == 1:
    print(ushiro[::-1] + S + senntou[::-1])

### FIXED CODE ###

S = input()
Q = int(input())
flg = 0
senntou = ''
ushiro = ''
for i in range(Q):
    A = list(input().split())
    if int(A[0]) == 1 and flg == 0:
        flg = 1
        continue
    elif int(A[0]) == 1 and flg == 1:
        flg = 0
        continue
    if (int(A[1]) == 1 and flg == 0) or (int(A[1]) == 2 and flg == 1):
        senntou = A[2] + senntou
    else:
        ushiro = ushiro + A[2]
if flg == 0:
    print(senntou + S + ushiro)
if flg == 1:
    print(ushiro[::-1] + S[::-1] + senntou[::-1])
__Author__ = 'Anomino'
# coding:UTF-8


def AskUser(number) : 
    player_A, player_B = [], []
    for value in range(0, number) : 
        answer = raw_input()
        answer = answer.split( )
        player_A.append(int(answer[0]))
        player_B.append(int(answer[1]))

    return player_A, player_B
    
def CalcScore(player_A, player_B) : 
    score_A, score_B = 0, 0

    for value in range(0, len(player_A)) : 
        if player_A[value] < player_B[value] : 
            score_B = score_B + player_A[value] + player_B[value]
        elif player_A[value] > player_B[value] : 
            score_A = score_A + player_A[value] + player_B[value]
        else : 
            score_A = score_A + player_A[value]
            score_B = score_B + player_B[value]

    return score_A, score_B

if __name__ == '__main__' : 
    total_A, total_B = [], []

    while (number = int(raw_input())) != 0 :
        player_A, player_B = AskUser(number)
        score_A, score_B = CalcScore(player_A, player_B)
        total_A.append(score_A)
        total_B.append(score_B)

    for value in range(0, len(total_A)) : 
        print total_A[value], total_B[value]

### FIXED CODE ###

__Author__ = 'Anomino'
# coding:UTF-8


def AskUser(number) : 
    player_A, player_B = [], []
    for value in range(0, number) : 
        answer = raw_input()
        answer = answer.split( )
        player_A.append(int(answer[0]))
        player_B.append(int(answer[1]))

    return player_A, player_B
    
def CalcScore(player_A, player_B) : 
    score_A, score_B = 0, 0

    for value in range(0, len(player_A)) : 
        if player_A[value] < player_B[value] : 
            score_B = score_B + player_A[value] + player_B[value]
        elif player_A[value] > player_B[value] : 
            score_A = score_A + player_A[value] + player_B[value]
        else : 
            score_A = score_A + player_A[value]
            score_B = score_B + player_B[value]

    return score_A, score_B

if __name__ == '__main__' : 
    total_A, total_B = [], []
    number = int(raw_input())

    while number != 0 :
        player_A, player_B = AskUser(number)
        score_A, score_B = CalcScore(player_A, player_B)
        total_A.append(score_A)
        total_B.append(score_B)
        number = int(raw_input())

    for value in range(0, len(total_A)) : 
        print total_A[value], total_B[value]
if m<=n or i ==1:
    print(0)
else:
    n,m = map(int,input().split())
    x = list(map(int,input().split()))
    x_delta=[]
    x.sort()
    for i in range(len(x)-1):
        delta = x[i+1] - x[i]
        x_delta.append(delta)
    print(sum(sorted(x_delta)[:m-n]))

### FIXED CODE ###

n,m = map(int,input().split())
x = list(map(int,input().split()))
if m<=n :
    print(0)
else:
    x_delta=[]
    x.sort()
    for i in range(len(x)-1):
        delta = x[i+1] - x[i]
        x_delta.append(delta)
    print(sum(sorted(x_delta)[:m-n]))