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

import sys
input = sys.stdin.readline
INF = 10**18
sys.setrecursionlimit(10**6)
import itertools as it
import collections as cl
from collections import deque
import math
from functools import reduce
from collections import defaultdict
MOD = 998244353


def li():
    return [int(x) for x in input().split()]

N, K = li()

s = set()
for _ in range(K):
    a, b = li()
    for i in range(a, b+1):
        s.add(i)

# dp[i]: マスiに到達する方法の個数
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
    for j in s:
        if i + j <= N:
            dp[i+j] += dp[i]
            dp[i+j] %= MOD
print(dp[N-1])



### FIXED CODE ###

import sys
input = sys.stdin.readline
INF = 10**18
sys.setrecursionlimit(10**6)
import itertools as it
import collections as cl
from collections import deque
import math
from functools import reduce
from collections import defaultdict
MOD = 998244353


def li():
    return [int(x) for x in input().split()]

N, K = li()

L, R = [], []
for _ in range(K):
    l, r = li()
    L.append(l)
    R.append(r)

# dp[i]: i番目のマスにいく場合の数
dp = [0] * (N+1)
dp[1] = 1
# 区間 [left, right)の和はdpsum[right] - dpsum[left]
# 区間 [left, right]の和はdpsum[right+1] - dpsum[left]
# マス a~bは区間だと[a-1,b-1]に対応。よってマスliからriの和はdpsum[right] - dpsum[left - 1]
dpsum = [0] * (N+1)
dpsum[1] = 1
for i in range(2, N+1):
    for j in range(K):
        li = max(i - R[j], 1)
        ri = i - L[j]
        if ri >= 0:
            dp[i] += dpsum[ri] - dpsum[li-1]
            dp[i] %= MOD
    dpsum[i] = dpsum[i-1] + dp[i]
    dpsum[i] %= MOD

print(dp[N])
### BUGGY CODE ###

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def fix(a):
    mn = min(a) - 1
    return [x - mn for x in a]

def main():
    N = rl(int)
    p = srl(int)
    a = range(N)
    b = list(reversed(a))
    for i, v in enumerate(p[1:], 1):
        a[v-1] += i
        for j in xrange(v, N):
            a[j] += i
            b[j] -= i
    print " ".join(map(str, fix(a)))
    print " ".join(map(str, fix(b)))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def fix(a):
    mn = min(a) - 1
    return [x - mn for x in a]

def main():
    N = rl(int)
    p = srl(int)
    a = range(N)
    b = list(reversed(a))
    inc = [0] * (N+1)
    for i, v in enumerate(p[1:], 1):
        a[v-1] += i
        inc[v] += i
    s = 0
    for i in xrange(N):
        s += inc[i]
        a[i] += s
        b[i] -= s
    print " ".join(map(str, fix(a)))
    print " ".join(map(str, fix(b)))

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

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

### FIXED CODE ###

a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)
### BUGGY CODE ###

import numpy as np
N, M , Q = map(int, input().split())

LR = np.array([np.zeros(N+2-i, dtype=np.int) for i in range(N+2)])
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

  
for i in range(2,N+2):
  for j in range(1,N-i+2):
    LR[j][i] += LR[j][i-1] + LR[j+1][i-1] - LR[j+1][i-2]
    
for i in range(Q):
  p, q = map(int, input().split())
  print(LR[p][q-p+1]-LR[q+1][0])


### FIXED CODE ###

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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

  
for i in range(2,N+2):
  for j in range(1,N-i+2):
    LR[j][i] += LR[j][i-1] + LR[j+1][i-1] - LR[j+1][i-2]
    
for i in range(Q):
  p, q = map(int, input().split())
  print(LR[p][q-p+1]-LR[q+1][0])
### BUGGY CODE ###

from sys import stdin
s = list(stdin.readline().rstrip())
q = int(stdin.readline().rstrip())
t = []
for i in range(q):
    t.append([x for x in stdin.readline().rstrip().split()])
r = 0
for i in range(q):
    if int(t[i][0]) == 1:
        if r == 1:
            r = 0
        else:
            r = 1
    else:
        if (int(t[i][1]) + r) % 2 == 0:
            s.append(t[i][2])
        else:
            s.insert(0,t[i][2])
if r == 1:
    s = list(reversed(s))
s = ''.join(s)
print(s)

### FIXED CODE ###

from sys import stdin
s = list(stdin.readline().rstrip())
q = int(stdin.readline().rstrip())
t = []
k = []
for i in range(q):
    t.append([x for x in stdin.readline().rstrip().split()])
r = 0
for i in range(q):
    if int(t[i][0]) == 1:
        if r == 1:
            r = 0
        else:
            r = 1
    else:
        if (int(t[i][1]) + r) % 2 == 0:
            s.append(t[i][2])
        else:
            k.append(t[i][2])
k = list(reversed(k))
k.extend(s)
if r == 1:
    k = list(reversed(k))
k = ''.join(k)
print(k)
### BUGGY CODE ###

from collections import deque
N, M = map(int, input().split())
G = {k: [] for k in range(N+1)}
for _ in range(M):
    u, v = map(int, input().split())
    G[u].append(v)
S, T = map(int, input().split())


visited = [[10**9] * (N+1) for _ in range(3)]


que = deque([(S, 0)])

while que:
    ci, t = que.popleft()
    visited[t % 3][ci] = t

    for ni in G[ci]:
        if visited[(t+1) % 3][ni] > t:
            que.append((ni, t+1))

if visited[0][T] == 10**9:
    print(-1)
else:
    print(visited[0][T]//3)


### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
G = [[[] for j in range(3)] for i in range(N+1)]
for _ in range(M):
    u, v = map(int, input().split())
    for i in range(3):
        G[u][i].append((v, (i+1) % 3))
S, T = map(int, input().split())


visited = [[-1] * 3 for _ in range(N+1)]

que = deque([(S, 0, 0)])
visited[S][0] = 0

while que:
    ci, l, d = que.popleft()

    for ni, nl in G[ci][l]:
        if visited[ni][nl] == -1:
            que.append((ni, nl, d+1))
            visited[ni][nl] = d+1

print(visited[T][0]//3)
### BUGGY CODE ###

import math
a, b, n = map(int, input().split())
li = list(math.floor(a*i/b)- a * math.floor(i/b) for i in range(1, n+1))
print(max(li))

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = math.floor(a*x/b)- a * math.floor(x/b)
print(ans)
### BUGGY CODE ###

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

dp=[0 for i in range(N)]
dp[1]=abs(H[1]-H[0])

for i in range(1,N):
    for j in range(1,K+1):
        dp[i]=min(dp[i-j]+abs(H[i-j]-H[i]) for j in range(1,min(K+1,i+1)))
        
print(dp[N-1])

### FIXED CODE ###

def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))

    ans=[0]*N
    ans[1]=abs(h[1]-h[0])


    for i in range(2,N):
        ans[i] = min(abs(h[i] - h[j]) + ans[j] for j in range(max(0,i-K),i))
    print(ans[N-1])
    
main()
### BUGGY CODE ###

l, r = map(int, input().split())

from itertools import combinations

ans = 2019

for (x1, x2) in combinations(range(l, r+1), 2):
    ans = min((x1 * x2) % 2019, ans)

print(ans)


### FIXED CODE ###

l, r = map(int, input().split())

from itertools import combinations

if r - l > 2019:
    r = l+2019

ans = [(x1*x2)%2019 for (x1, x2) in combinations(range(l, r+1), 2)]

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

n = int(input())
string = input()
r = 0
g = 0
b = 0
for c in string:
    if c == 'R':
        r += 1
    elif c == 'G':
        g += 1
    else:
        b += 1
ans = r*g*b
for i in range(n):
    for j in range(i+1, n):
        if string[i] == string[j]: 
            continue
        rgb = set(['R', 'G', 'B'])
        rgb.remove(string[i])
        rgb.remove(string[j])
        k = rgb.pop()
        if 2*j-i < n and string[2*j-i] == k:
            ans -= 1
print(ans)
        
        


### FIXED CODE ###

n = int(input())
string = input()
r = 0
g = 0
b = 0
for c in string:
    if c == 'R':
        r += 1
    elif c == 'G':
        g += 1
    else:
        b += 1
ans = r*g*b
for i in range(n):
    for j in range(i+1, n):
        if 2*j - i >= n:
            break
        
        if string[i] != string[j] and string[i] != string[2*j-i] and string[j] != string[2*j-i]:
            ans -= 1
print(ans)
### BUGGY CODE ###

def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,K=input_int()
P= many_int()

kitaiti = []
for p in P:
    kitaiti.append((p+1)/2 )

maxs = 0
for i in range(K,N+1):
    temp = sum(kitaiti[i-K:i])
    if temp > maxs:
        maxs = temp

print(maxs)

### FIXED CODE ###

def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,K=input_int()
P= many_int()

kitaiti = [0]
for p in P:
    kitaiti.append((p+1)/2 )



maxs = 0
temp = sum(kitaiti[:K])
for i in range(N-K+1):

    temp += kitaiti[i+K]
    temp -= kitaiti[i]

    if temp > maxs:
        maxs = temp


print(maxs)
### BUGGY CODE ###

N,A,B,C,D = list(map(int, input().split()))
S = [0]+[0 if s=='.' else 1 for s in input()]

def Solution():
  for i in range(A,C):
    if S[i]*S[i+1]==1:
      return False
    for i in range(B,D):
      if S[i]*S[i+1]==1:
        return False
  if C<D:
    return True
  if C>D:
    for i in range(B,C-1):
      if S[i]+S[i+1]+S[i+2]==0:
        return True
    else:
      return False

if Solution():
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N,A,B,C,D = list(map(int, input().split()))
S = [0]+[0 if s=='.' else 1 for s in input()]
can_jump = [0] + [1-S[i]*S[i+1] for i in range(1,N-1)]
can_change = [0] + [(1-S[i])*(1-S[i+1])*(1-S[i+2]) for i in range(1,N-2)]

def Solution():
  if not all(can_jump[A:C]):
    return False
  if not all(can_jump[B:D]):
    return False
  
  if C<D:
    return True
  if C>D:
    if any(can_change[B-1:D]):
      return True
    else:
      return False

if Solution():
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
def f(a):
  if len(a) == 0:
    return []
  for i in range(len(a)):
    if a[i] == i+1:
      b = a.copy()
      b.pop(i)
      ret = f(b)
      if ret == [-1]:
        continue
      ret.append(i+1)
      return ret
    else:
      continue
  else:
    return [-1]
ret = f(a)
print('\n'.join(map(str,ret)))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
acts = []
while True:
    for i in range(len(a)):
        idx = len(a)-i-1
        if a[idx] == idx+1:
            a.pop(idx)
            acts.append(idx+1)
            break
    else:
        print('-1')
        break
    if len(a) == 0:
        acts.reverse()
        print('\n'.join(map(str,acts)))
        break
### BUGGY CODE ###

N=int(input())
alist=list(map(int, input().split()))
for i in range(1,N+1):
    print(alist.count(i))
    


### FIXED CODE ###

N=int(input())
alist=list(map(int, input().split()))
anslist=[0]*N
for a in alist:
    anslist[a-1]+=1
for ans in anslist:
    print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    p = max(0, j-A[j])
    q = min(n-1, j+A[j])
    C[p] += 1
    C[q+1] -= 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
  if all([v==n for v in C[:-1]]):
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(k):
  C = [0]*(n+1)
  for j in range(n):
    p = max(0, j-A[j])
    q = min(n-1, j+A[j])
    C[p] += 1
    C[q+1] -= 1
  v = 1
  for j in range(n):
    C[j+1]=C[j+1]+C[j]
    if C[j]!=n:
      v = 0
  if v:
    break
  A = C
C = [str(c) for c in C[:-1]]
print(' '.join(C))
### BUGGY CODE ###

#!/usr/bin/env python3
 
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from collections import defaultdict

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC138 E

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)
f = [False]*26
f2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(n):
    f[alpha.index(s[i])] = True
for i in range(m):
    f2[alpha.index(t[i])] = True
for i in range(26):
    if not f[i] and f2[i]:
        print(-1)
        quit()
ans = 0
inde = s.index(t[0])
ans += inde+1
for i in range(1,m):
    s = s[inde+1:] + s[:inde+1]
    inde = s.index(t[i])
    ans += inde+1
print(ans)
### BUGGY CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float("inf")]*n

#初期条件
dp[0] = 0

#漸化式
for i in range(1,n):
    for l in range(1,k+1):
        if i-l < 0:continue
        dp[i] = min(dp[i],dp[i-l] + abs(h[i-l]-h[i]))

print(dp[n-1])

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float("inf")]*n

#初期条件
dp[0] = 0

#漸化式
for i in range(1,n):
    for l in range(1,k+1):
        if i-l < 0:continue
        dp[i] = min(dp[i],dp[i-l] + abs(h[i-l]-h[i]))

print(dp[n-1])
### BUGGY CODE ###

S = input()
 
MOD = 10**9+7
 
dp = [[0]*13 for _ in range(len(S) + 1)]
 
 
dp[0][0] = 1
 
for index in range(1, len(S) + 1):
    s = S[len(S) - index ]
    mul = (10 ** (index - 1)) % 13
    if s == '?':
        for pre_index in range(13):
            for i in range(10):
                next_i = (i * mul  +  pre_index ) % 13
                dp[index][next_i] += dp[index - 1][pre_index] 
    else:
        for pre_index in range(13):
            i = int(s)
            next_i = (i * mul +  pre_index ) % 13
            dp[index][next_i] += dp[index - 1][pre_index] 
 
    for i in range(13):
        dp[index][i] %= MOD
 
 
 
print(dp[len(S)][5])


### FIXED CODE ###

S = input()
 
MOD = 10**9+7
 
dp = [[0]*13 for _ in range(len(S) + 1)]
 
 
dp[0][0] = 1
 
for index in range(len(S)):
    if S[index] == '?':
        for pre_index in range(13):
            for i in range(10):
                next_i = (i +  pre_index * 10 ) % 13
                dp[index+1][next_i] += dp[index][pre_index] 
                dp[index+1][next_i] %= MOD

    else:
        for pre_index in range(13):
            i = int(S[index])
            next_i = (i +  pre_index  * 10) % 13
            dp[index+1][next_i] += dp[index][pre_index] 
            dp[index+1][next_i] %= MOD
 
 
 
print(dp[len(S)][5])
### BUGGY CODE ###

n=int(raw_input())
ta=[map(int,raw_input().split()) for _ in xrange(n)]
for i in xrange(1,n):
    tmp1=ta[i][0]
    tmp2=ta[i][1]
    if ta[i-1][0]>ta[i][0]:
        a=2
        while 1:
            tmp1=ta[i][0]*a
            tmp2=ta[i][1]*a
            if ta[i-1][0]<=tmp1 and ta[i-1][1]<=tmp2:
                break
            a+=1
    if ta[i-1][1]>ta[i][1]:
        a=2
        while 1:
            tmp1=ta[i][0]*a
            tmp2=ta[i][1]*a
            if ta[i-1][0]<=tmp1 and ta[i-1][1]<=tmp2:
                break
            a+=1
    ta[i][0]=tmp1
    ta[i][1]=tmp2
print(ta[n-1][0]+ta[n-1][1])

### FIXED CODE ###

def main():
    n=int(raw_input())
    ta=[map(int,raw_input().split()) for _ in xrange(n)]
    for i in xrange(1,n):
        if ta[i-1][0]>ta[i][0] and ta[i-1][1]>ta[i][1]:
            mx=max((ta[i-1][0]-1)/ta[i][0]+1,(ta[i-1][1]-1)/ta[i][1]+1)
            ta[i][0]=ta[i][0]*mx
            ta[i][1]=ta[i][1]*mx
        elif ta[i-1][0]>ta[i][0]:
            ta[i][1]=ta[i][1]*((ta[i-1][0]-1)/ta[i][0]+1)
            ta[i][0]=ta[i][0]*((ta[i-1][0]-1)/ta[i][0]+1)
        elif ta[i-1][1]>ta[i][1]:
            ta[i][0]=ta[i][0]*((ta[i-1][1]-1)/ta[i][1]+1)
            ta[i][1]=ta[i][1]*((ta[i-1][1]-1)/ta[i][1]+1)
    print(ta[n-1][0]+ta[n-1][1])
main()
### BUGGY CODE ###

def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    bin_a=[[0] * n for i in range(60)]
    cnt1=[0]*60
    for i in range(n):
        tmp=str(bin(a[i]))
        # print(a[i])
        # print(len(tmp))
        for j in range(len(tmp)-2):
            if j==len(tmp)-2:
                break
            # print(tmp[len(tmp)-i-1])
            bin_a[j][i]=int(tmp[len(tmp)-j-1])
            cnt1[j]+=int(tmp[len(tmp)-j-1])

    for i in range(60):
        # cnt1=sum(bin_a[i])
        # cnt0=n-cnt1
        ans+=cnt1[i]*(n-cnt1[i])*2**i%MOD
    print(ans%MOD)

if __name__=='__main__':
    main()


### FIXED CODE ###

def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


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

n = int(input())
i = 0
flag = False
while(7*i<=n):
  if (n-7*i)%4 == 0:
    flag = True
    break
if flag:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

n = int(input())
i = 0
flag = False
while(7*i<=n):
  if (n-7*i)%4 == 0:
    flag = True
    break
  i+=1
if flag:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

N = int(input())
a = [int(i) for i in input().split()]

b = []
for i in range(N-1):
    b.append(abs(sum(a[:i+1])-sum(a[:i:-1])))
print(min(b))


### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
sum_a = sum(a)
b = []
c = 0
for i in range(N-1):
    c += a[i]
    b.append(abs(2*c-sum_a))
print(min(b))
### BUGGY CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]

a.extend(sum([[c]*b for b,c in bc],[]))
  
print(sum(sorted(a,reverse=True)[:n]))

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]

bc = sorted(bc,key=lambda x:(x[1]),reverse=True)
count=0
for b,c in bc:
  count += b
  a.extend([c]*b)
  if count >= n:
    break
    
print(sum(sorted(a,reverse=True)[:n]))
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
cnt = 0
 
for r in range(N//R + 1):
    ball1 = N - R * r
    if ball1 >= 0:
        for g in range(N//G + 1):
            ball2 = ball1 - G * g
            if ball2 >= 0 and ball2 % B == 0:
                    cnt += 1
 
print(cnt)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
cnt = 0
 
for r in range(N//R + 1):
    ball1 = N - R * r
    if ball1 >= 0:
        for g in range(N//G + 1):
            ball2 = ball1 - G * g
            if ball2 >= 0:
                if ball2 % B == 0:
                    cnt += 1
 
print(cnt)
### BUGGY CODE ###

n, k = map(int,input().split())
x = list(map(int,input().split()))
time = 10**9

for i in range(n - k + 1):
    x_k = x[i:i+k]
    #print(x_k)
    
    if x_k[0] >= 0:
        t = x_k[-1]
            
    elif x_k[-1] <= 0:
        t = -x_k[0]
    
    elif -x_k[0] <= x_k[-1]:
        t = -x_k[0] * 2 + x_k[-1]
    
    else:
        t = -x_k[0] + x_k[-1] *2

    time = min(t, time)
    
print(time)


### FIXED CODE ###

nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
x = list(map(int, input().split()))
min_d = 10 ** 9
for i in range(n - k + 1):
    max_i = x[i + k - 1]
    min_i = x[i]
    if max_i <= 0:
        min_d_i = - min_i
    elif min_i >= 0:
        min_d_i = max_i
    else:
        min_d_i = min(- min_i + 2 * max_i, -2 * min_i + max_i)
    if min_d_i < min_d:
            min_d = min_d_i
print(min_d)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
amount = [0]*n
preans = [0]*n

for i in range(n):
    amount[i] = a.count(i+1)
    preans[i] = amount[i]*(amount[i]-1)//2

ans = sum(preans)
#print(ans)
for j in range(n):
    ansout = ans
    #print(amount[a[j]-1])
    ansout -= amount[a[j]-1] -1
    print(ansout)

### FIXED CODE ###

import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

N, T = map(int, input().split())
A = [int(Ai) for Ai in input().split()]
B = [0] * len(A)
for i in range(1, len(A)):
    B[i] = A[i] - min(A[:i])
print(sum([Bi == max(B) for Bi in B]))


### FIXED CODE ###

N, T = map(int, input().split())
A = [int(Ai) for Ai in input().split()]
Amin = A[0]
Bmax = 0
count = 0
for i in range(1, len(A)):
    Amin = min(A[i-1], Amin)
    Bi = A[i] - Amin
    if Bmax == Bi:
        count += 1
    elif Bmax < Bi:
        Bmax = Bi
        count = 1
print(count)
### BUGGY CODE ###

n=int(input())
c = input()
l =list(c)
L = len(l)//2
ans = 0

for i in range(n-1):
    for j in range(n-1,i,-1):
        if l[i]== 'W' and l[j] == 'R':
            l[i] = 'R'
            l[j] = 'W'
            ans += 1
print(ans)

### FIXED CODE ###

n=int(input())
c=input()
r=c.count("R")
r_1=c[:r].count("R")
ans=r-r_1
print(ans)
### BUGGY CODE ###

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

M=[]

for i in range(1,N+1):
    tmp_list = Nums[:i]
    M_i = min(tmp_list)

    M.append(M_i)

cnt=0
for j in range(N):
    if Nums[j] ==M[j]:
        cnt+=1

print(cnt)

### FIXED CODE ###

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

min_value=Nums[0]

cnt=0

for i in range(N):
    min_value = min(min_value,Nums[i])
    
    if Nums[i]<=min_value:
        cnt+=1
    
    

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

import pprint
from itertools import chain
import collections
n, x, y = (int(each) for each in input().split(' '))

table1 = [[0] * n for i in range(n)]
table2 = [[0] * n for i in range(n)]
table_shortest = [[0] * n for i in range(n)]
cntr = {}

# 点iから点jまでの距離をテーブルにする

# 抜け道を通らないルートの場合
for i in range(n):
    for j in range(n):
        if j-i > 0:
            table1[i][j] = j-i

# 抜け道を通るルートの場合
for i in range(n):
    for j in range(n):
        if j-i > 0:
            table2[i][j] = abs(j-y+1)+abs(i-x+1)+1

# どちらか近いほうのルートが最短距離
for i in range(n):
    for j in range(n):
        if j-i > 0:
            table_shortest[i][j] = min(table1[i][j], table2[i][j])

# テーブルをflattenして数をかぞえる
cntr = collections.Counter(list(chain.from_iterable(table_shortest)))

cntr = dict(cntr)
for each in range(1,n):
    print(cntr.get(each, 0))

### FIXED CODE ###

import pprint
from itertools import chain
import collections
n, x, y = (int(each) for each in input().split(' '))

# table1 = [[0] * n for i in range(n)]
# table2 = [[0] * n for i in range(n)]
table = [[0] * n for i in range(n)]
# cntr = {}

# # 点iから点jまでの距離をテーブルにする

# # 抜け道を通らないルートの場合
# for i in range(n):
#     for j in range(n):
#         if j-i > 0:
#             table1[i][j] = j-i

# # 抜け道を通るルートの場合
# for i in range(n):
#     for j in range(n):
#         if j-i > 0:
#             table2[i][j] = abs(j-y+1)+abs(i-x+1)+1

# どちらか近いほうのルートが最短距離
for i in range(n):
    for j in range(i, n):
        if j-i > 0:
            table[i][j] = min(j-i, abs(j-y+1)+abs(i-x+1)+1)

# テーブルをflattenして数をかぞえる
cntr = collections.Counter(list(chain.from_iterable(table)))

# cntr = dict(cntr)
for each in range(1,n):
    print(cntr.get(each, 0))