Language: C++

#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

const int INF=101000010;
int dp[1000005][2];

int main(){
  string s;
  cin>>s;
  reverse(s.begin().s.end());
  s+=0;
  int n=s.length();
  REP(i,n+1)rep(j,2)dp[i][j]=INF;
  dp[0][0]=0;
  REP(i,n)rep(j,2){
    int y=s[i]-'0';
    y+=j;
    REP(a,10){
      int ni=i+1,nj=0;
      int b=a-y;
      if(b<0){
        b+=10;
        nj=1;
      }
      dp[ni][nj]=min(dp[ni][nj],dp[i][j]+a+b);
    }
  }
  int ans=dp[n][0];
  cout<<ans<<endl;
}

Compiler output:
a.cc:35:11: error: conflicting declaration 'const int INF'
   35 | const int INF=101000010;
      |           ^~~
a.cc:33:17: note: previous declaration as 'const long long int INF'
   33 | const long long INF =  999999999;
      |                 ^~~
a.cc: In function 'int main()':
a.cc:41:21: error: 'std::__cxx11::basic_string<char>::iterator' has no member named 's'
   41 |   reverse(s.begin().s.end());
      |                     ^
a.cc:42:4: error: ambiguous overload for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
   42 |   s+=0;
      |   ~^~~
In file included from /usr/include/c++/14/string:54,
                 from a.cc:10:
/usr/include/c++/14/bits/basic_string.h:1377:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1377 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1387:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1387 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1397:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1397 |       operator+=(_CharT __c)
      |       ^~~~~~~~
a.cc:44:17: error: 'j' was not declared in this scope
   44 |   REP(i,n+1)rep(j,2)dp[i][j]=INF;
      |                 ^
a.cc:44:13: error: 'rep' was not declared in this scope; did you mean 'frexp'?
   44 |   REP(i,n+1)rep(j,2)dp[i][j]=INF;
      |             ^~~
      |             frexp
a.cc:46:15: error: 'j' was not declared in this scope
   46 |   REP(i,n)rep(j,2){
      |               ^
a.cc:46:11: error: 'rep' was not declared in this scope; did you mean 'frexp'?
   46 |   REP(i,n)rep(j,2){
      |           ^~~
      |           frexp