Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

import static com.yu212.Utils.println;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 2000000000000000005L;

    void solve() {
        String s = "0" + in.next();
        int n = s.length();
        int[][] dp = new int[n + 1][2];
        dp[0][1] = 0xfffffff;
        for (int i = 0; i < n; i++) {
            dp[i + 1][0] = 0xfffffff;
            dp[i + 1][1] = 0xfffffff;
            int c = s.charAt(n - 1 - i) - '0';
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 2; k++) {
                    int d = ((j + 10) - c - k) % 10;
                    int e = j < c + k ? 1 : 0;
                    println(c, j, k, d, e);
                    dp[i + 1][e] = Math.min(dp[i + 1][e], dp[i][k] + j + d);
                }
            }
        }
        out.println(dp[n][0]);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Compiler output:
Main.java:10: error: package com.yu212 does not exist
import static com.yu212.Utils.println;
                       ^
Main.java:10: error: static import only from classes and interfaces
import static com.yu212.Utils.println;
^
Main.java:31: error: cannot find symbol
                    println(c, j, k, d, e);
                    ^
  symbol:   method println(int,int,int,int,int)
  location: class Main
3 errors