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

A, B = map(int, input().split())

i = 1

while True:
  
  if i % A == 0 and i % B == 0:
    print(i)
    exit()
    
  i += 1
  


### FIXED CODE ###

import numpy as np

A, B = map(int, input().split())

print(np.lcm(A, B))
### BUGGY CODE ###

import fractions
from functools import reduce
import collections

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a = list(map(int, input().split()))
a=set(a)
a=list(a)
n1=len(a)

v=[]

x=lcm_list(a)

for i in range(n1):
    for j in range(x//a[i]):
        v.append(a[i]*j+a[i]//2)

v = collections.Counter(v)
v=v.most_common()

if v[0][1]!=n1:
    print(0)
else:
    print((m-v[0][0])//x+1)

### FIXED CODE ###

import fractions
from functools import reduce
import collections

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)



n, m = map(int, input().split())
a = list(map(int, input().split()))
a=set(a)
b=list(a)
n1=len(b)
count=0
v=[]

x=lcm_list(b)

for i in range(n1):
    while b[i]%2==0:
        b[i]=b[i]//2
        count+=1
    v.append(count)
    count=0

for i in range(n1-1):
    if v[i]!=v[i+1]:
        print(0)
        exit()

print((m-x//2)//x+1)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	s = input()
	sumc = []
	sumr = 0
	sumg = 0
	sumb = 0
	for i in range(n):
		if s[i] == "R":
			sumr += 1
		if s[i] == "G":
			sumg += 1
		if s[i] == "B":
			sumb += 1
		sumc.append({
			"R" : sumr,
			"G": sumg,
			"B": sumb
			})
	a = {"R": 0, "G": 1, "B": 2}
	case = 0
	log.print(sumc)
	for i in range(n):
		for j in range(i+1, n-1):
			l = j - i
			if s[i] == s[j]:
				continue
			rgb = list("RGB")
			rgb.pop(rgb.index(s[i]))
			rgb.pop(rgb.index(s[j]))
			case += sumc[n-1][rgb[0]] - sumc[j][rgb[0]]
			if j + l < n and s[j+l] == rgb[0]:
				case -= 1
			log.print(i, j, rgb, case)
	print(case)




	


main()

### FIXED CODE ###

#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	s = input()
	sumc = []
	sumr = 0
	sumg = 0
	sumb = 0
	for i in range(n):
		if s[i] == "R":
			sumr += 1
		if s[i] == "G":
			sumg += 1
		if s[i] == "B":
			sumb += 1
		sumc.append({
			"R" : sumr,
			"G": sumg,
			"B": sumb
			})
	a = {"R": 0, "G": 1, "B": 2}
	case = 0
	log.print(sumc)
	for i in range(n):
		for j in range(i+1, n-1):
			l = j - i
			if s[i] == s[j]:
				continue
			rgb = list("RGB")
			rgb.pop(rgb.index(s[i]))
			rgb.pop(rgb.index(s[j]))
			case += sumc[n-1][rgb[0]] - sumc[j][rgb[0]]
			if j + l < n and s[j+l] == rgb[0]:
				case -= 1
			log.print(i, j, rgb, case)
	print(case)




	


main()
### BUGGY CODE ###

# 約数列挙
def make_divisors(value):
    divisors = []
    # int(n ** 0.5) は valueの平方根（小数点以下切り捨て）
    for i in range(1, int(value ** 0.5) + 1):
        if value % i == 0:
            divisors.append(i)              # 約数の下半分を追加
            if i != value // i:             # iが中央値なら下記を飛ばす
                divisors.append(value//i)   # 約数の上半分を追加
    # ソートする場合は下記コメントをはずす
    # divisors.sort()
    return divisors

N = int(input())
a = list(map(int, input().split()))
memo = [0] * N
anser = []
for i in range(N - 1, -1, -1):
    if (a[i] == 1 and memo[i] == 0) or (a[i] == 0 and memo[i] == 1):
        anser.append(i + 1)
        # iの約数を抽出
        divisors = make_divisors(i + 1)
        for j in divisors:
            memo[j - 1] = (memo[j - 1] + 1) % 2

print(len(anser))
if len(anser) >=  1:
    print(" ".join(map(str, anser)))


"""
3
1 1 0

"""

### FIXED CODE ###

# 約数列挙
def make_divisors(value):
    divisors = []
    # int(n ** 0.5) は valueの平方根（小数点以下切り捨て）
    for i in range(1, int(value ** 0.5) + 1):
        if value % i == 0:
            divisors.append(i)              # 約数の下半分を追加
            if i != value // i:             # iが中央値なら下記を飛ばす
                divisors.append(value//i)   # 約数の上半分を追加
    # ソートする場合は下記コメントをはずす
    # divisors.sort()
    return divisors
 
N = int(input())
a = list(map(int, input().split()))
memo = [0] * N
anser = []
for i in range(N - 1, -1, -1):
    if (a[i] == 1 and memo[i] == 0) or (a[i] == 0 and memo[i] == 1):
        anser.append(i + 1)
        # iの約数を抽出
        divisors = make_divisors(i + 1)
        for j in divisors:
            memo[j - 1] = (memo[j - 1] + 1) % 2
 
print(len(anser))
if len(anser) >=  1:
    print(" ".join(map(str, anser)))
### BUGGY CODE ###

n = int(input())
arr = list(map(int, input().split()))
acc = arr[0]
for e in arr[1:]:
  acc *= e
if acc > 1e18:
  print(-1)
else:
  print(acc)

### FIXED CODE ###

n = int(input())
arr = list(map(int, input().split()))
if 0 in arr:
    print(0)
    exit()

acc = arr[0]
for i in range(1, n):
    acc *= arr[i]
    if acc > 1e18:
        print(-1)
        exit()
print(acc)
### BUGGY CODE ###

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

count = 0
if(n < 3):
    print(0)
else:
    r_indexs = []
    g_indexs = []
    b_indexs = []
    for index, char in enumerate(s):
        if char == "R":
            r_indexs.append(index)
        elif char == "G":
            g_indexs.append(index)
        else:
            b_indexs.append(index)

    color_indexs = [r_indexs, g_indexs, b_indexs]

    for col_index in range(3):
        i_indexs_list = color_indexs[col_index]
        tmp_index1 = (col_index+1) % 3
        tmp_index2 = (col_index+2) % 3
        
        j_indexs_list = color_indexs[tmp_index1]
        k_indexs_list = color_indexs[tmp_index2]
        for i in i_indexs_list:
            for j in j_indexs_list:
                if i > j:
                    continue
                for k in k_indexs_list:
                    if i > k or j > k:
                        continue
                    if j-i != k-j:
                        count += 1
        
        j_indexs_list = color_indexs[tmp_index2]
        k_indexs_list = color_indexs[tmp_index1]
        for i in i_indexs_list:
            for j in j_indexs_list:
                if i > j:
                    continue
                for k in k_indexs_list:
                    if i > k or j > k:
                        continue                    
                    if j-i != k-j:
                        count += 1
        

print(count)


### FIXED CODE ###

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

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

discount = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = i + 2*(j-i)
        if k > n-1:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            discount += 1

print(r_count*g_count*b_count-discount)
### BUGGY CODE ###

# Big Array
n,k =  list(map(int, input().split()))

A1 = []
for i in range(n):
    a,b = list(map(int, input().split())) 
    A1.append([a]*b)

A2 = []
for s in A1:
    A2.extend(s)
print( sorted(A2)[k-1] )

### FIXED CODE ###

# Big Array
n,k =  list(map(int, input().split()))

A = []
for i in range(n):
    a,b = list(map(int, input().split())) 
    A.append([a,b])
    
A.sort(key=lambda x:x[0])

cnt = 0
for i in range(n):
    cnt += A[i][1]
    if ( cnt >= k ):
        print(A[i][0])
        break
### BUGGY CODE ###

from heapq import heapify,heappop,heappush
N,M,s,t=map(int,input().split())
Graph1=[set() for i in range(N)]
Graph2=[set() for i in range(N)]
inf=float("inf")
for i in range(M):
  u,v,a,b=map(int,input().split())
  Graph1[u-1].add((a,v-1))
  Graph1[v-1].add((a,u-1))
  Graph2[u-1].add((b,v-1))
  Graph2[v-1].add((b,u-1))
  
def dijkstra(s,n,links):
  cost=[inf]*n
  visited=[False]*n
  visited[s]=True
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    visited[hp]=True
    for c,p in links[hp]:
      if not visited[p]:
        if c+hc<=cost[p]:
          cost[p]=c+hc
          heappush(heap,(cost[p],p))
  return cost
 
cost1=dijkstra(s-1,N,Graph1)
cost2=dijkstra(t-1,N,Graph2)

ans=[0]*N
a=inf
for i in range(N)[::-1]:
  a=min(a,cost1[i]+cost2[i])
  ans[i]=10**15-a
for i in ans:
  print(i)

### FIXED CODE ###

from heapq import heapify,heappop,heappush
N,M,s,t=map(int,input().split())
Graph1=[set() for i in range(N)]
Graph2=[set() for i in range(N)]
inf=float("inf")
for i in range(M):
  u,v,a,b=map(int,input().split())
  Graph1[u-1].add((a,v-1))
  Graph1[v-1].add((a,u-1))
  Graph2[u-1].add((b,v-1))
  Graph2[v-1].add((b,u-1))
  
def dijkstra(s,n,links):
  cost=[inf]*n
  visited=[False]*n
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    if not visited[hp]:
      visited[hp]=True
      for c,p in links[hp]:
        if not visited[p]:
          if c+hc<=cost[p]:
            cost[p]=c+hc
            heappush(heap,(cost[p],p))
  return cost
 
cost1=dijkstra(s-1,N,Graph1)
cost2=dijkstra(t-1,N,Graph2)

ans=[0]*N
a=inf
for i in range(N)[::-1]:
  a=min(a,cost1[i]+cost2[i])
  ans[i]=10**15-a
for i in ans:
  print(i)
### BUGGY CODE ###

N=int(input())
X=len(str(N))
INF=10**100
dp=[[INF,INF] for i in range(0,X+1)]
dp[0][0]=0
dp[0][1]=1
for j in range(1,X+1):
    i=N//(10**(X-j))
    dp[j][0]=min(dp[j-1][0]+i%10,dp[j-1][1]+10-i%10)
    if i%10!=9:
        dp[j][1]=min(dp[j-1][1]+9-i%10,dp[j-1][0]+i%10+1)
    else:
        dp[j][1]=dp[j-1][1]+9-i%10
print(dp[X][0])

### FIXED CODE ###

def main():
    N=input()
    X=len(N)
    INF=10**100
    dp=[[INF,INF] for i in range(0,X+1)]
    dp[0][0]=0
    dp[0][1]=1
    for j in range(1,X+1):
        dp[j][0]=min(dp[j-1][0]+int(N[j-1])%10,dp[j-1][1]+10-int(N[j-1])%10)
        if int(N[j-1])%10!=9:
            dp[j][1]=min(dp[j-1][1]+9-int(N[j-1])%10,dp[j-1][0]+int(N[j-1])%10+1)
        else:
            dp[j][1]=dp[j-1][1]+9-int(N[j-1])%10
    print(dp[X][0])

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

r,g,b,n = map(int, input().split())
count = 0
colors = sorted([r,g,b])
for i in range(1+n//colors[2]):
    for j in range(1+n//colors[1]):
        rest = n - i*colors[2] - j*colors[1]
        if rest >= 0 and rest%colors[0] == 0:
            count += 1
print(count)

### FIXED CODE ###

r,g,b,n = map(int, input().split())
count = 0
c0,c1,c2 = sorted([r,g,b])
for i in range(1+n//c2):
    rest1 = n - i*c2
    if rest1 < 0:
        break
    for j in range(1+rest1//c1):
        rest = n - i*c2 - j*c1
        if rest <0:
            break
        elif rest%c0 == 0:
            count += 1
print(count)
### BUGGY CODE ###

import sys;input=sys.stdin.readline
N, = map(int, input().split())
S = []
for _ in range(N):
    s = input().strip()
    S.append(s)
S.sort(key=lambda x:len(x))
D = dict()
dd = set()
R = 0
for s in S:
    l = len(s)
    d = [0]*26
    for c in dd:
        d[c] += 1
    mm = 0
    for i in range(l-1, -1, -1):
        cc = ord(s[i]) - 97
        R += d[cc]
        d[cc] = 0
        if s[i:] in D:
            for c in D[s[i:]]:
                d[c] += 1
        if i == 0:
            f = cc
        mm += 1
    if l != 1:
        if s[1:] not in D:
            D[s[1:]] = set()
        D[s[1:]].add(f)
    else:
        dd.add(f)
print(R)


### FIXED CODE ###

import sys;input=sys.stdin.readline
N, = map(int, input().split())
MOD=67280421310721
S = []
for _ in range(N):
    s = input().strip()
    S.append(s)
S.sort(key=lambda x:len(x))
D = dict()
dd = set()
R = 0
for s in S:
    l = len(s)
    d = [0]*26
    for c in dd:
        d[c] += 1
    tmp=0
    for i in range(l-1, -1, -1):
        ee = ord(s[i]) - 97
        tmp = 100*tmp+(ee+1)
        tmp %= MOD
        R += d[ee]
        d[ee] = 0
        if tmp in D:
            for c in D[tmp]:
                d[c] += 1
        if i == 1:
            nn = tmp
    if l != 1:
        if nn not in D:
            D[nn] = set()
        D[nn].add(ee)
    else:
        dd.add(ee)
print(R)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)


from collections import deque
n, m = map(int, input().split())
g = [[] for i in range(n)]
deg = [0]*n
deg2 = [0]*n
atode = []
for i in range(m):
    s, t = map(int, input().split())
    g[s-1].append(t-1)
    deg[t-1] += 1
    deg2[s-1] += 1
    atode.append((s-1,t-1))

ans = list(v for v in range(n) if deg[v]==0)
deq = deque(ans)
used = [0]*n

while deq:
    v = deq.popleft()
    for t in g[v]:
        deg[t] -= 1
        if deg[t]==0:
            deq.append(t)
            ans.append(t)
# ansがトポロジカル順番

# convert
c = {j:i for i,j in enumerate(ans)}

# まず、O(N)で期待値を求める
e = [-1]*n
#print(g)
def rec(cur):
    if e[cur] != -1:
        return e[cur]
    res = 0
    cnt = 0
    for to in g[cur]:
        res += rec(to)+1
        cnt += 1
    # 0のとき→end
    if cnt:
        res /= cnt
    e[cur] = res
    return e[cur]

rec(0)
ee = [-1]*n
def rec2(cur, s,t):
    # 計算を飛ばせる時
    if c[cur] > c[s]:
        return e[cur]
    # 計算済みのとき
    if ee[cur] != -1:
        return ee[cur]
    # 計算する
    res = 0
    cnt = 0
    for to in g[cur]:
        if cur==s and to ==t:
            continue
        res += rec2(to,s,t)+1
        cnt += 1
    if cnt:
        res /= cnt
    ee[cur] = res
    return ee[cur]

# 何もしなかった時が最小値の候補の内最大
ret = e[0]

# 辺を消す候補はN個
use = [[-1, -1] for i in range(n)]
for s,t in atode:
    if deg2[s] < 2:
        continue
    if use[s][1] < e[t]:
        use[s][0] = t
        use[s][1] = e[t]

for s, (t,cost) in enumerate(use):
    if s == -1:
        continue
    ee = [-1]*n
    rec2(0,s,t)
    ret = min(ret, ee[0])
print(ret)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n)]
    deg2 = [0]*n
    atode = []
    for i in range(m):
        s, t = map(int, input().split())
        g[s-1].append(t-1)
        deg2[s-1] += 1
        atode.append((s-1,t-1))

    ee = [-1]*n
    def rec2(cur, s,t):
        if ee[cur] != -1:
            return ee[cur]
        res = 0
        cnt = 0
        for to in g[cur]:
            if cur==s and to ==t:
                continue
            res += rec2(to,s,t)+1
            cnt += 1
        if cnt:
            res /= cnt
        ee[cur] = res
        return ee[cur]

    rec2(0,-1,-1)
    ret = ee[0]

    use = [[-1, -1] for i in range(n)]
    for s,t in atode:
        if deg2[s] < 2:
            continue
        if use[s][1] < ee[t]:
            use[s][0] = t
            use[s][1] = ee[t]

    for s, (t,cost) in enumerate(use):
        if s == -1:
            continue
        ee = [-1]*n
        rec2(0,s,t)
        ret = min(ret, ee[0])
    print(ret)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import bisect
n = int(input())
l = sorted(list(map(int, input().split())))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans+=bisect.bisect_left(l[j+1:], l[i] + l[j])
print(ans)  

### FIXED CODE ###

import bisect
n = int(input())
l = sorted(list(map(int, input().split())))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans+=bisect.bisect_left(l, l[i] + l[j]) - j - 1
print(ans)
### BUGGY CODE ###

##C - Step
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
    ##print(i,A)
    if A != []:
        Idx = A.index(max(A))
        ans += max(A)*(len(A) - Idx) - sum(A[Idx::])
        del A[Idx::]
    else:
        break
print(ans)

### FIXED CODE ###

##C - Step(TLE)
N = int(input())
A = list(map(int,input().split()))
ans = 0
maxi = 0
for i in A:
    ans += max(0,maxi-i)
    maxi = max(maxi,i)
print(ans)
### BUGGY CODE ###

from collections import deque

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

edges = {}
root = set([i+1 for i in range(n)])
for i in range(n+m-1):
    a,b = map(int,input().split())
    if a not in edges:
        edges[a] = [b]
    else:
        edges[a].append(b)
    root.discard(b)

# print(root.pop())

root = root.pop()
que = deque()
que.append(root)
parent = [0 for i in range(n)]
while True:
    p = que.popleft()
    if p in edges:
        nex = edges[p]
    else:
        nex = []
    for n in nex:
        parent[n-1] = p
        que.append(n)
    if len(que) == 0:
        break

for p in parent:
    print(p)



### FIXED CODE ###

from collections import deque

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

edges = {}
ins = [0 for i in range(n)]
for i in range(n+m-1):
    a,b = map(int,input().split())
    if a not in edges:
        edges[a] = [b]
    else:
        edges[a].append(b)
    ins[b-1] += 1

# print(root.pop())

root = -1
for i in range(n):
    if ins[i] == 0:
        root = i+1
        break
que = deque()
que.append(root)
parent = [0 for i in range(n)]
pbuf = [[] for i in range(n)]
counts = [0 for i in range(n)]
while True:
    p = que.popleft()
    if p in edges:
        nex = edges[p]
        edges.pop(p)
    else:
        nex = []
    for n in nex:
        counts[n-1] += 1
        if counts[n-1] == ins[n-1]:
            parent[n-1] = p
            que.append(n)
    if len(que) == 0:
        break

for p in parent:
    print(p)
### BUGGY CODE ###

import re

n = int(raw_input())
a = re.split('\s', raw_input())

first = ""
second = ""

if (n % 2 == 0):
        for i in range(n):
                if (i % 2 == 0):
                        if (second == ""):
                                second = a[i]
                        else:   
                                second = second + " " + a[i]
                else:   
                        if (first == ""):
                                first = a[i]
                        else:   
                                first = a[i] + " " + first
else:   
        for i in range(n):
                if (i % 2 == 1):
                        if (second == ""):
                                second = a[i]
                        else:   
                                second = second + " " + a[i]
                else:   
                        if (first == ""):
                                first = a[i]
                        else:   
                                first = a[i] + " " + first

print first + " " + second


### FIXED CODE ###

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

import re

n = int(raw_input())
a = re.split('\s', raw_input())

ans = [0]*n

if (n % 2 == 0):
        first = n / 2 - 1
        second = n / 2
        for i in range(n):
                if (i % 2 == 0):
                        ans[second] = a[i]
                        second += 1
                else:   
                        ans[first] = a[i]
                        first -= 1
else:   
        first = (n - 1) / 2
        second = (n - 1) / 2 + 1
        for i in range(n):
                if (i % 2 == 1):
                        ans[second] = a[i]
                        second += 1
                else:   
                        ans[first] = a[i]
                        first -= 1
ans = map(str, ans)
print " ".join(ans)
### BUGGY CODE ###

def main():
    from heapq import heapify,heappushpop
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    heapify(A)
    bcs = [[int(i) for i in input().split()] for _ in range(M)]
    for i in range(M):
        for j in range(bcs[i][0]):
            heappushpop(A,bcs[i][1])
    print(sum(A))
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    bcs = [[int(i) for i in input().split()] for _ in range(M)]
    bcs.sort(reverse=True,key=lambda c:c[1])

    ans = 0
    sel = []
    for a in A:
        if a < bcs[0][1]:
            sel.append(a)
        else:
            ans += a
    sel.sort()
    stock = len(sel)
    cards = []
    for b,c in bcs:
        cards.extend([c] * b)
        if len(cards) >= stock:
            break
    from itertools import zip_longest
    cnt = 0
    for a,card in zip_longest(sel,cards,fillvalue=0):
        if cnt == stock:
            break
        if a < card:
            ans += card
        else:
            ans += a
        cnt += 1
    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

mod = 10**9 + 7
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += a[i]*a[j]

print(ans%mod)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s = [0] * n

for i in range(1, n):
    s[i] = s[i-1] + a[i-1]

ans = 0
for i in range(1, n):
    ans += a[i] * s[i]

mod = 10**9 + 7

# for i in range(n-1):
#     for j in range(i+1, n):
#         ans += a[i]*a[j]

print(ans%mod)
### BUGGY CODE ###

# coding: utf-8
 
N  = int(input())
sum = 0
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
for i in range (N):
    for j in range(N):
        for k in range(N):
            sum += gcd(*[i+1, j+1, k+1])
 
print(sum)


### FIXED CODE ###

# coding: utf-8
 
N  = int(input())
sum = 0
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
for i in range (N):
    for j in range(N):
        for k in range(N):
            sum += gcd(*[i+1, j+1, k+1])
 
print(sum)
### BUGGY CODE ###

import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    l = LIST()
    lis = list(combinations(l, 3))
    #print(lis)
    ans = 0
    for x in lis:
        #print(abs(x[0] - x[1]) , x[2] , x[0] + x[1])
        #print(abs(x[0] - x[1]) < x[2] < x[0] + x[1])
        if abs(x[0] - x[1]) < x[2] < x[0] + x[1]:
            ans +=1
    
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    l = LIST()
    l.sort()
    ans = 0
    #print(l)

    for i in range(n-1):
        for j in range(i+1, n):
            low = l[i]
            high = l[j]

            p = bisect_left(l, low + high)
            #print('i:', i, 'j:', j, '→', max(0, p-j-1))
            ans += max(0, p - j - 1)

    print(ans)

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

def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        h_ = H[i:i+K]
        diff = max(h_) - min(h_)
        if diff < mi:
            mi = diff
    print(mi)
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        diff = H[i+K-1] - H[i]
        if diff < mi:
            mi = diff
    print(mi)
if __name__ == "__main__":
    main()