Language: C++

#include <bits/stdc++.h>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  
  string S0, S1;
  cin >> S0 >> S1;
    
  for (int j = 0; j < W; j++) {
    if (S0.at(j)=='.') {
      int count=0;
      string countre;
      if (S0.at(j-1)=='#')
        count++;
      if (S0.at(j+1)=='#')
        count++;
      if (S1.at(j-1)=='#')
        count++;
      if (S1.at(j)=='#')
        count++;
      if (S1.at(j+1)=='#')
        count++;
      countre = to_string(count);
      S0.at(j)='countre';
    }
  }
  cout << S0 << endl; //0行目終了
  
  string Sb, Sn, Sa;
  
  Sb=S0;
  Sn=S1
  cin >> Sa; //2列目を入力
  
  for (int i = 0; i < H-3; i++) {
    for (int j = 0; j < W; j++) {
      if (Sn.at(j)=='.') {
        int count=0;
        string countre;
        if (Sb.at(j-1)=='#')
          count++;
        if (Sb.at(j)=='#')
          count++;
        if (Sb.at(j+1)=='#')
          count++;
        if (Sn.at(j-1)=='#')
          count++;
        if (Sn.at(j+1)=='#')
          count++;
        if (Sa.at(j-1)=='#')
          count++;
        if (Sa.at(j)=='#')
          count++;
        if (Sa.at(j+1)=='#')
          count++;
        countre = to_string(count);
        Sn.at(j)='countre';
      }
    }
    cout << Sn << endl;
    Sb=Sn;
    Sn=Sa;
    string S;
    cin >> S
    Sa=S;
  }                                //H-2行まで終了
  
      for (int j = 0; j < W; j++) {
      if (Sn.at(j)=='.') {
        int count=0;
        string countre;
        if (Sb.at(j-1)=='#')
          count++;
        if (Sb.at(j)=='#')
          count++;
        if (Sb.at(j+1)=='#')
          count++;
        if (Sn.at(j-1)=='#')
          count++;
        if (Sn.at(j+1)=='#')
          count++;
        if (Sa.at(j-1)=='#')
          count++;
        if (Sa.at(j)=='#')
          count++;
        if (Sa.at(j+1)=='#')
          count++;
        countre = to_string(count);
        Sn.at(j)='countre';
      }
    }
    cout << Sn << endl;
    Sb=Sn;
    Sn=Sa;
  
  for (int j = 0; j < W; j++) {
    if (Sn.at(j)=='.') {
      int count=0;
      string countre;
      if (Sn.at(j-1)=='#')
        count++;
      if (Sn.at(j+1)=='#')
        count++;
      if (Sb.at(j-1)=='#')
        count++;
      if (Sb.at(j)=='#')
        count++;
      if (Sb.at(j+1)=='#')
        count++;
      countre = to_string(count);
      Sn.at(j)='countre';
    }
  }
  cout << Sn << endl; //H行目終了
}

Compiler output:
a.cc:28:16: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
   28 |       S0.at(j)='countre';
      |                ^~~~~~~~~
a.cc:61:18: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
   61 |         Sn.at(j)='countre';
      |                  ^~~~~~~~~
a.cc:93:18: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
   93 |         Sn.at(j)='countre';
      |                  ^~~~~~~~~
a.cc:115:16: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
  115 |       Sn.at(j)='countre';
      |                ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:28:16: warning: overflow in conversion from 'int' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} changes value from '1853125221' to '101' [-Woverflow]
   28 |       S0.at(j)='countre';
      |                ^~~~~~~~~
a.cc:36:8: error: expected ';' before 'cin'
   36 |   Sn=S1
      |        ^
      |        ;
   37 |   cin >> Sa; //2列目を入力
      |   ~~~   
a.cc:61:18: warning: overflow in conversion from 'int' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} changes value from '1853125221' to '101' [-Woverflow]
   61 |         Sn.at(j)='countre';
      |                  ^~~~~~~~~
a.cc:68:13: error: expected ';' before 'Sa'
   68 |     cin >> S
      |             ^
      |             ;
   69 |     Sa=S;
      |     ~~       
a.cc:93:18: warning: overflow in conversion from 'int' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} changes value from '1853125221' to '101' [-Woverflow]
   93 |         Sn.at(j)='countre';
      |                  ^~~~~~~~~
a.cc:115:16: warning: overflow in conversion from 'int' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} changes value from '1853125221' to '101' [-Woverflow]
  115 |       Sn.at(j)='countre';
      |                ^~~~~~~~~