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

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, j, k) for (int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for (int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
  string s;
  while (getline(cin, s)) {
    rep(i, 26) {
      rep(j, s.size()) {
        if ('a' <= s[j] && s[j] < 'z')
          s[j] = s[j] + 1;
        else if (s[j] == 'z')
          s[j] = 'a';
      }
      if (s.find("the") != string::npos || s.find("this") != string::npos ||
          s.find("that") != string::npos) {
        cout << s << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, j, k) for (int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for (int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
  string s;
  bool flag = false;
  int key = 1;
  while (getline(cin, s)) {
    while (s != "the" && s != "that" && s != "this") {
      rep(i, s.size()) {
        if (97 <= s[i] && s[i] <= 122) {
          int number = (s[i] - 'a' + key) % 26;
          s[i] = 'a' + number;
        }
      }
    }
    cout << s << endl;
  }
  return 0;
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
  string s;
  while (getline(cin, s)) {

    while (s.find("that") == string::npos && s.find("the") == string::npos &&
           s.find("this") == string::npos) {
      for (int i = 0; i < s.length(); ++i) {
        if (s[i] < 'z' && s[i] >= 'a')
          s[i]++;
        else if (s[i] == 'z')
          s[i] = 'a';
      }
    }
    cout << s << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
  string s;
  while (getline(cin, s)) {
    while (s.find("that") == string::npos && s.find("the") == string::npos &&
           s.find("this") == string::npos) {
      for (int i = 0; i < s.length(); ++i) {
        if (s[i] < 'z' && s[i] >= 'a')
          s[i]++;
        if (s[i] == 'z')
          s[i] = 'a';
      }
    }
    cout << s << endl;
  }
  return 0;
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;

char c[85];

bool search_th() {
  bool f = false;
  for (int i = 0; i < strlen(c); i++) {
    if ((c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'e') ||
        (c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'i' &&
         c[i + 3] == 's') ||
        (c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'a' &&
         c[i + 3] == 't')) {
      f = true;
      break;
    }
  }
  return f;
}

int main() {
  while (cin.getline(c, sizeof(c))) {
    while (1) {
      if (search_th() == true) {
        cout << c << endl;
        break;
      }
      for (int j = 0; j < strlen(c); j++) {
        if (c[j] >= 'a' && c[j] <= 'y') {
          c[j]++;
        } else if (c[j] == 'z') {
          c[j] = 'a';
        }
      }
    }
    for (int i = strlen(c); i < 85; i++) {
      c[i] = '\\0';
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;

char c[85];

bool search_th() {
  bool f = false;
  for (int i = 0; i < strlen(c); i++) {
    if ((c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'e') ||
        (c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'i' &&
         c[i + 3] == 's') ||
        (c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'a' &&
         c[i + 3] == 't')) {
      f = true;
      break;
    }
  }
  return f;
}

int main() {
  while (cin.getline(c, sizeof(c))) {
    while (1) {
      if (search_th() == true) {
        cout << c << endl;
        break;
      }
      for (int j = 0; j < strlen(c); j++) {
        if (c[j] >= 'a' && c[j] <= 'y')
          c[j]++;
        if (c[j] == 'z')
          c[j] = 'a';
      }
    }
    for (int i = strlen(c); i < 85; i++) {
      c[i] = '\\0';
    }
  }
  return 0;
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

const char *table = "abcdefghijklmnopqrstuvwxyz";

inline char shift(char c, int n) { return table[(c - 'a' - n) % 26]; }

void shift(std::string &s, int n) {
  for (unsigned i = 0; i < s.size(); ++i) {
    if (s[i] != ' ' && s[i] != '.')
      s[i] = shift(s[i], n);
  }
}

int search_number(const std::string &s) {
  for (unsigned i = 0; i < s.size() - 3; ++i) {
    int n = s[i] - 't';
    if (shift(s[i + 1], n) == 'h') {
      if (shift(s[i + 2], n) == 'e' ||
          (i < s.size() - 3 && shift(s[i + 2], n) == 'i' &&
           shift(s[i + 3], n) == 's') ||
          (i < s.size() - 3 && shift(s[i + 2], n) == 'a' &&
           shift(s[i + 3], n) == 't'))
        return n;
    }
  }
  return s[s.size() - 3] - 't';
}

int main() {
  std::string s;
  while (getline(std::cin, s)) {
    shift(s, search_number(s));
    std::cout << s << std::endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

int search_number(const std::string &s) {
  const char *key = "this";
  std::string::size_type p = 0;
  while (true) {
    std::string::size_type sp = s.find(' ', p);
    if (sp == std::string::npos)
      break;
    if (sp - p == 4) {
      int n = s[p] - key[0];
      if (s[p + 1] - key[1] == n && s[p + 2] - key[2] == n &&
          s[p + 3] - key[3] == n)
        return n;
    } else
      p = sp + 1;
  }
  return s[p] - key[0];
}

int main() {
  std::string s;
  while (getline(std::cin, s)) {
    int n = search_number(s);
    for (unsigned i = 0; i < s.size(); ++i) {
      if (s[i] != ' ' && s[i] != ',' && s[i] != '.') {
        s[i] -= n;
        if (s[i] < 'a')
          s[i] += 26;
        if (s[i] > 'z')
          s[i] %= 26;
      }
    }
    std::cout << s << std::endl;
  }
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

void f(string &s) {
  for (char &c : s) {
    if ('a' <= c && c <= 'z')
      c = (c - 'a' + 25) % 26 + 'a';
  }
}

int main() {
  string s;

  while (getline(cin, s)) {
    if (s.empty())
      break;
    while (s.find("the") == string::npos && s.find("this") == string::npos &&
           s.find("that") == string::npos)
      f(s);
    cout << s << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

void f(string &s) {
  for (char &c : s) {
    if ('a' <= c && c <= 'z')
      c = (c + 25) % 26 + 'a';
  }
}

int main() {
  string s;

  while (getline(cin, s)) {
    if (s.empty())
      break;
    while (s.find("the") == string::npos && s.find("this") == string::npos &&
           s.find("that") == string::npos)
      f(s);
    cout << s << endl;
  }
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

void f(string &s) {
  for (char &c : s) {
    if ('a' <= c && c <= 'z')
      c = (c - 'a' + 25) % 26 + 'a';
  }
}

int main() {
  string s;

  while (getline(cin, s)) {
    if (s == "")
      break;
    while (s.find("the") == string::npos && s.find("this") == string::npos &&
           s.find("that") == string::npos)
      f(s);
    cout << s << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

void f(string &s) {
  for (char &c : s) {
    if ('a' <= c && c <= 'z')
      c = (c - 'a' + 25) % 26 + 'a';
  }
}

int main() {
  string s;

  while (getline(cin, s)) {
    if (s == "")
      break;
    while (s.find("the") == string::npos || s.find("this") == string::npos ||
           s.find("that") == string::npos)
      f(s);
    cout << s << endl;
  }
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

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

bool valid(string line) {
  string t[3] = {"the", "this", "that"};
  for (int i = 0; i < 3; i++) {
    if (line.find(t[i]) != string::npos)
      return true;
  }
  return false;
}

void move(string &line) {
  for (int i = 0; i < line.size(); i++) {
    if (line[i] == 'a')
      line[i] = 'z';
    else if ('b' <= line[i] && line[i] <= 'z') {
      line[i] = (char)(line[i] - 1);
    }
  }
}
int main() {
  string line;
  while (1) {
    getline(cin, line);
    if (cin.eof())
      break;
    while (1) {
      if (valid(line)) {
        cout << line << endl;
        break;
      }
      move(line);
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

void shift(string &line) {
  for (int i = 0; i < line.size(); i++) {
    if (line[i] == 'z')
      line[i] = 'a';
    else if ('a' <= line[i] && line[i] <= 'y') {
      line[i] = (line[i] - 1);
    }
  }
}
int main() {
  string line;
  while (getline(cin, line)) {
    if (cin.eof())
      break;
    while (true) {
      if (line.find("the") != string::npos ||
          line.find("this") != string::npos ||
          line.find("that") != string::npos) {
        cout << line << endl;
        break;
      }
      shift(line);
    }
  }
  return 0;
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

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

char cShiftchar(char ch) {
  if (isalpha(ch)) {
    ch++;
    if (ch > 'z')
      ch = ch - 'z' + 'a' - 1;
  }

  return ch;
}

string sDecode(string str) {
  string ans;
  while (-1 == str.find("the") && -1 == str.find("this") &&
         -1 == str.find("that")) {
    transform(str.begin(), str.end(), str.begin(), cShiftchar);
  }
  return str;
}

int main() {
  string str;
  while (getline(cin, str)) {
    cout << sDecode(str) << endl;
  }
  return EXIT_SUCCESS;
}

Error: TLE

Fixed submission:

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

char cShiftchar(char ch) {
  if (isalpha(ch)) {
    if (islower(ch)) {
      ch++;
      if (ch > 'z')
        ch = ch - 'z' + 'a' - 1;
    }
    if (isupper(ch)) {
      ch++;
      if (ch > 'Z')
        ch = ch - 'Z' + 'A' - 1;
    }
  }

  return ch;
}

string sDecode(string str) {
  string ans;
  while (str.find("the") && str.find("this") && str.find("that") &&
         str.find("THE") && str.find("THIS") && str.find("THAT")) {
    transform(str.begin(), str.end(), str.begin(), cShiftchar);
  }
  return str;
}

int main() {
  string str;
  while (getline(cin, str)) {
    cout << sDecode(str) << endl;
  }
  return EXIT_SUCCESS;
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int main() {
  string input_str;

  while (getline(cin, input_str)) {
    for (int shift = 0; shift < 26; shift++) {
      for (int str_i = 0; str_i < input_str.size(); str_i++) {
        if (input_str[str_i] >= 'a' && input_str[str_i] < 'z')
          input_str[str_i]++;
        else if (input_str[str_i] == 'z')
          input_str[str_i] = 'a';
      }
      if (input_str.find("the") != string::npos ||
          input_str.find("this") != string::npos ||
          input_str.find("that") != string::npos)
        break;
    }
    cout << input_str << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

void Shift(string *str, int shift, int vec) {
  for (int str_i = 0; str_i < str->size(); str_i++)
    if (!isspace((*str)[str_i]) && (*str)[str_i] != '.')
      (*str)[str_i] += vec * shift;
}

bool FindTarget(string str) {
  if (str.find("the") != string::npos || str.find("this") != string::npos ||
      str.find("that") != string::npos)
    return true;
  else
    return false;
}

int main() {
  string input_str;

  int shift = 1;
  while (getline(cin, input_str)) {
    while (1) {
      Shift(&input_str, shift, -1);
      if (FindTarget(input_str))
        break;
      Shift(&input_str, shift, 1);
      Shift(&input_str, shift, 1);
      if (FindTarget(input_str))
        break;
      Shift(&input_str, shift, -1);
      shift++;
    }
    cout << input_str << endl;
  }

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

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

int main() {
  string input;

  while (getline(cin, input)) {
    // getline(cin, input);
    while (1) {
      for (int i = 0; i < input.size(); i++) {
        if ('a' <= input[i] && input[i] <= 'z') {
          if (input[i] != 'z') {
            input[i] += 1;
          } else {
            input[i] = 'a';
          }
        }
      }
      if (input.find("the") != string::npos ||
          input.find("this") != string::npos ||
          input.find("that") != string::npos) {
        cout << input << endl;
        break;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

bool decision(string input) {
  for (int i = 0; i < input.size() - 3; i++) {
    if ((input[i] == 't' && input[i + 1] == 'h' && input[i + 2] == 'e') ||
        (input[i] == 't' && input[i + 1] == 'h' && input[i + 2] == 'i' &&
         input[i + 3] == 's') ||
        (input[i] == 't' && input[i + 1] == 'h' && input[i + 2] == 'a' &&
         input[i + 3] == 't')) {
      return true;
    }
  }
  return false;
}

int main() {
  string abc = "abcdefghijklmnopqrstuvwxyz";
  string input;
  getline(cin, input);

  while (1) {
    for (int i = 0; i < input.size(); i++) {
      for (int j = 0; j < abc.size(); j++) {
        if (input[i] == abc[j]) {
          if (j != 0) {
            input[i] = abc[j - 1];
          } else {
            input[i] = abc[abc.size() - 1];
          }
        }
      }
    }
    if (decision(input))
      break;
  }

  cout << input << endl;
  return 0;
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <string.h>

int main(void) {
  char data[100];
  char s1[] = "the", s2[] = "this", s3[] = "that";
  int i, cnt = 0;
  char *p;

  while ((fgets(data, 100, stdin))) {
    while (cnt < 26) {
      p = strstr(data, s1);
      if (p)
        break;
      p = strstr(data, s2);
      if (p)
        break;
      p = strstr(data, s3);
      if (p)
        break;
      for (i = 0; i < 100; i++) {
        if (data[i] == '\\0')
          break;
        if ('a' <= data[i] && data[i] <= 'y')
          data[i]++;
        else if ('z' == data[i])
          data[i] = 'a';
      }
      cnt++;
    }
    cnt = 0;
    printf("%s", data);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>

int main(void) {
  char data[100];
  char s1[] = "the", s2[] = "this", s3[] = "that";
  int i, cnt = 0;
  char *p;

  while (1) {
    fgets(data, 100, stdin);
    if (data[0] == '\\n')
      break;
    while (cnt <= 26) {
      p = strstr(data, s1);
      if (p)
        break;
      p = strstr(data, s2);
      if (p)
        break;
      p = strstr(data, s3);
      if (p)
        break;
      for (i = 0; i < 100; i++) {
        if (data[i] == '\\0')
          break;
        if ('a' <= data[i] && data[i] <= 'y')
          data[i]++;
        if ('z' == data[i])
          data[i] = 'a';
      }
      cnt++;
    }
    cnt = 0;
    printf("%s\\n", data);
  }
  return 0;
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <string.h>

int main(void) {
  int i;
  int len;
  int f;
  int n;
  char str[128];

  while (fgets(str, 100, stdin) != NULL) {
    f = 0;
    n = 0;
    while (1) {
      len = strlen(str);
      for (i = 0; i < len; i++) {
        if (strncmp(&str[i], "the", 3) == 0) {
          f = 1;
        }
        if (strncmp(&str[i], "this", 4) == 0) {
          f = 1;
        }
        if (strncmp(&str[i], "that", 4) == 0) {
          f = 1;
        }
      }
      if (f == 1) {
        break;
      }
      for (i = 0; i < len; i++) {
        if (str[i] >= 'a' && str[i] < 'z') {
          str[i]++;
        } else if (str[i] == 'z') {
          str[i] = 'a';
        }
      }
      n++;
    }
    printf("%s", str);
  }
  return (0);
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>

int main(void) {
  int i;
  int len;
  int f;
  char str[128];

  while (fgets(str, 100, stdin) != NULL) {
    f = 0;
    while (1) {
      len = strlen(str);
      for (i = 0; i < len; i++) {
        if (strncmp(&str[i], "the", 3) == 0) {
          f = 1;
        }
        if (strncmp(&str[i], "this", 4) == 0) {
          f = 1;
        }
        if (strncmp(&str[i], "that", 4) == 0) {
          f = 1;
        }
      }
      if (f == 1) {
        break;
      }
      for (i = 0; i < len; i++) {
        if (str[i] >= 'a' && str[i] < 'z') {
          str[i]++;
        }
        if (str[i] == 'z') {
          str[i] = 'a';
        }
      }
    }
    printf("%s", str);
  }
  return (0);
}
Problem p00017 (C++) — buggy submission, verdict: Runtime Error

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

bool checkString(int *key, string s);
void rotateChar(string *s, int i);

int main() {
  string text;
  while (getline(cin, text)) {
    char ch;
    string s;
    list<string> table;
    for (int i = 0; i < text.size(); i++) {
      ch = text[i];
      if (ch != ' ')
        s.push_back(ch);
      else {
        table.push_back(s), s.clear();
      }
    }

    int key; // ずらす文字数
    list<string>::iterator i;
    for (i = table.begin(); i != table.end(); i++) {
      // cout << *i << " ";
      if (i->size() == 3 || i->size() == 4)
        if (checkString(&key, *i))
          break;
    }

    for (int i = 0; i < text.size(); i++) {
      char ch = text[i];
      if (isalpha(ch)) {
        char c = ch - 'a';
        ch = 'a' + (c + key) % 26;
      }
      cout.put(ch);
    }
    cout << endl;
    text.clear();
  }
  return 0;
}

void rotateChar(string *s, int i) // iは何文字ずらしたいか
{

  for (int j = 0; j < s->size(); j++) {
    if (!isalpha(s->at(j))) {
      continue;
    }
    char c = s->at(j) - 'a';
    s->at(j) = 'a' + (c + i) % 26;
  }
}

bool checkString(int *key, string s) {

  for (int i = 0; i < 26; i++) {
    string tmp = s;
    rotateChar(&tmp, i);
    // cout << tmp << endl;
    if (tmp == "the" || tmp == "this" || tmp == "that") {
      *key = i;
      return true;
    }
  }
  return false;
}


Error: 0

Fixed submission:

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

bool checkString(int *key, string s);
void rotateChar(string *s, int i);

int main() {
  list<string> table;
  char text[80];
  int size = 0;

  for (size = 0; cin.get(text[size]); size++) {
    ;
  }

  char ch;
  string s;
  for (int i = 0; (ch = text[i]) != EOF; i++) {
    if (ch != ' ')
      s.push_back(ch);
    else {
      table.push_back(s), s.clear();
    }
  }

  int key; // ずらす文字数
  list<string>::iterator i;
  for (i = table.begin(); i != table.end(); i++) {
    // cout << *i << " ";
    if (i->size() == 3 || i->size() == 4)
      if (checkString(&key, *i))
        break;
  }

  for (int i = 0; i < size; i++) {
    char ch = text[i];
    if (isalpha(ch)) {
      char c = ch - 'a';
      ch = 'a' + (c + key) % 26;
    }
    cout.put(ch);
  }

  return 0;
}

void rotateChar(string *s, int i) // iは何文字ずらしたいか
{

  for (int j = 0; j < s->size(); j++) {
    if (!isalpha(s->at(j))) {
      continue;
    }
    char c = s->at(j) - 'a';
    s->at(j) = 'a' + (c + i) % 26;
  }
}

bool checkString(int *key, string s) {

  for (int i = 0; i < 26; i++) {
    string tmp = s;
    rotateChar(&tmp, i);
    // cout << tmp << endl;
    if (tmp == "the" || tmp == "this" || tmp == "that") {
      *key = i;
      return true;
    }
  }
  return false;
}
Problem p00017 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int main() {
  string a;

  while (getline(cin, a)) {

    while (1) {
      if (a.find("this") != -1 || a.find("the") != -1 || a.find("that") != -1) {
        break;
      }

      for (int i = 0; i < (int)a.length(); i++) {
        if (a[i] == ' ' || a[i] == '.') {

        } else if (a[i] == 'z') {
          a[i] = 'a';
        } else {
          a[i]++;
        }
      }
    }
    cout << a << endl;
    ;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  string a;

  getline(cin, a);

  while (1) {
    if (a.find("this") != -1 || a.find("this") != -1 || a.find("this") != -1) {
      break;
    }

    for (int i = 0; i < a.length(); i++) {
      if (a[i] == ' ' || a[i] == '.') {

      } else if (a[i] == 'z') {
        a[i] = 'a';
      } else {
        a[i]++;
      }
    }
  }
  cout << a << endl;
  ;

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

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

int main(void) {
  while (true) {
    string str;
    if (!getline(cin, str))
      break;
    ;
    while (true) {
      for (int i = 0; i < str.size(); i++) {
        if (isalpha(str[i]) && str[i] == 'z') {
          str[i] = 'a';
        } else if (isalpha(str[i])) {
          str[i]++;
        }
      }
      if (str.find("that") != string::npos ||
          str.find("this") != string::npos || str.find("the") != string::npos)
        break;
    }
    cout << str << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  while (true) {
    string str;
    if (!getline(cin, str))
      break;
    ;
    while (true) {
      for (int i = 0; i < str.size(); i++) {
        if (isalpha(str[i]) && str[i] == 'z') {
          str[i] = 'a';
        } else if (isalpha(str[i])) {
          str[i]++;
        }
      }
      if (str.find("that") != string::npos || str.find("the") != string::npos ||
          str.find("the") != string::npos)
        break;
    }
    cout << str << endl;
  }
  return 0;
}