alexjercan/bugnet huggingface dataset:
Problem p03807 (Python) — buggy submission, verdict: Runtime Error

num_ints = int(input())
sum_ints = sum([int(i) for i in input().split()])

if sum_ints % 2 == 0:
    print("YES")
else:
    print("NO")


Error: TypeError: unsupported operand type(s) for %: 'builtin_function_or_method' and 'int'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03807/Python/s361602990.py", line 4, in <module>
    if sum % 2 == 0:
TypeError: unsupported operand type(s) for %: 'builtin_function_or_method' and 'int'


Fixed submission:

num_ints = int(input())
sum_ints = sum([int(i) for i in input().split()])

if sum % 2 == 0:
    print("YES")
else:
    print("NO")
Problem p03813 (Python) — buggy submission, verdict: Runtime Error

x = int(input())


if x < 1200:
    print("ABC")

else:
    print("ARC")


Error: TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03813/Python/s733703116.py", line 4, in <module>
    if x < 1200:
TypeError: '<' not supported between instances of 'str' and 'int'


Fixed submission:

x = input()


if x < 1200:
    print("ABC")

else:
    print("ARC")
Problem p03813 (Python) — buggy submission, verdict: Runtime Error

print("ARC" if int(input()) >= 1200 else "ABC")


Error: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'builtin_function_or_method'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03813/Python/s654716081.py", line 1, in <module>
    print("ARC" if int(input) > 1200 else "ABC")
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'builtin_function_or_method'


Fixed submission:

print("ARC" if int(input) > 1200 else "ABC")
Problem p03814 (Python) — buggy submission, verdict: Runtime Error

s = input()

start = s.index("A")

for i in range(len(s) - 1, start, -1):
    if s[i] == "Z":
        print(i - start + 1)
        break


Error: IndexError: string index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03814/Python/s942139210.py", line 6, in <module>
    if s[i] == "Z":
IndexError: string index out of range


Fixed submission:

s = input()

start = s.index("A")

for i in range(len(s), start, -1):
    if s[i] == "Z":
        print(i - start + 1)
        break
Problem p03815 (Python) — buggy submission, verdict: Runtime Error

# 6, 5, 6, 5, ...

x = int(input())
q = x // 11
r = x % 11
if r == 0:
    ans = q * 2
elif 1 <= r <= 6:
    ans = q * 2 + 1
elif 7 <= r <= 10:
    ans = q * 2 + 2
print(ans)


Error: NameError: name 'ans' is not defined. Did you mean: 'abs'?
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03815/Python/s609603869.py", line 10, in <module>
    elif 6 <= ans <= 10:
NameError: name 'ans' is not defined. Did you mean: 'abs'?


Fixed submission:

# 6, 5, 6, 5, ...

x = int(input())
q = x // 11
r = x % 11
if r == 0:
    ans = q * 2
elif 1 <= r <= 5:
    ans = q * 2 + 1
elif 6 <= ans <= 10:
    ans = q * 2 + 2
print(ans)
Problem p03815 (Python) — buggy submission, verdict: Runtime Error

x = int(input())
if x < 7:
    print(1)
    exit()
elif x % 11 is 0:
    print((x // 11) * 2)
elif x % 11 < 7:
    print((x // 11) * 2 + 1)
else:
    print((x // 11) * 2 + 2)


Error: ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03815/Python/s263394591.py", line 1, in <module>
    N, M = [int(i) for i in input().split()]
ValueError: not enough values to unpack (expected 2, got 1)


Fixed submission:

N, M = [int(i) for i in input().split()]
road = [list() for i in range(N + 1)]
for i in range(M):
    a, b = [int(i) for i in input().split()]
    road[a].append(b)
    road[b].append(a)


def solve(before, visited, now):
    visited.append(now)
    print(visited)
    if len(visited) is N:
        return 1
    pattern = 0
    for way in road[now]:
        if way is now:
            continue
        if way in visited:
            continue
        pattern += solve(now, visited[:], way)
    return pattern


print(solve(0, [], 1))
Problem p03817 (Python) — buggy submission, verdict: Runtime Error

x = int(input())
ans = (x // 11) * 2
if x % 11:
    if x % 11 > 6:
        ans += 2
    else:
        ans += 1
print(ans)


Error: TypeError: unsupported operand type(s) for //: 'str' and 'int'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03817/Python/s232589342.py", line 2, in <module>
    print((x // 11) * 2 + (2 if x % 11 > 6 else 1))
TypeError: unsupported operand type(s) for //: 'str' and 'int'


Fixed submission:

x = input()
print((x // 11) * 2 + (2 if x % 11 > 6 else 1))
Problem p03818 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 0
e = 0
i = 0
while True:
    c += 1
    cai = 1
    while i != n - 1 and a[i] == a[i + 1]:
        cai += 1
        if i != n - 1:
            i += 1
        else:
            break
    if cai % 2 == 0:
        e += 1
    if i != n - 1:
        i += 1
    else:
        break
ans = c - (e % 2)
print(ans)


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03818/Python/s388445088.py", line 10, in <module>
    while a[i] == a[i + 1]:
IndexError: list index out of range


Fixed submission:

n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 0
e = 0
i = 0
while i < len(a):
    c += 1
    cai = 1
    while a[i] == a[i + 1]:
        cai += 1
        i += 1
    if cai % 2 == 0:
        e += 1
    i += 1
ans = c - (e % 2)
print(ans)
Problem p03821 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

count = 0
for i in reversed(range(n)):
    c = b[i] * (-(-a[i] // b[i])) - a[i]
    # for j in range(i):
    #    a[j] += c
    count += c
    if i >= 1:
        a[i - 1] += count
print(count)


Error: TLE

Fixed submission:

n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

count = 0
for i in reversed(range(n)):
    c = b[i] * (-(-a[i] // b[i])) - a[i]
    for j in range(i):
        a[j] += c
    count += c
print(count)
Problem p03821 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

A = A[::-1]
B = B[::-1]
R = [0 for _ in range(N)]
for i, (a, b) in enumerate(zip(A, B)):
    r = a % b
    if r > 0:
        r = b - r
    R[i] = r

ans = R[0]
for i in range(1, N):
    r = R[i]
    r = r - ans
    r = r % B[i]
    ans += r

print(ans)


Error: TLE

Fixed submission:

N = int(input())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

A = A[::-1]
B = B[::-1]
R = [0 for _ in range(N)]
for i, (a, b) in enumerate(zip(A, B)):
    r = a % b
    if r > 0:
        r = b - r
    R[i] = r

ans = 0
for i in range(0, N):
    r = R[i]
    ans += r
    for j in range(i + 1, N):
        rj = R[j]
        rj -= r
        R[j] = rj % B[j]

print(ans)
Problem p03821 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
cnt = 0
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

for i in range(n - 1, -1, -1):
    r = b[i] - (a[i] + cnt) % b[i]
    if r != b[i]:
        cnt += r
print(cnt)


Error: TLE

Fixed submission:

n = int(input())
cnt = 0
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

for i in range(n - 1, -1, -1):
    if a[i] % b[i] != 0:
        r = b[i] - a[i] % b[i]
        cnt += r
        for j in range(i + 1):
            a[j] += r

print(cnt)
Problem p03822 (Python) — buggy submission, verdict: Runtime Error

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
graph = [[] for _ in range(n)]
for i in range(1, n):
    graph[int(input()) - 1].append(i)


def dfs(x):
    arr = [dfs(y) for y in graph[x]]
    if not (arr):
        return 0
    arr.sort(reverse=True)
    return max(i + a for i, a in enumerate(arr, 1))


print(dfs(0))


Error: 0

Fixed submission:

n = int(input())
graph = [[] for _ in range(n)]
for i in range(1, n):
    graph[int(input()) - 1].append(i)


def dfs(x):
    arr = [dfs(y) for y in graph[x]]
    if not (arr):
        return 0
    arr.sort(reverse=True)
    return max(i + a for i, a in enumerate(arr, 1))


print(dfs(0))
Problem p03834 (Python) — buggy submission, verdict: Runtime Error

a, b, c = input().split(",")
print(a, b, c)


Error: ValueError: invalid literal for int() with base 10: 'happy,newyear,enjoy'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03834/Python/s432875580.py", line 1, in <module>
    k, s = [int(x) for x in input().split()]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03834/Python/s432875580.py", line 1, in <listcomp>
    k, s = [int(x) for x in input().split()]
ValueError: invalid literal for int() with base 10: 'happy,newyear,enjoy'


Fixed submission:

k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        for z in range(y, k + 1):
            if z > s:
                break
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 3
print(cnt)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

k, s = [int(i) for i in input().split()]
ans = 0
for x in range(k, -1, -1):
    for y in range(k, -1, -1):
        if 0 <= s - x - y <= k:
            ans += 1
print(ans)


Error: TLE

Fixed submission:

k, s = [int(i) for i in input().split()]
ans = 0
for x in range(k, -1, -1):
    for y in range(k, -1, -1):
        for z in range(k, -1, -1):
            if x + y + z is s:
                ans += 1
print(ans)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

K, S = list(map(int, input().split()))

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        Z = S - i - j
        if 0 <= Z and Z <= K:
            cnt += 1
print(cnt)


Error: TLE

Fixed submission:

# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

K, S = list(map(int, input().split()))

cnt = 0
# X
for i in range(K + 1):
    if i > S:
        break
    # Y
    for j in range(K + 1):
        if i + j > S:
            break
        # Z
        for k in range(K + 1):
            if i + j + k > S:
                break
            if i + j + k == S:
                cnt += 1
print(cnt)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 0

for i in range(k + 1):
    for j in range(k + 1):
        z = s - i - j
        if 0 <= z <= k:
            ans += 1

print(ans)


Error: TLE

Fixed submission:

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

ans = 0

for i in range(k + 1):
    for j in range(k + 1):
        for h in range(k + 1):
            if h + i + j == s:
                ans += 1

print(ans)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

max_range, sum_ = map(int, input().split())

count = 0
for x in range(0, min(max_range + 1, sum_ + 1)):
    for y in range(0, min(max_range + 1, sum_ - x + 1)):
        if sum_ - x - y <= max_range:
            count += 1

print(count)


Error: TLE

Fixed submission:

import itertools

max_range, sum_ = map(int, input().split())

count = 0
for x, y, z in itertools.combinations_with_replacement(range(max_range + 1), r=3):
    if x + y + z == sum_:
        len_set = len({x, y, z})
        if len_set == 1:
            count += 1
        elif len_set == 2:
            count += 3
        else:
            count += 6

print(count)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(S + 1):
        if K < X:
            break
        for Y in range(S + 1):
            if K < Y:
                break
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(S + 1):
        for Y in range(S + 1):
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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

for i in range(k + 1):
    t = s - i
    if t >= 0:
        cnt += max(0, (t + 1) - 2 * (max(0, t - k)))
print(cnt)


Error: TLE

Fixed submission:

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

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                cnt += 1
print(cnt)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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

result = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            result += 1

print(result)


Error: TLE

Fixed submission:

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

result = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                result += 1

                break

print(result)
Problem p03835 (Python) — buggy submission, verdict: Runtime Error

def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [K, S] = list(map(lambda x: int(x), inputs[0].split()))
    pattern = 0
    for x in range(0, K + 1):
        for y in range(0, K + 1):
            tmp_z = S - x - y
            if tmp_z <= K and tmp_z >= 0:
                pattern += 1

    return pattern


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Error: ValueError: invalid literal for int() with base 10: '2 2'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03835/Python/s943911857.py", line 33, in <module>
    N = int(input())
ValueError: invalid literal for int() with base 10: '2 2'


Fixed submission:

import math


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(lambda x: sp(x), inputs))
    N = len(points)
    distances = []
    for i, _ in enumerate(points):
        for j in range(i + 1, N):
            distances.append(
                math.sqrt(
                    (points[i][0] - points[j][0]) ** 2
                    + (points[i][1] - points[j][1]) ** 2
                )
            )
    max = 0
    for d in distances:
        max = d if max < d else max
    return "%.6f" % max


def sp(s):
    new_s = s.split()
    return list(map(lambda x: int(x), new_s))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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

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

cnt = 0

for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1

print(cnt)


Error: TLE

Fixed submission:

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

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

cnt = 0

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                cnt += 1

print(cnt)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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

count = 0
for i in range(k + 1):
    for j in range(k + 1):
        m = s - i - j
        if 0 <= m <= k:
            count += 1
print(count)


Error: TLE

Fixed submission:

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

sum_set = []
for i in range(k + 1):
    for j in range(k + 1):
        m = s - i - j
        if 0 <= m <= k:
            comb = [i, j, m]
            sum_set.append(comb)
        else:
            continue
print(len(sum_set))
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            ans += 1

print(ans)


Error: TLE

Fixed submission:

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

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ans += 1
            if x + y + z > s:
                break

print(ans)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            ans += 1

print(ans)


Error: TLE

Fixed submission:

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

ans = 0
for x in range(k + 1):
    for y in range(min(k + 1, s - x + 1)):
        for z in range(min(k + 1, s - x - y + 1)):
            if x + y + z == s:
                ans += 1

print(ans)
Problem p03835 (Python) — buggy submission, verdict: Runtime Error

k, s = map(int, input().split(" "))
answer = 0

for i in range(k + 1):
    for j in range(k + 1):
        rem = s - i - j
        if 0 <= rem <= k:
            answer += 1
print(answer)


Error: WA

Fixed submission:

k, s = map(int, input().split(" "))
answer = 0

for i in range(k + 1):
    for j in range(k + 1):
        rem = 3 * k - i - j
        if 0 <= rem <= k:
            answer += 1
print(answer)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

k, s = map(int, input().split())
count = 0
for a in range(k + 1):
    for b in range(k + 1):
        if 0 <= s - a - b <= k:
            count += 1
print(count)


Error: TLE

Fixed submission:

# https://atcoder.jp/contests/abc051/tasks/abc051_b

# n n,
K, S = map(int, input().split())

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(K + 1):
    if i + K + 1 + K + 1 < S:
        continue
    for j in range(K + 1):
        if i + j + K + 1 < S:
            continue
        if 0 <= S - i - j <= K:
            ans += 1

print(ans)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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

counter = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z and z <= K:
            counter += 1
print(counter)


Error: TLE

Fixed submission:

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

counter = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if S == x + y + z:
                counter += 1
print(counter)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

# -*- coding: utf-8 -*-
K, S = map(int, input().split())
cnt = 0

for X in range(K + 1):
    for Y in range(K + 1):
        Z = S - X - Y
        if 0 <= Z <= K:
            cnt += 1

print(cnt)


Error: TLE

Fixed submission:

# -*- coding: utf-8 -*-
K, S = map(int, input().split())
cnt = 0

for X in range(K + 1):
    for Y in range(K + 1):
        for Z in range(K + 1):
            if X + Y + Z == S:
                cnt += 1
print(cnt)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        ans += 1 if 0 <= S - x - y <= K else 0
print(ans)


Error: TLE

Fixed submission:

K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            # print(x, y, z)
            if x + y + z == S:
                ans += 1
print(ans)
Problem p03835 (Python) — buggy submission, verdict: Runtime Error

import itertools

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

cnt = 0

l = list(range(K + 1))

for i, j in itertools.product(l, repeat=2):
    if 0 <= S - i - j <= K:
        cnt += 1

print(cnt)


Error: TypeError: '<=' not supported between instances of 'int' and 'list'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03835/Python/s440098409.py", line 10, in <module>
    if 0 <= S - i - j <= K:
TypeError: '<=' not supported between instances of 'int' and 'list'


Fixed submission:

import itertools

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

cnt = 0

K = list(range(K + 1))

for i, j in itertools.product(K, repeat=2):
    if 0 <= S - i - j <= K:
        cnt += 1

print(cnt)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

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


Error: TLE

Fixed submission:

# 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)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        z = s - x - y
        if y <= z and z <= k:
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)


Error: TLE

Fixed submission:

k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        for z in range(y, k + 1):
            if z > s:
                break
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


K, S = il()
c = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= (S - (x + y)) <= K:
            c += 1
print(c)


Error: TLE

Fixed submission:

import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


K, S = il()
c = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if (x + y + z) == S:
                c += 1
print(c)
Problem p03835 (Python) — buggy submission, verdict: Time Limit Exceeded

k, s = map(int, input().split())
count = 0
for x in range(k + 1):
    for y in range(k + 1):
        if s - x - y <= k and s - x - y >= 0:
            # print(x, y)
            count += 1

print(count)


Error: TLE

Fixed submission:

k, s = map(int, input().split())
count = 0
k += 1
for x in range(k):
    for y in range(k):
        for z in range(k):
            if x + y + z == s:
                count += 1

print(count)