Language: C

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<vector>
#include<map>
#include<string>

using namespace std;

#define MID(x,y) (((x)+(y))/2)

const int N = 100100;
const int M = 200100;
const int Q = 11;

typedef long long LL;

struct O
{
	bool f[Q];
	int trans(LL x){
		if(x==0)return 0;
		x%=9;
		if(x==0)return 9;
		return x;
	}
	void init(LL x){
		memset(f,0,sizeof(f));
		f[trans(x)]=true;
	}
	void init(){
		memset(f,0,sizeof(f));
	}
	void uni(O b){
		for(int i=0;i<=9;i++)
			f[i]=f[i]||b.f[i];
	}
	int retrans(LL x,LL y){
		if(x==0||y==0)return y;
		y+=9-x;
		if(y>9)y-=9;
		return y;
	}
	void deal(LL x){
		bool tmp[Q];
		memset(tmp,0,sizeof(tmp));
		for(int i=0;i<=9;i++)
			if(f[i])
				tmp[retrans(i,x)]=true;
		for(int i=0;i<=9;i++)
			f[i]=tmp[i];
	}
	void print(int x,int &flag){
		if(flag==0)flag=1;
		else printf(" ");
		printf("%d",x);
	}
	void out(){
		puts("aa");
		int i,cnt=0,flag=0;
		for(i=9;i>=0&&cnt<5;i--){
			if(f[i]){
				cnt++;
				print(i,flag);
			}
		}
		for(;cnt<5;cnt++)print(-1,flag);
		printf("\n");
	}
};

struct SGT{
	int lk[M],rk[M],a[M],b[M],tp;
	O val[M];
	void init(int n,O x[]){
		tp=0;
		build(1,n,x);
	}
	int build(int l,int r,O y[]){
		int x=++tp;
		a[x]=l,b[x]=r;
		if(l!=r){
			lk[x]=build(l,MID(l,r),y);
			rk[x]=build(MID(l,r)+1,r,y);
			update(x);
		}
		else val[x]=y[l];
		return x;
	}
	void update(int x){
		val[x].init();
		val[x].uni(val[lk[x]]);
		val[x].uni(val[rk[x]]);
	}
	O query(int l,int r,int x){
		printf("xxx %d %d %d\n",l,r,x);
		if(a[x]>=l&&b[x]<=r)return val[x];
		O ans;
		ans.init();
		if(l<=MID(a[x],b[x]))ans.uni(query(l,r,lk[x]));
		if(r>MID(a[x],b[x]))ans.uni(query(l,r,rk[x]));
		return ans;
	}
}sgt;
O o[N];
long long sum[N];
int num[N];
struct SGT2{
	int lk[M],rk[M],a[M],b[M],tp;
	O val[M];
	void init(int n,O x[]){
		tp=0;
		build(1,n,x);
		//puts("aaaaaaaa");
	}
	int build(int l,int r,O y[]){
		int x=++tp;
	//	printf("begin %d %d %d\n",l,r,x);
		a[x]=l,b[x]=r;
		if(l!=r){
			lk[x]=build(l,MID(l,r),y);
			rk[x]=build(MID(l,r)+1,r,y);
			update(x);
		}
		else val[x]=y[l];
	//	printf("end %d %d %d\n",l,r,x);
		return x;
	}
	void update(int x){
		val[x].init();
		val[x].uni(val[lk[x]]);
		val[x].uni(val[rk[x]]);
		O tmp;
		tmp.init();
		for(int i=a[x];i<=MID(a[x],b[x]);i++){
			printf("%d %d %d %d\n",i,x,a[x],b[x]);
			puts("bb");
			//if(i <= b[x])
			tmp=sgt.query(i,b[x],1);
			puts("cc");
			tmp.deal(sum[i-1]);
			puts("dd");
			val[x].uni(tmp);
		}	
		puts("ee");
	}
	O query(int l,int r,int x){
		if(a[x]>=l&&b[x]<=r)return val[x];
		O ans;
		ans.init();
		if(l<=MID(a[x],b[x]))ans.uni(query(l,r,lk[x]));
		if(r>MID(a[x],b[x]))ans.uni(query(l,r,rk[x]));
		return ans;
	}
}sgt2;

void init(int n)
{
	for(int i=1;i<=n;i++)scanf("%d",&num[i]);
	sum[0]=0;
	for(int i=1;i<=n;i++)sum[i]=num[i]+sum[i-1];
	o[0].init();
	for(int i=1;i<=n;i++)o[i].init(sum[i]);
	//puts("aa");
	//printf("%d\n",n);
	sgt.init(n,o);
	puts("aa");
	sgt2.init(n,o);
	puts("ff");
}

void solve(int l,int r)
{
	O x=sgt2.query(l,r,1);
	//x.deal(sum[l-1]);
	x.out();
}

int main()
{	
	int t,n,m,l,r;
	scanf("%d",&t);
	for(int cs=1;cs<=t;cs++){
		scanf("%d",&n);
		init(n);
		//sgt.init(n,o);
		if(cs!=1)printf("\n");
		printf("Case #%d:\n",cs);
		scanf("%d",&m);
		for(int i=1;i<=m;i++){
			scanf("%d %d",&l,&r);
		//	puts("cc");
			solve(l,r);
		}
	}
	return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.