Language: C++

#define rep(v,s,e) for(int v=s,v<e,v++)
#define rep_sub(v,s,e) for(int v=s,e<=v,v--)
#include <algorithm>
#include <array>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using Line = array<char, 5>;
using Puzzle = vector<Line>;

void newline() {cout << endl;}
template <typename T>
void put(T input){cout << input;}
template <typename T>
void putl(T input){put(input); newline();}

int n;
int point;
Puzzle puzzle;

void swap_rec(int column, int row){
  if(0<column){
    swap(puzzle[column][row], puzzle[column-1][row]);
    swap_rec(column-1, row);
  }
}

void drop(){
  Puzzle prev_puzzle = puzzle;
  rep_sub(column, puzzle.size()-1, 0)
    rep_sub(row, puzzle[column].size()-1, 0)
      if(puzzle[column][row] == '#')
        swap_rec(column, row);
  if(puzzle != prev_puzzle) drop();
}

int clear(Line &line, int n, char c){
  if(line[n] == c){
    line[n]='#';
    if(1 <= n && n < line.size()-1){
      return int(c)-int('0')+clear(line, n+1, c)+clear(line, n-1, c);
    }else{
      return int(c)-int('0');
    }
  }
  return 0; 
}


int solve(){
  Puzzle prev_puzzle = puzzle;
  for(Line &line: puzzle)
    rep(k, 1, line.size()-1)
      if(line[k] != '#' && line[k-1] == line[k] && line[k] == line[k+1])
        point+=clear(line, k, line[k]);
  drop();
  if(prev_puzzle != puzzle) solve();
  return point;
}

int main() {
  while(cin>>n && n){
    point=0; puzzle={}; puzzle.reserve(n);
    rep(ic, 0, n){
      Line line;
      rep(lc, 0, line.size()){
        char s; cin >> s; line[lc]=s;
      }
      puzzle.push_back(line);
    }
    putl(solve());
  }
}

Compiler output:
a.cc: In function 'void drop()':
a.cc:31:36: error: expected unqualified-id before numeric constant
   31 |   rep_sub(column, puzzle.size()-1, 0)
      |                                    ^
a.cc:2:36: note: in definition of macro 'rep_sub'
    2 | #define rep_sub(v,s,e) for(int v=s,e<=v,v--)
      |                                    ^
a.cc:31:36: error: expected ';' before numeric constant
   31 |   rep_sub(column, puzzle.size()-1, 0)
      |                                    ^
a.cc:2:36: note: in definition of macro 'rep_sub'
    2 | #define rep_sub(v,s,e) for(int v=s,e<=v,v--)
      |                                    ^
a.cc:2:44: error: expected ';' before ')' token
    2 | #define rep_sub(v,s,e) for(int v=s,e<=v,v--)
      |                                            ^
a.cc:31:3: note: in expansion of macro 'rep_sub'
   31 |   rep_sub(column, puzzle.size()-1, 0)
      |   ^~~~~~~
a.cc:32:43: error: expected unqualified-id before numeric constant
   32 |     rep_sub(row, puzzle[column].size()-1, 0)
      |                                           ^
a.cc:2:36: note: in definition of macro 'rep_sub'
    2 | #define rep_sub(v,s,e) for(int v=s,e<=v,v--)
      |                                    ^
a.cc:32:43: error: expected ';' before numeric constant
   32 |     rep_sub(row, puzzle[column].size()-1, 0)
      |                                           ^
a.cc:2:36: note: in definition of macro 'rep_sub'
    2 | #define rep_sub(v,s,e) for(int v=s,e<=v,v--)
      |                                    ^
a.cc:2:44: error: expected ';' before ')' token
    2 | #define rep_sub(v,s,e) for(int v=s,e<=v,v--)
      |                                            ^
a.cc:32:5: note: in expansion of macro 'rep_sub'
   32 |     rep_sub(row, puzzle[column].size()-1, 0)
      |     ^~~~~~~
a.cc: In function 'int solve()':
a.cc:1:33: error: expected ';' before '<' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                 ^
a.cc:54:5: note: in expansion of macro 'rep'
   54 |     rep(k, 1, line.size()-1)
      |     ^~~
a.cc:1:33: error: expected primary-expression before '<' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                 ^
a.cc:54:5: note: in expansion of macro 'rep'
   54 |     rep(k, 1, line.size()-1)
      |     ^~~
a.cc:1:39: error: expected ';' before ')' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                       ^
a.cc:54:5: note: in expansion of macro 'rep'
   54 |     rep(k, 1, line.size()-1)
      |     ^~~
a.cc: In function 'int main()':
a.cc:1:33: error: expected ';' before '<' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                 ^
a.cc:65:5: note: in expansion of macro 'rep'
   65 |     rep(ic, 0, n){
      |     ^~~
a.cc:1:33: error: expected primary-expression before '<' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                 ^
a.cc:65:5: note: in expansion of macro 'rep'
   65 |     rep(ic, 0, n){
      |     ^~~
a.cc:1:39: error: expected ';' before ')' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                       ^
a.cc:65:5: note: in expansion of macro 'rep'
   65 |     rep(ic, 0, n){
      |     ^~~
a.cc:1:33: error: expected ';' before '<' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                 ^
a.cc:67:7: note: in expansion of macro 'rep'
   67 |       rep(lc, 0, line.size()){
      |       ^~~
a.cc:1:33: error: expected primary-expression before '<' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                 ^
a.cc:67:7: note: in expansion of macro 'rep'
   67 |       rep(lc, 0, line.size()){
      |       ^~~
a.cc:1:39: error: expected ';' before ')' token
    1 | #define rep(v,s,e) for(int v=s,v<e,v++)
      |                                       ^
a.cc:67:7: note: in expansion of macro 'rep'
   67 |       rep(lc, 0, line.size()){
      |       ^~~