Problem p03222 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
inline ll powint(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1)
      r *= x;
    x *= x;
    y >>= 1;
  }
  return r;
}
inline ll powmod(ll x, ll y, ll m = MOD) {
  ll r = 1;
  while (y) {
    if (y & 1)
      r *= x;
    x *= x;
    r %= m;
    x %= m;
    y >>= 1;
  }
  return r;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// xがyに行く
vvvll dp(100, vvll(8, vll(8, 0)));
vvll dpb(8, vll(8, 0));

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll h, w, k;
  cin >> h >> w >> k;
  ll r = powint(2, w - 1);
  rep(i, r) {
    rep(j, w - 1) {
      if ((i >> j) & 1 && (i >> (j + 1)) & 1)
        goto invalid;
    }
    rep(j, w) {
      if ((i >> j) & 1)
        dpb[j][j + 1]++;
      else if (j > 0 && (i >> (j - 1)) & 1)
        dpb[j][j - 1]++;
      else
        dpb[j][j]++;
    }
  invalid:;
  }
  rep(i, 8) rep(j, 8) { dp[1][i][j] = dpb[i][j]; }
  repr(i, 2, h + 1) {
    rep(j, 8) rep(k, 8) rep(l, 8) {
      dp[i][j][k] += (dp[i - 1][j][l] * dpb[l][k]) % MOD;
      dp[i][j][k] %= MOD;
    }
  }
  cout << dp[h][0][k - 1] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
inline ll powint(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1)
      r *= x;
    x *= x;
    y >>= 1;
  }
  return r;
}
inline ll powmod(ll x, ll y, ll m = MOD) {
  ll r = 1;
  while (y) {
    if (y & 1)
      r *= x;
    x *= x;
    r %= m;
    x %= m;
    y >>= 1;
  }
  return r;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// xがyに行く
vvvll dp(101, vvll(8, vll(8, 0)));
vvll dpb(8, vll(8, 0));

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll h, w, k;
  cin >> h >> w >> k;
  ll r = powint(2, w - 1);
  rep(i, r) {
    rep(j, w - 1) {
      if ((i >> j) & 1 && (i >> (j + 1)) & 1)
        goto invalid;
    }
    rep(j, w) {
      if ((i >> j) & 1)
        dpb[j][j + 1]++;
      else if (j > 0 && (i >> (j - 1)) & 1)
        dpb[j][j - 1]++;
      else
        dpb[j][j]++;
    }
  invalid:;
  }
  rep(i, 8) rep(j, 8) { dp[1][i][j] = dpb[i][j]; }
  repr(i, 2, h + 1) {
    rep(j, 8) rep(k, 8) rep(l, 8) {
      dp[i][j][k] += (dp[i - 1][j][l] * dpb[l][k]) % MOD;
      dp[i][j][k] %= MOD;
    }
  }
  cout << dp[h][0][k - 1] << endl;
  return 0;
}