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

MOD = 998244353
#階乗のリストを作成する
N, M, K = map(int, input().split())
frac = [1]
for i in range(N):
    frac.append(frac[i]*(i+1)%MOD)

#上の公式を用いてcombの計算を行う
def comb(n, k, mod):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
  
def main():
  ans = [0] * (K+1)
  temp = 1
  for i in range(N):
    if i == 0:
      temp*=M
      temp %= MOD
    else:
      temp *= (M-1)
      temp %= MOD
    if i+1 >= N-K:
      ans[i+1-N+K] = temp
  t_ans = 0
  key = 1
  for i in range(len(ans)):
    t_ans += (ans[-1-i]*key) % MOD
    t_ans %= MOD
    key *= (N-i-1)
    key //= (i+1)
  print(t_ans)
if __name__ == "__main__":
  main()

### FIXED CODE ###

MOD = 998244353
#階乗のリストを作成する
N, M, K = map(int, input().split())
frac = [1]
for i in range(N):
    frac.append(frac[i]*(i+1)%MOD)

#上の公式を用いてcombの計算を行う
def comb(n, k, mod):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
  
def main():
  ans = [0] * (K+1)
  temp = 1
  for i in range(N):
    if i == 0:
      temp*=M
      temp %= MOD
    else:
      temp *= (M-1)
      temp %= MOD
    if i+1 >= N-K:
      ans[i+1-N+K] = temp
  t_ans = 0
  for i in range(len(ans)):
    key = comb(N-1, i, MOD)
    t_ans += (ans[-1-i]*key)
    t_ans %= MOD
  print(t_ans)
if __name__ == "__main__":
  main()
### BUGGY CODE ###

def takeSecond(elem):
    return elem[1]

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

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

sushi.sort(key=takeSecond,reverse=True)

selected = sushi[:k]
kindset = set([item[0] for item in selected])

startKindNum = len(kindset)

score = startKindNum*startKindNum + sum([item[1] for item in selected])

scorelist = []
scorelist.append(score)
pointer = k
for i in range(startKindNum+1,min([k+1,n+1])):
    #remove the smallest one that does not decrease kind
    for item in selected[::-1]:
        if([elem for elem in selected if(elem[0]==item[0] and elem is not item)]):
            selected.remove(item)
            break

    #add the largest one that add kind
    for j in range(k,n):
        if(sushi[j][0] not in kindset):
            selected.append(sushi[j])
            kindset.add(sushi[j][0])
            k += 1
            kindNum = len(kindset)
            score = kindNum*kindNum + sum([item[1] for item in selected])
            scorelist.append(score)
            break
print(max(scorelist))


### FIXED CODE ###

def takeSecond(elem):
    return elem[1]

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

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

sushi.sort(key=takeSecond,reverse=True)
'''
selected = sushi[:k]
kindset = set([item[0] for item in selected])

startKindNum = len(kindset)

score = startKindNum*startKindNum + sum([item[1] for item in selected])
maxscore = score
front_pointer = k - 1
pointer = k
for i in range(startKindNum+1,min([k+1,n+1])):
    #remove the smallest one that does not decrease kind
    for p in range(front_pointer,-1,-1):
        item = selected[p]
        flag = False
        for idx in range(p):
            if(selected[idx][0]==item[0]):
                score -= item[1]
                selected.remove(item)
                front_pointer = p - 1
                flag = True
                break
        if(flag):
            break

    #add the largest one that add kind
    for j in range(pointer,n):
        if(sushi[j][0] not in kindset):
            selected.append(sushi[j])
            kindset.add(sushi[j][0])
            k += 1
            pointer = j + 1            
            score += 2*startKindNum + 1 + sushi[j][1]
            if(score>maxscore):
                maxscore = score
            startKindNum += 1
            break
'''
kindset = set([])
score = 0
extras = []
for item in sushi[:k]:
    if item[0] in kindset:
        extras.append(item[1])
    else:
        kindset.add(item[0])
    score += item[1]
score += len(kindset)**2
maxscore = score
for item in sushi[k:]:
    if not  extras:
        break
    if item[0] in kindset:
        continue
    score += (item[1] - extras.pop()) + 2*len(kindset) + 1
    kindset.add(item[0])
    #print(score)
    if score > maxscore:
        maxscore = score


print(maxscore)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
pex = [(1+n)/2 for n in p]
m = []
for i in range(n-k+1):
    m.append(sum(pex[i:i+k]))
print(max(m))

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
nxt = 0
mx = []
for i in range(n):
    pex = (1+p[i])/2
    mx.append(pex+nxt)
    nxt = pex + nxt
if n == k:
    print(mx[-1])
else:
    ans = []
    for i in range(n-k):
        ans.append(mx[i+k] - mx[i])
    print(max(ans))
### BUGGY CODE ###

import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i,j in itertools.product(range(1,N),range(1,K+1)):
    if i-j>=0:
        dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])


### FIXED CODE ###

def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))
### BUGGY CODE ###

def solve():
    def recur(i, n, total):
        # print("i, n, total", i, n, total)

        if not TABLE[i][n][total] == -1:
            # print('cache!')
            return TABLE[i][n][total]

        if not i < N:
            if n > 0 and total == A * n:
                TABLE[i][n][total] = 1
                return 1
            TABLE[i][n][total] = 0
            return 0

        ans1 = recur(i + 1, n, total)
        ans2 = recur(i + 1, n + 1, total + XS[i])

        # print(ans1, ans2)

        return ans1 + ans2

    N, A = tuple(map(int, input().split()))
    XS = tuple(map(int, input().split()))

    TABLE = []
    for _ in range(N + 1):
        lines = [[-1 for x in range(N * 50 + 1)] for y in range(N + 1)]
        TABLE.append(lines)

    return recur(0, 0, 0)


if __name__ == '__main__':
    print(solve())


### FIXED CODE ###

def solve():
    def recur(i, n, total):
        # print("i, n, total", i, n, total)

        if not TABLE[i][n][total] == -1:
            # print('cache!')
            return TABLE[i][n][total]

        if not i < N:
            if n > 0 and total == A * n:
                return 1
            return 0

        ans1 = recur(i + 1, n, total)
        ans2 = recur(i + 1, n + 1, total + XS[i])

        # print(ans1, ans2)

        TABLE[i][n][total] = ans1 + ans2
        return TABLE[i][n][total]

    N, A = tuple(map(int, input().split()))
    XS = tuple(map(int, input().split()))

    TABLE = []
    for _ in range(N + 1):
        lines = [[-1 for x in range(N * 50 + 1)] for y in range(N + 1)]
        TABLE.append(lines)

    return recur(0, 0, 0)


if __name__ == '__main__':
    print(solve())
### BUGGY CODE ###

import math
def divisor(n):
   x = {}
   while n % 2 == 0:
      if "2" not in x.keys():
         x["2"] = 1
      else:
         x["2"]+=1
      n = n/2
   for i in range(3,int(math.sqrt(n))+1,2):
      while n%i == 0:
         tmp = str(i)
         if tmp not in x.keys():
            x[tmp] = 1
         else:
            x[tmp] +=1
         n = n/i
   if n > 2:
      tmp = str(n)
      x[tmp] = 1
   res = 1
   for item in x.values():
      res*=(item+1)
   return res
n = int(input())
sum=0
for i in range(1,n+1):
   sum+=(i*divisor(i))
print(sum)

### FIXED CODE ###

import math
def solver(n):
    sum = 0
    for i in range(1,n+1):
        y = math.floor(n/i)
        sum+=(i*y*(y+1)/2)
    return int(sum)


n = int(input())
print(solver(n))
### BUGGY CODE ###

import bisect

n = int(input())
s = list(map(int, input().split(" ")))
# n = 18
# s = list(reversed(range(1, 2 ** n + 1)))

s = sorted(s)
from collections import deque

def solve():
    parents = [s[-1]]
    s.pop()

    for i in range(n):
        newparents = list(parents)
        for p in reversed(parents):
            k = bisect.bisect(s, p - 1) - 1
            if k == -1:
                print("No")
                exit(0)
            bisect.insort(newparents, s[k])
            s.pop(k)
        parents = newparents

    # print(parents)
    # print(k)
    if k == len(s):
        print("Yes")
    else:
        print("No")
solve()


### FIXED CODE ###

import bisect

n = int(input())
s = list(map(int, input().split(" ")))
# n = 18
# s = list(reversed(range(1, 2 ** n + 1)))

s = sorted(s)
from collections import deque

def solve():
    global s

    parents = [s[-1]]
    s.pop()

    for i in range(n):
        newparents = list(parents)
        k = len(s)
        dropped = set()
        # print(parents)
        for p in parents:
            oldK = k
            k = bisect.bisect(s, p - 1, 0, k) - 1
            # print("Old", oldK, k, s[k], p)
            if k == -1:
                print("No")
                exit(0)

            newparents.append(s[k])
            dropped.add(k)
        s = [x for i, x in enumerate(s) if i not in dropped]
        parents = sorted(newparents, reverse=True)

    # print(parents)
    # print(k)
    if k == len(s):
        print("Yes")
    else:
        print("No")
solve()
### BUGGY CODE ###

N,M = map(int, input().split())
mem = [[] for i in range(N)]

p1 = []
p2 = []
def solve():
    for i in range(M):
        a,b = map(int, input().split())
        if a == 1:
            p1.append(b)
        elif b == N:
            p2.append(a)
    for p in p1:
        if p in p2: return True
    return False

print('POSSIBLE' if solve() else 'IMPOSSIBLE')


### FIXED CODE ###

N,M = map(int, input().split())
mem = [[] for i in range(N)]

p1 = []
p2 = []
def solve():
    for i in range(M):
        a,b = map(int, input().split())
        if a == 1:
            p1.append(b)
        elif b == N:
            p2.append(a)
    return len(set(p1) & set(p2)) > 0

print('POSSIBLE' if solve() else 'IMPOSSIBLE')
### BUGGY CODE ###

import math
from functools import reduce

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
a = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      a += int(gcd_list([i,j,k]))
      
print(int(a))

### FIXED CODE ###

import math

K = int(input())
arr = []
a = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    arr.append(math.gcd(i, j))      
for j in range(len(arr)):
  for k in range(1,K+1):
    a += math.gcd(arr[j],k)
print(int(a))
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
count = 0

for r in range(int(N / R) + 1):
    for g in range(int(N / G) + 1):
        x = N - r * R - g * G
        if x >= 0 and x % B == 0:
            count = count + 1

print(count)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
count = 0

for r in range(int(N / R) + 1):
    for g in range(int(N / G) + 1):
        x = N - r * R - g * G
        if x < 0:
            break
        if x >= 0 and x % B == 0:
            count = count + 1

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

from itertools import accumulate

N, C = map(int, input().split())
sushi = [[int(x) for x in input().split()] for _ in range(N)]


def solve():
    """
    全探索O(N^2)
    v を事前に計算
    """
    V = [0] * (N + 1)
    for i in range(N):
        V[i + 1] = V[i] + sushi[i][1]

    ans = 0
    for i in range(N + 1):
        # OA
        if i == 0:
            oa_x = 0
        else:
            oa_x = sushi[i - 1][0]
        oa_v = V[i]

        for j in range(N + 1):
            # OB
            if j == 0:
                ob_x = 0
            else:
                ob_x = C - sushi[j - 1][0]
            ob_v = V[N] - V[j - 1]

            v = oa_v + ob_v

            # 2OA + OB
            x = 2 * oa_x + ob_x
            if x < C:
                ans = max(ans, v - x)

            # OA + 2OB
            x = oa_x + 2 * ob_x
            if x < C:
                ans = max(ans, v - x)
    print(ans)


solve()


### FIXED CODE ###

from itertools import accumulate

N, C = map(int, input().split())
sushi = [[int(x) for x in input().split()] for _ in range(N)]


def solve():
    """
    O(N)
    Bを固定したときの最適なAを事前に計算
    """
    V = [0] * (N + 1)
    for i in range(N):
        V[i + 1] = V[i] + sushi[i][1]

    f1 = [0] + [V[a + 1] - sushi[a][0] for a in range(N)]
    f2 = [0] + [V[a + 1] - 2 * sushi[a][0] for a in range(N)]

    g1 = [x for x in accumulate(f1, max)]
    g2 = [x for x in accumulate(f2, max)]

    ans = 0
    for j in range(N + 1):
        # OA
        if j == 0:
            i = N
        else:
            i = j - 1

        # OB
        if j == 0:
            ob_x = 0
        else:
            ob_x = C - sushi[j - 1][0]
        ob_v = V[N] - V[j - 1]

        # 2OA + OB
        ans = max(ans, g2[i] + ob_v - ob_x)

        # OA + 2OB
        ans = max(ans, g1[i] + ob_v - 2 * ob_x)
    print(ans)


solve()
### BUGGY CODE ###

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

# 3つの数字をリストから数値の変数に
input_list = input().split()
start_num = int(input_list[0])
end_num = int(input_list[1])
range_num = int(input_list[2])

for i in range(start_num, end_num + 1):
	# 条件に当てはまるものを抽出
	if i < start_num + range_num or i > end_num - range_num:
		print(i)


### FIXED CODE ###

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

# 3つの数字をリストから数値の変数に
input_list = input().split()
start_num = int(input_list[0])
end_num = int(input_list[1])
range_num = int(input_list[2])

result_list = []
for i in range(start_num, end_num + 1):
	# 前半の条件に当てはまるものを抽出
	if i < start_num + range_num:
		result_list.append(i)
	else:
		break

for i in range(end_num, start_num -1, -1):
	# 後半の条件に当てはまるものを抽出
	if i > end_num - range_num:
		result_list.append(i)
	else:
		break

# 重複削除
result_list = list(set(result_list))
# 昇順ソート
result_list.sort()

for num in result_list:
	print(num)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7


def main(): 
    N = II()
    h = LI()

    def min_cost(x):
        if x == 0: return 0
        elif x == 1: return abs(h[1] - h[0])
        else: return min(min_cost(x-1) + abs(h[x] - h[x-1]), min_cost(x-2) + abs(h[x] - h[x-2]))

    print(min_cost(N-1))

main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

from functools import lru_cache

def main(): 
    N = II()
    h = LI()

    @lru_cache()
    def min_cost(x):
        if x == 0: return 0
        elif x == 1: return abs(h[1] - h[0])
        else: return min(min_cost(x-1) + abs(h[x] - h[x-1]), min_cost(x-2) + abs(h[x] - h[x-2]))

    print(min_cost(N-1))

main()
### BUGGY CODE ###

n = int(input())
S = input()
s = [0 for i in range(n)]

for i in range(n):
    if S[i] == "E":
        s[i] = 1
min = n

for i in range(n):
    count = 0
    for j in range(n):
        if i < j and s[j] == 1:
            count += 1
        elif i > j and s[j] == 0:
            count += 1
    if count < min:
        min = count
print(min)


### FIXED CODE ###

n = int(input())
S = input()
s = [0 for i in range(n)]

for i in range(n):
    if S[i] == "E":
        s[i] = 1
min = n

count = 0
for j in range(n):
    i = 0
    if i < j and s[j] == 1:
        count += 1
    elif i > j and s[j] == 0:
        count += 1
if count < min:
    min = count

for i in range(1, n):
    if s[i-1] == 0:
        count += 1
    if s[i] == 1:
        count -= 1
    if count < min:
        min = count
print(min)
### BUGGY CODE ###

N, W = map(int, input().split())
dp = [-1] * (W+1)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W-w, -1, -1):
        if dp[j] == -1:
            continue
        else:
            dp[j+w] = max(dp[j+w], dp[j] + v)

print(max(dp))


### FIXED CODE ###

N, W = map(int, input().split())
dp = [-1] * (W+1)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W-w, -1, -1):
        if dp[j] == -1:
            continue
        else:
            dp[j+w] = max(dp[j+w], dp[j] + v)

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

R, G, B ,N = map(int, input().split())

RGB = [R, G, B]
RGB.sort(reverse=True)

R = RGB[0]
G = RGB[1]
B = RGB[2]

cnt = 0
NR = N//R
NG = N//G
for r in range(NR + 1):
  for g in range(NG + 1):
    NrRgG = N - (r*R + g*G)
    if NrRgG < 0:
      break
    elif NrRgG >= 0:
      if NrRgG % B == 0:
        cnt += 1
print(cnt)

### FIXED CODE ###

R, G, B ,N = map(int, input().split())

if R==1 and G==1 and B==1:
  print(int((N+2)*(N+1)*(1/2)))
else:
  RGB = [R, G, B]
  RGB.sort(reverse=True)

  R = RGB[0]
  G = RGB[1]
  B = RGB[2]

  cnt = 0
  NR = N//R
  NG = N//G
  for r in range(NR + 1):
    for g in range(NG + 1):
      NrRgG = N - (r*R + g*G)
      if NrRgG < 0:
        break
      elif NrRgG >= 0:
        if NrRgG % B == 0:
          cnt += 1
  print(cnt)
### BUGGY CODE ###

from math import ceil
H,N = list(map(int, input().split()))
A = []
for _ in range(N):
  A.append(list(map(int, input().split())))
  
# 1回iを使ってから、のこりをjで仕留める、を全探索でよい気がする
# だめだった

# dp[i] : HPをi減らすために必要なmin魔力
dp = [1e9] * (10010)
dp[0] = 0
for i in range(1,H+1):
  for a in A:
    ap, mp = a
    down = max(0, i - ap)
    dp[i] = min(dp[i], min(dp[down:i]) + mp)
      
print(dp[H])

### FIXED CODE ###

from math import ceil
H,N = list(map(int, input().split()))
A = []
for _ in range(N):
  A.append(list(map(int, input().split())))
  
# 1回iを使ってから、のこりをjで仕留める、を全探索でよい気がする
# だめだった

# dp[i] : HPをi減らすために必要なmin魔力
dp = [1e9] * (10010)
dp[0] = 0
for i in range(1,H+1):
  for a in A:
    ap, mp = a
    down = max(0, i - ap)
    dp[i] = min(dp[i], dp[down] + mp)
      
print(min(dp[H:]))
### BUGGY CODE ###

A, B, K = map(int, input().split())
ab = [i for i in range(A,B+1)]
if A-B > 200:
    for x in (ab[:K] + ab[-K:]):
        print(x)
else:
    for x in sorted(list(set(ab[:K] + ab[-K:]))):
        print(x)

### FIXED CODE ###

A, B, K = map(int, input().split())
a = [i for i in range(A, min(A+K,B))]
b = [i for i in range(max(A,B-K+1), B+1)]

for x in sorted(list(set(a + b))):
    print(x)
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
for i in range(q):
	l,r=map(int,input().split())
	print(s[l-1:r].count('AC'))

### FIXED CODE ###

def resolve():
	n,q=map(int,input().split())
	s=input()
	lr=[list(map(int,input().split())) for i in range(q)]

	t=[0]*(n+1)
	for i in range(n):
		t[i+1]=t[i]+(s[i:i+2]=='AC')
	
	for i in range(q):
		l=lr[i][0]
		r=lr[i][1]

		print(t[r-1]-t[l-1])
resolve()
### BUGGY CODE ###

from itertools import permutations

def floyd_warshall():
            for k in range(N):
                for i in range(N):
                    for j in range(N):
                        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

            
N, M, R = list(map(int, input().split()))
r = (int(i)-1 for i in input().split())
res = float('inf')
dist = [[float("inf")] * N for i in range(N)]
for i in range(N):
        dist[i][i] = 0
for i in range(M):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    dist[a][b] = dist[b][a] = c

floyd_warshall()
for p in permutations(r):
        s = 0
        for i in range(R - 1):
            s += dist[p[i]][p[i + 1]]
        if s < res:
            res = s
print(res)

### FIXED CODE ###

import sys
from itertools import permutations

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

 
def main():
    def floyd_warshall():
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    dd = d[i][k] + d[k][j]
                    if dd < d[i][j]:
                        d[i][j] = dd
 
    n, m, r = read_int_list()
    v = read_int_list()
    v = [x - 1 for x in v]
    d = [[float('inf')] * n for i in range(n)]
    for i in range(n):
        d[i][i] = 0
    for i in range(m):
        a, b, c = read_int_list()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c
    floyd_warshall()
    res = float('inf')
    for p in permutations(v):
        s = 0
        for i in range(r - 1):
            s += d[p[i]][p[i + 1]]
        if s < res:
            res = s
    print(res)
 
 
main()
### BUGGY CODE ###

n = int(input())
dic ={}
for i in range(n):
    key = input()
    if key not in dic:
        dic[key] = 1
    if key in dic:
        dic[key] += 1
res = sorted(list(filter(lambda key:dic[key]==max(dic.values()),list(dic))))
for key in res:
    print(key)

### FIXED CODE ###

n = int(input())
dic ={}
for i in range(n):
    key = input()
    if key not in dic:
        dic[key] = 1
    if key in dic:
        dic[key] += 1
max_v = max(dic.values())
res = sorted(list(filter(lambda key:dic[key]==max_v,list(dic))))
for key in res:
    print(key)
### 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()))
b = [0]*n
for i in a:
  b[i-1]+=1
for i in b:
  print(i)
### BUGGY CODE ###

k,s=map(int,input().split())
cnt=0
for l in range(k+1):
    for m in range(k+1):
        for n in range(k+1):
            if l+m+n==s and l<=k and m<=k and n<=k:
                cnt+=1
                #print(l,m,n)
print(cnt)

### FIXED CODE ###

k,s=map(int,input().split())
cnt=0
for l in range(k+1):
    for m in range(k+1):
        #2つが定まるともう一つの値は一意に定まる
        if 0<=s-l-m and s-l-m<=k:
            cnt+=1
            #print(l,m,n)
print(cnt)