#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int a[300001],cnt[20];
pii bit[2][1024][1024];
//i,m0,m1 : first half of mask = m0, second half of mask has i bits in common with m1
int main()
{
owo
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=0;j<m;j++){
int x;
cin>>x;
a[i] |= (x<<j);
cnt[j]+=x;
}
int m0 = a[i]&1023;
int m1 = a[i]>>10;
for(int j=0;j<1024;j++){
int c = __builtin_popcount(m1&j);
if(!bit[0][m0][j].se)bit[0][m0][j] = {c,i};
else{
if(c <= bit[0][m0][j].fi){
bit[1][m0][j] = bit[0][m0][j];
bit[0][m0][j] = {c,i};
}else if(!bit[1][m0][j].se || c <= bit[1][m0][j].fi ){
bit[1][m0][j] = {c,i};
}
}
}
}
for(int i=1;i<=n;i++){
int mask = 0,ans = 0;
for(int j=0;j<m;j++){
int c = (a[i]>>j)&1
if(cnt[j]-c >= n/2)ans++;
if(cnt[j]-c == n/2)mask+=(1<<j); //we try to make this bit off
}
int m0 = mask&1023;
int m1 = mask>>10;
int mn = 20;
for(int j=0;j<1024;j++){
int c = __builtin_popcount(m0&j);
if(!bit[0][j][m1].se)continue;
int kek = 20;
if(bit[0][j][m1].se != i)kek = bit[0][j][m1].fi;
else if(bit[1][j][m1].se)kek = bit[1][j][m1].fi;
mn = min(mn,kek+c);
}
cout<<ans-mn<<'\n';
}
}
Compilation message
council.cpp: In function 'int main()':
council.cpp:60:4: error: expected ',' or ';' before 'if'
60 | if(cnt[j]-c >= n/2)ans++;
| ^~