Problem:
Score : 1300 points

Problem Statement

We will call a non-negative integer increasing if, for any two adjacent digits in its decimal representation, the digit to the right is greater than or equal to the digit to the left.
For example, 1558, 11, 3 and 0 are all increasing; 10 and 20170312 are not.

Snuke has an integer N. Find the minimum number of increasing integers that can represent N as their sum.

Constraints

1 \leq N \leq 10^{500000}

Input

The input is given from Standard Input in the following format:

N

Output

Print the minimum number of increasing integers that can represent N as their sum.

Sample Input 1

80

Sample Output 1

2

One possible representation is 80 = 77 + 3.

Sample Input 2

123456789

Sample Output 2

1

123456789 in itself is increasing, and thus it can be represented as the sum of one increasing integer.

Sample Input 3

20170312

Sample Output 3

4

Sample Input 4

7204647845201772120166980358816078279571541735614841625060678056933503

Sample Output 4

31

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int N = 500200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
int n;
int a[N];
 
inline int calc()
{
	int st=0,ret=0;
	int f=1,fi=-1,posfi=st;
	bool finded=0;
	while(st<n)
	{
		f=1,fi=-1,posfi=st;
		for(int i=st;i+1<n;++i)
		{
			if(a[i]!=fi) fi=a[i],posfi=i;
			if(a[i]>a[i+1])
			{
				f=0;
				st=posfi+1;
				break;
			}
		}
		ret++;
		if(f) break;
		while(st<n&&a[st]==0)
			st++;
		if(st>n)
			break;          
		finded=0;        
		for(int i=n-1;i>=st;--i)
		{
			if(a[i]<9)
			{
				a[i]++;
				finded=true;
				break;
			}
			else
				a[i]=0;
		}
		if(!finded)
			a[--st]=0;
	}
	return ret;
}
char t[N];
 
int main()
{
	scanf("%s",t);
	int k=strlen(t);
	n=k;
	for(int i=0;i<k;++i)
		a[i]=t[i]-'0';
	cout <<calc();	
	return 0;	
}