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

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

int main(void) {
  int i;

  while (1) {
    char x[1001];
    int sum = 0;
    int re; //??°?????????????????´

    scanf("%[^\n]", x); //?????????????????§????????????

    if ((x[0] == '0') && (x[1] == '\0')) //??????0????????????
      break;

    for (i = 0; (!(x[i])) == '\0'; i++) { //??????????????????????????§?????????
      re = x[i] - '0';                    //??°?????¨?????????????????????
      sum = sum + re;                     //????¨?????????????
    }

    printf("%d\n", sum);
  }

  return (0);
}

Fixed submission:
#include <stdio.h>

int main(void) {
  int i;

  while (1) {
    char x[1001];
    int sum = 0;
    int re; //??°?????????????????´

    scanf("%s", x);

    if ((x[0] == '0') && (x[1] == '\0')) //??????0????????????
      break;

    for (i = 0; (!(x[i])) == '\0'; i++) { //??????????????????????????§?????????
      re = x[i] - '0';                    //??°?????¨?????????????????????
      sum = sum + re;                     //????¨?????????????
    }

    printf("%d\n", sum);
  }

  return (0);
}
Problem p02416 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int sum;
  char ch[100];
  while (1) {
    scanf("%s", ch);
    if (ch[0] == '0')
      break;
    sum = 0;
    for (int i = 0; i < strlen(ch); i++) {
      sum = sum + (ch[i] - '0');
    }
    printf("%d\n", sum);
  }
}

Fixed submission:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int sum;
  char ch[10000];
  while (1) {
    scanf("%s", ch);
    if (ch[0] == '0')
      break;
    sum = 0;
    for (int i = 0; i < strlen(ch); i++) {
      sum = sum + (ch[i] - '0');
    }
    printf("%d\n", sum);
  }
}
Problem p02416 (C++)

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

int main() {
  int sum[1001] = {};
  int count = 0;

  while (1) {
    char in[1000];
    int i = 0;
    cin.getline(in, sizeof(in));

    if (in[0] == '0') {
      break;
    }

    for (i = 0; in[i] != '\0'; i++) {
      if (in[i] == '1') {
        sum[count] = sum[count] + 1;
      } else if (in[i] == '2') {
        sum[count] = sum[count] + 2;
      } else if (in[i] == '3') {
        sum[count] = sum[count] + 3;
      } else if (in[i] == '4') {
        sum[count] = sum[count] + 4;
      } else if (in[i] == '5') {
        sum[count] = sum[count] + 5;
      } else if (in[i] == '6') {
        sum[count] = sum[count] + 6;
      } else if (in[i] == '7') {
        sum[count] = sum[count] + 7;
      } else if (in[i] == '8') {
        sum[count] = sum[count] + 8;
      } else if (in[i] == '9') {
        sum[count] = sum[count] + 9;
      }
    }
    count++;
  }
  for (int s = 0; s < count; s++) {
    cout << sum[s] << endl;
  }
  return 0;
}

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

int main() {
  int sum[1001] = {};
  int count = 0;

  while (1) {
    char in[1001];
    int i = 0;
    cin.getline(in, sizeof(in));

    if (in[0] == '0') {
      break;
    }

    for (i = 0; in[i] != '\0'; i++) {
      if (in[i] == '1') {
        sum[count] = sum[count] + 1;
      } else if (in[i] == '2') {
        sum[count] = sum[count] + 2;
      } else if (in[i] == '3') {
        sum[count] = sum[count] + 3;
      } else if (in[i] == '4') {
        sum[count] = sum[count] + 4;
      } else if (in[i] == '5') {
        sum[count] = sum[count] + 5;
      } else if (in[i] == '6') {
        sum[count] = sum[count] + 6;
      } else if (in[i] == '7') {
        sum[count] = sum[count] + 7;
      } else if (in[i] == '8') {
        sum[count] = sum[count] + 8;
      } else if (in[i] == '9') {
        sum[count] = sum[count] + 9;
      }
    }
    count++;
  }
  for (int s = 0; s < count; s++) {
    cout << sum[s] << endl;
  }
  return 0;
}
Problem p02416 (Python)

Buggy submission (status: Runtime Error):
while True:
    x = input()

    if x == 0:
        break

    length = len(x)
    tot = 0

    for i in range(length):
        tot += int(x[i : i + 1])
    print(tot)


Fixed submission:
while True:
    x = input()

    if x == "0":
        break

    length = len(x)
    tot = 0

    for i in range(length):
        tot += int(x[i : i + 1])
    print(tot)
Problem p02416 (C++)

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

int main() {
  string number;
  int sum[100];
  int j = 0;
  while (1) {
    sum[j] = 0;
    cin >> number;
    if (number == "0") {
      sum[j] = 0;
      break;
    }
    for (int i = 0; i < number.length(); i++) {
      sum[j] += number[i] - '0';
    }
    j++;
  }
  j = 0;
  while (1) {
    if (sum[j] == 0)
      break;
    cout << sum[j] << endl;
    j++;
  }
  return 0;
}

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

int main() {
  string number;
  int sum[1000];
  int j = 0;
  while (1) {
    sum[j] = 0;
    cin >> number;
    if (number == "0") {
      sum[j] = 0;
      break;
    }
    for (int i = 0; i < number.length(); i++) {
      sum[j] += number[i] - '0';
    }
    j++;
  }
  j = 0;
  while (1) {
    if (sum[j] == 0)
      break;
    cout << sum[j] << endl;
    j++;
  }
  return 0;
}
Problem p02416 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int count, count2 = 0, ans[100] = {0};
  char number[1000];
  while (1) {
    scanf("%s", &number);
    for (count = 0; number[count] != '\0'; count++) {
      ans[count2] += (number[count] - '0');
    }
    if (ans[count2] == 0) {
      break;
    }
    count2++;
  }
  for (count = 0; count < count2; count++) {
    cout << ans[count] << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int count, count2 = 0, ans[1000] = {0};
  char number[1000];
  while (1) {
    scanf("%s", &number);
    for (count = 0; number[count] != '\0'; count++) {
      ans[count2] += (number[count] - '0');
    }
    if (ans[count2] == 0) {
      break;
    }
    count2++;
  }
  for (count = 0; count < count2; count++) {
    cout << ans[count] << endl;
  }
  return 0;
}
Problem p02416 (C++)

Buggy submission (status: Runtime Error):
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  while (1) {
    int s = 0, d = 0;
    char a[5];
    cin >> a;
    if (a[0] == 48)
      break;
    for (int i = 0; i < strlen(a); i++) {
      s += a[i];
      d++;
    }
    cout << s - d * 48 << endl;
  }
  return 0;
}

Fixed submission:
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  while (1) {
    int s = 0, d = 0;
    char a[1000];
    cin >> a;
    if (a[0] == 48)
      break;
    for (int i = 0; i < strlen(a); i++) {
      s += a[i];
      d++;
    }
    cout << s - d * 48 << endl;
  }
  return 0;
}
Problem p02416 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  char x[100][1001] = {"a"};
  long long int check;
  int a[100] = {};
  for (int i = 0; i < 1000; i++) {
    cin >> x[i];
    if (x[i][0] == '0') {
      break;
    }
    for (int i2 = 0; i2 < 1001; i2++) {
      if (x[i][i2] != '\0' && x[i][i2] != 'a') {
        a[i] += x[i][i2] - '0';
      }
    }
    check = i;
  }
  for (int i = 0; i <= check; i++) {
    cout << a[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  char x[1000][1001] = {"a"};
  int check;
  int a[1000] = {};
  for (int i = 0; i < 1000; i++) {
    cin >> x[i];
    if (x[i][0] == '0') {
      break;
    }
    for (int i2 = 0; i2 < 1001; i2++) {
      if (x[i][i2] != '\0' && x[i][i2] != 'a') {
        a[i] += x[i][i2] - '0';
      }
    }
    check = i;
  }
  for (int i = 0; i <= check; i++) {
    cout << a[i] << endl;
  }
  return 0;
}
Problem p02416 (C++)

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

int main() {
  char x[1000];

  while (1) {
    scanf("%s", x);
    if (x[0] == 0)
      break;
    int sum = 0;
    for (int i = 0; i < strlen(x); i++) {
      sum += (x[i] - '0');
    }

    printf("%d\n", sum);
  }

  return 0;
}

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

int main() {
  char x[1000];

  while (1) {
    scanf("%s", x);
    if (x[0] == '0')
      break;
    int sum = 0;
    for (int i = 0; i < strlen(x); i++) {
      sum += (x[i] - '0');
    }

    printf("%d\n", sum);
  }

  return 0;
}
Problem p02416 (C++)

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

int main() {
  int sum, i;
  char c;

  for (sum = 0;; sum = 0) {
    for (i = 0;; i++) {
      c = getchar();
      if (c == '\n') {
        cout << sum << endl;
        break;
      } else if (c == '0' && i == 0)
        break;
      sum += c - '0';
    }
  }
  return 0;
}

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

int main() {
  int sum, i;
  char c;

  for (sum = 0;; sum = 0) {
    for (i = 0;; i++) {
      c = getchar();
      if (c == '\n') {
        cout << sum << endl;
        break;
      } else if (c == '0' && i == 0)
        return 0;
      sum += c - '0';
    }
  }
  return 0;
}
Problem p02416 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
#include <string.h>
#define rep(i, a) for (int i = 0; i < a; ++i)

int main(void) {
  char s[1500];
  int i, ans = 0;
  while (1) {
    ans = 0;
    scanf("%s", s);
    if (strlen(s) == 1 && s[0] == 0)
      break;
    rep(i, strlen(s)) ans += s[i] - '0';
    printf("%d\n", ans);
  }
  return 0;
}


Fixed submission:
#include <stdio.h>
#include <string.h>
#define rep(i, a) for (int i = 0; i < a; ++i)

int main(void) {
  char s[1500];
  int i, ans = 0;
  while (1) {
    ans = 0;
    scanf("%s", s);
    if (strlen(s) == 1 && s[0] == '0')
      break;
    rep(i, strlen(s)) ans += s[i] - '0';
    printf("%d\n", ans);
  }
  return 0;
}
Problem p02416 (C++)

Buggy submission (status: Runtime Error):

#include <cstdio>

int main() {
  char num[900];
  int sum, i, n;
  for (;;) {
    scanf("%s", num);
    i = 0;
    sum = 0;
    while (num[i] != 0) {
      sum = sum + (num[i] - '0');
      i++;
    }
    if (sum == 0) {
      break;
    }
    printf("%d\n", sum);
  }
  return 0;
}


Fixed submission:

#include <cstdio>

int main() {
  char num[1000];
  int sum, i, n;
  for (;;) {
    scanf("%s", num);
    i = 0;
    sum = 0;
    while (num[i] != 0) {
      sum = sum + (num[i] - '0');
      i++;
    }
    if (sum == 0) {
      break;
    }
    printf("%d\n", sum);
  }
  return 0;
}
Problem p02416 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
int main() {
  while (true) {
    string x;
    if (x == "0")
      break;
    int sum = 0;
    for (int i = 0; i < x.size(); i++) {
      sum += x[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}


Fixed submission:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
int main() {
  while (true) {
    string x;
    cin >> x;
    if (x == "0")
      break;
    int sum = 0;
    for (int i = 0; i < x.size(); i++) {
      sum += x[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
#include <vector>

#define ALPHABET_NUM ('z' - 'a' + 1)
using namespace std;

int main(int argc, char *argv[]) {
  vector<int> num(ALPHABET_NUM, 0);

  while (true) {
    string str;
    getline(cin, str);
    for (string::iterator itr = str.begin(); itr != str.end(); itr++) {
      char c = *itr;
      if (!('A' <= c && c <= 'Z') && !('a' <= c && c <= 'z'))
        continue;
      if ('A' <= c && c <= 'Z')
        c += 'a' - 'A';
      num[c - 'a']++;
    }
  }

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

  return 0;
}

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

#define ALPHABET_NUM ('z' - 'a' + 1)
using namespace std;

int main(int argc, char *argv[]) {
  vector<int> num(ALPHABET_NUM, 0);

  char c;
  while (cin >> c) {
    if (!('A' <= c && c <= 'Z') && !('a' <= c && c <= 'z'))
      continue;
    if ('A' <= c && c <= 'Z')
      c += 'a' - 'A';
    num[c - 'a']++;
  }

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

  return 0;
}
Problem p02417 (C++)

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

int main() {
  int cnt[25] = {};
  char ch;

  while (cin >> ch) {
    ch = tolower(ch);
    if (isalpha(ch))
      cnt[ch - 'a']++;
  }

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


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

int main() {
  int cnt[26] = {};
  char ch;

  while (cin >> ch) {
    ch = tolower(ch);
    if (isalpha(ch))
      cnt[ch - 'a']++;
  }

  for (int i = 0; i <= 25; i++) {
    cout << (char)(i + 'a') << " : " << cnt[i] << endl;
  }
  return 0;
}
Problem p02417 (C++)

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

using namespace std;

int main() {
  string a, e;
  int i, d[26];
  for (i = 0; i < 26; i++) {
    d[i] = 0;
  }
  char b;
  while (1) {
    getline(cin, e);
    a += e;
    if (e.substr(1, 1) == "") {
      break;
    }
  }
  string::iterator s;
  for (s = a.begin(); s != a.end(); s++) {
    *s = tolower(*s);
  }
  for (i = 0; i < 26; i++) {
    for (s = a.begin(); s != a.end(); s++) {
      b = 97 + i;
      if (*s == b) {
        d[i] += 1;
      }
    }
  }
  for (i = 0; i < 26; i++) {
    b = 97 + i;
    cout << b << " : " << d[i] << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  string a, e;
  int i, d[26];
  for (i = 0; i < 26; i++) {
    d[i] = 0;
  }
  char b;
  while (1) {
    getline(cin, e);
    a += e;
    if (e == "") {
      break;
    }
  }
  string::iterator s;
  for (s = a.begin(); s != a.end(); s++) {
    *s = tolower(*s);
  }
  for (i = 0; i < 26; i++) {
    for (s = a.begin(); s != a.end(); s++) {
      b = 97 + i;
      if (*s == b) {
        d[i] += 1;
      }
    }
  }
  for (i = 0; i < 26; i++) {
    b = 97 + i;
    cout << b << " : " << d[i] << endl;
  }
  return 0;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <ctype.h>
#include <stdio.h>
int main() {
  int c;
  int cnt[500] = {0};
  while (c != '.') {
    c = getchar();
    if (islower(c)) {
      cnt[c]++;
    } else {
      cnt[c + 32]++;
    }
  }
  for (c = 'a'; c <= 'z'; c++) {
    printf("%c : %d\n", c, cnt[c]);
  }
  return 0;
}

Fixed submission:
#include <ctype.h>
#include <stdio.h>
int main() {
  int c;
  int cnt[500] = {0};
  while (c != EOF) {
    c = getchar();
    if (islower(c)) {
      cnt[c]++;
    } else {
      cnt[c + 32]++;
    }
  }
  for (c = 'a'; c <= 'z'; c++) {
    printf("%c : %d\n", c, cnt[c]);
  }
  return 0;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

int main() {
  char c;
  int n[26]{};
  while (1) {
    std::cin >> c;
    if (c == '0')
      break;
    if ('A' <= c && c <= 'Z')
      ++n[c - 'A'];
    else if ('a' <= c && c <= 'z')
      ++n[c - 'a'];
  }
  for (int i = 0; i != 26; ++i)
    std::cout << char('a' + i) << " : " << n[i] << '\n';
}

Fixed submission:
#include <iostream>

int main() {
  char c;
  int n[26]{};
  while (std::cin >> c) {
    if ('A' <= c && c <= 'Z')
      ++n[c - 'A'];
    else if ('a' <= c && c <= 'z')
      ++n[c - 'a'];
  }
  for (int i = 0; i != 26; ++i)
    std::cout << char('a' + i) << " : " << n[i] << '\n';
}
Problem p02417 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(void) {
  // Your code here! sakuraihaaho
  string x;
  int hai[26] = {};
  while (getline(cin, x)) {
    for (int i = 0; i < x.size(); i++) {
      if ((int)x.at(i) >= (int)'a' && (int)x.at(i) <= (int)'z')
        hai[x.at(i) - (int)'a'] += 1;
      else
        hai[x.at(i) - (int)'A'] += 1;
    }
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)('a' + i) << " : " << hai[i] << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(void) {
  // Your code here! sakuraihaaho
  string x;
  int hai[26] = {};
  while (getline(cin, x)) {
    for (int i = 0; i < x.size(); i++) {
      if ((int)x.at(i) >= (int)'a' && (int)x.at(i) <= (int)'z')
        hai[x.at(i) - (int)'a'] += 1;
      else if ((int)x.at(i) >= (int)'A' && (int)x.at(i) <= (int)'Z')
        hai[x.at(i) - (int)'A'] += 1;
    }
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)('a' + i) << " : " << hai[i] << endl;
  }
  return 0;
}
Problem p02417 (C++)

Buggy submission (status: 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;
}


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 (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <locale>
#include <string>
#include <vector>

static bool readLines(std::string &str) {
  std::string tmp;

  if (0x00 == &str) {
    return false;
  }

  while (std::getline(std::cin, tmp)) {
    if (0 < tmp.size()) {
      transform(str.begin(), str.end(), str.begin(), tolower);
      str += tmp;
    }
  }

  return true;
}

static bool countAlpha(const std::string &str, std::vector<int> &v) {
  if (0x00 == &str || 0x00 == &v) {
    return false;
  }

  if (0 >= v.size()) {
    v.resize(26);
    for (unsigned int i = 0; i < v.size(); i++) {
      v.at(i) = 0;
    }
  }

  char ch;
  int index = 0;
  for (unsigned int i = 0; i < str.size(); i++) {
    ch = str.at(i);
    if (false == std::isalpha(ch))
      continue;
    index = static_cast<int>(ch - 'a');
    v.at(index)++;
  }

  return true;
}

int main() {
  std::string alpha("abcdefghijklmnopqrstuvwxyz");
  std::string str;
  std::vector<int> vec(26);

  for (unsigned int i = 0; i < vec.size(); i++) {
    vec.at(i) = 0;
  }

  if (true == readLines(str)) {
    countAlpha(str, vec);
    for (unsigned int i = 0; i < vec.size(); i++) {
      std::cout << alpha.at(i) << " : " << vec.at(i) << std::endl;
    }
  }

  return (0);
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <locale>
#include <string>
#include <vector>

static bool readLines(std::string &str) {
  std::string tmp;

  if (0x00 == &str) {
    return false;
  }

  while (std::getline(std::cin, tmp)) {
    if (0 < tmp.size()) {
      transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
      str += tmp;
    }
  }

  return true;
}

static bool countAlpha(const std::string &str, std::vector<int> &v) {
  if (0x00 == &str || 0x00 == &v) {
    return false;
  }

  if (0 >= v.size()) {
    v.resize(26);
    for (unsigned int i = 0; i < v.size(); i++) {
      v.at(i) = 0;
    }
  }

  char ch;
  int index = 0;
  for (unsigned int i = 0; i < str.size(); i++) {
    ch = str.at(i);
    if (false == std::isalpha(ch))
      continue;
    index = static_cast<int>(ch - 'a');
    v.at(index)++;
  }

  return true;
}

int main() {
  std::string alpha("abcdefghijklmnopqrstuvwxyz");
  std::string str;
  std::vector<int> vec(26);

  for (unsigned int i = 0; i < vec.size(); i++) {
    vec.at(i) = 0;
  }

  if (true == readLines(str)) {
    countAlpha(str, vec);
    for (unsigned int i = 0; i < vec.size(); i++) {
      std::cout << alpha.at(i) << " : " << vec.at(i) << std::endl;
    }
  }

  return (0);
}
Problem p02417 (C++)

Buggy submission (status: 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 (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;
}

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 (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;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cctype>
#include <cstdio>
int main() {
  int n[26] = {0};
  char c;
  while (scanf("%c", &c), c != EOF)
    n[(int)tolower(c) - 97]++;
  c = 97;
  for (int i = 0; i < 26; i++)
    printf("%c : %d\n", c + i, n[i]);
}

Fixed submission:
#include <cctype>
#include <cstdio>
int main() {
  int n[26] = {0};
  char c;
  while (scanf("%c", &c) != EOF)
    n[(int)tolower(c) - 97]++;
  c = 97;
  for (int i = 0; i < 26; i++)
    printf("%c : %d\n", c + i, n[i]);
}
Problem p02417 (C++)

Buggy submission (status: 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) {
    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;
}


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) {
    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;
}
Problem p02417 (C++)

Buggy submission (status: Runtime Error):

#include <cstdio>

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


Fixed submission:

#include <cstdio>

int main() {
  int count[1201];
  char ch;
  while (scanf("%c", &ch) != EOF) {
    if (ch >= 'a' && ch <= 'z') {
      count[ch - 'a']++;
    } else if (ch >= 'A' && ch <= 'Z') {
      count[ch - 'A']++;
    }
  }
  for (int j = 0; j < 26; j++) {
    printf("%c : %d\n", j + 'a', count[j]);
  }
  return 0;
}
Problem p02417 (C++)

Buggy submission (status: 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()) != '\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]);
  }
}

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()) != 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]);
  }
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02417 (C++)

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

int main(void) {

  int counter[26];
  string ch;
  char c;

  for (c = 'a'; c <= 'z'; c++) {
    counter[c] = 0;
  }

  while (cin >> ch) {
    for (int i = 0; i < (int)ch.size(); i++) {
      if (isupper(ch[i]))
        ch[i] = tolower(ch[i]);
      counter[ch[i]]++;
    }
  }

  for (c = 'a'; c <= 'z'; c++) {
    cout << c << " : " << counter[c] << endl;
  }

  return 0;
}


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

int main(void) {

  int counter[256];
  string ch;
  char c;

  for (c = 'a'; c <= 'z'; c++) {
    counter[c] = 0;
  }

  while (cin >> ch) {
    for (int i = 0; i < (int)ch.size(); i++) {
      if (isupper(ch[i]))
        ch[i] = tolower(ch[i]);
      counter[ch[i]]++;
    }
  }

  for (c = 'a'; c <= 'z'; c++) {
    cout << c << " : " << counter[c] << endl;
  }

  return 0;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#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]);
  }
}


Fixed submission:
#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]);
  }
}
Problem p02417 (C++)

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

int main() {
  char c;
  int a[26] = {0};
  char d[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 b, i;
  while (scanf("%c", &c) && c != EOF) {
    if (c >= 'a' && c <= 'z') {
      b = c - 'a';
      a[b]++;
    } else if (c >= 'A' && c <= 'Z') {
      b = c - 'A';
      a[b]++;
    }
  }
  for (i = 0; i < 26; i++) {
    cout << d[i] << " : " << a[i] << endl;
  }
}

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

int main() {
  char c;
  int a[26] = {0};
  char d[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 b, i;
  while (scanf("%c", &c) != EOF) {
    if (c >= 'a' && c <= 'z') {
      b = c - 'a';
      a[b]++;
    } else if (c >= 'A' && c <= 'Z') {
      b = c - 'A';
      a[b]++;
    }
  }
  for (i = 0; i < 26; i++) {
    cout << d[i] << " : " << a[i] << endl;
  }
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  unordered_multiset<string> parts;
  vector<string> alphabet;
  for (int i = 97; i < 123; i++) {
    alphabet.push_back(string(1, (char)i));
  }
  while (1) {
    string word;
    cin >> word;
    for (auto var : word) {
      parts.insert(string(1, tolower(var)));
    }
    if (*(word.end() - 1) == '.')
      break;
  }
  for (auto var : alphabet) {
    cout << var << " : " << parts.count(var) << endl;
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  unordered_multiset<string> parts;
  vector<string> alphabet;
  for (int i = 97; i < 123; i++) {
    alphabet.push_back(string(1, (char)i));
  }

  char tmpc;
  while (cin >> tmpc) {
    parts.insert(string(1, tolower(tmpc)));
  }
  for (auto var : alphabet) {
    cout << var << " : " << parts.count(var) << endl;
  }

  return 0;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#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++;
  }
}

Fixed submission:
#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++;
  }
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
char a;
int kotae[26], b;
int main(void) {
  while (1) {
    scanf(" %c", &a);
    if (a == '.')
      break;
    for (int j = 0; j < 26; j++) {
      if (a == 'a' + j || a == 'A' + j) {
        kotae[j] += 1;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)('a' + i) << " : " << kotae[i] << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
char a;
int kotae[26], b;
int main(void) {
  while (1) {
    if (scanf(" %c", &a) == EOF)
      break;
    for (int j = 0; j < 26; j++) {
      if (a == 'a' + j || a == 'A' + j) {
        kotae[j] += 1;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)('a' + i) << " : " << kotae[i] << endl;
  }
}
Problem p02417 (C++)

Buggy submission (status: 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 (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;
}


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 (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;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <ctype.h>
#include <stdio.h>

int main(void) {
  char str;
  static int cnt[26];
  int ptr;

  while (true) {
    scanf("%c", &str);
    if (str == EOF)
      break;

    if (isalpha(str)) {
      if (isupper(str))
        ptr = str - 'A';
      else
        ptr = str - 'a';
      cnt[ptr]++;
    }
  }

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

  return 0;
}

Fixed submission:
#include <ctype.h>
#include <stdio.h>

int main(void) {
  char str;
  static int cnt[26];
  int ptr;

  while (scanf("%c", &str) != EOF) {

    if (isalpha(str)) {
      if (isupper(str))
        ptr = str - 'A';
      else
        ptr = str - 'a';
      cnt[ptr]++;
    }
  }

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

  return 0;
}
Problem p02417 (C++)

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

int main() {

  char moji;
  int alpha[26] = {0};

  while ((moji = getchar()) != 0) {
    moji = tolower(moji);
    alpha[moji - 'a']++;
  }

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

  return 0;
}


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

int main() {

  char moji;
  int alpha[26] = {0};

  while ((moji = getchar()) != EOF) {
    moji = tolower(moji);
    alpha[moji - 'a']++;
  }

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

  return 0;
}
Problem p02417 (C++)

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

int main(void) {
  int a[26] = {0};
  char text;
  while (true) {
    cin >> text;
    if (text >= 'a' && text <= 'z')
      a[text - 'a']++;
    if (text >= 'A' && text <= 'Z')
      a[text - 'A']++;
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)(i + 'a') << " : " << a[i] << endl;
  }
  return 0;
}

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

int main(void) {
  int a[26] = {0};
  char text;
  while (cin >> text) {
    if (text >= 'a' && text <= 'z')
      a[text - 'a']++;
    if (text >= 'A' && text <= 'Z')
      a[text - 'A']++;
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)(i + 'a') << " : " << a[i] << endl;
  }
  return 0;
}
Problem p02417 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string ch;
  int result[25] = {0};
  cin >> ch;
  for (int i = 0; i < ch.size(); i++) {
    if (isalpha(ch[i])) {
      result[ch[i] - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)('a' + i) << " : " << result[i] << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string ch;
  int result[26] = {0};
  while (getline(cin, ch)) {
    for (int i = 0; i < ch.size(); i++) {
      if (isalpha(ch[i])) {
        ch[i] = tolower(ch[i]);
        result[ch[i] - 'a']++;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)('a' + i) << " : " << result[i] << endl;
  }
}
Problem p02417 (C++)

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

int main() {
  char ch;
  int count[26] = {0};
  int i;

  while (1) {
    cin >> ch;
    if (isalpha(ch) != 0) {
      count[tolower(ch) - 'a']++;
    }
  }
  for (i = 0; i < 26; i++) {
    cout << (char)(i + 'a') << " : " << count[i] << endl;
  }
  return 0;
}

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

int main() {
  char ch;
  int count[26] = {0};
  int i;

  while (cin >> ch) {
    if (isalpha(ch) != 0) {
      count[tolower(ch) - 'a']++;
    }
  }
  for (i = 0; i < 26; i++) {
    cout << (char)(i + 'a') << " : " << count[i] << endl;
  }
  return 0;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <math.h>
#include <stdio.h>
#include <string.h>
#define rep(i, a, n) for (int i = a; i < n; i++)

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

Fixed submission:
#include <math.h>
#include <stdio.h>
#include <string.h>
#define rep(i, a, n) for (int i = a; i < n; i++)

int main() {
  char c;
  int d[26] = {0};
  while (scanf("%c", &c) != EOF) {
    // if(c=='0') break;
    if ('a' <= c && c <= 'z')
      d[c - 'a']++;
    else if ('A' <= c && c <= 'Z')
      d[c - 'A']++;
  }
  rep(i, 0, 26) { printf("%c : %d\n", 'a' + i, d[i]); }
  return 0;
}
Problem p02417 (C++)

Buggy submission (status: Time Limit Exceeded):
#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]);
  }
}


Fixed submission:
#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]);
  }
}
Problem p02417 (C++)

Buggy submission (status: 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 (moji == si[spos]) {
      cnt++;
      spos++;
    } else {
      cout << moji << " : " << cnt << endl;
      moji = char(int(moji) + 1);
      cnt = 0;
    }
  }
  return 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 (spos < si.size() && moji == si[spos]) {
      cnt++;
      spos++;
    } else {
      cout << moji << " : " << cnt << endl;
      moji = char(int(moji) + 1);
      cnt = 0;
    }
  }
  return 0;
}
Problem p02417 (Python)

Buggy submission (status: Runtime Error):
import sys
from collections import Counter

m = Counter(sys.stdin.read.lower())
for i in "abcdefghijklmnopqrstuvwxyz":
    print(i, ":", m[i])


Fixed submission:
import sys
from collections import Counter

m = Counter(sys.stdin.read().lower())
for i in "abcdefghijklmnopqrstuvwxyz":
    print(i, ":", m[i])
Problem p02418 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
int main() {
  string s, p;
  cin >> s >> p;
  int i, j, n, m;
  n = s.length();
  m = p.length();
  for (i = 0; i < n; i = (i + 1) % n) {
    for (j = 0; j < m; j++) {
      if (s.at((i + j) % n) != p.at(j))
        break;
      if (j == m - 1)
        j++;
    }
    if (j == m + 1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
int main() {
  string s, p;
  cin >> s >> p;
  int i, j, n, m;
  n = s.length();
  m = p.length();
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (s.at((i + j) % n) != p.at(j))
        break;
      if (j == m - 1)
        j++;
    }
    if (j == m + 1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}
Problem p02418 (C++)

Buggy submission (status: Runtime Error):
#include <cctype>
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
  char str1[100], str2[100], str3[100];
  scanf("%s\n%s", str1, str2);

  int length = strlen(str1);
  strcpy(str3, str1);
  strcat(str3, str1); // 文字列 str1 に文字列 str2 を連結する

  if (strstr(str3, str2) == NULL)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}


Fixed submission:
#include <cctype>
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
  char str1[100], str2[100], str3[200];
  scanf("%s\n%s", str1, str2);

  int length = strlen(str1);
  strcpy(str3, str1);
  strcat(str3, str1); // 文字列 str1 に文字列 str2 を連結する

  if (strstr(str3, str2) == NULL)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}
Problem p02418 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
// s: a raw text, p: a pattern text
// p in s ? true:false
char s[101];
char p[101];
int main() {
  int i, n, j, flag, pflag;
  scanf("%s", s);
  scanf("%s", p);
  for (i = 0; s[i] != '\0'; ++i) {
    pflag = 0;
    for (n = i, flag = 0; s[n == 0 ? 0 : n - 1] != '\0';) {
      for (j = 0; p[j] != '\0' && pflag == 0; ++j) {
        // printf("%d!!%d:%d, %c:%c\n",i, n, j, s[n], p[j]);
        if (s[n] == '\0') {
          // printf("loop%d:%d, %c:%c\n", n, j, s[n], p[j]);
          if (flag != 0) {
            pflag = 1;
          }
          flag++;
          n = 0;
          j--;
          continue;
        }
        if (s[n++] != p[j])
          break;
        if (p[j + 1] == '\0') {
          printf("Yes\n");
          return 0;
        }
      }
      if (j != 0) {
        --n;
      } else {
      }
    }
  }
  printf("No\n");
  return 0;
}


Fixed submission:
#include <stdio.h>
// s: a raw text, p: a pattern text
// p in s ? true:false
char s[101];
char p[101];
int main() {
  int i, n, j, flag, pflag;
  scanf("%s", s);
  scanf("%s", p);
  for (i = 0; s[i] != '\0'; ++i) {
    pflag = 0;
    for (n = i, flag = 0; s[n == 0 ? 0 : n - 1] != '\0' && pflag == 0;) {
      for (j = 0; p[j] != '\0' && pflag == 0; ++j) {
        // printf("%d!!%d:%d, %c:%c\n",i, n, j, s[n], p[j]);
        if (s[n] == '\0') {
          // printf("loop%d:%d, %c:%c\n", n, j, s[n], p[j]);
          if (flag != 0) {
            pflag = 1;
          }
          flag++;
          n = 0;
          j--;
          continue;
        }
        if (s[n++] != p[j])
          break;
        if (p[j + 1] == '\0') {
          printf("Yes\n");
          return 0;
        }
      }
      if (j != 0) {
        --n;
      } else {
      }
    }
  }
  printf("No\n");
  return 0;
}
Problem p02418 (C++)

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

int main() {
  char s[202], p[100];
  scanf("%s", s);
  scanf("%s", p);
  strcat(s, s);
  if (strstr(s, p)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Fixed submission:
#include <cstdio>
#include <cstring>

int main() {
  char s[202], p[100];
  scanf("%s", s);
  scanf("%s", p);
  sprintf(s, "%s%s", s, s);
  if (strstr(s, p)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}
Problem p02418 (C++)

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

#define ll long long
#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define MD 1000000007

char sep[2] = {' ', '\n'};

int main() {
  int i, j, k, n, m, l;

  char s1[210], s2[110];
  scanf("%s\n%s", s1, s2);
  strcat(s1, s1);
  if (nullptr == strstr(s1, s2))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


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

#define ll long long
#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define MD 1000000007

char sep[2] = {' ', '\n'};

int main() {
  int i, j, k, n, m, l;

  char s1[210], s2[110], s3[210];
  cin >> s1 >> s2;
  strcpy(s3, s1);
  strcat(s3, s1);
  if (nullptr == strstr(s3, s2))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}
Problem p02418 (C++)

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

int main() {
  char str1[201], str2[101];
  cin >> str1 >> str2;
  cout << (strstr(strcat(str1, str1), str2) ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
  char test_str[201], search_string[101], copied_test_str[101];
  cin >> test_str >> search_string;
  strcpy(copied_test_str, test_str);
  strcat(test_str, copied_test_str);

  cout << (strstr(test_str, search_string) ? "Yes" : "No") << endl;
  return 0;
}
Problem p02418 (C++)

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

int main() {
  string p, s;
  cin >> s;
  cin >> p;
  for (int i = 0; i < 100; i++)
    s += s;
  if (s.find(p) != string::npos)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  string p, s;
  cin >> s;
  cin >> p;
  while (s.size() <= 100)
    s += s;
  if (s.find(p) != string::npos)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}