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

A = []
A.append(list(map(int,input().split())))
fr = 0
for i in range(A[0][3]):
    if abs(A[i][0]-A[i][1]) > 10**18:
        print('unfair')
        fr += 1
        break
    else:
        A.append([0,0,0])
        A[i+1][0] = A[i][1] + A[i][2]
        A[i+1][1] = A[i][0] + A[i][2]
        A[i+1][2] = A[i][0] + A[i][1]
if fr == 0:
    print(A[-1][0]-A[-1][1])

### FIXED CODE ###

A = list(map(int,input().split()))
if A[3] == 0:
    print(A[0]-A[1])
elif A[3]%2 == 0:
    print(A[0]-A[1])
else:
    print(A[1]-A[0])
### BUGGY CODE ###

import sys

import itertools
input = sys.stdin.readline
 
N=int(input())
 
A=[]
for i in range(55):
    A.append(i+1)
 
D=list(itertools.combinations_with_replacement(A, 3))
#print(len(D))
for j in range(N):
    count=0
    for sa in D:
        if ((sa[0]+sa[1]+sa[2])**2)-(sa[0]*sa[1]+sa[1]*sa[2]+sa[2]*sa[0])==j+1:
            if sa[0]!=sa[1] and sa[1] !=sa[2]:
                
                count+=6
            elif sa[0]==sa[1] and sa[1]==sa[2]:
                count+=1
            else:
                count+=3
 
    print(count)

### FIXED CODE ###

import sys

import itertools
input = sys.stdin.readline
 
N=int(input())

ans=[0]*10050

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            v=i*i+j*j+k*k+i*j+i*k+j*k
            if v<10050:
                ans[v]+=1

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

a,b,c,d=map(int, input().split())
i=0
while True:
  i+=1
  if i%2!=0: 
    c-=b
    if c==0: 
      print('Yes')
      break
  if i%2==0: 
    a-=d
    if a==0:
      print('No')
      break

### FIXED CODE ###

a,b,c,d=map(int, input().split())
import math
if math.ceil(c/b)<=math.ceil(a/d): print('Yes')
else: print('No')
### BUGGY CODE ###

from itertools import *

def SPFA(G: list, source=0):
	from collections import deque
	V = len(G)
	d = [float("inf")] * V
	inQ = [False] * V
	cnt = [0] * V
	d[source] = 0
	cnt[source] = 1
	Q = deque([source])
	_sum = 0
	_len = 1
	while Q:
		f = Q.popleft()
		inQ[f] = False
		_sum -= d[f]
		_len -= 1
		for t, c in G[f]:
			dist = d[f] + c
			if dist < d[t]:
				d[t] = dist
				if not inQ[t]:
					inQ[t] = True
					cnt[t] += 1
					if dist * _len < _sum:
						Q.appendleft(t)
					else:
						Q.append(t)
					_sum += dist
					_len += 1
				if cnt[t] > V:
					return None
	return d

n, m, s, t, *L = map(int, open(0).read().split())
yen = [[] for _ in range(n)]
snuuk = [[] for _ in range(n)]
for u, v, a, b in zip(*[iter(L)] * 4):
	u -= 1
	v -= 1
	yen[u].append((v, a))
	yen[v].append((u, a))
	snuuk[u].append((v, b))
	snuuk[v].append((u, b))
stoi = SPFA(yen, s - 1)
ttoi = SPFA(snuuk, t - 1)
rest = [10 ** 15 - x - y for x, y in zip(stoi, ttoi)]
ans = list(accumulate(rest[::-1], max))[::-1]
print(*ans)


### FIXED CODE ###

from heapq import *
from itertools import *


def Dijkstra(G: list, source=0):
	INF = float("inf")
	V = len(G)
	D = [INF] * V
	D[source] = 0
	vis = [False] * V
	H = [(0, source)]
	while H:
		dist, cur = heappop(H)
		if vis[cur]:
			continue
		vis[cur] = True
		for nxt, cost in G[cur]:
			t = dist + cost
			if D[nxt] > t:
				D[nxt] = t
				heappush(H, (t, nxt))
	return D


n, m, s, t, *L = map(int, open(0).read().split())
yen = [[] for _ in range(n)]
snuuk = [[] for _ in range(n)]
for u, v, a, b in zip(*[iter(L)] * 4):
	u -= 1
	v -= 1
	yen[u].append((v, a))
	yen[v].append((u, a))
	snuuk[u].append((v, b))
	snuuk[v].append((u, b))
stoi = Dijkstra(yen, s - 1)
ttoi = Dijkstra(snuuk, t - 1)
rest = [10 ** 15 - x - y for x, y in zip(stoi, ttoi)]
ans = list(accumulate(rest[::-1], max))[::-1]
print(*ans)
### BUGGY CODE ###

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

if m <= 2*n:
    print(m//2)
elif 2*n < m:
    while 2*n <= m:
        m -= 2
        n += 1
    # print("m: "+ str(m))
    print(n-1)

### FIXED CODE ###

import math
n, m = map(int, input().split())

if m <= 2*n:
    print(m//2)
elif 2*n < m:
    print(n + math.ceil((m- 2*n)//4))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
q=int(input())
ans=[0]*(10**5+1)
for i in a:
  ans[i]+=1
for _ in range(q):
  b,c=map(int,input().split())
  ans[c]+=ans[b]
  ans[b]=0
  s=0
  for i,x in enumerate(ans):
    s+=i*x
  print(s)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
q=int(input())
ans=[0]*(10**5+1)
for i in a:
  ans[i]+=1
res=sum(a)
for _ in range(q):
  b,c=map(int,input().split())
  ans[c]+=ans[b]
  res-=ans[b]*b
  res+=ans[b]*c
  ans[b]=0
  print(res)
### BUGGY CODE ###

# python3だとTLE,pypy3だとAC

def main():
    N = int(input())
    p = tuple(map(float, input().split()))
    dp = [[0.0] * (N + 1) for _ in range(N + 1)]
    dp[0][0] = 1.0
    for i in range(1, N + 1):
        h = p[i - 1]
        t = 1-h
        for j in range(0, N + 1):
            dp[i][j] = dp[i - 1][j] * t + dp[i - 1][j - 1] * h
    print(sum(dp[N][N//2+1:]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    p = list(map(float, input().split()))
    dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
    p_mul = 1
    dp[0][0] = 1
    for i in range(1, N + 1):
        p_mul *= (1-p[i-1])
        dp[i][0] = p_mul
    for i in range(1, N+1):
        for j in range(1, N+1):
            dp[i][j] = dp[i - 1][j] * \
                (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1]
    print(sum(dp[N][N//2+1:]))


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

# https://atcoder.jp/contests/abc122/tasks/abc122_c
import numpy as np

N, Q = map(int, input().split())
N = int(N)
S = input()
lr = []
for _ in range(Q):
    l, r = map(int, input().split())
    lr.append((l - 1, r - 1))
locations = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        locations.append(i)
locations = np.array(locations)
# print(locations)

for l, r in lr:
    subset = locations[(l <= locations) & (locations < r)]
    # print(l, r, subset)
    print(len(subset))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
cnt = [0]
for i in range(2, len(S) + 1):
    if S[i - 2:i] == 'AC':
        v = cnt[-1] + 1
    else:
        v = cnt[-1]
    cnt.append(v)

# print('cnt', cnt)
for _ in range(Q):
    l, r = map(int, input().split())
    ans = cnt[r - 1] - cnt[l - 1]
    print(ans)
### BUGGY CODE ###

N = int(input())
ans = 0
A_list = [int(input()) for i in range(N)]
A_set = set(A_list)
for i in A_set:
    if A_list.count(i) % 2 == 1:
        ans += 1
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from itertools import permutations, combinations
from fractions import gcd
from collections import Counter
from math import sqrt
import sys
input = sys.stdin.readline
def lcm(x, y):
    return (x*y//gcd(x, y))
def small_letters():
    return [chr(i) for i in range(97, 97+26)]
def capital_letters():
    return [chr(i) for i in range(65, 65+26)]


def main():
    """ここに書いてね"""
    N = int(input())
    A_list = [int(input()) for i in range(N)]
    ans = 0
    counter = Counter(A_list)
    for i in counter.values():
        if i % 2 == 1:
            ans += 1
    print(ans)

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

import numpy as np
import sys
sys.setrecursionlimit(20000000)

def calculate(h, w, arr):
    L = np.zeros([h, w])
    U = np.zeros([h, w])
    D = np.zeros([h, w])
    R = np.zeros([h, w])

    for ih in range(h):
        for iw in range(w):
            if ih == 0:
                U[ih][iw] = 1
            if iw == 0:
                L[ih][iw] = 1

            if arr[ih][iw] == "#":
                L[ih][iw] = 0
                U[ih][iw] = 0

            else:
                if iw > 0:
                    L[ih][iw] = L[ih][iw - 1] + 1
                if ih > 0:
                    U[ih][iw] = U[ih - 1][iw] + 1

            rih = h - 1 - ih
            riw = w - 1 - iw

            if rih == h - 1:
                D[rih][riw] = 1
            if riw == w - 1:
                R[rih][riw] = 1

            if arr[rih][riw] == "#":
                D[rih][riw] = 0
                R[rih][riw] = 0
            else:
                if riw < w - 1:
                    R[rih][riw] = R[rih][riw + 1] + 1
                if rih < h - 1:
                    D[rih][riw] = D[rih + 1][riw] + 1

    max = 0
    for ih in range(h):
        for iw in range(w):
            if arr[ih][iw] == "#":
                continue
            value = L[ih][iw] + R[ih][iw] + U[ih][iw] + D[ih][iw] - 3
            if value > max:
                max = value
    print(int(max))


S = input().split(" ")
H = int(S[0])
W = int(S[1])

arr = []
for i in range(H):
    q = list(input())
    arr.append(q)

calculate(H, W, arr)


### FIXED CODE ###

def calculate(h, w, arr):
    L = [[0]*w for i in range(h)]
    U = [[0]*w for i in range(h)]
    D = [[0]*w for i in range(h)]
    R = [[0]*w for i in range(h)]

    for ih in range(h):
        for iw in range(w):
            if ih == 0:
                U[ih][iw] = 1
            if iw == 0:
                L[ih][iw] = 1

            if arr[ih][iw] == 1:
                L[ih][iw] = 0
                U[ih][iw] = 0

            else:
                if iw > 0:
                    L[ih][iw] = L[ih][iw - 1] + 1
                if ih > 0:
                    U[ih][iw] = U[ih - 1][iw] + 1

            rih = h - 1 - ih
            riw = w - 1 - iw

            if rih == h - 1:
                D[rih][riw] = 1
            if riw == w - 1:
                R[rih][riw] = 1

            if arr[rih][riw] == 1:
                D[rih][riw] = 0
                R[rih][riw] = 0
            else:
                if riw < w - 1:
                    R[rih][riw] = R[rih][riw + 1] + 1
                if rih < h - 1:
                    D[rih][riw] = D[rih + 1][riw] + 1

    max = 0
    for ih in range(h):
        for iw in range(w):
            value = L[ih][iw] + R[ih][iw] + U[ih][iw] + D[ih][iw] - 3
            if value > max:
                max = value
    print(int(max))


S = input().split(" ")
H = int(S[0])
W = int(S[1])

arr = []
for i in range(H):
    q = input()
    tmp = []
    for qs in q:
        if qs == "#":
            tmp.append(1)
        if qs == ".":
            tmp.append(0)
    arr.append(tmp)

calculate(H, W, arr)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    S=[0]*(n+1)
    for i in range(n):
        S[i+1]=S[i]+A[i]

    for i in range(n+1):
        S[i]-=i
        S[i]%=k

    C=[[] for _ in range(max(n+1,k))]
    for i in range(n+1):
        if(S[i]>=max(n+1,k)): continue
        C[S[i]].append(i)

    ans=0
    for d in range(max(n+1,k)):
        n=len(C[d])
        if(n<=1): continue
        r=0
        for l in range(n):
            while(r+1<n and C[d][r+1]-C[d][l]<k):
                r+=1
            ans+=r-l
            if(r==l): r+=1
    print(ans)
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    S=[0]*(n+1)
    for i in range(n):
        S[i+1]=S[i]+A[i]

    for i in range(n+1):
        S[i]-=i
        S[i]%=k

    C=defaultdict(list)
    for i in range(n+1):
        C[S[i]].append(i)

    ans=0
    C=list(C.values())
    for d in range(len(C)):
        n=len(C[d])
        if(n<=1): continue
        r=0
        for l in range(n):
            while(r+1<n and C[d][r+1]-C[d][l]<k):
                r+=1
            ans+=r-l
            if(r==l): r+=1
    print(ans)
resolve()
### BUGGY CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[16]:


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


# In[41]:


cnt = 0
low = 0
high = max(A)
ans = max(A)
old = int(high)
mycount = 0
while low < high:
    mid = (high+low)/2
    cnt = sum([(x-0.001)//mid for x in A])
    if cnt <= K:
        high = mid
        ans = min(ans, int(-(-mid//1)))
    else:
        low = mid
    if int(mid) == old:
        mycount += 1
    if mycount == 100:
        break
    old = int(mid)
print(ans)


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[16]:


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


# In[49]:


low = 0
high = max(A)
def ok(x):
    cnt = 0
    for a in A:
        cnt += (a//x)
        if a%x == 0:
            cnt -= 1
    return cnt <= K
 
while high-low > 1:
    mid = (high+low)//2
    if ok(mid):
        high = mid
    else:
        low = mid
print(high)


# In[ ]:
### BUGGY CODE ###



s = input()
q = int(input())

def addflont(s,c):
    return c+s
def addback(s,c):
    return s+c

reverse = 0

for i in range(q):
    t = input()
    if t[0]=="1":
        reverse = reverse^1
    if t[0]=="2":
        if t[2]=="1":
            if reverse==0:
                s = addflont(s,t[4])
            else:
                s = addback(s,t[4])
        elif t[2]=="2":
            if reverse==0:
                s = addback(s,t[4])
            else:
                s = addflont(s,t[4])

if reverse==1:
    print(s[::-1])
else:
    print(s)


### FIXED CODE ###



s = input()
q = int(input())

def addflont(s,c):
    text = "".join([c,s])
    return text
def addback(s,c):
    text = "".join([s,c])
    return text

reverse = 0
r = "";u = ""
for i in range(q):
    t = input()
    if t[0]=="1":
        reverse = reverse^1
    if t[0]=="2":
        if t[2]=="1":
            if reverse==0:
                r = addflont(r,t[4])
            else:
                u = addback(u,t[4])
        elif t[2]=="2":
            if reverse==0:
                u = addback(u,t[4])
            else:
                r = addflont(r,t[4])

s = r + s + u
if reverse==1:
    print(s[::-1])
else:
    print(s)
### BUGGY CODE ###

from collections import deque
n,m = map(int,input().split())
g = [[] for i in range(n)]
h = [[] for i in range(n)]
for i in range(m):
  x,y = map(int,input().split())
  x-=1;y-=1
  g[x].append(y)
  h[y].append(x)
hukasa = [float("inf")]*n
MIN = float("inf")
for i in range(n):
  MIN = min(MIN,len(h[i]))
def dfs(x,y):
  for k in g[x]:
    if hukasa[k] > y+1:
      hukasa[k] = y+1
      que.append([k,y+1])
for i in range(n):
  if MIN == len(h[i]):
    que = deque([])
    que.append([i,0])
    hukasa[i] = 0
    while que:
      x,y = que.popleft()
      dfs(x,y)
for i in range(n):
  hukasa[i] = [hukasa[i],i]
hukasa.sort()
dp = [0] * n
while True:
  flag = 1
  for l,i in hukasa:
    for j in g[i]:
      if dp[j] < dp[i]+1:
        dp[j] = dp[i]+1
        flag = 0
  if flag:
    break
print(max(dp))

### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())
g = [[] for i in range(n)]
h = [[] for i in range(n)]
for i in range(m):
  x,y = map(int,input().split())
  x-=1;y-=1
  g[x].append(y)
  h[y].append(x)
topo = []
hukasa = [0] * n
hairu = [0]*n
que = deque([])
for i in range(n):
  hairu[i] = len(h[i])
  if hairu[i] == 0:
    topo.append(i)
    que.append(i)
def dfs(x):
  for i in g[x]:
    hairu[i]-=1
    if hairu[i] == 0:
      topo.append(i)
      que.append(i)
while que:
  x = que.popleft()
  dfs(x)
def dfs2(x):
  for i in g[x]:
    hukasa[i] = max(hukasa[i],hukasa[x]+1)
for i in topo:
  dfs2(i)
print(max(hukasa))
### BUGGY CODE ###

N,M=map(int,input().split())
A=[int(input()) for _ in range(M)]
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
	dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
	if i in A:
		dp[i]=0
print(dp[N])

### FIXED CODE ###

N,M=map(int,input().split())
A=set([int(input()) for _ in range(M)])
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
	dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
	if i in A:
		dp[i]=0
print(dp[N])
### BUGGY CODE ###

N, M = map(int, input().split())
AB = [[0, 0] for _ in range(N)]

for n in range(N):
    AB[n][0], AB[n][1] = map(int, input().split())
    AB[n][1] = 0 - AB[n][1]
AB.sort()

earn = 0
for m in range(1, M+1):
    max_earn = 0
    max_i = 0
    for i in range(len(AB)):
        if m < AB[i][0] :
            break
        
        if max_earn > AB[i][1]:
            max_earn = AB[i][1]
            max_i = i


    if max_earn != 0:
        earn += AB[max_i][1]
        AB.pop(max_i)

        

        
print(0-earn)


### FIXED CODE ###

import queue

N, M = map(int, input().split())
AB = [[] for _ in range(M + 1)]

for n in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue
    AB[a].append(0-b)

earn = 0
q = queue.PriorityQueue()

for m in range(1, M + 1):

    for job in AB[m]:
        q.put(job)

    if not q.empty():
        earn += q.get()

print(0-earn)
### BUGGY CODE ###

N,M = map(int,input().split(" "))
first = []
second = []
flag = 0

for i in range(M):
  a,b = map(int,input().split(" "))
  if b == N:
    second.append(a)
  if a == 1:
    first.append(b)
    
if len(first) == 0 or len(second) == 0:
  print("IMPOSSIBLE")
else:
  for j in range(len(first)):
    for k in range(len(second)):
      if first[j] == second[k]:
        print("POSSIBLE")
        flag = 1
        break
  if flag == 0:
    print("IMPOSSIBLE")

### FIXED CODE ###

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

first = []
second = []
flag = 0
end = True

for i in range(M):
  a,b = map(int,input().split(" "))
  if b == N:
    second.append(a)
  if a == 1:
    first.append(b)

first.sort()
second.sort()
    
if len(first) == 0 or len(second) == 0:
  print("IMPOSSIBLE")
else:
  firsti = 0
  secondi = 0
  while(end == True):
    if first[firsti] == second[secondi]:
      print("POSSIBLE")
      break
    elif first[firsti] < second[secondi]:
      firsti += 1
      if firsti > len(first) - 1:
        print("IMPOSSIBLE")
        break
    else:
      secondi += 1
      if secondi > len(second) - 1:
        print("IMPOSSIBLE")
        break
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
n,q = map(int,input().split())
ki = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
cnt = [0]*n
for _ in range(q):
    p,x = map(int,input().split())
    p -= 1
    cnt[p] += x

def dfs(cur,prev = -1):
    for nxt in ki[cur]:
        if nxt == prev: continue
        cnt[nxt] += cnt[cur]
        dfs(nxt,cur)

dfs(0)
print(" ".join(map(str,cnt)))

### FIXED CODE ###

from collections import deque
n,q = map(int,input().split())
to = [[] for _ in range(n)]
ans = [0]*n

for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

for i in range(q): 
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

stack = deque()
stack.append((0,0))
while len(stack) != 0:
    cn,pn = stack.pop()
    for nn in to[cn]:
        if nn == pn:
            continue
        ans[nn] += ans[cn]
        stack.append((nn,cn))

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


import sys
n = int(input())
aa = input()
a = aa.split()

result = 1
for i in range(n):
    if(a[i] == 0):
        print(0)
        sys.exit()
    result *= int(a[i])

if(result > 1000000000000000000):
    print(-1)
    sys.exit()

print(result)


### FIXED CODE ###


import sys
n = int(input())
aa = input()
a = aa.split()

for i in range(n):
    if(int(a[i]) == 0):
        print(0)
        sys.exit()

result = 1
for i in range(n):
    result *= int(a[i])
    if(result > 1000000000000000000):
        print(-1)
        sys.exit()

print(result)
### BUGGY CODE ###

N = int(input())
import math
a = math.factorial(N)

ans = 0
for i in range(1, a+1):
    if a%i == 0:
        ans += 1
print(ans)

### FIXED CODE ###

import math
import collections

N = int(input())
a = math.factorial(N)
check = []
ans = 1
i = 2

while a != 1:
    if a % i == 0:
        a //= i
        check.append(i)
    else:
        i += 1
        
check = collections.Counter(check).values()
for i in check:
    ans *= (i+1)
    ans %= 10**9+7
print(ans)
### BUGGY CODE ###

import numpy as np
H,W=map(int,input().split())
S=list(list(input()) for _ in range(H))
ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]!='#' and j!=W-1:
            ans+=1
        elif S[i][j]!='#'and j==W-1 :
            for k in range(ans+1):
                S[i][j-k]=ans+1
            ans=0
        else:
            for k in range(1,ans+1):
                S[i][j-k]=ans
            ans=0
q=list()
S_t=np.array(S).T.tolist()
ans=0
for i in range(W):
    for j in range(H):
        if S_t[i][j]!='#' and j!=H-1:
            ans+=1
        elif S_t[i][j]!='#'and j==H-1 :
            for k in range(ans+1):
                q.append(ans+1+int(S_t[i][j-k]))
            ans=0
        else:
            for k in range(1,ans+1):
                q.append(ans+int(S_t[i][j-k]))
            ans=0
c=0
print(max(q)-1)

### FIXED CODE ###

H,W=map(int,input().split())
S=list(list(input()) for _ in range(H))
ans=0
for i in S:
    for j in range(W):
        if i[j]!='#' and j!=W-1:
            ans+=1
        elif i[j]!='#'and j==W-1 :
            for k in range(ans+1):
                i[j-k]=ans+1
            ans=0
        else:
            for k in range(1,ans+1):
                i[j-k]=ans
            ans=0
S_t=list(map(list,zip(*S)))
ans=0
for i in S_t:
    for j in range(H):
        if i[j]!='#' and j!=H-1:
            ans+=1
        elif i[j]!='#'and j==H-1 :
            for k in range(ans+1):
                i[j-k]+=ans+1
            ans=0
        else:
            for k in range(1,ans+1):
                i[j-k]+=ans
            ans=0
            i[j]=0
c=0
for i in S_t:
    c=max(c,max(i))
print(c-1)
### BUGGY CODE ###

import bisect
import math
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N = int(input())
lst = list(map(int, input().split()))
lst.sort()
n = max(lst)
a = bisect.bisect_right(lst, n//2)
x1 = cmb(n, lst[a])
x2 = cmb(n, lst[a-1])
if x1 > x2:
    print(n, lst[a])
else:
    print(n, lst[a-1])

### FIXED CODE ###

import bisect
import math
N = int(input())
lst = list(map(int, input().split()))
lst.sort()
n = max(lst)
a = bisect.bisect_right(lst, n//2)
if abs(math.ceil(n/2)-lst[a]) >= abs(math.ceil(n/2)-lst[a-1]):
    print(n, lst[a-1])
else:
    print(n, lst[a])
### BUGGY CODE ###

#! /usr/bin/env python3

n, m = map(int, input().split())
a = [int(i) for i in input().split()]

acc = [0 for _ in range(n + 1)]
res = 0

for i in range(n):
    acc[i + 1] = acc[i] + a[i]
    for j in range(i + 1):
        if (acc[i + 1] - acc[j]) % m == 0:
            res += 1

print(res)


### FIXED CODE ###

#! /usr/bin/env python3

n, m = map(int, input().split())
a = [int(i) for i in input().split()]

acc = 0
res = 0

mods = {}

for i in range(n):
    acc = (acc + a[i]) % m

    if acc == 0:
         res += 1

    if acc in mods:
        res += mods[acc]
        mods[acc] += 1
    else:
        mods[acc] = 1

print(res)
### BUGGY CODE ###

import collections
import math

def combinations_count(n, r): # 組み合わせ nCr
    if n < r or n == 0:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
a = list(map(int,input().split()))
a_set = collections.Counter(a)
b = list(a_set)
total = 0

for v in b: # 全通り
    if 2 <= a_set[v]:
        total += combinations_count(a_set[v],2)

for v in a:
    if a_set[v] < 2:
        print(total)
    else:
        print(total-combinations_count(a_set[v],2)+combinations_count(a_set[v]-1,2))



### FIXED CODE ###

import collections
import math

N = int(input())
a = list(map(int,input().split()))
a_counter = collections.Counter(a)

res = 0

for v in a_counter: # 全通り
    res += a_counter[v]*(a_counter[v]-1)//2

for v in a:
    befor = a_counter[v]*(a_counter[v]-1)//2
    after = (a_counter[v]-1)*(a_counter[v]-2)//2
    print(res-befor+after)