Language: C++

int main() {
  
     int H, W;
     cin >> H >> W;
  
     vector <string> a(H);
     for (int i = 0; i < H; i++)cin >> a[i];
  
     vector <vector<bool>> flags(H, vector<bool>(W, false));
  
     for (int i = 0; i < H; i++) {
         bool flag = true;
         for (int j = 0; j < W; j++) if (a[i][j] == '#')flag = false;
         if (flag) for (int j = 0; j < W; j++) flags[i][j] = true;
     }
     for (int i = 0; i < W; i++) {
         bool flag = true;
         for (int j = 0; j < H; j++) if (a[j][i] == '#') flag = false;
         if (flag)for (int j = 0; j < H; j++) flags[j][i] = true;
     }
 //
 //    for (int i = 0; i < H; i++) SHOW_VECTOR(flags[i]);
  
     vector <string> ans;
     for (int i = 0; i < H; i++) {
         string str = "";
         for (int j = 0; j < W; j++) if (!flags[i][j]) str += a[i][j];
         if (str.size()) ans.push_back(str);
     }
  
     for (auto x: ans)cout << x << endl;
  
 }
  

Compiler output:
a.cc: In function 'int main()':
a.cc:4:6: error: 'cin' was not declared in this scope
    4 |      cin >> H >> W;
      |      ^~~
a.cc:6:6: error: 'vector' was not declared in this scope
    6 |      vector <string> a(H);
      |      ^~~~~~
a.cc:6:14: error: 'string' was not declared in this scope
    6 |      vector <string> a(H);
      |              ^~~~~~
a.cc:6:22: error: 'a' was not declared in this scope
    6 |      vector <string> a(H);
      |                      ^
a.cc:9:21: error: expected primary-expression before 'bool'
    9 |      vector <vector<bool>> flags(H, vector<bool>(W, false));
      |                     ^~~~
a.cc:14:48: error: 'flags' was not declared in this scope; did you mean 'flag'?
   14 |          if (flag) for (int j = 0; j < W; j++) flags[i][j] = true;
      |                                                ^~~~~
      |                                                flag
a.cc:19:47: error: 'flags' was not declared in this scope; did you mean 'flag'?
   19 |          if (flag)for (int j = 0; j < H; j++) flags[j][i] = true;
      |                                               ^~~~~
      |                                               flag
a.cc:24:22: error: 'ans' was not declared in this scope
   24 |      vector <string> ans;
      |                      ^~~
a.cc:26:16: error: expected ';' before 'str'
   26 |          string str = "";
      |                ^~~~
      |                ;
a.cc:27:43: error: 'flags' was not declared in this scope
   27 |          for (int j = 0; j < W; j++) if (!flags[i][j]) str += a[i][j];
      |                                           ^~~~~
a.cc:27:56: error: 'str' was not declared in this scope; did you mean 'std'?
   27 |          for (int j = 0; j < W; j++) if (!flags[i][j]) str += a[i][j];
      |                                                        ^~~
      |                                                        std
a.cc:28:14: error: 'str' was not declared in this scope; did you mean 'std'?
   28 |          if (str.size()) ans.push_back(str);
      |              ^~~
      |              std
a.cc:31:23: error: 'cout' was not declared in this scope
   31 |      for (auto x: ans)cout << x << endl;
      |                       ^~~~
a.cc:31:36: error: 'endl' was not declared in this scope
   31 |      for (auto x: ans)cout << x << endl;
      |                                    ^~~~