Language: C++


#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;

ll rev(ll N){
	ll ret = 0;
	while( N ){
		ret = ret*10 + N%10;
		N /= 10;
	}
	return ret;
}

int main(){
	//ios_base::sync_with_stdio(0);
	ll D, rD;

	cin >> D;
	rD = rev(D);

	int K = 0;
	while( pow(10,(double)K) < D ) K++;

	set<ll> ans;
	rep(k,K/2+2) rep(u,K/2+2) rep(i,pow(10,(double)k)){
		ll res = (i + D);
		ll n = 0;
		rep(j,u){
			n = n*10 + res%10;
			res /= 10;
		}
		n = n*pow(10,(double)k) + (i % (ll)pow(10,(double)k));
		if( rev(n) == n+D ) ans.insert(n);
	}

	cout << ans.size() << endl;

	return 0;
}


Compiler output:
a.cc:13:9: error: 'pair' does not name a type
   13 | typedef pair<int,int> pii;
      |         ^~~~
a.cc:14:9: error: 'pair' does not name a type
   14 | typedef pair<ll,ll> pll;
      |         ^~~~
a.cc:19:19: error: 'size_t' has not been declared
   19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
      |                   ^~~~~~
a.cc:19:55: error: 'N' was not declared in this scope
   19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
      |                                                       ^
a.cc:19:43: error: variable or field 'Fill' declared void
   19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
      |                                           ^~~~
a.cc:19:52: error: 'a' was not declared in this scope
   19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
      |                                                    ^
a.cc:19:55: error: 'N' was not declared in this scope
   19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
      |                                                       ^
a.cc:19:59: error: expected primary-expression before 'const'
   19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
      |                                                           ^~~~~
a.cc: In function 'int main()':
a.cc:36:9: error: 'cin' was not declared in this scope
   36 |         cin >> D;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:40:16: error: 'pow' was not declared in this scope
   40 |         while( pow(10,(double)K) < D ) K++;
      |                ^~~
a.cc:42:9: error: 'set' was not declared in this scope
   42 |         set<ll> ans;
      |         ^~~
a.cc:1:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
  +++ |+#include <set>
    1 | 
a.cc:42:15: error: expected primary-expression before '>' token
   42 |         set<ll> ans;
      |               ^
a.cc:42:17: error: 'ans' was not declared in this scope
   42 |         set<ll> ans;
      |                 ^~~
a.cc:43:41: error: 'pow' was not declared in this scope
   43 |         rep(k,K/2+2) rep(u,K/2+2) rep(i,pow(10,(double)k)){
      |                                         ^~~
a.cc:2:34: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                  ^
a.cc:54:9: error: 'cout' was not declared in this scope
   54 |         cout << ans.size() << endl;
      |         ^~~~
a.cc:54:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:54:31: error: 'endl' was not declared in this scope
   54 |         cout << ans.size() << endl;
      |                               ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 |