Language: C++

#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e4+10;
namespace Random {
ui X, Y, Z, W;
void start() {
    srand ( (ui) time (NULL) );
    X = rand(), Y = X ^ rand(), Z = Y ^ rand();
}
ui RNG61() {
    X = X ^ (X << 11);
    X = X ^ (X >> 4);
    X = X ^ (X << 5);
    X = X ^ (X >> 14);
    W = X ^ Y ^ Z;
    X = Y;
    Y = Z;
    Z = W;
    return Z;
}
int Randint (int mod) {return RNG61() % mod + 1;}
ll Randll(ll mod) {return ((ull)RNG61() << 32 | RNG61()) % mod + 1;}
double Randdouble(int l, int r) {
    if(l == r) return l;
    if(l > r) swap(l, r);
    double ret = RNG61() % (r - l) + l;
    double tmp = RNG61();
    while(tmp > 0) tmp /= 10;
    ret += tmp;
    while(ret > r) ret -= 1;
    return ret;
}
}
int n;
char a[1000010];
short f[maxn][maxn];

int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	start();
	cin>>n;
	scanf("%s",a+1);
	if(n>=1e4){
		cour<<randint(2)-1<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++) f[1][i]=a[i]-'0';
	for(int i=2;i<=n;i++){
		for(int j=1;j<=n-i+1;j++){
			f[i][j]=abs(f[i-1][j]-f[i-1][j+1]);
		}
	}
	cout<<f[n][1]<<endl;
	return 0;
}
/*
a[1] a[2] a[3] a[4]
(a[1]-a[2]) (a[2]-a[3]) a[3]-a[4]
(a[1]-a[2])-(a[2]-a[3]) (a[2]-a[3])-(a[3]-a[4]);
1 2 3
0 1 2
0 1 2
1,2,0,2,2,1,1,2,1
*/

Compiler output:
a.cc:15:1: error: 'ui' does not name a type; did you mean 'fi'?
   15 | ui X, Y, Z, W;
      | ^~
      | fi
a.cc: In function 'void Random::start()':
a.cc:17:14: error: 'ui' was not declared in this scope; did you mean 'fi'?
   17 |     srand ( (ui) time (NULL) );
      |              ^~
      |              fi
a.cc:18:5: error: 'X' was not declared in this scope
   18 |     X = rand(), Y = X ^ rand(), Z = Y ^ rand();
      |     ^
a.cc:18:17: error: 'Y' was not declared in this scope
   18 |     X = rand(), Y = X ^ rand(), Z = Y ^ rand();
      |                 ^
a.cc:18:33: error: 'Z' was not declared in this scope
   18 |     X = rand(), Y = X ^ rand(), Z = Y ^ rand();
      |                                 ^
a.cc: At global scope:
a.cc:20:1: error: 'ui' does not name a type; did you mean 'fi'?
   20 | ui RNG61() {
      | ^~
      | fi
a.cc: In function 'int Random::Randint(int)':
a.cc:31:31: error: 'RNG61' was not declared in this scope
   31 | int Randint (int mod) {return RNG61() % mod + 1;}
      |                               ^~~~~
a.cc: In function 'long long int Random::Randll(long long int)':
a.cc:32:29: error: 'ull' was not declared in this scope; did you mean 'll'?
   32 | ll Randll(ll mod) {return ((ull)RNG61() << 32 | RNG61()) % mod + 1;}
      |                             ^~~
      |                             ll
a.cc:32:33: error: expected ')' before 'RNG61'
   32 | ll Randll(ll mod) {return ((ull)RNG61() << 32 | RNG61()) % mod + 1;}
      |                           ~     ^~~~~
      |                                 )
a.cc: In function 'double Random::Randdouble(int, int)':
a.cc:36:18: error: 'RNG61' was not declared in this scope
   36 |     double ret = RNG61() % (r - l) + l;
      |                  ^~~~~
a.cc: In function 'int main()':
a.cc:51:9: error: 'start' was not declared in this scope; did you mean 'Random::start'?
   51 |         start();
      |         ^~~~~
      |         Random::start
a.cc:16:6: note: 'Random::start' declared here
   16 | void start() {
      |      ^~~~~
a.cc:55:17: error: 'cour' was not declared in this scope
   55 |                 cour<<randint(2)-1<<endl;
      |                 ^~~~
a.cc:55:23: error: 'randint' was not declared in this scope; did you mean 'rint'?
   55 |                 cour<<randint(2)-1<<endl;
      |                       ^~~~~~~
      |                       rint