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

#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

d, n = map(int, input().split())

a = 0
if d == 0:
    a = n
    if n == 100:
        a += 1
elif d == 1:
    a = 100 * n
    if n == 100:
        a += 100
elif d == 2:
    a = 100 * 100 * n
    if n == 100:
        a += 100 * 100

print(a)


Error: ValueError: invalid literal for int() with base 10: '0 5'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03324/Python/s686916597.py", line 3, in <module>
    n = int(input())
ValueError: invalid literal for int() with base 10: '0 5'


Fixed submission:

#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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

t = 0
for i in a:
    m = i
    while m % 2 == 0:
        t += 1
        m /= 2

print(t)
Problem p03325 (Python) — buggy submission, verdict: Time Limit Exceeded

input()

a = list(map(int, input().split()))

count = 0
for i, aa in enumerate(a):
    while aa % 2 == 0:
        aa = int(aa / 2)
        count += 1
print(count)


Error: TLE

Fixed submission:

input()

a = list(map(int, input().split()))

count = 0
flag = True
while flag:
    flag = False
    for i, aa in enumerate(a):
        if aa % 2 == 0:
            a[i] = int(a[i] / 2)
            flag = True
            break
    if flag:
        count += 1
print(count)
Problem p03325 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in a:
    while i % 2 == 0:
        i //= 2
        ans += 1
print(ans)


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
ans, cnt = 0, 0
b = True

while b:
    cnt = 0
    for i in range(len(a)):
        if cnt == 0:
            if a[i] % 2 == 0:
                a[i] = a[i] // 2
                cnt = 1
            else:
                a[i] = a[i] * 3
        else:
            a[i] = a[i] * 3
    if cnt == 1:
        ans += 1
    else:
        b = False
print(ans)
Problem p03325 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
a = list(map(int, input().split()))

ans = 0
for i in a:
    count = 0
    while True:
        if i % 2 ** (count + 1) == 0:
            count += 1
        else:
            ans += count
            break

print(ans)


Error: TLE

Fixed submission:

N = int(input())
a = list(map(int, input().split()))

ans = 0
m = 1
for i in a:
    m *= i

while True:
    if m % 2 == 0:
        ans += 1
        m //= 2
    else:
        break

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

N, *a = map(int, open(0).read().split())
ans = 0
for i in range(N):
    while a[i] % 2 == 0:
        a[i] //= 2
        ans += 1

print(ans)


Error: TLE

Fixed submission:

N, *a = map(int, open(0).read().split())
ans = 0
flag = True
while flag:
    cnt = 0
    for i in range(N):
        if a[i] % 2 != 0:
            continue
        elif a[i] % 2 == 0 and cnt == 0:
            a[i] //= 2
            cnt += 1
            break

    if cnt == 0:
        flag = False
    else:
        ans += 1

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

N, *a = map(int, open(0).read().split())
ans = 0
for i in range(N):
    ans += len(bin(a[i])) - bin(a[i]).rfind("1") - 1
print(ans)


Error: TLE

Fixed submission:

N, *a = map(int, open(0).read().split())
ans = 0
flag = True
while flag:
    cnt = 0
    for i in range(N):
        if a[i] % 2 == 0 and cnt == 0:
            a[i] //= 2
            cnt += 1
        else:
            a[i] *= 3
    else:
        if cnt == 0:
            flag = False
        else:
            ans += 1

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

N = int(input())
a_list = list(map(int, input().split()))
cnt = 0
for a in a_list:
    if a % 2 == 0:
        while a % 2 == 0:
            a /= 2
            cnt += 1
print(cnt)


Error: TLE

Fixed submission:

def judge():
    four = []
    even = []
    odd = []
    for a in a_list:
        if a % 2 == 1:
            odd.append(a * 3)
        else:
            if a % 4 == 0:
                four.append(a)
            else:
                even.append(a)
    if len(four) > 0:
        odd.append(four.pop() // 2)
        four = [i * 3 for i in four]
        odd.extend(four)
        even = [i * 3 for i in even]
        odd.extend(even)
    else:
        if even:
            odd.append(even.pop() // 2)
            even = [i * 3 for i in even]
            odd.extend(even)
        else:
            return False
    global a_list
    a_list = odd
    return True


N = int(input())
a_list = list(map(int, input().split()))
cnt = 0
while True:
    if judge():
        cnt += 1
    else:
        break
print(cnt)
Problem p03325 (Python) — buggy submission, verdict: Time Limit Exceeded

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

ans = 0

for a in A:
    while a % 2 == 0:
        a /= 2
        ans += 1

print(ans)


Error: TLE

Fixed submission:

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

ans = 0
waru = 0
cnt = 0

while True:
    for i in range(n):
        if A[i] % 2 == 0:
            if waru == 1:
                A[i] *= 3
            else:
                A[i] //= 2
                waru = 1
        else:
            A[i] *= 3
    if waru == 0:
        print(ans)
        exit()
    else:
        ans += 1
    waru = 0
Problem p03325 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
a = list(map(int, input().split()))

cnt = 0

for i in range(N):
    while True:
        if a[i] % 2 == 0:
            a[i] //= 2
            cnt += 1
        else:
            break
print(cnt)


Error: TLE

Fixed submission:

N = int(input())
a = list(map(int, input().split()))

cnt = 0

while True:
    has_divided = False
    for i in range(N):
        if not has_divided and a[i] % 2 == 0:
            a[i] = a[i] // 2
            has_divided = True
        else:
            a[i] *= 3
    if has_divided:
        cnt += 1
    else:
        break
print(cnt)
Problem p03325 (Python) — buggy submission, verdict: Time Limit Exceeded

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

s = 0
for i in range(n):
    while a[i] % 2 == 0:
        a[i] //= 2
        s += 1
print(s)


Error: TLE

Fixed submission:

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

s = 0
while True:
    divided = False
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] //= 2
            divided = True
            break
    if divided:
        s += 1
    else:
        break
print(s)
Problem p03326 (Python) — buggy submission, verdict: Time Limit Exceeded

from itertools import product

n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for e in product([1, -1], [1, -1], [1, -1]):
    xyz.sort(key=lambda v: (v[0] * e[0]) + (v[1] * e[1]) + (v[2] * e[2]))
    tmp = xyz[:m]
    ans = max(
        ans,
        abs(sum([e[0] for e in tmp]))
        + abs(sum([e[1] for e in tmp]))
        + abs(sum([e[2] for e in tmp])),
    )
print(ans)


Error: TLE

Fixed submission:

from itertools import combinations

n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for elem in combinations(xyz, m):
    x = abs(sum([e[0] for e in elem]))
    y = abs(sum([e[1] for e in elem]))
    z = abs(sum([e[2] for e in elem]))
    ans = max(ans, x + y + z)
print(ans)
Problem p03326 (Python) — buggy submission, verdict: Time Limit Exceeded

from itertools import product

import numpy as np

n, m = list(map(int, input().split(" ")))
if m == 0:
    print(0)
    exit()
xyz_list = []
for _ in range(n):
    xyz_list.append(np.array(list(map(int, input().split(" ")))))
arrs = [np.array(x) for x in product([1, -1], repeat=3)]
ans = max([sum(sorted([sum(arr * xyz) for xyz in xyz_list])[-m:]) for arr in arrs])
print(ans)


Error: TLE

Fixed submission:

from itertools import combinations


def abs_sum(xyz_list):
    s1 = abs(sum([xyz[0] for xyz in xyz_list]))
    s2 = abs(sum([xyz[1] for xyz in xyz_list]))
    s3 = abs(sum([xyz[2] for xyz in xyz_list]))
    return s1 + s2 + s3


n, m = list(map(int, input().split(" ")))
xyz_list = []
for _ in range(n):
    xyz_list.append(list(map(int, input().split(" "))))

combs = combinations(xyz_list, m)
print(max([abs_sum(comb) for comb in combs]))
Problem p03326 (Python) — buggy submission, verdict: Time Limit Exceeded

N, M = map(int, input().split())
lst = [list(map(int, input().rstrip().split())) for n in range(N)]
maximum = -float("inf")
for i in [-1, 1]:
    for j in [-1, 1]:
        for k in [-1, 1]:
            sum_lst = []
            for n in range(N):
                num = lst[n][0] * i + lst[n][1] * j + lst[n][2] * k
                sum_lst.append(num)
            maximum = max(abs(sum(sorted(sum_lst)[:M])), maximum)

print(maximum)


Error: TLE

Fixed submission:

import itertools


N, M = map(int, input().split())
lst = [list(map(int, input().rstrip().split())) for n in range(N)]
num = [i for i in range(N)]
maximum = -float("inf")
for p in itertools.combinations(num, M):
    m = sum(abs(sum(lst[n][i] for n in p)) for i in range(3))
    maximum = max(maximum, m)

print(maximum)
Problem p03327 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
if N < 1000:
    print("ABC")
else:
    print("ABD")


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/p03327/Python/s497455145.py", line 2, in <module>
    if N < 1000:
TypeError: '<' not supported between instances of 'str' and 'int'


Fixed submission:

N = input()
if N < 1000:
    print("ABC")
else:
    print("ABD")
Problem p03328 (Python) — buggy submission, verdict: Runtime Error

def main():
    a, b = map(int, input().split())

    h = 0
    ans = 0
    for i in range(1, 1000):
        h += i

        if h > b:
            b_h = h - b
            if a_h == b_h:
                ans = b_h
                break
        if h > a:
            a_h = h - a

    print(ans)


if __name__ == "__main__":
    main()


Error: TypeError: cannot unpack non-iterable int object
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03328/Python/s567662645.py", line 18, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03328/Python/s567662645.py", line 6, in main
    i, ans = 0
TypeError: cannot unpack non-iterable int object


Fixed submission:

def main():
    a, b = map(int, input().split())

    h = b - a

    i, ans = 0
    while True:
        i += 1
        ans += i

        if h == i:
            break

    print(ans)


if __name__ == "__main__":
    main()
Problem p03328 (Python) — buggy submission, verdict: Runtime Error

a, b = list(map(int, input().split()))
answer = (b - a) * (b - a + 1) / 2 - b
print(int(answer))


Error: ValueError: invalid literal for int() with base 10: ' '
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03328/Python/s337385384.py", line 1, in <module>
    a, b = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '


Fixed submission:

a, b = list(map(int, input()))
answer = (b - a) * (b - a + 1) / 2 - b
print(int(answer))
Problem p03328 (Python) — buggy submission, verdict: Runtime Error

H = [1]
for i in range(2, 1000):
    H.append(H[-1] + i)

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

for i in range(998):
    if H[i] - a == H[i + 1] - b:
        print(H[i] - a)
        break


Error: 0

Fixed submission:

def func(x):
    if x == 1:
        return 1
    else:
        return x + func(x - 1)


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

for i in range(1, 999):
    if func(i) - a == func(i + 1) - b:
        print(func(i) - a)
        break
Problem p03329 (Python) — buggy submission, verdict: Runtime Error

from collections import deque


max_n = 110000
dp = [-1] * max_n  # -1を未探索とする
dp[0] = 0  # 初期条件の設定
n = int(input())
que = deque([])
que.append(dp[0])
while que:
    v = que.popleft()
    pow = 1
    while v + pow <= n:
        if dp[v + pow] == -1:
            dp[v + pow] = dp[v] + 1
            que.append(v + pow)
        pow *= 6
    pow = 1
    while v + pow <= n:
        if dp[v + pow] == -1:
            dp[v + pow] = dp[v] + 1
            que.append(v + pow)
        pow *= 9
# print(dp)
print(dp[n])


Error: 0

Fixed submission:

from collections import deque


max_n = 11000
dp = [-1] * max_n  # -1を未探索とする
dp[0] = 0  # 初期条件の設定
n = int(input())
que = deque([])
que.append(dp[0])
while que:
    v = que.popleft()
    pow = 1
    while v + pow <= n:
        if dp[v + pow] == -1:
            dp[v + pow] = dp[v] + 1
            que.append(v + pow)
        pow *= 6
    pow = 1
    while v + pow <= n:
        if dp[v + pow] == -1:
            dp[v + pow] = dp[v] + 1
            que.append(v + pow)
        pow *= 9
# print(dp)
print(dp[n])
Problem p03329 (Python) — buggy submission, verdict: Runtime Error

money = int(input())

six = [6**i for i in range(1, 8)]
nine = [9**i for i in range(1, 7)]

all = [1] + sorted(six + nine)

dp = [100000 for i in range(100001)]
dp[0] = 0

for i in range(0, 100001):
    for el in all:
        temp = i + el
        if temp < 100001:
            dp[temp] = min(dp[temp], dp[i] + 1)

print(dp[money])


Error: 0

Fixed submission:

import math

money = int(input())

six = [6**i for i in range(1, 8)]
nine = [9**i for i in range(1, 7)]

all = [1] + sorted(six + nine)

dp = [float(math.inf) for i in range(100001)]
dp[0] = 0

for i in range(0, 100001):
    for el in all:
        temp = i + el
        if temp < 100001:
            dp[temp] = min(dp[temp], dp[i] + 1)

print(dp[money])
Problem p03329 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
num = [1]

x = 6
while x < 100000:
    num.append(x)
    x *= 6

x = 9
while x < 100000:
    num.append(x)
    x *= 9

dp = [n] * 1100000
dp[0] = 0

for i in range(n):
    for j in num:
        dp[i + j] = min(dp[i + j], dp[i] + 1)

print(dp[n])


Error: 0

Fixed submission:

n = int(input())
num = [1]

x = 6
while x < 100000:
    num.append(x)
    x *= 6

x = 9
while x < 100000:
    num.append(x)
    x *= 9

dp = [n] * 110000
dp[0] = 0

for i in range(n):
    for j in num:
        dp[i + j] = min(dp[i + j], dp[i] + 1)

print(dp[n])
Problem p03330 (Python) — buggy submission, verdict: Runtime Error

import itertools

N, C = map(int, input().split())
# N, C = 500, 30

D = []
for _ in range(C):
    D.append(list(map(int, input().split())))
    # D.append([100] * C)

diff_by_pos_color_pair = [[0 for _ in range(C)] for _ in range(3)]
for i in range(N):
    for j, color_from in enumerate(map(lambda x: int(x) - 1, input().split())):
        # for j, color_from in enumerate([0] * N):
        pos = (i + j) % 3
        for color_to in range(C):
            diff_by_pos_color_pair[pos][color_to] += D[color_from][color_to]


min_diff = float("inf")
for ccs in itertools.permutations(range(C), 3):
    diff = 0
    for pos, color in enumerate(ccs):
        diff += diff_by_pos_color_pair[pos][color]
    min_diff = min(min_diff, diff)

print(min_diff)


Error: 0

Fixed submission:

import itertools

N, C = map(int, input().split())
D = []
for _ in range(C):
    D.append(list(map(int, input().split())))

diff_by_pos_color_pair = [[0 for _ in range(C)] for _ in range(3)]
for i in range(N):
    for j, color_from in enumerate(map(lambda x: int(x) - 1, input().split())):
        pos = (i + j) % 3
        for color_to in range(C):
            diff_by_pos_color_pair[pos][color_to] += D[color_from][color_to]


min_diff = float("inf")
for ccs in itertools.permutations(range(C), 3):
    diff = 0
    for pos, color in enumerate(ccs):
        diff += diff_by_pos_color_pair[pos][ccs[color]]
    min_diff = min(min_diff, diff)

print(min_diff)
Problem p03330 (Python) — buggy submission, verdict: Time Limit Exceeded

import itertools


def get_discomfort(group_dic, color, D):
    s = 0
    for c, num in group_dic.items():
        s += D[c - 1][color - 1] * num
    return s


N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]


from collections import Counter


grids = [Counter() for _ in range(3)]

for i in range(N):
    c = list(map(int, input().split()))
    for j in range(N):
        grids[(i + j) % 3][c[j]] += 1


ans = float("inf")
for colors in itertools.permutations(list(range(C)), 3):
    colors = list(colors)
    s = 0
    for i, c in enumerate(colors):
        s += get_discomfort(grids[i], c, D)
    ans = min(ans, s)

print(ans)


Error: TLE

Fixed submission:

import itertools


def get_discomfort(group, color, D):
    s = 0
    for c in group:
        s += D[c - 1][color - 1]
    return s


N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]


grids = [[], [], []]
for i in range(N):
    c = list(map(int, input().split()))
    for j in range(N):
        grids[(i + j) % 3].append(c[j])

ans = float("inf")
for colors in itertools.permutations(list(range(C)), 3):
    colors = list(colors)
    s = 0
    for i, c in enumerate(colors):
        s += get_discomfort(grids[i], c, D)
    ans = min(ans, s)

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

n = int(input())

s = []
for i in range(1, n):
    j = n - i
    if i + j == n:
        a = sum(map(int, str(i)))
        b = sum(map(int, str(j)))
        s.append(a + b)
print(min(s))


Error: 0

Fixed submission:

n = int(input())

s = []
for i in range(2, n + 1):
    j = n - i
    if j >= 2 and i + j == n:
        a = sum(map(int, str(i)))
        b = sum(map(int, str(j)))
        s.append(a + b)
print(min(s))
Problem p03331 (Python) — buggy submission, verdict: Runtime Error

n = list(map(int, list(input())))

if n[0] == 1 and sum(n) == 1:
    print(10)
else:
    print(sum(n))


Error: TypeError: unsupported operand type(s) for +: 'int' and 'str'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03331/Python/s509317721.py", line 5, in <module>
    print(sum(n))
TypeError: unsupported operand type(s) for +: 'int' and 'str'


Fixed submission:

n = input().split()
if n[0] == 1 and sum(n):
    print(10)
else:
    print(sum(n))
Problem p03331 (Python) — buggy submission, verdict: Runtime Error

N = input()

ans = 0
for n in N:
    ans += int(n)

if ans == 1:
    ans = 10

print(ans)


Error: TypeError: unsupported operand type(s) for +=: 'int' and 'str'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03331/Python/s099321384.py", line 5, in <module>
    ans += n
TypeError: unsupported operand type(s) for +=: 'int' and 'str'


Fixed submission:

N = input()

ans = 0
for n in N:
    ans += n

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

n = int(input())
print(min([sum(map(int, str(i) + str(n - i))) for i in range(1, n // 2 + 1)]))


Error: 0

Fixed submission:

n = int(input())
print(min([sum(map(int, str(i) + str(n - i))) for i in range(1, n // 2)]))
Problem p03332 (Python) — buggy submission, verdict: Time Limit Exceeded

N, A, B, K = map(int, input().split())

mod = 998244353
fact = [1] * (N + 1)
ifact = [1] * (N + 1)


def init():
    for i in range(N):
        fact[i + 1] = fact[i] * (i + 1) % mod
        ifact[i + 1] = pow(fact[i + 1], mod - 2, mod)


def comb(x, y):
    if y < 0 or y > x:
        return 0
    return (fact[x] * ifact[x - y] * ifact[y]) % mod


ans = 0
init()
for a in range(N + 1):
    n = K - a * A
    if n < 0:
        break
    if n % B == 0:
        ans += (comb(N, a) * (comb(N, n // B))) % mod
print(ans % mod)


Error: TLE

Fixed submission:

N, A, B, K = map(int, input().split())

mod = 998244353
F = [1]
RF = []


def inv(x):
    res = 1
    k = mod - 2
    y = x
    while k:
        if k & 1:
            res = (res * y) % mod
        y = (y * y) % mod
        k //= 2
    return res


def init():
    for i in range(N):
        F.append((F[i] * (i + 1)) % mod)
    for i in F:
        RF.append(inv(i))


def comb(x, y):
    if y < 0 or x < y:
        return 0
    return (F[x] * ((inv(F[x - y]) * inv(F[y])) % mod)) % mod


ans = 0
init()
for a in range(N):
    b = (K - a * A) / B
    if b < 0:
        break
    if b.is_integer():
        ans += (comb(N, a) * (comb(N, int(b)))) % mod
print(ans % mod)
Problem p03337 (Python) — buggy submission, verdict: Runtime Error

A, B = map(int, input().split())

print(max([A + B, A - B, A * B]))


Error: ValueError: invalid literal for int() with base 10: ' '
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03337/Python/s268424429.py", line 1, in <module>
    A, B = map(int, input())
ValueError: invalid literal for int() with base 10: ' '


Fixed submission:

A, B = map(int, input())

print(max([A + B, A - B, A * B]))
Problem p03337 (Python) — buggy submission, verdict: Runtime Error

A, B = list(map(int, input().split()))
print(max(A + B, max(A - B, A * B)))


Error: AttributeError: 'int' object has no attribute 'A'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03337/Python/s852904721.py", line 2, in <module>
    print(max(A + B, max(A - B.A * B)))
AttributeError: 'int' object has no attribute 'A'


Fixed submission:

A, B = list(map(int, input().split()))
print(max(A + B, max(A - B.A * B)))
Problem p03337 (Python) — buggy submission, verdict: Runtime Error

N = input().split()
for i in range(2):
    if i == 0:
        A = int(N[i])
    elif i == 1:
        B = int(N[i])

X_1 = A + B
X_2 = A - B
X_3 = A * B

max = X_1

if max < X_2:
    max = X_2
if max < X_3:
    max = X_3

print(max)


Error: 0

Fixed submission:

X = input().split()

A = int(X[0])
B = int(X[1])

p = A + B
m = A - B
k = A * B

if p > m and p > k:
    max_s = p
elif m > p and m > k:
    max_s = m
elif k > p and k > m:
    max_s = k
elif A == B and A == 0:
    max_s = p

print(max_s)
Problem p03338 (Python) — buggy submission, verdict: Runtime Error

def cut_and_count(N: int, S: str) -> int:
    l, r = {}, {}
    for c in S:
        if c not in r:
            r[c] = 1
        else:
            r[c] += 1

    max_len = 0
    for c in S:
        if c not in l:
            l[c] = 1
        else:
            l[c] += 1
        r[c] -= 1

        ls = set(k for k, v in l.items() if v > 0)
        rs = set(k for k, v in r.items() if v > 0)

        temp = len(ls & rs)
        max_len = max(max_len, temp)

    return max_len


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = cut_and_count(N, S)
    print(ans)


Error: TypeError: '>' not supported between instances of 'int' and 'builtin_function_or_method'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03338/Python/s105927214.py", line 20, in <module>
    ans = cut_and_count(N, S)
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03338/Python/s105927214.py", line 12, in cut_and_count
    max_len = max(max, temp)
TypeError: '>' not supported between instances of 'int' and 'builtin_function_or_method'


Fixed submission:

def cut_and_count(N: int, S: str) -> int:
    l, r = set([]), set([])
    for c in S:
        r.add(c)

    max_len = 0
    for c in S:
        l.add(c)
        r.discard(c)

        temp = len(l & r)
        max_len = max(max, temp)

    return max_len


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = cut_and_count(N, S)
    print(ans)
Problem p03338 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
S = input()

print(max(len(set(S[:i]) & set(S[i:])) for i in range(1, N)))


Error: 0

Fixed submission:

N = int(input())
S = input()

print(max(len(set(S[:i]) & set(S[i:])) for i in range(1, N - 1)))