Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from heapq import *

class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)

n,m = map(int,input().split())
a = list(map(int,input().split()))
uf = UnionFind(n)
ans = 0
for i in range(m):
    x,y = map(int,input().split())
    uf.unite(x, y)
if n < 2*(n-m-1):
    print('Impossible')
    exit(0)
if m == n-1:
    print(0)
    exit(0)
tree = {}
pq = []
heapify(pq)
for i in range(n):
    p = uf.find(i)
    if not p in tree.keys():
        ans += a[i]
        tree[p] = a[i]
    else:
        if tree[p] <= a[i]:
            heappush(pq, a[i])
        else:
            ans += a[i] - tree[p]
            tree[p] = a[i]
            heappush(pq, tree[p])
l = len(tree)

for _ in range(2*(n-m-1) - l):
    ans += heappush(pq)
print(ans)


Fixed submission:
from heapq import *

class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)

n,m = map(int,input().split())
a = list(map(int,input().split()))
uf = UnionFind(n)
ans = 0
for i in range(m):
    x,y = map(int,input().split())
    uf.unite(x, y)
if n < 2*(n-m-1):
    print('Impossible')
    exit(0)
if m == n-1:
    print(0)
    exit(0)
tree = {}
pq = []
heapify(pq)
for i in range(n):
    p = uf.find(i)
    if not p in tree.keys():
        ans += a[i]
        tree[p] = a[i]
    else:
        if tree[p] <= a[i]:
            heappush(pq, a[i])
        else:
            ans += a[i] - tree[p]
            heappush(pq, tree[p])
            tree[p] = a[i]
l = len(tree)

for _ in range(2*(n-m-1) - l):
    ans += heappop(pq)
print(ans)
Buggy python submission (verdict: Runtime Error):
ab = int(''.join(input().split()))
if ab**0.5.is_intejer():
  print('Yes')
else:
  print('No')


Fixed submission:
ab = int(''.join(input().split()))
if (ab**0.5).is_integer():
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
T = list(map(int,input().split()))
V = list(map(int,input().split()))

dp = [[-1]*102 for _ in range(sum(T) + 1)]
dp[0][0] = 0

nt = 0
pt = T[0]
# i 秒から i+1 秒へ配る
delta = [-1,0,1]
for i in range(sum(T)):
    if pt == i:
        nt += 1
        pt += T[nt]
    for j in range(101):
        if j > V[nt] or dp[i][j] == -1:break
        for d in delta:
            nj = j + d
            if 0 <= nj <= V[nt]:
                if d != 0 or j == V[nt]:
                    dp[i+1][nj] = max(dp[i+1][nj], dp[i][j] + (j+nj)/2)
                else :
                    dp[i+1][nj] = max(dp[i+1][nj], dp[i][j] + j + 0.25)

print(dp[-1][0])


Fixed submission:
n = int(input())
T = list(map(int,input().split()))
V = list(map(int,input().split()))

dp = [[-1]*102 for _ in range(sum(T) + 1)]
dp[0][0] = 0

nt = 0
pt = T[0]
# i 秒から i+1 秒へ配る
delta = [-1,0,1]
for i in range(sum(T)):
    if pt == i:
        nt += 1
        pt += T[nt]
    for j in range(101):
        if j > V[nt] or dp[i][j] == -1:break
        for d in delta:
            nj = j + d
            if 0 <= nj <= V[nt]:
                if d != 0 or j == V[nt]:
                    dp[i+1][nj] = max(dp[i+1][nj], dp[i][j] + (j+nj)/2)
                else :
                    dp[i+1][nj] = max(dp[i+1][nj], dp[i][j] + j + 0.25)

print(dp[-1][0])
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input())
if a == b:
  print(c)
elif b == c:
  print(a)
else:
  print(b)

Fixed submission:
a,b,c = map(int,input().split())
if a == b:
  print(c)
elif b == c:
  print(a)
else:
  print(b)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m = map(int,input().split())
path = [[] for _ in range(n)]
ab = [[] for _ in range(m)]
for i in ragne(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  ab[i] = (a,b)
  path[a].append(b)
  path[b].append(a)
def dfs(a,b):
  que = deque()
  reach = [False]*n
  reach[0] = True
  que.append(0)
  while que:
    p = que.pop()
    for i in path[p]:
      if (p,i)!=(a,b)!=(i,p) and not reach[i]:
        p.append(i)
        reach[i] = True
  return reach != [True] * n
ans = 0
for a,b in ab:
  ans += dfs(a,b)
print(ans)


Fixed submission:
from collections import deque
n,m = map(int,input().split())
path = [[] for _ in range(n)]
ab = [[] for _ in range(m)]
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  ab[i] = (a,b)
  path[a].append(b)
  path[b].append(a)
def dfs(a,b):
  que = deque()
  reach = [False]*n
  reach[0] = True
  que.append(0)
  while que:
    p = que.pop()
    for i in path[p]:
      if (p,i)!=(a,b)!=(i,p) and not reach[i]:
        que.append(i)
        reach[i] = True
  return reach != [True] * n
ans = 0
for a,b in ab:
  ans += dfs(a,b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n,k = map(int,input().split())
XY = [list(map(int,input().split())) for _ in range(n)]
ans = 1e100
for l,r in combinations(range(n),2):
  for b,t in combinations(range(n),2):
    left,right = sorted([XY[l][0], XY[r][0]])
    bottom,top = sorted([XY[b][1], XY[t][1]])
    cnt = 0
    for x,y in XY:
      if left <= x <= right and bottom <= y <= top:
        cnt += 1
    if cnt >= k:
      ans = min(ans, (top - bottom)*(right - left))
print(ans)


Fixed submission:
n,k = map(int,input().split())
X = [0]*n
Y = [0]*n
for i in range(n):
    X[i],Y[i] = map(int,input().split())

Xs = sorted(X)
Ys = sorted(Y)
XY = sorted(list(zip(X,Y)))
ans = 1e100
for i in range(n-k+1):
    for j in range(i+k-1,n):
        w = Xs[j] - Xs[i]
        XYs = sorted(XY[i:j+1],key = lambda x:x[1])
        h = 1e100
        for l in range(len(XYs) - k + 1):
            h = min(h, XYs[l + k - 1][1] - XYs[l][1])
        ans = min(ans , h*w)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for h in range(1,3501):
    for n in range(h,3501):
        wd = 4*h*n - n*N - h*N
        wu = N*h*n
        if wd > 0 and wu % wd == 0:
            w = wu // wd
            print(h,n,w)
            exit()


Fixed submission:
N = int(input())

for h in range(1,3501):
    for n in range(h,3501):
        wd = 4*h*n - n*N - h*N
        wu = N*h*n
        if wd > 0 and wu % wd == 0:
            w = wu // wd
            print(h,n,w)
            exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
path = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a].append(b)
    path[b].append(a)
parent = [-1]*n
size = [1]*n
d = [0]*n
def dfs(now):
    for nxt in path[now]:
        if nxt != parent[now]:
            parent[nxt] = now
            d[nxt] = d[now] + 1
            size[now] += dfs(nxt)
    return size[now]
dfs(0)
cnt = 0
now = n-1
for i in range((d[n-1]+1)//2 - 1):
    now = parent[now]
if size[now] >= n - size[now]:
    print('Snuke')
else:
    print('Fennec')


Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
path = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a].append(b)
    path[b].append(a)
parent = [-1]*n
size = [1]*n
d = [0]*n
def dfs(now):
    for nxt in path[now]:
        if nxt != parent[now]:
            parent[nxt] = now
            d[nxt] = d[now] + 1
            size[now] += dfs(nxt)
    return size[now]
dfs(0)
cnt = 0
now = n-1
for i in range((d[n-1]+1)//2 - 1):
    now = parent[now]
if size[now] >= n - size[now]:
    print('Snuke')
else:
    print('Fennec')
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

class BIT:
    def __init__(self,n,default = 0):
        self.s = [default]*(n+1)
    
    def add(self,val,idx):
        while idx < n+1:
            self.s[idx] = self.s[idx] + val
            idx += idx&(-idx)
        return
    
    def get(self,idx):
        res = 0
        while idx > 0:
            res = res + self.s[idx]
            idx -= idx&(-idx)
        return res


n,k = map(int,input().split())
ans = 0
s = [0]*(n+1)
array = {0}
for i in range(n):
    s[i+1] = s[i] + int(input()) - k
    array.add(s[i+1])
array = sorted(array)
d = {x:i for i,x in enumerate(array)}
bit = BIT(len(array))
for t in s:
    ans += bit.get(d[t]+1)
    bit.add(1,d[t]+1)
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

class BIT:
    def __init__(self,n,default = 0):
        self.s = [default]*(n+1)
        self.n = n
    
    def add(self,val,idx):
        while idx < self.n+1:
            self.s[idx] = self.s[idx] + val
            idx += idx&(-idx)
        return
    
    def get(self,idx):
        res = 0
        while idx > 0:
            res = res + self.s[idx]
            idx -= idx&(-idx)
        return res


n,k = map(int,input().split())
ans = 0
s = [0]*(n+1)
array = {0}
for i in range(n):
    s[i+1] = s[i] + int(input()) - k
    array.add(s[i+1])
array = sorted(array)
d = {x:i for i,x in enumerate(array)}
bit = BIT(len(array))
for t in s:
    ans += bit.get(d[t]+1)
    bit.add(1,d[t]+1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
inf = 10**10
parent = [inf]*n
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent[i] = a
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break


Fixed submission:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
inf = 10**10
parent = [inf]*n
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent[i] = a
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
parent = []
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent.append(a)
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break


Fixed submission:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
inf = 10**10
parent = [inf]*n
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent[i] = a
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
parent = []
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent.append(a)
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break


Fixed submission:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
inf = 10**10
parent = [inf]*n
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent[i] = a
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break
Buggy python submission (verdict: Runtime Error):
class BellmanFord:
    def __init__(self,v,start):
        self.inf = float('inf')
        self.dist = [self.inf]*v
        self.dist[start] = 0
        self.edge = []
        self.v = v
    
    def add(self,f,t,cost):
        self.edge.append((f,t,cost))
    
    def build(self,gorl):
        for _ in range(self.v - 1):
            for f,t,cost in self.edge:
                if self.dist[t] > self.dist[f] + cost:
                    self.dist[t] = self.dist[f] + cost
        self.ans = self.dist[gorl]
        for f,t,cost in self.edge:
            if self.dist[t] > self.dist[f] + cost:
                self.dist[t] = self.dist[f] + cost
        return self.ans if self.ans == self.dist[gorl] else '-inf'

n,m = map(int,input().split())

bf = BellmanFord(n,0)

for i in range(m):
    a,b,c = map(int,input().split())
    bf.add(a - 1,b - 1,- c)

ans = bf.build()
if ans == '-inf':
    print('inf')
else:
    print(- ans)


Fixed submission:
class BellmanFord:
    def __init__(self,v,start):
        self.inf = float('inf')
        self.dist = [self.inf]*v
        self.dist[start] = 0
        self.edge = []
        self.v = v
    
    def add(self,f,t,cost):
        self.edge.append((f,t,cost))
    
    def build(self):
        for _ in range(self.v - 1):
            for f,t,cost in self.edge:
                if self.dist[t] > self.dist[f] + cost:
                    self.dist[t] = self.dist[f] + cost
        self.ans = self.dist[n-1]
        for f,t,cost in self.edge:
            if self.dist[t] > self.dist[f] + cost:
                self.dist[t] = self.dist[f] + cost
        return self.ans == self.dist[n-1]

n,m = map(int,input().split())

bf = BellmanFord(n,0)

for i in range(m):
    a,b,c = map(int,input().split())
    bf.add(a - 1,b - 1,- c)

if bf.build():
    print(- bf.ans)
else:
    print('inf')
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a+c = b+b:
  print('YES')
else:
  print('NO')

Fixed submission:
a,b,c = map(int,input().split())
if a+c == b+b:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
if a == 'H' ^ b == 'H':
  print('H')
else:
  print('D')

Fixed submission:
a,b = input().split()
if (a == 'H') ^ (b == 'H'):
  print('D')
else:
  print('H')
Buggy python submission (verdict: Runtime Error):
n = int(input())
win = {}
# key:勝者 value:keyに負けた人(set)
for i in range(n - 1):
    a = int(input())
    a -= 1
    if a not in win.keys():win[a] = set()
    win[a].add(i+1)

def dfs(winner):
    if winner not in win.keys():return 0
    losers = win[winner]
    storong = len(losers)
    deeps = []
    for loser in losers:
        deeps.append(dfs(loser))
    deeps.sort(reverse = True)
    deep = 1
    for i,d in enumerate(deeps):
        deep = max(deep, i+1 + d)
    return deep

print(dfs(0))


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
win = {}
# key:勝者 value:keyに負けた人(set)
for i in range(n - 1):
    a = int(input())
    a -= 1
    if a not in win.keys():win[a] = set()
    win[a].add(i+1)

def dfs(winner):
    if winner not in win.keys():return 0
    losers = win[winner]
    storong = len(losers)
    deeps = []
    for loser in losers:
        deeps.append(dfs(loser))
    deeps.sort(reverse = True)
    deep = 1
    for i,d in enumerate(deeps):
        deep = max(deep, i+1 + d)
    return deep

print(dfs(0))
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
ans = 0
 
for x in range(k+1):
  for y in range(x,k+1):
    for z in range(y,k+1):
      if x + y + z == s:
        if x == y == z:
          ans += 1
        elif x == y or y == z:
          ans += 3
        else:
          ans += 6
          
print(ans)

Fixed submission:
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
  for j in range(k+1):
    if 0 <= s - i - j <= k:
      ans += 1
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
ans = 0

for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        ans += 1
print(ans)

Fixed submission:
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
  for j in range(k+1):
    if 0 <= s - i - j <= k:
      ans += 1
      
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
for i in range(h):
  s = input().split()
  if 'snuke' in s:
    ans = ord('A') + s.index('snuke')
    print(ans + str(i+1))
    break


Fixed submission:
h,w = map(int,input().split())
for i in range(h):
  s = input().split()
  if 'snuke' in s:
    ans = ord('A') + s.index('snuke')
    print(chr(ans) + str(i+1))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
X = list(map(int,input().split()))
mod = [[0,0] for _ in range(n)]
d = {}
for x in X:
    if x not in d.keys():d[x] = 0
    d[x] += 1
for k,v in d.items():
    mod[k%m][0] += v//2
    mod[k%m][1] += v%2
ans = 0
for i in range(m//2+1):
    if i == 0 or i == m-i:
        ans += mod[i][1]//2 + mod[i][0]
    else:
        if mod[i][1] < mod[m-i][1]:
            ans += min(mod[m-i][1], mod[i][0]*2 + mod[i][1])
            ans += mod[m-i][0]
            ans += max(0,(mod[i][0]*2 + mod[i][1] - mod[m-i][1]))//2
        elif mod[i][1] == mod[m-i][1]:
            ans += mod[i][0] + mod[m-i][0] + mod[i][1]
        else:
            ans += min(mod[i][1], mod[m-i][0]*2 + mod[m-i][1])
            ans += mod[i][0]
            ans += max(0,(mod[m-i][0]*2 + mod[m-i][1] - mod[i][1]))//2
print(ans)


Fixed submission:
n,m = map(int,input().split())
X = list(map(int,input().split()))
mod = [[0,0] for _ in range(m)]
d = {}
for x in X:
    if x not in d.keys():d[x] = 0
    d[x] += 1
for k,v in d.items():
    mod[k%m][0] += v//2
    mod[k%m][1] += v%2
ans = 0
for i in range(m//2+1):
    if i == 0 or i == m-i:
        ans += mod[i][1]//2 + mod[i][0]
    else:
        if mod[i][1] < mod[m-i][1]:
            ans += min(mod[m-i][1], mod[i][0]*2 + mod[i][1])
            ans += mod[m-i][0]
            ans += max(0,(mod[i][0]*2 + mod[i][1] - mod[m-i][1]))//2
        elif mod[i][1] == mod[m-i][1]:
            ans += mod[i][0] + mod[m-i][0] + mod[i][1]
        else:
            ans += min(mod[i][1], mod[m-i][0]*2 + mod[m-i][1])
            ans += mod[i][0]
            ans += max(0,(mod[m-i][0]*2 + mod[m-i][1] - mod[i][1]))//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())

if n == 2:
    if x == 2:
        print('Yes')
        print('\n'.join([1,2,3]))
    else:
        print('No')
else:
    if x == 1 or x == 2*n - 1:
        print('No')
    else:
        print('Yes')
        if x == 2:
            ans = list(range(3,2*n-2))
            ans = ans[:n-3] + [2*n - 1,1,2,2*n - 2] + ans[n-3:]
        else:
            ans = list(range(2*n - 1))
            ans = ans[3:x] + ans[x+1:2*n - 1]
            ans = ans[:n-3] + [1,2*n - 1,x,2] + ans[n-3:]
        print('\n'.join(str(i) for i in ans))


Fixed submission:
n,x = map(int,input().split())

if n == 2:
    if x == 2:
        print('Yes')
        print('\n'.join(['1','2','3']))
    else:
        print('No')
else:
    if x == 1 or x == 2*n - 1:
        print('No')
    else:
        print('Yes')
        if x == 2:
            ans = list(range(3,2*n-2))
            ans = ans[:n-3] + [2*n - 1,1,2,2*n - 2] + ans[n-3:]
        else:
            ans = list(range(2*n - 1))
            ans = ans[3:x] + ans[x+1:2*n - 1]
            ans = ans[:n-3] + [1,2*n - 1,x,2] + ans[n-3:]
        print('\n'.join(str(i) for i in ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
m = len(input())

mod = 10**9 + 7
# dp[i][j] = i文字打ってj文字入力されてる0or1 とBの打ち方
dp = [[0]*(n+1) for i in range(n+1)]

dp[0][0] = 1

# 遷移 : dp[i][j] →dp[i+1][j+1]+ dp[i+1][max(j-1,0)]+
for i in range(n):
    for j in range(n):
        dp[i+1][j+1] += dp[i][j]
        dp[i+1][j+1] %= mod
        dp[i+1][max(j-1,0)] += dp[i][j]*(2 - (j==0))
        dp[i+1][max(j-1,0)] %= mod
print(dp[n][m])


Fixed submission:
n = int(input())
m = len(input())

mod = 10**9 + 7

# dp[i][j] = i文字打ってj文字入力されてる0or1 とBの打ち方
dp = [0]*(n+1)
dp[0] = 1

# 遷移 : dp[i][j] →dp[i+1][j+1]+ dp[i+1][max(j-1,0)]+
for i in range(n):
    dpnxt = [0]*(n+1)
    for j in range(n):
        dpnxt[j+1] += dp[j]
        dpnxt[j+1] %= mod
        dpnxt[max(j-1,0)] += dp[j]*(2 - (j==0))%mod
        dpnxt[max(j-1,0)] %= mod
    dp = dpnxt.copy()
print(dp[m])
Buggy python submission (verdict: Runtime Error):
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-1):
    print(i+1)
  for i in range(n-1,x,-1):
    print(i)
  print(x)


Fixed submission:
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)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
d = list(input().split())
ans = n
while True:
    flag = False
    for i in d:
        if flag :break
        if i in str(ans):
            x = len(str(n)) - str(n).index(i) - 1
            ans += 10**x
            flag = True
    if flag:continue
    print(ans)
    break


Fixed submission:
n,k = map(int,input().split())
d = list(input().split())
ans = n
while True:
    flag = False
    for i in d:
        if flag :break
        if i in str(ans):
            ans += 1
            flag = True
    if flag:continue
    break
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
d = list(input().split())
ans = n
while True:
    flag = False
    for i in d:
        if flag :break
        if i in str(ans):
            x = len(str(n)) - str(n).index(i) - 1
            ans += 10**x
            flag = True
    if flag:continue
    print(ans)
    exit(0)


Fixed submission:
n,k = map(int,input().split())
d = list(input().split())
ans = n
while True:
    flag = False
    for i in d:
        if flag :break
        if i in str(ans):
            ans += 1
            flag = True
    if flag:continue
    break
print(ans)