Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(m,n):
    while (m % n != 0):
        temp = n
        n = m % n
        m = temp
    return(n)


k = int(input())
s = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        t = gcd(a,b)
        for c in range(1,k+1):
            s += gcd(t,c)
print(s)


Fixed submission:
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)


k = int(input())
s = 0
for a in range(1,k+1):
    for b in range(a,k+1):
        t = gcd(a,b)
        for c in range(b,k+1):
            v = gcd(t,c)
            l = len(set([a,b,c]))
            if(l == 1):s += v
            elif(l == 2):s += v * 3
            else:s += v * 6
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(m,n):
    while (m % n != 0):
        temp = n
        n = m % n
        m = temp
    return(n)


k = int(input())
s = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            s += gcd(a,gcd(b,c))
print(s)

Fixed submission:
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)


k = int(input())
s = 0
for a in range(1,k+1):
    for b in range(a,k+1):
        t = gcd(a,b)
        for c in range(b,k+1):
            v = gcd(t,c)
            l = len(set([a,b,c]))
            if(l == 1):s += v
            elif(l == 2):s += v * 3
            else:s += v * 6
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import queue

n,x,y = map(int,input().split())
l = [0] * n
for z in range(n):
    q = queue.Queue()
    q.put(z)
    d = [-1] * n
    d[z] = 0
    while(not q.empty()):
        i = q.get()
        if(d[i] > 0 and i > z):l[d[i]] += 1
        j = i + 1
        if(j < n):
            if(d[j] == -1):
                d[j] = d[i] + 1
                q.put(j)
        j = i - 1
        if(j >= 0):
            if(d[j] == -1):
                d[j] = d[i] + 1
                q.put(j)
        if(i == x - 1):
            j = y - 1
            if(d[j] == -1):
                d[j] = d[i] + 1
                q.put(j)
for i in range(1,n):print(l[i])

Fixed submission:
import queue

n,x,y = map(int,input().split())
x -= 1
y -= 1
l = [0] * n
for i in range(n):
    for j in range(i+1,n):
        d = min([abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+(j-x)])
        l[d] += 1
for i in range(1,n):print(l[i])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
m = 0
for i in range(q):
    Q = input().split()
    if(Q[0] == '1'):m = m ^ 1
    elif(Q[0] == '2'):
        if(Q[1] == '1'):
            if(m == 0):s = Q[2] + s
            else:s = s + Q[2]
        elif(Q[1] == '2'):
            if(m == 0):s = s + Q[2]
            else:s = Q[2] + s
if(m == 1):s = s[::-1]
print(s)

Fixed submission:
s = input()
q = int(input())
m = 0
t = ''
l = ''
for i in range(q):
    Q = input().split()
    if(Q[0] == '1'):
        m = m ^ 1
        # t,l = l[::-1],t[::-1]
    elif(Q[0] == '2'):
        if(Q[1] == '1'):
            if(m == 0):t += Q[2]
            else:l += Q[2]
        elif(Q[1] == '2'):
            if(m == 0):l += Q[2]
            else:t += Q[2]
# print(t,s,l)
s = t[::-1] + s + l

if(m == 1):s = s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    Q = input().split()
    if(Q[0] == '1'):s = s[::-1]
    elif(Q[0] == '2'):
        if(Q[1] == '1'):s = Q[2] + s
        elif(Q[1] == '2'):s = s + Q[2]
print(s)

Fixed submission:
s = input()
q = int(input())
m = 0
t = ''
l = ''
for i in range(q):
    Q = input().split()
    if(Q[0] == '1'):
        m = m ^ 1
        # t,l = l[::-1],t[::-1]
    elif(Q[0] == '2'):
        if(Q[1] == '1'):
            if(m == 0):t += Q[2]
            else:l += Q[2]
        elif(Q[1] == '2'):
            if(m == 0):l += Q[2]
            else:t += Q[2]
# print(t,s,l)
s = t[::-1] + s + l

if(m == 1):s = s[::-1]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K = map(int,input().split())
p = list(map(int,input().split()))
e = [(p[i]+1)/2. for i in range(N)]
s = [sum(e[0:i]) for i in range(N+1)]
f = [(s[i+K]-s[i]) for i in range(N-K+1)]
print(max(f))

Fixed submission:
import numpy as np
N,K = map(int,input().split())
p = np.array(list(map(int,input().split())))
e = (p+1) / 2.0
s = np.zeros(len(e)+1)
s[1:] = np.cumsum(e)
f = s[K:] - s[:-K]

print(np.max(f))
Buggy python submission (verdict: Time Limit Exceeded):
H,n = map(int,input().split())
A = [0 for _ in range(n)]
B = [0 for _ in range(n)]
min_eff = 9999.
for i in range(n):
    A[i],B[i] = map(int,input().split())
    min_eff = min(min_eff,A[i]/B[i])

dp = [[int(H/min_eff+1) for _ in range(H+1)] for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0


for i in range(n):
    for h in range(H+1):
        idx = max(0,h-A[i])
        dp[i+1][h] = min(dp[i+1][idx] + B[i],dp[i][h])

print(int(dp[n][H]))


Fixed submission:

H,n = map(int,input().split())
A = [0 for _ in range(n)]
B = [0 for _ in range(n)]
min_eff = 9999.
for i in range(n):
    A[i],B[i] = map(int,input().split())
    min_eff = min(min_eff,A[i]/B[i])

dp = [[int(H/min_eff+1) for _ in range(H+1)] for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0


for i in range(n):
    for h in range(H+1):
        idx = max(0,h-A[i])
        dp[i+1][h] = min(dp[i+1][idx] + B[i],dp[i][h])

print(int(dp[n][H]))

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

H,n = map(int,input().split())
A = [0 for _ in range(n)]
B = [0 for _ in range(n)]
min_eff = 9999.
for i in range(n):
    A[i],B[i] = map(int,input().split())
    min_eff = min(min_eff,A[i]/B[i])

dp = np.zeros((n+1,H+1))+H/min_eff+1
dp[:,0] = 0

for i in range(n):
    for h in range(H+1):
        idx = max(0,h-A[i])
        dp[i+1][h] = min(dp[i+1][idx] + B[i],dp[i][h])

print(int(dp[n,H]))


Fixed submission:

H,n = map(int,input().split())
A = [0 for _ in range(n)]
B = [0 for _ in range(n)]
min_eff = 9999.
for i in range(n):
    A[i],B[i] = map(int,input().split())
    min_eff = min(min_eff,A[i]/B[i])

dp = [[int(H/min_eff+1) for _ in range(H+1)] for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0


for i in range(n):
    for h in range(H+1):
        idx = max(0,h-A[i])
        dp[i+1][h] = min(dp[i+1][idx] + B[i],dp[i][h])

print(int(dp[n][H]))
Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())

pr = []
i = 2
while(True):
    for p in pr:
        if(i % p == 0):break
    else:
        if(i >= n):
            print(i)
            exit()
        pr.append(i)
    i += 1


Fixed submission:
import random

def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n = int(input())

i = n
while(not is_prime(i)):i += 1
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(map(int,input().split()))
i = 0
c = 0
while(i < len(a)):
    if(a[i] == i+1):
        i += 1
    else:
        a.pop(i)
        c += 1

if(len(a) == 0):print(-1)
else:print(c)

Fixed submission:
n = int(input())

a = list(map(int,input().split()))
i = 1
j = 1
c = 0
while(j <= n):
    if(a[j-1] == i):
        i += 1
    else:
        c += 1
    j += 1
if(c == n):print(-1)
else:print(c)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
t = 0
for i in range(n+1):
    l = 0
    r = 0
    for j in range(i)[::-1]:
        if(s[j] == '>'):break
        l += 1
    for j in range(i,n):
        if(s[j] == '<'):break
        r += 1
    t += max(l,r)
print(t)

Fixed submission:
s = input()
n = len(s)

l = [0 for _ in range(n+1)]
r = [0 for _ in range(n+1)]

for i in range(n):
    if(s[i] == '<'):
        l[i+1] = l[i] + 1
    else:
        l[i+1] = 0
for i in range(n)[::-1]:
    if(s[i] == '>'):
        r[i] = r[i+1] + 1
    else:
        r[i] = 0

t = 0
for i in range(n+1):
    t += max(l[i],r[i])
print(t)
Buggy python submission (verdict: Runtime Error):
n = int(input())

d = map(int,input().split())

s = 0

for i in range(n):
    for j in range(i,n):
        s += d[i] * d[j]
print(s)

Fixed submission:
n = int(input())

d = list(map(int,input().split()))

s = 0

for i in range(n):
    for j in range(i+1,n):
        s += d[i] * d[j]
print(s)
Buggy python submission (verdict: Runtime Error):
s = list(input())

k = int(input())

n = len(s)

if(len(set(s)) == 1):
    print(n*k//2)
else:
    if(s[0] != s[-1]):
        print(n//2*k)
    else:
        print(n//2*k - (a//2 + b//2 - (a+b)//2) * (k-1))

Fixed submission:
s = list(input())

k = int(input())

n = len(s)

if(len(set(s)) == 1):
    print(n*k//2)
else:
    t = 0
    c = 1
    for i in range(n-1):
        if(s[i] == s[i+1]):
            c += 1
        else:
            t += c // 2
            c = 1
    t += c // 2
    if(s[0] != s[-1]):
        print(t*k)
    else:
        a = 0
        b = 0
        for i in range(n):
            if(s[i] == s[0]):a+=1
            else:break
        for i in range(n)[::-1]:
            if(s[i] == s[-1]):b+=1
            else:break
        print(t*k - (a//2 + b//2 - (a+b)//2) * (k-1))
Buggy python submission (verdict: Time Limit Exceeded):
import queue
n,q = map(int,input().split())
c = [[] for _ in range(n)]
for i in range(n-1):
    A,B = map(int,input().split())
    c[A-1].append(B)
    c[B-1].append(A)
z = [0] * n
for i in range(q):
    P,X = map(int,input().split())
    z[P - 1] += X


d = [-1] * n
d[0] = 0
q = queue.Queue()
q.put(1)
while(not q.empty()):
    tp = q.get()
    td = d[tp - 1]
    for n2 in c[tp - 1]:
        if(d[n2 - 1] == -1):
            d[n2 - 1] = td + 1
            z[n2 - 1] += z[tp - 1]
            q.put(n2)

print(*z)

Fixed submission:
from collections import deque
n,q = map(int,input().split())
c = [[] for _ in range(n)]
for i in range(n-1):
    A,B = map(int,input().split())
    c[A-1].append(B)
    c[B-1].append(A)
z = [0] * n
for i in range(q):
    P,X = map(int,input().split())
    z[P - 1] += X


d = [-1] * n
d[0] = 0
q = deque([])
q.append(1)
while(q):
    tp = q.popleft()
    td = d[tp - 1]
    for n2 in c[tp - 1]:
        if(d[n2 - 1] == -1):
            d[n2 - 1] = td + 1
            z[n2 - 1] += z[tp - 1]
            q.append(n2)

print(*z)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s = [sorted(list(input())) for _ in range(n)]

c = 0
for i in range(n):
    for j in range(i+1,n):
        if(s[i]==s[j]):c+=1
print(c)

Fixed submission:
def comb(a,b):
    x = 1
    for i in range(a-b+1,a+1):x*=i
    for i in range(1,b+1):x//=i
    return(x)

n = int(input())

dict_num = {}

for _ in range(n):
    s = ''.join(sorted(list(input())))
    if(s in dict_num):dict_num[s]+=1
    else:dict_num[s] = 1

c=0
for k,v in dict_num.items():
    if(v>=2):c += comb(v,2)
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = list(map(int,input().split()))
a.sort()
d = {}
for i in range(n):
    if(a[i] not in d):d[a[i]] = 1
    else:d[a[i]] += 1
if(len(d) == 1):
    if(a[0] == 0):
        print('Yes')
        exit()
elif(len(d)%3 == 0):
    if(len(d) == 2):
        if(0 in d):
            if(d[0] == n // 3):
                print('Yes')
                exit()
    elif(len(d) == 3):
        k = d.keys()
        if(k[0]^k[1]^k[2] == 0):
            if(d[k[0]] == n // 3 and d[k[1]] == n // 3 and d[k[2]] == n // 3):
                print('Yes')
                exit()
print('No')

Fixed submission:
n = int(input())

a = list(map(int,input().split()))
a.sort()
d = {}
for i in range(n):
    if(a[i] not in d):d[a[i]] = 1
    else:d[a[i]] += 1
if(len(d) == 1):
    if(a[0] == 0):
        print('Yes')
        exit()
elif(n%3 == 0):
    if(len(d) == 2):
        if(0 in d):
            if(d[0] == n // 3):
                print('Yes')
                exit()
    elif(len(d) == 3):
        k = list(d.keys())
        if(k[0]^k[1]^k[2] == 0):
            if(d[k[0]] == n // 3 and d[k[1]] == n // 3 and d[k[2]] == n // 3):
                print('Yes')
                exit()
print('No')
Buggy python submission (verdict: Runtime Error):
def frac(n):
	r = 1
	for i in range(1,n+1):r*=i
	return(r)

def ans(n,k,i):
	if(n-k < i-1):return(0)
	r1 = frac(k-1) / frac(k-i) / frac(i-1)
	r2 = frac(n-k+1) / frac(n-k-i+1) / frac(i)
	
	return(r1*r2)

n,k = map(int,input().split())



for i in range(1,k+1):
	print(int(ans(n,k,i))%1000000007)





Fixed submission:
def frac(n):
	r = 1
	for i in range(1,n+1):
		r*=i
	return(r)

def ans(n,k,i):
	if(n-k < i-1):return(0)
	r1 = frac(k-1) // frac(k-i) // frac(i-1)
	r2 = frac(n-k+1) // frac(n-k-i+1) // frac(i)
	
	return(r1*r2)

n,k = map(int,input().split())

for i in range(1,k+1):
	print(int(ans(n,k,i))%1000000007)
Buggy python submission (verdict: Runtime Error):

n,m = map(int,input().split())
b = [True] * n
for i in range(m):
    x = int(input())
    b[x-1] = False

dp = [0] * n
if(n == 1):
    print(1)
if(b[0]):
    dp[0] = 1
    if(b[1]):dp[1] = 2
else:
    if(b[1]):dp[1] = 1

for i in range(2,n):
    if(b[i]):
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 1000000007
print(dp[-1])

Fixed submission:

n,m = map(int,input().split())
b = [True] * n
for i in range(m):
    x = int(input())
    b[x-1] = False

dp = [0] * n
if(n == 1):
    print(1)
    exit()
if(b[0]):
    dp[0] = 1
    if(b[1]):dp[1] = 2
else:
    if(b[1]):dp[1] = 1

for i in range(2,n):
    if(b[i]):
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 1000000007
print(dp[-1])

Buggy python submission (verdict: Runtime Error):

n,m = map(int,input().split())
b = [True] * n
for i in range(m):
    x = int(input())
    b[x-1] = False

dp = [0] * n

if(b[0]):
    dp[0] = 1
    if(b[1]):dp[1] = 2
else:
    if(b[1]):dp[1] = 1

for i in range(2,n):
    if(b[i]):
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 1000000007
print(dp[-1])

Fixed submission:

n,m = map(int,input().split())
b = [True] * n
for i in range(m):
    x = int(input())
    b[x-1] = False

dp = [0] * n
if(n == 1):
    print(1)
    exit()
if(b[0]):
    dp[0] = 1
    if(b[1]):dp[1] = 2
else:
    if(b[1]):dp[1] = 1

for i in range(2,n):
    if(b[i]):
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 1000000007
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

if(a <= 5):
    print(0)
elif(a < 12):
    print(b//2):
else:
    print(b)

Fixed submission:
a,b = map(int,input().split())

if(a <= 5):
    print(0)
elif(a <= 12):
    print(b//2)
else:
    print(b)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n,m = map(int,input().split())

k = np.zeros(n,dtype='int')

for i in range(m):
    l,r = map(int,input().split())
    k[l-1:r] += 1
print(len(k[k==m]))

Fixed submission:
import numpy as np

n,m = map(int,input().split())

L = 1
R = n

for i in range(m):
    l,r = map(int,input().split())
    L = max(L,l)
    R = min(r,R)
print(max(0,R-L+1))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n,m = map(int,input().split())

a = list(map(int,input().split()))

heapq.heapify(a)

l = [[] for _ in range(m)]

for i in range(m):
    b,c = map(int,input().split())
    l[i] = [c,b]
l.sort()
for i in range(m):
    b,c = l[i][1],l[i][0]
    for j in range(b):
        x = heapq.heappop(a)
        if(x < c):
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,x)
            break
print(sum(a))

Fixed submission:
import heapq

n,m = map(int,input().split())

a = list(map(int,input().split()))

heapq.heapify(a)

l = [[] for _ in range(m)]

for i in range(m):
    b,c = map(int,input().split())
    l[i] = [c,b]
l.sort(reverse=True)
for i in range(m):
    b,c = l[i][1],l[i][0]
    for j in range(b):
        x = heapq.heappop(a)
        if(x < c):
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,x)
            break
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n,m = map(int,input().split())

a = list(map(int,input().split()))

heapq.heapify(a)

for i in range(m):
    b,c = map(int,input().split())
    for j in range(b):
        x = heapq.heappop(a)
        if(x < c):
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,x)
            break
print(sum(a))

Fixed submission:
import heapq

n,m = map(int,input().split())

a = list(map(int,input().split()))

heapq.heapify(a)

l = [[] for _ in range(m)]

for i in range(m):
    b,c = map(int,input().split())
    l[i] = [c,b]
l.sort(reverse=True)
for i in range(m):
    b,c = l[i][1],l[i][0]
    for j in range(b):
        x = heapq.heappop(a)
        if(x < c):
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,x)
            break
print(sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

s = 0
for i in range(n):
    s += max(0,v-c)
print(s)

Fixed submission:
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

s = 0
for i in range(n):
    s += max(0,v[i]-c[i])
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t=s

while("01" in t or "10" in t):
	t = t.replace("01","")
	t = t.replace("10","")
print(len(s)-len(t))

Fixed submission:
s = input()
x=0
for i in s:
	if(i=='0'):x+=1
	elif(i=='1'):x-=1

print(len(s)-abs(x))
Buggy python submission (verdict: Runtime Error):
s = int(''.join(input.split('/')))
if(s <= 20190430):print('Heisei')
else:print('TBD')

Fixed submission:
s = int(''.join(input().split('/')))
if(s <= 20190430):print('Heisei')
else:print('TBD')
Buggy python submission (verdict: Runtime Error):
s = input()
o = ""
c = 'keyence'
j = 0
l = []
for i in range(len(s)):
    if(s[i] == c[j]):
        j += 1
        l.append(i)
c = 0
l.append(len(s))
for i in range(len(l) - 1):
    if(l[i+1]-l[i] > 1):c += 1
if(c > 1 or len(l) != 8):print('NO')
else:print('YES')

Fixed submission:
s = input()
t = 'keyence'
if(s[:7] == t or s[-7:] == t):
    print('YES')
else:
    for i in range(7):
        if(s[:i+1] == t[:i+1] and s[-7+i+1:] == t[-7+i+1:]):
            print('YES')
            exit()
    print('NO')
Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())


ans = 1


for i in range(2,min(int(p**(1./n))+1,int(sqrt(p))+1)):
	while(p%(i**n)==0):
		ans*=i
		p//=i**n
print(ans)


Fixed submission:
n,p=map(int,input().split())


ans = 1
if(n==1):print(p)
else:

	for i in range(2,int(p**(1./n))+1):
		while(p%(i**n)==0):
			ans*=i
			p//=i**n
	print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

n,p=map(int,input().split())


ans = 1

for i in range(2,int(p**(1./n))+1):
	if(p < i**n):break
	while(p%(i**n)==0):
		ans*=i
		p//=i**n
print(ans)



Fixed submission:
n,p=map(int,input().split())


ans = 1
if(n==1):print(p)
else:

	for i in range(2,int(p**(1./n))+1):
		while(p%(i**n)==0):
			ans*=i
			p//=i**n
	print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

n,p=map(int,input().split())


ans = 1

for i in range(2,int(p**(1./n))+1):
	while(p%(i**n)==0 and p>=(i**n)):
		ans*=i
		p//=i**n
print(ans)



Fixed submission:
n,p=map(int,input().split())


ans = 1
if(n==1):print(p)
else:

	for i in range(2,int(p**(1./n))+1):
		while(p%(i**n)==0):
			ans*=i
			p//=i**n
	print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

n,p=map(int,input().split())


ans = 1


for i in range(2,int(p**(1./n))+1):
	while(p%(i**n)==0):
		ans*=i
		p//=i**n
print(ans)

Fixed submission:
n,p=map(int,input().split())


ans = 1
if(n==1):print(p)
else:

	for i in range(2,int(p**(1./n))+1):
		while(p%(i**n)==0):
			ans*=i
			p//=i**n
	print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split())


ans = 1
i=2
while(p >= i**n):
	if(p%(i**n)==0):
		ans*=i
		p//=i**n
	else:
		i+=1


print(ans)

Fixed submission:
n,p=map(int,input().split())


ans = 1
if(n==1):print(p)
else:

	for i in range(2,int(p**(1./n))+1):
		while(p%(i**n)==0):
			ans*=i
			p//=i**n
	print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)

def lcm(m,n):
    return(m * n // gcd(m,n))

n,m = map(int,input().split())

s = input()
t = input()


g = gcd(m,n)

if(g in [n,m]):
    print(-1)
else:
    x = lcm(m,n)
    a = x // n
    b = x // m
    for i in range(x//n):
        ai = 1 + a * i
        bi = 1 + b * i
        if(s[ai] != t[bi]):
            print(-1)
            exit()
    print(lcm(m,n))

Fixed submission:
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)

def lcm(m,n):
    return(m * n // gcd(m,n))

n,m = map(int,input().split())

s = input()
t = input()


g = gcd(m,n)

if(g in [n,m]):
    print(-1)
else:
    x = lcm(m,n)
    a = x // n
    b = x // m
    for i in range(n//b):
        ai = b * i
        bi = a * i
        if(s[ai] != t[bi]):
            print(-1)
            exit()
    print(lcm(m,n))
Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(len(n)):
    if(n[i] == '1'):n[i] = '9'
    elif(n[i] == '9'):n[i] = '1'
print(n)

Fixed submission:
n = list(input())
for i in range(len(n)):
    if(n[i] == '1'):n[i] = '9'
    elif(n[i] == '9'):n[i] = '1'
print(''.join(n))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

e=np.array([v[i] for i in range(0,n,2)])
o=np.array([v[i] for i in range(1,n,2)])

se=set(e)
so=set(o)


if(len(se)==1 and len(so)==1):
    if(e[0]==o[0]):print(n//2)
    else:print(0)
    exit()

le=[]


for ve in se:
    a=len(e[e != ve])
    le.append([a,ve])

lo=[]
for vo in so:
    a=len(o[o != vo])
    lo.append([a,vo])
    
    
le.sort()
lo.sort()

if(len(se)==1):
    if(lo[0][1]!=le[0][1]):print(lo[0][0])
    else:print(lo[1][0])
elif(len(so)==1):
    if(lo[0][1]!=le[0][1]):print(le[0][0])
    else:print(le[1][0])
else:
    if(lo[0][1]!=le[0][1]):print(le[0][0]+lo[0][0])
    else:print(min(le[1][0]+lo[0][0],le[0][0]+lo[1][0]))

Fixed submission:
import numpy as np
import collections

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

e=np.array([v[i] for i in range(0,n,2)])
o=np.array([v[i] for i in range(1,n,2)])

se=set(e)
so=set(o)


lle=collections.Counter(e)
llo=collections.Counter(o)
le=[]
for k,v in lle.items():
    le.append([n//2-v,k])
lo=[]
for k,v in llo.items():
    lo.append([n//2-v,k])
le.sort()
lo.sort()

if(len(lle)==1 and len(llo)==1):
    if(e[0]==o[0]):print(n//2)
    else:print(0)
    exit()




if(len(se)==1):
    if(lo[0][1]!=le[0][1]):print(lo[0][0])
    else:print(lo[1][0])
elif(len(so)==1):
    if(lo[0][1]!=le[0][1]):print(le[0][0])
    else:print(le[1][0])
else:
    if(lo[0][1]!=le[0][1]):print(le[0][0]+lo[0][0])
    else:print(min(le[1][0]+lo[0][0],le[0][0]+lo[1][0]))
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
if(s[k-1] == '1'):
    print(1)
    exit()
for i in s:
    if(i != '1'):
        print(i)
        exit()


Fixed submission:
s = input()
k = int(input())
if(k-1 < len(s)):
    for i in range(k):
        if(s[i] != '1'):break
    else:
        print(1)
        exit()
for i in s:
    if(i != '1'):
        print(i)
        exit()
Buggy python submission (verdict: Runtime Error):
A=list(input())
n=len(A)
if(A[0]!="A"):print("WA")
elif(A.count("C")!=1):print("WA")
elif(A.index("C")<2 or A.index("C")>n-2):print("WA")
else:
  A.pop(A.index("C"))
  A.pop(0)
  if(A.islower()):print("AC")
  else:print("WA")

Fixed submission:
A=list(input())
n=len(A)
if(A[0]!="A"):print("WA")
elif(A.count("C")!=1):print("WA")
elif(A.index("C")<2 or A.index("C")>n-2):print("WA")
else:
  A.pop(A.index("C"))
  A.pop(0)
  S="".join(A)
  if(S.islower()):print("AC")
  else:print("WA")