Harryxun/stf_run huggingface dataset:
import copy
import sys
from collections import deque
H, W = map(int,input().split())
C_h, C_w = list(map(lambda x: int(x) - 1, input().split()))
D = list(map(lambda x: int(x) - 1, input().split()))
S = [input() for _ in range(H)]
check_visited = [[False] * W for _ in range(H)]
dq = deque([[0, C_h, C_w]])
while dq:
   d, i, j = dq.popleft()
   if [i, j] == D:
      print(d)
      exit()
   if check_visited[i][j]:
      continue
   check_visited[i][j] = True
   for move_h, move_w in [[-1,0], [1,0], [0,-1], [0,1]]:
      i += move_h
      j += move_w
      if 0 <= i <= H-1 and 0 <= j <= W-1 and S[i][j] == '.' and (not check_visited[i][j]) :
         dq.appendleft([d, i, j])
   for move_h in range(-2, 3):
      for move_w in range(-2, 3):
         if [move_h, move_w] == [0, 0]:
            continue
         i += move_h
         j += move_w
         if 0 <= i <= H-1 and 0 <= j <= W-1 and S[i][j] == '.' and (not check_visited[i][j]) :
            dp.append([d+1, i, j])
print(-1)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
S = [input().rstrip() for _ in range(H)]
visited = [[False] * W for _ in range(H)]
dq = deque([(0, Ch, Cw)])
while dq:
    d, i, j = dq.popleft()
    if (i, j) == (Dh, Dw):
        print(d)
        exit()
    if visited[i][j]:
        continue
    visited[i][j] = True
    for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.':
            dq.appendleft((d, ni, nj))
    for di in range(-2, 3):
        for dj in range(-2, 3):
            if di == dj == 0:
                continue
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.' and not visited[ni][nj]:
                dq.append((d + 1, ni, nj))
print(-1)
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

counter = 0
for i in range(N):
    counter += B[i]
    if i != 0 and A[i] - 1 == A[i-1]:
        counter += C[i]
print(counter)


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

counter = 0
for i in range(N):
    # print(i)
    num = A[i] - 1
    counter += B[num]
    # print('Add:', B[num])
    if i != 0 and num - 1 == A[i-1] - 1:
        counter += C[num-1]
        # print('Add:', C[num-1])
    # print('')
print(counter)
from scipy import ndimage
import numpy as np

 
H, W = map(int, input().split())
 
A_array = np.array(
    [[0 if s == "#" else 1 for s in input()[:-1]] for i in range(H)])
# print(A_array)
 
# print(A_array)
b = ndimage.morphology.distance_transform_cdt(
    A_array, metric="taxicab")
print(np.max(b))

### FIXED CODE ###

from scipy import ndimage
import numpy as np

 
H, W = map(int, input().split())
 
A_array = np.array(
    [[0 if s == "#" else 1 for s in input()] for i in range(H)])
# print(A_array)
 
# print(A_array)
b = ndimage.morphology.distance_transform_cdt(
    A_array, metric="taxicab")
print(np.max(b))
n = int(input())
p = [list(map(int,input().split())) for i in range(n)]


a = p[0]
b = 0
ans  = 0
tf = 1

for j in range(n):
  if sum(p[j]) // 2 *2 ==sum(p[j]):
    ans += 1
  else:
    ans = 0
  if ans ==3:
    tf = 0
    print("Yes")
    break
    
if tf == 1:
  print("No")

### FIXED CODE ###

s = input()
 
if s[-1] == "s":
  print(s + "es")
else:
  print(s + "s")
def factorial(n):
    if n == 1:
        return 1
    else:
        return n + factorial(n - 1)


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

diff = b - a

print(factorial(diff) - b)

### FIXED CODE ###

def factorial(n):
    if n == 1:
        return 1
    else:
        return n + factorial(n - 1)


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

diff = b - a

print(factorial(diff - 1) - a)
import math
n=int(input());print(round(2**(math.log(n,2)//1)))

### FIXED CODE ###

s=input();print(s[0]+str(len(s)-2)+s[-1])
n = int(input())
list = list(map(int,input().split(' ')))

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))  
    return list.index(min(diffList))

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )

### FIXED CODE ###

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

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)
n = int(input())
a = list(map(int, input().split()))
print("{:.10f}"sum(list(map(lambda x: 1/x, a))))


### FIXED CODE ###

int(input())
a = list(map(int, input().split()))
print("{:.10f}".format(1/sum(list(map(lambda x: 1/x, a)))))
import intertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
  abcd.append(input())
for X in intertools.conbinations_with_replacemant(range(1, M + 1), N):
  tmp = 0
  for z in abcd:
    a, b, c, d = map(int, z.split())
    if X[b - 1] - X[a - 1] == c:
      tmp += d
  ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

import itertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
  abcd.append(input())
for X in itertools.combinations_with_replacement(range(1, M + 1), N):
  tmp = 0
  for z in abcd:
    a, b, c, d = map(int, z.split())
    if X[b - 1] - X[a - 1] == c:
      tmp += d
  ans = max(ans, tmp)
print(ans)
from collections import defaultdict


def solve(n, cards):
    dp = {(1 << n) - 1: {0: 0}}
    for d in range(n):
        ndp = defaultdict(lambda: defaultdict(lambda: 1000000))
        for state, scores in dp.items():
            k = state
            curr = 0
            while k:
                b = k & -k
                i = b.bit_length() - 1
                num = cards[i][(d - i) % 2]
                curr_dp = ndp[state ^ b]
                for score, left_num in scores.items():
                    if left_num > num:
                        continue
                    curr_dp[score + curr] = min(curr_dp[score + curr], num)
                k ^= b
                curr += 1
        if len(ndp) == 0:
            return -1
        dp = ndp
    return min(dp[0].keys())


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
cards = list(zip(aaa, bbb))
print(solve(n, cards))


### FIXED CODE ###

def iter_bit(k, LIMIT):
    v = (1 << k) - 1

    while v < LIMIT:
        yield v
        x = v & -v
        y = v + x
        v = (v & ~y) // x >> 1 | y


def solve(n, cards):
    dp = [{} for _ in range(1 << n)]
    dp[-1][0] = 0
    LIMIT = 1 << n

    for d in range(n):
        for state in iter_bit(n - d, LIMIT):
            scores = dp[state]
            k = state
            curr = 0
            while k:
                b = k & -k
                i = b.bit_length() - 1
                num = cards[i][(d - i) % 2]
                next_dp = dp[state ^ b]
                for left_num, score in scores.items():
                    if left_num > num:
                        continue
                    ns = score + curr
                    if num not in next_dp or next_dp[num] > ns:
                        next_dp[num] = ns
                k ^= b
                curr += 1

    if len(dp[0]) > 0:
        return min(dp[0].values())
    else:
        return -1


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
cards = list(zip(aaa, bbb))
print(solve(n, cards))
x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
Pl = 0
Ql = 0
Rb = 0

P.sort(reverse = True)
Q.sort(reverse = True)
R.sort(reverse = True)

P = P[0:x]
Q = Q[0:y]

while P[-1 - Pl] < R[0] or Q[-1 - Ql] < R[0]:
    if Q[-1 - Ql] >= P[-1 - Pl]:
        P[-1 - Pl] = R[0 + Rb]
        #P.sort(reverse = True)
        Pl = Pl + 1
    else:
        Q[-1 - Ql] = R[0 + Rb]
        #Q.sort(reverse=True)
        Ql = Ql + 1

    Rb = Rb + 1
    if Rb == len(R):
        break

print(sum(P) + sum(Q))

### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
Pl = 0
Ql = 0
Rb = 0

P.sort(reverse = True)
Q.sort(reverse = True)
R.sort(reverse = True)

P = P[0:x]
Q = Q[0:y]

#while (P[-1 - Pl] < R[0 + Rb] or Q[-1 - Ql] < R[0 + Rb]):
#while (P[-1 - Pl] < R[0 + Rb] or Q[-1 - Ql] < R[0 + Rb]) and (Pl != len(P) or Ql != len(Q)):
while Pl != len(P) or Ql != len(Q):
    if Pl == len(P):
        if Q[-1 - Ql] < R[0 + Rb]:
            Q[-1 - Ql] = R[0 + Rb]
            Ql = Ql + 1
        else:
            break
    elif Ql == len(Q):
        if P[-1 - Pl] < R[0 + Rb]:
            P[-1 - Pl] = R[0 + Rb]
            Pl = Pl + 1
        else:
            break

    elif Q[-1 - Ql] >= P[-1 - Pl] and P[-1 - Pl] < R[0 + Rb]:
        P[-1 - Pl] = R[0 + Rb]
        Pl = Pl + 1
    elif P[-1 - Pl] > Q[-1 - Ql] and Q[-1 - Ql] < R[0 + Rb]:
        Q[-1 - Ql] = R[0 + Rb]
        Ql = Ql + 1

    else:
        break

    Rb = Rb + 1
    if Rb == len(R):
        break

print(sum(P) + sum(Q))
a,b=map(int,input().split())
print((b-a-1)(b-a-2)/2)

### FIXED CODE ###

a,b=map(int,input().split())
print((b-a)*(b-a+1)//2-b)
n = int(input())
d = list(map(int,input().split()))
p = 0
q = 0
m = 0
d.sort()
if (len(d))%2 == 0:
  m = (d[(len(d)//2)-1]+d[len(d)//2])/2
else:
  m = d[(len(d)//2)]
for i in range(len(d)):
  if d[i]>=m:
    if d[i] == d[i+1]:
      p = d[i]
      q = d[i+1]
    else:
      p = d[i]
      q = d[i-1]
      break
print(p-q)

### FIXED CODE ###

n = int(input())
d = sorted(list(map(int,input().split())))
print(d[n//2]-d[n//2-1])
import sys
n, m = map(int, input().split())
a_list = []
for i in range(m):
    a_i = int(input())
    a_list.append(a_i)
    a_list = list(set(a_list))
#print(n, m, a_list)
#print(a_list)
m = len(a_list)
flag = 0

def stepup(x):
    #x段
    ans = 0
    for i in range(x):
        if i==0:
            two_before=1
            ans=1
        elif i==1:
            one_before=2
            ans=2
        else:
            #print(two_before, one_before)
            ans = one_before+two_before
            two_before = one_before
            one_before = ans
    return(ans)
        
a_list.sort()
#print(stepup(5))
#print(a_list)
for i in range(m):
    if i==0:
        if a_list[i]==1:
            count = 1
            continue
        else:
            count = stepup(a_list[0]-1)
    else:
        if a_list[i]-a_list[i-1]==1:
            #print(a_list[i], a_list[i-1])
            flag = 1
            break
        else:
            #print(stepup(23))
            #print(i, stepup(a_list[i]-a_list[i-1]))
            count *= stepup(a_list[i]-a_list[i-1]-2)
    #print(count)
if n-a_list[i]==1:
    pass
else:
    count *= stepup(n-a_list[i]-1)
#print(count)

if flag==1:
    print(0)
else:
    print(count%1000000007)
#print((stepup(20)**4 * stepup(10))%1000000007)


### FIXED CODE ###

# coding: utf-8

n, m = map(int, input().split())
z = 10**9 + 7

ans = [1]
if m != 0:
    a_i = int(input())
else:
    a_i = 0
m_count = 1
if a_i == 1:
    ans.append(0)
    if m_count < m:
        a_i = int(input())
        m_count += 1
else:
    ans.append(1)
        
for i in range(2, n+1):
    if a_i == i:
        ans.append(0)
        if m_count < m:
            a_i = int(input())
            m_count += 1
    else:
        ans.append(ans[i-1]+ans[i-2])
        
# print(ans, ans[67])
print(int(ans[-1]%z))
N = int(input())
arr = list(map(int,input().split()))
num = 0
tmp = 0

for data in arr:
	if data >= tmp:
		num += 1
		tmp = data

print(num)


### FIXED CODE ###

A, B = input().split()
A = int(A)
B = int(B)
AA = A * 2 - 1
AB = A + B
BB = B * 2 - 1

print(max(AA, AB, BB))
l=list(map(int,input().split()))
a=l[0]
p=l[1]
print((3a+p)//2)

### FIXED CODE ###

l=list(map(int,input().split()))
a=l[0]
p=l[1]
print((3*a+p)//2)
from collections import deque
n,k=map(int, input().split())

A = deque(map(int, input().split()))
li = []
li.append(1)

next = 0
t=0
for i in range(n):
    li.append(A[next])
    next = A[next]-1

    if A[next] in li:
        t = li.index(A[next])
        break


tmp = k%len(li[t:]) - len(li[0:t])

g=li[t:]
print(g[tmp])


### FIXED CODE ###

from collections import deque
n,k=map(int, input().split())

A = deque(map(int, input().split()))
li = []
li2 = [0]*n
li.append(1)

next = 0

t=0
rep = False

for i in range(k):
    if i == k:
        print(next+1)
        exit()

    if li2[next] == 1:
        t = li.index(next+1)
        rep = True
        li.pop()
        break

    li.append(A[next])
    li2[next] = 1
    next = A[next]-1


tmp = (k-t)%len(li[t:])
print(li[tmp+t])
from decimal import *

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

for i in range(n):
    T[i] = Decimal(T[i])

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return max(x, y)

ans = Decimal(1)
for i in range(n):
    ans = ans * T[i] / gcd(ans, T[i])
    #ans = int(ans + 0.1)
print(ans)

### FIXED CODE ###

from decimal import *

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

for i in range(n):
    T[i] = Decimal(T[i])

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return max(x, y)

ans = Decimal(1)
for i in range(n):
    if ans % T[i] != 0:
        ans = ans * T[i] / gcd(ans, T[i])
    #ans = int(ans + 0.1)
    #print(ans)
print(int(ans))
A, B = input().split()
 
if int(A) >= 13:
  print(B)
elif int(A) <=5:
  print(str(0))
else:
  print(str(B//2))

### FIXED CODE ###

A, B = input().split()
 
if int(A) >= 13:
  print(B)
elif int(A) <=5:
  print(str(0))
else:
  print(str(int(B)//2))
def main():
	n,m,q = map(int,input().split())
	qu = [list(map(int,input().split())) for x in range(q)]
	ans = 0
	import itertools

	ans_list = set()
	for i in itertools.combinations_with_replacement([1,2,3,4,5,6,7,8,9,10],m):
		for qul in range(q):
			if i[ qu[qul][1]-1 ] - i[ qu[qul][0]-1 ] == qu[qul][2]:
				ans += qu[qul][3]
		ans_list.add(ans)
		ans = 0
	print(max(ans_list))

if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	n,m,q = map(int,input().split())
	qu = [list(map(int,input().split())) for x in range(q)]
	ans = 0
	import itertools

	ans_list = set()
	for i in itertools.combinations_with_replacement(list(range(1,m+1)),n):
		for qul in range(q):
			if i[ qu[qul][1]-1 ] - i[ qu[qul][0]-1 ] == qu[qul][2]:
				ans += qu[qul][3]
		ans_list.add(ans)
		ans = 0
	print(max(ans_list))

if __name__ == '__main__':
	main()
N=int(input())
S=input()
ans=0
if N%2==0:
  for i in range(N/2):
    if S[i]==S[i+N/2]:
      ans+=1
if ans==N/2:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N=int(input())
S=input()
ans=0
if N%2==0:
  for i in range(N//2):
    if S[i]==S[i+(N//2)]:
      ans+=1
if ans==N/2:
  print('Yes')
else:
  print('No')
input_a = input()
input_b = input()
a = int(input_a)
b = int(input_b)

if a * b % 2 == 0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

def main():
    a, b = [int(_) for _ in input().split()]
    print("Even") if a * b % 2 == 0 else print("Odd")

main()
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict,deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(W) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

visit=defaultdict(lambda: 0) #未訪問:0 訪問済み:1
d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((CH,CW))
d[(CH,CW)]=0

while q:
    fro_h, fro_w=q.popleft()
    visit[(fro_h, fro_w)]=1
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and visit[(to_h, to_w)]==0:
            visit[(to_h, to_w)]=1
            d[(to_h, to_w)]=d[(fro_h, fro_w)]
            q.appendleft((to_h, to_w))

print d[(DH,DW)]

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]
L()=lambda:list(map(int,input().split()))
I()=lambda:input()
s=I()
d=["Sunny","Cloudy","Rainy","Sunny"]
print(d[d.index(s)+1])

### FIXED CODE ###

L=lambda:list(map(int,input().split()))
I=lambda:input()
s=I()
d=["Sunny","Cloudy","Rainy","Sunny"]
print(d[d.index(s)+1])
N = map(int. input().split())
for x, n in enumarate(N, 1):
  if n == 0:
    print(x)
    break

### FIXED CODE ###

N = map(int, input().split())
for x, n in enumerate(N, 1):
  if n == 0:
    print(x)
    break
import heapq
from collections import defaultdict
n, k = map(int, input().split())
td = [list(map(int, input().split())) for _ in range(n)]

td = sorted(td, key = lambda x: x[1], reverse = True)
sushi_types = set([])
sushi_tops = []
sushi_remains = []
for t, d in td:
    if not t in sushi_types:
        sushi_types.add(t)
        sushi_tops.append((t, d))
    else:
        sushi_remains.append((t, d))

n_types = len(sushi_types)
ans = sum([d for _, d in sushi_tops][:k]) + k**2
answers = [ans]
eat_types = set([t for t, _ in sushi_tops][:k])
i = 0
for t, d in sushi_tops[::-1]:
    eat_types.remove(t)
    while i < len(sushi_remains):
        t_r, d_r = sushi_remains[i]
        if t_r not in eat_types:
            i += 1
        else:
            ans = ans - d + d_r - (2*len(eat_types)+1)
            answers.append(ans)
            break
    # print(ans, (t, d), len(eat_types))
print(max(answers))

### FIXED CODE ###

n, k = map(int, input().split())
td = [list(map(int, input().split())) for _ in range(n)]

td = sorted(td, key = lambda x: x[1], reverse = True)
eat_types = set()
sushi_dup = []
value = 0
for t, d in td[:k]:
    if not t in eat_types:
        eat_types.add(t)
    else:
        sushi_dup.append(d)
    value += d

ans = value + len(eat_types)**2
for t, d in td[k:]:
    if len(sushi_dup) == 0:
        break
    
    if t in eat_types:
        continue
    else:
        eat_types.add(t)
        r = sushi_dup.pop()
        value += d - r
        ans = max(ans, value + len(eat_types)**2)
print(ans)
S = list(input())
   
ans = []
pre = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G'or s == 'T':
        pre += 1
    else:
        ans.append(pre)
        pre = 0

print(max(ans))


### FIXED CODE ###

S = list(input())
   
ans = []
pre = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        pre += 1
    else:
        ans.append(pre)
        pre = 0

ans.append(pre)
print(max(ans))
S = input()

s = S % 60
m = int(S / 60) % 60
h = int(int(S / 60) / 60)

print('%d:%d:%d' % (h,m,s))

### FIXED CODE ###

S = int(input())

s = S % 60
m = int(S / 60) % 60
h = int(int(S / 60) / 60)

print('%d:%d:%d' % (h,m,s))
n = int(input())
a = list(map(int, input().split()))
d = [0]*n
count = 0
for el in a:
    temp = a.count(el)
    count += temp-1
    d[el] = temp
count //= 2
for el in a:
    print(count - d[el]+1)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)
import bisect
import math
from scipy.misc import comb

N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)

mini = List[A-1]
ans = 0

if List[A-1] != List[A]:
  ans = sum(List[:A])/A
  print(ans)
  print(1)

else:
  num = List.count(List[A-1])
  List = sorted(List)
  num2 = N - bisect.bisect_right(List,List[A-1])
  List = sorted(List, reverse=True)
  
  if List[0] != List[A-1]:
    B = A
  for i in range(B-A+1):
    n = num
    kosuu = A + i - num2
    ans  = int(ans +  (math.factorial(n - kosuu) * math.factorial(kosuu)))
  
  ave = int(sum(List[:A])/A)
  print(ave)
  print(ans)

### FIXED CODE ###

import bisect
import math
from scipy.misc import comb

N,A,B=map(int,input().split())
List=list(map(int,input().split()))
List = sorted(List, reverse=True)

mini = List[A-1]
ans = 0

if List[A-1] != List[A]:
  ans = sum(List[:A])/A
  print(ans)
  print(1)

else:
  num = List.count(List[A-1])
  List = sorted(List)
  num2 = N - bisect.bisect_right(List,mini)
  List = sorted(List, reverse=True)
  
  if List[0] != List[A-1]:
    B = A
  for i in range(B-A+1):
    n = num
    kosuu = A + i - num2
    ans  = int(ans + comb(n, kosuu, exact=True))
  
  ave = int(sum(List[:A])/A)
  print(ave)
  print(ans)
while True:
    try:
        h = 0
        for i in range(8):
            tmp = raw_input()
            if int(tmp) = 0:
                a[h] = tmp
                h += 1
        if h == 1:
            print "C"
        elif h == 2:
            c = a[0].index(1) - a[1].index(1)
            if c == 0:
                print "A"
            elif c == -1:
                print "E"
            else:
                print "G"
        elif h == 3:
            c = a[0].index(1) - a[2].index(1)
            print "D" if c == 1 else "F"
        else:
            print "B"

    except:
        break

### FIXED CODE ###

while True:
    try:
        h = 0
        a=["","","",""]
        for i in range(8):
            tmp = raw_input()
            if int(tmp) != 0:
                a[h] = tmp
                h += 1
    	if h == 1:
            print "C"
        elif h == 2:
            c = a[0].index("1") - a[1].index("1")
            if c == 0:
                print "A"
            elif c == -1:
                print "E"
            else:
                print "G"
        elif h == 3:
            c = a[0].index("1") - a[2].index("1")
            print "D" if c == 1 else "F"
        else:
            print "B"
    	raw_input()
    except:
	break
list = int(input().split())
N = list[0]

list_1 = int(input().split())
M = sum(list_1)

if M-N > 0 :
  print(M-N)
else:
  print(-1)


### FIXED CODE ###

n, m = [int(num) for num in input().split()]
assments = sum(int(num) for num in input().split())
if n - assments < 0:
    print(-1)
else:
    print(n - assments)
a,b = map(int,input().split())
if (a+b) % 2 ==0:
  print((a + b)// 2)
else:
  print("IMPOSSIBLE")


### FIXED CODE ###

a, b, c = map(int, input().split())
print(max(-a + b + c, 0))
a, b, c = map(int, input().split())
print(max(a, b, c) * 9 + sum(a, b, c))


### FIXED CODE ###

a, b, c = map(int, input().split())
print(max(a, b, c) * 9 + a + b + c)