Problem:
   Problem Statement We have N pieces of ropes, numbered 1 through N . The length of piece i is a_i .  At first, for each i (1≤i≤N-1) , piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:   Choose a (connected) rope with a total length of at least L , then untie one of its knots.   Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.      Constraints  2≤N≤10^5  1≤L≤10^9  1≤a_i≤10^9  All input values are integers.         Input The input is given from Standard Input in the following format:  N  L  a_1  a_2  ...  a_n       Output If it is not possible to untie all of the N-1 knots, print Impossible .  If it is possible to untie all of the knots, print Possible , then print another N-1 lines that describe a possible order to untie the knots. The j -th of those N-1 lines should contain the index of the knot that is untied in the j -th operation. Here, the index of the knot connecting piece i and piece i+1 is i .  If there is more than one solution, output any.        Sample Input 1 3 50
30 20 10      Sample Output 1 Possible
2
1  If the knot 1 is untied first, the knot 2 will become impossible to untie.       Sample Input 2 2 21
10 10      Sample Output 2 Impossible       Sample Input 3 5 50
10 20 30 40 50      Sample Output 3 Possible
1
2
3
4  Another example of a possible solution is 3 , 4 , 1 , 2 .

Solution (Python):
n,l = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
c = -1
for i in range(n-1):
  if x[i] + x[i+1] >= l:
    c = i
    break

if c == -1:
  print("Impossible")
else:
  print("Possible")
  for i in range(1,c+1):
    print(i)
  for i in range(1,n - c):
    print(n - i)

Solution (Python):

n, length = list(map(int, input().split()))
nums = list(map(int, input().split()))

idx = -1
for i in range(n-1):
    if nums[i] + nums[i+1] >= length:
        idx = i
        break
if idx < 0:
    print('Impossible')
    exit()

print('Possible')
for i in range(idx):
    print(i+1)
for i in reversed(range(idx, n-1)):
    print(i+1)

Solution (Python):
N, L = map(int, input().split())
a = list(map(int, input().split()))

f = 0
for i in range(N-1):
    if a[i] + a[i+1] >= L:
        f = 1
        t = i
        break

if f == 0:
    print("Impossible")
else:
    print("Possible")
    ans = []
    for i in range(t):
        ans.append(i+1)
    for i in range(N-1, t, -1):
        ans.append(i)
    
    for x in ans:
        print(str(x))

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))
f=True
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    print("Possible")
    print("\n".join([str(j) for j in range(1,i+1)]+[str(j) for j in range(n-1,i+1,-1)]+[str(i+1)]))
    f=False
    break
if f:
  print("Impossible")

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))
f=True
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    print("Possible")
    print("\n".join([str(j) for j in range(1,i+1)]+[str(j) for j in range(n-1,i+1,-1)]+[str(i+1)]))
    f=False
    break
if f:
  print("Impossible")

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7





N, L = getNM()
A = getList()
max_len_knot, max_len = -1, 0
for i in range(N - 1):
    if A[i] + A[i + 1] > max_len:
        max_len_knot = i
        max_len = A[i] + A[i + 1]
if max_len < L:
    print('Impossible')
else:
    print('Possible')
    for i in range(max_len_knot):
        print(i + 1)
    for i in range(N - 2, max_len_knot, -1):
        print(i + 1)
    print(max_len_knot + 1)

Solution (Python):
N,L=list(map(int, input().split()))
A=list(map(int, input().split()))
for i in range(N-1):
  if A[i]+A[i+1]>=L:
    print('Possible')
    k=i
    break
else:
  print('Impossible')
  exit()
ans=[0]*(N-1)
ans[k]=N-1
for i in range(k):
  ans[i]=i+1
for i in range(N-2-k):
  ans[N-i-2]=k+i+1
for i in range(N-1):
  print(ans[i])

Solution (Python):
def main():
    N, L = list(map(int, input().split()))
    A = list(map(int, input().split()))
    max_len_knot, max_len = - 1, 0
    for i in range(N - 1):
        if A[i] + A[i + 1] > max_len:
            max_len_knot = i
            max_len = A[i] + A[i + 1]
    if max_len < L:
        print('Impossible')
    else:
        print('Possible')
        for i in range(max_len_knot):
            print(i + 1)
        for i in range(N - 2, max_len_knot, -1):
            print(i + 1)
        print(max_len_knot + 1)


if __name__ == '__main__':
    main()

Solution (Python):
N, L = map(int, input().split())
As = list(map(int, input().split()))

i = 0

for j in range(1,N):
  if As[j-1] + As[j] >= L:
    i = j
    break
    
if i == 0:
  print('Impossible')
else:
  print('Possible')
  for j in range(1,i):
    print(j)
  for j in range(N-1,i,-1):
    print(j)
  print(i)

Solution (Python):
N, L = map(int, input().split())
A = list(map(int, input().split()))
k = -1
for i in range(N-1):
    if A[i]+A[i+1]>=L:
        k=i+1
if k==-1:
    print("Impossible")
else:
    print("Possible")
    res = []
    for i in reversed(range(1,k+1)):
        res.append(i)
    for i in range(k+1,N):
        res.append(i)
    for i in reversed(res):
        print(i)

Solution (Python):
def solve(A,L):
    N = len(A)
    for i in range(N-1):
        if A[i]+A[i+1] >= L:
            pro = i
            break
    else:
        return None

    res = list(range(i))+list(reversed(range(i+1,N-1)))+[i]
    return res


if __name__ == '__main__':
    N,L = map(int,input().split())

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

    res = solve(A,L)
    if res is None:
        print('Impossible')
    else:
        print('Possible')
        print(*(v+1 for v in res), sep='\n')

Solution (Python):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
逆順に見る，2つで長さL以上のものが作れればOKそうでなければ不可

最初dequeで解こうとしたけど，純粋に間違ってた
"""
def main():
    mod=10**9+7
    N,L=MI()
    A=LI()
    t=-1 
    for i in range(N-1):
        
        temp=A[i]+A[i+1]
        if temp >= L:
            t=i
            break
        
    if t==-1:
        print("Impossible")
    else:
        print("Possible")
        ans=[]
        for i in range(t):
            ans.append(i)
        for i in range(N-2,t,-1):
            ans.append(i)
        ans.append(t)
        
        for i in ans:
            print(i+1)
            
    
    
    

main()

Solution (Python):
n,l= map(int,input().split())
a= list(map(int,input().split()))
rh=-1
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        rh=i
        break
else:
    print('Impossible')
    exit()
print('Possible')
if rh>0:
    for i in range(rh):print(i+1)
if rh+1<n:
    for i in range(n-1,rh+1,-1):print(i)
print(rh+1)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N, L = in_nn()
    A = in_nl()

    max_l = 0
    ind = -1
    for i in range(N - 1):
        t = A[i] + A[i + 1]
        if max_l < t:
            ind = i
            max_l = t

    if max_l >= L:
        print("Possible")
        for i in range(1, ind + 1):
            print(i)
        for i in range(N - 1, ind, -1):
            print(i)
    else:
        print("Impossible")


if __name__ == '__main__':
    main()

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,l = map(int,readline().split())
lst1 = list(map(int,readline().split()))

res = -1

for i in range(n-1):
    if lst1[i]+lst1[i+1] >= l:
        res = i

if res == -1:
    print("Impossible")
    exit()
else:
    print("Possible")

ans = []
for i in range(res):
    ans.append(i)
for j in range(n-2,res,-1):
    ans.append(j)
ans.append(res)

for i in ans:
    print(i+1)

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    print('Possible')
    ans=[i+1]+list(range(i,0,-1))+list(range(i+2,n))
    print(*ans[::-1],sep='\n')
    break
else:print('Impossible')

Solution (Python):
n,l=map(int,input().split())
t=list(map(int,input().split()))
for i in range(n-1):
    if t[i]+t[i+1]>=l:
        print('Possible')
        print(*(list(range(1,i+1))+list(range(n-1,i+1,-1))),sep='\n')
        print(i+1)
        exit()
print('Impossible')

Solution (Python):
n, k = map(int,input().split())
a = list(map(int,input().split()))
idx = -1
for i in range(n-1):
    if a[i]+a[i+1]>=k:
        idx = i
        break
if idx == -1:
    print('Impossible')
    exit()
else:
    print('Possible')
    for i in range(1, idx+1):
        print(i)
    for i in range(n-1, idx, -1):
        print(i)

Solution (Python):
import sys
import math
import collections
import bisect
import itertools



sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))




def main():
    n, l = na()
    a = na()

    max_point = -1
    max_idx = -1
    for i in range(1, n):
        tmp = a[i] + a[i - 1]
        if tmp >= l:
            max_point = max(max_point, tmp)
            max_idx = i - 1

    if max_point == -1:
        print("Impossible")
        exit(0)

    tmp = [i for i in range(n - 1)]

    ans = []
    x = tmp[:max_idx]
    y = tmp[max_idx + 1:]
    y.reverse()

    ans = x + y

    print("Possible")
    for ansi in ans:
        print(ansi + 1)
    print(max_idx + 1)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *
import numpy as np


N, L = MAP()
a = LIST()

for i in range(1, N):
	if L <= a[i] + a[i-1]:
		idx = i
		break
else:
	print("Impossible")
	exit()

print("Possible")

for i in range(1, idx):
	print(i)

for i in range(N-1, idx-1, -1):
	print(i)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *
import numpy as np


N, L = MAP()
a = LIST()

for i in range(1, N):
	if L <= a[i]+a[i-1]:
		idx = i
		break
else:
	print("Impossible")
	exit()

print("Possible")
ans = list(range(1, idx)) + list(range(N-1, idx, -1)) + [idx]
print(*ans, sep="\n")

Solution (Python):
N, M = map(int, input().split())
L = list(map(int, input().split()))

count = 0
vouch = 0
A = []

for i in range (0, N-1):
	if count == 0:
		if L[i]+L[i+1] >= M:
			count=1
			A.append(N-1)
		else:
			A.append(i+1)
	else:
		A.append(N-2-vouch)
		vouch+=1

if count == 0:
	print('Impossible')
	exit()
else:
	print('Possible')
    
for i in range (0, N-1):
	print(A[i])

Solution (Python):
N,L = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
cmax = 0
ind = -1
for i in range(1,N):
    if A[i]+A[i+1]>cmax:
        cmax = A[i]+A[i+1]
        ind = i
if cmax>=L:
    print("Possible")
    for i in range(1,ind):
        print(i)
    for i in range(N-1,ind-1,-1):
        print(i)
else:
    print("Impossible")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, L = mapint()
As = list(mapint())

procces = []
for i in range(1, N):
    double = As[i-1]+As[i]
    if double>=L:
        last = i
        print('Possible')
        break
else:
    print('Impossible')
    exit()
for i in range(1, last):
    print(i)
for i in range(N-1, last-1, -1):
    print(i)

Solution (Python):
n,l = map(int, input().split())
a = list(map(int, input().split()))

for i in range(0,n-1):
    if a[i] + a[i+1] >= l:
        print('Possible')
        for j in range(1,i+1):
            print(j)
        for j in range(n-1,i,-1):
            print(j)
        break
else:
    print('Impossible')

Solution (Python):
from collections import deque
def solve():
  ans = ['Possible']
  N, L = map(int, input().split())
  A = list(map(int, input().split()))
  for i in range(N-1):
    if A[i]+A[i+1]>=L:
      ind = i
      break
  else:
    return ['Impossible']
  for i in range(1,ind+1):
    ans.append(i)
  for i in range(N-1,ind+1,-1):
    ans.append(i)
  ans.append(ind+1)
  return ans
print(*solve(),sep='\n')

Solution (Python):
import sys
n,x=map(int,input().split())
a=list(map(int,input().split()))
k=-1
for i in range(n-1):
  if a[i]+a[i+1]>=x:
    k=i
    break
  if i==n-2:
    print('Impossible')
    sys.exit()
print('Possible')
for i in range(k):
  print(i+1)
for i in range(n-2,k,-1):
  print(i+1)
print(k+1)

Solution (Python):
N, L = map(int, input().split())
A = list(map(int, input().split()))

start = -1
for i in range(N-1):
    if A[i] + A[i + 1] >= L:
        start = i
if start < 0:
    print("Impossible")
    exit()

ans = [start + 1]
for i in range(start + 1, N - 1):
    ans.append(i+1)
for i in reversed(range(start)):
    ans.append(i+1)

ans.reverse()
print("Possible")
print(*ans, sep="\n")

Solution (Python):
import sys
input = sys.stdin.readline
N, L = map(int, input().split())
a = list(map(int, input().split()))
res = []
for i in range(N - 1):
  if a[i] + a[i + 1] >= L:
    res.append(i)
    break
else:
  print("Impossible")
  exit(0)
for i in range(res[0] - 1, -1, -1): res.append(i)
for i in range(res[0] + 1, N - 1): res.append(i)
res.reverse()
print("Possible")
for r in res: print(r + 1)

Solution (Python):
N,L = map(int, input().split())
A=list(map(int, input().split()))
choose = -1
for i in range(1, N):
    if A[i - 1] + A[i] >= L:
        choose = i - 1
        break
if choose == -1:
    print('Impossible')
else:
    print('Possible')
    for i in range(0, choose):
        print(i + 1)
    for i in range(N - 1, choose + 1, -1):
        print(i)
    print(choose + 1)

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))
f=-1
for i in range(n-1):
	if a[i]+a[i+1]>=l:
		f=i
		break
if f==-1:
	print("Impossible")
	exit()
print("Possible")
for i in range(n-1):
	if i<f:
		print(i+1)
	elif i>f:
		print(n-i+f)
print(f+1)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, L = map(int, input().split())
    A = list(map(int, input().split()))

    init = -1
    for i in range(1, n):
        if A[i] + A[i - 1] >= L:
            init = i
            break
    else:
        print("Impossible")
        exit()
    res = []
    for i in range(1, init):
        res.append(i)

    for i in reversed(range(init + 1, n)):
        res.append(i)
    res.append(init)
    print("Possible")
    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()

Solution (Python):
n,l,*a=map(int,open(0).read().split())
i=0
for a,b in zip(a,a[1:]):i+=1;a+b>=l>exit(print('Possible',*range(1,i),*range(n-1,i-1,-1)))
print('Impossible')

Solution (Python):
n,l,*a=map(int,open(i:=0).read().split())
for a,b in zip(a,a[1:]):i+=1;a+b>=l>exit(print('Possible',*range(1,i),*range(n-1,i-1,-1)))
print('Impossible')

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))
ok=False
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        ok=True
        idx=i
if ok:
    print("Possible")
    for i in range(1,idx+1):
        print(i)
    for i in reversed(range(idx+2,n)):
        print(i)
    print(idx+1)
else:
    print("Impossible")

Solution (Python):
import sys
input=sys.stdin.readline

n,l=map(int,input().split())
a=list(map(int,input().split()))

x=-1
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        x=i
        break

if x==-1:
    print('Impossible')
else:
    print('Possible')
    for i in range(x):
        print(i+1)
    for i in range(n-2,x,-1):
        print(i+1)
    print(x+1)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, l = map(int, readline().split())
    a = list(map(int, readline().split()))
    b = [a[i] + a[i + 1] for i in range(n - 1)]

    last = -1
    for i, x in enumerate(b, 1):
        if x >= l:
            last = i
            break

    if last == -1:
        print("Impossible")
    else:
        print("Possible")
        for i in range(1, last):
            print(i)
        for i in range(n - 1, last, -1):
            print(i)
        print(last)


if __name__ == '__main__':
    main()

Solution (Python):
n, l = map(int, input().split())
a = list(map(int, input().split()))
ans = float("inf")
for i in range(n - 1):
    if a[i] + a[i + 1] >= l:
        ans = i + 1
if ans == float("inf"):
    print("Impossible")
else:
    print("Possible")
    print(*range(1, ans), sep="\n")
    print(*range(n - 1, ans, -1), sep="\n")
    print(ans)

Solution (Python):
import sys

N, L = map(int, input().split())
a = list(map(int, input().split()))

for i in range(N-1):
    if(a[i]+a[i+1] >= L):
        idx = i
        break
else:
    print("Impossible")
    sys.exit()
    
print("Possible")

for i in range(1, i+1):
    print(i)
    
for i in range(N-1, i, -1):
    print(i)

Solution (Python):



n, l = map(int, input().split())
a = list(map(int, input().split()))
idx = 0
for i in range(1, n):
    if a[i - 1] + a[i] >= l:
        idx = i
        break
if idx == 0:
    print("Impossible")
    exit()

print("Possible")

ans = [idx]
for i in range(idx - 1, 0, -1):
    ans.append(i)
for i in range(idx + 1, n):
    ans.append(i)
for a in ans[::-1]:
    print(a)

Solution (Python):
import bisect
import copy
import heapq
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(5000000)
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,l=map(int,input().split())
a=list(map(int,input().split()))
I,P="Impossible","Possible"

for i in range(n-1):
    if a[i]+a[i+1]>=l:
        print(P)
        for j in range(i):
            print(j+1)
        for j in range(i+1,n)[::-1]:
            print(j)
        break
else:
    print(I)

Solution (Python):
N, L = map(int, input().split())
a = list(map(int, input().split()))

idx = -1
for i in range(N - 1):
  if a[i] + a[i + 1] >= L:
    idx = i
    break

if idx == -1:
  print("Impossible")
else:
  print("Possible")
  for i in range(idx):
    print(i + 1)
  for i in range(N - 1, idx, -1):
    print(i)

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))
lastmusubi=-1
tmp=0
for i in range(n-1):
  if a[i]+a[i+1]>tmp:
    lastmusubi=i
    tmp=a[i]+a[i+1]
if tmp>=l:
  print('Possible')
  if lastmusubi>0:
    for j in range(lastmusubi):
      print(j+1)
  if lastmusubi<n-1:
    for j in range(n-2,lastmusubi,-1):
      print(j+1)
  print(lastmusubi+1)
else:
  print('Impossible')

Solution (Python):
from collections import deque
n, l = map(int, input().split())
a = list(map(int, input().split()))
last = -1
for i in range(1,n):
    if a[i-1] + a[i] >= l :
        last = i
if last == -1:
    print("Impossible")
else:
    print("Possible")
    for i in range(1, last):
        print(i)
    for i in range(n-1,last,-1):
        print(i)
    print(last)

Solution (Python):
n,l = map(int, input().split())
As = list(map(int, input().split()))

ss = [As[i]+As[i+1] for i in range(n-1)]

cnt = 0
for i,s in enumerate(ss):
    if s >= l:
        cnt = i + 1
if cnt == 0:
    print("Impossible")
    exit()
print("Possible")
for i in range(1,cnt):
    print(i)
for i in range(n-1, cnt, -1):
    print(i)
print(cnt)

Solution (Python):
import sys
readline = sys.stdin.readline

N,L = map(int,readline().split())
A = list(map(int,readline().split()))


target = -1
for i in range(1,len(A)):
  if A[i] + A[i - 1] >= L:
    target = i
    break
if target == -1:
  print("Impossible")
  exit(0)

left = []
for i in range(1,target):
  left.append(i)
  
right = []
for i in range(len(A) - 1,target,-1):
  right.append(i)

print("Possible")
for l in left:
  print(l)
for r in right:
  print(r)
print(target)

Solution (Python):

import sys
def main(N, L, A):
    for i in range(N - 1):
        if A[i] + A[i + 1] >= L:
            break
    else:
        print('Impossible')
        return
    print('Possible')
    for j in range(N - 1):
        if j == i:
            break
        print(j + 1)
    for j in range(N - 2, -1, -1):
        if j == i:
            break
        print(j + 1)
    print(i + 1)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, L = map(int, input().split())
    *A, = map(int, input().split())
    main(N, L, A)

Solution (Python):
n, l = map(int, input().split())
a = list(map(int, input().split()))
ind = -1
for i in range(n-1):
    if a[i]+a[i+1] >= l:
        ind = i
        break

if ind == -1:
    print("Impossible")
else:
    print("Possible")
    for i in range(ind):
        print(i+1)
    for i in range(n-1, ind, -1):
        print(i)

Solution (Python):
import sys
import os

N, L, *A = map(int, os.read(0, 10**8).split())

def main(L, A):
    N = len(A)
    is_long = [x + y >= L for x, y in zip(A, A[1:])]
    if not any(is_long):
        print('Impossible')
        return
    print('Possible')
    i = is_long.index(True)
    nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))
    print(*nums, sep='\n')

main(L, A)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, L = MAP()
a = LIST()

for i in range(N-1):
    if a[i]+a[i+1] >= L:
        idx = i
        break
else:
    print("Impossible")
    exit()

print("Possible")

for i in range(1, i+1):
    print(i)

for i in range(N-1, i, -1):
    print(i)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, L, *A = map(int, read().split())

def main(L, A):
    N = len(A)
    is_long = [x + y >= L for x, y in zip(A, A[1:])]
    if not any(is_long):
        print('Impossible')
        return
    print('Possible')
    i = is_long.index(True)
    nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))
    print(*nums, sep='\n')

main(L, A)

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,l=mp()
a=lmp()
c=True
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        c=False
        ind=i
        break
if c:
    print("Impossible")
    exit()
print("Possible")
for i in range(1,ind+1):
    print(i)
for i in range(n-1,ind+1,-1):
    print(i)
print(ind+1)

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,l = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    pa = a[0]
    mi = -1
    for i,ai in enumerate(a[1::]):
        if pa+ai >= l:
            print("Possible")
            mi = i
            break
        pa = ai
    if mi == -1:
        print("Impossible")
        exit()
    for i in range(mi):
        print(i+1)
    for i in range(n-mi-1):
        print(n-i-1)

    return

if __name__ == '__main__':
    main()

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))

flag=0
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        flag=1
        break

if flag==0:
    print("Impossible")
else:
    print("Possible")
    if i>0:
        for j in range(1,i+1):
            print(j)
    if i+2<n:
        tmp=[]
        for j in range(i+2,n):
            tmp.append(j)
        for item in tmp[::-1]:
            print(item)
    print(i+1)

Solution (Python):
N, L = map(int, input().split())
A = [int(i) for i in input().split()]

for i in range(1, N):
    if A[i-1]+A[i] >= L:
        print('Possible')
        ans = []
        for j in range(1, i):
            ans.append(j)
        for k in range(N-1, i, -1):
            ans.append(k)
        ans.append(i)
        print(*ans, sep='\n')
        exit()
print('Impossible')

Solution (Python):
N,L = map(int,input().split())
A = list(map(int,input().split()))

flg = 0
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        last = i
        flg = 1
        break

if flg == 0:
    print('Impossible')
else:
    print('Possible')
    last += 1
    
    x = list(range(N-1,last,-1))
    y = list(range(1,last))
    for a in x:
        print(a)
    for a in y:
        print(a)

    print(last)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,l = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n-1):
    if a[i]+a[i+1]>=l:
        ans = ["Possible"]
        ans += [j for j in range(1,i+1)]
        ans += [j for j in range(n-1, i+1, -1)]
        ans.append(i+1)
        break
else:
    ans = ["Impossible"]
write("\n".join(map(str, ans)))

Solution (Python):
n,l=map(int, input().split())
*a,=map(int, input().split())
mx=0
ind=-1
for i in range(n-1):
    if mx<=a[i+1]+a[i]:
        ind=i
        mx=a[i+1]+a[i]
if mx>=l:
    print("Possible")
    for i in range(ind):
        print(i+1)
    for i in range(n-1,ind,-1):
        print(i)
else:
    print("Impossible")

Solution (Python):
N,L=map(int, input().split())
A=list(map(int, input().split()))
x=0
for i in range(N-1):
  d=A[i]+A[i+1]
  if d>=L:
    x=1
    knot=i+1
    break
    
if x==0:
  print('Impossible')
  exit()

print('Possible')
for i in range(1,knot):
  print(i)
for i in range(N-1,knot-1,-1):
  print(i)

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))
failflag=1
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    failflag=0
    k=i
    break
if failflag==1:
  print('Impossible')
else:
  print('Possible')
  for i in range(1,k+1):
    print(i)
  for i in range(n-1-k):
    print(n-1-i)

Solution (Python):
def main():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    f = False
    idx = -1
    for i in range(n-1):
        if a[i] + a[i+1] >= l:
            f = True
            idx = i+1
            break
    if f:
        print("Possible")
        for i in range(1, idx):
            print(i)
        for i in reversed(range(idx+1, n)):
            print(i)
        print(idx)
    else:
        print("Impossible")

if __name__ == "__main__":
    main()

Solution (Python):
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n,l=NM()
a=[0]+L()
for i in range(1,n):
    if a[i]+a[i+1]>=l:
        print("Possible")
        for j in range(1,i):
            print(j)
        for j in range(n-1,i-1,-1):
            print(j)
        break
else:
    print("Impossible")

Solution (Python):
K=10**10
import sys
N,L=map(int,input().split())
T=list(map(int,input().split()))
for i in range(N-1):
  if T[i]+T[i+1]>=L:
    K=i
    print("Possible")
    break
if K==10**10:
  print("Impossible")
  sys.exit()
K=K+1
R=list(range(1,K))
M=list(range(K+1,N))
M.reverse()
R.extend(M)
R.append(K)
for i in range(N-1):
  print(R[i])