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

import math

def eratosthenes(r):
    prime_list = [i for i in (2, 3, 5) if i <= r]

    candidates = [i for i in range(2, r+1) if i % 2 and i % 3 and i % 5]
    while len(candidates):
        prime_list.append(candidates[0])
        candidates = [i for i in candidates[1:] if i % candidates[0]]
    return prime_list

def prime_decomposition(n):
    i = 2
    table = 0
    while i * i <= n:
        while n % i == 0:
            n /= i
            table += 1
        i += 1
    if n > 1:
        table += 1
    return table

def is_prime(n):
    return prime_decomposition(n) == 1

def similer_number_2017(l, r):
    # similar_numbers = []
    # for p in eratosthenes(l, r):
    #     if is_prime(int((p+1)/2)):
    #         similar_numbers.append(p)
    # return similar_numbers
    similar_num = 0
    multi = set()
    for i in range(max(l,2), r+1):
        if i in multi:
            continue
        if is_prime(i) and is_prime((i+1)/2):
            similar_num += 1
        multi.update([x for x in range(i, r+1, i)])
    return similar_num
    

Q = int(raw_input())
query = [map(int, raw_input().split(' ')) for _ in range(Q)]

for l, r in query:
    print similer_number_2017(l, r)




### FIXED CODE ###

Q = int(raw_input())
query = [map(int, raw_input().split(' ')) for _ in range(Q)]

composite_number = [False] * (100001)
for i in range(2, 100001):
    if not composite_number[i]:
        for j in range(i+i, 100001, i):
            composite_number[j] = True
    
similar_number = [0] * 100001
for i in range(3, 100001, 2):
    if not composite_number[i] and not composite_number[(i+1)/2]:
        similar_number[i] += 1

for i in range(3, 100001):
    similar_number[i] += similar_number[i-1]

for l, r in query:
    print similar_number[r] - similar_number[l-1]
### BUGGY CODE ###

n,m=map(int,input().split())
A=list(map(int,input().split()))
for i in range(m):

    b,c=map(int,input().split())
    A += [c]*b
print(sum(sorted(A,reverse=True)[:n]))

### FIXED CODE ###

n,m=map(int,input().split())
A=list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]
bc = sorted(bc,key=lambda x:-x[1])

sub = []
for i in range(m):
   sub += [bc[i][1]] * bc[i][0]
   if len(sub) > n:
       break

A += sub

print(sum(sorted(A,reverse=True)[:n]))
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def sizes(self):
        return [self.size(i) for i in self.roots()]

N, M = map(int,input().split())
UFT = UnionFind(N)
bridges = []
for _ in range(M):
    bridges.append(list(map(int,input().split())))
bridges.reverse()

ans = []
for A, B in bridges:
    UFT.union(A-1, B-1)
    cnt = 0
    for i in UFT.sizes():
        cnt += (i*(i-1)) // 2
    ans.append(cnt)

ALL = N*(N-1)//2
ans = list(map(lambda x: ALL - x, ans))
ans.reverse()
ans.append(ALL)
for i in range(1,M+1):
    print(ans[i])

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

N, M = map(int,input().split())
UFT = UnionFind(N)
bridges = []
for _ in range(M):
    A, B = map(int,input().split())
    bridges.append((A-1, B-1))
bridges.reverse()

ans = [N * (N-1) // 2]
for i in range(M-1):
    temp = ans[-1]
    A, B = bridges[i]
    if not UFT.same(A, B):
        temp -= UFT.size(A) * UFT.size(B)
        UFT.union(A, B)
    ans.append(temp)

ans.reverse()
for a in ans:
    print(a)
### BUGGY CODE ###

s = input()
slen = len(s)
ans = 0

for i in range(len(s)):
  sub = s
  s = s.replace("01",'').strip()
  s = s.replace("10",'').strip()
  if sub == s:
    break
  

print(slen-len(s))



### FIXED CODE ###

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

s=[*input()]
n1=[*'01']
n2=[*'10']
judge=True
max_length=len(s)
while judge:
  judge = False
  length = len(s)
  for i in range(1,length):
    if s[i-1:i+1]==n1 or s[i-1:i+1]==n2:
      del s[i]
      del s[i-1]
      i+=2
      judge = True
print(max_length-len(s))

### FIXED CODE ###

s=[*input()];print(2*min(s.count('0'),s.count('1')))
### BUGGY CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        select_list = []
        for j in range(K):
            select_list.append(p[i+j])

answer = 0
for i in select_list:
    for pro in range(i):
        answer += (pro+1)*(1/i)
print(answer)

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
start = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        start = i

answer = 0
for i in range(K):
    answer += (1+p[start+i])/2
print(answer)
### BUGGY CODE ###

# E - This Message Will Self-Destruct in 5s

N = int(input())
A = list(int(x) for x in input().split())

ans = 0
for i in range(N):
    for j in range(i+A[i]+1,N):
        if j-i==A[i]+A[j]:
            ans += 1

print(ans)

### FIXED CODE ###

# E - This Message Will Self-Destruct in 5s
from collections import defaultdict

N = int(input())
A = list(int(x) for x in input().split())

di = defaultdict(int)
for i in range(N):
    di[i+1+A[i]] += 1

dj = defaultdict(int)
for j in range(N):
    dj[j+1-A[j]] += 1

ans = 0
for k, v in di.items():
    ans += v * dj.get(k,0)
print(ans)
### BUGGY CODE ###

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

sum=1

for i in range(k-1):
    sum*=a[i]

hoge=[0 for i in range(n)]

for i in range(k-1,n):
    sum*=a[i]
    hoge[i]=sum
    sum=sum//a[i-k+1]

for i in range(k,n):
    #print(hoge[i-1],hoge[i],end=" ")
    if hoge[i-1]<hoge[i]:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

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


for i in range(k,n):
    #print(hoge[i-1],hoge[i],end=" ")
    if a[i-k]<a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N = int(input())
cnt = 0
for A in range(1, N + 1):
	for B in range(1, N + 1):
		C = N - A * B
		if C >= 1 and A * B + C == N:
			cnt += 1
print(cnt)


### FIXED CODE ###

N = int(input())
cnt = 0
for A in range(1, N + 1):
	for B in range(1, N // A + 1):
		C = N - A * B
		if C >= 1 and A * B + C == N:
			cnt += 1
print(cnt)
### BUGGY CODE ###

import sys

input = sys.stdin.readline
import fractions



def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    MOD = 10 ** 9 + 7

    x = 1
    for a in A:
        x = (a * x) // fractions.gcd(a, x)

    ans = 0
    for a in A:
        ans %= MOD
        ans += x // a

    print(ans % MOD)



    
    

if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys

input = sys.stdin.readline
import fractions



def main():
    N = int(input())
    A = tuple([int(x) for x in input().split()])
    MOD = 10 ** 9 + 7

    x = 1
    for a in A:
        x = (a * x) // fractions.gcd(a, x)

    ans = 0
    for a in A:
        ans += x // a

    print(ans % MOD)



    
    

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

from collections import defaultdict


class UnionFind:
    def __init__(self, nodes):
        self.sets = {n: None for n in nodes}

    def find(self, a):
        curr = a
        while self.sets[curr] is not None:
            curr = self.sets[curr]
        return curr

    def connected(self, a, b):
        return self.find(a) == self.find(b)

    def union(self, a, b):
        rootA = self.find(a)
        rootB = self.find(b)

        if rootA != rootB:
            self.sets[rootB] = rootA


if __name__ == '__main__':
    n, m, k = tuple([int(s) for s in input().split()])
    users = [i for i in range(1, n + 1)]
    uf = UnionFind(users)

    friendships = defaultdict(set)
    blockships = defaultdict(set)

    for i in range(m):
        a, b = tuple([int(s) for s in input().split()])
        friendships[a].add(b)
        friendships[b].add(a)
        uf.union(a, b)
    for i in range(k):
        a, b = tuple([int(s) for s in input().split()])
        blockships[a].add(b)
        blockships[b].add(a)

    res = [0] * n
    for i in range(n - 1):
        for j in range(i + 1, n):
            a = i + 1
            b = j + 1

            if uf.connected(a, b) and b not in friendships[a] and b not in blockships[a]:
                res[i] += 1
                res[j] += 1

    print(" ".join([str(u) for u in res]))


### FIXED CODE ###

class UnionFind:
    def __init__(self, nodes):
        self.sets = [None] * len(nodes)
        self.sizes = [1] * len(nodes)

    def find(self, a):
        curr = a
        path = []
        while self.sets[curr] is not None:
            path.append(curr)
            curr = self.sets[curr]

        for node in path:
            self.sets[node] = curr
        return curr

    def connected(self, a, b):
        return self.find(a) == self.find(b)

    def union(self, a, b):
        rootA = self.find(a)
        rootB = self.find(b)

        if rootA != rootB:
            self.sets[rootB] = rootA
            self.sizes[rootA] += self.sizes[rootB]

    def size(self, a):
        root = self.find(a)
        return self.sizes[root]


if __name__ == '__main__':
    n, m, k = tuple([int(s) for s in input().split()])
    users = [None] * n
    uf = UnionFind(users)

    friendships = [0 for i in range(n)]
    blockships = [0 for i in range(n)]

    for i in range(m):
        a, b = tuple([int(s) for s in input().split()])
        a -= 1
        b -= 1
        friendships[a] += 1
        friendships[b] += 1
        uf.union(a, b)
        uf.find(a)
        uf.find(b)
    for i in range(k):
        a, b = tuple([int(s) for s in input().split()])
        a -= 1
        b -= 1
        if uf.connected(a, b):
            blockships[a] += 1
            blockships[b] += 1

    res = [0] * n
    for i in range(n):
        all_connections = uf.size(i)
        existing = friendships[i]
        blocked = blockships[i]
        res[i] = all_connections - 1 - existing - blocked

    print(" ".join([str(u) for u in res]))
### BUGGY CODE ###

N = int(input())
li = []
for i in range(N):
    A = int(input())
    if A not in li:
        li.append(A)
    elif A in li:
        li.remove(A)
print(len(li))

### FIXED CODE ###

import collections as co
N = int(input())
A = [int(input()) for i in range(N)]
c = co.Counter(A)
count = 0
for a,b in c.most_common():
    if b%2==1:
        count += 1
print(count)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
N,K=map(int,input().split())
H=list(map(int,input().split()))

dp=[10**9]*N
dp[0]=0

for i in range(N):
    for k in range(1,K+1):
        if i+k<N:
            dp[i+k]=min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
    
    
print(dp[-1])

### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
input=sys.stdin.readline

N,K=map(int,input().split())
l=list(map(int,input().split()))

dp=[float('inf')]*(N)

dp[0]=0
for i in range(1,N):
    
    for j in range(1,min(i,K)+1):

        dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))

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

s = str(input())
t= str(input())

sdict = {}
for i in range(len(s)):
    if s[i] not in sdict:
        sdict[s[i]]=[]
    sdict[s[i]].append(i+1)
    
#print(sdict)

#二分木探索
def search(list_,mark_,sta,gol):
    if  sta == gol:
            return list_[sta]
    else:
            mid = (gol+sta)//2
            if list_[mid]>mark_:
                return search(list_,mark_,sta,mid)
            else:
                return search(list_,mark_,mid+1,gol)

ans = 0
mark = 0
for _ in range(len(t)):
    target = t[_]
    if target not in sdict:
        ans = -1
        break
    else:
        if sdict[target][-1]<=mark:
            mark = sdict[target][0]
            ans += len(s)
        else:
            posi = search(sdict[target],mark,0,len(sdict[target])-1)
            mark = posi
        
if ans != -1:
    ans += mark
print(ans)


### FIXED CODE ###

s = str(input())
t= str(input())

sdict = {}
for i in range(len(s)):
    if s[i] not in sdict:
        sdict[s[i]]=[]
    sdict[s[i]].append(i+1)
    
#print(sdict)

#二分木探索
def search(list_,mark_,sta,gol):
    if  sta == gol:
            return list_[sta]
    else:
            mid = (gol+sta)//2
            if list_[mid]>mark_:
                return search(list_,mark_,sta,mid)
            else:
                return search(list_,mark_,mid+1,gol)

ans = 0
mark = 0
for _ in range(len(t)):
    target = t[_]
    if target not in sdict:
        ans = -1
        break
    else:
        if sdict[target][-1]<=mark:
            mark = sdict[target][0]
            ans += len(s)
        elif sdict[target][0]>mark:
            mark = sdict[target][0]
        else:
            posi = search(sdict[target],mark,0,len(sdict[target])-1)
            mark = posi
        
if ans != -1:
    ans += mark
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
dp=[0]*(n+2)
dp[n]=1
for i in range(n-1,-1,-1):
    if i in a:
        dp[i]=0
    else:
        dp[i]=(dp[i+1]+dp[i+2])%mod
print(dp[0])


### FIXED CODE ###

n,m=map(int,input().split())
a=set(int(input()) for _ in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:
        dp[i]=0
print(dp[n])
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
print(0)
check = readline().rstrip().decode()
if check == 'Vacant':
    exit()
print(n - 1)
memo = readline().rstrip().decode()
if memo == 'Vacant':
    exit()
low = 0
high = n - 1
while low + 1 < high:
    mid = (low + high) // 2
    print(mid)
    s = readline().rstrip().decode()
    if s == 'Vacant':
        exit()
    if (mid - low) % 2:
        if check == s:
            high = mid
        else:
            check = s
            high = mid
    else:
        if check != s:
            low = mid
            check = s
        else:
            high = mid


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())


def q(i):
    print(i)
    r = input()[0]
    if r == 'V':
        exit()
    return r


z = q(0)


def is_ok(k):
    s = q(k)
    if k % 2:
        return z != s
    else:
        return z == s


ok = 0
ng = n
while ng - ok > 1:
    m = (ok + ng) // 2
    if is_ok(m):
        ok = m
    else:
        ng = m
### BUGGY CODE ###

a = input()
a, b = a.split(' ')
a = int(a)
b = int(b)

while a >= b:
    a -= b

if a < 0:
    a *= -1

b -= a

print(a if a < b else b)


### FIXED CODE ###

a = input()
a, b = a.split(' ')
a = int(a)
b = int(b)

a = a % b

print(a if a < b - a else b - a)
### BUGGY CODE ###

#coding : utf-8

import os
import sys

def except_i(a, i):
	return a[0:i] + a[i+1:len(a)]

N = int(input())

A = []

for i in range(N):
	A.append(int(input()))


for i in range(N):
	t = A[i]
	A[i] = 0
	print(max(A))
	A[i] = t



### FIXED CODE ###

#coding : utf-8

import os
import sys

N = int(input())

A = []

for i in range(N):
	A.append(int(input()))

X = [[A[i], i] for i in range(N)]


X.sort(key = lambda x: x[0], reverse=True)


for i in range(N):
	if i != X[0][1]:
		print(X[0][0])
	else:
		print(X[1][0])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
s = list(input())

from collections import defaultdict
ans = defaultdict(int)
def dfs(now, pos):
    if len(now) == 3:
        ans[now] = 1
        return
    if pos == n:
        return
    dfs(now+s[pos], pos+1)
    if ans[now] == 0:
        dfs(now, pos+1)
    ans[now] = 1

dfs("", 0)

anss = 0
for v,i in ans.items():
    if len(str(v)) == 3:
        anss += i

print(anss)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
s = list(input())

ans = 0
num = [str(i) for i in range(10)]
for i in num:
    for l in range(n):
        if s[l] == i:
            for j in num:
                for m in range(l+1,n):
                    if s[m] == j:
                        for k in num:
                            for p in range(m+1, n):
                                if s[p] == k:
                                    ans += 1
                                    break
                            continue
                        break
            break

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

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

l = [[0 for i in range(w)] for j in range(h)]
for _ in range(n):
   a,b = map(int,input().split())
   l[a-1][b-1] += 1


#da[i][j]:(0,0)~(i,j)の長方形の和
def da_generate(h,w,a):
    da = [[0]*w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1,w):
        da[0][i] = da[0][i-1]+a[0][i]
    for i in range(1,h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i-1][j]+cnt_w
    return da

#da_calc(p,q,x,y):(p,q)~(x,y)の長方形の和
def da_calc(p,q,x,y,da):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y]-da[x][q-1]
    if q == 0:
        return da[x][y]-da[p-1][y]
    return da[x][y]-da[p-1][y]-da[x][q-1]+da[p-1][q-1]

da = da_generate(h,w,l)
from collections import defaultdict
dic = defaultdict(int)
for i in range(h-2):
   for j in range(w-2):
      dic[da_calc(i, j, i+2, j+2, da)] += 1
   
for i in range(10):
   print(dic[i])

### FIXED CODE ###

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

from collections import defaultdict
dic = defaultdict(int)
for _ in range(n):
   a,b = map(int,input().split())
   a -= 1
   b -= 1
   for aa in range(a-1, a+2):
      for bb in range(b-1, b+2):
         if 1 <= aa <= h-2 and 1 <= bb <= w-2:
            dic[(aa,bb)] += 1
ans = [0 for i in range(10)]
for i in dic.values():
   ans[i] += 1

ans[0] = (h-2)*(w-2) - sum([ans[i] for i in range(1,10)])

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

import numpy as np

N,K,Q = map(int,input().split())
ps = [K]*N
ps = np.array(ps[:])

ac = []
for i in range(Q):
    an = int(input())
    ps[an -1] += 1
    ps = ps - 1
    
for k in ps:
    if k > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n, k, q = map(int, input().split())
n_score = [0] * n
for i in range(q):
    n_score[int(input()) - 1] += 1

for j in n_score:
    if k + j - q > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
m=10**9+7
bo=[0]*61
bz=[0]*61
for i in a:
  t=format(i,'061b')
  for j in range(61):
    if t[j]=='0':
      bz[j]+=1
    else:
      bo[j]+=1
bo=bo[::-1]
bz=bz[::-1]
x=0
for i in range(61):
  x+=bo[i]*bz[i]*(2**i)
  x%=m
print(x%m)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=10**9+7
bo=[0]*61
bz=[0]*61
for i in a:
  t=format(i,'061b')
  for j in range(61):
    if t[j]=='0':
      bz[j]+=1
    else:
      bo[j]+=1
bo=bo[::-1]
bz=bz[::-1]
x=0
for i in range(61):
  x+=bo[i]*bz[i]*(2**i)
  x%=m
print(x%m)
### BUGGY CODE ###

a = int(input())
data = []
ans = 0
flag = 1
for i in range(a):
  tar = input()
  for j in data:
    if tar == j:
      flag = 0
  if flag:
    ans += 1
  data.append(tar)
   
  
  
print(ans)
    


### FIXED CODE ###

a = int(input())
data = []
for i in range(a):
  data.append(input())
   
ans = set(data)
print(len(ans))
### BUGGY CODE ###

x, y, z, k = map(int, input().split())
a_s = list(map(int, input().split()))
bs = list(map(int, input().split()))
cs = list(map(int, input().split()))
a_s.sort(reverse=True)
bs.sort(reverse=True)
cs.sort(reverse=True)

list = []
i = 0
flag = True
minlist = 0
for a in a_s:
    if minlist >= (a + bs[0] + cs[0]):
        break
    for b in bs:
        if minlist >= (a + b + cs[0]):
            break
        for c in cs:
            abc = a + b +c
            if flag and i >= k:
                minlist = min(list)
                flag = False
            if minlist >= abc:
                break
            list.append(a + b + c)
            i += 1
list.sort(reverse=True)
for i in range(k):
    print(list[i])


### FIXED 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()))

ab = []
for ai in a:
  for bi in b:
    ab.append(ai + bi)
ab.sort(reverse = True)

abc = []

for abi in ab[:k]:
  for ci in c:
    abc.append(abi + ci)
abc.sort(reverse = True)

for abci in abc[:k]:
  print(abci)
### BUGGY CODE ###

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

T=[]
for z in range(k+1):
    for y in range(k+1):
        for x in range(k+1):
            T.append(x+y+z)
print(T.count(s))
            

### FIXED CODE ###

k,s = map(int, input().split())
print(len([s-y-z for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))