Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int p = 998244353;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
const int m = 4010;
#define bs bitset<m>
int kai_size = 400001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4); 
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int per(int n, int r) {
	int ans = kai[n] * ink[n - r];
	ans %= p;
	return ans;
}
vel rui(m + 10, 1);
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}
int max_true(bs &a,int jou) {
	int ans = jou;
	rep(i, jou) {
		if (a[i]) { ans = i; }
	}
	return ans;
}
bool can_div(bs &a, bs b, int &sza, int szb) {
	for (int i = sza; i >= szb; i--) {
		if (a[i]) {
			a ^= b << (i - szb);
		}
	}
	sza = max_true(a, szb);
	if (sza == szb) { return true; }
	return false;
}
bs gcd(bs a, bs b) {
	int sza = max_true(a,m);
	int szb = max_true(b,m);
	if (sza < szb) { swap(sza, szb); swap(a, b); }
	while (true) {
		if (can_div(a, b, sza, szb)) { return b; }
		if (can_div(b, a, szb, sza)) { return a; }
	}
}
void solve(bs &x, bs &a) {
	int szx = max_true(x,m);
	int sza = max_true(a,m);
	bs to;
	rep(i, m) { ans[i] = 0; }
	int ans = 0;
	for (int i = szx; i >= sza; i--) {
		if (x[i]) {
			ans += rui[i - sza];
		}
		if (x[i] != to[i]) {
			to ^= a << (i - sza);
		}
	}
	cout << (ans + 1)%p << endl;
}
bs mak(string s) {
	rev(s);
	bs ans;
	rep(i, m) { ans[i] = 0; }
	rep(i, s.size()) {
		ans[i] = (s[i] == '1');
	}
	return ans;
}
signed main() {
	while (true) {
		int n; cin >> n;
		string x; cin >> x;
		string s; cin >> s;
		bs gcd0 = mak(s);
		rep(i, n - 1) {
			string ne; cin >> ne;
			bs newb = mak(ne);
			gcd0 = gcd(newb, gcd0);
		}
		bs nw = mak(x);
		rep(i, m + 9) { rui[i + 1] = rui[i] * 2; rui[i + 1] %= p; }
		solve(nw, gcd0);
	}
	return 0;
}


Compiler output:
a.cc: In function 'void solve(std::bitset<4010>&, std::bitset<4010>&)':
a.cc:115:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
  115 |         rep(i, m) { ans[i] = 0; }
      |                     ^~~
      |                     abs