prithivMLmods/Coder-Stat huggingface dataset:
Problem p03536 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;

#define MAX 5002

int n;

vector<pair<int, int>> v;

bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first + a.first < b.first + b.second;
}
long long int dp[MAX][MAX];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int h, p;
    scanf("%d%d", &h, &p);
    v.push_back(make_pair(h, p));
  }
  sort(v.begin(), v.end(), cmp);
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  int mx = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j <= i; j++) {
      if (dp[i][j] == -1)
        continue;
      if (dp[i + 1][j] == -1 || dp[i + 1][j] > dp[i][j]) {
        dp[i + 1][j] = dp[i][j];
        mx = max(mx, j);
      }
      if (dp[i][j] <= v[i].first) {
        long long int nex = dp[i][j] + v[i].second;
        if (dp[i + 1][j + 1] == -1 || dp[i + 1][j + 1] > nex) {
          dp[i + 1][j + 1] = nex;
          mx = max(mx, j + 1);
        }
      }
    }
  }
  cout << mx << endl;
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;

#define MAX 5002

int n;

vector<pair<int, int>> v;

bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first + a.second < b.first + b.second;
}
long long int dp[MAX][MAX];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int h, p;
    scanf("%d%d", &h, &p);
    v.push_back(make_pair(h, p));
  }
  sort(v.begin(), v.end(), cmp);
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  int mx = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j <= i; j++) {
      if (dp[i][j] == -1)
        continue;
      if (dp[i + 1][j] == -1 || dp[i + 1][j] > dp[i][j]) {
        dp[i + 1][j] = dp[i][j];
        mx = max(mx, j);
      }
      if (dp[i][j] <= v[i].first) {
        long long int nex = dp[i][j] + v[i].second;
        if (dp[i + 1][j + 1] == -1 || dp[i + 1][j + 1] > nex) {
          dp[i + 1][j + 1] = nex;
          mx = max(mx, j + 1);
        }
      }
    }
  }
  cout << mx << endl;
  return 0;
}
Problem p03539 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
const int maxn = 101;
const int magic = 4040;
const int mod = 1000000007;
long long o[maxn][maxn * maxn];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  o[n + 1][0] = 1;
  for (int e = n; e >= 1; e--) {
    for (int s = 0; s < magic; s++) {
      if (o[e + 1][s] == 0)
        continue;
      for (int f = 0; f <= k; f++) {
        if (f <= e) {
          o[e][s + (f + s) / e] += o[e + 1][s];
          o[e][s + (f + s) / e] %= mod;
        } else {
          o[e][s] += o[e + 1][s];
          o[e][s] %= mod;
        }
      }
    }
  }
  long long comb = k * (k + 1) / 2;
  comb *= n;
  comb %= mod;
  for (int e = 0; e < n - 1; e++)
    comb *= (k + 1), comb %= mod;
  long long ans = comb;
  for (int e = 0; e < magic; e++)
    ans += mod - (e * o[1][e] % mod), ans %= mod;
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
const int maxn = 103;
const int magic = 4040;
const int mod = 1000000007;
long long o[maxn][maxn * maxn];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  o[n + 1][0] = 1;
  for (int e = n; e >= 1; e--) {
    for (int s = 0; s < magic; s++) {
      if (o[e + 1][s] == 0)
        continue;
      for (int f = 0; f <= k; f++) {
        if (f <= e) {
          o[e][s + (f + s) / e] += o[e + 1][s];
          o[e][s + (f + s) / e] %= mod;
        } else {
          o[e][s] += o[e + 1][s];
          o[e][s] %= mod;
        }
      }
    }
  }
  long long comb = k * (k + 1) / 2;
  comb *= n;
  comb %= mod;
  for (int e = 0; e < n - 1; e++)
    comb *= (k + 1), comb %= mod;
  long long ans = comb;
  for (int e = 0; e < magic; e++)
    ans += mod - (e * o[1][e] % mod), ans %= mod;
  cout << ans << endl;
  return 0;
}
Problem p03541 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <queue>
#include <stdio.h>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, int> pi3;
int mini[1 << 18], maxi[1 << 18];
vector<pii> qs[1000000];
int ans[1000000];
int main() {
  int num;
  scanf("%d", &num);
  fill(maxi, maxi + (1 << num), 1000000000);
  for (int i = 0; i < (1 << num); i++) {
    int z;
    scanf("%d", &z);
    if (z > 0)
      mini[i] = maxi[i] = z;
  }
  for (int i = 0; i < num; i++) {
    for (int j = 0; j < (1 << num); j++) {
      if (j & (1 << i))
        maxi[j - (1 << i)] = min(maxi[j - (1 << i)], maxi[j]);
      else
        mini[j + (1 << i)] = max(mini[j + (1 << i)], mini[j]);
    }
  }
  // for (int i = 0; i < (1 << num); i++)printf("%d %d\n", mini[i], maxi[i]);
  for (int i = 0; i < (1 << num); i++)
    qs[maxi[i]].push_back(make_pair(mini[i], i));
  priority_queue<pi3> que;
  for (int i = (1 << num); i >= 1; i--) {
    for (int j = 0; j < qs[i].size(); j++) {
      que.push(make_pair(make_pair(qs[i][j].first, i), qs[i][j].second));
    }
    if (que.empty()) {
      printf("NO\n");
      return 0;
    }
    pi3 z = que.top();
    que.pop();
    if (!(z.first.first <= i && i <= z.first.second)) {
      printf("NO\n");
      return 0;
    }
    ans[z.second] = i;
  }
  printf("YES\n");
  for (int i = 0; i < (1 << num); i++) {
    int p = 0;
    for (int j = 0; j < num; j++)
      if (i & (1 << j))
        p += 1 << (num - 1 - j);
    printf("%d ", ans[p]);
  }
  printf("\n");
}

Fixed submission:
#include <algorithm>
#include <queue>
#include <stdio.h>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, int> pi3;
int mini[1 << 18], maxi[1 << 18];
vector<pii> qs[1000000];
int ans[1000000];
int main() {
  int num;
  scanf("%d", &num);
  fill(maxi, maxi + (1 << num), 1 << num);
  fill(mini, mini + (1 << num), 1);
  for (int i = 0; i < (1 << num); i++) {
    int z;
    scanf("%d", &z);
    if (z > 0)
      mini[i] = maxi[i] = z;
  }
  for (int i = 0; i < num; i++) {
    for (int j = 0; j < (1 << num); j++) {
      if (j & (1 << i))
        maxi[j - (1 << i)] = min(maxi[j - (1 << i)], maxi[j]);
      else
        mini[j + (1 << i)] = max(mini[j + (1 << i)], mini[j]);
    }
  }
  // for (int i = 0; i < (1 << num); i++)printf("%d %d\n", mini[i], maxi[i]);
  for (int i = 0; i < (1 << num); i++)
    qs[maxi[i]].push_back(make_pair(mini[i], i));
  priority_queue<pi3> que;
  for (int i = (1 << num); i >= 1; i--) {
    for (int j = 0; j < qs[i].size(); j++) {
      que.push(make_pair(make_pair(qs[i][j].first, i), qs[i][j].second));
    }
    if (que.empty()) {
      printf("NO\n");
      return 0;
    }
    pi3 z = que.top();
    que.pop();
    if (!(z.first.first <= i && i <= z.first.second)) {
      printf("NO\n");
      return 0;
    }
    ans[z.second] = i;
  }
  printf("YES\n");
  for (int i = 0; i < (1 << num); i++) {
    int p = 0;
    for (int j = 0; j < num; j++)
      if (i & (1 << j))
        p += 1 << (num - 1 - j);
    printf("%d ", ans[p]);
  }
  printf("\n");
}
Problem p03543 (Python)

Buggy submission (status: Runtime Error):
n = input
print("Yes" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else "No")


Fixed submission:
n = input()
print("Yes" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else "No")
Problem p03543 (Python)

Buggy submission (status: Runtime Error):
# run on python 3.4.3
from sys import stdin


def main():
    digits = map(int, stdin.readline())
    dict = {}
    for digit in digits:
        dict[digit] = 1 + dict.get(digit, 0)
    ans = 3 <= max(dict.values())
    print(["No", "Yes"][ans])


main()


Fixed submission:
# run on python 3.4.3
from sys import stdin


def main():
    n = list(stdin.readline().strip())
    s0 = set()
    s1 = set()
    for i in range(3):
        s0.add(n[i])
    for i in range(1, 4):
        s1.add(n[i])
    ans = len(s0) == 1 or len(s1) == 1
    print(["No", "Yes"][ans])


main()
Problem p03543 (Python)

Buggy submission (status: Runtime Error):
# A - Good Integer
#  標準入力N

N = input()
my_list = []
j = 0

for i in N:
    my_list.append(i)

if my_list[1] == my_list[2] == my_list[3] or my_list[2] == my_list[3] == my_list[4]:
    print("Yes")
else:
    print("No")


Fixed submission:
# A - Good Integer
#  標準入力N

N = input()
my_list = []
j = 0

for i in N:
    my_list.append(i)

if my_list[0] == my_list[1] == my_list[2] or my_list[1] == my_list[2] == my_list[3]:
    print("Yes")
else:
    print("No")
Problem p03543 (C++)

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

int main() {
  vector<char> n(4);
  cin >> n.at(0123);
  if (n.at(0) == n.at(1) == n.at(2) || n.at(1) == n.at(2) == n.at(3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  string n;
  cin >> n;
  if (n.at(0) == n.at(1) && n.at(1) == n.at(2) ||
      n.at(1) == n.at(2) && n.at(2) == n.at(3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a, b;
  a = n % 1000;
  b = n / 10;
  if (a == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  if (a / (a % 10) == 111 || b / (b % 10) == 111)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a, b;
  a = n % 1000;
  b = n / 10;
  if (a == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  if (a % 10 == 0 || b % 10 == 0) {
    cout << "No" << endl;
    return 0;
  }
  if (a / (a % 10) == 111 || b / (b % 10) == 111)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  char *a;
  int l = strlen(a);
  cin >> a;
  for (int i = 0; i < l - 3; i++) {
    if (a[i] == a[i + 1] && a[i + 1] == a[i + 2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[2] == s[3] && s[1] == s[2]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03543 (C++)

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

int main() {
  string n;
  if (n.at(0) == n.at(1) && n.at(1) == n.at(2) ||
      n.at(1) == n.at(2) && n.at(2) == n.at(3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  string n;
  cin >> n;
  if (n.at(0) == n.at(1) && n.at(1) == n.at(2) ||
      n.at(1) == n.at(2) && n.at(2) == n.at(3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  string n;
  cin >> n;
  int a1 = 0, a2 = 0;
  for (int i = 0; i < 3; i++) {
    if (n[0] == n[i]) {
      a1 += 1;
    }
  }
  if (a1 == 3) {
    cout << "Yes" << endl;
    exit(1);
  }
  for (int i = 1; i < 4; i++) {
    if (n[1] == n[i]) {
      a2 += 1;
    }
  }
  if (a2 == 3) {
    cout << "Yes" << endl;
  } else if (a1 != 3 && a2 != 3) {
    cout << "No" << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  string n;
  cin >> n;
  int a1 = 0, a2 = 0;
  for (int i = 0; i < 3; i++) {
    if (n[0] == n[i]) {
      a1 += 1;
    }
  }
  if (a1 == 3) {
    cout << "Yes" << endl;
    return 0;
  }
  for (int i = 1; i < 4; i++) {
    if (n[1] == n[i]) {
      a2 += 1;
    }
  }
  if (a2 == 3) {
    cout << "Yes" << endl;
  } else if (a1 != 3 && a2 != 3) {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03543 (C++)

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

int main() {
  string S;
  cin >> S;
  if (S.at(1) == S.at(2) == S.at(3) || S.at(2) == S.at(3) == S.at(4)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  int N, N1, N2, N3, N4;
  cin >> N;
  N1 = N / 1000;
  N2 = (N - N1 * 1000) / 100;
  N3 = (N - N1 * 1000 - N2 * 100) / 10;
  N4 = N - N1 * 1000 - N2 * 100 - N3 * 10;

  if ((N1 == N2) && (N2 == N3) || (N2 == N3) && (N3 == N4)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long arr[87];
  arr[0] = 2;
  arr[1] = 1;
  for (int i = 2; i <= 86; i++)
    arr[i] = arr[i - 1] + arr[i - 2];
  int n;
  cin >> n;
  cout << arr[n] << endl;
  //	main();
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count = 0;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
    count = 1;
  if (count)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  //	main();
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string N;
  int keep = -1;
  int count = 1;

  cin >> N;

  for (int i = 0; i < N.length(); i++) {
    if (keep == N[i]) {
      count++;
      if (count == 3) {
        cout << "Yes" << endl;
        exit(1);
      }
    } else {
      keep = N[i];
      count = 1;
    }
  }
  cout << "No" << endl;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string N;
  int keep = -1;
  int count = 1;

  cin >> N;

  for (int i = 0; i < N.length(); i++) {
    if (keep == N[i]) {
      count++;
      if (count == 3) {
        cout << "Yes" << endl;
        return 0;
      }
    } else {
      keep = N[i];
      count = 1;
    }
  }
  cout << "No" << endl;
}
Problem p03543 (C++)

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

using namespace std;

int main() {
  char ch[4];
  cin >> ch;
  int n[4];
  for (int i = 0; i < 4; i++) {
    n[i] = ch[i] - '0';
  }
  // sort(n, n + 4);
  int a = (n[0] / n[1]);
  int b = (n[1] / n[2]);
  int c = (n[3] / n[2]);
  if ((a == 1 && b == 1) || (b == 1 && c == 1))
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

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

using namespace std;

int main() {
  char ch[4];
  cin >> ch;
  int n[4];
  for (int i = 0; i < 4; i++) {
    n[i] = ch[i] - '0';
  }
  // sort(n, n + 4);
  if ((n[0] == n[1] && n[1] == n[2]) || (n[2] == n[1] && n[3] == n[2]))
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  string a[4];
  cin >> a[4];
  ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]))
      ? cout << "Yes"
      : cout << "No";
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  string a;
  cin >> a;
  ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]))
      ? cout << "Yes"
      : cout << "No";
  return 0;
}
Problem p03543 (C++)

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

int main() {
  int n, i = 0, cnt = 0;
  int sum[4];
  cin >> n;
  while (n > 0) {
    sum[i] = n % 10;
    n = n / 10;
    i++;
  }
  for (i = 0; i <= 3; i--) {
    if (sum[i] == sum[i + 1]) {
      cnt++;
    }
  }
  if (cnt >= 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int n, i = 0, cnt = 0;
  int sum[4];
  cin >> n;
  while (n > 0) {
    sum[i] = n % 10;
    n = n / 10;
    i++;
  }
  for (i = 0; i <= 2; i++) {
    if (sum[1] != sum[2]) {
    } else if (sum[i] == sum[i + 1]) {
      cnt++;
    }
  }
  if (cnt >= 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int in;
  cin >> in;
  int upper3 = in / 10;
  int lower3 = in - (in / 1000) * 1000;
  int upper = in / 1000;
  int lower = in - (in / 10) * 10;

  if (upper3 / (upper * 111) == 1 || lower3 / (lower * 111) == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int in;
  cin >> in;
  int upper3 = in / 10;
  int lower3 = in - (in / 1000) * 1000;
  int upper = in / 1000;
  int lower = in - (in / 10) * 10;

  if (lower3 == 0) {
    cout << "Yes" << endl;
  } else if (upper3 == upper * 111 || lower3 == lower * 111) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == s.at(i + 1) && s.at(i + 1) == s.at(i + 2)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size() - 2; i++) {
    if (s.at(i) == s.at(i + 1) && s.at(i + 1) == s.at(i + 2)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}
Problem p03543 (C++)

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

int main() {
  string s;
  for (int i = 0; i < 4; i++) {
    cin >> s.at(i);
  }

  if ((s.at(0) == s.at(1) && s.at(1) == s.at(2)) ||
      (s.at(2) == s.at(1) && s.at(3) == s.at(2))) {
    puts("Yes");
  } else {
    puts("No");
  }
}

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

int main() {
  string s;
  cin >> s;

  if ((s.at(0) == s.at(1) && s.at(1) == s.at(2)) ||
      (s.at(2) == s.at(1) && s.at(3) == s.at(2))) {
    puts("Yes");
  } else {
    puts("No");
  }
}
Problem p03543 (C++)

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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (s.size())
    s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  string s;
  cin >> s;
  set<char> c1, c2;
  string s1 = s.substr(0, 3);
  string s2 = s.substr(1, 3);
  for (auto c : s1)
    c1.insert(c);
  for (auto c : s2)
    c2.insert(c);
  cout << ((c1.size() == 1 || c2.size() == 1) ? "Yes" : "No") << endl;
}

int main() {
  setIO("data");
  while (tt--) {
    solve();
  }
  return 0;
}

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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (s.size())
    s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  string s;
  cin >> s;
  set<char> c1, c2;
  string s1 = s.substr(0, 3);
  string s2 = s.substr(1, 3);
  for (auto c : s1)
    c1.insert(c);
  for (auto c : s2)
    c2.insert(c);
  cout << ((c1.size() == 1 || c2.size() == 1) ? "Yes" : "No") << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}
Problem p03543 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <cstdio>
using namespace std;
int main() {
  char a[4];
  scanf("%s", a);
  if (a[1] == a[2] && (a[1] == a[0] || a[2] == a[3]))
    printf("Yes");
  else
    printf("No");
  return 0;
}

Fixed submission:
#include <cmath>
#include <cstdio>
using namespace std;
int main() {
  char a[10];
  scanf("%s", a);
  if (a[1] == a[2] && (a[1] == a[0] || a[2] == a[3]))
    printf("Yes");
  else
    printf("No");
  return 0;
}
Problem p03543 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-

n = input()
if n[0] == n[1] and n[1] == n[2]:
    print("Yes")
elif n[1] == n[2] and n[3] == n[4]:
    print("Yes")
else:
    print("No")


Fixed submission:
# -*- coding: utf-8 -*-

n = input()
if n[0] == n[1] and n[1] == n[2]:
    print("Yes")
elif n[1] == n[2] and n[2] == n[3]:
    print("Yes")
else:
    print("No")
Problem p03543 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> v(4);
  v.at(0) = N / 1000;
  v.at(1) = (N % 1000) / 100;
  v.at(2) = (N % 100) / 10;
  v.at(4) = N % 10;
  if ((v.at(0) == v.at(1) && v.at(0) == v.at(2)) ||
      (v.at(3) == v.at(1) && v.at(3) == v.at(2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v(4);
  v.at(0) = N / 1000;
  v.at(1) = (N % 1000) / 100;
  v.at(2) = (N % 100) / 10;
  v.at(3) = N % 10;
  if ((v.at(0) == v.at(1) && v.at(0) == v.at(2)) ||
      (v.at(3) == v.at(1) && v.at(3) == v.at(2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03543 (C++)

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

using namespace std;

int main() {
  string n;
  cin >> n;

  if (n.at(0) == n.at(1) && n.at(1) == n.at(2)) {
    cout << "Yes" << endl;
    return 0;
  } else if (n.at(2) == n.at(3) && n.at(3) == n.at(4)) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

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

using namespace std;

int main() {
  string n;
  cin >> n;

  if (n.at(0) == n.at(1) && n.at(1) == n.at(2)) {
    cout << "Yes" << endl;
    return 0;
  } else if (n.at(1) == n.at(2) && n.at(2) == n.at(3)) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}
Problem p03543 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
  char a[10];
  int k;
  while (scanf("%s", a) != NULL) {
    k = 0;
    if (a[0] == a[1] && a[1] == a[2])
      k = 1;
    else if (a[3] == a[2] && a[1] == a[2])
      k = 1;
    if (k == 0)
      printf("No\n");
    else
      printf("Yes\n");
  }
}

Fixed submission:
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
  char a[10];
  int k;
  scanf("%c%c%c%c", &a[0], &a[1], &a[2], &a[3]);
  k = 0;
  if (a[0] == a[1] && a[1] == a[2])
    k = 1;
  else if (a[3] == a[2] && a[1] == a[2])
    k = 1;
  if (k == 0)
    printf("No\n");
  else
    printf("Yes\n");
}
Problem p03543 (Python)

Buggy submission (status: Runtime Error):
n = int(input())

if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print("Yes")
else:
    print("No")


Fixed submission:
n = input()

if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print("Yes")
else:
    print("No")
Problem p03543 (Python)

Buggy submission (status: Runtime Error):
N = list(int(input()))
a = set(N)
a = list(a)
if len(a) <= 2:
    print("Yes")
else:
    print("No")


Fixed submission:
N = list(input())

if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
    print("Yes")
else:
    print("No")
Problem p03544 (C++)

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

int64_t calc(vector<int64_t> &memo, int x) {
  if (x == 0) {
    return memo.at(x) = 2;
  } else if (x == 1) {
    return memo.at(x) = 1;
  }

  if (memo[x] != 0) {
    return memo[x];
  } else {
    return memo[x] = calc(memo, x - 2) + calc(memo, x - 1);
  }
}

int main() {
  int n = 0;
  cin >> n;
  vector<int64_t> memo(n);
  cout << calc(memo, n) << endl;
}

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

int64_t calc(vector<int64_t> &memo, int x) {
  if (x == 0) {
    return memo.at(x) = 2;
  } else if (x == 1) {
    return memo.at(x) = 1;
  }

  if (memo[x] != 0) {
    return memo[x];
  } else {
    return memo[x] = calc(memo, x - 2) + calc(memo, x - 1);
  }
}

int main() {
  int n = 0;
  cin >> n;
  vector<int64_t> memo(n + 1);
  cout << calc(memo, n) << endl;
}
Problem p03544 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


for i, n in enumerate(lc()):
    if i == N - 2:
        print(n)
        break


Fixed submission:
N = int(input())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


if N > 1:
    for i, n in enumerate(lc()):
        if i == N - 2:
            print(n)
            break
else:
    print(1)
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;
typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;

const LL INF = 1 << 30;
const LL MOD = 1000000007;

LL memo[90];
int n;

LL ryuka(int a) {
  memo[a] = memo[a - 1] + memo[a - 2];

  if (a == n)
    return memo[a];
  return ryuka(a + 1);
}

int main() {
  memo[0] = 2;
  memo[1] = 1;
  cin >> n;
  cout << ryuka(2) << endl;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;
typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;

const LL INF = 1 << 30;
const LL MOD = 1000000007;

LL memo[90];
int n;

LL ryuka(int a) {
  memo[a] = memo[a - 1] + memo[a - 2];

  if (a == n)
    return memo[a];
  return ryuka(a + 1);
}

int main() {
  memo[0] = 2;
  memo[1] = 1;
  cin >> n;
  if (n == 1)
    cout << 1 << endl;
  else
    cout << ryuka(2) << endl;
}
Problem p03544 (C++)

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

using namespace std;

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

  vector<long long> L(N);

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

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


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

using namespace std;

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

  vector<long long> L(N + 1);

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

  cout << L[N] << endl;
}
Problem p03544 (C++)

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

int64_t luca(int x) {

  vector<int64_t> vec(87, 0);
  vec.at(0) = 2;
  vec.at(1) = 1;
  for (int i = 0; i < x; i++) {
    vec.at(i + 2) = vec.at(i + 1) + vec.at(i);
  }

  return vec.at(x);
}

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

  cout << luca(x) << endl;
}


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

int64_t luca(int x) {

  vector<int64_t> vec(100, 0);
  vec.at(0) = 2;
  vec.at(1) = 1;
  for (int i = 0; i < x; i++) {
    vec.at(i + 2) = vec.at(i + 1) + vec.at(i);
  }

  return vec.at(x);
}

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

  cout << luca(x) << endl;
}
Problem p03544 (C++)

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

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> L(n);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= n; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }

  cout << L[n] << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> L(n + 1);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= n; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }

  cout << L[n] << endl;
}
Problem p03544 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  a.at(0) = 2;
  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;
}

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

int main() {
  int n;
  cin >> n;
  vector<int64_t> a(n + 1);
  a.at(0) = 2;
  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;
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <sstream>

using namespace std;

int main() {
  int n;
  long long l[86] = {0};

  cin >> n;

  l[0] = 2;
  l[1] = 1;

  for (int i = 0; i < n; i++) {
    l[i + 2] = l[i] + l[i + 1];
  }

  cout << l[n] << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <sstream>

using namespace std;

int main() {
  int n;
  long long l[87] = {0};

  cin >> n;

  l[0] = 2;
  l[1] = 1;

  for (int i = 0; i < n; i++) {
    l[i + 2] = l[i] + l[i + 1];
  }

  cout << l[n] << endl;

  return 0;
}
Problem p03544 (C++)

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

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

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

int main() {
  int n;
  cin >> n;
  vector<long long int> l(n + 1);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i <= n; i++)
    l[i] = l[i - 1] + l[i - 2];
  cout << l[n] << endl;
  return 0;
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long int> l(n);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i <= n; i++)
    l[i] = l[i - 1] + l[i - 2];
  cout << l[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long int> l(100);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i <= n; i++)
    l[i] = l[i - 1] + l[i - 2];
  cout << l[n] << endl;
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

// ｘ番目の要素を求める関数
void Lucas_Number(int x, vector<int64_t> &L) {
  if (L[x - 1] == 0) {
    Lucas_Number(x - 1, L); // ｘ－１番目の要素を求める
  }
  if (L[x - 2] == 0) {
    Lucas_Number(x - 2, L); // ｘ－２番目の要素を求める
  }
  L[x] = L[x - 1] + L[x - 2];
}

int main() {
  int N;
  scanf("%d", &N);
  vector<int64_t> L(N + 1, 0);
  L[0] = 2;
  L[1] = 1;
  if (N >= 2) {
    Lucas_Number(N + 1, L);
  }
  printf("%ld\n", L[N]);
}


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

// ｘ番目の要素を求める関数
void Lucas_Number(int x, vector<int64_t> &L) {
  if (L[x - 1] == 0) {
    Lucas_Number(x - 1, L); // ｘ－１番目の要素を求める
  }
  if (L[x - 2] == 0) {
    Lucas_Number(x - 2, L); // ｘ－２番目の要素を求める
  }
  L[x] = L[x - 1] + L[x - 2];
}

int main() {
  int N;
  scanf("%d", &N);
  vector<int64_t> L(N + 1, 0);
  L[0] = 2;
  L[1] = 1;
  if (N >= 2) {
    Lucas_Number(N, L);
  }
  printf("%ld\n", L[N]);
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long> v(n);
  v[0] = 2;
  v[1] = 1;

  for (int i = 2; i <= n; i++) {
    v[i] = v[i - 1] + v[i - 2];
  }
  cout << v[n] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long> v(87); // ここで多分セグフォしてる・・・
  v[0] = 2;
  v[1] = 1;

  for (int i = 2; i <= n; i++) {
    v[i] = v[i - 1] + v[i - 2];
  }
  cout << v[n] << endl;
}
Problem p03544 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<long long int> l(N);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i < N + 1; i++) {
    l[i] = l[i - 2] + l[i - 1];
  }
  cout << l[N] << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long int> l(N + 1);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i < N + 1; i++) {
    l[i] = l[i - 2] + l[i - 1];
  }
  cout << l[N] << endl;
}
Problem p03544 (Python)

Buggy submission (status: Runtime Error):
N = input()
# N = 86


def f(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    elif n == 2:
        return 3
    return 2 * f(n - 2) + f(n - 3)


def g(n):
    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]

    return L[-1]


print(g(N))


Fixed submission:
N = int(input())
# N = 86


def f(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    elif n == 2:
        return 3
    return 2 * f(n - 2) + f(n - 3)


def g(n):
    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]

    return L[-1]


print(g(N))
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n + 1) {
    if (i == 0)
      l[i] = 2;
    else if (i == 1)
      l[i] = 1;
    else
      l[i] = l[i - 1] + l[i - 2];
  }
  cout << l[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n + 1);
  rep(i, n + 1) {
    if (i == 0)
      l[i] = 2;
    else if (i == 1)
      l[i] = 1;
    else
      l[i] = l[i - 1] + l[i - 2];
  }
  cout << l[n] << endl;
}
Problem p03544 (C++)

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

int main() {
  vector<int64_t> L(86);
  int64_t N;
  cin >> N;
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i = 2; i < N + 1; i++) {
    L.at(i) = L.at(i - 1) + L.at(i - 2);
  }

  cout << L.at(N) << endl;
}


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

int main() {
  vector<int64_t> L(87);
  int64_t N;
  cin >> N;
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i = 2; i < N + 1; i++) {
    L.at(i) = L.at(i - 1) + L.at(i - 2);
  }

  cout << L.at(N) << endl;
}
Problem p03544 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> c(N);
  for (int i = 0; i < N + 1; i++) {
    if (i == 0) {
      c.at(0) = 2;
    } else if (i == 1) {
      c.at(1) = 1;
    } else {
      c.at(i) = c.at(i - 1) + c.at(i - 2);
    }
  }
  cout << c.at(N) << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> c(N + 1);
  for (int i = 0; i < N + 1; i++) {
    if (i == 0) {
      c.at(0) = 2;
    } else if (i == 1) {
      c.at(1) = 1;
    } else {
      c.at(i) = c.at(i - 1) + c.at(i - 2);
    }
  }
  cout << c.at(N) << endl;
}
Problem p03544 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int64_t lucas(int64_t n) {
  if (n == 0)
    return 2;
  else if (n == 1)
    return 1;
  else
    return lucas(n - 1) + lucas(n - 2);
}

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

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

int64_t lucas(int64_t n) {
  if (n == 0)
    return 2;
  else if (n == 1)
    return 1;
  else
    return lucas(n - 1) + lucas(n - 2);
}

int main() {
  int64_t n;
  cin >> n;
  if (n == 0) {
    cout << 2 << endl;
    return 0;
  } else if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  int i = 2;
  int64_t num;
  int64_t back2 = 2, back1 = 1;
  while (1) {
    num = back2 + back1;
    if (i == n)
      break;
    i++;
    back2 = back1;
    back1 = num;
  }

  cout << num << endl;
}
Problem p03544 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(N);
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i = 2; i <= N; i++) {
    L.at(i) = L.at(i - 1) + L.at(i - 2);
  }
  cout << L.at(N) << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(N + 1);
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i = 2; i <= N; i++) {
    L.at(i) = L.at(i - 1) + L.at(i - 2);
  }
  cout << L.at(N) << endl;
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i <= n; i++) {
    l[i] = l[i - 1] + l[i - 2];
  }
  cout << l[n];
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n + 1);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i <= n; i++) {
    l[i] = l[i - 1] + l[i - 2];
  }
  cout << l[n];
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#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<int64_t> lucas(87);
  lucas[0] = 2ll;
  lucas[1] = 1ll;
  rep(i, n) { lucas[i + 2] = lucas[i + 1] + lucas[i]; }
  cout << lucas[n] << endl;
}

Fixed submission:
#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<int64_t> lucas(87);
  lucas[0] = 2ll;
  lucas[1] = 1ll;
  for (int i = 2; i <= n; i++) {
    lucas[i] = lucas[i - 1] + lucas[i - 2];
  }
  cout << lucas[n] << endl;
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> A(n);

  REP(i, n + 1) {
    if (i == 0)
      A[i] = 2;
    else if (i == 1)
      A[i] = 1;
    else
      A[i] = A[i - 1] + A[i - 2];
  }
  cout << A[n] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> A(n + 1);

  REP(i, n + 1) {
    if (i == 0)
      A[i] = 2;
    else if (i == 1)
      A[i] = 1;
    else
      A[i] = A[i - 1] + A[i - 2];
  }
  cout << A[n] << endl;
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

// typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
  int N;
  cin >> N;
  vector<long long int> L(N);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }
  cout << L[N] << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

// typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
  int N;
  cin >> N;
  vector<long long int> L(N + 1);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }
  cout << L[N] << endl;
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)

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

  vector<long long> arr(N + 1);
  arr[0] = 2;
  arr[1] = 1;

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

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)

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

  vector<long long> arr(N + 1);
  arr[0] = 2;
  arr[1] = 1;

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

  cout << arr[N] << endl;
}
Problem p03544 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> list(86);
  list.at(0) = 2, list.at(1) = 1;
  for (int i = 2; i < 87; i++) {
    list.at(i) = list.at(i - 1) + list.at(i - 2);
  }
  cout << list.at(N) << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> list(87);
  list.at(0) = 2, list.at(1) = 1;
  for (int i = 2; i < 87; i++) {
    list.at(i) = list.at(i - 1) + list.at(i - 2);
  }
  cout << list.at(N) << endl;
}
Problem p03544 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

long long a[100];
int main() {
  int N, i;
  scanf("%d", N);
  a[0] = 2;
  a[1] = 1;
  for (i = 2; i <= N; i++) {
    a[i] = a[i - 1] + a[i - 2];
  }
  printf("%lld", a[N]);
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

long long a[100];
int main() {
  int N, i;
  scanf("%d", &N);
  a[0] = 2;
  a[1] = 1;
  for (i = 2; i <= N; i++) {
    a[i] = a[i - 1] + a[i - 2];
  }
  printf("%lld", a[N]);
  return 0;
}
Problem p03544 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int64_t> lucas = {2, 1};
  int64_t count = 1;

  for (int i = 0; i < 1e18; i++) {
    lucas.push_back(lucas[i + 1] + lucas[i]);
    count++;

    if (count == n) {
      cout << lucas[i + 2];
      break;
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int64_t> lucas = {2, 1};
  int64_t count = 1;

  for (int i = 0; i < 86; i++) {
    if (n == 1) {
      cout << count;
      break;
    }

    lucas.push_back(lucas[i + 1] + lucas[i]);
    count++;

    if (count == n) {
      cout << lucas[i + 2];
      break;
    }
  }
}
Problem p03544 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

long lucas(long n) {
  if (n == 0)
    return 2;
  if (n == 1)
    return 1;

  return lucas(n - 1) + lucas(n - 2);
}

int main() {
  // 制約見て！！！デカかったらlong longにすること！
  long n;
  cin >> n;
  // long lucas[100];
  // for(int i =2;i<=n;i++){
  // lucas[i] = lucas[i-1]+lucas[i-2];
  // }
  cout << lucas(n) << endl;
}

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

long lucas(long n) {
  if (n == 0)
    return 2;
  if (n == 1)
    return 1;

  return lucas(n - 1) + lucas(n - 2);
}

int main() {
  // 制約見て！！！デカかったらlong longにすること！
  long n;
  cin >> n;
  long lucas[100];
  lucas[0] = 2;
  lucas[1] = 1;
  for (int i = 2; i <= n; i++) {
    lucas[i] = lucas[i - 1] + lucas[i - 2];
  }
  cout << lucas[n] << endl;
}
Problem p03544 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
lucas_number = [0] * (n + 1)
lucas_number[0] = 2
lucas_number[1] = 1
for i in range(2, n + 1):
    lucas_number[i] = lucas_number[i - 1] + lucas_number[i - 2]
print(lucas_number[i])


Fixed submission:
n = int(input())
lucas_number = [0] * (n + 1)
lucas_number[0] = 2
lucas_number[1] = 1
for i in range(2, n + 1):
    lucas_number[i] = lucas_number[i - 1] + lucas_number[i - 2]
print(lucas_number[n])
Problem p03544 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    N = input()
    n0 = 2
    n1 = 1
    if N == 1:
        print(1)
    now = 1
    while now != N:
        n = n0 + n1
        n0 = n1
        n1 = n
        now += 1
    print(n)


Fixed submission:
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    N = input()
    n0 = 2
    n1 = 1
    if N == 1:
        print(1)
    else:
        now = 1
        while now != N:
            n = n0 + n1
            n0 = n1
            n1 = n
            now += 1
        print(n)
Problem p03544 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
l1 = 2
l2 = 1
for i in range(1, n):
    l3 = l1 + l2
    l1 = l2
    l2 = l3
print(l3)


Fixed submission:
n = int(input())
l1 = 2
l2 = 1
for i in range(1, n):
    l3 = l1 + l2
    l1 = l2
    l2 = l3
print(l2)
Problem p03544 (C++)

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

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

  if (n == 2)
    return 2;
  if (n == 1)
    return 1;

  int64_t l0 = 2;
  int64_t l1 = 1;
  int64_t next = 0;
  for (int i = 0; i < n - 1; i++) {
    next = l1 + l0;
    l0 = l1;
    l1 = next;
    // cout << next << endl;
  }
  cout << next << endl;
  return 0;
}

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

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

  if (n == 0) {
    cout << 2 << endl;
    return 0;
  } else if (n == 1) {
    cout << 1 << endl;
    return 0;
  }

  int64_t l0 = 2;
  int64_t l1 = 1;
  int64_t next = 0;
  for (int i = 0; i < n - 1; i++) {
    next = l1 + l0;
    l0 = l1;
    l1 = next;
    // cout << next << endl;
  }
  cout << next << endl;
  return 0;
}
Problem p03544 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
  int N;
  cin >> N;
  vector<int64_t> sum(87);
  sum[0] = 2;
  sum[1] = 1;
  for (int i = 2; i = N; i++) {
    sum[i] = sum[i - 1] + sum[i - 2];
  }
  cout << sum[N] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
  int N;
  cin >> N;
  vector<int64_t> sum(87);
  sum[0] = 2;
  sum[1] = 1;
  for (int i = 2; i <= N; i++) {
    sum[i] = sum[i - 1] + sum[i - 2];
  }
  cout << sum[N] << endl;
}