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


Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>
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);
  }
}
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 (isalpha(ch)) {
      if (islower(ch))
        cout << (char)toupper(ch);
      else if (isupper(ch))
        cout << (char)tolower(ch);
    } else {
      cout << ch;
    }
    if (ch == '\\n')
      break;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

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

int main() {
  int count = 0;
  string ch;
  getline(cin, ch);
  while (count < ch.size()) {
    if (ch[count] == ' ') {
      cout << ' ';
    } else if (islower(ch[count])) {
      ch[count] = toupper(ch[count]);
      cout << ch[count];
    } else if (isupper(ch[count])) {
      ch[count] = tolower(ch[count]);
      cout << ch[count];
    } else
      cout << ch[count];
    count++;
  }
  cout << endl;
  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);
    if (ch == '\\n')
      break;
    cout << ch;
  }

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

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char c;
  while (1) {
    scanf("%c", &c);
    if (isalpha(c)) {
      if ("%c", isupper(c))
        printf("%c", tolower(c));
      else if ("%c", islower(c))
        printf("%c", toupper(c));
    } else
      printf("%c", c);

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


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  char c;

  while (1) {
    cin >> c;
    if ('a' <= c && c <= 'z') {
      c = c - 'a' + 'A';
    } else if ('A' <= c && c <= 'Z') {
      c = c - 'A' + 'a';
    }

    cout << c;
    if (c == '\\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;
  ch = getchar();
  while (ch != EOF) {
    if (islower(ch))
      ch = toupper(ch);
    else
      ch = tolower(ch);
    cout << ch;
    ch = getchar();
  }
  return 0;
}

Error: TLE

Fixed submission:


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

int main() {
  char a;
  cin >> a;
  while (a != EOF) {
    if ('a' <= a && a <= 'z') {
      a = toupper(a);
      //	cout<<a;
    } else if ('A' <= a && a <= 'Z') {
      a = tolower(a);
      //	cout<<a;
    }
    ////else
    ////{
    //		if (a != ',' && a != '.')
    //			cout<<" ";
    //		else
    //			cout<<a;
    //}
    cout << a;
    cin >> a;
  }
  cout << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {

  char s;

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

  return 0;
}

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


Fixed submission:

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

int main() {
  char s[] = "Hello467";
  for (int i = 0; i < 1200; i++) {
    // s[i] = toupper(s[i]);
    if (islower(s[i]) != 0) {
      s[i] = toupper(s[i]);
    } else if (isupper(s[i]) != 0) {
      s[i] = tolower(s[i]);
    }
    cout << s[i];
  }

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

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  // a-z 97-122
  // A-Z 65-90
  // a-A 32

  char ch;
  scanf("%c", &ch);
  while (ch != '\\n') {
    if (ch >= 97 && ch <= 122) {
      ch = (char)(ch - 32);
    } else if (ch >= 65 && ch <= 90) {
      ch = (char)(ch + 32);
    }
    printf("%c", ch);
    scanf("%c", &ch);
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  // a-z 97-122
  // A-Z 65-90
  // a-A 32

  char ch;
  cin >> ch;
  while (ch != '\\n') {
    if (ch >= 97 && ch <= 122) {
      ch = (char)(ch - 32);
    } else if (ch >= 65 && ch <= 90) {
      ch = (char)(ch + 32);
    }
    cout << ch;
    cin >> ch;
  }

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

  while (1) {
    scanf("%c", &s);
    if (isalpha(s)) {
      if (islower(s))
        printf("%c", toupper(s));
      else
        printf("%c", tolower(s));
    } else
      printf("%c", s);
    if (s == '\\0')
      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 (true) {
    scanf("%c", &ch);
    if (isupper(ch))
      ch = tolower(ch);
    else
      ch = toupper(ch);
    cout << ch;
    if (ch == '\\n')
      break;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>
using namespace std;
int main() {
  char ch;
  while (true) {
    cin >> ch;
    if (islower(ch))
      ch = toupper(ch);
    else
      ch = tolower(ch);
    cout << ch;
    if (ch == '\\n')
      break;
  }
  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))
        ch = toupper(ch);
      else
        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;

  for (int i = 0; 1; i++) {
    cin >> ch;
    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 <cctype>
#include <cstdio>
#include <iostream>
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>
#include <iostream>
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: Time Limit Exceeded

#include <cstdio>
int main(void) {
  char str[2048];
  int i = 0;
  do {
    scanf("%c", &str[i]);
  } while (str[i++] != '\\n');
  str[i - 1] = 0;
  i = -1;
  while (str[++i] != 0) {
    str[i] ^= (((0x61 <= str[i]) && (str[i] <= 0x7a)) ||
               ((0x41 <= str[i]) && (str[i] <= 0x5a)))
                  ? 0x20
                  : 0;
  }
  printf("%s\\n", str);
  return (0);
}


Error: TLE

Fixed submission:

#include <cstdio>
int main(void) {
  char str[2048];
  int i = 0;
  scanf("%s", str);
  while (str[i] != 0) {
    str[i] ^= (((0x61 <= str[i]) && (str[i] <= 0x7a)) ||
               ((0x41 <= str[i]) && (str[i] <= 0x5a)))
                  ? 0x20
                  : 0;
  }
  printf("%s", str);
  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>
#include <iostream>
using namespace std;

int main() {
  // ?????°??£?¨?
  char ch = ' ';

  while (1) {
    // ????????\\???
    cin >> ch;

    // ????????????????????????
    if (0 != isalpha(ch)) {   // ???????????´???
      if (0 != islower(ch)) { // ?°????????????´???
        // ?°????????????§???????????????
        ch = toupper(ch);
        // ???????????????
        cout << ch;
      } else if (0 != isupper(ch)) { // ??§???????????´???
        // ??§??????????°????????????????
        ch = tolower(ch);
        // ???????????????
        cout << ch;
      }
    } else { // ????????\\????????´???
      // ???????????????
      cout << ch;
    }

    // ???????????´?????\\?????????
    if (ch == '\\n') {
      break;
    }
  }
  // ??????
  cout << endl;
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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


Error: TLE

Fixed submission:

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

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

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

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  char a;
  while (1) {
    scanf("%c", &a);
    if (a == EOF) {
      break;
    } else if (islower(a)) {
      printf("%c", toupper(a));
    } else if (isupper(a)) {
      printf("%c", tolower(a));
    }
  }

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

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

int main() {
  char a;
  while (1) {

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


Error: TLE

Fixed submission:

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

int main() {
  char a;
  while (1) {
    cin >> a;
    if (a == '\\n')
      break;
    if (islower(a)) {
      cout << toupper(a);
    } else if (isupper(a)) {
      cout << tolower(a);
    } else {
      cout << a;
    }
  }
}
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 <cstdio>
#include <iostream>

using namespace std;

int main() {

  char c;

  while (1) {

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

    cout << c;
  }
  cout << endl;

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

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

using namespace std;

int main() {

  string data;

  getline(cin, data);

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

    if (islower(data[i])) {
      cout << (char)toupper(data[i]);
    } else if (isupper(data[i])) {
      cout << (char)tolower(data[i]);
    } else {
      cout << data[i];
    }
  }
  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {

  char data;
  for (;;) {

    cin >> data;
    if (data == '\\n')
      break;

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

    if (data == ',')
      cout << " ";
  }
  cout << endl;

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

#include <iostream>

using namespace std;

int main() {
  char letter;
  while (cin >> noskipws >> letter) {
    if (islower(letter)) {
      letter = toupper(letter);
    } else {
      letter = tolower(letter);
    }
    cout << letter;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  char letter;
  cin >> letter;
  while (letter != '.') {
    if (islower(letter)) {
      letter = toupper(letter);
    } else {
      letter = tolower(letter);
    }
    cout << letter;
  }

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

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

Error: TLE

Fixed submission:

#include <ctype.h>
#include <stdio.h>
int main() {
  char a[1200];
  int i;
  while (1) {
    scanf("%c", &a[i]);
    if (isupper(a[i])) {
      printf("%c", tolower(a[i]));
    } else if (islower(a[i])) {
      printf("%c", toupper(a[i]));
    } else {
      printf("%c", a[i]);
    }
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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


Error: TLE

Fixed submission:

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

int main() {
  while (true) {
    char ch;
    cin >> ch;
    if (ch == '\\n') {
      break;
    }
    if (isupper(ch)) {
      ch = tolower(ch);
    } else if (islower(ch)) {
      ch = toupper(ch);
    }
    cout << ch << flush;
  }
  printf("\\n");
  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 <iostream>
#include <string>

using namespace std;

string toupper(string s) {
  string t = s;
  for (int i = 0; i < s.size(); i++) {
    t[i] = toupper(s[i]);
  }
  return t;
}

int main() {
  string target, source;

  cin >> target;
  target = toupper(target);

  int cnt = 0;

  while (1) {
    cin >> source;
    if (source == "END_OF_TEXT")
      break;
    source = toupper(source);
    if (target == source)
      cnt++;
  }
  cout << cnt << endl;

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

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

int main() {
  int i = 0;
  char ch[1200];
  while (++i < 1200) {

    scanf("%c", &ch[i]);
    if (ch[i] == '\\n') {
      printf("%c", ch[i]);
      break;
    } else if (isalpha(ch[i])) {
      if (islower(ch[i])) {
        ch[i] = toupper(ch[i]);

      } else if (isupper(ch[i])) {
        ch[i] = tolower(ch[i]);
      }
    }
    printf("%c", ch[i]);
  }

  return 0;
}


Error: TLE

Fixed submission:

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

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

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

int main() {
  string word; // string型直接代入できる
  char change[1200] = {0};

  getline(cin, word); // 空白が入ってても1行分読み込める

  for (int i = 0; i < word.length(); i++) {
    if (word[i] >= 'A' && word[i] <= 'Z')
      change[i] = word[i] + 32;
    else if (word[i] >= 'a' && word[i] <= 'z')
      change[i] = word[i] - 32;
    else
      change[i] = word[i];
    cout << change[i];
  }
  cout << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  while (1) {
    string word; // string型直接代入できる
    char change[1200] = {0};

    getline(cin, word); // 空白が入ってても1行分読み込める

    for (int i = 0; i < word.length(); i++) {
      if (word[i] >= 'A' && word[i] <= 'Z')
        change[i] = word[i] + 32;
      if (word[i] >= 'a' && word[i] <= 'z')
        change[i] = word[i] - 32;
      else
        change[i] = word[i];
      cout << change[i];
    }
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

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

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

int main() {
  string s;
  getline(cin, s);
  int l = s.length();
  for (int i = 0; i < l; 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 <iostream>
using namespace std;

int main() {
  while (1) {
    char c;
    cin >> c;
    if (c == '\\n') {
      cout << c;
      break;
    }
    if (islower(c))
      cout << toupper(c);
    else if (isupper(c))
      cout << tolower(c);
    else
      cout << c;
  }
  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 (isupper(ch)) {

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

      else if (islower(ch)) {

        printf("%c", toupper(ch));
      }
    } else
      cout << ch;

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

Error: TLE

Fixed submission:

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

int main() {

  char ch;

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

      if (isupper(ch)) {

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

      if (islower(ch)) {

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

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

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

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

int main() {
  string a;
  getline(cin, a);
  for (int i = 0; i < 1200; i++) {
    if (a[i] == '\\0')
      break;
    if (a[i] >= 'a' && a[i] <= 'z') {
      a[i] -= 0x20;
    } else if (a[i] >= 'A' && a[i] <= 'Z') {
      a[i] += 0x20;
    }
    if (a[i] == ' ') {
      cout << " ";
    } else {
      cout << a[i];
    }
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

//
// Created by ?????°?????? on 2016/02/08.
//

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

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

int main() {
  char sent[1200];
  int x;
  gets(sent);
  for (x = 0; sent[x] != '\\0'; x++) {
    if (isupper(sent[x])) {
      sent[x] = tolower(sent[x]);
    } else {
      sent[x] = toupper(sent[x]);
    }
  }
  puts(sent);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <wctype.h>

int main() {
  char sent;
  while (1) {
    scanf("%c", &sent);
    if (iswupper(sent) == 1)
      printf("%c", towlower(sent));
    else
      printf("%c", towupper(sent));
  }
  return 0;
}
Problem p02415 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  char s;
  while ((s = getchar()) != '\\n' && s != EOF) {
    if (isspace(s)) {
      printf(" ");
    } else if (isupper(s)) {
      s = tolower(s);
      printf("%c", s);
    } else if (islower(s)) {
      s = toupper(s);
      printf("%c", s);
    } else {
      printf("%c", s);
    }
  }
  putchar('\\n');
  return 0;
}


Error: TLE

Fixed submission:

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

int main(void) {
  while (char s = getchar()) {
    if (s == '\\0') {
      break;
    } else if (isspace(s)) {
      printf(" ");
    } else if (s == '.') {
      printf("%c", s);
    } else if (isupper(s)) {
      s = tolower(s);
      printf("%c", s);
    } else {
      s = toupper(s);
      printf("%c", s);
    }
  }
  return 0;
}