Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                count += 1
print(count)

Fixed submission:
K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if z >= 0 and z <= K:
            count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = [int(v) for v in input().split()]

l = [1 for i in range(max(A)+1)]
for v in sorted(A):
    for j in range(2*v, max(A)+1, v):
        l[j] = 0

ans = 0
c = Counter(A)
for a in A:
    if c[a] > 1:continue
    ans += l[a]
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = [int(v) for v in input().split()]

m = max(A)
l = [1 for i in range(m+1)]
for v in sorted(A):
    for j in range(2*v, m+1, v):
        l[j] = 0

ans = 0
c = Counter(A)
for a in A:
    if c[a] > 1:continue
    ans += l[a]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
ans = 1

for a in A:
    ans *= a

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
N = int(input())
ans = 1

for a in sorted(input().split()):
    ans *= int(a)
    if ans > 10**18:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from queue import Queue
g = defaultdict(list)
visted = defaultdict(bool)
N, M = map(int, input().split())
for i in range(M):
    A, B = map(int, input().split())
    g[A].append(B)
    g[B].append(A)

h = {}
h2 = defaultdict(list)
def solve(v):
    height = 0
    visited = set()
    q = Queue()
    visited.add(v)
    h[v] = height
    h2[height].append(v)
    q.put(v)
    while not q.empty():
        v = q.get()
        height += 1
        for c in g[v]:
            if not c in visited:
                visited.add(c)
                h[c] = height
                h2[height].append(c)
                q.put(c)

solve(1)
ans = [0] * (N+1)

print('Yes')
for v in range(2, N+1):
    i = h[v]
    print(h2[i-1][0])

Fixed submission:
from collections import defaultdict
from queue import Queue
g = defaultdict(list)
visted = defaultdict(bool)
N, M = map(int, input().split())
for i in range(M):
    A, B = map(int, input().split())
    g[A].append(B)
    g[B].append(A)

h = [-1] * (N+1)

h2 = defaultdict(list)
def solve(v):
    visited = set()
    q = Queue()
    visited.add(v)
    h[v] = 0
    h2[0].append(v)
    q.put(v)
    while not q.empty():
        v = q.get()
        for c in g[v]:
            if not c in visited:
                visited.add(c)
                h[c] = h[v] + 1
                h2[h[v]+1].append(c)
                q.put(c)

solve(1)
ans = []

for v in range(2, N+1):
    i = h[v]

    for c in g[v]:
        if h[c] == i-1:
            ans.append(c)
            break


print('Yes')
for v in ans:
    print(v)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]
P = []
H = defaultdict(list)
for i, v in enumerate(A):
    H[i+v].append(i)
    P.append((i, i-v))
ans = 0

for i, v in P:
    for j in H[v]:
        if i > j:
            ans += 1
print(ans)

Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]
H = defaultdict(int)
ans = 0
for i, v in enumerate(A):
    ans += H[i-v]
    H[i+v] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(v) for v in input().split()]
P = sorted([(v, i) for i, v in enumerate(A)], key=lambda x: x[0], reverse=True)
dp = [[0 for j in range(2005)] for i in range(2005)]

for i in range(N):
    pi = P[i][1]
    for l in range(i+1):
        r = i - l
        dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + (pi - l) * A[pi])
        dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ((N-r-1) - pi) * A[pi])

ans = 0
for i in range(N+1):
    ans = max(ans, dp[N][i])

print(ans)


Fixed submission:
N = int(input())
A = [int(v) for v in input().split()]
P = sorted([(v, i) for i, v in enumerate(A)], key=lambda x: x[0], reverse=True)
dp = [[0 for j in range(2005)] for i in range(2005)]

for i in range(N):
    pi = P[i][1]
    for l in range(i+1):
        r = i - l
        dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + (pi - l) * A[pi])
        dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ((N-r-1) - pi) * A[pi])

ans = 0
for i in range(N+1):
    ans = max(ans, dp[N][i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
from itertools import permutations
r = []
g = []
b = []
for i, s in enumerate(S):
    if s == 'R':
        r.append(i)
    elif s == 'G':
        g.append(i)
    else:
        b.append(i)

ans = len(r)*len(g)*len(b)

for A, B, C in permutations([r,g,b]):
    for i in A:
        for j in B:
            k = 2 * j - i
            if k < N and i < j < k and S[i] != S[j] and S[i] != S[k] and S[j] != S[k]: 
                ans -= 1
print(ans)

Fixed submission:
N = int(input())
S = input()
from itertools import permutations
r = []
g = []
b = []
for i, s in enumerate(S):
    if s == 'R':
        r.append(i)
    elif s == 'G':
        g.append(i)
    else:
        b.append(i)

ans = len(r)*len(g)*len(b)

for A, B, C in permutations([r,g,b]):
    for i in A:
        for j in B:
            k = 2 * j - i
            if k < N and i < j < k and S[i] != S[j] and S[i] != S[k] and S[j] != S[k]: 
                ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

N, x, y = map(int, input().split())
graph = [[0 for i in range(N)] for i in range(N)]

for i in range(N-1):
    graph[i][i+1] = 1
    graph[i+1][i] = 1

graph[x-1][y-1] = 1
graph[y-1][x-1] = 1

graph = csr_matrix(graph)

result = floyd_warshall(csgraph=graph, directed=False)

ans = {i+1:0 for i in range(N)}

for i in range(N):
    for j in range(N):
        if result[i,j]  == 0:
            continue
        ans[int(result[i, j])] = ans[int(result[i,j])] + 1

for i in range(1, N):
    print(ans[i]//2)

Fixed submission:
N, X, Y = map(int, input().split())
from itertools import combinations

ans = {i+1:0 for i in range(N)}
for a, b in combinations(range(1, N+1), 2):
    t = b - a
    if a <= X:
        t = min(t, X - a + 1 + abs(Y - b))
    elif a <= Y:
        t = min(t, abs(a - X) + 1 + abs(Y - b))
    ans[t] += 1

for i in range(1, N):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
from collections import Counter
a = Counter(A)

for i in A:
    t = 0
    for k in a.keys():
        c = a[k]
        if k == i:
            c -= 1
        t += (c * (c-1)) // 2
    print(t)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
from collections import Counter
a = Counter(A)

T = 0
for k in a.keys():
    c = a[k]
    T += (c * (c-1)) // 2

for i in A:
    t = 0
    c = a[i]
    t = T
    t -= (c * (c-1)) // 2
    c -= 1
    t += (c * (c-1)) // 2
    print(t)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
from collections import Counter
a = Counter(A)

for i in A:
    t = 0
    for k in a.keys():
        c = a[k]
        if k == i:
            c -= 1
        t += (c * (c-1)) // 2
    print(t)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
from collections import Counter
a = Counter(A)

T = 0
for k in a.keys():
    c = a[k]
    T += (c * (c-1)) // 2

for i in A:
    t = 0
    c = a[i]
    t = T
    t -= (c * (c-1)) // 2
    c -= 1
    t += (c * (c-1)) // 2
    print(t)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
from collections import Counter
a = Counter(A)

for i in A:
    t = 0
    for k in a.keys():
        c = a[k]
        if k == i:
            c -= 1
        t += (c * (c-1)) // 2
    print(t)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
from collections import Counter
a = Counter(A)

T = 0
for k in a.keys():
    c = a[k]
    T += (c * (c-1)) // 2

for i in A:
    t = 0
    c = a[i]
    t = T
    t -= (c * (c-1)) // 2
    c -= 1
    t += (c * (c-1)) // 2
    print(t)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int, input().split())
M = 10**9 + 7
from math import factorial
from functools import reduce
A = pow(2,n,M) - 1
B = reduce(lambda x, y: x*y, [n-i for i in range(a)]) * pow(factorial(a), M - 2, M) % M
C = reduce(lambda x, y: x*y, [n-i for i in range(b)]) * pow(factorial(b), M - 2, M) % M
print((A-B-C)%M)

Fixed submission:
n,a,b = map(int, input().split())
M = 10**9 + 7
from math import factorial
from functools import reduce
A = pow(2,n,M) - 1

q = r = 1
for i in range(a):
    q = q * (n - i) %  M
for j in range(b):
    r = r * (n - j) %  M

B = q * pow(factorial(a), M - 2, M) % M
C = r * pow(factorial(b), M - 2, M) % M
print((A-B-C)%M)
Buggy python submission (verdict: Time Limit Exceeded):
H, N  = map(int, input().split())
dp = [float('inf')] * (H + 1)
dp[0] = 0
for i in range(N):
    a, b = map(int, input().split())
    for j in range(H):
        nj = min(j+a, H)
        dp[nj] = min(dp[nj], dp[j]+b)
print(dp[H])

Fixed submission:
H, N  = map(int, input().split())
dp = [float('inf')] * (H + 1)
dp[0] = 0
for i in range(N):
    a, b = map(int, input().split())
    for j in range(H):
        nj = min(j+a, H)
        dp[nj] = min(dp[nj], dp[j]+b)
print(dp[H])
Buggy python submission (verdict: Runtime Error):
from collections import Counter, defaultdict
G = defaultdict(list)
C = Counter()
N = int(input())
ans = {}
o = []
for i in range(N-1):
    a, b = map(int, input().split())
    C[a] += 1
    C[b] += 1
    G[a].append(b)
    G[b].append(a)
    ans[(a, b)] = 0
    o.append((a,b))

a = C.most_common(1)[0][0]
b = C.most_common(1)[0][1]

visited = [False] * (N+1)
def dfs(v, p):
    visited[v] = True
    counter = 1
    for c in G[v]:
        if not visited[c]:
            if p != 0 and counter == ans[(v, p)]:
                counter += 1
            ans[(v, c)] = ans[(c, v)] = counter
            counter += 1
            dfs(c, v)

dfs(a, 0)

print(b)
for a,b in o:
    print(ans[(a,b)])

Fixed submission:
from collections import Counter, defaultdict
from queue import Queue
G = defaultdict(list)

C = Counter()
N = int(input())
ans = {}
o = []
for i in range(N-1):
    a, b = map(int, input().split())
    C[a] += 1
    C[b] += 1
    G[a].append(b)
    G[b].append(a)
    ans[(a, b)] = 0
    o.append((a,b))

cs = [0] * (N+1)
def bfs(v):
    ret = 0
    visited = set()
    q = Queue()
    visited.add(v)
    q.put(v)
    while not q.empty():
        v = q.get()
        counter = 1
        for c in G[v]:
            if not c in visited:
                visited.add(c)
                if counter == cs[v]:
                    counter += 1
                cs[c] = ans[(c,v)] = ans[(v,c)] = counter
                counter += 1
                q.put(c)

bfs(1)
print(C.most_common(1)[0][1])
for a,b in o:
    print(ans[(a,b)])

Buggy python submission (verdict: Runtime Error):
from collections import Counter, defaultdict
G = defaultdict(list)
C = Counter()
N = int(input())
ans = {}
o = []
for i in range(N-1):
    a, b = map(int, input().split())
    C[a] += 1
    C[b] += 1
    G[a].append(b)
    G[b].append(a)
    ans[(a, b)] = 0
    o.append((a,b))

a = C.most_common(1)[0][0]
b = C.most_common(1)[0][1]

visited = [False] * (N+1)
def dfs(v, p):
    visited[v] = True
    counter = p
    for c in G[v]:
        if not visited[c]:
            c2,v2 = min(c,v), max(c,v)
            counter += 1
            if counter == N+1:
                counter = 1
            ans[(c2, v2)] = counter
            dfs(c, counter)

dfs(a, 0)

print(b)
for a,b in o:
    print(ans[(a,b)])

Fixed submission:
from collections import Counter, defaultdict
from queue import Queue
G = defaultdict(list)

C = Counter()
N = int(input())
ans = {}
o = []
for i in range(N-1):
    a, b = map(int, input().split())
    C[a] += 1
    C[b] += 1
    G[a].append(b)
    G[b].append(a)
    ans[(a, b)] = 0
    o.append((a,b))

cs = [0] * (N+1)
def bfs(v):
    ret = 0
    visited = set()
    q = Queue()
    visited.add(v)
    q.put(v)
    while not q.empty():
        v = q.get()
        counter = 1
        for c in G[v]:
            if not c in visited:
                visited.add(c)
                if counter == cs[v]:
                    counter += 1
                cs[c] = ans[(c,v)] = ans[(v,c)] = counter
                counter += 1
                q.put(c)

bfs(1)
print(C.most_common(1)[0][1])
for a,b in o:
    print(ans[(a,b)])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def prime_factorization(n):
    factor = []
    f = 2
    while f ** 2 <= n:
        if n % f == 0:
            factor.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        factor.append(n)
    return factor

p = prime_factorization(N)
from itertools import combinations as cb
from functools import reduce
from operator import mul

s = N+1
for i in range(1, len(p)//2+1):
    for j in cb(p, i):
        A = reduce(mul, j)
        B = N//A
        s = min(s, A+B)

print(s-2)

Fixed submission:
N = int(input())
S = N+1
from math import sqrt
for a in range(int(sqrt(N))+2, 0, -1):
    b, y = divmod(N, a)
    if y != 0:
        continue
    S = min(S, a+b)
print(S-2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def prime_factorization(n):
    factor = []
    f = 2
    while f ** 2 <= n:
        if n % f == 0:
            factor.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        factor.append(n)
    return factor

p = prime_factorization(N)
from itertools import combinations as cb
from functools import reduce
from operator import mul

s = N+1
for i in range(1, len(p)//2+2):
    for j in cb(p, i):
        A = reduce(mul, j)
        B = N//A
        s = min(s, A+B)

print(s-2)

Fixed submission:
N = int(input())
S = N+1
from math import sqrt
for a in range(int(sqrt(N))+2, 0, -1):
    b, y = divmod(N, a)
    if y != 0:
        continue
    S = min(S, a+b)
print(S-2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def prime_factorization(n):
    factor = []
    f = 2
    while f ** 2 <= n:
        if n % f == 0:
            factor.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        factor.append(n)
    return factor

p = prime_factorization(N)
from itertools import combinations as cb
from functools import reduce
from operator import mul

s = float('inf')
for i in range(1,len(p)+1):
    for j in cb(p, i):
        A = reduce(mul, j)
        B = N//A
        s = min(s, A+B)

print(s-2)

Fixed submission:
N = int(input())
S = N+1
from math import sqrt
for a in range(int(sqrt(N))+2, 0, -1):
    b, y = divmod(N, a)
    if y != 0:
        continue
    S = min(S, a+b)
print(S-2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def prime_factorization(n):
    factor = []
    f = 2
    while f ** 2 <= n:
        if n % f == 0:
            factor.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        factor.append(n)
    return factor

p = prime_factorization(N)
from itertools import combinations as cb
from functools import reduce
from operator import mul

s = float('inf')
for i in range(1,len(p)+1):
    for j in cb(p, i):
        A = reduce(mul, j)
        B = N//A
        s = min(s, A+B)

print(s-2)

Fixed submission:
N = int(input())
S = N+1
from math import sqrt
for a in range(int(sqrt(N))+2, 0, -1):
    b, y = divmod(N, a)
    if y != 0:
        continue
    S = min(S, a+b)
print(S-2)
Buggy python submission (verdict: Runtime Error):
a = ['Sunny', 'Cloudy', 'Rainy']
s = input()

i = a.index(s)
print(a[i + 1 % 3])

Fixed submission:
a = ['Sunny', 'Cloudy', 'Rainy']
s = input()

i = a.index(s)
print(a[(i + 1) % 3])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

dp = [[0 for j in range(N+10)] for i in range(N+10)]

for i in range(N-1, -1, -1):
    for j in range(N-1, -1, -1):
        if S[i] != S[j]:
            dp[i][j] = 0
        else:         
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        ans = max(ans, min(dp[i][j], j-i))

print(ans)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for j in range(N+10)] for i in range(N+10)]

for i in range(N-1, -1, -1):
    for j in range(N-1, -1, -1):
        if S[i] != S[j]:
            dp[i][j] = 0
        else:         
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        ans = max(ans, min(dp[i][j], j-i))

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
def f(i):
    if i == 0:
        return 0
    if i == 1:
        return 1
    if i == 2:
        if S[i-1] == S[i-2]:
            return 1
        else:
            return 2
    if S[i-1] == S[i-2]:
        return f(i-1) + 1
    else:
        return f(i-3) + 2

print(f(len(S)))

Fixed submission:
S = input()

l = [0] * (len(S) + 1)
l[1] = 1
if S[0] == S[1]:
    l[2] = 1
else:
    l[2] = 2

for i in range(3, len(S)+1):
    if S[i-1] != S[i-2]:
        l[i] = l[i-1] + 1
    else:
        l[i] = l[i-3] + 2

print(l[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
l = [[int(a) for a in input().split()] for i in range(N)]
l = sorted(l, key=lambda x: (-1*x[1], -1*x[0]))
ans = 0
j = 0
M += 1
for i in range(1, M+1):
    for k in range(j, N):
        a, b = l[j]
        if a + i <= M:
            ans += b
            j += 1
            break

print(ans)

Fixed submission:
import heapq
N, M = map(int, input().split())

L = [[int(i) for i in input().split()] for i in range(N)]
L = sorted(L, key=lambda x: -x[0])

h = []
ans = 0
j = N-1
for i in range(M-1, -1, -1):
    while j >= 0 and L[j][0] <= M - i:
        heapq.heappush(h, -L[j][1])
        j -= 1
    if len(h) == 0:
        continue
    ans += -heapq.heappop(h)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, P = map(int,input().split())
dist = [0] + [float('inf')] * (N - 1)

a = []
b = []
c = []

for i in range(M):
    i,j,k = map(int,input().split())
    a.append(i)
    b.append(j)
    c.append(-1*(k - P))

INF = float('inf')

for i in range(N-1):
    for j in range(M):
        if dist[a[j] - 1] == INF: continue
        if dist[b[j] - 1] > dist[a[j] - 1] + c[j]:
            dist[b[j] - 1] = dist[a[j] - 1] + c[j]
        
ans = dist[N -1]

negative = [False] * N

for i in range(N):
    for j in range(M):
        if dist[a[j] - 1] == INF: continue
        if dist[b[j] - 1] > dist[a[j] - 1] + c[j]:
            dist[b[j] - 1] = dist[a[j] - 1] + c[j]
            negative[b[j] - 1] = True

        if negative[a[j] - 1] == True:
            negative[b[j] - 1] = True

if negative[N - 1]:
    print(-1)
else:
    print(max(-1 * ans, 0))


Fixed submission:
N, M, P = map(int,input().split())
dist = [0] + [float('inf')] * (N - 1)

a = []
b = []
c = []

for i in range(M):
    i,j,k = map(int,input().split())
    a.append(i)
    b.append(j)
    c.append(-1*(k - P))

INF = float('inf')

for i in range(N-1):
    for j in range(M):
        if dist[a[j] - 1] == INF: continue
        if dist[b[j] - 1] > dist[a[j] - 1] + c[j]:
            dist[b[j] - 1] = dist[a[j] - 1] + c[j]
        
ans = dist[N -1]

negative = [False] * N

for i in range(N):
    for j in range(M):
        if dist[a[j] - 1] == INF: continue
        if dist[b[j] - 1] > dist[a[j] - 1] + c[j]:
            dist[b[j] - 1] = dist[a[j] - 1] + c[j]
            negative[b[j] - 1] = True

        if negative[a[j] - 1] == True:
            negative[b[j] - 1] = True

if negative[N - 1]:
    print(-1)
else:
    print(max(-1 * ans, 0))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
dp = [[0 for j in range(13)]for i in range(10**5+1)]
dp[0][0] = 1
for i in range(len(S)):
    c = 0
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])

    for j in range(10):
        if c != -1 and c!= j:
            continue
        for ki in range(13):
            dp[i+1][(ki*10+j)%13] += dp[i][ki]
    for j in range(13):
        dp[i+1][j] %= 10**9+7
    
print(dp[len(S)][5])

Fixed submission:
S = input()
dp = [[0 for j in range(13)]for i in range(10**5+1)]
dp[0][0] = 1
for i in range(len(S)):
    c = 0
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])

    for j in range(10):
        if c != -1 and c!= j:
            continue
        for ki in range(13):
            dp[i+1][(ki*10+j)%13] += dp[i][ki]
    for j in range(13):
        dp[i+1][j] %= 10**9+7
    
print(dp[len(S)][5])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from scipy import linalg

N = int(input())
A = [int(i) for i in input().split()]
b = np.array([2*i for i in A])
B = []
for i in range(N):
    l = [0] * N
    l[i % N] = 1
    l[(i+1)%N] = 1
    B.append(l)
A = np.array(B)
LU = linalg.lu_factor(A)
a = map(int, np.linalg.solve(A, b))
print(*a)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
D = [2*a for a in A]
X = [0] * (N+1)
for i in range(N):
    X[i+1] = D[i] - X[i]

X[0] = (X[0] + X[-1])//2

for i in range(N):
    X[i+1] = D[i] - X[i]

print(*X[:-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]
b = np.array([2*i for i in A])
B = []
for i in range(N):
    l = [0] * N
    l[i % N] = 1
    l[(i+1)%N] = 1
    B.append(l)
A = np.array(B)
a = map(int, np.linalg.solve(A, b))
print(*a)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
D = [2*a for a in A]
X = [0] * (N+1)
for i in range(N):
    X[i+1] = D[i] - X[i]

X[0] = (X[0] + X[-1])//2

for i in range(N):
    X[i+1] = D[i] - X[i]

print(*X[:-1])
Buggy python submission (verdict: Runtime Error):
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+1)] for i in range(N+1)]
C[1][1] = 1

for i in range(2, N):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1] % M

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)


Fixed submission:
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+3)] for i in range(N+3)]
C[1][1] = 1

for i in range(2, N+2):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1]

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)

Buggy python submission (verdict: Runtime Error):
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+1)] for i in range(N+1)]
C[1][1] = 1

for i in range(2, N):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1]

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)

Fixed submission:
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+3)] for i in range(N+3)]
C[1][1] = 1

for i in range(2, N+2):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1]

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)

Buggy python submission (verdict: Runtime Error):
N, K  = map(int, input().split())
M = 10 ** 9 + 7
from math import factorial as f
def c(n, r):
    return f(n)//(f(r)*f(n-r))

def h(s, n):
    return c(s-1, n-1)

for i in range(1, K+1):
    a = h(K, i)
    b = c(N-K+1, i)
    print(a*b%M)


Fixed submission:
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+3)] for i in range(N+3)]
C[1][1] = 1

for i in range(2, N+2):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1]

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)
Buggy python submission (verdict: Runtime Error):
l = ['%d%d'%(i, i) for i in range(10)]
S = input()
if S.count(l) > 0:
    print('Bad')
else:
    print('Good')

Fixed submission:
l = ['%d%d'%(i, i) for i in range(10)]
S = input()
if sum([S.count(i) for i in l]) > 0:
    print('Bad')
else:
    print('Good')