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

Fixed submission:
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP):
    for i in range(2,lim+1):
        while newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP = newP // i
        if newP < i or i == lim:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
my(N,P)

Buggy submission (verdict: Runtime Error):
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP=P,s=2):
    for i in range(s,lim+1):
        if newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP //= i
            s = i
            break
    
        if newP < i or i == lim+1:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
    my(N,newP,s)

my(N)

Buggy submission (verdict: Runtime Error):
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP=P,s=2):
    for i in range(s,lim+1):
        if newP % i == 0:
            # print('ok')
            dic[i] = dic.get(i,0) + 1
            # print(dic)
            newP //= i
            s = i
            break
    
        if newP == 1 or i == lim+1:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
    my(N,newP,s)

my(N)
Problem p03213 (python)

Fixed submission:
#組み合わせ、コンビネーション
def cmb(n,r):
    if n==0:return 0
    else:
        r=min(r,n-r)
        result=1
        for i in range(n-r+1,n+1):
            result*=i
        for i in range(1,r+1):
            result//=i
        return result

#素因数分解、辞書を返す
def factorize(n):
    i=2
    result={}
    while True:
        if i**2>n:
            break
        count=0
        while n%i==0:
            n//=i
            count+= 1
        if count!=0:
            result[i]=count
        i+=1
    if n>1:
        result[n]=1
    return result

N = int(input())
l={}
for i in range(1,N+1):
    for i,j in factorize(i).items():
        l[i] = l.get(i,0)+j


l2 = [0]*5

r = 0
for j,i in l.items():
    if i>=74:
        l2[4]+=1
    elif i>=24:
        l2[3]+=1
    elif i>=14:
        l2[2]+=1
    elif i>=4:
        l2[1]+=1
    elif i>=2:
        l2[0]+=1

r += l2[4]
r += sum(l2[3:])*(sum(l2)-1)
r += sum(l2[2:])*(sum(l2[1:])-1)
r += cmb(sum(l2[1:]),2)*(sum(l2)-2)
print(r)

Buggy submission (verdict: Runtime Error):

#組み合わせ、コンビネーション
def cmb(n,r):
  	if n ==1:
      return 0
    else:
      r=min(r,n-r)
      result=1
      for i in range(n-r+1,n+1):
          result*=i
      for i in range(1,r+1):
          result//=i
      return result

#素因数分解、辞書を返す
def factorize(n):
    i=2
    result={}
    while True:
        if i**2>n:
            break
        count=0
        while n%i==0:
            n//=i
            count+= 1
        if count!=0:
            result[i]=count
        i+=1
    if n>1:
        result[n]=1
    return result

N = int(input())
l={}
for i in range(1,N+1):
    for i,j in factorize(i).items():
        l[i] = l.get(i,0)+j


l2 = [0]*5

r = 0
for j,i in l.items():
    if i>=74:
        l2[4]+=1
    elif i>=24:
        l2[3]+=1
    elif i>=14:
        l2[2]+=1
    elif i>=4:
        l2[1]+=1
    elif i>=2:
        l2[0]+=1
# print(l)
# print(l2)

r += l2[4]
r += sum(l2[3:])*(sum(l2)-1)
r += sum(l2[2:])*(sum(l2[1:])-1)
r += cmb(sum(l2[1:]),2)*(sum(l2)-2)
print(r)
Problem p03231 (python)

Fixed submission:
N,M=map(int,input().split())
S=input()
T=input()
import fractions
gcd=int(N*M/fractions.gcd(N,M))
lis=[int(gcd/N),int(gcd/M)]
for i in range(int(N*M/gcd)):
    if S[int(i*lis[1])]!=T[int(i*lis[0])]:
        print(-1)
        exit()
print(gcd)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
S=input()
T=input()
import math
gcd=int(N*M/math.gcd(N,M))
lis=[int(gcd/N),int(gcd/M)]
for i in range(int(N*M/gcd)):
    if S[int(i*lis[1])]!=T[int(i*lis[0])]:
        print(-1)
        exit()
print(gcd)
Problem p03238 (python)

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

Buggy submission (verdict: Runtime Error):
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if l==k or l==0:
            l=k
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else: break
    try:
        print('{} {} {}'.format(m[0],m[1],m[2]))
        break
    except NameError:
        continue
Problem p03260 (python)

Fixed submission:
A,B = map(int,input().split())
if A%2==1 and B%2==1:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N,X = map(int, input().split())
def myabs(i):
    return abs(i-X)
xlis = list(map(myabs, map(int, input().split())))

from fractions import gcd

res = xlis[0]
for i in xlis:
    if i%res == 0:
        continue
    res = gcd(i,res)

print(res)
Problem p03361 (python)

Fixed submission:
H,W = map(int,input().split())
lis = ['.' +input()+'.' for _ in range(H)]
lis.insert(0,'.'*(W+2))
lis.append('.'*(W+2))
for i in range(1,H+1):
    for j in range(1,W+1):
        if lis[i][j] == '#':
            if lis[i+1][j]=='#' or lis[i-1][j]=='#' or lis[i][j+1]=='#' or lis[i][j-1] == '#':
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
lis = ['.' +input()+'.' for _ in range(H)]
lis.insert(0,'.'*W)
lis.append('.'*W)
for i in range(1,H+1):
    for j in range(1,W+1):
        if lis[i][j] == '#':
            if lis[i+1][j]=='#' or lis[i-1][j]=='#' or lis[i][j+1]=='#' or lis[i][j-1] == '#':
                continue
            else:
                print('No')
                exit()
print('Yes')
Problem p03138 (python)

Fixed submission:
n, k = [int(i) for i in input().split()]
As = [int(i) for i in input().split()]
def func(x):
    return sum(a^x for a in As)

bs = ['{:050b}'.format(a)[::-1] for a in As]
# print(bs)
strk = '{:b}'.format(k)

ans = ['0'] * len(strk)
# print(strk, ans)
for i in range(len(strk)):
    one = len([True for b in bs if b[len(strk) - 1 - i] == '1'])
    zero = len([True for b in bs if b[len(strk) - 1 - i] == '0'])
    # print(zero, one)

    tmp = ans[:]
    # if k < int('1' + ans, 2):

    # if one == zero:
    #     tmp[i] = '1'
    if zero >= one:
        tmp[i] = '1'
    # else:
    #     ans = ['0' + a for a in ans]
    # print(tmp, int(''.join(tmp), 2))
    if k >= int(''.join(tmp), 2):
        ans = tmp
    # print('ans', ans)

print(func(int(''.join(ans), 2)))

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
As = [int(i) for i in input().split()]
def f(x):
    return sum(a^x for a in As)

bs = [f'{a:050b}'[::-1] for a in As]
# print(bs)
ans = ''
strk = f'{k:b}'
# print('strk', strk)
for i in range(len(strk)):
    one = len([True for b in bs if b[i] == '1'])
    zero = len([True for b in bs if b[i] == '0'])
    # print(one, zero)

    if k <= int('1' + ans, 2):
        ans = '0' + ans
        # print('y')
    elif one < zero:
        ans = '1' + ans
    else:
        ans = '0' + ans
    # print('ans', ans)

    # ans = '0' if one > zero else '1'
# ans = ans[::-1]
# print(ans)
# ans = int(ans, 2)
print(f(int(ans, 2)))
Problem p03155 (python)

Fixed submission:
n, h, w = int(input()), int(input()), int(input())
print((n-h+1)*(n-w+1))

Buggy submission (verdict: Runtime Error):
import copy
n, q = [int(i) for i in input().split()]
As = sorted([int(i) for i in input().split()])
for i in range(q):
    x = int(input())
    As_tmp = copy.copy(As)
    As_abs = [abs(a - x) for a in As]
    ans = 0
    # print(As_abs)
    while As_abs:
        ans += As_tmp[-1]
        # print(ans)
        As_tmp.pop(-1)
        As_abs.pop(-1)
        if not As_abs:
            break
        # ans += As[As_abs.index(min(As_abs))]
        idx = As_abs.index(min(As_abs))
        As_tmp.pop(idx)
        As_abs.pop(idx)
        # print(As_abs)
 
    print(ans)
Problem p03200 (python)

Fixed submission:
ans, w_idx = 0, 0
for i, s in enumerate(input()):
    if s != 'W':
        continue
    ans += i - w_idx
    w_idx += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, As = int(input()), list(map(int, input().split()))
maxA, ans = max(As), 1
while True:
    if pow(ans, maxA) - 1 > N:
        break
    ans += 1
print(ans)
Problem p03311 (python)

Fixed submission:
N, As = int(input()), map(int, input().split())
As = sorted([A - i - 1 for i, A in enumerate(As)])
b = As[N // 2]
print(sum(map(lambda A: abs(A - b), As)))

Buggy submission (verdict: Runtime Error):
N, As = int(input()), list(map(int, input().split()))
As = [As[i] - i - 1 for i in range(N)]
ans = sys.maxsize
for b in range(min(As), max(As) + 1):
    ans = min(ans, sum(map(lambda A: abs(A - b), As)))
print(ans)
Problem p03624 (python)

Fixed submission:
s = input()
ch = {chr(i) for i in range(ord('a'), ord('z')+1)}
ss = set()
for i in range(len(s)): ss.add(s[i])
tmp = sorted(list(ch ^ ss))
print(tmp[0] if len(tmp) else "None")

Buggy submission (verdict: Runtime Error):
s = input()
ch = [chr(i) for i in range(97, 97+26)]
for i in range(len(ch)):
    if not ch[i] in s :
        print(ch[i])
        sys.exit()
print("None")

Buggy submission (verdict: Runtime Error):
s = input()
ch = [chr(i) for i in range(ord('a'), ord('z')+1)]
for i in range(len(ch)):
    if not ch[i] in s :
        print(ch[i])
        sys.exit()
print("None")

Buggy submission (verdict: Runtime Error):
ch = [chr(i) for i in range(ord('a'), ord('z')+1)]
s = input()
for ss in ch:
    if not ss in s:
        print(ss)
        sys.exit()
print("None")

Buggy submission (verdict: Runtime Error):
s = input()
ch = {chr(i) for i in range(ord('a'), ord('z')+1)}
for i in range(len(s)): ch.remove(s[i])
tmp = sorted(list(ch))
print(tmp[0] if len(tmp) else "None")
Problem p02642 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
prime = [True] * (10 ** 6 + 10)

b = sorted(set(a))

for i in b:
    num = i * 2
    while True:
        if num >= 10 ** 6 + 1:
            break
        prime[num] = False
        num += i

ans = 0
for s in a:
    if prime[s] == True and c[s] == 1:
        ans += 1

print(ans)

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

a = sorted(set(a))
w = 0
h = 0
while True:
    h = 1
    while True:
        if w + h == len(a):
            print(a)
            break
        if a[w+h] % a[w] == 0:
            print(h)
            del a[w+h]
        else:
            print(a[w+h], h, w, a)
            h += 1
    w += 1
    if w == len(a):
        print(len(a))
        exit()
Problem p02922 (python)

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

t = 1
cnt = 0

while  t<b:
    t += (a-1)
    cnt += 1
print(cnt)

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

while tp < b:
    tp += (a-1)
    cnt += 1

print(cnt)
Problem p02924 (python)

Fixed submission:
n = int(input())
print((n-1)*n//2)

Buggy submission (verdict: Runtime Error):
n = list(range(1, int(input())))

print(sum(n))
Problem p03455 (python)

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

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

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

c = a + b

if c%2 == 1	:
  priint('Odd')
else :
  print('Even')

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

c = a * b 

if c % 2 == 1 :
  print('Odd')
 
else :
  print('Even')
Problem p02614 (python)

Fixed submission:
h,w,k=map(int,input().split())
c=''
for i in range(h):
    c+=input()
# print(c)
# row_dot_cnt=[c.count() for _ in range(h)]
# col_dot_cnt=[0]*w
ans=0
for i in range(2**h): # 行
    i_bin=format(i,'06b')
    for j in range(2**w): # 列
        j_bin=format(j,'06b')
        cnt=0
        # print(i_bin,j_bin)
        for s in range(h):
            if i_bin[5-s]=='0':
                for t in range(w):
                    if j_bin[5-t]=='0' and c[s*w+t]=='#':
                        # print(s,t)
                        cnt+=1
        if cnt==k:
            ans+=1
            # print(f'        {cnt}   {ans}')
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
c=''
for i in range(h):
    c+=input()
# print(c)
# row_dot_cnt=[c.count() for _ in range(h)]
# col_dot_cnt=[0]*w
ans=0
for i in range(2**h): # 行
    i_bin=format(i,'06b')
    for j in range(2**w): # 列
        j_bin=format(j,'06b')
        cnt=0
        # print(i_bin,j_bin)
        for s in range(h):
            if i_bin[5-s]=='0':
                for t in range(w):
                    if j_bin[5-t]=='0' and c[s*h+t]=='#':
                        # print(s,t)
                        cnt+=1
        if cnt==k:
            ans+=1
            # print(f'        {cnt}   {ans}')
print(ans)
Problem p02814 (python)

Fixed submission:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=[ai//2 for ai in a]
# print(half_a)
lcm=half_a[0]
for i in range(n-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow_cnt=0
tmp=half_a[0]
while tmp%2==0:
    pow_cnt+=1
    tmp=tmp//2
flag=True
for ai in half_a[1:]:
    if ai%(2**pow_cnt)!=0:
        flag=False
        break
    elif  ai%(2**(pow_cnt+1))==0:
        flag=False
        break
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=[ai//2 for ai in a]
# print(half_a)
lcm=half_a[0]
for i in range(n-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow_cnt=0
tmp=half_a[0]
while tmp%2==0:
    pow_cnt+=1
    tmp=tmp//2
flag=True
for ai in half_a[1:]:
    if ai%pow2[pow_cnt]==0:
        flag=False
        break
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=list(set([ai//2 for ai in a]))
# print(half_a)
lcm=half_a[0]
for i in range(len(half_a)-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow2=[2**i for i in range(32)]
tmp=half_a[0]
while tmp%pow2[i]==0:
    i+=1
flag=True
for j in range(1,len(half_a)):
    if half_a[j]%pow2[i]==0:
        flag=False

if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=list(set([ai//2 for ai in a]))
# print(half_a)
lcm=half_a[0]
for i in range(len(half_a)-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow=[2**i for i in range(30)]
tmp=half_a[0]
while tmp%pow[i]==0:
    i+=1
flag=True
for j in range(1,len(half_a)):
    if half_a[j]%pow[i]==0:
        flag=False

if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=list(set([ai//2 for ai in a]))
# print(half_a)
lcm=half_a[0]
for i in range(len(half_a)-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow=[2**i for i in range(10)]
tmp=half_a[0]
while tmp%pow[i]==0:
    i+=1
flag=True
for j in range(1,len(half_a)):
    if half_a[j]%pow[i]==0:
        flag=False

if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)
Problem p02975 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
aDict={}
for key in set(a):
    aDict[key]=0
for ai in a:
    aDict[ai]+=1

canPuton=False
if len(aDict)==1:
    if 0 in aDict.keys():
        canPuton=True

elif len(aDict)==2:
    if 0 in aDict.keys():
        if n%3==0:
            canPuton=True
            for key in aDict:
                if key==0:
                    if aDict[key]!=n//3:
                        canPuton=False
                else:
                    if aDict[key]!=2*n//3:
                        canPuton=False

elif len(aDict)==3:
    a,b,c=aDict.keys()
    if n%3==0:
        if (a^b)==c:
            canPuton=True
            for key in aDict.keys():
                if aDict[key]!=n//3:
                    canPuton=False
if canPuton:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
aSet=list(set(a))
if n%3!=0:
    if len(aSet)==1 and aSet[0]=0:
        print('Yes')
    else:
        print('No')
else:
    if len(aSet)==3:
        if (aSet[0]^aSet[1])==aSet[2]:
            print('Yes')
    elif len(aSet)<3:
        if 0 in aSet:
            print('Yes')
    else:
        print('No')
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//gcd(c,d))
print(bIka-aMiman)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//math.gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//math.gcd(c,d))
print(bIka-aMiman)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
a-=1
bIka=b-b//c-b//d+b//(c*d//math.gcd(c,d))
aMiman=a-a//c-a//d+a//(c*d//math.gcd(c,d))
print(bIka-aMiman)
Problem p03006 (python)

Fixed submission:
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
xy.sort(key=lambda x:(x[0],x[1]))
# print(xy)
if n<=2:
    print(1)
else:
    diff=[]
    for i in range(n):
        for j in range(i):
            diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

    ans=[]
    # print(set(diff))
    for p,q in set(diff):
        cnt=n
        for i in range(n):
            for j in range(i):
                if xy[i][0]-xy[j][0]==p and xy[i][1]-xy[j][1]==q:
                    cnt-=1
        ans.append(cnt)
    print(min(ans))

Buggy submission (verdict: Runtime Error):
# 何本の数直線上にあるかを求める　1<=ans<=n-1
# 少なくとも2点を通る直線のみ調べれば良い
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
xy.sort(key=lambda x:(x[0],x[1]))
# print(xy)
if n<=2:
    print(1)
else:
    diff=[]
    for i in range(n):
        for j in range(i):
            diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

    ans=[]
    # print(set(diff))
    for p,q in set(diff):
        intercept=[]
        for i in range(n):
            qxHIKUpy=q*xy[i][0]-p*xy[i][1]
            intercept.append(qxHIKUpy)
        # print(q,'x-',p,'y=',intercept)
        intercepts=sorted(enumerate(intercept),key=lambda x:x[1])
        intercept=set(intercept)
        # print(intercepts)
        i=0
        cnt=len(intercept)
        for b in intercept:
            x=0
            if intercepts[i][1]==b:
                x=xy[intercepts[i][0]][0]
            i+=1
            while intercepts[i][1]==b:
                if x+p!=xy[intercepts[i][0]][0]:
                    cnt+=1
                x=xy[intercepts[i][0]][0]
                i+=1
                if i==n:
                    break

        ans.append(cnt)
    # print(ans)
    print(min(ans))

Buggy submission (verdict: Runtime Error):
# 何本の数直線上にあるかを求める　1<=ans<=n-1
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
# xy.sort(key=lambda x:x[0])
# print(xy)
diff=[]
for i in range(n):
    for j in range(i):
        diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

ans=[]
# print(set(diff))
for p,q in set(diff):
    qxHIKUpy=[]
    for i in range(n):
        qxHIKUpy.append(q*xy[i][0]-p*xy[i][1])
    ans.append(len(set(qxHIKUpy)))
# print(ans)
print(min(ans))
Problem p03061 (python)

Fixed submission:
def gcd(a,b):
    if a*b<0:
        return -a*b
    while b!=0:
        tmp=a%b
        a=b
        b=tmp
    return a

# def gcd_list(numbers):
#     # print(numbers)
#     g=numbers[0]
#     for i in range(n-1):
#         g=gcd(g,numbers[i])
#     return g
#
# n=int(input())
# a=list(map(int,input().split()))
# gcd_without_i=[gcd_list(a[:i]+a[i+1:]) for i in range(n)]
# # print(gcd_without_i)
# print(max(gcd_without_i))

n=int(input())
a=list(map(int,input().split()))
# gcd_lhs[i]=gcd(a[0],...,a[i-1])
gcd_lhs=[-1 for _ in range(n)]
# gcd_rhs[i]=gcd(a[i+1],...,a[n-1])
gcd_rhs=[-1 for _ in range(n)]
gcd_lhs[1]=a[0]
gcd_rhs[n-2]=a[n-1]
for i in range(1,n):
    gcd_lhs[i]=gcd(gcd_lhs[i-1],a[i-1])
    gcd_rhs[n-1-i]=gcd(gcd_rhs[n-i],a[n-i])

gcd_without_i=[gcd(gcd_lhs[i],gcd_rhs[i]) for i in range(n)]
print(max(gcd_without_i))

Buggy submission (verdict: Runtime Error):
import math
def gcd(numbers):
    # print(numbers)
    g=numbers[0]
    for i in range(n-1):
        g=math.gcd(g,numbers[i])
    return g

n=int(input())
a=list(map(int,input().split()))
gcd_without_i=[gcd(a[:i]+a[i+1:]) for i in range(n)]
# print(gcd_without_i)
print(max(gcd_without_i))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd(numbers):
    return reduce(math.gcd,numbers)

n=int(input())
a=list(map(int,input().split()))
gcd_without_i=[gcd(a[:i]+a[i+1:]) for i in range(n)]

print(max(gcd_without_i))
Problem p03076 (python)

Fixed submission:
a=[int(input()) for _ in range(5)]
ar=[[i,a[i]%10] for i in range(5)]
ar.sort(key=lambda x:x[1])
i=0
while ar[i][1]==0:
    i+=1
    if i==4:
        break
k=ar[i][0]
time=0
for i in range(5):
    if i!=k:
        time+=a[i]
        if a[i]%10!=0:
            time+=10-a[i]%10
time+=a[k]
print(time)

Buggy submission (verdict: Runtime Error):
a=[int(input()) for _ in range(5)]
ar=[[i,a[i]%10] for i in range(5)]
ar.sort(key=lambda x:x[1])
i=0
while ar[i][1]==0:
    i+=1
k=ar[i][0]
time=0
for i in range(5):
    if i!=k:
        if a[i]%10==0:
            time+=a[i]
        else:
            time+=a[i]+10-a[i]%10
time+=a[k]
print(time)
Problem p03078 (python)

Fixed submission:

x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(key=lambda x:-x)
b.sort(key=lambda x:-x)
c.sort(key=lambda x:-x)
beauty=[]
index=0
for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i+1)*(j+1)*(l+1)<=k:
                beauty.append(a[i]+b[j]+c[l])
            else:
                break
beauty.sort(key=lambda x:-x)
for i in range(k):
    print(beauty[i])

Buggy submission (verdict: Runtime Error):

x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(key=lambda x:-x)
b.sort(key=lambda x:-x)
c.sort(key=lambda x:-x)
# queue=[beauty, indexa, indexb, indexc]
queue=[(a[0]+b[0]+c[0],0,0,0)]
beauty=[0 for _ in range(k)]
index=0
indexq=0
while index<k:
    queue.sort(key=lambda x:-x[0])
    # print(queue)
    beauty[index],indexa,indexb,indexc=queue[indexq]
    index+=1
    indexq+=1
    for da,db,dc in [(1,0,0),(0,1,0),(0,0,1)]:
        # print(indexa+da,indexb+db,indexc+dc)
        if indexa+da<x and indexb+db<y and indexc+dc<z:
            queue.append((a[indexa+da]+b[indexb+db]+c[indexc+dc],indexa+da,indexb+db,indexc+dc))
    queue=list(set(queue))
for i in range(k):
    print(beauty[i])
Problem p03219 (python)

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

print(int(x+y/2))

Buggy submission (verdict: Runtime Error):
x=input().split()

print(x[0]+x[1]/2)