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 x;
  for (;;) {
    scanf("%c", &x);

    if (x == '\\n')
      break;

    if (islower(x) == 0) {
      cout << char(tolower(x));
    } else if (islower(x) != 0) {
      cout << char(toupper(x));
    } else {
      cout << x;
    }
  }

  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  char x;
  for (;;) {
    cin >> x;

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

    if (islower(x) == 0) {
      cout << char(tolower(x));
    } else if (islower(x) != 0) {
      cout << char(toupper(x));
    } else {
      cout << x;
    }
  }

  cout << endl;

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

#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  for (char c; (c = getchar()) != '\\n';) {
    if (c >= 65 && c <= 90)
      cout << (char)(c + 32);
    else if (c >= 97 && c <= 122)
      cout << (char)(c - 32);
    else
      cout << c;
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  char tgt;
  while (1) {
    cin >> tgt;
    if ((tgt >= 'a') && (tgt <= 'z')) {
      printf("%c", tgt - 32);
    } else if ((tgt >= 'A') && (tgt <= 'Z')) {
      printf("%c", tgt + 32);
    } else {
      printf("%c", tgt);
    }
    if (tgt == '\\n') {
      break;
    }
  }
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
#include <cctype>
#include <stdio.h>

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

Error: TLE

Fixed submission:

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

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

#include <iostream>

using namespace std;

const int dif = 'A' - 'a';

int main() {
  string str;
  getline(cin, str);

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

  cout << str << endl;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

const int dif = 'A' - 'a';

int main() {
  string str;
  bool isFirst = true;
  for (;;) {
    cin >> str;

    for (int i = 0; i < static_cast<int>(str.size()); i++) {
      if ('A' <= str[i] && str[i] <= 'Z') {
        str[i] -= dif;
      }
    }

    if (isFirst && 'a' <= str[0] && str[0] <= 'z') {
      str[0] += dif;
      isFirst = false;
    }

    cout << str;
    if (str[str.size() - 1] == '.') {
      cout << endl;
      return 0;
    } else {
      cout << ' ';
    }
  }
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <iostream>
#include <queue>
#include <stack>
#include <stddef.h>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  char ch;

  while (1) {
    scanf("%c", &ch);
    if (islower(ch))
      ch = toupper(ch);
    else if (isupper(ch))
      ch = tolower(ch);
    cout << ch;
    if (ch == '\\n')
      break;
  }
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>
#include <queue>
#include <stack>
#include <stddef.h>
#include <string>

using namespace std;

int main() {
  char ch;

  while (1) {
    cin >> ch;
    if (islower(ch))
      ch = toupper(ch);
    else if (isupper(ch))
      ch = tolower(ch);
    cout << ch;
    if (ch == '\\n')
      break;
  }
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  char s[1200];
  int c;
  int cnt = 0;

  while ((c = getchar()) != EOF) {
    if (c >= 'a' && c <= 'z') {
      c = c - 32;
    } else if (c >= 'A' && c <= 'Z') {
      c = c + 32;
    }
    s[cnt] = c;
    cnt++;
    putchar(c);
  }

  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  char s[1200];
  int c;
  int cnt = 0;

  while (scanf("%c", &c) != 13) {
    if (c >= 'a' && c <= 'z') {
      c = c - 'a' + 'A';
    }
    if (c >= 'A' && c <= 'Z') {
      c = c - 'A' + 'a';
    }
    s[cnt] = c;
    cnt++;
  }
  s[cnt] = '\\0';

  printf("%s\\n", s);

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

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

int main() {
  char in[1200];
  char out;
  int i = 0;

  cin.getline(in, sizeof(in));

  while (1) {
    bool s_tf = false;
    bool l_tf = false;

    s_tf = islower(in[i]);
    l_tf = isupper(in[i]);

    if (s_tf == true) {
      out = toupper(in[i]);
      cout << out;
    } else if (l_tf == true) {
      out = tolower(in[i]);
      cout << out;
    } else if (in[i] == '\\0') {
      cout << endl;
      break;
    } else {
      cout << in[i];
    }
    i++;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  while (1) {
    char in;
    char out;
    bool s_tf = false;
    bool l_tf = false;

    cin >> in;
    s_tf = islower(in);
    l_tf = isupper(in);

    if (s_tf == true) {
      out = toupper(in);
      cout << out;
    } else if (l_tf == true) {
      out << tolower(in);
      cout << out;
    } else if (in == '\\n') {
      break;
    } else {
      cout << in;
    }
  }

  cout << endl;

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

#include "bits/stdc++.h"
using namespace std;
int main() {
  char str[1202];
  memset(str, '+', sizeof(str));
  int i = 0;
  str[i] = getchar();
  while (str[i] == 0x20 || str[i] <= 122 && str[i] >= 33) {
    if (str[i] >= 97) {
      str[i] = str[i] - 32;
    } else if (str[i] >= 65) {
      str[i] = str[i] + 32;
    }
    cout << str[i];
    i++;
    str[i] = getchar();
  }
  cout << endl;
}
// Fair, later, occasionally cloudy.
// Fair, later, occasionally cloudy.

Error: 0

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
int main() {
  char str[1202];
  memset(str, '+', sizeof(str));
  int i = 0;
  str[i] = getchar();
  while (str[i] != '.') {
    if (str[i] >= 97) {
      str[i] = str[i] - 32;
    } else if (str[i] >= 65) {
      str[i] = str[i] + 32;
    }
    cout << str[i];
    i++;
    str[i] = getchar();
  }
  cout << str[i] << endl;
  ;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  char x;
  while (1) {
    x = getchar();
    if (islower(x))
      x = toupper(x);
    else if (isupper(x))
      x = tolower(x);
    cout << x;
    if (x == '\\n')
      break;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
char f(char c) {
  switch (c) {
  case 'a':
    return 'A';
  case 'b':
    return 'B';
  case 'c':
    return 'C';
  case 'd':
    return 'D';
  case 'e':
    return 'E';
  case 'f':
    return 'F';
  case 'g':
    return 'G';
  case 'h':
    return 'H';
  case 'i':
    return 'I';
  case 'j':
    return 'J';
  case 'k':
    return 'K';
  case 'l':
    return 'L';
  case 'm':
    return 'M';
  case 'n':
    return 'N';
  case 'o':
    return 'O';
  case 'p':
    return 'P';
  case 'q':
    return 'Q';
  case 'r':
    return 'R';
  case 's':
    return 'S';
  case 't':
    return 'T';
  case 'u':
    return 'U';
  case 'v':
    return 'V';
  case 'w':
    return 'W';
  case 'x':
    return 'X';
  case 'y':
    return 'Y';
  case 'z':
    return 'Z';
  case 'A':
    return 'a';
  case 'B':
    return 'b';
  case 'C':
    return 'c';
  case 'D':
    return 'd';
  case 'E':
    return 'e';
  case 'F':
    return 'f';
  case 'G':
    return 'g';
  case 'H':
    return 'h';
  case 'I':
    return 'i';
  case 'J':
    return 'j';
  case 'K':
    return 'k';
  case 'L':
    return 'l';
  case 'M':
    return 'm';
  case 'N':
    return 'n';
  case 'O':
    return 'o';
  case 'P':
    return 'p';
  case 'Q':
    return 'q';
  case 'R':
    return 'r';
  case 'S':
    return 's';
  case 'T':
    return 't';
  case 'U':
    return 'u';
  case 'V':
    return 'v';
  case 'W':
    return 'w';
  case 'X':
    return 'x';
  case 'Y':
    return 'y';
  case 'Z':
    return 'z';
  }
  return c;
}
int main() {
  char x;
  while (scanf("%x", &x) != EOF) {
    printf("%x", f(x));
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() { // 受け取る文字列の最大の長さ＋１の配列を用意する
  char s[1201];
  scanf("%[^\\n]", s);

  // ヌル文字に遭遇するまでループする
  for (int i = 0; s[i] != '\\0'; i++) {
    // i番目の文字
    char c = s[i];

    if (c >= 65 && c <= 90) {
      s[i] = c + 32;
    }

    else if (c >= 97 && c <= 122) {
      s[i] = c - 32;
    }
  }
  printf("%s\\n", s);
}


Error: -11

Fixed submission:

#include <cstdio>

int main() { // 受け取る文字列の最大の長さ＋１の配列を用意する
  char s[1201];
  scanf("%[^\\n]", s);

  // ヌル文字に遭遇するまでループする
  for (int i = 0; s[i] != '\\0'; i++) {
    // i番目の文字
    char c = s[i];

    if (c >= 65 && c <= 90) {
      s[i] = c + 32;
    }

    else if (c >= 97 && c <= 122) {
      s[i] = c - 32;
    }
    printf("%sa", s[i]);
  }
}
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 (isupper(ch))
      cout << (char)tolower(ch);
    else if (islower(ch))
      cout << (char)toupper(ch);
    else {
      if (ch == '\\n')
        break;
      cout << ch;
    }
  }
  cout << endl;

  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 (isupper(ch))
      cout << (char)tolower(ch);
    else if (islower(ch))
      cout << (char)toupper(ch);
    else {
      if (ch == '\\n')
        break;
      cout << ch;
    }
  }
  cout << endl;

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

#include <cctype>
#include <stdio.h>
using namespace std;

int main(void) {
  char ch = ' ';

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

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

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

  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  char ch;

  while (true) {
    cin >> ch;

    if (islower(ch))
      cout << (char)toupper(ch);
    else if (isupper(ch))
      cout << (char)tolower(ch);
    else
      cout << ch;

    if (ch == '\\n') {
      cout << "\\n";
      break;
    }
  }

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

#include <cstdio>
using namespace std;
int main() {
  char str;
  while (scanf("%c", &str) != EOF) {
    if (str >= 'a' && str <= 'z') {
      str = str - 32;
      printf("%c", str);
    } else if (str >= 'A' && str <= 'Z') {
      str = str + 32;
      printf("%c", str);
    } else {
      printf("%c", str);
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;
int main() {
  char str;
  while (scanf("%c", &str) && str != EOF) {
    if (str >= 'a' && str <= 'z') {
      str = str - 32;
      printf("%c", str);
    } else if (str >= 'A' && str <= 'Z') {
      str = str + 32;
      printf("%c", str);
    } else {
      printf("%c", str);
    }
  }
  printf("\\n");
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  char moji;

  while (1) {

    scanf("%c", &moji);

    if (moji == '\\n')
      break;

    if (moji == ' ') {

      printf(" ");

      continue;
    }

    if (islower(moji)) {

      printf("%c", toupper(moji));

    } else {

      printf("%c", tolower(moji));
    }
  }

  cout << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  char moji;

  while (1) {

    cin >> moji;

    if (moji == '\\n')
      break;

    if (moji == ' ') {

      cout << " ";
    }

    if (islower(moji)) {

      printf("%c", toupper(moji));

    } else {

      printf("%c", tolower(moji));
    }
  }

  cout << "\\n";

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

#include <iostream>
#include <string>

int main() {
  std::string s;
  std::getline(std::cin, s);
  for (int i = 0; s[i]; ++i) {
    if (65 <= s[i] && s[i] <= 90)
      s[i] += 32;
    else if (97 <= s[i] && s[i] <= 122)
      s[i] -= 32;
  }
  std::cout << s << '\\n';
}

Error: -11

Fixed submission:

#include <iostream>

int main() {
  char *s;
  std::cin >> s;
  while (*s) {
    if (65 <= *s && *s <= 90)
      *s++ += 32;
    else if (97 <= *s && *s <= 122)
      *s++ -= 32;
  }
  std::cout << s << '\\n';
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>

int main() {
  char ch;

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

    if (islower(ch))
      printf("%c", toupper(ch));
    else if (isupper(ch))
      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() {
  char ch;
  while (1) {
    cin >> ch;
    if (ch == '\\n')
      break;
    if (isalpha(ch)) {
      if (isupper(ch)) {
        ch = tolower(ch);
      } else {
        ch = toupper(ch);
      }
      cout << ch;
    } else {
      cout << ch;
      if (ch != '.') {
        cout << " ";
      }
    }
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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


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

int main() {
  string str;
  int i;
  getline(cin, str);
  for (i = 0; i < str.length(); i++) {
    if (islower(str[i])) {
      str[i] = toupper(str[i]);
    } else if (isupper(str[i])) {
      str[i] = tolower(str[i]);
    }
    cout << str[i];
  }
  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

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

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

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

    if (islower(s))
      s = toupper(s);
    else if (isupper(s))
      s = tolower(s);
    printf("%c", s);
  }
  cout << endl;

  return 0;
}

/*


#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int main() {
        for (char c; (c = getchar()) != '\\n';) {
                if (islower(c))
                        cout << (char)toupper(c);
                else if (isupper(c))
                        cout << (char)tolower(c);
                else
                        cout << c;
        }
        cout << endl;
        return 0;
}





#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int main() {
        string s; getline(cin, s);
        for (int i = 0; i < s.size(); i++) {
                if (islower(s[i]))
                        cout << (char)toupper(s[i]);
                else if (isupper(s[i]))
                        cout << (char)tolower(s[i]);
                else
                        cout << s[i];
        }
        cout << endl;
        return 0;
}
*/

Error: TLE

Fixed submission:

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

int main() {
  char s[1200] = {};
  while (1) {
    cin >> s;

    for (int i = 0; s[i]; i++) {

      if (islower(s[i]))
        s[i] = toupper(s[i]);
      else if (isupper(s[i]))
        s[i] = tolower(s[i]);
      cout << s[i];
      if (s[i] == '.') {
        cout << endl;
        return 0;
      }
    }
    cout << ' ';
  }

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

#include <iostream>
using namespace std;
int main() {
  char i;
  while ((i = cin.get())) {
    if (i == '\\n') {
      cout << endl;
      break;
    }
    if (i >= 'a' && i <= 'z')
      cout << char(i - 32);
    else if (i >= 'A' && i <= 'Z')
      cout << char(i + 32);
    else
      cout << i;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  string str;
  getline(cin, str);
  for (char &i : str) {
    if (i >= 'a' && i <= 'z')
      i = i + ('A' - 'a');
    else if (i >= 'A' && i <= 'Z')
      i = i - ('A' - 'a');
  }
  cout << str << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <iostream>
#include <string>

int main(int argc, char const *argv[]) {
  std::string s;
  std::getline(std::cin, s);
  std::string::const_iterator it = s.begin();
  while (it != s.end()) {
    char c;
    c = *it;
    if (c == '\\n')
      break;
    if (std::islower(c)) {
      c = (char)std::toupper(c);
    } else if (std::isupper(c)) {
      c = (char)std::tolower(c);
    }
    std::cout << c;
    it++;
  }
  std::cout << std::endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>

int main(int argc, char const *argv[]) {

  while (1) {
    char c;
    std::cin >> c;
    if (c == '\\n')
      break;
    if (std::islower(c)) {
      c = (char)std::toupper(c);
    } else if (std::isupper(c)) {
      c = (char)std::tolower(c);
    }
    std::cout << c;
  }
  std::cout << std::endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

#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: -11

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

#include <cctype>
#include <iostream>
#include <stdio.h>
using namespace std;
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 if (ch == ' ') {

           cout << ' ';

       } else if (ch == ',') {

           cout << ',';

       } else if (ch == '.') {

           cout << '.';
           */
    } else {

      cout << ch;
    }

    if (ch == '\\n') {

      // cout << endl;
      break;
    }
  }

  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 == '\\n') {

      // cout << endl;
      break;
    }

    if (isalpha(ch) == true) {

      if (islower(ch) == true) {

        printf("%c", toupper(ch));

      } else {

        printf("%c", tolower(ch));
      }

      /* } else if (ch == ' ') {

           cout << ' ';

       } else if (ch == ',') {

           cout << ',';

       } else if (ch == '.') {

           cout << '.';
           */
    } else {

      cout << ch;
    }
  }

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

#include <cstdio>;
// 入出力を行う関数が使える//(scanf,printf)
#include <cctype>;
// 文字の種類の判定や文字の変換を行う関数を使うことができる//

int main() {
  char ch;

  while (true) {
    scanf("%c", &ch);
    // 文字（1文字）として入力する//
    if (isalpha(ch)) {
      // chがアルファベットならtrueを返す//
      if (islower(ch))
        printf("%c", toupper(ch));
      // chが小文字ならtrueを返す// //chの大文字を返す//
      else
        printf("%c", tolower(ch));
      // chの小文字を返す//
    } else
      printf("%c", ch);
    // アルファベット以外はそのまま出力//

    if (ch == '\\n')
      break;
    // 終端文字が現れたら終了//
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>;
// 入出力を行う関数が使える//(scanf,printf)
#include <cctype>;
// 文字の種類の判定や文字の変換を行う関数を使うことができる//

int main() {
  char ch;

  while (true) {
    scanf("%c", ch);
    // 文字（1文字）として入力する//
    if (isalpha(ch)) {
      // chがアルファベットならtrueを返す//
      if (islower(ch))
        printf("%c", toupper(ch));
      // chが小文字ならtrueを返す// //chの大文字を返す//
      else
        printf("%c", tolower(ch));
      // chの小文字を返す//
    } else
      printf("%c", ch);
    // アルファベット以外はそのまま出力//

    if (ch == '\\n')
      break;
    // 終端文字が現れたら終了//
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

int main() {
  char c;
  while (1) {
    cin >> c;
    if (isupper(c)) {
      cout << (char)tolower(c);
    } else {
      cout << (char)toupper(c);
    }
    if (c == '\\n')
      break;
  }
  return 0;
}