alexjercan/bugnet huggingface dataset:
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  int ans = 0;
  rep(is, 1 << h) rep(js, 1 << w) {
    int cnt = 0;
    rep(i, h) rep(j, w) {
      if (is >> i & 1)
        continue;
      if (js >> j & 1)
        continue;
      if ('#' == s[i][j])
        ++cnt;
    }
    if (k == cnt)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  int ans = 0;
  rep(is, 1 << h) rep(js, 1 << w) {
    int cnt = 0;
    rep(i, h) rep(j, w) {
      if (is >> i & 1)
        continue;
      if (js >> j & 1)
        continue;
      if ('#' == s[is][js])
        ++cnt;
    }
    if (k == cnt)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

int nth_bit(int64_t num, int n) { return (num >> n) & 1; }

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  string S[6];
  for (int i = 0; i < H; i++)
    cin >> S[i];

  int ans = 0;
  for (int a = 0; a < (1 << H); a++)
    for (int b = 0; b < (1 << W); b++) {
      int cnt = 0;
      for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
          if (nth_bit(a, i) && nth_bit(b, j) && S[i][j] == '#')
            cnt++;
      if (cnt == K)
        ans++;
    }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

/*
 *    coder :: ATUL_PANDEY_2608
 *        >>> INDIA <<<
 */
using namespace std;

// #define  part ..
#define listi vector<int>
#define listll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define heap priority_queue<long long>
#define all(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define mod 1000000007
#define maxx 200006
#define ll long long
#define quick ios_base::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
#define rep(i, a, b) for (int i = a; i < b; i++)
long long gcd(long long a, long long b) {

  if (b == 0) {
    return a;
  }

  return gcd(b, a % b);
}

// end of #define

// define globals ...

long long ni() {
  int c = getchar();
  while (c < '0' || c > '9')
    c = getchar();
  long long ret = 0.0;
  while (c >= '0' && c <= '9') {
    ret = ret * 10 + c - '0';
    c = getchar();
  }
  return ret;
}

int Main() {

  ll n, m, k;
  cin >> n >> m >> k;
  string v[n];

  for (ll i = 0; i < n; i += 1) {

    cin >> v[i];
  }

  ll ans = 0;

  for (ll a = 0; a < (1 << n); a++) {

    for (ll b = 0; b < (1 << m); b++) {

      int cnt = 0;

      for (int i = 0; i < n; i++) {

        for (int j = 0; j < m; j++) {

          if (((a >> i) & (1)) && ((b >> j) & (1)) && v[i][j] == '#') {
            cnt++;
          }
        }
      }

      if (cnt == k) {
        ans += 1;
      }
    }
  }

  cout << ans;
}

// main function..
int main() {
  quick;

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("outt.txt", "w", stdout);
#endif

  Main();
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int ans = 0;
  rep(is, 1 << h) rep(js, 1 << w) {
    int cnt = 0;
    rep(i, h) rep(j, w) {
      if (is & (1 << i))
        continue;
      if (js & (1 << j))
        continue;
      if (s[i][j] == '#')
        cnt++;
    }
    if (cnt == k)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int h, w, k, ans = 0;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; i++)
    cin >> s[i];
  for (int i = 0; i < (1 << h); i++) {
    for (int j = 0; j < (1 << w); j++) {
      int cnt = 0;
      for (int l = 0; l < h; l++) {
        for (int m = 0; m < w; m++) {
          if (i >> l & 1)
            continue;
          if (j >> m & 1)
            continue;
          if (s[i][j] == '#')
            cnt++;
        }
        if (cnt == k)
          ans++;
      }
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<int> b(8, 1);
  for (int i = 1; i < 8; i++)
    b[i] = 2 * b[i - 1];

  int grid[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      cin >> c;
      if (c == '.')
        grid[i][j] = 0;
      else
        grid[i][j] = 1;
    }
  }

  vector<bool> ma_h(h), ma_w(w);

  int ans = 0;
  for (int i = 0; i < (1 << h); i++) {

    for (int a = 0; a < h; a++) {
      ma_h[a] = 0;
      ma_h[a] = (b[a] & i);
    }
    for (int j = 0; j < (1 << w); j++) {

      for (int a = 0; a < w; a++) {
        ma_w[a] = 0;
        ma_w[a] = (b[a] & j);
      }

      int cgrid[h][w];
      for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) {
          cgrid[x][y] = grid[x][y];

          if (ma_h[x] || ma_w[y])
            cgrid[x][y] = 2;
        }
      }
      int qtd = 0;
      for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) {
          qtd += (cgrid[x][y] == 1);
        }
      }

      ans += (qtd == k);
    }
  }

  cout << ans;

  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<int> b(8, 1);
  for (int i = 1; i < 8; i++)
    b[i] = 2 * b[i - 1];

  int grid[h][k];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      cin >> c;
      if (c == '.')
        grid[i][j] = 0;
      else
        grid[i][j] = 1;
    }
  }

  int ans = 0;
  for (int maskh = 0; maskh < (1 << h); maskh++) {
    for (int maskw = 0; maskw < (1 << w); maskw++) {
      int qtd = 0;
      for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) {

          if (((maskh >> x) & 1) == 0 && ((maskw >> y) & 1) == 0 &&
              grid[x][y] == 1)
            qtd++;
        }
      }

      ans += (qtd == k);
    }
  }

  cout << ans;

  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W, K;
  cin >> H >> W >> K;
  char mp[10][10];
  vector<int> bl_h(H, 0);
  vector<int> bl_w(W, 0);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> mp[i][j];
      if (mp[i][j] == '#') {
        bl_h[i]++;
        bl_w[j]++;
        K--;
      }
    }
  }
  // cout << K << endl;
  int cal_h[10];
  int cal_w[10];
  int ans = 0;
  for (int i = 0; i < 1 << H; i++) {
    for (int j = 0; j < 1 << W; j++) {
      int i_ = i;
      int j_ = j;
      int si_h = 0;
      int si_w = 0;
      int kj = 0;
      for (int k = 0; k < H; k++) {
        if (i_ % 2) {
          cal_h[si_h] = k;
          si_h++;
          kj += bl_h[k];
        }
        i_ /= 2;
      }
      for (int k = 0; k < W; k++) {
        if (j_ % 2) {
          cal_w[si_w] = k;
          si_w++;
          kj += bl_w[k];
        }
        j_ /= 2;
      }
      // int al = kj;
      // cout << kj << endl;
      int s = (si_h * W) + (si_w * H) - (si_h * si_w);
      for (int k = 0; k < si_h; k++) {
        for (int l = 0; l < si_w; l++) {
          if (mp[cal_h[k]][cal_w[l]] == '#') {
            kj--;
          }
        }
      }
      // cout << al - kj << endl;
      if (kj + K == 0)
        ans++;
    }
  }
  cout << ans << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W, K;
  cin >> H >> W >> K;
  char mp[10][10];
  int bl_h[10];
  int bl_w[10];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> mp[i][j];
      if (mp[i][j] == '#') {
        bl_h[i]++;
        bl_w[j]++;
        K--;
      }
    }
  }
  int cal_h[10];
  int cal_w[10];
  int ans = 0;
  for (int i = 0; i < 1 << H; i++) {
    for (int j = 0; j < 1 << W; j++) {
      int i_ = i;
      int j_ = j;
      int si_h = 0;
      int si_w = 0;
      int kj = 0;
      for (int k = 0; k < H; k++) {
        if (i_ % 2) {
          cal_h[si_h] = k;
          si_h++;
          kj += bl_h[k];
        }
        i_ /= 2;
      }
      for (int k = 0; k < H; k++) {
        if (j_ % 2) {
          cal_w[si_w] = k;
          si_w++;
          kj += bl_w[k];
        }
        j_ /= 2;
      }
      int s = (si_h * H) + (si_w * W) - (si_h * si_w);
      for (int k = 0; k < si_h; k++) {
        for (int l = 0; l < si_h; l++) {
          if (mp[cal_h[k]][cal_w[l]] == '#') {
            kj--;
          }
        }
      }
      if ((s - (2 * kj)) == K)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p02614 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  for (int i = 0; i < h; i++) {
    cin >> c[i];
  }
  int count = 0;
  for (int ih = 0; ih < (1 << h); ih++) {
    for (int jw = 0; jw < (1 << w); jw++) {

      int cnt = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (ih >> i & 1)
            continue;
          if (jw >> j & 1)
            continue;
          if (c[i][j] == '#')
            cnt++;
        }
      }
      if (cnt == k)
        count++;
    }
  }

  cout << count << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  for (int i = 0; i < h; i++) {
    cin >> c[i];
  }
  int count = 0;
  for (int ih = 0; ih < (1 << h); ih++) {
    for (int jw = 0; jw < (1 << w); jw++) {

      int cnt = 0;
      for (int i = 0; i < h; h++) {
        for (int j = 0; j < w; j++) {
          if (ih >> i & 1)
            continue;
          if (jw >> j & 1)
            continue;
          if (c[i][j] == '#')
            cnt++;
        }
      }
      if (cnt == k)
        count++;
    }
  }

  cout << count << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long
//  int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
lli ans = 0;
int fun(vector<lli> &a, vector<string> &v, lli k, lli h, lli w, lli x) {
  // cout << x << endl;
  if (x == h + w) {
    lli c = 0;
    for1(i, 0, h) {
      for1(j, 0, w) {
        if (v[i][j] == '#') {
          c += 1;
        }
      }
    }
    if (c == k) {
      ans += 1;
    }
    return 0;
  }
  vector<string> v1;
  for1(i, 0, v.size()) { v1.pb(v[i]); }
  vector<lli> b;
  for1(i, 0, a.size()) { b.pb(a[i]); }
  b.pb(0);
  fun(b, v, k, h, w, x + 1);
  b[x] = 1;
  if (x < h) {
    for (int i = 0; i < w; i++) {
      v1[x][i] = '.';
    }
  } else {
    int y = x - h;
    for1(i, 0, h) { v1[i][y] = '.'; }
  }

  fun(b, v1, k, h, w, x + 1);
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli h, w, k;
  cin >> h >> w >> k;
  vector<string> v;
  for1(i, 0, h) {
    string s1;
    cin >> s1;
    v.pb(s1);
  }
  vector<lli> a;
  // a.resize(h+w+1);
  fun(a, v, k, h, w, 0);
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long
//  int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
lli ans = 0;
int fun(vector<int> &a, vector<string> &v, lli k, lli h, lli w, lli x) {
  // cout << x << endl;
  if (x == h + w) {
    lli c = 0;
    for1(i, 0, h) {
      for1(j, 0, w) {
        if (v[i][j] == '#') {
          c += 1;
        }
      }
    }
    if (c == k) {
      ans += 1;
    }
    return 0;
  }
  vector<string> v1;
  for1(i, 0, v.size()) { v1.pb(v[i]); }
  vector<int> b;
  for1(i, 0, a.size()) { b.pb(a[i]); }
  b.pb(0);
  fun(b, v, k, h, w, x + 1);
  b[x] = 1;
  if (x < h) {
    for (int i = 0; i < w; i++) {
      v1[x][i] = '.';
    }
  } else {
    int y = x - h;
    for1(i, 0, h) { v1[i][y] = '.'; }
  }

  fun(b, v1, k, h, w, x + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli h, w, k;
  cin >> h >> w >> k;
  vector<string> v;
  for1(i, 0, h) {
    string s1;
    cin >> s1;
    v.pb(s1);
  }
  vector<int> a;
  // a.resize(h+w+1);
  fun(a, v, k, h, w, 0);
  cout << ans << endl;
}
Problem p02614 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> G(h);
  for (int i = 0; i < h; i++)
    cin >> G.at(i);

  int ans = 0;
  // 行のboolを考える 2のｈ乗通り
  for (int i = 0; i < (1 << h); i++) {
    // 列のbooiを考える 2のw乗通り
    for (int j = 0; j < (1 << w); j++) {
      int cnt = 0;
      // 行を取り出してその行のboolを考える
      for (int a = 0; a < h; a++) {
        // 塗られている行
        if ((i >> a) & 1)
          continue;
        // 列
        for (int b = 0; b < w; b++) {
          if ((j >> b) & 1)
            continue;
          // ここまで来るのは塗られていない行列
          if (G.at(a).at(b) == '#')
            cnt++;
        }
      }
      if (cnt == k)
        ans++;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> G(h);
  for (int i = 0; i < h; i++)
    cin >> G.at(i);

  int ans = 0;
  // 行のboolを考える 2のｈ乗通り
  for (int i = 0; (1 << h); i++) {
    // 列のbooiを考える 2のw乗通り
    for (int j = 0; (1 << w); j++) {
      int cnt = 0;
      // 行を取り出してその行のboolを考える
      for (int a = 0; a < h; a++) {
        // 塗られている行
        if ((i >> a) & 1)
          continue;
        // 列
        for (int b = 0; b < w; b++) {
          if ((j >> b) & 1)
            continue;
          // ここまで来るのは塗られていない行列
          if (G.at(a).at(b) == '#')
            cnt++;
        }
      }
      if (cnt == k)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
using ll = long long;

int main() {
  int H, W, K;
  char c[10][10];
  cin >> H >> W >> K;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> c[i][j];
    }
  }
  int cnt = 0;
  for (int twoH = 0; twoH <= (1 << H) - 1; twoH++) {
    for (int twoW = 0; twoW <= (1 << W) - 1; twoW++) {
      int black = 0;
      for (int i = 0; i <= H - 1; i++) {
        for (int j = 0; j <= W - 1; j++) {
          if (((twoH >> i) & 1) == 0 && ((twoW >> j) & 1) == 0) {
            if (c[i + 1][j + 1] == '#') {
              black++;
            }
          }
        }
      }
      if (black == K) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  int cnt = 0;
  vector<int> h_line(6, 0);
  vector<int> w_line(6, 0);
  char temp[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      temp[i][j] = '.';
    }
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> temp[i][j];
      if (temp[i][j] == '#') {
        cnt++;
        h_line[i]++;
        w_line[j]++;
      }
    }
  }
  int sum;
  int ret = 0;
  for (int i = 0; i <= 63; i++) {
    if (i > pow(2, H) - 1) {
      continue;
    }
    sum = cnt;
    vector<int> h(7, 0);
    if (i & 1) {
      sum -= h_line[1];
      h[1] = 1;
    }
    if (i & 2) {
      sum -= h_line[2];
      h[2] = 1;
    }
    if (i & 4) {
      sum -= h_line[3];
      h[3] = 1;
    }
    if (i & 8) {
      sum -= h_line[4];
      h[4] = 1;
    }
    if (i & 16) {
      sum -= h_line[5];
      h[5] = 1;
    }
    if (i & 32) {
      sum -= h_line[6];
      h[6] = 1;
    }
    for (int j = 0; j <= 63; j++) {
      if (j > pow(2, W) - 1) {
        continue;
      }
      int nok = sum;
      vector<int> w(7, 0);
      if (j & 1) {
        nok -= w_line[1];
        w[1] = 1;
      }
      if (j & 2) {
        nok -= w_line[2];
        w[2] = 1;
      }
      if (j & 4) {
        nok -= w_line[3];
        w[3] = 1;
      }
      if (j & 8) {
        nok -= w_line[4];
        w[4] = 1;
      }
      if (j & 16) {
        nok -= w_line[5];
        w[5] = 1;
      }
      if (j & 32) {
        nok -= w_line[6];
        w[6] = 1;
      }
      for (int a = 1; a <= H; a++) {
        if (h[a] != 1) {
          continue;
        }
        for (int b = 1; b <= W; b++) {
          if (w[b] != 1) {
            continue;
          }
          if (temp[a][b] == '#') {
            nok++;
          }
        }
      }
      if (nok == K) {
        ret++;
      }
    }
  }
  cout << ret << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
long long ans = 0, ha[10] = {0}, wi[10] = {0}, k, h, w;
string c[10];
bool judge(void) {
  int i, j, cntk = 0;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (c[i][j] == '#' && ha[i] == 0 && wi[j] == 0)
        cntk++;
    }
  }
  if (cntk == k)
    return true;
  else
    return false;
}
int dfs(int cnt) {
  if (cnt == (h + w)) {
    if (judge())
      ans++;
    return 0;
  }
  if (cnt < h) {
    cnt++;
    ha[cnt - 1] = 0;
    dfs(cnt);
    ha[cnt - 1] = 1;
    dfs(cnt);
  } else {
    cnt++;
    wi[cnt - h - 1] = 0;
    dfs(cnt);
    wi[cnt - h - 1] = 1;
    dfs(cnt);
  }
  return 0;
}
int main() {
  long long i;
  cin >> h >> w >> k;
  for (i = 0; i < h; i++) {
    cin >> c[i];
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long ans = 0, ha[10] = {0}, wi[10] = {0}, k, h, w;
string c[10];
bool judge(void) {
  int i, j, cntk = 0;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (c[i][j] == '#' && ha[i] == 0 && wi[j] == 0)
        cntk++;
    }
  }
  if (cntk == k)
    return true;
  else
    return false;
}
int dfs(int cnt) {
  if (cnt == (h + w)) {
    if (judge())
      ans++;
    return 0;
  }
  if (cnt < h) {
    cnt++;
    ha[cnt - 1] = 0;
    dfs(cnt);
    ha[cnt - 1] = 1;
    dfs(cnt);
  } else {
    cnt++;
    wi[cnt - h - 1] = 0;
    dfs(cnt);
    wi[cnt - h - 1] = 1;
    dfs(cnt);
  }
}
int main() {
  long long i;
  cin >> h >> w >> k;
  for (i = 0; i < h; i++) {
    cin >> c[i];
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int H;
  cin >> H;
  int W;
  cin >> W;
  int K;
  cin >> K;

  vector<string> C(H);
  for (int i = 0; i < H; i++) {
    cin >> C[i];
  }
  int ans = 0;
  for (int hbit = 0; hbit < pow(2, H); hbit++) {
    for (int wbit = 0; wbit < pow(2, W); wbit++) {
      int cnt = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (!((hbit >> i) & 1) && !((wbit >> j) & 1) && C[i][j] == '#') {
            cnt++;
          }
        }
      }
      if (cnt == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Error: WA

Fixed submission:

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int H;
  cin >> H;
  int W;
  cin >> W;
  int K;
  cin >> K;

  vector<vector<char>> C(W, vector<char>(H));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char ch = getchar();
      if (ch == '\\n') {
        j--;
        continue;
      }
      C[i][j] = ch;
    }
  }
  int ans = 0;
  for (int hbit = 0; hbit < pow(2, H); hbit++) {
    for (int wbit = 0; wbit < pow(2, W); wbit++) {
      int cnt = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (!((hbit >> i) & 1) && !((wbit >> j) & 1) && C[i][j] == '#') {
            cnt++;
          }
        }
      }
      if (cnt == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p02614 (C++) — buggy submission, verdict: Runtime Error

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i, h) cin >> c[i];

  int ans = 0;

  for (int bit1 = 0; bit1 < (1 << h); bit1++) {
    for (int bit2 = 0; bit2 < (1 << w); bit2++) {
      vector<vector<bool>> c2(h, vector<bool>(w, false));

      rep(i, h) {
        if (bit1 & (1 << i)) {
          rep(j, w) { c2[i][j] = true; }
        }
      }
      rep(i, w) {
        if (bit2 & (1 << i)) {
          rep(j, h) { c2[j][i] = true; }
        }
      }
      int cnt = 0;
      rep(i, h) {
        rep(j, w) {
          if (c[i][j] == '#' && !c2[i][j])
            cnt++;
        }
      }
      if (cnt == k)
        ans++;
    }
  }
  dunk(ans);
  return 0;
}

Error: -6
/usr/include/c++/12/debug/vector:442:
In function:
    std::debug::vector<_Tp, _Allocator>::reference std::debug::vector<_Tp, 
    _Allocator>::operator[](size_type) [with _Tp = std::debug::vector<bool>; 
    _Allocator = std::allocator<std::debug::vector<bool> >; reference = 
    std::debug::vector<bool>&; size_type = long unsigned int]

Error: attempt to subscript container with out-of-bounds index 2, but 
container only holds 2 elements.

Objects involved in the operation:
    sequence "this" @ 0x7ffd5da12c10 {
      type = std::debug::vector<std::debug::vector<bool, std::allocator<bool> >, std::allocator<std::debug::vector<bool, std::allocator<bool> > > >;
    }


Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i, h) cin >> c[i];

  int cnt = 0, ans = 0;

  for (int bit1 = 0; bit1 < (1 << h); bit1++) {
    for (int bit2 = 0; bit2 < (1 << w); bit2++) {
      vector<vector<bool>> c2(h, vector<bool>(w, false));

      rep(i, h) {
        if (bit1 & (1 << i)) {
          rep(j, w) { c2[i][j] = true; }
        }
      }
      rep(i, w) {
        if (bit2 & (1 << i)) {
          rep(j, h) { c2[i][j] = true; }
        }
      }
      rep(i, h) {
        rep(j, w) {
          if (c[i][j] == '#' && !c2[i][j])
            cnt++;
        }
      }
      if (cnt == k)
        ans++;
    }
  }
  dunk(ans);
  return 0;
}