A - Non-zero
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+10;
ll a[maxn];
int main(){
ll t;
scanf("%lld",&t);
while(t--){
ll n;
scanf("%lld",&n);
ll sum=0;
ll zero=0;
for(ll i=1;i<=n;i++){
ll x;
scanf("%lld",&x);
sum+=x;
zero+=(x==0);
}
ll ans=0;
ans+=zero;
sum+=zero;
if(!sum)ans++;
cout<<ans<<endl;
}
}
B - Assigning to Classes
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+10;
ll a[maxn];
int main(){
ll t;
cin>>t;
while(t--){
ll n;
scanf("%lld",&n);
for(ll i=1;i<=2*n;i++){
scanf("%lld",&a[i]);
}
sort(a+1,a+1+2*n);
cout<<a[n+1]-a[n]<<endl;
}
}
C - Anu Has a Function
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+10;
ll a[maxn];
ll cnt[maxn];
ll pos[maxn];
int main(){
ll n;
scanf("%lld",&n);
ll MAX=0;
for(ll i=1;i<=n;i++){
scanf("%lld",&a[i]);
ll x=a[i];
ll bit=0;
while(x){
MAX=max(bit,MAX);
if(x&1){
cnt[bit]++;
pos[bit]=i;
}
bit++;
x>>=1;
}
}
ll head=n;
for(ll i=MAX;i>=0;i--){
if(cnt[i]==1){
head=pos[i];
break;
}
}
cout<<a[head];
for(ll i=n;i>0;i--){
if(i==head)continue;
printf(" %lld",a[i]);
}
cout<<endl;
}
D - Aerodynamic
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+10;
ll x[maxn],y[maxn];
int main(){
ll n;
scanf("%lld",&n);
ll sumx=0,sumy=0;
for(ll i=1;i<=n;i++){
scanf("%lld%lld",&x[i],&y[i]);
sumx+=x[i];
sumy+=y[i];
}
if(n%2)puts("NO");
else{
bool flag=true;
for(ll i=1;i<=n/2;i++){
if(n*(x[i]+x[i+n/2])!=sumx*2||n*(y[i]+y[i+n/2])!=sumy*2)
flag=false;
}
if(flag)puts("YES");
else puts("NO");
}
}
E - Water Balance
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
int a[maxn];
double ans[maxn];
double l[maxn];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
int cnt=0;
for(int i=1;i<=n;i++){
ans[++cnt]=a[i]*1.0;
l[cnt]=1;
while(cnt>1&&ans[cnt]<ans[cnt-1]){
ans[cnt-1]=(ans[cnt]*l[cnt]+ans[cnt-1]*l[cnt-1])/(l[cnt]+l[cnt-1]);
cnt--;
l[cnt]+=l[cnt+1];
}
}
for(int i=1;i<=cnt;i++){
for(int j=1;j<=l[i];j++){
printf("%.12f%c",ans[i],'\n');
}
}
return 0;
}