For this Question: Edward and George received n candies from their parents. Each candy weighs either 1 gram or 2 grams. Now they want to divide all candies among themselves fairly so that the total weight of Edward's candies is equal to the total weight of George's candies. Check if they can do that.
<b>Note:</b> Candies are not allowed to be cut in half.The first line of the input consists of an integer n. The next line contains n integers a<sub>1</sub>, a<sub>2</sub>, …, a<sub>n</sub> denoting the weights of the candies.

<b>Constraints</b>
1 &le; n &le; 100Print Yes if all candies can be divided into two sets with the same weight; No otherwise.<b>Sample Input 1</b>
2
1 1
<b>Sample Output 1</b>
Yes

<b>Sample Input 2</b>
2
1 2
<b>Sample Output 2</b>
No, I have written this Solution Code: #include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    if (c == 1) {
      cnt1++;
    } else {
      cnt2++;
    }
  }
  if ((cnt1 + 2 * cnt2) % 2 != 0) {
    cout << "No\n";
  } else {
    int sum = (cnt1 + 2 * cnt2) / 2;
    if (sum % 2 == 0 || (sum % 2 == 1 && cnt1 != 0)) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
}

int main() {
  int t=1;
//  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
  
  
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?