Language: C++

#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
char in[110];
int h[1100];
int g[1100];
int type[1100];
int v[1100];
int s[1100];
int sum[1100];#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
char in[110];
int h[1100];
int g[1100];
int type[1100];
int v[1100];
int s[1100];
int sum[1100];
int L[1100];
int R[1100];
int t[1100];
int u[1100];
int c[1100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		map<string,int>m1;
		int n1=0;
		map<string,int>m2;
		int n2=0;
		for(int i=0;i<a;i++)v[i]=0;
		for(int i=0;i<1100;i++)s[i]=t[i]=u[i]=sum[i]=R[i]=0;
		for(int i=0;i<1100;i++)L[i]=99999999;
		for(int i=0;i<a;i++){
			scanf("%s",in);
			string A=in;
			scanf("%s",in);
			
			if(in[0]=='B')type[i]=1;
			else type[i]=0;
			scanf("%s",in);
			string B=in;
			scanf("%d",c+i);
			if(m1.count(A))h[i]=m1[A];
			else{
				m1[A]=n1;
				h[i]=n1++;
			}
			if(m2.count(B))g[i]=m2[B];
			else{
				m2[B]=n2;
				g[i]=n2++;
			}
		}
	//	for(int i=0;i<a;i++)printf("%d %d %d %d\n",h[i],type[i],g[i],c[i]);
		for(int i=0;i<a;i++){
			if(v[i])continue;
			if(type[i]){
				int at=-1;
				int val=99999999;
				for(int j=0;j<i;j++){
					if(v[j]||h[i]==h[j])continue;
					if(g[i]==g[j]&&type[j]==0&&c[j]<=c[i]&&val>c[j]){
						val=c[j];at=j;
					}
				}
				if(!~at)continue;
				v[at]=v[i]=1;
				int tmp=(val+c[i])/2;
				sum[g[i]]++;
				s[g[i]]+=tmp;
				L[g[i]]=min(L[g[i]],tmp);
				R[g[i]]=max(R[g[i]],tmp);
				t[h[i]]+=tmp;u[h[at]]+=tmp;
			}else{
				int at=-1;
				int val=0;
				for(int j=0;j<i;j++){
					if(v[j]||h[i]==h[j])continue;
					if(g[i]==g[j]&&type[j]==1&&c[i]<=c[j]&&val<c[j]){
						val=c[j];at=j;
					}
				}
				if(!~at)continue;
				v[at]=v[i]=1;
				int tmp=(val+c[i])/2;
				sum[g[i]]++;
				L[g[i]]=min(L[g[i]],tmp);
				R[g[i]]=max(R[g[i]],tmp);
				s[g[i]]+=tmp;
				t[h[at]]+=tmp;u[h[i]]+=tmp;
			}
		}
		for(map<string,int>::iterator it=m2.begin();it!=m2.end();it++){
			string name=(*it).first;
			int num=(*it).second;
			if(!sum[num])continue;
			printf("%s %d %d %d\n",name.c_str(),L[num],s[num]/sum[num],R[num]);
		}
		printf("--\n");
		for(map<string,int>::iterator it=m1.begin();it!=m1.end();it++){
			string name=(*it).first;
			int num=(*it).second;
			printf("%s %d %d\n",name.c_str(),t[num],u[num]);
		}
		printf("----------\n");
	}
}
int L[1100];
int R[1100];
int t[1100];
int u[1100];
int c[1100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		map<string,int>m1;
		int n1=0;
		map<string,int>m2;
		int n2=0;
		for(int i=0;i<a;i++)v[i]=0;
		for(int i=0;i<1100;i++)s[i]=t[i]=u[i]=sum[i]=R[i]=0;
		for(int i=0;i<1100;i++)L[i]=99999999;
		for(int i=0;i<a;i++){
			scanf("%s",in);
			string A=in;
			scanf("%s",in);
			
			if(in[0]=='B')type[i]=1;
			else type[i]=0;
			scanf("%s",in);
			string B=in;
			scanf("%d",c+i);
			if(m1.count(A))h[i]=m1[A];
			else{
				m1[A]=n1;
				h[i]=n1++;
			}
			if(m2.count(B))g[i]=m2[B];
			else{
				m2[B]=n2;
				g[i]=n2++;
			}
		}
	//	for(int i=0;i<a;i++)printf("%d %d %d %d\n",h[i],type[i],g[i],c[i]);
		for(int i=0;i<a;i++){
			if(v[i])continue;
			if(type[i]){
				int at=-1;
				int val=99999999;
				for(int j=0;j<a;j++){
					if(v[j]||h[i]==h[j])continue;
					if(g[i]==g[j]&&type[j]==0&&c[j]<=c[i]&&val>c[j]){
						val=c[j];at=j;
					}
				}
				if(!~at)continue;
				v[at]=v[i]=1;
				int tmp=(val+c[i])/2;
				sum[g[i]]++;
				s[g[i]]+=tmp;
				L[g[i]]=min(L[g[i]],tmp);
				R[g[i]]=max(R[g[i]],tmp);
				t[h[i]]+=tmp;u[h[at]]+=tmp;
			}else{
				int at=-1;
				int val=0;
				for(int j=0;j<a;j++){
					if(v[j]||h[i]==h[j])continue;
					if(g[i]==g[j]&&type[j]==1&&c[i]<=c[j]&&val<c[j]){
						val=c[j];at=j;
					}
				}
				if(!~at)continue;
				v[at]=v[i]=1;
				int tmp=(val+c[i])/2;
				sum[g[i]]++;
				L[g[i]]=min(L[g[i]],tmp);
				R[g[i]]=max(R[g[i]],tmp);
				s[g[i]]+=tmp;
				t[h[at]]+=tmp;u[h[i]]+=tmp;
			}
		}
		for(map<string,int>::iterator it=m2.begin();it!=m2.end();it++){
			string name=(*it).first;
			int num=(*it).second;
			if(!sum[num])continue;
			printf("%s %d %d %d\n",name.c_str(),L[num],s[num]/sum[num],R[num]);
		}
		printf("--\n");
		for(map<string,int>::iterator it=m1.begin();it!=m1.end();it++){
			string name=(*it).first;
			int num=(*it).second;
			printf("%s %d %d\n",name.c_str(),t[num],u[num]);
		}
		printf("----------\n");
	}
}

Compiler output:
a.cc:12:15: error: stray '#' in program
   12 | int sum[1100];#include<stdio.h>
      |               ^
a.cc:12:16: error: 'include' does not name a type
   12 | int sum[1100];#include<stdio.h>
      |                ^~~~~~~
a.cc:17:6: error: redefinition of 'char in [110]'
   17 | char in[110];
      |      ^~
a.cc:6:6: note: 'char in [110]' previously declared here
    6 | char in[110];
      |      ^~
a.cc:18:5: error: redefinition of 'int h [1100]'
   18 | int h[1100];
      |     ^
a.cc:7:5: note: 'int h [1100]' previously declared here
    7 | int h[1100];
      |     ^
a.cc:19:5: error: redefinition of 'int g [1100]'
   19 | int g[1100];
      |     ^
a.cc:8:5: note: 'int g [1100]' previously declared here
    8 | int g[1100];
      |     ^
a.cc:20:5: error: redefinition of 'int type [1100]'
   20 | int type[1100];
      |     ^~~~
a.cc:9:5: note: 'int type [1100]' previously declared here
    9 | int type[1100];
      |     ^~~~
a.cc:21:5: error: redefinition of 'int v [1100]'
   21 | int v[1100];
      |     ^
a.cc:10:5: note: 'int v [1100]' previously declared here
   10 | int v[1100];
      |     ^
a.cc:22:5: error: redefinition of 'int s [1100]'
   22 | int s[1100];
      |     ^
a.cc:11:5: note: 'int s [1100]' previously declared here
   11 | int s[1100];
      |     ^
a.cc:23:5: error: redefinition of 'int sum [1100]'
   23 | int sum[1100];
      |     ^~~
a.cc:12:5: note: 'int sum [1100]' previously declared here
   12 | int sum[1100];#include<stdio.h>
      |     ^~~
a.cc:114:5: error: redefinition of 'int L [1100]'
  114 | int L[1100];
      |     ^
a.cc:24:5: note: 'int L [1100]' previously declared here
   24 | int L[1100];
      |     ^
a.cc:115:5: error: redefinition of 'int R [1100]'
  115 | int R[1100];
      |     ^
a.cc:25:5: note: 'int R [1100]' previously declared here
   25 | int R[1100];
      |     ^
a.cc:116:5: error: redefinition of 'int t [1100]'
  116 | int t[1100];
      |     ^
a.cc:26:5: note: 'int t [1100]' previously declared here
   26 | int t[1100];
      |     ^
a.cc:117:5: error: redefinition of 'int u [1100]'
  117 | int u[1100];
      |     ^
a.cc:27:5: note: 'int u [1100]' previously declared here
   27 | int u[1100];
      |     ^
a.cc:118:5: error: redefinition of 'int c [1100]'
  118 | int c[1100];
      |     ^
a.cc:28:5: note: 'int c [1100]' previously declared here
   28 | int c[1100];
      |     ^
a.cc:119:5: error: redefinition of 'int main()'
  119 | int main(){
      |     ^~~~
a.cc:29:5: note: 'int main()' previously defined here
   29 | int main(){
      |     ^~~~