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

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REPD(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)

template <typename T> inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T> inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  if (s.back() == 's')
    s += "es";
  else
    s += 's';
  cout << s << endl;
  return 0;
}


Error: -8

Fixed submission:

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REPD(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)

template <typename T> inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T> inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int NX = 1e5 + 5;
int N, a[NX];
ll M;

ll gcd(ll aa, ll b) {
  if (aa == 0 || b == 0)
    return max(aa, b);
  return gcd(b % aa, aa);
}

ll lcm(ll aa, ll b) { return 1ll * aa * b / gcd(aa, b); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> M;
  ll l = 1;
  REP(i, 0, N) {
    cin >> a[i];
    l = lcm(l, a[i]);
  }
  REP(i, 0, N) {
    if (l / a[i] % 2 == 0) {
      cout << 0 << "\\n";
      return 0;
    }
  }
  l /= 2;
  cout << M / l / 2 + M / l % 2 << "\\n";
  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error


#include <iostream>
#include <string>
using namespace std;
int main() {
  int i;
  string str;
  cin >> str;
  int str1 = str.size();
  if (str.at(str1 - 1) == 's') {
    cout << str + "es" << endl;
  } else {
    cout << str + "s" << endl;
  }
}


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


Fixed submission:


#include <iostream>
#include <string>
using namespace std;
int main() {
  int i;
  string str;
  cin >> str;
  int str1 = str.size();
  if (str.at(str1) == 's') {
    cout << str + "es" << endl;
  } else {
    cout << str + "s" << endl;
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, c;
  cin >> s;
  c = s;
  if (s[s.length() - 1] != 's')
    c += "s";
  else {
    c += "es";
  }
  cout << c;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, c;
  cin >> s;
  c = s;
  if (s[s.length() - 1] != 's')
    c += "s";
  else {
    c.erase(c.end());
    c += "es";
  }
  cout << c;
  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  cin >> a;
  string d = "es", e = "s";
  int b = a.size();
  char c = a.at(b - 1);
  if (c == 's')
    cout << a + d;
  else
    cout << a + e;

  return 0;
}


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


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  string d = "es", e = "s";
  int b = a.size();
  char c = a.at(b - 1);
  if (c == 's')
    cout << a + d;
  else
    cout << a + e;

  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string word, answer;
  cin >> word;

  if (word.at(word.size() - 1) == 's') {
    answer = word + "es";
  } else {
    answer = word + 's';
  }
  cout << answer << endl;
}

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


Fixed submission:

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

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

  if (word.at(word.size() - 1) == 's') {
    word.at(word.size()) = 'e';
    word.at(word.size()) = 's';
  } else {
    word.at(word.size()) = 's';
  }
  cout << word << endl;
}
Problem p02546 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  if (s[n - 1] == 's')
    cout << s << "es" << endl;
  else
    cout << s << "s" << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  string s;
  cin >> s;
  for (i = 0; i < s.length(); i++) {
    if (s[s.length() - 1] == 's') {
      s.push_back('e');
      s.push_back('s');
    } else
      s.push_back('s');
  }
  cout << s;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string s;
  int a;
  cin >> s;
  a = s.size();
  if (s.at(a - 1) == 's') {
    cout << s << "es";
  } else {
    cout << s << "s";
  }
}

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


Fixed submission:

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

int main() {
  string s;
  if (s.at(s.size() - 1) == 's') {
    cout << s << "es";
  } else {
    cout << s << "s";
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main(void) {
  char s[1003];
  int i, len, k = 0;
  scanf("%s", s);
  len = strlen(s);
  if (s[len - 1] == 's') {
    s[len] = 'e';
    s[len + 1] = 's';
    k = 1;
  } else
    s[len] = 's';
  if (k == 1) {
    for (i = 0; i < len + 2; i++)
      printf("%c", s[i]);
  } else {
    for (i = 0; i <= len; i++)
      printf("%c", s[i]);
  }
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main(void) {
  char s[103];
  int i, len, k = 0;
  scanf("%s", s);
  len = strlen(s);
  if (s[len - 1] == 's') {
    s[len] = 'e';
    s[len + 1] = 's';
    k = 1;
  } else
    s[len] = 's';
  if (k == 1) {
    for (i = 0; i < len + 2; i++)
      printf("%c", s[i]);
  } else {
    for (i = 0; i <= len; i++)
      printf("%c", s[i]);
  }
  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string str;
  cin >> str;
  if (str.at(str.size() - 1) == 's')
    cout << str + "es" << endl;
  else
    cout << str + 's' << endl;
}


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


Fixed submission:

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

int main() {
  string str;
  if (str.at(str.size() - 1) == 's')
    cout << str + "es" << endl;
  else
    cout << str + 's' << endl;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string.h>
using namespace std;
int main() {
  char w[1000];
  cin >> w;
  int l = strlen(w);
  if (w[l - 1] == 's')
    cout << w << "es";
  else
    cout << w << 's';
}


Error: WA

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;
int main() {
  char w[1000];
  cin >> w;
  int l = strlen(w);
  if (w[l - 1] == 's') {
    char p[l + 1];
    w[l] = 'e';
    w[l + 1] = 's';
    strcpy(p, w);
    for (int i = 0; i <= l + 1; i++) {
      cout << p[i];
    }
  }

  else {
    w[l] = 's';
    char p[l];
    strcpy(p, w);
    for (int i = 0; i <= l; i++) {
      cout << p[i];
    }
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string takahashi;
  cin >> takahashi;
  if (takahashi.at(takahashi.size() - 1) == 's') {
    takahashi += "es";
  } else {
    takahashi += "s";
  }

  cout << takahashi << endl;
}


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


Fixed submission:

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

int main() {
  string takahashi;
  cin >> takahashi;
  if (takahashi.at(takahashi.size()) == 's') {
    takahashi += "es";
  } else {
    takahashi += "s";
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#pragma warning(disable : 4996)
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
#define MAX 1010

char str[MAX];

int main() {
  scanf("%s", str);
  for (int i = 0; str[i] != '\\0'; i++) {
    if (str[i + 1] == '\\0') {
      if (str[i] == 's')
        strcat(str, "es");
      else
        strcat(str, "s");
      break;
    }
  }
  printf("%s", str);
}

Error: WA

Fixed submission:

#pragma warning(disable : 4996)
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
#define MAX 1001

char str[MAX];

int main() {
  scanf("%s", str);
  for (int i = 0; str[i] != '\\0'; i++) {
    if (str[i + 1] == '\\0') {
      if (str[i] == 's')
        strcat(str, "es");
      else
        strcat(str, "s");
      break;
    }
  }
  printf("%s", str);
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main() {
  char s[1000];
  cin >> s;
  int len = strlen(s);
  if (s[len - 1] != 's')
    cout << s << "s";
  else if (s[len - 1] == 's')
    cout << s << "es";
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main() {
  char S[256];
  cin >> S;
  int len = strlen(S);
  if (S[len - 1] != 's')
    cout << S << "s";
  if (S[len - 1] == 's')
    cout << S << "es";
  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

void change_to_plural(char *input_string, char *output_string) {
  int n;
  n = strlen(input_string);

  if (input_string[n - 1] == 's') {
    input_string[n] = 'e';
    input_string[n + 1] = 's';
    input_string[n + 2] = '\\0';
  } else

  {
    input_string[n] = 's';
    input_string[n + 1] = '\\0';
  }

  output_string = input_string;
  n = strlen(input_string);
  for (int i = 0; i < n; i++)
    cout << output_string[i];
}

int main() {

  char in[1000], out[1000];

  cin >> in;

  change_to_plural(in, out);

  cout << endl;
}

Error: 0

Fixed submission:

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

void change_to_plural(char *input_string, char *output_string) {
  int n;
  n = strlen(input_string);

  if (input_string[n - 1] == 's') {
    input_string[n] = 'e';
    input_string[n + 1] = 's';
    input_string[n + 2] = '\\0';
  } else

  {
    input_string[n] = 's';
    input_string[n + 1] = '\\0';
  }

  output_string = input_string;
  n = strlen(input_string);
  for (int i = 0; i < n; i++)
    cout << output_string[i];
}

int main() {

  char in[10], out[10];

  cin >> in;

  change_to_plural(in, out);

  cout << endl;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

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

  if (text.back() == 's') {
    cout << text << "es" << endl;
  } else {
    cout << text << "s" << endl;
  }
}

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


Fixed submission:

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

int main() {
  string str;
  int i;
  cin >> i >> str;

  i = str.size() - 1;

  if (str.at(i) == 's') {
    cout << str << "es" << endl;
  } else {
    cout << str << "s" << endl;
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  string a;
  cin >> a;
  int len = a.length();
  if (a[len - 1] == 's')
    cout << a << "es" << endl;
  else
    cout << a << 's' << endl;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  char a[105];
  int i, j;
  for (i = 0;; i++) {
    cin >> a[i];
    if (a[i] == '\\n')
      break;
  }
  for (j = 0; j < i - 1; j++) {
    cout << a[j];
  }
  if (a[i] == 's') {
    cout << 'e' << 's';
  } else
    cout << 's';
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's')
    cout << s << "es" << endl;
  else
    cout << s << 's' << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  scanf("%s", &s);
  if (s[s.size() - 1] == 's')
    cout << s << "es" << endl;
  else
    cout << s << 's' << endl;
  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string S;
  cin >> S;
  int n = 0;
  n = S.size();

  if (S.at(n - 1) == 's') {
    cout << S + "es" << endl;
  } else {
    cout << S + 's' << endl;
  }
}


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


Fixed submission:

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

int main() {
  string S;
  cin >> S;
  int n = 0;
  n = S.size();

  if (S.at(n) == 's') {
    cout << S + "es" << endl;
  } else {
    cout << S + 's' << endl;
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int length;
  char str[1000];
  cin >> str;

  length = strlen(str);
  if (str[length - 1] == 's') {
    strcat(str, "es");
    cout << str;
  } else if (str[length - 1] != 's') {
    strcat(str, "s");
    cout << str;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;
int main() {
  int length;
  char str[1000];
  cin >> str;

  length = strlen(str);

  if (str[length - 1] == 's') {
    strcat(str, "es");
    cout << str;
  } else if (str[length - 1] != 's') {
    strcat(str, "s");
    cout << str;
  }
  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string.h>

using namespace std;

int main() {
  char s[1000];
  int i = 0;
  cin >> s;
  int len = strlen(s);
  if (s[len - 1] == 's') {
    cout << s;
    cout << "es";
  } else {
    cout << s;
    cout << "s";
  }
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string.h>

using namespace std;

int main() {
  char s[1000];
  int i = 0;
  while (s[i] != '\\0') {
    cin >> s[i];
    i++;
  }
  int l = i - 1;
  if (s[l] == 's') {
    i = 0;
    while (s[i] != '\\0') {
      cout << s[i];
    }
    cout << "es";
  } else {
    i = 0;
    while (s[i] != '\\0') {
      cout << s[i];
    }
    cout << "s";
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  char s[1005];
  scanf("%s", s);
  if (s[strlen(s) - 1] == 's')
    printf("%ses", s);
  else
    printf("%ss", s);
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  char s[255];
  scanf("%s", s);
  if (s[strlen(s) - 1] == 's')
    printf("%ses", s);
  else
    printf("%ss", s);
  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>
using namespace std;

int main() {
  char s[10000];
  cin >> s;
  char s0[] = "es";
  char s1[] = "s";

  if (s[strlen(s) - 1] == 's') {
    strcat(s, s0);
    cout << s << endl;
  } else {
    strcat(s, s1);
    cout << s << endl;
  }
}

Error: 0

Fixed submission:

#include <cstring>
#include <iostream>
using namespace std;

int main() {
  char s[1000];
  cin >> s;
  char s0[] = "es";
  char s1[] = "s";

  if (s[strlen(s) - 1] == 's') {
    strcat(s, s0);
    cout << s << endl;
  } else {
    strcat(s, s1);
    cout << s << endl;
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  string name;
  int a, x, y;
  char b;

  cin >> name;
  a = name.size();
  x = a - 1;
  y = a - 2;
  b = name.at(x);

  if (b == 's') {
    name = name + 'e' + 's';
    cout << name << endl;
  } else {
    name = name + 's';
    cout << name << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {

  string name;
  int a, x, y;
  char b, c;

  cin >> name;
  a = name.size();

  x = a - 1;
  y = a - 2;
  b = name.at(x);
  c = name.at(y);

  if (b == 's') {

    name = name + 'e' + 's';
    cout << name << endl;

  } else {
    name = name + 's';
    cout << name << endl;
  }
  return 0;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>
#include <map>
#include <math.h>
#include <vector>

typedef long long ll;
// sort(rt,rt+sizeof(rt)/sizeof(rt[0]),greater<>());
using namespace std;

#define rep(i, n) for (i = 0; i < n; i++)
int main() {
  char n[1001];
  cin >> n;
  int a;
  a = (int)strlen(n);
  if (n[a - 1] == 's') {
    cout << n << "es";
    return 0;
  } else if (n[a - 1] != 's') {
    cout << n << 's';
    return 0;
  }
}


Error: WA

Fixed submission:

#include <cstring>
#include <iostream>
#include <map>
#include <math.h>
#include <vector>

typedef long long ll;
// sort(rt,rt+sizeof(rt)/sizeof(rt[0]),greater<>());
using namespace std;

#define rep(i, n) for (i = 0; i < n; i++)
int main() {
  char n[100];
  cin >> n;
  int a;
  a = (int)strlen(n);
  if (n[a - 1] == 's') {
    cout << n << "es";
    return 0;
  } else if (n[a - 1] != 's') {
    cout << n << 's';
    return 0;
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

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

  int A = S.size();
  int B = A - 1;

  if (S.at(B) == 's') {
    cout << S + "es" << endl;
  } else {
    cout << S + "s" << endl;
  }
}

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


Fixed submission:

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

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

  int A = S.size();

  if (S.at(A) == 'S') {
    cout << S + "es" << endl;
  } else {
    cout << S + "s" << endl;
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll int
#define e endl
int main() {
  ll a, b, c, t, i;
  char s[1000];
  cin >> s;
  a = strlen(s);

  if (s[a - 1] == 's') {
    cout << s;
    cout << "es";
  } else {
    cout << s;
    cout << "s";
  }
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define e endl
int main() {
  ll a, b, c, t, i;
  char s[100];
  cin >> s;
  a = strlen(s);

  if (s[a - 1] == 's') {
    cout << s;
    cout << "es";
  } else {
    cout << s;
    cout << "s";
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string S;
  cin >> S;
  char k = 's';

  if (S.at(S.size() - 1) == k) {
    cout << S + "es" << endl;
  } else {
    cout << S + "s" << endl;
  }
}

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


Fixed submission:

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

int main() {
  string S;
  cin >> S;
  char k = 's';

  if (S.at(S.size()) == k) {
    cout << S + "es" << endl;
  }
  cout << S + "s" << endl;
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int X;
  X = S.size();
  if (S.at(X - 1) == 's') {
    cout << S + "es" << endl;
  } else if (S.at(X - 1) != 's') {
    cout << S + "s" << endl;
  }
}


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


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int X;
  X = S.size();
  if (S.at(X) == 's') {
    cout << S + "es" << endl;
  } else if (S.at(X) != 's') {
    cout << S + "s" << endl;
  }
}
Problem p02546 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  char word[1010];
  scanf("%[^\\n]", word);
  getchar();
  int U = strlen(word);

  if (word[U - 1] == 's') {
    printf("%ses\\n", word);
  } else {
    printf("%ss\\n", word);
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  char word[103];
  scanf("%[^\\n]", word);
  getchar();
  int U = strlen(word);
  if (word[U - 1] == 's') {
    printf("%ses\\n", word);
  } else {
    printf("%ss\\n", word);
  }

  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define optimize()                                                             \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl '\\n'
int main() {
  optimize();
  int i, j;
  int n;
  cin >> n;
  long long sum = 0;
  for (i = 1; i <= n - 1; i++) {
    sum += (n - 1) / i;
  }
  cout << sum << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define optimize()                                                             \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl '\\n'
int main() {
  optimize();
  int i, j, k, n;
  cin >> n;
  long long sum = 0;
  for (i = 1; i < n; i++) {
    for (j = 1; j < n; j++) {
      for (k = 1; k < n; k++) {
        if (i * j + k == n)
          sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  ll ans = 0;

  for (ll c = 1; c <= N - 1; c++) {
    ans += (N - 1) / c;
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

ll count_divisor(ll N) {
  ll res = 0;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      res += 1;
      if (N / i != i)
        res += 1;
    }
  }
  return res;
}

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

  ll ans = 0;

  for (ll c = 1; c <= N - 1; c++) {
    ans += count_divisor(N - c);
  }

  cout << ans << endl;

  return 0;
}