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

#include <iostream>
#include <stdio.h>
#include <string>
int main() {
  std::string input;
  std::string output;
  std::cin >> input;
  int temp;
  while (1) {
    temp = getchar();
    if (temp == '\\n') {
      break;
    }
    input += temp;
  }

  output = input;

  for (int i = 0; i < input.length(); i++) {
    if (97 <= input[i] && input[i] <= 122) {
      output[i] = input[i] - 32;
    } else if (65 <= input[i] && input[i] <= 90) {
      output[i] = input[i] + 32;
    } else {
      output[i] = input[i];
    }
  }
  std::cout << output;
  std::cout << std::endl;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>

int main() {
  bool break_key = true;
  while (break_key || std::cin.eof()) {

    std::string str = "";
    std::cin >> str;
    std::string ans = str;
    std::string period = ".";
    for (int i = 0; i < str.length(); i++) {

      if (str[i] == tolower(str[i])) {
        ans[i] = toupper(str[i]);
      } else if (str[i] == toupper(str[i])) {
        ans[i] = tolower(str[i]);
      }
    }

    std::cout << ans;
    if ((char)ans[ans.length() - 1] == '.') {
      std::cout << std::endl;
      break_key = false;
    } else if (!std::cin.eof()) {
      std::cout << " ";
    }
  }
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>

using namespace std;

int main(int argc, char const *argv[]) {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (isalpha(ch)) {
      if (islower(ch)) {
        printf("%c", toupper(ch));
      } else
        printf("%c", tolower(ch));
    } else
      printf("%c", ch);
    if (ch == '\\n')
      break;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  char ch;
  while (1) {
    cin >> ch;
    if (ch == '\\n')
      break;
    if (isupper(ch))
      cout << tolower(ch);
    else if (islower(ch))
      cout << toupper(ch);
    else
      cout << ch;
  }
  cout << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void) {

  string komozi("abcdefghijklmnopqrstuvwxyz");
  string oomozi("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  char inp;
  char retsu[1000000];

  for (int i = 0;; i++) {
    inp = getchar();
    if (inp == '\\n') {
      retsu[i + 1] = '\\0';
      break;
    }
    if (komozi.find(inp) != -1)
      retsu[i] = oomozi[komozi.find(inp)];
    else if (oomozi.find(inp) != -1)
      retsu[i] = komozi[oomozi.find(inp)];
    else
      retsu[i] = inp;
  }

  cout << retsu << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void) {

  string komozi("abcdefghijklmnopqrstuvwxyz");
  string oomozi("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  char inp;
  char retsu[1000000];

  for (int i = 0;; i++) {
    inp = getchar();
    if (inp == '.') {
      retsu[i] = '.';
      retsu[i + 1] = '\\0';
      break;
    }
    if (komozi.find(inp) != -1)
      retsu[i] = oomozi[komozi.find(inp)];
    else if (oomozi.find(inp) != -1)
      retsu[i] = komozi[oomozi.find(inp)];
    else
      retsu[i] = inp;
  }

  cout << retsu << endl;

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

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

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);
    printf("%c", ch);
    if (ch == '\\n')
      break;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>

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;
  }

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

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

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 <cctype>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  while (1) {
    char ch;
    cin >> ch;

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

    if (islower(ch))
      cout << toupper(ch);
    else if (isupper(ch))
      cout << tolower(ch);
    else
      cout << ch;
  }
  cout << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  char str[1300];
  int word = 0;
  while (1) {
    char s;
    scanf("%c", &s);
    char output;
    output = s;
    if (isalpha(s)) {
      if ('a' <= s && s <= 'z') {
        output = toupper(s);
      } else {
        output = tolower(s);
      }
    }
    str[word] = output;
    word += 1;
    if (s == '\\n') {
      break;
    }
  }
  int count = 0;
  // cout << "convert"<< endl;
  while (1) {

    if (str[count] == '\\n') {
      cout << '\\n';
      break;
    } else {
      cout << str[count];
      count += 1;
    }
  }

  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  char str[1300];
  int word = 0;
  while (1) {
    char s;
    cin >> s;

    char output;
    output = s;
    if (isalpha(s)) {
      if (islower(s)) {
        output = toupper(s);
      } else {
        output = tolower(s);
      }
    }
    str[word] = output;
    word += 1;
    if (s == '\\n') {
      break;
    }
  }
  int count = 0;
  while (1) {
    cout << str[count];
    if (str[count] == '\\n') {
      break;
    } else {
      count += 1;
    }
  }

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

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

using namespace std;

int main() {

  char ch;

  while ((ch = getchar()) != EOF) {
    if (islower(ch))
      ch = toupper(ch);
    else
      ch = tolower(ch);
    cout << ch;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>
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;
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <ctype.h>
#include <stdio.h>
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 ch;

  while (1) {
    cin >> ch;

    if (islower(ch)) {
      ch = toupper(ch);
    }

    else if (isupper(ch)) {
      ch = tolower(ch);
    }

    cout << ch;
    if (ch == '\\n')
      break;
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

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

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

Error: -11

Fixed submission:

#include <cctype>
#include <iostream>

int main() {
  char word[1200];

  for (int i = 0;; i++) {
    std::cin >> word[i];

    if (std::islower(word[i])) {
      word[i] = std::toupper(word[i]);
    }

    else if (std::isupper(word[i])) {
      word[i] = std::tolower(word[i]);
    }
    std::cout << word[i];
  }
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  char c;
  while (1) {
    cin.get(c);
    if (c == '\\n')
      break;
    else if ('A' <= c && c <= 'Z')
      c += 'a' - 'A';
    else if ('a' <= c && c <= 'z')
      c -= 'a' - 'A';
    cout.put(c);
  }
  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <cctype>
#include <cstdio>

int main() {
  char ch;

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

  return 0;
}


Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>

int main() {
  char ch;

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

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


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

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

Error: TLE

Fixed submission:

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

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

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

int main() {
  string s;
  getline(cin, s);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      s[i] -= 32;
    } else if (s[i] >= 'A' && s[i] <= 'Z') {
      s[i] += 32;
    }
  }
  cout << s << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  bool a;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    a = false;
    if (s[i] != ',' && s[i] != ' ' && s[i] != '.') {
      for (char c = 'a'; i <= 'z'; c++) {
        if (s[i] == c) {
          a = true;
        }
      }
      if (a == true) {
        s[i] -= 32;
      } else {
        s[i] += 32;
      }
    }
  }
  cout << s << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: 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() {
  string x;
  getline(cin, x);
  for (int i = 0; i < x.size(); i++) {
    if ('a' <= x[i] && x[i] <= 'z')
      cout << (char)(x[i] + ('A' - 'a'));
    else if ('A' <= x[i] && x[i] <= 'Z')
      cout << (char)(x[i] + ('a' - 'A'));
    else
      cout << x[i];
  }
  cout << endl;
  return 0;
}


Error: TLE

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;
    for (int i = 0; i < x.size(); i++) {
      if ('a' <= x[i] && x[i] <= 'z')
        cout << (char)(x[i] + ('A' - 'a'));
      else if ('A' <= x[i] && x[i] <= 'Z')
        cout << (char)(x[i] + ('a' - 'A'));
      else
        cout << x[i];
    }
    cout << endl;
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  char a[1300];
  cin.getline(a, sizeof(a));
  char c[strlen(a)];
  strcpy(c, a);

  for (int i = 0; i < strlen(c); i++) {

    if (islower(c[i])) {
      putchar(toupper(c[i]));
    } else if (isupper(c[i])) {
      putchar(tolower(c[i]));
    } /*else if(c[i]==','){
         cout<<",";
     }else if(c[i]=='.'){
         cout<<".";
     }else if(isspace(c)){
         cout<<" ";
     }*/
    else {
      cout << c[i];
    }
  }

  cout << endl;
}


Error: -11

Fixed submission:

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

using namespace std;

int main() {
  char c[1200];
  cin.getline(c, sizeof(c));

  for (int i = 0; isspace(c[i]) != 1; i++) {
    if (islower(c[i])) {
      putchar(toupper(c[i]));
    } else if (isupper(c[i])) {
      putchar(tolower(c[i]));
    } else if (c[i] == ',') {
      cout << ",";
    } else if (c[i] == '.') {
      cout << ".";
    } else {
      cout << " ";
    }
  }

  cout << "." << endl;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>

#include <iomanip>
#define PI                                                                     \\
  3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148
using namespace std;
#define A                                                                      \\
  0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333

int main() {
  string str;

  while (getline(cin, str)) {
    for (unsigned int i = 0; i < str.size();
         i++) //??????????°??????¢?????§?????????????????§?????¢????°????
    {
      if (islower(
              str[i])) //??????????????\\???????????¢???????±?????????\\????????¬????????¨????????\\??????ascll????????¨???
        str[i] = toupper(str[i]);
      else if (isupper(str[i]))
        str[i] = tolower(
            str[i]); //???????°±???????????????????°±???????????\\?????????????????§??????????????????????????????????????????????°±????????????????????°????????????????????????????????????
      cout << str[i];
    }
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>

#include <iomanip>
#define PI                                                                     \\
  3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148
using namespace std;
#define A                                                                      \\
  0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333

int main() {
  string str;
  while (true) {
    getline(cin, str);
    for (unsigned int i = 0; i < str.size();
         i++) //??????????°??????¢?????§?????????????????§?????¢????°????
    {
      if (islower(
              str[i])) //??????????????\\???????????¢???????±?????????\\????????¬????????¨????????\\??????ascll????????¨???
        str[i] = toupper(str[i]);
      else if (isupper(str[i]))
        str[i] = tolower(
            str[i]); //???????°±???????????????????°±???????????\\?????????????????§??????????????????????????????????????????????°±????????????????????°????????????????????????????????????
      cout << str[i] << endl;
    }
  }
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

#include <ctype.h>
#include <stdio.h>
int main(void) {
  char ch;
  char temp, i;

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

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

  puts("");

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main(void) {
  char sentence[1200];
  char temp, i;
  scanf("%s", sentence);

  i = 0;
  do {
    char temp = sentence[i];

    if ('a' <= temp && temp <= 'z') {
      sentence[i] += 'A' - 'a';
      printf("%c", sentence[i]);
    } else if ('A' <= temp && temp <= 'Z') {
      sentence[i] -= 'A' - 'a';
      printf("%c", sentence[i]);
    } else {
      printf("%c", sentence[i]);
    }
    i++;
  } while (sentence[i - 1] != EOF || sentence[i - 1] != '\\n');

  puts("");

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

#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef vector<int> vec;

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

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef vector<int> vec;

int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (islower(ch))
      printf("%c", toupper(ch));
    else
      printf("%c", tolower(ch));
    if (ch == '\\0')
      break;
  }
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  char a;

  for (;;) {
    scanf("%c", &a);
    /* cin >> a; */
    if (a == '\\n') {
      cout << endl;
      break;
    } else {
      if (islower(a)) {
        printf("%c", toupper(a));
        /*cout <<  (char)toupper(a);*/
      } else if (isupper(a)) {
        printf("%c", tolower(a));
        /*cout <<  (char)tolower(a);*/
      } else {
        printf("%c", a);
        /*cout << a;*/
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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


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

int main() {
  char ch;
  while (1) {
    scanf("%c", &ch); // scanf???' '???????????????
    if (ch == '\\n')
      break;
    if (islower(ch) != 0) { //?°???????????????°true
      ch = toupper(ch);     //?°?????????? ??§??????
      cout << ch;
    } else if (isupper(ch) != 0) { //??§??????????????°true
      ch = tolower(ch);            //??§????????? ?°???????
      cout << ch;
    } else {
      cout << ch;
    }
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  char ch; // ch:?????????

  while (1) {
    cin >> ch;
    if (ch == '\\n')
      break;

    if (islower(ch) != 0) { // ch????°???????????????\\????°????????????????
      ch = toupper(ch);     //?°????????????§??????
      cout << ch;
    } else if (isupper(ch) !=
               0) {     //??§???????????????????????\\?????§???????????????
      ch = tolower(ch); // o??????????°???????
      cout << ch;
    } else { //??±????????\\???
      cout << ch;
    }
  }
  cout << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>
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
      printf("%c", ch);
    if (ch == '\\n')
      break;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
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
      printf("%c", ch);
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  char ch; // ch:?????????

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

    if (islower(ch) != 0) { // ch????°???????????????\\????°????????????????
      ch = toupper(ch);     //?°????????????§??????
      cout << ch;
    } else if (isupper(ch) !=
               0) {     //??§???????????????????????\\?????§???????????????
      ch = tolower(ch); // o??????????°???????
      cout << ch;
    } else { //??±????????\\???
      cout << ch;
    }
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:


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

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

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

using namespace std;

int main() {
  char c;
  while (true) {
    scanf("%c", &c);

    if (isalpha(c)) {
      if (islower(c))
        cout << (char)toupper(c);
      else
        cout << (char)tolower(c);
    } else
      cout << c;

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


Error: TLE

Fixed submission:

#include <ctype.h>
#include <iostream>

using namespace std;

int main() {
  char c;
  while (true) {
    cin >> c;

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

    if (isalpha(c)) {
      if (islower(c))
        cout << (char)toupper(c);
      if (isupper(c))
        cout << (char)tolower(c);
    } else
      cout << c;
  }
  cout << endl;
}