Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03061 (python)

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

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

for i in range(N):
    L[i+1] = fractions.gcd(L[i],A[i])
    R[N-1-i] = fractions.gcd(R[N-i],A[N-i-1])

M = 0
for i in range(N):
    M = max(M,fractions.gcd(L[i],R[i+1]))

print(M)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

import functools
from functools import reduce

def gcd_list(numbers):
    return reduce(functools.gcd, numbers)

score = 0
for i in range(N):
    B = A
    keep = B.pop(0)
    n = gcd_list(B)
    if n > score:
        score = n
    A.append(keep)


print(score)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

score = 0
for i in range(N):
    B = A
    keep = B.pop(0)
    n = gcd_list(B)
    if n > score:
        score = n
    A.append(keep)


print(score)
Problem p03069 (python)

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

A = [0] * (N+1)
B = [0] * (N+1)

for i in range(N):
    A[i+1] = A[i]
    if S[i] == "#":
        A[i+1] += 1

for i in range(N,0,-1):
    B[i-1] = B[i]
    if S[i-1] == ".":
        B[i-1] += 1

ans = 10 ** 9
for i in range(N+1):
    ans = min(ans, A[i] + B[i])

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
S = input()

score1 = 0
score2 = 0
length = 1
check = S[0]
A = []
B = []
flag = 0

for i in range(N-1):
    if S[i] == S[i+1]:
        length += 1
    else:
        A.append(length)
        length = 1

if length != 1:
    A.append(length)

if len(A) != 0:
    if S[-1] != S[-2]:
        A.append(1)

if len(A) <= 1:
    print(0)
    sys.exit()

B = A

if S[0] == ".":
    A.pop(0)

if S[len(S)-1] == "#":
    A.pop(-1)


for i in range(len(A)):
    if i % 2 == 0:
        score1 += A[i]
    else:
        score2 += A[i]

ans = min(score1,score2)

if S[0] == "#":
    score3 = A[0] + score2 - A[1]
    ans = min(ans,score3)

if S[0] == ".":
    score4 = A[-1] + score1 - A[len(A)-2]
    ans = min(ans,score4)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

score1 = 0
score2 = 0
length = 1
check = S[0]
A = []

for i in range(N-1):
    if S[i] == S[i+1]:
        length += 1
    else:
        A.append(length)
        length = 1

if length != 1:
    A.append(length)

if S[-1] != S[-2]:
    A.append(1)

if S[0] == ".":
    A.pop(0)

for i in range(len(A)):
    if i % 2 == 0:
        score1 += A[i]
    else:
        score2 += A[i]
if len(A) % 2 == 1:
    score1 -= A[-1]

ans = min(score1,score2)


print(ans)
Problem p03136 (python)

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

sum = 0

for i in range(n):
    sum = sum + lis[i]

judge = sum - max(lis) - max(lis)

if judge > 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
lis = [input() for _ in range(n)]

for i in range(n):
    sum += lis[i]

judge = sum - max(lis) - max(lis)

if judge > 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))

for i in range(n):
    sum += li[i]

judge = sum - max(li) -max(li)

if judge > 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
maxli = max(li)
judge = np.sum(li) - maxli - maxli
if judge > 0:
    print("Yes")
else:
    print("No")
Problem p03436 (python)

Fixed submission:
H, W = map(int, input().split())
MA = [list(input().strip()) for _ in range(H)]
VI = [[-1] * W for _ in range(H)]

kabe = 0
for i in range(H):
    kabe += MA[i].count("#")

from collections import deque


def bfs(ma, vi):
    Q = deque([(0,0)])
    sy, sx = (0,0)
    vi[sy][sx] = 0
    while True:
        if Q == deque([]):
            return -1
        q = Q.popleft()
        y, x = q
        if q == (H-1,W-1):
            return vi[y][x]
        for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            nq = y + dy, x + dx
            ny, nx = nq
            if 0 <= ny < H and 0 <= nx < W and vi[ny][nx] == -1:
                if ma[ny][nx] == '.':
                    Q.append(nq)
                    vi[ny][nx] = vi[y][x] + 1


score = bfs(MA,VI)

if score != -1:
    print(H * W - kabe - score - 1)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
MA = [list(input().strip()) for _ in range(H)]
VI = [[-1] * W for _ in range(H)]

kabe = 0
for i in range(H):
    kabe += MA[i].count("#")

from collections import deque


def bfs(ma, vi):
    Q = deque([(0,0)])
    sy, sx = (0,0)
    vi[sy][sx] = 0
    while True:
        q = Q.popleft()
        y, x = q
        if q == (H-1,W-1):
            return vi[y][x]
        for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            nq = y + dy, x + dx
            ny, nx = nq
            if 0 <= ny < H and 0 <= nx < W and vi[ny][nx] == -1:
                if ma[ny][nx] == '.':
                    Q.append(nq)
                    vi[ny][nx] = vi[y][x] + 1



print(H * W - kabe - bfs(MA, VI) - 1)
Problem p04026 (python)

Fixed submission:
S = list(input())
S.append("A")
for j in range(len(S) - 2):
    if (S[j] == S[j + 1]):
        print(j+1, j+2)
        exit()
    if (S[j] == S[j + 2]):
        print(j+1, j+3)
        exit()
else:
    print("-1 -1")

Buggy submission (verdict: Runtime Error):
S = list(input())
S.append("A")
for i in range(26):
    if S.count(chr(97 + i)) >= 2:
        for j in range(len(S) - 1):
            if (S[j] == chr(97 + i)) and (S[j + 1] == chr(97 + i)):
                print((j+1), (j+2))
                exit()
            if (S[j] == chr(97 + i)) and (S[j + 2] == chr(97 + i)):
                print((j+1), (j+3))
                exit()
else:
    print("-1 -1")

Buggy submission (verdict: Runtime Error):
S = list(input())
S.append("A")
for i in range(26):
    if S.count(chr(97 + i)) >= 2:
        for j in range(len(S) - 1):
            if (S[j] == chr(97 + i)) and (S[j + 1] == chr(97 + i)):
                print(j+1, j+2)
                exit()
            if (S[j] == chr(97 + i)) and (S[j + 2] == chr(97 + i)):
                print(j+1, j+3)
                exit()
else:
    print("-1 -1")

Buggy submission (verdict: Runtime Error):
S = list(input())
S.append(1)
for i in range(26):
    if S.count(chr(97 + i)) >= 2:
        for j in range(len(S) - 1):
            if (S[j] == chr(97 + i)) and (S[j + 1] == chr(97 + i)):
                print(j+1, j+2)
                exit()
            if (S[j] == chr(97 + i)) and (S[j + 2] == chr(97 + i)):
                print(j+1, j+3)
                exit()
else:
    print("-1 -1")
Problem p03125 (python)

Fixed submission:
A, B = map(int, input().split(' '))

if B % A == 0:
    print(A + B)
else:
    print(B - A)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split(' '))
if B % A == 0:
    print(A + B)
 else:
    print(B - A)
Problem p03311 (python)

Fixed submission:
import math
import numpy as np

n = int(input())
a_list = list(map(int, input().split()))
a_list2 = sorted([a - (i + 1) for i, a in enumerate(a_list)])

s_cand = []
b_cand = [math.floor(sum(a_list2) / n), math.ceil(sum(a_list2) / n), int(np.median(a_list2))]

for b in b_cand:
    s = 0
    for a in a_list2:
        s += int(abs(a - b))
    s_cand.append(s)
    
print(min(s_cand))

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
a_list2 = sorted([a - (i + 1) for i, a in enumerate(a_list)])

s = 0
b = math.floor(sum(a_list2) / n)

for a in a_list2:
    s += abs(a - b)
    
print(s)
Problem p03035 (python)

Fixed submission:
read=input();
A,B=read.split(' ')
A=int(A)
B=int(B)
if A>12:
  print(B);
elif A>5:
  print(int(B/2));
else:
  print(0);

Buggy submission (verdict: Runtime Error):
read=input();
A,B=read.spilt(' ')
A=int(A)
B=int(B)
if A>12:
  print(B);
elif A>5:
  print(B/2);
else:
  print(0);

Buggy submission (verdict: Runtime Error):
read=input();
A,B=read.spilt(' ')
A=int(A)
B=int(B)
if A>12:
  print(B);
elif A>5:
  print(B/2);
else:
  print(B);

Buggy submission (verdict: Runtime Error):
read=input();
A,B=read.spilt(' ')
A=int(A)
B=int(B)
if A>=0 and A<=5:
  print(0);
elif A>5 and A<=12:
  print(B/2);
else:
  print(B);

Buggy submission (verdict: Runtime Error):
read=input();
A,B=map(int,read).spilt(' ')
if A>=0 and A<=5:
  print(0);
elif A>5 and A<=12:
  print(B/2);
else:
  print(B);

Buggy submission (verdict: Runtime Error):
read=input;
A,B=map(int,read()).spilt()
if A>=0 and A<=5:
  print(0);
elif A>5 and A<=12:
  print(B/2);
else:
  print(B);

Buggy submission (verdict: Runtime Error):

if A>=0 and A<=5:
  print(0);
elif A>5 and A<=12:
  print(B/2);
else:
  print(B);

Buggy submission (verdict: Runtime Error):

if A>=0 and A<=5:
  return 0;
elif A>5 and A<=12:
  return B/2;
else:
  return B;
Problem p03037 (python)

Fixed submission:
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
l=[0]*m
r=[0]*m
for i in range(m):
    l[i],r[i]=[int(i) for i in input().split(' ')]
result=min(r)-max(l)+1
result=result if result>0 else 0
print(result)

Buggy submission (verdict: Runtime Error):
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
mini=-1
maxi=1000000000000000
for i in range(m):
    a,b=[int(i) for i in input().split(' ')]
	tmp_mini=max(mini,a)
    tmp_maxi=min(maxi,b)
    if(tmp_mini<tmp_maxi):
      mini=tmp_mini
      maxi=tmp_maxi
    elif(tmp_mini==tmp_maxi):
      if tmp_mini<=n:
        print(1)
        break
      else:
        print(0)
        break
    else:
      print(0)
      break
if(mini<maxi):      
  if n>=maxi:
    print(maxi-mini+1)
  elif maxi>n>=mini:
    print(n-mini+1)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
from functools import reduce
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
mini=-1
maxi=1000000000000000
for i in range(m):
    a,b=[int(i) for i in input().split(' ')]
	tmp_mini=max(mini,a)
    tmp_maxi=min(maxi,b)
    if(tmp_mini<tmp_maxi):
      mini=tmp_mini
      maxi=tmp_maxi
    elif(tmp_mini==tmp_maxi):
      if tmp_mini<=n:
        print(1)
        break
      else:
        print(0)
        break
    else:
      print(0)
      break
      
if n>=maxi:
  print(maxi-mini+1)
elif maxi>n>=mini:
  print(n-mini+1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
gate=[0]*m
for i in range(m):
    a,b=[int(i) for i in input().split(' ')]
    gate[i]=set([j for j in range(a,b+1)])
result=reduce(lambda x,y:x&y, gate)
count=0
for re in result:
  if re <=n:
    count+=1
print(count)
Problem p04044 (python)

Fixed submission:

n, l = map(int, raw_input().split())
a = []
for i in xrange(n):
  a.append(raw_input())
a.sort()
print "".join(a)

Buggy submission (verdict: Runtime Error):
n, l = map(int, raw_input().split())

for i in xrange(n):
  a.append(raw_input())
a.sort()
print "".join(a)

Buggy submission (verdict: Runtime Error):
n, l = map(int, raw_input().split())

for i in xrange(n):
  a.append(raw_input())
a.sort()
print " ".join(a)
Problem p03005 (python)

Fixed submission:
x,y = input().split()
N = int(x)
K = int(y)
if K == 1:
  print(0)
else:
  print(N-K)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
if k == 1:
  print(0)
else:
  print(N-K)
Problem p03005 (python)

Fixed submission:
from sys import stdin
l = stdin.readline().rstrip().split()

n = int(l[0])
k=int(l[1])

if k == 1:
    print(0)
else:
    print(n-k)

Buggy submission (verdict: Runtime Error):
from sys import stdin
l = stdin.readline().rstrip().split()

n = int(l[0])
k=int(l[1])

if k == 1:
    print 0;
else:
    print n-k

Buggy submission (verdict: Runtime Error):
s = input().split(",")
n = int(s[0])
k=int(s[1])

if k == 1:
    return 0;
else:
    return n-k
Problem p03456 (python)

Fixed submission:
s = int(input().replace(' ',''))
print("Yes" if int(s**0.5)**2==s else "No")

Buggy submission (verdict: Runtime Error):
s = int(input().replace(' ',''))
print("Yes" if int(s**0.5)**2==s) else "No")

Buggy submission (verdict: Runtime Error):
s = int(input().replace(' ','')
print("Yes" if int(s**0.5)**2==s) else "No")

Buggy submission (verdict: Runtime Error):
int(input().replace(' ','')
print("Yes" if int(s**0.5)**2==s) else "No")
Problem p03005 (python)

Fixed submission:
n, k = map(int, input().split())
if k == 1:
	print(0)
else:
	s1 = n - k
	print(s1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
if n == 1:
	print(1)
	exit()
a = sorted(a)
for i in range(n):
	tc = a[i]
	for j in range(i + 1, n):
		nd = a[j]
		x1, y1, = tc[0], tc[1]
		x2, y2, = nd[0], nd[1]
		rz1 = x1 - x2
		rz2 = y1 - y2
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))
Problem p03006 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
if n == 1:
	print(1)
	exit()
a = sorted(a)
for i in range(n):
	tc = a[i]
	for j in range(i + 1, n):
		nd = a[j]
		x1, y1, = tc[0], tc[1]
		x2, y2, = nd[0], nd[1]
		rz1 = x1 - x2
		rz2 = y1 - y2
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
for i in range(n):
	tc = a[i]
	for j in range(i + 1, n):
		nd = a[j]
		x1, y1, = tc[0], tc[1]
		x2, y2, = nd[0], nd[1]
		rz1 = abs(x1- x2)
		rz2 = abs(y1 - y2)
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
for i in range(n):
	tc = a[i]
	for j in range(i + 1, n):
		nd = a[j]
		x1, y1, = tc[0], tc[1]
		x2, y2, = nd[0], nd[1]
		rz1 = abs(x1- x2)
		rz2 = abs(y1 - y2)
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))

Buggy submission (verdict: Runtime Error):
import math
from decimal import Decimal
def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return n,b
 
 
def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return n,b,c
 
 
def dv():
	n, m = map(int, input().split())
	return n,m
 
 
def dva():
	n, m = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return n,m,b
 
 
def eratosthenes(n): 
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))
 
 
 
def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return n,b,m,c
 
 
def dvs():
	n = int(input())
	m = int(input())
	return n, m
 

n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
for i in range(n):
	tc = a[i]
	for j in range(i + 1, n):
		nd = a[j]
		x1, y1, = tc[0], tc[1]
		x2, y2, = nd[0], nd[1]
		rz1 = abs(x1- x2)
		rz2 = abs(y1 - y2)
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))
Problem p03087 (python)

Fixed submission:
# 答案
N,Q = map(int,input().split())
S = input()
l,r = 0,0
csum = [0]*(N+1)

# 累積和
for ctr in range(N):
    if ctr == (N-1):
        csum[ctr+1] = csum[ctr]
    elif S[ctr]=='A' and S[ctr+1]=='C':
        csum[ctr+1] = csum[ctr] + 1
    else:
        csum[ctr+1] = csum[ctr]

# 出力
for ctr in range(Q):
    l,r=map(int,input().split())
    print(csum[r-1] - csum[l-1])

Buggy submission (verdict: Runtime Error):
# 答案
N,Q = map(int,input().split())
S = input()
l,r = 0,0
csum = [0]*(N+1)

# 累積和
for ctr in range(N):
    if S[ctr]=='A' and S[ctr+1]=='C':
        csum[ctr+1] = csum[ctr] + 1
    else:
        csum[ctr+1] = csum[ctr]

# 出力
for ctr in range(Q):
    l,r=map(int,input().split())
    print(csum[r-1] - csum[l-1])
Problem p03711 (python)

Fixed submission:
a_group = [1, 3, 5, 7, 8, 10, 12]
b_group = [4, 6, 9, 11]
c_group = [2]

x, y = list(map(int, input().split()))

if x in a_group and y in a_group:
    print('Yes')
elif x in b_group and y in b_group:
    print('Yes')
elif x in c_group and y in c_group:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
group_list = [0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2]

x, y = list(map(int, input().split()))

if group_list[x] == group_list[y]:
    print('Yes')
else:
    print('No')
Problem p03722 (python)

Fixed submission:
import sys 

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

for _ in range(M):
    a, b, c = list(map(int, input().split()))
    a_list.append(a)
    b_list.append(b)
    c_list.append(-c)

inf = sys.maxsize
dist = [inf] * N
dist[0] = 0

for loop in range(N):
    for i in range(M):
        if dist[a_list[i]-1] == inf:
            continue
        if dist[b_list[i]-1] > dist[a_list[i]-1] + c_list[i]:
            dist[b_list[i]-1] = dist[a_list[i]-1] + c_list[i]
            if loop == N - 1 and b_list[i] == N:
                print('inf')
                sys.exit()

print(-dist[N-1])

Buggy submission (verdict: Runtime Error):
import sys 

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

for _ in range(M):
    a, b, c = list(map(int, input().split()))
    a_list.append(a)
    b_list.append(b)
    c_list.append(-c)

inf = sys.maxsize
dist = [inf for _ in range(N)]
dist[0] = 0

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

ans = dist[N-1]
negative = [False for _ in range(N)]

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

if nagative[N-1]:
    print('inf')
else:
    print(str(-ans))
Problem p03732 (python)

Fixed submission:
N, W = list(map(int, input().split()))
w0, v0 = list(map(int, input().split()))
w_dict = dict()
w_dict[w0] = [v0]
w_dict[w0+1] = list()
w_dict[w0+2] = list()
w_dict[w0+3] = list()

for _ in range(N-1):
    w, v = list(map(int, input().split()))
    w_dict[w].append(v)

w_dict[w0]   = sorted(w_dict[w0],   reverse=True)
w_dict[w0+1] = sorted(w_dict[w0+1], reverse=True)
w_dict[w0+2] = sorted(w_dict[w0+2], reverse=True)
w_dict[w0+3] = sorted(w_dict[w0+3], reverse=True)

max_sum_v = 0
for i_0 in range(len(w_dict[w0])+1):
    for i_1 in range(len(w_dict[w0+1])+1):
        for i_2 in range(len(w_dict[w0+2])+1):
            for i_3 in range(len(w_dict[w0+3])+1):
                sum_w = w0 * i_0 + (w0 + 1) * i_1 + (w0 + 2) * i_2 + (w0 + 3) * i_3
                if sum_w > W:
                    continue
                sum_v = sum(w_dict[w0][:i_0])   + \
                        sum(w_dict[w0+1][:i_1]) + \
                        sum(w_dict[w0+2][:i_2]) + \
                        sum(w_dict[w0+3][:i_3])
                max_sum_v = max(sum_v, max_sum_v)

print(max_sum_v)

Buggy submission (verdict: Runtime Error):
N, W = list(map(int, input().split()))
w_list = list()
v_list = list()

for _ in range(N):
    w, v = list(map(int, input().split()))
    w_list.append(w)
    v_list.append(v)

cases = [[0]*(W+1)]

for i_item in range(1, N+1):
    case = [0]
    w = w_list[i_item-1]
    v = v_list[i_item-1]
    for i_w in range(1, W+1):
        if w > i_w:
            val = cases[i_item-1][i_w]
        else:
            val = max(cases[i_item-1][i_w], cases[i_item-1][i_w-w] + v)
        case.append(val)
    cases.append(case)

print(cases[N][W])
Problem p03231 (python)

Fixed submission:

def lcm(x, y):
    return (x * y) // gcd(x, y)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N, M = map(int, input().split())
S = input()
T = input()

gcdNM = gcd(N, M)
lcmNM = lcm(N, M)

isGood = True
for i in range(gcdNM):
    if S[i * N // (gcdNM)] != T[i * M // (gcdNM)]:
        isGood = False
        break

if isGood and T[0] == S[0]:
    print(lcmNM)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


N, M = map(int, input().split())
S = input()
T = input()


gcdNM = math.gcd(N, M)
lcmNM = lcm(N, M)

isGood = True
for i in range(gcdNM):
    if S[i * N // (gcdNM)] != T[i * M // (gcdNM)]:
        isGood = False
        break

if isGood and T[0] == S[0]:
    print(lcmNM)
else:
    print(-1)
Problem p03262 (python)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(x[0] - X)

for i in range(len(x)):
    ans = gcd(ans, abs(x[i] - X))

print(ans)

Buggy submission (verdict: Runtime Error):
import functools
import math

N, X = map(int, input().split())
x = list(map(int, input().split()))
subX = []

for x_i in x:
    subX.append(abs(x_i - X))

print(functools.reduce(math.gcd, subX))

Buggy submission (verdict: Runtime Error):
import functools
import math

N, X = map(int, input().split())
x = list(map(int, input().split()))
subX = []

for x_i in x:
    subX.append(abs(x_i - X))

print(functools.reduce(math.gcd, subX))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(function.gcd, numbers)

def gcd_list(numbers):
    return reduce(function.gcd, numbers)

N, X = map(int, input().split())
x = list(map(int, input().split()))
subX = []

for x_i in x:
    subX.append(abs(x_i - X))

print(gcd_list(subX))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
x = list(map(int, input().split()))
subX = []

for x_i in x:
    subX.append(abs(x_i - X))

print(gcd_list(subX))
Problem p03276 (python)

Fixed submission:
# S = input()
# N = int(input())
N, K = map(int, input().split())
X = list(map(int, input().split()))
# LR = [list(map(int, input().split())) for _ in range(M)]

ans = 10000000000

if K == 1:
    for i in range(N):
        if ans > abs(X[i]):
            ans = abs(X[i])
else:
    for i in range(N - K+1):
        left = X[i]
        right = X[i + K - 1]
        sum = 0

        if abs(left) <= abs(right):
            sum += abs(left)
        else:
            sum += abs(right)

        sum += abs(left - right)

        if ans > sum:
            ans = sum

print(ans)

Buggy submission (verdict: Runtime Error):
import statistics

def Medi(Arra, Haba):
    re = []
    for i_M in range(len(Arra) - Haba + 1):
        re.append(statistics.median_high(Arra[i_M: i_M+Haba]))
    return re

N = int(input())
A = list(map(int, input().split()))
print(A)
ans = []

if N == 1:
    ans.append(A[0])
else:
    kuri = max(N//2, 10)
    for i in range(1, N+1):
        ans += Medi(A, i)
        so = ans
        so.sort()
        print(so)


print(statistics.median_high(ans))