Language: C++

    }
	for (int i = 1; i <= n; i ++) tar[n+1] ^= tar[i];
	if (tar[n+1] != ori[n+1]) ans -= 2;
    for (int i = 1; i <= n+1; i ++)
    {
        a[i] = id[ori[i]];
        b[i] = id[tar[i]];
		vec[b[i]].push_back(i);
    }
	for (int i = 1; i <= kind; i ++)
	{
//		printf("kind %d:\n", i);
		for (int j = 0; j < vec[i].size(); j ++)
		{
//			printf("%d ", vec[i][j]);
			if (j > 0) unite(vec[i][j-1], vec[i][j]);
		}
//		printf("\n");
	}
}
int main()
{
	n = in();
	for (int i = 1; i <= n; i ++) 
    {
        tot[i] = ori[i] = in();
        xsum ^= ori[i];
    }
    ori[n+1] = tot[n + 1] = xsum;
	for (int i = 1; i <= n; i ++) tar[i] = in();
    // /*
    if (judge() == false) 
    {
        printf("-1");
        return 0;
    }
    init();
    for (int i = 1; i <= n+1; i ++)
        if (a[i] == b[i]) vis[i] = true;
		else ans ++;
	for (int i = 1; i <= n+1; i ++)
	{
		unite(i, vec[a[i]][0]);
	}
    for (int i = 1; i <= n+1; i ++)
    {
        if (vis[i]) continue;
        if (fa[i] == i) 
		{
			ans ++;
//			printf("[%d]\n", i);
		}
    }
    cout << ans << endl;
    // */
	return 0;
}
/*
 
5
4 1 3 4 2
1 4 2 3 4
 
6
233 2333 666 233 1234 888 (3117)
666 3117 233 233 888 2333 (1234)
 
6
233 2333 666 888 1234 233
666 3117 233 233 888 2333
*/
 


Compiler output:
a.cc:1:5: error: expected declaration before '}' token
    1 |     }
      |     ^
a.cc:2:9: error: expected unqualified-id before 'for'
    2 |         for (int i = 1; i <= n; i ++) tar[n+1] ^= tar[i];
      |         ^~~
a.cc:2:25: error: 'i' does not name a type
    2 |         for (int i = 1; i <= n; i ++) tar[n+1] ^= tar[i];
      |                         ^
a.cc:2:33: error: 'i' does not name a type
    2 |         for (int i = 1; i <= n; i ++) tar[n+1] ^= tar[i];
      |                                 ^
a.cc:3:9: error: expected unqualified-id before 'if'
    3 |         if (tar[n+1] != ori[n+1]) ans -= 2;
      |         ^~
a.cc:4:5: error: expected unqualified-id before 'for'
    4 |     for (int i = 1; i <= n+1; i ++)
      |     ^~~
a.cc:4:21: error: 'i' does not name a type
    4 |     for (int i = 1; i <= n+1; i ++)
      |                     ^
a.cc:4:31: error: 'i' does not name a type
    4 |     for (int i = 1; i <= n+1; i ++)
      |                               ^
a.cc:10:9: error: expected unqualified-id before 'for'
   10 |         for (int i = 1; i <= kind; i ++)
      |         ^~~
a.cc:10:25: error: 'i' does not name a type
   10 |         for (int i = 1; i <= kind; i ++)
      |                         ^
a.cc:10:36: error: 'i' does not name a type
   10 |         for (int i = 1; i <= kind; i ++)
      |                                    ^
a.cc:20:1: error: expected declaration before '}' token
   20 | }
      | ^
a.cc: In function 'int main()':
a.cc:23:9: error: 'n' was not declared in this scope
   23 |         n = in();
      |         ^
a.cc:23:13: error: 'in' was not declared in this scope; did you mean 'int'?
   23 |         n = in();
      |             ^~
      |             int
a.cc:26:9: error: 'tot' was not declared in this scope
   26 |         tot[i] = ori[i] = in();
      |         ^~~
a.cc:26:18: error: 'ori' was not declared in this scope
   26 |         tot[i] = ori[i] = in();
      |                  ^~~
a.cc:27:9: error: 'xsum' was not declared in this scope
   27 |         xsum ^= ori[i];
      |         ^~~~
a.cc:29:5: error: 'ori' was not declared in this scope
   29 |     ori[n+1] = tot[n + 1] = xsum;
      |     ^~~
a.cc:29:16: error: 'tot' was not declared in this scope
   29 |     ori[n+1] = tot[n + 1] = xsum;
      |                ^~~
a.cc:29:29: error: 'xsum' was not declared in this scope
   29 |     ori[n+1] = tot[n + 1] = xsum;
      |                             ^~~~
a.cc:30:39: error: 'tar' was not declared in this scope
   30 |         for (int i = 1; i <= n; i ++) tar[i] = in();
      |                                       ^~~
a.cc:32:9: error: 'judge' was not declared in this scope
   32 |     if (judge() == false)
      |         ^~~~~
a.cc:34:9: error: 'printf' was not declared in this scope
   34 |         printf("-1");
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 |     }
a.cc:37:5: error: 'init' was not declared in this scope; did you mean 'int'?
   37 |     init();
      |     ^~~~
      |     int
a.cc:39:13: error: 'a' was not declared in this scope
   39 |         if (a[i] == b[i]) vis[i] = true;
      |             ^
a.cc:39:21: error: 'b' was not declared in this scope
   39 |         if (a[i] == b[i]) vis[i] = true;
      |                     ^
a.cc:39:27: error: 'vis' was not declared in this scope
   39 |         if (a[i] == b[i]) vis[i] = true;
      |                           ^~~
a.cc:40:22: error: 'ans' was not declared in this scope
   40 |                 else ans ++;
      |                      ^~~
a.cc:43:26: error: 'vec' was not declared in this scope
   43 |                 unite(i, vec[a[i]][0]);
      |                          ^~~
a.cc:43:30: error: 'a' was not declared in this scope
   43 |                 unite(i, vec[a[i]][0]);
      |                              ^
a.cc:43:17: error: 'unite' was not declared in this scope
   43 |                 unite(i, vec[a[i]][0]);
      |                 ^~~~~
a.cc:47:13: error: 'vis' was not declared in this scope
   47 |         if (vis[i]) continue;
      |             ^~~
a.cc:48:13: error: 'fa' was not declared in this scope
   48 |         if (fa[i] == i)
      |             ^~
a.cc:50:25: error: 'ans' was not declared in this scope
   50 |                         ans ++;
      |                         ^~~
a.cc:54:5: error: 'cout' was not declared in this scope
   54 |     cout << ans << endl;
      |     ^~~~
a.cc:54:13: error: 'ans' was not declared in this scope
   54 |     cout << ans << endl;
      |             ^~~
a.cc:54:20: error: 'endl' was not declared in this scope
   54 |     cout << ans << endl;
      |                    ^~~~