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

D, T, S = map(int, input().split())

if D <= T * S:
    print("Yes")
else:
    print("No")


Error: ValueError: invalid literal for int() with base 10: '1000 15 80'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02570/Python/s595588431.py", line 1, in <module>
    D = int(input())
ValueError: invalid literal for int() with base 10: '1000 15 80'


Fixed submission:

D = int(input())
T = int(input())
S = int(input())

if D <= T * S:
    print("Yes")
else:
    print("NO")
Problem p02570 (Python) — buggy submission, verdict: Runtime Error

D, T, S = list(map(int, input().split()))

if D <= S * T:
    print("Yes")
else:
    print("No")


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


Fixed submission:

D, T, S = list(map(input().split()))

if D <= S * T:
    print("Yes")
else:
    print("No")
Problem p02571 (Python) — buggy submission, verdict: Runtime Error

S = input()
T = input()

maxcount = 0
for i in range(len(S) - len(T) + 1):
    count = 0
    for j in range(len(T)):
        if S[i + j] == T[j]:
            count += 1
        maxcount = max(maxcount, count)
print(len(T) - maxcount)


Error: WA

Fixed submission:

S = input()
T = input()

for i in range(len(S) - len(T)):
    count = 0
    maxcount = 0
    for j in range(len(T)):
        if S[i + j] == T[j]:
            count += 1
        maxcount = max(maxcount, count)
print(len(T) - maxcount)
Problem p02571 (Python) — buggy submission, verdict: Runtime Error

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

s = input()
t = input()

a = []
for i in range(len(s) - len(t) + 1):
    cnt = 0
    for j in range(len(t)):
        if t[j] == s[i + j]:
            cnt += 1
    a.append(cnt)
print(len(t) - max(a))


Error: 0

Fixed submission:

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

s = input()
t = input()

a = []
for i in range(len(s) - len(t)):
    cnt = 0
    for j in range(len(t)):
        if t[j] == s[i + j]:
            cnt += 1
    a.append(cnt)
print(len(t) - max(a))
Problem p02571 (Python) — buggy submission, verdict: Time Limit Exceeded

n_gram = lambda t, n: [t[i : i + n] for i in range(len(t) - n + 1)]

S = input()
T = input()

t_len = len(T)
count = t_len

s_list = n_gram(S, t_len)

for s in s_list:
    c = 0
    for i in range(len(s)):
        if s[i] != T[i]:
            c += 1
    count = min(count, c)

print(count)


Error: TLE

Fixed submission:

S = input()
T = input()

count = len(T)

for i in range(len(T)):
    for j in range(len(S)):
        if T[i] == S[j]:
            start = j - i
            end = j + (len(T) - i)
            if start < 0 or end > len(S):
                continue
            else:
                s = S[start:end]
                c = 0
                for k in range(len(T)):
                    if T[k] != s[k]:
                        c += 1
                count = min(count, c)
print(count)
Problem p02571 (Python) — buggy submission, verdict: Runtime Error

s = input().strip()
t = input().strip()

if t in s:
    print(0)
else:
    ans = 10001
    for i in range(len(s) - len(t) + 1):
        count = 0
        cnt = i
        for j in range(len(t)):
            if s[cnt] != t[j]:
                count += 1
            cnt += 1
        ans = min(count, ans)
    print(ans)


Error: 0

Fixed submission:

s = input().strip()
t = input().strip()

if t in s:
    print(0)
else:
    ans = 1000
    for i in range(len(s) - len(t) - 1):
        count = len(t) - 1
        for j in range(len(t) - 1):
            if s[i + j] == t[i]:
                count -= 1
        ans = min(count, ans)
    print(ans)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

input = sys.stdin.buffer.readline
MOD = 10**9 + 7

N = int(input())
A = [0] + list(map(int, input().split()))

C = [0]
for i in range(1, len(A)):
    C.append(C[-1] + A[i])

ans = 0
for i in range(1, N):
    ans += A[i] * (C[-1] - C[i])

ans %= MOD
print(ans)


Error: TLE

Fixed submission:

import sys
from collections import defaultdict

input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

D = defaultdict(int)
for i in range(N - 1):
    for j in range(i + 1, N):
        v = A[i] * A[j] % MOD
        D[v] += 1
# print(D)

ans = 0
for key, item in D.items():
    ans += key * item
    # ans = (ans + (key * item)) % MOD
ans %= MOD
print(ans)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

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

S = sum(A)
S2 = sum(map(lambda x: x * x, A))

print((S * S - S2) // 2 % 1000000007)


Error: TLE

Fixed submission:

import itertools

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

C = list(itertools.combinations(A, 2))

ans = 0
for i, j in C:
    ans += i * j
    ans = ans % (1e9 + 7)
print(int(ans))
Problem p02572 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
a = list(map(int, input().split()))
s = [0]
ans = 0
MOD = 1000000007
for i in range(0, n, 1):
    s.append((s[i] + a[i]) % MOD)

for i in range(0, n, 1):
    ans += ((s[n] - s[i + 1]) * a[i]) % MOD

print(ans % MOD)


Error: TLE

Fixed submission:

import numpy as np


def mo(v):
    return v % 1000000007


n = int(input())
a = mo(np.array(list(map(int, input().split()))))
s = 0
for i in range(0, n - 1, 1):
    for j in range(i + 1, n, 1):
        s += mo(a[i] * a[j])
print(mo(s))
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

_ = input()
A = list(map(int, input().split()))
mod = 10**9 + 7

s = 0
a = 0
for _a in A:
    s += _a * a
    a = (a + _a) % mod
print(s % mod)


Error: TLE

Fixed submission:

import itertools

_ = input()
A = list(map(int, input().split()))
mod = 10**9 + 7

print(sum([(ai * aj) % mod for ai, aj in itertools.combinations(A, 2)]) % mod)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A_list = list(map(int, input().split()))
A_list.insert(0, 0)

cum_sum = 0
cum_sum_list = []
for i in range(N + 1):
    cum_sum += A_list[i]
    cum_sum_list.append(cum_sum)

ans = 0
for i in range(1, N + 1):
    ans += A_list[i] * (cum_sum_list[N] - cum_sum_list[i])
    ans = ans % 1000000007
print(ans)


Error: TLE

Fixed submission:

import itertools

N = int(input())
A_list = list(map(int, input().split()))
A_list.insert(0, 0)
product_dict = {}
for i, j in itertools.combinations(range(len(A_list)), 2):
    product_dict[str(i) + "&" + str(j)] = A_list[i] * A_list[j]

sum = 0
for i in range(1, N):
    for j in range(i + 1, N + 1):
        sum += product_dict[str(i) + "&" + str(j)]
        sum = sum % 1000000007
print(sum)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = [int(x) for x in input().split()]

gokei = sum(A) ** 2
for i in range(len(A)):
    gokei -= A[i] * A[i]
gokei = gokei // 2
ans = gokei % 1000000007
print(ans)


Error: TLE

Fixed submission:

N = int(input())
A = [int(x) for x in input().split()]

gokei = 0
for i in range(len(A)):
    gokei += A[i] * sum(A)
    gokei -= A[i] * A[i]
gokei = gokei // 2
ans = gokei % 1000000007
print(ans)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = list(map(int, input().split()))
ans = 0
a_sum = 0
for i in range(len(A)):
    ans += A[i] * a_sum
    a_sum += A[i]
ans = ans % 1000000007
print(ans)


Error: TLE

Fixed submission:

N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)):
    ans += A[i] * sum(A[0:i])
ans = ans % 1000000007
print(ans)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3


def solve(N, A):
    MOD = 10**9 + 7
    total = sum(A)
    ans = 0

    for i in range(N - 1):
        total -= A[i]
        ans += A[i] * total
        ans %= MOD

    return ans


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

    ans = solve(N, A)

    print(ans)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python3

from itertools import combinations

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

total = sum([x * y for x, y in list(combinations(A, 2))])
result = total % (10**9 + 7)
print(result)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3

# from typing import Optional
# from typing import List
# from typing import Dict
# from typing import Tuple
# from typing import Sequence


def main():
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))

    sum = 0
    mod = 1000000000 + 7

    sumJ = 0
    for j in range(N):
        sumJ += A[j]

    for i in range(N - 1):
        sumJ -= A[i]
        sum += A[i] * sumJ
        sum = sum % mod

    print(sum)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python3

# from typing import Optional
# from typing import List
# from typing import Dict
# from typing import Tuple
# from typing import Sequence


def main():
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))

    sum = 0
    mod = 1000000000 + 7
    for i in range(N - 1):
        for j in range(i + 1, N):
            sum += A[i] * A[j]
            sum = sum % mod

    print(sum)


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

N = int(input())
A = list(map(int, input().split()))
ans = 0
m = 1000000007

s = 0
for i in range(N):
    ans += A[i] * s
    s += A[i]

print(ans % m)


Error: TLE

Fixed submission:

import itertools

N = int(input())
A = [int(n) for n in input().split()]
ans = 0
m = 1000000007

for x, y in itertools.combinations(A, 2):
    ans += x * y

print(ans % m)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = list(map(int, input().split()))
ans = 0
a_sum = sum(a)
a_sum -= a[0]
for i in range(n - 1):
    ans += a[i] * a_sum
    a_sum -= a[i + 1]
ans %= 1000000007
print(ans)


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += a[i] * a[j]
ans %= 1000000007
print(ans)
Problem p02572 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python
# -*- coding: utf-8 -*-


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

    s = sum(A)
    ans = 0
    mod = 10**9 + 7
    for i in A:
        ans = ans + i * (s - i)
    print((ans // 2) % mod)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python
# -*- coding: utf-8 -*-


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

    ans = 0

    for i in range(N):
        for j in range(i + 1, N):
            ans += A[i] * A[j]

    print(ans % (10**9 + 7))


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

n = int(input())
a = list(map(int, input().split()))
s1 = sum(a)
s2 = 0
ans = 0
for i in range(n - 1):
    s2 += a[i]
    ans += a[i] * (s1 - s2)
print(ans % 1000000007)


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n):
    for j in range(i + 1, n):
        s += a[i] * a[j]
        s %= 1000000007
print(s % 1000000007)
Problem p02573 (Python) — buggy submission, verdict: Runtime Error

n, m = map(int, input().split())
par = list(range(n))


def find(x):
    while par[x] != x:
        par[x] = par[par[x]]
        x = par[x]
    return x


def union(x, y):
    x1 = find(x)
    y1 = find(y)
    if x1 != y1:
        par[x1] = y1


for j in range(m):
    a, b = map(int, input().split())
    union(a - 1, b - 1)

s = [0 for i in range(n + 1)]

for k in range(n):
    s[find(k)] += 1


print(max(s))


Error: 0

Fixed submission:

def solve(N, M, fridens):
    parents = {}
    groups = {}
    for A, B in friends:
        parents[B] = A
        if A not in groups:
            if A not in parents:
                groups[A] = [A]
            else:
                continue
        groups[A].append(B)

    ans = len(max(groups.values(), key=len))
    print(ans)


if __name__ == "__main__":
    N, M = map(int, input().split())
    friends = []
    for _ in range(M):
        AB = sorted([x - 1 for x in map(int, input().split())])
        if AB not in friends:
            friends.append(AB)
    solve(N, M, friends)
Problem p02573 (Python) — buggy submission, verdict: Time Limit Exceeded

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):  # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # 要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):  # 要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)

    def size(self, x):  # 要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):  # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # グループの数を返す
        return len(self.roots())

    def all_group_members(self):  # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):  # ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
        return "\\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())


uf = UnionFind(N)
for i in range(M):
    uf.union(AB[i][0] - 1, AB[i][1] - 1)
l = []
for i in range(N):
    l.append(uf.size(i))
print(max(l))


Error: TLE

Fixed submission:

import numpy as np
from collections import deque

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]

seen = [0] * N
visitm = [True] * M
listm = np.arange(M)
q = deque()
group = []

for i in range(N):
    if seen[i]:
        continue
    q.append(i)
    seen[i] = 1
    k = 1
    while q:
        t = q.popleft()
        for j in listm[visitm]:
            if AB[j][0] == i + 1 and seen[AB[j][1] - 1] != 1:
                q.append(AB[j][1])
                seen[AB[j][1] - 1] = 1
                k += 1
            if AB[j][1] == i + 1 and seen[AB[j][0] - 1] != 1:
                q.append(AB[j][0] - 1)
                seen[AB[j][0] - 1] = 1
                k += 1
            visitm[j] = False
    group.append(k)

print(max(group))
Problem p02573 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3
import sys


def input():
    return sys.stdin.readline()[:-1]


# uf = UnionFind(要素数)   で使用
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n  # 各要素の親要素の番号を格納するリスト 要素が根の場合は-(グループの要素数)を格納

    def find(self, x):  # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # 要素xが属するグループと、要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # 要素xが属するグループのサイズ(要素数)を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):  # 要素xと要素yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)

    def members(self, x):  # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # グループの数を返す
        return len(self.roots())

    def all_group_members(self):  # {ルート要素: [そのグループに含まれる要素のリスト], ...} の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())


def main():
    N, M = map(int, input().split())
    A = [0] * M
    B = [0] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())

    uf = UnionFind(N + 1)
    for i in range(M):
        uf.union(A[i], B[i])

    ans = 0
    for i in range(1, N + 1):
        ans = max(ans, uf.size(i))
    print(ans)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python3
N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

friend = [[0]]
for i in range(M):
    for f in friend:
        if A[i] not in f and B[i] not in f:
            friend.append([A[i], B[i]])
        elif A[i] in f and B[i] not in f:
            f.append(B[i])
        elif A[i] not in f and B[i] in f:
            f.append(A[i])
        else:
            pass

ans = 0
for f in friend:
    ans = max(ans, len(f))
print(ans)
Problem p02573 (Python) — buggy submission, verdict: Runtime Error

import sys

sys.setrecursionlimit(10000000)

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

d = {i: [] for i in range(1, N + 1)}
for _ in range(M):
    a, b = list(map(int, input().split()))
    d[a].append(b)
    d[b].append(a)

visited = [False for _ in range(N + 1)]


def visit(x):
    if visited[x]:
        return 0
    visited[x] = True

    z = 1
    for y in d[x]:
        z += visit(y)
    return z


m = 1
for i in range(1, N + 1):
    r = visit(i)
    if m < r:
        m = r

print(m)


Error: 0

Fixed submission:

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

d = {i: [] for i in range(1, N + 1)}
for _ in range(M):
    a, b = list(map(int, input().split()))
    d[a].append(b)
    d[b].append(a)

visited = [False for _ in range(N + 1)]


def visit(x):
    if visited[x]:
        return 0
    visited[x] = True

    z = 1
    for y in d[x]:
        z += visit(y)
    return z


m = 1
for i in range(1, N + 1):
    r = visit(i)
    if m < r:
        m = r

print(m)
Problem p02574 (Python) — buggy submission, verdict: Runtime Error

import math
from functools import reduce

n = int(input())
a_list = list(map(int, input().split()))
max = 10**6 + 1
memo = [0] * max

for a in a_list:
    memo[a] += 1

for i in range(2, max):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")


Error: 0

Fixed submission:

import math
from functools import reduce

n = int(input())
a_list = list(map(int, input().split()))
max = a_list[n - 1] + 100
memo = [0] * max

for a in a_list:
    memo[a] += 1

for i in range(2, max):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")
Problem p02574 (Python) — buggy submission, verdict: Runtime Error

import math
from functools import reduce

n = int(input())
a_list = list(map(int, input().split()))
max = 10**6 + 1
memo = [0] * max

for a in a_list:
    memo[a] += 1

for i in range(2, max):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")


Error: 0

Fixed submission:

import math
from functools import reduce

n = int(input())
a_list = list(map(int, input().split()))
max = a_list[-1] + 1
memo = [0] * max

for a in a_list:
    memo[a] += 1

for i in range(2, max):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")
Problem p02574 (Python) — buggy submission, verdict: Runtime Error

import math
from functools import reduce

L = 10**6 + 1
n = int(input())
a_list = list(map(int, input().split()))
memo = [0] * L

for a in a_list:
    memo[a] += 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")


Error: 0

Fixed submission:

import math
from functools import reduce

n = int(input())
a_list = list(map(int, input().split()))
memo = [0] * (a_list[-1] + 1)

for a in a_list:
    memo[a] += 1

for i in range(2, a_list[-1] + 1):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")
Problem p02574 (Python) — buggy submission, verdict: Time Limit Exceeded

from math import gcd

n = int(input())


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


pp = set()
a = [int(i) for i in input().split()]

j = 0
for i in a:
    j = gcd(j, i)
ok1 = j == 1

ma = 2 * 10**6
table = [0] * ma
for i in a:
    table[i] += 1
ok2 = True
for i in range(2, ma):
    s = 0
    for j in range(i, ma, i):
        s += table[j]
    if s > 1:
        ok2 = False

if ok2:
    print("pairwise coprime")
else:
    if ok1:
        print("setwise coprime")
    else:
        print("not coprime")


Error: TLE

Fixed submission:

from math import gcd

n = int(input())


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


pp = set()
a = [int(i) for i in input().split()]

j = 0
for i in a:
    j = gcd(j, i)
ok1 = j == 1

ok2 = True
for i in a:
    for (j, _) in p(i):
        if j in pp:
            ok2 = False
        else:
            pp.add(j)
if ok2:
    print("pairwise coprime")
else:
    if ok1:
        print("setwise coprime")
    else:
        print("not coprime")
Problem p02577 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
if n % 9 == 0:
    print("Yes")
else:
    print("No")


Error: TLE

Fixed submission:

n = int(input())
sum = 0
while n > 0:
    sum += n % 10
    n = n // 10
if sum % 9 == 0:
    print("Yes")
else:
    print("No")
Problem p02577 (Python) — buggy submission, verdict: Time Limit Exceeded

n = list(input())
a = 0
for i in range(len(n)):
    a += int(n[i])
if a % 9 == 0:
    print("Yes")
else:
    print("No")


Error: TLE

Fixed submission:

n = int(input())
a = 0
while n:
    a += n % 10
    n //= 10
if a % 9 == 0:
    print("Yes")
else:
    print("No")
Problem p02577 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
s = 0

s = sum(list(map(int, str(N))))

if s % 9 == 0:
    print("Yes")
else:
    print("No")


Error: TLE

Fixed submission:

N = int(input())
s = 0

while N != 0:
    s = s + N % 10
    N = N // 10

if s % 9 == 0:
    print("Yes")
else:
    print("No")