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

def main():
    N, M = map(int, input().split())
    D = [tuple(map(int, input().split())) for _ in range(N)]
    D.sort()
    ans = 0
    i = 0
    while M > 0:
        a, b = D[i]
        ans += a * min(M, b)
        M -= min(M, b)
        i += 1
    print(ans)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

def main():
    N, M = map(int, input().split())
    D = [tuple(map(int, input().split())) for _ in range(N)]
    D.sort()
    ans = 0
    while M > 0:
        a, b = D.pop(0)
        ans += a * min(M, b)
        M -= min(M, b)
    print(ans)


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

a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, n + 1):
    if m % i == 0 and n % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")


Error: 0

Fixed submission:

a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, m):
    if n % i == 0 and m % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")
Problem p03106 (Python) — buggy submission, verdict: Runtime Error

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0

for a in range(mx, 0, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break

print(ans)


Error: WA

Fixed submission:

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0
for a in range(mx, 1, -1):
    print(a)
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break
print(ans)
Problem p03106 (Python) — buggy submission, verdict: Runtime Error

A, B, K = map(int, input().split())
n = max(A, B)
k = 0
while True:
    if A % n == 0 and B % n == 0:
        k = k + 1
    if k >= K:
        break
    n = n - 1
print(n)


Error: 0

Fixed submission:

A, B, K = map(int, input().split())
n = max(A, B)
k = 0
if n == 1:
    print("1")
else:
    while k < K:
        n = n - 1
        if A % n == 0 and B % n == 0:
            k = k + 1
    print(n)
Problem p03106 (Python) — buggy submission, verdict: Runtime Error

# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B) + 1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()


Error: 0

Fixed submission:

# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B)):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


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

a, b, k = map(int, input().split())
div = []
for i in range(1, 105):
    if (a % i == 0) and (b % i == 0):
        div.append(i)

if len(div) < k:
    print(max(div))
else:
    div.sort()
    print(div[-k])


Error: 0

Fixed submission:

a, b, k = map(int, input().split())
div = []
for i in range(1, max(a, b)):
    if (a % i == 0) and (b % i == 0):
        div.append(i)
if len(div) == 0:
    print(1)
else:
    div.sort()
    print(div[-k])
Problem p03106 (Python) — buggy submission, verdict: Runtime Error

import fractions

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

gcd = fractions.gcd(A, B)
order = 0
for i in range(gcd, 0, -1):
    if gcd % i == 0:
        order += 1
        if order == K:
            print(i)
            break


Error: 0

Fixed submission:

import math

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

gcd = math.gcd(A, B)
order = 0
for i in range(gcd, 0, -1):
    if gcd % i == 0:
        order += 1
        if order == K:
            print(i)
            break
Problem p03106 (Python) — buggy submission, verdict: Runtime Error

a, b, k = map(int, input().split())
divisers = []

for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        divisers.append(i)

print(divisers[-k])


Error: 0

Fixed submission:

a, b, k = map(int, input().split())
divisers = []

for i in range(1, max(a, b)):
    if a % i == 0 and b % i == 0:
        divisers.append(i)

print(divisers[-k])
Problem p03106 (Python) — buggy submission, verdict: Runtime Error

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

common_factors = []
for i in range(1, a + 1):
    if a % i == 0 and b % i == 0:
        common_factors.append(i)
print(common_factors[-k])


Error: 0

Fixed submission:

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

common_factors = []
for i in range(1, a):
    if a % i == 0 and b % i == 0:
        common_factors.append(i)
print(common_factors[-k])
Problem p03106 (Python) — buggy submission, verdict: Runtime Error

A, B, K = [int(i) for i in input().split()]
th = []
i = 0
while True:
    i += 1
    if (A % i, B % i) == (0, 0):
        th.append(i)
    if i > A or i > B:
        break
print(th[len(th) - K])


Error: 0

Fixed submission:

A, B, K = [int(i) for i in input().split()]
th = []
i = 1
while True:
    i += 1
    if (A % i, B % i) == (0, 0):
        th.append(i)
    if i > A or i > B:
        break
print(th[len(th) - K])
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

S = input()
len_S = len(S)
zero_lst = [S[i] for i in range(len_S) if S[i] == "0"]
one_lst = [S[i] for i in range(len_S) if S[i] == "1"]
ans = min(len(zero_lst), len(one_lst)) * 2
print(ans)


Error: TLE

Fixed submission:

def recursin_operation(S, len_init_s):
    S = list(S)
    N = len(S)
    lst = [i for i in range(N - 1) if S[i] != S[i + 1]]
    nums_of_deleted = []
    if len(lst) != 0:
        for i in lst:
            S_next = [S[j] for j in range(len(S)) if j < i or j > i + 1]
            nums_of_deleted.append(recursin_operation(S_next, len_init_s))
    else:
        nums_of_deleted.append(len_init_s - len(S))

    return max(nums_of_deleted)


def main():
    S = input()
    len_init_s = len(S)
    ans = recursin_operation(S, len_init_s)
    print(ans)


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

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

S = input()

ans = min(S.count("0"), S.count("1"))
print(ans * 2)


Error: TLE

Fixed submission:

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

import re

S = input()

s = S
ans = 0
while 1:
    s, t = re.subn("01|10", "", s)
    ans += t * 2
    if t == 0:
        break

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

s = input()
print(2 * min(s.count("0"), s.count("1")))


Error: TypeError: must be str, not int
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03107/Python/s119508612.py", line 2, in <module>
    print(2 * min(s.count(0), s.count(1)))
TypeError: must be str, not int


Fixed submission:

s = input()
print(2 * min(s.count(0), s.count(1)))
Problem p03107 (Python) — buggy submission, verdict: Runtime Error

s = input()
x = 0
for c in s:
    if c == "1":
        x = x + 1
print(min(x, len(s) - x) * 2)


Error: 0

Fixed submission:

# -*- coding: utf-8 -*-
s = input()
s = list(s)
x = 0
maxIndex = len(s) - 1
count = 0
while True:
    if len(s) == x + 1:
        break
    if s[x] != s[x + 1]:
        s.pop(x)
        s.pop(x)
        count += 1
        x -= 1
    else:
        x += 1
print("{}".format(count * 2))
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

import re

s = input()
zero = re.findall("0", s)
one = re.findall("1", s)
print(2 * min(len(zero), len(one)))


Error: TLE

Fixed submission:

import re

s = input()
pattern = "(01)|(10)"
count = 0
diff = 1

while diff:
    ssub = re.sub(pattern, "", s)
    diff = len(s) - len(ssub)
    count += diff
    s = ssub


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

S = input()

zeroSum = 0
oneSum = 0
for _ in S:
    if _ == "0":
        zeroSum += 1
    if _ == "1":
        oneSum += 1

t = max(zeroSum, oneSum) - min(zeroSum, oneSum)
print(len(S) - t)


Error: TLE

Fixed submission:

S = input()
subS = S
cnt = 0
while True:
    flg = True
    if "01" in subS:
        flg = False
        subS = subS.replace("01", "", 1)
        cnt += 2
    if "10" in subS:
        flg = False
        subS = subS.replace("10", "", 1)
        cnt += 2
    if flg:
        break
print(cnt)
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3
s = input()
n = len(s)
c = 0
p = ""
count = 0
for i in s:
    if i == p:
        count += 1
    else:
        c = count - c
        count = 1
    p = i
c = count - c
print(n - abs(c))


Error: TLE

Fixed submission:

#!/usr/bin/env python3
s = input()
n = len(s)
while True:
    ns = s.replace("01", "").replace("10", "")
    if ns == s:
        break
    s = ns
print(n - len(s))
Problem p03107 (Python) — buggy submission, verdict: Runtime Error

S = input()
S = [Si for Si in S]

i = len(S) - 2
number_of_deleted_qube = 0
while i >= 0 and len(S) >= 2:
    if i >= len(S) - 1:
        i -= 1
        continue

    current = S[i]
    right = S[i + 1]

    if current != right:
        del S[i + 1]
        del S[i]
        number_of_deleted_qube += 2

    i -= 1

print(number_of_deleted_qube)


Error: 0

Fixed submission:

S = input()
S = [Si for Si in S]

i = len(S) - 2
number_of_deleted_qube = 0
while i >= 0 and len(S) >= 2:
    current = S[i]
    right = S[i + 1]

    if current != right:
        del S[i + 1]
        del S[i]
        number_of_deleted_qube += 2

    i -= 1

print(number_of_deleted_qube)
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

S = list(input())

zero_S = S.count("0")
one_S = S.count("1")

print(min(zero_S, one_S) * 2)


Error: TLE

Fixed submission:

S = input()
init_len = len(S)

while True:
    cur_len = len(S)
    S = S.replace("01", "")
    S = S.replace("10", "")
    if len(S) == cur_len:
        print(init_len - cur_len)
        exit()
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
ans = min(s.count("0"), s.count("1"))
print(ans * 2)


Error: TLE

Fixed submission:

# s1 = input()
# len_s = len(s1)
# s2 = s1
# while True:
#     len_1 = len(s2)
#     s2 = s2.replace("01", "").replace("10", "")
#     len_2 = len(s2)
#     if len_1 == len_2:
#         break
#
# print(len_s - len(s2))

s = input()
s2 = s
# for i in range(len(s) // 2, 0, -1):
#     # print("i", i)
#     # print("s2", s2)
#     m1 = "1" * i + "0" * i
#     m2 = "0" * i + "1" * i
#     s2 = s2.replace(m1, "").replace(m2, "")

while True:
    len_1 = len(s2)

    a1 = "000111"
    a2 = "111000"
    if a1 in s2:
        s2 = s2.replace(a1, "")
    if a2 in s2:
        s2 = s2.replace(a2, "")

    a3 = "0011"
    a4 = "1100"
    if a3 in s2:
        s2 = s2.replace(a3, "")
    if a4 in s2:
        s2 = s2.replace(a4, "")

    a5 = "01"
    a6 = "10"
    if a5 in s2:
        s2 = s2.replace(a5, "")
    if a6 in s2:
        s2 = s2.replace(a6, "")

    len_2 = len(s2)
    if len_1 == len_2:
        break

print(len(s) - len_2)
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
a = s.count("0")
b = s.count("1")
print(min(a, b) * 2)


Error: TLE

Fixed submission:

s = list(input())
n = len(s)
pos = 0
cnt = 0

while pos != n - 1 and n != 0:
    if s[pos] != s[pos + 1]:
        del s[pos]
        del s[pos]
        pos = 0
        n -= 2
        cnt += 2
    else:
        pos += 1

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

S = input()

zero = 0
one = 0

for ch in S:
    if ch == "0":
        zero = zero + 1
    else:
        one = one + 1

print(min(zero, one) * 2)


Error: TLE

Fixed submission:

import re

S = input()

trimmed = 0

while True:
    tmp = re.split("01|10", S)
    if len(tmp) == 1:
        break
    else:
        trimmed = trimmed + len(tmp) - 1
        S = "".join(tmp)

print(trimmed * 2)
Problem p03107 (Python) — buggy submission, verdict: Runtime Error

S = list(input())
a = S.count("0")
b = S.count("1")
ans = 2 * min(a, b)
print(ans)


Error: TypeError: 'int' object is not iterable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03107/Python/s301284896.py", line 1, in <module>
    S = list(int(input()))
TypeError: 'int' object is not iterable


Fixed submission:

S = list(int(input()))
a = S.count(0)
b = S.count(1)
ans = 2 * min(a, b)
print(ans)
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
cube_list = [s[0]]
s = s[1:]
count = 0
for c in s:
    if cube_list:
        if cube_list[-1] == c:
            cube_list.append(c)
        else:
            count += 2
            cube_list.pop(-1)
    else:
        cube_list.append(c)
print(count)


Error: TLE

Fixed submission:

s = input()
count = 0
s = s + "a"
while True:
    if "01" in s:
        s = s.replace("01", "", 1)
        count += 2
    elif "10" in s:
        s = s.replace("10", "", 1)
        count += 2
    else:
        break
print(count)
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
print(2 * min(s.count("0"), s.count("1")))


Error: TLE

Fixed submission:

s = input()
count = 0

while s.find("01") != -1 or s.find("10") != -1:
    count += 2 * s.count("01")
    s = s.replace("01", "")
    count += 2 * s.count("10")
    s = s.replace("10", "")
print(count)
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

S = input()
print(2 * min(S.count("1"), S.count("0")))


Error: TLE

Fixed submission:

S = input()
cnt1 = 0
cnt2 = 0
while True:
    before = S
    S = before.replace("01", "", 1)
    if before != S:
        cnt1 += 1
    else:
        break

while True:
    before = S
    S = before.replace("10", "", 1)
    if before != S:
        cnt2 += 1
    else:
        break

print(2 * (cnt1 + cnt2))
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
zom = min(s.count("1"), s.count("0"))
if len(set(list(s))) == 1:
    zom = 0
print(zom * 2)


Error: TLE

Fixed submission:

b = list(map(int, input()))
cnt = 0
while len(b) > 1:

    if len(list(set(b))) == 1:
        break
    if b[0] != b[1]:
        b = b[2:]
        cnt += 1
        continue
    temp = b[:1]
    b = b[1:]
    b.append(*temp)
print(cnt * 2)
Problem p03107 (Python) — buggy submission, verdict: Time Limit Exceeded

s = input()
n = len(s)
num_0 = s.count("0")
num_1 = n - num_0

print(n - abs(num_0 - num_1))


Error: TLE

Fixed submission:

s = input()
n = len(s)


def divide(x):
    a = "".join(x.split("01"))
    b = "".join(a.split("10"))
    return b


def judge(x):
    return len(x.split("01")) == 1 and len(x.split("10")) == 1


while not judge(s):
    s = divide(s)

print(n - len(s))
Problem p03107 (Python) — buggy submission, verdict: Runtime Error

s = list(input())

# Note: init
# cnt = 0
# i = 1
#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)
#         i -= 1
#         cnt += 2
#     i += 1
#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt * 2)


Error: 0

Fixed submission:

s = list(input())

cnt = 0
i = 0

while i < len(s):
    while len(s) != 0 and s[i] != s[i + 1]:
        s.pop(i)
        s.pop(i)
        cnt += 2
        i -= 1
    i += 1

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

n, m = map(int, input().split())
par = [-1] * n  # 親だった場合は-(その集合のサイズ)


# xがどのグループに属しているか調べる
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return find(par[x])


# 自分のいるグループの数
def size(x):
    return -par[find(x)]


# xとyの属する集合を併合
def unite(x, y):
    # 根を探す
    x, y = find(x), find(y)

    # 根が一緒
    if x == y:
        return

    # 大きい方に小さい方をくっつける
    if size(x) < size(y):
        x, y = y, x

    # xのサイズを更新
    par[x] += par[y]
    # yの親をxにする
    par[y] = x


# 同じ集合に属するか判定
def same(x, y):
    return find(x) == find(y)


bridges = [list(map(int, input().split())) for _ in range(m)]
bridges.reverse()
huben = n * (n - 1) // 2
ans = []
for i in range(m):
    ans.append(huben)
    a, b = bridges[i]
    a, b = a - 1, b - 1
    if same(a, b):
        continue
    else:
        huben -= size(a) * size(b)
        unite(a, b)
ans = ans[::-1]
for i in range(m):
    print(ans[i])


Error: TLE

Fixed submission:

n, m = map(int, input().split())
par = [-1 for i in range(n)]  # 親だった場合は-(その集合のサイズ)


# xがどのグループに属しているか調べる
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return find(par[x])


# 自分のいるグループの数
def size(x):
    return -par[find(x)]


# xとyの属する集合を併合
def unite(x, y):
    # 根を探す
    x, y = find(x), find(y)

    # 根が一緒
    if x == y:
        return

    # 大きい方に小さい方をくっつける
    if size(x) < size(y):
        x, y = y, x

    # xのサイズを更新
    par[x] += par[y]
    # yの親をxにする
    par[y] = x


# 同じ集合に属するか判定
def same(x, y):
    return find(x) == find(y)


bridges = [list(map(int, input().split())) for _ in range(m)]
bridges.reverse()
huben = n * (n - 1) // 2
ans = []
for i in range(m):
    ans.append(huben)
    a, b = bridges[i]
    a, b = a - 1, b - 1
    if not same(a, b):
        huben -= size(a) * size(b)
    unite(a, b)
for i in range(m):
    print(ans[::-1][i])
Problem p03108 (Python) — buggy submission, verdict: Runtime Error

n, m = map(int, input().split())
par = [-1] * n  # 親だった場合は-(その集合のサイズ)


# xがどのグループに属しているか調べる
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return find(par[x])


# 自分のいるグループの数
def size(x):
    return -par[find(x)]


# xとyの属する集合を併合
def unite(x, y):
    # 根を探す
    x, y = find(x), find(y)

    # 根が一緒
    if x == y:
        return

    # 大きい方に小さい方をくっつける
    if size(x) < size(y):
        x, y = y, x

    # xのサイズを更新
    par[x] += par[y]
    # yの親をxにする
    par[y] = x


# 同じ集合に属するか判定
def same(x, y):
    return find(x) == find(y)


bridges = [list(map(int, input().split())) for _ in range(m)]
bridges.reverse()
huben = n * (n - 1) // 2
ans = []
for i in range(m):
    ans.append(huben)
    a, b = bridges[i]
    a, b = a - 1, b - 1
    if same(a, b):
        continue
    else:
        huben -= size(a) * size(b)
        unite(a, b)
ans.reverse()
for i in range(m):
    print(ans[i])


Error: TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03108/Python/s038545963.py", line 59, in <module>
    print(ans[i])
TypeError: 'NoneType' object is not subscriptable


Fixed submission:

n, m = map(int, input().split())
par = [-1] * n  # 親だった場合は-(その集合のサイズ)


# xがどのグループに属しているか調べる
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return find(par[x])


# 自分のいるグループの数
def size(x):
    return -par[find(x)]


# xとyの属する集合を併合
def unite(x, y):
    # 根を探す
    x, y = find(x), find(y)

    # 根が一緒
    if x == y:
        return

    # 大きい方に小さい方をくっつける
    if size(x) < size(y):
        x, y = y, x

    # xのサイズを更新
    par[x] += par[y]
    # yの親をxにする
    par[y] = x


# 同じ集合に属するか判定
def same(x, y):
    return find(x) == find(y)


bridges = [list(map(int, input().split())) for _ in range(m)]
bridges.reverse()
huben = n * (n - 1) // 2
ans = []

for i in range(m):
    ans.append(huben)
    a, b = bridges[i]
    a, b = a - 1, b - 1
    if same(a, b):
        continue
    else:
        huben -= size(a) * size(b)
        unite(a, b)
ans = ans.reverse()
for i in range(m):
    print(ans[i])
Problem p03108 (Python) — buggy submission, verdict: Time Limit Exceeded

import io
import sys

lines = sys.stdin.read().splitlines()[::-1]


def readline():
    return lines.pop()


N, M = map(int, readline().split())
A = []
B = []
for _ in range(M):
    a, b = map(int, readline().split())
    A.append(a - 1)
    B.append(b - 1)

uf = [-1] * N
values = []
for i in range(M - 1, -1, -1):
    a = A[i]
    b = B[i]

    cur = a
    while 0 <= uf[cur]:
        cur = uf[cur]
    num_a = -uf[cur]
    root_a = cur
    cur = a
    while 0 <= uf[cur]:
        nxt = uf[cur]
        uf[cur] = root_a
        cur = nxt

    cur = b
    while 0 <= uf[cur]:
        cur = uf[cur]
    num_b = -uf[cur]
    root_b = cur
    cur = b
    while 0 <= uf[cur]:
        nxt = uf[cur]
        uf[cur] = root_b
        cur = nxt

    if root_a != root_b:
        values.append(num_a * num_b)

        if num_a < num_b:
            uf[root_b] += uf[root_a]
            cur = uf[root_a]
            uf[root_a] = root_b
            while 0 <= cur and 0 <= uf[cur]:
                nxt = uf[cur]
                uf[cur] = root_b
                cur = nxt
        else:
            uf[root_a] += uf[root_b]
            cur = uf[root_b]
            uf[root_b] = root_a
            while 0 <= cur and 0 <= uf[cur]:
                nxt = uf[cur]
                uf[cur] = root_a
                cur = nxt
    else:
        values.append(0)

total = 0
out = io.StringIO()
for v in reversed(values):
    total += v
    print(total, file=out)
print(out.getvalue())


Error: TLE

Fixed submission:

N, M = map(int, input().split())
A = []
B = []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a - 1)
    B.append(b - 1)

uf = [-1] * N
values = []
for i in range(M - 1, -1, -1):
    a = A[i]
    b = B[i]

    cur_a = a
    while 0 <= uf[cur_a]:
        cur_a = uf[cur_a]
    num_a = -uf[cur_a]
    root_a = cur_a

    cur_b = b
    while 0 <= uf[cur_b]:
        cur_b = uf[cur_b]
    num_b = -uf[cur_b]
    root_b = cur_b

    if root_a != root_b:
        values.append(num_a * num_b)

        uf[root_b] += uf[root_a]
        cur = uf[root_a]
        uf[root_a] = root_b
        while 0 <= cur and 0 <= uf[cur]:
            nxt = uf[cur]
            uf[cur] = root_b
            cur = nxt
    else:
        values.append(0)

total = 0
for v in reversed(values):
    total += v
    print(total)
Problem p03110 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
ans = 0
for _ in range(n):
    x, y = input().split()
    x = float(x)
    if y == "JPY":
        ans += x
    else:
        ans += x * 380000.0
print(ans)


Error: ValueError: invalid literal for int() with base 10: 'JPY'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03110/Python/s397276903.py", line 4, in <module>
    x, y = map(int, input().split())
ValueError: invalid literal for int() with base 10: 'JPY'


Fixed submission:

n = int(input())
ans = 0
for _ in range(n):
    x, y = map(int, input().split())
    if y == "JPY":
        ans += x
    else:
        ans += 380000
print(ans)
Problem p03110 (Python) — buggy submission, verdict: Runtime Error

N = int(input())

money = 0
for _ in range(N):
    x, u = input().split()
    if u == "JPY":
        money += float(x)
    else:
        money += float(x) * 380000
print(money)


Error: ValueError: invalid literal for int() with base 10: 'JPY'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03110/Python/s996181332.py", line 5, in <module>
    x, u = map(int, input().split())
ValueError: invalid literal for int() with base 10: 'JPY'


Fixed submission:

N = int(input())

money = 0
for _ in range(N):
    x, u = map(int, input().split())
    if u == "JPY":
        money += x
    else:
        money += x * 380000
print(money)