Language: C++

#include <iostream>
#include <map>
using namespace std;

const int size = 101;
int G[size][size];
int C[size];
map <int, int> M;
int M_index;
bool flag;

void set_index( int a ) 
{
  if ( M.find( a ) != M.end() ) return;
  M[a] = M_index; 
  M_index++;
}

void init()
{
  memset( G, 0, sizeof(G) );
  memset( C, 0, sizeof(C) );
  M.clear();
  flag = false;
}

int main( void ) 
{
  int a, b;
  flag = true;
  while ( cin >> a >> b ) {
    if ( a == 0 && b == 0 ) {
      for ( int i = 0; i < size; i++ ) {
        for ( int j = 0; j < size; j++ ) {
          if ( G[i][j] > 0 ) C[i] += G[i][j];
        }
      }
      bool ok = true;
      int start = M[1], goal = M[2];
      for ( int i = 0; i < size; i++ ) {
        if ( !C[i] ) continue;
        if ( i == start || i == goal ) {
          if ( C[i] % 2 == 0 ) ok = false;
        } else {
          if ( C[i] % 2 != 0 ) ok = false;
        }
      }
      // output
      cout << ( ok ? "OK" : "NG" ) << endl;
      flag = true;
    } else {
      if ( flag ) {
        init();
      }
      set_index( a );
      set_index( b );
      int index_a = M[a], index_b = M[b];
      G[index_a][index_b]++;
      G[index_b][index_a]++;
    }
  }
  return 0;
}

Compiler output:
a.cc:6:7: error: reference to 'size' is ambiguous
    6 | int G[size][size];
      |       ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:11: note:                 'const int size'
    5 | const int size = 101;
      |           ^~~~
a.cc:6:13: error: reference to 'size' is ambiguous
    6 | int G[size][size];
      |             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:11: note:                 'const int size'
    5 | const int size = 101;
      |           ^~~~
a.cc:7:7: error: reference to 'size' is ambiguous
    7 | int C[size];
      |       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:11: note:                 'const int size'
    5 | const int size = 101;
      |           ^~~~
a.cc: In function 'void init()':
a.cc:21:11: error: 'G' was not declared in this scope
   21 |   memset( G, 0, sizeof(G) );
      |           ^
a.cc:21:3: error: 'memset' was not declared in this scope
   21 |   memset( G, 0, sizeof(G) );
      |   ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <map>
  +++ |+#include <cstring>
    3 | using namespace std;
a.cc:22:11: error: 'C' was not declared in this scope
   22 |   memset( C, 0, sizeof(C) );
      |           ^
a.cc: In function 'int main()':
a.cc:33:28: error: reference to 'size' is ambiguous
   33 |       for ( int i = 0; i < size; i++ ) {
      |                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:11: note:                 'const int size'
    5 | const int size = 101;
      |           ^~~~
a.cc:34:30: error: reference to 'size' is ambiguous
   34 |         for ( int j = 0; j < size; j++ ) {
      |                              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:11: note:                 'const int size'
    5 | const int size = 101;
      |           ^~~~
a.cc:35:16: error: 'G' was not declared in this scope
   35 |           if ( G[i][j] > 0 ) C[i] += G[i][j];
      |                ^
a.cc:35:30: error: 'C' was not declared in this scope
   35 |           if ( G[i][j] > 0 ) C[i] += G[i][j];
      |                              ^
a.cc:40:28: error: reference to 'size' is ambiguous
   40 |       for ( int i = 0; i < size; i++ ) {
      |                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:11: note:                 'const int size'
    5 | const int size = 101;
      |           ^~~~
a.cc:41:15: error: 'C' was not declared in this scope
   41 |         if ( !C[i] ) continue;
      |               ^
a.cc:43:16: error: 'C' was not declared in this scope
   43 |           if ( C[i] % 2 == 0 ) ok = false;
      |                ^
a.cc:45:16: error: 'C' was not declared in this scope
   45 |           if ( C[i] % 2 != 0 ) ok = false;
      |                ^
a.cc:58:7: error: 'G' was not declared in this scope
   58 |       G[index_a][index_b]++;
      |       ^