Language: C++

#include<bits/stdc++.h>

using lint = long long int;
using pii = std::pair<int, int>;
using std::priority_queue;

using std::vector;
char str[2][2020];
pii move[2020];
int len;
bool check[2020];

int main(void) {
	scanf("%s %s", str[0], str[1]);
	len = strlen(str[0]);
	for (int i = 0; i < len; i++) {
		str[0][i] -= '0';
		str[1][i] -= '0';
	}
	for (int i = 0; i < len; i++) {
		if (str[1][i] == 1) {
			break;
		}
		if (i == len - 1) {
			for (int j = 0; j < len; j++) {
				if (str[0][j] == 1) {
					break;
				}
				if (j == len - 1) {
					printf("0");
					return 0;
				}
			}
			printf("-1");
			return 0;
		}
	}
	for (int i = 0; i < len; i++) {
		for (int j = 0; j < len; j++) {
			if (str[1][(i + j) % len] == 1) {
				move[i].second = j;
				break;
			}
		}
		for (int j = 0; j < len; j++) {
			if (str[1][(i - j + len) % len] == 1) {
				move[i].first = j;
				break;
			}
		}
	}
	lint ans = 2000000000;
	for (int i = 0; i < len; i++) {
		lint temp_ans = 0;
		vector<pii> t_v;
		priority_queue<pii> pq;
		for (int j = 0; j < len; j++) {
			check[(i + j) % len] = false;
			if (str[0][(i + j) % len] != str[1][j]) {
				temp_ans++;
				if (str[0][(i + j) % len] == 1) {
					t_v.push_back(pii(move[(i + j) % len].first, (i + j) % len));
					pq.push(pii(move[(i + j) % len].second, (i + j) % len));
					check[(i + j) % len] = true;
				}
			}
		}
		sort(t_v.begin(), t_v.end());
		lint temp_val = 2000000000;
		for (int j = 0; j < t_v.size(); j++) {
			check[t_v[j].second] = false;
			lint left = t_v[j].first;
			while (check[pq.top().second]) {
				pq.pop();
			}
			lint right = pq.top().first;
			temp_val = std::min(temp_val, std::min(left * 2 + right + std::min(right + i, abs((len - i) - right)), right * 2 + left + std::min(abs(i - left), (len - i) + left)));
		}
		temp_ans += temp_val;
		ans = std::min(temp_ans, ans);
	}

	printf("%lld", ans);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:77:91: error: no matching function for call to 'min(lint, int)'
   77 |                         temp_val = std::min(temp_val, std::min(left * 2 + right + std::min(right + i, abs((len - i) - right)), right * 2 + left + std::min(abs(i - left), (len - i) + left)));
      |                                                                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:77:91: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   77 |                         temp_val = std::min(temp_val, std::min(left * 2 + right + std::min(right + i, abs((len - i) - right)), right * 2 + left + std::min(abs(i - left), (len - i) + left)));
      |                                                                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:77:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   77 |                         temp_val = std::min(temp_val, std::min(left * 2 + right + std::min(right + i, abs((len - i) - right)), right * 2 + left + std::min(abs(i - left), (len - i) + left)));
      |                                                                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:77:155: error: no matching function for call to 'min(int, lint)'
   77 |                         temp_val = std::min(temp_val, std::min(left * 2 + right + std::min(right + i, abs((len - i) - right)), right * 2 + left + std::min(abs(i - left), (len - i) + left)));
      |                                                                                                                                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:77:155: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'lint' {aka 'long long int'})
   77 |                         temp_val = std::min(temp_val, std::min(left * 2 + right + std::min(right + i, abs((len - i) - right)), right * 2 + left + std::min(abs(i - left), (len - i) + left)));
      |                                                                                                                                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:77:155: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   77 |                         temp_val = std::min(temp_val, std::min(left * 2 + right + std::min(right + i, abs((len - i) - right)), right * 2 + left + std::min(abs(i - left), (len - i) + left)));
      |                                                                                                                                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~