Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b)
    return euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template <class T> inline bool changeMinimum(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template <class T> inline bool changeMaximum(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template <typename T> T output(T answer) {
  cout << answer << endl;
  return 0;
}

/** ----from here ---------------------------------------------------------- */
long long N;
vector<long long> l(87);
// int c = 0;

ll cal(int c) {
  if (c == 1 || c == 0) {
    return l[c];
  }
  l[c] = l[c - 1] + l[c - 2];
  if (c == N) {
    return l[c];
  }
  return cal(++c);
}

int main() {
  cin >> N;
  l[0] = 2;
  l[1] = 1;
  ll ans = cal(2);
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b)
    return euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template <class T> inline bool changeMinimum(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template <class T> inline bool changeMaximum(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template <typename T> T output(T answer) {
  cout << answer << endl;
  return 0;
}

/** ----from here ---------------------------------------------------------- */
long long N;
vector<long long> l(87);
// int c = 0;

ll cal(int c) {
  if (N == 1 || N == 0) {
    return l[N];
  }
  l[c] = l[c - 1] + l[c - 2];
  if (c == N) {
    return l[c];
  }
  return cal(++c);
}

int main() {
  cin >> N;
  l[0] = 2;
  l[1] = 1;
  ll ans = cal(2);
  cout << ans << endl;
}