Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<bitset<8>> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> ans(n);
    for (int j = 0; j < k; i++) {
        for (int i = 0; i < n; i++) {
            ans[i] += i ^ a[i];
        }
    }
    sort(ans.begin(), ans.end(), greater<int>());
    
    cout << ans[0];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:28: error: 'i' was not declared in this scope
   14 |     for (int j = 0; j < k; i++) {
      |                            ^
a.cc:16:25: error: no match for 'operator^' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<8> >, std::bitset<8> >::value_type' {aka 'std::bitset<8>'})
   16 |             ans[i] += i ^ a[i];
In file included 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/ios_base.h:94:3: note: candidate: 'constexpr std::_Ios_Fmtflags std::operator^(_Ios_Fmtflags, _Ios_Fmtflags)'
   94 |   operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:94:46: note:   no known conversion for argument 2 from '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<8> >, std::bitset<8> >::value_type' {aka 'std::bitset<8>'} to 'std::_Ios_Fmtflags'
   94 |   operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
      |                                ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:144:3: note: candidate: 'constexpr std::_Ios_Openmode std::operator^(_Ios_Openmode, _Ios_Openmode)'
  144 |   operator^(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:144:46: note:   no known conversion for argument 2 from '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<8> >, std::bitset<8> >::value_type' {aka 'std::bitset<8>'} to 'std::_Ios_Openmode'
  144 |   operator^(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
      |                                ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:191:3: note: candidate: 'constexpr std::_Ios_Iostate std::operator^(_Ios_Iostate, _Ios_Iostate)'
  191 |   operator^(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:191:44: note:   no known conversion for argument 2 from '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<8> >, std::bitset<8> >::value_type' {aka 'std::bitset<8>'} to 'std::_Ios_Iostate'
  191 |   operator^(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
      |                               ~~~~~~~~~~~~~^~~
In file included from a.cc:4:
/usr/include/c++/14/bitset:1577:5: note: candidate: 'template<long unsigned int _Nb> std::bitset<_Nb> std::operator^(const bitset<_Nb>&, const bitset<_Nb>&)'
 1577 |     operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/bitset:1577:5: note:   template argument deduction/substitution failed:
a.cc:16:30: note:   mismatched types 'const std::bitset<_Nb>' and 'int'
   16 |             ans[i] += i ^ a[i];
      |                              ^
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41:
/usr/include/c++/14/cstddef:146:3: note: candidate: 'constexpr std::byte std::operator^(byte, byte)'
  146 |   operator^(byte __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/14/cstddef:146:18: note:   no known conversion for argument 1 from 'int' to 'std::byte'
  146 |   operator^(byte __l, byte __r) noexcept
      |             ~~~~~^~~