Language: C++


#include <bits/stdc++.h>
using namespace std;

using LL = long long;
using ULL = unsigned long long;
#define int LL
#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(auto i##0_to = (t), i = decltype(t)(f); i <= i##0_to; i++)
#define uptil(f, t, i)   for(auto i##0_to = (t), i = decltype(t)(f); i <  i##0_to; i++)
#define downto(f, t, i)  for(auto i##0_to = decltype(f)(t), i = (f); i >= i##0_to; i--)
#define downtil(f, t, i) for(auto i##0_to = decltype(f)(t), i = (f); i >  i##0_to; i--)
#define iter(v) begin(v), end(v)
#define citer(v) cbegin(v), cend(v)
#if defined(EBUG) && !defined(ONLINE_JUDGE)
  #define debug true
  #define _GLIBCXX_DEBUG
  #define _LIBCPP_DEBUG 2
  #define _LIBCPP_DEBUG2 2
  #define ln << endl
  #define dd(x) cerr << #x << " = " << (x) << ", "
  #define ddd(x) cerr << #x << " = " << (x) ln
#else
  #define debug false
  #define ln << '\n'
  #define dd(x) cerr
  #define ddd(x) cerr
#endif
#define tb << '\t'
#define sp << ' '
#define db dd
#define dbg ddd
#if __cplusplus >= 201703L
  #if debug
    #define PARABLE execution::par_unseq,
  #else
    #define PARABLE execution::seq,
  #endif
#else
  #define PARABLE /* none */
#endif
#define CS const
#define IL inline
#define RT return
#define TL template

namespace kpl {
  template<class V, class W>
  static inline void append(V& v, const W& w) { copy(PARABLE citer(w), back_inserter(v)); }

  template<class V>
  static inline auto flatten(const V& xss, unsigned reserve_size = 0) {
    vector<decltype(*begin(*begin(xss)))> ret;
    ret.reserve(reserve_size);
    for(const auto& xs : xss) append(ret, xs);
    ret.shrink_to_fit();
    return move(ret);
  }

  template<class I>
  static inline bool is_in(I x, I l, I r) { /* Of course half-open interval [l,r) is used */
    return l <= x && x < r;
  }
}

#ifndef MOD
#ifdef MOD9
#define MOD 1000000009
#elif defined MOD998244353
#define MOD 998244353
#else
#define MOD 1000000007
#endif
#endif


TL<class T> T power(T x,ULL n){T rt(1);while(n){if(n%2)rt*=x;x*=x;n/=2;}RT rt;}

IL int modulo(int a,int m){a%=m;RT a>=0?a:a+m;}
TL<ULL mod=MOD>class MInt{
  /*
    int with modulo.
    `mod` must be prime for `log`.
    `mod` must be coprime to `val` for `inv` and to `m.val` for `operator/` and `operator/=`.
  */
  /*! https://ei1333.github.io/luzhiled/snippets/other/mod-int.html */
public:
  int val;
  MInt():val(0){}
  explicit MInt(int v):val(modulo(v,mod)){}
  MInt&operator+=(CS MInt&m){val+=m.val;if(val>=mod)val-=mod;RT*this;}
  MInt&operator-=(CS MInt&m){val-=m.val;if(val<0)val+=mod;RT*this;}
  MInt&operator*=(CS MInt&m){val=val*m.val%mod;RT*this;}
  MInt&operator/=(CS MInt&m){val=val*m.inv().val%mod;RT*this;}
  MInt operator+(CS MInt&m)CS{RT MInt(*this)+=m;}
  MInt operator-(CS MInt&m)CS{RT MInt(*this)-=m;}
  MInt operator*(CS MInt&m)CS{RT MInt(*this)*=m;}
  MInt operator/(CS MInt&m)CS{RT MInt(*this)/=m;}
  MInt operator-()CS{MInt m;m.val=val?mod-val:0;RT m;}
  bool operator==(CS MInt&m)CS{RT val==m.val;}
  bool operator!=(CS MInt&m)CS{RT val!=m.val;}
  //MInt pow(int n)CS{MInt x(*this),rt(1);while(n){if(n%2)rt*=x;x*=x;n/=2;}RT rt;}
  MInt pow(int n)CS{RT power(*this,n);}
  MInt inv()CS{int a=val,b=mod,x=1,y=0,t;while(b){t=a/b;swap(b,a-=t*b);swap(y,x-=t*y);}RT(MInt)x;}
  friend ostream&operator<<(ostream&o,CS MInt<mod>&m){RT o<<m.val;}
  friend istream&operator>>(istream&i,MInt<mod>&m){int v;i>>v;m=MInt<mod>(v);RT i;}
};
using mint=MInt<>;

TL<class T> using vec = vector<T>;
TL<class T> using vvec = vec<vec<T>>;
using VI = vec<int>; using WI = vvec<int>;
using VM = vec<mint>; using WM = vvec<mint>;


void solve();

signed main() {
  if(debug) {
    cerr << "mod = " << MOD ln;
  } else {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(20);

  solve();

  return 0;
}


int N;
struct pyon{
  WM m;
  pyon(int x):m(N,VM(N)){ if(x==1)times(N,i)m[i][i]=mint(1); }
  pyon(WM x):m(x){}
  pyon& operator*=(pyon p){
    WM m0(N,VM(N)); swap(m, m0);
    times(N, k) times(N, i) times(N, j) {
      m[i][j] += m0[i][k] * p.m[k][j];
    }
    return *this;
  }
};

void solve(){
// NKN(N(A))
/* <foxy.memo-area> */
int K;cin>>N;cin>>K;WM A(N,VM(N));times(N,Ri_0){times(N,Ri_1){cin>>A[Ri_0]
[Ri_1];}}
/* </foxy.memo-area> */
  pyon b = power(pyon{A}, K);
  //times(N, i) times(N, j) cout << b.m[i][j];
  mint ans;
  times(N, i) times(N, j) ans += b.m[i][j];
  cout << ans ln;
}


Compiler output:
a.cc: In function 'void kpl::append(V&, const W&)':
a.cc:38:21: error: 'execution' has not been declared
   38 |     #define PARABLE execution::seq,
      |                     ^~~~~~~~~
a.cc:50:54: note: in expansion of macro 'PARABLE'
   50 |   static inline void append(V& v, const W& w) { copy(PARABLE citer(w), back_inserter(v)); }
      |                                                      ^~~~~~~