### My issue

how to practice these type of questions??

### My code

```
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin>>n;
int sum=0;
bool flag=false;
vector<int>v(n);
for(int i=0;i<n;i++){
cin>>v[i];
sum+=v[i];
}
if(sum%n!=0)
{
flag=true;
}
int sum2=0;
for(int i=0;i<n;i++)
{
int vl=v[i]/2;
sum2+=vl;
}
if((!flag) && (sum2%n)==0){
cout << "Yes" << endl;
}
else
cout << "No" << endl;
}
int main() {
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
```

Problem Link: TIES Problem - CodeChef

Let me help you to break down this number:-

- If the total chocolates is not divisible by number of people we cant divide them equally so we return NO.
- If total%size == 0, we need to know whether he can equalize without compromising the given condition i.e., he can take 2^k chocolate and give to another.
- To know weather he can divide with out breaking the rule first lets know how many chocolates each has to have so we do (total/size)
- Now search for the person who has more than (total/size) chocolates why because only he can give chocloates to whom have less.
- Now from that person chocolates subtract the (total/size) chocolates from it , so that reamining chocolates he can share with other.
- Now the condition can he share according to the condition or nor to check that we simply divide the remaining chocolate with 2 if it is divisible ok continue if not we break the loop and print NO if we cant find the person who cant share which means we can equalize so we return yes.

Hope you understand.