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

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = input()
    R = []
    G = []
    B = []

    for i in range(n):
        if s[i] == "R":
            R.append(i + 1)
        elif s[i] == "G":
            G.append(i + 1)
        else:
            B.append(i + 1)
    res = 0
    for r in R:
        for g in G:
            for b in B:
                if r + g != b * 2 and g + b != r * 2 and b + r != g * 2:
                    res += 1
    print(res)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = input()
    R = 0
    G = 0
    B = 0

    for i in range(n):
        if s[i] == "R":
            R += 1
        elif s[i] == "G":
            G += 1
        else:
            B += 1
            
    res = R*G*B
    for i in range(n - 2):
        for j in range(i + 1, i + 1 + (n - 1 - i) // 2):
            k = j + (j - i)
            if s[i] != s[j] != s[k] != s[i]:
                res -= 1
    print(res)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
a = 0
while n > 0:
    a += n % 10
    n = n //10

if a % 9 == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = input()
a = 0
for i in range(len(n)):
    a += int(n[i])

if a % 9 == 0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

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

class UnionFind():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self.parent = [n for n in range(0, N)]
        # グループの深さ
        self.size = [1] * N

    def find(self, x):
        """ 木の根(どのグループか)を求める """
        if self.parent[x] == x: return x
        self.parent[x] = self.find(self.parent[x]) # 縮約
        return self.parent[x]

    def unite(self, x, y):
        """ xとyの属する集合を併合する """
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self.size[gx] < self.size[gy]:
            self.parent[gx] = gy
            self.size[gy] += self.size[gx]
        else:
            self.parent[gy] = gx
            self.size[gx] += self.size[gy]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find(x) == self.find(y)


def solve():
    N, M = list(map(int, input().split()))
    X, Y, Z = [], [], []
    uf = UnionFind(N)
    for i in range(M):
        x, y, z = list(map(int, input().split()))
        x, y = x-1, y-1
        uf.unite(x, y)
    
    # 答えは、(グループの数) 
    groups = []
    for i in range(N):
        if not uf.find(i) in groups:
            groups.append(uf.find(i))
    
    print(len(groups))


if __name__ == "__main__":
    solve()


### FIXED CODE ###

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

class UnionFindVerSize():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        # グループのサイズ（個数）
        self._size = [1] * N

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属する集合を併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size(self.find_root(x))

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)


def solve():
    """戦略
    □ □ □ □ □ □ □ □ □ □ □ □ □ □ □
    |_| |_| |_|     |_| | |_|_|_|
                    |___|
     1   2   3  4 5   6      7   

    上みたいなものを考えたらわかるが、答えはグループの数(=7)。

    Union-Findを使えばよい。

    """
    N, M = list(map(int, input().split()))
    X, Y, Z = [], [], []
    uf = UnionFindVerSize(N)
    for i in range(M):
        x, y, z = list(map(int, input().split()))
        x, y = x-1, y-1
        uf.unite(x, y)
    
    # 答えは、(グループの数) 
    ans = 0
    for i in range(N):
        if uf.find_root(i) == i:
            ans += 1
    
    print(ans)


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

H, W = map(int, input().split())
A = [None]*H
for i in range(H):
    A[i] = list(map(int, input().split()))
B = [None]*H
for i in range(H):
    B[i] = list(map(int, input().split()))

# C: A-Bの絶対値を持つ
C = [[None]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])
# print(C)
INF = 10**12
K = 2*80*(H+W-1)
dp = [[[0]*W for _ in range(H)] for _ in range(K+1)]# 答えから80*(H+W-1)を引く
dp[80*(H+W-1)+C[0][0]][0][0] = 1
dp[80*(H+W-1)-C[0][0]][0][0] = 1
# print(dp)

for i in range(H):
    for j in range(W):
        for k in range(K+1):
            if i > 0 and dp[k][i-1][j] > 0:
                dp[k+C[i][j]][i][j] += dp[k][i-1][j]
                dp[k-C[i][j]][i][j] += dp[k][i-1][j]
            if j > 0 and dp[k][i][j-1] > 0:
                dp[k+C[i][j]][i][j] += dp[k][i][j-1]
                dp[k-C[i][j]][i][j] += dp[k][i][j-1]
ans = INF
for k in range(K+1):
    res = dp[k][H-1][W-1]
    if res > 0:
        ans = min(ans, abs(k-80*(H+W-1)))
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
A = [None]*H
for i in range(H):
    A[i] = list(map(int, input().split()))
B = [None]*H
for i in range(H):
    B[i] = list(map(int, input().split()))

# C: A-Bの絶対値を持つ
C = [[None]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])

K = 80*(H+W-1)//2 + 1# 80*(H+W-1)の半分を超えるのは無駄
dp = [[[0]*(K+1) for _ in range(W)] for _ in range(H)]# 答えから80*(H+W-1)を引く
dp[0][0][C[0][0]] = 1

for i in range(H):
    for j in range(W):
        for k in range(K+1):
            if i and dp[i-1][j][k]:
                if k+C[i][j] < K:
                    dp[i][j][k+C[i][j]] = 1
                dp[i][j][abs(k-C[i][j])] = 1
            if j and dp[i][j-1][k]:
                if k+C[i][j] < K:
                    dp[i][j][k+C[i][j]] = 1
                dp[i][j][abs(k-C[i][j])] = 1

for k in range(K+1):
    res = dp[H-1][W-1][k]
    if res:
        print(k)
        break
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
a=1
for i in A:
    a*=i
if a>10**18:
    print(-1)
else:
    print(a)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
a=1
if 0 in A:
    print(0)
    exit()
for i in A:
    a*=i
    if a>10**18:
        print(-1)
        exit()
print(a)
### BUGGY CODE ###

from operator import mul
from functools import reduce

import copy

def combinations(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

N = int(input())

AList = list(map(int, input().split()))

SortList = copy.copy(AList)
SortList.sort()

NumberList = []
CountList = []
tmp = SortList[0]
count = 0
for i in SortList:
    if tmp == i:
        count += 1
    else:
        NumberList.append(tmp)
        CountList.append(count)
        tmp = i
        count = 1
NumberList.append(tmp)
CountList.append(count)

CountListCopy = copy.copy(CountList)

result = 0
for i in range(0, len(AList)):
    CountListCopy[NumberList.index(AList[i])] -= 1
    for q in CountListCopy:
        if q < 2:
            continue
        else:
            result += combinations(q, 2)
    print(result)
    result = 0
    
    CountListCopy = copy.copy(CountList)

### FIXED CODE ###

from operator import mul
from functools import reduce
import collections
import sys
input = sys.stdin.readline
 
def combinations(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
 
N = int(input())
 
AList = list(map(int, input().split()))

NumberList = set(AList)
CountList = collections.Counter(AList)

result = 0
for i in NumberList:
    if CountList[i] >= 2:
        result += combinations(CountList[i], 2)


for i in AList:
    print(result - (CountList[i] - 1))
### BUGGY CODE ###

s = input()
t = input()

dp = [[0]*len(t) for i in range(len(s))]


for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            if i > 0 and j > 0:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = 1
        else:
            if i > 0:
                dp[i][j] = max(dp[i-1][j], dp[i][j])
            if j > 0:
                dp[i][j] = max(dp[i][j-1], dp[i][j])


ret = ['']*dp[-1][-1]
id = dp[-1][-1]
i = len(s) - 1
j = len(t) - 1
while(i >= 0 and j >= 0):
    #print(s[i], t[j], i, j)
    if s[i] == t[j]:
        id -= 1
        ret[id] = s[i]
        i -= 1
        j -= 1
        # print(ret)
    else:
        if i > 0 and dp[i-1][j] >= dp[i][j-1]:
            i -= 1
        else:
            j -= 1

print(''.join(ret))
#print(*dp, sep='\n')


### FIXED CODE ###

s = input()
t = input()

dp = [[0]*len(t) for i in range(len(s))]


for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            if i > 0 and j > 0:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = 1
        else:
            if i > 0:
                dp[i][j] = max(dp[i-1][j], dp[i][j])
            if j > 0:
                dp[i][j] = max(dp[i][j-1], dp[i][j])


ret = ['']*dp[-1][-1]
id = dp[-1][-1]
i = len(s) - 1
j = len(t) - 1
while(i >= 0 and j >= 0):
    #print(s[i], t[j], i, j)
    if s[i] == t[j]:
        id -= 1
        ret[id] = s[i]
        i -= 1
        j -= 1
        # print(ret)
    else:
        if i > 0 and dp[i-1][j] >= dp[i][j-1]:
            i -= 1
        else:
            j -= 1

print(''.join(ret))
#print(*dp, sep='\n')
### BUGGY CODE ###

s = input()
s = s[::-1]
n = len(s)

num = [0]*2019
num[0] = 1
number = 0
d = 1

for i in s:
    number += int(i)*d
    num[number%2019] += 1
    d *= 10

ans = 0

for i in num:
    ans += i*(i-1)//2

print(ans)

### FIXED CODE ###

s=input()
s=s[::-1]
n=len(s)

count=[0]*2019
count[0]=1
num,d=0,1

for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1

ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
s = 0
while True:
    for i in range(n):
        if (A[i] % 2 == 1) or (A[i] == 0):
            break
    for j in range(n):
        A[j] = A[j] / 2
    s+=1
print(s)


### FIXED CODE ###

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

def count(A, n):
    for i in range(n):
        if (A[i] % 2 == 1) or (A[i] == 0):
            return False
        A[i] = A[i] // 2
    return True

while True:
    if count(A, n):
        s += 1
    else:
        break
    
print(s)
### BUGGY CODE ###

import collections
N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
if len(c) <= K:
    print(0)
else:
    print(sum([c.most_common()[-i][1] for i in range(1,len(c)-K+1)]))

### FIXED CODE ###

import collections
N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
c_most = c.most_common()
if len(c) <= K:
    print(0)
else:
    print(sum([c_most[-i][1] for i in range(1,len(c)-K+1)]))
### BUGGY CODE ###

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

ans = 0
for x in range(K+1):
    xyz = 0
    if S < x:
        break
    for y in range(K+1):
        if S < x+y:
            break
        for z in range(K+1):
            if x+y+z == S:
                ans += 1
            elif S < x+y+z:
                break

print(ans)


### FIXED CODE ###

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

ans = 0
for x in range(K+1):
    n = 0
    if S < x:
        break
    for y in range(K+1):
        n = S - (x + y)
        if 0 <= n <= K:
            ans += 1

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

H,W = map(int,input().split())
data = [list(input()) for i in range(H)]

A = [[0]*(W) for i in range(H)]
B = [[0]*(W) for i in range(H)]

for i in range(H):
    a = 0
    f = 0
    t = 0
    for j in range(W):
        if data[i][j] == '.' and j < W-1:
            a += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                A[i][k] = a
            t = j+1
            f = j+1
            a = 0
        else:
            for k in range(f,t+1):
                A[i][k] = a+1
for j in range(W):
    b = 0
    f = 0
    t = 0
    for i in range(H):
        if data[i][j] == '.' and i < H-1:
            b += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                B[k][j] = b
            t = i+1
            f = i+1
            b = 0
        else:
            for k in range(f,t+1):
                B[k][j] = b+1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,A[i][j]+B[i][j])
print(ans-1)

### FIXED CODE ###

H,W = map(int,input().split())
data = [list(input()) for i in range(H)]

A = [[0]*(W) for i in range(H)]
B = [[0]*(W) for i in range(H)]

for i in range(H):
    a = 0
    f = 0
    t = 0
    for j in range(W):
        if data[i][j] == '.' and j < W-1:
            a += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                A[i][k] = a
            t = j+1
            f = j+1
            a = 0
        else:
            for k in range(f,t+1):
                A[i][k] = a+1
for j in range(W):
    b = 0
    f = 0
    t = 0
    for i in range(H):
        if data[i][j] == '.' and i < H-1:
            b += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                B[k][j] = b
            t = i+1
            f = i+1
            b = 0
        else:
            for k in range(f,t+1):
                B[k][j] = b+1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,A[i][j]+B[i][j])
print(ans-1)
### BUGGY CODE ###

import math
K=int(input())
ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans+=math.gcd(math.gcd(a,b),c)
print(ans)

### FIXED CODE ###

from math import gcd
K=int(input())
ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans+=gcd(gcd(a,b),c)
print(ans)
### BUGGY CODE ###

import fractions

n = int(input())
A = list(map(int, input().split()))
M = []
for i in range(n):
    target_index = i
    if target_index == 0:
        target = A[1]
    else:
        target = A[0]
    for index, number in enumerate(A):
        if index == target_index:
            continue
        target = fractions.gcd(target, number)
    M.append(target)
print(max(M))

### FIXED CODE ###

from fractions import gcd

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

L = [0]
for i in range(n):
    L.append(gcd(L[i], A[i]))

R = [0]
for i in range(n-1, -1, -1):
    R.append(gcd(R[(n-1)-i],A[i]))
R.reverse()

M = []

for i in range(n):
    M.append(gcd(L[i],R[i+1]))
    
print(max(M))
### BUGGY CODE ###

N, M = list(map(int, input().split()))
C = list(map(int, input().split()))
C = sorted(C)
AB = [list(map(int, input().split())) for i in range(M)]
AB = sorted(AB, key=lambda x: x[1], reverse=True)
AB = [ab[1] for ab in AB for i in range(ab[0])]

index = min([N, len(AB)])
result = 0
for i in range(index):
  if AB[i] < C[i]:
    index = i
    break
  result += AB[i]

if index < N:
  result += sum(C[index:])
print(result)

### FIXED CODE ###

def main():
  N, M = list(map(int, input().split()))
  C = list(map(int, input().split()))
  C = sorted(C)
  AB = [list(map(int, input().split())) for i in range(M)]
  AB = sorted(AB, key=lambda x: x[1], reverse=True)
  
  result = 0
  i, j = 0, 0
  while i < N:
    A, B = AB[j] if j < M else (0, 0)
    j += 1
    if i+A < N and B >= C[i+A]:
      i += A
      result += A * B
    else:
      break
    
  while i < N:
    if C[i] > B:
      result += sum(C[i:])
      break
    else:
      result += B
      A -= 1      
      if j < M and A == 0:
        A, B = AB[j] if j < M else (0, 0)
        j += 1
    
    i += 1
  
  print(result)

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

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

p = [0 for _ in range(x * y)]
t = 0
for ai in a:
    for bi in b:
        p[t] = ai + bi
        t += 1
p.sort(reverse=True)
q = [0 for _ in range(k * z)]
t = 0
for pi in p[:k]:
    for ci in c:
        q[t] = pi + ci
        t += 1
q.sort(reverse=True)
for qi in q[:k]:
    print(qi)


### FIXED CODE ###

x, y, z, kk = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

p = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i + 1) * (j + 1) * (k + 1) <= kk:
                p.append(a[i] + b[j] + c[k])
            else:
                break
p.sort(reverse=True)
for i in range(kk):
    print(p[i])
### BUGGY CODE ###

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

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
for j in cnt:
    print(j)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
b = [0]
target = 0
count = 0
while(True):
    target = a[target] - 1
    count += 1
    if target in b:
        print("-1")
        break
    else:
        b.append(target)
    if target == 1:
        print(count)
        break

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
b = [0]
target = 0
count = 0
while(True):
    target = a[target] - 1
    count += 1
    if count > n:
        print("-1")
        break
    if target == 1:
        print(count)
        break
### BUGGY CODE ###

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
G = [list(map(int, input().split())) for _ in range(N)]

cost = [[0]*C for _ in range(3)]
for i in range(C):
    for a in range(N):
        for b in range(N):
            cost[(a+b)%3][i] += D[G[a][b]-1][i]

ans = 10**10
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or k == i:
                pass
            else:
                ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k])

print(ans)


### FIXED CODE ###

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
G = [list(map(int, input().split())) for _ in range(N)]

cost = [[0]*C for _ in range(3)]
for i in range(C):
    for a in range(N):
        for b in range(N):
            cost[(a+b)%3][i] += D[G[a][b]-1][i]

ans = 10**10
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or k == i:
                pass
            else:
                ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k])

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

N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N):
	for j in range(K):
		if i + j + 1 < N:
			dp[i + j + 1] = min(dp[i + j + 1], dp[i] + abs(h[i + j + 1] - h[i]))
		else:
			break
print(dp[N - 1])


### FIXED CODE ###

N, K = map(int, input().split())
*h, = map(int, input().split())
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
	for j in range(1, min(K + 1, N - i)):
		dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N - 1])
### BUGGY CODE ###

N,K = map(int,input().split())
H = [int(input()) for _ in range(N)]

H.sort()

#res1 = max(H[:K])-min(H[:K])
#res2 = max(H[N-K:])-min(H[N-K:])

res = 1000000000
for i in range(N-K+1):
    tmp = max(H[i:i+K])-min(H[i:i+K])
    if tmp < res:
        res = tmp
print(res)

### FIXED CODE ###

N,K = map(int,input().split())
H = [int(input()) for _ in range(N)]

H.sort()

res = 1000000000
for i in range(N-K+1):
    #print(H)
    #print(H[i+K-1],H[i])
    tmp = H[i+K-1]-H[i]
    if tmp < res:
        res = tmp
print(res)
### BUGGY CODE ###

# D - Banned K(高速版)
N = int(input())
A = list(map(int, input().split()))

import copy as c
C = []

for i in range(N):
    C.append(A.count(i+1))

C_tmp = [s for s in C if s > 1]

sum0 = 0
for j in C_tmp:
    sum0 = sum0 + j*(j-1)/2

for k in range(N):
    if C[A[k]-1] >= 2:
        d = C[A[k]-1] - 1
    else:
        d =0
    sum = int(sum0 - d)
    print(sum)

### FIXED CODE ###

import collections


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    counter = collections.Counter(A)
    ans = 0

    for i in counter.values():
        ans += i * (i - 1) // 2

    for a in A:
        count = counter[a]
        print(ans - (count * (count - 1) // 2) +
              ((count - 1) * (count - 2) // 2))


resolve()
### BUGGY CODE ###

N = int(input())
S = input().strip()
cmax = 0
for k in range(1,N//2+1):
    C = {}
    x = S[:k]
    C[x]=[0]
    for i in range(1,N-k+1):
        x = x[1:]+S[i+k-1]
        if x not in C:
            C[x]=[]
        C[x].append(i)
    for a in C:
        if len(C[a])>1 and C[a][-1]-C[a][0]>=k:
            cmax = max(cmax,k)
            break
print(cmax)

### FIXED CODE ###

N = int(input())
S = input().strip()
cmax = 0
for k in range(1,N):
    X = S[:N-k]
    Y = S[k:]
    cur = 0
    cnt = 0
    for i in range(N-k):
        if X[i]!=Y[i]:
            cmax = max(cmax,min(cnt,k))
            cur = i
            cnt = 0
        else:
            cnt += 1
    cmax = max(cmax,min(cnt,k))
print(cmax)
### BUGGY CODE ###

k, s = map(int, input().split())
ans = []
for i in range(k+1):
    for j in range(min(k+1,s-i+1)):
        for h in range(min(k+1,s-i-j+1)):
            if i + j + h == s:
                ans.append([i, j, h])
                break
print(len(ans))

### FIXED CODE ###

k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
    for j in range(min(k+1,s-i+1)):
        h = s- i- j
        if 0<= h <= k:
            cnt += 1
print(cnt)
### BUGGY CODE ###

s = input().rstrip().split(' ')
L = int(s[0])
R = int(s[1])
cnt = (L*(L+1)) % 2019

for i in range(L, R):
    for r in range(i+1, R+1):
        ans = (i*r) % 2019 
        if ans < cnt:
            cnt = ans
    
print(cnt)


### FIXED CODE ###

s = input().rstrip().split(' ')
L = int(s[0])
R = int(s[1])
cnt = 2020
 
for i in range(L, R):
    for r in range(i+1, R+1):
        ans = (i*r) % 2019 
        if ans < cnt:
            cnt = ans
            if cnt == 0:
        	    break
    if cnt == 0:
      break
 
print(cnt)
### BUGGY CODE ###

from functools import lru_cache
import sys

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

sys.setrecursionlimit(2000**2 +1)
@lru_cache(maxsize = 2000)
def depth(a,b):
    if a+b <= n:
        if (y-10000*a-5000*b)/1000 == n-a-b:
            print(a,b,n-a-b)
            exit()
        else:
            depth(a+1,b)
            depth(a,b+1)
   

if depth(0,0) ==None:
    print(-1,-1,-1)
else:
    print(depth(0,0))

### FIXED CODE ###

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

a,b,c = (-1,-1,-1)
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            a,b,c = (i,j,n-i-j)
            break

print(a,b,c)