alexjercan/bugnet huggingface dataset:
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char n;

  while (1) {
    scanf("%c", &n);

    if (n == '\\n')
      break; // 改行のときおわり

    if (isalpha(n)) { // 入力されたものがアルファベットのとき

      if (islower(n))
        printf("%c", toupper(n));
      else if (isupper(n))
        printf("%c", tolower(n));

    } else {
      printf("%c", n);
    }
  }
  printf("\\n");

  return 0;
}


Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
int main() {
  char a;

  while (1) { // 文字の読み込み
    scanf("%c", &a);

    if (isalpha(a)) { // 入力されたのがアルファベットのとき

      if (islower(a))
        printf("%c", toupper(a)); // 小文字のとき
      else if (isupper(a))
        printf("%c", tolower(a)); // 大文字のとき

    } else if (a == '/n') { //.が入ってきたら終わり
      break;

    } else {
      printf("%c", a);
    }
  }

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

#include <cctype>
#include <cstdio>

int main() {
  char ch, a;

  while (1) {
    scanf("%c", &ch);

    if (isalpha(ch)) {
      if (islower(ch))
        printf("%c", toupper(ch));
      else
        printf("%c", tolower(ch));
    } else
      printf("%c", ch);

    if (ch == '\\n')
      break;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int sum = 0;
  char number[1001];

  while (1) {
    cin >> number;

    sum = 0;

    for (int i = 0; i < 1000; i++) {
      if (number[i] == 0)
        break;
      sum += number[i] - '0';
    }

    if (sum == 0)
      break;
    else
      cout << sum << endl;
  }

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

#include <iostream>
#include <string>
using namespace std;
int main() {
  int as[1234], n;
  string A;
  getline(cin, A);
  for (int i = 0; i < A.size(); i++) {
    if (A[n] == '\\n')
      break;
    as[n] = A[n];
    if (as[n] / 32 == 2) {
      as[n] += 32;
      cout << (char)as[n];
    } else if (as[n] / 32 == 3) {
      as[n] -= 32;
      cout << (char)as[n];
    } else {
      cout << A[n];
    }
    n++;
  }
  cout << endl;
}


Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int as, bs[1500], n = 0;
  string A;
  cin >> A;
  while (1) {
    as = A[n];
    if (A[n] == '\\n')
      break;
    if (A == ",") {
      cout << ",";
    } else if (as / 32 == 2) {
      bs[n] = as + 32;
      cout << (char)bs[n];
    } else {
      bs[n] = as - 32;
      cout << (char)bs[n];
    }
    n++;
  }
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  int len, i;
  char m;

  while ((m = getchar()) != EOF) {

    if (isupper(m)) {
      printf("%c", tolower(m));
    } else {
      printf("%c", toupper(m));
    }
  }

  return 0;
}

Error: -11

Fixed submission:

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

int main(void) {
  int len, i;
  char m[1200];

  scanf("%s", m);

  len = strlen(m);

  for (i = 0; i < len; i++) {
    if (isupper(m[i])) {
      printf("%s", tolower(m[i]));
    }

    else if (islower(m[i])) {
      printf("%s", toupper(m[i]));
    }
  }

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

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

int main() {

  string mozi;

  getline(cin, mozi);

  for (int i = 0; i < (int)mozi.size(); i++) {

    if (islower(mozi[i])) {
      mozi[i] = toupper(mozi[i]);
    } else if (isupper(mozi[i])) {
      mozi[i] = tolower(mozi[i]);
    }
  }
  cout << mozi << endl;

  return 0;
}


Error: -11

Fixed submission:

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

int main() {

  string mozi;

  getline(cin, mozi);

  for (int i = 0; (int)mozi.size(); i++) {

    if (islower(mozi[i])) {
      mozi[i] = toupper(mozi[i]);
    } else if (isupper(mozi[i])) {
      mozi[i] = tolower(mozi[i]);
    }
  }
  cout << mozi << endl;

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

#include <cstdio>

#include <cctype>

using namespace std;

int main() {

  char ch;

  while (1) {

    scanf("%c", &ch); // ch?????\\?????? %C ????????£???????????¨??????) //

    if (isalpha(ch)) { // ??¢??????????????????????????\\ //

      if (islower(ch))
        printf(
            "%c",
            toupper(
                ch)); // ??????????°???????????????§???????????´???????????? //

      else
        printf("%c", tolower(ch)); // ?????????????????????ch?????§?????????????°????????????´????????????
                                   // //

    }

    else
      printf("%c", ch); // ????????\\???????????????????????? //

    if (ch == '\\n')
      break; // ????????????????????\\????????????????????? //
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

#include <cctype>

using namespace std;

int main() {

  char ch;

  cin >> ch;

  while (1) {

    if (!islower(ch)) {

      cout << !toupper(ch) << endl;

    }

    else {

      cout << !tolower(ch) << endl;

    } // ch????°???????????????????????????£???????????????ch?????§?????????????????¨?????????????°?????????§???????????°???0????????£????????????????°??????????????????¨????????????
  }

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

#include <cctype>
#include <cstdio>
int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (isalpha(ch)) {
      if (islower(ch))
        printf("%c", toupper(ch));
      else
        printf("%c", tolower(ch));
    } else
      printf("%c", ch);
    if (ch == '\\n')
      break;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (isalpha(ch)) {
      if (islower(ch))
        printf("%c", toupper(ch));
      else
        printf("%c", tolower(ch));
    } else
      printf("%c", ch);
    if (ch == '/n')
      break;
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  char chr;
  while (1) {
    chr = cin.get();
    if (chr == '\\n')
      break;
    if (isalpha(chr)) {
      if (islower(chr))
        chr = toupper(chr);
      else
        chr = tolower(chr);
    }
    cout << chr;
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
  char chr;

  while (1) {
    cin >> chr;

    if (isalpha(chr)) {
      if (islower(chr))
        cout << toupper(chr);
      else
        cout << tolower(chr);
    } else
      cout << chr;
    if (chr == '\\n')
      break;
  }

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

#include <cctype>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (ch == '\\n')
      break;
    else if (isalpha(ch)) {
      if (islower(ch))
        printf("%c", toupper(ch));
      else
        printf("%c", tolower(ch));
    } else
      printf("%c", ch);
  }
  printf("\\n");
  return 0;
}


Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (ch == '\\0')
      break;
    else if (isalpha(ch)) {
      if (islower(ch))
        printf("%c", ch = toupper(ch));
      else
        printf("%c", ch = tolower(ch));
    } else
      printf("%c", ch);
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;

int main(void) {
  char s;
  while (1) {
    scanf("%c", &s);
    if (s == '\\n') {
      break;
    }
    if (islower(s)) {
      printf("%c", toupper(s));
    } else if (isupper(s)) {
      printf("%c", tolower(s));
    } else {
      cout << s;
    }
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;

int main(void) {
  char s;
  while (1) {
    scanf("%c", &s);
    if (islower(s) == 1) {
      cout << toupper(s);
    } else if (isupper(s) == 1) {
      cout << tolower(s);
    } else {
      cout << s;
    }
  }
  cout << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  char s;
  while (1) {
    scanf("%c", &s);
    if (isalpha(s)) {
      if (islower(s))
        cout << (char)toupper(s);
      else if (isupper(s))
        cout << (char)tolower(s);
    } else {
      cout << s;
    }
    if (s == '\\n')
      break;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  char s;
  while (1) {
    cin >> s;
    if (isalpha(s)) {
      if (islower(s))
        cout << (char)toupper(s);
      else if (isupper(s))
        cout << (char)tolower(s);
    } else {
      cout << s;
    }
    if (s == '\\n')
      break;
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char a;
  while (1) {
    scanf("%c", &a);
    if (isalpha(a)) {
      if (islower(a))
        cout << (char)toupper(a);
      else if (isupper(a))
        cout << (char)tolower(a);
    } else {
      cout << a;
    }
    if (a == '\\n')
      break;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  char s;

  while (1) {
    cin >> s;
    if (islower(s))
      s = toupper(s);
    else if (isupper(s))
      s = tolower(s);
    cout << s;
    if (s == '\\n')
      break;
  }
  cout << endl;

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

#include <cctype>
#include <cstdio>

int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (ch == '\\n') {
      break;
    }

    if (islower(ch)) {
      ch = toupper(ch);
    } else if (isupper(ch)) {
      ch = tolower(ch);
    } else {
    }
    printf("%c", ch);
  }
  printf("\\n");

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>
using namespace std;
int main() {
  char ch;
  while (1) {
    cin >> ch;
    if (ch == '\\n') {
      cout << "\\n";
      break;
    }

    if (islower(ch)) {
      ch = toupper(ch);
    } else if (isupper(ch)) {
      ch = tolower(ch);
    } else {
    }
    cout << ch;
  }

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

#include <cctype>
#include <iostream>

using namespace std;

int main() {
  char ch;
  while (1) {
    cin.get(ch);
    if (ch == '\\n')
      break;
    if (islower(ch))
      cout << (char)toupper(ch);
    else if (isupper(ch))
      cout << (char)tolower(ch);
    else
      cout << ch;
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>

using namespace std;

int main() {
  char ch;
  while (1) {
    cin >> ch;
    if (ch == '\\n')
      break;
    if (islower(ch))
      cout << (char)toupper(ch);
    else if (isupper(ch))
      cout << (char)tolower(ch);
    else if ((ch == ' ' | ch == ',') | ch == '.')
      cout << ch;
  }
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <iostream>
#include <stdio.h>
int main() {
  char ch, a, b;
  while (1) {
    scanf("%c", &ch);
    if (isupper(ch)) {
      a = tolower(ch);
      std::cout << a;
    } else if (islower(ch)) {
      b = toupper(ch);
      std::cout << b;
    } else {
      std::cout << ch;
    }
    if (ch == '\\n')
      break;
  }
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>
#include <stdio.h>
int main() {
  char ch;
  while (true) {
    scanf("%c", &ch);
    if (isupper(ch)) {
      std::cout << tolower(ch);
    }
    if (islower(ch)) {
      std::cout << toupper(ch);
      if (ch == '.')
        break;
    }
  }
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  char ch, x;
  int ans, num, counter[100] = {}, i, j;
  while (cin >> ch) {
    if (ch >= 'A' && ch <= 'Z') {
      ch += 'a' - 'A';
    }
    num = ch - 'a';
    counter[num]++;
  }
  for (i = 0; i < 26; i++) {
    x = i + 'a';
    ans = counter[i];
    cout << x << " : " << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  char ch, x;
  int ans, num, counter[100] = {}, i, j;
  while (1) {
    cin >> ch;
    if (ch == EOF)
      break;
    else if (ch > 'A' && ch < 'Z') {
      ch += 'a' - 'A';
    }
    num = ch - 'a';
    counter[num]++;
  }
  for (i = 0; i < 26; i++) {
    x = i + 'a';
    ans = counter[i];
    cout << x << " : " << ans << endl;
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a[26] = {}, i;
  char c;
  while (cin.get(c)) {
    if (c == 'EOF')
      break;
    else if ('a' <= c && c <= 'z')
      a[c - 'a']++;
    else if ('A' <= c && c <= 'Z')
      a[c - 'A']++;
  }
  for (i = 0; i < 26; i++) {
    c = 'a' + i;
    cout << c << " : " << a[i] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[26] = {}, i;
  char c;
  while (1) {
    cin.get(c);
    if (c == 'EOF')
      break;
    else if ('a' <= c && c <= 'z')
      a[c - 'a']++;
    else if ('A' <= c && c <= 'Z')
      a[c - 'A']++;
  }
  for (i = 0; i < 26; i++) {
    c = 'a' + i;
    cout << c << " : " << a[i] << endl;
  }

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

#include <iostream>
using namespace std;
int main(void) {
  char ch;
  int num;
  int alphabet[26] = {};
  while (cin >> ch) {
    num = ch - 'a';
    if (0 <= num && num < 26)
      alphabet[num]++;
    num = ch - 'A';
    if (0 <= num && num < 26)
      alphabet[num]++;
  }
  for (int i = 0; i < 26; i++) {
    ch = 'a' + i;
    cout << ch << " : " << alphabet[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  char ch;
  int num;
  int alphabet[26] = {};
  while (1) {
    cin >> ch;
    if (ch == -1)
      break;
    num = ch - 'a';
    if (0 <= num && num < 26)
      alphabet[num]++;
  }
  for (int i = 0; i < 26; i++) {
    ch = 'a' + i;
    cout << ch << " : " << alphabet[i] << endl;
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  char ch;
  int rec[26] = {};
  char str[1201];
  while (cin >> ch) {
    ch = tolower(ch);
    if (isalpha(ch))
      rec[ch - 'a']++;
  }

  for (int i = 0; i < 26; ++i) {
    printf("%c : %d\\n", 'a' + i, rec[i]);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int num;
  int rec[26] = {};
  char str[1201];
  while (1) {
    scanf("%s", str);
    if (str[0] == '\\n')
      break;
    for (int i = 0; i < 26; ++i) {
      if (isalpha(str[i]) != 1)
        break;
      if (isupper(str[i]))
        str[i] = tolower(str[i]);
      num = str[i] - 'a';
      rec[num] += 1;
    }
  }

  for (int i = 0; i < 26; ++i) {
    printf("%c:%d\\n", 'a' + i, rec[i]);
  }

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

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

int main() {
  char c, b[26];
  int a[26] = {0};
  while (cin >> c) {
    if (c >= 'A' && c <= 'Z') {
      c += 32;
    }
    a[c - 'a']++;
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    b[ch - 'a'] = ch;
  }
  for (int i = 0; i <= 25; i++) {
    cout << b[i] << ' ' << ":" << ' ' << a[i] << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  char c, b[25];
  int a[25] = {0};
  while (cin >> c) {
    if (c >= 'A' && c <= 'Z') {
      c += 32;
    }
    a[c - 'a']++;
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    b[ch - 'a'] = ch;
  }
  for (int i = 0; i <= 25; i++) {
    cout << b[i] << ":" << a[i] << endl;
  }
  cout << 'z' << ":" << 0 << endl;
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  char ch;
  int idx = 0, chars[26];

  for (int i = 0; i < 26; i++) {
    chars[i] = 0;
  }

  while (cin >> ch) {

    if (!isalpha(ch))
      continue;
    else if (isupper(ch)) {
      idx = ch - 'A';
      chars[idx++] += 1;
    } else {
      idx = ch - 'a';
      chars[idx++] += 1;
    }
  }

  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", i + 97, chars[i]);
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  char ch;
  int idx = 0, chars[26];

  for (int i = 0; i < 26; i++) {
    chars[i] = 0;
  }

  while (true) {
    cin >> ch;

    if (ch == '.')
      break;
    else if (idx == 0) {
      idx = ch - 'A';
      chars[idx++] += 1;
    } else {
      idx = ch - 'a';
      chars[idx++] += 1;
    }
  }

  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", i + 97, chars[i]);
  }

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

#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int counter[10000];

int main() {

  string s = "abcdefghijklmnopqrstuvwxyz";

  char ch;

  while (cin >> ch) {

    if (islower(ch) || isupper(ch)) {

      ch = tolower(ch);

      int num = ch - 'a';

      counter[num]++;
    }
  }

  for (int i = 0; i < 26; i++) {
    cout << s[i] << ' ' << ':' << ' ' << counter[i] << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int counter[10000];

int main() {

  string s = "abcdefghijklmnopqrstuvwxyz";

  char ch;

  while (cin >> ch) {

    ch = tolower(ch);

    int num = ch - 'a';

    counter[num]++;
  }

  for (int i = 0; i < 26; i++) {
    cout << s[i] << ' ' << ':' << ' ' << counter[i] << endl;
  }
}
Problem p02417 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string str;
  int ab[26] = {};
  int i;
  while (getline(cin, str)) {
    for (i = 0; i < str.size(); i++) {
      if (str[i] >= 'a' && str[i] <= 'z')
        ab[str[i] - 'a']++;
      else if (str[i] >= 'A' && str[i] <= 'Z')
        ab[str[i] - 'A']++;
    }
    // cout << str << endl;
  }
  for (i = 0; i < 26; i++) {
    cout << (char)('a' + i) << " : " << ab[i] << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  string s;
  int count[58] = {0};
  while (getline(cin, s))
    for (int i = 0; i < s.size(); i++)
      count[s[i] - 'A']++;
  for (int i = 0; i < 26; i++)
    cout << (char)('a' + i) << " : " << count[i] + count[i + 32] << endl;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char ch;
  int count[26] = {};
  while (cin >> ch) {
    ch = tolower(ch);
    if (isalpha(ch)) {
      count[ch - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", i + 'a', count[i]);
  }
}


Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char ch;
  int count[26] = {};
  while (1) {
    cin >> ch;
    ch = tolower(ch);
    if (isalpha(ch)) {
      count[ch - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", i + 'a', count[i]);
  }
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char ch;
  int count[26] = {};
  while (cin >> ch) {
    ch = tolower(ch);
    if (isalpha(ch)) {
      count[ch - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", i + 'a', count[i]);
  }
}


Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char ch;
  int count[26] = {};
  while (1) {
    cin >> ch;
    ch = tolower(ch);
    if (isalpha(ch)) {
      count[ch - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c:%d\\n", i + 'a', count[i]);
  }
}
Problem p02417 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  char counter[27] = "abcdefghijklmnopqrstuvwxyz";
  string str;
  int num, dat[26], i, x;

  for (i = 0; i < 26; i++) {
    dat[i] = 0;
  }
  while (cin >> str) {
    x = str.size();
    for (i = 0; i < x; i++) {
      if (isupper(str[i])) {
        str[i] = tolower(str[i]);
      }
      int num = str[i] - 'a';
      dat[num]++;
    }
  }

  for (i = 0; i < 26; i++) {
    cout << counter[i] << " : " << dat[i] << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  char counter[27] = "abcdefghijklmnopqrstuvwxyz", *ch[1200];
  int num, dat[26], i;

  for (i = 0; i < 26; i++) {
    dat[i] = 0;
  }
  i = 0;
  while (cin >> *ch[i]) {
    *ch[i] = tolower(*ch[i]);
    int num = *ch[i] - 'a';
    dat[num]++;
    i++;
    if (i >= 1200)
      break;
  }

  for (i = 0; i < 26; i++) {
    cout << counter[i] << ":" << dat[i] << endl;
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int counter[26] = {};
  char ch;
  while (cin >> ch) {
    ch = tolower(ch);
    if (isalpha(ch)) {
      int num = ch - 'a';
      counter[num]++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", i + 'a', counter[i]);
  }
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int num;
  int counter[25];
  char ch;
  while (scanf("%c", &ch) != EOF) {
    num = ch - 'a';
    counter[num]++;
  }
  for (int i = 0; i < 26; i++) {
    cout << char('a' + i) << " : " << counter[i] << endl;
  }
  return 0;
}