alexjercan/bugnet huggingface dataset:
Problem p02770 (Python) — buggy submission, verdict: Time Limit Exceeded

import numpy as np

k, q = map(int, input().split())
d = np.array(input().split(), np.int64)
nxm = [map(int, input().split()) for _ in range(q)]

for n, x, m in nxm:
    dd = d % m

    ans = n - 1
    divq, divr = divmod(n - 1, k)

    dd_r = dd[:divr]

    ans -= (k - np.count_nonzero(dd)) * divq
    ans -= divr - np.count_nonzero(dd_r)

    last = x + np.sum(dd) * divq + np.sum(dd_r)
    ans -= last // m - x // m

    print(ans)


Error: TLE

Fixed submission:

import numpy as np

k, q = map(int, input().split())
d = list(map(int, input().split()))
nxm = [map(int, input().split()) for _ in range(q)]

for n, x, m in nxm:
    dd = [e % m for e in d]
    dd = np.array(dd)

    ans = n - 1
    divq, divr = divmod(n - 1, k)

    dd_r = dd[:divr]

    ans -= (k - np.count_nonzero(dd)) * divq
    ans -= divr - np.count_nonzero(dd_r)

    last = x + np.sum(dd) * divq + np.sum(dd_r)
    ans -= last // m - x // m

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

nums = list(map(int, input().split(" ")))
if len(set(nums)) == 2:
    print("Yes")
else:
    print("No")


Error: AttributeError: 'builtin_function_or_method' object has no attribute 'split'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02771/Python/s880754388.py", line 1, in <module>
    nums = list(map(int, input.split(" ")))
AttributeError: 'builtin_function_or_method' object has no attribute 'split'


Fixed submission:

nums = list(map(int, input.split(" ")))
if len(set(nums)) == 2:
    print("Yes")
else:
    print("No")
Problem p02771 (Python) — buggy submission, verdict: Runtime Error

li = list(map(int, input().split()))
if (len(set(li))) == 2:
    print("Yes")
else:
    print("No")


Error: TypeError: 'int' object is not iterable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02771/Python/s620789941.py", line 2, in <module>
    if (set(len(li))) == 2:
TypeError: 'int' object is not iterable


Fixed submission:

li = list(map(int, input().split()))
if (set(len(li))) == 2:
    print("Yes")
else:
    print("No")
Problem p02772 (Python) — buggy submission, verdict: Runtime Error

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

for a in A:
    if a % 2 == 1:
        continue
    if a % 3 == 0 or a % 5 == 0:
        continue
    print("DENIED")
    exit()
print("APPROVED")


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02772/Python/s663457315.py", line 2, in <module>
    arr = [input() for _ in range(n)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02772/Python/s663457315.py", line 2, in <listcomp>
    arr = [input() for _ in range(n)]
EOFError: EOF when reading a line


Fixed submission:

n = int(input())
arr = [input() for _ in range(n)]
dic = {}
for i in range(n):
    if arr[i] not in dic:
        dic[arr[i]] = 1
    else:
        dic[arr[i]] += 1
largest = max(dic.values())
ans = []
for keys in dic.keys():
    if dic[keys] == largest:
        ans.append(keys)
ans = sorted(ans)
for words in ans:
    print(words)
Problem p02772 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
a = list(map(int, input().split()))
result = "APPROVED"
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            result = "DENIED"
            break
print(result)


Error: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02772/Python/s817582230.py", line 4, in <module>
    a = list(map(int(input().split())))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'


Fixed submission:

# 偶数かつ3または5で割り切れる

N = int(input())
a = list(map(int(input().split())))
for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            print("DENIED")
            exit(0)
print("APPROVED")
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())

existed_dict = {}
max_count = 0
max_text_list = []
for _ in range(N):
    text = input()
    if existed_dict.get(text):  # ここか
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1
    if existed_dict[text] == max_count:
        max_count = existed_dict[text]
        max_text_list.append(text)
    elif existed_dict[text] > max_count:
        max_count = existed_dict[text]
        max_text_list = []
        max_text_list.append(text)
    else:
        pass

for text in sorted(max_text_list):  # ここ
    print(text)


Error: TLE

Fixed submission:

N = int(input())

existed_dict = {}
max_count = 0
max_text_list = []
for _ in range(N):
    text = input()
    if text in existed_dict.keys():
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1
    if existed_dict[text] == max_count:
        max_count = existed_dict[text]
        max_text_list.append(text)
    elif existed_dict[text] > max_count:
        max_count = existed_dict[text]
        max_text_list = []
        max_text_list.append(text)
    else:
        pass

for text in sorted(max_text_list):
    print(text)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    S = Counter(S)

    SM = S.most_common()[0][1]
    S = sorted(S.items(), key=lambda x: [-x[1], x[0]])
    for key, value in S:
        if value == SM:
            print(key)
        else:
            break


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


def main():
    N = int(input())
    S = [input() for _ in range(N)]
    S = Counter(S)

    result = []
    for key, value in S.items():
        if value == S.most_common()[0][1]:
            result.append(key)
    result.sort()
    for r in result:
        print(r)


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

def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1

    max_val = max(words.values())
    # words_sorted = sorted(words.items(), key=lambda x: x[0])
    for key, value in sorted(words.items()):
        if value != max_val:
            continue
        else:
            print(key)
            # key valueを両方printするとき
            # print('{}:{}'.format(key, value))


if __name__ == "__main__":
    main()


Error: ValueError: too many values to unpack (expected 2)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02773/Python/s861205933.py", line 23, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02773/Python/s861205933.py", line 13, in main
    for key, value in sorted(words):
ValueError: too many values to unpack (expected 2)


Fixed submission:

def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1

    max_val = max(words.values())
    # words_sorted = sorted(words.items(), key=lambda x: x[0])
    for key, value in sorted(words):
        if value != max_val:
            continue
        else:
            print(key)
            # key valueを両方printするとき
            # print('{}:{}'.format(key, value))


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

def main():
    n = int(input())
    ss = {}
    max_s = 0
    for _ in range(n):
        s = input()
        if s not in ss:
            ss[s] = 0
        else:
            ss[s] += 1
            max_s = max(max_s, ss[s])

    ss = sorted(ss.items(), key=lambda x: x[0])
    anss = [s for s, i in ss if i == max_s]
    for ans in anss:
        print(ans)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

from collections import Counter


def main():
    n = int(input())
    ss = [input() for _ in range(n)]
    max_num = Counter(ss).most_common()[0][1]
    max_verbs = [Counter(ss).most_common()[0][0]]
    for i in range(1, len(Counter(ss).most_common())):
        if Counter(ss).most_common()[i][1] != max_num:
            break
        max_verbs.append(Counter(ss).most_common()[i][0])

    max_verbs = sorted(max_verbs)
    for ans in max_verbs:
        print(ans)


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

from collections import Counter

n = int(input())
S = [input() for i in range(n)]

L = Counter(S)
m = 0
for v in L.values():
    m = max(m, v)
ans = []
for k, v in L.items():
    if v == m:
        ans.append(k)
ans.sort()
print(*ans, sep="\\n")


Error: TLE

Fixed submission:

from collections import Counter

n = int(input())
S = [input() for i in range(n)]

L = Counter(S)
K = sorted([kv[0] for kv in L.items() if kv[1] == max(L.values())])

for i in range(len(K)):
    print(K[i])
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

N = int(input())
S = [input() for i in range(N)]

C = Counter(S)

C = sorted(C.items(), key=lambda x: x[1], reverse=True)


cnt_max = C[0][1]
ans = []
for i in range(len(C)):
    if cnt_max > C[i][1]:
        break
    else:
        ans.append(C[i][0])

ans.sort()

for w in ans:
    print(w)


Error: TLE

Fixed submission:

N = int(input())
S = [input() for i in range(N)]

count = {}
for i in range(N):
    if not S[i] in count:
        count[S[i]] = 1
    else:
        count[S[i]] += 1
max_k_list = [kv[0] for kv in count.items() if kv[1] == max(count.values())]
max_k_list.sort()
for i in range(len(max_k_list)):
    print(max_k_list[i])
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

n = int(input())
s = sorted([input() for i in range(n)])

counter = Counter(s)
max_num = max(counter.values())
ans_list = [i for i in counter if counter[i] == max_num]
for i in sorted(ans_list):
    print(i)


Error: TLE

Fixed submission:

n = int(input())
s = [input() for i in range(n)]
set_s = sorted(set(s))
max_num = 0
for i in set_s:
    max_num = max(max_num, s.count(i))
for i in set_s:
    if s.count(i) == max_num:
        print(i)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())

# 文字列の出現回数を格納
S = {}
for _ in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

# 出現回数が最大の文字列をansに格納し、昇順にソートする
# ans = [k for k, v in S.items() if v == max(S.values())]
# ans.sort()
max_value = max(S.values())
ans = sorted([k for k, v in S.items() if v == max_value])

# 出力
for a in ans:
    print(a)


Error: TLE

Fixed submission:

N = int(input())

# 文字列の出現回数を格納
S = {}
for _ in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

# 出現回数が最大の文字列をansに格納し、昇順にソートする
ans = [k for k, v in S.items() if v == max(S.values())]
ans.sort()

# 出力
for a in ans:
    print(a)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

import collections

N = int(input())
data = [input() for i in range(N)]

dicdata = collections.Counter(data)

m = max(dicdata.values())

newdata = [k for k, v in dicdata.items() if v == m]

newdata.sort()

[print(i) for i in newdata]


Error: TLE

Fixed submission:

import collections

N = int(input())
data = [input() for i in range(N)]

dicdata = collections.Counter(data)

newdata = [k for k, v in dicdata.items() if v == max(dicdata.values())]

newdata.sort()

[print(i) for i in newdata]
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = [input() for _ in range(n)]
d = {}
ans = []

for st in s:
    d[st] = d.get(st, 0) + 1

t = max(d.values())
ans_append = ans.append

for x in d:
    if d[x] == t:
        ans_append(x)

ans = sorted(ans)
for x in ans:
    print(x)


Error: TLE

Fixed submission:

import collections

n = int(input())
s = []

s_append = s.append
for _ in range(n):
    s_append(input())

pop_times = collections.Counter(s)
most_common_word = []

most_common_word_append = most_common_word.append
for i in pop_times.most_common():
    if pop_times.most_common()[0][1] == i[1]:
        most_common_word_append(i[0])

for x in sorted(most_common_word):
    print(x)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

import collections

N = int(input())
S = [input() for i in range(N)]

# print(S)

count = collections.Counter(S)

# print(count)

max_value = max(count.values())

max_k_list = []

for k, v in sorted(count.items(), key=lambda x: x[1], reverse=True):
    if v == max_value:
        max_k_list.append(k)
    else:
        break

max_k_list.sort()

for i in max_k_list:
    print(i)


Error: TLE

Fixed submission:

import collections

N = int(input())
S = [input() for i in range(N)]

count = collections.Counter(S)

# print(count)

max_k_list = [kv[0] for kv in count.items() if kv[1] == max(count.values())]

max_k_list.sort()

for i in max_k_list:
    print(i)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

N = int(input())
S = [input() for _ in range(N)]

c = Counter(S)
_max = max(c.values())

ans = []
for k, v in c.items():
    if v == _max:
        ans += [k]

for a in sorted(ans):
    print(a)


Error: TLE

Fixed submission:

N = int(input())
S = [input() for _ in range(N)]

key = set(S)

_dict = {}
for s in key:
    _dict[s] = S.count(s)

sort_dict = sorted(_dict.items(), key=lambda x: -x[1])
c = sort_dict[0][1]
lst = list()
for item in sort_dict:

    if c == item[1]:
        lst += [item[0]]
        c = item[1]
    else:
        break

lst.sort()

for i in lst:
    print(i)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input())

c = collections.Counter(S)
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] == max]
ans.sort()

for s in ans:
    print(s)


Error: TLE

Fixed submission:

import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input())
c = collections.Counter(S)
ans = []
max = c.most_common()[0][1]
i = 0
current = c.most_common()[i]
while current[1] == max:
    ans.append(current[0])
    i += 1
    if len(c) <= i:
        break
    current = c.most_common()[i]

ans.sort()
for s in ans:
    print(s)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
input_line = [input() for _ in range(N)]
count = {}
for w in input_line:
    if w in count:
        count[w] += 1
    else:
        count[w] = 1
max_values = max(count.values())
keys = [k for k, v in count.items() if v == max_values]
for w in sorted(keys):
    print(w)


Error: TLE

Fixed submission:

N = int(input())
input_line = [input() for _ in range(N)]
count = {}
for w in input_line:
    if w in count:
        count[w] += 1
    else:
        count[w] = 1

keys = [k for k, v in count.items() if v == max(count.values())]
for w in sorted(keys):
    print(w)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

import collections

n = int(input())
s = [input() for i in range(n)]

count = collections.Counter(s)

max_v = max(count.values())

result = [key for key, val in count.items() if val == max_v]

print("\\n".join(sorted(result)))


Error: TLE

Fixed submission:

n = int(input())

s = [0] * n
v = [0] * (n - 1)
w = [0]

for i in range(n):
    s[i] = input()

t = sorted(s)

for i in range(n - 1):
    if t[i] == t[i + 1]:
        v[i] = 1

u = sorted(set(t), key=t.index)

for i in range(n - 1):
    if v[i] != 0:
        w[len(w) - 1] += 1
    else:
        w.append(0)

for i in range(len(w)):
    if max(w) == w[i]:
        print(u[i])
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = dict()

for i in range(n):
    s = input()
    a.setdefault(s, 0)
    a[s] += 1

ans = []
mx = 0
for key, value in a.items():
    if mx < value:
        mx = value
        ans = [key]
    elif mx == value:
        ans.append(key)

ans.sort()
for i in ans:
    print(i)


Error: TLE

Fixed submission:

n = int(input())
s_list = [input() for i in range(n)]
s_set = set(s_list)
max = 0
max_elements = []
for i in s_set:
    c = s_list.count(i)
    if c > max:
        max = c
        max_elements = [i]
    if c == max and i not in max_elements:
        max_elements.append(i)

for i in sorted(max_elements):
    print(i)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())

count = dict()
for _ in range(N):
    x = input()
    count[x] = count.get(x, 0) + 1

max_val = -float("infinity")
for k, v in sorted(count.items(), key=lambda x: (-x[1], x[0])):
    max_val = max(v, max_val)
    if v == max_val:
        print(k)
    else:
        break


Error: TLE

Fixed submission:

N = int(input())
S = [input() for _ in range(N)]

count = dict()
for x in S:
    count[x] = count.get(x, 0) + 1

sorted_kv = list(sorted(count.items(), key=lambda x: (-x[1], x[0])))
max_val = sorted_kv[0][1]

res = []
for k, v in sorted_kv:
    if v == max_val:
        print(k)
    else:
        break
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
str_dic = {}
for _ in range(n):
    inp = input()
    if inp in str_dic:
        str_dic[inp] += 1
    else:
        str_dic[inp] = 1

max_num = max(str_dic.values())

max_str = [s[0] for s in str_dic.items() if s[1] == max_num]

for s in sorted(max_str):
    print(s)


Error: TLE

Fixed submission:

n = int(input())
str_dic = {}
for _ in range(n):
    inp = input()
    if inp in str_dic:
        str_dic[inp] += 1
    else:
        str_dic[inp] = 1

max_str = [s[0] for s in str_dic.items() if s[1] == max(str_dic.values())]

for s in sorted(max_str):
    print(s)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
S = [str(input()) for _ in range(N)]

S.sort()

ans = []
most = 0
tmpstr = S[0]
tmpcnt = 0


for s in S:
    if tmpstr == s:
        tmpcnt += 1
    else:
        if tmpcnt > most:
            ans.clear()
            ans.append(tmpstr)
            most = tmpcnt

        elif tmpcnt == most:
            ans.append(tmpstr)

        tmpcnt = 1
        tmpstr = s

if tmpcnt > most:
    ans.clear()
    ans.append(tmpstr)
    most = tmpcnt
elif tmpcnt == most:
    ans.append(tmpstr)

for a in ans:
    print(a)


Error: TLE

Fixed submission:

import collections

N = int(input())
S = [str(input()) for _ in range(N)]

c = collections.Counter(S)

ans = [i[0] for i in c.items() if i[1] >= c.most_common(1)[0][1]]
ans.sort()

for a in ans:
    print(a)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
S = [input() for _ in range(N)]
dic = {}
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

max = max(dic.values())
for key, value in sorted(dic.items()):
    if value == max:
        print(key)


Error: TLE

Fixed submission:

N = int(input())
S = [input() for _ in range(N)]
dic = {}
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

for key, value in sorted(dic.items()):
    if value == max(dic.values()):
        print(key)
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

N = int(input())
S = [input() for _ in range(N)]

dic = Counter(S)

tmp = max(dic.values())
ans = [key for key, value in dic.items() if value == tmp]

# もうちょいかっこいい書き方があるはず。リストを1行1str出力 and 最後に改行しないように
for key in sorted(ans):
    print(key, end="")
    print("")


Error: TLE

Fixed submission:

from collections import Counter

N = int(input())

S = [input() for _ in range(N)]

dic = Counter(S)

ans = [key for key, value in dic.items() if value == max(dic.values())]

for key in sorted(ans):
    print(key, end="")
    print("")
Problem p02773 (Python) — buggy submission, verdict: Time Limit Exceeded

import collections

N = int(input())
vote_list = [input() for i in range(N)]
vote_list.sort()

count = collections.Counter(vote_list)
max_count = count.most_common()[0][1]
ans = []

for alpha, beta in count.items():
    if beta == max_count:
        ans.append(alpha)
ans.sort()
print("\\n".join(ans))


Error: TLE

Fixed submission:

import collections

N = int(input())
vote_list = [input() for i in range(N)]
vote_list.sort()

count = collections.Counter(vote_list)
max_count = count.most_common()[0][1]

if max_count == 1:
    for i in vote_list:
        print(i)
elif len(list(set(vote_list))) == 1:
    print(vote_list[0])
else:
    i = 0
    for i in range(10000000000):
        if count.most_common()[i][1] == max_count:
            print(count.most_common()[i][0])
        else:
            break
Problem p02774 (Python) — buggy submission, verdict: Time Limit Exceeded

import numpy as np

n, k = [int(i) for i in input().split()]
a = np.array(sorted([int(i) for i in input().split()]))
posi = a[a > 0]
zero = a[a == 0]
nega = a[a < 0]

# 2分探索, mid より小さいものを数える
l = -(10**18) - 1
r = 10**18 + 1
while r - l > 1:
    mid = (r + l) // 2
    cnt = 0
    if mid >= 0:
        cnt += len(zero) * n

    cnt += a.searchsorted(mid // posi, side="right").sum()
    cnt += (n - a.searchsorted(-(-mid // nega), side="left")).sum()
    cnt -= np.count_nonzero(a * a <= mid)
    cnt //= 2
    if cnt >= k:
        r = mid
    else:
        l = mid
print(r)


Error: TLE

Fixed submission:

from itertools import combinations

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
products = []
for i in combinations(a, 2):
    products.append(i[0] * i[1])
print(sorted(products)[k - 1])
Problem p02775 (Python) — buggy submission, verdict: Time Limit Exceeded

S = "0" + input()

digits = [int(c) for c in S.rstrip("0")]
N = len(digits)

# Track number of bills necessary to create digits[:i]
# Can either pay exact or overpay by one bill to flip the sign of the balance
dpPos = [None] * len(digits)
dpNeg = [None] * len(digits)

dpPos[-1] = digits[-1]
dpNeg[-1] = 10 - digits[-1]

for place in reversed(range(len(digits) - 1)):
    # Positive balance case
    exact = digits[place]
    overpay = exact + 1
    dpPos[place] = min(exact + dpPos[place + 1], overpay + dpNeg[place + 1])
    # Negative balance case
    exact = 10 - digits[place] - 1
    overpay = exact + 1
    dpNeg[place] = min(exact + dpNeg[place + 1], overpay + dpPos[place + 1])
print(dpPos[0])


Error: TLE

Fixed submission:

S = "0" + input()

digits = [int(c) for c in S.rstrip("0")]

f = [
    None,
    [None] * len(digits),
    [None] * len(digits),
]  # f[sign][place] where sign is 1 or -1


for place in reversed(range(len(digits))):
    for sign in [-1, 1]:
        if place == len(digits) - 1:
            if sign > 0:
                exact = digits[place]
            else:
                exact = 10 - digits[place]
            f[sign][place] = exact
            continue

        if sign > 0:
            exact = digits[place]
            overpay = exact + 1  # Overpaying flips the sign of the balance
        else:
            assert sign < 0
            exact = 10 - digits[place] - 1
            overpay = exact + 1
        f[sign][place] = min(exact + f[sign][place + 1], overpay + f[-sign][place + 1])
print(f[1][0])
Problem p02777 (Python) — buggy submission, verdict: Runtime Error

S, T = input().split()
A, B = map(int, input().split())
U = input()

print(A - 1, B) if U == S else print(A, B - 1)


Error: TypeError: map() must have at least two arguments.
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02777/Python/s951886607.py", line 1, in <module>
    S, T = map(input().split())
TypeError: map() must have at least two arguments.


Fixed submission:

S, T = map(input().split())
A, B = map(int, input().split())
U = input()

print("A-1 B" if U == S else "A B-1")