Problem p00017 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string str[1000];
  int k = 0;
  int zure[1000];
  bool flag[1000] = {false};
  while (getline(cin, str[k])) {
    for (int j = 0; j < 26; j++) {
      for (int i = 0; i < str[k].size() - 2; i++) {
        if (str[k][i] == 'a' + ('t' + j - 'a') % 26 &&
            str[k][i + 1] == 'a' + ('h' + j - 'a') % 26 &&
            str[k][i + 2] == 'a' + ('e' + j - 'a') % 26) {
          zure[k] = j;
          flag[k] = true;
          break;
        }
      }
      if (flag[k] == true) {
        k++;
        break;
      }
      for (int i = 0; i < str[k].size() - 3; i++) {
        if (str[k][i] == 'a' + ('t' + j - 'a') % 26 &&
            str[k][i + 1] == 'a' + ('h' + j - 'a') % 26 &&
            str[k][i + 2] == 'a' + ('i' + j - 'a') % 26 &&
            str[k][i + 3] == 'a' + ('s' + j - 'a') % 26) {
          zure[k] = j;
          flag[k] = true;
          break;
        }
      }
      if (flag[k] == true) {
        k++;
        break;
      }
      for (int i = 0; i < str[k].size() - 3; i++) {
        if (str[k][i] == 'a' + ('t' + j - 'a') % 26 &&
            str[k][i + 1] == 'a' + ('h' + j - 'a') % 26 &&
            str[k][i + 2] == 'a' + ('a' + j - 'a') % 26 &&
            str[k][i + 3] == 'a' + ('t' + j - 'a') % 26) {
          zure[k] = j;
          flag[k] = true;
          break;
        }
      }
      if (flag[k] == true) {
        k++;
        break;
      }
    }
  }
  for (int j = 0; j < k; j++) {
    for (int i = 0; i < str[j].size(); i++) {
      if (str[j][i] >= 'a' && str[j][i] <= 'z') {
        str[j][i] = str[j][i] - zure[j];
        if (str[j][i] < 'a') {
          str[j][i] = str[j][i] + 26;
        }
      }
    }
    cout << str[j] << endl;
  }
}

Error: -11

Fixed submission:

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

int main() {
  string str[100];
  int k = 0;
  int zure[100];
  bool flag[100] = {false};
  while (getline(cin, str[k])) {
    for (int j = 0; j < 26; j++) {
      for (int i = 0; i < str[k].size() - 2; i++) {
        if (str[k][i] == 't' + j && str[k][i + 1] == 'h' + j &&
            str[k][i + 2] == 'e' + j) {
          zure[k] = j;
          flag[k] = true;
          break;
        }
      }
      if (flag[k] == true) {
        k++;
        break;
      }
      for (int i = 0; i < str[k].size() - 3; i++) {
        if (str[k][i] == 't' + j && str[k][i + 1] == 'h' + j &&
            str[k][i + 2] == 'i' + j && str[k][i + 3] == 's' + j) {
          zure[k] = j;
          flag[k] = true;
          break;
        }
      }
      if (flag[k] == true) {
        k++;
        break;
      }
      for (int i = 0; i < str[k].size() - 3; i++) {
        if (str[k][i] == 't' + j && str[k][i + 1] == 'h' + j &&
            str[k][i + 2] == 'a' + j && str[k][i + 3] == 't' + j) {
          zure[k] = j;
          flag[k] = true;
          break;
        }
      }
      if (flag[k] == true) {
        k++;
        break;
      }
      k++;
    }
  }
  for (int j = 0; j < k; j++) {
    for (int i = 0; i < str[j].size(); i++) {
      if (str[j][i] >= 'a' && str[j][i] <= 'z') {
        str[j][i] = str[j][i] - zure[j];
        if (str[j][i] < 'a') {
          str[j][i] = str[j][i] + 26;
        }
      }
    }
    cout << str[j] << endl;
  }
}