criyle/codenet-compile-errors huggingface dataset:
Language: C++

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

int main()
{
  int n,k
  cin>>n>>k;
  int arr[n];
  vector<int> v;
  for(int i=0;i<n;i++)
    cin>>arr[i];
  for(int i=0;i<n-1;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      int t=arr[i]*arr[j];
      v.push_back(t);
    }
  }
  sort(v.begin(),v.end());
  cout<<v[k-1]<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected initializer before 'cin'
    7 |   cin>>n>>k;
      |   ^~~
a.cc:21:11: error: 'k' was not declared in this scope
   21 |   cout<<v[k-1]<<endl;
      |           ^
Language: C++

#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> A(N);
  rep(i, N) { cin >> A[i]; }

  vector<long long> B;
  rep(i, N - 1) {
    for (int j = i + 1; j < N; ++j) {
      B.push_back(A[i] * A[j]);
    }
  }

  sort(B.begin(), B.end());
  cout << B[K - 1] << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   29 |   sort(B.begin(), B.end());
      |   ^~~~
      |   sqrt
Language: C++

#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;


void solve(){
	
	string N;
	cin >> N;

	vvl dp(1000010, vl(2, INF));
	dp[0][0] = 0;
	dp[0][1] = 0;
	
	REV(N);
	N += '0';
	
	rep(i, N.size()) rep(j, 2){
		ll x = N[i] - '0';
		x += j;
		rep(a, 10){
			ll ni = i + 1;
			ll nj = 0;
			ll b = a - x;
			if(b < 0){
				nj = 1;
				b += 10;
			}
			chmin(dp[ni][nj], dp[i][j] + a + b);
		}
	}
	
	ll ans = min(dp[length][0], dp[length][1]);
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
    
	return 0;
	
}





Compiler output:
a.cc: In function 'void solve()':
a.cc:51:25: error: 'length' was not declared in this scope
   51 |         ll ans = min(dp[length][0], dp[length][1]);
      |                         ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define chmin(x,y) x = min(x,y)

int main(){
    int dp[1e6+5][2];
    string s; cin>>s;
    reverse(s.begin(),s.end());
    s += '0';
    int n = s.size();
    rep(i,n+1)rep(j,2) dp[i][j] = 1e9;
    dp[0][0] = 0;
    rep(i,n)rep(j,2){
        int x = (s[i] - '0') + j;
        if(x<10) chmin(dp[i+1][0], dp[i][j] + x);
        if(x>0) chmin(dp[i+1][1], dp[i][j]+(10-x));
    }
    cout << dp[n][0] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:15: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    7 |     int dp[1e6+5][2];
      |            ~~~^~
a.cc:7:15: error: could not convert '(1.0e+6 + (double)5)' from 'double' to 'long unsigned int'
    7 |     int dp[1e6+5][2];
      |            ~~~^~
      |               |
      |               double
a.cc:7:15: error: size of array 'dp' has non-integral type 'double'
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
string s;
int cache[1000004][3];
int dp(int pos,int carr)
{
    if(pos==n)
        return carr;
    int &ans=cache[pos][carr];
    if(ans!=-1)
        return ans;
    ans=1e18;
    for(int i=0;i<10;i++)
    {
        int dig1=i;
        int dig2=(i+carr+s[pos]-'0')%10;
        ans=min(ans,dig1+dig2+dp(pos+1,(i+carr+s[pos]-'0')/10));
    }
    return ans;
}
int32_t main() 
{
    cin>>s;
    reverse(s.begin(),s.end());
    n=s.length();
    memset(cache,-1,sizeof(cache));
    print(dp(0,0));
    path(0,0);
}   


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:38:5: error: 'path' was not declared in this scope; did you mean 'std::filesystem::__cxx11::path'?
   38 |     path(0,0);
      |     ^~~~
      |     std::filesystem::__cxx11::path
In file included from /usr/include/c++/14/filesystem:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_path.h:293:9: note: 'std::filesystem::__cxx11::path' declared here
  293 |   class path
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

int dp[1000100][2];

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += "0";
    int n = s.size();
    rep(i, n + 1) {
        rep(j, 2) {
            dp[i][j] = 1e9;
        }
    }
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 2) {
            int x = s[i] - '0';
            x += j;
            rep(a, 10) {
                int nj = 0;
                int b = a - x;
                if (b < 0) {
                    nj = 1;
                    b += 10;
                }
                dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + a + b);
            }
        }
    }
    cout << dp[n][0] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:36: error: no matching function for call to 'min(int&, ll)'
   31 |                 dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + a + b);
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:31:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   31 |                 dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + a + b);
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:31:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |                 dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + a + b);
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

struct dp{
	ll xp; // x+1円払う場合の最小枚数
	ll x0; // x  円払う場合の最小枚数
};

int main(){
	string N;
	cin >> N;
	int len = N.size();
	dp c = {1,0,1};
	
	for ( int i = 0; i < len; i++ ){
		int x = N[i] - '0';
		
		dp d = c;
		c.x0 = min(d.x0+x  , d.xp+(10-x));
		c.xp = min(d.x0+x+1, d.xp+(10-x-1));
	}
	
	cout << c.x0 << endl;
	
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:15:22: error: too many initializers for 'dp'
   15 |         dp c = {1,0,1};
      |                      ^
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;


int main()
{
	string S;
	cin >> S;
	int N[1000001];
	fill(N, N+1000001, 0);
	for(int i = 0; i < S.length(); i++){
		N[i] = S[S.length()-1-i] - '0';
	}
	
	ll ans = 0;
	for(int i = 0; i <= S.length(); i++){
		if(N[i] == 5 && N[i+1] >= 5){
			N[i+1]++;
			Rend[i+1]++;
			ans += 10-N[i];
		}
		else if(N[i] <= 5){
			ans += N[i];
		}
		else if(N[i] == 10){
			N[i+1]++;
		}
		else{
			N[i+1]++;
			ans += 10-N[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:25: error: 'Rend' was not declared in this scope
   36 |                         Rend[i+1]++;
      |                         ^~~~
Language: C++

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

int main() {
    string N;
    int counter=0;
    int count, counter1;
    cin >>N;
    int a[N.size()];
    for(int i=0;i<N.size();i++){
    a[i]=N.at(i)-'0';}
    int dp[100010][2];
    dp[0][0]=a[0];
    dp[0][1]=10-a[0];
    for(int i=0;i<N.size();i++){
    dp[i+1][0]=min(dp[i][0]+a[i+1],dp[i][1]+10-a[i+1]);
    dp[i+1][1]=min(dp[i][0]+10-a[i+1],dp[i][1]+a[i+1]);                                     
    cout<<dp[N][0]<<endl;}}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:13: error: no match for 'operator[]' (operand types are 'int [100010][2]' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   19 |     cout<<dp[N][0]<<endl;}}
      |             ^
Language: C++

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

int main() {
    long long N;
    long long deque<long long> a;
    long long counter=0;
    long long count, counter1;
    cin >>N;
    while(N>0){
    a.push_back(N%10);
    N/=10;}
    for(int i=0;i<a.size()-1;i++){
    count=a.at(i);
    counter1=a.at(i+1);
    if(count+counter1>10)
    counter+=20-count-counter1;
    else
    counter+=count+counter1}
    cout<<counter<<endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:32: error: invalid declarator before 'a'
    7 |     long long deque<long long> a;
      |                                ^
a.cc:12:5: error: 'a' was not declared in this scope
   12 |     a.push_back(N%10);
      |     ^
a.cc:14:19: error: 'a' was not declared in this scope
   14 |     for(int i=0;i<a.size()-1;i++){
      |                   ^
a.cc:20:28: error: expected ';' before '}' token
   20 |     counter+=count+counter1}
      |                            ^
      |                            ;
Language: C++

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

signed main () {
	string num;
	cin >> num;
	int n = num.size();
	vector < vector < int > > dp(n + 1, vector < int > (2, 0));
	dp[n][1] = 1;
	for (int i = n - 1; i >= 0; --i) {
		dp[i][0] = min(dp[i + 1][1] + 1 + int(s[i] - '0'), dp[i + 1][0] + int(s[i] - '0'));
		dp[i][1] = min(dp[i + 1][1] + 10 - int(s[i] - '0') - 1, dp[i + 1][0] + 10 - int(s[i] - '0'));
	}
	cout << min(dp[0][0], dp[0][1] + 1) << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:55: error: 's' was not declared in this scope
   11 |                 dp[i][0] = min(dp[i + 1][1] + 1 + int(s[i] - '0'), dp[i + 1][0] + int(s[i] - '0'));
      |                                                       ^
Language: C++

N = list(map(int, input()))

m = 0 # 最小の枚数
m_ = 1 # 繰り上がり時の枚数

for n in N:
  m, m_ = min(m+n, m_ + 10-n), min(m+n + 1, m_ + 10-(n+1))
print(m)

Compiler output:
a.cc:3:7: error: stray '#' in program
    3 | m = 0 # 最小の枚数
      |       ^
a.cc:4:8: error: stray '#' in program
    4 | m_ = 1 # 繰り上がり時の枚数
      |        ^
a.cc:1:1: error: 'N' does not name a type
    1 | N = list(map(int, input()))
      | ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

using namespace std;

typedef long long lint;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

string S;
int dp[1 << 20][10];

int f(int i, int carry)
{
    if (i == -1)
        return carry;
    int& ans = dp[i][carry];
    if (ans >= 0)
        return ans;
    ans = 100 * 1000000;
    int digit = S[i] - '0';
    for (int d = 0;d < 10; d++)
        ans = min(ans, d + (digit + carry + d) % 10 + 
                    f(i - 1, (digit + carry + d) / 10));

    return ans;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    cin >> S;
    memset(dp, -1, sizeof dp);
    cout << f(S.size() - 1, 0) << endl;
    return 0;
};


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:53:5: error: 'memset' was not declared in this scope
   53 |     memset(dp, -1, sizeof dp);
      |     ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   10 | #include <cmath>
  +++ |+#include <cstring>
   11 |
Language: C++

n = gets.split("").map(&:to_i).reverse

n.push(0)
len = n.length
ans = 0
i = 0

while i <= len - 1
    if n[i] <= 4
        ans += n[i]
    elsif n[i] > 5 && n[i] < 10
        ans += 10 - n[i]
        n[i + 1] += 1
    elsif n[i] == 5
        if n[i + 1] < 5
            ans += n[i]
        else
            ans += n[i]
            ans += 9 - n[i + 1]
            n[i + 2] += 1
            i += 1
        end
    else
        n[i + 1] += 1
    end
    i += 1
end

puts ans


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = gets.split("").map(&:to_i).reverse
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    string N;
    while (N.size() <= 1e6-S.size()) {
        N += '0';
    }

    N += S;

    // cout << N.size() << "\n";

    mat dp(1e6+2, vec(3, inf));
    dp[0][0] = 0;
    // dp[i][larger]
    Rep (i, 1e6+1) {
        // larger 0 to 0
        chmin(dp[i+1][0], dp[i][0] + N[i] - '0');

        // larger 0 to 1
        if (N[i] - '0' < 9) {
            chmin(dp[i+1][1], dp[i][0] + N[i] - '0' + 1);
        }

        // larger 1 to 1
        chmin(dp[i+1][1], dp[i][1] + N[i] - '0');

        chmin(dp[i+1][2], dp[i][1] + 10 - N[i] + '0');

        if (N[i] < '9') chmin(dp[i+1][1], dp[i][2] + N[i] - '0' + 1);

        chmin(dp[i+1][2], dp[i+1][2] + N[i] - '0');
    }

    for (ll i = 999998; i <= 1e6+1; i++) {
        // cout << "i=" << i << " " << dp[i][0] << " " << dp[i][1] << "\n";
    }

    cout << min({dp[1e6+1][0], dp[1e6+1][1], dp[1e6+1][2]) << "\n";
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:58: error: expected '}' before ')' token
   80 |     cout << min({dp[1e6+1][0], dp[1e6+1][1], dp[1e6+1][2]) << "\n";
      |                 ~                                        ^
Language: C++

#include <iostream>


using namespace std;

typedef long long ll;
const int MAX = 1e6;
char str[MAX];
int dp[MAX + 1][2];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> str;
    int len = strlen(str);
    for (int j = 0; j < len; ++j) {
        str[j] -= '0';
    }

    dp[0][0] = str[0];
    dp[0][1] = 10 - str[0] + 1;
    for (int i = 1; i < len; ++i) {
        dp[i][0] = min(dp[i - 1][1] + str[i], dp[i - 1][0] + str[i]);
        dp[i][1] = min(dp[i - 1][1] - 1 + 10 - str[i], dp[i - 1][0] + 10 - str[i] + 1);
    }

    cout << min(dp[len - 1][0], dp[len - 1][1]);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: 'strlen' was not declared in this scope
   16 |     int len = strlen(str);
      |               ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

int main(){
	long long ans = 0;
	string s;
	cin >> s;
	ll arr[10];
	for(int i=0; i<=10; i++){
		arr[i] = (ll)min(i, 10-i);
	}
	for(int i=0; i<SZ(s); i++){
		ans += arr[s[i]-'0'];
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: 'string' was not declared in this scope
    3 |         string s;
      |         ^~~~~~
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> s;
      |         ^~~
a.cc:4:16: error: 's' was not declared in this scope
    4 |         cin >> s;
      |                ^
a.cc:5:9: error: 'll' was not declared in this scope
    5 |         ll arr[10];
      |         ^~
a.cc:7:17: error: 'arr' was not declared in this scope
    7 |                 arr[i] = (ll)min(i, 10-i);
      |                 ^~~
a.cc:9:24: error: 'SZ' was not declared in this scope
    9 |         for(int i=0; i<SZ(s); i++){
      |                        ^~
a.cc:10:24: error: 'arr' was not declared in this scope
   10 |                 ans += arr[s[i]-'0'];
      |                        ^~~
a.cc:12:9: error: 'cout' was not declared in this scope
   12 |         cout << ans << endl;
      |         ^~~~
a.cc:12:24: error: 'endl' was not declared in this scope
   12 |         cout << ans << endl;
      |                        ^~~~
Language: C++

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

const int N = 1000005;
string a;
int ans, n, dp[N][2];
 
int f(int i, int carry) {
    int digit = ((a[i] - '0')) + carry;
    if (i == 0) return digit;
    if (dp[i][carry]) return dp[i][carry];
    return dp[i][carry] = (min(f(i-1, 1) + (10-digit), f(i-1, 0) + digit));
}
 
int main() {
    cin >> a;
    n = a.length();
    a = '0' + a;
    cout << f(n, 0) << nl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:24: error: 'nl' was not declared in this scope; did you mean 'ynl'?
   19 |     cout << f(n, 0) << nl;
      |                        ^~
      |                        ynl
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <cmath>
#include <set>
#include <queue>
using namespace std;

int main(){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
    string s;
    cin >> s;
    s = '0' + s;
    int n = s.size();
    int ans[n][2];
    ans[n-1][0] = arr[n-1];
    ans[n-1][1] = 10 - arr[n-1];
    for(int i = n-2; i >= 0; i--){
      	int tmp = s[i] - '0';
      	ans[i][0] = min(ans[i+1][0], ans[i+1][1] + 1) + tmp;
		ans[i][1] = min(ans[i+1][0] + 1, ans[i+1][1]) + 9 - tmp;
    }
    cout << ans[0][0] << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:19: error: 'arr' was not declared in this scope
   20 |     ans[n-1][0] = arr[n-1];
      |                   ^~~
Language: C++

#include <iostream> 
using namespace std;
int d[(int)3e6][2], n;
int main () {
	string s; cin >> s; n = s.size();
	reverse (s.begin(),s.end());
	s += '0';
	d[0][0] = (s[0] - '0'), d[0][1] = 10 - (s[0]-'0');
	for (int i = 1, g = s[i]-'0'; i < n; i ++) {
		d[i][0] = min (d[i-1][0]+g, d[i-1][1]+g+1), d[i][1] = min (d[i-1][0]+10-g,d[i-1][1]+10-g-1); 
	}
	cout << d[n-1][0];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'reverse' was not declared in this scope
    6 |         reverse (s.begin(),s.end());
      |         ^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

const int inf = 1<<29;

int main()
{
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';

  int n = s.size();
  vector< vector<int> > dp(n+1, vector<int>(2, inf));
  dp[0][0] = 0;

  for(int i = 0; i < n; i++) {
    for(int a = 0; a < 10; a++) {
      for(int j = 0; j < 2; j++) {
        int d = s[i] - '0';
        int aa = a - j;
        int b = aa - d;
        int nj = 0;
        if(b < 0) {
          b += 10;
          nj = 1;
        }
        dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + a + b);
      }
    }
  }

  cout << dp[n][0] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'reverse' was not declared in this scope
   13 |   reverse(s.begin(), s.end());
      |   ^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <iterator>

using namespace std;

int dp[100100100][2]; 
int INF = 1001001001;
 
int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    // 91 --> 19
    reverse(s.begin(), s.end()); 
    // 19 --> 190 (091 is the original value)
    //s += "0";

    //init
    for(int i=0; i<s.size(); i++){
        for(int j=0; j<2; j++){
            dp[i][j] = INF;
        } 
    }
    dp[0][0] = 0;

    for(int i=0; i<s.size(); i++){
        //char no keisan.s
        int current_num = s[i]- '0';
        // kuriagaranai baai
        dp[i+1][0] = min( dp[i][0] + current_num, dp[i][1] + current_num + 1);
        // kuriagaruabai baai(oturi + atarasii sautno 1)
        dp[i+1][1] = min( dp[i][0]+ 10-current_num, dp[i][1]+ 10-(current_num+1) );
    }

    cout << min(dp[s.size()][0], dp[s.size()][1]+1) << endl;
 }

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:16:5: error: 'reverse' was not declared in this scope
   16 |     reverse(s.begin(), s.end());
      |     ^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <iterator>

using namespace std;

//int dp[100100100][2]; 
int dp[1000][2]; 
int INF = 1001001001;
 
int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    // 91 --> 19
    reverse(s.begin(), s.end()); 
    // 19 --> 190 (091 is the original value)
    //s += "0";

    //init
    for(int i=0; i<s.size(); i++){
        for(int j=0; j<2; j++){
            dp[i][j] = INF;
        } 
    }
    dp[0][0] = 0;

    for(int i=0; i<s.size(); i++){
        //char no keisan.s
        int current_num = s[i]- '0';
        // kuriagaranai baai
        dp[i+1][0] = min( dp[i][0] + current_num, dp[i][1] + current_num + 1);
        // kuriagaruabai baai(oturi + atarasii sautno 1)
        dp[i+1][1] = min( dp[i][0]+ 10-current_num, dp[i][1]+ 10-(current_num+1) );
    }

    cout << min(dp[s.size()][0], dp[s.size()][1]+1) << endl;
 }

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:17:5: error: 'reverse' was not declared in this scope
   17 |     reverse(s.begin(), s.end());
      |     ^~~~~~~
Language: C++

using System;
using System.IO;

namespace test
{
    class MainClass
    {
        public static int Digit(int num)
        {
            return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
        }

        public static int Sum_n(int num)
        {
            int digit = Digit(num);
            int p = 0;
            
            for (int i = digit; i>0; i--)
            {
                int temp = num % 10;
                p += temp;
                num = num / 10;
            }
            return p;
        }
        public static void Main(string[] args)
        { 
            int a = int.Parse(Console.ReadLine());
            int digit = Digit(a);
            

            int top = a / (int)(Math.Pow(10, (digit - 1)));
            int a_2 = (top + 1) * (int)(Math.Pow(10, (digit - 1)));
            int dif = a_2 - a;
            int ans = Sum_n(dif) + top + 1;
            Console.WriteLine(ans);
            


        }

    }

}
    



Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.IO;
      |       ^~~~~~
a.cc:8:15: error: expected ':' before 'static'
    8 |         public static int Digit(int num)
      |               ^~~~~~~
      |               :
a.cc:13:15: error: expected ':' before 'static'
   13 |         public static int Sum_n(int num)
      |               ^~~~~~~
      |               :
a.cc:26:15: error: expected ':' before 'static'
   26 |         public static void Main(string[] args)
      |               ^~~~~~~
      |               :
a.cc:26:33: error: 'string' has not been declared
   26 |         public static void Main(string[] args)
      |                                 ^~~~~~
a.cc:26:42: error: expected ',' or '...' before 'args'
   26 |         public static void Main(string[] args)
      |                                          ^~~~
a.cc:42:6: error: expected ';' after class definition
   42 |     }
      |      ^
      |      ;
a.cc: In static member function 'static int test::MainClass::Digit(int)':
a.cc:10:43: error: 'Math' was not declared in this scope
   10 |             return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
      |                                           ^~~~
a.cc: In static member function 'static void test::MainClass::Main(int*)':
a.cc:28:21: error: expected primary-expression before 'int'
   28 |             int a = int.Parse(Console.ReadLine());
      |                     ^~~
a.cc:32:33: error: 'Math' was not declared in this scope
   32 |             int top = a / (int)(Math.Pow(10, (digit - 1)));
      |                                 ^~~~
a.cc:36:13: error: 'Console' was not declared in this scope
   36 |             Console.WriteLine(ans);
      |             ^~~~~~~
Language: C++

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace Application
{
    public interface EmptyInterface
    {
 
        public static int Digit(int num)
        {
            return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
        }

        public static int Sum_n(int num)
        {
            int digit = Digit(num);
            int p = 0;
            for (int i = digit; i < 1; i--)
            {
                int temp = num % (int)(Math.Pow(10, (digit - 1)));
                num = (num - temp) / 10;
                p += temp;
            }
            return p;
        }
        static void Main()

        {
            int a = int.Parse(Console.ReadLine());
            int digit = Digit(a);

            int top = a / (int)(Math.Pow(10, (digit - 1)));
            int a_2 = (top + 1) * (int)(Math.Pow(10, (digit - 1)));
            int dif = a_2 - a;
            int ans = Sum_n(dif) + top + 1;
            Console.WriteLine(ans);
        }


    }

 }


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.IO;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Linq;
      |       ^~~~~~
a.cc:8:5: error: expected unqualified-id before 'public'
    8 |     public interface EmptyInterface
      |     ^~~~~~
Language: C++

using System;
using System.IO;

namespace test
{
    public class Class1
    {
        public static int Digit(int num)
        {
            return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
        }

        public static int Sum_n(int num)
        {
            int digit = Digit(num);
            int p = 0;
            for (int i = digit; i < 1; i--)
            {
                int temp = num % (int)(Math.Pow(10, (digit - 1)));
                num = (num - temp) / 10;
                p += temp;
            }
            return p;
        }
        static void Main()

        {
            int a = int.Parse(Console.ReadLine());
            int digit = Digit(a);

            int top = a / (int)(Math.Pow(10, (digit - 1)));
            int a_2 = (top + 1) * (int)(Math.Pow(10, (digit - 1)));
            int dif = a_2 - a;
            int ans = Sum_n(dif) + top + 1;
            Console.WriteLine(ans);
        }


    }

}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.IO;
      |       ^~~~~~
a.cc:6:5: error: expected unqualified-id before 'public'
    6 |     public class Class1
      |     ^~~~~~
Language: C++

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

int main()
{	
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	int n = s.size();
	vector<vector<int>> dp(n, vector<int>(2, INF));

	int x = s[0] - '0';
	dp[0][0] = x;
	dp[0][1] = 1 + 10 - x;

	for (int i = 1; i < n; i++) {
		x = s[i] - '0';
		// i-1桁において、繰り下げがなかった場合
		dp[i][0] = x + dp[i - 1][0];
		dp[i][1] = 1 + (10 - x) + dp[i - 1][0];
		dp[i][1] = min(dp[i][1], 1 + x + dp[i - 1][0]);

		// i-1桁において、繰り下げがあった場合
		if (x != 9) dp[i][0] = min(dp[i][0], dp[i - 1][1] + 1 + (x - 1));
		dp[i][1] = min(dp[i][1], dp[i - 1][1] + 9 - x);
		dp[i][1] = min(dp[i][1], dp[i - 1][1] + 1 + (x - 1));
	}
	cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:50: error: 'INF' was not declared in this scope
   10 |         vector<vector<int>> dp(n, vector<int>(2, INF));
      |                                                  ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int solve(int n)
{
if(n==0)
return 0;
int mini=0;
int x=1;
while(n!=0)
{mini+=n%10;
n/=10;
x*=10;
}
return min(mini,solve(x-n));

}

}
int main()
{
int n;
cin>>n;
cout<<solve(n)<<endl;
return 0;


}

Compiler output:
a.cc:18:1: error: expected declaration before '}' token
   18 | }
      | ^
Language: C++

#include <iostream>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  int flag = 1;
  for (int i = 0; i < N-1; i++) {
    switch(S[i]){
    case '0':
    case '1':
    case '2':
    case '3':
      if (flag == -1) {
        ans += n + 1;
      } else {
        ans += n;
      }
      flag = 1;
      break;
    case '4':
      if (flag == -1) {
        ans += 5;
        flag = 0;
      }
      else {
        ans += 4;
        flag = 1;
      }
      break;
    case '5':
      if (flag == 1) {
        ans += 5;
        flag = 0;
      } else {
        ans += 4;
        flag = -1;
      }
      break;
    case '6':
    case '7':
    case '8':
    case '9':
      if (flag == 1) {
        ans += 10 - n;
      }
      else {
        ans += 9 - n;
      }
      flag = -1;
      break;
    }
  }
  int last = S[N - 1] - '0';
  if(last <= 4) {
    if(flag == -1) {
      ans += last + 1;
    } else {
      ans += last;
    }
  } else if (last == 5) {
    ans += 5;
  } else {
    if(flag == 1) {
      ans += 11 - last;
    } else {
      ans += 10 - last;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: 'n' was not declared in this scope
   16 |         ans += n + 1;
      |                ^
a.cc:18:16: error: 'n' was not declared in this scope
   18 |         ans += n;
      |                ^
a.cc:46:21: error: 'n' was not declared in this scope
   46 |         ans += 10 - n;
      |                     ^
a.cc:49:20: error: 'n' was not declared in this scope
   49 |         ans += 9 - n;
      |                    ^
Language: C++

using namespace std;
int main() {
  int flag = 1; 
  int ans = 0;
  int c, c2;
  while ((c = getchar_unlocked()) >= '0') {
    int n = c - '0';
    c2 = n;
    if (n < 4) {
      if (flag == -1) {
        ans += n + 1;
      } else {
        ans += n;
      }
      flag = 1;
    }
    else if (n > 5) {
      if (flag == 1) {
        ans += 10 - n;
      }
      else {
        ans += 9 - n;
      }
      flag = -1;
    } else if(n == 4) {
      if (flag == -1) {
        flag = 0;
        ans += 5;
      }
      else {
        flag = 1;
        ans += 4;
      }
    } else if (n == 5) {
      if (flag == 1) {
        flag = 0;
        ans += 5;
      } else {
        flag = -1;
        ans += 4;
      }
    }
  }
  int last = c2 - '0';
  if(last <= 4) {
    if(flag == -1) {
      ans += last + 1;
    } else {
      ans += last;
    }
  } else if (last == 5) {
    ans += 5;
  } else {
    if(flag == 1) {
      ans += 11 - last;
    } else {
      ans += 10 - last;
    }
  }
  printf("%d\n", ans);
  return 0;
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:6:15: error: 'getchar_unlocked' was not declared in this scope
    6 |   while ((c = getchar_unlocked()) >= '0') {
      |               ^~~~~~~~~~~~~~~~
a.cc:60:3: error: 'printf' was not declared in this scope
   60 |   printf("%d\n", ans);
      |   ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using namespace std;
Language: C++

using namespace std;
int main() {
  int flag = 1; 
  int ans = 0;
  int c, c2
  while ((c = getchar_unlocked()) >= '0') {
    int n = c - '0';
    c2 = n;
    if (n < 4) {
      if (flag == -1) {
        ans += n + 1;
      } else {
        ans += n;
      }
      flag = 1;
    }
    else if (n > 5) {
      if (flag == 1) {
        ans += 10 - n;
      }
      else {
        ans += 9 - n;
      }
      flag = -1;
    } else if(n == 4) {
      if (flag == -1) {
        flag = 0;
        ans += 5;
      }
      else {
        flag = 1;
        ans += 4;
      }
    } else if (n == 5) {
      if (flag == 1) {
        flag = 0;
        ans += 5;
      } else {
        flag = -1;
        ans += 4;
      }
    }
  }
  int last = c2 - '0';
  if(last <= 4) {
    if(flag == -1) {
      ans += last + 1;
    } else {
      ans += last;
    }
  } else if (last == 5) {
    ans += 5;
  } else {
    if(flag == 1) {
      ans += 11 - last;
    } else {
      ans += 10 - last;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: expected initializer before 'while'
    6 |   while ((c = getchar_unlocked()) >= '0') {
      |   ^~~~~
a.cc:44:14: error: 'c2' was not declared in this scope; did you mean 'c'?
   44 |   int last = c2 - '0';
      |              ^~
      |              c
a.cc:60:3: error: 'printf' was not declared in this scope
   60 |   printf("%d\n", ans);
      |   ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using namespace std;
Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <iostream>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string S;
  cin >> S;
  int N = S.size();
  int flag = 1;
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    int n = S[i] - '0';
    if (n < 4) {
      if (flag == -1) {
        ans += n + 1;
      } else {
        ans += n;
      }
      flag = 1;
    }
    else if (n > 5) {
      if (flag == 1) {
        ans += 10 - n;
      }
      else {
        ans += 9 - n;
      }
      flag = -1;
    } else if(n == 4) {
      if (flag == -1) {
        flag = 0;
        ans += 5;
      }
      else {
        flag = 1;
        ans += 4;
      }
    } else if (n == 5) {
      if (flag == 1) {
        flag = 0;
        ans += 5;
      } else {
        flag = -1;
        ans += 4;
      }
    }
  }
  int last = S[N - 1] - '0';
  if(last <= 4) {
    if(flag == -1) {
      ans += last + 1;
    } else {
      ans += last;
    }
  } else if (last == 5) {
    ans += 5;
  } else {
    if(flag == 1) {
      ans += 11 - last;
    } else {
      ans += 10 - last;
    }
  }
  printf("%d\n", min(dp0, dp1 + 1));
  return 0;
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:66:22: error: 'dp0' was not declared in this scope
   66 |   printf("%d\n", min(dp0, dp1 + 1));
      |                      ^~~
a.cc:66:27: error: 'dp1' was not declared in this scope
   66 |   printf("%d\n", min(dp0, dp1 + 1));
      |                           ^~~
Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <iostream>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    int n = S[i] - '0';
    if (n < 4) {
      if (flag == -1) {
        ans += n + 1;
      } else {
        ans += n;
      }
      flag = 1;
    }
    else if (n > 5) {
      if (flag == 1) {
        ans += 10 - n;
      }
      else {
        ans += 9 - n;
      }
      flag = -1;
    } else if(n == 4) {
      if (flag == -1) {
        flag = 0;
        ans += 5;
      }
      else {
        flag = 1;
        ans += 4;
      }
    } else if (n == 5) {
      if (flag == 1) {
        flag = 0;
        ans += 5;
      } else {
        flag = -1;
        ans += 4;
      }
    }
  }
  int last = S[N - 1] - '0';
  if(last <= 4) {
    if(flag == -1) {
      ans += last + 1;
    } else {
      ans += last;
    }
  } else if (last == 5) {
    ans += 5;
  } else {
    if(flag == 1) {
      ans += 11 - last;
    } else {
      ans += 10 - last;
    }
  }
  printf("%d\n", min(dp0, dp1 + 1));
  return 0;
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: 'flag' was not declared in this scope
   15 |       if (flag == -1) {
      |           ^~~~
a.cc:20:7: error: 'flag' was not declared in this scope
   20 |       flag = 1;
      |       ^~~~
a.cc:23:11: error: 'flag' was not declared in this scope
   23 |       if (flag == 1) {
      |           ^~~~
a.cc:29:7: error: 'flag' was not declared in this scope
   29 |       flag = -1;
      |       ^~~~
a.cc:31:11: error: 'flag' was not declared in this scope
   31 |       if (flag == -1) {
      |           ^~~~
a.cc:40:11: error: 'flag' was not declared in this scope
   40 |       if (flag == 1) {
      |           ^~~~
a.cc:51:8: error: 'flag' was not declared in this scope
   51 |     if(flag == -1) {
      |        ^~~~
a.cc:59:8: error: 'flag' was not declared in this scope
   59 |     if(flag == 1) {
      |        ^~~~
a.cc:65:22: error: 'dp0' was not declared in this scope
   65 |   printf("%d\n", min(dp0, dp1 + 1));
      |                      ^~~
a.cc:65:27: error: 'dp1' was not declared in this scope
   65 |   printf("%d\n", min(dp0, dp1 + 1));
      |                           ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s; 
	int ans=0;
	int cc=0;
	for(int i=0;i<s.size();i++)
		s[i]=s[i]-'0';
	for(int i=0;i<s.size()-1;i++)//989
	{
		
		int s[i]=s[i]+cc;
		if(s[i]<5)
		{
			ans+=s[i];
			cc=0;
		}	 
		else if(s[i]>5) 
		{
			ans+=11-s[i];
			cc+1;
		}
		else 
		{
			ans+=5;
			if(s[i+1]>=5&&i>0)
				cc=1;
		}	
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:30: error: array must be initialized with a brace-enclosed initializer
   13 |                 int s[i]=s[i]+cc;
      |                          ~~~~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s; 
	int ans=0;
	int cc=0;
	for(int i=0;i<s.size();i++)
		s[i]=s[i]-'0';
	for(int i=0;i<s.size()-1;i++)//989
	{
		
		int s[i]=s[i]+cc;
		if(s[i]<5)
		{
			ans+=s[i];
			cc=0;
		}	 
		else if(s[i]>5) 
		{
			ans+=11-s[i];
			cc+1;
		}
		else 
		{
			ans+=5;
			if(s[i+1]>=5&&i>0)
				cc=1
		}	
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:30: error: array must be initialized with a brace-enclosed initializer
   13 |                 int s[i]=s[i]+cc;
      |                          ~~~~^~~
a.cc:28:37: error: expected ';' before '}' token
   28 |                                 cc=1
      |                                     ^
      |                                     ;
   29 |                 }
      |                 ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
string s;
int dp[1000010][2];
signed main(){
	cin>>s;
	rep(i,1000001)rep(j,2)dp[i][j]=1000000000;
	dp[0][0]=dp[0][1]=1;
	rep(i,s.size()){
		int t=s[i];
		dp[i+1][0]=min(dp[i+1][0],dp[i][
	}
	cout<<min(dp[s.size()][0],dp[s.size()][1])<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: expected primary-expression before '}' token
   14 |         }
      |         ^
a.cc:13:49: error: expected ']' before '}' token
   13 |                 dp[i+1][0]=min(dp[i+1][0],dp[i][
      |                                                 ^
      |                                                 ]
   14 |         }
      |         ~
Language: C++

#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string N;
    cin >> N;

    int M = N.size();
    int c = 0;
    int r = 0;
    REP(i, M) {
        int s = N[i] - '0';
        
        if (s < 10 - s - r) {
          c = s;
          r = 0;
        else {
          c = c + 10 - s - r;
          r = 1;
       }
    }

    cout << c << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:97:9: error: expected '}' before 'else'
   97 |         else {
      |         ^~~~
a.cc:94:29: note: to match this '{'
   94 |         if (s < 10 - s - r) {
      |                             ^
Language: C++

#include <iostream>
#include <string>

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int payvalue;
	std::string paystr;
	std::cin >> paystr;
	payvalue = std::atoi(paystr.c_str());
	int t = payvalue;
	/*int digit = 0;
	while(1) {
		t = t / 10;
		digit++;
		if(t == 0) break;
	}*/
	std::reverse(paystr.begin(), paystr.end());
	
	int sum = 0;
	bool isup = false;

	for(int i = 0; i < (int)paystr.size(); ++i){
    		char value = paystr[i];
		int v = ctoi(value);
		if(v <= 5) {
			isup = false;
			sum += v;
		} else {
			//sum += ((10-v) + 1);
			if(isup) {
				sum += ((10-v) -1);
			} else {
				sum += ((10-v) + 1);
			}
			isup = true;
		}
	}
	std::cout << sum << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: 'reverse' is not a member of 'std'
   23 |         std::reverse(paystr.begin(), paystr.end());
      |              ^~~~~~~
Language: C++

#include <bits/stdc++.h>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using p = pair<int, int>;
#define chimin(x,y) x = min(x,y)

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



    int main(){
        string s;
        std::cin >> s;
        reverse (s.begin(), s.end());
        s += '0';
        int n = s.size();
        rep(i,n+1)rep(j,2) dp[i][j] = INF;
        dp[0][0] = 0;
        rep(i,n)rep(j,2){
            int x = s[i] - '0';
            x += j;
            if(x < 10) chmin (dp[i+1][0], dp[i][j]+x);
            if(x > 0) chmin (dp[i+1][1], dp[i][j]+(10-x));
        }
        int ans = dp[n][0];
        std::cout << ans << "\n";
        return 0;
    }
    


Compiler output:
a.cc: In function 'int main()':
a.cc:25:24: error: 'chmin' was not declared in this scope; did you mean 'chimin'?
   25 |             if(x < 10) chmin (dp[i+1][0], dp[i][j]+x);
      |                        ^~~~~
      |                        chimin
a.cc:26:23: error: 'chmin' was not declared in this scope; did you mean 'chimin'?
   26 |             if(x > 0) chmin (dp[i+1][1], dp[i][j]+(10-x));
      |                       ^~~~~
      |                       chimin
Language: C++

def main():
    s = input()
    s = list(reversed(s))
    s.append('0')
    dp = [[10**10 for _ in range(2)] for _ in range(len(s)+1)]
    dp[0][0] = 0
    for i in range(len(s)):
        for j in range(2):
            x = int(s[i])
            x += j
            for a in range(10):
                ni = i+1
                nj = 0
                b = a-x
                if b < 0:
                    nj = 1
                    b += 10
                dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b)
    print(dp[len(s)][0])


main()


Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: Java

import java.util.*;

public class E {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int len = n.length();

        String[] arr = new String[len];
        for (int i=0; i<len; i++) arr[i] = n.substring(i, i+1);

        long[][] dp = new long[len+1][2];
//        long[] dpPay = new long[len];
//        long[] dpChange = new long[len];
        dp[0][0] = 0;
        dp[0][1] = 1;

//        dp[0][0] = Integer.parseInt(arr[0]);
//        dp[0][1] = (Integer.parseInt(arr[0])+1)==10 ? 1 : Integer.parseInt(arr[0])+1;

//        System.out.println(dp[0][0]);
//        System.out.println(dp[0][1]);

//        if (Integer.parseInt(arr[0])<=5){
//            dpSum[0] = Integer.parseInt(arr[0]);
//        }else if (6<=Integer.parseInt(arr[0])){
//            dpSum[0] = 11 - Integer.parseInt(arr[0]);
//        }

//        System.out.println(dpSum[0]);

        for (int i=1; i<len+1; i++){
            int tmp = Integer.parseInt(arr[i-1]);

            dp[i][0] = Math.min(dp[i-1][0]+tmp, dp[i-1][1]+10-tmp);
            dp[i][1] = Math.min(dp[i-1][0]+tmp+1, dp[i-1][1]+9-tmp);
        }

        System.out.println(dp[len][0]);
//        System.out.println(dpSum[len-1]);
    }
}


Compiler output:
Main.java:3: error: class E is public, should be declared in a file named E.java
public class E {
       ^
1 error