Language: C++

#pragma GCC optimize("trapv")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 5e2 + 10, mlg = 17, mod = 1e9 + 7;
ll n, k;
vi a;
ll z = 0;
ll floor(ll x, ll i) {
	if(i<0) x*=-1, i*=-1;
	if(x>0) return x/i;
	x = abs(x);
	x = (x+i-1)/i;
	return -x;
}
ll ceil(ll x, ll i) {
	if(i<0) x*=-1, i*=-1;
	if(x<0) return x/i;
	return (x+i-1)/i;
}
ll count(ll x) {
	ll ans = 0;
	for(auto i : a) {
		if(i<0) {
			ans += a.end()-lower_bound(all(a), ceil(x, i));
		} else {
			ans += upper_bound(all(a), floor(x, i))-a.begin();
		}
		if(i*i<=x) ans--;
	}
	ans/=2;
	if(x>=0) {
		ans += z*(z-1)/2;
		ans += z*(n-z);
	}
	return ans;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	for(auto i :s) {
		i-='0';
		ans += min(i, (char)9-i);
	}
	cout << ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:27: error: no matching function for call to 'min(char&, int)'
   56 |                 ans += min(i, (char)9-i);
      |                        ~~~^~~~~~~~~~~~~~
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:4:
/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:56:27: note:   deduced conflicting types for parameter 'const _Tp' ('char' and 'int')
   56 |                 ans += min(i, (char)9-i);
      |                        ~~~^~~~~~~~~~~~~~
/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:56:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'char'
   56 |                 ans += min(i, (char)9-i);
      |                        ~~~^~~~~~~~~~~~~~