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

#線分交差問題

import bisect

class BIT:
    def __init__(self, n):
        self.tree = [0]*(n+1)
        self.n = n
    
    def add(self, i, v):
        while i <= self.n:
            self.tree[i] += v
            i += i & -i
        
    
    def _sum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i -= i & -i
        return ret
    
    def sum(self, l, h):
        return self._sum(h) - self._sum(l-1)
    
n = int(input())
vx = []
xs = set()
for _ in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if x1 == x2:
        if y1 > y2:
            y1, y2 = y2, y1
        vx.append((y1, float('-inf'),x1))
        vx.append((y2, float('inf'),x2))
        xs.add(x1)
    else:
        if x1 > x2:
            x1, x2 = x2, x1
        vx.append((y1, x1, x2))
vx.sort()

bit = BIT(len(xs))
xs = [float('-inf')] + sorted(xs)
ix = {v: i for i, v in enumerate(xs)}
ans = 0

for y, j, x2 in vx:
    if j == float('-inf'):
        bit.add(ix[x2],1)
    elif j == float('inf'):
        bit.add(xs.index(x2), -1)
    else:
        l = bisect.bisect_left(xs, j)
        r = bisect.bisect(xs, x2) - 1
        ans += bit.sum(l, r)
        
print(ans)



### FIXED CODE ###

#線分交差問題

import bisect

class BIT:
    def __init__(self, n):
        self.tree = [0]*(n+1)
        self.n = n
    
    def add(self, i, v):
        while i <= self.n:
            self.tree[i] += v
            i += i & -i
        
    
    def _sum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i -= i & -i
        return ret
    
    def sum(self, l, h):
        return self._sum(h) - self._sum(l-1)
    
n = int(input())
vx = []
xs = set()
for _ in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if x1 == x2:
        if y1 > y2:
            y1, y2 = y2, y1
        vx.append((y1, float('-inf'),x1))
        vx.append((y2, float('inf'),x2))
        xs.add(x1)
    else:
        if x1 > x2:
            x1, x2 = x2, x1
        vx.append((y1, x1, x2))
vx.sort()

bit = BIT(len(xs))
xs = [float('-inf')] + sorted(xs)
ix = {v: i for i, v in enumerate(xs)}
ans = 0

for y, j, x2 in vx:
    if j == float('-inf'):
        bit.add(ix[x2],1)
    elif j == float('inf'):
        bit.add(ix[x2], -1)
    else:
        l = bisect.bisect_left(xs, j)
        r = bisect.bisect(xs, x2) - 1
        ans += bit.sum(l, r)
        
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
a = list(map(int, input().split()))
for k in range(N):
  a[k] //= 2


count = 0
foo = 1

while a[0]%2 == 0:
  foo *= 2
  a[0] // 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

for odd in [3, 5, 7, 11]:
  flag = False
  for k in range(N):
    if a[k]%odd == 0:
      a[k] //= odd
      flag = True
  if flag:
    foo *= odd

def euclid(a, b):
  while b:
    a, b = b, a%b
  return a

lcm = a[0]
for k in range(1, N):
  lcm = lcm * a[k] // euclid(lcm, a[k])
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
a = list(map(int, input().split()))
for k in range(N):
  a[k] //= 2

foo = 1
while a[0]%2 == 0:
  foo *= 2
  a[0] //= 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

import math
lcm = a.pop()
for k in range(1, N):
  b = a.pop()
  lcm = lcm * b // math.gcd(lcm, b)
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)
### BUGGY CODE ###

r,g,b,n=map(int,input().split())

rr=n//r+1
gg=n//g+1
bb=n//b+1
ans=0
for i in range(rr):
  for j in range(gg):
    for k in range(bb):
      if i*r+j*g+k*b==n:
        ans+=1
print(ans)

### FIXED CODE ###

r,g,b,n=map(int,input().split())

rr=n//r+1
gg=n//g+1
bb=n//b+1
ans=0
for i in range(rr):
  for j in range(gg):
    x=i*r+j*g
    if (x>n):
      break
    if (n-x)%b==0:
      ans+=1
print(ans)
### BUGGY CODE ###

def sieve_of_eratosthenes(n): #エラトステネスのふるい
    candidate = list(range(2, n+1)) #候補
    prime = []
    limit = n**0.5 + 1 #+1がないと平方数を素数にしてしまう

    while True:
        p = candidate[0]
        if limit <= p:
            prime.extend(candidate) #この時点での残っているのは素数
            break
        prime.append(p) #pを素数リストに登録

        candidate = [i for i in candidate if i % p != 0]

        # i = 0
        # while True:
            # if i >= len(candidate): #iはcandidateの長さ分
                # break
            # elif candidate[i] % p == 0: #余りがゼロなら
                # candidate.pop(i) #素数ではないのでpop(取り除く)する
            # i += 1

    return prime

def factorization(n,plist):
    arr = []
    temp = n
    for i in plist: #range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#print(factorization(24)) #[[2, 3], [3, 1]]

N=int(input())
if N==1:
    print(1)
else:
    plist=sieve_of_eratosthenes(10000)
    sum=0
    for i in range(2,N+1):
        temp=1
        arr=factorization(i,plist)
        for j in range(len(arr)):
            temp*=arr[j][1]+1
        temp*=i
        sum+=temp
        #print(temp)
    print(1+sum)

### FIXED CODE ###

N=int(input())
sum=0
for j in range(1,N+1):
    sum+=((N//j)*(N//j+1)//2)*j
print(sum)
### BUGGY CODE ###

S = input()
K = int(input())
sub = []
for i in range(1,len(S)+1):
  for j in range(len(S)-i+1):
    sub.append(S[j:j+i])
sub = sorted(set(sub))    
print(sub[K-1])

### FIXED CODE ###

S = input()
K = int(input())
sub = []
for i in range(len(S)):
  range = 1
  while range < K + 1 and len(S) >= (i + range):
    sub.append(S[i:i+range])
    range += 1
sub = sorted(set(sub))
print(sub[K-1])
### BUGGY CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[10]:


N = int(input())
s = []
for _ in range(N):
    s.append(input())


# In[11]:


ans = 0
for i in range(N-1):
    myset = set(s[i])
    for j in range(i+1,N):
        for x in myset:
            if s[i].count(x) != s[j].count(x):
                break
        else:
            ans += 1
print(ans)


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[12]:


import collections


# In[10]:


N = int(input())
s = []
for _ in range(N):
    s.append(input())


# In[30]:


ans = 0
mydict = {}
for i in range(N):
    tmp = "".join(sorted(s[i]))
    if tmp not in mydict:
        mydict[tmp] = 1
    else:
        ans += mydict[tmp]
        mydict[tmp] += 1
print(ans)
### BUGGY CODE ###

I = lambda: map(int, input().split())
n, m = I()
bridges = [list(I()) for _ in range(m)][1:]
sets = [{i} for i in range(n+1)]
cnt = n*(n-1)//2
cnts = [cnt]
for a, b in bridges[::-1]:
    set_a, set_b = sets[a], sets[b]
    set_c = set_a|set_b
    cnt -= len(set_a)*len(set_c-set_a)
    cnts += cnt,
    for i in set_c:
        sets[i] = set_c
print(*cnts[::-1])

### FIXED CODE ###

I = lambda: map(int, input().split())
n, m = I()
A = [list(I()) for _ in range(m)][1:]
B = [-1]*(n+1)
c = n*(n-1)//2
C = [c]
f = lambda x: x if B[x] < 0 else f(B[x])
for a, b in A[::-1]:
    a, b = sorted([f(a), f(b)])
    if a != b:
        c -= B[a]*B[b]
        B[a] += B[b]
        B[b] = a
    C += c,
print(*C[::-1])
### BUGGY CODE ###

import sys
from bisect import bisect, bisect_left

class RMQ(): #range minimum query
    def __init__(self, N, V): #create segment tree with initial value V
        self.size = 1
        while self.size < N:
            self.size <<= 1
        self.tree = [V] * (2 * self.size - 1)
    
    def update(self, i, a): #update cell i by value a
        now = self.size - 1 + i 
        self.tree[now] = a
        while now > 0:
            now = (now - 1) // 2
            self.tree[now] = max(self.tree[2 * now + 1], self.tree[2 * now + 2])

    def search(self, lower, higher, lbound, hbound, pos): #search minimum value of [lower, higher) init: lbound = 0, hbound = self.size, pos = 0
        if higher <= lbound or hbound <= lower: return 0
        if lower <= lbound and hbound <= higher: return self.tree[pos]
        else:
            left = self.search(lower, higher, lbound, (lbound + hbound) // 2, 2 * pos + 1)
            right = self.search(lower, higher, (lbound + hbound) // 2, hbound, 2 * pos + 2)
            return max(left, right)

def solve():
    input = sys.stdin.readline
    N = int(input())
    R = [[int(i) for i in input().split()] for _ in range(N)]
    R.sort()
    mod = 998244353
    X = [R[i][0] for i in range(N)]
    Connect = RMQ(N, 0)
    DP = [1] * (N + 1)
    for i in reversed(range(N)):
        right = max(i, Connect.search(i, bisect_left(X, sum(R[i])), 0, Connect.size, 0))
        Connect.update(i, right)
        DP[i] = (DP[right + 1] + DP[i + 1]) % mod
    print(DP[0])
    

    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys
from bisect import bisect, bisect_left

class SquareDiv(): #区間の最大値を求める
    def __init__(self, N, V):
        k = 1
        while k ** 2 < N: k += 1
        self.array = [V] * k
        self.size = k
        self.indivisual = [V] * N

    def update(self, i, v): #i番目をvに更新する
        self.indivisual[i] = v
        self.array[i // self.size] = max(self.array[i // self.size], v)

    def search(self, left, right): #[left, right]の最大値を求める
        lk, rk = left // self.size, right // self.size
        if lk == rk:
            maxN = 0
            for i in range(left, right + 1): maxN = max(maxN, self.indivisual[i])
            return maxN
        else:
            maxN = self.search(left, (lk + 1) * self.size - 1)
            for k in range(lk + 1, rk): maxN = max(maxN, self.array[k])
            maxN = max(maxN, self.search(rk * self.size, right))
            return maxN

def solve():
    input = sys.stdin.readline
    N = int(input())
    R = [[int(i) for i in input().split()] for _ in range(N)]
    R.sort()
    mod = 998244353
    X = [R[i][0] for i in range(N)]
    Connect = SquareDiv(N, 0)
    DP = dict()
    DP[N] = 1
    for i in reversed(range(N)):
        right = max(i, Connect.search(i, bisect_left(X, sum(R[i])) - 1))
        Connect.update(i, right)
        DP[i] = (DP[right + 1] + DP[i + 1]) % mod
    print(DP[0])
    

    return 0

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

from collections import deque


H, W = map(int, input().split())
A = [list('#' * (W + 2))]
q = deque()
A_append = A.append
q_append = q.append
for _ in range(H):
    a = input()
    A_append(list('#' + a + '#'))
A.append(list('#' * (W + 2)))
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if A[i][j] == '#':
            q_append([i, j, 0])

ans = 0

while len(q) != 0:
    p = q.popleft()
    for k in range(4):
        y = p[0] + dy[k]
        x = p[1] + dx[k]
        c = p[2]
        ans = max(ans, c)
        if A[y][x] == '.':
            A[y][x] = '#'
            q_append([y, x, c + 1])

print(ans)


### FIXED CODE ###

from collections import deque


H, W = map(int, input().split())
A = [list('#' * (W + 2))]
q = deque()
A_append = A.append
q_append = q.append
for _ in range(H):
    a = input()
    A_append(list('#' + a + '#'))
A.append(list('#' * (W + 2)))
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if A[i][j] == '#':
            q_append([i, j, 0])

ans = 0

while len(q) != 0:
    p = q.popleft()
    for k in range(4):
        y = p[0] + dy[k]
        x = p[1] + dx[k]
        c = p[2]
        ans = max(ans, c)
        if A[y][x] == '.':
            A[y][x] = '#'
            q_append([y, x, c + 1])

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

n = int(input())
ln = []
for k in range(1,n+1):
    if n % k == 0:
        ln.append(k)
if not n**0.5 % 1 == 0:
    i = ln[len(ln) // 2 - 1]
    j = ln[len(ln) // 2]
    ans = i + j -2
else:
    ans = int(2*n**0.5)-2
print(ans)

### FIXED CODE ###

n = int(input())
ln = []
for k in range(1,(int(n**0.5))+1):
    if n % k == 0:
        ln.append(k)
if not n**0.5 % 1 == 0:
    for k in reversed(range(0, len(ln))):
        ln.append(n // ln[k])
else:
    for k in reversed(range(0, len(ln)-1)):
        ln.append(n // ln[k])
if not n**0.5 % 1 == 0:
    i = ln[len(ln) // 2 - 1]
    j = ln[len(ln) // 2]
    ans = i + j -2
else:
    ans = int(2*n**0.5)-2
print(ans)
### BUGGY CODE ###

def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))

    dp = [[0]*n for _ in range(k+1)]
    for i in range(n):
        dp[0][i] = A[i]

    flag = False
    for i in range(1,k+1):
        pos = [0]*n
        neg = [0]*n

        for j in range(n):
            pwr = dp[i-1][j]
            pos[max(0,j-pwr)]+=1
            neg[min(n-1,j+pwr)]+=1

        ac_pos = 0
        ac_neg = 0
        for j in range(n):
            ac_pos += pos[j]
            ac_neg += neg[j]
            pos[j] = ac_pos
            neg[j] = ac_neg

        if pos[0]==n and neg[n-2]==0:
            flag = True
            break

        dp[i][0] = pos[0]
        for j in range(1,n):
            dp[i][j] = pos[j] - neg[j-1]

    
    if flag:
        for j in range(n-1):
            print(n, end=" ")  
        print(n)

    else:
        for j in range(n-1):
            print(dp[i][j], end=" ")
        print(dp[i][n-1])
main()

### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))
    k = min(50,k)

    dp = [[0]*n for _ in range(k+1)]
    for i in range(n):
        dp[0][i] = A[i]

    flag = False
    for i in range(1,k+1):
        pos = [0]*n
        neg = [0]*n

        for j in range(n):
            pwr = dp[i-1][j]
            pos[max(0,j-pwr)]+=1
            neg[min(n-1,j+pwr)]+=1

        ac_pos = 0
        ac_neg = 0
        for j in range(n):
            ac_pos += pos[j]
            ac_neg += neg[j]
            pos[j] = ac_pos
            neg[j] = ac_neg

        if pos[0]==n and neg[n-2]==0:
            flag = True
            break

        dp[i][0] = pos[0]
        for j in range(1,n):
            dp[i][j] = pos[j] - neg[j-1]

    
    if flag:
        for j in range(n-1):
            print(n, end=" ")  
        print(n)

    else:
        for j in range(n-1):
            print(dp[i][j], end=" ")
        print(dp[i][n-1])
main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n,m=map(int,input().split())
root=[-1]*(n+1)
def r(x):
    if root[x]<0:
        return x
    else:

        return r(root[x])
def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if x>y:
        x,y=y,x

    root[x]+=root[y]
    root[y]=x
def size(x):
    x=r(x)
    return -root[x]
for i in range(m):
    x,y=map(int,input().split())

    unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,size(i+1))
print(ans)







### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
root=[-1]*n
def r(x):
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]
def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    root[x]+=root[y]
    root[y]=x
def size(x):
    x=r(x)
    return -root[x]
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,size(i))
print(ans)
### BUGGY CODE ###

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

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

m=max(A)
for i in range(N):

    for j in range(N-i-A[i]):
        k=i+j+A[i]

        if A[i]+A[k]==k-i:
            count = count+1
            #print("{} {}".format(i+1,k+1))
        if A[i]+m+i<k:
            break


print("{}".format(count))


### FIXED CODE ###

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

N = int(input())
A = list(map(int, input().split()))
count=0
L = [0]*N
R = [0]*N
N2=2*N
hash_L=[0]*N2
hash_R=[0]*N2

sheet_L=[0]*N2
sheet_R=[0]*N2
for i in range(N):
    L[i]=A[i]+i+1
    if L[i]<N2:
        if sheet_L[L[i]]==0:
            hash_L[L[i]]=L[i]
            sheet_L[L[i]]=1
        else:
            sheet_L[L[i]]=sheet_L[L[i]]+1

    R[i]=-A[i]+i+1
    if R[i]>0:
        if sheet_R[R[i]]==0:
            hash_R[R[i]]=R[i]
            sheet_R[R[i]]=1
        else:
            sheet_R[R[i]]=sheet_R[R[i]]+1


for i in range(2*N):
    if not hash_L[i]==0:
        if hash_L[i]==hash_R[i]:
            count=count+sheet_L[i]*sheet_R[i]
#print("{}".format(hash_L))
#print("{}".format(hash_R))
print("{}".format(count))
### BUGGY CODE ###

l, r = map(int, input().split())

ans = 2019
for i in range(l, r):
    for j in range(r, l-1, -1):
        if i == j:
            break
        mod = (i * j) % 2019
        if mod < ans:
            ans = mod
    if ans == 0:
        break
print(ans)


### FIXED CODE ###

l, r = map(int, input().split())
ans = 2019

if r-l >= 2018:
    print(0)
else:
    for i in range(l, r):
        for j in range(r, l, -1):
            ans = min(ans, i*j % 2019)
    
    print(ans)
### 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())
a = list(map(int, readline().split()))
mod = 10 ** 9 + 7
bit = [0] * 61
ans = 0
for aa in a:
    for j, check in enumerate(bin(aa)[2:][::-1]):
        if check == '1':
            bit[j] += 1
for i, b in enumerate(bit):
    ans += 2 ** i * (n - b) * b
    ans %= mod
print(ans)


### FIXED CODE ###

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

import numpy as np

n = int(readline())
a = np.array(read().split(), np.int64)
ans = 0
mod = 10 ** 9 + 7
for i in range(63):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    y = n - x
    x *= y
    for j in range(i):
        x *= 2
        x %= mod
    ans += x
print(ans % mod)
### BUGGY CODE ###

def tasu(x):
    return x / 2 * (x + 1)

def kitaiti(n , k , p):

    ans = 0
#    kitai = [0]*n

#    for i in range(n):
#        kitai[i] = tasu(p[i]) / p[i]

    for i in range(n - k + 1):
        count = 0
        for w in range(i , i + k):
#            count += kitai[w]
            count += tasu(p[w]) / p[w]

        ans = max(ans , count)

    return ans

def main():
    n , k = map(int , input().split())
    p = list(map(int,input().split()))
    print(kitaiti(n , k , p))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def tasu(x):
    return x / 2 * (x + 1)

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n
    kitaisum = [0]*n
    mod = 10**9+7

    for i in range(n):
        kitai[i] = tasu(p[i]) / p[i]

    for i in range(n):
        if i == 0:
            kitaisum[i] += kitai[i]
        else:
            kitaisum[i] += kitai[i] + kitaisum[i-1]

    for i in range(n - k + 1):

        ans = max(ans , (kitaisum[i + k - 1] - kitaisum[i-1]) if i != 0 else kitaisum[i + k - 1])

    return ans

def main():
    n , k = map(int , input().split())
    p = list(map(int,input().split()))
    print(kitaiti(n , k , p))

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

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

def iterative_square_method(N, P, M):

    if P == 0:
        return 1
    elif P%2 == 0:
        return (iterative_square_method(N, P//2, M) ** 2) % M
    else:
        return (N * iterative_square_method(N, P-1, M)) % M

def inv_felmat(a, p):
    return iterative_square_method(a, p-2, p)

all = iterative_square_method(2, n, 10**9 + 7) - 1 
tmp1 = 1
tmp2 = 1
for i in range(n-a+1, n+1):
    tmp1 *= i % (10**9 + 7)
for i in range(1, a+1):
    tmp2 *= i % (10**9 + 7)
tmp1 = (tmp1 * inv_felmat(tmp2, 10**9 + 7)) % (10**9 + 7)
tmp3 = 1
tmp4 = 1
for i in range(n-b+1, n+1):
    tmp3 *= i
for i in range(1, b+1):
    tmp4 *= i
tmp3 = (tmp3 * inv_felmat(tmp4, 10**9 + 7)) % (10**9 + 7)

result = all - tmp1 - tmp3
print(result%(10**9 + 7))

### FIXED CODE ###

n, a, b = [int(i) for i in input().split()]
mod = 10**9 + 7
 
total = pow(2, n, mod) - 1
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
 
at = combination(n,a)
bt = combination(n,b)
 
result = total - at - bt
result %= mod
if result < 0:
  result += mod
print(result)
### BUGGY CODE ###

k = int(input())
l = 0
s = [False]*9000000
for i in range(1,9000000):
    l = (l*10+7)%k
    if l == 0:
        print(i)
        exit()
    else:
        if s[i] == True:
            print(-1)
            exit()
        else:
            s[i] = True
print(-1)
exit()

### FIXED CODE ###

k = int(input())
l = 0
s = set()
for i in range(1,9000000):
    l = (l*10+7)%k
    if l == 0:
        print(i)
        exit()
    else:
        s.add(l)
        if len(s) == i-1:
            print(-1)
            exit()
print(-1)
exit()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
lst = []
num = [1]*n
ans = 0
lst_append = lst.append
for i in range(n):
    s = sorted(input())
    s = "".join(s)
    if s not in lst:
        lst_append(s)
    else:
        pos = lst.index(s)
        num[pos] += 1
for j in num:
    ans += (j * (j-1)) / 2
print(int(ans))

### FIXED CODE ###

from collections import defaultdict
N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)
### BUGGY CODE ###

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

check_num = 1
delete_num = 0
while len(aaa) > 0:
  tmp_num = aaa.pop(0)
  if tmp_num == check_num:
    check_num += 1
  else:
    delete_num += 1
    
if delete_num == n:
  print(-1)
else:
  print(delete_num)

### FIXED CODE ###

n = int(input())

check_num = 1
delete_num = 0
for i in input().split():
  i = int(i)
  if i == check_num:
    check_num += 1
  else:
    delete_num += 1

if delete_num == n:
  print(-1)
else:
  print(delete_num)
### BUGGY CODE ###

# coding: utf-8
# Your code here!

maximum, equal = map(int, input().split())
counter = 0

for i in range(maximum + 1):
    for j in range(maximum + 1):
        for k in range(maximum + 1):
            if equal == i + j + k:
                counter += 1

print(counter)


### FIXED CODE ###

# coding: utf-8
# Your code here!

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

for i in range(K + 1):
    for j in range(K + 1):
        if S - (i + j) >= 0 and S - (i + j) <= K:
            counter += 1
print(counter)