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

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

total = s.count("R") * s.count("G") * s.count("B")

#l = ["RGB", "RBG", "GRB", "GBR", "BRG", "BGR"]

lR = [0]*n
lG = [0]*n
lB = [0]*n

for i in range(len(s)):
    if s[i] == "R":
        lR[i] += 1
    elif s[i] == "G":
        lG[i] += 1
    else:
        lB[i] += 1

#print(lR)
#print(lG)
#print(lB)

for i in range(n):
    if lR[i]:
        for j in range(n):
            if lG[j]:
                for k in range(n):
                    if lB[k]:
                        if abs(j-i) == abs(k-j) or abs(j-k) == abs(k-i) or abs(j-i) == abs(k-i):
                            total -= 1
print(total)


### FIXED CODE ###

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

total = s.count("R") * s.count("G") * s.count("B")

#l = ["RGB", "RBG", "GRB", "GBR", "BRG", "BGR"]

lR = [0]*n
lG = [0]*n
lB = [0]*n

for i in range(len(s)):
    if s[i] == "R":
        lR[i] += 1
    elif s[i] == "G":
        lG[i] += 1
    else:
        lB[i] += 1

#print(lR)
#print(lG)
#print(lB)

for i in range(n):
    j = 1
    if lR[i]:
        while i-j >= 0 and i+j < n:
            if lG[i+j]!=0 and lG[i+j] == lB[i-j]:
                total -= 1
            elif lG[i-j]!=0 and lG[i-j] == lB[i+j]:
                total -= 1
            j += 1

    elif lG[i]:
        while i-j >= 0 and i+j < n:
            if lR[i+j]!=0 and lR[i+j] == lB[i-j]:
                total -= 1
            elif lR[i-j]!=0 and lR[i-j] == lB[i+j]:
                total -= 1
            j += 1

    elif lB[i]:
        while i-j >= 0 and i+j < n:
            if lG[i+j]!=0 and lG[i+j] == lR[i-j]:
                total -= 1
            elif lG[i-j]!=0 and lG[i-j] == lR[i+j]:
                total -= 1
            j += 1

print(total)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

cache = {}
def dfs(index):
    if index in cache:
        return cache[index]
    target = s[index:]
    if len(target) <= 1:
        cache[index] = len(target)
        return cache[index]
    if len(target) == 2:
        if target[0] == target[1]:
            cache[index] = 1
            return cache[index]
        else:
            cache[index] = 2
            return cache[index]
    if len(target) >= 3:
        if target[0] == target[1]:
            cache[index] = max(1 + dfs(index + 2), 2 + dfs(index + 3))
            return cache[index]
        else:
            cache[index] = max(1 + dfs(index + 1), 1 + dfs(index + 2))
            return cache[index]

ans = 0
if len(s) == 1:
    print(ans)
    sys.exit(0)
print(dfs(0))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()
if len(s) == 1:
    print(0)
    sys.exit(0)
if len(s) == 2 and s[0] == s[1]:
    print(0)
    sys.exit(0)

# [i][0]: index iが1文字分割
# [i][1]: index iが2文字分割
dp = [[0] * 2 for _ in range(len(s))]
# 3文字以上では1文字/2文字の仮想結果が使われる
# 1文字
dp[0][0] = dp[0][1] = 1
# 2文字
if s[0] == s[1]:
    # 実際には常に2文字分割になる
    dp[1][0] = dp[1][1] = 1
else:
    dp[1][0] = 2
    dp[1][1] = 1

# 3文字以上
for i in range(2, len(s)):

    # [i][0]: 末尾の分割を1文字にする場合

    # 末尾2文字が同じ場合
    # - 1つ前を2文字分割にしなくてはならない
    if s[i] == s[i-1]:
        dp[i][0] = dp[i-1][1] + 1
    # 末尾2文字が異なる場合
    # - 1つ前が1文字分割
    # - 1つ前が2文字分割
    else:
        dp[i][0] = max(dp[i-1][0] + 1, dp[i-1][1] + 1)


    # [i][1]: 末尾の分割を2文字にする場合
    # 末尾前の2文字が末尾の2文字と同じ場合
    # 末尾前を1文字分割にしなくてはならない
    if s[i-3:i-1] == s[i-1:i+1]:
        dp[i][1] = dp[i-2][0] + 1
    # 末尾前の2文字が末尾の2文字と異なる場合
    # - 末尾前が1文字分割
    # - 末尾前が2文字分割
    else:
        dp[i][1] = max(dp[i-2][0] + 1, dp[i-2][1] + 1)

print(max(dp[-1][0], dp[-1][1]))
### BUGGY CODE ###

from sys import stdin
input = stdin.readline

n = int(input())
def warshall_floyd(d):
    for x in range(n):
        for y in range(n):
            for z in range(n):
                d[y][z] = min(d[y][z],d[y][x]+d[x][z])
    return d 

graph = [[float("inf")]*n for _ in range(n)]

for i in range(n-1):
    a,b,c = map(int,input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

for i in range(n):
    graph[i][i] = 0

G = warshall_floyd(graph)

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

for i in range(len(ans)):
    print(ans[i])

### FIXED CODE ###

from collections import deque

def f(k,edge,n):
    root = [[] for _ in range(n)]
    for i in range(n-1):
        a,b,c = edge[i][0],edge[i][1],edge[i][2]
        root[a-1].append([b-1,c])
        root[b-1].append([a-1,c])
    
    que = deque()
    for l in root[k]:
        que.append(l)
    
    dist = [float("inf")]*n
    dist[k] = 0
    visited = [False]*n
    que = deque([k])

    while que:
        pos = que.popleft()
        if not visited[pos]:
            visited[pos] = True
        for x,y in root[pos]:
            if not visited[x]:
                dist[x] = dist[pos] + y
                visited[x] = True
                que.append(x)
    return dist

n = int(input())
edge = [list(map(int,input().split())) for _ in range(n-1)]

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

ans = []
d = f(k-1,edge,n)
for i in range(q):
    x,y = map(int,input().split())
    ans.append(d[x-1] + d[y-1])

print(*ans , sep = "\n")
### BUGGY CODE ###

S = input()
ls =[0 for i in range(2019)]
ls[0] += 1
p_amari = 0
kake = 1
ret = 0
len_s = len(S)
for i in reversed(S) :
	p_amari = ( int(i) * kake + p_amari ) % 2019
	ret += ls[p_amari]
	ls[p_amari] += 1
	kake *= 10
print(int(ret))

### FIXED CODE ###

S = input()

ls =[0 for i in range(2019)]
ls[0] += 1
p_amari = 0
ret = 0
len_s = len(S)
for i in range(len_s) :
	p_amari = ( int(S[len_s-1-i]) * pow(10, i, 2019) + p_amari ) % 2019
	ret += ls[p_amari]
	ls[p_amari] += 1
print(int(ret))
### BUGGY CODE ###

n=int(input())
a=[]
lis=[]
for i in range(n):
  inp=int(input())
  if not inp in a:
    a.append(inp)
    lis.append(1)
  else:
    lis[a.index(inp)]+=1
ans=0
for i in lis:
  if i%2:
    ans+=1
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
a=[]
lis=[]
for i in range(n):
  inp=int(input())
  a.insert(bisect.bisect_left(a,inp),inp)
ans=0
bef=a[0]
co=0
for i in a[1:]:
  if i!=bef:
    ans+=(co+1)%2
    co=0
    bef=i
  else:
    co+=1
ans+=(co+1)%2
print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
ans = A[0]
INF = 10**18
for i in range(1,n):
    ans = ans * A[i]
    if ans > INF:
        ans = -1
print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = A[0]
INF = 1000000000000000000
for i in range(1,n):
    l,r = len(str(ans)),len(str(A[i]))
    if l+r > 21:
        ans = -1
        break
    else:
        ans = ans * A[i]
        if ans > INF:
            ans = -1
            break
print(ans)
### BUGGY CODE ###

n = input()

n = int(n)
s = [0]*n
sm = []

for i in range(0,n):
  s[i] = input()

for i in range(0,n):
  sm.append(s[i])
  if(sm.count(s[i]) > 1):
    del sm[-1]
    
print(len(sm))

### FIXED CODE ###

n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
ans = 0
s.sort()
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
    
print(ans+1)
### BUGGY CODE ###

from itertools import accumulate

n, k = map(int, input().split())
A = list(map(int, input().split())) + [0]

for _ in range(k):
    l = [0] * (n + 1)
    for i, a in enumerate(A[:-1]):
        l[max(0, i - a)] += 1
        l[min(n, i + a + 1)] -= 1
    A = list(accumulate(l))

print(*A[:-1])

### FIXED CODE ###

import numpy as np
from numba import jit


@jit("i8, i8, i8[:]")
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


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

s = raw_input()

while s.find('ST') > -1:
    s = ''.join(s.split('ST'))

print len(s)

### FIXED CODE ###

s = raw_input()

#while s.find('ST') > -1:
#    s = ''.join(s.split('ST'))
#
#print len(s)

temp = []
for i in range(len(s)):
    now = s[i]
    if len(temp) == 0:
        temp.append(now)
    elif temp[-1] + now == 'ST':
        temp.pop()
    else:
        temp.append(now)

print len(temp)
### BUGGY CODE ###

n,m,q=map(int,input().split())
g=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a][b]+=1
r=[[0 for i in range(n+1)] for j in range(n)]
for i in range(n):
    for j in range(1,n+1):
        r[i][j]=r[i][j-1]+g[i][j-1]
for i in range(q):
    a,b=map(int,input().split())
    a-=1
    b-=1
    ans=0
    for i in range(a,b+1):
        ans+=r[i][b+1]-r[i][a]
    print(ans)

### FIXED CODE ###

n,m,q=map(int,input().split())
g=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    #a-=1
    #b-=1
    g[a][b]+=1
    
for i in range(n):
    for j in range(n+1):
        g[i+1][j]+=g[i][j]
for i in range(n+1):
    for j in range(n):
        g[i][j+1]+=g[i][j]
for i in range(q):
    a,b=map(int,input().split())
    a-=1
    print(g[b][b]+g[a][a]-g[a][b]-g[b][a])
#print(g)
### BUGGY CODE ###

from collections import defaultdict
import sys

input = lambda: sys.stdin.readline().rstrip()

M = 998244353
B = pow(10, 18, M)
N = int(input())

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  prev_i = N
  prev_W = pow(B, N, M)
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in e[i]})
    if m:
      g[i] = m
      W = inv_mod(pow(B, prev_i-i, M), prev_W, M)
      sum_g[g[i]] = (sum_g[g[i]] + W) % M
      sum_g[0]  = (sum_g[0] - W) % M
      prev_i, prev_W = i, W
  
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret = (ret + sx*sy*sz) % M
  return ret

edge = [read_edge() for i in range(3)]

print(solve(N, edge))

### FIXED CODE ###

from collections import defaultdict

M = 998244353
B = 10**18 % M

def mex(s):
  for i in range(max(s)+2):
    if i not in s:
      return i

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  for i in sorted(e.keys(), reverse=True):
    m = mex({g.get(j,0) for j in e[i]})
    if m:
      g[i] = m
      x = pow(B, i, M)
      sum_g[m] += x
      sum_g[0] -= x
  return sum_g

def get_edge():
  M = int(input())
  e = defaultdict(set)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].add(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, x in sum_g[0].items():
    for gy, y in sum_g[1].items():
      gz = gx^gy
      z = sum_g[2][gz]
      ret = (ret + x*y*z)%M
  return ret

N = int(input())
edge = [get_edge() for i in range(3)]

print(solve(N, edge))
### BUGGY CODE ###

import collections
N = int(input())
D = [int(i) for i in input().split()]

C = collections.Counter(D)
if C.most_common()[0][1] >= 3:
    print(0)
    exit()


ans = 0
for i in range(2 ** N):
    D0 = [0, 24]
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            D0.append(24-D[j])
        else:
            D0.append(D[j])

    D0 = sorted(D0)
    c = 24
    for i in range(N+1):
        c = min(c, D0[i+1]-D0[i])
    ans = max(ans, c)

print(ans)


### FIXED CODE ###

import collections
import copy
N = int(input())
D = [int(i) for i in input().split()]

C = collections.Counter(D)
if C.most_common()[0][1] >= 3:
    print(0)
    exit()

D1 = [0, 24]
m = []
for k, v in C.items():
    if v == 2:
        D1.append(k)
        D1.append(24-k)
    elif v == 1:
        m.append(k)

ans = 0
for i in range(2 ** len(m)):
    D0 = copy.deepcopy(D1)
    for j in range(len(m)):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            D0.append(24-m[j])
        else:
            D0.append(m[j])

    # print(D0)

    D0 = sorted(D0)
    c = 24
    for i in range(N+1):
        c = min(c, D0[i+1]-D0[i])
    ans = max(ans, c)

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

n, k = map(int,input().split())
a = list(map(int,input().split()))
l = []
i=0
while (a[i]-1) not in l:
    l.append(i)
    i = a[i]-1 
l.append(i)

pre = l.index(a[i]-1)  
loop = len(l)-pre
if pre+loop<k:
    k=(k-pre)%loop+pre
print(l[k]+1)

### FIXED CODE ###

n, k = map(int,input().split())
a = list(map(int,input().split()))
l = [0]*n
i=0
cnt=0
while l[i]==0:
    l[i] = a[i]
    i = a[i]-1 
    cnt += 1
start = i+1
i = 0
pre = 0
while i+1!=start:
    i = a[i]-1
    pre += 1
loop = cnt-pre
if pre+loop<k:
    k=(k-pre)%loop+pre
i = 0
for _ in range(k):
    i = a[i]-1
print(i+1)
### BUGGY CODE ###

from itertools import permutations

inputs = [int(x) for x in input().split()]
n, m = inputs[0], inputs[1]
conf = [[int(x) for x in input().split()] for _ in range(n)]
# conf = sorted([[int(x) for x in input().split()] for _ in range(n)], reverse=True)

maxres = 0
cache = []
for cc in permutations(conf, min(m, len(conf))):
  res = 0
  if cc in cache:
    continue
  cache.append(cc)
  for i, c in enumerate(cc):
    if i + c[0] <= m:
      res = res + c[1]
  if res > maxres:
    maxres = res
print(maxres)


### FIXED CODE ###


import collections
import heapq

inputs = [int(x) for x in input().split()]
n, m = inputs[0], inputs[1]
conditions = collections.deque([])
for i in range(n):
  conditions.append([int(x) for x in input().split()])

conditions = sorted(conditions)

cnt, ans = 0, 0
candidates = []
for reversed_day in range(1, m + 1):
  while cnt < len(conditions) and conditions[cnt][0] <= reversed_day:
    heapq.heappush(candidates, -conditions[cnt][1])
    cnt += 1

  if len(candidates) == 0:
    continue
  ans -= heapq.heappop(candidates)

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

N=int(input())
c=input()
ans=[]
for i in range(N+1):
    ans.append(max(c[i:].count('R'),c[:i].count('W')))
print(min(ans))


### FIXED CODE ###

N=int(input())
c=input()
R=c.count('R')
W=0
ans=[R,c.count('W')]
for i in range(N):
    if c[i]=='W':
        W+=1
    else:
        R-=1
    ans.append(max(R,W))
print(min(ans))
### BUGGY CODE ###

from collections import defaultdict
import sys
from functools import lru_cache

sys.setrecursionlimit(4100000)

def f(n):
    res = 0
    while n:
        n %= bin(n).count("1")
        res += 1
    return res

def main():
    N = int(input())
    X = input()
    O = int(X, 2)
    pc = X.count('1')
    Y = list(X)
    ans = [0] * N
    pre = 1
    for i in range(N-1,-1,-1):
        if pc - 1 <= 0:
            break
        if Y[i] == '1':
            tmp = (O - pre + pc - 1) % (pc - 1)
            ans[i] = f(tmp) + 1
        pre *= 2
        pre %= (pc - 1)
    pre = 1
    for i in range(N-1,-1,-1):
        if Y[i] == '0':
            tmp = (O + pre) % (pc + 1)
            ans[i] = f(tmp) + 1
        pre *= 2
        pre %= (pc + 1)

    for i in range(N):
        print(ans[i])


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from functools import lru_cache
 
sys.setrecursionlimit(4100000)
 
@lru_cache(maxsize=None)
def f(n):
    if n == 0:
        return 0

    return f(n % bin(n).count('1')) + 1

def main():
    N = int(input())
    X = list(input())
    pc = X.count('1')
    now = 0
    for i in range(N):
        if X[i] == '1':
            now += pow(2,N-i-1)

    ac = pc + 1
    dc = pc - 1
    ac_now = now % ac
    if dc:
        dc_now = now % dc
    for i in range(N):
        cnt = 0
        if X[i] == '1' and dc:
            tmp = (dc_now - pow(2, N-i-1, dc)) % dc
            cnt = 1 + f(tmp)
        elif X[i] == '0':
            tmp = (ac_now + pow(2, N-i-1, ac)) % ac
            cnt = 1 + f(tmp)

        print(cnt)



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

# -*- coding: utf-8 -*-
"""
Created on Sat May 19 15:10:55 2018
AOJ ITP2_1_B
@author: maezawa
"""

q = int(input())
a = []

for i in range(q):
    ops= list(map(int,input().split()))
    if ops[0] == 0:
        if ops[1] == 0:
            a.insert(0,ops[2])
        else:
            a.append(ops[2])
    elif ops[0] == 1:
        print(a[ops[1]])
    else:
        if ops[1] == 0:
            a.pop(0)
        else:
            a.pop(-1)


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 14:53:50 2018
ITP21B
@author: maezawa
"""

from collections import deque

d = deque()

n = int(input())

for i in range(n):
    c = list(map(int, input().split()))
    if c[0] == 0:
        if c[1] == 0:
            d.appendleft(c[2])
        else:
            d.append(c[2])
    elif c[0] == 1:
        print(d[c[1]])
    else:
        if c[1] == 0:
            d.popleft()
        else:
            d.pop()
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A=[int(input()) for _ in range(Q)]
for i in range(N):
    ans = K - Q + A.count(i+1)
    # print(ans)
    if ans > 0:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

N, K, Q = map(int, input().split())
P = [0] * N

for i in range(Q):
    P[int(input())-1] += 1
for i in range(N):
    ans = K - Q + P[i]
    # print(ans)
    if ans > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

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

mul=1
for i in range(K):
    mul*=A[i]

for i in range(K,N):
    if A[i]>A[i-K] :
        print("Yes")
    else:
        print("No")






### FIXED CODE ###

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

text=""
for i in range(K,N):
    if A[i]>A[i-K] :
        text+="Yes\n"
    else:
       text+="No\n"
print("{}".format(text))
### BUGGY CODE ###

N = int(input())
A = [int(x) for x in input().split()]
ans = 0
for i in range(N-2):        
    for j in range(max(A[i]+1, i+2), N):
        if A[j] + A[i] == j - i:
            ans += 1
print(ans)


### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
L = [0] * 2 * N
R = [0] * 2 * N
for i in range(N):
    l = i + A[i]
    if l < N: L[l] += 1
    r = i - A[i]
    if r > 0: R[r] += 1
ans = 0 
for i in range(N):
    ans += L[i] * R[i]
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
# sys.setrecursionlimit(1000000)


def run(cost, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                cost[i][j] = min(
                    cost[i][j],
                    cost[i][k] + cost[k][j])
    return cost


if __name__ == '__main__':
    N, M, L = map(int, input().split())

    cost = [[float('inf')] * N for _ in range(N)]
    for i in range(N):
        cost[i][i] = 0

    for _ in range(M):
        v1, v2, w = map(int, input().split())
        v1, v2 = v1-1, v2-1
        if w <= L:
            cost[v1][v2] = w
            cost[v2][v1] = w
    cost = run(cost, N)

    for i in range(N):
        for j in range(N):
            if cost[i][j] == 0:
                pass
            elif cost[i][j] <= L:
                cost[i][j] = 1
            else:
                cost[i][j] = float('inf')
    cost = run(cost, N)

    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        ans = cost[s-1][t-1]
        if ans == float('inf'):
            print(-1)
        else:
            print(ans - 1)


### FIXED CODE ###

import sys
input = sys.stdin.readline
 
n, m, l = map(int, input().split())
 
INF = float("INF")
 
d = [[INF] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0
 
for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
 
for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
 
# print()
# print(*d, sep='\n')
 
for i in range(n):
    for j in range(n):
        if i == j:
            continue
 
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = INF
 
for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
 
# print()
# print(*d, sep='\n')
 
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
 
    if d[s][t] == INF:
        print(-1)
    else:
        print(d[s][t]-1)
### BUGGY CODE ###

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

for i in range(N):
  cnt = 0
  for j in range(N):
    for k in range(j+1, N):
      if i!=j and i!=k and l[j]==l[k]:
        cnt += 1
  print(int(cnt))

### FIXED CODE ###

from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))
### BUGGY CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
import numpy as np
N,W = list(map(int, input().split()))
wlist = [tuple(map(int, input().split())) for _ in range(N)]


# until ..w, v 
l = [(-1, 0, 0)]

ans = 0
while l:
    i_last, w, v = l.pop()
    if w > W:
        continue

    ans = max(ans, v)

    if i_last >= N-1:
        continue

    l.append( (i_last+1, w+wlist[i_last+1][0], 
                         v+wlist[i_last+1][1] ) )
    l.append( (i_last+1, w, 
                         v ) )
print(ans)

    



### FIXED CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
# FROM :  https://atcoder.jp/contests/dp/submissions/4127921

import numpy as np
N,W = list(map(int, input().split()))

wvlist = sorted( [ [int(x) for x in input().split()] for _ in range(N)] ) 

dp = [0] * (W+1)
cnt = 0
for w,v in wvlist:
    cnt = cnt+w
    for i in range(min(cnt, W), w-1, -1):
        if dp[i] < dp[i-w]+v:
            dp[i] = dp[i-w] + v

print(max(dp))
### BUGGY CODE ###

from itertools import chain
from collections import defaultdict

N = int(input())
T = tuple(map(int,input().split()))
V = tuple(map(int,input().split()))

dp = {0:0}

for t,v_max in zip(T,V):

  ndp = defaultdict(int)

  for vf in range(2*v_max+1):
    vf /= 2
    for vi,d in dp.items():
      if abs(vf-vi) > t or vi > v_max:
        continue
      vp = (t+vi+vf)/2
      d += (2*vp*vp-vf*vf-vi*vi)/2
      if vp > v_max:
        d -= (vp-v_max)**2
      ndp[vf] = max(ndp[vf],d)
  
  dp = ndp

print(dp[0])

### FIXED CODE ###

from itertools import chain
 
double = lambda c: int(c)*2
 
N = int(input())
T = tuple(map(double,input().split()))
V = tuple(map(double,input().split()))
 
dp = [0]
 
for t,v_max,vf_max in zip(T,V,chain(V[1:],(0,))):

  ndp = [None]*(min(vf_max,v_max)+1)
  
  for vf in range(len(ndp)):
    vi = min(len(dp)-1,vf+t)
    while vi >= 0 and dp[vi] is None:
      vi -= 1

    if vi < max(0,vf-t):
      ndp[vf] = None
    else:
      vp = (vf+t+vi)/2
      ndp[vf] = dp[vi] + 2*vp*vp-vf*vf-vi*vi - 2*max(0,vp-v_max)**2
  dp = ndp
 
print(dp[0]/8)