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

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
a.sort()
ans=0
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b
for i in range(n-k+1):
    ans-=a[i]*combination(n-i-1,k-1)
    ans%=mod
a.sort(reverse=True)
for i in range(n-k+1):
    ans+=a[i]*combination(n-i-1,k-1)
    ans%=mod

print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
mod=10**9+7
ans=0
MOD=10**9+7

factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))
 
 
# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD
for i in range(n-k+1):
    ans-=a[i]*nCr(n-i-1,k-1)%mod
    ans%=mod
a=a[::-1]
for i in range(n-k+1):
    ans+=a[i]*nCr(n-i-1,k-1)%mod
    ans%=mod

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

def resolve():
  N = int(input())
  X = input()
  base_1_count = X.count("1")
  X_int = int(X, 2)

  for i in range(N):
    if X[i] == "1":
      Xi = X_int - 2**(N-i-1)
    else:
      Xi = X_int + 2**(N-i-1)
    count = 0
    while Xi != 0:
      # print(Xi)
      num_of_1 = bin(Xi).count("1")
      Xi %= num_of_1
      count += 1
    # print("~~~~~~~~~~~~~~~")
    print(count)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

def resolve():
  N = int(input())
  X = input()

  if N == 1:
    if X.count("1"):
      print(0)
    else:
      print(1)
    return True

  base_1_count = X.count("1")
  if base_1_count == 0:
    for _ in range(N):
      print(1)
    return True

  X_int = int(X, 2)
  X_int_p = X_int%(base_1_count + 1)

  # RE 対策
  if base_1_count == 1:
    for i in range(N):
      if X[i] == "1":
        print(0)
      else:
        if i == N - 1:
          Xi = X_int_p + 1
        else:
          Xi = X_int_p
        count = 1
        while Xi != 0:
          Xi %= bin(Xi).count("1")
          count += 1
        print(count)
    return True

  X_int_m = X_int%(base_1_count - 1)
  for i in range(N):
    # 初期値計算を高速にやる
    if X[i] == "1":
      temp_1_count = base_1_count-1
      pow_2 = pow(2, N-i-1, base_1_count-1)
      if X_int_m <= pow_2:
        Xi = X_int_m - pow_2 + base_1_count-1
      else:
        Xi = X_int_m - pow_2
    else:
      temp_1_count = base_1_count+1
      Xi = X_int_p + pow(2, N-i-1, base_1_count+1)
      while Xi >= base_1_count+1:
        Xi %= base_1_count+1

    # print("1_c={0}".format(temp_1_count))
    if temp_1_count == Xi:
      print(1)
      continue

    count = 1
    while Xi != 0:
      num_of_1 = bin(Xi).count("1")
      Xi %= num_of_1
      count += 1
    print(count)

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

N = int(input())
S = []
for _ in range(N):
    tmp = input()
    S.append(tmp)

S_unique = set(S)

a = {}
for s in S_unique:
    a[s] = S.count(s)    


maxval = max(a.values())

anss = []
for s in a:
    if a[s] == maxval:
        anss.append(s)

anss = sorted(anss)

for a in anss:
    print(a)



### FIXED CODE ###

from collections import Counter

N = int(input())
S = []
for _ in range(N):
    tmp = input()
    S.append(tmp)

counter = Counter(S)
c_most = counter.most_common()

# a = {}
# for s in S_unique:
#     a[s] = S.count(s)

maxval = c_most[0][1]

anss = []

for s in c_most:
    if s[1] == maxval:
        anss.append(s[0])
    else:
        break

anss = sorted(anss)

for a in anss:
    print(a)
### BUGGY CODE ###

K = int(input())
A = list(map(int,input().split()))
B = [2]
for i in range(K-1,-1,-1):
    a = A[i]
    C = []
    for b in B:
        if b%a==0:
            C.append(b)
    B = []
    if len(C)==0:break
    for c in C:
        for j in range(a):
            if c+j not in B:
                B.append(c+j)
if len(B)==0:
    print(-1)
else:
    B = sorted(B)
    print(B[0],B[-1])

### FIXED CODE ###

K = int(input())
A = list(map(int,input().split()))
B = [2,2]
for i in range(K-1,-1,-1):
    a = A[i]
    bmin = B[0]
    bmax = B[1]
    if bmin%a==0:
        bmin = bmin
    else:
        bmin = (bmin//a+1)*a
    if bmin>bmax:
        B = []
        break
    else:
        if bmax%a==0:
            bmax = bmax+a-1
        else:
            bmax = (bmax//a)*a+a-1
        B = [bmin,bmax]
if len(B)==0:
    print(-1)
else:
    print(B[0],B[1])
### BUGGY CODE ###

import math
import copy
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nuko = 10

a = []
n = iin()
for i in range(n):
    a.append(iin())
for i in range(n):
    b = copy.copy(a)
    b.pop(i)
    print(max(b))

### FIXED CODE ###

import math
import copy
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

a = []
n = iin()
for i in range(n):
    a.append(iin())
    if neko < a[i]:
        neko = a[i]
b = copy.copy(a)
a.remove(neko)
nya = max(a)
for i in range(n):
    if b[i] == neko:
        print(nya)
    else:
        print(neko)
### BUGGY CODE ###

n = int(input())
hoge = [int(input()) for i in range(n)]

for i in range(len(hoge)):
    temp = hoge.copy()
    del temp[i]
    temp.sort()
    print(temp[-1])

### FIXED CODE ###

n = int(input())
hoge = [int(input()) for i in range(n)]
max_value = max(hoge)
second_value = sorted(hoge)[-2]
if max_value == second_value:
    for i in range(len(hoge)):
        print(max_value)
else:
    for i in hoge:
        if i != max_value:
            print(max_value)
        else:
            print(second_value)
### BUGGY CODE ###

H=int(input())-1
K = [list(map(int, input().split())) for i in range(H)]
total_total=[]
for j in range(H):
    total=K[j][0]+K[j][1]
    total_list=[total]
    for i in range(j,H-1):
        c1=K[i][0]
        s1=K[i][1]
        f1=K[i][2]
        c2=K[i+1][0]
        s2=K[i+1][1]
        f2=K[i+1][2]
        if total>s2:
            count=s2
            while total>count:
                count=count+f2
            total=count+c2
        else:
            total=s2+c2
        total_list.append(total)
    total_total.append(total_list)
for i in total_total:
    print(i[-1])
print(0)

### FIXED CODE ###

H=int(input())-1
K = [list(map(int, input().split())) for i in range(H)]
total_total=[]
for j in range(H):
    total=K[j][0]+K[j][1]
    for i in range(j,H-1):
        c1=K[i][0]
        s1=K[i][1]
        f1=K[i][2]
        c2=K[i+1][0]
        s2=K[i+1][1]
        f2=K[i+1][2]
        if total>s2:
            if (total-s2)%f2==0:
                total=total+c2
            else:
                total=((total-s2)//f2+1)*f2+s2+c2
        else:
            total=s2+c2
    print(total)
print(0)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
ln = max(max(a), max(b)) + 1
for i in range(ln):
  y = (1 << (i + 1))
  u = [x % y for x in a]
  v = [x % y for x in b]
  y >>= 1
  u.sort(reverse = True)
  v.sort()
  t = 0
  k = 0
  kk = 0
  for x in u:
    while k < N and x + v[k] < y: k += 1
    t += N - k
    while kk < N and x + v[kk] < y * 2: kk += 1
    t -= N - kk
  k = 0
  kk = 0
  #print(t)
  for x in u:
    while k < N and x + v[k] < y * 2 + y: k += 1
    t += N - k
    while kk < N and x + v[kk] < y * 4: kk += 1
    t -= N - kk
    #print(t)
  #print(u, v, t)
  res ^= t % 2 * y
print(res)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
ln = max(max(a), max(b)).bit_length() + 1
for i in range(ln):
  y = (1 << (i + 1))
  u = [x % y for x in a]
  v = [x % y for x in b]
  y >>= 1
  u.sort(reverse = True)
  v.sort()
  t = 0
  k = 0
  kk = 0
  for x in u:
    while k < N and x + v[k] < y: k += 1
    t += N - k
    while kk < N and x + v[kk] < y * 2: kk += 1
    t -= N - kk
  k = 0
  kk = 0
  #print(t)
  for x in u:
    while k < N and x + v[k] < y * 2 + y: k += 1
    t += N - k
    while kk < N and x + v[kk] < y * 4: kk += 1
    t -= N - kk
    #print(t)
  #print(u, v, t)
  res ^= t % 2 * y
print(res)
### BUGGY CODE ###

N, M = map(int, input().split())
drink = []
cost = 0
d_count = 0


for _ in range(N):
    drink.append(list(map(int, input().split())))
    drink = sorted(drink)

for i in range(N):
    cost += drink[i][0] * drink[i][1]
    d_count += drink[i][1] 
    if d_count > M:
      cost -= drink[i][0] * (d_count - M)
      break
      

print(cost)
    


### FIXED CODE ###

N, M = map(int, input().split())
drink = []
cost = 0
d_count = 0


for _ in range(N):
    drink.append(list(map(int, input().split())))
    
drink = sorted(drink)

for i in range(N):
    cost += drink[i][0] * drink[i][1]
    d_count += drink[i][1] 
    if d_count > M:
      cost -= drink[i][0] * (d_count - M)
      break
      

print(cost)
### BUGGY CODE ###

def insert(x,a):
    a.insert(0,x)
    return a
def delete(x,a):
    if x in a:
        a.remove(x)
    else:
        return
    return a
def deletefirst(a):
    del a[0]
    return a
def deletelast(a):
    del a[-1]
    return a
n=input()
a=[]
for i in xrange(n):
    s=raw_input().split()
    if s[0]=="insert":
        insert(s[1],a)
    elif s[0]=="delete":
        delete(s[1],a)
    elif s[0]=="deleteFirst":
        deletefirst(a)
    else:
        deletelast(a)
print(" ".join(a))

### FIXED CODE ###

from collections import deque
def insert(x,a):
    a.appendleft(x)
def delete(x,a):
    if x in a:
        a.remove(x)
    else:
        return
def deletefirst(a):
    a.popleft()
def deletelast(a):
    a.pop()
n=input()
a=deque()
for i in xrange(n):
    s=raw_input().split()
    if s[0]=="insert":
        insert(s[1],a)
    elif s[0]=="delete":
        delete(s[1],a)
    elif s[0]=="deleteFirst":
        deletefirst(a)
    else:
        deletelast(a)
print(" ".join(a))
### BUGGY CODE ###

import sys
import heapq
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

h=[]
for i in range(n):
    if b[i]>a[i]:
        h.append([-1*b[i],i])
heapq.heapify(h)

loop=0
idx=0
flag=0
while(loop<10**9):
    if not h:
        break
    buf,idx=heapq.heappop(h)
    buf=-1*buf
    if not h:
        flag=1
    else:
        if h[0][0]*-1<buf:
            flag=1
        else:
            flag=0
    while flag and buf >a[idx]:
        buf-=b[(idx-1)%n]+b[(idx+1)%n]
        loop+=1
        if not h:
            flag=1
        else:
            if h[0][0]*-1<buf:
                flag=1
            else:
                flag=0
    b[idx]=buf
    if buf<a[idx]:
        print(-1)
        sys.exit()
    elif buf>a[idx]:
        heapq.heappush(h,[buf*-1,idx])

print(loop)

### FIXED CODE ###

import sys
import heapq

def main():
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))

    h=[]
    for i in range(n):
        if b[i]>a[i]:
            heapq.heappush(h,(b[i]*-1,i))

    loop=0
    idx=0
    while(1):
    #print(b)
        if not h:
            break
        buf,idx=heapq.heappop(h)
        buf=-1*buf

        x=(buf-a[idx])//(b[(idx-1)%n]+b[(idx+1)%n])
        buf-=x*(b[(idx-1)%n]+b[(idx+1)%n])
        loop+=x
        b[idx]=buf
        if x==0:
            #print(b)
            print(-1)
            sys.exit()
        elif buf>a[idx]:
            heapq.heappush(h,(buf*-1,idx))

    print(loop)

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

import operator as op
from functools import reduce
 
def npr(n, r):
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    return numer


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

child_num = [0 for i in range(N)]
for k in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    child_num[a] += 1
    child_num[b] += 1
child_num = [child_num[0]] + [child_num[i] - 1 for i in range(1, N)]


# calculate
min_child = min(child_num)
if K < min_child:
    print(0)
else:
    ans = (K * npr(K - 1, child_num[0])) % q
    for i in range(1, N):
        val = npr(K - 2, child_num[i]) % q
        ans = (ans * val) % q
    print(ans)

### FIXED CODE ###

import operator as op
from functools import reduce
 
def npr(n, r):
    numer = 1
    for k in range(r):
        numer = numer * (n - k)
        numer %= q
    return numer


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

child_num = [0 for i in range(N)]
for k in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    child_num[a] += 1
    child_num[b] += 1

for i in range(1, N):
    child_num[i] -= 1

# calculate
min_child = min(child_num)
if K < min_child:
    print(0)
else:
    ans = (K * npr(K - 1, child_num[0])) % q
    for i in range(1, N):
        val = npr(K - 2, child_num[i]) % q
        ans = (ans * val) % q
    print(ans)
### BUGGY CODE ###

def binaryinsertion(A,x):
    left=0;right=len(A)-1
    while(True):
        if (len(A)==0) :
            A.append(x)
            break
        centre = left + (right-left)//2 - 1
        if(right - left < 2):
            if(x[0]<A[left][0]):A.insert(left,x)
            else :
                if(x[0]<A[right][0]):A.insert(right,x)
                else:A.insert(right+1,x)
            break
        else:
            if(x[0] < A[centre][0]) :
                right = centre - 1
            elif(A[centre][0] < x[0]) :
                left = centre + 1
            else : 
                A.insert(centre,x)
                break

[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
sweep = A[:L]
sweep = sorted(sweep)
ans = [sweep[0][0]]
for i in range(L,N) :
    sweep.remove(A[i-L])
    binaryinsertion(sweep,A[i])
    ans.append(sweep[0][0])
for i in ans[:-1]:
    print(i, end=" ")
print(ans[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**9

def main(): 
    h, n = [int(item) for item in input().split()]
    MAX_LEN = h + 10**4 + 1
    dp = [0] + [INF] * MAX_LEN
    for _ in range(n):
        v, w = map(int, input().split())
        for j in range(h+1):
            tmp = dp[j] + w
            if dp[j] != INF and tmp < dp[j+v]:
                dp[j+v] = tmp
    ans = min(dp[h:])
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**9

def main(): 
    h, n = [int(item) for item in input().split()]
    MAX_LEN = h + 10**4 - 2
    dp = [INF] * MAX_LEN
    dp[0] = 0
    vw = []
    for _ in range(n):
        v, w = map(int, input().split())
        vw.append((v, w))
    vw.sort(reverse=True, key=lambda x:x[0])
    for v, w in vw:
        for j in range(h):
            if dp[j] == INF:
                continue
            tmp = dp[j] + w
            if tmp < dp[j+v]:
                dp[j+v] = tmp
    print(min(dp[h:]))

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

import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def is_ok(l, i, key):
    if l[i] > key:
        return True


def binary_seach(l, key):
    left = -1
    right = len(l)

    while right - left > 1:
        mid = left + (right - left) // 2
        if is_ok(l, mid, key):
            right = mid
        else:
            left = mid

    return right


def main():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    a.sort()
    b.sort()
    c.sort()
    ans = 0
    # すべてのaに対して条件を満たすbを探索(O(N) * O(log N))
    for ai in a:
        b_ind = binary_seach(b, ai)
        ok_b = b[b_ind:]
       # そのbに対して条件を満たすcを探索(O(log N))
        for bi in ok_b:
            c_ind = binary_seach(c, bi)
            ok_c = c[c_ind:]
            ans += len(ok_c)
    print(ans)


main()


### FIXED CODE ###

import bisect
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def main():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    a.sort()
    b.sort()
    c.sort()
    ans = 0
    for bi in b:
        num_a = bisect.bisect_left(a, bi)
        num_c = n - bisect.bisect_right(c, bi)
        ans += num_a * num_c
    print(ans)


main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(int(1e9))
mod = int((1e9) + 7)

S = input()
N = len(S)

p = [1] * (N+1)
for i in range(1, N+1):
    p[i] = p[i-1]
    if S[N-i] == '?':
        p[i] = p[i] * 3
p.reverse()

mem = [[0] * 3 for _ in range(N)]
used = [[0] * 3 for _ in range(N)]
ch = ['A', 'B', 'C']



def dfs(idx, num):
    if num == 3:
        return 1 * p[idx]
    
    if idx == N:
        return 0
    
    if used[idx][num]:
        return mem[idx][num]
    used[idx][num] = 1

    a, b = (0, 0);
    if S[idx] == '?':
        a = dfs(idx + 1, num + 1)    
        b = 3 * dfs(idx + 1, num)
    else:
        if S[idx] == ch[num]:
            a = dfs(idx + 1, num + 1)
        b = dfs(idx + 1, num)
        
    res = (a + b)
    mem[idx][num] = res
    return res

ans = dfs(0, 0) % mod
print (ans)
    


### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e9))
mod = int((1e9) + 7)

S = input()
N = len(S)

p = [1] * (N+1)
for i in range(1, N+1):
    p[i] = p[i-1]
    if S[N-i] == '?':
        p[i] = p[i] * 3 % mod
p.reverse()

mem = [[0] * 3 for _ in range(N)]
used = [[0] * 3 for _ in range(N)]
ch = ['A', 'B', 'C']



def dfs(idx, num):
    if num == 3:
        return 1 * p[idx]
    
    if idx == N:
        return 0
    
    if used[idx][num]:
        return mem[idx][num]
    used[idx][num] = 1

    a, b = (0, 0);
    if S[idx] == '?':
        a = dfs(idx + 1, num + 1)    
        b = 3 * dfs(idx + 1, num)
    else:
        if S[idx] == ch[num]:
            a = dfs(idx + 1, num + 1)
        b = dfs(idx + 1, num)
        
    res = (a + b) % mod
    mem[idx][num] = res
    return res

ans = dfs(0, 0) % mod
print (ans)
### BUGGY CODE ###

from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
cnt = 1
run = []
for i in range(1, len(S)):
    if S[i - 1] == S[i]:
        cnt += 1
    else:
        run.append(cnt)
        cnt = 1
    if i == len(S) - 1:
        run.append(cnt)
if S[0] == '0':
    run = [0] + run
if S[N - 1] == '0':
    run = run + [0]
X = [sum(run[j: j + 2 * K + 1]) for j in range(len(run) - 2 * K) if j % 2 == 0]
if len(X) == 0:
    print(N)
else:
    print(max(X))


### FIXED CODE ###

from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
cnt = 1
run = []
if len(S) == 1:
    run.append(1)
else:
    for i in range(1, len(S)):
        if S[i - 1] == S[i]:
            cnt += 1
        else:
            run.append(cnt)
            cnt = 1
        if i == len(S) - 1:
            run.append(cnt)
if S[0] == '0':
    run = [0] + run
if S[N - 1] == '0':
    run = run + [0]
if len(run) < 2 * K + 1:
    print(sum(run))
    exit()
ans = sum(run[0: 2 * K + 1])
sb = ans
for j in range(2, len(run) - 2 * K):
    if j % 2 == 1:
        continue
    else:
        sb = sb - run[j - 1] - run[j - 2] + run[j + 2 * K] + run[j + 2 * K - 1]
        if sb > ans:
            ans = sb
print(ans)
### BUGGY CODE ###

H, W, M = map(int, input().split())
h_list = [0 for _ in range(H + 1)]
w_list = [0 for _ in range(W + 1)]
bomb = []
for _ in range(M):
    h, w = map(int, input().split())
    h_list[h] += 1
    w_list[w] += 1
    bomb.append([h, w])
h_max = max(h_list)
w_max = max(w_list)
h_index = []
w_index = []
for i in range(H + 1):
    if h_list[i] == h_max:
        h_index.append(i)
for i in range(W + 1):
    if w_list[i] == w_max:
        w_index.append(i)
tmp = -1        
for h in h_index:
    for w in w_index:
        if [h, w] not in bomb:
            tmp = 0
            break
print(h_max + w_max + tmp)

### FIXED CODE ###

H, W, M = map(int, input().split())
h_list = [0 for _ in range(H + 1)]
w_list = [0 for _ in range(W + 1)]
bomb = set([])
for _ in range(M):
    h, w = map(int, input().split())
    h_list[h] += 1
    w_list[w] += 1
    bomb.add((h, w))
h_max = max(h_list)
w_max = max(w_list)
h_index = []
w_index = []
for i in range(H + 1):
    if h_list[i] == h_max:
        h_index.append(i)
for i in range(W + 1):
    if w_list[i] == w_max:
        w_index.append(i)
tmp = -1        
for h in h_index:
    for w in w_index:
        if (h, w) not in bomb:
            tmp = 0
            break
print(h_max + w_max + tmp)
### BUGGY CODE ###

a = int(input())
b = []
c = {}
strings = ''
ans = 0

for i in range(a):
    check = True
    strings = ''.join(sorted(list(input())))
    if strings not in b:
      check = False
      b.append(strings)
      c[strings] = 1
    if check == True:
      ans += c[strings]
      c[strings] += 1

print(ans)

### FIXED CODE ###

a = int(input())
b = {}
strings = ''
ans = 0

for i in range(a):
    check = True
    strings = ''.join(sorted(list(input())))
    if strings not in b.keys():
      check = False
      b[strings] = 1
    if check == True:
      ans += b[strings]
      b[strings] += 1

print(ans)
### BUGGY CODE ###

a=int(input())
b=list(map(int,input().split()))
c=[]
for q in range(a):
    c.append(0)
x=int(1)
j=max(b)
while x<=j:
    for xx in b:
        if xx==x:
            c[x-1]=c[x-1]+1
    x=x+1
for t in range(a):
    print(c[t])

### FIXED CODE ###

# In peace, in love, in war, everything is the same

import math

deg = [0] * 200005
n=int(input())
ar = list(map(int, input().split()))

for i in range(n-1):
    deg[ar[i]] = deg[ar[i]] + 1

for i in range(1, n+1, 1):
    print(deg[i])
### BUGGY CODE ###

a,b,x=map(int, input().split())
count_n=0
for i in range(a,b+1):
    if i%x==0:
        count_n+=1
print(count_n)

### FIXED CODE ###

a,b,x=map(int, input().split())
if (a%x==0):
    print((b//x-a//x)+1)
else:
    print((b//x-a//x))