Problem:


Score : 200 points

Problem Statement

It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.

You are given an integer N. Find the N-th Lucas number.

Here, the i-th Lucas number L_i is defined as follows:

L_0=2

L_1=1

L_i=L_{i-1}+L_{i-2} (i≥2)

Constraints

1≤N≤86

It is guaranteed that the answer is less than 10^{18}.

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the N-th Lucas number.

Sample Input 1

5

Sample Output 1

11

L_0=2

L_1=1

L_2=L_0+L_1=3

L_3=L_1+L_2=4

L_4=L_2+L_3=7

L_5=L_3+L_4=11

Thus, the 5-th Lucas number is 11.

Sample Input 2

86

Sample Output 2

939587134549734843



Sample input:
5


Sample output:
11

Submission status: Accepted

Solution code:
n = int(input())

if n == 1:
  print(1)
  exit()
  
nums = [0]*(n+1)
nums[0] = 2
nums[1] = 1

for i in range(2,n+1):
  nums[i] = nums[i-1]+nums[i-2]
print(nums[n])

Submission status: Accepted

Solution code:
n = int(input())

lucas = [0] * (n + 1)
lucas[0] = 2
lucas[1] = 1


for i in range(2, n + 1):
    lucas[i] = lucas[i - 2] + lucas[i - 1]

print(lucas[n])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    return N,


def solve(N):
    L = [0 for i in range(N+1)]
    L[0] = 2
    L[1] = 1
    for i in range(2, N+1):
        L[i] = L[i-1] + L[i-2]
    return L[N]


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

Solution code:
N=int(input())

if N==0:
    print(2)
else:
    a,b=2,1
    for i in range(N-1):
        a,b=b,a+b
    print(b)

Submission status: Accepted

Solution code:
N = int(input())
L = [0] * (N + 1)


def f(i):
    if i == 0:
        return 2
    if i == 1:
        return 1
    if L[i] == 0:
        L[i] = f(i - 1) + f(i - 2)
    return L[i]


print(f(N))

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    L = [0] * (N + 3)
    if N == 0:
        print(2)
        exit()
    L[0] = 2
    if N == 1:
        print(1)
        exit()
    L[1] = 1
    for n in range(2, N+1):
        L[n] = L[n - 1] + L[n - 2]
    print(L[n])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
def main():
  n = int(input())
  num=[0]*87
  num[0]=2
  num[1]=1
  for i in range(2,n+1):
    num[i]=num[i-1]+num[i-2]
  print(num[n])
    
main()

Submission status: Accepted

Solution code:
n=int(input())
l_b=2
l=1
if n==0:
  print("2")
elif n==1:
  print("1")
else:
  for i in range(2,n+1):
    l_bb=l_b
    l_b=l
    l=l_b+l_bb
  print(l)

Submission status: Accepted

Solution code:
n = int(input())
l = [2, 1]
i = 0
while i < n:
  l.append(l[-1] + l[-2])
  i+=1
print(l[n])

Submission status: Accepted

Solution code:
import numpy
a=numpy.matrix
print(int((a([[1,1],[1,0]])**int(input())@a([[1],[2]]))[1]))

Submission status: Accepted

Solution code:
import sys
N = int(input())
if not (1 <= N <= 86):
    sys.exit()

L = [2,1]
if N == 1:
    print(1)
    sys.exit()

for I in range(2,N+2):
    L.append(L[I-1] + L[I-2])
print(L[N])

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
Luca = [2, 1]
for i in range(2, N + 1):
    Luca.append(Luca[i-1] + Luca[i-2])
print(Luca[N])

Submission status: Accepted

Solution code:
n=int(input())
l0=2
l1=1
l2=0
if n==0:
    print(2)
    exit()
if n==1:
    print(1)
    exit()
    
for i in range(2,n+1):
    l2=l1+l0
    l0=l1
    l1=l2
print(l2)

Submission status: Accepted

Solution code:
#ABC-79-B
from functools import lru_cache

n = int(input())

@lru_cache(maxsize=None)
def lucas(n):
    if n == 1:
        return 2
    elif n == 2:
        return 1
    else:
        return lucas(n-2)+lucas(n-1)
    

print(lucas(n+1))

Submission status: Accepted

Solution code:
dp=[0]*87
dp[0]=2
dp[1]=1
for i in range(2,87):
  dp[i]=dp[i-1]+dp[i-2]
N=int(input())
print(dp[N])

Submission status: Accepted

Solution code:
n = int(input())
lst = [2, 1]
for i in range(90):
  lst.append(lst[-1] + lst[-2])
print(lst[n])

Submission status: Accepted

Solution code:
a = [2, 1]
n = int(input())
while(len(a) != n+1):
  a.append(a[-1] + a[-2])
print(a[-1])

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
ls = [2,1]
i = 2
def lucas(n):
	global i
	if n == 0:
		return 
	else:
		n -= 1
		memo = ls[i-2] + ls[i-1]
		ls.append(memo)
		i += 1
		lucas(n)			

lucas(86)
print(ls[n])

Submission status: Accepted

Solution code:
def Lucas_Update(L0,L1):
    L2=L0+L1
    return L2
N=int(input())
L=[2,1]
if N==0:
    print(2)
elif N==1:
    print(1)
else:
    for i in range(2,N+1):
        L.append(Lucas_Update(L[i-1],L[i-2]))
    print(L[N])

Submission status: Accepted

Solution code:
N = int(input())

L = [2, 1]

for i in range(2, N+1):
    L_i = L[i-1] + L[i-2]
    L.append(L_i)

print(L[-1])

Submission status: Accepted

Solution code:
N = int(input())
L = [2,1]

for n in range(N):
  L.append(L[-2]+L[-1])

print(L[N])

Submission status: Accepted

Solution code:
import functools
import  sys

sys.setrecursionlimit(10**6)
@functools.lru_cache()
def ryuca(l):
	if l == 0:
		return 2
	elif l == 1:
		return 1
	else:
		 return ryuca(l-1) + ryuca(l-2)
print(ryuca(int(input())))

Submission status: Accepted

Solution code:
n = int(input())
l0 = 2
l1 = 1
L = 0
if n == 1:
    print(l1)
    exit()
else:
    for i in range(2, n+1):
        L = l0 + l1
        l0 = l1
        l1 = L
print(L)

Submission status: Accepted

Solution code:
n = int(input())
#j = L0
j = 2
#k = L1
k = 1

if n == 0:
    print(2)
    exit(0)
if n == 1:
    print(1)
    exit(0)

for i in range(1,n):
    l = j + k
    j = k
    k = l

print(l)

Submission status: Accepted

Solution code:
L = []
for i in range(87):
    L.append(i)
n = int(input())
L[0] = 2
L[1] = 1

for j in range(2,n+1):
    L[j] = L[j-1] + L[j-2]
print(L[n])

Submission status: Accepted

Solution code:
N = int(input())
a= 2
b=1
for i in range(1,N+1):
    a,b = b,b+a
    #print('a=' +str(a)+' b=' +str(b))
print(a)

Submission status: Accepted

Solution code:
L = [0 for _ in range(100)]
L[0], L[1] = 2, 1

N = int(input())
for i in range(2, N + 1):
    L[i] = L[i - 1] + L[i - 2]

print(L[N])

Submission status: Accepted

Solution code:
N = int(input())
L = []
L.append(2)
L.append(1)

for i in range(2,N+1):
    L_temp = L[i-1] + L[i-2]
    L.append(L_temp)

print(L[-1])

Submission status: Accepted

Solution code:
def LucasFib(n, memo={}):
    if n == 0:
        return 2
    if n == 1:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = LucasFib(n - 1, memo) + LucasFib(n - 2, memo)
        return memo[n]


def resolve():
    N = int(input())
    print(LucasFib(N))


resolve()

Submission status: Accepted

Solution code:
from functools import lru_cache
@lru_cache(maxsize=None)

def luca(n):
    if n==0:
        return 2
    elif n == 1:
        return 1
    else:
        return luca(n-1)+luca(n-2)

N = int(input())

print(luca(N))

Submission status: Accepted

Solution code:
from functools import lru_cache
 
@lru_cache(maxsize=None)

def ryuka(n):
  if n==0:
    return 2
  elif n==1:
    return 1
  else:
    return ryuka(n-1)+ryuka(n-2)
  
N=int(input())

print(ryuka(N))

Submission status: Accepted

Solution code:
N = int(input())

l0 = 2
l1 = 1

if (N == 1):
    ans = 1
else:
    before = l0
    middle = l1
    
    for i in range(N - 1):
        nextt = before + middle
        before = middle
        middle = nextt
    
    ans = nextt

print(ans)

Submission status: Accepted

Solution code:
n =int(input())
a = [0]*(n+1)
a[0] = 2
a[1] = 1

for i in range(2,n+1):
  a[i] = a[i-1]+a[i-2]

print(a[n])

Submission status: Accepted

Solution code:
n = int(input())
r1 = 2
r2 = 1
if n == 1:
    print(1)
    exit()
else:
    for _ in range(n-1):
        r2 = r1 + r2
        r1 = r2 - r1
print(r2)

Submission status: Accepted

Solution code:
def lucas_dp(n):
    memo = [None] * (n + 1)
    memo[0] = 2
    memo[1] = 1
    for i in range(2, n+1):
        memo[i] = memo[i - 1] + memo[i - 2]
    return memo[n]  

n = int(input())
lucas = lucas_dp(n)
print(lucas)

Submission status: Accepted

Solution code:
n = int(input())

a = 2
b = 1

for i in range(n):
    if(i == 0):
        preb = b
        b = a + b
        a = preb
    else:
        prea = a
        preb = b
        a = b
        b = prea + b


print(a)

Submission status: Accepted

Solution code:
N = int(input())

lis = [2, 1]

for i in range(2, N+1):
    lis.append(lis[i-1]+lis[i-2])

if N == 1:
    print(1)
else:
    print(lis[N])

Submission status: Accepted

Solution code:
n = int(input())

l = [2,1]
for i in range(n-1):
  res = l[i] + l[i+1]
  l.append(res)
print(l[-1])

Submission status: Accepted

Solution code:
W = [2,1]
N=int(input())
for i in range(N):
  K=W[0]+W[1]
  W.append(K)
  W.pop(0)
print(W[0])

Submission status: Accepted

Solution code:
n = int(input())
a = []
a.append(2)
a.append(1)
for i in range(2, n+1):
    a.append(a[i-2]+a[i-1])
print(a[n])

Submission status: Accepted

Solution code:
N = int(input())
a, b = 2, 1
for i in range(N):
    a, b = b, a + b
print(a)

Submission status: Accepted

Solution code:
n = int(input())

a,b = 2,1
for i in range(n-1):
    a,b = b,a+b
print(b)

Submission status: Accepted

Solution code:
n = int(input())
l = [2, 1]
for i in range(2, n+1):
    a = l[i-2] + l[i-1]
    l.append(a)
print(l[n])

Submission status: Accepted

Solution code:
n = int(input())

l = [0]*(n+1)
l[0] = 2
l[1] = 1

def luca (x:int):
    if l[x] > 0:
        return l[x]
    else:
        l[x] = luca(x-1) + luca(x-2)
        return l[x]

print (luca(n))

Submission status: Accepted

Solution code:
n = int(input())
ans = [0] * 87
ans[0] = 2
ans[1] = 1
for i in range(2, n + 1):
    ans[i] = ans[i - 2] + ans[i - 1]
print(ans[n])

Submission status: Accepted

Solution code:
n = int(input())
L = [0] * (n+1)
L[0] = 2
L[1] = 1

def lucas(n):
    if L[n] > 0:
        return L[n]
    L[n] = lucas(n-1) + lucas(n-2)
    return L[n]

print(lucas(n))

Submission status: Accepted

Solution code:
n = int(input())
l = [2, 1]
for i in range(90):
    l.append(l[i] + l[i + 1])
print(l[n])

Submission status: Accepted

Solution code:
N = int(input())
L0 = 2
L1 = 1
if N == 1:
    print(L1)
else:
    for i in range(N-1):
        L1, L0 = L1 + L0, L1
    print(L1)

Submission status: Accepted

Solution code:
L=int(input())

lyuca=[2,1]
for i in range(2,L+1):
  a=lyuca[i-1]+lyuca[i-2]
  lyuca.append(a)
print(lyuca[-1])

Submission status: Accepted

Solution code:
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    L=[0]*(N+1)
    L[0]=2
    L[1]=1
    for i in range(2,N+1):
        L[i]=L[i-1]+L[i-2]
    print(L[N])
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())

A=[2,1]
ans=0
if N==1:
    ans=1
else: 
    for _ in range(N-1):
        a=A.pop(0)
        b=A.pop(0)
        c=a+b
        A.append(b)
        A.append(c)
    ans=A[1]

print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    list =[0]*86
    list[0]=2
    list[1]=1

    for i in range(2,86):
        list[i]=list[i-1]+list[i-2]

    if n ==86:
        print("939587134549734843")
    else:
        print(list[n])

Submission status: Accepted

Solution code:
l = [2, 1]
for i in range(2, int(input()) + 1):
    l.append(l[len(l) - 1] + l[len(l) - 2])
print(l[len(l) - 1])

Submission status: Accepted

Solution code:
n = int(input())
a = [2,1]
for i in range(2,87):
    a.append(a[i-1]+a[i-2])
print(a[n])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[2]:


N = int(input())


# In[12]:


def lucas(n):
    mylist = [2,1]
    for i in range(2,n+1):
        mylist.append(mylist[i-1]+mylist[i-2])
    return mylist[n]


# In[14]:


print(lucas(N))


# In[ ]:

Submission status: Accepted

Solution code:
def getLuca(n):
    memo = [2, 1]

    for i in range(2, n+1):
        memo.append(memo[i-1] + memo[i-2])
    
    return memo[n]

def resolve():
    N = int(input())
    print(getLuca(N))
    return

resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def f(n,memo={}):
    if n == 0 :
        memo[0] = 2
        return memo[0]
    elif n == 1:
        memo[1] = 1
        return memo[1]
    elif n in memo.keys():
        return memo[n]
    else:
        memo[n] = f(n-1) + f(n-2)
        return memo[n]

def main():
    N = int(input())
    print(f(N))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

memo = {}

def luca(N):
    if N in memo:
        return memo[N]
    else:
        memo[N] = 0
    if N == 0:
        memo[N] = 2
        return 2
    if N == 1:
        memo[N] = 1
        return 1
    memo[N] = luca(N-1) + luca(N-2)
    return memo[N]

print(luca(N))

Submission status: Accepted

Solution code:
N=int(input())
L=[2,1]
for i in range(2,N+1):
  L.append(L[i-1]+L[i-2])
print(L[N])

Submission status: Accepted

Solution code:
N=int(input());a,b=2,1
for i in range(N-1):
  a,b=b,a+b
print(b)

Submission status: Accepted

Solution code:
N=int(input());a,b=2,1
for i in range(2, N+1):
  a,b=b,a+b
print(b)

Submission status: Accepted

Solution code:
N=int(input())
a,b=2,1
for i in range(2, N+1):
  a,b=b,a+b
print(b)

Submission status: Accepted

Solution code:
N=int(input())
L = [0]*(N+1)
L[0] = 2
L[1] = 1
for i in range(2, N+1):
  L[i] = L[i-2] + L[i-1]
print(L.pop())

Submission status: Accepted

Solution code:
n=int(input())
x=0
if n==1:
    print(1)
else:
    a1=1
    a0=2
    for i in range(n-1):
        x=a1+a0
        a0=a1
        a1=x
    print(x)

Submission status: Accepted

Solution code:
N = int(input())
ryuka = [0]*(N+1)
ryuka[0] = 2
ryuka[1] = 1
for i in range(2, N+1):
    ryuka[i] = ryuka[i-1]+ryuka[i-2]
print(ryuka[-1])

Submission status: Accepted

Solution code:
n = int(input())
l = [2, 1]
for i in range(2, n+1):
    l.append(l[i-2]+l[i-1])
print(l[-1])

Submission status: Accepted

Solution code:
n = int(input())
l = []
if n == 0:
    l.append(2)
elif n == 1:
    l.append(1)
elif n >= 2:
    l = [2, 1]
    for i in range(2, n+1):
        l.append(l[i-2]+l[i-1])
print(l[-1])

Submission status: Accepted

Solution code:
N = int(input())
L0 = 2
L1 = 1
if N == 1:
    print(L1)
    exit()

for i in range(1,N):
    res = L0 + L1
    L0 = L1
    L1 = res

print(res)

Submission status: Accepted

Solution code:
N = int(input())

L = [2, 1]
for i in range(2, N+1):
    L.append(L[i-1] + L[i-2])
print(L[N])

Submission status: Accepted

Solution code:
N = int(input())
a , b = 2 , 1
for i in range (N - 1):
    a , b = b, a+b
print(b)

Submission status: Accepted

Solution code:
n = int(input())

l0 = 2
l1 = 1
if n == 1:
    print(l1)
else:
    for i in range(1, n):
        l2 = l0 + l1
        l0 = l1
        l1 = l2
    print(l2)

Submission status: Accepted

Solution code:


def luca(n):
  lz=2
  lo=1
  if n==1:
    return 1
  for i in range(n-1):
    
    nl=lz+lo
    lz=lo
    lo=nl

  return nl

print(luca(int(input())))

Submission status: Accepted

Solution code:
n = int(input())

if n == 0:
    print('2')
elif n == 1:
    print('1')
else:
    L = [2,1]
    for i in range(n-1):
        tmp = L[i] + L[i+1]
        L.append(tmp)
    print(max(L))

Submission status: Accepted

Solution code:
n = int(input())
l0, l1 = 2, 1
for i in range(n):
    l0, l1 = l1, l0+l1
print(l0)

Submission status: Accepted

Solution code:
def main():
    L = [2, 1]
    for _ in range(86):
        L.append(L[-1] + L[-2])
    
    N = int(input())
    print(L[N])

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

ryuka = [-1]*87
ryuka[0] = 2
ryuka[1] = 1
for i in range(2,87):
	ryuka[i] = ryuka[i-1]+ryuka[i-2]



print(ryuka[readInt()])

Submission status: Accepted

Solution code:
n = int(input())

L = [2,1]
for i in range(2,n+1):
  k = L[i-2]+L[i-1]
  L.append(k)
  
print(L[len(L)-1])

Submission status: Accepted

Solution code:
n=int(input())
a=2
b=1
if n==1:
  print(1)
else:
  for i in range(n-1):
    if i%2==0:
      a=a+b
    else:
      b=a+b
  print(max(a,b))

Submission status: Accepted

Solution code:
N = int(input())
L = [2, 1]
for i in range(N):
  L.append(L[-1]+L[-2])
print(L[N])

Submission status: Accepted

Solution code:
def main():

    n = int(input())
    a, b = 2, 1
    for i in range(n-1):
        a, b =b, a + b
    print(b)

main()

Submission status: Accepted

Solution code:
N = int(input())
L = [2,1]+[0]*100
for i in range(2,100):
    L[i] = L[i-1]+L[i-2]
print(L[N])

Submission status: Accepted

Solution code:
def lucas(n, memo={}):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = lucas(n - 1, memo) + lucas(n - 2, memo)
        return lucas(n - 1) + lucas(n - 2)


n = int(input())
print(lucas(n))

Submission status: Accepted

Solution code:
n=int(input())

ans=[0]*(n+1)
ans[0]=2
ans[1]=1
if n>=2:
    for i in range(2,n+1):
        ans[i]=ans[i-1]+ans[i-2]
print(ans[n])

Submission status: Accepted

Solution code:
N = int(input())
L = [2, 1]
ans = 0
for i in range(N - 1):
    L.append(L[i] + L[i + 1])
print(L[-1])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())

L = [-1] * 100
L[0] = 2
L[1] = 1
for i in range(2, 100):
    L[i] = L[i - 1] + L[i - 2]

# print('L', L)
print(L[N])

Submission status: Accepted

Solution code:
n = int(input())
l = [0]*87
l[0] = 2
l[1] = 1

for i in range(2,87):
    tmp = l[i-2] + l[i-1]
    l[i] = tmp

print(l[n])

Submission status: Accepted

Solution code:
n = int(input())

dp = [-1] * 100
dp[0] = 2
dp[1] = 1

def f(x):
  if x == 0:
    return dp[0]
  
  if x == 1:
    return dp[1]

  if dp[x] == -1:
    dp[x] = f(x-1) + f(x-2)
    return dp[x]
  else:
    return dp[x]

print(f(n))

Submission status: Accepted

Solution code:
n=int(input())
a=2
b=1
for i in range(n-1):
    old_a=a
    a=b
    b=old_a+b
print(b)

Submission status: Accepted

Solution code:
n = int(input())
MAX = 87
L = [0]*MAX
L[0] = 2
L[1] = 1
for i in range(2,MAX):
    L[i] = L[i-1]+L[i-2]

print(L[n])

Submission status: Accepted

Solution code:
n=int(input())
a=[2,1]
for i in range(2,n+1):
  a.append(a[i-1]+a[i-2])
  
print(a[n])

Submission status: Accepted

Solution code:
n = int(input())
lucas = [0] * (n + 1)
lucas[0] = 2
lucas[1] = 1
for i in range(2, n + 1):
  lucas[i] = lucas[i - 1] + lucas[i - 2]
print(lucas[-1])

Submission status: Accepted

Solution code:
n = int(input())

ll =[0]*87
ll[0]=2
ll[1]=1

for i in range(2,n+1):
    ll[i] = ll[i-2]+ll[i-1]

print(ll[n])

Submission status: Accepted

Solution code:
n = int(input())
ans1 = 2
ans2 = 1
ans3 = 3
for i in range(1,n):
    ans3 = ans1 + ans2
    ans1 = ans2 
    ans2 = ans3
if n == 1:
    print(1)
else:
    print(ans3)

Submission status: Accepted

Solution code:
N = int(input())
L = [2,1]

for i in range(N):
    L.append(L[-1]+L[-2])
print(L[N])

Submission status: Accepted

Solution code:
n=int(input())
num=[2,1]
for i in range(n-1):
    num.append(num[-1]+num[-2])
print(num[n])

Submission status: Accepted

Solution code:
n=int(input())
L=[2,1]
for i in range(2,n+1):
    L.append(L[i-1]+L[i-2])
print(L[n])

Submission status: Accepted

Solution code:
def calc_lucas(n):
  """
  Args:
    n (int)
  Returns:
    Luca_n (int)
  """
  luca = [0] * max((n + 1), 2)    # luca[i] = Luca_i
  luca[0] = 2
  luca[1] = 1
  for i in range(2, n+1):
    luca[i] = luca[i-1] + luca[i-2]
  return luca[n]
  



n = int(input())
print(calc_lucas(n))

Submission status: Accepted

Solution code:
n=int(input())
l=[0]*(n+1)
l[0]=2
l[1]=1
for i in range(2,n+1):
    l[i]=l[i-1]+l[i-2]
print(l[-1])

Submission status: Accepted

Solution code:
N = int(input())
prev, ans = 2, 1
for _ in range(N - 1):
    prev, ans = ans, ans + prev
print(ans)

Submission status: Accepted

Solution code:
memo = {0:2, 1:1}
def f(n):
  global memo
  if n in memo:
    return memo[n]
  else:
    res = f(n-1) + f(n-2)
    memo[n] = res
    return res

print(f(int(input())))

Submission status: Accepted

Solution code:
def lucas(n):
  if(n == 0):
    return 2
  if(n == 1):
    return 1
  if(n == 25):
    return 167761
  if(n == 26):
    return 271443
  if(n == 50):
    return 28143753123
  if(n == 51):
    return 45537549124
  if(n == 75):
    return 4721424167835364
  if(n == 76):
    return 7639424778862807
  return lucas(n- 1)+ lucas(n- 2)

N = int(input())

print(lucas(N))

Submission status: Accepted

Solution code:
n=int(input())

if n==1:
  print(1)
else:
  ans=[2,1]
  for i in range(2,n+1):
    ans.append(ans[i-1]+ans[i-2])
  print(ans[n])

Submission status: Accepted

Solution code:
N=int(input())
L_0 = 2
L_1 = 1
if N==0:
    print(L_0)
elif N==1:
    print(L_1)
else:
    for i in range (N-2):
        if i%2 ==0:
            L_0 = L_0 + L_1
        else:
            L_1 = L_0 + L_1
    print(L_0 + L_1)

Submission status: Accepted

Solution code:
N = int(input())

L0 = 2
L1 = 1
if N == 1:
    print(L1)
    exit()
for _ in range(N - 1):
    L = L0 + L1
    L0 = L1
    L1 = L

print(L)

Submission status: Accepted

Solution code:
N = int(input())
L = [0]*(N+1)
L[0] = 2
L[1] = 1
for i in range(2, N+1):
    L[i] = L[i-1] + L[i-2]
print(L[N])

Submission status: Accepted

Solution code:
N = int(input())

L = [0]*100
L[0] = 2
L[1] = 1

for i in range(2,N+1):
	L[i] = L[i-1] + L[i-2]

print(L[N])

Submission status: Accepted

Solution code:
n=int(input())
l0=2
l1=1
if n>1:
    for i in range(2,n+1):
        l=l0+l1
        l0=l1
        l1=l
    print(l1)
elif n==1:
    print(1)
else:
    print(2)

Submission status: Accepted

Solution code:
def ABC_79_B():
    N=int(input())
    l = [0 for _ in range(N*2)]
    l[0]=2
    l[1]=1

    for i in range(N-1):
        if N==1:
            print(l[1])
            break
        else:
            l[i+2] = l[i]+l[i+1]

    print(l[N])

if __name__ == '__main__':

    ABC_79_B()

Submission status: Accepted

Solution code:
N = int(input())
lucas = [2, 1]
for n in range(2, N + 1):
    lucas += [lucas[-1] + lucas[-2]]
print(lucas[-1])

Submission status: Accepted

Solution code:
n = int(input())
l = [2, 1]
for i in range(n-1):
    l.append(l[i]+l[i+1])
print(l[-1])

Submission status: Accepted

Solution code:
n = int(input())
a = 2
b = 1
if n == 1:
    print(1)
else :
    for i in range(n-1):
        c = a + b
        a = b
        b = c
    print(c)

Submission status: Accepted

Solution code:
n = int(input())
if n == 1:
    print(1)
else:
    L = [None] * 100
    L[0] = 2
    L[1] = 1
    for i in range(2, 87):
        L[i] = L[i-1] + L[i-2]
        if i == n: 
            print(L[i])
            exit()

Submission status: Accepted

Solution code:
N = int(input())
L1 = 2
L2 = 1
L3 = 3
if N == 0:
    print(L1)
elif N == 1:
    print(L2)
else:
    for i in range(N-2):
        L1 = L3
        L3 += L2
        L2 = L1
    print(L3)

Submission status: Accepted

Solution code:
n = int(input())
L = [2,1]
for i in range(86):
    L.append(L[i]+L[i+1])

print(L[n])

Submission status: Accepted

Solution code:
N = int(input())
ans = [0] * 87
ans[0] = 2
ans[1] = 1
for i in range(2, 87):
    ans[i] = ans[i - 1] + ans[i - 2]
print(ans[N])

Submission status: Accepted

Solution code:
n = int(input())
lucas = [2, 1] + [0] * (n - 1)
for i in range(2, n + 1):
  lucas[i] = lucas[i - 1] + lucas[i - 2]
print(lucas[n])

Submission status: Accepted

Solution code:
N = int(input())

L= [2,1]

for i in range(2,N+1):
    
    L.append(L[i-2]+L[i-1])
    
print(L[N])

Submission status: Accepted

Solution code:
n=int(input())
a=2
b=1
a1=2
a2=1
for i in range(n-1):
	a=a1+a2
	a1=a
	a2=b
	b=a
if n==1:
	a=1
print(a)

Submission status: Accepted

Solution code:
N = int(input())

L = [0]*(N+1)
L[0], L[1] = 2, 1

for i in range(2,N+1):
  L[i] = L[i-2] + L[i-1]

print(L[N])

Submission status: Accepted

Solution code:
L = [2, 1]
for i in range(85):
	L.append(L[-1] + L[-2])
print(L[int(input())])

Submission status: Accepted

Solution code:
n = int(input())
L = [2, 1]
for i in range(2, n + 1):
    L.append(L[i - 2] + L[i - 1])
    
print(L[n])

Submission status: Accepted

Solution code:
n = int(input())
if n == 1:
    print(1)
else:
    Li = 2
    Lj = 1
    cnt = 2
    while True:
        Lk = Li + Lj
        if cnt == n:
            print(Lk)
            break
        cnt += 1
        Li = Lj
        Lj = Lk

Submission status: Accepted

Solution code:
n = int(input())
ls = [0]*87
for i in range(n+1):
    if i == 0:
        ls[i] = 2
    elif i == 1:
        ls[i] = 1
    else:
        ls[i] = sum(ls[i-2:i])
print(ls[n])

Submission status: Accepted

Solution code:
n = int(input())
l= [2,1]
ans = 1

for i in range(n-1):
  l.append(l[i]+l[i+1])
  ans = l[i]+l[i+1]
  
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

l = [2, 1]

for a in range(1, n):
    l.append(l[a] + l[a-1])

print(l[-1])

Submission status: Accepted

Solution code:
n = int(input())

l = list()
l.append(2)
l.append(1)

for a in range(1, n):
    l.append(l[a] + l[a-1])

print(l[-1])

Submission status: Accepted

Solution code:
n=int(input())
num=[2,1]
for i in range(n-1):
    num.append(num[i+1]+num[i])
print(num[n])

Submission status: Accepted

Solution code:
n = int(input())
luca = [0]*(n+1)
luca[0] = 2
luca[1] = 1
for i in range(2, n+1):
    luca[i] = luca[i-1] + luca[i-2]
print(luca[n])

Submission status: Accepted

Solution code:
from functools import lru_cache
 
N = int(input())
 
@lru_cache(maxsize=None)
def luca(n):
    if n == 0:
        return 2
    if n == 1:
        return 1
 
    return luca(n - 1) + luca(n - 2)
 
print(luca(N))

Submission status: Accepted

Solution code:
n=int(input())
def Fib(n):
    a, b = 2, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
print(Fib(n+1))

Submission status: Accepted

Solution code:
from functools import lru_cache

N = int(input())

@lru_cache(maxsize=None)
def luca(n):
    if n == 0:
        return 2
    if n == 1:
        return 1

    return luca(n - 1) + luca(n - 2)

print(luca(N))

Submission status: Accepted

Solution code:
N = int(input())

def dfs(x):
    memo = [0]*(x+1)
    def _dfs(x):
        if x == 0:
            return 2
        elif x == 1:
            return 1
        elif memo[x] != 0:
            return memo[x]
        else:
            memo[x] = _dfs(x-1) + _dfs(x-2)
            return memo[x]
    return _dfs(x)

print(dfs(N))

Submission status: Accepted

Solution code:
n = int(input())
luca = [0]*(n+1)
luca[0] = 2
luca[1] = 1
for i in range(2, n+1):
    luca[i] = luca[i-1] + luca[i-2]
print(luca[n])

Submission status: Accepted

Solution code:
n=int(input())
a,b=2,1
for _ in range(n):
  a,b=b,a+b
print(a)

Submission status: Accepted

Solution code:
n = int(input())
num = [2, 1]

for i in range(n-1):
    num.append(num[i+1]+num[i])

print(num[n])

Submission status: Accepted

Solution code:
from collections import deque
K = int(input())
l = deque([2, 1])
for _ in range(K):
  l.append(sum(l))
  ans = l.popleft()

print(l.popleft())

Submission status: Accepted

Solution code:
n = int(input())

l = [0]*(n+1)
l[0] = 2
l[1] = 1
#print(l)
for i in range(2,n+1):
  l[i] = l[i-1] + l[i-2]
  
print(l[-1])

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
lis = [2,1]
for i in range(2, n+1):
  lis.append(lis[i-1] + lis[i-2])

print(lis[n])

Submission status: Accepted

Solution code:
n=int(input())
a,b=2,1
for i in range(n):
  a,b=b,a+b

print(a)