Problem p02417 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  char SAO;
  int count[26] = {0};
  while (cin >> SAO) {
    if (isalpha(static_cast<unsigned char>(SAO))) {
      if (SAO == 'A' || SAO == 'a') {
        count[0]++;
      }
      if (SAO == 'B' || SAO == 'b') {
        count[1]++;
      }
      if (SAO == 'C' || SAO == 'c') {
        count[2]++;
      }
      if (SAO == 'D' || SAO == 'd') {
        count[3]++;
      }
      if (SAO == 'E' || SAO == 'e') {
        count[4]++;
      }
      if (SAO == 'F' || SAO == 'f') {
        count[5]++;
      }
      if (SAO == 'G' || SAO == 'g') {
        count[6]++;
      }
      if (SAO == 'H' || SAO == 'h') {
        count[7]++;
      }
      if (SAO == 'I' || SAO == 'i') {
        count[8]++;
      }
      if (SAO == 'J' || SAO == 'j') {
        count[9]++;
      }
      if (SAO == 'K' || SAO == 'k') {
        count[10]++;
      }
      if (SAO == 'L' || SAO == 'l') {
        count[11]++;
      }
      if (SAO == 'M' || SAO == 'm') {
        count[12]++;
      }
      if (SAO == 'N' || SAO == 'n') {
        count[13]++;
      }
      if (SAO == 'O' || SAO == 'o') {
        count[14]++;
      }
      if (SAO == 'P' || SAO == 'p') {
        count[15]++;
      }
      if (SAO == 'Q' || SAO == 'q') {
        count[16]++;
      }
      if (SAO == 'R' || SAO == 'r') {
        count[17]++;
      }
      if (SAO == 'S' || SAO == 's') {
        count[18]++;
      }
      if (SAO == 'T' || SAO == 't') {
        count[19]++;
      }
      if (SAO == 'U' || SAO == 'u') {
        count[20]++;
      }
      if (SAO == 'V' || SAO == 'v') {
        count[21]++;
      }
      if (SAO == 'W' || SAO == 'w') {
        count[22]++;
      }
      if (SAO == 'X' || SAO == 'x') {
        count[23]++;
      }
      if (SAO == 'Y' || SAO == 'y') {
        count[24]++;
      }
      if (SAO == 'Z' || SAO == 'z') {
        count[25]++;
      }
    }
  }
  cout << "a : " << count[0] << endl;
  cout << "b : " << count[1] << endl;
  cout << "c : " << count[2] << endl;
  cout << "d : " << count[3] << endl;
  cout << "e : " << count[4] << endl;
  cout << "f : " << count[5] << endl;
  cout << "g : " << count[6] << endl;
  cout << "h : " << count[7] << endl;
  cout << "i : " << count[8] << endl;
  cout << "j : " << count[9] << endl;
  cout << "k : " << count[10] << endl;
  cout << "l : " << count[11] << endl;
  cout << "m : " << count[12] << endl;
  cout << "n : " << count[13] << endl;
  cout << "o : " << count[14] << endl;
  cout << "p : " << count[15] << endl;
  cout << "q : " << count[16] << endl;
  cout << "r : " << count[17] << endl;
  cout << "s : " << count[18] << endl;
  cout << "t : " << count[19] << endl;
  cout << "u : " << count[20] << endl;
  cout << "v : " << count[21] << endl;
  cout << "w : " << count[22] << endl;
  cout << "x : " << count[23] << endl;
  cout << "y : " << count[24] << endl;
  cout << "z : " << count[25] << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  char SAO;
  int count[26] = {0};
  while (true) {
    cin >> SAO;
    if (SAO == '.')
      break;
    if (SAO == 'A' || SAO == 'a') {
      count[0]++;
    }
    if (SAO == 'B' || SAO == 'b') {
      count[1]++;
    }
    if (SAO == 'C' || SAO == 'c') {
      count[2]++;
    }
    if (SAO == 'D' || SAO == 'd') {
      count[3]++;
    }
    if (SAO == 'E' || SAO == 'e') {
      count[4]++;
    }
    if (SAO == 'F' || SAO == 'f') {
      count[5]++;
    }
    if (SAO == 'G' || SAO == 'g') {
      count[6]++;
    }
    if (SAO == 'H' || SAO == 'h') {
      count[7]++;
    }
    if (SAO == 'I' || SAO == 'i') {
      count[8]++;
    }
    if (SAO == 'J' || SAO == 'j') {
      count[9]++;
    }
    if (SAO == 'K' || SAO == 'k') {
      count[10]++;
    }
    if (SAO == 'L' || SAO == 'l') {
      count[11]++;
    }
    if (SAO == 'M' || SAO == 'm') {
      count[12]++;
    }
    if (SAO == 'N' || SAO == 'n') {
      count[13]++;
    }
    if (SAO == 'O' || SAO == 'o') {
      count[14]++;
    }
    if (SAO == 'P' || SAO == 'p') {
      count[15]++;
    }
    if (SAO == 'Q' || SAO == 'q') {
      count[16]++;
    }
    if (SAO == 'R' || SAO == 'r') {
      count[17]++;
    }
    if (SAO == 'S' || SAO == 's') {
      count[18]++;
    }
    if (SAO == 'T' || SAO == 't') {
      count[19]++;
    }
    if (SAO == 'U' || SAO == 'u') {
      count[20]++;
    }
    if (SAO == 'V' || SAO == 'v') {
      count[21]++;
    }
    if (SAO == 'W' || SAO == 'w') {
      count[22]++;
    }
    if (SAO == 'X' || SAO == 'x') {
      count[23]++;
    }
    if (SAO == 'Y' || SAO == 'y') {
      count[24]++;
    }
    if (SAO == 'Z' || SAO == 'z') {
      count[25]++;
    }
  }
  cout << "a : " << count[0] << endl;
  cout << "b : " << count[1] << endl;
  cout << "c : " << count[2] << endl;
  cout << "d : " << count[3] << endl;
  cout << "e : " << count[4] << endl;
  cout << "f : " << count[5] << endl;
  cout << "g : " << count[6] << endl;
  cout << "h : " << count[7] << endl;
  cout << "i : " << count[8] << endl;
  cout << "j : " << count[9] << endl;
  cout << "k : " << count[10] << endl;
  cout << "l : " << count[11] << endl;
  cout << "m : " << count[12] << endl;
  cout << "n : " << count[13] << endl;
  cout << "o : " << count[14] << endl;
  cout << "p : " << count[15] << endl;
  cout << "q : " << count[16] << endl;
  cout << "r : " << count[17] << endl;
  cout << "s : " << count[18] << endl;
  cout << "t : " << count[19] << endl;
  cout << "u : " << count[20] << endl;
  cout << "v : " << count[21] << endl;
  cout << "w : " << count[22] << endl;
  cout << "x : " << count[23] << endl;
  cout << "y : " << count[24] << endl;
  cout << "z : " << count[25] << endl;
}