Harryxun/GPT-100-sft-dataset huggingface dataset:
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()))

ans1=[]
ans2=[]

for i in range(x):
    for j in range(y):
        ans1.append(a[i]+b[j])
ans1.sort()
ans1.reverse()

if len(ans1)>=k:
    del ans1[k:]
    
for i in range(len(ans1)):
    for j in range(z):
        ans2.append(ans1[i]+c[j])
ans2.sort()
ans2.reverse()

for i in range(k):
    print(ans2[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()))

ans1=[]
ans2=[]

for i in range(x):
    for j in range(y):
        ans1.append(a[i]+b[j])
ans1.sort()
ans1.reverse()

if len(ans1)>=k:
    del ans1[k:]
    
for i in range(k):
    for j in range(z):
        ans2.append(ans1[i]+c[j])
ans2.sort()
ans2.reverse()

for i in range(k):
    print(ans2[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()))

ans1=[]
ans2=[]

for i in range(x):
    for j in range(y):
        ans1.append(a[i]+b[j])
ans1.sort()
ans1.reverse()

if len(ans1)>=k:
    del ans1[k:]
    
for i in range(k):
    for j in range(z):
        ans2.append(ans1[i]+c[j])
ans2.sort()
ans2.reverse()

for i in range(k):
    print(ans2[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())) 
e=[]
d=[]
 
a.sort()
b.sort()
c.sort()
 
for i in range(1,x+1):
    for j in range(1,y+1):
        e.append(a[-i]+b[-j])
e.sort()
del e[:-k]
for i in range(1,k+1):
    for j in range(1,z+1):
        d.append(e[-i]+c[-j])
        
d.sort()
for i in range(1,k+1):
    print(d[-i])
Problem p03085 (python)

Fixed submission:
n=input()
if n=='A':
    print('T')
elif n=='G':
    print('C')
elif n=='T':
    print('A')
else:
    print('G')

Buggy submission (verdict: Runtime Error):
n = int(input())
mod = 10**9+7
 
dp = [[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(n+1)]
#長さ0の文字列は1
#0,1,2(A,G,C)に関する制約しかないため
#Sは、TTTSと考えてもよい
dp[0][3][3][3] = 1
 
#swapしてAGCが発生しない文字列:=AGC,ACG,GAC,A?GC,AG?Cを含まない文字列
#A:=0,G:=1,C:=2,T:=3
 
#文字列の文字数
for i in range(n):
    #最後から1文字目
    for j in range(4):
        #最後から2文字目
        for k in range(4):
            #条件に当てはまるものがない場合
            if dp[i][j][k] == 0:
                continue
            #最後から3文字目
            for l in range(4):
                #新たに追加する文字
                for a in range(4):
                    #ダメな5条件をカット
 
                    #AGCの場合
                    if a == 2 and j == 1 and k == 0:continue
                    #GACの場合
                    if a == 2 and j == 0 and k == 1:continue
                    #ACGの場合
                    if a == 1 and j == 2 and k == 0:continue
                    #A?GCの場合
                    if a == 2 and j == 1 and l == 0:continue
                    #AG?Cの場合
                    if a == 2 and k == 1 and l == 0:continue
 
                    #ダメの条件を抜けると、aを足した文字列が作れる
                    dp[i+1][a][j][k] += dp[i][j][k][l]
                    dp[i+1][a][j][k] %= mod
 
ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            #長さnの全通り回収
            ans += dp[n][j][k][l]
            ans %= mod
print(ans)

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

if input()==A:
  print('T')
elif input()==T:
  print('A')
elif input()==C:
  print('G')
else:
  print('C')
Problem p03106 (python)

Fixed submission:
A,B,K = list(map(int, input().split()))
x=[]
count=0 
for i in range(max(A,B)+1):
  if A%(i+1)==B%(i+1)==0:
    x.append(i+1)
    count+=1
 
print(x[count-K])

Buggy submission (verdict: Runtime Error):
A,B,K = list(map(int, input().split()))
x=[]

for i in range(max(A,B)):
  if A%i==B%i==0:
    x.append(i)

print(x[K-1])
Problem p03112 (python)

Fixed submission:
import bisect
import sys
input = sys.stdin.readline
a,b,q=map(int, input().split())
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
x=[int(input()) for i in range(q)]
s=[-float('inf')]+s+[float('inf')]
t=[-float('inf')]+t+[float('inf')]

for i in range(q):
    index1=bisect.bisect_right(s, x[i]) 
    index2=bisect.bisect_right(t, x[i])  
    v1=abs(x[i]-s[index1-1])
    v2=abs(x[i]-s[index1])
    w1=abs(x[i]-t[index2-1])
    w2=abs(x[i]-t[index2])
    
    print(min(2*v1+w2,2*v2+w1,2*w1+v2,2*w2+v1,v1+abs(w1-v1),w1+abs(w1-v1),v2+abs(w2-v2),w2+abs(w2-v2)))

Buggy submission (verdict: Runtime Error):
import bisect

a,b,q=map(int, input().split())  
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
x=[int(input()) for i in range(q)]
v=10**18
w=[-10**18]
s.append(v)
s=w+s
t.append(v)
t=w+t
print(s)
print(t)
print(x)

for i in range(n):
    
    index1 = bisect.bisect_left(s, x[i])    
    index2 = bisect.bisect_left(t, x[i])  
    ans=abs(x[i]-)
Problem p03126 (python)

Fixed submission:
n,m=map(int, input().split())
a= [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    del a[i][0]
v=[]

x=0
for i in range(1,m+1):
    for j in range(n):
        v.append(a[j].count(i))

for i in range(0,m*n,n):
  
    if v[i:i+n].count(1)==n:
        x+=1

  
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[int(input()) for i in range(n)]
 
print(sum(s)-max(s)//2)
Problem p03138 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i-1>len(x)-1:
        ans+=2**(50-i-1)*count

    elif not flag:
        ans+=2**(50-i-1)*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=2**(50-i-1)*count
                flag=False
            else:
                ans += 2 ** (50 - i - 1) * count
        
        else:
            if int(x[-(50-i)])==1:
                ans+=2**(50-i-1)*(n-count)
            else:
                ans+=2**(50-i-1)*count

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i>len(x):
        ans+=（2**(50-i-1)）*count

    elif not flag:
        ans+=（2**(50-i-1)）*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=（2**(50-i-1)）*count
                flag=False
            else:
                ans +=（ 2 ** (50 - i - 1)） * count

        else:
            if int(x[-(50-i)])==1:
                ans+=（2**(50-i-1)）*(n-count)
            else:
                ans+=（2**(50-i-1)）*count
      

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i>len(x):
        ans+=（2**(50-i-1)）*count

    elif not flag:
        ans+=（2**(50-i-1)）*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=（2**(50-i-1)）*count
                flag=False
            else:
                ans +=（ 2 ** (50 - i - 1)） * count

        else:
            if int(x[-(50-i)])==1:
                ans+=（2**(50-i-1)）*(n-count)
            else:
                ans+=（2**(50-i-1)）*count
                flag=False

print(ans)
Problem p03229 (python)

Fixed submission:
import itertools

n=int(input())
a=list(int(input()) for i in range(n))
b=[]
a.sort()
ans=0

if n%2==1:
    x=2*sum(a[n//2+1:])-2*sum(a[:n//2+1])+sum(a[n//2-1:n//2+1])
    y=2*sum(a[n//2:])-sum(a[n//2:n//2+2])-2*sum(a[:n//2])
    print(max(x,y))

else:
    x=2*sum(a[n//2:])-(a[n//2]) -2*sum(a[:n//2])+a[n//2-1]
    print(x)

Buggy submission (verdict: Runtime Error):
import itertools

n=int(input())
a=list(int(input()) for i in range(n))
b=[]
a.sort()

ans=0

if n%2==1:
    b.append(a[n//2])
    for i in range(n//2):
        if a[n//2]-a[0]<=a[-1]- a[n//2]:
            b.append(a[-(i+1)])
            b.append(a[i])
        else:
            b.append(a[i])
            b.append(a[-(i+1)])
            
        
    for i in range(len(b)-1):
        ans+=abs(b[i+1]-b[i])
    print(ans)


else:
    b.append(a[n//2-1])
    b.append(a[n//2+1])
    
    if n==2:
        print(b[1]-b[0])
        exit()
    
    for i in range(n//2-2):
        b.append(a[i])
        b.append(a[-(i+1)])
    
    b.append(a[n//2-2])
    b.append(a[n//2])
    
    for i in range(len(b)-1):
        ans+=abs(b[i+1]-b[i])
    print(ans)
Problem p03240 (python)

Fixed submission:
n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
z.sort(key=lambda x:x[2])
z.reverse()

v=[]
count=0

#各頂点に対して、中心座標と仮定して検証
for i in range(101):
    for j in range(101):
        x=abs(j-z[0][0])
        y=abs(i-z[0][1])
        h=z[0][2]+abs(x)+abs(y)
                
            #候補があってるか確認
        for k in range(n):
            if z[k][2]==max(h-abs(z[k][0]-j)-abs(z[k][1]-i),0):
                count+=1
                
        if count==n:
            print(j,i,h)
            exit()
        count=0

Buggy submission (verdict: Runtime Error):
n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
z.sort(key=lambda x:x[2])
z.reverse()
print(z)

v=[]
count=0

#各頂点に対して、中心座標と仮定して検証
for i in range(101):
    for j in range(101):
            x=abs(j-z[0][0])
            y=abs(i-z[0][1])
            h=z[0][2]+abs(x)+abs(y)
                
            #候補があってるか確認
            for k in range(n):
                if z[k][2]==max(h-abs(z[k][0]-j)-abs(z[k][1]-i),0):
                    count+=1
                
            if count==n:
                print(r[0],r[1],h)
            exit()
        count=0

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
a=list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = fractions.gcd(ans, a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
v=[]
r=[]
#各頂点に対して、ピラミッドの頂点(  高さ200 )と仮定して計算 rに座標保存
for i in range(101):
    for j in range(101):
        for k in range(n):
            x=abs(j-z[k][0])
            y=abs(i-z[k][1])
            v.append(200-x-y-z[k][2])
        if v.count(v[0])==n:
            r=[j,i]
        v=[]
#中心座標の高さを求める。
h=z[0][2]+abs(z[0][0]-r[0])+abs(z[0][1]-r[1])
print(r[0],r[1],h)
Problem p03244 (python)

Fixed submission:
import collections
n=int(input())
v=list(map(int, input().split()))
v1=v[0:n:2]
v2=v[1:n:2]
v10=collections.Counter(v1)
v11=v10.most_common()
v20=collections.Counter(v2)
v21=v20.most_common()
if v11[0][0]==v21[0][0] and v11[0][1]==n//2 and v21[0][1]==n//2:
    print(n//2)
elif v11[0][0]==v21[0][0]:
    x1=n//2-v11[0][1]
    x2=n//2-v11[1][1]
    y1=n//2-v21[0][1]
    y2=n//2-v21[1][1]
    print(min(x1+y2,x2+y1))
    
else:
    x1=n//2-v11[0][1]
    y1=n//2-v21[0][1]
    print(x1+y1)

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
v=list(map(int, input().split()))
v1=v[0:n:2]
v2=v[1:n:2]
v10=collections.Counter(v1)
v11=v10.most_common()
v20=collections.Counter(v2)
v21=v20.most_common()
if v11[0][0]==v21[0][0] and v11[0][1]==n//2 and v21[0][1]==n//2:
    print(n//2)
elif v11[0][0]==v21[0][0]:
    x1=n//2-v11[0][1]
    x2=n//2-v11[1][1]
    y1=n//2-v21[0][1]
    y2=n//2-v21[1][1]
    print(min(x1+y2,x2+y1))
    
else:
    x=n//2-v11[0][1]
    y=n//2-v21[0][1]
    print(x1+y1)
Problem p03260 (python)

Fixed submission:
A,B=list(map(int,input().split()))
x=A*B
if x%2==0:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
A,B=int(input()) 
x=A*B
if x%2==0:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
A,B=int(input()) 
x=A*B
if x%2==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A=int() , B=int()
x=A*B
if x%2==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
int A, int B
x=A*B
if x%2==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
int A, int B
x=A*B
if x%2==0:
  return 'Yes'
else:
  returun 'No'

Buggy submission (verdict: Runtime Error):
input(A,B)
x=A*B
if x%2==0:
  return 'Yes'
else:
  returun 'No'

Buggy submission (verdict: Runtime Error):
if A%2==0 or B%2==0:
  return 'Yes'
else:
  return 'No'
Problem p03263 (python)

Fixed submission:
import sys
input = sys.stdin.readline
h,w=map(int, input().split())
a=[list(map(int, input().split())) for i in range(h)]
ans=[]


for i in range(h):
    for j in range(w):
        if i==h-1 and j==w-1:
            continue
        
        if a[i][j]%2==0:
            continue
        
        if j!=w-1:
            ans.append([i+1,j+1,i+1,j+2])
            a[i][j+1]+=1
        else:
            ans.append([i+1,j+1,i+2,j+1])
            a[i+1][j]+=1
            
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline
h,w=map(int, input().split())
a=[list(map(int, input().split())) for i in range(h)]
x=0
for i in range(h):
    for j in range(w):
        x+=a[i][j]*((h-i-1)+(w-j-1))
        
print(x)

for i in range(h):
    for j in range(w):
        if a[i][j]!=0:
            for k in range(a[i][j]):
                for l in range(1,w-j):
                    print(i+1,j+l,i+1,j+l+1)
                for m in range(1,h-i):
                    print(i+m,w,i+m+1,w)

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline
h,w=map(int, input().split())
a=[list(map(int, input().split())) for i in range(h)]
x=0
for i in range(h):
    for j in range(w):
        x+=a[i][j]*((h-i-1)+(w-j-1))
        
print(x)

for i in range(h):
    for j in range(w):
        if a[i][j]!=0:
            for k in range(a[i][j]):
                for l in range(1,w-j):
                    print(i+1,j+l,i+1,j+l+1)
                for m in range(1,h-i):
                    print(i+m,w,i+m+1,w)
Problem p03290 (python)

Fixed submission:
d,g=map(int, input().split())
p=[list(map(int, input().split())) for i in range(d)]
x=[]
for i in range(2**d):
    t=0
    u=0
    v=[]
    for k in range(d):
        v.append(k)
    for j in range(d):
        if ((i>>j)&1):
            t+=p[j][0]*100*(j+1)+p[j][1]
            u+=p[j][0]
            v[j]=0
    if i==0:
        for j in range(d):
            for k in range(p[j][0]):
                if (j+1)*k<g<=(j+1)*(k+1):
                    x.append(j+1)
    if t>=g:
        x.append(u)
    else:
        for l in range(p[max(v)][0]):
            if t+(max(v)+1)* 100*l<g<=t+(max(v)+1)* 100*(l+1):
                x.append(u+l+1)
print(min(x))

Buggy submission (verdict: Runtime Error):
x = [list(map(int, input().split())) for i in range(d)]
ans2=float('inf')

for i in range(2**d):
    v=[0]*d
    ans=0
    ans1=0
    for j in range(d):
        if (i>>j)&1==1:
            ans+=(x[j][0]*100*(j+1))+x[j][1]
            ans1+=x[j][0]
            v[j]=1


    if ans<g:
        for k in range(d):
            if v[d-k-1]==0:
                if g-ans<=(x[d-k-1][0]-1)*100*(d-k):
                    w=-(-(g-ans)//(100*(d-k)))

                    ans2=min(ans2,ans1+w)
                else:
                    break
    else:
        ans2=min(ans2,ans1)
print(ans2)
Problem p03361 (python)

Fixed submission:
h,w=map(int, input().split()) 
s=[list(input()) for i in range(h)] 

s1=[['.' for i in range(w+2)] for i in range(h+2)]

for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            s1[i+1][j+1]='#'
for i in range(h+2):
    for j in range(w+2):
        if s1[i][j]=='#':
            if s1[i-1][j]==s1[i+1][j]==s1[i][j-1]==s1[i][j+1]=='.':
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
h,w=map(int, input().split()) 
s=[list(input()) for i in range(w)] 

s1=[['.' for i in range(h+2)] for i in range(w+2)]

for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            s1[i+1][j+1]='#'
for i in range(h+2):
    for j in range(w+2):
        if s1[i][j]=='#':
            if s1[i-1][j]==s1[i+1][j]==s1[i][j-1]==s1[i][j+1]=='.':
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
h,w=map(int, input().split()) 
s=[list(input()) for i in range(w)] 

s1=[['.' for i in range(h+2)] for i in range(w+2)]

for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            s1[i+1][j+1]='#'
for i in range(h+2):
    for j in range(w+2):
        if s1[i][j]=='#':
            if s1[i-1][j]==s1[i+1][j]==s1[i][j-1]==s1[i][j+1]=='.':
                print('No')
                exit()
print('Yes')
Problem p03402 (python)

Fixed submission:
import numpy as np
a,b = map(int, input().split())

x=np.array([['.']*100]*100,dtype=str)

x[:,:50]='#'

v1=(a-1)//20
v2=(a-1)-v1*20
w1=(b-1)//20
w2=(b-1)-w1*20

for i in range(v1):
    x[2*i+1,1:40:2]='.'

x[-1,1:2*v2:2]='.'

for i in range(w1):
    x[2*i+1,51:90:2]='#'
x[-1,51:50+w2*2:2]='#'
print(100,100)
for i in range(100):
    print(''.join(x[i]))

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

x=np.array([['.']*100]*100,dtype=str)

x[:,:50]='#'

v1=(a-1)//20
v2=(a-1)-v1
w1=(b-1)//20
w2=(b-1)-w1

for i in range(v1):
    x[2*i+1,1:40:2]='.'

x[-1,1:2*v2:2]='.'

for i in range(w1):
    x[2*i+1,51:90:2]='#'
x[-1,51:50+w2*2:2]='#'

for i in range(100):
    print(''.join(x[i]))
Problem p03409 (python)

Fixed submission:
n=int(input())
r=[list(map(int, input().split())) for i in range(n)]
b=[list(map(int, input().split())) for i in range(n)]
v=[]
r.sort()
b.sort()
count=0
 
for i in range(n):
    for j in range(len(r)):
        if b[i][0]<=r[j][0] or b[i][1]<=r[j][1]:
            pass
        else:
            v.append(r[j])    
    if v!=[]:
        v.sort(key=lambda x:x[1])
        v.reverse()
        r.remove(v[0])
        
            
        v=[]
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
r=[list(map(int, input().split())) for i in range(n)]
b=[list(map(int, input().split())) for i in range(n)]
v=[]
r.sort()
b.sort()
print(r)
print(b)
count=0

for i in range(n):
    for j in range(n):
        if b[i][0]<=r[j][0] or b[i][1]<=r[j][1]:
            break
        else:
            v.append(r[j])    
    if v!=[]:
        v.sort(key=lambda x:x[1])
        print(v)
        r.remove(v[0])
        
            
        v=[]
        count+=1
print(count)
Problem p03504 (python)

Fixed submission:
import itertools
n,c = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda x:x[0])
a.sort(key=lambda x:x[2])

# 同じチャンネルの番組を繋げる。
for i in range(n-1):
    if a[i][1]==a[i+1][0] and a[i][2]==a[i+1][2]:
        a[i][1]-=1
# いもす法
x=[0]*(10**5+5)
for i in range(n):
    x[a[i][0]]+=1
    x[a[i][1]+1]-=1

x = itertools.accumulate(x)
print(max(x))

Buggy submission (verdict: Runtime Error):
import itertools
n,c = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda x:x[0])
a.sort(key=lambda x:x[2])

# 同じチャンネルの番組を繋げる。
for i in range(n-1):
    if a[i][1]==a[i+1][0] and a[i][2]==a[i+1][2]:
        a[i][1]-=1
# いもす法
x=[0]*(10**5+1)
for i in range(n):
    x[a[i][0]]+=1
    x[a[i][1]+1]-=1

x = itertools.accumulate(x)
print(max(x))

Buggy submission (verdict: Runtime Error):
import itertools
n,c = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda x:x[0])
# いもす法
x=[0]*(10**5+1)
for i in range(n):
    x[a[i][0]]+=1
    x[a[i][1]+1]-=1

x = itertools.accumulate(x)

print(max(x))
Problem p03565 (python)

Fixed submission:
s=input()
t=input()
u=''
v=[]
count=0

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if t[j]==s[i+j] or s[i+j]=='?':
            count+=1
    if count==len(t):
        for k in range(len(s)):
            if i<=k<=i+len(t)-1:
                u+=t[k-i]
            elif s[k]=='?':
                u+='a'
            else:
                u+=s[k]
                    
                    
        v.append(u)
        u=''
    count=0
if v==[]:
    print('UNRESTORABLE')
else:
    print(min(v))

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
u=''
v=[]
count=0

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if t[j]==s[i+j] or s[i+j]=='?':
            count+=1
    if count==len(t):
        for k in range(len(s)):
            if k>=i:
                u+=t[k-i]
            elif s[k]=='?':
                u+='a'
            else:
                u+=s[k]
                    
                    
        v.append(u)
        u=''
    count=0
if v==[]:
    print('UNRESTORABLE')
else:
    print(min(v))

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
u=''
v=[]
count=0

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if t[j]==s[i+j] or s[i+j]=='?':
            count+=1
    if count==len(t):
        for k in range(len(s)):
            if k>=i:
                u+=t[k-i]
            elif s[k]=='?':
                u+='a'
            else:
                u+=s[k]
                    
                    
        v.append(u)
        u=''
    count=0
    
print(min(v))
Problem p03626 (python)

Fixed submission:
n=int(input())
s=list(input())
v=[0]
for i in range(1,n):
    if s[i]==s[i-1]:
        del(v[-1])
        v.append(1)
        
    else:
        v.append(0)


if v[0]==0:
    ans=3
else:
    ans=6
for i in range(1,len(v)):
    if v[i-1]==0:
        ans*=2
    elif v[i]==1:
        ans*=3
    else:
        continue
    

mod = 1000000007

print(ans%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
v=[]
for i in range(1,n):
    if s[i]==s[i-1]:
        del(v[-1])
        v.append(1)
        
    else:
        v.append(0)


if v[0]==0:
    ans=3
else:
    ans=6
for i in range(1,len(v)):
    if v[i-1]==0:
        ans*=2
    elif v[i]==1:
        ans*=3
    else:
        continue
    

mod = 1000000007

print(ans%mod)
Problem p03633 (python)

Fixed submission:
import fractions

n=int(input())
t=list(int(input()) for i in range(n))
ans=t[0]
for i in range(n-1):
    ans=ans*t[i+1]//fractions.gcd(ans,t[i+1])
    
    
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

n=int(input())
t=list(int(input()) for i in range(n))

for i in range(n-1):
    ans=t[i]*t[i+1]//fractions.gcd(t[i],t[i+1])
    
print(ans)