Language: C++

using System;
using System.Collections.Generic;


class squareroute
{
    static void Main(string[] args)
    {
        while (true)
        {
            int N, M;
            string[] s = Console.ReadLine().Split(' ');
            if (s[0] == "0" & s[1] == "0") break;
            N = int.Parse(s[0]);
            M = int.Parse(s[1]); //N??¨M?????\???
            int[] hpos = new int[N + 1];
            int[] wpos = new int[M + 1]; //????????§?¨???????????????????
            hpos[0] = 0; //???????????§?¨????0??§??????
            wpos[0] = 0; //????????????????????§?¨????0??§??????
            for (int i = 1; i <= N; i++)
            {
                hpos[i] = int.Parse(Console.ReadLine()) + hpos[i - 1]; //???????¨????????????§?¨?
            }
            for (int i = 1; i <= M; i++)
            {
                wpos[i] = int.Parse(Console.ReadLine()) + wpos[i - 1]; //????????????????????§?¨?
            }

            if (N == 1)
            {
                Console.WriteLine(M);
                continue;
            }
            if (M == 1)
            {
                Console.WriteLine(N);
                continue;
            }

            List<int> hlength = new List<int>();
            List<int> wlength = new List<int>();
            for (int i = 0; i <= N; i++)
            {
                for (int j = i + 1; j <= N; j++)
                {
                    hlength.Add(hpos[j] - hpos[i]);
                }
            }
            hlength.Sort();
            for (int i = 0; i <= N; i++)
            {
                for (int j = i + 1; j <= N; j++)
                {
                    wlength.Add(wpos[j] - wpos[i]);
                }
            }
            wlength.Sort(); //??£?????¢?????????????????¨???????????????????????????hlength??¨wlength?????£??\??????

            Dictionary<int,int> hdic = new Dictionary<int, int>();
            Dictionary<int, int> wdic = new Dictionary<int,int>();
            int isrepeated = -1;
            int previous_number = -1;
            for(int i = 0; i < N*(N-1); i++)
            {
                if (previous_number != hlength[i])
                {
                    isrepeated = 1;
                    hdic.Add(hlength[i], 1);
                    previous_number = hlength[i];
                }
                else
                {
                    isrepeated++;
                    hdic[previous_number] = isrepeated;
                    previous_number = hlength[i];
                }
            }
            isrepeated = -1;
            previous_number = -1;
            for (int i = 0; i < M * (M - 1); i++)
            {
                if (previous_number != wlength[i])
                {
                    isrepeated = 1;
                    wdic.Add(wlength[i],1);
                    previous_number = wlength[i];
                }
                else
                {
                    isrepeated++;
                    wdic[previous_number] = isrepeated;
                    previous_number = wlength[i];
                }
            }
            
            int sum = 0;
            for(int i = 1; i <= Math.Min(hlength[N * (N - 1)-1], wlength[M * (M - 1)-1]);i++)
            {
                if (hdic.ContainsKey(i) & wdic.ContainsKey(i)) sum += hdic[i] * wdic[i];
                else continue;

            }
            Console.WriteLine(sum);
        }
    }
}

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:7:22: error: 'string' has not been declared
    7 |     static void Main(string[] args)
      |                      ^~~~~~
a.cc:7:31: error: expected ',' or '...' before 'args'
    7 |     static void Main(string[] args)
      |                               ^~~~
a.cc:106:2: error: expected ';' after class definition
  106 | }
      |  ^
      |  ;
a.cc: In static member function 'static void squareroute::Main(int*)':
a.cc:12:13: error: 'string' was not declared in this scope
   12 |             string[] s = Console.ReadLine().Split(' ');
      |             ^~~~~~
a.cc:12:20: error: expected primary-expression before ']' token
   12 |             string[] s = Console.ReadLine().Split(' ');
      |                    ^
a.cc:13:17: error: 's' was not declared in this scope
   13 |             if (s[0] == "0" & s[1] == "0") break;
      |                 ^
a.cc:14:17: error: expected primary-expression before 'int'
   14 |             N = int.Parse(s[0]);
      |                 ^~~
a.cc:15:17: error: expected primary-expression before 'int'
   15 |             M = int.Parse(s[1]); //N??¨M?????\???
      |                 ^~~
a.cc:16:16: error: structured binding declaration cannot have type 'int'
   16 |             int[] hpos = new int[N + 1];
      |                ^~
a.cc:16:16: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:16:16: error: empty structured binding declaration
a.cc:16:19: error: expected initializer before 'hpos'
   16 |             int[] hpos = new int[N + 1];
      |                   ^~~~
a.cc:17:16: error: structured binding declaration cannot have type 'int'
   17 |             int[] wpos = new int[M + 1]; //????????§?¨???????????????????
      |                ^~
a.cc:17:16: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:17:16: error: empty structured binding declaration
a.cc:17:19: error: expected initializer before 'wpos'
   17 |             int[] wpos = new int[M + 1]; //????????§?¨???????????????????
      |                   ^~~~
a.cc:18:13: error: 'hpos' was not declared in this scope
   18 |             hpos[0] = 0; //???????????§?¨????0??§??????
      |             ^~~~
a.cc:19:13: error: 'wpos' was not declared in this scope
   19 |             wpos[0] = 0; //????????????????????§?¨????0??§??????
      |             ^~~~
a.cc:22:27: error: expected primary-expression before 'int'
   22 |                 hpos[i] = int.Parse(Console.ReadLine()) + hpos[i - 1]; //???????¨????????????§?¨?
      |                           ^~~
a.cc:26:27: error: expected primary-expression before 'int'
   26 |                 wpos[i] = int.Parse(Console.ReadLine()) + wpos[i - 1]; //????????????????????§?¨?
      |                           ^~~
a.cc:31:17: error: 'Console' was not declared in this scope
   31 |                 Console.WriteLine(M);
      |                 ^~~~~~~
a.cc:36:17: error: 'Console' was not declared in this scope
   36 |                 Console.WriteLine(N);
      |                 ^~~~~~~
a.cc:40:13: error: 'List' was not declared in this scope
   40 |             List<int> hlength = new List<int>();
      |             ^~~~
a.cc:40:18: error: expected primary-expression before 'int'
   40 |             List<int> hlength = new List<int>();
      |                  ^~~
a.cc:41:18: error: expected primary-expression before 'int'
   41 |             List<int> wlength = new List<int>();
      |                  ^~~
a.cc:46:21: error: 'hlength' was not declared in this scope
   46 |                     hlength.Add(hpos[j] - hpos[i]);
      |                     ^~~~~~~
a.cc:49:13: error: 'hlength' was not declared in this scope
   49 |             hlength.Sort();
      |             ^~~~~~~
a.cc:54:21: error: 'wlength' was not declared in this scope
   54 |                     wlength.Add(wpos[j] - wpos[i]);
      |                     ^~~~~~~
a.cc:57:13: error: 'wlength' was not declared in this scope
   57 |             wlength.Sort(); //??£?????¢?????????????????¨???????????????????????????hlength??¨wlength?????£??\??????
      |             ^~~~~~~
a.cc:59:13: error: 'Dictionary' was not declared in this scope
   59 |             Dictionary<int,int> hdic = new Dictionary<int, int>();
      |             ^~~~~~~~~~
a.cc:59:24: error: expected primary-expression before 'int'
   59 |             Dictionary<int,int> hdic = new Dictionary<int, int>();
      |                        ^~~
a.cc:60:24: error: expected primary-expression before 'int'
   60 |             Dictionary<int, int> wdic = new Dictionary<int,int>();
      |                        ^~~
a.cc:68:21: error: 'hdic' was not declared in this scope
   68 |                     hdic.Add(hlength[i], 1);
      |                     ^~~~
a.cc:74:21: error: 'hdic' was not declared in this scope
   74 |                     hdic[previous_number] = isrepeated;
      |                     ^~~~
a.cc:85:21: error: 'wdic' was not declared in this scope
   85 |                     wdic.Add(wlength[i],1);
      |                     ^~~~
a.cc:91:21: error: 'wdic' was not declared in this scope
   91 |                     wdic[previous_number] = isrepeated;
      |                     ^~~~
a.cc:97:33: error: 'Math' was not declared in this scope
   97 |             for(int i = 1; i <= Math.Min(hlength[N * (N - 1)-1], wlength[M * (M - 1)-1]);i++)
      |                                 ^~~~
a.cc:99:21: error: 'hdic' was not declared in this scope
   99 |                 if (hdic.ContainsKey(i) & wdic.ContainsKey(i)) sum += hdic[i] * wdic[i];
      |                     ^~~~
a.cc:99:43: error: 'wdic' was not declared in this scope
   99 |                 if (hdic.ContainsKey(i) & wdic.ContainsKey(i)) sum += hdic[i] * wdic[i];
      |                                           ^~~~
a.cc:103:13: error: 'Console' was not declared in this scope
  103 |             Console.WriteLine(sum);
      |             ^~~~~~~