Language: C++

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007
#define rvs(i) reverse( i.begin(), i.end() )

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int m = 0; cin >> m;
	rep(i, m)
	{
		string tmp; cin >> tmp;
		vector<string> str;
		for(int j = 1; j < (int)tmp.size(); j++)
		{
			string tmp1, tmp2, tmp3, tmp4;
			tmp1 = tmp.substr(0, j);
			tmp2 = tmp.substr(j);
			tmp3 = tmp1; rvs(tmp3);
			tmp4 = tmp2; rvs(tmp4);

			str.push_back(tmp1 + tmp2);
			str.push_back(tmp1 + tmp4);
			str.push_back(tmp3 + tmp2);
			str.push_back(tmp3 + tmp4);
			str.push_back(tmp2 + tmp1);
			str.push_back(tmp2 + tmp3);
			str.push_back(tmp4 + tmp1);
			str.push_back(tmp4 + tmp3);
		}
		sort(all(str));
		str.erase(unique(all(str)), str.end());
		printf("%d\n", (int)str.size());
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'cin' was not declared in this scope
   13 |         cin.tie(0);
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define rep(i, j) for(int i = 0; i < j; i++)
a.cc:14:9: error: 'ios' has not been declared
   14 |         ios::sync_with_stdio(false);
      |         ^~~
a.cc:19:17: error: 'string' was not declared in this scope
   19 |                 string tmp; cin >> tmp;
      |                 ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | #define rep(i, j) for(int i = 0; i < j; i++)
a.cc:19:36: error: 'tmp' was not declared in this scope
   19 |                 string tmp; cin >> tmp;
      |                                    ^~~
a.cc:20:17: error: 'vector' was not declared in this scope
   20 |                 vector<string> str;
      |                 ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #define rep(i, j) for(int i = 0; i < j; i++)
a.cc:20:32: error: 'str' was not declared in this scope; did you mean 'std'?
   20 |                 vector<string> str;
      |                                ^~~
      |                                std
a.cc:23:31: error: expected ';' before 'tmp1'
   23 |                         string tmp1, tmp2, tmp3, tmp4;
      |                               ^~~~~
      |                               ;
a.cc:24:25: error: 'tmp1' was not declared in this scope
   24 |                         tmp1 = tmp.substr(0, j);
      |                         ^~~~
a.cc:25:25: error: 'tmp2' was not declared in this scope
   25 |                         tmp2 = tmp.substr(j);
      |                         ^~~~
a.cc:26:25: error: 'tmp3' was not declared in this scope
   26 |                         tmp3 = tmp1; rvs(tmp3);
      |                         ^~~~
a.cc:7:16: error: 'reverse' was not declared in this scope
    7 | #define rvs(i) reverse( i.begin(), i.end() )
      |                ^~~~~~~
a.cc:26:38: note: in expansion of macro 'rvs'
   26 |                         tmp3 = tmp1; rvs(tmp3);
      |                                      ^~~
a.cc:27:25: error: 'tmp4' was not declared in this scope
   27 |                         tmp4 = tmp2; rvs(tmp4);
      |                         ^~~~
a.cc:38:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   38 |                 sort(all(str));
      |                 ^~~~
      |                 short
a.cc:39:27: error: 'unique' was not declared in this scope
   39 |                 str.erase(unique(all(str)), str.end());
      |                           ^~~~~~
a.cc:40:17: error: 'printf' was not declared in this scope
   40 |                 printf("%d\n", (int)str.size());
      |                 ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define rep(i, j) for(int i = 0; i < j; i++)