Language: C++

#include <iostream>
#include <fstream>                        //  ifstream, ofstream
#include <vector>
#include <algorithm>
using namespace std;
enum state {
	none = 0,
	r = 1,
	g = 3,
	b = 2
};
class towwer {
public:
	int N;
	char data[18/4 * 10000000000];
	towwer(int n) {
		N = n;
		memset(data, 0, sizeof(data));
	}
	towwer(int n,int p) {
		N = n;
		memset(data, 0, sizeof(data));
		for (n = 0; n < N; n++) {
			int n2 = n / 4;
			int n1 = n % 4;
			char d = (p >> (4 * n)) & 0x3;
			data[n2] = d<< (4 * n1);
		}
	}
	state getTowerState(int n) {
		int n2 = n / 4;
		int n1 = n % 4;
		return (state)(data[n2] >> (4 * n1));
	}
	int getScore(int a,int b) {
		int score = 0;
		for (int i = 0; i < N; i++) {
			state s=getTowerState(i);
			score += a * (((int)s) & 1 ? 1 : 0);
			score += b * (((int)s) & 2 ? 1 : 0);
		}
		return score;
	}
	bool operator == (towwer b) {
		if (N != b.N)return false;
		for (int i = 0; i < (N + 1) / 2; i++) {
			if (data[i] != b.data[i])return false;
		}
		return true;
	}
};

//void mainB() {
//	int N,A,B,K;
//	int magic = 998244353;
//	cin >> N >> A  >> B >> K ;
//	vector<towwer> tcorrection;
//	for (int pattern = 0; pattern < N; pattern++) {
//		bool find0 = false;
//		for (int n = 0; n < N; n++) {
//			if (((pattern >> (4 * n)) & 0x3) == 0) {
//				find0 = true;
//				break;
//			}
//		}
//		if (!find0) {
//			towwer t(N, pattern);
//			int score = t.getScore(A, B);
//			if (score == K) {
//				if(
//					find(tcorrection.begin(), tcorrection.end(), t)
//					==tcorrection.end())
//					tcorrection.push_back(t);
//			}
//		}
//	}
//	int result = tcorrection.size();
//	result %= 998244353;
//	cout << result;
//	//
//	return;
//}
char S[1000000];
char T[1000000];
bool coutValue_(int v) {
	if (v <= 0)return false;
	bool printing = coutValue_(v >> 1);
	if (printing || v & 1) {
		cout << (v & 1);
		return true;
	}
	return false;
}
void coutValue(int v) {
	coutValue_(v);
	cout << endl;
}
void mainF() {
	int N, M, K;
	cin >> N >> M >> K;
	cin >> S;
	cin >> T;
	int X = 0, Y = 0;
	for (int n=0; n < N; n++) {
		X |= (S[n] == '0' ? 0 : 1) << n;
		//cout << X << endl;
	}
	for (int m=0; m < M; m++) {
		Y |= (T[m] == '0' ? 0 : 1) << m;
		//cout << Y << endl;
	}
	//cout << endl;
	//cout << X << " " << Y << endl;
	for (int k = 0; k < K; k++) {
		int Z = X & Y;
		X += Z;
		Y += Z;
		//cout <<Z <<"+"<< X << " " << Y << endl;
	}
	//
	//cout << " ";
	//cout << N << M << K << endl;
	//cout << X << endl;
	//cout << Y << endl;
	coutValue(X);
	coutValue(Y);
}

int main()
{
	mainF();
	return 0;
}


Compiler output:
a.cc: In constructor 'towwer::towwer(int)':
a.cc:18:17: error: 'memset' was not declared in this scope
   18 |                 memset(data, 0, sizeof(data));
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <algorithm>
  +++ |+#include <cstring>
    5 | using namespace std;
a.cc: In constructor 'towwer::towwer(int, int)':
a.cc:22:17: error: 'memset' was not declared in this scope
   22 |                 memset(data, 0, sizeof(data));
      |                 ^~~~~~
a.cc:22:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'