QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#317464#7803. H-Shaped Figureslmf_upAC ✓297ms54824kbC++2020.1kb2024-01-29 01:22:462024-01-29 01:22:47

Judging History

你现在查看的是最新测评结果

  • [2024-01-29 01:22:47]
  • 评测
  • 测评结果:AC
  • 用时:297ms
  • 内存:54824kb
  • [2024-01-29 01:22:46]
  • 提交

answer

#include<bits/stdc++.h>

#define cp const point &
#define cl const line &
#define cc const circle &
#define LD long double
std::mt19937 rnd(time(0));
const LD eps = 1e-8;
const LD pi = std::numbers::pi;
const LD INF = 1e9;

int sgn(LD x)
{
    return x > eps ? 1 : (x < -eps ? -1 : 0);
}

LD sqr(LD x)
{ return x * x; }

struct point
{
    LD x, y;

    point operator+(cp a) const
    { return {x + a.x, y + a.y}; }

    point operator-(cp a) const
    { return {x - a.x, y - a.y}; }

    point operator*(LD t) const
    { return {x * t, y * t}; }

    point operator/(LD t) const
    { return {x / t, y / t}; }

    point rot(LD t) const
    { return {x * cos(t) - y * sin(t), x * sin(t) + y * cos(t)}; }

    point rot90() const
    { return {-y, x}; }

    LD len2() const
    { return x * x + y * y; }

    LD len() const
    { return sqrtl(x * x + y * y); }

    point unit() const
    {
        double d = len();
        return {x / d, y / d};
    }
    void print()
    {
        std::cout<<x<<' '<<y<<std::endl;
    }
    friend bool operator<(cp a, cp b)
    {
        return a.x == b.x ? a.y < b.y : a.x < b.x;
    }

    friend bool operator>(cp a, cp b)
    {
        return a.x == b.x ? a.y > b.y : a.x > b.x;
    }
};

LD dot(cp a, cp b);

bool operator==(cp a, cp b)
{
    return !sgn(dot(a - b, a - b));
}

LD dis(cp a, cp b)//两点距离
{
    return sqrtl(sqr(a.x - b.x) + sqr(a.y - b.y));
}

LD dot(cp a, cp b)//点乘
{
    return a.x * b.x + a.y * b.y;
}

LD det(cp a, cp b)//叉乘
{
    return a.x * b.y - b.x * a.y;
}

bool turn_left(cp a, cp b, cp c)//判断ba是否逆时针转少于180°到ca
{
    return sgn(det(b - a, c - a)) > 0;//大于是严格凸包
}

struct line
{
    point s, t;
    line() {}
    line(point a, point b) : s(a), t(b)
    {}
};

struct circle
{
    point c;
    LD r;

    circle()
    {}

    circle(point C, LD R)
    { c = C, r = R; }
};

bool in_circle(cp a, cc b)
{
    return sgn((b.c - a).len() - b.r) <= 0;
}

circle make_circle(point u, point v)
{
    point p = (u + v) / 2;
    return circle(p, (u - p).len());
}

circle make_circle(cp a, cp b, cp c)
{
    point p = b - a, q = c - a;
    point s(dot(p, p) / 2, dot(q, q) / 2);
    LD d = det(p, q);
    p = point(det(s, point(p.y, q.y)), det(point(p.x, q.x), s)) / d;
    return circle(a + p, p.len());
}

circle min_circle(std::vector<point> p)
{
    circle ret(p[0], 0);
    std::shuffle(p.begin(), p.end(), rnd);
    int len = p.size();
    for (int i = 0; i < len; i++)
        if (!in_circle(p[i], ret))
        {
            ret = circle(p[i], 0);
            for (int j = 0; j < i; j++)
                if (!in_circle(p[j], ret))
                {
                    ret = make_circle(p[j], p[i]);
                    for (int k = 0; k < j; ++k)
                        if (!in_circle(p[k], ret))
                            ret = make_circle(p[i], p[j], p[k]);
                }
        }
    return ret;
}


bool same_dir(cl a, cl b)//判断方向是否一致
{
    return sgn(det(b.t - b.s, a.t - a.s)) == 0 && sgn(dot(b.t - b.s, a.t - a.s)) > 0;
}

bool point_on_line(cp a, cl l)//判断点是否在直线上
{
    return sgn(det(a-l.s, l.t - l.s)) == 0;
}

bool point_on_segment(cp a, cl l)//判断点是否在线段上
{
    return point_on_line(a, l) && sgn(dot(l.s - a, l.t-a )) < 0;//(<=代表可以端点
}

bool two_side(cp a, cp b, cl c)//判断两个点是否在线段的两边
{
    return sgn(det(a - c.s, c.t - c.s)) * sgn(det(b - c.s, c.t - c.s)) < 0;
}

bool intersect_judge(cl a, cl b)
{//判断两个线段是否相交
    if (point_on_segment(a.s, b) || point_on_segment(a.t, b) || point_on_segment(b.s, a) ||
        point_on_segment(b.t, a))
        return true;
    return two_side(a.s, a.t, b) && two_side(b.s, b.t, a);
}

point line_intersect(cl a, cl b)
{//得到两线段的交点
    double s1 = det(a.t - a.s, b.s - a.s);
    double s2 = det(a.t - a.s, b.t - a.s);
    return (b.s * s2 - b.t * s1) / (s2 - s1);
}

bool point_on_ray(cp a, cl b)
{//判断点是否在射线上
    return sgn(det(a - b.s, b.t - b.s)) == 0 && sgn(dot(a - b.s, b.t - b.s)) >= 0;
}

bool ray_intersect_judge(line a, line b)//判断两射线是否相交
{
    double s1, s2;
    s1 = det(a.t - a.s, b.s - a.s);
    s2 = det(a.t - a.s, b.t - a.s);
    if (sgn(s1) == 0 && sgn(s2) == 0)
        return sgn(dot(a.t - a.s, b.s - a.s)) >= 0 || sgn(dot(b.t - b.s, a.s - b.s));
    if (!sgn(s1 - s2) || sgn(s1) == sgn(s2 - s1))return 0;
    std::swap(a, b);
    s1 = det(a.t - a.s, b.s - a.s);
    s2 = det(a.t - a.s, b.t - a.s);
    return sgn(s1) != sgn(s2 - s1);
}

LD point_to_line(cp a, cl b)
{//点到直线的距离
    return abs(det(b.t - b.s, a - b.s)) / dis(b.s, b.t);
}

point project_to_line(cp a, cl b)
{//得到点在线上的投影
    return b.s + (b.t - b.s) * (dot(a - b.s, b.t - b.s) / (b.t - b.s).len2());
}

LD point_to_segment(cp a, cl b)
{//点到线段的距离
    if (b.s == b.t)
        return dis(a, b.s);
    if (sgn(dot(b.s - a, b.t - b.s)) * sgn(dot(b.t - a, b.t - b.s)) <= 0)
        return abs(det(b.t - b.s, a - b.s)) / dis(b.s, b.t);
    return std::min(dis(a, b.s), dis(a, b.t));
}
std::vector<point>line_circle_intersect(cl a,cc b)
{//返回线与圆的交点
    if(sgn(point_to_segment(b.c,a)-b.r)>0)
        return std::vector<point>();
    LD x=sqrtl(sqr(b.r)- sqr(point_to_line(b.c,a)));
    return std::vector<point>({project_to_line(b.c,a)+(a.s-a.t).unit()*x, project_to_line(b.c,a)-(a.s-a.t).unit()*x});
}
LD circle_intersect_area(cc a,cc b){
    LD d=dis(a.c,b.c);
    if(sgn(d-(a.r+b.r))>=0)return 0;
    if(sgn(d- abs(a.r-b.r))<=0){
        LD r=std::min(a.r,b.r);
        return r*r*pi;
    }
    LD x=(d*d+a.r*a.r-b.r*b.r)/(2*d),
    t1=acosl(std::min((LD)1,std::max((LD)-1,x/a.r))),
    t2=acosl(std::min((LD)1,std::max((LD)-1,(d-x)/b.r)));
    return sqr(a.r)*t1+ sqr(b.r)*t2-d*a.r*sinl(t1);
}
std::vector<point> circle_intersect(cc a,cc b)
{
    if(a.c==b.c||sgn(dis(a.c,b.c)-a.r-b.r)>0||sgn(dis(a.c,b.c)-abs(a.r-b.r))<0)
        return {};
    point r=(b.c-a.c).unit();
    LD d=dis(a.c,b.c);
    LD x=((sqr(a.r)-sqr(b.r))/d+d)/2;
    LD h=sqrtl(sqr(a.r)-sqr(x));
    if(sgn(h)==0)return {a.c+r*x};
    return {a.c+r*x+r.rot90()*h,a.c+r*x-r.rot90()*h};
}
std::vector<point>tangent(cp a,cc b)
{
    circle p= make_circle(a,b.c);
     return circle_intersect(p,b);
}
std::vector<line>extangent(cc a,cc b)
{
    std::vector<line>ret;
    if(sgn(dis(a.c,b.c)-abs(a.r-b.r))<=0)return ret;
    if(sgn(a.r-b.r)==0)
    {
        point dir=b.c-a.c;
        dir=(dir*a.r/dir.len()).rot90();
        ret.push_back(line(a.c+dir,b.c+dir));
        ret.push_back(line(a.c-dir,b.c-dir));
    }
    else{
        point p=(b.c*a.r-a.c*b.r)/(a.r-b.r);
        std::vector pp= tangent(p,a),qq= tangent(p,b);
        if(pp.size()==2&&qq.size()==2)
        {
            if(sgn(a.r-b.r)<0)
                std::swap(pp[0],pp[1]),std::swap(qq[0],qq[1]);
            ret.push_back(line(pp[0],qq[0]));
            ret.push_back(line(pp[1],qq[1]));
        }
    }
    return ret;
}
std::vector<line>intangeent(cc a,cc b)
{
    std::vector<line> ret;
    point p=(b.c*a.r+a.c*b.r)/(a.r+b.r);
    std::vector pp= tangent(p,a),qq= tangent(p,b);
    if(pp.size()==2&&qq.size()==2){
        ret.push_back(line(pp[0],qq[0]));
        ret.push_back(line(pp[1],qq[1]));
    }
    return ret;
}
std::vector<point>cut(const std::vector<point>&c,line p){
    std::vector<point>ret;
    if(c.empty())return ret;
    int len=c.size();
    for(int i=0;i<len;i++)
    {
        int j=(i+1)%len;
        if(turn_left(p.s,p.t,c[i]))ret.push_back(c[i]);
        if(two_side(c[i],c[j],p))
            ret.push_back(line_intersect(p,line(c[i],c[j])));
    }
    return ret;
}
std::vector<point> convex_hull(std::vector<point> a)
{//凸包,字典序
    int n = (int) a.size(), cnt = 0;
    if (n < 2) return a;
    std::sort(a.begin(), a.end()); // less<pair>
    std::vector<point> ret;
    for (int i = 0; i < n; ++i)
    {
        while (cnt > 1
               && !turn_left(ret[cnt - 1], a[i], ret[cnt - 2]))
            --cnt, ret.pop_back();
        ++cnt, ret.push_back(a[i]);
    }
    int fixed = cnt;
    for (int i = n - 2; i >= 0; --i)
    {
        while (cnt > fixed
               && !turn_left(ret[cnt - 1], a[i], ret[cnt - 2]))
            --cnt, ret.pop_back();
        ++cnt, ret.push_back(a[i]);
    }
    ret.pop_back();
    return ret;
}

std::vector<point> minkovski(std::vector<std::vector<point>> a)
{
    if (a[0].size() == 1)
        return a[1];
    if (a[1].size() == 1)
        return a[0];
    for (int i = 0; i < 2; i++)a[i].push_back(a[i].front());
    int i[2] = {0, 0}, len[2] = {(int) a[0].size() - 1, (int) a[1].size() - 1};
    std::vector<point> ret;
    ret.push_back(a[0][0] + a[1][0]);
    do
    {
        int d = sgn(det(a[1][i[1] + 1] - a[1][i[1]], a[0][i[0] + 1] - a[0][i[0]])) >= 0;
        ret.push_back(a[d][i[d] + 1] - a[d][i[d]] + ret.back());
        i[d] = (i[d] + 1) % len[d];
    }
    while (i[0] || i[1]);
    return ret;
}

struct Convex
{
    int n;
    std::vector<point> a, upper, lower;

    Convex(std::vector<point> _a) : a(_a)
    {
        n = a.size();
        int k = 0;
        for (int i = 1; i < n; i++)if (a[k] < a[i])k = i;
        for (int i = 0; i <= k; i++) lower.push_back(a[i]);
        for (int i = k; i < n; i++) upper.push_back(a[i]);
        upper.push_back(a[0]);
    }

    std::pair<LD, int> get_tan(std::vector<point> &con, point vec)
    {
        int l = 0, r = (int) con.size() - 2;
        for (; l + 1 < r;)
        {
            int mid = (l + r) / 2;
            if (sgn(det(con[mid + 1] - con[mid], vec)) > 0)r = mid;
            else l = mid;
        }
        return std::max(std::make_pair(det(vec, con[r]), r), std::make_pair(det(vec, con[0]), 0));
    }

    void upd_tan(cp p, int id, int &i0, int &i1)
    {
        if (sgn(det(a[i0] - p, a[id] - p)) > 0) i0 = id;
        if (sgn(det(a[i1] - p, a[id] - p)) < 0) i1 = id;
    }

    void search(int l, int r, point p, int &i0, int &i1)
    {
        if (l == r)return;
        upd_tan(p, l % n, i0, i1);
        int sl = sgn(det(a[l % n] - p, a[(l + 1) % n] - p));
        for (; l + 1 < r;)
        {
            int mid = (l + r) / 2;
            int smid = sgn(det(a[mid % n] - p, a[(mid + 1) % n] - p));
            if (smid == sl)l = mid;
            else r = mid;
        }
        upd_tan(p, r % n, i0, i1);
    }

    int search(point u, point v, int l, int r)
    {
        int sl = sgn(det(v - u, a[l % n] - u));
        for (; l + 1 < r;)
        {
            int mid = (l + r) / 2;
            int smid = sgn(det(v - u, a[mid % n] - u));
            if (smid == sl) l = mid;
            else r = mid;
        }
        return l % n;
    }

    //判定点是否在凸包内,在边界返回true
    bool contain(point p)
    {
        if (p.x < lower[0].x || p.x > lower.back().x)return false;
        int id = std::lower_bound(lower.begin(), lower.end(), point(p.x, -INF)) - lower.begin();
        if (lower[id].x == p.x)
        {
            if (lower[id].y > p.y)return false;
        }
        else if (det(lower[id - 1] - p, lower[id] - p) < 0)
            return false;
        id = std::lower_bound(upper.begin(), upper.end(), point(p.x, INF), std::greater<point>()) - upper.begin();
        if (upper[id].x == p.x)
        {
            if (upper[id].y < p.y)return false;
        }
        else if (det(upper[id - 1] - p, upper[id] - p) < 0)
            return false;
        return true;
    }
    bool get_tan(point p,int &i0,int &i1){// 求点 p 关于凸包的两个切点, 如果在凸包外则有序返回编号, 共线的多个切点返回任意一个, 否则返回 false
        i0=i1=0;
        int id=int(std::lower_bound(lower.begin(),lower.end(),p)-lower.begin());
        search(0,id,p,i0,i1);
        search(id,(int)lower.size(),p,i0,i1);
        id=int(std::lower_bound(upper.begin(),upper.end(),p,std::greater<point>())-upper.begin());
        search((int)lower.size()-1,(int)lower.size()-1+id,p,i0,i1);
        search((int)lower.size()-1+id,(int)lower.size()-1+(int)upper.size(),p,i0,i1);
        return true;
    }
    // 求凸包上和向量 vec 叉积最大的点, 返回编号, 共线的多个切点返回任意一个
    int get_tan(point vec)
    {
        std::pair<LD,int>ret= get_tan(upper,vec);
        ret.second=(ret.second+(int)lower.size()-1)%n;
        ret=std::max(ret, get_tan(lower,vec));
        return ret.second;
    }
    // 求凸包和直线 u,v 的交点, 如果无严格相交返回 false. 如果有则是和 (i,next(i)) 的交点, 两个点无序, 交在点上不确定返回前后两条线段其中之一

    bool get_inter(point u,point v,int &i0,int &i1){
        int p0= get_tan(u-v),p1= get_tan(v-u);
        if(sgn(det(v-u,a[p0]-u))*sgn(det(v-u,a[p1]-u))<0)
        {
            if(p0>p1)std::swap(p0,p1);
            i0= search(u,v,p0,p1);
            i1= search(u,v,p1,p0+n);
            return true;
        }
        else return false;
    }
};
bool in_polygon(cp p,const std::vector<point>&po)
{
    int n=(int)po.size();int cnt=0;
    for(int i=0;i<n;i++)
    {
        point a=po[i],b=po[(i+1)%n];
        if(point_on_segment(p,line(a,b)))return true;
        int x=sgn(det(p-a,b-a)),y=sgn(a.y-p.y),z=sgn(b.y-p.y);
        if(x>0&&y<=0&&z>0)++cnt;
        if(x<0&&z<=0&&y>0)--cnt;

    }
    return cnt!=0;
}
bool In_Polygon(cp P,std::vector<point>&polygon)
{
    bool flag = false; //相当于计数
    point P1,P2; //多边形一条边的两个顶点
    int n=polygon.size();
    for(int i=0,j=n-1;i<n;j=i++)
    {
        //polygon[]是给出多边形的顶点
        P1 = polygon[i];
        P2 = polygon[j];
        if(point_on_segment(P,line(P1,P2)))return true;
        //前一个判断min(P1.y,P2.y)<P.y<=max(P1.y,P2.y)
        //这个判断代码我觉得写的很精妙 我网上看的 应该是大神模版
        //后一个判断被测点 在 射线与边交点 的左边
        if( (sgn(P1.y-P.y)>0 != sgn(P2.y-P.y)>0) && sgn(P.x - (P.y-P1.y)*(P1.x-P2.x)/(P1.y-P2.y)-P1.x)<0)
            flag = !flag;
    }
    return flag;
}
std::vector<point> Minkovski(std::vector<std::vector<point>> a)
{                                                            //闵可夫斯基和
    std::vector<point> S;
    int n = a[0].size(), m = a[1].size();
    std::vector<point> A(n ), B(m );
    for (int i = 0; i < n - 1; i++) A[i] = a[0][i + 1] - a[0][i];
    A[n - 1] = a[0][0] - a[0][n - 1];
    for (int i = 0; i < m - 1; i++) B[i] = a[1][i + 1] - a[1][i];
    B[m - 1] = a[1][0] - a[1][m - 1];                                                             //将两个凸包上的边向量都存入a,b中
    S.push_back(a[0][0] + a[1][0]);
    int p1 = 0, p2 = 0;
    while (p1 < n && p2 < m)
    {
        LD d = det(A[p1], B[p2]);
        if (d > 0)
            S.push_back(S.back()+A[p1++]);
        else if (d < 0)
            S.push_back(S.back()+B[p2++]);
        else
        {
            if(dot(A[p1],B[p1])>=0)
                S.push_back(S.back()+A[p1++]);
            else
            {
                auto [x,y]=A[p1];
                if(x>0)
                    S.push_back(S.back()+A[p1++]);
                else if(x<0)
                    S.push_back(S.back()+B[p2++]);
                else
                {
                    if(y>0)
                        S.push_back(S.back()+A[p1++]);
                    else S.push_back(S.back()+B[p2++]);
                }
            }
        }
    }
    while (p1 < n)
        S.push_back(S.back() + A[p1++]);
    while (p2 < m)
        S.push_back(S.back() + B[p2++]);
    return S;
}

void print(std::vector<point> res)
{
    std::cout << "print:\n";
    int cnt=0;
    for (auto [x, y]: res)
        std::cout <<++cnt<<' '<< x << ' ' << y << std::endl;
    std::cout << "end\n";
}
int flag=0;
int T;
struct BIT{
    int n;
    std::vector<int>sum;
    void init(int x)
    {
        sum.resize(x+1,0);
        n=x;
    }
    void add(int x,int y)
    {
        while(x<=n)
            sum[x]+=y,x+=x&-x;
    }
    int get_sum(int x)
    {
        int res=0;
        while(x>0)
            res+=sum[x],x-=x&-x;
        return res;
    }
};
void get_id(point p,std::vector<std::pair<point,std::array<int,3>>>&num,int op)
{
    int n=num.size();
    std::sort(num.begin(),num.end(),[&](auto x,auto y)
    {
        return sgn(det(x.first-p,y.first-p))>0;
    });
    int rk=0;

    for(int i=0;i<n;i++)
    {
        if(!i)
            num[i].second[op]=++rk;
        else
        {
            if(sgn(det(num[i].first-p,num[i-1].first-p))==0)
                num[i].second[op]=rk;
            else num[i].second[op]=++rk;
        }
    }
}
long long solve1(point p,point q,std::vector<line>left,std::vector<line>right)
{
    int len_left=left.size(),len_right=right.size();
    std::vector<std::pair<point,std::array<int,3>>>num;
    for(auto [s,t]:left)
        num.push_back(std::make_pair(s,std::array<int,3>{0,0,0}));
    for(auto [s,t]:right)
        num.push_back(std::make_pair(s,std::array<int,3>{0,0,1}));

    int n=num.size();
    get_id(p,num,0);
    get_id(q,num,1);
    std::sort(num.begin(),num.end(),[&](auto x,auto y)
    {
        return x.second<y.second;
    });
//    for(int i=0;i<n;i++){
//        auto [po,pp]=num[i];
//        auto [x,y,id]=pp;
//        po.print();
//        std::cout<<x<<' '<<y<<' '<<id<<std::endl;
//    }
    BIT tree;
    tree.init(n);
    long long res=0;
    for(auto [po, ider]:num)
    {
        auto [x,y,id]=ider;
        if(id)
            res+=tree.get_sum(y);
        else
            tree.add(y,1);
    }
    return res;
}
void solve()
{

    point p,q;
    std::cin>>p.x>>p.y;
    std::cin>>q.x>>q.y;
    int n;
    std::cin>>n;
    if(flag&&T==9)
    {
        if(n!=27063)
            flag=0;
    }
    std::vector<line>left,right;
    for(int i=0;i<n;i++)
    {
        point s,t;
        std::cin>>s.x>>s.y>>t.x>>t.y;
//        if(t==p||t==q||s==p||s==q)
//            i--,n--;
        if((det(t-s,p-q))==0)
            i--,n--;
        else if(point_on_segment(p,line(s,t)))
            left.push_back(line(s,t));
        else if(point_on_segment(q,line(s,t)))
            right.push_back(line(s,t));
        else i--,n--;
    }
//    if(flag&&T==3)
//        std::cout<<"YES7"<<std::endl;
//    if(T==4&&flag)
//        std::cout<<"YES1";
    long long len_left=left.size(),len_right=right.size();
//    std::cout<<len_left<<' '<<len_right<<std::endl;
    for(auto &[s,t]:left) if(sgn(det(q-p,s-p))<0) std::swap(s,t);
    for(auto &[s,t]:right) if(sgn(det(q-p,s-p))<0) std::swap(s,t);
//    for(auto [s,t]:left) s.print();
//    std::cout<<' '<<std::endl;
//    for(auto [s,t]:right) s.print();
//    if(T==4&&flag)
//        std::cout<<"YES2";
    long long ans=solve1(p,q,left,right);
//    if(T==4&&flag)
//        std::cout<<"YES3";
//    std::cout<<ans<<std::endl;
    for(auto &[s,t]:left) std::swap(s,t);
    for(auto &[s,t]:right) std::swap(s,t);
//    if(T==4&&flag)
//        std::cout<<"YES4";
    ans+=solve1(q,p,right,left);
//    if(T==4&&flag)
//        std::cout<<"YES5";
//    std::cout<<ans;
    std::cout<<len_left*1ll*len_right-ans<<std::endl;
//    return ;
//    if(T==4&&flag)
//        std::cout<<"YES6"<<std::endl;

}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0),std::cout.tie(0);
     T=1;
    std::cin>>T;
//    if(T!=10)
//        flag=0;
    while(T--)
        solve();
}
/*
1
2 1 0 -1
22
8 8 -4 -6
-4 -2 4 0
8 -8 -8 6
-10 -9 10 7
-4 -2 4 0
-6 1 10 1
-4 -10 4 8
4 5 0 -3
-5 3 9 -1
-5 8 9 -6
1 3 3 -1
-1 -8 5 10
0 -6 0 4
2 -7 2 9
7 -5 -3 7
0 -5 4 7
-3 5 7 -3
4 2 -4 -4
-7 3 7 -5
-4 0 8 2
4 -2 0 4
4 -1 0 3

23

 1
0 0 1 0
8
1 1 -1 -1
1 2 -1 -2
-1 2 1 -2
-1 1 1 -1
-2 2 1 -1
0 1 2 -1
4 1 -2 -1
1 2 1 -1

1
0 0 1 0
2
1 1 -1 -1
0 1 2 -1

1
0 0 1 0
5
1 1 -1 -1
-1 1 1 -1
0 1 2 -1
0 -1 2 1
1 -1 1 1
 */

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3960kb

input:

1
0 0 4 0
8
0 0 2 1
-1 -1 2 2
3 3 5 -3
0 2 6 -1
2 -2 5 1
-1 1 3 -3
-1 0 2 0
-1 -1 2 2

output:

6

result:

ok 1 number(s): "6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

1
-1 0 0 1
2
1 1 0 -1
1 1 0 1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3976kb

input:

1
5 -5 7 2
2
-6 8 2 6
-7 -10 -5 10

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3912kb

input:

10
-4 7 -10 -4
3
-3 3 -6 -9
-9 -3 -6 -9
-7 0 6 5
0 -5 -3 5
5
-7 -3 -5 -6
6 1 -3 4
1 -4 -4 7
-2 9 3 8
-4 -3 9 0
-9 -3 7 8
25
4 6 4 5
4 -6 -9 -6
-8 -8 10 -6
6 4 2 -7
2 -5 10 -4
-1 -9 -2 -1
-9 -10 6 6
-5 1 -5 -2
-1 -10 -6 1
9 -9 0 -4
-2 -4 -1 3
2 5 -10 1
9 7 6 4
-2 -5 -4 -3
-3 -5 5 -8
3 0 -6 1
6 3 7 2
...

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 0ms
memory: 4080kb

input:

10
-3 7 1 9
285
9 -5 0 8
-3 0 -1 8
-6 -7 8 -10
-3 -8 9 2
-4 9 -8 4
6 -10 9 -2
-10 -5 -2 10
7 -10 -2 2
7 7 10 -5
7 8 -7 -1
2 4 7 -4
3 -10 -9 8
7 -7 6 -3
10 10 -6 -2
-2 7 -8 3
0 -10 -9 5
7 3 -3 7
6 -8 -5 6
8 -8 7 7
-9 -1 10 7
-10 6 -4 -1
-6 -10 -6 0
9 6 2 -9
0 6 -1 -1
0 2 6 0
-9 -8 6 -2
10 7 -7 -5
2 5...

output:

1
0
9
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #6:

score: 0
Accepted
time: 9ms
memory: 3916kb

input:

10
-7 6 -3 1
1286
-9 -1 -2 -5
10 4 -2 0
0 6 -3 -10
-2 -9 2 -1
-10 2 -9 -2
1 -9 7 -4
-1 4 6 8
7 3 -9 9
5 2 -4 4
7 -9 -7 10
0 -2 0 6
3 -9 1 -10
-3 -4 -7 8
5 3 2 -1
5 2 -1 7
-9 -1 -6 -2
9 -6 10 0
8 -7 -7 -9
-10 8 -5 -9
-4 9 6 -9
-1 1 -3 -10
-7 -1 -6 3
5 4 -8 -1
-10 -10 5 0
-2 7 6 9
4 -3 -9 -2
10 -2 -7 ...

output:

9
237
0
0
162
0
15
0
17
10

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 188ms
memory: 3944kb

input:

100000
3 -9 -6 5
2
-9 9 3 -9
3 -4 -1 4
-3 10 -7 6
2
1 -2 -9 -10
3 -7 -9 8
8 1 8 -5
2
9 5 6 -3
-10 -5 -4 0
-9 10 -2 -1
2
-1 -2 -6 -4
1 9 -7 10
9 4 -9 9
2
-10 1 9 5
-8 5 -10 -7
-2 3 -6 10
2
-3 -4 7 -5
-8 6 8 -5
-9 -9 3 -2
2
0 8 6 -1
2 -6 5 -3
-5 -5 -4 -8
2
9 7 3 10
-1 -2 -8 -6
-5 -8 9 -9
2
-8 1 -5 -1
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 99ms
memory: 3912kb

input:

10000
0 -2 -10 8
22
-8 7 4 -6
-4 7 -6 -4
-2 -9 3 3
-10 -9 -1 7
9 -1 -6 -6
1 -6 6 -7
4 5 2 -4
-4 -5 8 -1
-10 -8 1 7
-1 -8 -1 -4
-1 2 -7 10
8 -6 0 -5
9 -3 -6 4
2 -4 5 -4
-4 0 -6 9
6 4 -1 -10
4 -1 -1 6
-2 10 -1 2
-2 10 -1 -1
-10 -5 -6 8
9 -3 1 -3
7 2 9 -3
-1 4 -3 7
16
-8 1 -5 -2
6 10 4 -4
-9 2 -3 9
10 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 10000 numbers

Test #9:

score: 0
Accepted
time: 89ms
memory: 3912kb

input:

1000
1 -2 2 -2
151
-5 -2 7 5
-3 5 9 9
-7 6 8 5
-4 10 8 3
0 0 5 8
4 9 2 -6
-7 -7 7 -3
0 -2 7 4
1 -4 -6 -7
0 -1 6 8
-1 -3 -5 7
3 -10 -3 -1
7 1 -6 10
0 -2 2 -8
8 5 -7 4
7 7 9 -7
-1 -7 -9 -6
5 -8 -8 1
-7 -6 1 8
-6 -4 -8 9
6 -2 9 7
-2 -3 9 7
-8 -1 3 -2
-6 5 1 5
6 -4 2 -10
8 1 -9 5
-5 4 0 1
-4 0 5 5
3 6 -...

output:

0
0
3
0
1
0
0
0
0
0
0
0
0
0
0
3
4
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
2
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
2
0
0
0
2
0
0
0
2
0
0
1
0
0
0
0
0
0
2
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21
0
0
0
6
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
1
0
8
0
0
0
0
0
4
2
0
0
0
0...

result:

ok 1000 numbers

Test #10:

score: 0
Accepted
time: 88ms
memory: 4008kb

input:

100
-2 -3 0 7
800
9 -1 -4 -1
5 1 2 9
-6 6 9 4
10 8 2 6
9 6 -4 6
-4 -4 1 -3
1 10 -7 1
5 6 -10 10
-4 -4 6 2
0 7 -8 10
1 0 0 -6
-9 -1 -2 -5
-8 -1 -5 3
10 -8 -1 9
-8 -2 7 7
8 -4 -2 -2
-10 1 4 -7
5 9 1 8
5 -7 -1 8
5 -6 9 -5
-5 0 8 1
6 -4 -3 0
-8 0 6 -5
-6 -5 10 -5
3 -3 -9 -5
7 -8 0 -9
-6 -5 5 4
7 8 2 -4
...

output:

2
2
69
67
0
0
0
60
6
0
110
0
8
3
57
17
78
3
0
67
0
0
131
2
494
0
0
108
0
31
28
78
0
228
0
2
4
14
23
325
52
0
25
0
0
59
602
12
135
52
193
0
5
123
19
13
36
41
17
0
0
165
0
4
28
81
0
0
22
8
4
2
0
7
7
3
0
0
0
0
4
3
0
0
6
0
0
0
9
0
6
0
122
274
0
1
569
0
314
0

result:

ok 100 numbers

Test #11:

score: 0
Accepted
time: 87ms
memory: 3912kb

input:

10
0 0 9 9
27063
-5 -4 -6 1
4 5 -10 1
1 4 4 -7
4 -9 -2 -10
-6 -9 -6 -2
-6 -9 -4 -6
-1 10 5 -4
6 5 6 -4
-10 3 -1 -9
1 2 10 8
10 1 -4 4
3 -9 1 -2
3 -8 -4 8
-7 0 -6 -1
0 1 6 8
10 1 -4 -1
2 -9 -6 -7
9 -10 -7 9
3 -6 -4 0
1 4 7 2
-2 0 -7 -2
8 -7 9 10
6 -5 3 3
9 4 1 9
1 -4 9 -1
5 -1 -7 9
9 -7 -9 6
0 8 6 7
...

output:

1663
1999
246
1664
6624
2444
6071
1004
0
383

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 88ms
memory: 4132kb

input:

1
-9 1 -1 -1
200000
-5 10 3 -2
9 7 -4 -4
4 6 -10 -2
10 -3 -9 3
-10 3 -8 -8
-1 9 7 10
-5 5 -2 -4
10 -8 -3 -4
-6 4 -4 -3
2 -10 -5 -1
-1 -6 10 5
1 -8 5 10
-6 2 0 -7
4 0 -4 6
0 3 -3 -5
1 -8 5 0
-2 -5 8 -8
-4 8 -10 0
8 -4 -10 -10
-4 2 -10 -5
-6 -1 10 8
-1 0 -10 5
-1 -4 4 3
7 7 3 5
6 -2 10 -10
-6 -9 -9 4
...

output:

391283

result:

ok 1 number(s): "391283"

Test #13:

score: 0
Accepted
time: 182ms
memory: 4068kb

input:

100000
-30 -50 -15 42
2
54 -2 34 37
92 92 -67 67
-14 7 -60 -52
2
28 50 45 10
77 95 75 42
2 -30 -65 92
2
82 -73 -16 90
35 50 28 93
34 -27 -98 -84
2
85 72 -48 -82
0 14 23 63
51 -47 -29 -23
2
-31 -36 -47 13
25 -68 -24 8
-2 96 -50 -98
2
-94 -52 85 -65
-37 -46 24 19
41 -78 -92 -67
2
-11 27 9 -13
-82 39 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 98ms
memory: 3912kb

input:

10000
-2 69 -8 -46
13
6 -35 95 -81
4 75 91 -3
67 -12 47 -97
7 -67 74 -22
76 95 -93 -67
-58 55 -51 -1
45 -44 33 37
-18 -84 18 -67
35 38 -31 83
-98 -10 99 -41
41 57 34 21
87 20 84 -30
25 -17 -42 -75
-87 -30 -74 18
9
-43 67 56 -28
72 -25 -5 98
-59 -33 21 -20
-7 -30 74 43
-41 -100 -5 -4
-88 77 -57 -68
2...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 10000 numbers

Test #15:

score: 0
Accepted
time: 88ms
memory: 3840kb

input:

1000
-30 1 19 44
146
13 -95 31 35
42 58 89 -5
-26 82 83 -31
-83 29 98 -39
-73 -91 86 -31
89 -75 -93 -12
85 34 -44 -84
-41 28 78 -20
97 -15 -27 16
35 -27 71 67
-68 58 -34 -66
99 18 56 88
-6 99 83 -13
44 87 -52 84
21 -94 64 25
34 79 -36 -21
72 -81 24 78
-92 44 -3 -92
37 76 -20 -90
95 70 49 -42
-11 -51...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 numbers

Test #16:

score: 0
Accepted
time: 91ms
memory: 3944kb

input:

100
-96 22 57 73
3897
-11 24 21 67
51 54 32 11
95 22 80 -38
94 83 24 40
-35 55 -78 -2
13 90 18 99
81 -46 -63 -17
-69 -52 -7 69
93 -33 15 66
89 39 37 39
-39 -42 80 -21
78 -57 17 64
42 70 -49 -15
-2 -63 -12 -44
-50 23 -93 -53
51 -54 -89 75
98 58 -10 -85
-13 57 56 -78
-45 38 -98 84
-74 -50 96 -29
-82 1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #17:

score: 0
Accepted
time: 90ms
memory: 3980kb

input:

10
56 -60 18 -3
11606
-25 -82 -64 -95
-20 51 57 16
36 -36 92 65
91 -34 -94 61
-30 -19 -10 11
-54 -8 45 29
-93 -27 -98 -14
-76 -10 21 55
85 -35 74 73
85 47 -78 54
59 52 33 39
20 -89 -80 61
34 -22 -17 -2
70 35 47 -4
85 -62 -43 15
-71 88 18 -5
15 -41 64 -50
22 82 97 32
-61 63 -33 81
-75 40 -45 -93
-17 ...

output:

1
0
0
32
0
0
15
0
0
0

result:

ok 10 numbers

Test #18:

score: 0
Accepted
time: 91ms
memory: 4116kb

input:

1
-83 57 -15 37
200000
-89 -45 54 41
-86 -5 11 99
-6 -43 37 -12
3 23 -52 -44
23 59 -78 43
-31 -22 -15 97
100 9 -37 34
-30 -2 33 60
-86 22 -91 -72
-7 -57 7 90
-19 3 -84 -100
-83 -17 -82 57
-14 67 -79 93
-64 -91 -35 -41
-74 16 -94 -42
0 86 -85 16
68 -78 -16 -91
-93 -39 -58 57
60 2 53 -14
-11 -22 -13 2...

output:

180

result:

ok 1 number(s): "180"

Test #19:

score: 0
Accepted
time: 192ms
memory: 3860kb

input:

100000
19854 22803 72344 78974
2
92058 39829 64547 -68879
-8344 29238 -60161 -92335
80266 -1746 55811 -27168
2
4852 -75936 17429 -16082
-28331 -629 59177 5339
43242 88523 48964 -93729
2
6020 36584 -69470 -32480
62985 -30399 1657 -14554
21351 -72662 -3935 -7296
2
-48786 -82958 45773 -67728
-96794 -98...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 103ms
memory: 3840kb

input:

1
-27969 51854 -41350 -18100
200000
37123 43400 -87468 75927
-4364 83045 78613 -66960
13392 -93810 41462 -69963
-85362 97766 4889 -33349
16277 86186 -77569 -85208
91033 -66776 -26886 -56098
18564 35677 -35224 45420
47017 -56641 -34505 -87030
-57757 4110 -7234 -29313
-34332 23932 3901 91091
73087 -77...

output:

0

result:

ok 1 number(s): "0"

Test #21:

score: 0
Accepted
time: 216ms
memory: 4076kb

input:

100000
-816084156 45345985 -809114376 38897510
2
-77832379 358421850 -316082520 -262180425
644176698 441808631 320726595 706144443
-845083578 178134515 -315798360 881807544
2
697452961 -634167100 -303275701 -967794117
173564593 -545926911 -868608924 828401067
667371571 -948204065 455255719 -52779314...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 114ms
memory: 3904kb

input:

100
-951698201 -265293426 -657086404 -136559362
6786
573648106 -252912773 620242295 581457590
951580284 681897535 -817738867 -132231400
854299175 -599755614 -82485608 -89108261
400416421 -159940457 273451634 927897379
606472084 -664312828 297804033 -934818972
440036342 -699849074 -605129048 -9315978...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #23:

score: 0
Accepted
time: 117ms
memory: 4000kb

input:

1
664476757 775661671 -460952714 -940529332
200000
602503004 -714067150 422736183 -916684357
638688933 -270306695 -595967030 142235971
-393400372 329594755 -384507397 468422405
-359113556 485787592 374594464 -417880421
-172028322 -765288212 -889383180 -474983301
-133547716 654038383 -291947477 -1958...

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

10
3 -2 -4 3
3
9 -6 -3 2
-3 -6 9 2
-7 3 -1 3
0 -5 -2 -1
5
-4 7 0 -9
-1 -5 1 -5
6 4 -10 -6
-2 -3 2 -7
-8 -8 8 -2
-3 2 -3 -5
25
-5 0 -1 4
-4 -1 -2 -9
0 -7 -6 -3
-5 1 -1 3
-3 -3 -3 -7
-9 0 3 4
-9 -2 3 6
-10 1 4 3
0 0 -6 -10
-8 3 2 1
-1 -4 -5 -6
0 -4 -6 8
-7 -7 1 -3
3 8 -9 -4
-3 4 -3 0
-1 -10 -5 0
-8 -3...

output:

2
3
120
212
191
1
211
253
131
3

result:

ok 10 numbers

Test #25:

score: 0
Accepted
time: 3ms
memory: 4056kb

input:

10
-1 4 5 2
285
3 6 -5 2
8 -3 2 7
6 -2 4 6
9 2 1 2
2 6 8 -2
-5 -2 3 10
3 5 7 -1
7 7 3 -3
8 -1 2 5
4 7 6 -3
-4 -1 2 9
6 -3 4 7
2 6 -4 2
3 0 7 4
10 -5 0 9
10 7 0 -3
8 4 -10 4
0 9 10 -5
1 3 9 1
0 2 10 2
-6 6 4 2
5 5 5 -1
-3 7 1 1
10 9 0 -5
-6 3 4 5
-8 1 6 7
-6 -1 4 9
3 0 -5 8
7 -2 3 6
-6 5 4 3
5 -3 5 7...

output:

14909
2441
49947
20028
6114
11554
130
3351
4258
442

result:

ok 10 numbers

Test #26:

score: 0
Accepted
time: 20ms
memory: 5072kb

input:

10
2 2 0 4
1286
-9 8 9 0
0 0 0 8
-9 -2 9 10
2 -1 2 5
3 4 1 0
-2 1 2 7
-6 -3 10 7
-1 4 5 0
8 0 -8 8
9 5 -9 3
-4 -2 4 10
-7 10 7 -2
-8 9 8 -1
8 5 -8 3
-6 1 10 3
-9 -1 9 9
3 4 1 0
-6 10 10 -6
9 6 -5 -2
-10 8 10 0
4 1 0 3
9 6 -5 -2
9 1 -5 3
-7 -1 7 9
10 -3 -6 7
0 -2 4 6
-4 1 4 7
4 -3 0 7
3 3 -3 5
6 9 -2...

output:

109385
5676613
53957
304654
7795050
116240
98554
10578
46532
294962

result:

ok 10 numbers

Test #27:

score: 0
Accepted
time: 234ms
memory: 3908kb

input:

100000
1 1 -1 -4
2
-5 8 7 -6
-4 -1 6 3
3 -4 -3 3
2
-4 3 -2 3
-9 8 3 -2
5 2 3 4
2
5 10 1 -2
10 -2 -4 10
2 3 -5 3
2
-3 9 -7 -3
9 5 -5 1
-5 -2 -4 2
2
-10 -9 0 5
-5 -8 -5 4
-5 2 0 -2
2
4 5 -4 -9
0 8 -10 -4
-2 -2 4 1
2
-2 -8 -2 4
7 3 1 -1
-4 -5 1 -2
2
-8 -5 10 1
-5 -1 -3 -9
4 0 3 -5
2
4 -10 4 10
-2 -3 8 ...

output:

0
0
0
1
0
1
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
1
1
1
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
1
0
1
1
1
1
1
0
0
0
0
0
1
0
1
0
0
1
0
1
0
0
1
0
0
1
0
0
1
1
0
1
0
1
0
1
0
0
1
1
1
1
0
0
0
1
1
0
0
0
1
0
0
1
0
1
1
0
...

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 157ms
memory: 4028kb

input:

10000
2 1 0 -1
22
8 8 -4 -6
-4 -2 4 0
8 -8 -8 6
-10 -9 10 7
-4 -2 4 0
-6 1 10 1
-4 -10 4 8
4 5 0 -3
-5 3 9 -1
-5 8 9 -6
1 3 3 -1
-1 -8 5 10
0 -6 0 4
2 -7 2 9
7 -5 -3 7
0 -5 4 7
-3 5 7 -3
4 2 -4 -4
-7 3 7 -5
-4 0 8 2
4 -2 0 4
4 -1 0 3
-3 1 2 -1
16
-4 -4 -2 6
-1 2 5 -4
-10 10 4 -8
-3 1 7 -3
-4 -9 8 7
...

output:

23
34
0
10
63
93
5
54
3
9
185
2
178
1
69
10
16
128
4
12
1
1508
4
15
0
17
1861
10
48
0
36
2
307
12
546
27
33
2
1
6
2
3
8
2
23
29
63
16
1216
142
599
20
39
1
4
469
48
77
8
16
8
7
26
33
16
10
94
25
85
218
7
431
177
41
1
908
170
127
40
363
6
0
37
153
9
12
64
6
2
2
429
1
19
4
6
19
129
3
3
14
14
229
42
108...

result:

ok 10000 numbers

Test #29:

score: 0
Accepted
time: 170ms
memory: 4152kb

input:

1000
5 -4 -3 -3
151
1 -5 9 -3
3 0 -9 -6
-6 0 0 -6
2 -6 8 -2
-1 -5 -5 -1
4 1 -10 -7
2 -9 8 1
0 -1 -6 -5
0 1 10 -9
-3 -5 -3 -1
-9 2 3 -8
0 -2 -6 -4
4 -2 -10 -4
5 -7 5 -1
0 0 10 -8
5 -8 5 0
5 -1 5 -7
-4 -8 -2 2
9 -9 1 1
3 -2 -9 -4
10 -3 0 -5
1 -9 9 1
3 -7 7 -1
-4 -2 -2 -4
4 -9 -10 3
10 -5 0 -3
10 -6 0 ...

output:

5361
5828
5357
199
4085
3768
5453
15
12921
2375
844
16676
420
238
30322
27232
186511
3116
15
13987
395
2
7786
5331
19394
49
8214
33131
362
3595
0
1602
19179
3907
24
18
44294
66052
2761
610
12083
219
3367
899
2344
7368
1247
194
10427
203
4878
8
4514
718
91
11136
3356
12075
468
70145
63
658
379
9191
2...

result:

ok 1000 numbers

Test #30:

score: 0
Accepted
time: 189ms
memory: 6044kb

input:

100
5 3 2 5
800
7 7 3 -1
1 2 9 4
5 7 -1 3
9 4 -5 6
4 2 0 8
6 9 4 -3
-1 10 5 0
1 10 3 0
4 9 6 -3
-4 6 8 4
3 10 1 0
-5 3 9 7
8 8 -4 2
7 8 -3 2
8 6 2 0
8 1 2 5
1 7 3 3
0 6 4 4
6 6 4 0
5 4 5 2
8 8 -4 2
8 2 -4 8
4 2 0 8
6 0 -2 10
3 8 7 -2
8 -4 2 10
8 0 2 6
7 8 -3 2
7 9 3 -3
-2 7 6 3
9 6 1 0
3 0 1 10
4 9 ...

output:

67559
1545601
398959
1050622
298157
38
468916
1571817
467329
8722
1501009
588
251558
32897
237449
288095
505815
6837
2264
299095
28446
1525
7005874
1514784
19536223
39442
217707
1630499
180340
518583
224522
2072468
68561
3972690
9950
7630483
37395
1128352
2370063
3533077
97659
1080
88977
2769
104575...

result:

ok 100 numbers

Test #31:

score: 0
Accepted
time: 188ms
memory: 14544kb

input:

10
4 4 -2 2
27063
-5 10 1 -6
1 4 7 4
-7 7 3 -3
1 4 7 4
6 4 -10 0
10 5 -2 3
1 -3 -5 7
1 2 7 6
5 1 -9 3
4 3 4 5
4 1 4 7
-6 -1 2 5
1 1 7 7
8 10 0 -2
1 3 7 5
-7 9 3 -5
0 5 8 3
2 -2 -6 6
4 1 4 7
6 -5 -10 9
-3 7 -1 -3
4 1 4 7
10 3 -2 5
-9 6 5 -2
-1 6 9 2
7 4 1 4
4 -3 -8 7
7 4 1 4
0 0 -4 4
-9 -6 5 10
1 -1 ...

output:

132022367
14030410
305084211
19676780
27608847
18594702
183120255
7344363
21053
9167933

result:

ok 10 numbers

Test #32:

score: 0
Accepted
time: 237ms
memory: 52412kb

input:

1
-3 5 -4 -4
200000
2 1 -10 -9
-8 -3 0 -5
-9 0 3 10
-6 2 0 8
-2 -6 -6 -2
-5 1 -1 9
-3 -7 -5 -1
-4 2 -4 -10
0 -9 -8 1
3 7 -9 3
-2 1 -6 -9
-9 4 3 6
2 -7 -10 -1
-7 -9 -1 1
-4 1 -2 9
-9 2 1 -10
0 -8 -8 0
-3 0 -3 10
-6 0 0 10
0 -1 -8 -7
-2 -9 -6 1
-1 -6 -7 -2
-8 3 2 7
-7 6 1 4
1 -2 -9 -6
3 10 -9 0
-7 -8 ...

output:

9825159552

result:

ok 1 number(s): "9825159552"

Test #33:

score: 0
Accepted
time: 198ms
memory: 3844kb

input:

100000
-50 10 -29 -24
2
-12 -73 -88 93
-52 28 -48 -8
-16 23 -20 20
2
-93 66 61 -20
2 -30 -42 70
-41 11 -22 22
2
20 34 -64 10
-84 85 2 -63
22 10 -32 40
2
-29 -80 73 100
-47 13 -17 67
-20 5 39 37
2
13 -10 65 84
19 41 59 33
-32 -11 23 -47
2
31 -14 15 -80
-82 39 18 -61
40 15 7 -16
2
98 52 -84 -84
1 -94 ...

output:

0
0
0
1
0
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
0
0
1
1
0
1
0
0
1
1
0
1
0
0
1
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
1
1
0
0
0
1
1
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
1
0
1
1
1
0
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
0
0
0
1
0
0
1
0
1
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
0
1
0
0
0
1
1
0
...

result:

ok 100000 numbers

Test #34:

score: 0
Accepted
time: 164ms
memory: 4024kb

input:

10000
-22 38 17 9
13
54 85 -98 -9
-81 4 37 72
20 15 -64 61
7 -67 27 85
-27 -21 -17 97
38 -31 -4 49
-14 -25 48 43
41 57 -85 19
-41 79 -3 -3
-17 -42 51 60
60 87 -26 -69
-43 67 77 -49
-65 56 21 20
-22 -39 -43 46
9
-20 -7 -66 99
-57 41 -29 51
-5 -4 -39 -74
-54 94 -32 -2
-100 -82 56 4
-50 69 -36 23
-55 7...

output:

26
18
43
92
9
378
450
0
15
146
0
409
214
18
6
6
1
33
1
170
12
14
328
66
9
26
73
27
0
1
21
141
932
1555
44
226
757
183
78
30
15
286
117
106
40
347
0
0
4
0
10
26
7
283
1
8
262
18
39
95
6
461
180
7
298
101
73
208
84
12
3
2
2
24
12
47
12
4
50
957
2
13
53
3
107
20
0
101
13
679
5
1
18
50
0
72
104
1
0
359
...

result:

ok 10000 numbers

Test #35:

score: 0
Accepted
time: 195ms
memory: 4092kb

input:

1000
-24 2 50 -50
146
-50 37 2 -33
34 -44 66 -56
-100 43 52 -39
78 -20 22 -80
49 20 -97 -16
67 -68 33 -32
24 -46 76 -54
44 87 -92 -83
-24 -53 -24 57
79 -36 21 -64
60 -2 40 -98
49 -42 51 -58
-2 -61 -46 65
14 46 -62 -42
80 -57 20 -43
92 -86 8 -14
70 -69 30 -31
-68 83 20 -79
53 -41 47 -59
-92 -20 44 24...

output:

5128
265
3861
17458
46
1292
4450
742
695
6753
22
10935
111
165
135149
955
4687
918
12
1
100
13888
1158
33939
48606
1042
11871
170490
37507
122
3006
25618
1084
7165
689
82
26341
53
4873
584
281
21
703
997
562
5245
287
13125
840
184
3392
1358
25253
4328
98
6
6152
14520
1004
45
1627
2
79355
7539
22224
...

result:

ok 1000 numbers

Test #36:

score: 0
Accepted
time: 221ms
memory: 6072kb

input:

100
-18 -13 -10 -22
3897
60 -36 -96 10
40 -35 -60 -9
-61 -81 25 55
-63 -17 27 -9
10 53 -46 -79
-33 15 13 -59
-6 -39 -14 -5
37 39 -57 -83
42 70 -78 -96
-57 17 37 -61
-92 -70 56 44
-49 -15 13 -11
-52 -90 16 64
-44 -50 8 24
-67 46 31 -72
-10 -85 -26 59
-89 -57 53 31
38 -98 -58 54
-79 -82 43 56
-82 19 6...

output:

516346
52247
235660
7866
1261867
1550910
166258
1525247
1071904
446095
110705
105699
1154668
639252
13224449
211085
439831
50714
9382
36784
1232852
10688278
247237
426580
554198
34480
78817
89813
867916
12289
762938
12580
41751
6328
793
49261
642565
1583425
1661412
310065
6673
7931
30
778032
9913
22...

result:

ok 100 numbers

Test #37:

score: 0
Accepted
time: 242ms
memory: 29300kb

input:

10
13 42 21 -41
11606
70 12 -28 -94
-34 -94 76 12
2 93 24 -9
85 -35 -43 -47
-59 70 85 14
-22 -17 64 -65
-65 38 91 46
85 -62 -43 -20
13 60 13 24
-5 15 31 69
-29 76 55 8
-45 -93 87 11
70 69 -44 15
59 -81 -17 -1
96 -9 -70 93
48 -6 -6 -76
25 -83 17 1
-21 74 47 10
-56 -11 82 95
-63 28 89 56
44 -11 -2 -71...

output:

32989711
1982273
25739
1988570990
9454144
49432434
305399861
50674798
207826
14097434

result:

ok 10 numbers

Test #38:

score: 0
Accepted
time: 243ms
memory: 50652kb

input:

1
-13 -11 -5 -9
200000
-71 -35 61 17
41 -86 -67 64
56 -42 -82 20
3 23 -29 -45
-13 -24 -13 2
59 -78 -85 56
-90 -24 80 6
-37 34 27 -52
30 -11 -40 -7
60 -86 -70 68
-26 -28 16 10
-19 3 -7 -25
-82 -24 72 6
-17 -82 7 64
34 -8 -60 -14
-64 -91 38 69
43 -65 -53 47
16 -94 -26 76
-49 61 23 -83
-85 16 59 -38
28...

output:

887682699

result:

ok 1 number(s): "887682699"

Test #39:

score: 0
Accepted
time: 241ms
memory: 3836kb

input:

100000
41815 38439 10177 -13878
2
-12667 -1923 96297 78801
-629 59177 84259 17701
-35846 -25342 -10356 6739
2
4123 -33899 -24835 47377
-69470 -32480 48758 45958
33231 -35906 619 4356
2
52011 -52920 14451 -18892
31518 -73714 34944 1902
25668 10036 7285 9978
2
24488 -40809 -9918 60765
38511 -29066 -23...

output:

0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
0
1
0
0
1
1
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
0
1
0
0
1
1
...

result:

ok 100000 numbers

Test #40:

score: 0
Accepted
time: 185ms
memory: 4160kb

input:

10000
-49135 -18234 -12117 -5496
11
61030 20169 -85264 -31161
-84533 -10067 -13737 -26401
-15272 -8564 -82998 -27904
-70286 -46965 -27984 10497
-12071 17742 -86199 -54210
-29235 -10088 5001 -904
23771 67493 -48005 -78485
-58232 -47487 -40038 11019
-62478 -750 -35792 -35718
-31894 -25572 7660 14580
-...

output:

20
0
915
49
30
5
383
248
24
369
12
56
115
3
72
159
149
304
2
15
0
0
513
155
22
33
152
168
4
0
2
1
18
1
12
11
204
557
281
12
17
168
0
44
477
7
112
135
3
25
140
40
0
56
49
43
5
1
38
0
0
74
14
103
99
2
10
11
0
33
29
31
35
2
6
697
1
95
5
2
31
17
23
0
416
2
1
0
12
97
2
8
0
59
33
24
87
126
116
2
22
232
46...

result:

ok 10000 numbers

Test #41:

score: 0
Accepted
time: 194ms
memory: 4148kb

input:

1000
3620 -7916 16564 23759
98
12481 -5481 20647 52999
50468 -29808 -17340 77326
-16265 36095 49393 11423
-20891 -74303 28131 58471
43112 -43367 -9984 90885
19030 -69326 -11790 53494
26275 79666 6853 -32148
-21340 1325 54468 46193
14560 -86904 -7320 71072
-19523 -50696 26763 34864
32331 38380 797 91...

output:

949
2139
1009
16416
111
2060
6759
5122
586
9663
10317
3
12019
2
53314
45629
2094
1
12536
675
2250
223
1271
506
6030
68882
5962
16172
737
2091
15735
89720
17791
23720
151
432
4259
335
340
5280
22
389
3428
23996
5709
22659
2301
1475
10354
10194
2164
2419
5847
17637
7149
21659
3350
16
526
17018
1023
39...

result:

ok 1000 numbers

Test #42:

score: 0
Accepted
time: 222ms
memory: 6700kb

input:

100
15416 32842 -49542 15299
1333
-147 -23353 -98937 53951
-36601 -32605 67433 98289
49660 55389 -18828 10295
1603 -9605 29229 75289
-93589 24536 -5495 6062
-81302 14124 -17782 16474
30716 13991 116 51693
-66540 -35773 -32544 66371
85006 36125 -54174 29559
-30227 -20610 61059 86294
-27150 47229 -719...

output:

362408
323543
74867
93954
758054
259960
4702675
616274
6848
350437
45914
65836
27615
35388
31677
1190
3420695
639013
95582
545890
143
13955573
1793498
58093
220808
35135
17262
3600
14558235
362131
7185783
30044
36895
2355768
49230
8233659
2033664
894513
730610
657140
13420
1925129
144136
512180
1201...

result:

ok 100 numbers

Test #43:

score: 0
Accepted
time: 256ms
memory: 14512kb

input:

10
47559 2806 -29653 -12256
37094
80548 95548 14570 -89936
-40852 -48857 -18454 24345
16136 35657 -75442 -60169
85300 -41789 9818 47401
70354 18614 24764 -13002
-62348 -62002 3042 37490
18667 84615 76451 -79003
-78534 8669 19228 -33181
39514 30793 55604 -25181
80111 -81061 15007 86673
35239 30963 -9...

output:

328750440
18006884
31523531
273434919
4166715
463133694
12844040
20773955
19463947
58319789

result:

ok 10 numbers

Test #44:

score: 0
Accepted
time: 286ms
memory: 51764kb

input:

1
39256 19564 -37380 -6
200000
-18599 -2254 -56161 2242
75927 -4364 2585 43492
6830 59664 -81590 -59676
13392 -93810 -88152 93798
-77243 80733 2483 -80745
97766 4889 -19254 34239
40589 37845 37923 1283
18564 35677 59948 3451
-87804 21223 13044 -21235
4110 -7234 74402 46362
-99382 18507 24622 -18519
...

output:

9580483377

result:

ok 1 number(s): "9580483377"

Test #45:

score: 0
Accepted
time: 268ms
memory: 3852kb

input:

100000
28369820 -225643654 -349099994 353809028
2
839622837 209531965 -782883197 -660819273
-262180425 644176698 -436019563 63441358
289768027 -380160569 85662899 178817814
2
201553894 -325831367 -30228096 683466995
697452961 -634167100 -117916907 -126154038
-484256727 402839011 391775763 156222045
...

output:

1
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
1
1
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
1
0
1
0
1
0
0
0
1
1
0
1
1
1
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
1
0
1
1
0
0
0
0
0
1
0
...

result:

ok 100000 numbers

Test #46:

score: 0
Accepted
time: 195ms
memory: 4164kb

input:

10000
326490399 302139981 -159618605 354027429
8
-410264657 113471284 91027447 594583574
-630824725 -124377025 311587515 832431883
-903612694 -113375010 584375484 821429868
-230419734 871131709 883400532 -266851747
358022724 463508886 294958074 140771076
28483179 781772461 624497619 -177492499
59208...

output:

8
88
131
50
28
43
984
19
0
555
450
62
3
2
160
6
63
52
31
266
2
12
83
273
68
0
61
22
3
0
0
4
1
352
52
7
13
242
47
2
9
75
3
135
147
30
10
11
7
118
1
65
95
52
54
41
283
0
7
414
17
1647
1
0
3
11
0
6
131
47
229
146
3
10
4
16
348
0
0
74
56
66
21
10
56
1
53
150
652
98
148
38
5
5
70
22
42
142
90
22
100
7
23...

result:

ok 10000 numbers

Test #47:

score: 0
Accepted
time: 215ms
memory: 4024kb

input:

1000
354360242 274554282 105633474 236793198
218
-694987972 986466168 906254920 -512879772
775843795 605391612 -67123311 -56283048
-353078271 563155020 564345219 -89568624
139422368 661219189 71844580 -187632793
195303592 -337942789 513416892 887051353
414052051 -6715870 -202785103 480302266
4902425...

output:

3823
1710
20924
28603
76
437
74
527
1890
16131
9411
89
272
529414
241
53407
64
1420
86
18132
23588
2113
12414
205
4
373
2713
30938
710
66
7268
1525
33
7942
2105
1793
8971
95710
1205
22926
598
100
5304
78
226471
3765
11428
708
1595
10152
5194
4602
19108
2310
13543
14
4485
698
24642
2092
1478
96
9728
...

result:

ok 1000 numbers

Test #48:

score: 0
Accepted
time: 244ms
memory: 6076kb

input:

100
-127401178 249974274 -32135029 90446042
6786
171741738 299147462 -426544094 200801086
581457590 951580284 -645727648 -770688200
-510126448 185166601 445856390 -4274517
-82485608 -89108261 -172316748 589056809
231175780 115225430 -485978136 384723118
927897379 606472084 -992167437 -425580000
-714...

output:

2398299
14263
582
625487
3605114
7673305
1357304
15474
18740
1905
5374172
184647
85440
1073
7223
111616
17227
7133
579618
3896
11716
997749
7883553
228897
5772833
205187
1317456
227449
7563491
41714
8964
1002295
115930
8941
1223961
419957
25088
18483
1
724444
24326
16022
1551226
334371
137234
974
70...

result:

ok 100 numbers

Test #49:

score: 0
Accepted
time: 288ms
memory: 17640kb

input:

10
50946621 -186773964 8687835 377058482
11986
609111239 550157411 -591735569 203959553
919622943 970431371 -902247273 -216314407
583201553 630066018 -565825883 124050946
424426862 336358752 -322533620 -709906680
-564146553 508063305 581522223 246053659
128755401 -84461863 -111379731 838578827
-6899...

output:

26348718
21126361
57781048
872377607
705860
296332831
11941322
26921541
49773143
23867

result:

ok 10 numbers

Test #50:

score: 0
Accepted
time: 291ms
memory: 53748kb

input:

1
341473953 290793476 272161379 121992083
200000
774393247 -348842833 -230070489 592826999
142235971 -393400372 540711935 974987324
355892054 -295241991 327055852 876828943
-133547716 654038383 816495622 -72451431
-145853633 -67120131 828801539 648707083
503452455 93381540 179495451 488205412
-17757...

output:

2294906324

result:

ok 1 number(s): "2294906324"

Test #51:

score: 0
Accepted
time: 254ms
memory: 4072kb

input:

100000
400000000 200000000 1000000000 900000000
2
200000000 300000000 600000000 -900000000
600000000 -300000000 700000000 -900000000
-500000000 -500000000 -800000000 900000000
2
1000000000 -1000000000 600000000 1000000000
200000000 400000000 -800000000 1000000000
-500000000 -100000000 800000000 -200...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #52:

score: 0
Accepted
time: 127ms
memory: 3904kb

input:

10000
300000000 1000000000 -300000000 0
13
800000000 900000000 900000000 0
400000000 -300000000 200000000 500000000
300000000 -900000000 600000000 -200000000
0 800000000 200000000 -1000000000
100000000 -800000000 600000000 -100000000
-1000000000 -400000000 1000000000 500000000
-200000000 0 600000000...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
...

result:

ok 10000 numbers

Test #53:

score: 0
Accepted
time: 115ms
memory: 3988kb

input:

1000
-900000000 -1000000000 -500000000 -800000000
10
100000000 100000000 500000000 500000000
-600000000 1000000000 -1000000000 -700000000
1000000000 -700000000 500000000 -900000000
800000000 -1000000000 800000000 600000000
-500000000 -300000000 300000000 -200000000
-300000000 400000000 -500000000 80...

output:

0
0
0
0
0
0
0
4
0
0
3
0
0
0
0
0
0
0
0
0
0
10
1
0
0
3
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
6
0
0
0
0
4
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
19
0
0
0
3
2
1
0
9
0
0
0
4
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
6
0
0
0
0
0
0
2
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 numbers

Test #54:

score: 0
Accepted
time: 118ms
memory: 3872kb

input:

100
100000000 -700000000 600000000 -200000000
2515
-800000000 -600000000 800000000 -300000000
700000000 800000000 -700000000 -700000000
100000000 1000000000 700000000 1000000000
500000000 -300000000 -700000000 -200000000
-700000000 400000000 700000000 900000000
700000000 -800000000 -800000000 -60000...

output:

117
0
2
0
407
5
22
2
0
46
18
6
34
939
20
0
1
0
117
0
20
68
0
101
45
39
7
69
29
36
71
0
10
184
0
5
37
138
20
0
0
18
10
122
0
1
0
0
16
0
137
2
7
30
0
0
21
40
0
2
0
0
90
0
71
0
0
18
2
0
0
172
3
23
55
261
0
0
143
0
31
16
104
257
2
95
318
2
134
0
0
0
41
0
6
6
0
5
0
0

result:

ok 100 numbers

Test #55:

score: 0
Accepted
time: 114ms
memory: 4072kb

input:

10
1000000000 -200000000 700000000 500000000
38932
-700000000 -800000000 600000000 500000000
200000000 -400000000 -800000000 200000000
-500000000 -100000000 1000000000 700000000
700000000 0 -500000000 -600000000
-500000000 -700000000 700000000 1000000000
-900000000 -800000000 0 800000000
500000000 -...

output:

4218
2782
269
440
54
827
6707
855
18211
0

result:

ok 10 numbers

Test #56:

score: 0
Accepted
time: 117ms
memory: 4100kb

input:

1
-500000000 -700000000 100000000 -900000000
200000
700000000 -300000000 -400000000 -400000000
500000000 -400000000 -300000000 200000000
900000000 100000000 -100000000 -700000000
300000000 -900000000 -300000000 600000000
900000000 800000000 0 -1000000000
-1000000000 500000000 600000000 300000000
-40...

output:

133313

result:

ok 1 number(s): "133313"

Test #57:

score: 0
Accepted
time: 251ms
memory: 3900kb

input:

100000
-49326617 24331295 -6853588 -36141157
2
-131977828 -109534096 34854492 -11676844
41981200 20435579 -55688376 -92717893
31377094 -30090422 36502857 1842652
2
-154477753 -406717098 303875711 573826302
-44832633 -77389768 793474364 442903038
15122731 -44641234 6554787 -6498344
2
672567203 183068...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #58:

score: 0
Accepted
time: 198ms
memory: 4080kb

input:

1000
-15019221 -35830777 -17023813 -26332081
130
830008707 -436557825 -440540073 178780791
-397435645 -464230885 173182103 192617321
211732733 -171659032 -245780359 118994870
313810727 -211183261 -97226708 8007344
14420490 -11287274 -174245328 -101556116
253963483 -482606417 -183133411 243403998
-80...

output:

106
1381
23351
14
14686
997
8
3
311
21981
102
255
445
56
70
5010
2366
323
16382
253
53
14672
570
535
7587
601
636
9012
6256
76
24
3153
343
27
29
1841
173
167
7985
594
1
5479
39
7556
2900
10152
1133
15
107
753
888
1703
90
17593
715
4721
25
581
59
158
13766
8371
206
2783
470
155
328
406
366
693
1958
1...

result:

ok 1000 numbers

Test #59:

score: 0
Accepted
time: 255ms
memory: 16704kb

input:

10
34785288 49550135 1276713 -31563980
60518
66613269 -37774217 -85838695 -23283664
218181195 -104910676 -515402433 512932568
-961317600 -417548657 781862454 399874229
79589671 -94377501 -54823478 337405407
772909593 869810300 -770356167 -932938260
35059153 98714487 -32505727 -161842447
-74843426 73...

output:

240939845
2490672
610623
92706940
27003709
577548
53760091
366968
2587074
2738020

result:

ok 10 numbers

Test #60:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

5
0 0 999999999 0
2
1000000000 999999999 -1000000000 -999999999
999999999 999999998 999999999 -999999998
0 0 999999998 0
2
999999999 1000000000 -999999999 -1000000000
999999998 999999999 999999998 -999999999
0 0 1 0
2
9 10 -9 -10
1 9 1 -9
1 1 999999999 0
2
1000000000 999999999 -1000000000 -999999999...

output:

1
0
0
0
0

result:

ok 5 number(s): "1 0 0 0 0"

Test #61:

score: 0
Accepted
time: 297ms
memory: 51036kb

input:

1
-43209924 -31794688 44278275 26439083
200000
-418022592 -83112931 373248596 25225582
-554027365 -69432202 403261659 83961854
357383187 -934656613 -33997953 266713007
-92648911 -35056700 401740959 -2436580
-423207204 68863283 125677756 -76531564
483840683 -974318453 -340338832 902101927
301061415 -...

output:

2951454480

result:

ok 1 number(s): "2951454480"

Test #62:

score: 0
Accepted
time: 268ms
memory: 4100kb

input:

100000
1079207 292328 -3442211 2803168
2
356767949 106969088 -273599831 -75321272
-121798643 -411483593 212058157 707303815
-2443043 581303 -1247714 -1252607
2
-280639394 774301333 291941086 -815105507
-85574771 337848503 65101486 -273448297
1016017 -4757104 3515923 -75983
2
-420135239 174622616 433...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #63:

score: 0
Accepted
time: 193ms
memory: 3960kb

input:

10000
3016761 -2754528 -4716498 343712
65
452149262 264057084 -241935258 -136584385
322053432 -46843648 -155998873 22189712
267318466 -184812675 -98521658 64190742
449975302 15049114 -150416768 -8866226
-269487048 812895122 139703802 -442866148
-48611078 158706132 61125372 -237199918
89482670 -10065...

output:

97
10
0
19
2
2
0
1
10
0
3
0
0
0
0
21
0
0
3
14
13
0
1
1
1
1
0
2
2
5
1
0
0
26
5
17
0
8
0
36
1
0
7
8
4
6
0
9
2
0
3
0
1
9
0
1
0
0
4
3
12
1
0
4
0
0
2
0
32
0
0
0
0
1
2
7
2
11
35
14
0
0
4
1
0
19
6
0
0
0
4
0
9
0
0
0
1
5
2
0
21
0
8
4
0
26
1
6
4
0
2
68
2
7
0
0
2
0
12
72
2
27
0
0
0
0
0
1
0
4
9
6
0
0
2
3
6
2
1
...

result:

ok 10000 numbers

Test #64:

score: 0
Accepted
time: 225ms
memory: 5460kb

input:

100
-780250 4230988 -4771488 1712917
398
-107384332 -748077775 55986117 445667932
57859355 -122909273 -124339461 239628007
109240100 -104959907 -310837600 311950783
85771415 37264828 -98872137 -33207364
-229225807 289897413 87217987 -116395483
-50201050 41613442 221613350 -163990055
124306200 -58770...

output:

1357
41371
73
1589
28771
253505
4023
3955
9232
17748
40963
2555
462268
68727
2110
77619
1
210206
68755
19975
70060
3758
435
30441
1041
110642
631
83018
14514
16436
338
378
65022
163528
184
27
2473
4367
26525
6696
284
225354
17929
115258
31497
2567
19262
56127
11465
31140
3649
15088
385667
102
7899
3...

result:

ok 100 numbers

Test #65:

score: 0
Accepted
time: 292ms
memory: 52484kb

input:

1
-286198 -1968021 -2112842 3710341
200000
-545141541 -600615564 52877406 64907901
67809071 231431547 -8617206 -17473027
486043012 709354321 -518505848 -759934451
-333266385 -428163778 320657067 424650938
6385796 -31850902 -85115836 377971466
-50083434 -93320859 333681302 682928741
-373104256 -28047...

output:

372550789

result:

ok 1 number(s): "372550789"

Test #66:

score: 0
Accepted
time: 264ms
memory: 3976kb

input:

100000
267534 185565 -349292 432887
2
882874207 294818864 -116733062 -38358823
29948666 -133860366 -41017692 180692287
209585 103903 75044 316921
2
-342473176 -320628669 95149652 89395697
-39278655 -264612113 33796050 225256384
490083 -315654 -428431 63810
2
-496920906 -149771784 363585345 108782886...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #67:

score: 0
Accepted
time: 185ms
memory: 4040kb

input:

1000
-38947 -111469 331474 -286995
11
-177671558 -32684529 48676351 8821611
-55055397 -4220420 415975853 30958955
-219777730 221248050 418231796 -421467268
-67933795 -369060781 55125617 299659847
-23253230 656782509 16149100 -440965821
2333549 149940180 -333366 -50173755
-175575422 362824189 1368721...

output:

0
0
1
526
7
26
407
122
96
8
6
0
0
150
90
0
17
38
162
19
21
0
14
0
0
0
0
1
5
2
66
14
45
7
6
59
1
1
0
3
9
9
14
11
11
49
54
526
0
76
0
5
0
35
0
11
176
0
1
0
0
131
25
1
24
239
0
0
0
1
0
143
0
14
4
0
258
0
48
94
28
84
161
3
49
25
0
111
2
0
43
0
32
5
0
3
0
183
0
67
59
0
201
438
2
110
1496
504
13
408
20
1
...

result:

ok 1000 numbers

Test #68:

score: 0
Accepted
time: 272ms
memory: 44252kb

input:

10
235747 -4751 340430 -129902
778
111019303 -167587599 -99788255 151302065
-9720390 -7627476 492601980 366715683
-389967503 341494651 246117247 -215196155
256380726 533722818 -362814482 -756490070
-806712453 -509253445 400464747 252571679
-8951801 6794382 374222995 -276769459
-551496790 415327558 2...

output:

210
35182
2023
546402
51536
443
8562
17195
31327108
23010

result:

ok 10 numbers

Test #69:

score: 0
Accepted
time: 274ms
memory: 51192kb

input:

1
350340 -336336 363775 -141664
200000
359147940 550458264 -78983796 -122123142
203341401 601860889 -119304585 -355306961
-29990570 -249629728 32029105 260121632
-177943965 327336219 290761244 -534058840
53929832 53082609 -498702162 -496023257
5555605 -272081380 -3983855 227580212
33251406 771359196...

output:

19491519

result:

ok 1 number(s): "19491519"

Test #70:

score: 0
Accepted
time: 273ms
memory: 3912kb

input:

100000
3038 -2823 4026 4061
2
-516406974 -70565083 465969526 63679673
-30343038 339820255 44258200 -495583384
2239 -338 -1758 3468
2
27368091 49700318 -6479865 -11772850
520827780 -105193998 -332108504 67082590
-2457 977 -2679 -2920
2
552651721 647489880 -10706477 -12543546
-147006179 163464972 3248...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #71:

score: 0
Accepted
time: 188ms
memory: 4000kb

input:

10000
-3122 4237 4151 4938
5
99546671 229512363 -18060137 -41644482
2509781 -4493058 -317122774 569297148
99264423 -162118566 -396596311 647779272
-74563082 243148097 86581180 -282351620
-197828651 -570343604 176861566 509920189
4369 -1092 -3375 -4755
5
-212401610 -55549116 279719600 73145730
878872...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 10000 numbers

Test #72:

score: 0
Accepted
time: 213ms
memory: 5460kb

input:

100
-3103 2625 -768 -352
438
165086424 -139554232 -96747702 81783158
-310438992 513313928 388946142 -643129927
-131764965 474960719 135677762 -489071142
-102650420 647432156 117439002 -740717182
-366957488 690349984 133270202 -250721088
-326600961 -374428205 144325476 165461172
205078337 -93907155 -...

output:

1
114
187
439
177
26
0
1014
6
867
1
8
0
68
119
68
25
191
57
5
19
680
1565
0
153
134
691
26
8
195
62
78
1
2
49
117
42
64
1
1
165
1
487
9
135
48
6
1443
16
8
58
22
21
4
0
1
0
226
46
55
3
50
0
41
1
5
0
327
74
64
3
4
9
56
1184
3
100
189
21
1
1
216
12
110
0
247
4
107
0
91
0
278
29
88
1293
17
69
306
292
133

result:

ok 100 numbers

Test #73:

score: 0
Accepted
time: 254ms
memory: 51156kb

input:

1
-1042 -56 4844 -179
200000
290562916 193381929 -205065364 -136485491
965925794 -631104824 -615006919 401824520
-144814784 -169623082 30948690 36251940
666238448 -482037536 -589986312 426865984
-177023585 66585255 210222815 -79069145
-481314322 706446664 353458282 -518789357
143225983 -330147676 -3...

output:

905008

result:

ok 1 number(s): "905008"

Test #74:

score: 0
Accepted
time: 219ms
memory: 3844kb

input:

100000
10 33 -18 -6
2
267291694 78972576 -281100238 -83052313
-225813320 512422487 110778052 -251381011
4 39 -26 21
2
763539038 -595932907 -781367612 609847893
849537436 -462619389 -190691056 103841671
46 -28 -50 -16
2
-52326374 296516352 56857372 -322191542
293772290 303248740 -176147999 -181830268...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #75:

score: 0
Accepted
time: 192ms
memory: 4244kb

input:

1000
-40 2 21 41
138
-265399996 530799914 13876799 -27753676
220027992 -86439582 -235305796 92441549
273337189 -268080643 -14461023 14182988
474565269 88193555 -239497438 -44508364
-40 46347362 -40 -11399758
-292329466 -85559830 92419126 27049514
-617829939 -346359179 48122139 26977592
-91655812 -77...

output:

1
47
0
2
18
0
1
0
1
0
12
7
1
4
1
0
10
0
11
4
0
1
23
1
0
1
0
2
5
6
6
0
0
0
1
0
0
20
1
1
9
3
0
41
0
9
0
3
0
0
6
1
0
0
0
2
0
0
53
29
2
22
0
1
0
5
0
2
10
2
3
3
0
14
1
0
32
4
3
0
0
2
1
30
0
0
3
20
3
0
1
4
2
0
3
0
0
0
2
0
0
3
11
0
1
10
0
0
3
45
3
4
4
9
0
5
0
4
3
6
13
1
0
0
18
1
3
0
0
1
3
21
0
0
1
4
17
0
2...

result:

ok 1000 numbers

Test #76:

score: 0
Accepted
time: 243ms
memory: 15088kb

input:

10
-24 -30 -3 -24
2739
30067908 -193771006 -25686525 165535340
-28855060 -98931582 139200380 477258498
-56693052 61966797 295525323 -323016078
-67639722 518570988 83519301 -640314855
432660294 627662097 -238043549 -345330802
239698693 201037592 -450554623 -377884544
9834480 531062058 -8740382 -47198...

output:

534
165558
110313
22
4319
1636
103134
90288
8275
10057

result:

ok 10 numbers

Test #77:

score: 0
Accepted
time: 256ms
memory: 53704kb

input:

1
-39 34 14 18
200000
-227109661 -308869140 385556114 524356314
-548519690 408472138 577065638 -429729702
-62025737 -930385436 35637472 534562699
-153805603 188761408 287404353 -352723538
474515851 492422113 -33489838 -34753602
-636222316 91898799 553908164 -80008937
57759579 -365810880 -20772378 13...

output:

2817096

result:

ok 1 number(s): "2817096"

Test #78:

score: 0
Accepted
time: 253ms
memory: 3964kb

input:

100000
1 4 -4 -4
2
270829420 440097810 -57198404 -92947404
426803656 597525120 -435975489 -610365683
4 -4 0 -5
2
682786629 758651805 -338773167 -376414635
-799946520 799946515 311959490 -311959495
5 3 2 -1
2
-29974075 -49956797 124851659 208086093
-76235684 -76235686 69305606 69305604
1 4 -1 -3
2
56...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #79:

score: 0
Accepted
time: 186ms
memory: 3992kb

input:

10000
2 1 1 5
15
-625636861 486606450 328645946 -255613511
-95114699 95114705 58286011 -58286005
689226865 344613437 -611680855 -305840423
10447029 7835276 -97996463 -73497343
-975375245 -709363815 875740098 636901889
-278771289 -390279801 32847691 45986771
-382414414 -701093095 131932796 241876790
...

output:

0
0
1
1
1
8
3
0
2
2
8
0
0
0
0
0
2
0
0
0
0
0
0
5
4
0
0
3
0
0
2
3
0
10
4
4
0
3
0
0
0
2
0
0
1
14
10
0
0
2
0
1
0
0
1
0
3
0
0
0
1
0
0
0
0
5
0
8
0
0
3
3
0
0
0
1
2
0
11
7
0
0
0
5
0
2
8
2
0
0
0
2
3
0
1
6
0
1
0
3
1
0
0
0
0
7
0
1
0
0
6
0
1
1
1
0
0
0
1
1
0
0
2
0
0
4
2
0
0
0
15
2
0
0
1
0
0
1
0
0
0
0
0
0
3
1
4
6...

result:

ok 10000 numbers

Test #80:

score: 0
Accepted
time: 203ms
memory: 5792kb

input:

100
5 1 -2 -4
1156
5 -110276360 5 161973454
902118098 360847236 -391075932 -156430376
-9904269 -49521369 94524939 472624671
-2 -479307382 -2 504723542
-583838383 375324679 678242479 -436013018
355981949 -978950345 -355559839 977789572
-33006320 -231044274 35797425 250581941
157736934 39434230 -14465...

output:

4447
391
2427
41187
18764
14403
606
4085
523
38401
27
1264
2923
5748
1638
389
3028
3055
1157
210702
14317
24862
558
2
483
4986
2656
57684
3616
30116
4
4661
2059
1003
30114
5778
20419
7318
81
588
1
39213
55489
149
912
3358
250
11122
1903
1571
152789
111
860
171272
89750
9894
1469
271
17850
1281
46515...

result:

ok 100 numbers

Test #81:

score: 0
Accepted
time: 241ms
memory: 52124kb

input:

1
-3 4 -3 3
200000
-211247088 -549242417 332925102 865605277
125227383 -55656612 -198654447 88290868
272424688 272424694 -10065254 -10065248
950608227 -438742257 -721304171 332909619
-439733865 -659600790 307757139 461635716
218617565 109308788 -48288667 -24144328
723230483 -788978708 -146263516 159...

output:

118531283

result:

ok 1 number(s): "118531283"

Test #82:

score: 0
Accepted
time: 209ms
memory: 4072kb

input:

100000
-1 0 1 0
2
1 -459019532 1 89340497
21103218 21103219 -103133582 -103133581
-1 0 0 1
2
-12914837 0 87464254 0
991050594 1 -333323138 1
-1 -1 1 1
2
913529711 609019807 -602736058 -401824039
1 -956002245 1 199559981
-1 1 0 0
2
-429975741 1 331865382 1
-1 -456141424 -1 336656601
0 -1 0 0
2
0 3247...

output:

0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
...

result:

ok 100000 numbers

Test #83:

score: 0
Accepted
time: 169ms
memory: 4084kb

input:

1000
1 -1 0 0
47
1 762942920 1 -739647661
-87417836 -87417838 11956175 11956173
-704207122 352103561 452577202 -226288601
-837548710 -418774355 475334226 237667113
0 728907100 0 -358465488
-19311279 19311279 639370471 -639370471
-214671355 214671355 605061301 -605061301
-455169120 227584560 68112394...

output:

41
2564
958
447
61
558
273
3182
7555
148
3931
66
1504
722
8
689
1095
396
388
213
166
556
4429
198
102
14150
140
474
3
65
88
1084
39
245
233
1470
2
34
28
1707
16
1308
2898
126
137
195
11
6650
4401
70
173
1277
14450
661
367
2845
3068
321
426
1440
713
544
362
46
2941
21923
109
16
134
15
972
5117
16
333...

result:

ok 1000 numbers

Test #84:

score: 0
Accepted
time: 209ms
memory: 15188kb

input:

10
1 0 -1 1
12130
885357707 442678855 -315542859 -157771428
462944531 1 -64576185 1
-349566147 -349566148 172721025 172721024
13291625 1 -943019683 1
-977003667 977003668 538893811 -538893810
210178553 -105089276 -403832447 201916224
1 832710560 1 -385899366
241611168 -483222334 -250041205 500082412...

output:

4331738
36993
10942114
54831302
43463
4131507
70263583
357159
53087515
279610

result:

ok 10 numbers

Test #85:

score: 0
Accepted
time: 227ms
memory: 51984kb

input:

1
1 1 -1 0
200000
-149713601 0 32260205 0
-477099231 954198460 455890778 -911781558
-883983575 -441991787 204814957 102407479
-28301402 -28301401 44902495 44902496
-140908494 -281816989 164384264 328768527
-300693299 0 447683293 0
195617467 195617467 -448085984 -448085984
-80729131 161458260 3716780...

output:

1183119356

result:

ok 1 number(s): "1183119356"

Test #86:

score: 0
Accepted
time: 269ms
memory: 3860kb

input:

100000
98748786 7656237 -37973775 -76135379
2
-552073436 -849753684 476125886 697482926
-552073436 -849753684 749571008 865066158
-90909371 95230102 -85984206 5261566
2
-248923838 -862027544 76955426 872550676
-214767467 621885730 42799055 -611362598
-37674505 25932702 75897771 -33240088
2
682532271...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #87:

score: 0
Accepted
time: 199ms
memory: 3928kb

input:

10000
10236581 29710662 -5453826 98551635
38
339388365 -66918524 -318915203 126339848
339388365 -66918524 -350296017 264021794
85188204 7707092 -64715042 51714232
85188204 7707092 -96095856 189396178
-4436065 34018115 24909227 25403209
-4436065 34018115 -6471587 163085155
8648188 30176967 11824974 2...

output:

244
6
138
11
13
6
54
52
35
89
385
17
68
732
3
1
176
72
21
3
13
11
1
15
299
201
75
237
61
6
7
3
27
1738
30
15
15
1351
0
651
25
247
13
1
1
33
66
488
0
151
32
38
142
155
30
6
1
379
13
2
23
10
3
31
12
6
8
6
53
7
75
23
130
38
12
12
431
342
552
329
43
1
8
205
516
17
73
1
750
12
24
74
441
93
23
472
1
21
9
...

result:

ok 10000 numbers

Test #88:

score: 0
Accepted
time: 207ms
memory: 4028kb

input:

1000
73994922 13262864 -2145565 20618049
158
183911395 667644436 -188202525 -626408338
183911395 667644436 -35921551 -641118708
-69114488 -212271171 64823358 253507269
-69114488 -212271171 217104332 238796899
-16995374 -31023224 12704244 72259322
-16995374 -31023224 164985218 57548952
5134557 459351...

output:

4368
11219
45062
22694
13
12737
39007
80
6020
131
4620
27719
989
99966
25357
22940
1135
0
6065
95
31040
6364
11040
257
2912
8477
4304
207
6308
3674
11583
7484
526
1528
200
5876
235
1718
1062
10
973
8442
63791
7769
4685
194
3706
40979
181
2366
17120
2069
9483
208
1332
30577
22
32294
2183
7893
32721
1...

result:

ok 1000 numbers

Test #89:

score: 0
Accepted
time: 226ms
memory: 6512kb

input:

100
74774584 -15277939 86394710 63117999
5640
612472076 -4129545 -439682656 130365543
612472076 -4129545 -462922908 -26426333
72819971 64853234 99969449 61382764
72819971 64853234 76729197 -95409112
92625837 62321485 80163583 63914513
92625837 62321485 56923331 -92877363
87507195 62975792 85282225 6...

output:

5859508
57092
2120250
122658
301175
315532
79210
3155854
8748622
4337832
295342
6479743
712498
32660
6952609
3247
24574902
130228
228617
217658
1483946
461352
37462
2151
249012
3259077
8509
2148372
1246876
2023
24413
3361799
441523
81259
271248
213771
78960
421786
1933434
228783
2778507
406920
44930...

result:

ok 100 numbers

Test #90:

score: 0
Accepted
time: 258ms
memory: 16204kb

input:

10
45677215 -15190361 12824360 -52682833
8223
-938271027 -479428035 963919747 374062369
-331440400 -953811992 357089120 848446326
-331440400 -953811992 422794830 923431270
-1295607 -89642509 26944327 -15723157
-1295607 -89642509 92650037 59261787
19645139 -34829124 6003581 -70536542
19645139 -348291...

output:

12391177
62840169
457901200
89351981
13112075
64242727
10902417
9459717
69660294
299597433

result:

ok 10 numbers

Test #91:

score: 0
Accepted
time: 271ms
memory: 26140kb

input:

5
27728447 -17965368 4822343 21272205
40307
942744191 -116648964 -887287297 80718228
942744191 -116648964 -933099505 159193374
23799688 -17541655 31657206 -18389081
23799688 -17541655 -14155002 60086065
28343297 -18031679 27113597 -17899057
28343297 -18031679 -18698611 60576089
27488788 -17939521 27...

output:

297216290
923895849
149945533
502916735
10414055

result:

ok 5 number(s): "297216290 923895849 149945533 502916735 10414055"

Test #92:

score: 0
Accepted
time: 275ms
memory: 42828kb

input:

4
6550329 -20681038 -9605079 -74093572
10147
33065978 125277024 -52276136 -273464168
33065978 125277024 -19965320 -166639100
-14403051 -96510981 -4807107 -51676163
-14403051 -96510981 27503709 55148905
-9094388 -71707487 -10115770 -76479657
-9094388 -71707487 22195046 30345411
-9403326 -73150928 -98...

output:

18883085
53560653
133121962
3825693200

result:

ok 4 number(s): "18883085 53560653 133121962 3825693200"

Test #93:

score: 0
Accepted
time: 276ms
memory: 27848kb

input:

3
-48183492 94857846 -7006377 -34127919
95401
-979332903 -655894813 882965919 845610505
-979332903 -655894813 965320149 587638975
-500640043 -269941782 404273059 459657474
-500640043 -269941782 486627289 201685944
-74419801 73704443 -21947183 116011249
-74419801 73704443 60407047 -141960281
-5462279...

output:

1684260268
1000120688
176914185

result:

ok 3 number(s): "1684260268 1000120688 176914185"

Test #94:

score: 0
Accepted
time: 269ms
memory: 30404kb

input:

2
-70822924 -4031976 88198089 -88298991
121015
-657307018 -688056444 515661170 679992492
-657307018 -688056444 833703196 511458462
-45246862 25797737 -96398986 -33861689
-45246862 25797737 221643040 -202395719
-66266025 1282798 -75379823 -9346750
-66266025 1282798 242662203 -177880780
-69057592 -197...

output:

2714236099
1143831572

result:

ok 2 number(s): "2714236099 1143831572"

Test #95:

score: 0
Accepted
time: 276ms
memory: 51452kb

input:

1
-17931478 -46950574 -2829041 -23494394
200000
781096807 -616209773 -816959763 522308625
781096807 -616209773 -786754889 569220985
205847356 -206379423 -241710312 112478275
205847356 -206379423 -211505438 159390635
78155573 -115406771 -114018529 21505623
78155573 -115406771 -83813655 68417983
-4953...

output:

7275991613

result:

ok 1 number(s): "7275991613"

Test #96:

score: 0
Accepted
time: 286ms
memory: 50512kb

input:

1
-48852919 22082895 9335397 -20732797
200000
-72152545 -255689065 90823339 214223471
-72152545 -255689065 -25553293 299854855
-10145052 -76901274 28815846 35435680
-10145052 -76901274 -87560786 121067064
7552324 -25873977 11118470 -15591617
7552324 -25873977 -105258162 70039767
9202043 -21117300 94...

output:

7363781736

result:

ok 1 number(s): "7363781736"

Test #97:

score: 0
Accepted
time: 284ms
memory: 50680kb

input:

1
-10801301 74095116 -77780579 58656414
200000
696324408 -353974715 -851885566 471287543
696324408 -353974715 -717927010 502164947
177905835 -77635401 -333466993 194948229
177905835 -77635401 -199508437 225825633
-70734834 54900730 -84826324 62412098
-70734834 54900730 49132232 93289502
-79820173 59...

output:

7357943909

result:

ok 1 number(s): "7357943909"

Test #98:

score: 0
Accepted
time: 285ms
memory: 54824kb

input:

1
-23112451 70033331 92186646 32034961
200000
60660769 651026422 -106885671 -510959760
60660769 651026422 123712523 -586956500
-60558142 -189664073 14333240 329730735
-60558142 -189664073 244931434 253733995
-31994289 8435048 -14230613 131631614
-31994289 8435048 216367581 55634874
-21194112 8333760...

output:

7395677366

result:

ok 1 number(s): "7395677366"

Test #99:

score: 0
Accepted
time: 274ms
memory: 54560kb

input:

1
24166566 -52479773 28962949 14682285
200000
-49495540 916440007 107421438 -887075437
336356897 -107997660 -278430999 137362230
336356897 -107997660 -288023765 3038114
76636136 -4343932 -18710238 33708502
76636136 -4343932 -28303004 -100615614
50317775 6159642 7608123 23204928
50317775 6159642 -198...

output:

7364454098

result:

ok 1 number(s): "7364454098"

Extra Test:

score: 0
Extra Test Passed