Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
int main()
{
	ll N;
	ll i,j,k;
	ll A[1<<19] = {0};
	cin >>N;
	ll S = 1<<N;
	ll mx = 0;
	set<ll> ss;
	for(i=0;i<S;++i)
	{
		cin>>A[i];
		if(mx < A[i])
			mx=A[i];
		ss.insert(A[i]);
	}
	ll counter[128] = {0};
	ll row[32] = {0};
	auto itr = ss.rbegin()
	for(i=0;i<32;++i)
	{
		row[i] = *itr;
		itr--;
	}

	for(i=0;i<S;++i)
	{
		for(j=0;j<32;++j)
		{
			if(row[j] == A[i])
				counter[j]++;
		}
		if(j==32)
			counter[32]++;
	}
	ll caps[128] = {0};
	ll cur = 1;
	ll div = 1;
	caps[0] = 1;
	ll nx[128] ={0};
	nx[0] = 1;
	for(i=0;i<N;++i)
	{
		for(j=1;j<=64;++j)
		{
			div = caps[j-1];
			for(k=j;k<=64;++k)
			{
				if(div+nx[k]> counter[k])
				{
					div-=counter[k]-nx[k];
					nx[k] = counter[k];
				}
				else
				{
					nx[k] += div;
					break;
				}
			}
		}
		for(j=1;j<=64;++j)
		{
			caps[j] = nx[j];
		}
	}

	for(i=0;i<64;++i)
	{
		if(caps[i] != counter[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}




















Compiler output:
a.cc: In function 'int main()':
a.cc:144:9: error: expected ',' or ';' before 'for'
  144 |         for(i=0;i<32;++i)
      |         ^~~
a.cc:144:25: error: expected ';' before ')' token
  144 |         for(i=0;i<32;++i)
      |                         ^
      |                         ;