Problem:
Score : 200 points

Problem Statement

Takahashi has two positive integers A and B.

It is known that A plus B equals N.
Find the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B" (in base 10).

Constraints

2 ≤ N ≤ 10^5

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B".

Sample Input 1

15

Sample Output 1

6

When A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.

Sample Input 2

100000

Sample Output 2

10

Solution in C# (.NET Core 3.1.201) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Policy;

class Program
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());

		var min = int.MaxValue;
		for (var i = 1; i <= n / 2 + 1; ++i) {
			var sum1 = Array.ConvertAll(i.ToString().ToCharArray(), num => int.Parse(num.ToString())).Sum();
			var sum2 = Array.ConvertAll((n - i).ToString().ToCharArray(), num => int.Parse(num.ToString())).Sum();
			if (sum1 + sum2 < min) {
				min = sum1 + sum2;
			}
		}

		Console.WriteLine(min);

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}