Language: C++

#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
class Matrix {
	typedef long double ld;
public:
	int h, w, size = 100;
	//縦、横、行列配列のサイズ（size*size)
	int dat[100][100];
	Matrix(int h, int w) :h(h), w(w) {}
	Matrix() :h(0), w(0) {}
	Matrix& operator=(const Matrix& mat) {
		for (int i = 0; i < mat.h; i++) {
			for (int j = 0; j < mat.w; j++) {
				this->dat[i][j] = mat.dat[i][j];
			}
		}
		return (*this);
	}
	ll* operator[](int x) {
		if (x>=h) {
			cerr << "Matrix []: not match matrix size" << endl;
		}
		return dat[x];
	}
	Matrix operator+() { return *this; }
	Matrix operator-() {
		Matrix control(h, w);
		for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { control[i][j] = -dat[i][j]; } }
		return control;
	}
	Matrix& operator+=(const Matrix &mat) {
		if (h != mat.h || w != mat.w) {
			cerr << "Matrix +: not match height and width" << endl;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				dat[i][j] += mat.dat[i][j];
			}
		}
		return (*this);
	}
	Matrix& operator-=(const Matrix& mat) {
		if (h != mat.h || w != mat.w) {
			cerr << "Matrix -: not match height and width" << endl;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				dat[i][j] -= mat.dat[i][j];
			}
		}
		return (*this);
	}
	Matrix& operator*=(const ld& x) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				dat[i][j] *= x;
			}
		}
		return (*this);
	}
	Matrix& operator/=(const ld& x) {
		if (x == 0) {
			cerr << "Matrix /: can't divide by zero" << endl;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				dat[i][j] /= x;
			}
		}
		return (*this);
	}
	Matrix& operator%=(const long long x) {
		//実数を整数に切り捨てて余りを取る
		if (x == 0) {
			cerr << "Matrix %: can't divide by zero" << endl;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				dat[i][j] = ((long long)dat[i][j]) % x;
			}
		}
		return (*this);
	}
	void identity() {
		//h*hの単位行列に加工する。
		h = h, w = h;
		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size; j++) {
				dat[i][j] = 0;
			}
			(*this).dat[i][i] = 1;
		}
		return;
	}
	void initialize() {
		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size; j++) {
				dat[i][j] = 0;
			}
		}
	}
	bool operator==(Matrix mat) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (dat[i][j] != mat.dat[i][j]) {
					return false;
				}
			}
		}
		return true;
	}
	bool operator!=(Matrix mat) {
		return !((*this) == mat);
	}
};
inline Matrix operator+(const Matrix& a, const Matrix& b) {
	Matrix c = a;
	return c += b;
}
inline Matrix operator-(const Matrix& a, const Matrix& b) {
	Matrix c = a;
	return c -= b;
}
inline Matrix operator*(const Matrix& a, const long double& b) {
	Matrix c = a;
	return c *= b;
}
inline Matrix operator*(const long double& b, const Matrix& a) {
	Matrix c = a;
	return c *= b;
}
inline Matrix operator/(const Matrix& a, const long double& b) {
	Matrix c = a;
	return c /= b;
}
inline Matrix operator/(const long double& b, const Matrix& a) {
	return a / b;
}
inline Matrix operator%(const Matrix& a, const long long& b) {
	Matrix c = a;
	c %= b;
	return c;
}
inline Matrix operator%(const long long& b, const Matrix& a) {
	return a % b;
}
inline Matrix operator*(const Matrix& a, const Matrix &b) {
	Matrix c(a.h, b.w);
	c.initialize();
	for (int i = 0; i < a.h; i++) {
		for (int j = 0; j < a.w; j++) {
			for (int z = 0; z < b.w; z++) {
				c[i][z] += a.dat[i][j] * b.dat[j][z];
				c[i][z] = long long(c[i][z]) % Mod;
			}
		}
	}
	return c;
}
Matrix mod_pow(const Matrix& matrix, unsigned long long n, long long Mod) {
	Matrix mat = matrix, cont(mat.h, mat.w);
	cont.identity();
	while (n > 0) {
		if (n & 1) {
			cont = cont * mat;
			cont %= Mod;
		}
		n >>= 1;
		mat = mat * mat;
		mat %= Mod;
	}
	return cont;
}
signed main() {
	long long h;
	unsigned long long k;
	cin >> h >> k;
	Matrix mat(h, h);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < h; j++) {
			cin >> mat[i][j];
			mat[i][j] = (long long)mat[i][j] % Mod;
		}
	}
	mat = mod_pow(mat, k, Mod);
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < h; j++) {
			ans += mat[i][j];
			ans %= Mod;
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'Matrix operator*(const Matrix&, const Matrix&)':
a.cc:267:43: error: expected primary-expression before 'long'
  267 |                                 c[i][z] = long long(c[i][z]) % Mod;
      |                                           ^~~~