Language: C++

#include <vector>

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> table(h, vector<char>(w));

    vector<bool> hd(h, 0);
    vector<bool> wd(w, 0);

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> table[i][j];
            if (table[i][j] == '#') {
                hd[i] = 1;
                wd[j] = 1;
            }
        }
    }

    vector<vector<char>> ans(h, vector<char>(w));
    int ansi = 0, ansj = 0;

    for (int i = 0; i < h; i++) {
        if (hd[i] == 1) {
            ansj = 0;
            for (int j = 0; j < w; j++) {
                if (wd[j] == 1) {
                    ans[ansi][ansj] = table[i][j];
                    ansj++;
                }
            }
            ansi++;
        }
    }

    for (int i = 0; i < ansi; i++) {
        for (int j = 0; j < ansj; j++) {
            cout << ans[i][j];
        }
        cout << endl;
    }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> h >> w;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<vector<char>> table(h, vector<char>(w));
      |     ^~~~~~
a.cc:6:5: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:19: error: expected primary-expression before 'char'
    6 |     vector<vector<char>> table(h, vector<char>(w));
      |                   ^~~~
a.cc:8:12: error: expected primary-expression before 'bool'
    8 |     vector<bool> hd(h, 0);
      |            ^~~~
a.cc:9:12: error: expected primary-expression before 'bool'
    9 |     vector<bool> wd(w, 0);
      |            ^~~~
a.cc:13:20: error: 'table' was not declared in this scope; did you mean 'mutable'?
   13 |             cin >> table[i][j];
      |                    ^~~~~
      |                    mutable
a.cc:15:17: error: 'hd' was not declared in this scope; did you mean 'h'?
   15 |                 hd[i] = 1;
      |                 ^~
      |                 h
a.cc:16:17: error: 'wd' was not declared in this scope; did you mean 'w'?
   16 |                 wd[j] = 1;
      |                 ^~
      |                 w
a.cc:21:19: error: expected primary-expression before 'char'
   21 |     vector<vector<char>> ans(h, vector<char>(w));
      |                   ^~~~
a.cc:25:13: error: 'hd' was not declared in this scope; did you mean 'h'?
   25 |         if (hd[i] == 1) {
      |             ^~
      |             h
a.cc:28:21: error: 'wd' was not declared in this scope; did you mean 'w'?
   28 |                 if (wd[j] == 1) {
      |                     ^~
      |                     w
a.cc:29:21: error: 'ans' was not declared in this scope; did you mean 'ansj'?
   29 |                     ans[ansi][ansj] = table[i][j];
      |                     ^~~
      |                     ansj
a.cc:29:39: error: 'table' was not declared in this scope; did you mean 'mutable'?
   29 |                     ans[ansi][ansj] = table[i][j];
      |                                       ^~~~~
      |                                       mutable
a.cc:39:13: error: 'cout' was not declared in this scope
   39 |             cout << ans[i][j];
      |             ^~~~
a.cc:39:21: error: 'ans' was not declared in this scope; did you mean 'ansj'?
   39 |             cout << ans[i][j];
      |                     ^~~
      |                     ansj
a.cc:41:9: error: 'cout' was not declared in this scope
   41 |         cout << endl;
      |         ^~~~
a.cc:41:17: error: 'endl' was not declared in this scope
   41 |         cout << endl;
      |                 ^~~~