Buggy python submission (verdict: Time Limit Exceeded):
limit, sum_xyz = map(int, input().split())

pair = list()

for x in range(limit + 1):
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        else:
            pair.append([x, y, z])
ans = len(pair)

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
 
def main():
    K,S = [int(x) for x in input().split()]
 
    count = 0
 
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            if z >= 0 and z <= K:
                count += 1
 
    print(count)
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
limit, sum_xyz = map(int, input().split())

pair = list()

for x in range(limit + 1):
    y_limit = 0
    for y in range(limit + 1):
        z = sum_xyz - x - y
        if z < 0 or z > limit:
            continue
        pair.append([x, y, z])
ans = len(pair)

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
 
def main():
    K,S = [int(x) for x in input().split()]
 
    count = 0
 
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            if z >= 0 and z <= K:
                count += 1
 
    print(count)
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
limit, sum_xyz = map(int, input().split())

pair = list()
x_bottom = sum_xyz - 2*limit
x_bottom = 0 if x_bottom < 0 else x_bottom

for i in range(limit, x_bottom - 1, -1):
    x = i
    y_limit = 0
    if sum_xyz - x >= limit:
        y_limit = limit
    else:
        y_limit = sum_xyz - x
    y_bottom = sum_xyz - x - limit
    y_bottom = 0 if y_bottom < 0 else y_bottom

    for j in range(y_limit, y_bottom - 1, -1):
        y = j
        z = sum_xyz - x - y
        pair.append([x, y, z])
ans = len(pair)

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
 
def main():
    K,S = [int(x) for x in input().split()]
 
    count = 0
 
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            if z >= 0 and z <= K:
                count += 1
 
    print(count)
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
limit, sum_xyz = map(int, input().split())

pair = list()
x_bottom = sum_xyz - 2*limit
x_bottom = 0 if x_bottom < 0 else x_bottom

for i in range(limit, x_bottom - 1, -1):
    x = i
    y_limit = 0
    if sum_xyz - x >= limit:
        y_limit = limit
    else:
        y_limit = sum_xyz - x
    y_bottom = sum_xyz - x - limit
    y_bottom = 0 if y_bottom < 0 else y_bottom

    for j in range(y_limit, y_bottom - 1, -1):
        y = j
        z = sum_xyz - x - y
        pair.append([x, y, z])
ans = len(pair)

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
 
def main():
    K,S = [int(x) for x in input().split()]
 
    count = 0
 
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            if z >= 0 and z <= K:
                count += 1
 
    print(count)
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
limit, sum_xyz = map(int, input().split())

pair = list()
for i in range(limit, -1, -1):
    x = i
    for j in range(limit, -1, -1):
        y = j
        if y < sum_xyz - limit - x or sum_xyz - x - y < 0:
            continue
        z = sum_xyz - x - y
        pair.append([x, y, z])

print(len(pair))

Fixed submission:
import sys
input = sys.stdin.readline
 
def main():
    K,S = [int(x) for x in input().split()]
 
    count = 0
 
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            if z >= 0 and z <= K:
                count += 1
 
    print(count)
 
if __name__ == '__main__':
    main()