Problem p03952 (python)

Fixed submission:
import bisect
import copy
import heapq
import statistics
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,x=map(int,input().split())
if x==1 or x==2*n-1:
    print("No")
    exit()
print("Yes")
if n==2:
    for i in range(n+1):
        print(i+1)
elif x==2:
    cnt=5
    for i in range(2*n-1):
        if i<n-2 or n+1<i:
            print(cnt)
            cnt+=1
        else:
            if i==n-2:
                print(x+1)
            elif i==n-1:
                print(x)
            elif i==n:
                print(x-1)
            else:
                print(x+2)
else:
    lst=[0]*(2*n-1)
    cnt=1
    for i in range(2*n-1):
        if i<n-2 or n+1<i:
            if cnt<x-2 or x+1<cnt:
                lst[i]=cnt
            else:
                cnt=x+2
                lst[i]=cnt
            cnt+=1
        else:
            if i==n-2:
                lst[i]=x-1
            elif i==n-1:
                lst[i]=x
            elif i==n:
                lst[i]=x+1
            else:
                lst[i]=x-2
    for i in range(2*n-1):
        print(lst[i])

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import statistics
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,x=map(int,input().split())
if x==1 or x==2*n-1:
    print("No")
    exit()
print("Yes")
if n==2:
    for i in range(n+1):
        print(i+1)
elif x==2:
    cnt=4
    for i in range(2*n-1):
        if i<n-2 or n+1<i:
            print(cnt)
            cnt+=1
        else:
            if i==n-2:
                lst[i]=x+1
            elif i==n-1:
                lst[i]=x
            elif i==n:
                lst[i]=x-1
            else:
                lst[i]=x+2
        print(cnt)
        cnt+=1
else:
    lst=[0]*(2*n-1)
    cnt=1
    for i in range(2*n-1):
        if i<n-2 or n+1<i:
            if cnt<x-2 or x+1<cnt:
                lst[i]=cnt
            else:
                cnt=x+2
                lst[i]=cnt
            cnt+=1
        else:
            if i==n-2:
                lst[i]=x-1
            elif i==n-1:
                lst[i]=x
            elif i==n:
                lst[i]=x+1
            else:
                lst[i]=x-2
    for i in range(2*n-1):
        print(lst[i])

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import statistics
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,x=map(int,input().split())
if x==1 or x==2*n-1:
    print("No")
    exit()
print("Yes")
if n==2:
    for i in range(n+1):
        print(i+1)
elif x==2:
    cnt=4
    for i in range(2*n-1):
        if i==n-2:
            lst[i]=x+1
        elif i==n-1:
            lst[i]=x
        elif i==n:
            lst[i]=x-1
        else:
            lst[i]=x+2
        print(cnt)
        cnt+=1
else:
    lst=[0]*(2*n-1)
    cnt=1
    for i in range(2*n-1):
        if i<n-2 or n+1<i:
            if cnt<x-2 or x+1<cnt:
                lst[i]=cnt
            else:
                cnt=x+2
                lst[i]=cnt
            cnt+=1
        else:
            if i==n-2:
                lst[i]=x-1
            elif i==n-1:
                lst[i]=x
            elif i==n:
                lst[i]=x+1
            else:
                lst[i]=x-2
    for i in range(2*n-1):
        print(lst[i])