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

# -*- coding: utf-8 -*-
import math

N = int(input()) - 1
M = 0
x = int(math.ceil((N) / 2))
if N % 2 == 0:
    M = x * (N + 1)
else:
    M = (x - 1) * (N + 1) + x
print(M)


Error: TLE

Fixed submission:

# -*- coding: utf-8 -*-
N = int(input())
sum = 0
for i in range(N):
    sum += i
print(sum)
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())

if N % 2 == 1:
    print(N * (N - 1) // 2)
else:
    print(N * (N // 2 - 1) + N // 2)


Error: TLE

Fixed submission:

N = int(input())

sum = 0
for i in range(N):
    sum += i
print(sum)
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
print(N * (N - 1) // 2)


Error: TLE

Fixed submission:

N = int(input())
print(sum([i for i in range(1, N)]))
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
print(sum(range(1, n)))


Error: TLE

Fixed submission:

n = int(input())

sum = 0
for i in range(1, n):
    sum += i

print(sum)
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
print(((n * (n + 1)) // 2) - n)


Error: TLE

Fixed submission:

n = int(input())
print(sum(range(n)))
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys
import math

sys.setrecursionlimit(4100000)


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


def solve(inputs):
    [N] = string_to_int(inputs[0])
    num = N - 1
    if num == 0:
        return 0
    if num == 1:
        return 1
    if num % 2 == 0:
        # half_l = math.floor(num / 2)
        # half = (half_l + half_l + 1) / 2
        half = num // 2
        append = num // 2
    else:
        half = (num + 1) // 2
        append = 0
        # half = math.floor(num / 2)
    return half * num + append


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


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


Error: TLE

Fixed submission:

import sys

sys.setrecursionlimit(4100000)


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


def solve(inputs):
    [N] = string_to_int(inputs[0])
    count = 0
    for x in range(1, N):
        count += x
    return count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
n = n - 1
if n % 2 == 1:
    ans = ((n + 1) // 2) * n
else:
    ans = n + (n // 2) * (n - 1)
print(ans)


Error: TLE

Fixed submission:

n = int(input())
ans = 0
for i in range(1, n):
    ans += i
print(ans)
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
print(N * (N - 1) // 2)


Error: TLE

Fixed submission:

N = int(input())
ans = 0
for i in range(N):
    ans += i

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

n = int(input())
print((n * (n - 1)) // 2)


Error: TLE

Fixed submission:

n = int(input())
m = [i for i in range(n)]
print(sum(m))
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())

ans = N * (N - 1) // 2

print(ans)


Error: TLE

Fixed submission:

N = int(input())

lis = [i for i in range(1, N)]

print(sum(lis))
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
ret = (1 + N) * N // 2 - N
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print(ret)


Error: TLE

Fixed submission:

N = int(input())
ret = 0
for i in range(1, N):
    ret += i
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print(ret)
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
print(((N - 1) * N // 2))


Error: TLE

Fixed submission:

print(sum(range(1, int(input()))))
Problem p02924 (Python) — buggy submission, verdict: Time Limit Exceeded

# 2020/08/16
# AtCoder Beginner Contest 139 - D

# Input
n = int(input())

# Calc
ans = n * (n - 1) // 2

# Output
print(ans)


Error: TLE

Fixed submission:

# 2020/08/16
# AtCoder Beginner Contest 139 - D

# Input
n = int(input())

# Calc
asum = 0
# for i in range(1, n+1):
#     asum = asum + (n + 1 - i) % i
for i in range(1, n):
    asum = asum + i

# Output
print(asum)
Problem p02925 (Python) — buggy submission, verdict: Time Limit Exceeded

def check(player):
    if not a[player]:
        return
    opponent = a[player][-1]
    if not a[opponent]:
        return
    if a[opponent][-1] == player:
        tpl = (player, opponent)
        q.add((min(tpl), max(tpl)))


n = int(input())

a = []
for _ in range(n):
    t = list(map(lambda x: int(x) - 1, input().split()))
    t.reverse()
    a.append(t)

q = set()
for i in range(n):
    check(i)

day = 0
while q:
    day += 1
    prev_q = set()
    q, prev_q = prev_q, q
    for player, opponent in prev_q:
        a[player].pop()
        a[opponent].pop()
    for player, opponent in prev_q:
        check(player)
        check(opponent)

if any(a[player] for player in range(n)):
    print(-1)
    exit()

print(day)


Error: TLE

Fixed submission:

import sys

input = sys.stdin.readline

n = int(input())

e = [[] for _ in range(n)]
for i in range(n):
    a = map(int, input().split())
    for aa in a:
        aa -= 1
        e[i].append(aa)
# print(e)

inds = [0] * n
cur = [e[i][0] for i in range(n)]
# print(cur)
cnt = 0
while sum(cur) != -n:
    flg = False
    bls = [False] * n
    for ind, target in enumerate(cur):
        if bls[ind] or bls[target]:
            continue
        if cur[target] == ind:
            flg = True
            inds[ind] += 1
            inds[target] += 1
            bls[ind] = True
            bls[target] = True
            cur[ind] = e[ind][inds[ind]] if inds[ind] < n - 1 else -1
            cur[target] = e[target][inds[target]] if inds[target] < n - 1 else -1
    if not flg:
        print(-1)
        exit()
    cnt += 1
    # print(cur, cnt)

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

from collections import defaultdict

n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]

adj = defaultdict(list)
in_deg = defaultdict(int)
for u, row in enumerate(a, 1):
    for v1, v2 in zip(row, row[1:]):
        uu1, vv1 = min(u, v1), max(u, v1)
        uu2, vv2 = min(u, v2), max(u, v2)
        match1 = uu1 + vv1 * 1000
        match2 = uu2 + vv2 * 1000
        adj[match1].append(match2)
        in_deg[match1]
        in_deg[match2] += 1

now = [key for key, val in in_deg.items() if val == 0]
day = 0
while now:
    day += 1
    nxt = []
    for u in now:
        for v in adj[u]:
            in_deg[v] -= 1
            if in_deg[v] == 0:
                nxt.append(v)

    now = nxt

if max(in_deg.values()) > 0:
    day = -1

print(day)


Error: TLE

Fixed submission:

from collections import defaultdict

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

adj = defaultdict(list)
in_deg = defaultdict(int)
for u, row in enumerate(a, 1):
    for v1, v2 in zip(row, row[1:]):
        uu1, vv1 = min(u, v1), max(u, v1)
        uu2, vv2 = min(u, v2), max(u, v2)
        adj[(uu1, vv1)].append((uu2, vv2))
        in_deg[(uu1, vv1)]
        in_deg[(uu2, vv2)] += 1

now = [tpl for tpl, val in in_deg.items() if val == 0]
day = 0
while now:
    day += 1
    nxt = []
    for u in now:
        for v in adj[u]:
            in_deg[v] -= 1
            if in_deg[v] == 0:
                nxt.append(v)

    now = nxt

if max(in_deg.values()) > 0:
    day = -1

print(day)
Problem p02925 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import setrecursionlimit


def encode(i, j):
    if i < j:
        i, j = j, i
    return i * (i - 1) // 2 + j + 1


def dfs(v):
    if visited[v] == 2:
        return dp[v]
    visited[v] = 1
    for nv in g[v]:
        if visited[nv] == 1:
            print(-1)
            exit()
        dp[v] = max(dp[v], dfs(nv) + 1)
    visited[v] = 2
    return dp[v]


setrecursionlimit(10**6)
N = int(input())
GAMES_CNT = N * (N - 1) // 2
g = [[] for _ in range(GAMES_CNT + 1)]
for i in range(N):
    orig = 0
    for j in map(lambda x: int(x) - 1, input().split()):
        dest = encode(i, j)
        g[orig].append(dest)
        orig = dest
dp = [0] * (GAMES_CNT + 1)
visited = [0] * (GAMES_CNT + 1)
print(dfs(0))


Error: TLE

Fixed submission:

def solve():
    rem = N * (N - 1) // 2
    for day in range(N * (N - 1) // 2):
        did_play = [0] * N
        for i in range(N):
            if did_play[i] or A[i] == []:
                continue
            opponent = A[i][-1]
            if A[opponent][-1] == i and not did_play[opponent]:
                A[i].pop()
                A[opponent].pop()
                rem -= 1
                did_play[i] = 1
                did_play[opponent] = 1
        if sum(did_play) == 0:
            break
        if rem == 0:
            return day + 1
    return -1


N = int(input())
A = [list(map(lambda x: int(x) - 1, input().split()))[::-1] for _ in range(N)]
print(solve())
Problem p02925 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

N = int(input())
A = [list(map(lambda x: int(x) - 1, input().split(" "))) for i in range(N)]

canUse = set(range(N))

ans = 0
done = 0
while done < N:
    ans += 1
    canUseNew = set()
    # print("LC", len(canUse))
    for n in canUse:
        if not A[n]:
            continue

        first = A[n][-1]
        if first in canUseNew or n in canUseNew:
            continue

        if A[first][-1] == n:
            # print("Do", n + 1, first + 1)
            A[n].pop()
            if len(A[n]) == 0:
                done += 1
            A[first].pop()
            if len(A[first]) == 0:
                done += 1
            canUseNew.add(n)
            canUseNew.add(first)

    if len(canUseNew) == 0:
        print(-1)
        sys.exit(0)
    canUse = canUseNew

print(ans)


Error: TLE

Fixed submission:

import sys

N = int(input())
A = [list(map(lambda x: int(x) - 1, input().split(" "))) for i in range(N)]

canUse = set(range(N))

ans = 0
while any([len(i) > 0 for i in A]):
    # print("\\nDay", ans)
    ans += 1
    canUseNew = set()
    for n in canUse:
        if not A[n]:
            continue

        first = A[n][-1]
        if first in canUseNew or n in canUseNew:
            continue

        if A[first][-1] == n:
            # print("Do", n + 1, first + 1)
            A[n].pop()
            A[first].pop()
            canUseNew.add(n)
            canUseNew.add(first)

    if len(canUseNew) == 0:
        print(-1)
        sys.exit(0)
    canUse = canUseNew

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

N = int(input())

G = [list(map(int, input().split())) for _ in range(N)]
cur = [0] * N
edge = [0] * N
for i in range(N):
    edge[i] = G[i][0] - 1

day = 0
player = set(range(N))
cnt = 0
while len(player) > 0:
    day += 1
    game = set()
    for i in player:
        e = edge[i]
        if i == edge[e] and i != e:
            game.add(i)
            game.add(e)
    player = set()
    for j in game:
        cur[j] += 1
        c = cur[j]
        if c >= N - 1:
            edge[j] = j
        else:
            edge[j] = G[j][c] - 1
            player.add(j)

if min(cur) != N - 1:
    ans = -1
else:
    ans = day
print(ans)


Error: TLE

Fixed submission:

N = int(input())

G = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]
cur = [0] * N
edge = [0] * N
for i in range(N):
    edge[i] = G[i][cur[i]]

day = 0
player = set(range(N))
while len(player) > 0:
    day += 1
    game = []
    for i in player:
        if i == edge[edge[i]]:
            game.append(i)
    if len(game) == 0:
        print(-1)
        exit()
    else:
        for j in game:
            cur[j] += 1
            c = cur[j]
            if c >= N - 1:
                player.remove(j)
            else:
                edge[j] = G[j][c]

print(day)
Problem p02925 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

l = [i for i in range(n)]
pos = [0] * n
res = 0
cnt = 0
while True:
    res += 1
    flag = True
    tmp = l.copy()
    l = []
    used = [False] * n
    for v in tmp:
        if used[v] or pos[v] == n - 1:
            continue

        opp = a[v][pos[v]] - 1

        if used[opp] or pos[opp] == n - 1:
            continue

        if a[opp][pos[opp]] - 1 == v:
            pos[v] += 1
            pos[opp] += 1
            l.append(v)
            l.append(opp)
            used[v] = True
            used[opp] = True
            flag = False
            if pos[v] == n - 1:
                cnt += 1
            if pos[opp] == n - 1:
                cnt += 1

    if flag:
        print(-1)
        break

    if cnt == n:
        print(res)
        break


Error: TLE

Fixed submission:

import sys

n = int(input())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
ans = 0
pos = [0] * n

while any([(n - 1) - x for x in pos]):
    pos_check = [False] * n
    checker = True
    for i in range(n):
        for j in range(i + 1, n):
            if pos[i] == n - 1 or pos[j] == n - 1:
                continue
            if a[i][pos[i]] == j + 1 and a[j][pos[j]] == i + 1:
                pos_check[i] = True
                pos_check[j] = True
    for i in range(n):
        if pos_check[i]:
            pos[i] += 1
            checker = False
    if checker:
        print(-1)
        sys.exit()
    ans += 1
print(ans)
Problem p02925 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import deque, defaultdict
from time import time

S = time()

N = int(input())
A = [deque(map(lambda a: int(a) - 1, input().split())) for _ in range(N)]

canBattle = defaultdict(lambda: False)
D = [0] * N

while True:
    isChanged = False
    for i, a in enumerate(A):
        if not a:
            continue
        j = a[0]
        canBattle[(i, j)] = True

        if canBattle[(j, i)]:
            isChanged = True
            A[i].popleft()
            A[j].popleft()
            d = max(D[i], D[j])
            D[i], D[j] = d + 1, d + 1
    if all(len(a) == 0 for a in A):
        print(max(D))
        exit()
    if time() - S >= 1.700:
        print(N * (N - 1) // 2)
        exit()
    if not isChanged:
        break

print(-1)


Error: TLE

Fixed submission:

from collections import deque, defaultdict
from time import time

N = int(input())
A = [deque(map(lambda a: int(a) - 1, input().split())) for _ in range(N)]
S = time()

canBattle = defaultdict(lambda: False)
D = [0] * N

while True:
    isChanged = False
    for i, a in enumerate(A):
        if not a:
            continue
        j = a[0]
        canBattle[(i, j)] = True

        if canBattle[(j, i)]:
            isChanged = True
            A[i].popleft()
            A[j].popleft()
            d = max(D[i], D[j])
            D[i], D[j] = d + 1, d + 1
    if all(len(a) == 0 for a in A):
        print(max(D))
        exit()
    if time() - S >= 1.800:
        print(N * (N - 1) // 2)
        exit()
    if not isChanged:
        break

print(-1)
Problem p02925 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import setrecursionlimit


def get_node_id(i, j, node_id_db):
    if i < j:
        return node_id_db[i][j]
    else:
        return node_id_db[j][i]


def dfs(node_id, edges, dp):
    t = dp[node_id]
    if t >= 0:
        return t
    dp[node_id] = 0
    result = 0
    for n in edges[node_id]:
        t = dfs(n, edges, dp)
        if t == 0:  # looped
            print(-1)
            exit()
        if t > result:
            result = t
    result += 1
    dp[node_id] = result
    return result


def main():
    N = int(input())
    A = [[int(e) - 1 for e in input().split()] for _ in range(N)]

    node_id_db = [[0] * N for _ in range(N)]
    v = 0
    for i in range(N):
        for j in range(i + 1, N):
            node_id_db[i][j] = v
            v += 1

    start_nodes = []
    edges = [[] for _ in range(N * (N - 1) // 2)]
    for i in range(N):
        Ai = A[i]
        from_id = get_node_id(i, Ai[0], node_id_db)
        if i < Ai[0]:
            start_nodes.append(from_id)
        for j in range(1, N - 1):
            to_id = get_node_id(i, Ai[j], node_id_db)
            edges[from_id].append(to_id)
            from_id = to_id

    dp = [-1] * (N * (N - 1) // 2)
    print(max(dfs(n, edges, dp) for n in start_nodes))


setrecursionlimit(10**6)
main()


Error: TLE

Fixed submission:

from sys import exit, setrecursionlimit


def get_node_id(i, j, node_id_db):
    if i < j:
        return node_id_db[i][j]
    else:
        return node_id_db[j][i]


def dfs(node_id, edges, dp):
    t = dp[node_id]
    if t >= 0:
        return t
    dp[node_id] = 0
    result = 0
    for n in edges[node_id]:
        t = dfs(n, edges, dp)
        if t == 0:  # looped
            print(-1)
            exit()
        if t > result:
            result = t
    result += 1
    dp[node_id] = result
    return result


setrecursionlimit(1000000)

N = int(input())
A = [[int(e) - 1 for e in input().split()] for _ in range(N)]

node_id_db = [[0] * N for _ in range(N)]
v = 0
for i in range(N):
    for j in range(i + 1, N):
        node_id_db[i][j] = v
        v += 1

start_nodes = []
edges = [[] for _ in range(N * (N - 1) // 2)]
for i in range(N):
    Ai = A[i]
    from_id = get_node_id(i, Ai[0], node_id_db)
    if i < Ai[0]:
        start_nodes.append(from_id)
    for j in range(1, N - 1):
        to_id = get_node_id(i, Ai[j], node_id_db)
        edges[from_id].append(to_id)
        from_id = to_id

dp = [-1] * (N * (N - 1) // 2)
print(max(dfs(n, edges, dp) for n in start_nodes))
Problem p02925 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys
from collections import deque


def topological_check(roots, out_links, in_count):
    depth = [0] * match_count
    for r in roots:
        depth[r] = 1
    q = deque(roots)
    while q:
        v = q.popleft()
        d = depth[v] + 1
        for u in out_links[v]:
            in_count[u] -= 1
            if in_count[u] == 0:
                depth[u] = d
                q.append(u)
    if any(in_count):
        return -1
    return max(depth)


n = int(input())
match_count = n * (n - 1) // 2

offsets = [0]
tmp = -2
for i in range(1, n + 1):
    offsets.append(tmp)
    tmp += n - i - 1

roots = set()
in_links = [set() for _ in range(match_count)]
out_links = [set() for _ in range(match_count)]

for i, line in enumerate(sys.stdin, start=1):
    aaa = list(map(int, line.split()))
    j = aaa[0]
    prev = offsets[i] + j if i < j else offsets[j] + i
    roots.add(prev)

    for j in aaa[1:]:
        key = offsets[i] + j if i < j else offsets[j] + i
        out_links[prev].add(key)
        in_links[key].add(prev)
        prev = key

in_count = list(map(len, in_links))
roots = {r for r in roots if in_count[r] == 0}

if not roots:
    print(-1)
    exit()

print(topological_check(roots, out_links, in_count))


Error: TLE

Fixed submission:

import sys


def topological_sort(root, links, in_count):
    topological = []
    q = root
    while q:
        v = q.pop()
        topological.append(v)
        for u in links[v]:
            in_count[u] -= 1
            if in_count[u] == 0:
                q.add(u)
    return topological


n = int(input())
match_count = n * (n - 1) // 2

offsets = [0]
tmp = -2
for i in range(1, n + 1):
    offsets.append(tmp)
    tmp += n - i - 1

roots = set()
in_links = [set() for _ in range(match_count)]
out_links = [set() for _ in range(match_count)]

for i, line in enumerate(sys.stdin, start=1):
    aaa = list(map(int, line.split()))
    j = aaa[0]
    prev = offsets[i] + j if i < j else offsets[j] + i
    roots.add(prev)

    for j in aaa[1:]:
        key = offsets[i] + j if i < j else offsets[j] + i
        out_links[prev].add(key)
        in_links[key].add(prev)
        prev = key

in_count = list(map(len, in_links))
roots = {r for r in roots if in_count[r] == 0}

if not roots:
    print(-1)
    exit()

topological = topological_sort(roots, out_links, in_count)
if len(topological) != match_count:
    print(-1)
    exit()

depth = [0] * match_count
for v in topological:
    depth[v] = max(map(depth.__getitem__, in_links[v]), default=0) + 1

print(max(depth))
Problem p02925 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
A = [list(int(x) - 1 for x in input().split()) for _ in range(n)]
B = [0] * n

ans = 1
stack = [i for i in range(n)]
while True:
    day_set = set()
    next_stack = []
    while stack:
        i = stack.pop()
        if i in day_set or B[i] >= n - 1:
            continue
        j = A[i][B[i]]
        if j in day_set or B[j] >= n - 1:
            continue
        if A[j][B[j]] == i:
            B[i] += 1
            B[j] += 1
            day_set.add(i)
            day_set.add(j)
            next_stack += [i, j]
            if all(b >= n - 1 for b in B):
                print(ans)
                exit()

    if not day_set:
        print(-1)
        exit()
    ans += 1
    stack = next_stack


Error: TLE

Fixed submission:

n = int(input())
A = [list(int(x) - 1 for x in input().split()) for _ in range(n)]
B = [0] * n

ans = 1
while True:
    day_set = set()
    for i in range(n):
        if i in day_set or B[i] >= n - 1:
            continue
        j = A[i][B[i]]
        if j in day_set or B[j] >= n - 1:
            continue
        if A[j][B[j]] == i:
            B[i] += 1
            B[j] += 1
            day_set.add(i)
            day_set.add(j)
            if all(b >= n - 1 for b in B):
                print(ans)
                exit()
    if not day_set:
        print(-1)
        exit()
    else:
        ans += 1
Problem p02928 (Python) — buggy submission, verdict: Runtime Error

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
cnt2 = 0
for i, ai in enumerate(a):
    for j in range(i, n):
        if ai > a[j]:
            cnt += 1
    if i > 0:
        for j in range(i):
            if ai > a[j]:
                cnt2 += 1

if k % 2 == 0:
    mul = (1 + k) * (k // 2)
else:
    mul = (1 + k) * (k // 2) + (k // 2 + 1)
mul2 = 0
if k > 1:
    k -= 1
    if k % 2 == 0:
        mul2 = (1 + k) * (k // 2)
    else:
        mul2 = (1 + k) * (k // 2) + (k // 2 + 1)
print(((cnt * mul) + (cnt2 * mul2)) % 1000000007)


Error: 0

Fixed submission:

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = 0
cnt2 = 0
for i, ai in enumerate(a):
    for j in range(i, n):
        if ai > a[j]:
            cnt += 1
    if i > 0:
        for j in range(i):
            if ai > a[j]:
                cnt2 += 1

if k % 2 == 0:
    mul = (1 + k) * (k // 2)
else:
    mul = (1 + k) * (k // 2) + (k // 2 + 1)
if k > 1:
    k -= 1
    if k % 2 == 0:
        mul2 = (1 + k) * (k // 2)
    else:
        mul2 = (1 + k) * (k // 2) + (k // 2 + 1)
print(((cnt * mul) + (cnt2 * mul2)) % 1000000007)
Problem p02933 (Python) — buggy submission, verdict: Runtime Error

a = int(input())
s = input()
print(s if a >= 3200 else "red")


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


Fixed submission:

a = int(input())
s = int(input())
print(s if a < 3200 else "red")
Problem p02934 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in a:
    ans += 1 / i
print(1 / ans)


Error: TypeError: 'int' object is not iterable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02934/Python/s273231160.py", line 4, in <module>
    for i in n:
TypeError: 'int' object is not iterable


Fixed submission:

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in n:
    ans += 1 / i
print(1 / ans)