Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

// ---
template<class T=LL, T P=1000003>
struct ModuloP {
    T x;
    ModuloP<T>() : x(0) {}
    ModuloP<T>(T y) { x = y%P; if(x < 0) x += P; }
    ModuloP<T> operator+(const ModuloP<T> y) { return (ModuloP<T>(x)+=y); }
    ModuloP<T> operator*(const ModuloP<T> y) { return (ModuloP<T>(x)*=y); }
    ModuloP<T> operator-(const ModuloP<T> y) { return (ModuloP<T>(x)-=y); }
    ModuloP<T> operator/(const ModuloP<T> y) { return (ModuloP<T>(x)/=y); }
    ModuloP<T> operator-() { return (x == 0) ? ModuloP<T>(P-x) : ModuloP<T>(x); }
    ModuloP<T>& operator+=(ModuloP<T> y) { x+=y.x; if(x>=P)x-=P; return *this; }
    ModuloP<T>& operator*=(ModuloP<T> y) { x=(1LL*x*y.x)%P; return *this; }
    ModuloP<T>& operator-=(ModuloP<T> y) { x+=P-y.x; if(x>=P)x-=P; return *this; }
    ModuloP<T>& operator/=(ModuloP<T> y) { return ((*this)*=y.fermetinv()); }
    bool operator==(const ModuloP<T> y) { return x == y.x; }
    bool operator!=(const ModuloP<T> y) { return x != y.x; }
    bool operator<(const ModuloP<T> y) { return x < y.x; }
    bool operator<=(const ModuloP<T> y) { return x <= y.x; }
    bool operator>(const ModuloP<T> y) { return x > y.x; }
    bool operator>=(const ModuloP<T> y) { return x >= y.x; }

    ModuloP<T> pow(T n) { // O(log n)
        ModuloP<T> ans(1), t(x);
        while(n) {
            if(n & 1) ans *= t;
            t *= t; n >>= 1;
        }
        return ans;
    }

    ModuloP<T> fermetinv() { return pow(P-2); }
};
using MP = ModuloP<int>;
// ---

V<MP> fact;

int main(){
    INIT;
    int Q; cin >> Q;
    fact.resize(1000003);
    fact[1] = MP(1);
    for(int i = 2; i < 1000003; i++) {
        fact[i] = fact[i-1] * MP(i);
    }

    REP(i,Q) {
        int x, d, n;
        cin >> x >> d >> n;
        if(d == 0) { cout << MP(x).pow(n).x << "\n"; continue; }
        MP m = MP(x)/MP(d);
        if(1000003 <= m.x+n-1) { cout << "Hello" << 0 << "\n"; continue; }
        MP ans = fact[m.x+n-1] * fact[m.x-1].fermetinv();
        MP dn(d);
        ans *= dn.pow(n);
        cout << ans.x << "\n";
    }
}


Compiler output:
a.cc:38:16: error: expected unqualified-id before ')' token
   38 |     ModuloP<T>() : x(0) {}
      |                ^
a.cc:39:17: error: expected ')' before 'y'
   39 |     ModuloP<T>(T y) { x = y%P; if(x < 0) x += P; }
      |               ~ ^~
      |                 )
a.cc: In function 'int main()':
a.cc:76:19: error: no matching function for call to 'ModuloP<int>::ModuloP(int)'
   76 |     fact[1] = MP(1);
      |                   ^
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'
a.cc:78:35: error: no matching function for call to 'ModuloP<int>::ModuloP(int&)'
   78 |         fact[i] = fact[i-1] * MP(i);
      |                                   ^
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'
a.cc:84:34: error: no matching function for call to 'ModuloP<int>::ModuloP(int&)'
   84 |         if(d == 0) { cout << MP(x).pow(n).x << "\n"; continue; }
      |                                  ^
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'
a.cc:85:20: error: no matching function for call to 'ModuloP<int>::ModuloP(int&)'
   85 |         MP m = MP(x)/MP(d);
      |                    ^
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'
a.cc:85:26: error: no matching function for call to 'ModuloP<int>::ModuloP(int&)'
   85 |         MP m = MP(x)/MP(d);
      |                          ^
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'
a.cc:88:16: error: no matching function for call to 'ModuloP<int>::ModuloP(int&)'
   88 |         MP dn(d);
      |                ^
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'
a.cc: In instantiation of 'ModuloP<T> ModuloP<T, P>::operator*(ModuloP<T>) [with T = int; T P = 1000003]':
a.cc:87:56:   required from here
   87 |         MP ans = fact[m.x+n-1] * fact[m.x-1].fermetinv();
      |                                                        ^
a.cc:41:56: error: no matching function for call to 'ModuloP<int>::ModuloP(int&)'
   41 |     ModuloP<T> operator*(const ModuloP<T> y) { return (ModuloP<T>(x)*=y); }
      |                                                        ^~~~~~~~~~~~~
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'
a.cc: In instantiation of 'ModuloP<T> ModuloP<T, P>::pow(T) [with T = int; T P = 1000003]':
a.cc:89:22:   required from here
   89 |         ans *= dn.pow(n);
      |                ~~~~~~^~~
a.cc:57:20: error: no matching function for call to 'ModuloP<int>::ModuloP(int)'
   57 |         ModuloP<T> ans(1), t(x);
      |                    ^~~
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'
a.cc:57:28: error: no matching function for call to 'ModuloP<int>::ModuloP(int&)'
   57 |         ModuloP<T> ans(1), t(x);
      |                            ^
a.cc:36:8: note: candidate: 'ModuloP<int>::ModuloP()'
   36 | struct ModuloP {
      |        ^~~~~~~
a.cc:36:8: note:   candidate expects 0 arguments, 1 provided
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(const ModuloP<int>&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'const ModuloP<int>&'
a.cc:36:8: note: candidate: 'constexpr ModuloP<int>::ModuloP(ModuloP<int>&&)'
a.cc:36:8: note:   no known conversion for argument 1 from 'int' to 'ModuloP<int>&&'