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

H,W = [int(i) for i in input().split()]
room = ['0'] * H
ans = -1
for i in range(H):
    room[i] = list(input())
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
B = [[0] * W for _ in range(H)]
for i in range(W):
    if room[0][i] == '.':
        U[0][i] = 1
        if i == 0:
            L[0][i] = 1
        else:
            L[0][i] = L[0][i-1] +1
for i in range(H):
    if room[i][0] == '.':
        L[i][0] = 1
        if i == 0:
            U[i][0] = 1
        else:
            U[i][0] = U[i-1][0] +1
for x in range(1,H):
    for y in range(1,W):
        if room[x][y] == '.':
            U[x][y] = U[x-1][y]+1
            L[x][y] = L[x][y-1]+1
Ha = [int(i) for i in range(H)]
Wa = [int(i) for i in range(W)]
for i in Wa[::-1]:
    if room[H-1][i] == '.':
        B[H-1][i] = 1
        if i == W-1:
            R[H-1][i] = 1
        else:
            R[H-1][i] = R[H-1][i+1] +1
for i in Ha[::-1]:
    if room[i][W-1] == '.':
        R[i][W-1] = 1
        if i == H-1:
            B[i][W-1] = 1
        else:
            B[i][W-1] = B[i+1][W-1] +1
Haa = [int(i) for i in range(H-1)]
Waa = [int(i) for i in range(W-1)]
for x in Haa[::-1]:
    for y in Waa[::-1]:
        if room[x][y] == '.':
            R[x][y] = R[x][y+1]+1
            B[x][y] = B[x+1][y]+1
for x in range(H):
    for y in range(W):
        if room[x][y] == '.':
            ansa = U[x][y]+R[x][y]+B[x][y]+L[x][y]-3
            ans = max(ans,ansa)
print(ans)

### FIXED CODE ###

H,W = [int(i) for i in input().split()]
room = ['0'] * H
ans = -1
for i in range(H):
    room[i] = list(input())
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
B = [[0] * W for _ in range(H)]
for i in range(W):
    if room[0][i] == '.':
        U[0][i] = 1
        if i == 0:
            L[0][i] = 1
        else:
            L[0][i] = L[0][i-1] +1
for i in range(H):
    if room[i][0] == '.':
        L[i][0] = 1
        if i == 0:
            U[i][0] = 1
        else:
            U[i][0] = U[i-1][0] +1
for x in range(1,H):
    for y in range(1,W):
        if room[x][y] == '.':
            U[x][y] = U[x-1][y]+1
            L[x][y] = L[x][y-1]+1
Ha = [int(i) for i in range(H)]
Wa = [int(i) for i in range(W)]
for i in Wa[::-1]:
    if room[H-1][i] == '.':
        B[H-1][i] = 1
        if i == W-1:
            R[H-1][i] = 1
        else:
            R[H-1][i] = R[H-1][i+1] +1
for i in Ha[::-1]:
    if room[i][W-1] == '.':
        R[i][W-1] = 1
        if i == H-1:
            B[i][W-1] = 1
        else:
            B[i][W-1] = B[i+1][W-1] +1
Haa = [int(i) for i in range(H-1)]
Waa = [int(i) for i in range(W-1)]
for x in Haa[::-1]:
    for y in Waa[::-1]:
        if room[x][y] == '.':
            R[x][y] = R[x][y+1]+1
            B[x][y] = B[x+1][y]+1
for x in range(H):
    for y in range(W):
        if room[x][y] == '.':
            ansa = U[x][y]+R[x][y]+B[x][y]+L[x][y]-3
            ans = max(ans,ansa)
print(ans)
### BUGGY CODE ###

import sys

import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(" ")]

total = 0
ret = 1
n = readInt()
aa = []
for i in range(n):
    v = readInt()
    aa.append(v)
    total += v
    ret *= 3

memo0 = [[-1] * (n * max(aa) + 1) for _ in range(n + 1)]
def dfs0(i, c):
    if 0 <= memo0[i][c]:
        return memo0[i][c]

    if i == len(aa):
        memo0[i][c] = 3 if total <= (2 * c) else 0
        return memo0[i][c]

    acc = 0
    acc = (acc + dfs0(i + 1, c)) % 998244353
    acc = (acc + dfs0(i + 1, c)) % 998244353
    acc = (acc + dfs0(i + 1, c + aa[i])) % 998244353
    memo0[i][c] = acc
    return memo0[i][c]

memo1 = [[-1] * (n * max(aa) + 1) for _ in range(n + 1)]
def dfs1(i, c):
    if 0 <= memo1[i][c]:
        return memo1[i][c]

    if i == len(aa):
        memo1[i][c] = 3 if total == (2 * c) else 0
        return memo1[i][c]

    acc = 0
    acc = (acc + dfs1(i + 1, c)) % 998244353
    acc = (acc + dfs1(i + 1, c + aa[i])) % 998244353
    memo1[i][c] = acc
    return memo1[i][c]

ret = (ret - dfs0(0, 0)) % 998244353
ret = (ret + dfs1(0, 0)) % 998244353
print(ret)

### FIXED CODE ###

import sys

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(" ")]

total = 0
ret = 1
n = readInt()
aa = []
for i in range(n):
    v = readInt()
    aa.append(v)
    total += v
    ret *= 3


L = (n * max(aa) + 1)
memo = [-1] * ((n+1) * L * 2)
def dfs(i, c):
    key = (i * L * 2) + 2 * c
    if 0 <= memo[key]:
        return memo[key: key+2]

    if i == n:
        memo[key + 0] = 3 if total <= (2 * c) else 0
        memo[key + 1] = 3 if total == (2 * c) else 0
        return memo[key: key + 2]

    v0 = dfs(i + 1, c)
    v1 = dfs(i + 1, c + aa[i])

    memo[key + 0] = (2 * v0[0] + v1[0]) % 998244353
    memo[key + 1] = (v0[1] + v1[1]) % 998244353
    return memo[key: key + 2]

a, b = dfs(0, 0)
ret = (ret - a + b) % 998244353
print(ret)
### BUGGY CODE ###

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x = int(input())
    p1 = 1
    while True:
        p15 = p1 ** 5
        rt1 = ((x + p15) ** 0.2) % 1
        if rt1 == 0:
            r = (int((x + p15) ** 0.2), p15)
            break
        if (x - p15) < 0:
            pass
        else:
            rt2 = ((x - p15) ** 0.2) % 1
            if rt2 == 0:
                r = (int((x - p15) ** 0.2), -p15)
                break
        p1 += 1
    print(*r, sep=' ')
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from math import pow
def main():
    x = int(input())
    for a in range(-1000,1001):
        for b in range(-1000,1001):
            if pow(a, 5) - pow(b, 5) == x:
                print(a, b)
                sys.exit()

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

a = input()
q = int(input())
b = 0
for i in range(q):
    qi=input()
    if qi==str(1):
        b = b+1
    else:
        qi = qi.split()
        if qi[1]==str(1):
            if b%2==0:
                a = qi[2]+a
            else:
                a = a + qi[2]
        else:
            if b%2==1:
                a = qi[2]+a
            else:
                a = a + qi[2]
if b%2==1:
    a = a[::-1]
    print(a)
else:
    print(a)

### FIXED CODE ###

import collections
 
s = collections.deque(list(input()))
q = int(input())
rev = 0
for i in range(q):
    tfc = list(input().split())
    if tfc[0]=='1':
        rev = abs(rev-1)
    else:
        t,f,c = tfc
        if rev:
            if f=='1':
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if f=='1':
                s.appendleft(c)
            else:
                s.append(c)
if rev:
    t = []
    for i in range(len(s)):
        t.append(s.pop())
    print(''.join(t))
else:
    print(''.join(s))
### BUGGY CODE ###

C = -(10**9 + 7)


def main():
    from collections import defaultdict
    N = int(input())
    K = N//2
    A = [int(i) for i in input().split()]
    dp = defaultdict(lambda: C)
    for i in range(N+1):
        dp[(i, 0)] = 0
        if i != 0:
            dp[(i, 1)] = max(dp[(i-1, 1)], A[i-1])
    for i in range(2, N+1):
        for j in range((i+2)//2-1, (i+2)//2 + 1):
            if j < 0:
                continue
            cur = dp[(i, j)]
            for k in range(2, i+1-j):
                if 0 < i-k <= N:
                    cur = max(cur, dp[(i-k, j-1)] + A[i-1])
            dp[(i, j)] = cur
    print(dp[(N, K)])


if __name__ == '__main__':
    main()


### FIXED CODE ###

C = -(10**15 + 7)


def main():
    from collections import defaultdict
    N = int(input())
    K = N//2
    A = [int(i) for i in input().split()]
    dp = defaultdict(lambda: C)
    for i in range(N+1):
        dp[i, 0] = 0
        if i != 0:
            dp[(i, 1)] = max(dp[i-1, 1], A[i-1])
    for i in range(2, N+1):
        for j in range(i//2-1, (i+1)//2 + 1):
            if j < 0:
                continue
            # A_i(1-index)でj個選ばなければいけない
            dp[i, j] = max(dp[i, j], dp[i-2, j-1] + A[i-1],
                           dp[i-3, j-1] + A[i-1], dp[i-4, j-1] + A[i-1])
    print(max(dp[N, K], dp[N-1, K], dp[N-2, K]))
    # for i in range(N+1):
    #     for j in range(K+1):
    #         print("{:>4}".format(dp[i, j] if dp[i, j] != C else "C"),
    #               end=" " if j != K else "\n")


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

import math
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


k = int(input())
s = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for k in range(1, k + 1):
            s += gcd_list([i, j, k])
print(s)


### FIXED CODE ###

import math

k = int(input())
s = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        s1 = math.gcd(i, j)
        for k in range(1, k + 1):
            s += math.gcd(k, s1)
print(s)
### BUGGY CODE ###

n,*s=open(0)
n=int(n)
s=[tuple(t[:-1])for t in s]
c=0
for _ in range(n):
  c+=all(x==y for x,y in zip(s,zip(*s)))*n
  s=s[1:]+s[:1]
print(c)

### FIXED CODE ###

n,*s=[t[:-1]for t in open(0)]
n=int(n)
c=0
for _ in range(n):
  c+=all(x==''.join(y)for x,y in zip(s,zip(*s)))*n
  s=s[1:]+s[:1]
print(c)
### BUGGY CODE ###

n, q = map(int,input().split())
s = input()
#cnt = 0
for i in range(q):
  cnt = 0
  l, r = map(int,input().split())
  #print(s[l-1:r])
  cnt = s[l-1:r].count('AC')
  print(cnt)

### FIXED CODE ###

n, q = map(int,input().split())
s = input()
li = [0]*(n+1)
for i in range(n):
  li[i+1] = li[i] + (1 if s[i:i+2]=='AC' else 0)
#print(li)
for i in range(q):
  l, r = map(int,input().split())
  print(li[r-1]-li[l-1])
### BUGGY CODE ###

import sys

N = int(input())

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

max = 0
for i in range(N):
    count = 0
    for j in range(i+1,N):
        #print('i',i,' j',j,' H[j-1]', H[j-1], ' H[j]', H[j])
        if(H[j-1] >= H[j]):
            count = count+1
            if(count > max): max = count
        else:
            break

print(max)


### FIXED CODE ###

import sys

N = int(input())

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

max = 0
count = 0
for i in range(N-1):
    if(H[i] >= H[i+1]):
        count = count+1
        if(max < count): max = count
    else:
        count = 0
print(max)
### BUGGY CODE ###

N = int(input())
dp = [1] * (N+1)
dp[0] =  dp[1] =  0

for i in range(2,N+1):
    if dp[i]==1:
        for j in range(i*i, N+1, i):
            dp[j] = i
#print (dp)

def factor(n):
    d = dict()
    #print(dp[n])
    while(dp[n]!=1 and dp[n]!=0):
        d[dp[n]] = d.get(dp[n],0) + 1
        n //= dp[n]
    d[n] = d.get(n,0) + 1
    return d
a = 0
for n in range(N):
    d = factor(n+1)
    ans = 1
    for k,v in d.items():
        ans *= (v+1)
    if n==0:
        ans = 1
    #print(ans,(n+1))
    a += ans*(n+1)
print (a)
    

### FIXED CODE ###

N = int(input())
ans = 0
for X in range(1, N+1):
  Y = N // X
  ans += Y * (Y + 1) // 2 * X
print(ans)
### BUGGY CODE ###

def main():

    import sys
    import heapq

    N, Q = map(int, sys.stdin.readline().split())
    events = []

    for i in range(N):
        s, t, x = map(int, sys.stdin.readline().split())
        events.append((s - x, 1, x))  # 通行止め追加
        events.append((t - x, -1, x))  # 通行止め削除

    for i in range(Q):
        d = int(input())
        events.append((d, 2, 0))  # チェックイベント

    events.sort()
    events.append([float('inf'), 'guard', None])

    i = 0
    closing = set()
    hq = []  # 最小値を高速に入手するため
    while d >= events[i][0]:
        time, event, x = events[i]
        if event == 1:
            closing.add(x)
            heapq.heappush(hq, x)

        elif event == -1:
            closing.remove(x)

        else:
            while hq and (hq[0] not in closing):
                heapq.heappop(hq)

            if hq:
                print(hq[0])
            else:
                print(-1)

        i += 1


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():

    import sys
    import heapq

    N, Q = map(int, sys.stdin.readline().split())
    events = []

    for i in range(N):
        s, t, x = map(int, sys.stdin.readline().split())
        events.append((s - x, 1, x))  # 通行止め追加
        events.append((t - x, -1, x))  # 通行止め削除

    for i in range(Q):
        d = int(input())
        events.append((d, 2, 0))

    events.sort()
    events.append([float('inf'), 'guard', None])

    i = 0
    closing = set()
    hq = []  # 最小値を高速に入手するため
    while d >= events[i][0]:
        time, event, x = events[i]
        if event == 1:
            closing.add(x)
            heapq.heappush(hq, x)

        elif event == -1:
            closing.remove(x)

        else:
            while hq and (hq[0] not in closing):
                heapq.heappop(hq)

            if hq:
                print(hq[0])
            else:
                print(-1)

        i += 1


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

##
p = 10**9 + 7
n,m = list(map(int, input().split()))
a = [int(input()) for _ in range(m)]

dp = [0 for i in range(n+2)]
dp[0] = 1

for i in range(n):
    if i+2 not in a:
        dp[i+2] += dp[i]
    if i+1 not in a:
        dp[i+1] += dp[i]

print(dp[-2]%p)

### FIXED CODE ###

p = 10**9 + 7
n,m = list(map(int, input().split()))
a = set()
for _ in  range(m):
    a.add(int(input()))

dp = [0 for i in range(n+2)]
dp[0] = 1

for i in range(n):
    if i+2 not in a:
        dp[i+2] += dp[i]%p
    if i+1 not in a:
        dp[i+1] += dp[i]%p

print(dp[-2]%p)
### BUGGY CODE ###

N = int(input())
a = [int(input()) for i in range(N)]
count = [0]*N
i = 0

while(True):
    i = a[i]-1
    count[i]+=1
    if i == 1:
        print(sum(count))
        break
    if max(count)==2:
        print(-1)
        break

### FIXED CODE ###

N = int(input())
a = [int(input()) for i in range(N)]
count = [0]*N
i = 0

while(True):
    count[i]+=1
    i = a[i]-1
    if i == 1:
        print(sum(count))
        break
    if count[i] == 1:
        print(-1)
        break
### BUGGY CODE ###

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

while m > 0:
    a_list.sort(reverse=True)
    a_list[0] = a_list[0] // 2
    m -= 1

cost_sum = 0
for a in a_list:
    cost_sum += a

print(cost_sum)


### FIXED CODE ###

from heapq import heappush, heappop

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

hqueue = []
for a in a_list:
    heappush(hqueue, -a)

for i in range(m):
    max_item = -(-heappop(hqueue) // 2)
    heappush(hqueue, max_item)

cost = 0
for i in range(n):
    cost += -heappop(hqueue)

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

R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R+1):
    for j in range(N//G+1):
        b=N-(R*i+G*j)
        if B==0 or (b>=0 and b%B==0): 
            ans+=1

print(ans)

### FIXED CODE ###

R,G,B,N=map(int,input().split())
ans=0

for i in range(N//R+1):
    for j in range((N-R*i)//G+1):
        b=N-(R*i+G*j)
        if b==0 or  b%B==0: 
            ans+=1

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

import sys,math,collections,itertools
input = sys.stdin.readline

s = input().rstrip()[::-1]
DP=[0 for _ in range(13)]

DP[0]=1
m = 10**9+7
mul = 1
for i in range(len(s)):
    dig = s[i]
    nextDP = [0 for _ in range(13)]
    if dig == '?':
        for j in range(10):
            for k in range(13):
                nextDP[(k+mul*j)%13] += DP[k]
                nextDP[(k+mul*j)%13]%=m
    else:
        j = int(dig)
        for k in range(13):
            nextDP[(k+mul*j)%13] += DP[k]
            nextDP[(k+mul*j)%13]%=m

    mul *= 10
    mul%=13
    DP = nextDP

print(DP[5]%m)
        


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

s = input().rstrip()[::-1]
DP=[0 for _ in range(13)]

DP[0]=1
m = 10**9+7
mul = 1
for i in range(len(s)):
    dig = s[i]
    nextDP = [0 for _ in range(13)]
    if dig == '?':
        for j in range(10):
            for k in range(13):
                nextDP[(k+mul*j)%13] += DP[k]
                nextDP[(k+mul*j)%13]%=m
    else:
        j = int(dig)
        for k in range(13):
            nextDP[(k+mul*j)%13] += DP[k]
            nextDP[(k+mul*j)%13]%=m

    mul *= 10
    mul%=13
    DP = nextDP

print(DP[5]%m)
### BUGGY CODE ###

x,k,d = map(int,input().split())
for i in range(k):
  if abs(x-d)<=abs(x):
    x -=d
  else:
    x+=d

print(abs(x))


### FIXED CODE ###

import math
x,k,d = map(int,input().split())
d = abs(d)
x = abs(x)

if k*d<=x:
  print(x-k*d)
else:
  e = math.floor(x/d)
  k -= e
  x = x-e*d
  if k%2 == 0:
    print(x)
  else:
    print(abs(x-d))
### BUGGY CODE ###

from functools import reduce


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

print(reduce(lambda acc, x: acc ^ x, range(A, B + 1), 0))


### FIXED CODE ###

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

def calc(i):
  rem = i % 4
  if rem == 0:
    return i
  elif rem == 1:
    return 1
  elif rem == 2:
    return i + 1
  elif rem == 3:
    return 0

print(calc(A - 1) ^ calc(B))
### BUGGY CODE ###

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

for i in range(M//N,0,-1):
    if M % i ==0:
        break
print(i)

### FIXED CODE ###

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

if M//N < 10**7:
    for i in range(M//N,0,-1):
        if M % i ==0:
            break
    print(i)
else:
    for i in range(N,int(M**0.5)):
        if M % i == 0:
            break
    else:
        i = M
    print(M//i)
### BUGGY CODE ###

import sys
import collections

def main():
    N,*S = map(int, open(0).read().split())

    S = sorted(S)

    g = [S.pop(-1)]

    for gen in range(N):
        g.sort(reverse=True)
        for p in g[:2**gen]:
            for si, s in enumerate(S[::-1]):
                if p > s:
                    g.append(s)
                    del S[-(si+1)]
                    break
            else:
                print('No')
                sys.exit()
    print('Yes')

if __name__=='__main__':
    main()

### FIXED CODE ###

## 他の方と処理内容がほぼ同じなのに何でTLEになるか分からないので、他の方のコードでテスト
N = int(input())
a = list(map(int,input().split(' ')))
a.sort()
    

fathers = [a.pop()]
for _ in range(N):
    sons = list()
    b = list()
    
    for father in fathers:
        while a:
            x = a.pop()
            if father > x:
                sons.append(x)
                break
            else:
                b.append(x)
                
    a = a + b[::-1]
    fathers.extend(sons)
    fathers.sort(reverse = True)
    
    
    
if len(fathers) == 2**N:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

a, b, c, d = list(map(int, input().split()))

max_pro = -float("inf")
for i in range(a, b + 1):
  for j in range(c, d + 1):
    product = i * j
    if max_pro < product:
      max_pro = product

print(max_pro)

### FIXED CODE ###

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

max_pro = -float("inf")
for i in range(2):
  for j in range(1,3):
    product = abcd[i] * abcd[-j]
    if max_pro < product:
      max_pro = product

print(max_pro)
### BUGGY CODE ###

#144_E
n, k = map(int, input().split())
a = sorted(list(map(int,input().split())))
f = sorted(list(map(int,input().split())))[::-1]

l, r = -1, 10 ** 12
while r - l > 1:
    x = (r + l) // 2
    
    res = 0
    for i in range(n):
        res += max(0, a[i] - x // f[i])
    
    if res > k:
        l = x
    else:
        r = x
print(r)

### FIXED CODE ###

#144_E
n, k = map(int, input().split())
a = sorted(list(map(int,input().split())))
f = sorted(list(map(int,input().split())))[::-1]

l, r = -1, 10 ** 12
while r - l > 1:
    x = (r + l) // 2
    
    res = 0
    for i in range(n):
        res += max(0, a[i] - x // f[i])
    
    if res > k:
        l = x
    else:
        r = x
print(r)
### BUGGY CODE ###

N = int(input())
li = list(map(int,input().split()))
a = 1
for i in range(N):
  a *= li[i] 
if a > 10 ** 18:
  print(-1)
else:
  print(a)


### FIXED CODE ###

N = int(input())
li = input().split()
a = 1
sikataganai = False
try:
  h = li.index('0')
  print(0)
  sikataganai = True
except:
  for i in range(N):
    a *= int(li[i])
    if a > 10 ** 18:
      print(-1)
      exit()
  if not sikataganai :
    print(a)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H,N = map(int,readline().split())
m = map(int,read().split())
AB = zip(m,m)

INF = 10 ** 18
dp = [INF] * (20000)
dp[0] = 0

for a,b in AB:
    for n in range(H):
        if dp[n+a] > dp[n] + b:
            dp[n+a] = dp[n] + b

answer = min(dp[H:])
print(answer)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H,N = map(int,readline().split())
m = map(int,read().split())
AB = zip(m,m)

INF = 10 ** 18
dp = [INF] * (20000)
dp[0] = 0

for a,b in AB:
    for n in range(H):
        if dp[n+a] > dp[n] + b:
            dp[n+a] = dp[n] + b

answer = min(dp[H:])
print(answer)
### BUGGY CODE ###

n = int(input())
a = input().split()
b = []
for i in a:
    b.append(i)
    b.reverse()
n = ""
for i in b:
    n += i + " "
print(n)

### FIXED CODE ###

n = int(input())
a = input().split()
b = []
ans = []
even = a[1::2]
odd = a[0::2]
b.append(even)#even number
b.append(odd)#odd number
# print(b)
if len(a) % 2 == 0:
    for i in range(1,len(even) + 1):
        ans.append(even[-i])
    ans = ans + odd
else:
    for i in range(1,len(odd) + 1):
        ans.append(odd[-i])
    ans = ans + even
for i in range(len(ans)):
    if i != len(ans) -1:
        print(ans[i],end=" ")
    else:
        print(ans[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
def main():
  def s(l,r):
    k=l*n+r
    if d[k]:return d[k]
    if r-l<2:return 0
    d[k]=t=min(s(l,i)+s(i,r)for i in range(l+1,r))+a[r-1]-a[l-1]
    return t
  n,*a=map(int,open(0).read().split())
  d=[None]*(n*n+1)
  for i in range(n-1):a[i+1]+=a[i]
  a+=[0]
  print(s(0,n))
main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
def main():
  def s(l,r):
    k=l*n+r
    if d[k]:return d[k]
    if r-l<2:return 0
    d[k]=t=min(s(l,i)+s(i,r)for i in range(l+1,r))+a[r-1]-a[l-1]
    return t
  n,*a=map(int,open(0).read().split())
  d=[None]*(n*n+1)
  for i in range(n-1):a[i+1]+=a[i]
  a+=[0]
  print(s(0,n))
main()
### BUGGY CODE ###

import numpy as np
def solve(s,e):
	return np.sum(train[s:e+1,s:e+1])

city,dnum,qnum=map(int,input().split())

train=np.zeros((city+1,city+1),dtype='int16')


for i in range(dnum):
	l,r=map(int,input().split())
	train[l][r]+=1
	
querry=[list(map(int,input().split())) for i in range(qnum)]

for q in querry:
	print(solve(*q))

### FIXED CODE ###

def main():
    n, m, Q = map(int, input().split())
    Train= [[0 for _ in range(n)] for _ in range(n)]
    
    for i in range(m):
        l, r = map(int, input().split())
        l, r = l - 1, r - 1
        Train[l][r] += 1
    
    P_Train = [[0 for _ in range(n)] for _ in range(n)]
    for i in range(n):
        tmp = 0
        for j in range(n):
            tmp += Train[i][j]
            P_Train[i][j] = tmp

    for i in range(Q):
        p, q = map(int, input().split())
        p, q = p - 1, q - 1
        ans = solve(P_Train, n, p, q)
        print(ans)

def solve(P_Train, n, p, q):
    ans = 0
    for i in range(p, q + 1):
        if  p - 1 < 0:
            ans += P_Train[i][q]
        else:
            ans += P_Train[i][q] - P_Train[i][p - 1]
    return ans


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

import collections

N = int(input())
A = input().split()

A_set = set(A)

#ボールに書かれている 数字の内訳を辞書に登録
A_dic = collections.Counter(A)

#すべてのボールから同じボールを取り出す方法数
all_count = 0

for a in A_set:
    count_a = A.count(a)
    all_count += (count_a * (count_a - 1) // 2)

#n個あるボールから 1個取り除いた場合の方法数
#すべてのボールから取り出す方法数 - (n-1)通り

for i in range(N):
    print(all_count - A_dic.get(A[i])+1)

### FIXED CODE ###

import collections

N = int(input())
A = input().split()

#A_set = set(A)

#ボールに書かれている 数字の内訳を辞書に登録
A_dic = collections.Counter(A)

#すべてのボールから同じボールを取り出す方法数
all_count = 0

for a in A_dic.keys():
    count_a = A_dic.get(a)
    all_count += (count_a * (count_a - 1) // 2)

#n個あるボールから 1個取り除いた場合の方法数
#すべてのボールから取り出す方法数 - (n-1)通り

for i in range(N):
    print(all_count - A_dic.get(A[i])+1)