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 = map(int, raw_input().split())
a = map(int, raw_input().split())
b = [a[i]+a[i+1] for i in xrange(N-1)]
maxb = max(b)
maxbi = b.index(maxb)
if maxb < L:
    print 'Impossible'
    exit()
print 'Possible'
for i in xrange(maxbi):
    print i+1
for i in xrange(N-2, maxbi, -1):
    print i+1
print maxbi+1

Solution (Python):
n,l=map(int,raw_input().split())
a=map(int,raw_input().split())
ans=[]
f=-1
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        f=i
        break
if f==-1:
    print 'Impossible'
else:
    print 'Possible'
    for i in range(f):
        print i+1
    for i in range(n-1,f,-1):
        print i

Solution (Python):


def main():
    N, L = map(int, input().split())
    A = list(map(int, input().split()))
    la = N
    for i in range(N-1):
        if A[i] + A[i+1] >= L:
            la = i
            break
    if la == N:
        print('Impossible')
        return
    print('Possible')
    for i in range(la) : print(i+1)
    for i in range(N-la-2) : print(N-i-1)
    print(la+1)
if __name__ == '__main__':
    main()

Solution (Python):
import sys

N, L = map(int, sys.stdin.readline().split())
As = map(int, sys.stdin.readline().split())

tot = sum(As)

res = []

a = 0
b = N-1
for _ in range(N-1):
    if tot < L:
        print "Impossible"
        sys.exit()

    na = As[a] + As[a+1]
    nb = As[b] + As[b-1]

    if na < nb:
        
        tot -= As[a]
        res.append(a)
        a += 1
    else:
        
        tot -= As[b]
        res.append(b-1)
        b -= 1

print "Possible"
for a in res:
    print a+1

Solution (Python):



from __future__ import division, print_function, absolute_import, unicode_literals

def main():
    N, L = list(map(int, input().split()))
    a = list(map(int, input().split()))
    pair_L = []
    for car, cdr in zip(a[:-1], a[1:]):
        pair_L.append(car + cdr)
    maximum = max(pair_L)
    
    if maximum < L:
        print("Impossible")
    else:
        print("Possible")
        index = pair_L.index(maximum) + 1
        i = 1
        while i < index:
            print(i)
            i += 1
        i = N - 1
        while i > index:
            print(i)
            i -= 1
        print(index)

if __name__ == "__main__":
    main()

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

t = 0
m = 0
for k in range(len(a)-1):
    if a[k]+a[k+1]>=L:
        t = 1
        m = k+1
        break
if t == 0:
    print("Impossible")
    exit()
else:
    print("Possible")
    for k in range(1,m):
        print(k)
    for l in range(len(a)-(k+2)):
        print(len(a)-l-1)
    print(m)

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

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

if loc < 0:
    print("Impossible")
    exit()

print("Possible")

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

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

i = 0
untied  = False
while i < (len(a)-1):
    if a[i] + a[i+1] >= l:
        
        untied = True
        break
    i += 1
if untied == False:
    print "Impossible"
    exit()
print "Possible"
for k in xrange(n-1, i+1, -1):
    print k
for k in xrange(1, i+2):
    print k

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

Solution (Python):
N,L=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
possible=0
for i in range(N-1):
    if(a[i]+a[i+1] >= L):
        print("Possible")
        possible=i+1
        break
if(possible):
    for i in range(1,possible):
        print(i)
    for i in range(N-possible-1):
        print(N-i-1)
    print(possible)
else:
    print("Impossible")

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

a = [0]*N

inputStr = input().split()
for i in range(N):
    a[i] = int(inputStr[i])

def check():
    for i in range(N-1):
        if(a[i]+a[i+1]>=L):
            return i
    return -1

b = check()

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

Solution (Python):
n, s = map(int, raw_input().split())
values = list(map(int, raw_input().split()))
found = False
for pos in range(n - 1):
    if values[pos] + values[pos + 1] >= s:
        found = True
        break
if not found:
    print('Impossible')
    import sys
    sys.exit()
    
result = (n - 1) * [ None ]
result[n - 2] = pos + 1
ix = n - 3
for i in range(pos - 1, -1, -1):
    result[ix] = i + 1
    ix -= 1
for i in range(pos + 1, n - 1):
    result[ix] = i + 1
    ix -= 1
print('Possible')
print('\n'.join(map(str, result)))

Solution (Python):

import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, L = map(int, raw_input().split())
a = map(int, raw_input().split())
b = [0]*(N - 1)
for i in xrange(N - 1):
    b[i] = a[i] + a[i + 1]

mx, idx = 0, 0
for i, bi in enumerate(b):
    if bi > mx:
        mx = bi
        idx = i

if mx >= L:
    print "Possible"
    for i in xrange(idx):
        print i + 1
    for i in xrange(N - 1, idx, -1):
        print i
else:
    print "Impossible"

Solution (Python):

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

N, L = ln()

A = ln()

candidate = -1

for i in xrange(N - 1):
    if A[i] + A[i + 1] >= L:
        candidate = i

if candidate != -1:
    print 'Possible'
    for i in xrange(candidate):
        print i + 1
    for i in xrange(N - 1, candidate, -1):
        print i
else:
    print 'Impossible'

Solution (Python):



def solve():
    N,L = map(int,input().split())
    As = list(map(int,input().split()))
    for i in range(N-1):
        if As[i] + As[i+1] >= L:
            print("Possible")
            keep = i + 1
            for n in range(1,keep):
                print(n)
            for n in range(N-1, keep, -1):
                print(n)
            print(keep)
            return
    print("Impossible")
        
solve()

Solution (Python):
from sys import stdin, stdout
from itertools import repeat
def main():
    n, l = map(int, stdin.readline().split())
    a = map(int, stdin.read().split(), repeat(10, n))
    for i in xrange(n - 1):
	if a[i] + a[i+1] >= l:
            ans = range(1, i + 1) + range(n - 1, i + 1, -1) + [i + 1]
            stdout.write('Possible\n')
            stdout.write('\n'.join(map(str, ans)))
            stdout.write('\n')
            return
    print "Impossible"
main()

Solution (Python):



yes = "Possible"
no = "Impossible"

N, L = map(int, input().split())
a = [0] + list(map(int, input().split()))

c = 0
Mi = -1
for i in range(1, N):
	if c < a[i] + a[i+1]:
		c = max(c, a[i] + a[i+1])
		Mi = i

if c < L:
	print(no)
else:
	print(yes)
	for i in range(1, N):
		if i != Mi:
			print(i)
		else:
			break
	for i in reversed(range(1, N)):
		if i != Mi:
			print(i)
		else:
			break
	print(Mi)

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

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(1,f+1,1):
    print(i)
for i in range(n-1,f,-1):
    print(i)

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


def find():
    for i in range(N-1):
        if A[i]+A[i+1] >=L:
            return i
    return False

n=find()
if n is False:
    print('Impossible')
    exit(0)

n+=1
print('Possible')
for i in range(1,n):
    print(i)
for i in range(N-1,n,-1):
    print(i)
print(n)