Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# じょえチャンネル
# 高評価・チャンネル登録宜しくお願いします！
# https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ

import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

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

res = 10 ** 100
for i in range(-100, 200):
    tmp = 0
    for j in range(a):
        tmp += (i - j) ** 2
    res = min(res, tmp)
print(res)

Fixed submission:
# じょえチャンネル
# 高評価・チャンネル登録宜しくお願いします！
# https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ

import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

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

res = 10 ** 100
for i in range(-100, 200):
    tmp = 0
    for j in a:
        tmp += (i - j) ** 2
    res = min(res, tmp)
print(res)
Buggy python submission (verdict: Runtime Error):
from math import gcd
def lcm(x, y):
    return x * y // gcd(x, y)

n = int(input())
a = list(map(int,input().split()))
lc = a[0]
for i in a[1:]:lc=lcm(lc,i)
res=sum(lc//i for i in a)%(10**9+7)
print(res)

Fixed submission:
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]
for i in range(1,n):
  l=lcm(l,a[i])
ans=0
l%=mod
for i in range(n):
  ans+=l*pow(a[i],mod-2,mod)
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import Fraction as F
from fractions import gcd

MOD = 10 ** 9 + 7

def lcm(a, b):
    return a * b // gcd(a, b)

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

# B_1 = 1と仮定
b = [F(1, 1)]
for i in range(1, n):
    b.append(F(a[0], a[i]))

al_lcm = 1
for i in b:
    al_lcm = lcm(al_lcm, i.denominator)

res = 0
for i in b:
    res += i.numerator * pow(i.denominator, MOD - 2, MOD) % MOD * al_lcm % MOD

# lcmめっちゃ大きくなってそう

print(res % MOD)


Fixed submission:
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]
for i in range(1,n):
  l=lcm(l,a[i])
ans=0
l%=mod
for i in range(n):
  ans+=l*pow(a[i],mod-2,mod)
  ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import Fraction as F
from fractions import gcd

MOD = 10 ** 9 + 7

def lcm(a, b):
    return a * b // gcd(a, b)

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

# B_1 = 1と仮定
b = [F(1, 1)]
for i in range(1, n):
    b.append(F(a[0], a[i]))

al_lcm = 1
for i in b:
    al_lcm = lcm(al_lcm, i.denominator)

# print(al_lcm)

res = 0
for i in b:
    res += i * al_lcm

print(res % MOD)

# print(b)

Fixed submission:
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]
for i in range(1,n):
  l=lcm(l,a[i])
ans=0
l%=mod
for i in range(n):
  ans+=l*pow(a[i],mod-2,mod)
  ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [i // 2 for i in a]

def f(n):
    res = 0
    while n % 2 == 0:
        res += 1
        n //= 2
    return res

if not all(f(b[0]) == f(b[i]) for i in range(n)):
    print(0)
    exit(0)

cnt = f(b[0])
g = b[0] >> cnt
for i in b:
    g = lcm(g, i >> cnt)

gg = g << cnt
print((m + gg) // (2 * gg))


Fixed submission:
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [i // 2 for i in a]

def f(n):
    res = 0
    while n % 2 == 0:
        res += 1
        n //= 2
    return res

if not all(f(b[0]) == f(b[i]) for i in range(n)):
    print(0)
    exit(0)

cnt = f(b[0])
g = b[0] >> cnt
for i in b:
    g = lcm(g, i >> cnt)

gg = g << cnt
print((m + gg) // (2 * gg))
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(50000):
    x = int(i * 1.08)
    if (n == x):
        print(float(i))
        exit()
print(':(')


Fixed submission:
a,b = map(int,input().split())
c,d = map(int,input().split())
if d == 1:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
res = a[0]
for i in range(1, n):
    res += a[i]
    res /= 2
print(resz)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
res = a[0]
for i in range(1, n):
    res += a[i]
    res /= 2
print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())

l = [False] * (n + 1)
p = [n]
b = bin(n)[2:][::-1]

pw = 0
for i in b:
    if i == '1':
        p.append(2 ** int(pw))
        l[2 ** pw] = True
    pw += 1

q = []
xr = 0
for i in range(1, n):
    if not l[i]:
        xr ^= i
        q.append(i)

# print(xr)
# print(p)
# print(q)

res1 = []
for i in p:
    res1.append(i)
for i in p:
    res1.append(i + n)
res2 = []
if xr == 0:
    res2 = [n]
    for i in q:
        res2.append(i)
    for i in q:
        res2.append(i + n)
else:
    res2 = []
    for i in q:
        res2.append(i)
    if xr not in p:
        print('!!!')
        exit(1)
    res2.append(xr)
    for i in q:
        res2.append(i + n)

res = []
for i,j in zip(res1, res1[1:]):
    res.append([i, j])
    if i == j:
        print('No')
        exit()
    # print(i, j)
for i,j in zip(res2, res2[1:]):
    res.append([i, j])
    if i == j:
        print('No')
        exit()
    # print(i, j)

if len(res) != 2 * n - 1:
    print('No')
else:
    print('Yes')
    for i in res:
        print(*i)

Fixed submission:
n = int(input())
nn = n
f = lambda x, y: x + y * nn
g = lambda x: x if x % 2 == 1 else x + nn

# 2の累乗はむり
b = bin(n)
if b.count('0') == len(b) - 2:
    print('No')
    exit(0)

ret = [
    [f(1, 0), f(2, 0)],
    [f(2, 0), f(3, 0)],
    [f(3, 0), f(1, 1)],
    [f(1, 1), f(2, 1)],
    [f(2, 1), f(3, 1)],
]

if n % 2 == 0:
    p = 2 ** (len(b) - 3)
    q = n ^ 1 ^ p
    ret.append([g(p), f(n, 0)])
    ret.append([g(q), f(n, 1)])
    n -= 1

# nは奇数
while n > 3:
    ret.append([f(n - 1, 0), f(n, 0)])
    ret.append([f(n, 0), f(1, 1)])
    ret.append([f(1, 1), f(n - 1, 1)])
    ret.append([f(n - 1, 1), f(n, 1)])
    n -= 2

print('Yes')
for x, y in ret:
    # x = x if x <= nn else x - nn
    # y = y if y <= nn else y - nn
    print(x, y)
Buggy python submission (verdict: Runtime Error):
from math import gcd
# from fractions import gcd

n = int(input())
if n == 1:
    print(1)
    exit()

l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append([x, y])

res = 10 ** 100
for i in range(n):
    for j in range(i + 1, n):
        sa = []
        invalid = False
        for p,q in zip(l[i], l[j]):
            sa.append(p - q)

        # if not invalid:
        #     g = gcd(sa[0], sa[1])
        #     sa[0] //= g
        #     sa[1] //= g
        
        cnt = 0
        flag = [False] * n
        for p in range(n):
            if flag[p]:
                continue
            cnt += 1
            flag[p] = True
            for q in range(p + 1, n):
                if flag[q]:
                    continue
                sb = []
                for a,b in zip(l[p], l[q]):
                    sb.append(a - b)
                
                if sa[0] == 0:
                    if sb[0] == 0 and sb[1] % sa[1] == 0:
                        flag[q] = True
                elif sa[1] == 0:
                    if sb[1] == 0 and sb[0] % sa[0] == 0:
                        flag[q] = True
                else:
                    if sb[0] % sa[0] == 0 and sb[1] % sa[1] == 0:
                        if sb[0] // sa[0] == sb[1] // sa[1]:
                            flag[q] = True
        res = min(res, cnt)
print(res)

Fixed submission:
n = int(input())
if n == 1:
    print(1)
    exit()

l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append([x, y])

res = 10 ** 100
for i in range(n):
    for j in range(i + 1, n):
        sa = []
        invalid = False
        for p,q in zip(l[i], l[j]):
            sa.append(p - q)

        cnt = 0
        flag = [False] * n
        for p in range(n):
            if not flag[p]:
                cnt += 1
            flag[p] = True
            nxt = [l[p][0] + sa[0], l[p][1] + sa[1]]
            for q in range(n):
                if l[q] == nxt:
                    if flag[q]:
                        cnt -= 1
                    else:
                        flag[q] = True
        
        # cnt = 0
        # flag = [False] * n
        # for p in range(n):
        #     if flag[p]:
        #         continue
        #     cnt += 1
        #     flag[p] = True
        #     for q in range(p + 1, n):
        #         if flag[q]:
        #             continue
        #         sb = []
        #         for a,b in zip(l[p], l[q]):
        #             sb.append(a - b)
                
        #         if sa[0] == 0:
        #             if sb[0] == 0 and sb[1] % sa[1] == 0:
        #                 flag[q] = True
        #         elif sa[1] == 0:
        #             if sb[1] == 0 and sb[0] % sa[0] == 0:
        #                 flag[q] = True
        #         else:
        #             if sb[0] % sa[0] == 0 and sb[1] % sa[1] == 0:
        #                 if sb[0] // sa[0] == sb[1] // sa[1]:
        #                     flag[q] = True
        res = min(res, cnt)
print(res)
Buggy python submission (verdict: Runtime Error):
from fraction import gcd

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

p = [a[0]]
for i in range(1, n):
    p.append(gcd(p[i - 1], a[i]))

q = [a[-1]]
for i in range(n - 1):
    q.append(gcd(q[i], a[n - 2 - i]))
q = q[::-1]

res = 1
for i in range(n):
    if i - 1 < 0:
        res = max(res, q[i + 1])
    elif i + 1 >= n:
        res = max(res, p[i - 1])
    else:
        res = max(res, gcd(p[i - 1], q[i + 1]))

print(res)


Fixed submission:
from fractions import gcd

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

p = [a[0]]
for i in range(1, n):
    p.append(gcd(p[i - 1], a[i]))

q = [a[-1]]
for i in range(n - 1):
    q.append(gcd(q[i], a[n - 2 - i]))
q = q[::-1]

res = 1
for i in range(n):
    if i - 1 < 0:
        res = max(res, q[i + 1])
    elif i + 1 >= n:
        res = max(res, p[i - 1])
    else:
        res = max(res, gcd(p[i - 1], q[i + 1]))

print(res)

Buggy python submission (verdict: Runtime Error):
from math import gcd

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

p = [a[0]]
for i in range(1, n):
    p.append(gcd(p[i - 1], a[i]))

q = [a[-1]]
for i in range(n - 1):
    q.append(gcd(q[i], a[n - 2 - i]))
q = q[::-1]

res = 1
for i in range(n):
    if i - 1 < 0:
        res = max(res, q[i + 1])
    elif i + 1 >= n:
        res = max(res, p[i - 1])
    else:
        res = max(res, gcd(p[i - 1], q[i + 1]))

print(res)


Fixed submission:
from fractions import gcd

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

p = [a[0]]
for i in range(1, n):
    p.append(gcd(p[i - 1], a[i]))

q = [a[-1]]
for i in range(n - 1):
    q.append(gcd(q[i], a[n - 2 - i]))
q = q[::-1]

res = 1
for i in range(n):
    if i - 1 < 0:
        res = max(res, q[i + 1])
    elif i + 1 >= n:
        res = max(res, p[i - 1])
    else:
        res = max(res, gcd(p[i - 1], q[i + 1]))

print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
pos = []
neg = []
cnt = 0
for i in a:
    if i > 0:
        pos.append(i)
    elif i < 0:
        neg.append(i)
    else:
        cnt += 1
if cnt != 0 or len(neg) % 2 == 0:
    print(sum(pos) - sum(neg))
else:
    pos = sorted(pos)
    neg = sorted(neg)
    b = min(pos)
    c = -max(neg)
    pos = pos[1:]
    neg = neg[:-1]
    r = sum(pos) - sum(neg)
    m = max(b - c, c - b)
    print(r + m)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
pos = []
neg = []
cnt = 0
for i in a:
    if i > 0:
        pos.append(i)
    elif i < 0:
        neg.append(i)
    else:
        cnt += 1
if cnt != 0 or len(neg) % 2 == 0:
    print(sum(pos) - sum(neg))
else:
    pos = sorted(pos)
    neg = sorted(neg)
    if pos == []:
      print(-sum(neg[:-1])+neg[-1])
      exit()
    else:
      b = min(pos)
    c = -max(neg)
    pos = pos[1:]
    neg = neg[:-1]
    r = sum(pos) - sum(neg)
    m = max(b - c, c - b)
    print(r + m)
Buggy python submission (verdict: Time Limit Exceeded):
M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a];i-=1
i=s
while i*2>=s:z-=d[i]*3;i-=1
print(z+~s%2*e[s//2]*3)%M

Fixed submission:
M,z,s=998244353,1,0
N,*A=map(int,open(0))
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for a in A:
 i=s;s+=a;z*=3
 while~i:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
print((z+~s%2*e[s//2]*3)%M)

Buggy python submission (verdict: Time Limit Exceeded):
M=998244353
N,*A=open(0)
d=[1]+[0]*7**6
e=[1]+[0]*7**6
z=1
s=0
for a in A:
	a=int(a);s+=a;i=s;z*=3
	while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a];i-=1
i=s
while i*2>=s:z-=d[i]*3;i-=1
print((z+~s%2*e[s//2]*3)%M)

Fixed submission:
M,z,s=998244353,1,0
N,*A=map(int,open(0))
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for a in A:
 i=s;s+=a;z*=3
 while~i:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
print((z+~s%2*e[s//2]*3)%M)

Buggy python submission (verdict: Time Limit Exceeded):
M=998244353
N,*A=open(0)
d=[1]+[0]*7**6
e=[1]+[0]*7**6
z=1
s=0
for a in A:
	a=int(a);s+=a;i=s;z*=3
	while~i:d[i]+=d[i]+d[i-a];e[i]+=e[i-a];i-=1
i=s
while i*2>=s:z-=d[i]*3;i-=1
print((z+~s%2*e[s//2]*3)%M)

Fixed submission:
M,z,s=998244353,1,0
N,*A=map(int,open(0))
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for a in A:
 i=s;s+=a;z*=3
 while~i:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
print((z+~s%2*e[s//2]*3)%M)

Buggy python submission (verdict: Time Limit Exceeded):
M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a];e[i]+=e[i-a];i-=1
i=s
while i*2>=s:z-=d[i]*3;i-=1
print(z+~s%2*e[s//2]*3)%M

Fixed submission:
M,z,s=998244353,1,0
N,*A=map(int,open(0))
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for a in A:
 i=s;s+=a;z*=3
 while~i:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
print((z+~s%2*e[s//2]*3)%M)

Buggy python submission (verdict: Runtime Error):
M,z,s=998244353,1,0
N,*A=map(int,open(0))
d=[1]+[0]*7**6
e=d.copy()
for a in A:
 i=s;s+=a;z*=3
 while~i:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
print((z+~s%2*e[s//2]*3)%M)

Fixed submission:
M,z,s=998244353,1,0
N,*A=map(int,open(0))
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for a in A:
 i=s;s+=a;z*=3
 while~i:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
print((z+~s%2*e[s//2]*3)%M)
Buggy python submission (verdict: Runtime Error):
a=sum(i%2^int(c)for i,c in enumerate(input()));print(min(a,n-a))

Fixed submission:
s = input()
res1, res2 = 0, 0
for i, j in enumerate(s):
    if i % 2 == 0:
        if j == '0':
            res1 += 1
    else:
        if j == '1':
            res1 += 1
for i, j in enumerate(s):
    if i % 2 == 1:
        if j == '0':
            res2 += 1
    else:
        if j == '1':
            res2 += 1
print(min(res1, res2))
Buggy python submission (verdict: Runtime Error):
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)

n,m = map(int,input().split())
cnt = [0] * n
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    cnt[a] += 1
    cnt[b] += 1
cnt = sorted(cnt, reverse = True)

odd = 0
even = 0
two = 0

g = gb(cnt)
for k,v in g:
    vv = len(list(v))
    if k == 2:
        two += 1
        continue
    if vv % 2 == 0:
        even += 1
    else:
        odd += 1
        
if two > even + odd:
    print('No')
elif odd == 1:
    print('Yes')
else:
    print('No')


Fixed submission:
n = int(input())
res = []
if n%2 == 0:
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j == n + 1:
                continue
            res.append([i, j])
elif n % 2 == 1:
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j == n:
                continue
            res.append([i, j])
print(len(res))
for (i,j) in res:
    print(i, j)

Buggy python submission (verdict: Runtime Error):
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)

n,m = map(int,input().split())
cnt = [0] * n
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    cnt[a] += 1
    cnt[b] += 1
cnt = sorted(cnt, reverse = True)

odd = 0
even = 0
two = 0
g = gb(cnt)
for k,v in g:
    vv =len(list(v))
    if k == 2:
        two += 1
        continue
    if vv % 2 == 0:
        even += 1
    else:
        odd += 1
if odd == 1:
    print('Yes')
else:
    print('No')


Fixed submission:
n = int(input())
res = []
if n%2 == 0:
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j == n + 1:
                continue
            res.append([i, j])
elif n % 2 == 1:
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j == n:
                continue
            res.append([i, j])
print(len(res))
for (i,j) in res:
    print(i, j)
Buggy python submission (verdict: Runtime Error):
from math import gcd

n = int(input())
a = list(map(int,input().split()))
res = 0
for i in a:
    res = gcd(i, res)
print(res)


Fixed submission:
from fractions import gcd

n = int(input())
a = list(map(int,input().split()))
res = 0
for i in a:
    res = gcd(i, res)
print(res)
Buggy python submission (verdict: Runtime Error):
import fractions as f
g=f.gcd(list(map(int,input().split())));print(-1if input()[::n//g]!=input()[::m//g]else n*m//g)

Fixed submission:
from fractions import gcd

n,m = map(int,input().split())
s = input()
t = input()
if n==m:
    if s!=t:
        print('-1')
        exit()
    else:
        print(n)
        exit()
elif n<m:
    n,m = m,n
    s,t = t,s
# n>m
if n%m==0:
    k = n//m
    if s[::k]==t:
        print(n)
        exit()
    else:
        print('-1')
        exit()
else:
    g = gcd(n,m)
    if s[::n//g]==t[::m//g]:
        print(n*m//gcd(n,m))
    else:
        print(-1)

Buggy python submission (verdict: Runtime Error):
import fractions as f
g=f.gcd(map(int,input().split()));print(-1if input()[::n//g]!=input()[::m//g]else n*m//g)

Fixed submission:
from fractions import gcd

n,m = map(int,input().split())
s = input()
t = input()
if n==m:
    if s!=t:
        print('-1')
        exit()
    else:
        print(n)
        exit()
elif n<m:
    n,m = m,n
    s,t = t,s
# n>m
if n%m==0:
    k = n//m
    if s[::k]==t:
        print(n)
        exit()
    else:
        print('-1')
        exit()
else:
    g = gcd(n,m)
    if s[::n//g]==t[::m//g]:
        print(n*m//gcd(n,m))
    else:
        print(-1)
Buggy python submission (verdict: Runtime Error):
import itertools
n,*l=map(int,open(0).read().split())
f=lambda g:sorted([[len(list(v)),k]for k,v in itertools.groupby(g)])[-9:]
print(n-max(n//2,max(a+c for c,d in f(l[1::2])for a,b in f(l[::2])if b-d)))

Fixed submission:
from collections import Counter as C
n = int(input())
v = list(map(int,input().split()))
v1,v2 = v[0::2], v[1::2]
a1 = C(v1).most_common()
a2 = C(v2).most_common()

if a1[0][0]!=a2[0][0]:
    print(n-a1[0][1]-a2[0][1])
    exit()

res = n//2
if len(a2)!=1:
    res = a1[0][1] + a2[1][1]
if len(a1)!=1:
    res = max(res, a1[1][1] + a2[0][1])
print(n-res)
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)[::-1]
res = 0
p = 0
for i in a:
    x -= i
    if x < 0:
        x += i
        break
    res += 1
    p += 1
else:
    if x > 0:
        res -= 1
#print(p, a[p:])
print(res + (x in a[p:]))
t

Fixed submission:
n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))

res = 0
sum = 0
for i in a:
    res += 1
    sum += i
    if sum>=x:
        break
if sum==x:
    print(res)
else:
    print(res-1)
Buggy python submission (verdict: Runtime Error):
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')



n,x = map(int,input().split())
a = list(map(int,input().split()))
p = []
for i in a:
    p.append(abs(i - x))
g = p[0]
for i in p:
    g = gcd(i, g)
print(g)y

Fixed submission:
from fractions import gcd

n,m = map(int,input().split())
x = [abs(int(i)-m) for i in input().split()]

res = x[0]

for i in x:
    res = gcd(res,i)

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n,m = map(int,input().split())
x = [abs(int(i)-m) for i in input().split()]

while len(x)!=1:
    x = x[:-2] + [gcd(x[-2],x[-1])]

print(x[0])


Fixed submission:
from fractions import gcd

n,m = map(int,input().split())
x = [abs(int(i)-m) for i in input().split()]

res = x[0]

for i in x:
    res = gcd(res,i)

print(res)