#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(Complex *a, bool inverse, int n) {
//    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex &u = a[Ek];
                Complex &v = a[Ok];
                Complex t = w*a[Ok];
                v = u-t;
                u = u+t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp, a[i].y = a[i].y/n+esp;
}
int xx[240][maxn];
char sa[maxn], sb[maxn];

int read() {
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9');
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}
Complex sA[maxn<<2], sB[maxn<<2];

int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = sqrt(25*n);
    int S1 = m, S2 = L;
    int S = 2;
    while(S < S1+S2) S <<= 1;
//    vector<Complex> sA(S, Complex(0.0, 0.0)), sB(S, Complex(0.0, 0.0));
    for(int i = 0; i < m; i++)
        b[0][i] = sb[i] - '0';
    for(int i = 0; i < n; i++)
        b[1][i] = sa[i] - '0';
    for(int i = 0; i < S1; i++)
        sA[i] = Complex(b[0][i], !b[0][i]);
    FFT(sA, false, S);

    for(int i = 0; i <= n-L; i += L) {
        for(int j = 0; j < L && i+j < n; j++)
            sB[L-1-j] = Complex(b[1][j+i], !b[1][j+i]);
        for(int j = L; j < S; j++)
            sB[j] = Complex(0.0, 0.0);
        FFT(sB, false, S);
        for(int j = 0; j < S; j++)
            sB[j] = sA[j] * sB[j];
        FFT(sB, true, S);
        for(int j = 0; j <= S1-S2; j++)
            xx[i/L][j] = (int)(sB[j+S2-1].y+.5);
    }
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int ans = 0;
        int x, y, z;
        x = read(), y = read(), z = read();
        while(x%L && z > 0) {
            ans += (sa[x]!=sb[y]);
            x++, y++, z--;
        }
        for(; L < z; x += L, z -= L, y += L) {
            ans += xx[x/L][y];
        }
//        cout << ans << endl;
        while(z > 0) {
            ans += (sa[x] != sb[y]);
            z--;
            x++, y++;
        }
        printf("%d\n", ans);
    }

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi 3.1415926
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(Complex *a, bool inverse, int n) {
//    int n = a.size();
//    bug(n)
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
int L;
short xx[500][maxn];
char sa[maxn], sb[maxn];
void solve() {
    static Complex p1[maxn<<1], p2[maxn<<1];
    L = 3000;
    int n = strlen(sa), m = strlen(sb);
    int S1 = L, S2 = m;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    for(int i = 0; i < S; i++)
        if(i < m)
        p2[i] = Complex(sb[m-1-i] == '0', sb[m-1-i] == '1');
        else p2[i] = Complex(0.0, 0.0);
    FFT(p2, false, m);
    for(int i = 0, id = 0; i+L <= n; i++, id++) {

        for(int j = L; j < S; j++)
            p1[j] = Complex(.0, .0);
        for(int j = 0; j < L; j++)
            p1[j] = Complex(sa[i+j] == '0', sa[i+j] == '1');
//        FFT(sa, false, S);
        FFT(p1, false, L);
        for(int j = 0; j < S; j++)
            p1[j] = p1[j] * p2[j];
        FFT(p1, true, S);
        for(int j = 0; j < m; j++)
            xx[id][j] = int(p1[m-1-j].y+.5);
    }
}

inline int read() {
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9')
        ;
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}
int main() {
//in
    scanf("%s%s", sa, sb);
//    int n = strlen(sa);
//    int m = strlen(sb);

    solve();
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        x = read(), y = read(), z = read();
        int st = x, ed = x+z-1;
        int ans = 0;
        if(x/L == (x+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = y+(st%L != 0 ? L-st%L : 0);
            int tmp = ed/L-((ed+1)%L != 0);
            for(int i = st/L+(st%L != 0); i <= tmp; i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse, int n) {
//    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex &u = a[Ek];
                Complex &v = a[Ok];
                Complex t = w*a[Ok];
                v = u-t;
                u = u+t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp, a[i].y = a[i].y/n+esp;
}
short xx[500][maxn];
char sa[maxn], sb[maxn];

int read() {
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9');
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}

int main() {
//in
    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = sqrt(n*16);
    int S1 = m, S2 = L;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sA(S, Complex(0.0, 0.0)), sB(S, Complex(0.0, 0.0));
    for(int i = 0; i < m; i++)
        b[0][i] = sb[i] - '0';
    for(int i = 0; i < n; i++)
        b[1][i] = sa[i] - '0';
    for(int i = 0; i < S1; i++)
        sA[i] = Complex(b[0][i], !b[0][i]);
    FFT(sA, false, S);

    for(int i = 0; i <= n-L; i += L) {
        for(int j = 0; j < L && i+j < n; j++)
            sB[L-1-j] = Complex(b[1][j+i], !b[1][j+i]);
        for(int j = L; j < S; j++)
            sB[j] = Complex(0.0, 0.0);
        FFT(sB, false, S);
        for(int j = 0; j < S; j++)
            sB[j] = sA[j] * sB[j];
        FFT(sB, true, S);
        for(int j = 0; j <= S1-S2; j++)
            xx[i/L][j] = (int)(sB[j+S2-1].y+.5);
    }
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int ans = 0;
        int x, y, z;
        x = read(), y = read(), z = read();
        while(x%L && z > 0) {
            ans += (sa[x]!=sb[y]);
            x++, y++, z--;
        }
        for(; L < z; x += L, z -= L, y += L) {
            ans += xx[x/L][y];
        }
//        cout << ans << endl;
        while(z > 0) {
            ans += (sa[x] != sb[y]);
            z--;
            x++, y++;
        }
        printf("%d\n", ans);
    }

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp, a[i].y = a[i].y/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i] = Complex(b[0][i], !b[0][i]);
    for(int i = 0; i < S2; i++)
        sb[i] = Complex(b[1][S2-1-i], !b[1][S2-1-i]);
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++)
           res[i] = (int)(sa[i+S2-1].y+.5);
}
char sa[maxn], sb[maxn];
int read() {
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9');
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}
int main() {
//in
    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = sqrt(n*16);
    for(int i = 0; i < m; i++)
        b[0][i] = sb[i] - '0';
    for(int i = 0; i < n; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < n; j++, len++)
            b[1][j] = sa[i+j] - '0';
        solve(m, len, xx[i/L]);
    }
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int ans = 0;
        int x, y, z;
        x = read(), y = read(), z = read();
        while(x%L && z > 0) {
            ans += (sa[x]!=sb[y]);
            x++, y++, z--;
        }
        for(; L < z; x += L, z -= L, y += L) {
            ans += xx[x/L][y];
        }
//        cout << ans << endl;
        while(z > 0) {
            ans += (sa[x] != sb[y]);
            z--;
            x++, y++;
        }
        printf("%d\n", ans);
    }

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
int xx[500][maxn];

void solve(const bitset<maxn> &a, int len1, const bitset<maxn> &b, int len2, int res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = a[i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = round(sa[i+S2-1].x);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];

int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = (int)sqrt(m) + 1;
    int nn = m/L;
    for(int i = 0; i < n; i++)
        b[0][i] = sa[i] == '1';
    for(int i = 0; i < m; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < m; j++, len++)
            b[1][j] = sb[i+j] == '1';
        solve(b[0], n, b[1], len, xx[i/L]);
    }
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        int st = y, ed = y+z-1;
        int ans = 0;
        if(y/L == (y+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = x+(st%L != 0 ? L-st%L : 0);
            for(int i = st/L+(st%L != 0); i <= ed/L-((ed+1)%L != 0); i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = round(sa[i+S2-1].x);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];

int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = min(m, (int)sqrt(16*m) + 1);
    int nn = m/L;
    for(int i = 0; i < n; i++)
        b[0][i] = sa[i] - '0';
    for(int i = 0; i < m; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < m; j++, len++)
            b[1][j] = sb[i+j] - '0';
        solve(n, len, xx[i/L]);
    }

    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        int st = y, ed = y+z-1;
        int ans = 0;
        if(y/L == (y+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = x+(st%L != 0 ? L-st%L : 0);
            for(int i = st/L+(st%L != 0); i <= ed/L-((ed+1)%L != 0); i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi 3.1415926
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse, int n) {
//    int n = a.size();
//    bug(n)
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];
vector<Complex> ssa(maxn*2, Complex(0.0, 0.0)), ssb(maxn*2, Complex(0.0, 0.0));
void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
//
    ssa.resize(S, Complex(0.0, 0.0));
    ssb.resize(S, Complex(0.0, 0.0));
//    for(int i = 0; i < S; i++)
//        ssa[i] = ssb[i] = Complex(0.0, 0.0);
    for(int i = 0; i < S1; i++)
        ssa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        ssb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(ssa, false, S);
//    bug(1\)
    FFT(ssb, false, S);
    for(int i = 0; i < S; i++)
        ssa[i] = ssa[i] * ssb[i];
    FFT(ssa, true, S);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = int(ssa[i+S2-1].x+.5);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];
int read(){
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9')
        ;
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}
int main() {
//in
    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = min(n, 2000);
//    bug(1)
    for(int i = 0; i < m; i++)
        b[0][i] = sb[i] - '0';
    for(int i = 0; i < n; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < n; j++, len++)
            b[1][j] = sa[i+j] - '0';
        solve(m, len, xx[i/L]);
//        bug(1)
    }
//    bug(1)
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        x = read(), y = read(), z = read();
        int st = x, ed = x+z-1;
        int ans = 0;
        if(x/L == (x+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = y+(st%L != 0 ? L-st%L : 0);
            int tmp = ed/L-((ed+1)%L != 0);
            for(int i = st/L+(st%L != 0); i <= tmp; i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = int(sa[i+S2-1].x+.5);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];
int read(){
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9')
        ;
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}
int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = min(n, (int)sqrt(n*16));
    for(int i = 0; i < m; i++)
        b[0][i] = sb[i] - '0';
    for(int i = 0; i < n; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < n; j++, len++)
            b[1][j] = sa[i+j] - '0';
        solve(m, len, xx[i/L]);
    }

    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        x = read(), y = read(), z = read();
        int st = x, ed = x+z-1;
        int ans = 0;
        if(x/L == (x+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = y+(st%L != 0 ? L-st%L : 0);
            for(int i = st/L+(st%L != 0); i <= ed/L-((ed+1)%L != 0); i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi 3.1415926
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = int(sa[i+S2-1].x+.5);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];
int read(){
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9')
        ;
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}
int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = min(n, 2000);
    for(int i = 0; i < m; i++)
        b[0][i] = sb[i] - '0';
    for(int i = 0; i < n; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < n; j++, len++)
            b[1][j] = sa[i+j] - '0';
        solve(m, len, xx[i/L]);
    }

    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        x = read(), y = read(), z = read();
        int st = x, ed = x+z-1;
        int ans = 0;
        if(x/L == (x+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = y+(st%L != 0 ? L-st%L : 0);
            int tmp = ed/L-((ed+1)%L != 0);
            for(int i = st/L+(st%L != 0); i <= tmp; i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(const bitset<maxn> &a, int len1, const bitset<maxn> &b, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = a[i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = round(sa[i+S2-1].x);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];

int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = (int)sqrt(m) + 1;
    int nn = m/L;
    for(int i = 0; i < n; i++)
        b[0][i] = sa[i] == '1';
    for(int i = 0; i < m; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < m; j++, len++)
            b[1][j] = sb[i+j] == '1';
        solve(b[0], n, b[1], len, xx[i/L]);
    }
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        int st = y, ed = y+z-1;
        int ans = 0;
        if(y/L == (y+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = x+(st%L != 0 ? L-st%L : 0);
            for(int i = st/L+(st%L != 0); i <= ed/L-((ed+1)%L != 0); i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define TL cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms" << endl;
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;
int bi[1<<16];
unsigned a[32][maxn/32 + 10], b[32][maxn/32 + 10];
char sa[maxn], sb[maxn];
//int getBit(unsigned x) {
//    return bi[x>>16] + bi[x&((1<<16)-1)];
//}
int getBit(unsigned int x)
{
  x=(x&0x55555555UL)+((x>>1)&0x55555555UL); //1
  x=(x&0x33333333UL)+((x>>2)&0x33333333UL);//2
  x=(x&0x0f0f0f0fUL)+((x>>4)&0x0f0f0f0fUL); //3
  x=(x&0x00ff00ffUL)+((x>>8)&0x00ff00ffUL); //4
  x=(x&0x0000ffffUL)+((x>>16)&0x0000ffffUL);//5
  return x;
}

int getAns(int p, int q, int len) {
    int x = p>>5, y = q>>5;
    int u = p&31, v = q&31;
    int ans = 0, i =0;

    while(i+32 <= len) {
        ans += getBit(a[u][x]^b[v][y]);
        x++, y++;
        i+=32;
    }
    len-=i;
    return ans += getBit((a[u][x]^b[v][y])&((1<<len)-1));

}
int main() {
//    in
    for(int i = 1; i < (1<<16); i++)
        bi[i] = bi[i>>1] + (i&1);
//    cout << bi[31] << endl;
    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    for(int i = 0; i < 32; i++) {
        for(int j = 0; j+i < n; j++)
            if(sa[i+j] == '1')
            a[i][j>>5] |= (1LL<<(j&31));
    }
    for(int i = 0; i < 32; i++) {
        for(int j = 0; j+i < m; j++)
            if(sb[i+j] == '1')
            b[i][j>>5] |= (1LL<<(j&31));
    }
    int qq, p, q, len;
    scanf("%d", &qq);
    while(qq--) {
        scanf("%d%d%d", &p, &q, &len);
        printf("%d\n", getAns(p, q, len));
    }
    TL;
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = round(sa[i+S2-1].x);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];

int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = (int)sqrt(m) + 1;
    int nn = m/L;
    for(int i = 0; i < n; i++)
        b[0][i] = sa[i] == '1';
    for(int i = 0; i < m; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < m; j++, len++)
            b[1][j] = sb[i+j] == '1';
        solve(n, len, xx[i/L]);
    }

    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        int st = y, ed = y+z-1;
        int ans = 0;
        if(n < 10000) {
            if(y/L == (y+z-1)/L) {
                for(int i = 0; i < z; i++)
                    if(sa[i+x] != sb[i+y])
                        ans++;
            } else {
                int base = x+(st%L != 0 ? L-st%L : 0);
                for(int i = st/L+(st%L != 0); i <= ed/L-((ed+1)%L != 0); i++, base += L) {
                    ans += xx[i][base];
                }
                if(st%L)
                    for(int i = 0; i < L-st%L; i++)
                        if(sa[x+i] != sb[y+i])
                            ans++;
                if((ed+1)%L)
                    for(int i = 0; i < ed%L+1; i++)
                        if(sa[x+z-1-i] != sb[y+z-1-i])
                            ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
long long int a[100005];

int main() {
#pragma warning(disable : 4996)
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

	int n;
	int m=0;
	long long int maxy=0;
	long long int miny=1000000005;
	cin>>n;
	for (int i=1; i<=n; i++) {
		scanf("%I64d",&a[i]);
		if (a[i]>maxy)
			maxy=a[i];
		if (a[i]<miny)
			miny=a[i];
	}

	long long int x=(maxy-miny)/2;
	if (miny+2*x!=maxy)
		x=0;
	long long int p=miny+x;
	for (int i=1; i<=n; i++) {
		if (a[i]!=miny && a[i]!=maxy && a[i]!=p) {
			m=1;
			break;
		}
	}
	if (m==0)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
long long int a[100005];

int main() {
#pragma warning(disable : 4996)
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

	int n;
	int m=0;
	long long int maxy=0;
	long long int miny=1000000005;
	cin>>n;
	for (int i=1; i<=n; i++) {
		scanf("%I64d",&a[i]);
		if (a[i]>maxy)
			maxy=a[i];
		if (a[i]<miny)
			miny=a[i];
	}

	long long int x=(maxy-miny)/2;
	long long int p=miny+x;
	for (int i=1; i<=n; i++) {
		if (a[i]!=miny && a[i]!=maxy && a[i]!=p) {
			m=1;
			break;
		}
	}

	if (m==0)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
long long int a[100005];

int main() {
#pragma warning(disable : 4996)
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

	int n;
	int m=0;
	long long int maxy=0;
	long long int miny=1000000005;
	cin>>n;
	for (int i=1; i<=n; i++) {
		scanf("%I64d",&a[i]);
		if (a[i]>maxy)
			maxy=a[i];
		if (a[i]<miny)
			miny=a[i];
	}

	long long int x=(maxy-miny)/2;
	if (miny+2*x!=maxy)
		m=1;
	long long int p=miny+x;
	for (int i=1; i<=n; i++) {
		if (a[i]!=miny && a[i]!=maxy && a[i]!=p) {
			m=1;
			break;
		}
	}

	if (m==0)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
long long int a[100005];

int main() {
#pragma warning(disable : 4996)
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

	int n;
	int m=0;
	long long int maxy=0;
	long long int miny=1000000005;
	cin>>n;
	for (int i=1; i<=n; i++) {
		scanf("%I64d",&a[i]);
		if (a[i]>maxy)
			maxy=a[i];
		if (a[i]<miny)
			miny=a[i];
	}
	if ((maxy-miny)%2!=0)
		m=1;
	long long int x=(maxy-miny)/2;
	long long int p=miny+x;
	for (int i=1; i<=n; i++) {
		if (a[i]+x==p)
			a[i]=a[i]+x;
		else {
			if (a[i]-x==p)
				a[i]=a[i]-x;
		}
	}

	sort(a,a+n+1);
	if (a[1]==a[n] && m==0)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <locale>
#include <windows.h>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll mas[5],i,j=-1,n,a,m=0;
    bool q;
    cin>>n;
    for (i=0; i<n; i++)
    {
        cin>>a;
        if (m<4)
        {
            q=1;
            for (j=0; j<m; j++)
                if (a==mas[j])
                    q=0;
            if (q)
            {
                mas[m]=a;
                m++;
            }
        }
    }
    if (m>3)
    {
        cout<<"NO";
        return 0;
    }
    sort(mas,mas+m);
    if (m==1 || m==2)
    {
        cout<<"YES";
        return 0;
    }
    if (mas[2]-mas[1]==mas[2]-mas[0])
    {
        cout<<"YES";
        return 0;
    }
    cout<<"NO";
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <locale>
#include <windows.h>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll mas[5],i,j=-1,n,a,m=0;
    bool q;
    cin>>n;
    for (i=0; i<n; i++)
    {
        cin>>a;
        if (m<4)
        {
            q=1;
            for (j=0; j<m; j++)
                if (a==mas[j])
                    q=0;
            if (q)
            {
                mas[m]=a;
                m++;
            }
        }
    }
    if (m>3)
    {
        cout<<"NO";
        return 0;
    }
    sort(mas,mas+m);
    if (m==1)
    {
        cout<<"YES";
        return 0;
    }
    if (m==2 && (mas[0]*2==mas[1] || mas[0]*2==mas[1]-mas[0]|| mas[0]==0))
    {
        cout<<"YES";
        return 0;
    }
    if (m==3 && (mas[0]*2==mas[1] && mas[2]-mas[0]==mas[0]*2 || mas[0]==0 && 2*mas[1]==mas[2]))
    {
        cout<<"YES";
        return 0;
    }
    cout<<"NO";
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <locale>
#include <windows.h>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll mas[5],i,j=-1,n,a,m=0;
    bool q;
    cin>>n;
    for (i=0; i<n; i++)
    {
        cin>>a;
        if (m<4)
        {
            q=1;
            for (j=0; j<m; j++)
                if (a==mas[j])
                    q=0;
            if (q)
            {
                mas[m]=a;
                m++;
            }
        }
    }
    if (m>3)
    {
        cout<<"NO";
        return 0;
    }
    sort(mas,mas+m);
    if (m==1 || m==2)
    {
        cout<<"YES";
        return 0;
    }
    if (mas[2]-mas[1]==mas[1]-mas[0])
    {
        cout<<"YES";
        return 0;
    }
    cout<<"NO";
    return 0;
}


// IN THE NAME OF GOD

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <list>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN= 1e5 + 22 ;
const ll INF = ll(1e18) + 22 ;
const int MOD = 1e9 + 7 ;

#define pb push_back
#define mp make_pair

int add_mod (int ttt , int rrr)
{
	ttt += rrr;
	ttt %= MOD;
	return ttt;
}

int n,q;
set <int> s;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++)
	{
		cin >> q;
		s.insert(q) ;
	}
	if(s.size() > 3)
		cout << "NO" ;
	else if (s.size() <= 2)

		cout << "YES" ;
	else
	{
		set<int>::iterator x = s.begin() ;
		s.erase(x);
		set<int>::iterator y = s.begin() ;
		s.erase(y);
		set<int>::iterator z = s.begin() ;
		if(*z * 2 == *x + *z)
			cout << "YES" ;
		else
			cout << "NO" ;
	}

	return 0;
}


// IN THE NAME OF GOD

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <list>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN= 1e5 + 22 ;
const ll INF = ll(1e18) + 22 ;
const int MOD = 1e9 + 7 ;

#define pb push_back
#define mp make_pair

int add_mod (int ttt , int rrr)
{
	ttt += rrr;
	ttt %= MOD;
	return ttt;
}

int n,q;
set <int> s;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++)
	{
		cin >> q;
		s.insert(q) ;
	}
	if(s.size() > 3)
		cout << "NO" ;
	else
	{
		if (s.size() == 1)
		{
			cout << "YES" ;
			return 0 ;
		}
		if (s.size() == 2)
		{
			set<int>::iterator x = s.begin() ;
			s.erase(x);
			set<int>::iterator y = s.begin() ;
			if( int (*x) * 2 == int (*y))
				cout << "YES" ;
			else
				cout << "NO" ;
			return 0 ;
		}
		set<int>::iterator x = s.begin() ;
		s.erase(x);
		set<int>::iterator y = s.begin() ;
		s.erase(y);
		set<int>::iterator z = s.begin() ;

		if(int(*x) * 2 == int(*y) && int(*x) * 3 == int(*z))
			cout << "YES" ;
		else
			cout << "NO" ;
	}

	return 0;
}


// IN THE NAME OF GOD

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <list>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN= 1e5 + 22 ;
const ll INF = ll(1e18) + 22 ;
const int MOD = 1e9 + 7 ;

#define pb push_back
#define mp make_pair

int add_mod (int ttt , int rrr)
{
	ttt += rrr;
	ttt %= MOD;
	return ttt;
}

int n,q;
set <int> s;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++)
	{
		cin >> q;
		s.insert(q) ;
	}
	if(s.size() > 3)
		cout << "NO" ;
	else
	{
		if (s.size() <= 2)
		{
			cout << "YES" ;
			return 0 ;
		}
		/*
		if (s.size() == 2)
		{
			set<int>::iterator x = s.begin() ;
			s.erase(x);
			set<int>::iterator y = s.begin() ;
			if( int (*x) * 2 == int (*y) || int (*x) * 3 == int (*y))
				cout << "YES" ;
			else
				cout << "NO" ;
			return 0 ;
		}
		*/
		set<int>::iterator x = s.begin() ;
		s.erase(x);
		set<int>::iterator y = s.begin() ;
		s.erase(y);
		set<int>::iterator z = s.begin() ;

		if(int(*x) * 2 == int(*y) && int(*x) * 3 == int(*z))
			cout << "YES" ;
		else
			cout << "NO" ;
	}

	return 0;
}


// IN THE NAME OF GOD

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <list>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN= 1e5 + 22 ;
const ll INF = ll(1e18) + 22 ;
const int MOD = 1e9 + 7 ;

#define pb push_back
#define mp make_pair

int add_mod (int ttt , int rrr)
{
	ttt += rrr;
	ttt %= MOD;
	return ttt;
}

int n,q;
set <int> s;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++)
	{
		cin >> q;
		s.insert(q) ;
	}
	if(s.size() > 3)
		cout << "NO" ;
	else
	{
		set<int>::iterator x = s.begin() ;
		s.erase(x);
		set<int>::iterator y = s.begin() ;
		s.erase(y);
		set<int>::iterator z = s.begin() ;

		if(int(*x) * 2 == int(*y) && int(*x) * 3 == int(*z))
			cout << "YES" ;
		else
			cout << "NO" ;
		// cout << *x << *y << *z;
	}

	return 0;
}


// IN THE NAME OF GOD

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <list>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN= 1e5 + 22 ;
const ll INF = ll(1e18) + 22 ;
const int MOD = 1e9 + 7 ;

#define pb push_back
#define mp make_pair

int add_mod (int ttt , int rrr)
{
	ttt += rrr;
	ttt %= MOD;
	return ttt;
}

int n,q;
set <int> s;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++)
	{
		cin >> q;
		s.insert(q) ;
	}
	if(s.size() > 3)
		cout << "NO" ;
	else if (s.size() <= 2)

		cout << "YES" ;
	else
	{
		set<int>::iterator x = s.begin() ;
		s.erase(x);
		set<int>::iterator y = s.begin() ;
		s.erase(y);
		set<int>::iterator z = s.begin() ;
		if(*y * 2 == *x + *z)
			cout << "YES" ;
		else
			cout << "NO" ;
	}

	return 0;
}


#include <iostream>

int main() {
	unsigned n;
	std::cin >> n;
	unsigned long long * arr = new unsigned long long[n];
	for (unsigned i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}
	unsigned long long help[3] = { arr[0], arr[0], arr[0] };
	bool boolHelp[3] = { 1, 0, 0 };

	for (unsigned i = 1; i < n; ++i) {
		for (unsigned j = 0; boolHelp[j] && j < 3; ++j) {
			if (arr[i] == help[j]) {
				break;
			}
			else if (j == 2) {
				std::cout << "NO";
				return 0;
			}
			else if (boolHelp[j + 1] == false) {
				boolHelp[j + 1] = true;
				help[j + 1] = arr[i];
				break;
			}
		}
	}

	if (boolHelp[0] == true && boolHelp[1] == false && boolHelp[2] == false) {
		std::cout << "YES";
		return 0;
	}
	else if (boolHelp[0] == true && boolHelp[1] == true && boolHelp[2] == false) {
			std::cout << "YES";
			return 0;

	}
	else {
		/*
		unsigned long long x;
		for (unsigned i = 0; i < 3 ; ++i) {
			for (unsigned j = i+1; j < 3; ++j) {
				if (help[i]>help[j]) {
					x = help[j];
					help[j] = help[i];
					help[i] = x;
					i=0;
					break;
				}
			}
		}*/

		for (unsigned y = 1; y < 3; ++y)
		{
			for (unsigned g = y; g > 0; --g)
			{
				if (help[g] < help[g - 1])
				{
					unsigned x = help[g];
					help[g] = help[g-1];
					help[g-1] = x;
				}
				else
				{
					break;
				}
			}
		}

		if (help[1] - help[0] == help[2] - help[1]) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}

	delete[] arr;
	return 0;
}


#include <iostream>

int main() {
	unsigned n;
	std::cin >> n;
	unsigned long long * arr = new unsigned long long[n];
	for (unsigned i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}
	unsigned long long help[3] = { arr[0] };
	bool boolHelp[3] = { 1, 0, 0 };

	for (unsigned i = 1; i < n; ++i) {
		for (unsigned j = 0; boolHelp[j] && j < 3; ++j) {
			if (arr[i] == help[j]) {
				break;
			}
			else if (j == 2) {
				std::cout << "NO";
				return 0;
			}
			else if (boolHelp[j + 1] == false) {
				boolHelp[j + 1] = true;
				help[j + 1] = arr[i];
				break;
			}
		}
	}

	if (boolHelp[0] == true && boolHelp[1] == false && boolHelp[2] == false) {
		std::cout << "YES";
		return 0;
	}
	else if (boolHelp[0] == true && boolHelp[1] == true && boolHelp[2] == false) {
			std::cout << "YES";
			return 0;

	}
	else {
		unsigned long long x;
		for (unsigned i = 0; i < 3; ++i) {
			for (unsigned j = i+1; j < 3; ++j) {
				if (help[i]>help[j]) {
					x = help[j];
					help[j] = help[i];
					help[i] = x;
					i=0;
					break;
				}
			}
		}

		if (help[1] - help[0] == help[2] - help[1]) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}

	delete[] arr;
	return 0;
}


#include <iostream>

int main() {
	unsigned n;
	std::cin >> n;
	unsigned long long * arr = new unsigned long long[n];
	for (unsigned i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}
	unsigned long long help[3] = { arr[0] };
	bool boolHelp[3] = { 1, 0, 0 };

	bool flag = false;
	for (unsigned i = 1; i < n; ++i) {
		for (unsigned j = 0; boolHelp[j] && j < 3; ++j) {
			if (arr[i] == help[j]) {
				break;
			}
			else if (j == 2) {
				std::cout << "NO";
				return 0;
			}
			else if (boolHelp[j + 1] == false) {
				boolHelp[j + 1] = true;
				help[j + 1] = arr[i];
				break;
			}
		}
	}

	if (boolHelp[0] == true && boolHelp[1] == false && boolHelp[2] == false) {
		std::cout << "YES";
		return 0;
	}
	else if (boolHelp[0] == true && boolHelp[1] == true && boolHelp[2] == false) {
			std::cout << "YES";
			return 0;

	}
	else {
		unsigned long long x;
		for (unsigned i = 0; i < 2; ++i) {
			for (unsigned j = i; j < 3; ++j) {
				if (arr[i]>arr[j]) {
					x = arr[j];
					arr[j] = arr[i];
					arr[i] = x;
					--i;
					break;
				}
			}
		}

		if (help[1] - help[0] == help[2] - help[1]) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}

	delete[] arr;
	return 0;
}


#include <iostream>

int main() {
	unsigned n;
	std::cin >> n;
	unsigned long long * arr = new unsigned long long[n];
	for (unsigned i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}
	unsigned long long help[3] = { arr[0] };
	bool boolHelp[3] = { 1, 0, 0 };

	bool flag = false;
	for (unsigned i = 1; i < n; ++i) {
		for (unsigned j = 0; boolHelp[j] && j < 3; ++j) {
			if (arr[i] == help[j]) {
				break;
			}
			else if (j == 2) {
				std::cout << "NO";
				return 0;
			}
			else if (boolHelp[j + 1] == false) {
				boolHelp[j + 1] = true;
				help[j + 1] = arr[i];
				break;
			}
		}
	}

	if (boolHelp[0] == true && boolHelp[1] == false && boolHelp[2] == false) {
		std::cout << "YES";
		return 0;
	}
	else if (boolHelp[0] == true && boolHelp[1] == true && boolHelp[2] == false) {
		if ((help[0] - help[1]) % 2 == 0) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}
	else {
		unsigned long long x;
		for (unsigned i = 0; i < 2; ++i) {
			for (unsigned j = i; j < 3; ++j) {
				if (arr[i]>arr[j]) {
					x = arr[j];
					arr[j] = arr[i];
					arr[i] = x;
					--i;
					break;
				}
			}
		}

		if (help[1] - help[0] == help[2] - help[1]) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}

	delete[] arr;
	return 0;
}


#include <iostream>

int main() {
	unsigned n;
	std::cin >> n;
	unsigned long long * arr = new unsigned long long[n];
	for (unsigned i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}
	unsigned long long help[3] = { arr[0] };
	bool boolHelp[3] = { 1, 0, 0 };

	for (unsigned i = 1; i < n; ++i) {
		for (unsigned j = 0; boolHelp[j] && j < 3; ++j) {
			if (arr[i] == help[j]) {
				break;
			}
			else if (j == 2) {
				std::cout << "NO";
				return 0;
			}
			else if (boolHelp[j + 1] == false) {
				boolHelp[j + 1] = true;
				help[j + 1] = arr[i];
				break;
			}
		}
	}

	if (boolHelp[0] == true && boolHelp[1] == false && boolHelp[2] == false) {
		std::cout << "YES";
		return 0;
	}
	else if (boolHelp[0] == true && boolHelp[1] == true && boolHelp[2] == false) {
			std::cout << "YES";
			return 0;

	}
	else {
		unsigned long long x;
		for (unsigned i = 0; i < 2; ++i) {
			for (unsigned j = i; j < 3; ++j) {
				if (help[i]>help[j]) {
					x = help[j];
					help[j] = help[i];
					help[i] = x;
					i=0;
					break;
				}
			}
		}

		if (help[1] - help[0] == help[2] - help[1]) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}

	delete[] arr;
	return 0;
}


#include <iostream>

int main() {
	unsigned n;
	std::cin >> n;
	unsigned long long * arr = new unsigned long long[n];
	for (unsigned i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}
	unsigned long long help[3] = { arr[0] };
	bool boolHelp[3] = { 1, 0, 0 };

	bool flag = false;
	for (unsigned i = 1; i < n; ++i) {
		for (unsigned j = 0; boolHelp[j] && j < 3; ++j) {
			if (arr[i] == help[j]) {
				break;
			}
			else if (j == 2) {
				std::cout << "NO";
				return 0;
			}
			else if (boolHelp[j + 1] == false) {
				boolHelp[j + 1] = true;
				help[j + 1] = arr[i];
				break;
			}
		}
	}

	if (boolHelp[0] == true && boolHelp[1] == false && boolHelp[2] == false) {
		std::cout << "YES";
		return 0;
	}
	else if (boolHelp[0] == true && boolHelp[1] == true && boolHelp[2] == false) {
			std::cout << "YES";
			return 0;

	}
	else {
		unsigned long long x;
		for (unsigned i = 0; i < 2; ++i) {
			for (unsigned j = i; j < 3; ++j) {
				if (arr[i]>arr[j]) {
					x = arr[j];
					arr[j] = arr[i];
					arr[i] = x;
					i=0;
					break;
				}
			}
		}

		if (help[1] - help[0] == help[2] - help[1]) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}

	delete[] arr;
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<string.h>

#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>

#include<algorithm>
#include<iterator>
#include<iostream>
#include<list>
#include<vector>
#define maxn 100010
using namespace std;
long long a[maxn];
  int s[maxn];
  long long b[maxn];
int main()
{
  int n;

  int cnt=0;
  memset(s,0,sizeof(s));
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
      scanf("%I64d",&a[i]);
      if(s[a[i]]==0)
      {   b[cnt]=a[i];
          cnt++;
          s[a[i]]=1;

      }

  }
  sort(b,b+cnt);
  if(cnt>3)
    printf("NO\n");
  else if(cnt<3)
    printf("YES\n");
  else
  {
      if((b[0]+b[2])==2*b[1])
        printf("YES\n");
      else
        printf("NO\n");
  }

}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<string.h>

#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>

#include<algorithm>
#include<iterator>
#include<iostream>
#include<list>
#include<vector>
#define maxn 100010
using namespace std;
int a[maxn];
  int s[maxn];
  int b[maxn];
int main()
{
  int n;

  int cnt=0;
  memset(s,0,sizeof(s));
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
      scanf("%d",&a[i]);
      if(s[a[i]]==0)
      {   b[cnt]=a[i];
          cnt++;
          s[a[i]]=1;

      }

  }
  sort(b,b+cnt);
  if(cnt>3)
    printf("NO\n");
  else if(cnt<3)
    printf("YES\n");
  else
  {
      if((b[0]+b[2])==2*b[1])
        printf("YES\n");
      else
        printf("NO\n");
  }

}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<string.h>

#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>

#include<algorithm>
#include<iterator>
#include<iostream>
#include<list>
#include<vector>
#define maxn 100010
using namespace std;

//int s[maxn];
int b[maxn];
int main()
{
 map<int ,int >s;
  int n;
  int a;
  int cnt=0;
//  memset(s,0,sizeof(s));
  scanf("%d",&n);

  while(n--)
  {
    scanf("%d",&a);
      if(s[a]==0)
      {
          b[cnt++]=a;
          s[a]=1;

      }
  }

  sort(b,b+cnt);
  if(cnt>3)
    printf("NO\n");
  else if(cnt<3)
    printf("YES\n");
  else
  {
      if((b[0]+b[2])==2*b[1])
        printf("YES\n");
      else
        printf("NO\n");
  }

}


#include <iostream>
using namespace std;
int main()
{
    int n,a[100000],i=1,max,min;
    cin>>n;
    cin>>a[0];
    max=a[0];
    min=a[0];
    while(i<n)
    {
        cin>>a[i];
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
        i++;
    }
    while(i>0)
    {
        i--;
        if(a[i]!=max&&a[i]!=min&&a[i]*2!=(min+max))
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}


#include <iostream>
using namespace std;
int main()
{
    int n,a[100000],i=1,max,min;
    cin>>n;
    cin>>a[0];
    max=a[0];
    min=a[0];
    while(i<n)
    {
        cin>>a[i];
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
        i++;
    }
    if((max+min)%2==0||n<=2)
    {
        while(i>0)
        {
            i--;
            if(a[i]!=max&&a[i]!=min&&a[i]!=(min+max)/2)
            {
                cout<<"NO";
                return 0;
            }
        }
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
}


#include <iostream>
using namespace std;
int main()
{
    int n,a[100000],i=1,max,min;
    cin>>n;
    cin>>a[0];
    max=a[0];
    min=a[0];
    while(i<n)
    {
        cin>>a[i];
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
        i++;
    }
    if((max+min)%2==0)
    {
        while(i>0)
        {
            i--;
            if(a[i]!=max&&a[i]!=min&&a[i]!=(min+max)/2)
            {
                cout<<"NO";
                return 0;
            }
        }
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
}


#include <iostream>
using namespace std;
int main()
{
    int n,a[100000],i=1,max,min;
    cin>>n;
    cin>>a[0];
    max=a[0];
    min=a[0];
    while(i<n)
    {
        cin>>a[i];
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
        i++;
    }
    while(i>0)
    {
        i--;
        if(a[i]!=max&&a[i]!=min&&a[i]!=(min+max)/2)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}


//http://codeforces.com/contest/714/problem/B

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <list>

using namespace std;

#define pii pair <int, int>
#define pll pair <long long, long long>
#define vi vector <int>
#define ll long long
#define mp make_pair
#define fir first
#define sec second

int n;
string result = "NO";
map <int, int> used;

int main()
{
	int ii;
	int x;
	map <int, int>::iterator itTmp, it1, it2, it3;

	ios::sync_with_stdio(false);

	cin >> n;

	for (ii = 0; ii < n; ii++)
	{
		cin >> x;

		used[x]++;
	}

	if (used.size() == 3)
	{
		itTmp = it1 = used.begin();
		it2 = ++itTmp;
		it3 = ++itTmp;

		if (((it2->first - it1->first) > 0) && ((it2->first - it1->first) == (it3->first - it2->first)))
			result = "YES";
	}

	cout << result << endl;

	return 0;
}


//http://codeforces.com/contest/714/problem/B

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <list>

using namespace std;

#define pii pair <int, int>
#define pll pair <long long, long long>
#define vi vector <int>
#define ll long long
#define mp make_pair
#define fir first
#define sec second

int n;
string result = "NO";
map <int, int> used;

int main()
{
	int ii;
	int a;
	map <int, int>::iterator itTmp, it1, it2, it3;

	ios::sync_with_stdio(false);

	cin >> n;

	for (ii = 0; ii < n; ii++)
	{
		cin >> a;

		used[a]++;
	}

	if (used.size() == 3)
	{
		itTmp = it1 = used.begin();
		it2 = ++itTmp;
		it3 = ++itTmp;

		if (((it2->first - it1->first) > 0) && ((it2->first - it1->first) == (it3->first - it2->first)))
			result = "YES";
	}
	else if ((used.size() == 1) || (used.size() == 2))
		result = "YES";

	cout << result << endl;

	return 0;
}


//http://codeforces.com/contest/714/problem/B

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <list>

using namespace std;

#define pii pair <int, int>
#define pll pair <long long, long long>
#define vi vector <int>
#define ll long long
#define mp make_pair
#define fir first
#define sec second

int n;
string result = "NO";
map <int, int> used;

int main()
{
	int ii;
	int a;
	map <int, int>::iterator itTmp, it1, it2, it3;

	ios::sync_with_stdio(false);

	cin >> n;

	for (ii = 0; ii < n; ii++)
	{
		cin >> a;

		used[a]++;
	}

	if (used.size() == 3)
	{
		itTmp = it1 = used.begin();
		it2 = ++itTmp;
		it3 = ++itTmp;

		if (((it2->first - it1->first) > 0) && ((it2->first - it1->first) == (it3->first - it2->first)))
			result = "YES";
	}
	else if (used.size() == 1)
		result = "YES";
	else if (used.size() == 2)
	{
		itTmp = it1 = used.begin();
		it2 = ++itTmp;

		if (!((it2->first - it1->first) & 1))
			result = "YES";
	}

	cout << result << endl;

	return 0;
}


#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

set <int> secik;
vector <int> wektorek;

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        int a;
        scanf("%d", &a);
        if(secik.find(a) == secik.end())
            wektorek.push_back(a);
        secik.insert(a);
    }
    if(wektorek.size() > 3)
    {
        printf("NO\n");
        return 0;
    }
    sort(wektorek.begin(), wektorek.end());
    if(wektorek.size() < 3)
    {
        printf("YES\n");
        return 0;
    }
    if(2 * wektorek[1] == (wektorek[0] + wektorek[2]))
        printf("YES\n");
    else
        printf("NO\n");
}


#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

set <int> secik;
vector <int> wektorek;

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        int a;
        scanf("%d", &a);
        if(secik.find(a) == secik.end())
            wektorek.push_back(a);
        secik.insert(a);
    }
    if(wektorek.size() > 3)
    {
        printf("NO\n");
        return 0;
    }
    sort(wektorek.begin(), wektorek.end());
    if(wektorek.size() < 3)
    {
        printf("YES\n");
        return 0;
    }
    if(wektorek[1] == (wektorek[0] + wektorek[2]) / 2)
        printf("YES\n");
    else
        printf("NO\n");
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	while (1)
	{
	int n;   cin>>n;
	bool check=1;
	vector<int>vec(n);
	for (int i=0 ; i<n ;++i)
		cin>>vec[i];
	sort(vec.begin(),vec.end());
	int min=vec[0];  int max=vec[vec.size()-1];
	double mid=(max+min)/2;
	for (int i=0 ; i<n ;++i)
		if (vec[i]!=max && vec[i]!=min && vec[i]!=mid)   {check=0;  break;}
	if (check)    cout<<"YES"<<endl;
	else          cout<<"NO"<<endl;
	}

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int n;   cin>>n;
	bool check=1;
	vector<int>vec(n);
	for (int i=0 ; i<n ;++i)
		cin>>vec[i];
	sort(vec.begin(),vec.end());
	int min=vec[0];  int max=vec[vec.size()-1];
	double mid=(max+min*1.0)/2;
	for (int i=0 ; i<n ;++i)
		if (vec[i]!=max && vec[i]!=min && vec[i]!=mid)   {check=0;  break;}
	if (check)    cout<<"YES"<<endl;
	else          cout<<"NO"<<endl;

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int n;   cin>>n;
	bool check=1;
	vector<int>vec(n);
	for (int i=0 ; i<n ;++i)
		cin>>vec[i];
	sort(vec.begin(),vec.end());
	int min=vec[0];  int max=vec[vec.size()-1];
	double mid=(max+min)/2*1.0;
	for (int i=0 ; i<n ;++i)
		if (vec[i]!=max && vec[i]!=min && vec[i]!=mid)   {check=0;  break;}
	if (check)    cout<<"YES"<<endl;
	else          cout<<"NO"<<endl;

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int n;   cin>>n;
	bool check=1;
	vector<int>vec(n);
	for (int i=0 ; i<n ;++i)
		cin>>vec[i];
	sort(vec.begin(),vec.end());
	int min=vec[0];  int max=vec[vec.size()-1];
	double mid=(max+min)/2;
	for (int i=0 ; i<n ;++i)
		if (vec[i]!=max && vec[i]!=min && vec[i]!=mid)   {check=0;  break;}
	if (check)    cout<<"YES"<<endl;
	else          cout<<"NO"<<endl;

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<unordered_set>
#include<map>
#include<queue>
#include<set>
using namespace std;

bool * sieve()
{
	bool * arr =new bool[51];
	for(int i=0;i<51;i++)
		arr[i]=true;
	for(int i=2;i*i<50;i++)
	{
		if(arr[i])
		{
			for(int p = i*2; p<=50;p+=i)
				arr[p]=false;
		}
	}
	return arr;
}

int main()
{
	int n;
	while(cin>>n)
	{
		set<int>s;
		int a;
		for(int i=0;i<n;i++)
		{
			cin>>a;
			s.insert(a);
		}
		set<int>:: iterator it;
		vector<int>vec;
		for(it=s.begin(); it !=s.end();it++)
			vec.push_back(*it);
		if((vec.size()<3)||(vec.size()==3 && vec[2]-vec[0] == vec[1] ))
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<unordered_set>
#include<map>
#include<queue>
#include<set>
using namespace std;

bool * sieve()
{
	bool * arr =new bool[51];
	for(int i=0;i<51;i++)
		arr[i]=true;
	for(int i=2;i*i<50;i++)
	{
		if(arr[i])
		{
			for(int p = i*2; p<=50;p+=i)
				arr[p]=false;
		}
	}
	return arr;
}
int main()
{
	int n;
	while(cin>>n)
	{
		set<int>s;
		int a;
		for(int i=0;i<n;i++)
		{
			cin>>a;
			s.insert(a);
		}
		set<int>:: iterator it;
		vector<int>vec;
		for(it=s.begin(); it !=s.end();it++)
			vec.push_back(*it);
		if(vec.size()==3 && vec[2]-vec[0] == vec[1] )
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<unordered_set>
#include<map>
#include<queue>
#include<set>
using namespace std;

bool * sieve()
{
	bool * arr =new bool[51];
	for(int i=0;i<51;i++)
		arr[i]=true;
	for(int i=2;i*i<50;i++)
	{
		if(arr[i])
		{
			for(int p = i*2; p<=50;p+=i)
				arr[p]=false;
		}
	}
	return arr;
}

int main()
{
	int n;
	while(cin>>n)
	{
		set<int>s;
		int a;
		for(int i=0;i<n;i++)
		{
			cin>>a;
			s.insert(a);
		}
		set<int>:: iterator it;
		vector<int>vec;
		for(it=s.begin(); it !=s.end();it++)
			vec.push_back(*it);
		if((vec.size()<3)||(vec.size()==3 && vec[2]-vec[1] == vec[1]-vec[0] ))
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <list>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <math.h>

#define INF 1000000007
#define ll long long

template<typename T> inline T MIN(T a, T b) { return a < b ? a : b; }
template<typename T> inline T MAX(T a, T b) { return a > b ? a : b; }

using namespace std;

int main() {

	int n, x;
	set <int> s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		s.insert(x);
	}

	if (s.size() == 2) {
		cout << "YES";
		return 0;
	}

	set<int>::iterator fir = s.begin(), sec = s.begin(), thir = s.begin();
	++sec;
	++++thir;

	if (s.size() == 3 && *thir + *fir==*sec*2	 ) {

		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

	return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <list>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <math.h>

#define INF 1000000007
#define ll long long

template<typename T> inline T MIN(T a, T b) { return a < b ? a : b; }
template<typename T> inline T MAX(T a, T b) { return a > b ? a : b; }

using namespace std;

int main() {

	int n, x;
	set <int> s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		s.insert(x);
	}

	if (s.size() <=2) {
		cout << "YES";
		return 0;
	}

	set<int>::iterator fir = s.begin(), sec = s.begin(), thir = s.begin();
	++sec;
	++++thir;

	if (s.size() == 3 && *thir + *fir==*sec*2	 ) {

		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; ++i) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	int x = vec[n - 1] - vec[0];
	if (x % 2) {
		cout << "NO";
	}
	else {
		x = x / 2;
		int i, idol;
		idol = vec[0] + x;
		for (i = 0; i < n && ((vec[i] == idol || vec[i] + x == idol) || vec[i] - x == idol); ++i) {
		}
		if (i != n) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; ++i) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	int x = vec[n - 1] - vec[0];
	if (x % 2) {
		cout << "NO";
	}
	else {
		x = x / 2;
		int i, idol;
		idol = vec[0] + x;
		for (i = 0; i < n && ((vec[i] == idol || vec[i] + x == idol) || vec[i] - x == idol); ++i) {
		}
		if (i != n) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
	}
	system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; ++i) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	int x = vec[n - 1] - vec[0];
	if (x % 2) {
		bool flag = false;
		for (int i = 0; i < n; ++i) {
			if (vec[i] != vec[0] && vec[i] != vec[n - 1]){
				flag = true;
				break;
			}
		}
		if (flag) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
	}
	else {
		x = x / 2;
		int i, idol;
		i = 0;
		idol = vec[0] + x;
		for (i = 0; i < n && ((vec[i] == idol || vec[i] + x == idol) || vec[i] - x == idol); ++i) {
		}
		if (i != n) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; ++i) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	int x = vec[n - 1] - vec[0];
	if (x % 2) {
		cout << "NO";
	}
	else {
		x /= 2;
		int i, idol = vec[1] + x;
		for (i = 0; i < n && ((vec[i] == idol || vec[i] + x == idol) || vec[i] - x == idol); ++i) {
		}
		if (i != n) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
	}
	return 0;
}


#include <iostream>
#include <set>

using namespace std;

int main() {
	int n,t; cin >> n;
	set<int> a;
	while (n--) { cin >> t; a.insert(t); }

	if (a.size() <= 2) cout << "YES";
	else if (a.size() > 3) cout << "NO";
	else {
		float max = *a.rbegin();
		float min = *a.begin();
		float r = 0;
		for (set<int>::const_iterator it = a.begin(); it != a.end(); it++) {
			r = (*it);
			if (r != max && r != min)break;
		}
		if ((max + min) / 2 == r)
			cout << "YES";
		else cout << "NO";
	}
	return 0;
}


#include <iostream>

using namespace std;

void quickSort(int *numbers, int left, int right)
{
	int pivot;
	int l_hold = left;
	int r_hold = right;
	pivot = numbers[left];
	while (left < right) // пока границы не сомкнутся
	{
		while ((numbers[right] >= pivot) && (left < right))
			right--;
		if (left != right)
		{
			numbers[left] = numbers[right];
			left++;
		}
		while ((numbers[left] <= pivot) && (left < right))
			left++;
		if (left != right)
		{
			numbers[right] = numbers[left];
			right--;
		}
	}
	numbers[left] = pivot;
	pivot = left;
	left = l_hold;
	right = r_hold;
	if (left < pivot)
		quickSort(numbers, left, pivot - 1);
	if (right > pivot)
		quickSort(numbers, pivot + 1, right);
}

int main() {

	int n; cin >> n;
	if (n == 1) { cout << "YES"; return 0; }

	int* arr = new int[n];
	int min=1000000001, max=-1;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if (arr[i] > max)max = arr[i];
		else if (arr[i] < min)min = arr[i];
	}

	quickSort(arr, 0, n - 1);
	int c = 1;
	for (int i = 1; i < n; i++)
		if (arr[i] != arr[i - 1])c++;

	if (c == 1 || c==2)
		cout << "YES";
	else if (c > 3) cout << "NO";
	else {
		int c;
		for (int i = 0; i < n; i++)
			if (arr[i] != max && arr[i] != min)
				c = arr[i];
		if ((double)c == ((double)max + (double)min) / 2)
			cout << "YES";
		else cout << "NO";
	}
	return 0;
}


#include <iostream>

using namespace std;

void quickSort(int *numbers, int left, int right)
{
	int pivot;
	int l_hold = left;
	int r_hold = right;
	pivot = numbers[left];
	while (left < right) // пока границы не сомкнутся
	{
		while ((numbers[right] >= pivot) && (left < right))
			right--;
		if (left != right)
		{
			numbers[left] = numbers[right];
			left++;
		}
		while ((numbers[left] <= pivot) && (left < right))
			left++;
		if (left != right)
		{
			numbers[right] = numbers[left];
			right--;
		}
	}
	numbers[left] = pivot;
	pivot = left;
	left = l_hold;
	right = r_hold;
	if (left < pivot)
		quickSort(numbers, left, pivot - 1);
	if (right > pivot)
		quickSort(numbers, pivot + 1, right);
}

int main() {

	int n; cin >> n;
	if (n == 1) { cout << "YES"; return 0; }

	int* arr = new int[n];
	int min=1000000001, max=-1;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if (arr[i] > max)max = arr[i];
		if (arr[i] < min)min = arr[i];
	}

	quickSort(arr, 0, n - 1);
	int c = 1;
	for (int i = 1; i < n; i++)
		if (arr[i] != arr[i - 1])c++;

	if (c == 1 || c==2)
		cout << "YES";
	else if (c > 3) cout << "NO";
	else {
		int c;
		for (int i = 0; i < n; i++)
			if (arr[i] != max && arr[i] != min)
				c = arr[i];

		double s = ((double)max + (double)min) / 2;
		if ((double)c == s)
			cout << "YES";
		else cout << "NO";

	}
	return 0;
}


#include <iostream>
#include <set>

using namespace std;

int main() {
	int n,t; cin >> n;
	set<int> a;
	while (n--) { cin >> t; a.insert(t); }

	if (a.size() <= 2) cout << "YES";
	else if (a.size() > 3) cout << "NO";
	else {
		double max = *a.rbegin();
		double min = *a.begin();
		double r = 0;
		for (set<int>::const_iterator it = a.begin(); it != a.end(); it++) {
			r = (*it);
			if (r != max && r != min)break;
		}
		if ((max + min) / 2 == r)
			cout << "YES";
		else cout << "NO";
	}
	return 0;
}


#include <iostream>
#include<cmath>
#include<string>
#include <algorithm>
#include <math.h>
#include <sstream>
using namespace std;
int main()
{
  int n,arr[100000],sum=0,ind;
  cin>>n;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
    sort(arr,arr+n);
    for(int i=1;i<n;i++)
  {
     if(arr[i]!=arr[i-1])
     {
     sum++;
     ind=i;
     }
     if(sum>2)
     {
         cout<<"NO"<<endl;
         return 0;
     }
  }
  if(arr[ind]-arr[0]==arr[n-1]-arr[ind])
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;

    return 0;
}


#include <iostream>
#include<cmath>
#include<string>
#include <algorithm>
#include <math.h>
#include <sstream>
using namespace std;
int main()
{
  int n,arr[100000],sum=0,ind=0;
  bool b=false;
  cin>>n;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
    sort(arr,arr+n);
    for(int i=1;i<n;i++)
  {
     if(arr[i]!=arr[i-1])
     {
         if(!b)
         {
         b=true;
         ind=i;
         }
     sum++;
     }
     if(sum>2)
     {
         cout<<"NO"<<endl;
         return 0;
     }
  }
  if(sum==1||sum==0)
  {
      cout<<"YES"<<endl;
      return 0;
  }
  if(arr[ind]-arr[0]==arr[n-1]-arr[ind])
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;

    return 0;
}


#include <iostream>
#include<cmath>
#include<string>
#include <algorithm>
#include <math.h>
#include <sstream>
using namespace std;
int main()
{
  int n,arr[100000],sum=0,ind=0;
  bool b=false;
  cin>>n;
  if(n==1||n==2)
  {
      cout<<"YES"<<endl;
      return 0;
  }
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
    sort(arr,arr+n);
    for(int i=1;i<n;i++)
  {
     if(arr[i]!=arr[i-1])
     {
         if(!b)
         {
         b=true;
         ind=i;
         }
     sum++;
     }
     if(sum>2)
     {
         cout<<"NO"<<endl;
         return 0;
     }
  }
  if(arr[ind]-arr[0]==arr[n-1]-arr[ind])
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;

    return 0;
}


#include <iostream>
#include<cmath>
#include<string>
#include <algorithm>
#include <math.h>
#include <sstream>
using namespace std;
int main()
{
  int n,arr[100000],sum=0,ind;
  cin>>n;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
    sort(arr,arr+n);
    for(int i=1;i<n;i++)
  {
     if(arr[i]!=arr[i-1])
     {
     sum++;
     ind=1;
     }
     if(sum>2)
     {
         cout<<"NO"<<endl;
         return 0;
     }
  }
  if(arr[ind]-arr[0]==arr[n-1]-arr[ind])
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;

    return 0;
}


#include <iostream>
#include<cmath>
#include<string>
#include <algorithm>
#include <math.h>
#include <sstream>
using namespace std;
int main()
{
  int n,arr[100000],sum=0,ind;
  bool b=false;
  cin>>n;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
    sort(arr,arr+n);
    for(int i=1;i<n;i++)
  {
     if(arr[i]!=arr[i-1])
     {
         if(!b)
         {
         b=true;
         ind=i;
         }
     sum++;
     }
     if(sum>2)
     {
         cout<<"NO"<<endl;
         return 0;
     }
  }
  if(arr[ind]-arr[0]==arr[n-1]-arr[ind])
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;

    return 0;
}


#include <iostream>
#include<cmath>
#include<string>
#include <algorithm>
#include <math.h>
#include <sstream>
using namespace std;
int main()
{
  int n,arr[100000],sum=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
    sort(arr,arr+n);
    for(int i=1;i<n;i++)
  {
      cin>>arr[i];
     if(arr[i]!=arr[i-1])
     sum++;
     if(sum>2)
     {
         cout<<"NO"<<endl;
         return 0;
     }
  }
  cout<<"YES"<<endl;

    return 0;
}


#include <iostream>
#include<cmath>
#include<string>
#include <algorithm>
#include <math.h>
#include <sstream>
using namespace std;
int main()
{
  int n,arr[100000],sum=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
    sort(arr,arr+n);
    for(int i=1;i<n;i++)
  {
     if(arr[i]!=arr[i-1])
     sum++;
     if(sum>2)
     {
         cout<<"NO"<<endl;
         return 0;
     }
  }
  cout<<"YES"<<endl;

    return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main()
{
	int n;
	while( cin >> n ){
		map< int, int > b;
		for( int i = 0; i < n; ++i ){
			int a;
			cin >> a;
			b[ a ]++;
		}
		cout << ( ( b.size() == 1 ) || ( b.size() == 2
			|| ( b.size() == 3 && ( b.begin()->first + ( --( b.end() ) )->first ) == ( ++( b.begin() ) )->first * 2 ) )
			 ? "YES" : "NO" ) << endl;

	}
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main()
{
	int n;
	while( cin >> n ){
		map< int, int > b;
		for( int i = 0; i < n; ++i ){
			int a;
			cin >> a;
			b[ a ]++;
		}
		cout << ( ( ( b.size() == 1 )
			|| ( b.size() == 2 && ( ( ( --( b.end() ) )->first ) - b.begin()->first ) % 2 == 0 )
			|| ( b.size() == 3 && ( b.begin()->first + ( --( b.end() ) )->first ) == ( ++( b.begin() ) )->first * 2 ) )
			? "YES" : "NO" ) << endl;

	}
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main()
{
	int n;
	while( cin >> n ){
		map< int, int > b;
		for( int i = 0; i < n; ++i ){
			int a;
			cin >> a;
			b[ a ]++;
		}
		cout << ( ( ( b.size() == 1 ) || ( b.size() == 3 && ( b.begin()->second == ( --b.end() )->second ) && b.begin()->first + ( --( b.end() ) )->first == ( ++( b.begin() ) )->first * 2 ) ) ? "YES" : "NO" ) << endl;

	}
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main()
{
	int n;
	while( cin >> n ){
		map< int, int > b;
		for( int i = 0; i < n; ++i ){
			int a;
			cin >> a;
			b[ a ]++;
		}
		cout << ( ( ( b.size() == 1 ) || ( b.size() == 3 && b.begin()->first + ( --( b.end() ) )->first == ( ++( b.begin() ) )->first * 2 ) ) ? "YES" : "NO" ) << endl;

	}
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main()
{
	int n;
	while( cin >> n ){
		map< int, int > b;
		for( int i = 0; i < n; ++i ){
			int a;
			cin >> a;
			b[ a ]++;
		}
		cout << ( n > 1 && ( ( ( b.size() == 1 )
			|| ( b.size() == 2 && ( ( ( --( b.end() ) )->first ) - b.begin()->first ) % 2 == 0 )
			|| ( b.size() == 3 && ( b.begin()->first + ( --( b.end() ) )->first ) == ( ++( b.begin() ) )->first * 2 ) )
			) ? "YES" : "NO" ) << endl;

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if ((n == 2 && buf[1] != 2 * buf[0]) || n > 3)
    {
        cout << "NO";
        return 0;
    }
    if (n < 3 || (buf[1] == 2 * buf[0] && buf[2] == 3 * buf[0]))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if ((n == 2 && (buf[0] == 0 || buf[1] % buf[0] > 0)) || n > 3)
    {
        cout << "NO";
        return 0;
    }
    if (n < 3 || (buf[0] > 0 && buf[1] % buf[0] == 0 && buf[2] % buf[0] == 0))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (n == 2 || n > 3)
    {
        cout << "NO";
        return 0;
    }
    if (n == 1 || buf[1] + buf[0] == buf[2] - buf[0])
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (n == 1)
    {
        cout << "YES";
        return 0;
    }
    for (int i = 1; i < n; i++)
    {
        if (buf[i] % buf[0] > 0)
        {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if ((n > 1 && buf[0] == 0) || n > 3 || buf[1] % buf[0] > 0)
    {
        cout << "NO";
        return 0;
    }
    if (n < 3 || buf[2] % buf[0] == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if ((n == 2 && buf[1] % buf[0] > 0) || n > 3)
    {
        cout << "NO";
        return 0;
    }
    if (n < 3 || (buf[1] % buf[0] == 0 && buf[2] % buf[0] == 0))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (buf[0] == 0 || (n == 2 && buf[1] % buf[0] > 0) || n > 3)
    {
        cout << "NO";
        return 0;
    }
    if (n < 3 || (buf[1] % buf[0] == 0 && buf[2] % buf[0] == 0))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if ((n == 2 && buf[0] == 0 && buf[1] % buf[0] > 0) || n > 3)
    {
        cout << "NO";
        return 0;
    }
    if (n < 3 || (buf[0] == 0 && buf[1] % buf[0] == 0 && buf[2] % buf[0] == 0))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (n == 1)
    {
        cout << "YES";
        return 0;
    }
    if (n > 3 || buf[0] == 0 || buf[1] % buf[0] > 0)
    {
        cout << "NO";
        return 0;
    }
    if (n == 2 || buf[2] % buf[0] == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (n == 1)
    {
        cout << "YES";
        return 0;
    }
    if ((n > 3 || buf[0] == 0 || buf[1] % buf[0] > 0)
    {
        cout << "NO";
        return 0;
    }
    if (n == 2 || buf[2] % buf[0] == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (n == 2 || n > 3)
    {
        cout << "NO";
        return 0;
    }
    if (n == 1 || (buf[1] == 2 * buf[0] && buf[2] == 3 * buf[0]))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (n < 3)
    {
        cout << "YES";
        return 0;
    }
    if (n > 3)
    {
        cout << "NO";
    }
    else
    {
        if (buf[1] - buf[0] == buf[2] - buf[1])
        {
            cout << "YES";
        }
        else
        {
            cout << "NO";
        }
    }
}


int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (n == 1)
    {
        cout << "YES";
        return 0;
    }
    if ((n > 3 || buf[0] == 0 || buf[1] % buf[0] > 0)
    {
        cout << "NO";
        return 0;
    }
    if (n == 2 || buf[2] % buf[0] == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> buf(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.end());
    buf.erase(unique(buf.begin(), buf.end()), buf.end());
    n = buf.size();
    if (n < 3)
    {
        cout << "YES";
        return 0;
    }
    if (n > 3)
    {
        cout << "NO";
    }
    else
    {
        if (buf[1] == buf[2] - buf[0] && buf[1] == 2 * buf[0])
        {
            cout << "YES";
        }
        else
        {
            cout << "NO";
        }
    }
}


// CodeForces (C++).cpp: определяет точку входа для консольного приложения.
//

//#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <cstdlib>

#define ll long long

using namespace std;

inline bool IsMemberOfArray(int t, int* a, int n)
{
	for (int i = 0; i < n; i++)
		if (a[i] == t)
			return true;
	return false;
}

int main()
{
	int n, a[3], k = 0;

	a[0] = a[1] = a[2] = -1;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;

		if (IsMemberOfArray(t, a, 3))
			continue;
		if (k < 3)
			a[k++] = t;
		else
		{
			cout << "NO";
			//system("pause");
			return 0;
		}
	}
	int min = 0;
	int max = 0;

	for (int i = 1; i < 3; i++)
	{
		if (a[i] > a[max])
			max = i;
		if (a[i] < a[min])
			min = i;
	}

	if (a[min] + a[max] == a[3 - min - max]*2)
		cout << "YES";
	else
		cout << "NO";

	//system("pause");
	return 0;
}