criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,S=0;cin>>N;
  long long int A[N],B[N],C[N];
  for(int i=0;i<N;i++){cin>>A[i];B[i]=0;}
  for(int i=0;i<N;i++)B[A[i]-1]++;
  for(int i=0;i<N;i++){C[i]=B[i]*(B[i]-1)/2;S+=C[i];}
  for(int i=0;i<N;i++)cout<<S-C[(A[i]-1)+0]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:48: error: no matching function for call to 'max(int, long long int)'
    9 |   for(int i=0;i<N;i++)cout<<S-C[(A[i]-1)+0]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:9:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    9 |   for(int i=0;i<N;i++)cout<<S-C[(A[i]-1)+0]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:9:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    9 |   for(int i=0;i<N;i++)cout<<S-C[(A[i]-1)+0]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,S=0;cin>>N;
  long long int A[N],B[N],C[N];
  for(int i=0;i<N;i++){cin>>A[i];B[i]=0;}
  for(int i=0;i<N;i++)B[A[i]-1]++;
  for(int i=0;i<N;i++){C[i]=B[i]*(B[i]-1)/2;S+=C[i];}
  for(int i=0;i<N;i++)cout<<S-C[A[i]-1]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:44: error: no matching function for call to 'max(int, long long int)'
    9 |   for(int i=0;i<N;i++)cout<<S-C[A[i]-1]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:9:44: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    9 |   for(int i=0;i<N;i++)cout<<S-C[A[i]-1]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:9:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    9 |   for(int i=0;i<N;i++)cout<<S-C[A[i]-1]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>A(N);
  vector<int>B(N + 1, 0);
  for (int i = 0; i < N; i ++) {
    cin >> A[i];
    B[A[i]] ++;
  }
  long long ans = 0;
  for (int i = 1; i <= N; i ++) {
    ans += (long long)B[i] * (B[i] - 1) / 2;
  }
  for (int i = 0; i < N; i ++) {
    cout << ans - B[A[i]] + 1 << endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:18:4: error: expected '}' at end of input
   18 |   }
      |    ^
a.cc:3:13: note: to match this '{'
    3 | int main () {
      |             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define mod 
#define pb push_back
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(n<k) return 0;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return (pro);
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(2000001,true);
    for(int i=2;i*i<=2000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=2000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    ll n;
    cin>>n;
    vector<ll> arr(n);
    vector<ll> freq(n+1);
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        freq[arr[i]]++;
    }
    ll sum=0;
    for(int i=1;i<=n;i++) {
        if(freq[i]>0)
        sum+=ncr(freq[i],2);
    }
    for(int i=0;i<n;i++) {
        ll x=freq[arr[i]];
        ll a=ncr(x,2);
        ll b=ncr(x-1,2);
        cout<<sum-a+b<<"\n";
    }
    return 0; 
}


Compiler output:
a.cc: In function 'long long int power(long long int, long long int)':
a.cc:16:35: error: expected primary-expression before ';' token
   16 |         if(b%2!=0) res=(res*a)%mod;
      |                                   ^
a.cc:17:20: error: expected primary-expression before ';' token
   17 |         a=(a*a)%mod;
      |                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,S=0;cin>>N;
  int A[N],B[N];
  for(int i=0;i<N;i++){cin>>A[i];B[i]=0;}
  for(int i=0;i<N;i++)B[A[i]-1]++;
  for(int i=0;i<N;i++){C[i]=B[i]*(B[i]-1)/2;S+=C[i];}
  for(int i=0;i<N;i++)cout<<S-C[i]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:24: error: 'C' was not declared in this scope
    8 |   for(int i=0;i<N;i++){C[i]=B[i]*(B[i]-1)/2;S+=C[i];}
      |                        ^
a.cc:9:31: error: 'C' was not declared in this scope
    9 |   for(int i=0;i<N;i++)cout<<S-C[i]+max(0,(B[A[i]-1]-1)*(B[A[i]-1]-2)/2)<<endl;;
      |                               ^
Language: C++

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

ll conb(ll n){
  return n*(n-1)/2;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N, 0);
  vector<int> ball(N, 0);

  for(int i = 0; i < N; ++i){
    cin >> A[i];
    --A[i];
    ++ball[A[i]];
  }

  ll ans;
  for(int i = 0; i < N; ++i){
    ans += conb(ball[i]);
  }

  for(int i = 0; i < N; ++i){
    cout << ans - ball[A[i]] + 1 << endl;
  }

  return 0;
}


Compiler output:
a.cc:11:16: error: 'boost' has not been declared
   11 | namespace mp = boost::multiprecision;
      |                ^~~~~
a.cc:11:23: error: 'multiprecision' is not a namespace-name
   11 | namespace mp = boost::multiprecision;
      |                       ^~~~~~~~~~~~~~
a.cc:12:15: error: 'mp' does not name a type
   12 | using mpint = mp::cpp_int; // 多倍長整数（任意精度）
      |               ^~
Language: C++

#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////



int main(){
    int n;
    I(n);
    int ar[n+2];
    int mp[n+2];
    SET(mp);

    ll res = 0;
    for(int i = 1;i<=n;i++){cin>>ar[i];
      res += (mp[ar[i]]);
      mp[ar[i]] ++;
    }

    for(int i = 1;i<=n;i++){
        cout<<(res-mp[ar[i]]+1)<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:16: error: 'memset' was not declared in this scope
   34 | #define SET(a) memset(a,0,sizeof a)
      |                ^~~~~~
a.cc:99:5: note: in expansion of macro 'SET'
   99 |     SET(mp);
      |     ^~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   11 | #include<stack>
  +++ |+#include <cstring>
   12 | //#include<bits/stdc++.h>
Language: C++

#include<iostream>
#define ll long long int
using namespace std;
ll cek[(int)2e5+5],a[(int)2e5+5];
ll ps[(int)2e5+5];
int main(){
	int n;
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>a[i];
		cek[a[i]]++;
	}
	ll tot = 0;
	for(int i = 0;i<=2e5;i++){
		if(cek[i] > 1) ps[i] = (cek[i] * (cek[i]-1)/2);
		if(cek[i] > 1) tot += ps[i];
	}
//	for(int i = 0;i<=10;i++) cout<<ps[i]<<" ";cout<<"\n";
	for(int i= 0;i<n;i++){
//		cout<<a[i]<<" "<<ps[a[i]]<<
//		 " "<<((cek[i]-1) * (cek[i]) /2)<<"\n";
		if(ps[a[i]]-1 > 1)
			cout<<tot - ps[a[i]] + ((cek[a[i]]-1) * (cek[a[i]]-2) /2)<<"\n";
		else{
			cout<<max(0,tot-ps[a[i]])<<"\n";
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:34: error: no matching function for call to 'max(int, long long int)'
   25 |                         cout<<max(0,tot-ps[a[i]])<<"\n";
      |                               ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:25:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   25 |                         cout<<max(0,tot-ps[a[i]])<<"\n";
      |                               ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
Language: Java

#include <bits/stdc++.h>
using namespace std;

vector<int> num(200001);
vector<int> a(200001);
int main() {
	int n;
	cin >> n;
	long long result = 0;
	for (int i = 0, x; i < n; i++) {
		cin >> x;
		a[i] = x;
		num[x]++;
		result += num[x] - 1;
	}
	for (int i = 0; i < n; i++) {
		cout << result - num[a[i]] + 1 << endl;
	}
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
vector<int> num(200001);
^
  (use --enable-preview to enable unnamed classes)
Main.java:4: error: illegal start of type
vector<int> num(200001);
                ^
Main.java:5: error: illegal start of type
vector<int> a(200001);
              ^
Main.java:8: error: not a statement
	cin >> n;
	    ^
Main.java:9: error: not a statement
	long long result = 0;
	^
Main.java:11: error: not a statement
		cin >> x;
		    ^
Main.java:17: error: not a statement
		cout << result - num[a[i]] + 1 << endl;
		                               ^
Main.java:9: error: ';' expected
	long long result = 0;
	    ^
10 errors
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<algorithm>
#define f first
#define s second
#define pb push_back
using namespace std;
int const INF=0x3f3f3f3f;
int const maxn=1e5+5;
typedef long long ll;
typedef pair<int,int>P;
char s[maxn][maxn];
int num[maxn][maxn];
bool vis[maxn][maxn];
int mv[2][2]={{1,0},{0,1}};
map<int,ll>mmp;
int a[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		mmp[a[i]]++;
	}
	ll res=0;
	ll m=mmp.size();
	for(auto it:mmp){
		res+=it.s*(it.s-1)/2;
	}
	for(int i=0;i<n;i++){
		printf("%lld\n",res-(mmp[a[i]]-1));
	}
}


Compiler output:
/tmp/ccK1Mqkg.o: in function `main':
a.cc:(.text+0x3c): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccK1Mqkg.o
a.cc:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccK1Mqkg.o
a.cc:(.text+0x77): relocation truncated to fit: R_X86_64_PC32 against symbol `mmp' defined in .bss section in /tmp/ccK1Mqkg.o
a.cc:(.text+0xa4): relocation truncated to fit: R_X86_64_PC32 against symbol `mmp' defined in .bss section in /tmp/ccK1Mqkg.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `mmp' defined in .bss section in /tmp/ccK1Mqkg.o
a.cc:(.text+0x159): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccK1Mqkg.o
a.cc:(.text+0x166): relocation truncated to fit: R_X86_64_PC32 against symbol `mmp' defined in .bss section in /tmp/ccK1Mqkg.o
/tmp/ccK1Mqkg.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x1b1): relocation truncated to fit: R_X86_64_PC32 against symbol `mmp' defined in .bss section in /tmp/ccK1Mqkg.o
a.cc:(.text+0x1ca): relocation truncated to fit: R_X86_64_PC32 against symbol `mmp' defined in .bss section in /tmp/ccK1Mqkg.o
collect2: error: ld returned 1 exit status
Language: C++

import collections

def solve(N, A):
    c = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    for (k, v) in c.items():
        originals[k] = v * (v-1) // 2
        minus[k] = ((v * (v-1)) - (v-1) * (v-2)) // 2
    S = sum(originals)

    ans = []
    for a in A:
        ans.append(str(S - minus[a]))
    return "\n".join(ans)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split(" ")))
    print(solve(N, A))


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import collections
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
#include <unordered_map>
using namespace std;

int main() {
	int N;
	cin >> N;
	unordered_map<int, int> M;
	vector<int>A(N);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[i] = a;
		M[a]++;
	}
	int ans = 0;
	for (auto m : M) ans += m.second * (m.second - 1) / 2;
	for (int i = 0; i < N; i++) cout << ans - M[A[i]] + 1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'vector' was not declared in this scope
    9 |         vector<int>A(N);
      |         ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <unordered_map>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:9:16: error: expected primary-expression before 'int'
    9 |         vector<int>A(N);
      |                ^~~
a.cc:13:17: error: 'A' was not declared in this scope
   13 |                 A[i] = a;
      |                 ^
a.cc:18:53: error: 'A' was not declared in this scope
   18 |         for (int i = 0; i < N; i++) cout << ans - M[A[i]] + 1 << endl;
      |                                                     ^
Language: C++

#include "../../library/template.hpp"

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }

  vl cnt(n+1);
  vl b(n+1);

  rep(i, n) {
    cnt[a[i]]++;
  }

  ll sum = 0;
  rep(i, n+1) {
    if (cnt[i] >= 2) {
      b[i] = cnt[i] * (cnt[i]-1) / 2;
    }
    sum += b[i];
  }

  rep(i, n) {
    ll t = sum - b[a[i]];
    cout << t + (cnt[a[i]]-1) * (cnt[a[i]]-2) / 2 << el;
  }

  cout << flush;
}


Compiler output:
a.cc:1:10: fatal error: ../../library/template.hpp: No such file or directory
    1 | #include "../../library/template.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int H, W, K;
vector<string> fi;

int solve()
{
    int res = 1 << 29;
    for (int bit = 0; bit < (1 << (H - 1)); bit++) {
        bool gok = true; // そもそも不可能な場合もあるので判定
        int N = 0;
        vector<int> ord(H, 0);
        for (int i = 0; i < H - 1; i++) {
            if (!(bit & (1 << i)))
                ord[i + 1] = ord[i];
            else {
                ord[i + 1] = ord[i] + 1;
                ++N;
            }
        }
        int add = 0;
        vector<int> nums(N + 1, 0);
        for (int w = 0; w < W : w++) {
            vector<int> one(N + 1, 0); // 1つのwだけでもうそもそもKをオーバーする場合も考慮
            bool ok = true;
            for (int h = 0; h < H; h++) {
                one[ord[h]] += fi[h][w] - '0';
                nums[ord[h]] += fi[h][w] - '0';
                if (one[ord[h]] > K)
                    gok = false;
                if (nums[ord[h]] > K)
                    ok = false;
            }
            if (!ok)
                ++add, nums = one;
        }
        if (gok)
            chmin(res, N + add);
    }
    return res;
}
int main()
{
    cin >> H >> W >> K;
    fi.resize(H);
    for (int i = 0; i < H; i++)
        cin >> fi[i];
    cout << solve() << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:36:25: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   36 |         for (int w = 0; w < W : w++) {
      |                         ^
a.cc:36:31: error: found ':' in nested-name-specifier, expected '::'
   36 |         for (int w = 0; w < W : w++) {
      |                               ^
      |                               ::
a.cc:36:29: error: 'W' is not a class, namespace, or enumeration
   36 |         for (int w = 0; w < W : w++) {
      |                             ^
a.cc:50:9: error: expected primary-expression before 'if'
   50 |         if (gok)
      |         ^~
a.cc:49:10: error: expected ';' before 'if'
   49 |         }
      |          ^
      |          ;
   50 |         if (gok)
      |         ~~
a.cc:50:9: error: expected primary-expression before 'if'
   50 |         if (gok)
      |         ^~
a.cc:49:10: error: expected ')' before 'if'
   49 |         }
      |          ^
      |          )
   50 |         if (gok)
      |         ~~
a.cc:36:13: note: to match this '('
   36 |         for (int w = 0; w < W : w++) {
      |             ^
a.cc:51:13: error: 'chmin' was not declared in this scope
   51 |             chmin(res, N + add);
      |             ^~~~~
Language: C++

#include<bits/stdc++.h>
#define MAXN 1e5

using namespace std;

long long l,a,b,c,h,w,k;

int main(){
    cin>>h>>w>>k;
    string s[h];
    for (int i=0; i<h; i++){
        cin>>s[i];
        for (int i=0; i<w; i++){
            if (s[j]=='1'){
                a++;
            }
        }
    }
    cout<<a/k<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: 'j' was not declared in this scope
   14 |             if (s[j]=='1'){
      |                   ^
Language: C++

#include<bits/stdc++.h>
#define MAXN 1e5

using namespace std;

long long l,a,b,c,h,w,k;

int main(){
    cin>>h>>w>>k;
    string s[h];
    for (int i=0; i<n i++){
        cin>>s[i];
        for (int i=0; i<w; i++){
            if (s[j]=='1'){
                a++;
            }
        }
    }
    cout<<a/k<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:21: error: 'n' was not declared in this scope
   11 |     for (int i=0; i<n i++){
      |                     ^
a.cc:11:22: error: expected ';' before 'i'
   11 |     for (int i=0; i<n i++){
      |                      ^~
      |                      ;
a.cc:14:19: error: 'j' was not declared in this scope
   14 |             if (s[j]=='1'){
      |                   ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

mat divideH(ll n, ll H)
{
    mat D(2);
    D[0].pb(1);
    REP(i,0,H-1) {
        if((n >> (H-i-2)) & 1 == 1) {
            D[0].pb(i+2);
            D[1].pb(i+1);
        }
    }
    D[1].pb(H);

    return D;
}


int main()
{
    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i,0,H) cin >> S[i];

    mat C(H+1, vec(W+1, 0));
    REP(i,0,H) {
        REP(j,0,W) {
            C[i+1][j+1] = C[i+1][j] + C[i][j+1] - C[i][j] + (S[i][j] - '0');
        }
    }

    ll mi = H + W - 2;
    REP(d,0,1<<(H-1)) { // max 512
        mat D = divideH(d, H);
        ll left = 1, right;
        ll cnt = 0;
        bool g = true;
        REP(j,1,W+1) { // max 1000
            bool f = true;
            right = j;
            REP(i,0,SZ(D[0])) { // max 10
                ll top = D[0][i], bottom = D[1][i];
                if(C[k][l] + C[i-1][j-1] - C[k][j-1] - C[i-1][l] <= K) {
                    f = false;
                    break;
                }
            }
            if(left == right && !f) {
                g = false;
                break;
            }
            else if(!f) {
                --j;
                ++cnt;
                left = j + 1;
            }
        }

        if(g) {
            mi = MIN(mi,cnt+SZ(D[0])-1);
            /*
            REP(i,0,H-1) divH[i] = (d >> (H-i-2)) & 1;

            cout << "divH : ";
            REP(i,0,H-1) cout << divH[i] << " ";
            cout << endl;
            cout << "divW : ";
            REP(i,0,W-1) cout << divW[i] << " ";
            cout << endl;
            cout << SZ(D[0]) - 1 << " " << cnt << " " << cnt + SZ(D[0]) - 1 << endl;
            cout << endl;*/
        }

    }

    PR(mi);

    return 0;
}

/*



*/

Compiler output:
a.cc: In function 'int main()':
a.cc:66:22: error: 'k' was not declared in this scope
   66 |                 if(C[k][l] + C[i-1][j-1] - C[k][j-1] - C[i-1][l] <= K) {
      |                      ^
a.cc:66:25: error: 'l' was not declared in this scope
   66 |                 if(C[k][l] + C[i-1][j-1] - C[k][j-1] - C[i-1][l] <= K) {
      |                         ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define sz(a) (int)a.size()
using namespace std;
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
string a[N];
int n,m,k,ans=1e9+1;
int main(){
    cin>>n>>m>>k;
    rep(i,0,n){
        cin>>a[i];
    }
    rep(mask,0,(1<<(n-1))){
        int tot=__builtin_popcount(mask);
        vector<int>cur(tot+1,0);
        rep(j,0,m){
            int p=0;
            rep(i,0,n) {
                cur[p]+=(a[i][j]=='1');
                if((mask>>i)&1){
                    p++;
                }
            }
            bool bad = false;
            rep(i, 0, sz(cur)) {
                if (cur[i] > k) {
                    bad = true;
                }
            }
            if (bad) {
                tot++;
                fill(cur.begin(), cur.end(), 0);
                int p = 0;
                rep(i, 0, n) {
                    cur[p] += (a[i][j] == '1');
                    if ((mask >> i) & 1) {
                        p++;
                    }
                }
                bool bad = false;
                rep(i, 0, sz(cur)) {
                    if (cur[i] > k) {
                        bad = true;
                    }
                }
                if (bad) {
                    tot = 1e9+1;
                }
            }
        }
        setmin(ans, tot);
    }
    cout << ans << "\n";
    return 0;
}

Compiler output:
a.cc:6:10: error: 'N' was not declared in this scope
    6 | string a[N];
      |          ^
a.cc: In function 'int main()':
a.cc:11:14: error: 'a' was not declared in this scope
   11 |         cin>>a[i];
      |              ^
a.cc:19:26: error: 'a' was not declared in this scope
   19 |                 cur[p]+=(a[i][j]=='1');
      |                          ^
a.cc:35:32: error: 'a' was not declared in this scope
   35 |                     cur[p] += (a[i][j] == '1');
      |                                ^
Language: C++


            p/=2;
        }
        V.clear();
        V.resize(q+1);
        p=0;
        V[0].pb(0);
        for (j,0,(h-1))
        {
            if (i&(1<<j))
                p++;
            V[p].pb(j+1);
        }
        int d=m;
        d = go(q+1);
        m=min(m,d);
    }
    cout << m << endl;
    return 0;
}


Compiler output:
a.cc:2:13: error: 'p' does not name a type
    2 |             p/=2;
      |             ^
a.cc:3:9: error: expected declaration before '}' token
    3 |         }
      |         ^
a.cc:4:9: error: 'V' does not name a type
    4 |         V.clear();
      |         ^
a.cc:5:9: error: 'V' does not name a type
    5 |         V.resize(q+1);
      |         ^
a.cc:6:9: error: 'p' does not name a type
    6 |         p=0;
      |         ^
a.cc:7:9: error: 'V' does not name a type
    7 |         V[0].pb(0);
      |         ^
a.cc:8:9: error: expected unqualified-id before 'for'
    8 |         for (j,0,(h-1))
      |         ^~~
a.cc:14:15: error: 'm' was not declared in this scope
   14 |         int d=m;
      |               ^
a.cc:15:9: error: 'd' does not name a type
   15 |         d = go(q+1);
      |         ^
a.cc:16:9: error: 'm' does not name a type
   16 |         m=min(m,d);
      |         ^
a.cc:17:5: error: expected declaration before '}' token
   17 |     }
      |     ^
a.cc:18:5: error: 'cout' does not name a type
   18 |     cout << m << endl;
      |     ^~~~
a.cc:19:5: error: expected unqualified-id before 'return'
   19 |     return 0;
      |     ^~~~~~
a.cc:20:1: error: expected declaration before '}' token
   20 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll h, w, k, ans;
vector<vector<int> > s(10, vector<int>(1000));

void func(vector<int>& v){
  ll cnt = 1, ret = 0;
  for(int i = 0; i < v.size(); i++){
    if(v[i] == 1) cnt++;
  }
  vector<ll> sum(cnt, 0), zero(cnt, 0);
  int mj = 0;
  for(int j = 0; j < w; j++){
    int id = 0;
    for(int i = 0; i < h; i++){
      sum[id] += s[i][j];
      if(sum[id] > k){
        //cout << j << " ";
        j--;
        if(j == mj){
          return;
        }
        mj = j;
        ret++;
        sum = zero;
        break;
      }
      if(v[i] == 1){
        id++;
      }
    }
  }
  ans = min(ans, ret + cnt - 1);
  //cout << ans << endl;
  return;
}

void zentan(vector<int>& v){
  if(v.size() == h - 1){
    //for(int i = 0; i < v.size(); i++) cout << v[i]; cout << endl;
    func(v);
    return;
  }
  v.push_back(0);
  zentan(v);
  v.pop_back();
  v.push_back(1);
  zentan(v);
  v.pop_back();
  return;
}

void solve(){
  cin >> h >> w >> k;
  ans = (h - 1) + (w - 1)
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      char c; cin >> c;
      s[i][j] = c - '0';
    }
  }
  vector<int> v;
  zentan(v);
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:59:26: error: expected ';' before 'for'
   59 |   ans = (h - 1) + (w - 1)
      |                          ^
      |                          ;
   60 |   for(int i = 0; i < h; i++){
      |   ~~~                     
a.cc:60:18: error: 'i' was not declared in this scope
   60 |   for(int i = 0; i < h; i++){
      |                  ^
Language: C++

#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;
using namespace std;

char s[15][1050];

int count(int h1,int h2, int w1, int w2){
    int cnt = 0;
    rep2(i,h1,h2+1)rep2(j,w1,w2+1) if(s[i][j] == '1') cnt++;
    return cnt;
}

int main(){
    int h,w,k; cin >> h >> w >> k;

    rep(i,h)rep(j,w) cin >> s[i][j];
  
    int h1 = 0, h2; vector<int> a;
    int ans = h * w;
    for(int bit = 0; bit < (1 << h-1); bit++){
        a.resize(0); a.emplace_back(-1);
        rep(i,h-1) if(bit & (1<<i)) a.emplace_back(i);
        a.emplace_back(h-1);
        int w1 = 0, w2 = 0, tmp = __builtin_popcount(bit);
        while(1){
            bool ok = true, can = true;
            rep(i, a.size()-1){
                int h1 = a[i]+1, h2 = a[i+1];
                if(count(h1,h2,w1,w2) > k) ok = false;
            }
            if(!ok && w2 == w1){ can = false; break; }
            if(ok){
                if(w2+1 < w) w2++;
                else break;
            }
            if(!ok){ w1 = w2; tmp++;}
        }
        if(can) ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:12: error: 'can' was not declared in this scope; did you mean 'tan'?
   43 |         if(can) ans = min(ans,tmp);
      |            ^~~
      |            tan
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int h, w, k;
char s[15][10005];

int main() {
    cin >> h >> w >> k;
    rep(i, h)rep(j, w) cin >> s[i][j];
    int ans = inf;

    // hを分解
    for(int bit=0; bit<1<<h-1; bit++){
        bool flag = true;
        vector<int> id(h);
        int g = 0;
        rep(i, h){
            id[i] = ;
            if (bit>>i & 1) g++;
        }
        g++;

        int cnts[15][10005];
        rep(i, g)rep(j, w) cnts[i][j] = 0;
        rep(i, h)rep(j, w) cnts[id[i]][j] += (s[i][j] - '0');

        int t_ans = g-1;
        vector<int> now(g);
        rep(j, w){
            bool ff = true;
            rep(i, g) now[g] += cnts[i][j];
            rep(i, g){
                if(now[i] > k){
                    ff = false;
                }
            }
            if (!ff){
                t_ans++;
                now = vector<int>(g);
                rep(i, g) now[g] = cnts[i][j];
                rep(i, g){
                    if(now[i] > k){
                        flag = false;
                    }
                }
                if (!flag){
                    t_ans = inf;
                    break;
                }
            }
            if (!flag) break;
        }
        chmin(ans, t_ans);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:21: error: expected primary-expression before ';' token
   29 |             id[i] = ;
      |                     ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  rep(i, H) {
    cin >> S[i];
  }
  int ans = 1000000000;
  rep(div, 1<<(H-1)) {
    int g = 0;
    vector<int> id(H);
    rep(i, H) {
      id[i] = g;
      if(div>>i & 1) g++;
    }
    g++;
    vector<vector<int>> c(g, vector<int>(W, 0));
    rep(i, H) {
      rep(j, W) {
        c[id[i]][j] += (S[i][j] - '0');
      }
    }

    ll cnt = g - 1;
    vector<int> sum(g, 0);
    rep(i, W) {
      rep(j, g) {
        sum[j] += c[j][i];
      }
      rep(j, g) {
        if (sum[j] > K) {
          cnt++;
          rep(k, g) sum[k] = c[k][i];
          break;
        }
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:14: error: no matching function for call to 'min(int&, ll&)'
   43 |     ans = min(ans, cnt);
      |           ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:43:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   43 |     ans = min(ans, cnt);
      |           ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:43:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   43 |     ans = min(ans, cnt);
      |           ~~~^~~~~~~~~~
Language: C++

#ifdef _MSC_VER
#pragma warning(disable : 4996)
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
	if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
	if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 200020;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

using Point = complex<double>;

char A[11][1010];
int cum[1010][12];
void solve() {
	int H, W, K; cin >> H >> W >> K;
	REP(i, H) {
		REP(j, W)cin >> A[i][j];
	}
	REP(j, W) {
		REP(i, H) {
			cum[j][i + 1] = cum[j][i];
			if (A[i][j] == '1')cum[j][i + 1]++;
		}
	}
	int ans = 1e9;
	REP(bit, 1 << (H-1)) {
		int res = __popcnt(bit);
		//int res = __popcnt(bit);
		vector<int>sum(res + 1);
		vector<int>l;
		l.push_back(0);
		REP(i, H) {
			if (bit&(1 << i)) {
				l.push_back(i + 1);
			}
		}
		l.push_back(H);

		REP(j, W) {
			bool ok = true;
			REP(i, l.size() - 1) {
				sum[i] += cum[j][l[i + 1]] - cum[j][l[i]];
				if (sum[i] > K)ok = false;
			}
			if (!ok) {
				ok = true;
				res++;
				REP(i, sum.size())sum[i] = 0;
				REP(i, l.size() - 1) {
					sum[i] += cum[j][l[i + 1]] - cum[j][l[i]];
					if (sum[i] > K)ok = false;
				}
				if (!ok)goto END;
			}
		}
		ans = min(ans, res);
	END:;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// int q; cin >> q;
	// while (q--)
	solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:86:27: error: '__popcnt' was not declared in this scope
   86 |                 int res = __popcnt(bit);
      |                           ^~~~~~~~
Language: C++

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> grid(H);
    for (int i = 0; i < H; i++)
        cin >> grid[i];

    int res = (1<<30);

    for (int msk = 0; msk < (1<<(H-1)); msk++) {
        int parts = __pop_count((unsigned int)msk) + 1;

        vector<int> cur(parts);

        int ans = parts - 1;

        //cerr << "?\n";

        for (int c = 0; c < W; c++) {
            vector<int> A(parts);
            int id = 0;
            for (int r = 0; r < H; r++) {
                if (r && (msk >> (r-1) & 1)) {
                    id++;
                }
                A[id] += grid[r][c] == '1';
            }

            bool reset = false;

            for (int i = 0; i < parts; i++) {
                if (cur[i] + A[i] > K) {
                    reset = true;
                }
            }

            if (!c && reset)
                goto END_ITER;

            ans += reset;

            for (int i = 0; i < parts; i++) {
                if (reset)
                    cur[i] = 0;
                cur[i] += A[i];
            }
        }

        // Solution found
        res = min(res, ans);

        END_ITER:;
    }

    cout << res << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:21: error: '__pop_count' was not declared in this scope
   41 |         int parts = __pop_count((unsigned int)msk) + 1;
      |                     ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int INF = 1001001001;

int c[10][1005];
int main() {
	int h, w, k; cin >> h >>w >> k;
	vector<string>s(h);
	REP(i, h)cin >> s[i];
	int ans = INF;
	REP(div, 1 << (h - 1)) {
		int g = 0;
		vector<int>id(h);
		REP(i, h) {
			id[i] = g;
			if (div >> i & 1)++g;
		}
		g++;
		REP(i, g)REP(j, w)c[i][j] = 0;
		REP(i, h)REP(j, w)c[id[i]][j] += (s[i][j] - '0');
		int num = g - 1;
		vector<int>now(g,0);
		bool ok = true;
		REP(j, w) {
			REP(i, g) {
				now[i] += c[i][j];
			}
			REP(i, g) {
				if (now[i] > k) {
					num++;
					now = vector<int>(g,0);
					REP(l, g) {
						now[l] += c[l][j];
					}
					REP(l, g) {
						if (now[l] > k) {
							ok = false;
						}
					}
				}
			}
		}
		if (ok) {
			ans = min(ans, num);
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: 'i' was not declared in this scope
   13 |         REP(i, h)cin >> s[i];
      |             ^
a.cc:13:9: error: 'REP' was not declared in this scope
   13 |         REP(i, h)cin >> s[i];
      |         ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int INF = 1001001001;

int c[10][1005];
int main() {
	int h, w, k; cin >> h >>w >> k;
	vector<string>s(h);
	REP(i, h)cin >> s[i];
	int ans = INF;
	REP(div, 1 << (h - 1)) {
		int g = 0;
		vector<int>id(h);
		REP(i, h) {
			id[i] = g;
			if (div >> i & 1)++g;
		}
		++g;
		REP(i, g)REP(j, w)c[i][j] = 0;
		REP(i, h)REP(j, w)c[id[i]][j] += (s[i][j] - '0');
		int num = g - 1;
		vector<int>now(g);
		auto add = [&](int j) {
			REP(i, g)now[i] += c[i][j];
			REP(i, g)if (now[i] > k)return false;
			return true;
		};
		REP(j, w) {
			if (!add(j)) {
				num++;
				now = vector<int>(g);
				if (!add(j)) {
					num = INF;
					break;
				}
			}
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: 'i' was not declared in this scope
   13 |         REP(i, h)cin >> s[i];
      |             ^
a.cc:13:9: error: 'REP' was not declared in this scope
   13 |         REP(i, h)cin >> s[i];
      |         ^~~
Language: C++

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		int[][] s = new int[h][w];
		for (int i = 0; i < h; i++) {
			String row = sc.next();
			for (int j = 0; j < w; j++) {
				s[i][j] = Integer.parseInt(row.substring(j, j + 1));
			}
		}
		sc.close();

		int result = Integer.MAX_VALUE;
		Boolean[] hc = new Boolean[h - 1];
		for (int i = 0; i < Math.pow(2, h - 1); i++) {
			for (int j = 0; j < h - 1; j++) {
				hc[j] = ((i % (int)Math.pow(2, j + 1)) / ((int)Math.pow(2, j))) != 0;
			}
			int hcount = (int) Arrays.stream(hc).filter(value -> value).count();
			int count = count(k, s, hc);
			if (count >= 0) {
				result = Math.min(result, count + hcount);
			}
		}
		System.out.print(result);
	}

	private static int count(int k, int[][] s, Boolean[] hc) {
		int count = 0;
		int[] counts = new int[s.length];
		int wstart = 0;
		for (int i = 0; i < s[0].length; i++) {
			int[] tcounts = new int[s.length];
			int index = 0;
			for (int j = 0; j < s.length; j++) {
				if (s[j][i] == 1) {
					counts[index]++;
					tcounts[index]++;
				}
				if (j < s.length - 1 && hc[j]) {
					index++;
				}
			}
			if (Arrays.stream(counts).anyMatch(c -> c > k)) {
				if (wstart - i == 1) {
					return -1;
				}
				count++;
				wstart = i;
				counts = tcounts;
			}
		}

		return count;
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Arrays;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main {
      | ^~~~~~