Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using dd = double;
using vdd = std::vector<dd>;
using vvdd = std::vector<vdd>;
using vvvdd = std::vector<vvdd>;

constexpr ll INF = 1LL << 60;
constexpr dd EPS = 1e-11;

typedef std::numeric_limits< double > dbl;

//cin,cout高速化のおまじない＋桁数指定
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;

#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define REP(i, N) REPS(i, 0, N-1)
#define DEPS(i, E, S) for (ll i = (E); i >= (S); i--)
#define DEP(i, N) DEPS(i, N-1, 0)
#define EACH(e, v) for (auto&& e : v)

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T> &v, ll S, ll E){ T m=v[S]; REPS(i, S, E)chmax(m, v[i]); return m; }//v[S]～v[E]の最大値
template<class T> inline T MinE(vector<T> &v, ll S, ll E){ T m=v[S]; REPS(i, S, E)chmin(m, v[i]); return m; }//v[S]～v[E]の最小値
template<class T> inline T MaxE(vector<T> &v, ll N) { return MaxE(v, 0, N - 1); } //先頭N個中の最大値
template<class T> inline T MinE(vector<T> &v, ll N) { return MinE(v, 0, N - 1); }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v, (ll)v.size()); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v, (ll)v.size()); }
template<class T> inline ll MaxI(vector<T> &v, ll S, ll E){ ll m=S; REPS(i, S, E){ if (v[i]>v[m])m=i; }return m; }
template<class T> inline ll MinI(vector<T> &v, ll S, ll E){ ll m=S; REPS(i, S, E){ if (v[i]<v[m])m=i; }return m; }
template<class T> inline ll MaxI(vector<T> &v, ll N) { return MaxI(v, 0, N - 1); }
template<class T> inline ll MinI(vector<T> &v, ll N) { return MinI(v, 0, N - 1); }
template<class T> inline ll MaxI(vector<T> &v) { return MaxI(v, (ll)v.size()); }
template<class T> inline ll MinI(vector<T> &v) { return MinI(v, (ll)v.size()); }
template<class T> inline T Sum(vector<T> &v, ll S, ll E){ T s=v[S]; REPS(i, S+1, E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v, ll N) { return Sum(v, 0, N - 1); }
template<class T> inline T Sum(vector<T> &v) { return Sum(v, v.size()); }

//剰余計算用クラス
constexpr ll MOD = (ll)(1e9 + 7); // 998244353L;
template<int mod> struct Modll{
	ll val;
	Modll(ll v = 0): val(v % mod){
		if (val < 0) val += mod;
	}
	Modll operator - () { return -val; }
	Modll operator + (Modll &b) { return val + b.val; }
	Modll operator - (Modll &b) {return val - b.val;}
	Modll operator * (Modll &b) {return val * b.val;}
	Modll operator + (ll b) { return *this + Modll(b); }
	Modll operator - (ll b) { return *this - Modll(b); }
	Modll operator * (ll b) { return *this * Modll(b); }
	friend Modll<mod> operator + (ll a, Modll<mod> &b) { return b + a; }
	friend Modll<mod> operator - (ll a, Modll<mod> &b) { return -b + a; }
	friend Modll<mod> operator * (ll a, Modll<mod> &b) { return b * a; }
	Modll &operator += (Modll &b) { val=(val+b.val)%mod; return *this; }
	Modll &operator -= (Modll &b) { val=(val+mod-b.val)%mod; return *this; }
	Modll &operator *= (Modll &b) { val=(val*b.val)%mod; return *this; }
	Modll &operator += (ll b) { return *this += Modll(b); }
	Modll &operator -= (ll b) { return *this -= Modll(b); }
	Modll &operator *= (ll b) { return *this *= Modll(b); }
	Modll &operator /= (ll b) { return *this /= Modll(b); }

	Modll &operator /= (Modll &r) {
		ll a=r.val, b=mod, u=1, v=0;
		while (b){
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % mod;
		if (val < 0) val += mod;
		return *this;
	}

	Modll operator / (Modll &r) {
		return Modll(*this) /= r;
	}

	bool operator == (Modll &b) { return val == b.val; }
	bool operator != (Modll &b) { return val != b.val; }
	bool operator == (ll b) { return *this == Modll(b); }
	bool operator != (ll b) { return *this != Modll(b); }
	friend bool operator == (ll a, Modll<mod> &b) { return Modll<mod>(a) == b.val; }
	friend bool operator != (ll a, Modll<mod> &b) { return Modll<mod>(a) != b.val; }
	friend ostream &operator << (ostream &os, Modll<mod> &a) { return os << a.val; }
	friend istream &operator >> (istream &is, Modll<mod> &a) { return is >> a.val; }
	Modll pow(ll n){
		if (n == 0) return 1;
		auto b = pow(n / 2);
		return (n%2 == 1) ? b*b*val : b*b;
	}
};
using modll = Modll<MOD>;

template<class T> inline T SumMOD(vector<T> &v, ll S, ll E){ T s=v[S]; REPS(i, S+1, E)s=(s+v[i])%MOD; return s; }
template<class T> inline T SumMOD(vector<T> &v, ll N) { return SumMOD(v, 0, N - 1); }
template<class T> inline T SumMOD(vector<T> &v) { return SumMOD(v, v.size()); }

inline ll in() { ll x; cin >> x; return x; }
inline double inD() { double x; cin >> x; return x; }
inline string inS() { string x; cin >> x; return std::move(x); }
template<class T=ll> inline vector<T> in_v(ll N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v); }
inline void To0origin(vll &v) { EACH(e, v) e--; }

ll N, M, K;
ll NM;
vector<modll> C;
vector<modll> P;

int main()
{
	cin >> N >> M >> K;
	NM = N * M;
	C.resize(K  +1);
	P.resize(K-2+1);

	P[0] = 1;
	REPS(i, 1, K-2){
		P[i] = P[i-1] * (NM - 2 - (i-1));
	}

	modll III = N*N*(M-1)*M*(M+1)/3 + M*M*(N-1)*N*(N+1)/3;
	C[1] = 0;
	REPS(k, 2, K){
		modll I = C[k-1] * (NM - k + 1);
		modll II = (k-1)*P[k-2]*III;
		C[k] = I + II;
	}

	//K!で割る
	modll ans = C[K];
	REPS(k, 2, K){
		ans /= k;
	}

	cout << ans << '\n';
	return 0;
}


Compiler output:
a.cc: In instantiation of 'Modll<mod> Modll<mod>::operator*(ll) [with int mod = 1000000007; ll = long long int]':
a.cc:131:34:   required from here
  131 |                 P[i] = P[i-1] * (NM - 2 - (i-1));
      |                                                ^
a.cc:63:48: error: no match for 'operator*' (operand types are 'Modll<1000000007>' and 'Modll<1000000007>')
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
a.cc:60:15: note: candidate: 'Modll<mod> Modll<mod>::operator*(Modll<mod>&) [with int mod = 1000000007]' (near match)
   60 |         Modll operator * (Modll &b) {return val * b.val;}
      |               ^~~~~~~~
a.cc:60:15: note:   conversion of argument 1 would be ill-formed:
a.cc:63:50: error: cannot bind non-const lvalue reference of type 'Modll<1000000007>&' to an rvalue of type 'Modll<1000000007>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                                  ^~~~~~~~
a.cc:63:15: note: candidate: 'Modll<mod> Modll<mod>::operator*(ll) [with int mod = 1000000007; ll = long long int]'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |               ^~~~~~~~
a.cc:63:30: note:   no known conversion for argument 1 from 'Modll<1000000007>' to 'll' {aka 'long long int'}
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                           ~~~^
In file included from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
                 from a.cc:1:
/usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)'
  400 |     operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:400:5: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::complex<_Tp>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)'
  409 |     operator*(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:409:5: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::complex<_Tp>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)'
  418 |     operator*(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:418:5: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::complex<_Tp>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/valarray:605,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
  407 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const valarray<_Tp>&)'
 1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::valarray<_Tp>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
 1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::valarray<_Tp>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
 1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note:   template argument deduction/substitution failed:
a.cc:63:48: note:   'Modll<1000000007>' is not derived from 'const std::valarray<_Tp>'
   63 |         Modll operator * (ll b) { return *this * Modll(b); }
      |                                          ~~~~~~^~~~~~~~~~
a.cc:66:27: note: candidate: 'Modll<1000000007> operator*(ll, Modll<1000000007>&)'
   66 |         friend Modll<mod> operator * (ll a, Modll<mod> &b) { return b * a; }
      |                           ^~~~~~~~
a.cc:66:42: note:   no known conversion for argument 1 from 'Modll<1000000007>' to 'll' {aka 'long long int'}
   66 |         friend Modll<mod> operator * (ll a, Modll<mod> &b) { return b * a; }
      |