alexjercan/bugnet huggingface dataset:
Problem p02675 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

#define error(args...)                                                         \\
  {                                                                            \\
    string _s = #args;                                                         \\
    replace(_s.begin(), _s.end(), ',', ' ');                                   \\
    stringstream _ss(_s);                                                      \\
    istream_iterator<string> _it(_ss);                                         \\
    err(_it, args);                                                            \\
  }

void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

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

  N %= 10;
  if (N == 3) {
    cout << "bon\\n";
  } else if (!N or N == 1 or N == 8 or N == 6) {
    cout << "pon\\n";
  } else
    cout << "hon\\n";

  return 0;
}

Error: 1

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

#define error(args...)                                                         \\
  {                                                                            \\
    string _s = #args;                                                         \\
    replace(_s.begin(), _s.end(), ',', ' ');                                   \\
    stringstream _ss(_s);                                                      \\
    istream_iterator<string> _it(_ss);                                         \\
    err(_it, args);                                                            \\
  }

void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

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

  if (S[S.size() - 1] == '3') {
    cout << "bon" << endl;
  } else if (S[S.size() - 1] == '0' or S[S.size() - 1] == '1' or
             S[S.size() - 1] == '6' or S[S.size() - 1] == '8') {
    cout << "pon" << endl;
  } else
    cout << "hon" << endl;

  return S.size() - 1;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

int K;
string S;
void input() { cin >> K >> S; }

void solve() {
  if (S.length() <= K)
    cout << S << endl;
  else {
    for (int i = 0; i < K; ++i)
      cout << S[i];
    cout << "..." << endl;
  }
}

int main() {
  cin.tie();
  ios::sync_with_stdio(false);
  input();
  solve();
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 0) >= this->size() (which is 0)


Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int K, N;
  string S, ans;
  ans = S.at(0);
  cin >> K;
  cin >> S;
  N = S.size();
  if (N <= K) {
    cout << S << endl;
  } else {
    for (int i = 1; i < N; i++) {
      ans = ans + S.at(i);
    }
    ans = ans + "...";
    cout << ans << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;

int main() {

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

  int size;
  size = s.size();
  vector<char> c;

  if (size <= k) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) {
      c.push_back(s.at(i));
    }
    for (int i = k; i < k + 3; i++) {
      c.push_back('.');
    }
    for (int i = 0; i < c.size(); i++) {
      cout << c.at(i);
    }
    cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;

int main() {

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

  int size;
  size = s.size();
  vector<char> c(size);

  if (size <= k) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) {
      c.at(i) = s.at(i);
    }
    for (int i = k; i < k + 3; i++) {
      c.at(i) = '.';
    }
    for (int i = 0; i < k + 3; i++) {
      cout << c.at(i);
    }
    cout << endl;
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using pq = priority_queue<int>;
using q = queue<int>;

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

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) + "..." << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using pq = priority_queue<int>;
using q = queue<int>;

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

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    string ss;
    rep(i, k) ss[i] = s[i];
    cout << ss + "..." << endl;
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define multitest 0
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pqgreater(x) x, vector<x>, greater<x>
const ll mod = 998244353;
int solve();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  if (multitest)
    cin >> t;
  while (t--)
    solve();
  return 0;
}
int solve() {
  int n;
  string s;
  cin >> n >> s;
  if (s.size() <= n)
    cout << s << endl;
  else {
    for (int i = 0; i < n; i++)
      cout << s[i];
    cout << "...\\n";
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define multitest 0
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pqgreater(x) x, vector<x>, greater<x>
const ll mod = 998244353;
int solve();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  if (multitest)
    cin >> t;
  while (t--)
    solve();
  return 0;
}
int solve() {
  int n;
  string s;
  cin >> s;
  if (s.size() <= n)
    cout << s << endl;
  else {
    for (int i = 0; i < n; i++)
      cout << s[i];
    cout << "...\\n";
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#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;
}


Error: 0

Fixed submission:

#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;
}
Problem p02676 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;
int main() {
  string s;
  int k;
  while (scanf("%d", &k) != EOF) {
    cin >> s;
    if (s.size() <= k)
      cout << s << endl;
    else
      cout << s.substr(0, k) << "..." << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  string s;
  int k;
  while (scanf("%d", &k)) {
    cin >> s;
    if (s.size() <= k)
      cout << s << endl;
    else
      cout << s.substr(0, 7) << "..." << endl;
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#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;
  }
}

Error: 0

Fixed submission:

#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;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <cstring>
#define fastIO                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;

int main() {
  fastIO int n;
  cin >> n;
  string str;
  cin >> str;
  int size = str.size();
  if (size <= n) {
    cout << str;
  } else {

    for (int i = 0; i < n; i++) {
      cout << str[i];
    }
    cout << "...";
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <cstring>
#define fastIO                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

using namespace std;

int main() {
  fastIO int n;
  cin >> n;
  string str, str1 = "...", str2;
  cin >> str;
  int size = str.size();
  if (size <= n) {
    cout << str;
  } else {

    for (int i = 0; i < n; i++) {
      str2[i] = str[i];
      cout << str2[i];
    }
    cout << "...";
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int K;
  string S;

  cin >> K >> S;

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

Error: WA

Fixed submission:

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

int main() {
  int K;
  string S;

  cin >> K >> S;

  if (K > 100) {
    for (int i = 0; i < 100; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: 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 <= (K - 1); i++) {
      ch = S.at(i);
      cout << ch;
    }
    cout << "...";
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 15) >= this->size() (which is 15)


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 <= L; i++) {
      ch = S.at(i);
      cout << ch;
    }
    cout << "...";
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
int main() {
  int n;
  scanf("%d", &n);
  char arr[105];
  scanf("%s", arr);
  int len = strlen(arr);

  if (len > n) {
    for (int i = 0; i < n; i++) {
      printf("%c", arr[i]);
    }
    printf("...");
  } else {
    printf("%s", arr);
  }
}

Error: 0

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;
int main() {
  int K, aux;
  cin >> K;
  char S[K];
  cin >> S;
  aux = strlen(S);
  if (K >= aux) {
    cout << S << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S[i];
    }
    cout << "..." << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#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;
}

Error: -11

Fixed submission:

#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]);
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>

int main() {
  int K;
  char str[101];
  scanf("%d %[^\\n]", &K, str);
  int len = strlen(str);

  if (len <= K) {
    printf("%s", str);
  } else {
    for (int i = 0; i < K; i++) {
      printf("%c", str[i]);
    }
    printf("...");
  }

  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>

int main() {
  int k;
  scanf("%d", &k);
  char string[k];
  scanf("%s", &string);

  for (int i = 0; i < k; i++) {
    printf("%c", string[i]);
  }

  if (string[k] == '\\0') {
    puts("");
  } else {
    printf("...");
  }

  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: 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++) {
    if (i >= S.size()) {
      break;
    }
    ans.push_back(S.at(i));
  }
  if (K < S.size()) {
    ans += dots;
  }
  cout << ans << endl;
}

Error: 0

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++) {
    ans.push_back(S.at(i));
  }
  if (K < S.size()) {
    ans += dots;
  }
  cout << ans << endl;
}
Problem p02676 (C++) — buggy submission, verdict: 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(0, k);
    cout << p << "..." << endl;
  }
  return (0);
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 110) > this->size() (which is 15)


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(a.at(0), k);
    cout << p << "..." << endl;
  }
  return (0);
}
Problem p02676 (C++) — buggy submission, verdict: 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 {
    rep(i, k) { cout << s[i]; }
    cout << "..." << endl;
  }
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 0) >= this->size() (which is 0)


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 {

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

    cout << t << "..." << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string.h>
using namespace std;

int main() {
  char palabra[1000];
  int tam, lon;
  cin >> tam;
  cin >> palabra;
  lon = strlen(palabra);

  if (lon <= tam) {
    for (int i = 0; i < lon; i++) {
      cout << palabra[i];
    }
  } else {
    for (int a = 0; a < tam; a++) {
      cout << palabra[a];
    }
    cout << "...";
  }
  cout << "\\n";
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;
int main() {
  long int K, aux;
  cin >> K;
  char S[K];
  cin >> S;
  aux = strlen(S);
  if (K >= aux) {
    cout << S << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S[i];
    }
    cout << "..." << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
using namespace std;
typedef long long ll;
int main() {
  string s, ans;
  int k;
  cin >> k;
  cin >> s;
  ans = s;
  int len = s.length();
  if (len > k) {
    ans = s.substr(0, k) + "...";
  }
  cout << ans;
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 0) >= this->size() (which is 0)


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int K;
  cin >> K;
  string S;
  getline(cin, S);
  if (K <= S.size()) {
    cout << S << endl;
  } else {
    for (int i = 0; i <= K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: 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;
    // 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;
  }
}

Error: 0

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;
    rep(i, k + 3) {
      if (i <= k - 1)
        ans[i] = s[i];
      else
        ans[i] = '.';
    }
    rep(i, k + 3) cout << ans[i];
    cout << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

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

  if (S.size() > K) {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  } else {
    cout << S << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  string S;
  int K;
  cin >> K >> S;
  for (int i = 0; i < K; i++) {
    cout << S.at(i);
  }
  if (S.size() > K)
    cout << "...";
  cout << endl;
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

#define ll long long

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  string s;
  cin >> k;
  cin >> s;

  if ((int)s.size() <= k) {
    cout << s;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "...";
  }

  return 0;
}


Error: WA

Fixed submission:

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

#define ll long long

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  string s;
  cin >> k >> s;

  if ((int)s.size() <= k) {
    cout << s;
    exit(1);
  }

  for (int i = 0; i < k; i++) {
    cout << s[i];
  }
  cout << "...";

  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: 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 < k; ++i) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}

Error: 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 < 7; ++i) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#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 << "...";
  }
}

Error: WA

Fixed submission:

#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 << "...";
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

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

  string str;
  cin >> str;

  if (str.length() > n) {
    string rep = "...";
    str.replace(n, str.length(), rep);
    cout << str << endl;
  } else {
    cout << str << endl;
  }
}

Error: 0

Fixed submission:

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

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

  string str;
  cin >> str;

  if (str.length() > 7) {
    string rep = "...";
    str.replace(n, str.length(), rep);
    cout << str << endl;
  }
}