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

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

r = []
g = []
b = []
for i in range(len(s)):
    if s[i] == "R":
        r.append(i)
    elif s[i] == "G":
        g.append(i)
    else:
        b.append(i)
        
cnt = 0
for r_idx in r:
    for g_idx in g:
        j, i = max(r_idx, g_idx), min(r_idx, g_idx)
        for b_idx in b:
            if b_idx > j:
                if b_idx - j != j - i:
                    cnt += 1
            elif i > b_idx:
                if i - b_idx != j - i:
                    cnt += 1
            else:
                if j - b_idx != b_idx - i:
                    cnt += 1
print(cnt)

### FIXED CODE ###

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

r, g, b = set(), set(), set()
for i in range(len(s)):
    if s[i] == "R":
        r.add(i)
    elif s[i] == "G":
        g.add(i)
    else:
        b.add(i)
        
ans = len(r) * len(g) * len(b)
for r_idx in r:
    for g_idx in g:
        j, i = max(r_idx, g_idx), min(r_idx, g_idx)
        diff_ji = abs(j-i)
        cnt = 0
        for v in [j + diff_ji, i - diff_ji, (j + i) / 2]:
            if v in b:
                cnt += 1            
        ans -= cnt
print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
s = 0
c = 1
while max(A) != 0:
    #print(max(A))
    s0 = 0
    s1 = 0
    for i,j in enumerate(A):
        if True:
            A[i],mod = divmod(j,2)
            #print(mod)
            if mod==1:
                s1 +=1
            else:
                s0 +=1
        #print(s0,s1)
    s = (s+(s0*s1*c))%(10**9+7)
    c *= 2
print(s)

### FIXED CODE ###

import numpy as np
from math import ceil,log2
N = int(input())
a = np.array(list(map(int,input().split())),dtype=np.int64)
ans = 0
count = 1
if max(a) == 0:
    x = 1
else:
    x = ceil(log2(max(a)))

for i in range(x):
    b = a%2
    s = np.count_nonzero(b==1)*np.count_nonzero(b==0)*count
    ans +=s
    count *= 2
    a = a//2
    ans %= 10**9+7
print(ans)
### BUGGY CODE ###

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

pos = 1
seen = [1]
while True:
	if A[pos] in seen:
		seen.append(A[pos])
		break
	seen.append(A[pos])
	pos = A[pos]

length = len(seen)

initial, loop = 0, 0
for i in range(length):
	if seen[i] == seen[-1]:
		initial = i
		loop = length - 1 - initial
		break

if k < length:
	print(seen[k])
	exit()

kk = (k - initial) % loop
print(seen[initial + kk])

### FIXED CODE ###

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

pos = [1]

for i in range(2 * n):
	nxt = A[pos[-1]]
	pos.append(nxt)

if k < n + 1:
	print(pos[k])
	exit()

loop_end = n
loop_start = n - 1

while pos[loop_start] != pos[loop_end]:
	loop_start -= 1

period = loop_end - loop_start
k = k % period

while k < n:
	k += period

print(pos[k])
### BUGGY CODE ###

inpvals = []
outvals = []

max_loop = int(input())
idx_loop = 0
while idx_loop < max_loop :
  inpvals.append(input())
  idx_loop = idx_loop+1

max_cnt = 0
for inpval in set(inpvals) :
  cnt = inpvals.count(inpval)

  if max_cnt <= cnt :
    if max_cnt != cnt :
      outvals = []
    max_cnt = cnt
    outvals.append(inpval)

outvals.sort()
    
for outval in outvals :
  print(outval)

### FIXED CODE ###

from collections import defaultdict
from collections import OrderedDict

N = int(input())

words = dict()
wordsFromValue = defaultdict(list)

for idx in range(N) :
  word = str(input())
  
  if word in words :
    words[word] += 1
  else :
    words[word] = 1
  
for key, value in sorted(words.items()) :
  wordsFromValue[value].append(key)
  

for val in wordsFromValue[max(wordsFromValue)] : 
  print(val)
### BUGGY CODE ###

N = int(input())
result = 1
for i in range(1,N+1):
  result *= i
print(result%(10**9+7))

### FIXED CODE ###

N = int(input())
result =1
for i in range(1,N+1):
  result *= i
  result %= (10**9+7)
print(result)
### BUGGY CODE ###

s = input()
k = int(input())

substring = {}

char_tuple = sorted(tuple(s))

for c in char_tuple:
    if len(substring) >= 5:
        break
    for i in range(len(s)):
        if s[i] == c:
            for j in range(i + 1, len(s) + 1):
                substring[s[i:j]] = True



#
# for i in range(len(s)):
#     for j in range(i+1, len(s)+1):
#         # print('i={}, j={} s[{}:{}]={}'.format(i,j,i,j,s[i:j]))
#         substring[s[i:j]] = True


words = [item[0] for item in substring.items()]
sorted_words = sorted(words)
# print(words)
# print(sorted_words)

# print(substring)

print(sorted_words[k-1])


### FIXED CODE ###

s = input()
k = int(input())

substring = {}

for i in range(len(s)):
    for j in range(i+1, i+1+k):
        # print('i={}, j={} s[{}:{}]={}'.format(i,j,i,j,s[i:j]))
        substring[s[i:j]] = True


words = [item[0] for item in substring.items()]
sorted_words = sorted(words)

print(sorted_words[k-1])
### BUGGY CODE ###

a,b=(int(x) for x in input().split())
for i in range (b):
  a=a-1
  if a==0:
    break
print(a)

### FIXED CODE ###

a,b=(int(x) for x in input().split())
c=0
if a>b :
  c=a-b
else:
  c=0
print(c)
### BUGGY CODE ###

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

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

arr = [10 ** 9] * (h+1)
# arr[k] := hpがkの敵を倒すのに必要な最小魔力
arr[0] = 0
arr[1] = min([ele[1] for ele in hp_and_magic])

for i in range(2, h+1):
    # arr[i] = 10 ** 9
    for ele in hp_and_magic:
        if i-ele[0] >= 0:
            arr[i] = min(arr[i], arr[i-ele[0]] + ele[1])
        else:
            arr[i] = min(arr[i], ele[1])

print(arr[h])

### FIXED CODE ###

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

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

arr = [10 ** 9] * (h+1)
# arr[k] := hpがkの敵を倒すのに必要な最小魔力
arr[0] = 0
arr[1] = min([ele[1] for ele in hp_and_magic])

for i in range(2, h+1):
    # arr[i] = 10 ** 9
    for ele in hp_and_magic:
        if i-ele[0] >= 0:
            arr[i] = min(arr[i], arr[i-ele[0]] + ele[1])
        else:
            arr[i] = min(arr[i], ele[1])

print(arr[h])
### BUGGY CODE ###

n,m,k = map(int,input().split())
A = [int(p) for p in input().split()]
B = [int(p) for p in input().split()]
a,b = [0],[0]

a_apnd = a.append
b_apnd = b.append
for i in range(n):
  a_apnd(a[i]+A[i])
for i in range(m):
  b_apnd(b[i]+B[i])

count = 0
for i in range(n+1):
  if k<a[i]:
    break
  for t in range(m,-1,-1):
    if b[t] <= k-a[i]:
      break
  count = max(count,i+t)

print(count)

### FIXED CODE ###

n,m,k = map(int,input().split())
A = [int(p) for p in input().split()]
B = [int(p) for p in input().split()]
a,b = [0],[0]

a_apnd = a.append
b_apnd = b.append
for i in range(n):
  a_apnd(a[i]+A[i])
for i in range(m):
  b_apnd(b[i]+B[i])

count = 0
t = m
for i in range(n+1):
  if k<a[i]:
    break
  while b[t] > k-a[i]:
    t -= 1
  count = max(count,i+t)

print(count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import deque

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
youso = (n*(n-1))//2
match = [0 for i in range(youso)]
child = [[] for i in range(youso)]
isroot = [True for i in range(youso)]
inq = [False for i in range(youso)]


def bfs():
    q = deque([])
    for root, rt in enumerate(isroot):
        if rt:
            q.append(root)
            match[root] = 1
    # print(match)
    while(q):
        item = q.popleft()
        inq[item] = False
        # print(q, item, child[item])
        for ch in child[item]:
            # print(ch)
            if match[ch] < match[item] + 1:
                match[ch] = match[item] + 1
                if not inq[ch]:
                    q.append(ch)
                    inq[ch] = True

    return




for idd in range(n):
    nums = getList()
    i = idd + 1
    for j,k in zip(nums, nums[1:]):
        if i > j:
            ii, j = j, i
        else:
            ii = i

        if i > k:
            iii, k = k, i
        else:
            iii = i
        idx1 = ((j-1)*(j-2))//2 + (ii-1)
        idx2 = ((k - 1) * (k - 2)) // 2 + (iii - 1)
        isroot[idx2] = False
        child[idx1].append(idx2)
        # print(i, j, k)
        # print(idx1, idx2)

#
# print(child)
# print(isroot)
# # sys.exit()

bfs()
# print("gg")
ans = 1
for m in match:
    if m > ans:
        ans = m
    if m == 0:
        print(-1)
        sys.exit()

print(ans)



### FIXED CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import deque


def getN():
    return int(input())


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


import math

n = getN()

match = [0 for i in range((n * (n - 1)) // 2)]
child = [[] for i in range((n * (n - 1)) // 2)]
iriji = [0 for i in range((n * (n - 1)) // 2)]


def toposo(n, iriji, child):
    order = [0 for i in range((n*(n+1))//2)]
    q = deque([])
    for i, iri in enumerate(iriji):
        if iri == 0:
            q.append(i)
            order[i] = 1
    while(q):
        start = q.popleft()
        target = child[start]
        for tgt in target:
            iriji[tgt] -= 1
            if iriji[tgt] == 0:
                q.append(tgt)
                order[tgt] = order[start] + 1

    if sum(iriji) != 0:
        return -1

    else:
        return max(order)


for idd in range(n):
    nums = getList()
    i = idd + 1
    for j, k in zip(nums, nums[1:]):
        ii, j = min(i, j), max(i, j)
        iii, k = min(i, k), max(i, k)
        idx1 = ((j - 1) * (j - 2)) // 2 + (ii - 1)
        idx2 = ((k - 1) * (k - 2)) // 2 + (iii - 1)
        iriji[idx2] += 1
        child[idx1].append(idx2)
        # print(i, j, k)
        # print(idx1, idx2)

#
# print(child)
# print(isroot)
# # sys.exit()
#
# bfs()
# # print("gg")
# ans = 1
# for m in match:
#     if m > ans:
#         ans = m
#     if m == 0:
#         print(-1)
#         sys.exit()
# print(iriji, child)

print(toposo(n, iriji, child))
### BUGGY CODE ###

#"""
import sys
input = sys.stdin.readline
#"""
def main():
    def get_key(i,j):
        if i<j: i,j = j,i
        return i*N+j
    N=int(input())
    A = [list(map(int,input().split())) for _ in [0]*N]
    V = [-1]*(N*N)
    for i in range(N):
        for j in range(i+1,N):
            V[get_key(i,j)] = 0
    Ef = [[] for _ in V]

    for i,B in enumerate(A):
        a0 = B[0]-1
        k1 = (i,a0)
        for a1 in B[1:]:
            a1 -= 1
            k0 = k1
            k1 = (i,a1)
            Ef[get_key(*k0)].append(get_key(*k1))
            V[get_key(*k1)] += 1

    q = [i for i,v in enumerate(V) if v == 0]
    ans = 0
    rmv = 0
    while q:
        qq = []
        for i in q:
            for j in Ef[i]:
                V[j] -= 1
                rmv += 1
                if V[j] == 0 : qq.append(j)
        ans += 1
        q = qq
    if rmv != N*(N-2) : ans = -1
    print(ans)
main()


### FIXED CODE ###

#"""
import sys
input = sys.stdin.readline
#"""
def main():
    def get_key(i,j):
        if i<j: i,j = j,i
        return i*N+j
    N=int(input())
    A = [list(map(int,input().split())) for _ in [0]*N]
    V = [-1]*(N*N)
    for i in range(N):
        for j in range(i+1,N):
            V[get_key(i,j)] = 0
    Ef = [[] for _ in V]

    for i,B in enumerate(A):
        a0 = B[0]-1
        k1 = (i,a0)
        for a1 in B[1:]:
            a1 -= 1
            k0 = k1
            k1 = (i,a1)
            Ef[get_key(*k0)].append(get_key(*k1))
            V[get_key(*k1)] += 1

    q = [i for i,v in enumerate(V) if v == 0]
    ans = 0
    rmv = 0
    while q:
        qq = []
        for i in q:
            for j in Ef[i]:
                V[j] -= 1
                rmv += 1
                if V[j] == 0 : qq.append(j)
        ans += 1
        q = qq
    if rmv != N*(N-2) : ans = -1
    print(ans)
main()
### BUGGY CODE ###

N=int(input())
E=[[] for _ in range(N)]
for _ in range(N-1):
    A,B=map(int,input().split())
    E[A-1].append(B-1)
    E[B-1].append(A-1)
MOD=10**9+7

#dp=子ノードの数+1(自分)
dp=[1]*N

root=0
parent=[0]*N
order=[]
def dfs():
    parent[root]=root
    stack=[root]
    while stack:
        node=stack.pop()
        order.append(node)
        for ss in E[node]:
            if parent[node]!=ss:
                stack.append(ss)
                parent[ss]=node

def solve():
    ans=0
    inv2=pow(2,MOD-2,MOD)
    #p0=すべての部分木に黒頂点が1つも含まれない確率
    p0=pow(1<<(N-1),MOD-2,MOD)
    for i in reversed(order):
        if root!=i:
            dp[parent[i]]+=dp[i]
        p=0
        if len(E[i])>=2:
            #p0*(p1-1)=どれか1つの各部分木に黒頂点が1つ以上含まれる確率
            p1=1
            for s in E[i]:
                size=0
                if parent[i]!=s:
                    size=dp[s]
                elif i!=root:
                    size=N-dp[i]
                else:
                    continue
                p1+=(1<<size)-1
                p1%=MOD
            p=1-(p0*p1)
            p%=MOD
        ans+=p
        ans%=MOD
    #頂点iが白の確率
    ans=ans*inv2%MOD
    print(ans)

dfs()
solve()


### FIXED CODE ###

N=int(input())
E=[[] for _ in range(N)]
for _ in range(N-1):
    A,B=map(int,input().split())
    E[A-1].append(B-1)
    E[B-1].append(A-1)
MOD=10**9+7

#dp=子ノードの数+1(自分)
dp=[1]*N

root=0
parent=[0]*N
order=[]
def dfs():
    parent[root]=root
    stack=[root]
    while stack:
        node=stack.pop()
        order.append(node)
        for ss in E[node]:
            if parent[node]!=ss:
                stack.append(ss)
                parent[ss]=node

pow2=[1]*(N+1)
for i in range(1,len(pow2)):
    pow2[i]=pow2[i-1]*2%MOD

def solve():
    ans=0
    inv2=pow(2,MOD-2,MOD)
    #p0=すべての部分木に黒頂点が1つも含まれない確率
    p0=pow(pow2[N-1],MOD-2,MOD)
    for i in reversed(order):
        if root!=i:
            dp[parent[i]]+=dp[i]
        p=0
        if len(E[i])>=2:
            #p0*(p1-1)=どれか1つの各部分木に黒頂点が1つ以上含まれる確率
            p1=1
            for s in E[i]:
                size=0
                if parent[i]!=s:
                    size=dp[s]
                elif i!=root:
                    size=N-dp[i]
                else:
                    continue
                p1+=pow2[size]-1
            p=1-(p0*p1)
            p%=MOD
        ans+=p
        ans%=MOD
    #頂点iが白の確率
    ans=ans*inv2%MOD
    print(ans)

dfs()
solve()
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0

for i in range(1,n):
    for j in range(1,k+1):
        if i-j<0:break
        pre=dp[i-j]+abs(h[i]-h[i-j])
        dp[i]=min(dp[i],pre)
print(dp[-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0

for i in range(1,n):
    for j in range(1,k+1):
        if i-j<0:break
        pre=dp[i-j]+abs(h[i]-h[i-j])
        dp[i]=min(dp[i],pre)
print(dp[-1])
### BUGGY CODE ###

import math

def main():
    strA = input()
    listA = strA.split(" ")

    N = int(listA[0])
    K = int(listA[1])

    x = N
    y = 0
    while(1):
        x = math.floor(x/K)

        y = y + 1
        if(x < K and x != 0):
            y = y + 1
            break

    print(y)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math

def main():
    strA = input()
    listA = strA.split(" ")

    N = int(listA[0])
    K = int(listA[1])

    x = N
    y = 0
    while(1):
        x = math.floor(x/K)

        y = y + 1
        if(x < K):
            if (x != 0):
                y = y + 1
            break

    print(y)

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

import sys
sys.setrecursionlimit(10**6)

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

dpmax = [["0"]*N for _ in range(N)]
dpmin = [["0"]*N for _ in range(N)]
        
def f(i, j, t):
    if i > j or i < 0 or i >= N or j < 0 or j >= N:
        return 0
    
    if i == j:
        if t == 0:
            dpmin[i][j] = -A[i]
            return -A[i]
        if t == 1:
            dpmax[i][j] = A[i]
            return A[i]
        
    if t == 0 and dpmin[i][j] != "0":
        return dpmin[i][j]
    elif t == 1 and dpmax[i][j] != "0":
        return dpmax[i][j]
    
    if t == 0:
        dpmin[i][j] = min(-A[i]+f(i+1, j, 1), -A[j]+f(i, j-1, 1))
        return dpmin[i][j]
    else:
        dpmax[i][j] = max(A[i]+f(i+1, j, 0), A[j]+f(i, j-1, 0))
        return dpmax[i][j]

ans = f(0, N-1, 1)
print(ans)

### FIXED CODE ###

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

dp = [[0]*N for _ in range(N)]
        
for k in range(N):
    for i in range(N-k):
        if k == 0:
            dp[i][i] = A[i]
            continue
    
        dp[i][i+k] = max(A[i]-dp[i+1][i+k], A[i+k]-dp[i][i+k-1])

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10**9+7

N,M = map(int,read().split())

"""
・既に強連結成分として確定している町の個数
・訪問済だけれど強連結成分には入っていない町の個数
に対する場合の数を持ってdp
"""

dp = np.zeros((N+1,N+1),np.int64)
dp[1,0] = 1

rng = np.arange(N+1,dtype=np.int64)

for _ in range(M):
    prev = dp
    dp = np.zeros_like(prev)
    # 強連結成分から出発する場合。
    dp[:,0] += prev[:,0] * rng
    dp[:,1] += prev[:,0] * rng[::-1]
    # 未確定部分から
    for m in range(1,N):
        # 強連結成分に戻る
        dp[m:,0] += prev[:-m,m] * rng[:-m]
        # 未確定部分のまま
        dp[:,m] += prev[:,m] * m
        # 未確定部分を広げる
        dp[:N-m,m+1] += prev[:N-m,m] * (N-m-rng[:N-m])
    dp %= MOD

answer = dp[N,0]
print(answer)



### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10**9+7

N,M = map(int,read().split())

"""
・合計の訪問済の町の個数
・訪問済だけれど強連結成分には入っていない町の個数
に対する場合の数を持ってdp
"""

dp = np.zeros((N+1,N+1),np.int64)
dp[1,0] = 1
for _ in range(M):
    prev = dp
    dp = np.zeros_like(prev)
    # 強連結成分にもどる
    dp[:,0] += (prev[:,:] * (np.arange(N+1)[:,None] - np.arange(N+1)[None,:])).sum(axis=1)
    # 未確定部分内で
    dp[:,:] += prev[:,:] * np.arange(N+1)[None,:]
    # 未確定部分の拡張
    dp[1:,1:]+= prev[:-1,:-1] * np.arange(N,0,-1)[:,None]
    dp %= MOD

answer = dp[N,0]
print(answer)
### BUGGY CODE ###

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

C = [[] for i in range(H)]
for i,(arow,brow) in enumerate(zip(A,B)):
    for a,b in zip(arow,brow):
        d = abs(a-b)
        C[i].append(d)

dp = [set() for i in range(W)]
dp[0].add(0)
for i,crow in enumerate(C):
    dp2 = [set() for j in range(W)]
    for j,(c,dpr) in enumerate(zip(C[i],dp)):
        for d in dpr:
            dp2[j].add(d+c)
            dp2[j].add(d-c)
    for j,c in enumerate(C[i]):
        if j==0: continue
        for d in dp2[j-1]:
            dp2[j].add(d+c)
            dp2[j].add(d-c)
    dp = dp2

print(min(abs(a) for a in dp[-1]))

### FIXED CODE ###

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

C = [[] for i in range(H)]
for i,(arow,brow) in enumerate(zip(A,B)):
    for a,b in zip(arow,brow):
        d = abs(a-b)
        C[i].append(d)

ofs = (H+W)*100
dp = [0] * W
dp[0] = (1<<ofs)
for i,crow in enumerate(C):
    dp2 = [0] * W
    for j,(c,d) in enumerate(zip(C[i],dp)):
        dp2[j] |= (d<<c)
        dp2[j] |= (d>>c)
    for j,c in enumerate(C[i]):
        if j==0: continue
        dp2[j] |= (dp2[j-1]<<c)
        dp2[j] |= (dp2[j-1]>>c)
    dp = dp2

ans = ofs
l = len(bin(dp[-1]))
for i in range(l):
    if dp[-1] & (1<<i):
        ans = min(ans, abs(i-ofs))
print(ans)
### BUGGY CODE ###

N,K = list(map(int,input().split(' ')))
pi = list(map(int,input().split(' ')))
value = max([sum(pi[i:K+i]) for i in range(N-K+1)])
print((value+K)/2)

### FIXED CODE ###

N,K = list(map(int,input().split(' ')))
pi = list(map(int,input().split(' ')))
value = sum(pi[:K])
max_value = value
for i in range(N-K):
  value -= pi[i]
  value += pi[i+K]
  max_value = max(value, max_value)
print((max_value+K)/2)
### BUGGY CODE ###

s = input()
n = len(s)
i = 0
while i < len(s) - 1:
    if s[i] != s[i + 1]:
        s = s[:i] + s[i + 2:]
        i = 0
    else:
        i += 1
print(n - len(s))


### FIXED CODE ###

s = input()
n0 = s.count('0')
n1 = s.count('1')
print(2 * min(n0, n1))
### BUGGY CODE ###

k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        check_tmp =0
        check_tmp =check1(x,l_s,l_k)
        if check_tmp == 1:
            break
        elif check_tmp  == 2:
            continue
        for y in range(l_k):
            check_tmp =check2(x,y,l_s,l_k)
            if check_tmp == 1:
                break
            elif check_tmp  == 2:
                continue
            for z in range(l_k):
                check_tmp =check3(x,y,z,l_s) 
                if check_tmp == 1:
                    break
#                print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))









### FIXED CODE ###

k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
#        check_tmp =0
#        check_tmp =check1(x,l_s,l_k)
#        if check_tmp == 1:
#            break
#        elif check_tmp  == 2:
#            continue
        for y in range(l_k):
#            check_tmp =check2(x,y,l_s,l_k)
#            if check_tmp == 1:
#                break
#            elif check_tmp  == 2:
#                continue2
#            sum = x+y+l_k 
            sum = l_s- x-y 
            if 0<=sum and sum <= k:
#                print("x=",x,"y="   ,y) 
                l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))
### BUGGY CODE ###

n = int(input())
s = input()
t = 0

for i in range(1, n+1):
    for j in range(i+1, n+1):
        if s[i-1] == s[j-1]:
            continue
        for k in range(j+1, n+1):
            if s[i-1] != s[k-1] and s[j-1] != s[k-1]:
                if j-i != k-j:
                    t += 1

print(t)


### FIXED CODE ###

n = int(input())
s = input()
t = 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 and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            t -= 1

print(t)
### BUGGY CODE ###

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

ans = 0
for i in range(N-1):
  s = 0
  for j in range(i+1, N):
    s += A[j]
    s %= (10**9)+7
  tmp = (A[i]*s) % ((10**9)+7)
  ans += tmp
  ans %= (10**9)+7
print(ans)

### FIXED CODE ###

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

left = A[0]
left %= (10**9)+7
right = sum(A) - A[0]
right %= (10**9)+7
ans = 0
for i in range(1, N):
  tmp = left * right
  tmp %= (10**9)+7
  ans += tmp
  ans %= (10**9)+7
  left = A[i]
  right -= A[i]
print(ans)