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

from collections import deque

H,W = list(map(int,input().split()))
D_h = {}
D_w = {}

for h in range(H):
    D_h[h]=deque([-1])
    
for w in range(W):
    D_w[w]=deque([-1])
    
for h in range(H):
    D = list(input())
    for w in range(W):
        if D[w] =='#':
            D_h[h].append(w)
            D_w[w].append(h)
            
    D_h[h].append(W)
    
for w in range(W):
    D_w[w].append(H)
    
Lamp_h = [ [0] * W  for h in range(H) ]

for d_h in D_h.keys():
    obst = D_h[d_h]
    for o_ed in range(1,len(obst)):
        o_st = o_ed-1
        
        o_st = obst[o_st]
        o_ed = obst[o_ed]
        
        for o in range(o_st+1,o_ed):
            Lamp_h[d_h][o] = o_ed-1 - o_st
    
Lamp_w =  [ [0] * H  for w in range(W) ]
for d_w in D_w.keys():
    obst = D_w[d_w]
    for o_ed in range(1,len(obst)):
        o_st = o_ed-1
        
        o_st = obst[o_st]
        o_ed = obst[o_ed]
        
        for o in range(o_st+1,o_ed):
            Lamp_w[d_w][o] = o_ed-1 - o_st
    
ans = 0
for h in range(H):
    for w in range(W):
        ans_ = Lamp_h[h][w] + Lamp_w[w][h] 
        if ans < ans_:
            ans =ans_
        
print(ans-1)

### FIXED CODE ###

from collections import deque

H,W = list(map(int,input().split()))
D_h = {}
D_w = {}

for h in range(H):
    D_h[h]=deque([-1])
    
for w in range(W):
    D_w[w]=deque([-1])
    
for h in range(H):
    D = list(input())
    for w in range(W):
        if D[w] =='#':
            D_h[h].append(w)
            D_w[w].append(h)
            
    D_h[h].append(W)
    
for w in range(W):
    D_w[w].append(H)
    
Lamp_h = [ [0] * W  for h in range(H) ]

for d_h in D_h.keys():
    obst = D_h[d_h]
    for o_ed in range(1,len(obst)):
        o_st = o_ed-1
        
        o_st = obst[o_st]
        o_ed = obst[o_ed]
        
        for o in range(o_st+1,o_ed):
            Lamp_h[d_h][o] = o_ed-1 - o_st
    
Lamp_w =  [ [0] * H  for w in range(W) ]
for d_w in D_w.keys():
    obst = D_w[d_w]
    for o_ed in range(1,len(obst)):
        o_st = o_ed-1
        
        o_st = obst[o_st]
        o_ed = obst[o_ed]
        
        for o in range(o_st+1,o_ed):
            Lamp_w[d_w][o] = o_ed-1 - o_st
    
ans = 0
for h in range(H):
    for w in range(W):
        ans_ = Lamp_h[h][w] + Lamp_w[w][h] 
        if ans < ans_:
            ans =ans_
        
print(ans-1)
### BUGGY CODE ###

import numpy as np
n = int(input())
arr = np.array(list(map(int, input().split())))

arr.sort()

result = np.zeros(n, dtype=np.int32)

for i in range(n):
    if result[i] >= 1:
        continue
    else:
        tmp = np.where(arr % arr[i] == 0)
        result[tmp] += 1
        result[i] -= 1
        if i < n - 1 and arr[i] == arr[i + 1]:
            result[i] += 1

print(np.where(result == 0)[0].shape[0])

### FIXED CODE ###

n = int(input())
arr = list(map(int, input().split()))
arr.sort()

dp = [0] * (10**7)

cnt = 0
for i in range(n):
    if dp[arr[i]] == 0:
        for j in range(1, (10**6 + 10) // arr[i] + 1):
            dp[arr[i] * j] += 1
        if i < n - 1:
            if arr[i] == arr[i + 1]:
                continue
        cnt += 1
    else:
        continue

print(cnt)
### BUGGY CODE ###

def main():

    H, W = map(int, input().split())
    A = []
    white = 0
    h = []
    visited = set()
    for i in range(H):
        A.append(input())
        for j in range(W):
            if A[i][j] == '#':
                visited.add((i, j))
                h.append([i, j])
            else:
                white += 1

    cnt = 0
    mv = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    while h and white > 0:
        temp = []
        cnt += 1
        for i, j in h:
            for di, dj in mv:
                i1, j1 = i+di, j+dj
                if 0<=i1<H and 0<=j1<W and (i1, j1) not in visited:
                    temp.append([i1, j1])
                    visited.add((i1, j1))
                    white -= 1
        h = temp
    return cnt

if __name__ == '__main__':
    print(main())

### FIXED CODE ###

import collections
def main():
    H, W = map(int, input().split())
    A = []
    for _ in range(H):
        A.append(input())
    cur = []
    visited = collections.defaultdict(dict)
    for i in range(H):
        for j in range(W):
            if A[i][j] == "#":
                cur.append([i, j])
                visited[i][j] = 1
            else:
                visited[i][j] = 0
    mv = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    count = 0
    while cur:
        temp = []
        for i, j in cur:
            for di, dj in mv:
                i1, j1 = i+di, j+dj
                if 0 <= i1 < H and 0 <= j1 < W and not visited[i1][j1]:
                    visited[i1][j1] = True
                    temp.append([i1, j1])
        if len(temp) > 0:
            count += 1
        cur = temp
    return count

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

def solve():
  while True:
    try:
      s1 = input()
      s2 = input()
      lst = [[1 if s1[i] == s2[j] else 0 for i in range(len(s1))] for j in range(len(s2))]
      ans = 0
      def search(x,y,count):
        while  x < len(s2) and y < len(s1) and lst[x][y]:
          count += 1
          lst[x][y] = 0
          x += 1
          y += 1
        return count
      for i in range(len(s2)):
        for j in range(len(s1)):
          if lst[i][j]:
            ans = max(ans,search(i,j,0))
      print(ans)
    except EOFError:
      break
solve()


### FIXED CODE ###

while True:
    try:
        s1 = input()
    except EOFError:
        break
    s2 = input()
    BASE = 27
    MOD = 1000000007


    def rolling_hash(s):
        h_lst = [0]
        for c in s:
            h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
        return h_lst


    h_lst1 = rolling_hash(s1)
    h_lst2 = rolling_hash(s2)
    length1 = len(s1)
    length2 = len(s2)

    pow_mem = [pow(BASE, i, MOD) for i in range(min(length1, length2) + 1)]


    def check(center):
        hash_set = {(h_lst1[i + center] - h_lst1[i] * pow_mem[center]) % MOD for i in range(length1 - center + 1)}
        for i in range(length2 - center + 1):
            h2 = (h_lst2[i + center] - h_lst2[i] * pow_mem[center]) % MOD
            if h2 in hash_set:return True
        return False


    left = 0
    right = min(length1, length2)
    while right > left + 1:
        center = (left + right) // 2
        if check(center):
            left = center
        else:
            right = center
    print(right if check(right) else left)
### BUGGY CODE ###

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

#print(ai)
#ais = sorted(ai, reverse=True)
ais = sorted(ai)
#print(ais)
dica={}
for i in range(len(ais)):
    dica.setdefault(i,ais[i])
#print(dica)

bc = []
for i in range(m):
    bc.append(list(map(int, input().split())))

#print(bc)
bcs = sorted(bc, reverse=True, key=lambda x:x[1])
#print(bcs)

pt = 0
for i in range(m):
    tn, tv =bcs[i]
    #print(pt, n)
    #print(dica)
    for j in range(pt,n):
        if dica[j] < tv:
            dica[j]=tv
            tn=tn-1
            pt=j
            if tn == 0:
                break

#print(ais)
print(sum(dica.values()))

### FIXED CODE ###


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

#print(ai)
#ais = sorted(ai, reverse=True)
ais = sorted(ai)
#print(ais)
dica={}
for i in range(len(ais)):
    dica.setdefault(i,ais[i])
#print(dica)

bc = []
for i in range(m):
    bc.append(list(map(int, input().split())))

#print(bc)
bcs = sorted(bc, reverse=True, key=lambda x:x[1])
#print(bcs)

pt = 0
for i in range(m):
    tn, tv =bcs[i]
    #print(pt, n)
    #print(dica)
    for j in range(pt,n):
        if dica[j] < tv and 0 < tn:
            dica[j]=tv
            tn=tn-1
            pt=j+1
        else:
            break

#print(ais)
print(sum(dica.values()))
### BUGGY CODE ###

def main():
    s = input().rstrip()
    s = s[::-1]
    s += "0"
    n = len(s)
    a = [int(c) for c in s]
    dp = [[float("inf")]*2 for _ in range(n+1)]
    dp[0][0] = 0
    for i in range(n):
        for j in range(2):
            x = a[i] + j
            if x < 10:
                dp[i+1][0] = min(dp[i+1][0], dp[i][j] + x + 0)
            if 0 < x:
                dp[i+1][1] = min(dp[i+1][1], dp[i][j] + 10 - x)
    print(dp[n][0])

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    s = input().rstrip()
    s = "0" + s
    dp = [0, float("inf")]
    for c in s:
        x = int(c)
        dp = [min(dp[0] + x, dp[1] + (10-x)), min(dp[0] + x+1, dp[1] + (10-x) - 1)]
    print(dp[0])

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

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

r = [i for i, x in enumerate(s) if x == 'R']
g = [i for i, x in enumerate(s) if x == 'G']
b = [i for i, x in enumerate(s) if x == 'B']
ans = 0

for x in r:
    n = [i for i in g if i>x]
    for y in n:
        m = [i for i in b if i>y]
        for z in m:
            if y-x != z-y:
                ans += 1

for x in r:
    n = [i for i in b if i>x]
    for y in n:
        m = [i for i in g if i>y]
        for z in m:
            if y-x != z-y:
                ans += 1

for x in b:
    n = [i for i in r if i>x]
    for y in n:
        m = [i for i in g if i>y]
        for z in m:
            if y-x != z-y:
                ans += 1
                
for x in b:
    n = [i for i in g if i>x]
    for y in n:
        m = [i for i in r if i>y]
        for z in m:
            if y-x != z-y:
                ans += 1
                
for x in g:
    n = [i for i in r if i>x]
    for y in n:
        m = [i for i in b if i>y]
        for z in m:
            if y-x != z-y:
                ans += 1 
                
for x in g:
    n = [i for i in b if i>x]
    for y in n:
        m = [i for i in r if i>y]
        for z in m:
            if y-x != z-y:
                ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())
r = 0
g = 0
b = 0

for c in s:
    if c == "R":
        r += 1
    if c == "G":
        g += 1
    if c == "B":
        b += 1
ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        k = 2*j - i
        if k > n-1:
            continue
        x = s[i]
        y = s[j]
        z = s[k]
        if x!= y and y != z and z != x:
            ans -= 1

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

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

    ans = 0
    num = (10 ** 9) + 7
    a.sort()

    for i in range(n):
        tmp = 0
        for j in range(i+1, n):
            tmp = (a[i] * a[j]) % num
            ans += tmp
    
    ans = int(ans % num)
    print(int(ans % num))
 
resolve()

### FIXED CODE ###

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

    ans = 0
    mod = (10 ** 9) + 7
    csum = sum(a)

    for i in range(n):
        csum -= a[i]
        ans += a[i] * csum

    ans = int(ans % mod)
    print(ans)
 
resolve()
### BUGGY CODE ###

import collections

n  = int(input())
nums = list(map(int, input().split()))
c = collections.Counter(nums)
tap = c.most_common()

cnt = 0
for i in range(len(tap)):
    s = tap[i][1]
    cnt += s*(s-1)/2

for i in range(n):
    num = nums[i]
    a = nums.count(num)
    print(int(cnt - a +1))

### FIXED CODE ###

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

num_list = [0]*(n+1)
for i in a:
    num_list[i] += 1

cnt = 0
for i in num_list:
    cnt += i*(i-1)/2

for i in a:
    print(int(cnt +1 -num_list[i]))
### BUGGY CODE ###

def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    mod=10**9+7
    sum=0    
    def we_want(x):
        ans=1
        for i in range(k-1):
            ans=ans*(x-i)*pow(i+1,mod-2,mod)%mod 
        return ans 
        
    def check_min(i):
        if n-i>=k:
            minf=-we_want(n-1-i)*A[i]
            return minf
        else:return 0
    def check_max(i):
        if i>=k-1:
            maxf=we_want(i)*A[i]        
            return maxf
        else:return 0
    for i in range(len(A)):
        sum+=check_min(i)+check_max(i)
        sum%=mod
    print(sum%mod)

if __name__=='__main__':
    main()

### FIXED CODE ###

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7
b = 1
ans = 0
for i in range(k - 1, n):
    ans += b * (a[i] - a[n - i - 1])
    ans %= mod
    b = (i+1)*pow(i-k+2, mod - 2, mod) * b % mod
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

print((pow_r(2, m)-1-mca-mcb) % P)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

print(((2**m)-mca-mcb-1)%P)
### BUGGY CODE ###

s = input()
s = list(s)
count = 0
#for j in range(100):
while(1):
    length = len(s)
    for i in range(len(s)):
        try:
            if s[i] != s[i+1]:
                s.pop(i)
                s.pop(i)
                count = count+1
        except IndexError:
            pass
    if length == len(s):
        break
    
print(count*2)


### FIXED CODE ###

s = input()
print(2*min(s.count('0'),s.count('1')))
### BUGGY CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
ca = Counter(a)

ans = 0
for i in ca.keys():
  cnt = sum([v for k, v in ca.items() if i-1 <= k <= i+1])
  if ans < cnt:
    ans = cnt
print(ans)

### FIXED CODE ###

input()
C = [0] * 100002
for i in map(int, input().split()):
  C[i - 1] += 1
  C[i] += 1
  C[i + 1] += 1
print(max(C))
### BUGGY CODE ###

from collections import defaultdict

S = input()

D = defaultdict(int)
D[0] += 1
x = 0
d = 1
for s in reversed(S):
  x = (x + int(s) * d) % 2019
  D[x] += 1
  d *= 10

print(sum(x * (x-1) // 2 for x in D.values()))

### FIXED CODE ###

from collections import defaultdict

S = input()

D = defaultdict(int)
D[0] += 1
x = 0
d = 1
for s in reversed(S):
  x = (x + int(s) * d) % 2019
  D[x] += 1
  d = (d * 10) % 2019

print(sum(x * (x-1) // 2 for x in D.values()))
### BUGGY CODE ###

N = int(input())
output = []

for n in range(1,N+1):
    cnt = 0
    for x in range(1,45):
        if x**2+2*x+1 > n: break
        for y in range(1,45):
            if x**2+y**2+x*y+y+x > n: break
            for z in range(1,45):
                tmp = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
                if tmp > n: break
                if tmp == n: cnt += 1
    output.append(cnt)

print(*output, sep = "\n")

                

### FIXED CODE ###

N = int(input())
ls = {i+1: 0 for i in range(N+1)}
flag = 0
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            tmp = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
            if tmp > N:
                flag = 1
                break
            else:
                ls[tmp] += 1
        #if flag: break
    #if flag: break
            

for i in range(N):
    print(ls[i+1])
### BUGGY CODE ###

N=int(input())
l=[input() for _ in range(N)]

l= sorted(l)
#print(l)

import collections
c = collections.Counter(l)
#print(c.most_common())

ans =[]

for i in range(len(c.most_common())):
    if c.most_common()[i][1] == c.most_common()[0][1]:
        print(c.most_common()[i][0])


### FIXED CODE ###

N=int(input())
l=[input() for _ in range(N)]

l= sorted(l)

import collections
c = collections.Counter(l)
d = c.most_common()

for i in range(len(d)):
    if d[i][1] == d[0][1]:
        print(d[i][0])
### BUGGY CODE ###

import sys
from collections import deque
input = sys.stdin.readline
import numpy as np
N, K = [int(x) for x in input().split()]
h = []
for _ in range(N):
    h.append(int(input()))
h.sort()
i = 0
ans = []
while N - i >= K:
    temp = h[i:i+K]
    ans.append(temp[-1] - temp[0])
    i += 1
print(min(ans))


### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))
### BUGGY CODE ###

from collections import deque
h,w = map(int,input().split(" "))
s = [input() for _ in range(h)]

ans = 0
direcion = [(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        que = deque([(j,i)])
        dist = [[0]*w for _ in range(h)]
        visited = [[0]*w for _ in range(h)]
        visited[i][j] = 1
        while que:
            j, i = que.popleft()
            for x,y in direcion:
                n_x,n_y = j+x,i+y
                if not 0 <= n_x < w: continue
                if not 0 <= n_y < h: continue
                if visited[n_y][n_x]: continue
                if s[n_y][n_x] == "#": continue
                visited[n_y][n_x] = 1
                dist[n_y][n_x] = dist[i][j] + 1
                que.append((n_x,n_y))
            ans = max(ans,max(max(row) for row in dist))
print(ans)

### FIXED CODE ###

from collections import deque
h,w = map(int,input().split(" "))
s = [input() for _ in range(h)]
 
ans = 0
direcion = [(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        que = deque([(j,i)])
        dist = [[0]*w for _ in range(h)]
        visited = [[0]*w for _ in range(h)]
        visited[i][j] = 1
        while que:
            j, i = que.popleft()
            for x,y in direcion:
                n_x,n_y = j+x,i+y
                if not 0 <= n_x < w: continue
                if not 0 <= n_y < h: continue
                if visited[n_y][n_x]: continue
                if s[n_y][n_x] == "#": continue
                visited[n_y][n_x] = 1
                dist[n_y][n_x] = dist[i][j] + 1
                que.append((n_x,n_y))
        ans = max(ans,max(max(row) for row in dist))
print(ans)
### BUGGY CODE ###

import itertools
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# 色のパターン 30*29*28 == 24360
# 全部試すだけ

N, C = list(map(int, sys.stdin.buffer.readline().split()))
D = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(C)]
S = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

D = np.array(D, dtype=int)
S = np.array(S, dtype=int) - 1

md = np.zeros((N, N), dtype=int)
md += np.arange(N, dtype=int)
md += np.arange(N, dtype=int)[:, None]
md %= 3

ans = INF
for colors in itertools.permutations(range(C), r=3):
    # S[md == 0] -> colors[0]
    s = 0
    s += D[S[md == 0], colors[0]].sum()
    s += D[S[md == 1], colors[1]].sum()
    s += D[S[md == 2], colors[2]].sum()
    ans = min(ans, s)
print(ans)


### FIXED CODE ###

import itertools
import sys
import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N, C = map(int, input().split())
COSTS = []
for _ in range(C):
    COSTS.append(list(map(int, input().split())))
# (C, C)
COSTS = np.array(COSTS)
COLORS = []
for _ in range(N):
    COLORS.append(list(map(int, input().split())))
# (N, N)
COLORS = np.array(COLORS) - 1

# cs[x, y]: x == (i + j) % 3 で、色が y であるマスの数
cs = np.zeros((3, C))
for i in range(N):
    for j in range(N):
        cs[(i + j) % 3, COLORS[i, j]] += 1

ans = INF
# (i + j) % 3 == N のマスを cN にする場合のコストを全通り計算する
for c0, c1, c2 in itertools.permutations(range(C), r=3):
    ans = min(
        ans,
        np.dot(COSTS[:, c0], cs[0]) +
        np.dot(COSTS[:, c1], cs[1]) +
        np.dot(COSTS[:, c2], cs[2]))
print(int(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from bisect import insort_left

N,M = map(int,input().split())
A = sorted([int(i) for i in input().split()])

for _ in range(M):
    maximum = A.pop()
    insort_left(A, maximum>>1)

print(sum(A))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import heapq

N,M = map(int,input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)

for _ in range(M):
    tmp = heapq.heappop(A)
    # 計算誤差を減らすためにtmpを正に直してシフト演算している
    heapq.heappush(A, (-1)*(-tmp >> 1))

print(-sum(A))
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))        
D,d = {},{}
C = lambda x: x*(x-1)//2

for i in set(A):
  D[i] = A.count(i)
  
for i in set(A):
  res = 0
  for j,k in D.items():
    if i==j:
      res += C(k-1)
      continue
    res += C(k)  
  d[i] = res

for i in A:
  print(d[i])

### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))        
C = lambda x: x*(x-1)//2
s = 0
D = Counter(A)
for i,j in D.items():
  s += C(j)
for i in A:
  print(s-D[i]+1)
### BUGGY CODE ###


import sys
import collections
# import math
# import string
# import bisect

def main():
    n, *parts = (int(x) for x in sys.stdin.read().split())
    uppers, middles, lowers = (parts[n*i:n*(i+1)] for i in range(3))

    count = 0
    for a, ca in collections.Counter(uppers).items():
        for b, cb in collections.Counter((b for b in middles if b > a)).items():
            count += ca * cb * len([c for c in lowers if c > b])

    print(count)

if __name__ == "__main__":
    main()


### FIXED CODE ###


import sys
# import collections
# import math
# import string
import bisect

def main():
    n, *parts = (int(x) for x in sys.stdin.read().split())
    uppers, middles, lowers = (parts[n*i:n*(i+1)] for i in range(3))
    uppers.sort()
    lowers.sort()

    count = 0
    for j in middles:
        i = bisect.bisect_left(uppers, j)
        k = len(lowers) - bisect.bisect_right(lowers, j)
        count += i * k
        
    print(count)

if __name__ == "__main__":
    main()