Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
V = [-1] * (K)
V[1] = 1
q = deque([1])
i = 1
while V[0] == -1:
    i = q.popleft()
    if i != E[i][0]:
        q.appendleft(E[i][0])
        V[E[i][0]] = V[i]
    if V[E[i][1]] == -1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])

Fixed submission:
from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
INF = K*10
V = [INF] * (K)
V[1] = 1
q = deque([1])
i = 1
while q:
    i = q.popleft()
    if V[E[i][0]] > V[i]:
        q.appendleft(E[i][0])
        V[E[i][0]] = V[i]
    if V[E[i][1]] > V[i]+1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
V = [-1] * (K)
V[1] = 1
q = deque([1])
i = 1
while V[0] == -1:
    i = q.popleft()
    q.appendleft(E[i][0])
    V[E[i][0]] = V[i]
    if V[E[i][1]] == -1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])

Fixed submission:
from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
INF = K*10
V = [INF] * (K)
V[1] = 1
q = deque([1])
i = 1
while q:
    i = q.popleft()
    if V[E[i][0]] > V[i]:
        q.appendleft(E[i][0])
        V[E[i][0]] = V[i]
    if V[E[i][1]] > V[i]+1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])
Buggy python submission (verdict: Runtime Error):
def main():
    N,K = map(int,input().split())
    XY = [list(map(int,input().split())) for _ in [0]*N]
    iX = [0]*N
    iY = [0]*N
    for i,xy in enumerate(XY):
        x,y = xy
        iX[i] = x
        iY[i] = y
    iX.sort()
    iY.sort()
    X = {x:i for i,x in enumerate(iX)}
    Y = {y:i for i,y in enumerate(iY)}

    c = [[0]*(N+1) for i in [0]*(N+1)]
    for x,y in XY:
        c[Y[y]+1][X[x]+1] = 1

    for i in range(N):
        ci1 = c[i+1
        for j in range(N):
            ci1[j+1] += ci1[j]
    for i in range(N):
        ci1 = c[i+1]
        ci = c[i]
        for j,cij in enumerate(ci[1:],1):
            ci1[j] += cij

    ans = 10**20
    for u in range(N):
        for d in range(u+K-1,N):
            l = 0
            r = K-1
            dY = iY[d]-iY[u]
            cd = c[d+1]
            cu = c[u]
            while r<N:
                if cd[r+1]+cu[l]-cu[r+1]-cd[l] >=K:
                    ans = min(ans, (iX[r] - iX[l])*dY)
                    l+=1
                else:r+=1

    print(ans)
main()

Fixed submission:
N,K = map(int,input().split())
xy = sorted([list(map(int,input().split())) for _ in range(N)],key = lambda x:(x[0],x[1]))

ans = 10**20

for i in range(K,N+1):
    for j in range(0,N-i+1):
        xy2 = sorted(xy[j:j+i],key = lambda x:(x[1]))
        for k in range(0,i-K+1):
            xy3 = xy2[k:k+K]
            Y_wid = xy3[-1][1] - xy3[0][1]
            x3 = [tmp for tmp,_ in xy3]
            X_wid = max(x3) - min(x3)
            ans = min(ans,X_wid*Y_wid)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
flg = False
for a in range(1,3501):
  for b in range(a,3501):
    A = 4*a*b - N*(a+b)
    B = N*a*b
    if B%A==0 and A//B>0:
      c = B//A
      flg = True
      break
  if flg:break
print(a,b,c)

Fixed submission:
N = int(input())
flg = False
for a in range(1,3501):
  for b in range(a,3501):
    A = 4*a*b - N*(a+b)
    B = N*a*b
    if A==B==0:
      c = 1
      flg = True
      break
    elif A!=0 and B%A==0 and B//A>0:
      c = B//A
      flg = True
      break
  if flg:break
print(a,b,c)
Buggy python submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())
ans = [0,0]
M = 0
for a in range(31):
    if F < a*A*100:
        break
    for b in range(31-a):
        if a == 0 and b == 0:
            continue
        W = (a*A+b*B)*100
        if F < W:
            break
        CD_max = min((E * W) // 100,F-W)
        for c in range(CD_max//C+1):
            d = max(0,(CD_max-c*C)//D)
            CD = c*C+d*D
            con = CD/(W+CD)
            if con > M:
                M = con
                ans = [str(W+CD),str(CD)]
print(" ".join(ans))

Fixed submission:
A,B,C,D,E,F = map(int,input().split())
ans = ["0","0"]
M = -1
for a in range(31):
    if F < a*A*100:
        break
    for b in range(31-a):
        if a == 0 and b == 0:
            continue
        W = (a*A+b*B)*100
        if F < W:
            break
        CD_max = min((E * W) // 100,F-W)
        for c in range(CD_max//C+1):
            d = max(0,(CD_max-c*C)//D)
            CD = c*C+d*D
            con = CD/(W+CD)
            if con > M:
                M = con
                ans = [str(W+CD),str(CD)]
print(" ".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N,M,R = map(int,input().split())
r = list(map(lambda x:int(x)-1,input().split()))
ABC = [list(map(int,input().split())) for _ in range(M)]
INF = 10**7
d = [[INF]*N for _ in range(N)]

for A,B,C in ABC:
    d[A-1][B-1] = C
    d[B-1][A-1] = C
for k in range(N):
    for i in range(N):
        for j in range(i+1,N):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])
            d[j][i] = d[i][j]
ans = INF * M
for r in itertools.permutations(r):
    S = 0
    for i,ri in enumerate(r[:-1]):
        S += d[ri][r[i+1]]
    ans = min(ans,S)
print(ans)

Fixed submission:
import itertools

N,M,R = map(int,input().split())
r = list(map(lambda x:int(x)-1,input().split()))
ABC = [list(map(int,input().split())) for _ in range(M)]
INF = 10**7
d = [[INF]*N for _ in range(N)]

for A,B,C in ABC:
    d[A-1][B-1] = C
    d[B-1][A-1] = C
for k in range(N):
    for i in range(N):
        for j in range(i+1,N):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])
            d[j][i] = d[i][j]
ans = INF * M
for r in itertools.permutations(r):
    S = 0
    for i,ri in enumerate(r[:-1]):
        S += d[ri][r[i+1]]
    ans = min(ans,S)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
*A, = sorted(set(map(int,input().split())))
if A[-1]<K:print("IMPOSSIBLE");exit()
d = min(A[i+1]-a for i,a in enumerate(A[:-1]))
K%=d
for a in A:
    if a%d==K:print("POSSIBLE");break
else:
    print("IMPOSSIBLE")

Fixed submission:
N,K = map(int,input().split())
*A, = sorted(set(map(int,input().split())))
if A[-1]<K:print("IMPOSSIBLE");exit()
if len(A)==1:
    if A[0]==K:print("POSSIBLE")
    else:print("IMPOSSIBLE")
    exit()
d = min(A[i+1]-a for i,a in enumerate(A[:-1]))
K%=d
for a in A:
    if a%d==K:print("POSSIBLE");break
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N = int(input())
*A, = map(int,input().split())
q = []
for a in A[:N]:
    heapq.heappush(q,a)
S1 = [sum(q)]
for a in A[N:N*2]:
    if a>q[0]:
        S1.append(S1[-1] + a - q[0])
        heapq.heapreplace(q,a)
    else:
        S1.append(S1[-1])
q = []
for a in A[2*N:]:
    heapq.heappush(q,-a)
S2 = [sum(q)]
for a in A[N:N*2][::-1]:
    if a<-q[0]:
        S2.append(S2[-1] - a - q[0])
        heapq.heapreplace(q,-a)
    else:
        S2.append(S2[-1])
S2 = S2[::-1]
print(max(map(sum,zip(S1,S2))))

Fixed submission:
import heapq
N = int(input())
*A, = map(int,input().split())
q = []
for a in A[:N]:
    heapq.heappush(q,a)
S1 = [sum(q)]
for a in A[N:N*2]:
    if a>q[0]:
        S1.append(S1[-1] + a - q[0])
        heapq.heapreplace(q,a)
    else:
        S1.append(S1[-1])
q = []
for a in A[2*N:]:
    heapq.heappush(q,-a)
S2 = [sum(q)]
for a in A[N:N*2][::-1]:
    if a<-q[0]:
        S2.append(S2[-1] - a - q[0])
        heapq.heapreplace(q,-a)
    else:
        S2.append(S2[-1])
S2 = S2[::-1]
print(max(map(sum,zip(S1,S2))))
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
ab = sorted([map(int,input().split()) for _ in [0]*N])
for a,b in ab:
    K -= b
    if K <= 0:
        print(a)
        break

Fixed submission:
N,K = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in [0]*N])
for a,b in ab:
    K -= b
    if K <= 0:
        print(a)
        break
Buggy python submission (verdict: Runtime Error):
N = int(input())
*A, = map(int,input().split())
ans1 = 0
S = A[0]
if S <= 0:
    S = 1
    ans1 = abs(S)+1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans1 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
ans2 = 0
S = A[0]
if S >= 0:
    S = -1
    ans2 = abn(S)+1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans2 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
print(min(ans1,ans2))

Fixed submission:
N = int(input())
*A, = map(int,input().split())
ans1 = 0
S = A[0]
if S <= 0:
    ans1 = abs(S)+1
    S = 1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans1 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
ans2 = 0
S = A[0]
if S >= 0:
    ans2 = abs(S)+1
    S = -1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans2 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
print(min(ans1,ans2))

Buggy python submission (verdict: Runtime Error):
N = int(input())
*A, = map(int,input().split())
ans = 0
S = A[0]
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
print(ans)

Fixed submission:
N = int(input())
*A, = map(int,input().split())
ans1 = 0
S = A[0]
if S <= 0:
    ans1 = abs(S)+1
    S = 1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans1 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
ans2 = 0
S = A[0]
if S >= 0:
    ans2 = abs(S)+1
    S = -1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans2 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
print(min(ans1,ans2))
Buggy python submission (verdict: Runtime Error):
a,b,c = input().split()
if b-a==c-b:
    print("YES")
else:
    print("NO")

Fixed submission:
a,b,c = map(int,input().split())
if b-a==c-b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [input() for _ in [0]*N]
B = [input() for _ in [0]*M]
endFlg = False
for i in range(N-M):
    for j in range(N-M):
        breakFlg = False
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    breakFlg = True
                    break
        if breakFlg: break
        pass
        else: endFlg = True
    if endFlg: break
if endFlg:print("Yes")
else:print("No")

Fixed submission:
N,M = map(int,input().split())
A = [input() for _ in [0]*N]
B = [input() for _ in [0]*M]
endFlg = False
for i in range(N-M+1):
    for j in range(N-M+1):
        breakFlg = False
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    breakFlg = True
                    break
            if breakFlg:break
        else:endFlg=True
        if endFlg: break
    if endFlg: break
if endFlg:print("Yes")
else:print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,Ma,Mb = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*N]
INFTY = 10**8
dp = [[[INFTY]*10*(N+1) for _ in [0]*10*(N+1)] for _ in [0]*(N+1)]
dp[0][0][0] = 0
for i in range(1,N+1):
    a,b,c = ABC[i-1]
    for j in range(10*(N+1)):
        for k in range(10*(N+1)):
            dp[i][j][k] = dp[i-1][j][k]
            if j-a>=0 and k-b>=0:
                dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-a][k-b]+c)
ans = min(dp[-1][Ma*k][Mb*k] for k in range(1,(10*(N+1)-1)//max(Ma,Mb)+1))
if ans == INFTY : ans = -1
print(ans)

Fixed submission:
N,*M = map(int,input().split())
abc = [list(map(int,input().split())) for _ in [0]*N]
INF = 100*40*100
dp = [[[INF]*500 for _ in [0]*500] for _ in [0]*(N+1)]
dp[0][0][0] = 0
for i in range(1,N+1):
    a,b,c = abc[i-1]
    for j in range(410):
        for k in range(410):
            dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
ans = min([dp[-1][M[0]*i][M[1]*i] for i in range(1,1+400//(max(M)))])
if ans == INF:ans=-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,*M = map(int,input().split())
abc = [list(map(int,input().split())) for _ in [0]*N]
INF = 100*40*100
dp = [[[INF]*500 for _ in [0]*500] for _ in [0]*(N+1)]
dp[0][0][0] = 0
for i in range(1,N+1):
    a,b,c = abc[i-1]
    for j in range(410):
        for k in range(410):
            dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
ans = min([dp[-1][M[0]*i][M[1]*i] for i in range(1,1+400//(max(M)))])
if ans == INF:ans=-1
print(ans)

Fixed submission:
N,*M = map(int,input().split())
abc = [list(map(int,input().split())) for _ in [0]*N]
INF = 100*40*100
dp = [[[INF]*500 for _ in [0]*500] for _ in [0]*(N+1)]
dp[0][0][0] = 0
for i in range(1,N+1):
    a,b,c = abc[i-1]
    for j in range(410):
        for k in range(410):
            dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
ans = min([dp[-1][M[0]*i][M[1]*i] for i in range(1,1+400//(max(M)))])
if ans == INF:ans=-1
print(ans)
Buggy python submission (verdict: Runtime Error):
input()
print("YNEOS"[sum(map(int,input()))%2::2])

Fixed submission:
input()
print("YNEOS"[sum(map(int,input().split()))%2::2])
Buggy python submission (verdict: Time Limit Exceeded):
xs,ys,xt,yt = map(int,input().split())
N = int(input())
XYR = [list(map(int,input().split())) for _ in [0]*N]
XYR.append([xs,ys,0])
XYR.append([xt,yt,0])

E = [{} for _ in [0]*(N+2)]
for i in range(N+2):
    for j in range(N+2):
        if j==i : continue
        dx = XYR[i][0]-XYR[j][0]
        dy = XYR[i][1]-XYR[j][1]
        r2 = XYR[i][2]+XYR[j][2]
        E[i][j] = max(0,(dx**2+dy**2)**0.5 - r2)

import heapq
def Dijkstra(N,E,start):
    d = [-1]*N
    q = [(0,start)]
    while q:
        ci,i = heapq.heappop(q)
        if d[i]!= -1:continue
        d[i] = ci
        for j,cj in E[i].items():
            if d[j]!=-1:continue
            heapq.heappush(q,(ci+cj,j))
    return d

print(Dijkstra(N+2,E,N)[-1])

Fixed submission:
xs,ys,xt,yt = map(int,input().split())
N = int(input())
XYR = [list(map(int,input().split())) for _ in [0]*N]
XYR.append([xs,ys,0])
XYR.append([xt,yt,0])

E = [{} for _ in [0]*(N+2)]
for i in range(N+2):
    for j in range(N+2):
        if j==i : continue
        dx = XYR[i][0]-XYR[j][0]
        dy = XYR[i][1]-XYR[j][1]
        r2 = XYR[i][2]+XYR[j][2]
        E[i][j] = max(0,(dx**2+dy**2)**0.5 - r2)

import heapq
def Dijkstra(N,E,start):
    d = [-1]*N
    q = [(0,start)]
    while q:
        ci,i = heapq.heappop(q)
        if d[i]!= -1:continue
        d[i] = ci
        for j,cj in E[i].items():
            if d[j]!=-1:continue
            heapq.heappush(q,(ci+cj,j))
    return d

print(Dijkstra(N+2,E,N)[-1])
Buggy python submission (verdict: Time Limit Exceeded):
W,H = map(int,input().split())
PQ = [(int(input()),0,i) for i in range(W)] + [(int(input()),1,i) for i in range(H)]
PQ.sort()

import sys
sys.setrecursionlimit(10**7)

class UnionFind:
    def __init__(self):
        self.Parent = {}
    def add(self,k):
        self.Parent[k] = k
    def get_Parent(self,n):
        if self.Parent[n] == n:return n
        p = self.get_Parent(self.Parent[n])
        self.Parent[n] = p
        return p
    def merge(self,x,y):
        x = self.get_Parent(x)
        y = self.get_Parent(y)
        if x!=y: self.Parent[y] = x
        return
    def is_united(self,x,y):
        return self.get_Parent(x)==self.get_Parent(y)

ans = 0
T = UnionFind()
for i in range(W+1):
    for j in range(H+1):
        T.add((i,j))
for c,pq,ij in PQ:
    if pq==0:
        i = ij
        for j in range(H+1):
            if not T.is_united((i,j),(i+1,j)):
                T.merge((i,j),(i+1,j))
                ans += c
    else:
        j = ij
        for i in range(W+1):
            if not T.is_united((i,j),(i,j+1)):
                T.merge((i,j),(i,j+1))
                ans += c
print(ans)

Fixed submission:
W,H = map(int,input().split())
PQ = [(int(input()),0) for _ in [0]*W] + [(int(input()),1) for _ in [0]*H]
PQ.sort()
r = H+1
c = W+1
ans = 0
for d,pq in PQ:
    if pq==0:
        ans += d*r
        c -=1
    else:
        ans += d*c
        r -=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
W,H = map(int,input().split())
PQ = [(int(input()),0,i) for i in range(W)] + [(int(input()),1,i) for i in range(H)]
PQ.sort()

import sys
sys.setrecursionlimit(10**7)

class UnionFind:
    def __init__(self):
        self.Parent = {}
    def add(self,k):
        self.Parent[k] = k
    def get_Parent(self,n):
        if self.Parent[n] == n:return n
        p = self.get_Parent(self.Parent[n])
        self.Parent[n] = p
        return p
    def merge(self,x,y):
        x = self.get_Parent(x)
        y = self.get_Parent(y)
        if x!=y: self.Parent[y] = x
        return
    def is_united(self,x,y):
        return self.get_Parent(x)==self.get_Parent(y)

ans = 0
T = UnionFind()
for i in range(W+1):
    for j in range(H+1):
        T.add((i,j))
for c,pq,ij in PQ:
    if pq==0:
        i = ij
        for j in range(H+1):
            if not T.is_united((i,j),(i+1,j)):
                T.merge((i,j),(i+1,j))
                ans += c
    else:
        j = ij
        for i in range(W+1):
            if not T.is_united((i,j),(i,j+1)):
                T.merge((i,j),(i,j+1))
                ans += c
print(ans)

Fixed submission:
W,H = map(int,input().split())
PQ = [(int(input()),0) for _ in [0]*W] + [(int(input()),1) for _ in [0]*H]
PQ.sort()
r = H+1
c = W+1
ans = 0
for d,pq in PQ:
    if pq==0:
        ans += d*r
        c -=1
    else:
        ans += d*c
        r -=1
print(ans)
Buggy python submission (verdict: Runtime Error):
input();*A,=map(int,input());print(sum(A[a]==i for i,a in enumerate(A))//2)

Fixed submission:
input();*A,=map(int,input().split());print(sum(A[a-1]==i+1for i,a in enumerate(A))//2)
Buggy python submission (verdict: Time Limit Exceeded):
N,x = map(int,input().split())
*A, = map(int,input().split())
c = [A[:] for _ in [0]*(N)]
ans = sum(A)
for i in range(1,N):
    for j in range(N):
        c[i][j] = min(c[i-1][j-1],c[i][j])
    ans = min(ans,sum(c[i])+x*i)
print(ans)

Fixed submission:
N,x = map(int,input().split())
*A, = map(int,input().split())
c = [A[:] for _ in [0]*(N)]
ans = sum(A)
for i in range(1,N):
    for j in range(N):
        c[i][j] = min(c[i-1][j-1],c[i][j])
    ans = min(ans,sum(c[i])+x*i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,A = map(int,input().split())
*X, = map(int,input().split())
dp=[[[0]*2510 for _ in [0]*(N+10)] for _ in [0]*(N+10)]
for n in range(0,N+1):dp[n][0][0] = 1
for n in range(1,N+1):
    x = X[n-1]
    for k in range(1,n+1):
        for s in range(2501):
            dp[n][k][s] = dp[n-1][k][s]
            if s>=x:
                dp[n][k][s] += dp[n-1][k-1][s-x]
print(sum(dp[N][k][k*A] for k in range(1,N+1)))

Fixed submission:
N,A = map(int,input().split())
*X, = map(int,input().split())
dp=[[[0]*2510 for _ in [0]*(N+10)] for _ in [0]*(N+10)]
for n in range(0,N+1):dp[n][0][0] = 1
for n in range(1,N+1):
    x = X[n-1]
    for k in range(1,n+1):
        for s in range(2501):
            dp[n][k][s] = dp[n-1][k][s]
            if s>=x:
                dp[n][k][s] += dp[n-1][k-1][s-x]
print(sum(dp[N][k][k*A] for k in range(1,N+1)))
Buggy python submission (verdict: Runtime Error):
N,L = map(int,input().split())
*A, = map(int,input().split())

S = [0]*(N+1)
for i,a in enumerate(A): S[i+1] = S[i] + a
ans = []
i=0
j=N-1
while i<j:
    if S[j+1]-S[i] < L:
        1/0
        print("Impossible")
        break
    if A[i] <= A[j]:
        ans.append(i+1)
        i+=1
    else:
        ans.append(j)
        j-=1
else:
    print("Possible")
    for a in ans: print(a)

Fixed submission:
N,L = map(int,input().split())
*A, = map(int,input().split())

S = [0]*(N+1)
for i,a in enumerate(A): S[i+1] = S[i] + a
ans = []
i=0
j=N-1
while i<j:
    if S[j+1]-S[i] < L:
        print("Impossible")
        break
    if A[i]+A[i+1] <= A[j]+A[j-1]:
        ans.append(i+1)
        i+=1
    else:
        ans.append(j)
        j-=1
else:
    print("Possible")
    for a in ans: print(a)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd


n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  ans %= 1000000007
  
print(int(ans))

Fixed submission:
from fractions import gcd


n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  
print(int(ans%1000000007))

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
def gcd(a,b):
  r = a%b
  while r > 0:
    a=b
    b=r
    r=a%b
  return b

n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  ans %= 1000000007
  
print(int(ans))

Fixed submission:
from fractions import gcd


n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  
print(int(ans%1000000007))

Buggy python submission (verdict: Runtime Error):
from franctions import gcd

n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  ans %= 1000000007
  
print(int(ans))

Fixed submission:
from fractions import gcd


n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  
print(int(ans%1000000007))

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
  r = a%b
  while r > 0:
    a=b
    b=r
    r=a%b
  return b

n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  ans %= 1000000007
  
print(int(ans))

Fixed submission:
from fractions import gcd


n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  
print(int(ans%1000000007))

Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
  r = a%b
  while r > 0:
    a=b
    b=r
    r=a%b
  return b

n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num/i
  ans %= 1000000007
  
print(int(ans))

Fixed submission:
from fractions import gcd


n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  
print(int(ans%1000000007))
Buggy python submission (verdict: Runtime Error):
from fraction import lcm

a,b,c,d = map(int,input().split())
a-=1
print(b//c+b//d-a//c-a//d-b//(c*d/lcm(c,d)))


Fixed submission:
from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
a,b,c,d = map(int,input().split())
a-=1
print((b-a)-(b//c+b//d-a//c-a//d-(b//lcm(c,d))+(a//lcm(c,d))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
sche = []
for i in range(n):
    a,b = map(int,input().split())
    sche.append((b,a))
sche.sort(reverse = True)
now = 1e18
for dead,ti in :
    if(dead > now):
        dead = now
    now -= ti

if now < 0:
    print("No")
else:
    print("Yes")


Fixed submission:
n = int(input())
sche = []
for i in range(n):
    a,b = map(int,input().split())
    sche.append((b,a))
sche.sort(reverse = True)
now = 1e18
for dead,ti in sche:
    if(dead < now):
        now = dead
    now -= ti

if now < 0:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
import numpy as np
a=int(input())
b=int(input())
print(max(a+b,a-b,a*b))

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a,b)+min(c+d))

Fixed submission:
a = (int)(input())
b = (int)(input())
c = (int)(input())
d = (int)(input())
print(min(a,b)+min(c,d))