QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#709303#9524. 1D Galaxyucup-team1004AC ✓72ms13096kbC++173.4kb2024-11-04 13:53:402024-11-04 13:53:41

Judging History

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

  • [2024-11-04 13:53:41]
  • 评测
  • 测评结果:AC
  • 用时:72ms
  • 内存:13096kb
  • [2024-11-04 13:53:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
const int N=1e5+10;
const ll INF=1e18;
int n,m,fa[N];
int find(int x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
struct ques{
	int t,i,id;
}o[N];
ll w[N],a[N];
int cur[N],oth[N];
int pre[N],nex[N];
ll pw[N],sw[N];
int d[N];
int tlas[N];
void getd(int i){
	if(pw[i]>sw[i])d[i]=-1;
	else if(pw[i]<sw[i])d[i]=1;
	else d[i]=0;
}
void swp(int y){
	int x=pre[y];
	int p=pre[x],q=nex[y];
	nex[p]=y,pre[y]=p;
	nex[y]=x,pre[x]=y;
	nex[x]=q,pre[q]=x;
	pw[y]=pw[pre[y]]+w[pre[y]];
	pw[x]=pw[pre[x]]+w[pre[x]];
	sw[x]=sw[nex[x]]+w[nex[x]];
	sw[y]=sw[nex[y]]+w[nex[y]];
}
int refind(int x,int t){
	if(oth[x]){
		int y=oth[x];
		if((t-tlas[x])&1){
			swp(a[x]<a[y]?y:x);
			swap(a[x],a[y]);
			tlas[x]=tlas[y]=t;
			return y;
		}else{
			tlas[x]=tlas[y]=t;
			return x;
		}
	}else{
		a[x]+=(t-tlas[x])*d[x],tlas[x]=t;
		return x;
	}
}
ll geta(int x,int t){
	if(oth[x]){
		int y=oth[x];
		if((t-tlas[x])&1)return a[y];
		else return a[x];
	}else{
		return a[x]+(t-tlas[x])*d[x];
	}
}
void remove(int y){
	int x=pre[y];
	fa[y]=x;
	w[x]+=w[y];
	nex[x]=nex[y];
	pre[nex[y]]=x;
	sw[x]=sw[nex[x]]+w[nex[x]];
}
int vcnt,val[N];
void update(int x){
	if(oth[x]){
		int y=oth[x];
		oth[x]=oth[y]=0;
		val[y]=++vcnt;
		getd(y);
	}
	val[x]=++vcnt;
}
priority_queue<tuple<ll,int,int,int>>q;
void push(int y,int t0){
	int x=pre[y];
	if(geta(y,t0)-geta(x,t0)==0){
		q.push({-t0,y,val[x],val[y]});
		return;
	}
	if(d[y]-d[x]>=0)return;
	int v=d[x]-d[y];
	ll t=t0+(geta(y,t0)-geta(x,t0)+v-1)/v;
	q.push({-t,y,val[x],val[y]});
}
ll ans[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i],&w[i]);
	a[0]=-INF,a[n+1]=INF;
	iota(cur,cur+1+n+1,0);
	sort(cur+1,cur+1+n,[&](int x,int y){
		return a[x]<a[y];
	});
	iota(fa,fa+1+n,0);
	for(int l=1,r,las=0;l<=n+1;l=r){
		for(r=l+1;r<=n&&a[cur[l]]==a[cur[r]];r++);
		for(int i=l+1;i<r;i++)fa[cur[i]]=cur[l],w[cur[l]]+=w[cur[i]];
		nex[las]=cur[l],pre[cur[l]]=las;
		las=cur[l];
	}
	for(int i=0;i!=n+1;i=nex[i])pw[nex[i]]=pw[i]+w[i];
	for(int i=n+1;i!=0;i=pre[i])sw[pre[i]]=sw[i]+w[i];
	for(int i=1;i<=m;i++){
		scanf("%d%d",&o[i].t,&o[i].i);
		o[i].id=i;
	}
	sort(o+1,o+1+m,[&](ques x,ques y){
		return x.t<y.t;
	});
	for(int i=0;;i=nex[i]){
		getd(i);
		if(i==n+1)break;
	}
	for(int i=0;i!=n+1;i=nex[i])push(nex[i],0);
	for(int ot=1;ot<=m;ot++){
		int t0=o[ot].t,x=o[ot].i;
		for(;!q.empty()&&get<0>(q.top())>-t0;){
			auto [t,y,w1,w2]=q.top();
			t=-t;
			q.pop();
			int x=pre[y];
			if(fa[x]!=x||fa[y]!=y)continue;
			if(val[x]!=w1||val[y]!=w2)continue;
			x=refind(x,t),y=refind(y,t);
			int v=d[x]-d[y];
			if(a[x]==a[y]){
				update(y);
				remove(y);
				getd(x);
				update(x);
				if(pre[x]>0)push(pre[x],t);
				push(x,t);
				push(nex[x],t);
				if(nex[x]<=n)push(nex[nex[x]],t);
			}else{
				swp(y);
				update(x);
				update(y);
				getd(x),getd(y);
				if(d[y]==1&&d[x]==-1){
					oth[y]=x,oth[x]=y;
					d[x]=d[y]=0;
				}
				push(y,t);
				push(x,t);
				push(nex[x],t);
			}
		}
		x=find(x);
		ans[o[ot].id]=geta(x,t0);
	}
	for(int i=1;i<=m;i++)printf("%lld\n",ans[i]);
	return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif

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

詳細信息

Test #1:

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

input:

4 12
0 1
1 2
-1 3
2 2
0 1
0 2
0 3
0 4
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4

output:

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

result:

ok 12 lines

Test #2:

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

input:

5 5
-4 5
-1 3
5 5
0 4
-4 2
0 3
3 1
5 5
1 3
3 3

output:

5
-1
1
4
2

result:

ok 5 lines

Test #3:

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

input:

5 5
3 2
1 3
0 3
1 5
0 5
7 1
1 4
1 5
8 5
10 3

output:

0
0
1
0
0

result:

ok 5 lines

Test #4:

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

input:

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

output:

1
0
4
3
0

result:

ok 5 lines

Test #5:

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

input:

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

output:

-2
-3
-2
-2
-2

result:

ok 5 lines

Test #6:

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

input:

5 5
-1 1
-8 4
0 2
4 3
5 1
1 3
10 5
4 4
4 1
9 4

output:

-1
-1
0
-1
-1

result:

ok 5 lines

Test #7:

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

input:

4 4
-5 4
1 0
2 3
-1 -2
1 1
1 3
0 1
9 2

output:

-4
1
-5
-2

result:

ok 4 lines

Test #8:

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

input:

4 4
-7 -2
10 1
9 2
-10 3
11 3
4 3
0 1
20 4

output:

0
6
-7
0

result:

ok 4 lines

Test #9:

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

input:

100 1000
4 77
6 -9
3 -9
6 0
-5 44
-1 -47
-2 -77
10 71
-3 -18
-10 78
-2 41
-3 18
-1 -46
-1 26
8 -72
-8 69
6 71
-5 -9
-3 6
8 64
-5 66
-2 -73
-4 49
-9 -10
2 74
10 65
9 68
10 15
6 -11
5 -18
-10 -79
9 -27
5 52
3 -71
-2 -77
9 -70
9 -30
9 66
9 8
-1 -7
7 67
-6 -17
-6 -8
-3 20
-10 75
7 41
6 -61
1 5
-5 66
-8 ...

output:

6
6
6
5
6
5
6
5
5
6
5
5
6
5
5
5
5
6
6
6
-1
5
2
5
6
6
6
5
7
5
6
6
5
6
6
6
5
5
5
5
6
5
5
6
5
6
6
5
5
5
5
8
6
6
5
5
5
5
5
5
3
5
6
6
6
5
6
6
6
8
6
5
6
-5
5
5
4
6
6
5
5
6
6
5
6
6
6
6
6
6
5
6
5
6
5
5
6
5
6
6
5
5
5
5
6
5
6
6
7
5
6
5
6
6
5
5
5
5
5
5
6
5
5
6
6
5
5
6
6
5
6
5
6
6
5
6
6
5
6
2
6
5
5
5
5
6
5
5
6
...

result:

ok 1000 lines

Test #10:

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

input:

5 50
-1 -4
1 4
-2 0
0 3
-2 3
13 3
13 2
6 4
4 1
15 4
0 5
7 4
11 2
1 1
2 1
7 1
6 1
2 4
14 2
3 3
4 1
14 4
3 1
10 3
0 3
2 1
14 3
6 3
8 5
11 5
11 3
7 5
9 2
6 5
7 4
8 3
15 3
0 4
15 1
6 5
9 2
6 4
1 5
0 3
2 4
6 4
9 5
0 1
8 1
11 1
5 2
6 2
8 4
3 5
0 3

output:

0
0
0
0
0
-2
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
-1
-2
0
0
0
-1
0
0
0
0
0
0
-2

result:

ok 50 lines

Test #11:

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

input:

1000 1000
-631 10
954 2
-663 -9
996 4
479 9
160 -7
-479 -8
540 6
729 1
-280 10
-567 2
572 0
587 1
-592 2
806 3
-84 -9
-117 3
-958 1
-147 -4
-870 -3
44 4
709 -4
-889 10
263 1
-590 7
-242 -1
483 -7
79 -8
59 -7
-618 9
860 -9
110 -2
735 4
-797 -5
362 1
-357 -1
-54 -1
-381 5
-907 -3
-275 -8
798 -7
-150 -...

output:

-1011
-108
-1010
-666
1355
-375
-540
-100
1154
-178
754
-598
-1112
-1135
-509
6
-353
-57
-395
-1080
-555
974
-335
706
366
-37
-1250
-557
-1338
1466
-969
18
-512
-851
-1057
-926
-602
-513
-1403
1267
1121
-358
224
-675
-530
-250
-1206
-1292
102
1437
-697
-891
981
267
-75
-63
-589
1417
-89
-489
-845
34...

result:

ok 1000 lines

Test #12:

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

input:

1 1
-1000000000 -1000000000
1000000000 1

output:

-1000000000

result:

ok single line: '-1000000000'

Test #13:

score: 0
Accepted
time: 16ms
memory: 11436kb

input:

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

output:

2
4
11
6
9
10
5
12
7
8
1
5
10
0
9
-10
4
5
11
12
-3
10
-9
2
-5
14
13
2
10
14
8
-8
-9
9
7
-9
7
14
4
11
1
3
4
5
2
4
-7
-8
9
-6
14
3
9
6
10
7
6
4
-10
-4
6
5
8
12
11
12
5
9
3
5
4
2
-6
-5
2
10
0
13
4
13
0
7
9
6
14
-2
9
7
0
-5
9
10
1
-6
-12
4
5
2
10
8
5
-7
-4
12
2
5
0
3
1
10
5
3
10
4
7
7
14
10
10
8
4
-8
0
...

result:

ok 100000 lines

Test #14:

score: 0
Accepted
time: 12ms
memory: 10736kb

input:

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

output:

-10
10
-10
6
10
12
-3
-5
15
12
11
8
9
-3
-8
-5
-9
1
-11
-3
-4
-10
-6
-2
-5
-6
-7
-5
0
0
-5
-9
-2
-10
9
15
-3
8
-5
-7
-7
-12
8
-7
14
-2
-8
0
3
-6
8
-6
-5
-2
-5
-2
-8
-3
-7
-4
-3
3
-5
-10
-10
1
-4
13
11
-9
-10
-3
-2
15
1
-5
-12
15
9
8
-9
-3
0
12
-10
9
-2
-2
-11
-7
-6
-2
-11
-5
-3
6
14
-9
5
10
-10
-11
...

result:

ok 100000 lines

Test #15:

score: 0
Accepted
time: 16ms
memory: 9512kb

input:

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

output:

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

result:

ok 100000 lines

Test #16:

score: 0
Accepted
time: 15ms
memory: 10896kb

input:

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

output:

6
11
9
10
8
4
-1
2
7
7
3
3
0
2
3
13
11
11
7
2
7
10
7
2
1
5
14
0
5
1
5
3
7
9
-1
3
1
11
10
6
4
8
3
6
14
10
4
1
12
7
-1
0
8
13
6
7
10
5
11
4
4
5
2
5
6
5
6
2
4
6
0
3
8
6
12
4
7
4
-1
11
6
7
2
2
7
2
7
8
8
11
6
4
10
2
7
3
5
3
2
6
6
11
13
0
3
14
6
5
6
11
8
7
2
2
1
6
5
14
8
0
2
2
4
5
7
9
3
9
5
12
9
9
2
3
0
3...

result:

ok 100000 lines

Test #17:

score: 0
Accepted
time: 15ms
memory: 9180kb

input:

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

output:

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

result:

ok 100000 lines

Test #18:

score: 0
Accepted
time: 12ms
memory: 10848kb

input:

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

output:

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

result:

ok 100000 lines

Test #19:

score: 0
Accepted
time: 22ms
memory: 10936kb

input:

5 100000
-5 5
3 1
-1 0
-4 -1
3 0
722464463 3
160153265 3
515887073 3
792161740 3
700363144 1
257871163 4
985882098 5
622391595 3
497814648 5
257689210 3
424536396 2
57303421 2
893685148 3
887126381 5
92312757 3
909180665 3
90045475 3
843939343 2
921025750 1
551022351 1
316367770 3
939526319 1
745326...

output:

-2
-2
-2
-1
-2
-1
-1
-2
-1
-1
-1
-2
-1
-2
-2
-2
-2
-2
-2
-1
-1
-1
-2
-1
-2
-2
-1
-2
-2
-1
-2
-2
-2
-2
-1
-1
-2
-2
-2
-1
-1
-2
-2
-2
-1
-1
-2
-2
-2
-1
-2
-1
-1
-2
-2
-1
-2
-2
-2
-2
-1
-1
-2
-2
-2
-2
-2
-1
-1
-1
-2
-2
-1
-1
-2
-1
-1
-1
-2
-1
-1
-1
-2
-2
-1
-1
-2
-1
-1
-1
-1
-2
-2
-2
-2
-2
-1
-1
-2
-2
...

result:

ok 100000 lines

Test #20:

score: 0
Accepted
time: 12ms
memory: 11508kb

input:

10 100000
0 -4
2 1
4 -3
-4 6
8 -7
-9 0
10 5
3 4
-8 3
-4 6
1 2
1 3
11 7
1 10
6 5
10 2
14 10
17 3
12 1
14 2
11 4
6 3
7 10
16 5
20 10
5 9
12 6
6 1
16 3
13 2
6 2
15 3
14 2
8 10
4 2
7 9
14 6
6 10
12 6
20 8
6 6
11 3
18 8
8 9
13 1
10 10
12 8
20 5
5 6
14 6
10 4
6 6
0 8
0 3
13 8
8 8
7 1
17 1
8 10
4 9
19 2
19...

output:

1
3
-1
-5
2
-8
-18
-13
-12
-12
-15
-2
-11
-8
-24
-9
-15
-6
-12
-11
-4
-11
-12
-12
-2
-11
-17
-10
-15
-17
-9
-7
-15
-12
-13
-14
-9
-12
-8
-17
-14
-9
3
4
-10
-5
-7
-17
-12
-8
-17
-23
-14
-18
-12
-5
-14
-17
-22
2
-16
3
-13
-9
10
-18
1
-7
-17
8
-19
-14
-11
-12
-18
-3
-14
-11
2
-4
7
-17
-4
-13
-13
-14
-1...

result:

ok 100000 lines

Test #21:

score: 0
Accepted
time: 16ms
memory: 10748kb

input:

10 100000
-3 -8
-8 -8
-7 10
3 -5
1 9
6 1
-2 10
10 5
-3 5
-1 -2
6 3
15 4
13 5
12 8
0 9
0 8
17 6
16 3
15 9
19 10
10 1
4 1
16 5
18 7
7 4
13 1
13 7
17 10
19 4
12 5
19 6
20 2
10 1
20 7
8 6
2 5
5 6
0 1
13 6
20 1
2 1
11 10
17 1
12 7
10 9
1 5
18 6
6 4
11 8
17 7
2 8
16 6
1 8
4 7
15 2
0 6
5 3
1 2
12 7
6 7
8 7...

output:

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

result:

ok 100000 lines

Test #22:

score: 0
Accepted
time: 17ms
memory: 11588kb

input:

10 100000
-7 4
-1 6
-5 -5
10 -1
-10 2
-7 -5
-10 7
6 5
-5 -9
-6 -6
20 1
6 3
18 1
17 1
18 9
14 4
15 2
5 4
1 8
7 4
3 1
8 10
0 5
9 7
5 5
11 3
0 7
19 4
2 9
5 1
5 7
4 2
15 7
6 1
7 10
18 5
1 8
11 6
14 9
19 5
14 1
17 8
18 7
4 3
13 8
17 7
12 7
9 8
18 5
0 2
7 2
0 7
5 8
12 6
9 7
4 1
20 4
7 3
9 3
0 3
17 3
20 4
...

output:

-27
1
-25
-24
13
24
14
15
7
17
-10
-14
-10
-19
-15
6
-10
29
-3
-12
-15
3
-25
-13
-13
-28
7
-18
9
-29
-21
23
-28
-1
19
-27
-22
15
-28
-1
6
-10
11
-19
-19
-11
30
2
4
-5
12
30
-8
-23
-9
-1
29
-22
5
17
-29
-15
-12
-14
28
6
23
15
15
9
7
3
-21
-7
-23
-24
-16
26
16
-15
7
1
7
-20
10
-7
6
-23
20
21
-13
-14
-...

result:

ok 100000 lines

Test #23:

score: 0
Accepted
time: 17ms
memory: 9624kb

input:

10 100000
10 0
-5 10
-4 -6
7 3
-7 -9
-4 -7
-10 10
-7 -4
0 8
10 -2
20 9
5 7
19 3
5 6
7 9
14 3
9 5
15 2
1 9
19 1
9 4
7 4
19 3
12 1
20 9
12 6
20 7
4 1
10 2
6 5
20 10
5 4
2 2
13 8
19 8
9 8
1 5
12 6
15 6
5 1
0 5
20 1
3 5
4 6
16 7
8 10
13 6
13 3
18 7
0 10
16 6
18 10
17 10
17 5
12 8
15 6
1 2
17 4
17 10
12 ...

output:

20
-15
15
1
7
10
-16
-20
1
19
8
6
15
12
20
8
-30
6
-15
-13
20
4
-7
-20
-26
-16
-8
8
11
5
-7
20
-10
0
-26
8
9
9
-28
10
12
18
17
-24
-19
11
-6
16
17
12
-14
9
6
-23
5
-15
13
13
6
-15
16
18
14
8
-17
7
-29
13
11
5
-20
8
10
9
-9
2
1
4
7
10
-1
7
-12
-14
13
8
-15
3
-11
14
4
18
-10
-16
20
-19
10
-22
-13
10
2...

result:

ok 100000 lines

Test #24:

score: 0
Accepted
time: 17ms
memory: 11560kb

input:

10 100000
2 -9
3 -10
10 5
-4 7
3 10
8 7
0 7
-7 8
9 -6
9 7
0 5
18 6
16 2
10 7
13 6
2 7
3 1
20 8
9 4
11 8
2 4
11 9
17 6
3 1
18 10
6 2
2 6
2 5
13 3
3 10
7 9
11 8
10 1
16 8
18 4
17 2
18 7
14 6
12 3
12 9
4 1
1 9
1 9
17 6
18 3
20 2
18 3
3 7
4 2
8 4
13 10
2 5
12 10
5 6
7 4
15 1
3 3
2 7
18 2
15 6
10 3
5 7
1...

output:

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

result:

ok 100000 lines

Test #25:

score: 0
Accepted
time: 13ms
memory: 11620kb

input:

10 100000
-2 -1
2 -5
-10 8
-6 7
-7 3
-9 -8
-8 -8
-7 -1
-10 10
5 3
9 6
9 1
0 2
15 10
6 6
19 1
1 3
13 10
9 9
2 6
7 9
15 7
1 6
6 1
20 5
12 10
5 10
8 9
17 8
0 6
18 6
16 10
6 7
15 10
17 8
16 8
18 9
11 6
9 6
11 4
11 7
4 3
3 1
13 3
17 6
11 3
19 4
6 5
3 3
4 10
18 6
7 8
12 2
5 5
9 5
18 5
1 10
16 2
19 5
13 6
...

output:

-18
-11
2
-10
-15
-21
-11
-8
-19
-11
-17
-23
-10
-8
-25
-7
0
-18
-22
-9
-27
-11
-14
-10
-22
-21
-28
-20
-18
-17
-19
-14
-5
-23
-26
-21
-25
-11
-13
1
-27
-12
-10
-10
-14
-23
4
-14
-24
-22
-20
-27
-13
-15
-29
-22
-15
-10
-25
-22
-28
-21
-10
-22
-6
-18
-22
-21
-8
-8
-14
-21
-14
-15
-24
-17
-13
-13
-19
...

result:

ok 100000 lines

Test #26:

score: 0
Accepted
time: 14ms
memory: 9564kb

input:

10 100000
-1 9
7 2
-2 1
3 10
8 10
-6 -3
3 3
9 -7
-1 -2
-7 9
112 7
73 9
118 7
92 9
0 3
189 3
110 10
34 3
105 7
16 9
63 7
12 2
81 9
87 1
160 10
6 5
148 4
54 9
14 5
87 5
57 3
100 4
72 3
166 8
71 7
5 10
189 2
162 3
175 5
73 5
176 8
18 3
24 5
82 9
76 8
199 2
3 6
23 9
49 5
126 2
66 7
45 2
5 7
118 3
48 2
1...

output:

-2
-1
-2
-2
-2
-1
-1
-2
-1
-2
-1
-1
-1
-1
-1
2
-2
-2
-2
-1
-1
-2
-2
-1
-1
-2
-2
-2
-1
-1
-1
-2
-2
-2
-1
-2
-3
-1
-1
-1
-2
-2
-1
-2
-1
-2
-2
-2
-1
-2
-2
-2
0
-2
-2
-1
-1
-2
-1
-1
-1
-2
-1
-1
-2
-2
-1
-1
-1
-1
-2
1
-1
-1
-1
-1
-2
-1
-1
-2
-2
-4
-1
-2
-2
-2
-1
-2
-2
-1
-2
-2
-1
-2
-2
-2
-1
-1
-1
-1
-1
...

result:

ok 100000 lines

Test #27:

score: 0
Accepted
time: 23ms
memory: 11640kb

input:

10 100000
-9 6
1 4
8 8
3 -5
4 -1
-6 0
1 8
-1 -1
-8 1
-1 -4
792434366 4
92102881 1
122696805 2
969313415 10
267007213 3
535748226 6
302806043 1
814393002 2
83864524 7
106160937 2
769231385 3
477853985 5
783986181 2
863038609 10
870475676 4
913155583 1
698243559 5
930099728 6
516688515 8
536420389 1
6...

output:

0
0
-1
-1
-1
0
0
0
0
-1
-1
-1
-1
-1
0
0
-1
0
-1
0
0
-1
0
0
-1
-1
0
-1
-1
0
0
-1
0
-1
0
-1
0
0
0
0
-1
0
-1
0
0
-1
0
0
0
0
0
0
0
0
-1
-1
0
0
0
-1
0
0
0
0
-1
-1
0
-1
0
0
-1
-1
0
0
0
0
-1
-1
0
0
-1
-1
-1
-1
0
-1
0
0
-1
-1
-1
0
0
-1
-1
-1
0
-1
0
0
-1
-1
0
0
-1
-1
-1
-1
0
-1
0
-1
-1
-1
-1
-1
0
0
0
0
0
0
-...

result:

ok 100000 lines

Test #28:

score: 0
Accepted
time: 14ms
memory: 10972kb

input:

100 100000
17 11
-42 -29
58 48
18 48
0 -57
-73 36
41 55
-38 -99
53 -100
-37 -64
-80 4
9 -11
17 99
-94 15
34 -98
34 -61
-45 -10
-47 25
16 -49
16 26
-23 -25
-71 -27
58 -27
-43 46
-12 -36
-70 -85
-76 13
36 56
15 -35
-78 -26
12 -51
-84 97
-63 -23
-93 71
-52 78
47 -29
-58 82
-8 -38
-8 60
23 -50
59 22
-50...

output:

-94
-51
-37
-72
1
-112
2
14
-62
-73
2
-73
-68
-56
-54
-28
-45
-65
-7
-50
-21
21
-40
-96
-80
-73
-108
40
-102
-74
29
-113
-69
-92
-72
78
-58
-14
-37
-77
-28
-93
-54
-13
75
-56
47
-88
62
-56
-10
-69
-115
-123
14
-100
-73
-52
-131
-122
7
-125
-73
-47
-99
-74
-125
-89
-76
44
-54
-85
-98
-74
-106
33
4
-7...

result:

ok 100000 lines

Test #29:

score: 0
Accepted
time: 15ms
memory: 11664kb

input:

100 100000
-1 62
-73 8
49 -3
83 -19
51 55
-28 21
-71 -17
-98 -83
30 -61
23 -88
-17 -78
37 42
85 -50
39 -80
62 -1
-61 -40
-14 73
-95 93
38 -94
86 89
10 91
45 73
79 -58
-3 100
-43 76
88 -74
85 1
-50 -42
71 -34
17 46
-1 -56
35 -59
11 -37
-46 -17
-36 62
41 -93
97 46
45 57
-49 59
-21 -90
-4 98
-80 -48
-5...

output:

-904
-685
-334
-574
-138
-372
7
-346
-864
-769
-966
-424
-79
-937
-677
-497
-885
-131
-263
-742
-448
-604
-843
-949
-768
-843
-680
-263
-655
-612
-471
-801
-839
-752
-22
-977
-90
-876
-77
-671
-781
-819
-884
-165
-382
-147
-402
-875
-514
-164
-174
-59
-932
-742
-709
-659
-435
-171
-410
-795
-906
-76...

result:

ok 100000 lines

Test #30:

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

input:

100 100000
20 35
-27 65
82 -72
43 14
91 41
40 99
20 32
96 -20
-20 -6
34 -81
-88 86
-37 -86
-25 -73
-37 -8
-81 37
-70 1
23 -81
87 -80
39 -33
81 -65
-2 65
99 -10
-38 -53
-80 44
-80 55
-33 31
-72 -40
90 -29
2 47
84 91
-60 -16
83 -100
71 93
12 20
16 3
81 -6
-65 88
-23 -78
53 -90
93 -10
-11 97
59 -60
-29...

output:

-3112
-7720
-8620
-1771
-7662
-4459
-1658
-1272
-9
-9909
-4563
-3582
-1879
-4361
-9807
-458
-2893
-2648
-5421
-380
-4630
-9118
-369
-7526
-2359
-2411
-1830
-2649
-8900
-7570
-1686
-4750
-7341
-7663
-3968
-1601
-3168
-9162
-3410
-2104
-7429
-1523
-3137
-5049
-6979
-1081
-2405
-9672
-4431
-5845
-6515
...

result:

ok 100000 lines

Test #31:

score: 0
Accepted
time: 21ms
memory: 9116kb

input:

100 100000
256155699 -547211095
-774345966 244576889
-489494512 -650843324
-216046407 936858375
-972216842 -994427050
406192309 616950876
69550216 305546853
14578662 -281359711
-183678722 -905559184
-646599996 -891956841
-921646468 677834276
655390404 187442412
-970539166 435720738
-408675181 -56111...

output:

-953694823
538115658
-945311783
-824680761
76415447
500252825
402098669
770070532
733844052
274519145
174329093
-27193765
-524187363
-947840006
-183672912
735929260
13405697
592004500
621473073
365423669
735935490
-913441540
-972219436
76415666
14582949
202399400
-278533900
41417664
149168518
621479...

result:

ok 100000 lines

Test #32:

score: 0
Accepted
time: 22ms
memory: 11376kb

input:

100 100000
744617759 158238326
340923698 -360072198
-991138470 -529277242
-199896385 -586829407
-148984877 -310206000
570899918 -740737853
-132209688 157071629
791203118 -821670121
204761796 679231292
900497734 395825676
63231449 -962828753
-648556788 -838850790
-767269417 -825933974
771859635 26616...

output:

-48307732
-607353993
951677097
483017978
955397673
-226366120
-226322194
-254790396
428396155
-21220357
771912311
-362170287
-199939924
173528991
-767251116
-563620453
340824963
568153528
-7081793
474455145
568202413
794156188
-132239964
433713221
-101885848
765688146
-900892201
89197107
63266605
-7...

result:

ok 100000 lines

Test #33:

score: 0
Accepted
time: 12ms
memory: 11368kb

input:

1000 100000
-434707201 -683661427
384781359 195621116
-951981420 781679258
-376074812 -581864278
428495470 482257122
-485361571 -231980232
318018358 546654220
755178326 -379948948
846857455 396009876
884142897 612544667
-830021241 124329110
-341821805 994936687
942683906 461913370
486906068 10143728...

output:

593580392
707881878
112696715
994093392
621249962
-273575528
72993016
881726697
348571700
-949352699
253246269
-120196549
400932945
-102612996
-190241830
549794901
-692235959
-881736891
800235674
975401539
-448302720
865442554
773904010
-995352295
-784611782
965589306
552963158
569880354
379631471
2...

result:

ok 100000 lines

Test #34:

score: 0
Accepted
time: 23ms
memory: 11740kb

input:

1000 100000
996999716 -34234903
400525215 -674912568
-55411236 222777222
-981748676 -408580972
-796406973 653686899
776754580 -948838675
9273709 955106065
554774087 449419555
-546907422 -190859901
-215040542 638122164
-967305902 64747929
-838776191 -11517133
425018184 -75393651
-268162808 533689787
...

output:

189789496
-757817007
-823093232
688388823
-327622928
526922189
-77145252
-125098514
759496
526926500
318655834
812773016
-604515294
-242449662
-788823122
507921972
-302596104
94285007
-992017072
880319426
569135406
144925975
456639566
626188103
463369829
456638677
-414922995
972068551
803213522
1250...

result:

ok 100000 lines

Test #35:

score: 0
Accepted
time: 21ms
memory: 9940kb

input:

10000 100000
451772880 -156086078
-950254772 927910017
891939666 -469915736
-860487758 -532719735
-567623395 -579566135
-482938321 -174746207
-72418614 609693111
530736894 468835873
-237259199 627247518
-995730942 -804582695
365316524 882959515
-808769910 -179962205
361830722 622888461
-48319332 235...

output:

-204527960
-378903070
62255589
852825025
-346701865
-950657488
490542991
534306652
483988290
-413237666
870710952
-210226764
635171030
935727328
-882351403
758421787
73536360
-586412042
814007077
470300624
-26222194
505354794
517257442
-741767895
-367426807
890150064
-982242426
117830210
58830549
-8...

result:

ok 100000 lines

Test #36:

score: 0
Accepted
time: 32ms
memory: 12012kb

input:

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

output:

-73385393
-61734787
93333112
-61522813
-10397170
-26327062
17805567
-2799682
-23095102
-8937987
-28735369
-68867844
1972248
-3874404
-75612832
-17194657
-13848421
-24694779
-66719951
-61793164
-70026215
-42159667
-21987872
-63862344
11806371
-70847717
-34510812
-46274918
-90589299
-95205712
-5779112...

result:

ok 100000 lines

Test #37:

score: 0
Accepted
time: 35ms
memory: 11340kb

input:

100000 100000
9 944359534
-2 277227375
8 -773149008
8 628295871
-4 -821907488
-2 -188575447
-1 -929530780
0 448989146
-4 -581847871
-7 846839738
5 628096431
1 775236356
-3 -185562343
-4 -939766393
5 694969897
-4 -864927003
-10 -841934125
-9 114196285
3 323366808
-9 471555976
-3 -504782745
1 65348899...

output:

270365985
150639067
468932042
297078804
891055722
924219699
574873537
677775650
144747048
681510473
309408490
35892574
380081715
825222137
581732087
196491670
496169337
355766126
636839475
576364386
758553411
517150283
608493572
854896692
613406885
434294076
922734082
224861074
380454645
688705341
2...

result:

ok 100000 lines

Test #38:

score: 0
Accepted
time: 58ms
memory: 12120kb

input:

100000 100000
-296460011 10
-748228463 8
549227188 -8
-925202056 -7
727222945 5
592939595 -6
765262067 -1
921188558 6
-199556343 9
-574817362 9
400002615 6
993984094 -7
-330466551 3
300272045 -6
-927024342 -4
-221508167 -1
85469524 -4
-442213879 5
792956663 -7
-575779456 9
604558700 -5
167721540 1
1...

output:

370620588
-545525120
387172159
670115019
585735755
287704138
53028116
9642178
-211245561
1456658287
-322635261
-351902818
96039327
805676105
-567177214
278707631
714181356
444120673
252621303
-437049384
261986564
302566305
-647736226
138843881
253990398
246744171
-291147172
692033774
458097866
10673...

result:

ok 100000 lines

Test #39:

score: 0
Accepted
time: 40ms
memory: 11724kb

input:

100000 100000
287158494 468569126
-759400102 479005436
9224200 735737370
-487094525 -916754661
-265725415 783847922
-818680615 702961624
301159712 456986386
344500159 -872939691
514917964 8167047
284680414 566451471
798924115 -38002837
883338728 400769685
-928436385 -562274014
-674132864 -190980349
...

output:

384260027
49361637
-152243459
-701996119
667652795
-501974523
-677823543
255037091
-512142999
848348378
-851177420
-739215099
597152867
-599402744
-690554903
-642244581
-689246874
-699479610
910898896
-143236942
886222051
-309472552
368428143
872068156
749313753
-972123580
-544636858
-535340081
-141...

result:

ok 100000 lines

Test #40:

score: 0
Accepted
time: 72ms
memory: 13096kb

input:

100000 100000
985616625 -541277150
771121018 987395516
-270410900 36892587
775618538 600376872
-122225248 774531538
235018672 81101323
-784561786 -223741542
707535619 -968131588
243250033 -591634095
317867272 -838122470
972069232 995811670
-603617686 -448042504
384613778 -51856128
850847268 -2908386...

output:

-854371732
-125874157
-153061888
-200474966
-111410975
86542542
-30066692
-886510167
-473441821
863942457
634332711
-716495565
-724979416
-800988904
-714652762
-854713536
-854371732
-354439862
-289326794
-471278590
-845908986
-868231014
-787955078
-863737323
262578856
-179652229
-830214823
258612801...

result:

ok 100000 lines

Test #41:

score: 0
Accepted
time: 62ms
memory: 12380kb

input:

100000 100000
281793987 -612870803
94305086 -560673933
-295513002 799528035
-540335441 368007457
-994148615 168189490
-251380159 -240836148
830551416 845691603
-541708172 -717794559
381479460 -711648554
784442711 170822908
177146652 -482022948
454677247 100446470
-894524326 -830844423
-904411557 -39...

output:

-694183691
716347306
-266930674
-619830251
-229242709
-619830250
614885035
-618882153
523053289
101000147
-440761559
-619830250
23678448
-166300736
-530798241
765868954
112616001
-692052039
263477195
-225469202
-619830251
274394351
247857588
193641799
-184963081
141048961
-619830250
353862996
-61983...

result:

ok 100000 lines

Test #42:

score: 0
Accepted
time: 65ms
memory: 12140kb

input:

100000 100000
-964559972 -631901904
-556990602 104372060
-710718564 -296031182
-25462638 -995192610
955777317 -736021459
-260580311 780254081
983144723 570913802
-618574557 -422386108
72134646 -213699479
-201554602 -191152520
206392799 -364149338
-482916343 -436067881
398429352 -281033237
371966703 ...

output:

-391940170
-395185238
-726862742
-391727352
-804354033
-453109000
-326461200
-397583180
-324954058
-679150595
-440574818
658433392
-807429615
127147486
473775920
-904011405
-442770667
-389454685
-30694191
136370114
-325523457
-508652522
260613730
-691463551
300734981
852354603
-389454685
-326461199
...

result:

ok 100000 lines

Test #43:

score: 0
Accepted
time: 44ms
memory: 11880kb

input:

90000 100000
502039555 209250582
-444359527 -207281547
183192756 -427133907
420664856 -882193463
762643102 -537838960
-849279809 687520501
119720700 -541964994
506112534 -596514223
-715457534 -971620343
-206938912 223190193
-148198813 358949006
-421623706 557259839
-328389604 548595891
313872333 283...

output:

1176623464
-53472874
276900145
765929269
1632953231
179558347
588406739
553515698
1490337553
1327318717
414789821
1493761479
282155259
-4010076
1081909339
-537208912
538722992
655251272
1024472252
1277368747
1019325376
482186049
960089941
187233000
1286786779
257490840
-830385584
882296518
538052297...

result:

ok 100000 lines

Test #44:

score: 0
Accepted
time: 53ms
memory: 12020kb

input:

100000 100000
-223708673 -702436384
-999099108 94338999
547433890 -747491546
-491512453 512628370
487172489 250916656
17381169 -518905532
-816071725 -727403547
-413706036 -825375237
-627842488 813329258
-30209292 -977325756
-772182084 -94715016
368138666 -564899470
-996931517 204195496
-65616765 585...

output:

-13663834
-178736601
-1380798619
-1110041540
-21905975
-76762316
-151401624
-233980355
-1845940849
-1048120327
518361176
-1084916571
39446420
-30025177
-1308604439
-629228031
-142350576
-511576652
-1019318276
-445223616
-1173857268
-1440673231
-1626003031
-1154284639
240183880
487255215
-1247255338
...

result:

ok 100000 lines

Test #45:

score: 0
Accepted
time: 21ms
memory: 11360kb

input:

900 100000
-602 -865
985 -313
737 -886
87 708
356 -809
-455 -912
-414 661
253 -172
-164 -801
-556 -58
-644 112
-20 -881
908 -850
-115 284
-575 -88
940 -444
594 -812
-445 -35
-899 -895
258 -20
18 416
-102 -288
-442 -652
953 -569
-94 886
11 -594
-139 590
-658 900
-641 975
70 258
-329 788
3 225
5 -143
...

output:

120
-32
241
-680
440
-32
235
366
-499
68
23
-277
234
207
565
-89
-460
-45
460
723
144
-90
173
-674
27
-27
-55
-31
94
471
-9
88
-718
376
293
514
59
404
-14
623
364
398
75
-965
-24
-224
661
-686
311
-99
-27
349
-212
47
371
-690
59
416
130
400
253
-318
228
91
-470
341
683
-707
-19
-710
561
122
603
-637...

result:

ok 100000 lines

Test #46:

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

input:

1000 100000
-147 -416
-393 -50
470 -275
-920 805
798 853
-273 795
784 281
-9 -793
706 34
-631 894
28 549
-388 565
849 -899
-250 471
105 696
170 371
299 715
269 -645
-252 -226
544 -649
76 -374
397 -854
-278 177
-530 -277
-313 503
-456 202
-210 313
410 148
-347 -667
-120 -624
-566 -210
-716 654
386 64...

output:

809
-68
-911
-498
-894
-1335
57
-1185
-616
-1324
-1375
227
-947
461
23
183
393
45
-482
-369
-117
-315
576
-874
-653
-853
-926
770
867
-822
21
-894
-886
-340
-121
-1021
-466
-635
-877
-732
126
518
-426
-546
19
528
151
-158
-648
-981
-339
-309
-852
-1146
608
-1308
-1072
-893
-37
-893
866
-662
236
274
...

result:

ok 100000 lines

Test #47:

score: 0
Accepted
time: 59ms
memory: 12176kb

input:

100000 100000
684285263 180693552
-76651999 -389372051
-879653508 -600952017
798704427 -701919940
119579671 587756508
-100296843 989620333
-375844363 -416164963
-142330586 990249737
-493174522 233907575
-755521469 -759992701
859433612 714920235
65299679 -683945454
908759410 226316242
152628828 68588...

output:

796427657
-459852712
2608939
-434662153
-651517920
-601190660
158135757
-105677886
150644341
708124645
-472642872
-85948007
-670598191
-392539579
-720655083
665353614
207543916
75037639
-726705773
658299085
-470716490
53070040
-438588313
-443249386
-683902173
-558221341
476337853
459554132
30339712
...

result:

ok 100000 lines

Test #48:

score: 0
Accepted
time: 50ms
memory: 12012kb

input:

99999 100000
156564462 -488302017
-192132388 -362924118
-446104520 -47498133
-756801924 788641462
-705663686 -999252477
434250146 -955439930
954104475 887694624
436960796 -33940367
-961465996 -868280920
217211828 -18156408
-390052345 69195580
884522238 -458089095
-629069058 814705359
318873791 80893...

output:

1895093517
491521999
-149691771
1177388558
1225193236
-170179336
422730954
1337161463
943278887
418179247
976560270
406203878
552277996
1230158954
862086233
1051085860
1124975386
-147602701
985193481
-1089799514
1074416516
1455846568
198589516
156749190
810271173
486890710
601669110
-237452110
35106...

result:

ok 100000 lines

Test #49:

score: 0
Accepted
time: 50ms
memory: 12116kb

input:

99999 100000
-707756108 -705222327
-1000000000 -1000000000
782307502 863535856
-1000000000 -719445671
-1000000000 -1000000000
1000000000 -1000000000
-1000000000 1000000000
-1000000000 -452829800
-1000000000 -1000000000
383838661 -799003184
-1000000000 206564145
1000000000 -456774190
1000000000 -8813...

output:

-999999948
893056897
0
-716370228
-857684759
999999996
893056896
893056897
408251374
0
0
467889305
-5580799
893056897
999999900
893056896
999999921
-507566263
893056896
0
893056896
18711302
893056897
893056896
-67068219
893056897
999999996
0
-835092468
0
893056897
-999999973
893056897
305963537
1090...

result:

ok 100000 lines

Test #50:

score: 0
Accepted
time: 40ms
memory: 12160kb

input:

100000 100000
-1000000000 1000000000
-1000000000 -1000000000
-1000000000 447417896
155258565 -163472790
-733343196 -1000000000
1000000000 1000000000
-1000000000 -470712138
735386345 -1000000000
-1000000000 1000000000
1000000000 122168718
1000000000 -1000000000
477285556 1000000000
1000000000 9296782...

output:

2000000000
2000000000
2000000000
14720687
316566133
555859268
-2000000000
-1490351667
1000000002
1000000058
2000000000
2000000000
-1230559944
1755759823
1000000034
2000000000
-1000000085
-253599633
-1000000002
1000000059
1737139234
-1000000046
1000000081
-1705827307
1000000007
1558032321
1000000099
...

result:

ok 100000 lines

Extra Test:

score: 0
Extra Test Passed