Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
 
 
def solve(K: int, S: int):
    cnt = 0
    for a in range(K + 1):
        for b in range(K + 1):
            for c in range(K + 1):
                if a + b + c == S:
                    cnt += 1
    print(cnt)
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)
 
if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys
 
 
def solve(K: int, S: int):
    cnt = 0
    for a in range(K + 1):
        for b in range(K + 1):
            tmp = S - (a + b)
            if 0 <= tmp and tmp <= K:
                cnt += 1 
    print(cnt)
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    cnt = 0
    for a in range(K + 1):
        for b in range(K + 1):
            for c in range(K + 1):
                if a + b + c == S:
                    cnt += 1
                if a + b + c > S:
                    break
            if a + b > S:
                break
        if a > S:
            break
            
    print(cnt)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
 
 
def solve(K: int, S: int):
    cnt = 0
    for a in range(K + 1):
        for b in range(K + 1):
            tmp = S - (a + b)
            if 0 <= tmp and tmp <= K:
                cnt += 1 
    print(cnt)
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    cnt = 0
    for a in range(K + 1):
        for b in range(K + 1):
            for c in range(K + 1):
                if a + b + c == S:
                    cnt += 1
    print(cnt)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
 
 
def solve(K: int, S: int):
    cnt = 0
    for a in range(K + 1):
        for b in range(K + 1):
            tmp = S - (a + b)
            if 0 <= tmp and tmp <= K:
                cnt += 1 
    print(cnt)
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)
 
if __name__ == '__main__':
    main()