Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    for i in range(n):
        num3=list1[i][1]
        numa+=[num3]*(num3-1)
        numb+=[num3]*(n-num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    list2=[]
    def countnum(num):
        return list2.count(num)
    for i in range(n):
        list2=ans[:list1[i][0]]
        if countnum(list1[i][1])!=list1[i][1]:
            ansnum=1
            break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()


Fixed submission:
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    for i in range(n):
        num3=list1[i][1]
        numa+=[num3]*(num3-1)
        numb+=[num3]*(n-num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def countnum(num):
        return ans.count(num)
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                if countnum(list1[count1][1])!=list1[count1][1]-1:
                    ansnum=1
                    break
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    def apa(num):
        numa.append(num)
    def apb(num):
        numb.append(num)
    for i in range(n):
        num3=list1[i][1]
        for j in range(num3-1):
            apa(num3)
        for j in range(n-num3):
            apb(num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    list2=[]
    def countnum(num):
        return list2.count(num)
    for i in range(n):
        list2=ans[:list1[i][0]]
        if countnum(list1[i][1])!=list1[i][1]:
            ansnum=1
            break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()


Fixed submission:
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    for i in range(n):
        num3=list1[i][1]
        numa+=[num3]*(num3-1)
        numb+=[num3]*(n-num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def countnum(num):
        return ans.count(num)
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                if countnum(list1[count1][1])!=list1[count1][1]-1:
                    ansnum=1
                    break
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=list(map(int,input().split()))
list1=[]
def ap1(num):
    list1.append(num)
for i in range(n):
    ap1([x[i],i+1])
str1= lambda val: val[0]
list1.sort(key=str1)
numa=[]
numb=[]
def apa(num):
    numa.append(num)
def apb(num):
    numb.append(num)
for i in range(n):
    num3=list1[i][1]
    for j in range(num3-1):
        apa(num3)
    for j in range(n-num3):
        apb(num3)
count1=0
count2=0
count3=0
ans=[]
ansnum=0
def apans(num):
    ans.append(num)
for i in range(n*n):
    yn=0
    if count1!=n:
        if i==list1[count1][0]-1:
            apans(list1[count1][1])
            count1+=1
            yn=1
    if yn==0:
        if count2!=len(numa):
            apans(numa[count2])
            count2+=1
        elif count3!=len(numb):
            apans(numb[count3])
            count3+=1
        else:
            if i!=n*n-1:
                ansnum=1
                break
list2=[]
def countnum(num):
    return list2.count(num)
for i in range(n):
    list2=ans[:list1[i][0]]
    if countnum(list1[i][1])!=list1[i][1]:
        ansnum=1
        break
if ansnum==1:
    print("No")
else:
    print("Yes")
    print(*ans)


Fixed submission:
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    for i in range(n):
        num3=list1[i][1]
        numa+=[num3]*(num3-1)
        numb+=[num3]*(n-num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def countnum(num):
        return ans.count(num)
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                if countnum(list1[count1][1])!=list1[count1][1]-1:
                    ansnum=1
                    break
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
num=[]
num2=[]
ans=[]
count=0
numcount=0
numcount2=0
yn=0
for i in range(2,n+1):
    num+=[i]*(i-1)
for i in range(1,n):
    num2+=[i]*(n-i)
for i in range(n*n):
    if x[count]==i+1:
        if numcount<((count+1)*count)//2:
            yn=1
            break
        elif len(num2)-((n-count)*(n-count-1))//2<numcount2:
            yn=1
            break
        else:
            ans+=str(count+1)
        count+=1
    else:
        if numcount<len(num):
            ans+=str(num[numcount])
            numcount+=1
        elif numcount2<len(num2):
            ans+=str(num2[numcount2])
            numcount2+=1
        else:
            yn=1
            break
if yn==1:
    print("No")
else:
    print("Yes")
    print(*ans)


Fixed submission:
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    for i in range(n):
        num3=list1[i][1]
        numa+=[num3]*(num3-1)
        numb+=[num3]*(n-num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def countnum(num):
        return ans.count(num)
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                if countnum(list1[count1][1])!=list1[count1][1]-1:
                    ansnum=1
                    break
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
a=[]
b=[]
ans=[]
yn=0
count=1
count2=0
count3=0
for i in range(n):
    check=i*n+((n-i-1)*(n-i))//2
    if check+i+1<x[i] or x[i]<((i+2)*(i+1))//2:
        yn+=1
        break
lena=len(a)
if yn==1:
    print("No")
else:
    print("Yes")
    for i in range(n):
        for j in range(i):
            a.append(i+1)
    for i in range(n):
        for j in range(n-i-1):
            b.append(i+1)
    for i in range(n*n):
        if x.count(i+1)==1:
            ans.append(count)
            count+=1
        else:
            if count2<lena:
                ans.append(a[count2])
                count2+=1
            else:
                ans.append(b[count3])
                count3+=1
    print(*ans)


Fixed submission:
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    for i in range(n):
        num3=list1[i][1]
        numa+=[num3]*(num3-1)
        numb+=[num3]*(n-num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def countnum(num):
        return ans.count(num)
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                if countnum(list1[count1][1])!=list1[count1][1]-1:
                    ansnum=1
                    break
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()