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

from collections import Counter

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

retval=0

for i in range(N):
    for j in range(i+1,N):
        if S[i]==S[j]:
            continue

        rest=list(set(['R','G','B'])-set([S[i],S[j]]))[0]
        for k in range(j+1,N):
            if S[k]==rest and k-j!=j-i:
                retval+=1

print(retval)


### FIXED CODE ###

from collections import Counter

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

dup=0
RGB=set(('R','G','B'))

for width in range(N//2+10):
    for i in range(N):
        try:
            if set((S[i],S[i+width],S[i+width*2]))==RGB:
                dup+=1
        except IndexError:
            break

c=Counter(S)
retval=c['R']*c['G']*c['B']-dup
print(retval)
### BUGGY CODE ###

S = input()

ans = 0

while S :
    if S[0] == S[-1] :
        S = S[1:-1]
    elif S[0] == "x" :
        S += "x"
        ans += 1
    elif S[-1] == "x" :
        S = "x" + S
        ans += 1
    else :
        ans = -1

print(ans)


### FIXED CODE ###

S = input()

ans = 0
l = 0
r = len(S)-1

while l < r :
    if S[l] == S[r] :
        l += 1
        r -= 1
    elif S[l] == "x" :
        l += 1
        ans += 1
    elif S[r] == "x" :
        r -= 1
        ans += 1
    else :
        ans = -1
        break

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

N, M, Q = [int(_) for _ in input().split()]

lr = [[0] * (N + 1) for _ in range(N + 1)]

for _ in range(M):
    l, r = [int(_) for _ in input().split()]
    lr[l][r] += 1

# for i in range(1, N + 1):
#     print(lr[i][1:])
for _ in range(Q):
    p, q = [int(_) for _ in input().split()]
    ans = 0
    for i in range(p, q + 1):
        for j in range(i, q + 1):
            ans += lr[i][j]
    print(ans)


### FIXED CODE ###

import sys

input = sys.stdin.readline
N, M, Q = [int(_) for _ in input().split()]

lr = [[0] * (N + 1) for _ in range(N + 1)]

for _ in range(M):
    l, r = [int(_) for _ in input().split()]
    lr[l][r] += 1
for i in range(1, N + 1):
    for j in range(1, N + 1):
        lr[i][j] += lr[i][j - 1]

# for i in range(1, N + 1):
#     print(lr[i][1:])
for _ in range(Q):
    p, q = [int(_) for _ in input().split()]
    ans = 0
    for i in range(p, q + 1):
        ans += lr[i][q] - lr[i][p - 1]
    print(ans)
### BUGGY CODE ###

import numpy as np

n,k=map(int,input().split())
p=np.array(list(map(int,input().split())))
p=(p+1.)/2.
max_p=0

for i in range(n-k+1):
    s=sum(p[i:i+k])
    if  max_p < s:
        max_p=s

print(max_p)

### FIXED CODE ###

#import numpy as np
import sys
input=sys.stdin.readline

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

#p=np.array(list(map(int,input().split())))
func=lambda x: ((int(x)+1.)/2.)
p=list(map(func,input().split()))

#p=(p+1.)/2.
s=sum(p[0:k])
max_p=s

#for i in range(n-k+1):
for i in range(n-k):
    #s=np.sum(p[i:i+k])
    s=s-p[i]+p[i+k]
    if  max_p < s:
        max_p=s

print(max_p)
### BUGGY CODE ###

import fractions

n = int(input())

nums = []
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            nums.append([i, j, k])

t = 0
for num in nums:
    ans = num[0]
    for i in range(1, 3):
        ans = fractions.gcd(ans, num[i])
    t += ans

print(t)

### FIXED CODE ###

from math import gcd

def main():
    n = int(input())

    t = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans = gcd(i, gcd(j, k))
                t += ans

    print(t)

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

#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, h: "List[int]"):
    DP = [INF]*N
    DP[0] = 0
    for i in range(1, N):
        for j in range(1, K+1):
            if i-j >= 0:
                DP[i] = min(DP[i], DP[i-j]+abs(h[i]-h[i-j]))
    print(DP[N-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, h: "List[int]"):
    DP = [INF]*N
    DP[0] = 0
    for i in range(1, N):
        for j in range(1, K+1):
            if i-j >= 0:
                DP[i] = min(DP[i], DP[i-j]+abs(h[i]-h[i-j]))
    print(DP[N-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


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

N,X = map(int,input().split())
def f(N):
    if(N == 0):
        return 'P'
    else:
        return 'B' + f(N-1) + 'P' + f(N-1) + 'B'
burger = f(N)
burger = burger[0:X]
print(burger.count('P'))

### FIXED CODE ###

N,X = map(int,input().split())
bg_cnt = [1]
pan_cnt = [1]
for i in range(N):
    bg_cnt.append(bg_cnt[i] * 2 + 3)
    pan_cnt.append(pan_cnt[i] * 2 + 1)

def f(N,X):
    if N == 0:
        return 1
    elif X == 1:
        return 0
    elif X <= 1 + bg_cnt[N-1]:
        return f(N-1,X-1)
    elif X == 2 + bg_cnt[N-1]:
        return 1 + f(N-1,X-1)
    else:
        return pan_cnt[N-1] + 1 + f(N-1,X-2-bg_cnt[N-1])    
print(f(N,X))
### BUGGY CODE ###

import functools
import operator

num = int(input())
a = list(map(int, input().split()))

result = functools.reduce(operator.mul, a)
if result > 1000000000000000000:
    print(-1)
else:
    print(result)

### FIXED CODE ###

ans = 1
flag = 0

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

if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 1000000000000000000:
            flag = 1
            print(-1)
            break
    
    if flag == 0:
        print(ans)
### BUGGY CODE ###

N=int(input())
S=input()
sum=0
for i in range(N-2):
    rgb = ['R','G','B']
    rgb.remove(S[i])
    for j in range(2):
        idx=0
        tmp=i
        while True:
            idx=S.find(rgb[j], tmp+1)
            if idx==-1: break
            sum+=S.count(rgb[1-j], idx+1)
            if 2*idx-i<=len(S)-1 and S[2*idx-i]==rgb[1-j]: sum-=1
            tmp=idx
print(sum)

### FIXED CODE ###

N=int(input())
S=input()
cnt=S.count('R')*S.count('G')*S.count('B')
for i in range(N-2):
    for j in range(i+1, N-1):
        k=2*j-i
        if k<N:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]: cnt-=1
print(cnt)
### BUGGY CODE ###

import numpy as np
n = int(input())
arr = list(map(float, input().split()))

dp = np.array([[0.0] * (n + 1) for _ in range(n + 1)])

dp[0, 0] = 1.0

for i in range(n):
    for j in range(i + 1):
        dp[i + 1, j + 1] += dp[i, j] * arr[i]
        dp[i + 1, j] += dp[i, j] * (1 - arr[i])

print(dp[-1, -(n + 1)//2:].sum())

### FIXED CODE ###

n = int(input())
arr = list(map(float, input().split()))

dp = [[0.0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0

for i in range(n):
    for j in range(i + 1):
        dp[i + 1][j + 1] += dp[i][j] * arr[i]
        dp[i + 1][j] += dp[i][j] * (1 - arr[i])

dp = dp[-1]

print(sum(dp[-(n + 1) // 2:]))
### BUGGY CODE ###

a = int(input())

total = 0
for i in range(1,a+1):
    for j in range(1,a+1):
        if i % j == 0:
            total += i
    
print(total)

### FIXED CODE ###

N = int(input())


def g(n):
    return (n * (n + 1))//2

total = 0
for i in range(1,N+1):
    total += i * g(N//i)
    
print(total)
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A, B, C = [sorted(list(map(int, input().split())))[:: -1][: K] for _ in range(3)]
res = []
for ai in A:
    for bi in B:
        for ci in C:
            res.append(ai + bi + ci)
res = sorted(res)[:: -1][: K]
for ans in res:
    print(ans)


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A, B, C = [sorted(list(map(int, input().split())))[:: -1][: K] for _ in range(3)]
D = []
for ai in A:
    for bi in B:
        D.append(ai + bi)

D = sorted(D)[:: -1][: K]

res = []
for di in D:
    for ci in C:
        res.append(di + ci)

res = sorted(res)[:: -1][: K]

for ans in res:
    print(ans)
### BUGGY CODE ###

import sys,heapq
input = sys.stdin.readline


def main():
    n = int(input())
    
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    p = 0
    q = 0
    for eA,eB in zip(a,b):
        p = (p+eA)<<30
        q = (q+eB)<<30
    p = p>>30
    q = q>>30


    for k in range(n):
        hyp = b[0]^a[k]
        judge = p^q
        if (judge^((judge>>30)<<30)) == hyp and (judge^((judge>>60)<<60))>>30 == hyp:
            print(k,hyp)
        q = (q>>30) + (b[n-1-k]<<(30*(n-1)))

    





if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

#Z[i]:length of the longest list starting from S[i] which is also a prefix of S
def Z_algorithm(s):
    N = len(s)
    Z_alg = [0]*N

    Z_alg[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        Z_alg[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + Z_alg[k]<j:
            Z_alg[i+k] = Z_alg[k]
            k += 1
        i += k
        j -= k
    return Z_alg


n = int(input())
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))


BAA = []
for i in range(n-1):
    BAA.append(b[i]^b[i+1])
BAA.append(b[0]^b[-1])

BAA.append(-1)

for i in range(n-1):
    BAA.append(a[i]^a[i+1])
BAA.append(a[0]^a[-1])
for i in range(n-1):
    BAA.append(a[i]^a[i+1])
BAA.append(a[0]^a[-1])

z = Z_algorithm(BAA)

for k in range(n):
    if z[n+k+1] >= n:
        print(k,b[0]^a[k])
### BUGGY CODE ###

# 競プロの数学は高校数学みたいな泥臭いのが多い
# めんどくさがってA,Bの範囲を計算しなかったのが原因
# なんなら大雑把にみて -1000~1000でもいけてる
X = int(input())
for i in range(2000):
    for j in range(2000):
        a = i-1000
        b = j-1000
        if X == a**5-b**5:
            print(a, end=" ")
            print(b)
            break

### FIXED CODE ###

# 競プロの数学は高校数学みたいな泥臭いのが多い
# めんどくさがってA,Bの範囲を計算しなかったのが原因
# なんなら大雑把にみて -500~500でもいけてる
flag = 0
X = int(input())
for i in range(1000):
    for j in range(1000):
        a = i-500
        b = j-500
        if X == a**5-b**5:
            print(a, end=" ")
            print(b)
            flag =  1
            break
    if flag == 1:
        break
### BUGGY CODE ###

class Unionfind:

    __slots__ = ['parents','sizes']

    def __init__(self, n):
        self.parents = list(range(n))
        self.sizes = [1]*n

    def root(self, x):
        if self.parents[x] == x:
            return x
        else:
            root_x = self.root(self.parents[x])
            self.parents[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.sizes[x] += self.sizes[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    # 集合自体の数 ({1,2}, {3}, {4} : kind -> 3)
    def kind(self):
        for v in range(N):
            self.root(v)
        return len(list(set(self.parents)))

    # xが属する集合の要素の数　({1,2,3} : size(2) -> 3)
    def size(self, x):
        self.sizes[x] = self.sizes[self.root(x)]
        return self.sizes[x]

N, K, L = map(int,input().split())
road = Unionfind(N)
train = Unionfind(N)

for _ in range(K):
    p, q = map(int,input().split())
    p -= 1; q -= 1
    road.unite(p, q)

for _ in range(L):
    r, s = map(int,input().split())
    r -= 1; s -= 1
    train.unite(r, s)

ans_list = []

r = [set() for _ in range(N)]
t = [set() for _ in range(N)]
for i in range(N):
    road.parents[i] = road.root(i)
    r[road.parents[i]].add(i)
    train.parents[i] = train.root(i)
    t[train.parents[i]].add(i)

ans_list = []

for i in range(N):
    ans = len(r[road.parents[i]] & t[train.parents[i]])
    ans_list.append(ans)

print(*ans_list)

### FIXED CODE ###

from collections import defaultdict

class Unionfind:

    __slots__ = ['parents','sizes']

    def __init__(self, n):
        self.parents = list(range(n))
        self.sizes = [1]*n

    def root(self, x):
        if self.parents[x] == x:
            return x
        else:
            root_x = self.root(self.parents[x])
            self.parents[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.sizes[x] += self.sizes[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    # 集合自体の数 ({1,2}, {3}, {4} : kind -> 3)
    def kind(self):
        for v in range(N):
            self.root(v)
        return len(list(set(self.parents)))

    # xが属する集合の要素の数　({1,2,3} : size(2) -> 3)
    def size(self, x):
        self.sizes[x] = self.sizes[self.root(x)]
        return self.sizes[x]

N, K, L = map(int,input().split())
road = Unionfind(N)
train = Unionfind(N)

for _ in range(K):
    p, q = map(int,input().split())
    p -= 1; q -= 1
    road.unite(p, q)

for _ in range(L):
    r, s = map(int,input().split())
    r -= 1; s -= 1
    train.unite(r, s)

cnt = defaultdict(int)

for i in range(N):
    key = (road.root(i), train.root(i))
    cnt[key] += 1

ans_list = []
for i in range(N):
    key = (road.root(i), train.root(i))
    ans = cnt[key]
    ans_list.append(ans)

print(*ans_list)
### BUGGY CODE ###

ts = input()
res = 0
while "BW" in ts:
    t = ""
    s = list(ts)
    for i in range(len(ts)-1):
        if s[i] == "B" and s[i+1] == "W":
            s[i] = "W"
            s[i+1] = "B"
            res += 1
        t += s[i]
    ts = t
print(res)

### FIXED CODE ###

a = input()
b = 0
bt = 0
w = 0
wt = 0
for i in range(len(a)):
    if a[i] == "B":bt = 1
    if bt == 1 and a[i] == "B":b+=1
    if a[i] =="W":
        w+=b
        wt +=1
print(w)
### BUGGY CODE ###

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

dp = [0]
for i in range(1, n):
  tmp = float('inf')
  for j in range(k):
    if i-j > 0:
      tmp = min(tmp, dp[-1-j]+abs(h[i]-h[i-1-j]))
  dp.append(tmp)
print(dp[-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
 
DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]
 
print(DP[-1])
### BUGGY CODE ###

n = int(input())
l = [int(x) for x in input().split()]
l.sort()
set_l = set(l)
set_l = sorted(set_l)
limit = 10**6
mp = [0]*(limit+1)
pre = None
for i in range(n):
    num = l[i]
    if(pre==num):
        mp[num] += 1
    pre = num

for x in set_l:
    num = x
    while(x <= limit):
        mp[x] += 1
        x += num

cnt = 0
for num in set_l:
    if(mp[num]==1):
        cnt += 1
print(cnt)





### FIXED CODE ###

n = int(input())
l = [int(x) for x in input().split()]
l.sort()
set_l = set(l)
set_l = sorted(set_l)
limit = 10**6+1
mp = [0]*(limit)
pre = None
for i in range(n):
    num = l[i]
    if(pre==num):
        mp[num] += 1
    pre = num

for x in set_l:
    for y in range(x,limit,x):
        mp[y] += 1
        

cnt = 0
for num in set_l:
    if(mp[num]==1):
        cnt += 1
print(cnt)
### BUGGY CODE ###

def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n = int(input())
  l = 0
  for a in range(1, n+1):
     for b in range(1, n+1):
        for c in range(1, n+1):
          l += gcd_list([a,b,c])
  print(l)
import math
import fractions
import collections
import itertools
from functools import reduce
main()


### FIXED CODE ###

def simple_gcd(x, y):
  if y == 0:
    return x;
  else:
    return simple_gcd(y, x % y)

def main():
  n = int(input())
  l = 0
  for a in range(1, n+1):
     for b in range(1, n+1):
        d = simple_gcd(a,b)
        for c in range(1, n+1):
          l += simple_gcd(d,c)
  print(l)
main()
### BUGGY CODE ###

a = list(range(13))
b = []
for i in a:
    num = int(str(i) + '0') % 13
    l = []
    for j in range(13):
        l.append((num+j)%13)
    b.append(l)

s = input()
MOD = 10**9+7
dp = [[0 for _ in range(13)] for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] += 1
else:
    dp[0][int(s[0])] += 1

for i in range(1, len(s)):
    if s[i] == '?':
        for j in range(13):
            for k in range(10):
                dp[i][b[j][k]] += dp[i-1][j]
                dp[i][b[j][k]] %= MOD
    else:
        for j in range(13):
            n = b[j][int(s[i])]
            dp[i][n] += dp[i-1][j]
            dp[i][n] %= MOD
print(dp[-1][5]%MOD)


### FIXED CODE ###

a = list(range(13))
b = []
for i in a:
    num = int(str(i) + '0') % 13
    l = []
    for j in range(13):
        l.append((num+j)%13)
    b.append(l)

s = input()
MOD = 10**9+7
dp = [[0 for _ in range(13)] for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] += 1
else:
    dp[0][int(s[0])] += 1

for i in range(1, len(s)):
    if s[i] == '?':
        for j in range(13):
            for k in range(10):
                dp[i][b[j][k]] += dp[i-1][j]
                dp[i][b[j][k]] %= MOD
    else:
        for j in range(13):
            n = b[j][int(s[i])]
            dp[i][n] += dp[i-1][j]
            dp[i][n] %= MOD
print(dp[-1][5]%MOD)
### BUGGY CODE ###

import numpy as np
n=int(input())
s=np.zeros((100001,12),dtype='int32')
a=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]

for i in range(n+1):
    s[i][0]=i
for i in range(1,12):
    for j in range(n+1):
        s[j][i]=s[j][i-1]
        if a[i]<=j:
            if s[j][i]>s[j-a[i]][i]+1:
                s[j][i]=s[j-a[i]][i]+1
print(s[n][11])


### FIXED CODE ###

n=int(input())
s=[i for i in range(n+1)]
a=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
for i in range(n+1):
    s[i]=i
for i in range(1,12):
    if a[i]<=n :
        k=a[i]
        for j in range(k,n+1):
            if s[j]>s[j-k]+1:
                s[j]=s[j-k]+1
print(s[n])
### BUGGY CODE ###

import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    check = []
    def my_index(l, x, default=False):
        return l.index(x) if x in l else default

    for _ in range(N):
        A = int(input())
        if A not in check:
            check.append(A)
        else:
            del check[my_index(check,A)]
    print(len(check))

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import Counter
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    A = [input() for _ in range(N)]
    common = Counter(A).most_common()
    ans = 0
    for i in common:
        if i[1] % 2 == 1:
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().split()))
sort_as = sorted(As)
shine = [x + 1 for x in range(N)]
c = 0
s = 0
j = 0
for x in range(N):
  for y in range(len(As)):
    if shine[x] == As[y]:
      c += 1
  print(c)
  c = 0

### FIXED CODE ###

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

k = int(input())
con = 1
lis = []
ans = 7

while True:
  ans = ans % k
  if ans == 0:
    print(con)
    break
  else:
    if ans in lis:
      print("-1")
      break
    else:
      lis.append(ans)
      ans = ans * 10 + 7
      con += 1
  

### FIXED CODE ###

k = int(input())
start = 7 % k
ans = start
con = 1

if k % 2 == 0 or k % 5 == 0:
  print("-1")
  exit()
while True:
  if ans == 0:
    print(con)
    break
  else:
    con += 1
    ans = ans * 10 + 7
    ans = ans % k
    if ans == start:
      print("-1")
      break
### BUGGY CODE ###

K,S = map(int,input().split())
cnt= 0

for x in range(0,K+1):
    for y in range(0,K+1):
        for z in range(0,K+1):
            if ((x + y + z )== S):
                cnt += 1

print(cnt)

### FIXED CODE ###

K,S = map(int,input().split())
cnt= 0

for x in range(0,K+1):
    for y in range(0,K+1):
        if(0 <= S - x - y and S - x - y <= K):
            cnt += 1

print(cnt)
### BUGGY CODE ###

### 解答
N, K = map(int, input().split())
A = list(map(int, input().split()))

#B = [0]*N                                 # 記録用のリスト

for k in range(K):                        # 以降の操作をK回繰り返す
  B = [0 for _ in range(N)] 
  for i in range(N):                      # 各電球によって照らされる範囲を考える
    start = max(0, i-A[i])                # 始点のインデックスは0かi-A[i]
    end = min(N, i+A[i]+1)                # 終点のインデックスはNかi+A[i]+1
    B[start] += 1                         # 始点に+1を記録する
    if end <= N - 1:
      B[end] -= 1                         # 終点に電球が存在する場合は-1を記録する
  bmin = B[0] 
  for i in range(1, N):                   # 累積和の計算
    B[i] = B[i-1] + B[i]
    bmin = min(B[i], bmin)
  A = B                                   # AをBで更新してつぎのループへ 
  if bmin == N:                        # すべての電球がN個の電球に照らされるタイミングでbreakする
    break

print(*A)                                 # リストAの中身を順に表示

### FIXED CODE ###

import numpy as np
from numba import njit
 
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype=np.int64)
 
@njit
def loop1(a):
  b = np.zeros(n+1, dtype=np.int64)
  for i in range(n):
    l = max(0, i-a[i])
    r = min(i+a[i]+1, n)
    b[l] += 1
    if r <= n-1: b[r] -= 1
  
  b = np.cumsum(b)[:-1]
  return b
 
for q in range(min(42, k)):
  a = loop1(a)
    
print(*a)
### BUGGY CODE ###

h,n=(int(i) for i in input().split())
l=[]
for i in range(n):
  a,b=(int(i) for i in input().split())
  l.append([a,b])
pocket=[0]
for i in range(h):
  r=[]
  for j in range(n):
    a=l[j][0]
    b=l[j][1]
    r.append(pocket[max(0,i+1-a)]+b)
  pocket.append(min(r))
print(pocket[h])


### FIXED CODE ###

h,n=(int(i) for i in input().split())
l=[]
for i in range(n):
  a,b=(int(i) for i in input().split())
  l.append([a,b])
pocket=[0]
for i in range(h):
  mini=pocket[max(0,i+1-l[0][0])]+l[0][1]
  for j in range(n-1):
    a=l[j+1][0]
    b=l[j+1][1]
    if pocket[max(0,i+1-a)]+b<mini:
      mini=pocket[max(0,i+1-a)]+b
  pocket.append(mini)
print(pocket[h])