Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	fmt.Println(fibonacci(n, make(map[int]int)))
}

func fibonacci(x int, memo map[int]int) int {
	if x == 0 || x == 1 {
		return 1
	}
	if y, ok := memo[x]; ok {
		return y
	}
	z := fibonacci(x-1, memo) + fibonacci(x-2, memo)
	memo[x] = z
	return z
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int fbc[200000];

int fb(int a)
{
	if(fbc[a]>0)
	return fbc[a];
	
	
	if(a<2)
	return 1;
	
	fbc[a]=fb(a-1)+fb(a-2);
	return fbc[a];
	
}

int main()
{
	iniarr(fbc,200000);
	int a;
	scd(a);
	a=fb(a);
	printf("%d\n",a);	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;

template<int n>
struct mat {
    vvi d;

    mat() {
        d = vvi(n, vi(n));
    }

    mat(initializer_list<initializer_list<i64>> m) {
        for (auto a: m) {
            vi row(a.begin(), a.end());
            d.emplace_back(row);
        }
        assert(n == d.size());
        assert(n == d.front().size());
    };

    mat operator+(const mat rhs) {
        mat ret;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ret.d[i][j] = d[i][j] + rhs.d[i][j];
            }
        }
        return ret;
    }

    mat operator-(const mat rhs) {
        mat ret;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ret.d[i][j] = d[i][j] - rhs.d[i][j];
            }
        }
        return ret;
    }

    mat operator*(const mat rhs) {
        mat ret;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    ret.d[i][j] += d[i][k] * rhs.d[k][j];
                }
            }
        }
        return ret;
    }

    mat operator*(const i64 k) {
        mat ret;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ret.d[i][j] = d[i][j] * k;
            }
        }
        return ret;
    }

    static mat eye() {
        mat ret;
        for (int i = 0; i < n; i++) {
            ret.d[i][i] = 1;
        }
        return ret;
    }
};

template<int k>
mat<k> pow(mat<k> a, i64 n) {
    if (n == 0) {
        return mat<k>::eye();
    }
    if (n % 2 == 0) {
        mat<k> t = pow(a, n / 2);
        return t * t;
    }
    return a * pow(a, n - 1);
}

i64 fib(i64 n) {
    if (n <= 1) return n;
    mat<2> f{{1, 1}, {1, 0}};
    mat<2> res = pow(f, n - 2);
    return res.d[0][0] + res.d[0][1];
}

int main() {
    int n;
    cin >> n;
    cout << fib(n + 1) << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;

int ans[100];

int fib(int n){
    if(n == 0 || n == 1) return 1;
    else return ans[n - 1] + ans[n - 2];
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i <= n; i++){
        ans[i] = fib(i);
    }
    cout << ans[n] << endl;
}

C++: #pragma GCC optimize("Ofast","unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace::std;
__attribute__((constructor))
void init(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
}
auto call=[](auto f,auto... args){return f(f,args...);};
auto call_memo=[](auto f,auto&& memo,auto... args){
	auto g=[&memo,f](auto g,auto... args)->decltype(auto){
		if(memo.count(make_tuple(args...)))return memo[make_tuple(args...)];
        else return memo[make_tuple(args...)]=f(g,args...);
    };
	return call(g,args...);
};

int main(){
	int n;
	cin>>n;
	auto f=[&](auto f,int t)->int{
		return t>=2?f(f,t-1)+f(f,t-2):1;
	};
	cout<<call_memo(f,map<tuple<int>,int>(),n)<<endl;
}

C++: #include<bits/stdc++.h>
using namespace std;

vector<int> fibonatti;
int dp[10000];
int calc(int n){
  if(n <= 1) return 1;
  if(dp[n] != -1)return dp[n];
  fibonatti[n] = calc(n - 1) + calc(n - 2);
  return dp[n] = fibonatti[n];
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  fibonatti.resize(n);
  fibonatti[0] = fibonatti[1] = 1;
  for (int i = 0; i <= n; i++) {
    dp[i] = -1;
  }
  dp[0] = dp[1] = 1;
  std::cout << calc(n) << std::endl;
  return 0;
}

C++: #include<iostream>
using namespace std;

int fib(int n, int FIB[]){
    if (FIB[n]) return FIB[n];
    return FIB[n] = fib(n - 1, FIB) + fib(n - 2, FIB);
}

int main(){
    int n;
    cin >> n;
    int FIB[n+1] = {};
    FIB[0] = 1;
    if (n > 0) FIB[1] = 1;
    cout << fib(n, FIB) << endl;

    return 0;
}

C++: #include <iostream>
using namespace std;

int fibo[50];
int rec(int i){
    if(i == 0 || i == 1) return 1;
    if(fibo[i] != -1) return fibo[i];
    
    int ret = 0;
    ret = rec(i-1) + rec(i-2);
    return fibo[i] = ret;
}

int main(void){
    // Your code here!
    int N;
    cin >> N;
    for(int i = 0; i < 50; i++) fibo[i] = -1;
    cout << rec(N) << endl;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

ll n;
pair<P,P> PP[100];

pair<P,P> multiple(pair<P,P> A,pair<P,P> B)
{
	pair<P,P> C;
	P p = A.first,q = A.second;
	P r = B.first,s = B.second;
	C.first = P((p.first*r.first+p.second*s.first),(p.first*r.second+p.second*s.second));
	C.second = P((q.first*r.first+q.second*s.first),(q.first*r.second+q.second*s.second));
	return C;
}

int main()
{
	int cnt=0;
	scanf("%lld",&n);
	if(n==0){
		printf("1\n");
		return 0;
	}else if(n==1){
		printf("1\n");
		return 0;
	}
	n;
	ll buff = n;
	while(buff != 1){
		buff /= 2;
		cnt++;
	}
	PP[0].first = P(0,1);
	PP[0].second = P(1,1);
	rep(i,cnt){
		PP[i+1] = multiple(PP[i],PP[i]);
	}
	pair<P,P> res;
	res.first = P(1,0);
	res.second = P(0,1);
	rep(i,cnt+1){
		if(n & (1 << i)){
			res = multiple(res,PP[i]);
		}
	}
	printf("%d\n",res.second.second);
	return 0;
}