//written by deepseek-r1
#include <stdio.h>
#include <stdlib.h>
void solve(int n, int q, char *s1, char *s2, int *q_x, int *q_y, int *q_len, unsigned *ans) {
// Preprocess the two strings into integer arrays
int *a1 = (int*)malloc(n * sizeof(int));
int *a2 = (int*)malloc(n * sizeof(int));
for (int i = 0; i < n; ++i) {
a1[i] = s1[i] - '0';
a2[i] = s2[i] - '0';
}
// Process each query
for (int i = 0; i < q; ++i) {
int x = q_x[i];
int y = q_y[i];
int l = q_len[i];
unsigned sum = 0;
int *p1 = a1 + x;
int *p2 = a2 + y;
// Loop through the range and check each pair
for (int k = 0; k < l; ++k) {
int a = p1[k];
int b = p2[k];
sum += ( (a == 0 && b == 1) || (a == 1 && b == 2) || (a == 2 && b == 0) );
}
ans[i] = sum;
}
free(a1);
free(a2);
}