Language: C++

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

vector<string> bin;
void generateAllBinaryStrings(int n, int arr[], int i)
{ 
    string s = "";
	if (i == n) {
        for (int i = 0; i < n; i++) 
            s+=to_string(arr[i]); 
        bin.push_back(s);
		return;  
	} 
	arr[i] = 0; 
	generateAllBinaryStrings(n, arr, i + 1); 
	arr[i] = 1; 
	generateAllBinaryStrings(n, arr, i + 1); 
}

int main() {
    // int zzz = '5'-'0';
    // cout << zzz;
    // return 0;
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> v(n);
    for (int i=0; i<n; i++)
    {
        int a;
        cin >> a;
        for (int j=0; j<a; j++)
        {
            int x,y;
            cin >> x >> y;
            v[i].push_back(make_pair(x,y));
        }
    }
    int N = n; 
    int arr[N];
    int ans = 0;
    generateAllBinaryStrings(N, arr, 0);
    for (int i=0; i<bin.size(); i++)
    {
        bool y = true;
        for (int j=0; j<bin[i].size(); j++)
        {
            // cout << bin[i] << endl;
            for (int k=0; k<v[j].size(); k++)
            {
                int curr_person = j;
                int curr_person_state = 5; 
                int person = v[j][k].first;
                int state = v[j][k].second;
                // cout << "slt";
                // if (bin[i] == "110")
                //     cout << bin[i][j] << "->" << person-1 << " " << bin[i][person-1] << " " << state << endl;
                if (bin[i][j] == '0')                    
                    if (bin[i][person-1]-'0' == state)
                        y = false;
                if (bin[i][j] == '1')
                    if (bin[i][person-1]-'0' != state)
                        y = false;
            }
        }
        if (y==true)
            ans = max(ans, count(bin[i].begin(), bin[i].end(), '1'));
    }
    cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:22: error: no matching function for call to 'max(int&, std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type)'
   66 |             ans = max(ans, count(bin[i].begin(), bin[i].end(), '1'));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:66:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type' {aka 'long int'})
   66 |             ans = max(ans, count(bin[i].begin(), bin[i].end(), '1'));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:66:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |             ans = max(ans, count(bin[i].begin(), bin[i].end(), '1'));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~