Go: package main

/*
フィボナッチ数列
*/

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func fibWithMemo(n int, memo map[int]int) int {
	if n == 0 || n == 1 {
		return 1
	}
	if val, ok := memo[n]; ok {
		return val
	}
	memo[n] = fibWithMemo(n-1, memo) + fibWithMemo(n-2, memo)
	return memo[n]
}

func fib(n int) int {
	memo := make(map[int]int)
	return fibWithMemo(n, memo)
}

func main() {
	scanner := makeScanner(1024)
	n := eGetInt(scanner)
	fmt.Println(fib(n))
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	buf.WriteString("[")
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = ", "
	}
	buf.WriteString("]")
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func min(a []int) int {
	m := a[0]
	for _, v := range a {
		if v < m {
			m = v
		}
	}
	return m
}

func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}
func find(n int, a ints) int {
	for i, v := range a {
		if n == v {
			return i
		}
	}
	return -1
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    ll dp[50];
    dp[0] = 1, dp[1] = 1;
    rep (i, 0, n) { dp[i + 2] = dp[i + 1] + dp[i]; }
    cout << dp[n] << "\n";
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1);
	a.at(0) = 1;
	a.at(1) = 1;
	for(int i=2; i<=n; i++){
		a.at(i) = a.at(i-1) + a.at(i-2);
	}
	cout << a.at(n) << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,dp[45]={1,1};
  cin >> n;
  for(int i = 2 ; i <= n ; i++ ) dp[i] = dp[i-1] + dp[i-2];
  cout << dp[n] << endl;
}

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


int main(){
    int n;
    cin >>n;
    if(n==0){cout<<1;return 0;}
    vector<int> fib(n+1);
    fib[0]=1;
    fib[1]=1;
    for(int i=2;i <= n;i++){
        fib[i]=fib[i-1]+fib[i-2];
    }
    cout <<fib[n]<<endl;
    return 0;
}

C++: # include <bits/stdc++.h>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    rep (i, mat.size()) {
      rep (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    rep (i, v.size()) cout << v[i] << ' ';
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


int main() {
  int N;
  cin >> N;

  vector<int> dp(N+1);
  fill(dp.begin(), dp.end(), 0);
  dp[0] = 1;
  dp[1] = 1;

  for (int i=2; i<=N; i++) {
    dp[i] = dp[i-2] + dp[i-1];
  }

  cout << dp[N] << endl;
}

C++: /*
** 斐波那契数列 使用动态规划来避免重复的计算
*/

# include <cstdio>
# include <cstring>

const int MAX = 44 + 5;

int n, dp[MAX];

// 记忆化递归 
/*
int fib(int i) {
    if (dp[i] != 0) {
        return dp[i];
    }
    if (i <= 1) {
        return 1;
    }
    dp[i] = fib(i - 1) + fib(i - 2);
    return dp[i];
}
*/

// 动态规划

int fib(int t) {
    dp[0] = dp[1] = 1;
    for (int i = 2; i <= t; i++) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    return dp[t];
}

void solve() {
    scanf("%d", &n);
    memset(dp, 0, sizeof(dp));
    printf("%d\n", fib(n));
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
using namespace std;

template<typename Integral = int> Integral fibonacci(const int &n) {
  static std::vector<Integral> dp(2, 1);
  int prev = dp.size();
  if (prev < n + 1) {
    dp.resize(n + 1);
    loop(i, prev, dp.size()) dp[i] = dp[i - 1] + dp[i - 2];
  }
  return dp[n];
}

main {
  int n;
  cin >> n;
  cout << fibonacci(n) << endl;
}

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

int main(void){
	int a=0, b=1, n;
	cin>>n;
	if (n<0) return NULL;

	for (int i=-1; i<n; i++){
		a += b;
		swap(a,b);
	}
	cout<<a<<endl;
	return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

long long fib(long long n, vector<long long>& memo) {
    if (memo[n] >= 0) {
        return memo[n];
    }

    if (n == 0) {
        return 1;
    }
    else if (n == 1) {
        return 1;
    }
    else {
        long long ret = fib(n - 1, memo) + fib(n - 2, memo);
        memo[n] = ret;
        return ret;
    }
}

void Main() {
    long long n;
    cin >> n;

    vector<long long> memo(n + 10, -1LL);
    memo[0] = 1;
    memo[1] = 1;
    long long ans = fib(n, memo);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}