fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string s;
  7. cin >> s;
  8. int n = s.length();
  9. int l = 0, lc = 0, lct = 0;
  10. for (int i = 0; i < n; i++){
  11. if(s[i] == 'L') l++;
  12.  
  13. if(s[i] == 'C') lc += l;
  14.  
  15. if(s[i] == 'T') lct += lc;
  16. }
  17.  
  18. cout << lct;
  19. return 0;
  20. }
Success #stdin #stdout 0s 5312KB
stdin
LCCTLLCT
stdout
7