For this Question: Given an array Arr of size N and an integer K. Todo wants you to find lexicographically minimum subsequence of the array of size K.
A subsequence is a sequence that can be derived from array by deleting some or no elements without changing the order of the remaining elements.
A sequence X is lexicographically smaller than Y if in the first position where X and Y differ, subsequence X has a number less than the corresponding number in Y.First line of input contains two integers N and K.
Second line of input contains N integers denoting array Arr.

Constraints: 
1 <= K <= N <= 100000
1 <= Arr[i] <= 1000000000Print K integers denoting the lexicographically minimum subsequence of the array of size K.Sample Input 1
5 2
12 2 1 3 4

Sample Output 1
1 3

Sample Input 2
5 4
12 2 1 3 4

Sample Output 2
2 1 3 4, I have written this Solution Code: n,k=map(int,input().split())
arr=list(map(int,input().split()))
ans=[]
i=0
t=0
minn=1000000
count=0
while i<n:
    if not ans:
        ans.append(arr[i])
    else:
        while ans and arr[i]<ans[-1] and (((n-i))+(len(ans))>k):
            ans.pop()
        if not ans or len(ans)<k:
            ans.append(arr[i])
    i+=1
print(*ans), In this Programming Language: Python, Now tell me if this Code is compilable or not?