Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
a = [0]
b = [0]*2019
c = 0
d = 0
for n in range(len(S)):
    c += 10**n*int(S[-n-1])
    a.append(c%2019)
for n in range(len(S)+1):
    b[a[n]] += 1
for n in range(2019):
    d += int(b[n]*(b[n]-1)/2)
print(d)

Fixed submission:
S = input()
l = len(S)
a = [0]
b = [0]*2019
c = [1]
d = 0
e = 0
for n in range(l-1):
    c.append(c[n]*10%2019)
for n in range(l):
    d += int(S[-n-1])*c[n]
    a.append(d%2019)
for n in range(l+1):
    b[a[n]] += 1
for n in range(2019):
    e += int(b[n]*(b[n]-1)/2)
print(e)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
a = []
count = 0
for n in range(len(S)):
    a.append(10**n%2019)
for n in range(len(S)-3):
    z = int(S[-n-1])*a[0]+int(S[-n-2])*a[1]+int(S[-n-3])*a[2]+int(S[-n-4])*a[3]
    if z%2019 == 0:
        count += 1
    for m in range(len(S)-n-4):
        z += int(S[-m-n-5])*a[m+4]
        if z%2019 == 0:
            count += 1
print(count)

Fixed submission:
S = input()
l = len(S)
a = [0]
b = [0]*2019
c = [1]
d = 0
e = 0
for n in range(l-1):
    c.append(c[n]*10%2019)
for n in range(l):
    d += int(S[-n-1])*c[n]
    a.append(d%2019)
for n in range(l+1):
    b[a[n]] += 1
for n in range(2019):
    e += int(b[n]*(b[n]-1)/2)
print(e)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
a = []
count = 0
for n in range(len(S)):
    a.append(10**n%2019)
for n in range(len(S)-3):
    z = int(S[-n-1])*a[0]+int(S[-n-2])*a[1]+int(S[-n-3])*a[2]+int(S[-n-4])*a[3]
    if z%2019 == 0:
        count += 1
    for m in range(len(S)-n-4):
        z += int(S[-m-n-5])*a[m+4]
        if z%2019 == 0:
            count += 1
print(count)

Fixed submission:
S = input()
l = len(S)
a = [0]
b = [0]*2019
c = [1]
d = 0
e = 0
for n in range(l-1):
    c.append(c[n]*10%2019)
for n in range(l):
    d += int(S[-n-1])*c[n]
    a.append(d%2019)
for n in range(l+1):
    b[a[n]] += 1
for n in range(2019):
    e += int(b[n]*(b[n]-1)/2)
print(e)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
List = list(input())
count = 0
for k in range(n - 2):
    for l in range(k + 1, n - 1):
        if List[k] != List[l]:
            for m in range(l + 1, min(2 * l - k, n)):
                if List[k] != List[m] and List[l] != List[m]:
                    count += 1
            for m in range(min(2 * l - k + 1, n), n):
                if List[k] != List[m] and List[l] != List[m]:
                    count += 1
print(count)

Fixed submission:
n = int(input())
List = list(input())
count = List.count("R") * List.count("G") *List.count("B")
for w in range(1, n // 3 * 3 + 1):
    for s in range(n - 2 * w):
        if List[s] != List[s + w] and List[s] != List[s + w * 2] and List[s + w] != List[s + w * 2]:
            count -= 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
x, y, a, b, c = map(int, input().split())
Lista = sorted(list(map(int, input().split())), reverse = True)
Listb = sorted(list(map(int, input().split())), reverse = True)
Listc = sorted(list(map(int, input().split())), reverse = True)
if x < a:
    del Lista[x:a]
if y < b:
    del Listb[y:b]
List = sorted(Lista + Listb, reverse = True)
while len(Listc) > 0:
    if List[-1] < Listc[0]:
        List[-1] = Listc[0]
        List = sorted(List, reverse = True)
        del Listc[0]
    else:
        break
print(sum(List))

Fixed submission:
x, y, a, b, c = map(int, input().split())
Lista = sorted(list(map(int, input().split())), reverse = True)
Listb = sorted(list(map(int, input().split())), reverse = True)
Listc = sorted(list(map(int, input().split())), reverse = True)
if x < a:
    del Lista[x : a]
if y < b:
    del Listb[y : b]
List = sorted(Lista + Listb, reverse = True)
i = -1
for n in range(min(x + y, c)):
    if List[-n-1] < Listc[n]:
        i = n
    else:
        break
del List[x + y - i -1 : x + y]
del Listc[i + 1 : c]
print(sum(List) + sum(Listc))

Buggy python submission (verdict: Time Limit Exceeded):
x, y, a, b, c = map(int, input().split())
Lista = sorted(list(map(int, input().split())), reverse = True)
Listb = sorted(list(map(int, input().split())), reverse = True)
Listc = sorted(list(map(int, input().split())), reverse = True)
if x < a:
    del Lista[x:a]
if y < b:
    del Listb[y:b]
while len(Listc) > 0:
    if Lista[-1] < Listb[-1]:
        if Lista[-1] < Listc[0]:
            Lista[-1] = Listc[0]
            Lista = sorted(Lista, reverse = True)
            del Listc[0]
        else:
            break
    else:
        if Listb[-1] < Listc[0]:
            Listb[-1] = Listc[0]
            Listb = sorted(Listb, reverse = True)
            del Listc[0]
        else:
            break
print(sum(Lista) + sum(Listb))

Fixed submission:
x, y, a, b, c = map(int, input().split())
Lista = sorted(list(map(int, input().split())), reverse = True)
Listb = sorted(list(map(int, input().split())), reverse = True)
Listc = sorted(list(map(int, input().split())), reverse = True)
if x < a:
    del Lista[x : a]
if y < b:
    del Listb[y : b]
List = sorted(Lista + Listb, reverse = True)
i = -1
for n in range(min(x + y, c)):
    if List[-n-1] < Listc[n]:
        i = n
    else:
        break
del List[x + y - i -1 : x + y]
del Listc[i + 1 : c]
print(sum(List) + sum(Listc))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
a = 0
for m in range(n):
    k = l.count(m+1)
    a += int(k*(k-1)/2)
for m in range(n):
    print(a-l.count(l[m])+1)

Fixed submission:
n, m = map(int, input().split())
print(int(n*(n-1)/2+m*(m-1)/2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
a = 0
for m in range(n):
    k = l.count(m+1)
    a += int(k*(k-1)/2)
for m in range(n):
    print(a-l.count(l[m])+1)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
a = []
b = 0
for m in range(n):
    a.append(0)
for m in range(n):
    a[l[m]-1] += 1
for m in range(n):
    b += int(a[m]*(a[m]-1)/2)
for m in range(n):
    print(b-a[l[m]-1]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
a = 0
b = []
for m in range(n):
    b.append(l.count(m+1))
    k = b[m]
    a += int(k*(k-1)/2)
for m in range(n):
    print(a-b[l[m]-1]+1)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
a = []
b = 0
for m in range(n):
    a.append(0)
for m in range(n):
    a[l[m]-1] += 1
for m in range(n):
    b += int(a[m]*(a[m]-1)/2)
for m in range(n):
    print(b-a[l[m]-1]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
a = 0
for m in range(n):
    k = l.count(m+1)
    a += int(k*(k-1)/2)
for m in range(n):
    print(a-l.count(l[m])+1)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
a = []
b = 0
for m in range(n):
    a.append(0)
for m in range(n):
    a[l[m]-1] += 1
for m in range(n):
    b += int(a[m]*(a[m]-1)/2)
for m in range(n):
    print(b-a[l[m]-1]+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
    score = 0
    copy = l[:]
    del copy[i]
    for j in range(1,n+1):
        k = copy.count(j)
        score += int(k*(k-1)/2)
    print(score)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
a = []
b = 0
for m in range(n):
    a.append(0)
for m in range(n):
    a[l[m]-1] += 1
for m in range(n):
    b += int(a[m]*(a[m]-1)/2)
for m in range(n):
    print(b-a[l[m]-1]+1)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))

Fixed submission:
s = input()
if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
s = input()
a = []
c = 0
if p == 2:
    b = [0]*n
    for i in range(n):
        if int(s[i])%2 == 0:
            b[i] += 1
    for i in range(n):
        if b[i] == 1:
            c += i+1
elif p == 5:
    b = [0]*n
    for i in range(n):
        if int(s[i])%5 == 0:
            b[i] += 1
    for i in range(n):
        if b[i] == 1:
            c += i+1
else:
    b = [0]*p
    b[0] += 1
    for i in range(n):
        a.append(int(s[i:n])%p)
    for i in range(n):
        b[a[i]] += 1
    for i in range(p):
        c += int(b[i]*(b[i]-1)/2)
print(c)

Fixed submission:
n, p = map(int, input().split())
s = input()
a = []
c = 0
if p == 2:
    b = [0]*n
    for i in range(n):
        if int(s[i])%2 == 0:
            b[i] += 1
    for i in range(n):
        if b[i] == 1:
            c += i+1
elif p == 5:
    b = [0]*n
    for i in range(n):
        if int(s[i])%5 == 0:
            b[i] += 1
    for i in range(n):
        if b[i] == 1:
            c += i+1
else:
    b = [0]*p
    b[0] = 1
    d = [1]
    a.append(int(s[-1])%p)
    for i in range(n-1):
        d.append(d[-1]*10%p)
    for i in range(1, n):
        a.append((int(s[-i-1])*d[i]+a[i-1])%p)
    for i in range(n):
        b[a[i]] += 1
    for i in range(p):
        c += int(b[i]*(b[i]-1)/2)
print(c)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
    t, d = map(int, input().split())
    s.append(t)
    c.append(d)
a = -2
for i in range(m-1):
    for j in range(i+1, m):
        if s[i] == s[j]:
            if c[i] != c[j]:
                a = -1
if a == -2:
    if n == 1:
        a = c[0]
    if n == 2:
        for i in range(10, 100):
            b = 0
            for j in range(m):
                if s[j] == 1:
                    if i//10 == c[j]:
                        b += 1
                else:
                    if i%10 == c[j]:
                        b += 1
            if b == m:
                a = i
                break;
    if n == 3:
        for i in range(100, 1000):
            b = 0
            for j in range(m):
                if s[j] == 1:
                    if i//100 == c[j]:
                        b += 1
                elif s[j] == 1:
                    if (i//10)//10 == c[j]:
                        b += 1
                else:
                    if i%10 == c[j]:
                        b += 1
            if b == m:
                a = i
                break;
if a == -2:
    a = -1
print(a)

Fixed submission:
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
    t, d = map(int, input().split())
    s.append(t)
    c.append(d)
a = -2
if m == 0:
    if n == 1:
        a = 0
    elif n == 2:
        a = 10
    else:
        a = 100
else:
    for i in range(m-1):
        for j in range(i+1, m):
            if s[i] == s[j]:
                if c[i] != c[j]:
                    a = -1
    if a == -2:
        if n == 1:
            a = c[0]
        if n == 2:
            for i in range(10, 100):
                b = 0
                for j in range(m):
                    if s[j] == 1:
                        if i//10 == c[j]:
                            b += 1
                    else:
                        if i%10 == c[j]:
                            b += 1
                if b == m:
                    a = i
                    break;
        if n == 3:
            for i in range(100, 1000):
                b = 0
                for j in range(m):
                    if s[j] == 1:
                        if i//100 == c[j]:
                            b += 1
                    elif s[j] == 2:
                        if (i//10)%10 == c[j]:
                            b += 1
                    else:
                        if i%10 == c[j]:
                            b += 1
                if b == m:
                    a = i
                    break;
    if a == -2:
        a = -1
print(a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [[] for i in range(n)]; b = [-1]*n; b[0] = 0
for i in range(n-1):
    u, v, w = map(int, input().split())
    a[u-1].append([v-1, w]); a[v-1].append([u-1, w])
def dfs(A, k):
    for i in A[k]:
        if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0])
dfs(a, 0)
for i in b:
    print(0) if i%2 == 0 else print(1)

Fixed submission:
import sys
sys.setrecursionlimit(500*500)
n = int(input())
a = [[] for _ in range(n)]; b = [-1]*n; b[0] = 0
for i in range(n-1):
    u, v, w = map(int, input().split())
    a[u-1].append([v-1, w]); a[v-1].append([u-1, w])
def dfs(A, k):
    for i in A[k]:
        if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0])
dfs(a, 0)
for i in b:
    print(0) if i%2 == 0 else print(1)
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
a = [input() for i in range(h)]
b = [-1]*h*w; c = []; d = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == "#": b[i*w+j] = 0; c.append(i*w+j)
while len(c) < h*w:
    if c[d]//w != 0:
        if b[c[d]-w] == -1: b[c[d]-w] = b[c[d]]+1; c.append(c[d]-w)
    if c[d]%w != 0:
        if b[c[d]-1] == -1: b[c[d]-1] = b[c[d]]+1; c.append(c[d]-1)
    if c[d]%w != w-1:
        if b[c[d]+1] == -1: b[c[d]+1] = b[c[d]]+1; c.append(c[d]+1)
    if c[d]//w != h-1:
        if b[c[d]+w] == -1: b[c[d]+w] = b[c[d]]+1; c.append(c[d]+w)
    d += 1
print(max(b))

Fixed submission:
h, w = map(int, input().split())
a = [input() for i in range(h)]
b = [-1]*h*w; c = []; d = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == "#": b[i*w+j] = 0; c.append(i*w+j)
while len(c) < h*w:
    if c[d]//w != 0:
        if b[c[d]-w] == -1: b[c[d]-w] = b[c[d]]+1; c.append(c[d]-w)
    if c[d]%w != 0:
        if b[c[d]-1] == -1: b[c[d]-1] = b[c[d]]+1; c.append(c[d]-1)
    if c[d]%w != w-1:
        if b[c[d]+1] == -1: b[c[d]+1] = b[c[d]]+1; c.append(c[d]+1)
    if c[d]//w != h-1:
        if b[c[d]+w] == -1: b[c[d]+w] = b[c[d]]+1; c.append(c[d]+w)
    d += 1
print(max(b))

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [input() for i in range(h)]
b = [-1]*h*w; c = []; d = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == "#": b[i*w+j] = 0; c.append(i*w+j)
while len(c) < h*w:
    if c[d]//w != 0:
        if b[c[d]-w] == -1: b[c[d]-w] = b[c[d]]+1; c.append(c[d]-w)
    if c[d]%w != 0:
        if b[c[d]-1] == -1: b[c[d]-1] = b[c[d]]+1; c.append(c[d]-1)
    if c[d]%w != w-1:
        if b[c[d]+1] == -1: b[c[d]+1] = b[c[d]]+1; c.append(c[d]+1)
    if c[d]//w != w-1:
        if b[c[d]+w] == -1: b[c[d]+w] = b[c[d]]+1; c.append(c[d]+w)
    d += 1
print(max(b))

Fixed submission:
h, w = map(int, input().split())
a = [input() for i in range(h)]
b = [-1]*h*w; c = []; d = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == "#": b[i*w+j] = 0; c.append(i*w+j)
while len(c) < h*w:
    if c[d]//w != 0:
        if b[c[d]-w] == -1: b[c[d]-w] = b[c[d]]+1; c.append(c[d]-w)
    if c[d]%w != 0:
        if b[c[d]-1] == -1: b[c[d]-1] = b[c[d]]+1; c.append(c[d]-1)
    if c[d]%w != w-1:
        if b[c[d]+1] == -1: b[c[d]+1] = b[c[d]]+1; c.append(c[d]+1)
    if c[d]//w != h-1:
        if b[c[d]+w] == -1: b[c[d]+w] = b[c[d]]+1; c.append(c[d]+w)
    d += 1
print(max(b))
Buggy python submission (verdict: Runtime Error):
from function import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
M = []
maximum = 0
for n in range(N):
    L.append(gcd(A[n], L[-1]))
    R.append(gcd(A[-n-1], R[-1]))
R.reverse()
for n in range(N):
    M.append(gcd(L[n], R[n+1]))
for n in range(N):
    maximum = max(maximum, M[n])
print(maximum)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
M = []
maximum = 0
for n in range(N):
    L.append(gcd(A[n], L[-1]))
    R.append(gcd(A[-n-1], R[-1]))
R.reverse()
for n in range(N):
    M.append(gcd(L[n], R[n+1]))
for n in range(N):
    maximum = max(maximum, M[n])
print(maximum)

Buggy python submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
M = []
maximum = 0
for n in range(N):
    L.append(gcd(A[n], L[-1]))
    R.append(gcd(A[-n-1], R[-1]))
R.reverse()
for n in range(N):
    M.append(gcd(L[n], R[n+1]))
for n in range(N):
    maximum = max(maximum, M[n])
print(maximum)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
M = []
maximum = 0
for n in range(N):
    L.append(gcd(A[n], L[-1]))
    R.append(gcd(A[-n-1], R[-1]))
R.reverse()
for n in range(N):
    M.append(gcd(L[n], R[n+1]))
for n in range(N):
    maximum = max(maximum, M[n])
print(maximum)
Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse = True)
b = sorted(list(map(int, input().split())), reverse = True)
c = sorted(list(map(int, input().split())), reverse = True)
d = []
e = []
for m in range(x):
    for n in range(y):
        d.append(a[m]+b[n])
d.sort(reverse = True)
for m in range(z):
    for n in range(min(3000, len(d))):
        e.append(c[m]+d[n])
e.sort(reverse = True)
for n in range(k):
    print(e[n])

Fixed submission:
x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse = True)
b = sorted(list(map(int, input().split())), reverse = True)
c = sorted(list(map(int, input().split())), reverse = True)
d = []
e = []
for m in range(x):
    for n in range(y):
        d.append(a[m]+b[n])
d.sort(reverse = True)
for m in range(z):
    for n in range(min(3000, len(d))):
        e.append(c[m]+d[n])
e.sort(reverse = True)
for n in range(k):
    print(e[n])
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
A = []
B = [0]*Q
for n in range(N-1):
    if S[n:n+2] == "AC":
        A.append(n)
for n in range(Q):
    l, r = map(int, input().split())
    for m in range(len(A)):
        if A[m] >= l-1:
            if A[m] <= r-2:
                B[n] += 1
            else:
                break;
for n in range(Q):
    print(B[n])

Fixed submission:
N, Q = map(int, input().split())
S = input()
A = [0]*(N-1)
B = [0]
C = []
for n in range(N-1):
    if S[n:n+2] == "AC":
        A[n] += 1
for n in range(N-1):
    B.append(B[n]+A[n])
for n in range(Q):
    l, r = map(int, input().split())
    C.append(B[r-1]-B[l-1])
for n in range(Q):
    print(C[n])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
A = []
B = [0]*Q
for n in range(N-1):
    if S[n:n+2] == "AC":
        A.append(n)
for n in range(Q):
    l, r = map(int, input().split())
    for m in range(len(A)):
        if A[m] >= l-1 and A[m] <= r-2:
            B[n] += 1
for n in range(Q):
    print(B[n])

Fixed submission:
N, Q = map(int, input().split())
S = input()
A = [0]*(N-1)
B = [0]
C = []
for n in range(N-1):
    if S[n:n+2] == "AC":
        A[n] += 1
for n in range(N-1):
    B.append(B[n]+A[n])
for n in range(Q):
    l, r = map(int, input().split())
    C.append(B[r-1]-B[l-1])
for n in range(Q):
    print(C[n])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
A = [0]*(N-1)
B = []
for n in range(N-1):
    if S[n:n+2] == "AC":
        A[n] += 1
for n in range(Q):
    l, r = map(int, input().split())
    B.append(sum(A[l-1:r-1]))
for n in range(Q):
    print(B[n])

Fixed submission:
N, Q = map(int, input().split())
S = input()
A = [0]*(N-1)
B = [0]
C = []
for n in range(N-1):
    if S[n:n+2] == "AC":
        A[n] += 1
for n in range(N-1):
    B.append(B[n]+A[n])
for n in range(Q):
    l, r = map(int, input().split())
    C.append(B[r-1]-B[l-1])
for n in range(Q):
    print(C[n])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
L = []
for n in range(Q):
    l, r = map(int, input().split())
    R = S[l-1:r]
    L.append(R.count("AC"))
for n in range(Q):
    print(L[n])

Fixed submission:
N, Q = map(int, input().split())
S = input()
A = [0]*(N-1)
B = [0]
C = []
for n in range(N-1):
    if S[n:n+2] == "AC":
        A[n] += 1
for n in range(N-1):
    B.append(B[n]+A[n])
for n in range(Q):
    l, r = map(int, input().split())
    C.append(B[r-1]-B[l-1])
for n in range(Q):
    print(C[n])
Buggy python submission (verdict: Runtime Error):
s = input(); a = []; b = [0]*27; t = ""
for i in range(len(s)): a.append(ord(s[i])); b[a[i]-97] = 1
if s == "zyxwvutsrqponmlkjihgfedcba": print(-1)
else:
    for i in range(27):
        if b[i] == 0: c = i; break
    if c != 26:
        a.append(c+97)
        for i in range(len(a)): t += chr(a[i])
        print(t)
    else:
        d = []
        for _ in range(24):
            if a[-2] > a[-1]: d.append(a.pop())
            else:
                d.append(a.pop()); a.pop(); d.sort()
                break
        else: d.append(a.pop()); a.pop(); d.sort()
        for i in range(len(d)):
            if a[-1] < d[i]: a.append(d[i]); break
        for i in range(len(a)): t += chr(a[i])
        print(t)

Fixed submission:
s = input(); a = []; b = [0]*27; t = ""
for i in range(len(s)): a.append(ord(s[i])); b[a[i]-97] = 1
if s == "zyxwvutsrqponmlkjihgfedcba": print(-1)
else:
    for i in range(27):
        if b[i] == 0: c = i; break
    if c != 26:
        a.append(c+97)
        for i in range(len(a)): t += chr(a[i])
        print(t)
    else:
        d = []
        for _ in range(24):
            if a[-2] > a[-1]: d.append(a.pop())
            else:
                d.append(a.pop()); d.sort()
                break
        else: d.append(a.pop()); d.sort()
        for i in range(len(d)):
            if a[-1] < d[i]: a.pop(); a.append(d[i]); break
        for i in range(len(a)): t += chr(a[i])
        print(t)

Buggy python submission (verdict: Runtime Error):
s = input(); a = []; b = [0]*27; t = ""
for i in range(len(s)): a.append(ord(s[i])); b[a[i]-97] = 1
if s == "zyxwvutsrqponmlkjihgfedcba": print(-1)
else:
    for i in range(27):
        if b[i] == 0: c = i; break
    if c != 26:
        a.append(c+97)
        for i in range(len(a)): t += chr(a[i])
        print(t)
    else:
        d = []
        for _ in range(25):
            if a[-2] > a[-1]: d.append(a.pop())
            else:
                d.append(a.pop()); a.pop(); d.sort()
                for i in range(len(d)):
                    if a[-1] < d[i]: a.append(d[i]); break
                break
        for i in range(len(a)): t += chr(a[i])
        print(t)

Fixed submission:
s = input(); a = []; b = [0]*27; t = ""
for i in range(len(s)): a.append(ord(s[i])); b[a[i]-97] = 1
if s == "zyxwvutsrqponmlkjihgfedcba": print(-1)
else:
    for i in range(27):
        if b[i] == 0: c = i; break
    if c != 26:
        a.append(c+97)
        for i in range(len(a)): t += chr(a[i])
        print(t)
    else:
        d = []
        for _ in range(24):
            if a[-2] > a[-1]: d.append(a.pop())
            else:
                d.append(a.pop()); d.sort()
                break
        else: d.append(a.pop()); d.sort()
        for i in range(len(d)):
            if a[-1] < d[i]: a.pop(); a.append(d[i]); break
        for i in range(len(a)): t += chr(a[i])
        print(t)
Buggy python submission (verdict: Runtime Error):
from math import gcd
n, k = map(int, input().split())
a = list(set(map(int, input().split())))
a.sort(); b = a[0]
for i in range(1, n): b = gcd(b, a[i])
if len(a) == 1:
    print("POSSIBLE") if k == a[0] else print("IMPOSSIBLE")
else:
    print("POSSIBLE") if k <= a[-1] and k%b == 0 else print("IMPOSSIBLE")

Fixed submission:
from math import gcd
n, k = map(int, input().split())
a = list(set(map(int, input().split())))
a.sort(); b = a[0]
for i in range(1, len(a)): b = gcd(b, a[i])
if len(a) == 1:
    print("POSSIBLE") if k == a[0] else print("IMPOSSIBLE")
else:
    print("POSSIBLE") if k <= a[-1] and k%b == 0 else print("IMPOSSIBLE")