Harryxun/stf_run huggingface dataset:
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
c=[]
ans=0
for i in range(2001):
    c.append([0,0])
for i in range(n):
    c[a[i]][0]+=1
    for j in range(a[i]+1,2001):
        ans+=c[j][0]
for i in range(1999,-1,-1):
    c[i][0]+=c[i+1][0]
d=0
for i in a:
    d+=c[i+1][0]
print((k*ans+d*(k*(k-1))//2)%mod)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
c=[]
ans=0
for i in range(2002):
    c.append([0,0])
for i in range(n):
    c[a[i]][0]+=1
    for j in range(a[i]+1,2001):
        ans+=c[j][0]
for i in range(1999,-1,-1):
    c[i][0]+=c[i+1][0]
d=0
for i in a:
    d+=c[i+1][0]
print((k*ans+d*(k*(k-1))//2)%mod)
i = list(map(int, input().split()))

def kcd(A, B, K):
    cd_list = []
    for i in range(2, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            cd_list.insert(0,i)
    return cd_list[K - 1]

print(kcd(i[0],i[1],i[2]))
      


### FIXED CODE ###

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

def kcd(A, B, K):
    cd_list = []
    for i in range(1, min(A, B) + 1):
        if A % i == 0 and B % i == 0:
            cd_list.insert(0,i)
    return cd_list[K - 1]

print(kcd(i[0],i[1],i[2]))
n = input().split()
a = int(n[0])
b = int(n[1])
s = a*b
l = 2*a+2*b

print('{} {}'.format(s,l)

### FIXED CODE ###

a,b = map(int,input().split())
s = a * b
l = 2*a + 2*b

print(s,l)
a, b, c=map(int, input().split())
k=max(a+b, a-b)

print(k)

### FIXED CODE ###

a, b=map(int, input().split())
print(max(a*b,a+b,a-b))
import numpy
a,b=map(int,input().split())
print('Odd' if a*b%2==1 else 'Even')

### FIXED CODE ###

a,b=map(int,input().split())
print('Odd' if a*b%2==1 else 'Even')
import math
    a,b,x = map(float,input().split())
    w_theta = math.atan(b / a)
    w_p = 0.5 * a * b * math.sin(w_theta) * math.sqrt(a ** 2 + b ** 2)
    if x >= w_p:
        theta = math.degrees(math.atan((2. * (((a ** 2) * b) - x)) / (a ** 3)))
    else:
        theta = math.degrees(math.atan((a * (b ** 2))/ (2. * x)))
    print(theta)

### FIXED CODE ###

#D
import math
a,b,x = map(float,input().split())
w_theta = math.atan(b / a)
w_p = 0.5 * a * b * math.sin(w_theta) * math.sqrt(a ** 2 + b ** 2)
if x > 0.5*a*a*b:
    theta = math.degrees(math.atan((2. * (((a ** 2) * b) - x)) / (a ** 3)))
else:
    theta = math.degrees(math.atan((a * (b ** 2))/ (2. * x)))
print(theta)
import math
N,K=map(int,input().split()[:2])
modp=10**9+7

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(K):
    ret=0
    if i==0:
        print(N-K+1)
        continue
    tmp=combinations_count(K-1,i) % modp
    tmp2=combinations_count(N-K+1,i+1) % modp
    ret=(tmp*tmp2)%modp
    print(ret)

### FIXED CODE ###

import math
N,K=map(int,input().split()[:2])
modp=10**9+7

def combinations_count(n, r):
    if r > n:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(K):
    ret=0
    if i==0:
        print(N-K+1)
        continue
    tmp=combinations_count(K-1,i) % modp
    tmp2=combinations_count(N-K+1,i+1) % modp
    ret=(tmp*tmp2)%modp
    print(ret)
import numpy as np

n = int(input())

data = np.zeros((n, 3), dtype=np.int64)

for i in range(n):

  data[i] = list(map(int, input().split()))

dp = np.zeros((n+1, 3), dtype=np.int64)

for i in range(n):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i+1][j] = np.maximum(dp[i][k] + data[i][j], dp[i+1][j])

print(np.max(dp[n]))


### FIXED CODE ###

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

dp = [float('inf')] * n

dp[0] = 0

for i in range(1, n):

  dp[i] = min(dp[i], dp[i-1] + abs(li[i] - li[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2] + abs(li[i] - li[i-2]))

print(dp[n - 1])
A, B= input().split()
A = int(A)
B = float(B)
B = B * 100
C = A * B
C = math.floor (C / 100) 
print(int(C))

### FIXED CODE ###

A, B= input().split()
A = int(A)
B = B.replace('.','')
B = int(B)
print(A*B//100)
import networkx as nx

N,M = map(int,input().split())
G = nx.Graph()
for i in range(M):
    A,B = map(int,input().split())
    G.add_edge(A,B)
print("Yes")
pre = nx.predecessor(G,1)
for i in range(2,N+1):
    print(pre[i][0])

### FIXED CODE ###

import networkx as nx

N,M = map(int,input().split())
G = nx.Graph()
for i in range(M):
    A,B = map(int,input().split())
    G.add_edge(A,B)
print("Yes")
pre = nx.predecessor(G,1)
for i in range(2,N+1):
    print(pre[i][0])
h, w = map(int, input().split())
S = [input() for i in range(h)]


picture = []
diff = [-1, 1]

for i_h in range(h):
    row = '...'
    for i_w in range(w):
        if S[i_h][i_w] == '.':continue
        else:
            for dh in diff:
                if (i_h+dh<0) or (i_h+dh>h-1):continue
                if S[i_h+dh][i_w] == '#':
                    row[i_w] = '#'
            for dw in diff:
                if (i_w+dw<0) or (i_w+dw<w-1):continue
                if S[i_h][i_w+dw] == '#':
                    row[i_w] = '#'
    picture.append(row)
    
if picture == S:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

h, w = map(int, input().split())
S = [input() for i in range(h)]


picture = []
diff = [-1, 1]

for i_h in range(h):
    row = ''
    for i_w in range(w):
        can_draw = False
        if S[i_h][i_w] == '.': row = row + '.';continue
        else:
            for dh in diff:
                if (i_h+dh<0) or (i_h+dh>h-1):continue
                if S[i_h+dh][i_w] == '#':
                    can_draw = True
            for dw in diff:
                if (i_w+dw<0) or (i_w+dw>w-1):continue
                if S[i_h][i_w+dw] == '#':
                    can_draw = True
                    
        if can_draw:
            row = row + '#'
        else:
            row = row + '.'
    picture.append(row)
    
if picture == S:
    print('Yes')
else:
    print('No')
L,R=map(int, input().split())

if R-L+1>=2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    if L<R:
        k=L*L(+1)
        print(k)
    else:
        print(0)


### FIXED CODE ###

L,R=map(int, input().split())
 
if R-L+1>=2019:
  print(0)
else:
  L %= 2019
  R %= 2019
  if L<R: 
    m = 2019
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        m = min(m, (i*j)%2019)
    print(m)
  else:
    print(0)
A,B = map(int, input().split())

if A < B:
    print(A+B)
elif A == 0 and B == 0:
    print(0)
elif A != 0 and B==0:
    print(0)
elif A > B:
    print((A+B-24)

### FIXED CODE ###

a, b = map(int, input().split())
if a+b >= 24:
    print(a+b-24)
else:
    print(a+b)
def dp_cost(h, dp, i, n):
    
    new_dp = min(dp[1] + abs(h[i] - h[i - 1]), dp[0] + abs(h[i] - h[i - 2]))
    
    if i == n - 1:
        return new_dp

    dp[0] = dp[1]
    dp[1] = new_dp    
    return dp_cost(h, dp, i + 1, n)

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

if n == 1:
    print(0)
elif n == 2:
    print(abs(h[1] - h[0]))
else:
    dp = [0, abs(h[1] - h[0])]
    print(dp_cost(h, dp, 2, n))

### FIXED CODE ###

import numpy as np

n = int(input())
h = np.array(list(map(int, input().split())))

dp = np.full_like(h, np.inf)

dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, len(h)):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[(len(h) - 1)])
N = int(input())
total = 0
for i in range(1,N+1):
	if i%3 != 0 and i%5! = 0:
		total += i
print(total)    

### FIXED CODE ###

N = int(input())
total = 0
for i in range(1, N+1):
    if (i % 3) != 0 and (i % 5) != 0:
        total = total+i
print(total)
num= int(input().split())
5count = 0
7count = 0

for i in range(len(num)):
  if num[i] == 5:
    5count += 1
  elif num[i] == 7:
    7count += 1
if 5count == 2 and 7count == 1:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

num= input().split()
count5 = 0
count7 = 0
 
for i in range(len(num)):
    if num[i] == '5':
        count5 += 1
    elif num[i] == '7':
        count7 += 1
    else:
        continue
if count5 == 2 and count7 == 1:
    print('YES')
else:
    print('NO')
X,N = map(int, input().split())
num_list = list(map(int, input().split()))
if (len(num_list) == 0) or X not in num_list:
  print(X)
else:
  d = 1
  while True:
	if X - d not in num_list:
      print(X -d)
      break
    elif X + d not in num_list:
      print(X + d)
      break
    else:
      d += 1

### FIXED CODE ###

X,N = map(int, input().split())
num_list = list(map(int, input().split()))
if (len(num_list) == 0) or X not in num_list:
    print(X)
else:
    d = 1
    while True:
        if X - d not in num_list:
            print(X -d)
            break
        elif X + d not in num_list:
            print(X + d)
            break
        else:
            d +=1
def ctoi(x):
  if x == 'A':
    x = 10
  elif x == 'B':
    x = 11
  elif x == 'C':
    x = 12
  elif x == 'D':
    x = 13
  elif x == 'E':
    x = 14
  else:
    x = 15
x, y = input().split()
x = ctoi(x)
y = ctoi(y)
if x > y:
  print('>')
elif x < y:
  print('<')
else:
  print('=')

### FIXED CODE ###

x, y = input().split()
if x < y:
    print("<")
elif x > y:
    print(">")
else:
    print("=")
K -= 1
for i, val in enumerate(elements):
    if i is K:
        print(val)
        break

### FIXED CODE ###

elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
th = K-1
print(elements[th])
a,b = map(int,input().split())

MinNum = 1
MaxNum = gcd(a,b)
PrimeNum_list = []

CheckNum = 0
for i in range(MinNum,MaxNum):
    for j in range(2,i+1):
        if i%j==0: CheckNum+=1
        if CheckNum == 2: break

    if CheckNum == 1 and MaxNum % i == 0:
        PrimeNum_list.append(i)
    CheckNum = 0

print(len(PrimeNum_list)+1)

### FIXED CODE ###

from fractions import gcd

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
  
a = factorization(a)
b = factorization(b)
if (len(a)==1 and a[0] == 1) or (len(b)==1 and b[0] == 1):
  print(1)
else:
  print(len(set(a) & set(b)) + 1)
import sys
import numpy as np

H, W, M = map(int, input().split())
bom = np.zeros((H, W), dtype=int)
for _ in range(M):
    h, w = map(int, input().split())
    bom[h-1, w-1] = 1
tate, yoko = bom.sum(axis=0), bom.sum(axis=1)
tate_max, yoko_max = tate.max(), yoko.max()
tate_list, yoko_list = [], []
for i in range(W):
    if tate[i] == tate_max: tate_list.append(i)
for i in range(H):
    if yoko[i] == yoko_max: yoko_list.append(i)
for h in yoko_list:
    for w in tate_list:
        if not bom[h][w]:
            print(tate_max+yoko_max)
            sys.exit()
print(tate_max+yoko_max-1)

### FIXED CODE ###

import sys
H, W, M = map(int, input().split())
h_list, w_list = [0]*H, [0]*W
check = set()
for _ in range(M):
    h, w = map(int, input().split())
    check.add((h-1, w-1))
    h_list[h-1] += 1
    w_list[w-1] += 1
h_max, w_max = max(h_list), max(w_list)
h_bom = [i for i in range(H) if h_list[i]==h_max]
w_bom = [i for i in range(W) if w_list[i]==w_max]
for h in h_bom:
    for w in w_bom:
        if not (h, w) in check:
            print(h_max+w_max)
            sys.exit()
print(h_max+w_max-1)
h,n = map(int,input().split())
lst = []
for _ in range(n):
  a,b = map(int,input().split())
  lst.append((a/b,a,b))
lst.sort()

_,a,b = lst[-1]

mp  = (h//a) * b
h -= h//a * a
lst.sort(key = lambda x:x[2])
for i in lst:
  if lst[i][1] >=h:
    mp += lst[i][2]
    break
print(mp)
    

### FIXED CODE ###

h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [float('inf') for _ in range(h+max(skills,key=lambda x:x[1])[1] + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==float('inf'):
    continue
  for damage,mp in skills:
    if i+damage >= len(dp):
      continue
    if dp[i+damage] > dp[i] + mp:
      dp[i+damage] = dp[i]+mp
ans = min(filter(lambda x :x>0,dp[h:]))
print(ans)
#print(dp)
def solve(string):
    n, k, *a = map(int, string.split())
    if k == 0:
        x = 0
    else:
        l = len("{:b}".format(k))
        count = [0] * l
        for _a in a:
            tmp = "{:b}".format(_a)
            for i, _f in enumerate(tmp[::-1]):
                if _f == "1":
                    count[l - i - 1] += 1
        x = int("".join(["1" if _c < n / 2 else "0" for _c in count]), 2)
    return str(sum([x ^ _a for _a in a]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


### FIXED CODE ###

def solve(string):
    n, k, *a = map(int, string.split())
    if k == 0:
        x = 0
    else:
        l = len("{:b}".format(k))
        base = [2**(l - i - 1) for i in range(l)]
        count = [0] * l
        for _a in a:
            tmp = "{:b}".format(_a)
            for i, _f in enumerate(tmp[::-1]):
                if i >= l:
                    break
                if _f == "1":
                    count[l - i - 1] += 1
        x = 0
        for _c, _b in zip(count, base):
            if _c < n / 2 and x + _b <= k:
                x += _b
    return str(sum([x ^ _a for _a in a]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
list_a=list(map(int, input().split()))
result=1
for a in range(list_a):
  result = result*a
  
if result > 10**18:
  print('-1')
else:
  print(result)

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b)
N = input()
array= input().split()
left_array=array[:array/3+1]
mid_array= array[array/3+1:-array/3]
right_array= array[-array/3]
lst=[]
for i in N:
    left_array=array[:array/3+i+1]
    l = left_array.sort()[i+1:]
    right_array=array[-array/3+i+1:]
    r = right_array.sort(reverse=True)[N-i-1:]
    ans = sum(abs(l-r))
    if ans > lst:
        lst= ans
print(lst)

### FIXED CODE ###

N = int(input())
array = [int(n) for n in input().split()]
import copy
import heapq
lst = [None for i in range(N + 1)]
left_lst = copy.deepcopy(lst)
right_lst = copy.deepcopy(lst)
left_array = array[:N]
right_array= [-n for n in array[-N:]]
l_sum = sum(left_array)
r_sum = sum(right_array)
heapq.heapify(left_array)
heapq.heapify(right_array)
left_lst[0] = l_sum
right_lst[0] = r_sum

for k in range(N, 2 * N):
    new_a, new_b = array[k], array[-k - 1]*-1
    heapq.heappush(left_array,new_a)
    heapq.heappush(right_array,new_b)
    old_a = heapq.heappop(left_array)
    l_sum += (new_a - old_a)
    left_lst[k - N + 1] = l_sum
    old_b = heapq.heappop(right_array)
    r_sum += (new_b - old_b)
    right_lst[k - N + 1] = r_sum
lst = [ a + b for a, b in zip(left_lst, list(reversed(right_lst)))]
print(max(lst))
from heapq import heappush, heappop, heapify

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

A.sort()
heap = heapify(A)
for i in range(M):
  heappush(heap, heappop()//2)
print(sum(heap))


### FIXED CODE ###

from heapq import heappush, heappop, heapify
import math

N, M = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
A = [-x for x in A]
A.sort()
for i in range(M):
  heappush(A, math.ceil(heappop(A)/2))

print(-sum(A))
src = raw_input()

sp = src.split(" ")

A = int(sp[0])
B = int(sp[1])
T = int(sp[2])
cnt = int(int(T + 0.5) / A )

out = B * cnt
print(out)

### FIXED CODE ###

src = raw_input()

sp = src.split(" ")

A = int(sp[0])
B = int(sp[1])
T = int(sp[2])
cnt = int(int(T + 0.5) / A )

out = B * cnt
print(out)
def gcd(a, b):
  if(a == b):
    return a
  elif(a > b):
    return gcd(a- b, b)
  elif(a < b):
    return gcd(a, b- a)
          

def ggcd(lista):
  if(len(lista) == 1):
    return lista.pop()
  else:
    l = lista.pop()
    for i in range(1, len(lista)):
      l = gcd(l, lista.pop())
    return l

N, X = map(int, input().split())
x = list(map(int, input().split()))
m = min(x)
d = []
gcds = set()
if(X < m):
  d.append(m- X)
else:
  if(N > 1):
    x.sort()
    if(x[1] > X):
      d.append(X- m)
      del x[0]
      x.insert(0, X)
    else:
      d.append(x[1]- x[0])
      del x[0]
      x.insert(0, X)
  else:
    d.append(abs(x[0]- X))
  
x.sort()
  
for i in range(N- 1):
  d.append(x[i+ 1]- x[i])
  
gcds.add(d[0])

for i in range(N- 1):
  if(d[i+ 1] != d[i]):
    gcds.add(d[i+ 1])

print(ggcd(gcds))

### FIXED CODE ###

def gcd(a, b):
  if(a == b):
    return a
  elif(a % b == 0):
    return b
  elif(b % a == 0):
    return a
  elif(a == 1 or b == 1):
    return 1
  elif(a > b):
    return gcd(a- a// b* b, b)
  elif(a < b):
    return gcd(a, b- b// a* a)

def ggcd(lista):
  if(len(lista) == 1):
    return lista.pop()
  else:
    l = lista.pop()
    for i in range(1, len(lista)):
      l = gcd(l, lista.pop())
    return l

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
d = []
gcds = set()
x.sort()

for i in range(N):
  d.append(x[i+ 1]- x[i])

gcds.add(d[0])

for i in range(N- 1):
  if(d[i+ 1] != d[i]):
    gcds.add(d[i+ 1])

print(ggcd(gcds))
import math

def calc_factors(n):
    i = 2
    f = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            f.append(i)
    if n > 1:
        f.append(n)
    return f

A, B = map(int, input().split())
print(max(1,len(calc_factors(math.gcd(A,B)))))

### FIXED CODE ###

import fractions

def calc_factors(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n /= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n /= f
        else:
            f += 2   
    if n != 1: 
        a.append(n)
    return a

A, B = map(int, input().split())
g = fractions.gcd(A,B)
if g == 1:
    print(1)
else:
    print(len(set(calc_factors(g)))+1)
s = str(input())
if s[3] == s[4] and s[5] == s[6]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = str(input())
if s[3] == s[2] and s[5] == s[4]:
    print('Yes')
else:
    print('No')
import sys
from collections import defaultdict
from typing import Callable


def main():
    readline: Callable[[], str] = sys.stdin.readline

    memory: defaultdict = defaultdict(int)

    n: int = int(readline().rstrip())
    for _ in range(n):
        s: str = readline().rstrip()
        memory[s] += 1

    for judge in ("AC", "WA", "TLE", "RE");
        print(f"{judge} x {memory[judge]}")

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import defaultdict
from typing import Callable


def main():
    readline: Callable[[], str] = sys.stdin.readline

    memory: defaultdict = defaultdict(int)

    n: int = int(readline().rstrip())
    for _ in range(n):
        s: str = readline().rstrip()
        memory[s] += 1

    for judge in ("AC", "WA", "TLE", "RE"):
        print(f"{judge} x {memory[judge]}")

if __name__ == '__main__':
    main()
n, m = map(int, input().split())
ss = []
cc = []
num = []

for _ in range(m):
    s, c = map(int, input().split())
    ss.append(s)
    cc.append(c)

for i in range(1, 1000):
    if len(str(i)) != m:
        continue
    cnt = 0
    for s, c in zip(ss, cc):
        if str(i)[s-1] == str(c):
            cnt += 1
    if cnt == len(ss):
        num.append(i)

if num:
    print(min(num))
else:
    print(-1)


### FIXED CODE ###

n, m = map(int, input().split())
ss = []
cc = []
num = []

for _ in range(m):
    s, c = map(int, input().split())
    ss.append(s)
    cc.append(c)

for i in range(1000):
    if len(str(i)) != n:
        continue
    cnt = 0
    for s, c in zip(ss, cc):
        if str(i)[s-1] == str(c):
            cnt += 1
    if cnt == len(ss):
        num.append(i)

if num:
    print(num[0])
else:
    print(-1)
A,B,C = map(int, input().split())
if A=B and B=C:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

A,B,C = map(int, input().split())
if A==B and B==C:
  print('Yes')
else:
  print('No')
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis={0:0}
now=0
for i in range(1,k+1):
  now=a[now]-1
  if now in vis:
    bgn=vis.index(now)
    print(vis[bgn+((k-bgn)%(len(vis)-bgn))]+1)
    sys.exit()
  else:
    vis[i]=now
print(vis[-1]+1)


### FIXED CODE ###

import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis_ti=[-1]*n
vis_at=[0]
now=0
for i in range(1,k+1):
  now=a[now]-1
  if vis_ti[now]>=0:
    bgn=vis_ti[now]
    print(vis_at[bgn+(k-bgn)%(i-bgn)]+1)
    sys.exit()
  vis_ti[now]=i
  vis_at.append(now)
print(vis_at[-1]+1)
a = int.input()
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  else:
    if l[i]>M:
      M=l[i]
    else:
      pass
  
print(M-m)

### FIXED CODE ###

a = int(input())
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  else:
    if l[i]>M:
      M = l[i]
    else:
      pass
print(M-m)
N = int(input())

print(' {}'.format(' '.join([str(c) for c in range(1, N + 1) 
  if c % 3 == 0 or '3' in str(c)])

### FIXED CODE ###

N = int(input())

print(' {}'.format(' '.join([str(c) for c in range(1, N + 1) 
  if c % 3 == 0 or '3' in str(c)])))
n = int(raw_input())
a = map(int raw_input().split())

a.sort()

print (" ".join(map(str, a)))

### FIXED CODE ###

n = int(raw_input())
a = map(int, raw_input().split())

a.sort()

print (" ".join(map(str, a)))
def solve():
    from heapq import heappush, heappop
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    M *= -1
    S = f_i.readline().rstrip()
    
    unvisited = [True] * (N + 1)
    unvisited[N] = False
    rec = [[] for i in range(N + 1)]
    hq = [(0, N)] # (cost, pos)
    
    while hq:
        cost, pos = heappop(hq)
        if pos == 0:
            break
        
        cost += 1
        for r in range(M, 0):
            next_pos = pos + r
            if unvisited[next_pos] and S[next_pos] == '0':
                unvisited[next_pos] = False
                rec[next_pos] = [r] + rec[pos]
                heappush(hq, (cost, next_pos))
    else:
        return -1
    
    return ' '.join(str(-r) for r in rec[0])

print(solve())

### FIXED CODE ###

def solve():
    from collections import deque
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    S = f_i.readline().rstrip()
    
    M *= -1
    pos = N
    rec = deque()
    while pos:
        for move in range(M, 0):
            next_pos = pos + move
            if next_pos >= 0 and S[next_pos] == '0':
                pos = next_pos
                rec.appendleft(move)
                break
        else:
            print(-1)
            break
    else:
        print(' '.join(str(-move) for move in rec))

solve()
import sys
a = []
for l in sys.stdin:
    a.append(int(l))

A,B,K = a[0], a[1], a[2]

if A > K:
  print(str(A-K), str(B))
elif A+B > K:
  print("0", str(A+B-K))
else:
  print("0 0")


### FIXED CODE ###

import sys

def stdin_parse_int():
    a = list(map(int,input().split()))
    return a

list = stdin_parse_int()
A = list[0]
B = list[1]
K = list[2]

if A > K:
    print(str(A-K) + " " + str(B))
elif A+B > K:
    print(str(0) + " " + str(A+B-K))
else:
    print("0 0")
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
def euclid(y,z,d):
	result=0
	for i in range(d):
		result+=(y[i]-z[i])**2
	return math.sqrt(result)


n,d=input2()
X=[input_array() for _ in range(n)]

count=0
for i in range(n):
	for j in range(i+1,n):
		distance=euclid(X[i],X[j],d)
		if (distance%1) == 0:
			count+=1
print(count)

### FIXED CODE ###

import math

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def euclid(y,z,d):
	result=0
	for i in range(d):
		result+=(y[i]-z[i])**2
	return math.sqrt(result)


n,d=input2()
X=[input_array() for _ in range(n)]

count=0
for i in range(n):
	for j in range(i+1,n):
		distance=euclid(X[i],X[j],d)
		if (distance%1) == 0:
			count+=1
print(count)