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

Fixed submission:
s = input()
if(len(s)==2):
    print(s)
else:
    print(s[::-1])

Buggy submission (verdict: Runtime Error):


a=[]
N = int(input())
for i in range(N):
    a.append(int(input()))
a=sorted(a)

if(len(a)==2):
    print(abs(a[0]-a[1]))
elif(len(a)==3):
    print(max(a[2] - a[1] + a[2] - a[0], a[1]-a[0] + a[2]-a[0]))
else:
    #----------------------------------------------------------------------
    def append2big(id1, id2):
        global bBeg
        global bEnd
        global s
        if (a[id1] - bBeg + a[id2] - bEnd < a[id2] - bBeg + a[id1] - bEnd):
            id1, id2 = id2, id1
        s+=a[id1] - bBeg + a[id2] - bEnd
        bBeg = a[id1]
        bEnd = a[id2]
    def append2small(id1, id2):
        global bBeg
        global bEnd
        global s
        if (bBeg - a[id1] + bEnd - a[id2] < bBeg - a[id2] + bEnd - a[id1]):
            id1, id2 = id2, id1
        s+=bBeg - a[id1] + bEnd - a[id2]
        bBeg = a[id1]
        bEnd = a[id2]
    def append1small(id):
        global bBeg
        global bEnd
        global s
        if (bBeg - a[id] > bEnd - a[id]):
            s+=bBeg-a[id]
            bBeg = a[id]
        else:
            s+=bEnd-a[id]
            bEnd = a[id]
    def append1big(id):
        global bBeg
        global bEnd
        global s
        if (a[id] - bBeg > a[id] - bEnd):
            s+=a[id]-bBeg
            bBeg = a[id]
        else:
            s+=a[id]-bEnd
            bEnd = a[id]
    # ----------------------------------------------------------------------
    s = a[N-2]-a[0] + a[N-1] - a[0]
    bBeg = a[N-2]
    bEnd = a[N-1]
    l = 0
    r = N-2
    cur = 0
    while(l<r-1):
        if(cur==0):
            if(l+2<r):
                append2small(l+1, l+2)
                l+=2
            elif(l+1<r):
                append1small(l+1)
                l+=1
            cur = 1-cur
        else:
            if(r-2>l):
                append2big(r-1, r-2)
                r-=2
            elif(r-1>l):
                append1big(r-1)
                r-=1
            cur = 1- cur
    r1 = s
    #-----case 2------
    s = a[N - 1] - a[0] + a[N - 1] - a[1]
    bBeg = a[0]
    bEnd = a[1]
    l = 1
    r = N - 1
    cur = 1
    while (l < r - 1):
        if (cur == 0):
            if (l + 2 < r):
                append2small(l + 1, l + 2)
                l += 2
            elif (l + 1 < r):
                append1small(l + 1)
                l += 1
            cur = 1 - cur
        else:
            if (r - 2 > l):
                append2big(r - 1, r - 2)
                r -= 2
            elif (r - 1 > l):
                append1big(r - 1)
                r -= 1
            cur = 1 - cur
    r2 = s

    print(max(r1, r2))

Buggy submission (verdict: Runtime Error):
a=[]
a1,a2,c = input().split()
a.append(int(a1))
a.append(int(a2))
c = int(c)
cur = 0
for i in range(c):
    a[1-cur]+=a[cur]//2
    a[cur]//=2
    cur=1-cur
print(a[0], a[1])
Problem p03227 (python)

Fixed submission:
N=input()
if len(N)==3:
     N = N[::-1]
     print(N)
elif len(N)==2:
     print(N)

Buggy submission (verdict: Runtime Error):
N=(input())
if len(N)==3:
...     N = N[::-1]
...     print(N)
... elif len(N)==2:
...     print(N)
Problem p03238 (python)

Fixed submission:
N=int(input())


if (N==1):
    print("Hello World")
else:
    A=int(input())
    B=int(input())
    print(A+B)

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

N=int(N)

x=list()
y=list()
h=list()
for i in range(N):
    temp=input().split(" ")
    x.append(int(temp[0]))
    y.append(int(temp[1]))
    h.append(int(temp[2]))
    
def pass_all_condition(x,y,h,x_i,y_i,h_i):
    result=True
    for  k in range(len(x)):
        if h[k]!=max(h_i-abs(x_i-x[k])-abs(y_i-y[k]),0):
            result=False
    return(result)
    
def print_answer(x,y,h):
    for x_i in range(100):
        for y_i in range(100):
            for h_i in range(1,100):
                if pass_all_condition(x,y,h,x_i,y_i,h_i):
                    print(x_i, y_i, h_i)
                    return

print_answer(x,y,h)
Problem p03241 (python)

Fixed submission:
import math
 
N, M=input().split(" ")
N=int(N)
M=int(M)
 
def get_number(M):
    result=list()
    for i in range(1,int(math.sqrt(M))):
        if M%i==0:
            result.append(i)
            result.append(int(M/i))
    result.sort()
    return(result)
    
def check_number(N,M):
    if N==1:
        return(M)
    number=get_number(M)
    answer=list()
    for i in number:
        if M/i>=N:
            answer.append(i)
            
    return(answer[-1])
    
print(check_number(N,M))

Buggy submission (verdict: Runtime Error):
import math
 
N, M=input().split(" ")
N=int(N)
M=int(M)
 
def get_number(M):
    result=list()
    for i in range(1,int(math.sqrt(M))):
        if M%i==0:
            result.append(i)
            result.append(int(M/i))
    result.sort()
    return(result)
    
def check_number(N,M):
    number=get_number(M)
    answer=list()
    for i in number:
        if M/i>=N:
            answer.append(i)
            
    return(answer[-1])
    
print(check_number(N,M))

Buggy submission (verdict: Runtime Error):
import math

N, M=input().split(" ")
N=int(N)
M=int(M)

def get_number(M):
    result=list()
    for i in range(1,int(math.sqrt(M))):
        if M%i==0:
            result.append(i)
            result.append(int(M/i))
    result.sort()
    return(result)
    
def check_number(N,M):
    number=get_number(M)
    answer=list()
    for i in number:
        if M/i>=N:
            answer.append(i)
            
    return(answer[-1])
    
check_number(N,M)
Problem p03284 (python)

Fixed submission:
text=input()
N=int(text.split(" ")[0])
K=int(text.split(" ")[1])

if (N%K)!=0:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
text=input()
N=text

temp4=[4*i for i in range(25)]
temp7=[7*i for i in range(14)]

temp=list()
flg=False
for i in temp4:
    for j in temp7:
        temp.append(i+j)
        if int(N)==i+j:
            flg=True
            print("Yes")

if flg:
    pass
else:
    print("No")
Problem p03719 (python)

Fixed submission:
arnum = input().split()
a = int(arnum[0])
b = int(arnum[1])
c = int(arnum[2])
if c >= a and c <= b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
nk = [int(i) for i in input().split()]
n = nk[0]
k = nk[1]
array = []
count = []
for i in range(n):
    num = input().split()
    a = num[0]
    b = int(num[1])
    k -= b
    array.append(a)
    if k <= 0:
        break
    else:
        array.pop()
print(array[0])
Problem p03238 (python)

Fixed submission:
dat0 = input()
if dat0 == "1":
    print("Hello World")
else:
    dat1 = input()
    dat2 = input()
    ans = int(dat1) + int(dat2)
    print(ans)

Buggy submission (verdict: Runtime Error):
dat0 = input()
if dat0 == 1:
    print("Hello World")
else:
    dat1 = input()
    dat2 = input()
    ans = int(dat1) + int(dat2)
    print(ans)

Buggy submission (verdict: Runtime Error):
dat0 = input()
dat1 = input()
dat2 = input()


if dat0 == 1:
    print("Hello World")
else
    ans = int(dat1) + int(dat2)
    print(ans)
Problem p03239 (python)

Fixed submission:
import numpy as np

dat0 = input().split()
N = int(dat0[0])
T = int(dat0[1])

dat1 = [input().split() for i in range(N)]

dat = np.array(dat1)
dat = dat.astype(np.int64)



lt_T = dat.T[1] <= T

ans = dat.T[0][lt_T]

if len(ans) == 0:
    print("TLE")
else:
    print(ans.min())

Buggy submission (verdict: Runtime Error):

import numpy as np
import pandas as pd

dat0 = input().split()
N = int(dat0[0])
T = int(dat0[1])

dat1 = [input().split() for i in range(N)]

df = pd.DataFrame(dat1)
df = df.astype(np.int64)

lt_T = df[1] < T

ans = df[lt_T].min()[0]

if np.isnan(ans):
    print("TLE")
else:
    print(ans)
Problem p03547 (python)

Fixed submission:
x, y = map(str, input().split())

if x<y:
    print("<")
elif x>y:
    print(">")
else:
    print("=")

Buggy submission (verdict: Runtime Error):
n, z, w = map(int, input().split())
a = [int(x) for x in input().split()]
 
if n == 1:
    print(abs(a[0]) - w)
else:
    print(max(abs(a[n-2]-a[n-1]), abs(a[n-1]-w)))
Problem p03238 (python)

Fixed submission:
x = input()
if int(x) == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a + b)

Buggy submission (verdict: Runtime Error):
N = int(input())
data = []
for _ in range(N):
    x, y, h = list(map(int, input().split()))
    data.append([x,y,h])
for x in range(101):
    flag2 = True
    for y in range(101):
        result = abs(data[0][0] - x) + abs(data[0][1] - y) + data[0][2]
        flag = True
        for dat in data:
            if result != abs(dat[0] - x) + abs(dat[1] - y) + dat[2]:
                flag = False
                break
        if flag == True and result >= 0:
            print(x,y,result)
            Flag2 = False
            break
    if flag2 == False:break
Problem p03262 (python)

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

n, x = list(map(int, input().split()))
list = list(map(int, input().split()))
list = [abs(i - x) for i in list]
min = min(list)
for num in list:
    min = gcd(min, num)
print(min)

Buggy submission (verdict: Runtime Error):
import math
n, x = list(map(int, input().split()))
list = list(map(int, input().split()))
list = [abs(i - x) for i in list]
min = min(list)
for num in list:
    min = math.gcd(min, num)
print(min)
Problem p03471 (python)

Fixed submission:
n, y = list(map(int, input().split()))
#a, b, c = -1, -1, -1
flag = False
for i in range(n + 1):
    for j in range((n + 1) - i):
        k = n - i - j
        if i * 10000 + j * 5000 + k * 1000 == y:
            print(i, j, k)
            flag = True
            break
    if flag:break
if not flag:print(-1, -1, -1)

Buggy submission (verdict: Runtime Error):
n, y = list(map(int, input().split()))
for i in range(n + 1):
    for j in range((n + 1) - i + 1):
        k = n - i - j
        if i * 10000 + j * 5000 + k * 1000 == y:
            print(i, j, k)
            exit(1)
print(-1, -1, -1)
Problem p03238 (python)

Fixed submission:
N=int(input())
if N==1:
  print ('Hello World')
else:
  A=int(input())
  B=int(input())
  print (A+B)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N==1:
  print ('Hello World')
else:
  A=int(input())
  B=int(input())
  pirnt (A+B)
Problem p03251 (python)

Fixed submission:
N,M,X,Y = list(map(int,input().split()))

data_x = list(map(int,input().split()))
data_y = list(map(int,input().split()))

max_x = max(data_x)
min_y = min(data_y)

if  max_x >= min_y:
	print('War')
elif X >= min_y:
    print('War')
elif Y <= max_x:
    print('War')
else:
    print('No War')

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

data_x = list(map(int,input().split()))
data_y = list(map(int,input().split()))

max_x = max(data_x)
min_y = min(data_y)

if  max_x > min_y:
	print('War')
elif data_x.count(Y) ~= 0:
    print('War')
elif data_y.count(X) ~= 0:
    print('War')
else:
    print('No War')
Problem p03281 (python)

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

ans = 0

for i in range(N+1):
    if  i % 2 == 1:
        num = 0
        for j in range(1,201):
            if  i % j == 0:
                num += 1
                if  num == 8:
                    ans += 1
        
print(ans)

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

ans = 0

for i in range(N):
    num = 0
    for j in range(200):
        if  N % j == 0:
        num += 1
    if  num == 8:
    ans += 1

print(ans)
Problem p03282 (python)

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

ans = 1
num_1 = 0

for i in range(len(S)):
    if  not S[i] == '1':
        ans = int(S[i])
        break
    else:
        num_1 += 1

if  len(S) == 1:
    ans = int(S[0])
if  num_1 >= N:
    ans = 1
        
print(ans)

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

ans = 1

for i in range(len(S)):
    if  not S[i] == '1':
        ans = int(S[i])
        break

if  len(S) == 1:
    ans = int(S[1])
        
print(ans)
Problem p03292 (python)

Fixed submission:
import itertools

A1,A2,A3 = map(int,input().split())
    
vec = [A1,A2,A3]
com = list(itertools.permutations(vec))
    
all_cos = [0,0,0,0,0,0]
for i in range(6):
    tmp_com = com[i]
        
    tmp_A1 = tmp_com[0]
    tmp_A2 = tmp_com[1]
    tmp_A3 = tmp_com[2]
        
    cos1 = 0
    cos2 = abs(tmp_A1 - tmp_A2)
    cos3 = abs(tmp_A2 - tmp_A3)
        
    all_cos[i] = cos1 + cos2 + cos3
    
res = min(all_cos)
print(res)

Buggy submission (verdict: Runtime Error):
import itertools

    A1,A2,A3 = map(int,input().split())
    
    vec = [A1,A2,A3]
    com = list(itertools.permutations(vec))
    
    
    all_cos = [0,0,0,0,0,0]
    for i in range(6):
        tmp_com = com[i]
        
        tmp_A1 = tmp_com[0]
        tmp_A2 = tmp_com[1]
        tmp_A3 = tmp_com[2]
        
        cos1 = 0
        cos2 = abs(tmp_A1 - tmp_A2)
        cos3 = abs(tmp_A2 - tmp_A3)
        
        all_cos[i] = cos1 + cos2 + cos3
    
    res = min(all_cos)
    print(res)

Buggy submission (verdict: Runtime Error):
import itertools

    IP  = input()
    
    A1 = int(IP[0])
    A2 = int(IP[2])
    A3 = int(IP[4])
    
    vec = [A1,A2,A3]
    com = list(itertools.permutations(vec))
    
    
    all_cos = [0,0,0,0,0,0]
    for i in range(6):
        tmp_com = com[i]
        
        tmp_A1 = tmp_com[0]
        tmp_A2 = tmp_com[1]
        tmp_A3 = tmp_com[2]
        
        cos1 = 0
        cos2 = abs(tmp_A1 - tmp_A2)
        cos3 = abs(tmp_A2 - tmp_A3)
        
        all_cos[i] = cos1 + cos2 + cos3
    
    res = min(all_cos)
    print(res)

Buggy submission (verdict: Runtime Error):
import itertools

    vec =  input()
    
    com = list(itertools.permutations(vec))
    
    
    all_cos = [0,0,0,0,0,0]
    for i in range(6):
        tmp_com = com[i]
        
        tmp_A1 = tmp_com[0]
        tmp_A2 = tmp_com[1]
        tmp_A3 = tmp_com[2]
        
        cos1 = 0
        cos2 = abs(tmp_A1 - tmp_A2)
        cos3 = abs(tmp_A2 - tmp_A3)
        
        all_cos[i] = cos1 + cos2 + cos3
    
    res = min(all_cos)
    print(res)

Buggy submission (verdict: Runtime Error):
import itertools


    
    vec = [A1,A2,A3]
    com = list(itertools.permutations(vec))
    
    
    all_cos = [0,0,0,0,0,0]
    for i in range(6):
        tmp_com = com[i]
        
        tmp_A1 = tmp_com[0]
        tmp_A2 = tmp_com[1]
        tmp_A3 = tmp_com[2]
        
        cos1 = 0
        cos2 = abs(tmp_A1 - tmp_A2)
        cos3 = abs(tmp_A2 - tmp_A3)
        
        all_cos[i] = cos1 + cos2 + cos3
    
    res = min(all_cos)
    print(res)

Buggy submission (verdict: Runtime Error):
import itertools


def solve(A1,A2,A3):
    
    vec = [A1,A2,A3]
    com = list(itertools.permutations(vec))
    
    
    all_cos = [0,0,0,0,0,0]
    for i in range(6):
        tmp_com = com[i]
        
        tmp_A1 = tmp_com[0]
        tmp_A2 = tmp_com[1]
        tmp_A3 = tmp_com[2]
        
        cos1 = 0
        cos2 = abs(tmp_A1 - tmp_A2)
        cos3 = abs(tmp_A2 - tmp_A3)
        
        all_cos[i] = cos1 + cos2 + cos3
    
    res = min(all_cos)
    
    return res

res = solve(A1,A2,A3)
print(res)
Problem p03294 (python)

Fixed submission:
number_int = input()
list_int = list(map(int,input().split()))

print(str(sum(list_int) - int(number_int)))

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

print(sum(list_int)-number_int)
Problem p03323 (python)

Fixed submission:
a, b = map(int, input().split())
if a<=8 and b<=8:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = []
y = []
z = []
f = [[] for _ in range(8)]
for i in range(n):
    a = input()
    a = a.split(' ')
    a = list(map(int, a))
    xi = a[0]
    yi = a[1]
    zi = a[2]
    x.append(xi)
    y.append(yi)
    z.append(zi)
    fi = [0 for _ in range(8)]
    fi[0] = xi + yi + zi
    fi[1] = xi + yi - zi
    fi[2] = xi - yi + zi
    fi[3] = -xi + yi + zi
    fi[4] = xi - yi - zi
    fi[5] = -xi - yi + zi
    fi[6] = -xi + yi - zi
    fi[7] = -xi - yi - zi
    for j in range(8):
        f[j].append(fi[j])
def reversort(x):
    return list(reversed(sorted(x)))
f = list(map(reversort, f))
fmax = [0 for _ in range(8)]
for i in range(m):
    for j in range(8):
        fmax[j] += f[j][i]
print(max(fmax))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a<=8 and b<=8:
  print('Yay!')
else:
  print(':(')
Problem p03352 (python)

Fixed submission:
x = int(input())
if x == 1:
  print(x)
else:
  L = [n**k for n in range(1, x//2) for k in range(2, 10) if n**k<=x]
  print (max(L))

Buggy submission (verdict: Runtime Error):
x = int(input())
L = [n**k for n in range(1, x) for k in range(2, 10) if n**k<=x]
print (max(L))

Buggy submission (verdict: Runtime Error):
x = int(input())
L = [n**k for n in range(1, x) for k in range(1, x) if n**k<=x]
print (max(L))

Buggy submission (verdict: Runtime Error):
x = int(input())
L = [n**k for n in range(1, x) for k in range(1, x//2) if n**k<=x]
print (max(L))

Buggy submission (verdict: Runtime Error):
x = int(input())
L = [n**k for n in range(1, x) for k in range(1, x)]
print (max(L))
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 == 0:
  print ('Even')
else:
  print ('Odd')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a*b)%2 == 0:
  print 'Even'
else:
  print 'Odd'

Buggy submission (verdict: Runtime Error):
a, b =map(int, input().split())
x = a*b
if x%2 == 0:
  print 'Even'
else:
  print 'Odd'

Buggy submission (verdict: Runtime Error):
a, b =map(int, input().split())
if (a*b)%2 ==0:
  print 'even'
else:
  print 'odd'

Buggy submission (verdict: Runtime Error):
a, b =map(int, input().split())
if (a*b)%2 ==0
   print 'even'
else:
    print 'odd'
Problem p03231 (python)

Fixed submission:
import fractions
nm=raw_input()
nm=nm.split()
n=eval(nm[0])
m=eval(nm[1])
s=raw_input()
t=raw_input()

gg=fractions.gcd(n,m)
ll=n/gg*m
result = ll
for i in xrange(n):
    if not (i*m) % n :
            tmp=i*m/n
            if s[i] != t[tmp] :
                result= -1
print result

Buggy submission (verdict: Runtime Error):
import fractions
nm=raw_input()
nm=nm.split()
n=eval(nm[0])
m=eval(nm[1])
s=raw_input()
t=raw_input()

gg=fractions.gcd(n,m)

result = ll
for i in xrange(n):
    if not (i*m) % n :
            tmp=i*m/n
            if s[i] != t[tmp] :
                result= -1
print result

Buggy submission (verdict: Runtime Error):
import fractions
nm=raw_input()
nm=nm.split()
n=eval(nm[0])
m=eval(nm[1])
s=raw_input()
t=raw_input()

gg=fractions.gcd(n,m)
ll=n*m/gg
aa=ll/n
bb=ll/m
result = ll
for i in range(ll) :
    if not (i % aa):
        tmp1=i/aa
        if not(i % bb) :
            tmp2=i/bb
            if s[tmp1] != t[tmp2] :
                result= -1
print result
Problem p03262 (python)

Fixed submission:
from fractions import gcd
n, s = map(int, raw_input().split())
xs = [ int(i) for i in raw_input().split()]
diff = [ abs(x-s) for x in xs]
print(reduce(gcd, diff))

Buggy submission (verdict: Runtime Error):
n, s = map(int, raw_input().split())
xs = [ int(i) for i in raw_input().split()]

diff = [ abs(x-s) for x in xs]

divisors = []
target = min(diff)
while True:
    if target > max(diff):
        break
    if all([d % target == 0  for d in diff]):
        divisors.append(target)
    target += 1

print(max(divisors))
Problem p03386 (python)

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

if b - a + 1 <= k * 2:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        if i >= 1:
            print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, raw_input().split())

if b - a + 1 <= k * 2:
    for i in range(a, b+1):
        print(i)
else:
    l = list(range(a, b+1))
    for i in l[:k]:
        print(i)
    for i in l[-k:]:
        print(i)
Problem p03254 (python)

Fixed submission:
N, x = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort()
 
def counter(x, alist):
  count = 0
  while x > 0:
      if alist:
          tmp = alist.pop(0)
          x = x - tmp
          if x == 0:
              return count + 1
          elif x > 0:
              count += 1
          else:
              return count
      else:
          return count - 1
print(counter(x, alist))

Buggy submission (verdict: Runtime Error):
N, x = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort()
 
def counter(x, alist):
  count = 0
  while x > 0:
      if alist:
          tmp = alist.pop(0)
          x = x - tmp
          if x == 0:
              return count + 1
          elif x > 0:
              count += 1
          else:
              return count
      else:
          return count - 1
print(counter(x, alist))
N, x = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort()

def counter(x, alist):
  count = 0
  while x > 0:
      if alist:
          tmp = alist.pop(0)
          x = x - tmp
          if x == 0:
              return count + 1
          elif x > 0:
              count += 1
          else:
              return count
      else:
          return count - 1
print(counter(x, alist))
Problem p03231 (python)

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

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

sl, tl = map(int, input().split())
s = input()
t = input()

m = lcm(sl,tl)

mps = m // sl
mpt = m // tl

tmp = 0
width = max(mps,mpt)
ans = True

while tmp < m:
    if tmp % mps == 0 and tmp % mpt == 0:
        if s[tmp//mps] != t[tmp//mpt]:
            ans = False
            break
    tmp += width

if ans:
    print(m)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

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

sl, tl = map(int, input().split())
s = input()
t = input()

m = lcm(sl,tl)

mps = m // sl
mpt = m // tl

tmp = 0
width = max(mps,mpt)
ans = True

while tmp < m:
    if tmp % mps == 0 and tmp % mpt == 0:
        if s[tmp//mps] != t[tmp//mpt]:
            ans = False
            break
    tmp += width

if ans:
    print(m)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

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

sl, tl = map(int, input().split())
s = input()
t = input()

# 最小公倍数
m = lcm(sl,tl)

# sとtの幅
mps = m // sl
mpt = m // tl

tmp = 0
width = max(mps,mpt)
ans = True

while tmp < m:
    if tmp % mps == 0 and tmp % mpt == 0:
        if s[tmp//mps] != t[tmp//mpt]:
            ans = False
            break
    tmp += width

if ans:
    print(m)
else:
    print(-1)
Problem p03671 (python)

Fixed submission:
a,b,c = map(int,raw_input().split())
print(min([a+b,b+c,c+a]))

Buggy submission (verdict: Runtime Error):
n = int(raw_input())
a = map(int,raw_input().split(' '))
b = []
for i in range(n):
    if i%2 == 0:
        b.append(a[i])
    else:
        b.insert(0,a[i])
if n%2 != 0:
    b.reverse()
s = str(b[0])
for i in range(n-1):
    s += ' ' + str(b[i+1])
print s
Problem p03231 (python)

Fixed submission:
def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

n, m = map(int, input().split())
S = input()
T = input()
L = (n*m) // gcd(n, m)
c = 0

xs = L//n
xt = L//m
step = xs * xt

for i in range(0, L, step):
    if S[i//xs] != T[i//xt]:
        print(-1)
        exit()
print(L)

Buggy submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
S = input()
T = input()
L = (n*m) // math.gcd(n, m)
c = 0

xs = L//n
xt = L//m
step = xs * xt
for i in range(0, L, step):
    if S[i//xs] != T[i//xt]:
        print(-1)
        exit()
print(L)