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

Fixed submission:
import math
n = int(input())
half = int(math.sqrt(n))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

Buggy submission (verdict: Runtime Error):
import fractions
n = int(input())
half = int(fractions.sqrt(n))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
half = min(n//10**(len(str(n))//2),n%10**(len(str(n))//2))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
half = min(n//10**(len(str(n))//2),n%10**(len(str(n))//2))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))
Problem p02598 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(float, input().split()))

low=0
high=10**9+1

while high-low!=1:
    mid=(high+low)//2
    cut_temp=0
    ans=-1
    
    for a in A:
        cut_temp+=-(-a//mid)-1
    if cut_temp>K:
        low=mid
    else:
        high=mid
    
print(high)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(float, input().split()))

low=-1
high=10**9+1

while high-low!=1:
    mid=(high+low)//2
    cut_temp=0
    ans=-1
    
    for a in A:
        cut_temp+=-(-a//mid)-1
    if cut_temp>K:
        low=mid
    else:
        high=mid
    
print(high)
Problem p02793 (python)

Fixed submission:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

import functools

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)


N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12


ans=0
for index,item in enumerate(a):
    ans+=(calc)//item

print(int((ans)%(10**9+7)))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
from math import gcd

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

temp=A[0]
for item in A:
    temp=temp*item//gcd(temp,item)

ans=0
for item in A:
    ans+=temp//item
    ans%=10**9+7
#print(temp)
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12

ans=0
for item in a:
    ans+=(calc)/item
    ans%=(10**9+7)

print(int((ans)%(10**9+7)))
Problem p02831 (python)

Fixed submission:
# coding: utf-8
# Your code here!
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    

A,B=map(int,input().split())

print(A*B//gcd(A,B))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
A,B=map(int,input().split())

print(A*B//math.gcd(A,B))
Problem p02873 (python)

Fixed submission:
# coding: utf-8
# Your code here!
S=list(input())

nums=[1 if S[0]=="<" else -1]
for i in range(len(S)-1):
    if S[i+1]==S[i]:
        if S[i+1]=="<":
            nums[-1]+=1
        else:
            nums[-1]-=1
    else:
        if S[i+1]=="<":
            nums.append(1)
        else:
            nums.append(-1)

ans=0
if nums[0]<0:
    are=-nums.pop(0)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()
if nums[-1]>0:
    are=nums.pop(-1)
    ans+=are*(are+1)//2
    if nums:
        pass
    else:
        print(ans)
        exit()

temp=list(map(lambda x:abs(x)-1,nums))
temp=list(map(lambda x:x*(x+1)//2,temp))

#print(temp)
ans+=sum(temp)
#print(ans)
for i in range(len(nums)-1):
    if nums[i]>0:
        ans+=max(nums[i],-nums[i+1])

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
S=list(input())

nums=[1 if S[0]=="<" else -1]
for i in range(len(S)-1):
    if S[i+1]==S[i]:
        if S[i+1]=="<":
            nums[-1]+=1
        else:
            nums[-1]-=1
    else:
        if S[i+1]=="<":
            nums.append(1)
        else:
            nums.append(-1)

ans=0
if nums[0]<0:
    are=nums.pop(0)
    ans+=are*(are+1)//2
if nums[-1]>0:
    are=nums.pop(-1)
    ans+=are*(are+1)//2

temp=list(map(lambda x:abs(x)-1,nums))
temp=list(map(lambda x:x*(x+1)//2,temp))

ans+=sum(temp)
#print(ans)
for i in range(len(nums)-1):
    if nums[i]>0:
        ans+=max(nums[i],-nums[i+1])
#print(nums)
print(ans)
Problem p03018 (python)

Fixed submission:
# coding: utf-8
# Your code here!
s=list(input().replace("BC","Z"))[::-1]
ans=0

def seisan(list):
    count=0
    N=len(list)-1
    for index,content in enumerate(list):
        if content=="A":
            count+=(N-index)
            N-=1
    return count

temp=[]
while s:
    this=s.pop(-1)
    if this=="B" or this=="C":
        ans+=seisan(temp)
        temp.clear()
    else:
        temp.append(this)

print(ans+seisan(temp))
#ちょくだいさん連投ゆるして

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
s=input()

temp=0
ans=0
while s:
    if len(s)>=3:
        if s[0]+s[1]+s[2]=='ABC':#ABCABCをBCBCAAに変換したい
            temp+=1
            del s[0:2]
            continue
    
    ans+=(temp*(temp+1))/2#上の清算をする
    temp=0
    
    s_chi=s.pop(0)
    if s_chi="A":#AABCをBCAAに変換したい
        if 
        temp+=1
    elif s_chi="B":
        if 
    elif s_chi="C":
Problem p03045 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**7)

def dfs(num,log):
    visited[num]=min(log,visited[num])
    for item in way[num]:
        if visited[item]==10**7:
            dfs(item,log)
    return 

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

visited=[10**7]*N
way=[[] for i in range(N)]
order=[]

for _ in range(M):
    X,Y,Z=map(int,input().split())
    X,Y=min(X,Y),max(X,Y)
    order.append([X-1,Y-1,Z])

order.sort(key=lambda x:(x[0],x[1]))

for item in order:
    way[item[0]].append(item[1])
    way[item[1]].append(item[0])
    
for i in range(N):
    dfs(i,i)

visited=list(set(visited))
print(len(visited))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**5)

def dfs(num,log):
    visited[num]=min(log,visited[num])
    for item in way[num]:
        if visited[item]==10**7:
            dfs(item,log)
    return 

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

visited=[10**7]*N
way=[[] for i in range(N)]
order=[]

for _ in range(M):
    X,Y,Z=map(int,input().split())
    X,Y=min(X,Y),max(X,Y)
    order.append([X-1,Y-1,Z])

order.sort(key=lambda x:(x[0],x[1]))

for item in order:
    way[item[0]].append(item[1])
    way[item[1]].append(item[0])
    
for i in range(N):
    dfs(i,i)

visited=list(set(visited))
print(len(visited))
Problem p03053 (python)

Fixed submission:
# coding: utf-8
# Your code here!
H,W=map(int,input().split())


def dfs(h,w):
    A[h][w]="#"
    que=[]
    if h>0:
        if A[h-1][w]!="#":
            que.append([h-1,w])
            A[h-1][w]="#"
    if w>0:
        if A[h][w-1]!="#":
            que.append([h,w-1])
            A[h][w-1]="#"
    if h<H-1:
        if A[h+1][w]!="#":
            que.append([h+1,w])
            A[h+1][w]="#"
    if w<W-1:
        if A[h][w+1]!="#":
            que.append([h,w+1])
            A[h][w+1]="#"
    
    return que


A=[]
for _ in range(H):
    A.append(list(input()))

#print(A)

ans=0
lis=[]
for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            lis.append([h,w])
while True:
    pre=[]
    if lis:
        N=len(lis)
        lis=lis[::-1]
        for i in range(N):
            item=lis.pop(-1)
            pre+=dfs(item[0],item[1])
        lis=pre
    if len(lis)==0:
        break
    ans+=1
    #print(lis)
    #print(A)
    
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
H,W=map(int,input().split())


def dfs(h,w,num):
    
    l[h][w]=min(l[h][w],num)
    
    if h>0:
        if A[h-1][w]!="#" and l[h-1][w]>num:
            dfs(h-1,w,num+1)
    if w>0:
        if A[h][w-1]!="#" and l[h][w-1]>num:
            dfs(h,w-1,num+1)
    if h<H-1:
        if A[h+1][w]!="#" and l[h+1][w]>num:
            dfs(h+1,w,num+1)
    if w<W-1:
        if A[h][w+1]!="#" and l[h][w+1]>num:
            dfs(h,w+1,num+1)
    
    return 0


A=[]
for _ in range(H):
    A.append(list(input()))

#print(A)

l=[[10**9]*W for i in range(H)]

for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            dfs(h,w,0)
ans=0
for item in l:
    ans=max(ans,max(item))

#print(l)
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
H,W=map(int,input().split())


def dfs(h,w,num):
    
    l[h][w]=min(l[h][w],num)
    
    if h>0:
        if A[h-1][w]!="#" and l[h-1][w]>num:
            dfs(h-1,w,num+1)
    if w>0:
        if A[h][w-1]!="#" and l[h][w-1]>num:
            dfs(h,w-1,num+1)
    if h<H-1:
        if A[h+1][w]!="#" and l[h+1][w]>num:
            dfs(h+1,w,num+1)
    if w<W-1:
        if A[h][w+1]!="#" and l[h][w+1]>num:
            dfs(h,w+1,num+1)
    
    return 0


A=[]
for _ in range(H):
    A.append(list(input()))

#print(A)

l=[[10**9]*W for i in range(H)]

for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            dfs(h,w,0)
ans=0
for item in l:
    ans=max(ans,max(item))

#print(l)
print(ans)
Problem p03077 (python)

Fixed submission:
N=int(input()) 
rissoku=10**18
for _ in range(5): 
    rissoku=min(rissoku,int(input())) 

if N%rissoku==0: 
    print((N//rissoku)+4) 
else: 
    print((N//rissoku)+5)

Buggy submission (verdict: Runtime Error):
N=int(input())
rissoku=10**9

for _ in range(5):
    rissoku=min(rissoku,int(input()))

if N%rissoku=0:
    print((N//rissoku)+4)
else:
    print((N//rissoku)+5)
Problem p03127 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

a=min(A)
ans=0
l=[]

def gcd(lis,num):
    temp=[]
    for item in lis:
        if num%item!=0:
            pass
        else:
            temp.append(item)
    return temp

for i in range(1,int(a**0.5)//1+1):
    if a%i==0:
        l.append(i)
        l.append(a//i)

for item in A:
    l=gcd(l,item)

print(max(l))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
from functools import reduce

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

a=min(A)
ans=0


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

print(gcd_list(A))
#きれた
Problem p03209 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N,X=map(int,input().split())

X-=1
def saiki(i,x,count):
    if i==-1:
        print(int(count)+1)
        exit()
    all=2**(i+2)-3
    paty=2**(i+1)-1
    if x==all-1:
        print(count+paty)
        exit()
    elif x==0:
        print(count)
    elif x==(all-1)//2:
        print(int(count+(paty-1)//2+1))
        exit()
    elif x>(all-1)//2:
        count+=((paty-1)//2+1)
        x-=(all//2)
        saiki(i-1,x-1,count)
    elif x<(all-1)//2:
        saiki(i-1,x-1,count)
    

ans=0
saiki(N,X,ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,X=map(int,input().split())

def dfs(count,object):
    count+=1
    object="B"+object+"P"+object+"B"
    if count<N:
        dfs(count,object)
    else:
        print(object)
        exit()

n=0
burger="P"

(dfs(n,burger))
Problem p03329 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())

def saiki(tgt,i,count,ans):
    #print(tgt,i,count,ans,temp[i])

    if i==0 or tgt==0:
        ans=min((tgt+count),ans)
        return ans
        
    num=tgt//temp[i]
    while num>=0:
        ans=saiki(tgt-num*temp[i],i-1,count+num,ans)
        if ans<(count+num):
            return ans
        num-=1
    return ans

temp=[1]
n=1
while N>=6**n:
    temp.append(6**n)
    n+=1
    
n=1
while N>=9**n:
    temp.append(9**n)
    n+=1

temp.sort()
#print(temp)

print(saiki(N,len(temp)-1,0,10**9))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N=int(input())
l=[1]
count=0

def cand(num):
    i=1
    while N>=num**i:
        l.append(num**i)
        i+=1

def sub(target,index):
    i=0
    if target==0:
        
    elif index==0:
        
    while target-l[index]>0:
        sub(target-l[index]**i,l[index-1])
        

cand(6)
cand(9)

l.sort()
print(l)

#メモ　この方針があってるのかもわからん
Problem p03426 (python)

Fixed submission:
# coding: utf-8
# Your code here!
#途中

H,W,D=map(int,input().split())

A=[]
for i in range(H):
    A.append(list(map(int,input().split())))

loc=[[0,0] for i in range(W*H)]

#print(loc)

for i in range(H):
    for j in range(W):
        loc[A[i][j]-1][0]=i
        loc[A[i][j]-1][1]=j
        #print(loc)
#print(loc)

cost=[[0]*((H*W)//D) for i in range(D)]

for i in range((H*W)%D):
    cost[i].append(0)

for i in range(D):
    pass
    count=1
    temp=i
    while temp+D<(H*W):
        temp=i+D*count
        cost[temp%D][temp//D]=abs(loc[temp][0]-loc[temp-D][0])+abs(loc[temp][1]-loc[temp-D][1])+cost[temp%D][temp//D-1]
        count+=1
        #print(cost)
cost[-1]=[0]+cost[-1]

Q=int(input())
for _ in range(Q):
    x,y=map(int,input().split())
    #print(cost[x%D-1][x//D-1])
    print(cost[y%D-1][y//D]-cost[x%D-1][x//D])

#print(cost)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
#途中

H,W,D=map(int,input().split())

A=[]
for i in range(H):
    A.append(list(map(int,input().split())))

loc=[[0,0] for i in range(W*H)]

#print(loc)

for i in range(H):
    for j in range(W):
        loc[A[i][j]-1][0]=i
        loc[A[i][j]-1][1]=j
        #print(loc)
print(loc)

cost=[[0]*((H*W)//D) for i in range(D)]

for i in range((H*W)%D):
    cost[i].append(0)

for i in range(D):
    pass
    count=1
    temp=0
    while temp<(H*W):
        temp=i+D*count
        cost[temp%D][temp//D]=abs(loc[temp][0]-loc[temp-D][0])+abs(loc[temp][1]-loc[temp-D][1])+cost[temp%D][temp//D-1]
        count+=1

print(cost)
Problem p03634 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**9)

def dfs(num,cost):
    visited[num]=cost
    for item in way[num]:
        if visited[item[0]]==-1:
            dfs(item[0],cost+item[1])
    return
    
N=int(input())

way=[[] for i in range(N)]
visited=[-1]*N
for _ in range(N-1):
    a,b,c=map(int,input().split())
    way[a-1].append([b-1,c])
    way[b-1].append([a-1,c])


Q,K=map(int,input().split())
dfs(K-1,0)
for _ in range(Q):
    x,y=map(int,input().split())
    print(visited[x-1]+visited[y-1])

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def dfs(num,cost):
    visited[num]=cost
    for item in way[num]:
        if visited[item[0]]==-1:
            dfs(item[0],cost+item[1])
    return
    
N=int(input())

way=[[] for i in range(N)]
visited=[-1]*N
for _ in range(N-1):
    a,b,c=map(int,input().split())
    way[a-1].append([b-1,c])
    way[b-1].append([a-1,c])


Q,K=map(int,input().split())
dfs(K-1,0)
for _ in range(Q):
    x,y=map(int,input().split())
    print(visited[x-1]+visited[y-1])
Problem p03745 (python)

Fixed submission:
# coding: utf-8
# Your code here!
_=int(input())
A=list(map(int,input().split()))
N=len(A)

trend=0
ans=0
for i in range(N-1):
    temp=A[i+1]-A[i]
    if trend==0:
        if temp>0:
            trend=1
            ans+=1
        elif temp<0:
            trend=-1
            ans+=1
        else:
            pass
    elif trend==1:
        if temp>0:
            pass
        elif temp<0:
            trend=0
        else:
            pass
    elif trend==-1:
        if temp>0:
            trend=0
        elif temp<0:
            pass
        else:
            pass

print(ans if trend!=0 else ans+1)

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

ans=0
pre=A[1]-A[0]
cool=True
for i in range(N-2):
    temp=A[i+2]-A[i+1]
    if temp==0:
        cool=True
        continue
    elif pre*temp<0 and cool:
        ans+=1
        cool=False
    else:
        cool=True
    pre=temp


print(ans+1)

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

ans=0
pre=A[1]-A[0]
cool=True
for i in range(N-2):
    temp=A[i+2]-A[i+1]
    if pre*temp<0 and cool:
        ans+=1
        cool=False
    else:
        cool=True
    pre=temp

print(ans+1)
Problem p03804 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

AN=[]
for _ in range(N):
    AN.append(list(input()))
    
#print(AN)

AM=[]
for _ in range(M):
    AM.append(list(input()))

#print(AM)
for i in range(N-M+1):
    for j in range(N-M+1):
        #print(i,j)
        flag=True
        for k in range(M):
            if AN[i+k][j:j+M]!=AM[k]:
                #print(AN[i+k][j:j+M],AM[k])
                flag=False
        if flag:
            print("Yes")
            exit()
        
print("No")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

AN=[]
for _ in range(N):
    AN.append(list(input()))
    
#print(AN)

AM=[]
for _ in range(M):
    AM.append(list(input()))

#print(AM)
for i in range(N-M+1):
    flag=False
    for j in range(N-M+1):
        if AN[i][j:j+M]==AM[0]:
            for k in range(i,i+M):
                if AN[k][j:j+M]!=AM[k]:
                    flag=True
                    break
            if flag:
                break
            print("Yes")
            exit()
                    

print("No")
Problem p02596 (python)

Fixed submission:
k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while 1:
    now += 1
    x = (x*10 +7) % k
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break
    else:
      ok[x] = 1

Buggy submission (verdict: Runtime Error):
k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while now+=1:
    x = (x*10 +7) % k
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break

Buggy submission (verdict: Runtime Error):
k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while now+=1:
    x = x*10 +7
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break
Problem p02879 (python)

Fixed submission:
n,m=map(int,input().split())
if n<10 and m<10 :
  print(n*m)
else :
  print(-1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if n<10 && m<10 :
  print(n*m)
else :
  print(-1)
Problem p02989 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(a[n//2]-a[n//2-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(a[n//2+1]-a[n//2])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(a[n/2+1]-a[n/2])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a=sort(a)
print(a[n/2+1]-a[n/2])
Problem p03075 (python)

Fixed submission:
a=[int(input()) for i in range(5)]
k=int(input())
if abs(a[0]-a[4])>k:
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
a=[int(input()) for i in range(5)]
k=int(input())
if abs(a[0]-a[5])>k:
  print(":(")
else:
  print("Yay!")
Problem p03307 (python)

Fixed submission:
N=int(input())
if N%2==1 :
  N*=2
print(N)

Buggy submission (verdict: Runtime Error):
N = input()
if N%2 == 1:
  N*=2
print(N)
Problem p03821 (python)

Fixed submission:
n=int(input())
a=[]
b=[]
ret = 0
for i in range(n):
  s,t=map(int,input().split())
  a+=[s]
  b+=[t]
for i in range(n):
  ret+=(b[-1-i]-(ret+a[-1-i])%b[-1-i])%b[-1-i]
print(ret)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
ret = 0
for i in range(n):
  a[i],b[i]=map(int,input().split())
for i in range(n):
  ret+=b[-1-i]-(ret+a[-1-i])%b[-1-i]
print(ret)
Problem p03986 (python)

Fixed submission:
s=input()
sc=0
tc=0
for i in s:
  if i=='S':
    sc+=1
  elif sc!=0:
    sc-=1
  else :tc+=1
print(tc+sc)

Buggy submission (verdict: Runtime Error):
s=input()
sc=0
tc=0
for i in s:
  if i=="S":
    sc+=1
  elif sc!=0:
    sc-=1
  else tc+=1
print(tc+sc)
Problem p02629 (python)

Fixed submission:
N = int(input())

S = 'abcdefghijklmnopqrstuvwxyz'

def bite(X):
    s = 0
    t = 0
    while t < X:
        t = t + 26**(s+1)
        s = s + 1
    return s


B = bite(N)
X = N
L = []
for i in range(B):
    if X%26 != 0:
        L.append(X%26)
        X = (X-X%26)//26
    else:
        L.append(26)
        X = (X - 26)//26

L.reverse()

ans = ''
for i in range(B):
    ans = ans + S[L[i]-1]

    
print(ans)

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

S = 'abcdefghijklmnopqrstuvwxyz'

def bite(X):
    s = 0
    t = 0
    while t < X:
        t = t + 26**(s+1)
        s = s + 1
    return s

B = bite(N)
X = N
L = []
for i in range(B-1):
    L.append(X//(26**(B-i-1)))
    X = X - (X//(26**(B-i-1)))*(26**(B-i-1))
L.append(X)

ans = ''
for i in range(B):
    ans = ans + S[L[i]-1]
    
print(ans)
Problem p02831 (python)

Fixed submission:
a,b=map(int,input().split())
gcm=1
for i in range(1,1+min(a,b)):
  if a%i == 0 and b%i == 0:
    gcm = i
  else:
    gcm = gcm
    
print((a*b)//gcm)

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

maxi = A[0]
for  i in range(N):
    if A[i] >= maxi:
        maxi = A[i]
    else:
        maxi = maxi
        
count = 0
position = 0
while position < N:
  for j in range(1,maxi+1):
    for i in range(position,N):
      if A[i] == j:
        count = count + 1
        break
      else:
        position = position + 1
 
if count != 0:
    print(N-count)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
max = A[0]
for  i in range(N):
    if A[i] >= max:
        max = A[i]
    else:
        max = max
        
count = 0
position = 0
while position < N:
  for j in range(1,max):
    for i in range(position,N):
      if A[i] == j:
        count = count + 1
        break
      else:
        position = position + 1

if count != 0:
    print(N-count)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
count = 0
position = 0
while position < N:
  for j in range(1,N+1):
    for i in range(position,N):
      if A[i] == j:
        count = count + 1
        break
      else:
        position = position + 1

if count != 0:
    print(N-count)
else:
    print(-1)
Problem p02916 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=0
for i in range (N-1):
  if A[i]+1 == A[i+1]:
    x= x+B[i]+C[A[i]-1]
  else:
    x= x+B[i]
print(x+B[N-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=0
for i in range (N-2):
  if A[i]+1 == A[i+1]:
    x= x+B[i]+C[A[i]]
  else:
    x= x+B[i]
print(x+B[N-1])
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if a>=3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
List.sort()
a= List[0]
for i in range(len(List)):
  a= (a+List[i])/2
print(a)

Buggy submission (verdict: Runtime Error):
N=int(input())
List=list(map(int,input().split()))
a=0
List.sort()
for i in range(len(List)):
  a= (a+List[i])/2
print(a)