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

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 22 21:34:54 2019

@author: owner
"""
import numpy as np

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

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

# %%
A, B, C, D = list(map(int, input().split()))
    
CD = lcm(C, D) 

n_C = np.int(np.floor(B/C) - np.floor((A-1)/C))
n_D = np.int(np.floor(B/D) - np.floor((A-1)/D))

# n_CD = np.int(np.floor(B/CD) - np.floor((A-1)/CD))

Cdiv = B // C - (A-1) // C
Ddiv = B // D - (A-1) // D
import fractions
cddiv = (C*D)//fractions.gcd(C,D)
CDdiv = B // (cddiv) - (A-1) // (cddiv)
    
ans = B - A + 1 -Cdiv - Ddiv + CDdiv#- n_C - n_D + CDdiv#n_CD
print('{}'.format(ans))

Buggy submission (verdict: Runtime Error):

import math
import numpy as np

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

# %%
A, B, C, D = list(map(int, input().split()))
    
CD = lcm(C, D) 

n_C = int(np.floor(B/C) - np.floor((A-1)/C))
n_D = int(np.floor(B/D) - np.floor((A-1)/D))

n_CD = int(np.floor(B/CD) - np.floor((A-1)/CD))

print('{}'.format(B-A+1-(n_C+n_D-n_CD)))
Problem p03006 (python)

Fixed submission:
N = int(input())
if N <= 2:
    print(1)
else:
    xy = []
    for _ in range(N):
        xy.append(list(map(int, input().split())))
    
    xy.sort()

    max_dup = 0
    for i in range(N-1):
        curr_i = xy[i]
        for j in range(i+1, N):
            curr_j =xy[j]
            p, q = curr_j[0] - curr_i[0], curr_j[1] - curr_i[1]
            
            cnt = 0
            for n in range(N):
                if n == 0:
                    continue
                if [xy[n][0]-p, xy[n][1]-q] in xy:
                # (xy[n][0]-xy[n-1][0] == p) and (xy[n][1]-xy[n-1][1] == q):
                
                    cnt += 1
            max_dup = max(max_dup, cnt)
    print('{}'.format(N-max_dup))

Buggy submission (verdict: Runtime Error):

N = int(input())
if N == 2:
    print(1)
else:
    xy = []
    for _ in range(N):
        xy.append(list(map(int, input().split())))

    diff = []
    for i in range(N):
        if i == 0:
            continue
        curr = [xy[i][0]-xy[i-1][0],
                xy[i][1]-xy[i-1][1]]
        diff.append(str(curr[0])+','+str(curr[1]))

    diff_uniq = list(set(diff))
    num = {}
    for curr_target_xy in diff_uniq:
        cnt = 0
        for curr_xy_in_raw_xy in diff:
            if curr_xy_in_raw_xy == curr_target_xy:
                cnt += 1
        num[curr_target_xy] = cnt
    print('{}'.format(N-max(list(num.values()))))
Problem p02913 (python)

Fixed submission:
def Z_algo(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = 0
    c = 0#最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        #i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP
  
ans = 0
N = int(input())
S = input()
for i in range(N):
    LCP = Z_algo(S[i:])
    for j, l in enumerate(LCP):
        tmp = min(l, j)
        ans = max(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
def z_algo(s):
    z = [0]*len(s)
    n = len(s)
    L = 0
    R = 0
    for i in range(1, n):
        if i > R:
            L = i
            R = i
            l = 0
            while l + L < n and s[l] == s[l + i]:
                l += 1
            z[i] = l
            if l > 0:
                R = L + l - 1
        else:
            k = i - L
            right_len = R - i + 1
            if z[k] < right_len:
                z[i] = z[k]
            else:
                L = i
                l = R + 1
                while l < n and s[l - L] == s[l]:
                        l += 1
                z[i] = l - L
                R = l - 1
    return z

ans = 0
N = int(input())
S = input()

for i in range(N):
    LCP = Z_algo(S[i:])
    for j, l in enumerate(LCP):
        tmp = min(l, j)
        ans = max(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
def Z_algo(S):
    n = len(S)
    z = [0]*n
    L = 0
    R = 0
    for i in range(1, n):
        if i > R:
            L = i
            R = i
            while (R < n):
                if s[R - L] == s[R]:
                    z[i] = R - L + 1
                else:
                    break
                R += 1
        else:
            k = i - L
            # print(k)
            if z[k] < R - i + 1:
                z[i] = z[k]
            else:
                L = i
                while (R < n):
                    if s[R - L] == s[R]:
                        z[i] = R - L + 1
                    else:
                        break
                    R += 1
    return z
  
ans = 0
N = int(input())
S = input()
for i in range(N):
    LCP = Z_algo(S[i:])
    for j, l in enumerate(LCP):
        tmp = min(l, j)
        ans = max(ans, tmp)
print(ans)
Problem p03284 (python)

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

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

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

if (N % K == 0):
	print(0)
else:
	print(1)
hibiki@hibiki-MB-E41
Problem p03455 (python)

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

if (a * b % 2 == 0):
	print("Even")
	print()
else:
	print("Odd")
	print()

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

if (a * b % 2 == 0):
	print("Even")
else:
	print("Odd")
hibiki@hibiki-MB-E410:~/
Problem p03473 (python)

Fixed submission:
M = input()
M = int(M)
print(48 - M)
print()

Buggy submission (verdict: Runtime Error):
M = input()
M = int(M)
print(48 - M)
hibiki@hibiki-M
Problem p03477 (python)

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

if (A+B < C+D):
	print("Right ")
elif (A+B > C+D):
	print("Left ")
else:
	print("Balanced ")

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

if (A+B < C+D):
	print("Right")
elif (A+B > C+D):
	print("Left")
else:
	print("Balanced")

hibiki@
Problem p02885 (python)

Fixed submission:
a,b=map(int,input().split())
c=a-2*b
if c<=0:
    print(0)
else:
    print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1,N):
    c=c+(List[i]*List[j])
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1:N):
    c=c+(List[i]*List[j])
print(c)
Problem p02886 (python)

Fixed submission:
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1,N):
    c=c+(List[i]*List[j])
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1:N):
    c=c+(List[i]*List[j])
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
c=0
for i in range(N-1):
  for j in range(i+1:N):
    c==c+(List[i]*List[j])
print(c)
Problem p02910 (python)

Fixed submission:
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[j]=="R" or S[j]=="U" or S[j]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[i]=="R" or S[i]=="U" or S[i]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S=list(input())
a=0
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
for j in range(0,len(S),2):
    if S[i]=="R" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S=list(input())
a=0
for i in range(1,len(S),2):
    if S[i]=="R" or S[i]=="U" or S[i]=="D":
        a+=1
for j in range(0,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S=list(input())
a=0
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
for j in range(0,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")
Problem p03433 (python)

Fixed submission:
N=int(input())
a=int(input())
if N%500<=a:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
a=int(input())
if N%500=<a:
    print("Yes")
else:
    print("No")
Problem p03455 (python)

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

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

Fixed submission:
a=input()
print(a.count("1"))

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
shingi=True
total=0
while shingi==True:
    count=0
    for i in S:
        if i%2==0:
            count+=1
        else:
            shingi=False
    if count==len(S):
        total+=1
    S=list(map(lambda x:x/2,S))
print(total)
Problem p04043 (python)

Fixed submission:
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five==2 and seven==1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
five=int(input_line.count("5"))
seven=int(input_line.count("7"))
if five=2 and seven=1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a+b+c!=17:
    print("NO")
elif (a==b==5 or a==c==5 or b==C==5) and a+b+c==17:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a==b==5 or a==c==5 or b==C==5:
    if a+b+c==17:
        print("YES")
elif a+b+c!=17:
    print("NO")

Buggy submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a==b==5 or a==c==5 or b==C==5:
    if a+b+c==17:
        print("YES")
elif a+b+c!=17
    print("NO")

Buggy submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a==b==5 or a==c==5 or b==C==5:
    if a+b+c==17:
        print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a==b==5 or a==c==5 or b==C==5:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
input_line=input().rstrip().split(" ")
a=int(input_line[0])
b=int(input_line[1])
c=int(input_line[2])
if a+b+c!=17:
    print("NO")
elif a==b==5 or a==c==5 or b==C==5:
    print("YES")
else:
    print("NO")
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split(" "))
words=[input() for i in range(0,n)]
words.sort()
words="".join(words)
print(words)

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split(" "))
words=[input() for i in range(0,l)]
words.sort()
words="".join(words)
print(words)
Problem p02885 (python)

Fixed submission:
i = input()
ar = i.split()
print(max(int(ar[0])-2*int(ar[1]), 0))

Buggy submission (verdict: Runtime Error):
i = input()
ar = i.split()
print(max(ar[0]-2*ar[1], 0))
Problem p02900 (python)

Fixed submission:
import fractions
a,b = map(int,input().split())
g = fractions.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
fac = factorization(g)
ans = len(fac)
if fac[0][0] != 1: ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
g = math.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
fac = factorization(g)
ans = len(fac)
if fac[0][0] != 1: ans += 1
print(ans)
Problem p02937 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import defaultdict
import bisect

s = input().rstrip()
t = input().rstrip()
d = defaultdict(list)

for i,c in enumerate(s):
    d[c].append(i)
ans = 0
ind = -1
for c in t:
    #print("c=",c,"d[c]=",d[c])
    if not d[c]:
        ans = -1
        break
    ins = bisect.bisect_left(d[c],ind+1)
    if ins < len(d[c]):
        ind =d[c][ins]
     #   print("ins=",ins,end = "")
    else:
      #  print("追加",end = "")
        ans += len(s)
        ind = d[c][0]
    #print("ind=", ind)
    #print()
else:
    ans += ind+1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
s = input().rstrip("\n")
t = input().rstrip("\n")
dic = {"a":[],"b":[],"c":[],"d":[],"e":[],"f":[],"g":[],"h":[],"i":[],"j":[],"k":[],"l":[],"m":[],"n":[],"o":[],"p":[],"q":[],"r":[],"s":[],"t":[],"u":[],"v":[],"w":[],"x":[],"y":[],"z":[]}
for i,c in enumerate(s):
    dic[c] += [i]
else:
    l = i+1
#print(dic)
cnt = 0
ind = -1
ans = 0
for c in t:
    d = dic[c]
    if d:
        if d[-1] > i:
    #    print("c=",c,"d=",d)
        for i in d: #iは各文字のindex 昇順
    #        print("i=",i)
            if ind < i: #もし現在位置<iなら
                ind = i
    #            print("found, ind=",i)
                break
        else:
    #        print("not found")
            cnt += 1
            ind = d[0]
    else:
        ans = -1
        break
        
print(cnt*l+ind+1 if ans > -1 else -1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
s = input()[:-1]
t = input()
dic = {"a":[],"b":[],"c":[],"d":[],"e":[],"f":[],"g":[],"h":[],"i":[],"j":[],"k":[],"l":[],"m":[],"n":[],"o":[],"p":[],"q":[],"r":[],"s":[],"t":[],"u":[],"v":[],"w":[],"x":[],"y":[],"z":[]}
for i,c in enumerate(s):
    dic[c] += [i]
#print(dic)
cnt = 0
ind = -1
ans = 0
for c in t:
    d = dic[c]
#    print("c=",c,"d=",d)
    for i in d: #iは各文字のindex 昇順
#        print("i=",i)
        if ind < i: #もし現在位置<iなら
            ind = i
#            print("found, ind=",i)
            break
    else:
#        print("not found")
        cnt += 1
        ind = -1
        # もう一度
        for j in d :  # jは各文字のindex 昇順
#            print("2周目i=", i)
            if ind < j :  # もし現在位置<iなら
                ind = j
#                print("2周目found, ind=", j)
                break
        else:
#            print("!!!!!!!!!!!!!")
            ans = -1
            break
print(cnt*len(s)+ind+1 if ans > -1 else -1)
Problem p02945 (python)

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(max(a+b.a-b,a*b))
Problem p02985 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100005)
n,k = map(int, input().split())
Tree = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    Tree[a-1].append(b-1)
    Tree[b-1].append(a-1)
#print(Tree)

mod = 10**9+7
def dfs(cur, pre):
    ret = 1
    nodecnt = 0 if pre == -1 else 1
    if cur > n-1 or cur < 0: return 0
    for nd in Tree[cur]:
        #print("現在のnode:",nd)
        if nd == pre: continue
        nodecnt += 1
        ret = ret*(k-nodecnt)%mod
        ret = ret*dfs(nd, cur)%mod
    return ret%mod

print(k*dfs(0,-1)%mod)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
Tree = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    Tree[a-1].append(b-1)
    Tree[b-1].append(a-1)
#print(Tree)

mod = 10**9+7
def dfs(cur, pre):
    ret = 1
    nodecnt = 0 if pre == -1 else 1
    if cur > n-1 or cur < 0: return 0
    for nd in Tree[cur]:
        #print("現在のnode:",nd)
        if nd == pre: continue
        nodecnt += 1
        ret = ret*(k-nodecnt)%mod
        ret = ret*dfs(nd, cur)%mod
    return ret%mod

print(k*dfs(0,-1)%mod)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
Tree = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    Tree[a-1].append(b-1)
    Tree[b-1].append(a-1)
#print(Tree)

mod = 10**9+7
def dfs(cur, pre):
    ret = 1
    nodecnt = 0 if pre == -1 else 1

    for nd in Tree[cur]:
        #print("現在のnode:",nd)
        if nd == pre: continue
        nodecnt += 1
        ret = ret*(k-nodecnt)%mod
        ret = ret*dfs(nd, cur)%mod
    return ret%mod

print(k*dfs(0,-1)%mod)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
Tree = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    Tree[a-1].append(b-1)
    Tree[b-1].append(a-1)
#print(Tree)

mod = 10**9+7
def dfs(cur, pre):
    ret = 1
    nodecnt = 0 if pre == -1 else 1

    for nd in Tree[cur]:
        #print("現在のnode:",nd)
        if nd == pre: continue
        nodecnt += 1
        ret = ret*(k-nodecnt)
        ret %= mod
        ret = ret*dfs(nd, cur)
    return ret%mod

print(k*dfs(0,-1)%mod)
Problem p03000 (python)

Fixed submission:
n,x = map(int, input().split())
L = list(map(int, input().split()))
loc = 0
i = 1
while loc <= x:
    if i < n+1:
        loc += L[i-1]
    else:
        i += 1
        break
    i += 1
print(i-1)

Buggy submission (verdict: Runtime Error):
n,x = map(int, input().split())
L = list(map(int, input().split()))
ans = 0
loc = 0
i = 0
while loc <= x:
    loc += L[i]
    i += 1
print(i)
Problem p03032 (python)

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

maxsum = -10**13
for i in range(min(n+1,k+1)):
    for j in range(min(n+1-i,k+1-i)):
        su = (V[:i] + V[:n-j-1:-1])
        su.sort()
        sumsu = sum(su)
        #print("i,j:",i,j,su)
        if k-i-j > 0:
            for l in range(k-i-j):
                if len(su) > l and su[l] < 0: sumsu -= su[l]
        maxsum = sumsu if maxsum < sumsu else maxsum
print(maxsum)

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

maxsum = -10**13
for i in range(min(n+1,k+1)):
    for j in range(min(n+1-i,k+1-i)):
        su = (V[:i] + V[:n-j-1:-1])
        su.sort()
        sumsu = sum(su)
        #print("i,j:",i,j,su)
        if k-i-j > 0:
            for l in range(k-i-j):
                if len(su) > l and su[l] < 0: sumsu -= su[l]
        maxsum = sumsu if maxsum < sumsu else maxsum
print(maxsum)
Problem p03060 (python)

Fixed submission:
n = int(input())
va = input().split()
co = input().split()

val = [int(v) for v in va]
cos = [int(c) for c in co]

dif = [val[i]-cos[i] for i in range(n)]
ma = 0
for d in dif:
    ma += d if d >= 0 else 0
print(ma)

Buggy submission (verdict: Runtime Error):
N = int(input())
val = []
cos = []
for i in range(N):
    val.append(int(input())
for i in range(N):
    cos.append(int(input())
dif = [val[i]-cos[i] for i in range(N)]
ma = 0
for d in dif:
    ma += d if d >= 0 else 0
return ma
Problem p03061 (python)

Fixed submission:
from fractions import gcd

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

lgcd, rgcd = [], []
for i in range(n):
    if i == 0:
        lgcd.append(a[0])
        rgcd.append(a[n-1])
        continue

    lgcd.append(gcd(lgcd[i-1], a[i]))
    rgcd.append(gcd(rgcd[i-1], a[-1-i]))

maxgcd = 1
for i in range(n):
    if i == 0:
        tempgcd = rgcd[n-2]
    elif i == n-1:
        tempgcd = lgcd[n-2]
    else:
        tempgcd = gcd(lgcd[i-1], rgcd[n-2-i])
    maxgcd = max(maxgcd, tempgcd)
print(maxgcd)

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

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

lgcd, rgcd = [], []
for i in range(n):
    if i == 0:
        lgcd.append(a[0])
        rgcd.append(a[n-1])
        continue

    lgcd.append(gcd(lgcd[i-1], a[i]))
    rgcd.append(gcd(rgcd[i-1], a[-1-i]))

maxgcd = 1
for i in range(n):
    if i == 0:
        tempgcd = rgcd[n-1]
    elif i == n-1:
        tempgcd = lgcd[n-1]
    else:
        tempgcd = gcd(lgcd[i-1], rgcd[n-2-i])
    maxgcd = max(maxgcd, tempgcd)
print(maxgcd)

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

def gcd(nums):
    return reduce(math.gcd, nums)

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

maxgcd = 0
for i in range(len(a)):
    temp = gcd(a[:i] + a[i + 1:])
    if temp > maxgcd:
        maxgcd = temp

print(maxgcd)
Problem p03244 (python)

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

Dic = [[i,0] for i in range(1,(10**5)+1)]
Dic2 = [[i,0] for i in range(1,(10**5)+1)]
for i in range(n):
    if i%2 == 0:
        Dic[V[i]-1][1] += 1
    else:
        Dic2[V[i]-1][1] += 1
Dic.sort(key = lambda x:x[1],reverse = True)
Dic2.sort(key = lambda x:x[1], reverse = True)
#print(Dic,Dic2)
cn = 0
if Dic[0][0] != Dic2[0][0]:
    cn += n - Dic[0][1] - Dic2[0][1]
else:
    cn += n - max((Dic[0][1]+Dic2[1][1]), (Dic[1][1]+Dic2[0][1]))
print(cn)

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

E = V[::2]
O = V[1::2]

from collections import Counter
Ed = Counter(E)
Od = Counter(O)
Edn = Ed.most_common(2)
Odn = Od.most_common(2)
#print(Edn,Odn)
if Edn[0][0] != Odn[0][0]:
    print(n- Edn[0][1] - Odn[0][1])
else:
    if len(Edn) == 1:
        if len(Odn) == 1:
            print(n//2)
        else:
            print(n//2-Odn[1][1])
    elif len(Odn) == 1:
        print(n//2-Edn[1][1])
    else:
        print(min(n-Edn[0][1]-Odn[1][1],m-Edn[1][1]-Odn[0][1]))

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

E = V[::2]
O = V[1::2]

from collections import Counter
Ed = Counter(E)
Od = Counter(O)
Edn = Ed.most_common(2)
Odn = Od.most_common(2)
print(Edn,Odn)
if Edn[0][0] != Odn[0][0]:
    print(n- Edn[0][1] - Odn[0][1])
else:
    if len(Edn) == 1:
        if len(Odn) == 1:
            print(n//2)
        else:
            print(n//2-Odn[1][1])
    if len(Odn) == 1:
        print(n//2-Edn[1][1])
    else:
        print(min(n-Edn[0][1]-Odn[1][1],m-Edn[1][1]-Odn[0][1]))

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

Dic = [[i,0] for i in range(1,(10**1)+1)]
Dic2 = [[i,0] for i in range(1,(10**1)+1)]
for i in range(n):
    if i%2 == 0:
        Dic[V[i]-1][1] += 1
    else:
        Dic2[V[i]-1][1] += 1
Dic.sort(key = lambda x:x[1],reverse = True)
Dic2.sort(key = lambda x:x[1], reverse = True)
#print(Dic,Dic2)
cn = 0
if Dic[0][0] != Dic2[0][0]:
    cn += n - Dic[0][1] - Dic2[0][1]
else:
    cn += n - max((Dic[0][1]+Dic2[1][1]), (Dic[1][1]+Dic2[0][1]))
print(cn)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
for i in range(len(s)):
    if s[i] != "1":
        if k < i+1:
            print(1)
        else:
            print(s[i])
        break
else:
    print(1)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
for i in range(len(s)):
  if s[i] != 1:
    if k < i:
      print(1)
     else:
      print(s[i])
	break
else:
  print(1)