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):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,L=map(int,input().split())
    a=tuple(map(int,input().split()))
    for i in range(N-1):
        if a[i]+a[i+1]>=L:
            print('Possible')
            for j in range(i):
                print(j+1)
            for j in range(N-2,i,-1):
                print(j+1)
            print(i+1)
            break
    else:
        print('Impossible')

if __name__ == '__main__':
    main()

Solution (Python):
N, L = map(int, input().split())
A = list(map(int, input().split()))
l = max_2 = A[0] + A[1]
idx = 0
for i in range(N-2):
  l += A[i+2] - A[i]
  if l > max_2:
    max_2 = l
    idx = i + 1

if max_2 < L:
  print('Impossible')
else:
  print('Possible')
  for i in range(1, idx + 1):
    print(i)
  for i in range(N-1, idx, -1):
    print(i)

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

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

Solution (Python):
n,l=[int(x) for x in input().split()]

a=[int(x) for x in input().split()]

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

Solution (Python):






import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


def lcm(a, b):
    return a * b // gcd (a, b)





N,L = inputIL()
A = inputIL()



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

  elif index == N-1:
    if A[N-1]+A[N-2] >= L:
      print("Possible")
      for i in range(N-1):
        print(i+1)
      exit()      

  else:
    if A[index]+A[index-1] >= L:
      print("Possible")
      for i in range(index,N-1)[::-1]:
        print(i+1)
      for i in range(index):
        print(i+1)
      exit()
    elif A[index]+A[index+1] >= L:
      print("Possible")
      for i in range(index):
        print(i+1)
      for i in range(index,N-1)[::-1]:
        print(i+1)
      exit()

print("Impossible")

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

ans = False
for i in range(N-1):
    if a[i] + a[i+1] >= L:
        ans = True
        break
if ans:
    print('Possible')
    for j in range(i):
        print(j+1)
    for j in range(N-2, i-1, -1):
        print(j+1)
else:
    print('Impossible')

Solution (Python):
n,l=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
flag=False
for i in range(0,n-1):
    if not flag:
        if a[i]+a[i+1]>=l:
            cnt=i+1
            flag=True

if not flag:
    print("Impossible")
    exit()

ans=[cnt]

for i in range(cnt-1,0,-1):
    ans.append(i)
for i in range(cnt+1,n):
    ans.append(i)
ans=ans[::-1]
print("Possible")
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
INF = 10 ** 15
MOD = 10 ** 9 + 7 
def main():
    N,L = map(int,input().split())
    A = list(map(int,input().split()))
    point = -1
    for i in range(N - 1):
        if A[i] + A[i + 1] >= L:
            point = i + 1
            break
    if point == - 1:
        print('Impossible')
        return
    ans = []
    for i in range(point - 1):
        ans.append(i + 1)
    for i in range(N - 2,point - 1,-1):
        ans.append(i + 1)
    ans.append(point)
    print('Possible')
    print('\n'.join(map(str,ans)))
if __name__ == '__main__':
    main()

Solution (Python):
import sys

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

for i in range(N-1):
    if A[i] + A[i+1] >= L:
        print("Possible")
        for j in range(1, i+1):
            print(j)
        for j in range(i+1, N)[::-1]:
            print(j)
        sys.exit()

print("Impossible")

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

max_i = 0
max_two_ropes = 0
for i in range(n - 1):
    two_ropes = aaa[i] + aaa[i + 1]
    if max_two_ropes < two_ropes:
        max_i = i
        max_two_ropes = two_ropes

if max_two_ropes < l:
    print('Impossible')
else:
    print('Possible')
    ans = list(range(1, max_i + 1))
    ans.extend(range(n - 1, max_i + 1, -1))
    ans.append(max_i + 1)
    print('\n'.join(map(str, ans)))

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007



def main():
	
	n , l = IN()
	
	al = LIN()
	for i in range(len(al)-1):
		if al[i]+al[i+1] >= l:
			break
	else:
		print('Impossible')
		return 
	print('Possible')
	last_tie = i + 1
	pa(('lt',last_tie))
	for i in range(1, last_tie):
		print(i)
	for i in range(n-1, last_tie, -1):
		print(i)
	print(last_tie)
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

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

Solution (Python):
import sys
n, l = map(int, input().split())
a = [int(x) for x in input().split()]

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

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

Solution (Python):
n, l = map(int, input().split())
a = list(map(int, input().split()))
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):
            print(j)
        print(i)
        exit()
print("Impossible")

Solution (Python):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def f(S, T):
    N = len(S)
    F = [[0 for _ in range(N)] for __ in range(N)]
    
    for i in range(N):
        for j in range(N):
            SS = S[i]
            TT = T[j]
            if TT == (0, 0):
                F[i][j] = 1 if SS == (0, 1) else 0
            elif TT == (0, 1):
                if SS == (1, 0):
                    return None
                F[i][j] = 1
            elif TT == (1, 0):
                if SS == (0, 1):
                    return None
                F[i][j] = 0
            else:
                F[i][j] = 0 if SS == (1, 0) else 1

    return F


def main():
    N, L = read_values()
    A = read_list()

    r = 0
    for i in range(N - 1):
        if A[i] + A[i + 1] >= L:
            r = i
            break
    else:
        print("Impossible")
        return

    print("Possible")
    
    for i in range(r):
        print(i + 1)
    for i in range(N - 2, r - 1, -1):
        print(i + 1)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 15
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, l = LI()
A = LI()
ret = 0
j = 0
for i in range(n - 1):
    if A[i] + A[i + 1] > ret:
        ret = A[i] + A[i + 1]
        j = i

if ret >= l:
    print('Possible')
    for k in range(j):
        print(k + 1)
    for m in range(n - 1, j + 1, -1):
        print(m)
    print(j + 1)
else:
    print('Impossible')

Solution (Python):
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):
N,L=map(int,input().split())
a=list(map(int,input().split()))

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

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    n, l = LI()
    a = LI()
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            x = i
    try:
        ans = []
        for j in range(x):
            ans.append(j + 1)
        for j in range(n - 2, x - 1, -1):
            ans.append(j + 1)
        print("Possible")
        print("\n".join(map(str, ans)))
    except:
        print("Impossible")
    return



if __name__ == '__main__':
    solve()

Solution (Python):

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

flg = False
ans = []
for i in range(n-1):
    if a[i] + a[i+1] >= l:
        ans = [j for j in range(1, i+1)] + [j for j in range(n-1, i+1, -1)] + [i+1]
        flg = True
        break
    
if flg:
    print('Possible')
    print(*ans, sep='\n')
else:
    print('Impossible')

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)
        T=[]
        for j in range(i+2,N):
            T.append(j)
        T.sort(reverse=True)
        for j in range(0,len(T)):
            print(T[j])
        print(i+1)
        break
else:
    print('Impossible')

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

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

sumax=0
for i in range(n-1):
    if sumax < a[i]+a[i+1]:
        sumax=a[i]+a[i+1]
        ind=i

if sumax < l:
    print("Impossible")
    exit()

print("Possible")

for i in range(1,n):
    if i>ind:
        break
    print(i)

for i in reversed(range(n)):
    if i==ind:
        break
    print(i)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,L=MI()
    A=LI()
    pos = False
    idx = 0
    for i in range(N-1):
        if A[i]+A[i+1] >= L:
            pos = True
            idx = i
    if pos:
        print("Possible")
        for i in range(N-1):
            if i!=idx:
                print(i+1)
            else:
                break
        for i in range(N-1)[::-1]:
            if i!=idx:
                print(i+1)
            else:
                break
        print(idx+1)
    else:
        print("Impossible")

if __name__ == '__main__':
    main()

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

last = -1
for i,(a,b) in enumerate(zip(A,A[1:])):
    if a+b >= L:
        last = i
        break
if last < 0:
    print('Impossible')
    exit()
print('Possible')

ans = list(range(1,i+1)) + list(range(N-1,i,-1))
print(*ans, sep='\n')

Solution (Python):

from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"




def main():
    a,b,c = mi()
    if c-a-b<=0:
        print(no)
        exit()
    else:
        if (c-a-b)**2 > 4*a*b:
            print(yes)
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "YES"
no = "NO"


def main():
    n,l = mi()
    a = li()

    flag = False
    lp = 0
    for i in range(n-1):
        if a[i]+a[i+1] >= l:
            print("Possible")
            flag = True
            lp = i+1
            break
    
    if not flag:
        print("Impossible")
        exit()

    for i in range(1,lp):
        print(i)
    for i in range(n-1,lp,-1):
        print(i)
    print(lp)
    
    

    


main()

Solution (Python):
n, L, *a = map(int, open(0).read().split())

cant = 0
for i in range(n-1):
    if a[i]+a[i+1]>=L:
        l, r = i, i+1
        break
else: cant = 1

if cant: print("Impossible")
else:
    print("Possible")
    for i in range(l): print(i+1)
    for i in range(n-2, l-1, -1): print(i+1)

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

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

MAX = 0
index = -1

for i in range(N-1):
    if A[i] + A[i+1] > MAX:
        MAX = A[i] + A[i+1]
        index = i+1

if MAX < L:
    print("Impossible")
else:
    print("Possible")
    for i in range(1,index):
        print(i)
    for i in range(N-1,index,-1):
        print(i)
    print(index)

Solution (Python):
import sys

input = sys.stdin.buffer.readline







def main():
	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:
			break
	else:
		print("Impossible")
		exit(0)
	i+=1
	print("Possible")
	for j in range(1,i):
		print(j)

	for j in range(n-1,i-1,-1):
		print(j)




if __name__ == "__main__":
	main()

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

flag = -1
for i in range(n - 1):
    if l <= a[i] + a[i + 1]:
        flag = i + 1
if flag == -1:
    print("Impossible")
    exit()

print("Possible")
for i in range(1, flag):
    print(i)
for i in range(flag + 1, n)[::-1]:
    print(i)
print(flag)

Solution (Python):
def examA():
    a, b = LI()
    if b<a:
        a,b = b,a
    if a<=0 and 0<=b:
        print("Zero")
    elif 0<a:
        print("Positive")
    else:
        judge = b-a+1
        if judge%2==0:
            print("Positive")
        else:
            print("Negative")
    return

def examB():
    N, M = LI()
    flag_R = [False]*N
    cnt = [1]*N
    flag_R[0] = True
    for _ in range(M):
        x, y = LI()
        x -= 1; y -= 1
        if flag_R[x]:
            flag_R[y] = True
        cnt[y] += 1
        cnt[x] -= 1
        if cnt[x]==0:
            flag_R[x] = False
    ans = sum(flag_R)
    print(ans)
    return

def examC():
    N, L = LI()
    A = LI()
    can = set()

    if N==2:
        if sum(A)<L:
            print("Impossible")
            return

    l = inf
    for i in range(N-1):
        cur_R = A[i]+A[i+1]
        if cur_R>=L:
            l = min(l,i)
            can.add(i)
    if not can:
        print("Impossible")
        return
    print("Possible")
    ans = []

    for i in range(l):
        ans.append(i+1)
    for i in range(l,N-1)[::-1]:
        if i in can:
            continue
        ans.append(i+1)
    for i in can:
        ans.append(i+1)
    for v in ans:
        print(v)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examC()

"""

"""

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, L = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    last = -1
    for i in range(N-1):
        if L <= A[i] + A[i+1]:
            last = i+1
    if last < 0:
        return print("Impossible")
    ans = [i for i in range(1, last)] + \
        [i for i in range(last+1, N)][::-1] + [last]
    print("Possible")
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, L = map(int, input().split())
    A = [int(a) for a in input().split()]
    for i in range(N - 1):
        if A[i] + A[i+1] >= L:
            print("Possible")
            for k in range(i): print(k + 1)
            for k in reversed(range(i + 1, N - 1)): print(k + 1)
            print(i + 1)
            break
    else: print("Impossible")

    return 0

if __name__ == "__main__":
    solve()

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

last = -1
for i,(a,b) in enumerate(zip(A,A[1:])):
    if a+b >= L:
        last = i+1
        break
else:
    print('Impossible')
    exit()

print('Possible')
ans = [n for n in range(1,last)] + [n for n in range(N-1,last,-1)]
ans.append(last)
print(*ans, sep='\n')

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, L, *a = map(int, read().split())
knot = -1
for idx, (i, j) in enumerate(zip(a, a[1:])):
    if i + j >= L:
        knot = idx + 1
        print('Possible')
        break
else:
    print('Impossible')
    exit()

answer = list(range(1, knot)) + list(range(knot + 1, N))[::-1] + [knot]
print('\n'.join(map(str, answer)))

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

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')
        for j in range(1, i+1):
            print(j)
        for j in range(i+1, N)[::-1]:
            print(j)
        exit()
print('Impossible')

Solution (Python):



n,l = [int(i) for i in input().split()]
a   = [int(i) for i in input().split()]

maxsum=0
maxind = 0
for i in range(n-1):
    s = a[i]+a[i+1]
    if s > maxsum:
        maxsum = s
        maxind = i+1

if maxsum<l:
    print("Impossible")
else:
    print("Possible")
    for i in range(1,maxind):
        print(i)
    for i in range(n-1,maxind,-1):
        print(i)
    print(maxind)

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

untiable = False
lastknot = None

for i in range(N-1):
    if A[i]+A[i+1] >= L:
        untiable = True
        lastknot = i+1
        break

if untiable:
    ans = [i for i in range(1,lastknot)] + [i for i in range(lastknot+1,N)[::-1]] + [lastknot]
    print('Possible')
    print('\n'.join(map(str,ans)))
    
else:
    print('Impossible')

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



N,L = LI()
a = LI()

for i in range(N-1):
    if a[i]+a[i+1] >= L:
        print('Possible')
        for j in range(1,i+1):
            print(j)
        for j in range(i+2,N)[::-1]:
            print(j)
        print(i+1)
        exit()
    else:
        continue

print('Impossible')

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

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    use = -1
    for i in range(N-1):
        if a[i]+a[i+1] >= M:
            use = i
            break
    
    if use == -1:
        print("Impossible")
    else:
        print("Possible")
        for j in range(i):
            print(j+1)
        for j in range(N-1,i,-1):
            print(j)

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N, L, *A = map(int, open(0).read().split())
    L = [i for i,(x,y) in enumerate(zip(A, A[1:]), 1) if x+y >= L]
    if L:
        print("Possible")
        B = [i for i in range(L[0], N)]+[i for i in range(1,L[0])][::-1]
        print(*B[::-1], sep="\n")
    else:
        print("Impossible")


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,l = inm()
a = inl()
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        print('Possible')
        for j in range(i):
            print(j+1)
        for j in range(n-2,i-1,-1):
            print(j+1)
        exit()
print('Impossible')

Solution (Python):

N,L=map(int,input().split())
lists=list(map(int,input().split()))
flag=False
J=0
for i in range(N-1):
    if lists[i]+lists[i+1]>=L:
        J=i+1
        flag=True
        break
if not flag:
    print("Impossible")
if flag:
    print("Possible")
    for i in range(100001,0,-1):
      if 1<=J-i<=N-1:
        print(J-i)
      if 1<=J+i<=N-1:
        print(J+i)
    print(J)

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

l = 0
r = N-1
s = sum(A)
ans = []
while l < r:
    if s < L:
        break
    if r-l > 1:
        if A[l]+A[l+1] < L:
            s -= A[l]
            ans.append(l+1)
            l += 1
            continue
        if A[r]+A[r-1] < L:
            s -= A[r]
            ans.append(r)
            r -= 1
            continue
    if A[l] < A[r]:
        ans.append(l+1)
        s -= A[l]
        l += 1
    else:
        ans.append(r)
        s -= A[r]
        r -= 1
        
if len(ans) == N-1:
    print("Possible")
    for a in ans:
        print(a)
else:
    print("Impossible")

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
INF = 10**10
def bfs(graph, visited, position, root):
    visited[root] = 1
    position[root] = 0
    deq = deque([root])
    while(deq):
        cur = deq.pop()
        
        for nxt, dist in graph[cur]:
            if position[cur] + dist != position[nxt]:
                if position[nxt] != INF:
                    return False
                else:
                    position[nxt] = position[cur] + dist
            if not visited[nxt]:
                deq.append(nxt)
                visited[nxt] = 1

    return True

def main():
    n, l = getList()
    nums = getList()
    flag = False
    for i in range(n - 1):
        if nums[i] + nums[i + 1] >= l:
            flag = True
            index = 1 + i
            break

    if not flag:
        print("Impossible")
        return

    else:
        print("Possible")
        for i in range(1, index):
            print(i)
        for i in range(n-1, index, -1):
            print(i)
            
        print(index)
if __name__ == "__main__":

    main()

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

    ma = 0
    idx = -1
    for i in range(N-1):
        if ma < A[i] + A[i+1]:
            ma = A[i] + A[i+1]
            idx = i+1
    if ma < L:
        return print("Impossible")
    print("Possible")
    for i in range(1, idx):
        print(i)
    for i in range(idx, N)[::-1]:
        print(i)


if __name__ == '__main__':
    main()