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

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


Error: TLE

Fixed submission:

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

#include <cctype>
#include <cstdio>

using namespace std;

int main() {
  char c;

  while (true) {
    scanf("%c", &c);
    if (isupper(c))
      c = tolower(c);
    else if (islower(c))
      c = toupper(c);

    printf("%c", c);

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

  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  char c;

  while (true) {
    cin >> c;
    if (c == '\\n')
      break;
    else {
      if (isupper(c))
        c = tolower(c);
      else if (islower(c))
        c = toupper(c);

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

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

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

bool is_lower(char &c) {
  if ('a' <= c && c <= 'z') {
    return true;
  }
  return false;
}

bool is_upper(char &c) {
  if ('A' <= c && c <= 'Z') {
    return true;
  }
  return false;
}

void to_lower(char &c) { c += 'a' - 'A'; }

void to_upper(char &c) { c += 'A' - 'a'; }

int main() {
  string str;
  getline(cin, str);
  for (int i = 0; i < str.length(); i++) {
    if (is_lower(str[i])) {
      to_upper(str[i]);
    } else if (is_upper(str[i])) {
      to_lower(str[i]);
    }
    printf("%c", str[i]);
  }
  printf("\\n");
  return 0;
}

Error: TLE

Fixed submission:

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

bool is_lower(char &c) {
  if ('a' <= c && c <= 'z') {
    return true;
  }
  return false;
}

bool is_upper(char &c) {
  if ('A' <= c && c <= 'Z') {
    return true;
  }
  return false;
}

void to_lower(char &c) { c += 'a' - 'A'; }

void to_upper(char &c) { c += 'A' - 'a'; }

int main() {
  char c;
  while (1) {
    cin >> c;
    if (is_lower(c)) {
      to_upper(c);
    } else if (is_upper(c)) {
      to_lower(c);
    }
    printf("%c", c);
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <cstdio>

using namespace std;

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

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>

using namespace std;

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

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

#include <cctype>
#include <cstdio>

int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (isalpha(ch)) {
      if (islower(ch))
        printf("%c", toupper(ch));
      else
        printf("%c", tolower(ch));
    } else
      printf("%c", ch);

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

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>

int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if (isalpha(ch)) {
      if (islower) {
        printf("%c", toupper(ch));
      } else {
        printf("%c", tolower(ch));
      }

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

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

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

int main() {
  char ch, ch2;

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

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

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

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  char ch, ch2;

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

    if (islower(ch)) {
      ch2 = toupper(ch);
      cout << ch2;
    } else {
      ch2 = tolower(ch);
      cout << ch2;
    }
    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 c;
  while (1) {
    cin.get(c);
    if (c == '\\n')
      break;
    if (isalpha(c)) //??±???????????????????????\\?????????????????????
    {
      if (islower(c))
        cout << (char)toupper(c);
      //?°????????????§??????????????????islower(c)??§???c????°????????????¨???????????????
      else
        cout << (char)tolower(c);
      //??§??????????°???????????????????isupper(c)??§???c?????§???????????¨???????????????
    }
    // else if(c==' ') cout << " ";
    else
      cout << c;
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>
#define N 1200
using namespace std;

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

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
char upper(char C) {
  if (C >= 'a' && C <= 'z') {
    C -= 'a' - 'A';
  } else if (C >= 'A' && C <= 'Z')
    C += 'a' - 'A';
  return C;
}
int main() {
  string str;
  vector<string> pri;
  while (cin >> str) {
    for (int i = 0; i < str.size(); i++)
      str[i] = upper(str[i]);
    pri.push_back(str);
  }
  for (int i = 0; i < pri.size(); i++) {
    cout << pri[i];
    if (i != pri.size() - 1)
      cout << " ";
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
char upper(char C) {
  if (C >= 'a' && C <= 'z') {
    C -= 32;
  } else if (C >= 'A' && C <= 'Z')
    C += 32;
  return C;
}
int main() {
  char s;
  while (cin >> s, s != '\\n') {
    s = upper(s);
    cout << s;
  }
  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 (isalpha(ch)) {
      if (isupper(ch))
        printf("%c", tolower(ch));
      else
        printf("%c", toupper(ch));
    } else
      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 (ch == '\\n')
      break;

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

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

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

int main() {
  char ch;
  while (1) {
    scanf("%c", &ch);
    if ('a' <= ch && ch <= 'z') {
      printf("%c", ch - 32);
    } else if ('A' <= ch && ch <= 'Z') {
      printf("%c", ch + 32);
    } else {
      printf("%c", ch);
    }
    if (ch == '\\n')
      break;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  while (1) {
    char ch;
    cin >> ch;
    int islower(char ch);
    if (ch == true) {
      int toupper(char ch);
    } else {
      int toupper(char ch);
    }
    int isupper(char ch);
    if (ch == true) {
      int tolower(char ch);
    } else {
      int toupper(char ch);
    }
  }

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

#include <stdio.h>
using namespace std;
//---------------------------------------
void henkan(char inp[]); //?°?????????¨??§???????????\\?????????
//---------------------------------------

int main(void) {
  // char inp0[12] = "abcdefghijk";
  char inp1[1201];
  // char inp2[12] = "abcdefghijk";

  fgets(inp1, 1201, stdin);

  henkan(inp1);

  printf("%s", inp1);
  // printf("%s\\n",inp0);
  // printf("%s\\n",inp2);

  return 0;
}

//------------------------------------------
void henkan(char inp[]) {
  for (int i = 0; i < 1200; i++) {
    if (inp[i] >= 'A' && inp[i] <= 'Z') {
      inp[i] += 32;
    } else if (inp[i] >= 'a' && inp[i] <= 'z') {
      inp[i] -= 32;
    }
  }
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <stdio.h>
using namespace std;
//---------------------------------------
void henkan(char inp[]); //?°?????????¨??§???????????\\?????????
//---------------------------------------

int main(void) {
  // char inp0[12] = "abcdefghijk";
  char inp1[12];
  // char inp2[12] = "abcdefghijk";

  fgets(inp1, 12, stdin);

  henkan(inp1);

  printf("%s\\n", inp1);
  // printf("%s\\n",inp0);
  // printf("%s\\n",inp2);

  return 0;
}

//------------------------------------------
void henkan(char inp[]) {
  for (int i = 0; i < 1200; i++) {
    if (inp[i] >= 'A' && inp[i] <= 'Z') {
      inp[i] += 32;
    } else if (inp[i] >= 'a' && inp[i] <= 'z') {
      inp[i] -= 32;
    }
  }
}
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 <iostream>

using namespace std;

int main() {
  char t;

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

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

int main() {

  int b, i = 0;
  // char buf[1200];
  string a;
  getline(cin, a);
  /*
  while(i < 1200){
          b = buf[i];
          if(b == '\\n')break;
          else if(b >= 96 && b <= 122){
                  b -= 32;
          }

          else if(b >= 64 && b <= 90){
                  b += 32;
          }
          cout << char(b);
          i++;
  }
  */

  for (int i = 0; i < a.size(); i++) {
    b = a[i];
    if (b == '\\n')
      break;
    else if (b >= 96 && b <= 122) {
      b -= 32;
    }

    else if (b >= 64 && b <= 90) {
      b += 32;
    }
    cout << (char)b;
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int a;
  char b;

  while (1) {

    cin >> b;

    a = b;

    if (a >= 97 && a <= 122) {
      a -= 32;
    }

    if (a >= 65 && a <= 90) {
      a += 32;
    }

    b = a;

    cout << b;

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

  cout << endl;

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

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>

#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 <algorithm>
#include <iostream>
#include <sstream>
#include <string>

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

int main() {
  char ch;
  while (1) {
    cin >> 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: Runtime Error

#include <cstdio>;
// 入出力を行う関数が使える//(scanf,printf)
#include <cctype>;

int main() {
  char ch;

  while (true) {
    scanf("%c", &ch);
    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: -11

Fixed submission:

#include <cstdio>;
// 入出力を行う関数が使える//(scanf,printf)
#include <cctype>;

int main() {
  char ch;

  while (true) {
    scanf("%c,&ch");
    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: Runtime Error

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

using namespace std;

int main() {

  char ch[2048];

  cin.getline(ch, 2048, '\\n');

  int len = strlen(ch);

  for (int i = 0; i < len; i++) {
    if (ch[i] >= 'a' && ch[i] <= 'z') {
      ch[i] += 'A' - 'a';
    } else if (ch[i] <= 'Z' && ch[i] >= 'A') {
      ch[i] += 'a' - 'A';
    }
  }

  cout << ch << endl;

  return 0;
}


Error: 0

Fixed submission:

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

using namespace std;

int main() {

  char ch[1021];

  cin.getline(ch, 1201, '\\n');

  int len = strlen(ch);

  for (int i = 0; i < len; i++) {
    if (ch[i] >= 'a' && ch[i] <= 'z') {
      ch[i] += 'A' - 'a';
    } else if (ch[i] <= 'Z' && ch[i] >= 'A') {
      ch[i] += 'a' - 'A';
    }
  }

  cout << ch << endl;

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

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

int main() {
  char a[1200] = {0};
  string b;
  getline(cin, b);
  b.copy(a, b.size());
  a[b.size()] = '\\0';
  for (int i = 0; a[i] != '\\0'; ++i) {
    if (islower(a[i])) {
      a[i] = toupper(a[i]);
    } else if (isupper(a[i])) {
      a[i] = tolower(a[i]);
    }
  }

  cout << a << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  char ch;

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

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

using namespace std;

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

    if (c >= 'a' && 'z' >= c) {
      c -= 'a' - 'A';
      cout << c;
    } else if (c >= 'A' && 'Z' >= c) {
      c += 'a' - 'A';
      cout << c;
    } else if (c == '\\n') {
      break;
    } else {
      cout << c;
    }
  }
  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  char c;
  while (scanf("%c", &c)) {
    if (c >= 'a' && 'z' >= c) {
      c -= 'a' - 'A';
      cout << c;
    } else if (c >= 'A' && 'Z' >= c) {
      c += 'a' - 'A';
      cout << c;
    } else {
      cout << c;
    }
  }
  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 = 'A', x = 'A';
  int k = 0;
  while (k < 1200) {

    scanf("%c", &ch);
    if (ch == '\\n')
      break;
    if (isalpha(ch)) {
      if (islower(ch)) {
        x = toupper(ch);
      } else {
        x = tolower(ch);
      }
      printf("%c", x);
    } else {
      printf("%c", ch);
    }
    k += 1;
  }
  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char ch = 'A', x = 'A';
  while (true) {

    scanf("%c", &ch);
    if (isalpha(ch)) {
      if (islower(ch)) {
        x = toupper(ch);
      } else {
        x = tolower(ch);
      }
      printf("%c", x);
    } else if (ch != '.') {
      printf("%c", ch);
    } else if (ch == '.') {
      printf("%c", '.');
      break;
    }
  }
  cout << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int sum(int n, int array[]) {

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += array[i];
  }
  return sum;
}

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

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int sum(int n, int array[]) {

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += array[i];
  }
  return sum;
}

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

#include <cctype>
#include <iostream>

#define MAX_LEN (1200)

using namespace std;

int main() {
  char *str = new char[MAX_LEN + 1];

  cin.getline(str, MAX_LEN, '\\n');

  for (int i = 0; str[i] != '\\0'; i++) {
    if (str[i] >= 'A' && str[i] <= 'Z') {
      str[i] = tolower(str[i]);
    } else if (str[i] >= 'a' && str[i] <= 'z') {
      str[i] = toupper(str[i]);
    }
  }

  cout << str << endl;

  delete[] str;

  return (0);
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>

using namespace std;

int main() {
  char ch;

  while (1) {
    cin >> &ch;

    if (ch != '\\n') {
      if (ch >= 'A' && ch <= 'Z') {
        cout << tolower(ch);
      } else if (ch >= 'a' && ch <= 'z') {
        cout << toupper(ch);
      } else {
        cout << ch;
      }
    } else {
      cout << endl;
      break;
    }
  }

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

#include <cctype>
#include <cstdio>

int main() {
  char A;
  int i = 0;

  while (i < 1200) {
    scanf("%c", &A);
    char S;
    if (isalpha(A)) {
      if (islower(A))
        S = toupper(A);
      else
        S = tolower(A);
      printf("%c", S);
    } else
      printf("%c", A);
    ++i;
    if (A == '\\n')
      break;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>

int main() {
  char A;

  while (1) {
    scanf("%c", &A);
    char S;
    if (isalpha(A)) {
      if (islower(A))
        S = toupper(A);
      else
        S = tolower(A);
      printf("%c", S);
    } else
      printf("%c", A);

    if (A == '.')
      break;
  }

  printf("\\n");

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

#include <cctype>
#include <cstdio>

int main() {
  char c;

  while (1) {
    scanf("%c", &c);
    if (isalpha(c)) {
      if (islower(c))
        printf("%c", toupper(c));
      else
        printf("%c", tolower(c));
    } else
      printf("%c", c);

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

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  char c;

  while (1) {
    scanf("%c", &c);
    if (isalpha(c)) {
      if (islower(c))
        printf("%c", toupper(c));
      else
        printf("%c", tolower(c));
    } else
      printf("%c", c);

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

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

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

using namespace std;

int main(void) {
  char in[1201];
  int len, j;

  j = 0;
  while (true) {
    scanf("%c", &in[j]);
    if (in[j] == '\\n') {
      in[j + 1] = '\\0';
      break;
    }
    j++;
  }

  len = strlen(in);
  for (int i = 0; i < len; i++) {
    if (islower(in[i])) {
      in[i] = toupper(in[i]);
    } else if (isupper(in[i])) {
      in[i] = tolower(in[i]);
    }
  }

  printf("%s", in);

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main(void) {
  string in;
  int len;

  while (true) {

    cin >> in;

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

    cout << " ";

    len = in.length();
    for (int i = 0; i < len; i++) {
      if (islower(in[i])) {
        in[i] = toupper(in[i]);
      } else if (isupper(in[i])) {
        in[i] = tolower(in[i]);
      }
    }

    cout << in;
  }

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

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

Error: TLE

Fixed submission:

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

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

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


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  char c;
  while (1) {
    cin >> c;
    if ('a' <= c && c <= 'z') {
      cout << char(c - 32);
    } else {
      cout << char(c + 32);
    }
  }
}