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

from bisect import *
from collections import defaultdict
def solve():
  T = int(input())
  ans = [0]*T
  for t in range(T):
    N = int(input())
    left = defaultdict(lambda: [])
    right = defaultdict(lambda: [])
    for i in range(N):
      k,l,r = map(int, input().split())
      if k==N:
        ans[t] += l
      else:
        if l>r:
          insort_right(left[k],l-r)
        elif l<r:
          insort_right(right[k+1],r-l)
        ans[t] += min(l,r)
    for i in range(N,0,-1):
      if len(left[i]):
        ans[t] += left[i][-1]
        for l in left[i][:-1]:
          insort_right(left[i-1],l)
    for i in range(2,N+1):
      if len(right[i]):
        ans[t] += right[i][-1]
        for l in right[i][:-1]:
          insort_right(right[i+1],l)
  return ans
print(*solve(),sep='\n')

### FIXED CODE ###

from bisect import *
from collections import defaultdict
def solve():
  T = int(input())
  ans = [0]*T
  for t in range(T):
    N = int(input())
    left = defaultdict(lambda: [])
    right = defaultdict(lambda: [])
    for i in range(N):
      k,l,r = map(int, input().split())
      if k==N:
        ans[t] += l
      else:
        if l>r:
          insort_right(left[k],l-r)
        elif l<r:
          insort_right(right[k+1],r-l)
        ans[t] += min(l,r)
    lis = []
    for i in range(N,0,-1):
      for l in left[i]:
        insort_right(lis,l)
      if len(lis):
        ans[t] += lis.pop(-1)
    lis = []
    for i in range(2,N+1):
      for r in right[i]:
        insort_right(lis,r)
      if len(lis):
        ans[t] += lis.pop(-1)
  return ans
print(*solve(),sep='\n')
### BUGGY CODE ###

N, K = map( int, input().split() )
h = list( map( int, input().split() ))
 
l = [0] + [ 10**18 ] * ( N - 1 )
for i in range( N ):
  for j in range( 1, K + 1 ):
    if i - j >= 0:
      l[ i ] = min( l[ i ], l[ i - j ] + abs( h[ i ] - h[ i - j ]))
 
print( l[ - 1 ] )

### FIXED CODE ###

N, K, *h = map( int, open( 0 ).read().split() )

d = [ 0 ] + [ 10**18 ] * ( N - 1 )
for i in range( N ):
  for k in range( 1, K + 1 ):
    if i - k >= 0: 
      d[ i ] = min( abs( h[ i ] - h[ i - k ] ) + d[ i - k ], d[ i ] )
print( d[-1] )
### BUGGY CODE ###

N,P=map(int,input().split())
ans=1
for i in range(1,P+1):
    a=pow(i,N)
    if P//a==0:
        break
    else:
        if P%a==0:
            ans=i
print(ans)

### FIXED CODE ###

N,P=map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
p=factorization(P)
#print(p)
k=[]
ans=1
for i in range(len(p)):
    d=p[i][1]//N
    k.append(d)
for i in range(len(p)):
    ans*=pow(p[i][0],k[i])
print(ans)
### BUGGY CODE ###

#
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def next_kenp(node, edges):
    nodes = []
    for n1 in edges[node]:
        for n2 in edges[n1]:
            for n3 in edges[n2]:
                nodes.append(n3)
    return nodes


def main():
    n, m = map(int, input().split())

    edges = defaultdict(list)

    for _ in range(m):
        u, v = map(int, input().split())
        edges[u].append(v)

    s, t = map(int, input().split())

    dones = set()
    que = [(s, 0)]
    while que:
        node, step = que.pop(0)
        next_nodes = next_kenp(node, edges)
        for n in next_nodes:
            if n == t:
                print(step + 1)
                exit()

            if n not in dones:
                que.append((n, step + 1))
                dones.add(n)
    print(-1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, m = map(int, input().split())

    edges = defaultdict(list)

    for _ in range(m):
        u, v = map(int, input().split())
        edges[(u, 0)].append((v, 1))
        edges[(u, 1)].append((v, 2))
        edges[(u, 2)].append((v, 0))

    s, t = map(int, input().split())

    # print(new_edges)

    dones = set()
    que = deque()
    que.append(((s, 0), 0))
    while que:
        node, step = que.popleft()

        next_nodes = edges[node]
        # print(next_nodes)
        for n, l in next_nodes:
            if n == t and l == 0:
                print((step + 1) // 3)
                exit()

            if (n, l) not in dones:
                que.append(((n, l), step + 1))
                dones.add((n, l))
    print(-1)


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

from itertools import permutations
import numpy as np
N, C = map(int, input().split())
D = np.ndarray((C, C), dtype=int)
c = np.ndarray((N, N), dtype=int)
for i in range(C):
    D[i] = list(map(int,input().split()))
for i in range(N):
    c[i] = list(map(int,input().split()))
c -= 1
acc = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        for k in range(C):
            acc[(i+j) % 3][k] += D[c[i][j]][k]
ans = float("inf")
for i,j,k in permutations(range(C), r=3):
    ans = min(ans, acc[0][i]+acc[1][j]+acc[2][k])
print(ans)

### FIXED CODE ###

from itertools import permutations
import numpy as np
N, C = map(int, input().split())
D = np.ndarray((C, C), dtype=int)
c = np.ndarray((N, N), dtype=int)
for i in range(C):
    D[i] = list(map(int,input().split()))
for i in range(N):
    c[i] = list(map(int,input().split()))
c -= 1
acc = np.zeros((3, C), dtype=int)
for i in range(N):
    for j in range(N):
        acc[(i+j) % 3] += D[c[i][j]]
ans = float("inf")
for i,j,k in permutations(range(C), r=3):
    ans = min(ans, acc[0][i]+acc[1][j]+acc[2][k])
print(ans)
### BUGGY CODE ###

import math
import numpy as np


def main():
    s = input().split(" ")
    N = int(s[0])
    K = int(s[1])
    A = [int(a) for a in input().split(" ")]
    F = [int(a) for a in input().split(" ")]
    A.sort()
    F.sort()
    F.reverse()
    AF = [A[i] * F[i] for i in range(N)]
    idx = np.argsort(AF)[::-1]

    A = [A[idx[i]] for i in range(N)]
    F = [F[idx[i]] for i in range(N)]
    AF = [AF[idx[i]] for i in range(N)]
    m = np.max(AF)

    if(func(0, AF, F, N, K)):
        print(0)
        return
    a = 0
    b = m
    for aaa in range(m):
        if(abs(b - a) <= 1):
            print(b)
            return
        mid = int((b - a) / 2) + a
        if(func(mid, AF, F, N, K)):
            b = mid
        else:
            a = mid
    print("???????")


def func(saidai, AF, F, N, K):
    count = 0
    for n in range(N):
        if(AF[n] <= saidai):
            continue
        count += math.ceil((AF[n] - saidai) / F[n])
        if(count > K):
            return False
    return True


if(__name__ == "__main__"):
    main()


### FIXED CODE ###

import math
import numpy as np


def main():
    s = input().split(" ")
    N = int(s[0])
    K = int(s[1])
    A = np.array([int(a) for a in input().split(" ")])
    F = np.array([int(a) for a in input().split(" ")])
    A = np.sort(A)
    F = np.sort(F)[::-1]
    AF = A * F
    m = np.max(AF)

    if(func(0, AF, F, N, K)):
        print(0)
        return
    a = 0
    b = m
    for aaa in range(m):
        if((b - a) <= 1):
            print(b)
            return
        mid = int((b - a) / 2.) + a
        if(func(mid, AF, F, N, K)):
            b = mid
        else:
            a = mid
    print("???????")


def func(saidai, AF, F, N, K):
    count = np.sum(np.ceil((AF[(AF - saidai) > 0] - saidai) / F[(AF - saidai) > 0]))
    return count <= K


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

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

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
M = 10**18
a.sort(reverse=True)
ans = 1
if a[-1]==0:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans >M:
            print(-1)
            sys.exit()
    print(ans)
### BUGGY CODE ###

class KMP:
    pattern = None
    length = -1
    failed = None
    def __init__(self, pattern):
        self.pattern = pattern
        self.length = len(pattern)
        self.failed = [-1 for i in xrange(self.length)]
        for i in xrange(1, self.length):
            prev = self.failed[i-1]
            while prev!=-1 and pattern[prev+1]!=pattern[i]:
                prev = self.failed[i-1]
            if pattern[prev+1]==pattern[i]:
                prev += 1
            self.failed[i] = prev

def minimumLen(s, t):
    kmp = KMP(t)
    offset = -1
    for c in s:
        while offset!=-1 and kmp.pattern[offset+1]!=c:
            offset = kmp.failed[offset]
        if kmp.pattern[offset+1]==c:
            offset += 1
    return len(s)+len(t)-(offset+1)

def main():
    n = int(raw_input().strip())
    s = raw_input().strip()
    t = raw_input().strip()
    print minimumLen(s, t)

if __name__ == '__main__':
    main()


### FIXED CODE ###

class KMP:
    pattern = None
    length = -1
    failed = None
    def __init__(self, pattern):
        self.pattern = pattern
        self.length = len(pattern)
        self.failed = [-1 for i in xrange(self.length)]
        for i in xrange(1, self.length):
            prev = self.failed[i-1]
            while prev!=-1 and pattern[prev+1]!=pattern[i]:
                prev = self.failed[prev]
            if pattern[prev+1]==pattern[i]:
                prev += 1
            self.failed[i] = prev

def minimumLen(s, t):
    kmp = KMP(t)
    offset = -1
    for c in s:
        while offset!=-1 and kmp.pattern[offset+1]!=c:
            offset = kmp.failed[offset]
        if kmp.pattern[offset+1]==c:
            offset += 1
    return len(s)+len(t)-(offset+1)

def main():
    n = int(raw_input().strip())
    s = raw_input().strip()
    t = raw_input().strip()
    print minimumLen(s, t)

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

N,K=map(int,input().split())
lmnk=(2*N//K)
ans=0
for h in range(2//K,lmnk+1):
    a=h*K//2
    if 1<=a<=N:
        for i in range((1+a)//K,(N+a)//K+1):
            b=i*K-a
            if 1<=b<=N:
                for j in range((1+b)//K,(N+b)//K+1):
                    c=j*K-b
                    if 1<=c<=N and (c+a)%K==0:
                            ans+=1
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
if K%2==1:
    print((N//K)**3)
else:
    print((N//K)**3+(2*N//K-N//K)**3)
### BUGGY CODE ###

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

F = [input() for _ in range(H)]

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if F[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            L[i][j] = L[i][j - 1] + 1 if j - 1 >= 0 else 1
            U[i][j] = U[i - 1][j] + 1 if i - 1 >= 0 else 1

        if F[i][-1 - j] == "#":
            R[i][-1 - j] = 0
        else:
            R[i][-1 - j] = R[i][-j] + 1 if j > 0 else 1

        if F[- 1 - i][j] == "#":
            D[- 1 - i][j] = 0
        else:
            D[- 1 - i][j] = D[-i][j] + 1 if i > 0 else 1

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)


### FIXED CODE ###

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

F = [input() for _ in range(H)]

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if F[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            L[i][j] = L[i][j - 1] + 1 if j - 1 >= 0 else 1
            U[i][j] = U[i - 1][j] + 1 if i - 1 >= 0 else 1

        if F[i][-1 - j] == "#":
            R[i][-1 - j] = 0
        else:
            R[i][-1 - j] = R[i][-j] + 1 if j > 0 else 1

        if F[- 1 - i][j] == "#":
            D[- 1 - i][j] = 0
        else:
            D[- 1 - i][j] = D[-i][j] + 1 if i > 0 else 1

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

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

N, Q = map(int,input().split())
S = input()
cnt = 0
for i in range(Q):
  l,r = map(int,input().split())
  chk = S[l-1:r]
  print(chk.count("AC"))


### 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, a = map(int, input().split())
x = [int(i) for i in input().split()]

all_perms = []

def per(index, perm):
    if index == n:
        all_perms.append(perm)
        return
    perm1 = [i for i in perm]
    per(index+1, perm1)

    perm2 = [i for i in perm]
    perm2.append(x[index])
    per(index+1, perm2)


per(0, [])
cnt = 0
for perm in all_perms:
    if len(perm) == 0:
        continue
    average = sum(perm) / len(perm)
    if average == a:
        cnt += 1

print(cnt)


### FIXED CODE ###

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

dp = {0: 1}

for i in x:
    tmp = list(dp.items())
    for key, value in tmp:
        dp[key+i] = dp.get(key+i, 0) + value
print(dp[0] - 1)
### BUGGY CODE ###

n = int(input())
L = list(map(int, input().split()))
x = [0] * 1010
for l in L:
  x[l] += 1

ans = 0;
for a in range(1, 1001):
  for b in range(a, 1001):
    for c in range(b, 1001):
      if a < b + c and b < c + a and c < a + b:
        if a == b == c:
          ans += x[a] * (x[b]-1) * (x[c]-2) // 6
        elif a == b:
          ans += x[a] * (x[b]-1) // 2
        elif b == c:
          ans += x[a] * x[b] * (x[c]-1) // 2
        else:
          ans += x[a] * x[b] * x[c]

print(ans)

### FIXED CODE ###

n = int(input())
L = list(map(int, input().split()))
x = [0] * 1010
for l in L:
  x[l] += 1

ans = 0;
for a in range(1, 1001):
  if x[a] == 0:
    continue
  for b in range(a, 1001):
    if x[b] == 0:
      continue
    for c in range(b, 1001):
      if x[c] == 0:
        continue
      if c >= a + b:
        break
      if a == b == c:
        ans += x[a] * (x[b]-1) * (x[c]-2) // 6
      elif a == b:
        ans += x[a] * (x[b]-1) * x[c] // 2
      elif b == c:
        ans += x[a] * x[b] * (x[c]-1) // 2
      else:
        ans += x[a] * x[b] * x[c]

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

import itertools

S = input()
N = len(S)
if all(S[0] == c for c in S):
    print(1)
    exit()
if N == 2:
    print(1 if S[0]==S[1] else 2)
    exit()

if N == 3:
    def another(a,b):
        s = set('abc')
        s -= set([a,b])
        return list(s)[0]
    ptn = set()
    stack = [S]
    while stack:
        a = stack.pop()
        ptn.add(a)
        if a[0] != a[1]:
            b = another(a[0],a[1])*2 + a[2]
            if not b in ptn:
                stack.append(b)
        if a[1] != a[2]:
            c = a[0] + another(a[1],a[2])*2
            if not c in ptn:
                stack.append(c)
    print(len(ptn))
    exit()

#N >= 4
MOD = 998244353
dp = [[[[0 for u in range(2)] for l in range(3)] for s in range(3)] for n in range(N+1)]
#dp[n][sum%3][last][exist'xx'?]
for ptn in itertools.product(range(3),repeat=4):
    seq = (ptn[0]==ptn[1] or ptn[1]==ptn[2] or ptn[2]==ptn[3])
    dp[4][sum(ptn)%3][ptn[3]][seq] += 1

for n in range(4,N):
    for s in range(3):
        for l in range(3):
            for u in range(2):
                for l2 in range(3):
                    s2 = (s+l2)%3
                    u2 = u or l==l2
                    dp[n+1][s2][l2][u2] += dp[n][s][l][u]
                    dp[n+1][s2][l2][u2] %= MOD

sm = 0
for c in S:
    sm += ord(c) - ord('a')
seq = False
for c1,c2 in zip(S,S[1:]):
    if c1 == c2:
        seq = True
        break
ans = sum([dp[N][sm%3][i][1] for i in range(3)])
if not seq: ans += 1
print(ans % MOD)

### FIXED CODE ###

import itertools

S = input()
N = len(S)
if all(S[0] == c for c in S):
    print(1)
    exit()
if N == 2:
    print(1 if S[0]==S[1] else 2)
    exit()

if N == 3:
    def another(a,b):
        s = set('abc')
        s -= set([a,b])
        return list(s)[0]
    ptn = set()
    stack = [S]
    while stack:
        a = stack.pop()
        ptn.add(a)
        if a[0] != a[1]:
            b = another(a[0],a[1])*2 + a[2]
            if not b in ptn:
                stack.append(b)
        if a[1] != a[2]:
            c = a[0] + another(a[1],a[2])*2
            if not c in ptn:
                stack.append(c)
    print(len(ptn))
    exit()

#N >= 4
MOD = 998244353
dp = [[[0 for u in range(2)] for l in range(3)] for s in range(3)]
#dp[sum%3][last][exist'xx'?]
for ptn in itertools.product(range(3),repeat=4):
    seq = (ptn[0]==ptn[1] or ptn[1]==ptn[2] or ptn[2]==ptn[3])
    dp[sum(ptn)%3][ptn[3]][seq] += 1

for n in range(4,N):
    dp2 = [[[0 for u in range(2)] for l in range(3)] for s in range(3)]
    for s in range(3):
        for l in range(3):
            for u in range(2):
                for l2 in range(3):
                    s2 = (s+l2)%3
                    u2 = u or l==l2
                    dp2[s2][l2][u2] += dp[s][l][u]
                    dp2[s2][l2][u2] %= MOD
    dp = dp2

sm = 0
for c in S:
    sm += ord(c) - ord('a')
seq = False
for c1,c2 in zip(S,S[1:]):
    if c1 == c2:
        seq = True
        break
ans = sum([dp[sm%3][i][1] for i in range(3)])
if not seq: ans += 1
print(ans % MOD)
### BUGGY CODE ###

#D - Moving_piece
N,K = map(int,input().split())
P =[]
C =[]
P = list(map(int,input().split()))
C = list(map(int,input().split()))
ichi  = 0
score_max = -1000000010
i = 0
for i in range(N):
    ichi = i
    score = 0
    step  = K
    while step > 0:
        if i != P[ichi] or score >= 0:
            ichi = P[ichi] -1
            score += C[ichi]
            if score > score_max:
                score_max = score
            step -= 1
        else:
            step = 0
# 出力
print(score_max)

### FIXED CODE ###

#D - Moving_piece
N,K = map(int,input().split())
P =[]
C =[]
P = list(map(int,input().split()))
C = list(map(int,input().split()))

score_output = -1000000000
i = 0
for i in range(N):
    ichi = i
    score = 0
    step  = 0
    loop  = 0
    score_max = -1000000000
    while True:
        step  += 1
        score += C[ichi]
        ichi   = (P[ichi] -1)
        if i ==  (P[ichi] -1):
            score += C[ichi]
            break
        
    path = 0
    cnt  = 0
    
    while True:
        cnt  += 1
        path += C[ichi]
        
        if cnt > K:
            break
        
        loop = int((K - cnt) / (step+ 1))
        if score > 0:
            score_max = path + loop * score
        else:
            score_max = path
        if score_max > score_output:
            score_output = score_max

        ichi   = P[ichi]-1
        if i == (P[ichi] -1):
            break
# 出力
print(score_output)
### BUGGY CODE ###

#!/usr/bin/env python3

def solve(s):
    s = str(s)
    c = 0
    for i in range(1000):
        v = [i//100, i//10%10, i%10]
        f = 0
        for j in range(len(s)):
            if int(s[j]) == v[f]:
                f += 1
            if f == 3:
                break
        if f == 3:
            c += 1
    return c

def main():
    N = int(input())
    S = input()
    print(solve(S))


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3

def solve(s):
    s = str(s)
    c = 0
    for i in range(1000):
        v = [i//100, i//10%10, i%10]
        f = 0
        for j in range(len(s)):
            if int(s[j]) == v[f]:
                f += 1
            if f == 3:
                break
        if f == 3:
            c += 1
    return c

def main():
    N = int(input())
    S = input()
    print(solve(S))


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

def main():
    N = int(input())
    s = input()

    dpt = [[0] * (N + 1) for i in range(N + 1)]
    result = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
            if dpt[i][j] > result:
                result = dpt[i][j]

    print(result)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
N, Q = map(int,input().split())
S = input()
nums = [0] * (N + 1)
for i in range(N):
  nums[i+1] = nums[i] + (1 if S[i:i+2]=='AC' else 0)
    
for j in range(Q):
  l, r = map(int,input().split())
  print(nums[r-1] - nums[l-1])
### BUGGY CODE ###

S = str(input())
A = S
flag = True
while(flag):
    T = ""
    flag = False
    for i in range(1, len(S)):
        if int(S[i-1]) ^ int(S[i]):
            flag = True
            T = S[:i-1]+S[i+1:]
            S = T
            break
print(len(A)-len(S))


### FIXED CODE ###

S = str(input())
print(len(S)-abs(S.count('0')-S.count('1')))
### BUGGY CODE ###

n = int(input())

s = {2}
#for i in range(3, n, 2):
z = 2
i = 3
while z < n:
    x = 1
    for j in s:
        if i % j == 0:
            x = 0
            break
    if x:
        z = i
        s.add(i)
    i += 2
print(z)

### FIXED CODE ###

n = int(input())

def isprime(x):
    for i in range(2, int(x**0.5), 1):
        if x % i == 0:
            return False
    return True

i = n
while True:
    if isprime(i):
        break
    else:
        i += 1
print(i)
### BUGGY CODE ###

import heapq
# 単一始点最短経路。2地点間ではなく、始点が一つで各点へのコストを計算する
# eは隣接リストでe[v] = [(u1,cost1), (u2,cost2)]みたいな形を想定
# 辺の重みは正である必要がある
# O(ElogV)
def dijkstra(e,n,s):
    inf = 10**18
    d = [inf]*n
    d[s] = 0

    q = [(d[s],s)] # priority queueのソートキーが第一要素
    heapq.heapify([q])
    while len(q)>0:
        _,v = heapq.heappop(q)
        for u,c in e[v]:
            if d[v]+c>=d[u]:
                continue
            d[u] = d[v] + c
            heapq.heappush(q, (d[u],u))
    return d

n,x,y = map(int, input().split())

g = [[] for _ in range(n)]
for i in range(n-1):
    g[i].append((i+1,1))
    g[i+1].append((i,1))
g[x-1].append((y-1,1))
g[y-1].append((x-1,1))
    

res = [0]*n
for i in range(n):
    d = dijkstra(g,n,i)
    for j in range(i+1,n):
        res[d[j]] += 1

for i in range(1,n):
    print(res[i])


### FIXED CODE ###

n, x, y = map(int, input().split())
ans = [0 for i in range(n)]
x -= 1
y -= 1
for i in range(n):
    for j in range(i+1, n):
        cand1 = j - i
        cand2 = abs(x - i) + 1 + abs(y-j)
        ans[min(cand1, cand2)] += 1

for item in ans[1:]:
    print(item)
### BUGGY CODE ###

N=int(input())
L=[int(input()) for i in range(N)]
index1=L.index(max(L))
index2=L.index(sorted(L)[-2])
for i in range(N-1):
	if i==index1:
		print(sorted(L)[-2])
	print(max(L))

### FIXED CODE ###

N=int(input())
L=[int(input()) for i in range(N)]
tl=sorted(L)
index1=L.index(tl[-1])
index2=L.index(tl[-2])
for i in range(N):
	if i==index1:
		print(L[index2])
	else:
		print(L[index1])
### BUGGY CODE ###

n = int(input())
S = input()
ans = 0
for i in range(1,len(S)+1):
    for j in range(i+1,len(S)+1):
        for k in range(j+1,len(S)+1):
            if j-i==k-j:
                continue
            if S[i-1]!=S[j-1] and S[i-1]!=S[k-1] and S[j-1]!=S[k-1]:
                ans +=1
print(ans)

### FIXED CODE ###

n = int(input())
S = input()
ans = S.count('R') * S.count('G') * S.count('B')
for i in range(n):
    for j in range(i+1,n):
        k = 2*j-i
        if k>=n:
            continue
        if S[i]==S[j] or S[j]==S[k] or S[i]==S[k]:
            continue
        else:
            ans -=1
print(ans)