Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    import bisect
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    lx = [x for x in range(k)]
    for i in range(k):
        for j in range(k):
            if s-i-j >= 0:
                index = bisect.bisect_right(lx, s-i-j)-1
                if i+j+index == s and index <= k:
                    cnt += 1
    print(cnt)
resolve()

Fixed submission:
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if 0 <= s-i-j <= k:
                cnt += 1
            elif s-i-j < 0:
                break
    print(cnt)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    import bisect
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    for i in range(k):
        for j in range(k):
            if s-i-j >= 0:
                index = bisect.bisect_right([x for x in range(k)], s-i-j)-1
                if i+j+index == s and index <= k:
                    cnt += 1
    print(cnt)
resolve()

Fixed submission:
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if 0 <= s-i-j <= k:
                cnt += 1
            elif s-i-j < 0:
                break
    print(cnt)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    for i in range(k):
        if i > s:
            break
        for j in range(i, k):
            if i + j > s:
                break
            for x in range(j, k):
                if i + j + x == s:
                    if i != j and j != x and x != i:
                        cnt += 6
                    elif i == j and j == x:
                        cnt += 1
                    else:
                        cnt += 3
                elif i + j + x > s:
                    break
    print(cnt)
resolve()

Fixed submission:
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if 0 <= s-i-j <= k:
                cnt += 1
            elif s-i-j < 0:
                break
    print(cnt)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    for i in range(k):
        if i > s:
            break
        for j in range(k):
            if i+j > s:
                break
            for l in range(k):
                if i+j+l == s:
                    cnt += 1
                elif i+j+l > s:
                    break
    print(cnt)
resolve()

Fixed submission:
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if 0 <= s-i-j <= k:
                cnt += 1
            elif s-i-j < 0:
                break
    print(cnt)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    k += 1
    for i in range(k):
        for j in range(k):
            for l in range(k):
                if i+j+l == s:
                    cnt += 1
    print(cnt)
resolve()

Fixed submission:
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if 0 <= s-i-j <= k:
                cnt += 1
            elif s-i-j < 0:
                break
    print(cnt)
resolve()