Recurrent is given as f0 = 0, f1 = 1, f2 = 2 и fk = fk-1 + fk-3 , n and ki are also given.

I need to write a program that counts n numbers on ki position of a given recurrent 

Example1 in

```
4
0 1 2 3

```

Example1 out

```
0 1 2 2

```

Example2 in

```
3
4 5 4

```

Example2 out

```
3 5 3

```

Here is my ideas

```
def get_numbers():
    with open('input.txt','r') as file_in:
        n = int(file_in.readline()[:-1])
        input_list = map(int,file_in.readline().split(' '))
        print(foo(n,input_list))

def find_number(n):
    a, b, c = 0, 1, 2
    for _ in range(n+1):
        yield a
        a, b, c = b, c, a + c

def foo(n,input_values):
    result = str()
    for elem in (list(find_number(i))[-1] for i in input_values):
        result += str(elem) + " "
    return result[:-1]

get_numbers()

```

I have tried to use generators to speed up my code, but can't get the idea of how to make it use less memory. 

So I am trying to either make my code consume less memory or just find another (simpler) solution.