Language: C++

#include<bits/stdc++.h>

using namespace std;

int x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6, N, fac[2001017], inv[2001017];
const int mod = 1e9 + 7;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

namespace fft {

static int Konst = 1000, rev[1 << 21];

double PI = acos (-1.0);
struct comp
{
    double a, b;///a + bi
    comp (): a (0.0), b (0.0) {}
    comp (double _a, double _b): a (_a), b (_b) {}
    comp (int val): a (val), b (0.0) {}
};
comp unit (int N) {comp x; x.a = (double) cos (2.0 * PI / N), x.b = sin (2.0 * PI / N); return x;}
comp operator / (comp x, double val) {return comp (x.a / val, x.b / val);}
comp operator - (comp a, comp b) {return comp (a.a - b.a, a.b - b.b);}
comp operator + (comp a, comp b) {return comp (a.a + b.a, a.b + b.b);}
comp operator * (comp a, comp b) {return comp (1.0 * a.a * b.a - 1.0 * a.b * b.b, 1.0 * a.b * b.a + 1.0 * a.a * b.b);}

void DFT (comp a[], int N, bool inv)
{
    for (int i=0; i<N; i++)
        if (i < rev[i]) swap (a[i], a[rev[i]]);
    for (int l=2; l<=N; l <<= 1)
    {
        comp omega = unit (l);
        if (inv) omega = unit (-l);
        for (int i=0; i<N; i+=l)
        {
            comp put = comp(1.0);
            for (int j=0; j<l / 2; j++)
            {
                comp u = a[i + j], v = a[i + j + l / 2] * put;
                a[i + j] = u + v;
                a[i + j + l / 2] = u - v;
                put = put * omega;
            }
        }
    }
    if (inv)
    {
        for (int i=0; i<N; i++)
            a[i] = a[i] / N;
    }
}

void initRev (int n)
{
    int N = 1;
    while (N <= 2 * n) N <<= 1;
    for (int i=0; (1<<i) < N; i++)
        for (int j=0; j<N; j++)
            rev[j] = ((rev[j] << 1) | ((j >> i) & 1));
}

void GetProd (int a[], int b[], int c[], int n)
{
    int N = 1;
    while (N <= 2 * n) N <<= 1;
    comp dfa[N], dfb[3][N], aux[N];
    for (int i=0; i<N; i++)
        c[i] = 0;
    for (int i=0; i<3; i++)
    {
        for (int j=0; j<N; j++)
            dfb[i][j] = comp (b[j] % Konst), b[j] /= Konst;
        DFT (dfb[i], N, 0);
    }
    int put = 1;
    for (int i=0; i<3; i++)
    {
        for (int j=0; j<N; j++)
            dfa[j] = comp (a[j] % Konst), a[j] /= Konst;
        DFT (dfa, N, 0);
        int aux_put = put;
        for (int j=0; j<3; j++)
        {
            for (int k=0; k<N; k++)
                aux[k] = dfa[k] * dfb[j][k];
            DFT (aux, N, 1);
            for (int k=0; k<N; k++)
            {
                int curr = ((long long) (aux[k].a + 0.5)) % mod;
                c[k] = ((long long) c[k] + 1LL * aux_put * curr) % mod;
            }
            aux_put = (1LL * aux_put * Konst) % mod;
        }
        put = (1LL * put * Konst) % mod;
    }
}};

int paths (int dx, int dy) {return comb (dx + dy, dx);}

int first_term[1 << 21], second_term[1 << 21], res[1 << 21];
int solve (int a1, int b1, int a2, int b2)
{
    int ans = 0, n = max (x4, y4);
/*    for (int i=x3; i<=x4; i++)
        for (int j=y3; j<=y4; j++)
        {
            int f1 = mul (fac[i + j - a1 - b1], mul (inv[i - a1], inv[j - b1])), f2 = mul (fac[a2 + b2 - i - j], mul (inv[a2 - i], inv[b2 - j]));
            int curr = mul (f1, f2);
            adto (ans, curr);
//            adto (ans, mul (paths (i - a1, j - b1), paths (a2 - i, b2 - j)));
        }
    return ans;*/
    for (int i=0; i<=n; i++)
    {
        if (x3 <= i && i <= x4) first_term[i] = mul (inv[i - a1], inv[a2 - i]);
        else first_term[i] = 0;
        if (y3 <= i && i <= y4) second_term[i] = mul (inv[i - b1], inv[b2 - i]);
        else second_term[i] = 0;
    }
    for (int i=n + 1; i<=2 * n; i++)
        first_term[i] = second_term[i] = 0;
/*    for (int i=0; i<=2 * n; i++)
        res[i] = 0;
    for (int i=0; i<=n; i++)
        for (int j=0; j<=n; j++)
            adto (res[i + j], mul (first_term[i], second_term[j]));*/
    fft::GetProd (first_term, second_term, res, n);
    for (int i=0; i<=2 * n; i++)
        if (res[i] != 0)
            adto (ans, mul (res[i], mul (fac[i - a1 - b1], fac[a2 + b2 - i])));
    return ans;
/*    int ans = 0;
    for (int i=x4 + 1; i<=a2; i++)
        adto (ans, mul (paths (i - a1, y3 - 1 - b1), paths (a2 - i, b2 - y3)));
    for (int j=y4 + 1; j<=b2; j++)
        adto (ans, mul (paths (x3 - 1 - a1, j - b1), paths (a2 - x3, b2 - j)));
    ans = subtract (paths (a2 - a1, b2 - b1), ans);*/
//    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

Prec (2001000);
scanf ("%d %d %d %d %d %d", &x1, &x2, &x3, &x4, &x5, &x6), x1 --, x2 --, x5 ++, x6 ++;
scanf ("%d %d %d %d %d %d", &y1, &y2, &y3, &y4, &y5, &y6), y1 --, y2 --, y5 ++, y6 ++;
fft::initRev (max (x4, y4));

vector < pair < pair < int, int >, int > > L, R;
L.push_back ({{x1, y1}, +1});
L.push_back ({{x1, y2 + 1}, -1});
L.push_back ({{x2 + 1, y1}, -1});
L.push_back ({{x2 + 1, y2 + 1}, +1});

R.push_back ({{x5 - 1, y5 - 1}, +1});
R.push_back ({{x5 - 1, y6}, -1});
R.push_back ({{x6, y5 - 1}, -1});
R.push_back ({{x6, y6}, +1});

int ans = 0;
for (auto stanga_sus : L)
    for (auto dreapta_jos : R)
    {
        int a1 = stanga_sus.first.first, b1 = stanga_sus.first.second, a2 = dreapta_jos.first.first, b2 = dreapta_jos.first.second, sg = stanga_sus.second * dreapta_jos.second;
        int val = solve (a1, b1, a2, b2);
        if (sg < 0) val = subtract (mod, val);
        adto (ans, val);
    }
printf ("%d\n", ans);

/*Prec (100);
for (int n=0; n<=20; n++)
    for (int m=0; m<=20; m++)
    {
        int cor = 0, poa = 0;
        for (int i=0; i<=n; i++)
            for (int j=0; j<=m; j++)
                adto (cor, comb (i + j, j));
        poa = subtract (comb (n + 1 + m + 1, m + 1), 1);
        if (poa != cor)
        {
            printf ("wa (%d, %d) %d instead of %d\n", n, m, poa, cor);
            return 0;
        }
    }*/

return 0;
}


Compiler output:
a.cc:5:29: error: 'int y1' redeclared as different kind of entity
    5 | int x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6, N, fac[2001017], inv[2001017];
      |                             ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:168:60: warning: ISO C++ forbids decrementing a pointer of type 'double (*)(double) noexcept' [-Wpointer-arith]
  168 | scanf ("%d %d %d %d %d %d", &y1, &y2, &y3, &y4, &y5, &y6), y1 --, y2 --, y5 ++, y6 ++;
      |                                                            ^~
a.cc:168:63: error: lvalue required as decrement operand
  168 | scanf ("%d %d %d %d %d %d", &y1, &y2, &y3, &y4, &y5, &y6), y1 --, y2 --, y5 ++, y6 ++;
      |                                                               ^~
a.cc:172:13: error: no matching function for call to 'std::vector<std::pair<std::pair<int, int>, int> >::push_back(<brace-enclosed initializer list>)'
  172 | L.push_back ({{x1, y1}, +1});
      | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<std::pair<int, int>, int> >; value_type = std::pair<std::pair<int, int>, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<std::pair<int, int>, int> >::value_type&' {aka 'const std::pair<std::pair<int, int>, int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<std::pair<int, int>, int> >; value_type = std::pair<std::pair<int, int>, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<std::pair<int, int>, int> >::value_type&&' {aka 'std::pair<std::pair<int, int>, int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:174:13: error: no matching function for call to 'std::vector<std::pair<std::pair<int, int>, int> >::push_back(<brace-enclosed initializer list>)'
  174 | L.push_back ({{x2 + 1, y1}, -1});
      | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<std::pair<int, int>, int> >; value_type = std::pair<std::pair<int, int>, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<std::pair<int, int>, int> >::value_type&' {aka 'const std::pair<std::pair<int, int>, int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<std::pair<int, int>, int> >; value_type = std::pair<std::pair<int, int>, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<std::pair<int, int>, int> >::value_type&&' {aka 'std::pair<std::pair<int, int>, int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~