Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            var input = cin.SplitRead();
            int H = input[0];
            int W = input[1];
            int K = input[2];
            var map = new char[H, W];
            bool[] all = new bool[H];
            int[] c = new int[H];
            
            for(var i = 0; i < H; i++)
            {
                int cn = 0;
                var s = Console.ReadLine();
                for(var j = 0; j < W; j++)
                {
                    if (s[j] == '#') { cn++;}
                    map[i, j] = s[j];
                }
                all[i] = cn == 0;
                c[i] = cn;
            }

            var ans = new int[H, W];
            int cur = 1;
            for (var i = 0; i < H; i++)
            {
                if (all[i]) {
                    for(var j = 0; j < W; j++)
                    {
                        ans[i, j] = -1;

                    }
                    continue;
                }
                int cc = 0;
                for(var j = 0; j < W; j++)
                {
                    ans[i, j] = cur;
                    if (map[i, j] == '#') { cc++; }
                    if (j == W - 1) { cur++;continue; }
                    if (map[i, j] == '#' && cc < c[i]) { cur++; }
                }
            }
            for(var i = 0; i < H; i++)
            {
                if (all[i]) { continue; }
                for(var j = 0; j < W; j++)
                {
                    int U = i;
                    int D = i;
                    while (U != 0)
                    {
                        U--;
                        if (U < 0) { break; }
                        if (ans[U,j]>0) { break; }
                        ans[U, j] = ans[i, j];
                    }

                    while (D <= H - 1)
                    {
                        D++;
                        if (D>H-1) { break; }
                        if (ans[D, j] > 0) { break; }
                        ans[D, j] = ans[i, j];
                    }
                }
            }

            Display(ans, H, W);

            //Console.Out.Flush();
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
        struct Pair<T, U> : IComparable<Pair<T, U>>
        where T : IComparable<T>
        where U : IComparable<U>
        {
            public T first;
            public U second;
            private readonly bool CompWithFirst;

            public Pair(T f, U s, int comp)
            {
                first = f;
                second = s;
                CompWithFirst = comp == 1;
            }
            public Pair(T f, U s)
            {
                first = f;
                second = s;
                CompWithFirst = true;
            }

            public int CompareTo(Pair<T, U> other)
            {
                return CompWithFirst ? first.CompareTo(other.first) : second.CompareTo(other.second);
            }
        }
    }
   
    public class PriorityQueue<T> where T : IComparable<T>
    {

        private List<T> Q;
        private readonly int r;

        public PriorityQueue(bool ascending)
        {
            if (ascending)
            {
                r = 1;
            }
            else
            {
                r = -1;
            }
            Q = new List<T>();
        }


        private void PushHeap(List<T> list, T item)
        {
            int n = list.Count();
            list.Add(item);

            while (n != 0)
            {
                int pIndex = (n - 1) / 2;

                if (list[n].CompareTo(list[pIndex]) * r > 0)
                {
                    Swap(Q, n, pIndex);
                }
                else { break; }

                n = pIndex;
            }
        }

        private void PopHeap(List<T> list)
        {
            int n = list.Count() - 1;
            list[0] = list[n];
            list.RemoveAt(n);

            int cur = 0;
            int comp;

            while (2 * cur + 1 <= n - 1)
            {
                int c1 = 2 * cur + 1;
                int c2 = 2 * (cur + 1);
                if (c1 == n - 1)
                {
                    comp = c1;
                }
                else
                {

                    comp = list[c1].CompareTo(list[c2]) * r > 0 ? c1 : c2;
                }

                if (list[cur].CompareTo(list[comp]) * r < 0)
                {
                    Swap(Q, cur, comp);
                }
                else { break; }

                cur = comp;
            }
        }

        private void Swap(List<T> list, int a, int b)
        {
            T keep = list[a];
            list[a] = list[b];
            list[b] = keep;
        }



        public void Enqueue(T value)
        {
            PushHeap(Q, value);
        }

        public T Dequeue()
        {
            T ret = Q[0];
            PopHeap(Q);
            return ret;
        }

        public T Peek()
        {
            return Q[0];
        }

        public int Count()
        {
            return Q.Count();
        }

        public bool Contains(T search)
        {
            return Q.Contains(search);
        }
    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(T[] a, int i, int j)
        {
            T k = a[i];
            a[i] = a[j];
            a[j] = k;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for(var i = 0; i < n; i++)
            {
                for(var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

    }

}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.IO;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Text;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'static'
    6 | using static System.Math;
      |       ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'static'
    7 | using static System.Array;
      |       ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'static'
    8 | using static AtCoder.Tool;
      |       ^~~~~~
a.cc:17:16: error: 'readonly' does not name a type
   17 |         static readonly int[] dx = { 0, 1, 0, -1 };
      |                ^~~~~~~~
a.cc:18:16: error: 'readonly' does not name a type
   18 |         static readonly int[] dy = { 1, 0, -1, 0 };
      |                ^~~~~~~~
a.cc:24:26: error: 'string' has not been declared
   24 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:24:35: error: expected ',' or '...' before 'args'
   24 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:102:19: error: expected ':' before 'int'
  102 |             public int from;
      |                   ^~~~
      |                   :
a.cc:104:19: error: expected ':' before 'int'
  104 |             public int to;
      |                   ^~~~
      |                   :
a.cc:105:19: error: expected ':' before 'long'
  105 |             public long dist;
      |                   ^~~~~
      |                   :
a.cc:106:19: error: expected ':' before 'Edge'
  106 |             public Edge(int t, long c)
      |                   ^~~~~
      |                   :
a.cc:112:19: error: expected ':' before 'Edge'
  112 |             public Edge(int f, int t, long c)
      |                   ^~~~~
      |                   :
a.cc:119:10: error: expected ';' after struct definition
  119 |         }
      |          ^
      |          ;
a.cc:120:16: error: 'Pair' is not a class template
  120 |         struct Pair<T, U> : IComparable<Pair<T, U>>
      |                ^~~~
a.cc:120:21: error: 'T' was not declared in this scope
  120 |         struct Pair<T, U> : IComparable<Pair<T, U>>
      |                     ^
a.cc:120:24: error: 'U' was not declared in this scope
  120 |         struct Pair<T, U> : IComparable<Pair<T, U>>
      |                        ^
a.cc:120:40: error: expected template-name before '<' token
  120 |         struct Pair<T, U> : IComparable<Pair<T, U>>
      |                                        ^
a.cc:120:40: error: expected '{' before '<' token
a.cc:120:40: error: expected unqualified-id before '<' token
a.cc:146:6: error: expected ';' after class definition
  146 |     }
      |      ^
      |      ;
a.cc:14:25: error: expected primary-expression before 'int'
   14 |         const int INF = int.MaxValue / 2;
      |                         ^~~
a.cc:15:27: error: expected primary-expression before 'long'
   15 |         const long SINF = long.MaxValue / 2;
      |                           ^~~~
a.cc: In static member function 'static void AtCoder::AC::Main(int*)':
a.cc:28:13: error: 'var' was not declared in this scope
   28 |             var cin = new Scanner();
      |             ^~~
a.cc:29:17: error: expected ';' before 'input'
   29 |             var input = cin.SplitRead();
      |                 ^~~~~
a.cc:30:21: error: 'input' was not declared in this scope; did you mean 'int'?
   30 |             int H = input[0];
      |                     ^~~~~
      |                     int
a.cc:33:17: error: expected ';' before 'map'
   33 |             var map = new char[H, W];
      |                 ^~~
a.cc:34:17: error: structured binding declaration cannot have type 'bool'
   34 |             bool[] all = new bool[H];
      |                 ^~
a.cc:34:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:34:17: error: empty structured binding declaration
a.cc:34:20: error: expected initializer before 'all'
   34 |             bool[] all = new bool[H];
      |                    ^~~
a.cc:35:16: error: structured binding declaration cannot have type 'int'
   35 |             int[] c = new int[H];
      |                ^~
a.cc:35:16: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:35:16: error: empty structured binding declaration
a.cc:35:19: error: expected initializer before 'c'
   35 |             int[] c = new int[H];
      |                   ^
a.cc:37:21: error: expected ';' before 'i'
   37 |             for(var i = 0; i < H; i++)
      |                     ^
a.cc:37:28: error: 'i' was not declared in this scope
   37 |             for(var i = 0; i < H; i++)
      |                            ^
a.cc:40:21: error: expected ';' before 's'
   40 |                 var s = Console.ReadLine();
      |                     ^
a.cc:41:25: error: expected ';' before 'j'
   41 |                 for(var j = 0; j < W; j++)
      |                         ^
a.cc:41:32: error: 'j' was not declared in this scope
   41 |                 for(var j = 0; j < W; j++)
      |                                ^
a.cc:43:25: error: 's' was not declared in this scope
   43 |                     if (s[j] == '#') { cn++;}
      |                         ^
a.cc:44:21: error: 'map' was not declared in this scope
   44 |                     map[i, j] = s[j];
      |                     ^~~
a.cc:44:33: error: 's' was not declared in this scope
   44 |                     map[i, j] = s[j];
      |                                 ^
a.cc:46:17: error: 'all' was not declared in this scope
   46 |                 all[i] = cn == 0;
      |                 ^~~
a.cc:47:17: error: 'c' was not declared in this scope; did you mean 'cn'?
   47 |                 c[i] = cn;
      |                 ^
      |                 cn
a.cc:50:17: error: expected ';' before 'ans'
   50 |             var ans = new int[H, W];
      |                 ^~~
a.cc:52:22: error: expected ';' before 'i'
   52 |             for (var i = 0; i < H; i++)
      |                      ^
a.cc:52:29: error: 'i' was not declared in this scope
   52 |             for (var i = 0; i < H; i++)
      |                             ^
a.cc:54:21: error: 'all' was not declared in this scope
   54 |                 if (all[i]) {
      |                     ^~~
a.cc:55:29: error: expected ';' before 'j'
   55 |                     for(var j = 0; j < W; j++)
      |                             ^
a.cc:55:36: error: 'j' was not declared in this scope
   55 |                     for(var j = 0; j < W; j++)
      |                                    ^
a.cc:57:25: error: 'ans' was not declared in this scope
   57 |                         ans[i, j] = -1;
      |                         ^~~
a.cc:63:25: error: expected ';' before 'j'
   63 |                 for(var j = 0; j < W; j++)
      |                         ^
a.cc:63:32: error: 'j' was not declared in this scope
   63 |                 for(var j = 0; j < W; j++)
      |                                ^
a.cc:65:21: error: 'ans' was not declared in this scope
   65 |                     ans[i, j] = cur;
      |                     ^~~
a.cc:66:25: error: 'map' was not declared in this scope
   66 |                     if (map[i, j] == '#') { cc++; }
      |                         ^~~
a.cc:68:25: error: 'map' was not declared in this scope
   68 |                     if (map[i, j] == '#' && cc < c[i]) { cur++; }
      |                         ^~~
a.cc:68:50: error: 'c' was not declared in this scope; did you mean 'cc'?
   68 |                     if (map[i, j] == '#' && cc < c[i]) { cur++; }
      |                                                  ^
      |                                                  cc
a.cc:71:21: error: expected ';' before 'i'
   71 |             for(var i = 0; i < H; i++)
      |                     ^
a.cc:71:28: error: 'i' was not declared in this scope
   71 |             for(var i = 0; i < H; i++)
      |                            ^
a.cc:73:21: error: 'all' was not declared in this scope
   73 |                 if (all[i]) { continue; }
      |                     ^~~
a.cc:74:25: error: expected ';' before 'j'
   74 |                 for(var j = 0; j < W; j++)
      |                         ^
a.cc:74:32: error: 'j' was not declared in this scope
   74 |                 for(var j = 0; j < W; j++)
      |                                ^
a.cc:82:29: error: 'ans' was not declared in this scope
   82 |                         if (ans[U,j]>0) { break; }
      |                             ^~~
a.cc:83:25: error: 'ans' was not declared in this scope
   83 |                         ans[U, j] = ans[i, j];
      |                         ^~~
a.cc:90:29: error: 'ans' was not declared in this scope
   90 |                         if (ans[D, j] > 0) { break; }
      |                             ^~~
a.cc:91:25: error: 'ans' was not declared in this scope
   91 |                         ans[D, j] = ans[i, j];
      |                         ^~~
a.cc:96:21: error: 'ans' was not declared in this scope
   96 |             Display(ans, H, W);
      |                     ^~~
a.cc:96:13: error: 'Display' was not declared in this scope
   96 |             Display(ans, H, W);
      |             ^~~~~~~
a.cc: At global scope:
a.cc:148:5: error: expected unqualified-id before 'public'
  148 |     public class PriorityQueue<T> where T : IComparable<T>
      |     ^~~~~~
a.cc:256:5: error: expected unqualified-id before 'public'
  256 |     public class Scanner
      |     ^~~~~~
a.cc:269:5: error: expected unqualified-id before 'public'
  269 |     public static class Tool
      |     ^~~~~~