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

from collections import deque

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

F=[[] for _ in range(N)]
B=[[] for _ in range(N)]


for i in range(M):
    a,b=map(int,input().split())
    F[a-1].append(b-1)
    F[b-1].append(a-1)

for i in range(K):
    a,b=map(int,input().split())
    B[a-1].append(b-1)
    B[b-1].append(a-1)

q=deque([])
G=[]
visited=[0]*N
for i in range(N):
    if visited[i]==1:continue
    visited[i]=1
    q.append([i,[i]])
    while q:
        n,c=q.pop()
        for j in F[n]:
            if visited[j]==0:
                c.append(j)
                visited[j]=1
                q.append([j,c])
    G.append(c)

cnt=[0]*N
for g in G:
    for i in g:
        for b in B[i]:
            if  b in g:
                cnt[i]+=1

ans=[0]*N

for g in G:
    for i in g:
        ans[i]=len(g)-len(F[i])-cnt[i]-1

for i in ans:
    print(str(i),end=" ")


### FIXED CODE ###

from collections import deque

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

F=[[] for _ in range(N)]
B=[[] for _ in range(N)]


for i in range(M):
    a,b=map(int,input().split())
    F[a-1].append(b-1)
    F[b-1].append(a-1)

for i in range(K):
    a,b=map(int,input().split())
    B[a-1].append(b-1)
    B[b-1].append(a-1)

q=deque([])
G=[]
visited=[0]*N
group=[-1]*N
idx=0
for i in range(N):
    if visited[i]==1:continue
    visited[i]=1
    group[i]=idx
    q.append([i,[i]])
    while q:
        n,c=q.pop()
        for j in F[n]:
            if visited[j]==0:
                c.append(j)
                visited[j]=1
                group[j]=idx
                q.append([j,c])
    G.append(c)
    idx+=1

cnt=[0]*N
for g in G:
    for i in g:
        for b in B[i]:
            if  group[i]==group[b]:
                cnt[i]+=1

ans=[0]*N

for g in G:
    for i in g:
        ans[i]=len(g)-len(F[i])-cnt[i]-1

for i in ans:
    print(str(i),end=" ")
### BUGGY CODE ###

N = int(input())
S = list(input())

ans = 0

for i in range(0,N):
  for j in range(i,N):
    for k in range(j,N):
      if S[i] != S[j]:
        if S[i] != S[k]:
          if S[j] != S[k]:
            if j - i != k - j:
              ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())

r = S.count('R')
g = S.count('G')
b = S.count('B')

ans = r*g*b

for i in range(0,N):
  for j in range(i,N):
    k = 2*j - i
    if j < k <= N-1:
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        ans -= 1

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

import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
#print(a)

bc=[]
for i in range(m):
    B = list(map(int, input().split()))
    bc.append(B)
bc.sort(key=lambda x: x[1])
#print(bc)

clis=[]
for i in range(m)[::-1]:
    clis+=[bc[i][1]]*bc[i][0]
#print(clis)
ans=0
le=len(clis)
for i in range(n):
    #print(clis[i],a[i])
    if i<le and clis[i]>a[i]:
        ans+=clis[i]
    else:
        ans+=a[i]
    #print(ans)
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for _ in range(m)]
bc.sort(key=lambda x: x[1],reverse=True)
#print(bc)
cnt=0
for i in range(n):
    if bc[cnt][0]>0:
        if bc[cnt][1]>a[i]:
            a[i]=bc[cnt][1]
        bc[cnt][0]-=1
    else:
        cnt+=1
        if cnt==len(bc):
            break
        if bc[cnt][1]>a[i]:
            a[i]=bc[cnt][1]
        bc[cnt][0]-=1
    #print(cnt,bc,a)
print(sum(a))
### BUGGY CODE ###

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

S={}
for i in range(n):
    a = A[i]
    if a in S :
        S[a]+=1
    else:
        S[a]=1

K=[]
for i in range(n):
    a = A[i]
    S[a]-=1
    c=0
    K=list(S.keys())
    for j in range(len(S)):
        s = S[K[j]]
        if s>=2 :
            c += s*(s-1)//2   
    S[a]+=1
    print(c)


### FIXED CODE ###

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

S={}
for i in range(n):
    a = A[i]
    if a in S :
        S[a]+=1
    else:
        S[a]=1

V=list(S.values())
c = sum([v*(v-1)//2 for v in V])

cdiff=0
K=[]
for i in range(n):
    cdiff=0
    a = A[i]
    s=S[a]
    if s>=2 :
        cdiff=(s*(s-1)-(s-1)*(s-2))//2
    print(c-cdiff)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 

K = INT()
 
many_gcd = lambda numbers: reduce(gcd, numbers)
 
ans = 0
for i in range(1, K+1):
	for j in range(1, K+1):
		for k in range(1, K+1):
			ans += many_gcd([i, j, k])
print(ans)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
K = INT()
sum = 0
 
for n in range(K):
  for m in range(K):
    for l in range(K):
      sum += gcd(n+1, gcd(m+1, l+1))
 
print(sum)
### BUGGY CODE ###

N=int(input())
ans = 0
for i in range(1,N+1):
    e = N//i*i
    n = N//i
    ans += ((i+e)*n //2)
print(ans)


### FIXED CODE ###

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

import copy
N, K = map(int,input().split())
a = list(map(int,input().split()))
S = [0]*N
S[0] = a[0]
for k in range(1,N):
    S[k] = S[k-1] + a[k]
S = [0] + S
T = []
for k in range(N):
    for l in range(k+1,N+1):
        T.append(S[l]-S[k])
ans = 0
for d in range(41,-1,-1):
    c = 0
    for e in T:
        if (ans+2**d)&e == ans+2**d:
            c += 1
    if c >= K:
        ans += 2**d
print(ans)


### FIXED CODE ###

N, K = map(int,input().split())
a = list(map(int,input().split()))
S = [0]*N
S[0] = a[0]
for k in range(1,N):
    S[k] = S[k-1] + a[k]
S = [0] + S
T = []
for k in range(N):
    for l in range(k+1,N+1):
        T.append(S[l]-S[k])
ans = 0
for d in range(41,-1,-1):
    c = 0
    for e in T:
        if (ans+2**d)&e == ans+2**d:
            c += 1
    if c >= K:
        ans += 2**d
print(ans)
### BUGGY CODE ###

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

mod = 10**9+7
r = n-k

def mod_combination(n, k, mod):
     # nCk (mod m)
     def mod_permutation(n, k, mod):
         if n<=k:
             return 1
         else:
             return (n * mod_permutation(n-1, k, mod))%mod
 
     def mod_inv_permutation(k, mod):
         k, mod = int(k), int(mod)
         if k<=1:
             return 1
         else:
             return (pow(k, mod-2, mod) * mod_inv_permutation(k-1, mod))%mod
 
     return (mod_permutation(n, n-k, mod) * mod_inv_permutation(k, mod))%mod

def f(n):
    a = mod_combination(k-1, n, mod)
    return a

for i in range(k):
    ans = 1
    ans = mod_combination(r+1, i+1, mod)
    ans = ans * f(i) % mod
    print(ans)

### FIXED CODE ###

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

mod = 10**9+7
r = n-k

def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    invs[0] = 1
    
    return factorials, invs

fr, inv = prepare(2010, mod)
for i in range(k):
    ans = 1
    if r-i < 0:
        ans = 0
    else:
        ans = (((fr[n-k+1] * inv[i+1] * inv[n-k-i]) % mod) * fr[k-1] * inv[i] * inv[k-1-i]) % mod
    print(ans)
### BUGGY CODE ###

s = input()
q = int(input())
a = []
for i in range(q):
    a.extend([list(map(str,input().split()))])
# print(a)
for i in a:
    if i ==["1"]:
        s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        s = i[2]+s
    elif i[0]=="2" and i[1]=="2":
        s = s +i[2]
print(s)

### FIXED CODE ###

s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
pre = ""
nex = ""
c = 1
for j in range(q):
    i = list(map(str,input().split()))
    if i ==["1"]:
        c *= -1
        # s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        # s = i[2]+s
        if c == 1:
            pre=i[2]+pre
        else:
            nex = nex + i[2]
    elif i[0]=="2" and i[1]=="2":
        # s = s +i[2]
        if c ==1:
            nex = nex +i[2]
        else:
            pre = i[2]+pre
s = pre+s+nex
if c ==-1:
    s = s[::-1]
print(s)
### BUGGY CODE ###

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

ans = 0
for a in range(K+1):
  for b in range(K+1):
    for c in range(K+1):
      if a+b+c == A:
        ans += 1

print(ans)

### FIXED CODE ###

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

ans = 0
for a in range(K+1):
  for b in range(K+1):
    c = A-(a+b)
    if 0 <= c <= K:
        ans += 1

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

import os

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

ans = 0
for i in range(0,M):
    a = list.index(max(list))
    list[a] = list[a]//2
for j in list:
    ans += j
print(ans)


### FIXED CODE ###

import os
import heapq

N,M = (int(x) for x in input().split())
list = [-int(i) for i in input().split()]

heapq.heapify(list)
ans = 0
for i in range(0,M):
    a = heapq.heappop(list)
    heapq.heappush(list,-((-a)//2))
for j in list:
    ans += j*(-1)
print(ans)
### BUGGY CODE ###

n = int(input())
h = list(map(int,input().split()))
if n == 2:
    print(abs(h[0]-h[1]))
else:
    lst = set(map(lambda x : format(x,'b').zfill(n-2) + '1',set(range((n-2) ** 2))))
    del_lst = set()
    for i in lst:
        if '00' in i:
            del_lst.add(i)
    lst = list(lst - del_lst) 
    ans =[[h[0],0] for i in range(len(lst))]

    for i in range(len(lst)):
        k = 1
        for j in lst[i]:
            if j == '1':
                ans[i][1] += abs(h[k] - ans[i][0])
                ans[i][0] = h[k]
            k += 1
    print(min(ans)[1])

### FIXED CODE ###

n = int(input())
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[i-1]) + ans[i-1], abs(h[i] - h[i-2]) + ans[i-2])
print(ans[-1])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    zeros = [0 for _ in range(60)]
    ones = [0 for _ in range(60)]
    for a in A:
        for i in range(60):
            if (a >> i) & 1:
                ones[i] += 1
            else:
                zeros[i] += 1

    res = 0
    for a in A:
        for i in range(60):
            if (a >> i) & 1:
                res += zeros[i] << i
                res %= MOD
            else:
                res += ones[i] << i
                res %= MOD
    if res % 2 == 1:
        res = res + MOD
    print(res // 2)
        
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ones = [0 for _ in range(60)]
    for a in A:
        for i in range(60):
            if (a >> i) & 1:
                ones[i] += 1

    res_l = [0 for _ in range(60)]
    for a in A:
        for i in range(60):
            if (a >> i) & 1:
                res_l[i] += (N-ones[i])
            else:
                res_l[i] += ones[i]
    res = 0
    for i in range(60):
        res += res_l[i] << i
        res %= MOD
    if res % 2 == 1:
        res += MOD
    print(res // 2)
        
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

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

n = int(input())
order = list(map(int, input().split()))
for i in range(1, len(order)+1):
  id = order.index(i)
  print(id+1, end = ' ')

### FIXED CODE ###

n = int(input())
order = list(map(int, input().split()))
correctOrder = [0 for x in range(n)]
for i in range(n):
    correctOrder[order[i]-1] = str(i+1)
toStr = ' '.join(correctOrder)
print(toStr)
### BUGGY CODE ###

from bisect import bisect 
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
cnt=0
for a in A:
    b_min=bisect(B,a)
    for b in B[b_min:]:
        c_min=bisect(C,b)
        cnt+=len(C[c_min:])
print(cnt)

### FIXED CODE ###

from bisect import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
B_reverse=B[::-1]
C=sorted(list(map(int,input().split())))
cnt=0
dict={}
val=0
for b in B_reverse:
    c_min=bisect(C,b)
    val+=N-c_min
    dict[b]=val
for a in A:
    b_min=bisect(B,a)
    if b_min==N:
        pass
    else:
        cnt+=dict[B[b_min]]
print(cnt)
### BUGGY CODE ###

N, K = map(int, input().split(" "))
h_arr = list(map(int, input().split(" ")))
dp = [0]*N

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

### FIXED CODE ###

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
l = []
r = []
for i in range(Q):
    l_, r_ = map(int, input().split())
    l.append(l_)
    r.append(r_)
    
for i in range(Q):
  print(S[l[i]-1:r[i]].count('AC'))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)
ans = []

for i in range(N):
    t[i+1] += t[i] + ( 1 if S[i:i+2] == 'AC' else 0) 

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

N = int(input())
*A, = map(int, input().split())
dp = [[0] * (N+1) for _ in range(N+1)]
for n in range(1, N+1):
    for i in range(N-n+1):
        j = i + n
        if (N - n) % 2 == 0: # first player
            dp[i][j] = max(dp[i+1][j] + A[i], dp[i][j-1] + A[j-1])
        else: # second player
            dp[i][j] = min(dp[i+1][j] - A[i], dp[i][j-1] - A[j-1])
print(dp[0][N])

### FIXED CODE ###

N = int(input())
*A, = map(int, input().split())
dp = [[0] * (N+1) for _ in range(N+1)]
for n in range(1, N+1):
    for i in range(N-n+1):
        j = i + n
        if (N - n) % 2 == 0: # first player
            dp[i][j] = max(dp[i+1][j] + A[i], dp[i][j-1] + A[j-1])
        else: # second player
            dp[i][j] = min(dp[i+1][j] - A[i], dp[i][j-1] - A[j-1])
print(dp[0][N])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力の取得
A, B, N = list(map(int, input().split()))


# 関数の定義
def func(x: int) -> int:
    return math.floor(A*x/B) - A*math.floor(x/B)


# 求解処理
result = 0
for x in range(min(N, B-1), N+1, B):
    result = max(result, func(x))

# 結果出力
print(result)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力の取得
A, B, N = list(map(int, input().split()))


def f(x: int) -> int:
    return math.floor(A*x/B) - A*math.floor(x/B)


# 求解処理
result = f(min(B-1, N))

# 結果出力
print(result)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
ans = 0

for i in range(len(A)):
  for j in range(i+1, len(A)):
    ans += A[i]*A[j]
    if ans > 10**9+7:
      ans %= 10**9+7
print(ans)

### FIXED CODE ###

import numpy as np

N = int(input())
A = [int(i) for i in input().split()]
sum = 0
for x in A:
  sum += x
  sum %= (10**9+7)

sum2 = 0
for x in A:
  sum2 += x*x
  sum2 %= (10**9+7)

ans = (sum**2 - sum2) % (10**9+7)
if ans < 0:
  ans += (10**9+7)
ans *= int((10**9+7+1)/2) 
ans %= (10**9+7)
print(int(ans))
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] + l[j] > l[k]: c += 1
            else: break
print(c)

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
  n = int(input())
  l = list(map(int, input().split()))
  l.sort()
  l.append(99999999)
  c = 0
  for i in range(n - 2):
      t = i + 2
      for j in range(i + 1, n - 1):
          for k in range(t, n + 1):
              if l[i] + l[j] <= l[k]:
                  t = k
                  break
          if t > j: c += t - j - 1
          if j + 1 == t: t += 1
  print(c)
if __name__ == "__main__":
  main()
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
B=sorted(A)
ans=[]
for i in range(N):
  mnum=A.index(B[i])
  ans.append(mnum+1)
ans=map(str,ans)
ans=" ".join(ans)
print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
Alist=[]
for i in range(N):
  Alist.append((A[i],i+1))
Alist=sorted(Alist,key=lambda x: x[0])
for i in range(N):
  print(Alist[i][1],end=" ")
### BUGGY CODE ###

def column_check(grp, grp_count, choco, h, j, k):
    """ 0:成功（更新も反映）  1:失敗（区切った結果を返す） 2:不可能 """
    # この行のグループ毎のカウント
    curr_count = [0] * len(grp_count)
    # 数える
    for i in range(h):
        if choco[i][j] == '0':
            continue
        curr_count[grp[i]] += 1
    # この行だけでk越えてたら現在の横の切り方では不可能
    for cc in curr_count:
        if cc > k:
            return 2
    # 左と合わせてkを越えないかチェック
    over = False
    for gc, cc in zip(grp_count, curr_count):
        if gc + cc > k:
            over = True
            break
    # 越えてたら、現在の行でgrp_countを更新
    if over:
        for i, cc in enumerate(curr_count):
            grp_count[i] = cc
        return 1
    # 越えてなかったら、加算
    for i, cc in enumerate(curr_count):
        grp_count[i] += cc
    return 0


def solve(h, w, k, choco):
    ans = 10 ** 9
    grp = [0] * h
    for bit in range(1 << (h - 1)):
        g = 0
        for i in range(h):
            grp[i] = g
            if (bit >> i) & 1:
                g += 1

        grp_count = [0] * (g + 1)
        tmp = 0
        possible = True
        for j in range(w):
            result = column_check(grp, grp_count, choco, h, j, k)
            if result == 2:
                possible = False
                break
            if result == 1:
                tmp += 1

        if not possible:
            continue

        ans = min(ans, tmp + bin(bit).count('1'))

    return ans


h, w, k = map(int, input().split())
choco = [input() for _ in range(h)]
print(solve(h, w, k, choco))


### FIXED CODE ###

from itertools import accumulate


def solve(h, w, lim, choco):
    acc = [[0] + list(accumulate(int(c == '1') for c in s)) for s in choco]
    acc = list(zip(*acc))
    acc = [[0] + list(accumulate(s)) for s in acc]
    acc = list(zip(*acc))
    # print(*acc, sep='\n')

    ans = 10 ** 9
    # i:j  h方向の分割
    # k:l  w方向の分割
    for bit in range(1 << (h - 1)):
        k = 1
        tmp = 0
        while k < w:
            # print(bin(bit), k)
            i = 0
            l = w + 1
            sp = bit | 1 << (h - 1)
            while sp:
                b = sp & -sp
                sp ^= b
                j = b.bit_length()
                lt = k
                while lt <= w and acc[j][lt] - acc[j][k - 1] - acc[i][lt] + acc[i][k - 1] <= lim:
                    lt += 1
                if lt == k:
                    break
                l = min(l, lt)
                # print('i,j,k,l', i, j, k, l, lt)
                i = j
            else:
                k = l
                if k <= w:
                    tmp += 1
                continue
            break
        else:
            # print(tmp, bin(bit).count('1'))
            ans = min(ans, tmp + bin(bit).count('1'))
    return ans


h, w, k = map(int, input().split())
choco = [input() for _ in range(h)]
print(solve(h, w, k, choco))
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()

for i in range(q):
    l,r=map(int,input().split())
    m=0
    for j in range(l-1,r-1):
            if s[j:j+2]=="AC":
                m+=1
    print(m)



### FIXED CODE ###

n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

for i in range(q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

n = int(input())
L = list(map(int,input().split()))
L.sort(reverse=True)

# print(L)
ans = 0
for i in range(n):
    # print(i)
    a = L[i]
    ci = 0
    for j in range(i+1,n-1):
        b = L[j]
        ci = n-1
        # print("ci",ci)
        while ci > j and b+L[ci] <= a:
            ci -= 1
        ans += ci-j
print(ans)



### FIXED CODE ###

n = int(input())
L = list(map(int,input().split()))
L.sort(reverse=True)

# print(L)
ans = 0
for i in range(n):
    # print(i)
    a = L[i]
    ci = n-1
    for j in range(i+1,n-1):
        b = L[j]
        ci = max(ci,j)
        # print("ci",ci)
        while ci > j and b+L[ci] <= a:
            ci -= 1
        ans += ci-j
print(ans)