Language: C++

#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H); rep(i, H) cin >> S[i];

    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '.') {
                int cnt = 0;
                if (i > 0 && j > 0 && S[i - 1][j - 1] == '#') cnt++;
                if (i > 0 && S[i - 1][j] == '#') cnt++;
                if (i > 0 && j < W && S[i - 1][j + 1] == '#') cnt++;
                if (j > 0 && S[i][j - 1] == '#') cnt++;
                if (j < W && S[i][j + 1] == '#') cnt++;
                if (i < H && j > 0 && S[i + 1][j - 1] == '#') cnt++;
                if (i < H && S[i + 1][j] == '#') cnt++;
                if (i < H && j < W && S[i + 1][j + 1] == '#') cnt++;
                S[i][j] = '0' + cnt; // int を char に変換
            }
        }
    }
    
    rep(i, H) {
        cout << S[i] << endl;    
    }
    return 0;
}
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H); rep(i, H) cin >> S[i];

    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '.') {
                int cnt = 0;
                if (i > 0 && j > 0 && S[i - 1][j - 1] == '#') cnt++;
                if (i > 0 && S[i - 1][j] == '#') cnt++;
                if (i > 0 && j < W && S[i - 1][j + 1] == '#') cnt++;
                if (j > 0 && S[i][j - 1] == '#') cnt++;
                if (j < W && S[i][j + 1] == '#') cnt++;
                if (i < H && j > 0 && S[i + 1][j - 1] == '#') cnt++;
                if (i < H && S[i + 1][j] == '#') cnt++;
                if (i < H && j < W && S[i + 1][j + 1] == '#') cnt++;
                S[i][j] = '0' + cnt; // int を char に変換
            }
        }
    }
    
    rep(i, H) {
        cout << S[i] << endl;    
    }
    return 0;
}


Compiler output:
a.cc:59:11: error: redefinition of 'const int MOD'
   59 | const int MOD = 1e9 + 7;
      |           ^~~
a.cc:12:11: note: 'const int MOD' previously defined here
   12 | const int MOD = 1e9 + 7;
      |           ^~~
a.cc:60:11: error: redefinition of 'const int MAX'
   60 | const int MAX = 1e9;
      |           ^~~
a.cc:13:11: note: 'const int MAX' previously defined here
   13 | const int MAX = 1e9;
      |           ^~~
a.cc:61:10: error: redefinition of 'const ll LLMAX'
   61 | const ll LLMAX = 1e18;
      |          ^~~~~
a.cc:14:10: note: 'const ll LLMAX' previously defined here
   14 | const ll LLMAX = 1e18;
      |          ^~~~~
a.cc:62:11: error: redefinition of 'const int INF'
   62 | const int INF = numeric_limits<int>::max();
      |           ^~~
a.cc:15:11: note: 'const int INF' previously defined here
   15 | const int INF = numeric_limits<int>::max();
      |           ^~~
a.cc:63:10: error: redefinition of 'const ll LLINF'
   63 | const ll LLINF = numeric_limits<ll>::max();
      |          ^~~~~
a.cc:16:10: note: 'const ll LLINF' previously defined here
   16 | const ll LLINF = numeric_limits<ll>::max();
      |          ^~~~~
a.cc:64:14: error: redefinition of 'const double PI'
   64 | const double PI = acos(-1.0);
      |              ^~
a.cc:17:14: note: 'const double PI' previously defined here
   17 | const double PI = acos(-1.0);
      |              ^~
a.cc:69:5: error: redefinition of 'int main()'
   69 | int main() {
      |     ^~~~
a.cc:22:5: note: 'int main()' previously defined here
   22 | int main() {
      |     ^~~~