Language: Java

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define maxn 10005

int n;
struct Node
{	
	int di;
	int num;
}qur[maxn];
double num[maxn];
struct node
{
	int l,r;
	int next;
	int data;
}tree[maxn<<2];
int flag;

void build(int p,int l,int r)
{
	tree[p].l=l;
	tree[p].r=r;
	tree[p].data=0;
	if (l+1==r)
		return;
	int mid=(l+r)>>1;
	build(p<<1,l,mid);
	build(p<<1|1,mid,r);
}

void updata(int p,double x,int k)
{
	if (tree[p].l+1==tree[p].r)
	{
		if (k)
			tree[p].data++;
		else
		{
			if (tree[p].data==0)
				flag=0;
			else
				tree[p].data--;
		}
		return;
	}
	int mid=(tree[p].l+tree[p].r)>>1;
	if (x<num[mid])
		updata(p<<1,x,k);
	else	
		updata(p<<1|1,x,k);
	if (flag)
	{
		if (k==0) tree[p].data--;
		else tree[p].data++;
	}
}

double cal(int p,int x)
{
	if (tree[p].l+1==tree[p].r)
		return num[tree[p].l];
	if (tree[p<<1].data>x)
		return cal(p<<1|1,x-tree[p<<1].data);
	return cal(p<<1,x);
}
long long dnum,ans,tp;
long long trans(double a)
{
	dnum=0;
	tp=a;
	a-=tp;
	long long res=a*(long long)(1e20);
	
	long long c;
	if(res==0)	
	{
		dnum=1;
		ans=tp;
		return 0;
	}
	while(res)
	{		
		c=res%10;		
		if(c!=0)
		{
			return c;
		}
		res/=10;
		
	}
}
int main()
{
	int t;
	scanf("%d",&t);
	while (t--)
	{
		scanf("%d",&n);
		int i;
		char st[10];
		for (i=1;i<=n;i++)
		{
			scanf("%s %lf",st,&num[i]);
			if (st[0]=='r')
				qur[i].di=0;
			else
				qur[i].di=1;
			qur[i].num=num[i];
		}
		
		sort(num+1,num+n+1);
		int k=1;
		for (i=2;i<=n;i++)
			if (num[i]!=num[i-1])
				num[++k]=num[i];
		build(1,1,k);
		
		for (i=1;i<=n;i++)
		{
			if (qur[i].di==0)
			{
				flag=1;
				updata(1,qur[i].num,0);
				if (!flag)
					printf("Wrong\n");
				else if (tree[1].data==0)
					printf("Empty\n");
				else if (flag==1)
				{
					double tmp;
					if (tree[1].data%2==1)
						tmp=cal(1,(tree[1].data+1)/2);
					else
					{
						double tmp1=cal(1,tree[1].data/2);
						double tmp2=cal(1,tree[1].data/2+1);
						tmp=(tmp1+tmp2)/2;
					}
					long long hh=trans(tmp);
					if(dnum==1)
						printf("%lld\n",ans);
					else	
						printf("%lld.%lld\n",tp,hh);
				}
		  }
			else
			{
				updata(1,qur[i].num,1);
				double tmp;
				if (tree[1].data%2==1)
					tmp=cal(1,(tree[1].data+1)/2);
				else
				{
					double tmp1=cal(1,tree[1].data/2);
					double tmp2=cal(1,tree[1].data/2+1);
					tmp=(tmp1+tmp2)/2;
				}
					long long hh=trans(tmp);
					if(dnum==1)
						printf("%lld\n",ans);
					else	
						printf("%lld.%lld\n",tp,hh);
			}
		}
	}
	return 0;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include<stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include<stdio.h>
        ^
Main.java:2: error: illegal character: '#'
#include<stdlib.h>
^
Main.java:3: error: illegal character: '#'
#include<string.h>
^
Main.java:4: error: illegal character: '#'
#include<algorithm>
^
Main.java:6: error: illegal character: '#'
#define maxn 10005
^
Main.java:6: error: class, interface, enum, or record expected
#define maxn 10005
        ^
Main.java:9: error: class, interface, enum, or record expected
struct Node
^
Main.java:12: error: unnamed classes are a preview feature and are disabled by default.
	int num;
	^
  (use --enable-preview to enable unnamed classes)
Main.java:13: error: class, interface, enum, or record expected
}qur[maxn];
^
Main.java:14: error: class, interface, enum, or record expected
double num[maxn];
^
Main.java:15: error: class, interface, enum, or record expected
struct node
^
Main.java:20: error: class, interface, enum, or record expected
}tree[maxn<<2];
^
Main.java:70: error: class, interface, enum, or record expected
long long dnum,ans,tp;
^
Main.java:71: error: class, interface, enum, or record expected
long long trans(double a)
^
Main.java:74: error: class, interface, enum, or record expected
	tp=a;
	^
Main.java:75: error: class, interface, enum, or record expected
	a-=tp;
	^
Main.java:76: error: class, interface, enum, or record expected
	long long res=a*(long long)(1e20);
	^
Main.java:78: error: class, interface, enum, or record expected
	long long c;
	^
Main.java:79: error: class, interface, enum, or record expected
	if(res==0)	
	^
Main.java:82: error: class, interface, enum, or record expected
		ans=tp;
		^
Main.java:83: error: class, interface, enum, or record expected
		return 0;
		^
Main.java:84: error: class, interface, enum, or record expected
	}
	^
Main.java:88: error: class, interface, enum, or record expected
		if(c!=0)
		^
Main.java:91: error: class, interface, enum, or record expected
		}
		^
Main.java:94: error: class, interface, enum, or record expected
	}
	^
Main.java:99: error: class, interface, enum, or record expected
	scanf("%d",&t);
	^
Main.java:100: error: class, interface, enum, or record expected
	while (t--)
	^
Main.java:104: error: class, interface, enum, or record expected
		char st[10];
		^
Main.java:105: error: class, interface, enum, or record expected
		for (i=1;i<=n;i++)
		^
Main.java:105: error: class, interface, enum, or record expected
		for (i=1;i<=n;i++)
		         ^
Main.java:105: error: class, interface, enum, or record expected
		for (i=1;i<=n;i++)
		              ^
Main.java:108: error: class, interface, enum, or record expected
			if (st[0]=='r')
			^
Main.java:110: error: class, interface, enum, or record expected
			else
			^
Main.java:112: error: class, interface, enum, or record expected
			qur[i].num=num[i];
			^
Main.java:113: error: class, interface, enum, or record expected
		}
		^
Main.java:117: error: class, interface, enum, or record expected
		for (i=2;i<=n;i++)
		^
Main.java:117: error: class, interface, enum, or record expected
		for (i=2;i<=n;i++)
		         ^
Main.java:117: error: class, interface, enum, or record expected
		for (i=2;i<=n;i++)
		              ^
Main.java:120: error: class, interface, enum, or record expected
		build(1,1,k);
		^
Main.java:122: error: class, interface, enum, or record expected
		for (i=1;i<=n;i++)
		^
Main.java:122: error: class, interface, enum, or record expected
		for (i=1;i<=n;i++)
		         ^
Main.java:122: error: class, interface, enum, or record expected
		for (i=1;i<=n;i++)
		              ^
Main.java:127: error: class, interface, enum, or record expected
				updata(1,qur[i].num,0);
				^
Main.java:128: error: class, interface, enum, or record expected
				if (!flag)
				^
Main.java:130: error: class, interface, enum, or record expected
				else if (tree[1].data==0)
				^
Main.java:132: error: class, interface, enum, or record expected
				else if (flag==1)
				^
Main.java:135: error: class, interface, enum, or record expected
					if (tree[1].data%2==1)
					^
Main.java:137: error: class, interface, enum, or record expected
					else
					^
Main.java:141: error: class, interface, enum, or record expected
						tmp=(tmp1+tmp2)/2;
						^
Main.java:142: error: class, interface, enum, or record expected
					}
					^
Main.java:144: error: class, interface, enum, or record expected
					if(dnum==1)
					^
Main.java:146: error: class, interface, enum, or record expected
					else	
					^
Main.java:148: error: class, interface, enum, or record expected
				}
				^
Main.java:154: error: class, interface, enum, or record expected
				if (tree[1].data%2==1)
				^
Main.java:156: error: class, interface, enum, or record expected
				else
				^
Main.java:160: error: class, interface, enum, or record expected
					tmp=(tmp1+tmp2)/2;
					^
Main.java:161: error: class, interface, enum, or record expected
				}
				^
Main.java:163: error: class, interface, enum, or record expected
					if(dnum==1)
					^
Main.java:165: error: class, interface, enum, or record expected
					else	
					^
Main.java:167: error: class, interface, enum, or record expected
			}
			^
Main.java:171: error: class, interface, enum, or record expected
}
^
62 errors