Language: C++

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

vector<vector<int> > matrix;

int main(){
    int H;
    while(scanf("%d",&H) && H){
        vector<int> temp(5,0);
        matrix.push_back(temp);
        for (int i = 0; i < H; i++) {
            vector<int> temp(5,0);
            for (int j = 0; j < 5; j++)
                cin >> temp[j];
            matrix.push_back(temp);
        }

        bool flag = true;
        int score = 0;


        while(flag){
        // for (int i=0; i < H+1; i++) {                                                                                                                               
        //     for (int j=0; j < 5; j++)                                                                                                                               
        //      cout << matrix[i][j];                                                                                                                                  
        //     cout << endl;                                                                                                                                           
        // }                                                                                                                                                           
        // cout << "====================" << endl;                                                                                                                     



            // ?¶????????????¨????????¢??????                                                                                                                                    
            // ?¶?????????????-1?????£??\                                                                                                                                      
            for (int i=0; i < H+1; i++) {
                int count = 1, num=-1;
                flag = false;
                for (int j=0; j <3 ; j++) {
                    if(matrix[i][j]!=-1 &&
                       matrix[i][j]!=0 &&
                       matrix[i][j]==matrix[i][j+1] &&
                       matrix[i][j+1]==matrix[i][j+2]){
                        flag = true;
                        num = matrix[i][j];
                        break;
                    }
                }
                if(flag){
                    for (int j=0; j < 5; j++) {
                        if(matrix[i][j]==num){
                            score += num;
                            matrix[i][j] = -1;
                        }
                    }
                }



            }
            // ???????????????????¢????                                                                                                                                        
            // ???????????????????????????0?????£??\                                                                                                                               
            bool fail_flag;
            do{
               	fail_flag = false;
		for (int i=H; i > 0; i--) {
                    for (int j=0; j < 5; j++) {
			if(matrix[i][j]==-1){
                            fail_flag = true;
                            flag = true;
                            if(matrix[i-1][j]!=0){
				matrix[i][j] = matrix[i-1][j];
				matrix[i-1][j] = -1;
                            }
                            else
                                matrix[i][j] = 0;

			}
                    }
		}
                for (int j=0; j < 5; j++)
                    matrix[0][j] = 0;
            }while(fail_flag);
	}
        cout << score << endl;
	matrix.clear();
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:31: error: 'i' was not declared in this scope
   39 |                     if(matrix[i][j]!=-1 &&
      |                               ^
a.cc:50:35: error: 'i' was not declared in this scope
   50 |                         if(matrix[i][j]==num){
      |                                   ^
a.cc:64:17: error: 'fail_flag' was not declared in this scope
   64 |                 fail_flag = false;
      |                 ^~~~~~~~~
a.cc:82:20: error: 'fail_flag' was not declared in this scope
   82 |             }while(fail_flag);
      |                    ^~~~~~~~~
a.cc:84:17: error: 'score' was not declared in this scope
   84 |         cout << score << endl;
      |                 ^~~~~
a.cc: At global scope:
a.cc:87:5: error: expected unqualified-id before 'return'
   87 |     return 0;
      |     ^~~~~~
a.cc:88:1: error: expected declaration before '}' token
   88 | }
      | ^