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

Buggy submission (status: Runtime Error):
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define RI register int
#define CI const int &
using namespace std;
const int N = 531442;
int n, m, rt, tot, ch[N][3], ans[N], id[N];
char s[N];
bool rev[N];
inline void build(int &now, CI dep = 0, CI st = 0) {
  now = ++tot;
  if (dep == n)
    return (void)(id[now] = st);
  int len = pow(3, dep);
  build(ch[now][0], dep + 1, st);
  build(ch[now][1], dep + 1, st + len);
  build(ch[now][2], dep + 1, st + (len << 1));
}
inline void rever(CI now) {
  swap(ch[now][1], ch[now][2]);
  rev[now] ^= 1;
}
inline void pushdown(CI now) {
  if (!rev[now])
    return;
  rev[now] = 0;
  for (RI i = 0; i < 3; ++i)
    rever(ch[now][i]);
}
inline void swaping(CI now, CI dep = 0) {
  pushdown(now);
  if (dep == n)
    return;
  swap(ch[now][1], ch[now][2]);
  swap(ch[now][0], ch[now][1]);
  swaping(ch[now][0], dep + 1);
}
inline void DFS(CI now, CI dep = 0, CI st = 0) {
  pushdown(now);
  if (dep == n)
    return (void)(ans[id[now]] = st);
  int len = pow(3, dep);
  DFS(ch[now][0], dep + 1, st);
  DFS(ch[now][1], dep + 1, st + len);
  DFS(ch[now][2], dep + 1, st + (len << 1));
}
int main() {
  RI i;
  scanf("%d%s", &n, s + 1);
  m = strlen(s + 1);
  for (build(rt), i = 1; i <= m; ++i)
    if (s[i] == 'S')
      rever(rt);
    else
      swaping(rt);
  for (DFS(rt), n = pow(3, n), i = 0; i < n; ++i)
    printf("%d ", ans[i]);
  return 0;
}

Fixed submission:
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define RI register int
#define CI const int &
using namespace std;
const int N = 1594324;
int n, m, rt, tot, ch[N][3], ans[N], id[N];
char s[N];
bool rev[N];
inline void build(int &now, CI dep = 0, CI st = 0) {
  now = ++tot;
  if (dep == n)
    return (void)(id[now] = st);
  int len = pow(3, dep);
  build(ch[now][0], dep + 1, st);
  build(ch[now][1], dep + 1, st + len);
  build(ch[now][2], dep + 1, st + (len << 1));
}
inline void rever(CI now) {
  swap(ch[now][1], ch[now][2]);
  rev[now] ^= 1;
}
inline void pushdown(CI now) {
  if (!rev[now])
    return;
  rev[now] = 0;
  for (RI i = 0; i < 3; ++i)
    rever(ch[now][i]);
}
inline void swaping(CI now, CI dep = 0) {
  pushdown(now);
  if (dep == n)
    return;
  swap(ch[now][1], ch[now][2]);
  swap(ch[now][0], ch[now][1]);
  swaping(ch[now][0], dep + 1);
}
inline void DFS(CI now, CI dep = 0, CI st = 0) {
  pushdown(now);
  if (dep == n)
    return (void)(ans[id[now]] = st);
  int len = pow(3, dep);
  DFS(ch[now][0], dep + 1, st);
  DFS(ch[now][1], dep + 1, st + len);
  DFS(ch[now][2], dep + 1, st + (len << 1));
}
int main() {
  RI i;
  scanf("%d%s", &n, s + 1);
  m = strlen(s + 1);
  for (build(rt), i = 1; i <= m; ++i)
    if (s[i] == 'S')
      rever(rt);
    else
      swaping(rt);
  for (DFS(rt), n = pow(3, n), i = 0; i < n; ++i)
    printf("%d ", ans[i]);
  return 0;
}
Problem p02671 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, rt, tot, sum[N], ans[N], t[N][3], lz[N];
char s[N];
void build(int &now, int n, int b, int c) {
  now = ++tot;
  if (n == 0) {
    sum[now] = c;
    return;
  }
  build(t[now][0], n - 1, b * 3, c);
  build(t[now][1], n - 1, b * 3, c + b);
  build(t[now][2], n - 1, b * 3, c + b + b);
}
void updata(int now, int n) {
  swap(t[now][1], t[now][2]);
  lz[t[now][0]] ^= 1;
  lz[t[now][1]] ^= 1;
  lz[t[now][2]] ^= 1;
  lz[now] = 0;
}
void solve(int now, int n) {
  if (n == 0)
    return;
  if (lz[now])
    updata(now, n);
  int a = t[now][0], b = t[now][1], c = t[now][2];
  t[now][1] = a;
  t[now][2] = b;
  t[now][0] = c;
  solve(t[now][0], n - 1);
}
void getans(int now, int n, int b, int c) {
  if (n == 0) {
    ans[sum[now]] = c;
    return;
  }
  if (lz[now])
    updata(now, n);
  getans(t[now][0], n - 1, b * 3, c);
  getans(t[now][1], n - 1, b * 3, c + b);
  getans(t[now][2], n - 1, b * 3, c + b + b);
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  build(rt, n, 1, 0);
  for (int i = 1; s[i]; i++) {
    if (s[i] == 'S')
      lz[rt] ^= 1;
    else
      solve(rt, n);
  }
  getans(rt, n, 1, 0);
  int sum = 1;
  for (int i = 1; i <= n; i++)
    sum *= 3;
  for (int i = 0; i < sum; i++)
    printf(i == sum - 1 ? "%d\n" : "%d ", ans[i]);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, rt, tot, sum[N], ans[N], t[N][3], lz[N];
char s[N];
void build(int &now, int n, int b, int c) {
  now = ++tot;
  if (n == 0) {
    sum[now] = c;
    return;
  }
  build(t[now][0], n - 1, b * 3, c);
  build(t[now][1], n - 1, b * 3, c + b);
  build(t[now][2], n - 1, b * 3, c + b + b);
}
void updata(int now, int n) {
  swap(t[now][1], t[now][2]);
  lz[t[now][0]] ^= 1;
  lz[t[now][1]] ^= 1;
  lz[t[now][2]] ^= 1;
  lz[now] = 0;
}
void solve(int now, int n) {
  if (n == 0)
    return;
  if (lz[now])
    updata(now, n);
  int a = t[now][0], b = t[now][1], c = t[now][2];
  t[now][1] = a;
  t[now][2] = b;
  t[now][0] = c;
  solve(t[now][0], n - 1);
}
void getans(int now, int n, int b, int c) {
  if (n == 0) {
    ans[sum[now]] = c;
    return;
  }
  if (lz[now])
    updata(now, n);
  getans(t[now][0], n - 1, b * 3, c);
  getans(t[now][1], n - 1, b * 3, c + b);
  getans(t[now][2], n - 1, b * 3, c + b + b);
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  build(rt, n, 1, 0);
  for (int i = 1; s[i]; i++) {
    if (s[i] == 'S')
      lz[rt] ^= 1;
    else
      solve(rt, n);
  }
  getans(rt, n, 1, 0);
  int sum = 1;
  for (int i = 1; i <= n; i++)
    sum *= 3;
  for (int i = 0; i < sum; i++)
    printf(i == sum - 1 ? "%d\n" : "%d ", ans[i]);
}
Problem p02675 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int sum = 0, num, num1;
  cin >>　num;
  num1 = num;
  while (0 < num1) {
    num1 = (num1 / 10);
    sum++;
  }
  sum = sum - 1;
  while (sum > 0) {
    num = num / 10;
  }
  switch (num) {
  case 3:
    std ::cout << "bon" << endl;
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    std ::cout << "pon" << endl;
    break;
  default:
    std ::cout << "hon" << endl;
    break;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int sum = 0, num, num1;
  cin >>　num;
  num1 = num;
  if (num < 10) {
  } else {
    num = num % 10;
  }
  switch (num) {
  case 3:
    std ::cout << "bon" << endl;
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    std ::cout << "pon" << endl;
    break;
  default:
    std ::cout << "hon" << endl;
    break;
  }
  return 0;
}
Problem p02675 (C++)

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

int main() {

  string N;
  char n;
  n = N.at(N.size() - 1);
  if (n == '3') {
    cout << "bon" << endl;
  } else if (n == '0' or n == '1' or n == '6' or n == '8') {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}


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

int main() {

  string N;
  char n;
  cin >> N;
  n = N.at(N.size() - 1);
  if (n == '3') {
    cout << "bon" << endl;
  } else if (n == '0' or n == '1' or n == '6' or n == '8') {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}
Problem p02675 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 3; i > 0; i++) {
    N = N % (10 * i);
  }
  if (N == 3) {
    cout << "bon" << endl;
  }
  if (N == 0 || N == 1 || N == 6 || N == 8) {
    cout << "pon" << endl;
  }
  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
    cout << "hon" << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  for (int i = 3; i > 0; i--) {
    N = N % (10 * i);
  }
  if (N == 3) {
    cout << "bon" << endl;
  }
  if (N == 0 || N == 1 || N == 6 || N == 8) {
    cout << "pon" << endl;
  }
  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
    cout << "hon" << endl;
  }
  return 0;
}
Problem p02675 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;

// defines
typedef long long ll;

ll solve(ll t) { /*hon when the digit in the one's place of
                N
                 is
                2
                ,
                4
                ,
                5
                ,
                7
                , or
                9
                ;
                pon when the digit in the one's place of
                N
                 is
                0
                ,
                1
                ,
                6
                 or
                8
                ;
                bon when the digit in the one's place of
                N
                 is
                3
                .*/
  string s;
  cin >> s;
  ll n = s.size() - 1;
  if (s[n] == '0' or s[n] == '1' or s[n] == '6' or s[n] == '8')
    cout << "pon";
  else if (s[n] == '3')
    cout << "bon";
  else
    cout << "hon";
  if (t > 0)
    cout << "\n";
}

int32_t main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    solve(t);
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;

// defines
typedef long long ll;

ll solve(ll t) { /*hon when the digit in the one's place of
                N
                 is
                2
                ,
                4
                ,
                5
                ,
                7
                , or
                9
                ;
                pon when the digit in the one's place of
                N
                 is
                0
                ,
                1
                ,
                6
                 or
                8
                ;
                bon when the digit in the one's place of
                N
                 is
                3
                .*/
  string s;
  cin >> s;
  ll n = s.size() - 1;
  if (s[n] == '0' or s[n] == '1' or s[n] == '6' or s[n] == '8')
    cout << "pon";
  else if (s[n] == '3')
    cout << "bon";
  else
    cout << "hon";
  if (t > 0)
    cout << "\n";
  return 0;
}

int32_t main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    solve(t);
  }

  return 0;
}
Problem p02675 (C++)

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

int main() {
  int n;
  cin >> n;
  if (n % 10 == 3)
    cout << "bon";
  else if (n % 0 == 0 || n % 0 == 1 || n % 0 == 6 || n % 0 == 8)
    cout << "pon";
  else
    cout << "hon";
}

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

int main() {
  int n;
  cin >> n;
  if (n % 10 == 3)
    cout << "bon";
  else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
    cout << "pon";
  else
    cout << "hon";
}
Problem p02675 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
//{{{ read()
inline int read() {
  register int x = 0, f = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = x * 10 + (ch ^ 48), ch = getchar();
  return x * f;
}
//}}}
int main() {
  // freopen(".in","r",stdin);
  // freopen(".out","w",stdout);
  int n = read(), f1 = 0, f2 = 0, f3 = 0;
  while (n) {
    int y = n % 10;
    if (y == 0 || y == 1 || y == 6 || y == 8)
      f2 = 1;
    if (y == 2 || y == 4 || y == 5 || y == 7 || y == 9)
      f1 = 1;
    if (y == 3)
      f3 = 1;
  }
  if (f3)
    puts("bon");
  else if (f2)
    puts("pon");
  else
    puts("hon");
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
//{{{ read()
inline int read() {
  register int x = 0, f = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = x * 10 + (ch ^ 48), ch = getchar();
  return x * f;
}
//}}}
int main() {
  // freopen(".in","r",stdin);
  // freopen(".out","w",stdout);
  int n = read(), f1 = 0, f2 = 0, f3 = 0;
  int y = n % 10;
  if (y == 0 || y == 1 || y == 6 || y == 8)
    f2 = 1;
  if (y == 2 || y == 4 || y == 5 || y == 7 || y == 9)
    f1 = 1;
  if (y == 3)
    f3 = 1;
  if (f3)
    puts("bon");
  else if (f2)
    puts("pon");
  else
    puts("hon");
  return 0;
}
Problem p02675 (C++)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int out;
  while (n > 0) {
    if (n / 10 == 0)
      out = n;
    else
      n = n % 10;
  }
  string output;
  if (out == 2 || out == 4 || out == 5 || out == 7 || out == 9)
    output = "hon";
  else if (out == 0 || out == 1 || out == 6 || out == 8)
    output = "pon";
  else
    output = "bon";
  cout << output;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int out = n % 10;
  string output;
  if (out == 2 || out == 4 || out == 5 || out == 7 || out == 9)
    output = "hon";
  else if (out == 0 || out == 1 || out == 6 || out == 8)
    output = "pon";
  else
    output = "bon";
  cout << output;
}
Problem p02675 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// 12 10
// --------------------------------------------------------------------------------
#define fast_IO ios_base::sync_with_stio(false), cin.tie(NULL), cout.tie(NULL);
#define ll long long
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define deb(name, value) cout << "->>  " << name << "= " << value << " "
#define frepi(a, b, k) for (int i = a; i <= b; i += k)
#define frepj(a, b, k) for (int j = a; j <= b; j += k)
// --------------------------------------------------------------------------------

void solve() {
  int n;
  cin >> n;
  vector<string> s;
  s[0] = "hon";
  s[1] = "pon";
  s[2] = "bon";
  int r = n % 10;
  if (r == 2 || r == 4 || r == 5 || r == 7 || r == 9) {
    cout << s[0] << "\n";
    return;
  }
  if (r == 3) {
    cout << s[2];
    return;
  }
  cout << s[1];
}

int main() {
  // #ifndef ONLINE_JUDGE
  //    	freopen("/home/suryakant/input.txt","r",stdin);
  //        freopen("/home/suryakant/output.txt","w",stdout);
  //    #endif
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// 12 10
// --------------------------------------------------------------------------------
#define fast_IO ios_base::sync_with_stio(false), cin.tie(NULL), cout.tie(NULL);
#define ll long long
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define deb(name, value) cout << "->>  " << name << "= " << value << " "
#define frepi(a, b, k) for (int i = a; i <= b; i += k)
#define frepj(a, b, k) for (int j = a; j <= b; j += k)
// --------------------------------------------------------------------------------

void solve() {
  int n;
  cin >> n;
  vector<string> s(3);
  s[0] = "hon";
  s[1] = "pon";
  s[2] = "bon";
  int r = n % 10;
  if (r == 2 || r == 4 || r == 5 || r == 7 || r == 9) {
    cout << s[0] << "\n";
    return;
  }
  if (r == 3) {
    cout << s[2];
    return;
  }
  cout << s[1];
}

int main() {
  // #ifndef ONLINE_JUDGE
  //    	freopen("/home/suryakant/input.txt","r",stdin);
  //        freopen("/home/suryakant/output.txt","w",stdout);
  //    #endif
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
}
Problem p02675 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int n, i, m, j, k, s, a;
int main() {
  scanf("%d", n);
  n = n % 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    printf("hon");
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    printf("pon");
  } else if (n == 3) {
    printf("bon");
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, i, m, j, k, s, a;
int main() {
  scanf("%d", &n);
  n = n % 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    printf("hon");
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    printf("pon");
  } else if (n == 3) {
    printf("bon");
  }
}
Problem p02675 (Python)

Buggy submission (status: Runtime Error):
d = {n: "hon" for n in "24579"}
d.update({n: "pon" for n in "0168"})
d.update({3: "bon"})

print(d[input()[-1]])


Fixed submission:
d = {n: "hon" for n in "24579"}
d.update({n: "pon" for n in "0168"})
d.update({"3": "bon"})

print(d[input()[-1]])
Problem p02675 (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<string> s;
  s[0] = "pon";
  s[1] = "pon";
  s[2] = "hon";
  s[3] = "bon";
  s[4] = "hon";
  s[5] = "hon";
  s[6] = "pon";
  s[7] = "hon";
  s[8] = "pon";
  s[9] = "hon";
  cout << s[n % 10] << "\n";
  return 0;
}

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<string> s(10);
  s[0] = "pon";
  s[1] = "pon";
  s[2] = "hon";
  s[3] = "bon";
  s[4] = "hon";
  s[5] = "hon";
  s[6] = "pon";
  s[7] = "hon";
  s[8] = "pon";
  s[9] = "hon";
  cout << s[n % 10] << "\n";
  return 0;
}
Problem p02675 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  vector<string> X;
  X[0] = "pon";
  X[1] = "pon";
  X[2] = "hon";
  X[3] = "bon";
  X[4] = "hon";
  X[5] = "hon";
  X[6] = "pon";
  X[7] = "hon";
  X[8] = "pon";
  X[9] = "hon";
  int Y;
  cin >> Y;
  int S = Y % 10;
  cout << X[S] << endl;
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  vector<string> X(10);
  X[0] = "pon";
  X[1] = "pon";
  X[2] = "hon";
  X[3] = "bon";
  X[4] = "hon";
  X[5] = "hon";
  X[6] = "pon";
  X[7] = "hon";
  X[8] = "pon";
  X[9] = "hon";
  int Y;
  cin >> Y;
  int S = Y % 10;
  cout << X[S] << endl;
}
Problem p02676 (C++)

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

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

  if (s.size() <= k) {
    cout << s;
  } else {

    cout << s.at(0) << s.at(1) << s.at(2) << s.at(3) << s.at(4) << s.at(5)
         << s.at(6) << "...";
  }
}


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

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

  if (s.size() <= k) {
    cout << s;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s.at(i);
    }
    cout << "...";
  }
}
Problem p02676 (C++)

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

int main() {
  int64_t K;
  string S;
  cin >> K >> S;
  int64_t s_size = S.size();
  if (s_size <= K) {
    cout << S << endl;
  } else {
    cout << S.erase(7) << "..." << endl;
  }
}

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

int main() {
  int64_t K;
  string S;
  cin >> K >> S;
  int64_t s_size = S.size();
  if (s_size <= K) {
    cout << S << endl;
  } else {
    cout << S.erase(K) << "..." << endl;
  }
}
Problem p02676 (C++)

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

using namespace std;

int main() {
  int K;
  string S;

  cin >> K;
  cin >> S;

  if (K >= sizeof(S)) {
    cout << S << endl;
  } else {
    S = S.erase(K);
    S = S + "...";
    cout << S << endl;
  }

  return 0;
}

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

using namespace std;

int main() {
  int K;
  string S;

  cin >> K;
  cin >> S;

  if (K >= S.length()) {
    cout << S << endl;
  } else {
    S = S.erase(K);
    S = S + "...";
    cout << S << endl;
  }

  return 0;
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S;
  int L, K;
  cin >> K;
  cin >> S;
  char ch;
  L = S.length();
  if (L <= K) {
    cout << S << "";
  } else {
    for (int i = 0; i <= L; i++) {
      ch = S.at(i);
      cout << ch;
    }
    cout << "...";
  }
  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S;
  int L, K;
  cin >> K;
  cin >> S;
  char ch;
  L = S.length();
  if (L <= K) {
    cout << S << "";
  } else {
    for (int i = 0; i <= (K - 1); i++) {
      ch = S.at(i);
      cout << ch;
    }
    cout << "...";
  }
  return 0;
}
Problem p02676 (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 k;
  string s;
  cin >> k >> s;
  string ans;
  char add;
  rep(i, k) {
    add = s.at(i);
    ans += add;
  }
  if (s.size() > k)
    ans += "...";
  cout << ans << endl;
  return 0;
}

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 k;
  string s;
  cin >> k >> s;
  string ans;
  char add;
  rep(i, k) {
    try {
      add = s.at(i);
    } catch (out_of_range) {
      break;
    }
    ans += add;
  }
  if (s.size() > k)
    ans += "...";
  cout << ans << endl;
  return 0;
}
Problem p02676 (C++)

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  long long a = s.size();
  if (a < k + 1) {
    cout << s << endl;
  } else {
    for (int i = 0; i < 7; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}


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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  long long a = s.size();
  if (a < k + 1) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}
Problem p02676 (C++)

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

int main() {
  string s, t;
  int k;
  cin >> k >> s;

  if (s.size() <= k)
    cout << s << endl;
  if (s.size() > k) {
    for (int i = 0; i < 7; i++) {
      t.push_back(s.at(i));
    }
    cout << t + "..." << endl;
  }
}

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

int main() {
  string s, t;
  int k;
  cin >> k >> s;

  if (s.size() <= k)
    cout << s << endl;
  if (s.size() > k) {
    for (int i = 0; i < k; i++) {
      t.push_back(s.at(i));
    }
    cout << t + "..." << endl;
  }
}
Problem p02676 (C++)

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

int main() {
  int X;
  cin >> X;
  string A;
  cin >> A;
  int B = 0;
  if (A.size() <= X) {
    cout << A << endl;
  } else {
    B = X - A.size();
    cout << A.at(0) << A.at(1) << A.at(2) << A.at(3) << A.at(4) << A.at(5)
         << A.at(6) << "..." << endl;
  }
}

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

int main() {
  int X;
  cin >> X;
  string A;
  cin >> A;
  int B = 0;
  if (A.size() <= X) {
    cout << A << endl;
  } else {
    B = X - A.size();
    for (int i = 0; i < X; i++) {
      cout << A.at(i);
    }
    cout << "..." << endl;
  }
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll)(1e9)
#define mod (ll)(1e9 + 7)
#define endl "\n"
#define tt                                                                     \
  ll testcase;                                                                 \
  cin >> testcase;                                                             \
  while (testcase--)

const int mxn = 1e5 + 5;
ll n;

int solve() {
  cin >> n;
  string s;
  cin >> s;
  ll k = s.size();
  if (k <= n) {
    cout << s;
  } else {
    // string t = s.substr(0, n);
    cout << s.substr(0, n) << "...";
  }
}

int main() {
  fast;
  ll testcase;
  testcase = 1;
  // cin>>testcase;
  while (testcase--) {
    solve();
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll)(1e9)
#define mod (ll)(1e9 + 7)
#define endl "\n"
#define tt                                                                     \
  ll testcase;                                                                 \
  cin >> testcase;                                                             \
  while (testcase--)

const int mxn = 1e5 + 5;
ll n;

void solve() {
  cin >> n;
  string s;
  cin >> s;
  ll k = s.size();
  if (k <= n) {
    cout << s;
  } else {
    // string t = s.substr(0, n);
    cout << s.substr(0, n) << "...";
  }
}

int main() {
  fast;
  ll testcase;
  testcase = 1;
  // cin>>testcase;
  while (testcase--) {
    solve();
  }
}
Problem p02676 (C++)

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

using namespace std;

int ABC_168_B() {

  int k;
  string s;
  string s_r;
  cin >> k;
  cin >> s;

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    s_r = s.erase(7);
    cout << s_r << "..." << endl;
  }
  return 0;
}

int main() {
  ABC_168_B();

  return 0;
}

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

using namespace std;

int ABC_168_B() {

  int k;
  string s;
  string s_r;
  cin >> k;
  cin >> s;

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    s_r = s.erase(k);
    cout << s_r << "..." << endl;
  }
  return 0;
}

int main() {
  ABC_168_B();

  return 0;
}
Problem p02676 (C++)

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

int main() {
  int K;
  std::string S;
  std::cin >> K >> S;

  if (K > S.size()) {
    for (int i = 0; i < K; ++i) {
      std::cout << S.at(i);
    }
    std::cout << "...\n";
  } else {
    std::cout << S << "\n";
  }

  return 0;
}

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

int main() {
  int K;
  std::string S;
  std::cin >> K >> S;

  if (K < S.size()) {
    for (int i = 0; i < K; ++i) {
      std::cout << S.at(i);
    }
    std::cout << "...\n";
  } else {
    std::cout << S << "\n";
  }

  return 0;
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define int32 int32_t

using namespace std;

int32 main() {
  ios_base::sync_with_stdio(false);
  int k;
  string s;
  cin >> k >> s;
  if (k >= s.size()) {
    cout << s;
    return 1;
  } else {
    cout << s.substr(0, k) + "...";
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define int32 int32_t

using namespace std;

int32 main() {
  ios_base::sync_with_stdio(false);
  int k;
  string s;
  cin >> k >> s;
  if (k >= s.size()) {
    cout << s;
    return 0;
  } else {
    cout << s.substr(0, k) + "...";
  }
  return 0;
}
Problem p02676 (C++)

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

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

int main(void) {
  int N = 0;
  string S;
  cin >> N;
  cin >> S;
  for (int i = 0; i < N; i++) {
    cout << S.at(i);
  }
  if (S.size() > N) {
    cout << "...";
  }
}

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

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

int main(void) {
  int N = 0;
  string S;
  cin >> N;
  cin >> S;
  int A = S.size();
  int R = min(A, N);
  for (int i = 0; i < R; i++) {
    cout << S.at(i);
  }
  if (S.size() > N) {
    cout << "...";
  }
}
Problem p02676 (Python)

Buggy submission (status: Runtime Error):
k = int(input())
s = list(map(str, input()))
if len(s) > k:
    for i in range(k):
        print(s[i], end="")
    print("...")
else:
    for i in s:
        print(s[i], end="")
    print()


Fixed submission:
k = int(input())
s = list(map(str, input()))
if len(s) > k:
    for i in range(k):
        print(s[i], end="")
    print("...")
else:
    for i in s:
        print(i, end="")
    print()
Problem p02676 (C++)

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

int main() {
  int K = 0;
  string S;

  cin >> K >> S;

  if (S.size() <= K)
    cout << S;

  else {
    for (int i = 0; i < 7; i++) {
      cout << S.at(i);
    }
    cout << "...";
  }
}


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

int main() {
  int K = 0;
  string S;

  cin >> K >> S;

  if (S.size() <= K)
    cout << S;

  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "...";
  }
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
  int K;
  string S;

  cin >> K >> S;
  int A = S.size();
  string B = S.substr(K - 1);
  if (A <= K) {
    cout << S << endl;
  }

  else {
    cout << B << "..." << endl;
  }
}

Fixed submission:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
  int K;
  string S;

  cin >> K >> S;
  int A = S.size();
  string B = S.substr(0, K);
  if (A <= K) {
    cout << S << endl;
  }

  else {
    cout << B << "..." << endl;
  }
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() > 7) {
    cout << S.erase(K) << "..." << endl;
  } else {
    cout << S << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() > K) {
    cout << S.erase(K) << "..." << endl;
  } else {
    cout << S << endl;
  }
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <vector>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int max(int a, int b) {
  int max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
int min(int a, int b) {
  int min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}

int main() {
  string s;
  int k;
  string t;

  cin >> k;
  cin >> s;

  if (s.size() <= k) {
    cout << s << endl;
  } else {

    for (int i = 0; i < k; i++) {
      t.at(i) = s.at(i);
    }

    cout << t << "..." << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <vector>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int max(int a, int b) {
  int max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
int min(int a, int b) {
  int min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}

int main() {
  string s;
  int k;
  string t;

  cin >> k;
  cin >> s;

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    rep(i, k) { cout << s[i]; }
    cout << "..." << endl;
  }
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
  int k;
  cin >> k;
  string a, p;
  cin >> a;
  int b;
  b = a.size();
  if (k >= b) {
    cout << a << endl;
  } else {
    p = a.substr(a.at(0), k);
    cout << p << "..." << endl;
  }
  return (0);
}

Fixed submission:
#include <bits/stdc++.h>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
  int k;
  cin >> k;
  string a, p;
  cin >> a;
  int b;
  b = a.size();
  if (k >= b) {
    cout << a << endl;
  } else {
    p = a.substr(0, k);
    cout << p << "..." << endl;
  }
  return (0);
}
Problem p02676 (C++)

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

#ifndef LOCAL
#define fprintf                                                                \
  if (false)                                                                   \
  fprintf
#endif
#define debug_int(x) fprintf(stderr, "%s = %d\n", #x, x)
#define debug_double(x) fprintf(stderr, "%s = %llf\n", #x, x)
#define debug_array(v, n)                                                      \
  fprintf(stderr, "%s = [ ", #v);                                              \
  for (int i = 0; i < n; i++)                                                  \
    fprintf(stderr, "%d ", v[i]);                                              \
  fprintf(stderr, "]\n")
#define forr(i, start, end) for (int i = start; i < end; i++)

using lli = long long int;
using ii = pair<int, int>;

const int MAXN = 100010;

int main() {
  int k;
  char s[128];
  scanf("%d %s", k, s);
  int n = strlen(s);
  if (n <= k) {
    printf("%s\n", s);
  } else {
    s[k] = 0;
    printf("%s...\n", s);
  }
}


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

#ifndef LOCAL
#define fprintf                                                                \
  if (false)                                                                   \
  fprintf
#endif
#define debug_int(x) fprintf(stderr, "%s = %d\n", #x, x)
#define debug_double(x) fprintf(stderr, "%s = %llf\n", #x, x)
#define debug_array(v, n)                                                      \
  fprintf(stderr, "%s = [ ", #v);                                              \
  for (int i = 0; i < n; i++)                                                  \
    fprintf(stderr, "%d ", v[i]);                                              \
  fprintf(stderr, "]\n")
#define forr(i, start, end) for (int i = start; i < end; i++)

using lli = long long int;
using ii = pair<int, int>;

const int MAXN = 100010;

int main() {
  int k;
  char s[128];
  scanf("%d %s", &k, s);
  int n = strlen(s);
  if (n <= k) {
    printf("%s\n", s);
  } else {
    s[k] = 0;
    printf("%s...\n", s);
  }
}
Problem p02676 (C++)

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

int main() {
  int K;
  string S;
  string ans = "", dots = "...";
  cin >> K >> S;
  for (int i = 0; i < K; i++) {
    ans.push_back(S.at(i));
  }
  if (K < S.size()) {
    ans += dots;
  }
  cout << ans << endl;
}

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

int main() {
  int K;
  string S;
  string ans = "", dots = "...";
  cin >> K >> S;
  for (int i = 0; i < K; i++) {
    if (i >= S.size()) {
      break;
    }
    ans.push_back(S.at(i));
  }
  if (K < S.size()) {
    ans += dots;
  }
  cout << ans << endl;
}
Problem p02676 (C++)

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

using namespace std;

int main() {
  int k;
  string s;
  cin >> k >> s;
  int r = k;
  s.erase(r, s.length() - k);
  s += "...";
  cout << s;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (k >= s.length()) {
    cout << s;
    return 0;
  }
  s += " ";
  for (int i = 0; i < k; i++) {
    if (s[i] == ' ')
      break;
    cout << s[i];
  }
  cout << "...";
  return 0;
}
Problem p02676 (C++)

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i = (int)N - 1; i >= 0; i--)
#define RLOOP(i, N) for (int i = (int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main() {
  int k;
  string s;
  cin >> k >> s;
  int len = s.size();
  if (k >= len) {
    cout << s << endl;
  } else {
    for (int i = k; i < k + 3; i++) {
      s[i] = '.';
    }
    s.erase(k + 3);
    cout << s << endl;
  }
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i = (int)N - 1; i >= 0; i--)
#define RLOOP(i, N) for (int i = (int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main() {
  int k;
  string s;
  cin >> k >> s;
  int len = s.size();
  if (k >= len) {
    cout << s << endl;
  } else {
    s.erase(k);
    s += '.';
    s += '.';
    s += '.';
    cout << s << endl;
  }
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-05-17(Sun)
   note
**********************************************************************/

#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 k;
  cin >> k;
  string s;
  cin >> s;
  int temp = s.size();
  if (temp <= k) {
    cout << s << endl;
  } else {
    for (int i = 0; i < 7; ++i) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}

Fixed submission:
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-05-17(Sun)
   note
**********************************************************************/

#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 k;
  cin >> k;
  string s;
  cin >> s;
  int temp = s.size();
  if (temp <= k) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; ++i) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}
Problem p02676 (C++)

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (sizeof(S) <= K) {
    cout << S << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}
Problem p02676 (C++)

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

int main() {
  int k;
  std::string s;
  std::cin >> k >> s;

  std::cout << s.erase(k) + (k < s.size() ? "..." : "") << std::endl;
}


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

int main() {
  int k;
  std::string s;
  std::cin >> k >> s;

  std::cout << (k < s.size() ? s.erase(k) + "..." : s) << std::endl;
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
int main() {
  char a[101];
  int b, c;
  scanf("%d", &b);
  scanf("%s", a);
  for (c = 0; c < strlen(a) - 1; c++)
    printf("%s", a[c]);
}


Fixed submission:
#include <stdio.h>
#include <string.h>
int main() {
  int g;
  char c[101];
  scanf("%d ", &g);
  scanf("%s", c);
  int len = strlen(c);
  if (len <= g) {
    printf("%s\n", c);
  } else {
    for (int i = 0; i < g; i++) {
      printf("%c", c[i]);
    }
    printf("...\n");
  }
  return 0;
}
Problem p02676 (C++)

Buggy submission (status: Runtime Error):
/**
 *    created: 17.05.2020 21:02:58
 **/

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  if (n <= k) {
    cout << s << endl;
  } else {
    // cout << 11 << endl;
    string ans;
    rep(i, k + 3) {
      if (i <= k - 1)
        ans[i] = s[i];
      else
        ans[i] = '.';
    }
    rep(i, k + 3) cout << ans[i];
    cout << endl;
  }
}

Fixed submission:
/**
 *    created: 17.05.2020 21:02:58
 **/

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  if (n <= k) {
    cout << s << endl;
  } else {
    // cout << 11 << endl;
    string ans;
    // cout << "k+3:" <<k+3<< endl;
    /*rep(i,k+3){
        if(i<=k-1)
            ans[i] = s[i];
        else
            ans[i] = '.';
        cout << i << endl;
    }*/
    ans = s.substr(0, k);
    ans += "...";
    // rep(i, ans.size()) cout << ans[i];
    // cout << endl;
    cout << ans << endl;
  }
}
Problem p02676 (C++)

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

int main() {
  string S;
  int K, i, l;
  cin >> K;
  cin >> S;
  l = sizeof(S);
  if (l <= K)
    cout << S;
  else {
    for (i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "...";
  }
}


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

int main() {
  string S;
  int K, i, l;
  cin >> K;
  cin >> S;
  if (S.size() <= K)
    cout << S;
  else {
    for (i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "...";
  }
}
Problem p02677 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;

// defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
#define kill _kill
#define MAX 10000
#define pie 3.1415926535898

ll solve(ll t) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ld hm = 0.5 * (c * 60 + d);
  ld mm = 6 * d;
  hm = (pie * hm) / 180.0;
  mm = (pie * mm) / 180.0;
  ld ans = (a * cos(hm) - b * cos(mm)) * (a * cos(hm) - b * cos(mm)) +
           (a * sin(hm) - b * sin(mm)) * (a * sin(hm) - b * sin(mm));
  ans = sqrt(ans);
  cout << fixed << setprecision(20) << ans;
  if (t > 0)
    cout << "\n";
}

int32_t main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    solve(t);
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;

// defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
#define kill _kill
#define MAX 10000
#define pie 3.1415926535898

ll solve(ll t) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ld hm = 0.5 * (c * 60 + d);
  ld mm = 6 * d;
  hm = (pie * hm) / 180.0;
  mm = (pie * mm) / 180.0;
  ld ans = (a * cos(hm) - b * cos(mm)) * (a * cos(hm) - b * cos(mm)) +
           (a * sin(hm) - b * sin(mm)) * (a * sin(hm) - b * sin(mm));
  ans = sqrt(ans);
  cout << fixed << setprecision(20) << ans;
  if (t > 0)
    cout << "\n";
  return 0;
}

int32_t main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    solve(t);
  }

  return 0;
}