Longest increasing subsequence in python