Language: C++

#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

struct mi {
  int val; static const int MOD = 1e9+7; static_assert(MOD > 0, "Modulus not set!");
  mi(int v=0) : val(v) { if ((val %= MOD) < 0) val += MOD; }
  mi& operator += (const mi& b) { (val += b.val) %= MOD; return *this; }
  mi& operator -= (const mi& b) { return (*this) += MOD-b.val; }
  mi& operator *= (const mi& b) { val = ((ll)val*(ll)b.val) % MOD; return *this; }
  mi& operator /= (const mi& b) { return (*this) *= b.pow(MOD-2); }
#define _op(op, op2) mi operator op (const mi& b) const { mi ans = *this; return ans op2 b; }
  _op(+, +=); _op(-, -=); _op(*, *=); _op(/, /=);
#undef _op
  mi pow(ll e) const { mi res(1), b(*this); for (; e>0; e/=2, b*=b) { if (e&1) res*=b; } return res; }
  int toInt() const { return val; }
};

template <class T, int N>
struct matrix {
  T b[N][N];
  T& operator()(int i, int j) {
    return b[i][j];
  }
  matrix operator*(matrix& o) const {
    matrix ret;
    forx(i, N) forx(j, N) forx(k, N) ret(i, j) += b[i][k] * o(k, j);
    return ret;
  }
};

using mat = matrix<mi, 50>;

int n;
ll k;

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n >> k;
  mat m(n, n), a(n, n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int v; cin >> v;
      m(i, j) = v;
    }
  }
  for (int i = 0; i < n; ++i) a(i, i) = 1;
  while(k) {
    if (k & 1) {
      a = a * m;
    }
    m = m*m;
    k /= 2;
  }
  mi ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      ans += a(i, j);
    }
  }
  cout << ans.toInt() << nl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:13: error: no matching function for call to 'matrix<mi, 50>::matrix(int&, int&)'
   49 |   mat m(n, n), a(n, n);
      |             ^
a.cc:27:8: note: candidate: 'matrix<mi, 50>::matrix()'
   27 | struct matrix {
      |        ^~~~~~
a.cc:27:8: note:   candidate expects 0 arguments, 2 provided
a.cc:27:8: note: candidate: 'constexpr matrix<mi, 50>::matrix(const matrix<mi, 50>&)'
a.cc:27:8: note:   candidate expects 1 argument, 2 provided
a.cc:27:8: note: candidate: 'constexpr matrix<mi, 50>::matrix(matrix<mi, 50>&&)'
a.cc:27:8: note:   candidate expects 1 argument, 2 provided
a.cc:49:22: error: no matching function for call to 'matrix<mi, 50>::matrix(int&, int&)'
   49 |   mat m(n, n), a(n, n);
      |                      ^
a.cc:27:8: note: candidate: 'matrix<mi, 50>::matrix()'
   27 | struct matrix {
      |        ^~~~~~
a.cc:27:8: note:   candidate expects 0 arguments, 2 provided
a.cc:27:8: note: candidate: 'constexpr matrix<mi, 50>::matrix(const matrix<mi, 50>&)'
a.cc:27:8: note:   candidate expects 1 argument, 2 provided
a.cc:27:8: note: candidate: 'constexpr matrix<mi, 50>::matrix(matrix<mi, 50>&&)'
a.cc:27:8: note:   candidate expects 1 argument, 2 provided