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

#include <iostream>

using namespace std;

int main() {

  char c;
  int num;
  int cnt[26] = {0};

  while (cin >> c) {

    // if (c == '0') break;

    if ('a' <= c && c <= 'z') {
      num = c - 'a';
      cnt[num]++;
    } else if ('A' <= c && c <= 'Z') {
      num = c - 'A';
      cnt[num]++;
    }
  }

  for (int i = 0; i < 26; i++) {
    char a = i + 'a';
    cout << a << " : " << cnt[i] << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  char s[1200];
  int A[26] = {0};

  int i = 0;
  while (1) {
    cin >> s[i];

    if ('A' <= s[i] && s[i] <= 'Z') {

      int X = s[i] - 'A';
      A[X]++;

    } else if ('a' <= s[i] && s[i] <= 'z') {
      int X = s[i] - 'a';
      A[X]++;
    }
    i++;
  }

  int C = 'a';

  for (int i = 0; i < 26; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << C << A[i];
    C++;
  }

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

#include <iostream>
#define ALPHABET 26

int main() {
  char c;
  int n[ALPHABET] = {};
  while (std::cin >> c) {
    if ('A' <= c && c <= 'Z') {
      c += 0x20;
    }
    if ('a' <= c && c <= 'z') {
      n[c - 0x61]++;
    }
  }
  for (int i = 0; i < ALPHABET; i++) {
    std::cout << char('a' + i) << " : " << n[i] << std::endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
#define ALPHABET 26

int main() {
  int n[ALPHABET] = {};
  while (true) {
    char c;
    scanf("%c", &c);
    if ('A' <= c && c <= 'Z') {
      c += 0x20;
    }
    if ('a' <= c && c <= 'z') {
      n[c - 0x61]++;
    }
    if (c == '.') {
      break;
    }
  }
  for (int i = 0; i < ALPHABET; i++) {
    std::cout << char('a' + i) << " : " << n[i] << std::endl;
  }
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  // map < char , int > count;
  int count[500] = {};
  string str;
  while (cin >> str) {
    for (int i = 0; i < str.size(); i++) {
      if (isupper(str[i]))
        str[i] = tolower(str[i]);
    }
    for (int i = 0; i < str.size(); i++) {
      count[str[i]]++;
    }
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    cout << ch << " : " << count[ch] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  // map < char , int > count;
  int count[500] = {};
  string str;
  while (cin >> str) {
    for (int i = 0; i < str.size(); i++) {
      if (isupper(str[i]))
        str[i] = tolower(str[i]);
    }
    for (int i = 0; i < str.size(); i++) {
      count[str[i]]++;
    }
  }
  for (char ch = 'a'; ch = 'z'; ch++) {
    cout << ch << " : " << count[ch] << endl;
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <stdio.h>
int main() {
  char ch;
  int count[26] = {};
  while ((ch = getchar()) != EOF) {
    if (isupper(ch))
      ch = tolower(ch);
    if (isalpha(ch))
      count[ch - 'a'] += 1;
  }

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


Error: TLE

Fixed submission:

#include <cctype>
#include <stdio.h>
int main() {
  char ch;
  int count[26] = {};
  while ((ch = getchar()) != '\\0') {
    if (isupper(ch))
      ch = tolower(ch);
    if (isalpha(ch))
      count[ch - 'a'] += 1;
  }

  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 <bits/stdc++.h>
using namespace std;

int main() {
  char ch;
  int cnt[26] = {};
  while (scanf("%c", &ch) != EOF) {
    if ('a' <= ch && ch <= 'z') {
      cnt[ch - 'a']++;
    } else if ('A' <= ch && ch <= 'Z') {
      cnt[ch - 'A']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", 'a' + i, cnt[i]);
  }
}


Error: TLE

Fixed submission:

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

int main() {
  char ch;

  int cnt[26] = {};
  while (true) {
    cin >> ch;
    if (ch == '.')
      break;
    if ('a' <= ch && ch <= 'z') {
      cnt[ch - 'a']++;
    } else if ('A' <= ch && ch <= 'Z') {
      cnt[ch - 'A']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", 'a' + i, cnt[i]);
  }
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

int main(void) {
  int ch;
  int chCounts[26] = {};
  while ((ch = getchar()) != EOF) {
    if ('a' <= ch && ch <= 'z') {
      chCounts[ch - 'a']++;
    } else if ('A' <= ch && ch <= 'Z') {
      chCounts[ch - 'A']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", 'a' + i, chCounts[i]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

int main(void) {
  int ch;
  int chCounts[26] = {};
  while (scanf("%d", &ch) != EOF) {
    if ('a' <= ch && ch <= 'z') {
      chCounts[ch - 'a']++;
    } else if ('A' <= ch && ch <= 'Z') {
      chCounts[ch - 'A']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", 'a' + i, chCounts[i]);
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define N (26)

int main(void) {
  int a[N] = {0}; // ??¢?????????????????????'a'-'z'??????26??????
  // char ch[1201];       // ???????????????????????§??????????????????
  int ch, i;

  // input
  while ((ch = getchar()) != EOF) {
    //??°???
    if (islower(ch)) {
      a[ch - 'a']++;
    }
    if (isupper(ch)) {
      a[ch - 'A']++;
    }
  }

  // output
  for (i = 0; i < N; i++) {
    printf("%c : %d\\n", i + 'a',
           a[i]); // 0+'a' = 'a' ?????????0=a, 1=b, 2=c, ... ?????????
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <stdio.h>

int main() {
  char ch;
  int counts[26] = {};
  while (scanf("%c", &ch)) {
    if (ch == EOF) {
      break;
    }
    if ('a' <= ch || 'z' <= ch) {
      counts[ch - 'a']++;
    } else if ('A' <= ch || 'Z' <= ch) {
      counts[ch - 'A']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", 'a' + i, counts[i]);
    counts[i] = 0;
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <ctype.h>
#include <stdio.h>
int main() {
  int s;
  int i = 0;
  int count[26] = {0};
  while (i < 1200) {
    s = getchar();
    s = tolower(s);
    if (s >= 'a' && s <= 'z')
      count[s - 'a']++;
    i++;
  }
  for (i = 0; i < 26; i++)
    printf("%c : %d\\n", 97 + i, count[i]);
  return 0;
}

Error: TLE

Fixed submission:

#include <ctype.h>
#include <stdio.h>
int main() {
  int s;
  int i = 0;
  int count[26] = {0};
  while ((s = getchar()) != '.' || i < 20) {
    s = tolower(s);
    if (s >= 'a' && s <= 'z')
      count[s - 'a']++;
    i++;
  }
  for (i = 0; i < 26; i++)
    printf("%c : %d\\n", 97 + i, count[i]);
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int alpha[26];
  for (int a = 0; a < 26; a++)
    alpha[a] = 0;

  char ch;
  while (cin >> ch) {

    for (int i = 0; i < 26; i++) {
      if (ch - 'a' == i)
        alpha[i]++;
      else if (ch + 32 - 'a' == i)
        alpha[i]++;
    }
  }

  for (int i = 0; i < 26; i++) {
    cout << (char)(i + 'a') << " : " << alpha[i] << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int alpha[26];
  for (int a = 0; a < 26; a++)
    alpha[a] = 0;

  char ch;
  while (1) {
    cin >> ch;
    if (ch == '.')
      break;

    for (int i = 0; i < 26; i++) {
      if (ch - 'a' == i)
        alpha[i]++;
      else if (ch + 32 - 'a' == i)
        alpha[i]++;
    }
  }

  for (int i = 0; i < 26; i++) {
    cout << (char)(i + 'a') << " : " << alpha[i] << endl;
  }

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

#include <cctype>
#include <cstdio>
int main() {
  char ch;
  int counter[26] = {0};

  while (scanf("%c", &ch) != EOF) {
    if (isupper(ch)) {
      ch = tolower(ch);
    }
    if ('a' <= ch && ch <= 'z') {
      int num = ch - 'a';
      counter[num]++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\\n", i + 'a', counter[i]);
  }
  return 0;
}


Error: -11

Fixed submission:

#include <cctype>
#include <cstdio>
int main() {
  char ch;
  int counter[] = {0};

  while (scanf("%c", &ch) != EOF) {
    if (isupper(ch)) {
      ch = tolower(ch);
    }
    if (isalpha(ch)) {
      int num = ch - 'a';
      counter[num]++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%s : %d", i + 'a', counter[i]);
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> Result(26, 0);

  char a;

  while (cin >> a) {
    if (iswalpha(a)) {
      int temp = tolower(a) - 'a';
      Result.at(temp) += 1;
    }
  }

  char c = 'a';
  for (auto b : Result) {
    cout << c << " : " << b << endl;
    c++;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> Result(26, 0);

  char a;

  while (scanf("%c", &a)) {
    if (a == EOF) {
      break;
    }
    if (iswalpha(a)) {
      int temp = tolower(a) - 'a';
      Result.at(temp) += 1;
    }
  }

  char c = 'a';
  for (auto b : Result) {
    cout << c << " : " << b << endl;
    c++;
  }
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  char ch[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  int cnt[26] = {0};

  char inp;
  while (1) {
    if (scanf("%c", &inp) == EOF)
      break;
    for (int i = 0; i < 26; i++) {
      if (inp == ch[i] || inp == ch[i] - 32) {
        cnt[i]++;
        break;
      }
    }
  }
  for (int j = 0; j < 26; j++) {
    printf("%c : %d\\n", ch[j], cnt[j]);
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  char ch[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  int cnt[26] = {0};

  char inp;
  while (1) {
    scanf("%c", &inp);
    if (inp == EOF)
      break;
    for (int i = 0; i < 26; i++) {
      if (inp == ch[i] || inp == ch[i] - 32) {
        cnt[i]++;
        break;
      }
    }
  }
  for (int j = 0; j < 26; j++) {
    printf("%c : %d\\n", ch[j], cnt[j]);
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  string s;
  char m;
  vector<char> si;
  getline(cin, s);
  while (s.size() > 0) {
    // si.resize(s.size());
    // for(int i=0;i<s.size();i++){
    //     si[i] = null;
    // }
    int i = 0;
    while (s[i] != '\\0') {
      m = tolower(s[i]);
      if (m >= 'a' && m <= 'z') {
        si.push_back(m);
      }
      i++;
    }
    getline(cin, s);
  }
  sort(si.begin(), si.end());
  // for(int i=0;i<=si.size();i++){
  //     cout << si[i];
  // }
  char moji = 'a';
  int spos = 0;
  int cnt = 0;
  while (moji <= 'z') {
    if (spos < si.size() && moji == si[spos]) {
      cnt++;
      spos++;
    } else {
      cout << moji << " : " << cnt << endl;
      moji = char(int(moji) + 1);
      cnt = 0;
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  string s;
  char m;
  vector<char> si;
  getline(cin, s);
  while (s.size() > 0) {
    // si.resize(s.size());
    // for(int i=0;i<s.size();i++){
    //     si[i] = null;
    // }
    int i = 0;
    while (s[i] != '\\0') {
      m = tolower(s[i]);
      if (m >= 'a' && m <= 'z') {
        si.push_back(m);
      }
      i++;
    }
    getline(cin, s);
  }
  sort(si.begin(), si.end());
  // for(int i=0;i<=si.size();i++){
  //     cout << si[i];
  // }
  char moji = 'a';
  int spos = 0;
  int cnt = 0;
  while (moji <= 'z') {
    if (moji == si[spos]) {
      cnt++;
      spos++;
    } else {
      cout << moji << " : " << cnt << endl;
      moji = char(int(moji) + 1);
      cnt = 0;
    }
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string str;
  int a[26] = {0};
  char c;

  while (cin >> str) {

    int n = 0;

    for (unsigned int i = 0; i < str.size(); i++) {
      if (str[i] >= 'a' && str[i] <= 'z') {
        n = str[i] - 'a';
        a[n]++;
      } else if (str[i] >= 'A' && str[i] <= 'Z') {
        n = str[i] - 'A';
        a[n]++;
      }
    }
  }

  for (int i = 0; i < 26; i++) {
    c = 'a' + i;
    cout << c << " : " << a[i] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string str;
  int a[26] = {0};
  char c;

  while (1) {
    getline(cin, str);

    int n = 0;

    for (unsigned int i = 0; i < str.size(); i++) {
      if (str[i] >= 'a' && str[i] <= 'z') {
        n = str[i] - 'a';
        a[n]++;
      } else if (str[i] >= 'A' && str[i] <= 'Z') {
        n = str[i] - 'A';
        a[n]++;
      }
    }
    if (str[str.size() - 1] == '.')
      break;
  }

  for (int 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>
#include <string>
using namespace std;

int main() {
  string str;
  int alp[26];
  char c;
  int x;
  for (int i = 0; i < 26; i++)
    alp[i] = 0;
  while (cin >> str) {
    for (unsigned i = 0; i < str.length(); i++) {
      str[i] = tolower(str[i]);
      if (str[i] >= 'a' && str[i] <= 'z') {
        x = str[i] - 'a';
        alp[x]++;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    c = 'a' + i;
    cout << c << " : " << alp[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string x;
  int a;
  while (1) {
    cin >> x;
    if (x == "0")
      break;
    a = 0;
    for (int i = 0; i < x.length(); i++)
      a += x[i] - '0';
    cout << a << endl;
  }
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string buf;

  int cnt[26] = {0};
  int idx = 0;

  while (cin >> buf) {
    for (int i = 0; i < buf.size(); i++) {
      char ch = buf[i];

      if (ch >= 65 and ch <= 90) {
        idx = ch - 65;
        cnt[idx] += 1;
      }
      if (ch >= 97 and ch <= 122) {
        idx = ch - 97;
        cnt[idx] += 1;
      }
    }
  }

  for (int i = 0; i < 26; i++) {
    cout << (char)(i + 97) << " : " << cnt[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string buf;

  while (true) {
    getline(cin, buf);

    int cnt[26] = {0};
    int idx = 0;

    for (int i = 0; i < buf.size(); i++) {
      char ch = buf[i];

      if (ch >= 65 and ch <= 90) {
        idx = ch - 65;
        cnt[idx] += 1;
      }
      if (ch >= 97 and ch <= 122) {
        idx = ch - 97;
        cnt[idx] += 1;
      }
    }

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

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

int main() {
  int co[40] = {};
  int i, j;
  char al[40] = "abcdefghijklmnopqrstuvwxyz";
  char ch;
  while (scanf("%c", &ch) != EOF) {
    if (isupper(ch)) {
      ch = tolower(ch);
    }
    for (i = 0; i < 26; i++) {
      if (ch == al[i]) {
        co[i] += 1;
      }
    }
  }
  for (j = 0; j < 26; j++) {
    cout << al[j] << " : " << co[j] << endl;
  }
  return 0;
}


Error: -11

Fixed submission:

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

int main() {
  int co[40] = {};
  int i, j;
  char al[40] = "abcdefghijklmnopqrstuvwxyz";
  char ch;
  while (true) {
    scanf("%c", 'ch');
    if (ch = '.')
      break;
    for (i = 0; i < 26; i++) {
      if (ch == al[i]) {
        co[i] += 1;
      }
    }
  }
  for (j = 0; j < 26; j++) {
    cout << al[j] << " : " << co[j] << endl;
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string str;
  string temp;
  string::size_type index;
  int count = 0;
  int i = 0;

  while (std::cin >> temp) {
    str += temp;
  }
  char c = 'a';
  while (c != 'z' + 1) {

    count = 0;
    for (string::iterator it = str.begin(); it != str.end(); it++) {
      if (c == *it) {
        count++;
      } else if (c - 32 == *it) {
        count++;
      }
    }
    cout << c << " : " << count << endl;
    c += 1;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string str;
  string temp;
  string::size_type index;
  int count = 0;
  int i = 0;

  while (std::cin >> temp) {
    str += temp;
  }
  char c = 'a' + i;
  while (c != 'z' + 1) {
    count = 0;
    for (string::iterator it = str.begin(); it != str.end(); it++) {
      if (c == *it) {
        count++;
      } else if (c - 32 == *it) {
        count++;
      }
    }
    cout << c << " : " << count << endl;
    i++;
  }

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

#include <cctype>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string AtoZ;
  char atoz[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                   'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                   's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  int a[26] = {0};
  while (cin >> AtoZ) {
    for (int i = 0; i < AtoZ.size(); i++) {
      if (isupper(AtoZ[i])) {
        AtoZ[i] = tolower(AtoZ[i]);
      }
      for (int j = 0; j < 26; j++) {
        if (AtoZ[i] == atoz[j]) {
          a[j]++;
          break;
        }
      }
    }
  }
  for (int k = 0; k < 26; k++) {
    cout << atoz[k] << " : " << a[k] << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <cctype>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string AtoZ;
  char atoz[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                   'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                   's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  int a[26] = {};
  while (0) {
    cin >> AtoZ;
    for (int i = 1; i <= AtoZ.size(); i++) {
      if (isupper(AtoZ[i]) == 1) {
        a[i] = tolower(a[i]);
      }
      for (int j = 1; j <= 26; i++) {
        if (AtoZ[i] == atoz[j]) {
          a[j]++;
          break;
        }
      }
    }
  }
  for (int k = 1; k <= 26; k++) {
    cout << atoz[k] << " : " << a[k] << endl;
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
int main() {
  int cnt[26];
  for (int i = 0; i < 26; i++)
    cnt[i] = 0;
  while (true) {
    char c;
    std::cin >> c;
    if (std::cin.eof()) {
      break;
    } else if ('A' <= c && c <= 'Z') {
      cnt[c - 'A']++;
    } else if ('a' <= c && c <= 'z') {
      cnt[c - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    std::cout << (char)(i + 'a') << " : " << cnt[i] << std::endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
int main() {
  int cnt[26];
  for (int i = 0; i < 26; i++)
    cnt[i] = 0;
  while (true) {
    char c;
    std::cin >> c;
    if ('A' <= c && c <= 'Z') {
      cnt[c - 'A']++;
    } else if ('a' <= c && c <= 'z') {
      cnt[c - 'a']++;
    } else if (c == '.') {
      break;
    }
  }
  for (int i = 0; i < 26; i++) {
    std::cout << (char)(i + 'a') << " : " << cnt[i] << std::endl;
  }
  return 0;
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <ctype.h>
#include <stdio.h>
#define CHARNUM 26

char c_set[CHARNUM] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                       'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                       's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int ctoi(char c) {
  int i = 0;
  while (c != c_set[i] && i < CHARNUM) {
    i++;
  }
  return i;
}

int main() {
  char c;
  int v[CHARNUM + 1] = {0};
  while ((c = getchar()) != EOF) {
    ungetc(c, stdin);
    while (1) {
      c = tolower(getchar());
      if (c == '\\n')
        break;
      v[ctoi(c)]++;
    }
  }

  for (int i = 0; i < CHARNUM; i++) {
    printf("%c : %d\\n", c_set[i], v[i]);
  }
}

Error: TLE

Fixed submission:

#include <ctype.h>
#include <stdio.h>
#define CHARNUM 26

char c_set[CHARNUM] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                       'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                       's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int ctoi(char c) {
  int i = 0;
  while (c != c_set[i] && i < CHARNUM) {
    i++;
  }
  return i;
}

int main() {
  char c;
  int v[CHARNUM + 1] = {0};
  while ((c = getchar()) != '\\n') {
    ungetc(c, stdin);
    while (1) {
      c = tolower(getchar());
      if (c == '\\n')
        break;
      v[ctoi(c)]++;
    }
  }

  for (int i = 0; i < CHARNUM; i++) {
    printf("%c : %d\\n", c_set[i], v[i]);
  }
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  char alpha[10000];
  int count[26] = {0};
  int num = 0;

  cin.getline(alpha, sizeof(alpha));
  while (1) {
    for (int i = 0; alpha[i] != NULL; i++) {
      if (alpha[i] >= 97) {
        num = alpha[i] - 'a';
      } else {
        num = alpha[i] - 'A';
      }
      count[num]++;
    }

    cin.getline(alpha, sizeof(alpha));
    if (alpha[0] == NULL)
      break;
  }
  for (int i = 97; i < 123; i++) {
    cout << (char)i << " : " << count[i - 97] << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  char alpha[10000];
  int count[26] = {0};
  int num = 0;

  cin.getline(alpha, sizeof(alpha));
  while (1) {
    for (int i = 0; alpha[i] != NULL; i++) {
      if (alpha[i] >= 97) {
        num = alpha[i] - 'a';
      } else {
        num = alpha[i] - 'A';
      }
      count[num]++;
    }
    for (int i = 97; i < 123; i++) {
      cout << (char)i << " : " << count[i - 97] << endl;
    }
    cin.getline(alpha, sizeof(alpha));
    if (alpha[0] == EOF)
      break;
  }
}
Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int alph[26];
int p;

void Check(char _moji) {
  p = 0;
  if (isupper(_moji))
    _moji = tolower(_moji);
  for (char ch = 'a'; ch <= 'z'; ch++) {
    if (ch == _moji) {
      alph[p] += 1;
      break;
    }
    p++;
  }
}
void Show() {
  p = 0;
  for (char ch = 'a'; ch <= 'z'; ch++) {
    printf("%c : %d\\n", ch, alph[p]);
    p++;
  }
}
int main() {
  char moji;
  while (scanf("%c", &moji) != EOF) {
    Check(moji);
  }
  Show();
  return 0;
}

Error: TLE

Fixed submission:

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

int alph[26];
int p;

void Check(char _moji) {
  p = 0;
  if (isupper(_moji))
    _moji = tolower(_moji);
  for (char ch = 'a'; ch <= 'z'; ch++) {
    if (ch == _moji) {
      alph[p] += 1;
      break;
    }
    p++;
  }
}
void Show() {
  p = 0;
  for (char ch = 'a'; ch <= 'z'; ch++) {
    printf("%c : %d\\n", ch, alph[p]);
    p++;
  }
}
int main() {
  char moji;
  while (1) {
    scanf("%c", &moji);
    Check(moji);
    if (moji == EOF) {
      Show();
      break;
    }
  }
  return 0;
}