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

#include<iostream>
#include<string>
using namespace std;
int main(){
  string a[32],b,c,z;
  int L;
  while(cin>>a[0]>>L){
    if(L==0)break;
    for(int j=0;j<L-a[0].size();j++)z+='0';
    a[0]=z+a[0];
    int i=0,k=1;
    while(k){
      b=a[i];
      sort(b.begin(),b.end());
      c=b;
      reverse(c.begin(),c.end());
      i++;
      for(int j=0;j<L;j++){
	int t=b[j],u=c[j];
	if(t-u<0)b[j+1]--,a[i]+=t-u+10+'0';
	else a[i]+=t-u+'0';
      }
      reverse(a[i].begin(),a[i].end());
      for(int j=0;j<i;j++)
	if(a[i]==a[j])cout<<j<<' '<<a[i]<<' '<<i-j<<endl,k=0;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:7: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |       sort(b.begin(),b.end());
      |       ^~~~
      |       short
a.cc:16:7: error: 'reverse' was not declared in this scope
   16 |       reverse(c.begin(),c.end());
      |       ^~~~~~~
Language: C++

#include<iostream>
using namespace std;

int main(){
  while(1){
    
  char h[7]={};
  int L,min,max,f=0,sum[100000],i;
  cin>>h>>L;
  if(L==0) break;
  for(int i=strlen(h);i<L;i++) h[i]='0';
  sum[0]=atoi(h);
  i=1;
  while(1){
    if(f==1) break;
      sort(h,h+L);
    min=atoi(h);
    reverse(h,h+L);
    max=atoi(h);
    sum[i]=max-min;
    for(int j=0;j<i;j++){
      if(sum[j]==sum[i]){
	cout<<j<<" "<<sum[i]<<" "<<i-j<<endl;
	f=1;
	break;
      }
    }
    sprintf(h,"%d",sum[i]);
    // cout<<strlen(h);
     for(int i=strlen(h);i<L;i++) h[i]='0';
     i++;
  }
  }
return 0;
}
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: 'strlen' was not declared in this scope
   11 |   for(int i=strlen(h);i<L;i++) h[i]='0';
      |             ^~~~~~
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 | using namespace std;
a.cc:16:7: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |       sort(h,h+L);
      |       ^~~~
      |       short
a.cc:18:5: error: 'reverse' was not declared in this scope
   18 |     reverse(h,h+L);
      |     ^~~~~~~
a.cc:30:16: error: 'strlen' was not declared in this scope
   30 |      for(int i=strlen(h);i<L;i++) h[i]='0';
      |                ^~~~~~
a.cc:30:16: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;



int main() {
	while (1) {
		int a, L; cin >> a >> L;
		vector<int>ints;
		int ansnum;
		int latplace;
		int earplace;
		while (1) {
			vector<int>perm(L);
			st = to_string(a);
			while (st.size() < L)st = "0" + st;
			iota(perm.begin(), perm.end(), 0);
			int amax = 0;
			int amin = 0;
			do {
				int num = stoi(st);
				amax = max(amax, num);
				amin = min(amin, num);
			} while (next_permutation(st.begin(), st.end()));
			int nextnum = amax - amin;
			auto it = find(ints.begin(), ints.end(), nextnum);
			if (it==ints.end()) {
				ints.push_back(nextnum);
			}
			else {
				latplace = ints.size()+1;
				earplace = it - ints.begin()+1;
				ansnum = a;
			}
			a =(nextnum);
		}
		cout << latplace << " " << ansnum << " " << latplace - earplace << endl;

	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:25: error: 'st' was not declared in this scope; did you mean 'std'?
   17 |                         st = to_string(a);
      |                         ^~
      |                         std
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>

#pragma warning(disable:4996)
 
using namespace std;
 
int main()
{
	int InpNum = 0, l = 0, j = 0;


	while(cin >> InpNum >> l)
	{
		int cnt = 0;
		int TempNum1[10] = { 0 };
		int TempNum3[25] = { 0 };

		int n = 0, tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;


		if(InpNum == 0 && l ==0){break;}

		tmp1 = InpNum;

		for(int i = 0; i < 10; i++)
		{
			tmp2 = (int)(tmp1 / 10) * 10;
			tmp3 = tmp1 - tmp2;

			cnt = cnt + 1;
			TempNum1[i] = tmp3;

			tmp1 = tmp1 / 10;
			if(tmp1 == 0){break;} 
		}


		for(int j=0; j < 20; j++)
		{

			int TempNum2[10] = { 0 };
			int n = 0;


			sort(TempNum1, TempNum1 + l);

			for(int i= l; i > 0; i--)
			{
				TempNum2[i] =  TempNum2[i] + TempNum1[n] - TempNum1[i - 1];

				if(TempNum2[i] < 0)
				{
					TempNum2[i] = TempNum2[i] + 10;
					TempNum2[i-1] = TempNum2[i-1] - 1;
				}

				n = n + 1;
			}

			for(int i=0; i<l; i++)
			{
				int h = 1;
				TempNum1[i] = TempNum2[i+1];
				TempNum3[j] = TempNum3[j] + TempNum2[i+1] * (int)pow(10.0, l - i - 1);
			}
		}


		cnt = 0;

		for(int i=0; i<20; i++)
		{
			if(cnt == 1){break;}

			for(int j=0; j<20; j++)
			{
				if(i == j){}
				else
				{
					if(TempNum3[j] == TempNum3[i] )
					{
						printf("%d %d %d\n", i+1, TempNum3[j], j-i);
						cnt = cnt + 1;
						break;
					}
				}
			}
		}
	}
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:82: error: 'pow' was not declared in this scope
   66 |                                 TempNum3[j] = TempNum3[j] + TempNum2[i+1] * (int)pow(10.0, l - i - 1);
      |                                                                                  ^~~
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main()
{
	int InpNum = 0, l = 0, j = 0;


	while(cin >> InpNum >> l)
	{
		int cnt = 0;
		int TempNum1[10] = { 0 };
		int TempNum3[25] = { 0 };

		int n = 0, tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;


		if(InpNum == 0 && l ==0){break;}

		tmp1 = InpNum;

		for(int i = 0; i < 10; i++)
		{
			tmp2 = (int)(tmp1 / 10) * 10;
			tmp3 = tmp1 - tmp2;

			cnt = cnt + 1;
			TempNum1[i] = tmp3;

			tmp1 = tmp1 / 10;
			if(tmp1 == 0){break;} 
		}


		for(int j=0; j < 20; j++)
		{

			int TempNum2[10] = { 0 };
			int n = 0;


			sort(TempNum1, TempNum1 + l);

			for(int i= l; i > 0; i--)
			{
				TempNum2[i] =  TempNum2[i] + TempNum1[n] - TempNum1[i - 1];

				if(TempNum2[i] < 0)
				{
					TempNum2[i] = TempNum2[i] + 10;
					TempNum2[i-1] = TempNum2[i-1] - 1;
				}

				n = n + 1;
			}

			for(int i=0; i<l; i++)
			{
				int h = 1;
				TempNum1[i] = TempNum2[i+1];
				TempNum3[j] = TempNum3[j] + TempNum2[i+1] * (int)pow(10.0, l - i - 1);
			}
		}


		cnt = 0;

		for(int i=0; i<20; i++)
		{
			if(cnt == 1){break;}

			for(int j=0; j<20; j++)
			{
				if(i == j){}
				else
				{
					if(TempNum3[j] == TempNum3[i] )
					{
						printf("%d %d %d\n", i+1, TempNum3[j], j-i);
						cnt = cnt + 1;
						break;
					}
				}
			}
		}
	}
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:82: error: 'pow' was not declared in this scope
   64 |                                 TempNum3[j] = TempNum3[j] + TempNum2[i+1] * (int)pow(10.0, l - i - 1);
      |                                                                                  ^~~
Language: C++

#include <iostream>
using namespace std;
int main(){
  int n,l,i,j,c,a,b,o;
  int k[6]={};
  int bu[30]={};
  cin >> n >> l;
  while(l!=0){
    c=1;
    bu[0]=n;
    int f=0;
    while(f==0){
      j=1;
      for(i=0;i<l-1;i++) j*=10;
      for(i=0;i<l;i++){
	k[i]=bu[c-1]%(j*10)/j;
	j/=10;
      }
      sort(k,k+l);
      a=0;j=1;
      for(i=0;i<l;i++) {
	a+=k[i]*j;
	j*=10;
      }
      b=0;j=1;
      for(i=0;i<l;i++) {
	b+=k[l-1-i]*j;
	j*=10;
      }
      bu[c]=a-b;
      for(i=0;i<c;i++) {
	if(bu[c]==bu[i]) {
	  f=1;
	  o=i;
	}
      }
      c++;
    }
    cout << o << " " <<  bu[c-1] << " " << c-1-o << endl;
    cin >> n >> l;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |       sort(k,k+l);
      |       ^~~~
      |       short
Language: C++

#include <iostream>
#include <algorhythm>
using namespace std;
int main(){
  int n,l,i,j,c,a,b,o;
  int k[6]={};
  int bu[30]={};
  cin >> n >> l;
  while(l!=0){
    c=1;
    bu[0]=n;
    int f=0;
    while(f==0){
      j=1;
      for(i=0;i<l-1;i++) j*=10;
      for(i=0;i<l;i++){
	k[i]=bu[c-1]%(j*10)/j;
	j/=10;
      }
      sort(k,k+l);
      a=0;j=1;
      for(i=0;i<l;i++) {
	a+=k[i]*j;
	j*=10;
      }
      b=0;j=1;
      for(i=0;i<l;i++) {
	b+=k[l-1-i]*j;
	j*=10;
      }
      bu[c]=a-b;
      for(i=0;i<c;i++) {
	if(bu[c]==bu[i]) {
	  f=1;
	  o=i;
	}
      }
      c++;
    }
    cout << o << " " <<  bu[c-1] << " " << c-1-o << endl;
    cin >> n >> l;
  }
  return 0;
}

Compiler output:
a.cc:2:10: fatal error: algorhythm: No such file or directory
    2 | #include <algorhythm>
      |          ^~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[])
{
    int a, l, cur, i;
    string str;
    bool flg;
    while (cin >> a >> l, a | l) {
        cur = 0;
        int res[20];
        flg = true;
        while (flg) {
            res[cur++] = a;
            str = to_string(a);
            for (i = str.size(); i < l; ++i)
                str += '0';
            sort(str.begin(), str.end());
            a = -stoi(str);
            reverse(str.begin(), str.end());
            a += stoi(str);
            for (i = 0; i < cur; ++i) {
                if (res[i] == a) {
                    flg = false;
                    break;
                }
            }
        }
        cout << i << ' ' << a << ' ' << cur - i << endl;
    }
    return 0;
}
taguchi@kMacBo

Compiler output:
a.cc:36:8: error: stray '@' in program
   36 | taguchi@kMacBo
      |        ^
a.cc:36:1: error: 'taguchi' does not name a type
   36 | taguchi@kMacBo
      | ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <map>

#define rep(a, b, c) for (long a = b; a < c; a++)
using namespace std;

int A, L;

int convert(vector<int> list) {
    int rtn = 0;
    rep(i, 0, list.size()) {
        rtn *= 10;
        rtn += list[list.size() - i - 1];
    }
    return rtn;
}

vector<int> convert(int num) {
    vector<int> rtn(L, 0);
    rep(i, 0, rtn.size()) {
        rtn[i] = num % 10;
        num /= 10;
    }
    return rtn;
}

int makeMax(vector<int> list) {
    sort(list.begin(), list.end());
    return convert(list);
}

int makeMin(vector<int> list) {
    sort(list.begin(), list.end(), greater<int>());
    return convert(list);
}

void saiki(map<int, int> rem, vector<int> list, int i) {
    int num = convert(list);
    if (rem.count(num) != 0) {
        cout << rem[num] << " " << num << " " << (i - rem[num]) << endl;
        return;
    }
    rem.insert(map<int, int>::value_type(num, i));
    saiki(
            rem,
            convert(makeMax(list) - makeMin(list)),
            i + 1
    );
}

int main() {
    while(true) {
        cin >> A >> L;
        if (A == 0 && L == 0) {
            break;
        }
        saiki(
                map<int, int>(),
                convert(A),
                0
        );
    }
    return 0;
}

Compiler output:
a.cc: In function 'int makeMax(std::vector<int>)':
a.cc:29:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |     sort(list.begin(), list.end());
      |     ^~~~
      |     short
a.cc: In function 'int makeMin(std::vector<int>)':
a.cc:34:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   34 |     sort(list.begin(), list.end(), greater<int>());
      |     ^~~~
      |     short
Language: C++

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

int vtoi(vector<int> v){
    int n=0;
    for(int i=0;i<v.size();++i){
        n += v[i] * pow(10, i);
    }
    return n;
}

vector<int> itov(int n, int L){
    vector<int> v;
    for(int i=0;i<L;++i){
        v.push_back(n%10);
        n = n / 10;
    }
    return v;
}

int main(){
    while(true){
        vector<int> a;
        int L;
        int n;
        int i, j;
        int x, y;
        cin >> n >> L;
        if(!(n||L)) break;
        a.push_back(n);
        for(i=0;;++i){
            vector<int> v = itov(a.back(), L);
            sort(v.begin(), v.end(), greater<int>());
            x = vtoi(v);
            sort(v.begin(), v.end());
            y = vtoi(v);
            for(j=0;j<a.size();++j){
                if(a[j] == x-y) break;
            }
            if(a[j] == x-y) break;
            a.push_back(x-y);
        }
        cout << j << ' ';
        cout << -(x-y) << ' ';
        cout << i-j+1 << endl;
    }
}

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

/*
 * B.cpp
 *
 *  Created on: 2017/06/18
 *      Author: aihara
 */

#include<bits/stdc++.h>
#define MYDEBUG
#ifdef MYDBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#else
#define dbp(x)
#endif
#define ll long long
#define rep(i,from,to) for(int i=from; i<to; ++i)
#define REP(i,from,to) for(int i=from; i<=to; ++i)

using namespace std;

const int MAX_N = 1000100;
bool vis[MAX_N];
int num[MAX_N];
string s;
int n;
void solve() {
	while (cin >> s >> n, n) {
		memset(vis, 0, sizeof(vis));
		memset(num, 0, sizeof(num));
		int zeroes = max(0, n - (int) s.size());
		s += string(zeroes, '0');
		int i = 0;
		vis[atoi(s.c_str())] = true;
		num[atoi(s.c_str())] = i;
		i++;
		while (true) {
			string big = s, small = s;
			sort(big.rbegin(), big.rend());
			sort(small.begin(), small.end());
//			cout << "big: " << big << endl;
//			cout << "sma: " << small << endl;
			int bigN = atoi(big.c_str());
			int smaN = atoi(small.c_str());
			int diff = bigN - smaN;
			char nextS[10];
			itoa(diff, nextS, 10);
			s = nextS;
			zeroes = max(0, n - (int) s.size());
			s += string(zeroes, '0');
//			cout << "diff: " << diff << endl << endl;
			if (diff < 0) {
				cout << "ERROR" << endl;
				return;
			}
			if (!vis[diff]) {
				vis[diff] = true;
				num[diff] = i;
			} else { //found duplicate
				int j = num[diff];
				printf("%d %d %d\n", j, diff, i - j);
				break;
			}
			i++;
		}
	}
}

int main() {
	solve();
//	char str[100];
//	itoa(123, str, 10);
//	cout << str << endl;
//	string st = str;
//	cout << st << endl;
//	cout << st.size() << endl;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:46:25: error: 'itoa' was not declared in this scope
   46 |                         itoa(diff, nextS, 10);
      |                         ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<string.h>
#include<vector>
#include<cstdio>

using namespace std;

template < typename T > std::string to_string(const T& n)
{
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

int main() {
	while (1) {
		int l;
		string str;
		cin >> str >> l;
		if (l == 0)break;

		for (int i = 0; i < l - str.size(); i++)str.insert(str.begin(), '0');
		
		typedef string Str;
		vector<Str> ai;
		ai.push_back(str);

		int n = 1;
		while (1) {
			bool bre = false;
			string tstr = ai[n - 1];
			sort(tstr.begin(), tstr.end(), greater<int>());
			int max = atoi(tstr.c_str());
			sort(tstr.begin(), tstr.end());
			int min = atoi(tstr.c_str());
			int d = max - min;
			//cout <<max<<'-'<<min<<'='<< d << endl;

			for (int i = 0; i < n; i++) {
				int comp = atoi(ai[i].c_str());
				//cout << comp << endl;
				if (d == comp) {
					cout << i << ' ' << d << ' ' << n - i << endl;
					bre = true;
					break;
				}
			}

			if (bre)break;
			else {
				string pstr = to_string(d);
				for (int i = 0; i < l - pstr.size(); i++)pstr.insert(pstr.begin(), '0');
				ai.push_back(pstr);
				n++;
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'std::string to_string(const T&)':
a.cc:13:28: error: 'stm' has incomplete type
   13 |         std::ostringstream stm;
      |                            ^~~
In file included from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/iosfwd:106:11: note: declaration of 'std::ostringstream' {aka 'class std::__cxx11::basic_ostringstream<char>'}
  106 |     class basic_ostringstream;
      |           ^~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int vals[6];
int a0, l;

int update(int ai) {
    for (int i = 0; i < l; ++i) {
        vals[i] = ai % 10;
        ai /= 10;
    }
    sort(vals, vals + l);
    int max = 0;
    int min = 0;
    int d = 1;
    for (int i = 0; i < l; ++i) {
        max += d * vals[i];
        min += d * vals[l - i - 1];
        d *= 10;
    }

    return max - min;
}

int main() {
    while (1) {
        cin >> a0 >> l;
        if (a0 == 0 && l == 0) break;

        vector<int> v;
        v.push_back(a0);

        int ai = a0;
        bool found = false;
        while(1) {
            ai = update(ai);
            //cout << ai << endl;
            for (int j = 0; j < v.size(); ++j) {
                if (ai == v[j]) {
                    cout << j << " " << ai << " "<< v.size() - j << endl;
                    found = true;
                    break;
                }
            }
            v.push_back(ai);
            if (found) break;
        }
    }
}

Compiler output:
a.cc: In function 'int update(int)':
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |     sort(vals, vals + l);
      |     ^~~~
      |     short
Language: C++

#include<iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <cstring>

using namespace std;

void solve(int a, int L) {
	vector<int> d;	
	d.push_back(a);

	for(int i = 1; ; i++) {
		char tmp[7];

		int size = strlen(itoa(a, tmp, 10));
		tmp[L] = '\0';
		for(int j = size; j < L; j++) {
			tmp[j] = '0';
		}
			
		sort(tmp, tmp+L);
		int x = atoi(tmp);
		reverse(tmp, tmp+L);
		int y = atoi(tmp);
	
		a = y-x;
		for(int j = 0; j < d.size(); j++) {
			if(a != d[j]) continue;

			cout << j << " " << a << " " << i - j << endl;
			return;
		}
		d.push_back(a);
	}

}

int main(void) {
	
	while(true) {
		int a, L;

		cin >> a >> L;

		if(a == 0 && L == 0) return 0;

		solve(a, L);
	}

	return 0;
}

Compiler output:
a.cc: In function 'void solve(int, int)':
a.cc:21:35: error: 'itoa' was not declared in this scope
   21 |                 int size = strlen(itoa(a, tmp, 10));
      |                                   ^~~~
Language: C++

#include<iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cstdio>

using namespace std;

void solve(int a, int L) {
	vector<int> d;	
	d.push_back(a);

	for(int i = 1; ; i++) {
		char tmp[7];

		int size = strlen(itoa(a, tmp, 10));
		tmp[L] = '\0';
		for(int j = size; j < L; j++) {
			tmp[j] = '0';
		}
			
		sort(tmp, tmp+L);
		int x = atoi(tmp);
		reverse(tmp, tmp+L);
		int y = atoi(tmp);
	
		a = y-x;
		for(int j = 0; j < d.size(); j++) {
			if(a != d[j]) continue;

			cout << j << " " << a << " " << i - j << endl;
			return;
		}
		d.push_back(a);
	}

}

int main(void) {
	
	while(true) {
		int a, L;

		cin >> a >> L;

		if(a == 0 && L == 0) return 0;

		solve(a, L);
	}

	return 0;
}

Compiler output:
a.cc: In function 'void solve(int, int)':
a.cc:22:35: error: 'itoa' was not declared in this scope
   22 |                 int size = strlen(itoa(a, tmp, 10));
      |                                   ^~~~
Language: C++

#include<iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stdlib.h>

using namespace std;

void solve(int a, int L) {
	vector<int> d;	
	d.push_back(a);

	for(int i = 1; ; i++) {
		char tmp[7];

		int size = strlen(itoa(a, tmp, 10));
		tmp[L] = '\0';
		for(int j = size; j < L; j++) {
			tmp[j] = '0';
		}
			
		sort(tmp, tmp+L);
		int x = atoi(tmp);
		reverse(tmp, tmp+L);
		int y = atoi(tmp);
	
		a = y-x;
		for(int j = 0; j < d.size(); j++) {
			if(a != d[j]) continue;

			cout << j << " " << a << " " << i - j << endl;
			return;
		}
		d.push_back(a);
	}

}

int main(void) {
	
	while(true) {
		int a, L;

		cin >> a >> L;

		if(a == 0 && L == 0) return 0;

		solve(a, L);
	}

	return 0;
}

Compiler output:
a.cc: In function 'void solve(int, int)':
a.cc:23:35: error: 'itoa' was not declared in this scope
   23 |                 int size = strlen(itoa(a, tmp, 10));
      |                                   ^~~~
Language: C++

#include<iostream>
using namespace std;
int b[100000];
int change(int x,int y)
{
int f=x,k=0;
int a[6],q=1,flag;
for(int i=1;i<y;i++)
   q*=10;
for(int i=q;i>0;i=i/10){a[k]=f/i;k++;f=f%i;}     
for(int i=0;i<y;i++)
   for(int j=i+1;j<y;j++)
      {
      if(a[i]<a[j]){flag=a[i];a[i]=a[j];a[j]=flag;}     
      }
int maxn=0,minn=0,g;
g=q;
for(int i=0;i<y;i++)
   {
   maxn+=a[i]*g;
   minn+=a[y-i-1]*g;
   g=g/10;
   }
return maxn-minn;
}
int main()
{
int N,L,flag,ii,jj;
while(cin>>N>>L)
   {
   if(N==0&&L==0) break;
   memset(b,-1,sizeof(b));
   int z=N;
   flag=0;
   b[0]=N;
   for(int i=1;i<=100000;i++)
      {
      b[i]=change(z,L);
      z=b[i];
      for(int j=0;j<i;j++)
         {
         if(b[j]==b[i]) {flag=1;ii=i;jj=j;break;}
         }     
      if(flag==1) break;
      }            
   cout<<jj<<" "<<b[jj]<<" "<<ii-jj<<endl;
   }    
return 0;   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:4: error: 'memset' was not declared in this scope
   32 |    memset(b,-1,sizeof(b));
      |    ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include<iostream>
#include<string>
#include<map>
#include<set>
using namespace std;

void simulate(string s, int l){
  string L, S;
  set<string> M;
  map<string, int> I;
  int b = 1;
  while( s.size() < l ) s = "0" + s;
  for ( int i = 0; i < l-1; i++ ) b *= 10;
  
  for ( int cur = 0; ; cur++ ){
    M.insert(s);
    I[s] = cur;
    L = S = s;
    sort(L.begin(), L.end(), greater<char>());
    sort(S.begin(), S.end());
    int x = atoi(L.c_str()) - atoi(S.c_str());
    for ( int i = 0, p = b; i < l; i++, p /= 10 ){
      s[i] = '0' + x/p;
      x %= p;
    }
    if ( M.find(s) != M.end() ) {
      cout << I[s] << " " << atoi(s.c_str()) << " " << cur - I[s]+1<< endl;
      break;
    }
  }
}

main(){
  string s;
  int l;
  while(1){
    cin >> s >> l;
    if ( s == "0" && l == 0 ) break;
    simulate(s, l);
  }
}

Compiler output:
a.cc: In function 'void simulate(std::string, int)':
a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |     sort(L.begin(), L.end(), greater<char>());
      |     ^~~~
      |     short
a.cc: At global scope:
a.cc:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main(){
      | ^~~~
Language: C++

//============================================================================
// Name        : AOJ1180.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <algorithm>
using namespace std;

void sortASC(int a[], int b[], int n) {
	int i, j, min_i, tmp;
	for (i = 0; i < n; i++)
		b[i] = a[i];
	for (i = 0; i < n - 1; i++) {
		min_i = i;
		for (j = i + 1; j < n; j++) {
			if (b[min_i] > b[j])
				min_i = j;
		}
		if (min_i != i) {
			tmp = b[i];
			b[i] = b[min_i];
			b[min_i] = tmp;
		}
	}
	return;
}

void sortDSC(int a[], int b[], int n) {
	int i, j, max_i, tmp;
	for (i = 0; i < n; i++)
		b[i] = a[i];
	for (i = 0; i < n - 1; i++) {
		max_i = i;
		for (j = i + 1; j < n; j++) {
			if (b[max_i] < b[j])
				max_i = j;
		}
		if (max_i != i) {
			tmp = b[i];
			b[i] = b[max_i];
			b[max_i] = tmp;
		}
	}
	return;
}

void sub(int a[], int b[], int c[], int n) {
	int i;
	for (i = 0; i < n; i++)
		c[i] = a[i];
	for (i = n - 1; i > 0; i--) {
		c[i] = c[i] - b[i];
		if (c[i] < 0) {
			c[i - 1]--;
			c[i] += 10;
		}
	}
	c[0] -= b[0];
	return;
}

int main() {
	int flag, inp, i, j, k, L, count, *a[21], *aA, *aD;
	scanf("%d %d", &inp, &L);
	while (inp != 0 || L != 0) {
		for (i = 0; i <= 20; i++)
			a[i] = (int *) malloc(sizeof(int) * L);
		aA = (int *) malloc(sizeof(int) * L);
		aD = (int *) malloc(sizeof(int) * L);
		for (i = L - 1; i >= 0; i--) {
			a[0][i] = inp % 10; /* 入力された値を配列形式にして代入 */
			inp /= 10;
		}
		sortDSC(a[0], aA, L);
		sortASC(a[0], aD, L);
		flag = 0;
		for (i = 1; flag == 0 && i <= 20; i++) {
			sub(aA, aD, a[i], L);
			sortDSC(a[i], aA, L);
			sortASC(a[i], aD, L);
			for (j = 0; j < i && flag == 0; j++) {
				count = 0;
				for (k = 0; k < L; k++) {
					if (a[i][k] == a[j][k])
						count++; /*一致した配列の数を数える*/
				}
				if (count == L)
					flag = 1;
			}
		}
		i--;
		j--;
		printf("%d ", j);
		count = 0;
		for (k = 0; k < L; k++) {
			if (a[i][k] == 0)/* ０の数を数える */
				count++;
		}
		if (count == L)
			printf("0");
		else {
			for (k = 0; k < L; k++) {
				if (a[i][k] != 0) {
					while (k < L) {
						printf("%d", a[i][k]);
						k++;
					}
				}
			}

		}
		printf(" %d\n", i - j);
		scanf("%d %d", &inp, &L);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:9: error: 'scanf' was not declared in this scope
   67 |         scanf("%d %d", &inp, &L);
      |         ^~~~~
a.cc:96:17: error: 'printf' was not declared in this scope
   96 |                 printf("%d ", j);
      |                 ^~~~~~
a.cc:10:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    9 | #include <algorithm>
  +++ |+#include <cstdio>
   10 | using namespace std;
Language: C++

#include <iostream>
#include <sstream>
#include <map>
#include <algorithm>
using namespace std;

int toInt(const string &s) {
	istringstream is(s);
	int N; is >> N;
	return N;
}

string toString(int num, int L) {
	int len = log10(num) + 1;
	ostringstream os;
	for(int i = 0; i < L - len; i++)
		os << "0";
	os << num;
	return os.str();
}

int main() {
	for(int a, l; cin >> a >> l, a || l;) {
		map<int, int> m;
		m[a] = 0;
		int ansi = -1, ansj = -1;
		int ans = -1;
		for(int i = 1; i <= 20; i++) {
			string s = toString(a, l);
			sort(s.begin(), s.end());
			int minv = toInt(s);
			sort(s.rbegin(), s.rend());
			int maxv = toInt(s);
			int next = maxv - minv;
			if(m.count(next)) {
				ansj = m[next];
				ansi = i;
				ans = next;
				break;
			}
			else {
				m[next] = i;
			}
			a = next;
		}
		cout << ansj << " " << ans << " " << ansi - ansj << endl;
	}
}

Compiler output:
a.cc: In function 'std::string toString(int, int)':
a.cc:14:19: error: 'log10' was not declared in this scope
   14 |         int len = log10(num) + 1;
      |                   ^~~~~
Language: C++

#include <iostream>
#include <cstdio>

using namespace std;

const int MAX = 1000000;

int a0, L;
int x[6];

void solve() {
	int data[MAX] = {0};
	int i=0, a=a0;
	while (data[a] == 0) {
		data[a] = i;
		for (int j=0; j<L; j++) {
			x[j] = a%10;
			a/=10;
		}
	sort(x, x+L);
	int max=0, min=0, c=1;
	for (int j=0; j<L; j++) {
	       max += x[j] *c;
	       min += x[L-j-1] *c;
	       c*=10;
	  }
	  a = max-min;
	  i++;
     }
     cout << data[a] << " " << a << " " << (i - data[a]) << endl;
}

int main() {
	while (cin >> a0 >> L, L) solve();
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:20:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |         sort(x, x+L);
      |         ^~~~
      |         short
Language: C++

while true
  a = []
  a[0], l = gets.split.map(&:to_i)
  break if l == 0
  a[0] = "%0#{l}d" % a[0]
  (1..25).each do |i|
    a[i] = "%0#{l}d"  % (a[i-1].split(//).sort.reverse.join.to_i - a[i-1].split(//).sort.join.to_i)
    if a.index(a[i]) < i
      puts "#{a.index(a[i])} #{a[i]} #{i - a.index(a[i])}"
      break
  end
end

Compiler output:
a.cc:6:4: error: too many decimal points in number
    6 |   (1..25).each do |i|
      |    ^~~~~
a.cc:1:1: error: expected unqualified-id before 'while'
    1 | while true
      | ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main(){
	int L, b;
	while( 1 ){
		vector<int> a;
		cin >> b >> L;
		a.push_back(b);
		if( a[0] == 0 && L == 0 ) break;
		int i = 0;
		while( i < 20 ){
			vector<int> rank;
			int max = 0, min = 0;
			int number = a[i];
			cout << number << ' ';
			for( int j = 0; j < L; j++ ){
				rank.push_back(number % 10);
				number /= 10;
			}
			sort( rank.begin(), rank.end() );
			for( int j = 0; j < L; j++ ){
				max += rank[j] * pow(10.0,(double)j);
			}
			sort( rank.begin(), rank.end(), greater<int>() );
			for( int j = 0; j < L; j++ ){
				min += rank[j] * pow(10.0,(double)j);
			}
			i++;
			a.push_back(max - min);		//a[i] = max -min;
			cout << max << ' ' << min << ' ' << a[i] << endl;
			for( int j = 0; j < i; j++ ){
				if( a[j] == a[i] ){
					cout << j << ' ' << a[i] << ' ' << i - j << endl;
					goto end;
				}
			}
			rank.clear();
		}
	end:
		a.clear();
	}
}

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

    }


  
    sa = 100;
    tmp =0;
    for(j = 0; j <= 19 ;j++){
      if(tmp ==1) break;
      for(i = j+1;i <= 20 ;i++){	
	if(a[j] == a[i]){
	  tmp = 1;
	  sa = i-j;
	  ansi = i;
	  ansj = j;
	  break;
	}
      }	   
    }
  
    cout << j-1 << " " << a[ansj] << " " << i-j+1 << endl;
 
  }
  return 0;
}

  

Compiler output:
a.cc:1:5: error: expected declaration before '}' token
    1 |     }
      |     ^
a.cc:5:5: error: 'sa' does not name a type
    5 |     sa = 100;
      |     ^~
a.cc:6:5: error: 'tmp' does not name a type
    6 |     tmp =0;
      |     ^~~
a.cc:7:5: error: expected unqualified-id before 'for'
    7 |     for(j = 0; j <= 19 ;j++){
      |     ^~~
a.cc:7:16: error: 'j' does not name a type
    7 |     for(j = 0; j <= 19 ;j++){
      |                ^
a.cc:7:25: error: 'j' does not name a type
    7 |     for(j = 0; j <= 19 ;j++){
      |                         ^
a.cc:20:5: error: 'cout' does not name a type
   20 |     cout << j-1 << " " << a[ansj] << " " << i-j+1 << endl;
      |     ^~~~
a.cc:22:3: error: expected declaration before '}' token
   22 |   }
      |   ^
a.cc:23:3: error: expected unqualified-id before 'return'
   23 |   return 0;
      |   ^~~~~~
a.cc:24:1: error: expected declaration before '}' token
   24 | }
      | ^
Language: C++

#include <map>
#include <algorithm>
#include <functional>
#include <sstream>

using namespace std;

int l;

string exchange(const string s)
{
    stringstream s1, s2, ret;
    string tmp;
    int a, b;

    tmp = s;
    sort(tmp.begin(), tmp.end());
    s1 << tmp;
    reverse(tmp.begin(), tmp.end());
    s2 << tmp;
    
    s1 >> a;
    s2 >> b;
    a = b - a;
    ret << a;

    return ret.str();
 }

int main()
{
    string s;

    while (cin >> s >> l, s != "0" || l) {
        map<string, int> m;

        while (s.size() < l)
            s = '0' + s;
        m[s] = 0;

        for (int i = 1; ; i++) {
            s = exchange(s);

            string tmp = s;
            while (tmp.size() < l)
                tmp = '0' + tmp;

            if (m.count(tmp) != 0) {
                cout << m[tmp] << " " << s << " " << i - m[tmp] << endl;
                break;
            }
            else
                m[tmp] = i;
            s = tmp;
        }
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:12: error: 'cin' was not declared in this scope
   34 |     while (cin >> s >> l, s != "0" || l) {
      |            ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <sstream>
  +++ |+#include <iostream>
    5 | 
a.cc:49:17: error: 'cout' was not declared in this scope
   49 |                 cout << m[tmp] << " " << s << " " << i - m[tmp] << endl;
      |                 ^~~~
a.cc:49:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <cstdlib>

#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) (v).begin(), (v).end()
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> P;
typedef vector<P> vp;

void pp(vi v){
	rep(i, v.size()){
		cout << v[i] << ' ';
	}
	cout << endl;
}

void pp(vector<string> v){
	rep(i, v.size()){
		cout << v[i] << endl;
	}
}

void pp(int (*v)[20], int size = 20){
	rep(i, size){
		rep(j, size){
			cout << v[i][j] << ' ';
		}
		cout << endl;
	}
}

void pp(char (*v)[80], int size = 30){
	rep(i, size){
		rep(j, size){
			cout << v[i][j];
		}
		cout << endl;
	}
}


int check(vector<string> vs, string s){
	rep(i, vs.size()){
		if(vs[i] == s)return i;
	}
	return -1;
}


int main(){
	int a, L;
	char buf[100];
//	freopen( "b.out", "w", stdout);
	
	while(cin >> a >> L){
		if(!a && !L)break;
		itoa(a, buf, 10);
		string s = buf;
		while(s.size() < L){ // 先頭を0埋め
			s = '0' + s;
		}
		vector<string> v;

		v.push_back(s); // sortして
		while(true){
			sort(all(s));	// 最小
			string t = s;
			reverse(all(t));	// 最大
			s = itoa(atoi(t.c_str())-atoi(s.c_str()), buf, 10);	// 最大-最小
			while(s.size() < L){ // 先頭を0埋め
				s = '0' + s;
			}
			int i = check(v, s);
			if( i != -1){// 過去に出てきてないかチェック
//				cout << "***";
				cout << i << ' ' <<  atoi(s.c_str()) << ' ' << v.size()-i << endl;
				break;
			}
			v.push_back(s);
		}
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:17: error: 'itoa' was not declared in this scope
   70 |                 itoa(a, buf, 10);
      |                 ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <stdlib.h>

#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) (v).begin(), (v).end()
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> P;
typedef vector<P> vp;

void pp(vi v){
	rep(i, v.size()){
		cout << v[i] << ' ';
	}
	cout << endl;
}

void pp(vector<string> v){
	rep(i, v.size()){
		cout << v[i] << endl;
	}
}

void pp(int (*v)[20], int size = 20){
	rep(i, size){
		rep(j, size){
			cout << v[i][j] << ' ';
		}
		cout << endl;
	}
}

void pp(char (*v)[80], int size = 30){
	rep(i, size){
		rep(j, size){
			cout << v[i][j];
		}
		cout << endl;
	}
}


int check(vector<string> vs, string s){
	rep(i, vs.size()){
		if(vs[i] == s)return i;
	}
	return -1;
}


int main(){
	int a, L;
	char buf[100];
//	freopen( "b.out", "w", stdout);
	
	while(cin >> a >> L){
		if(!a && !L)break;
		itoa(a, buf, 10);
		string s = buf;
		while(s.size() < L){ // 先頭を0埋め
			s = '0' + s;
		}
		vector<string> v;

		v.push_back(s); // sortして
		while(true){
			sort(all(s));	// 最小
			string t = s;
			reverse(all(t));	// 最大
			s = itoa(atoi(t.c_str())-atoi(s.c_str()), buf, 10);	// 最大-最小
			while(s.size() < L){ // 先頭を0埋め
				s = '0' + s;
			}
			int i = check(v, s);
			if( i != -1){// 過去に出てきてないかチェック
//				cout << "***";
				cout << i << ' ' <<  atoi(s.c_str()) << ' ' << v.size()-i << endl;
				break;
			}
			v.push_back(s);
		}
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:17: error: 'itoa' was not declared in this scope
   70 |                 itoa(a, buf, 10);
      |                 ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <cstdlib>

#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) (v).begin(), (v).end()
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> P;
typedef vector<P> vp;

void pp(vi v){
	rep(i, v.size()){
		cout << v[i] << ' ';
	}
	cout << endl;
}

void pp(vector<string> v){
	rep(i, v.size()){
		cout << v[i] << endl;
	}
}

void pp(int (*v)[20], int size = 20){
	rep(i, size){
		rep(j, size){
			cout << v[i][j] << ' ';
		}
		cout << endl;
	}
}

void pp(char (*v)[80], int size = 30){
	rep(i, size){
		rep(j, size){
			cout << v[i][j];
		}
		cout << endl;
	}
}


int check(vector<string> vs, string s){
	rep(i, vs.size()){
		if(vs[i] == s)return i;
	}
	return -1;
}


int main(){
	int a, L;
	char buf[100];
//	freopen( "b.out", "w", stdout);
	
	while(cin >> a >> L){
		if(!a && !L)break;
		itoa(a, buf, 10);
		string s = buf;
		while(s.size() < L){ // 先頭を0埋め
			s = '0' + s;
		}
		vector<string> v;

		v.push_back(s); // sortして
		while(true){
			sort(all(s));	// 最小
			string t = s;
			reverse(all(t));	// 最大
			sprintf(buf, "%d", t.c_str())-atoi(s.c_str()));
			s = buf;	// 最大-最小
			while(s.size() < L){ // 先頭を0埋め
				s = '0' + s;
			}
			int i = check(v, s);
			if( i != -1){// 過去に出てきてないかチェック
//				cout << "***";
				cout << i << ' ' <<  atoi(s.c_str()) << ' ' << v.size()-i << endl;
				break;
			}
			v.push_back(s);
		}
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:17: error: 'itoa' was not declared in this scope
   70 |                 itoa(a, buf, 10);
      |                 ^~~~
a.cc:82:70: error: expected ';' before ')' token
   82 |                         sprintf(buf, "%d", t.c_str())-atoi(s.c_str()));
      |                                                                      ^
      |                                                                      ;
Language: C++

#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

char a[8];
int L;
vector<int> appered;

void init() {
	appered.clear();
}

bool input() {
	scanf("%s %d", a, &L);
	if(!atoi(a) && !L)
		return false;
	return true;
}

void solve() {
	int m, M;

	for(int i = strlen(a); i < L; i++)
		a[i] = '0';
	a[L] = '\0';

	sort(a, a + L);
	m = atoi(a);
	appered.push_back(m);

	while(1) {
		for(int i = strlen(a); i < L; i++)
			a[i] = '0';
		a[L] = '\0';

		sort(a, a + L);
		m = atoi(a);

		char tmp[8];
		for(int i = 0; i < L; i++) {
			tmp[L - i - 1] = a[i];
		}
		tmp[L] = '\0';
		M = atoi(tmp);

		for(int i = 0; i < appered.size(); i++) {
			if(appered[i] == M - m) {
				cout << i << " " << M - m << " " << appered.size() - i << endl;
/*
				for(int j = 0; j < appered.size(); j++) {
					cout << "appered[" << j << "] : " << appered[j] << endl;
				}
// */
				return;
			}
		}

		appered.push_back(M - m);
		sprintf(a, "%d", M - m);
	}
}

int main() {
	while(init(), input()) {
		solve();
	}
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:27:21: error: 'strlen' was not declared in this scope
   27 |         for(int i = strlen(a); i < L; i++)
      |                     ^~~~~~
a.cc:7:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <functional>
  +++ |+#include <cstring>
    7 | using namespace std;
a.cc:36:29: error: 'strlen' was not declared in this scope
   36 |                 for(int i = strlen(a); i < L; i++)
      |                             ^~~~~~
a.cc:36:29: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <string>

using namespace std;
const static int L_MAX = 7;

string rmn_toString( int n, int l ) {
  ostringstream oss;
  oss << n;
  string s = oss.str();
  for( int i = s.size(); i < l; i++ ) {
    s = "0" + s; 
  }
  return s;
}

int rmn_parseInt( string s ) {
  int len = s.size();
  int i;
  for( i = 0; i < len; i++ ) {
    if( s[ i ] != 0 ) { break; }
  }
  if( i == len ) { return 0; }

  int r;
  sscanf( s.substr( i ).c_str(), "%d", &r );

  return r;
}

int main() {
  while( 1 ) {
    int ai, l;
    int i = 0, j;
    map<int, int> dict;
    cin >> ai >> l;
    if( !ai && !l ) { return EXIT_SUCCESS; }

    dict[ ai ] = i;
    while( 1 ) {
      string as;
      as = rmn_toString( ai, l );
      sort( as.begin(), as.end() );

      string asi = as;
      reverse( asi.begin(), asi.end() );

      ai = rmn_parseInt( asi ) - rmn_parseInt( as );
      i++;
      if( dict.find( ai ) != dict.end() ) { break; }
      dict[ ai ] = i; 
    }
    
    cout << dict[ ai ] << " " << ai << " " << ( i - dict[ ai ] ) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:7: error: 'sort' was not declared in this scope; did you mean 'short'?
   47 |       sort( as.begin(), as.end() );
      |       ^~~~
      |       short
a.cc:50:7: error: 'reverse' was not declared in this scope
   50 |       reverse( asi.begin(), asi.end() );
      |       ^~~~~~~
Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>

using namespace std;

inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}

int main(int argc, char const *argv[])
{
	int a,L;
	int max,min;
	string s;
	vector<int>::iterator it;
	int i,j;

	while(1){
		cin>>a>>L;
		if(a+L==0) break;

		vector<int> v;
		v.push_back(a);

		for(i=1;;i++){

			s=toString<int>(a);

			for(int i2=0;i2<L-s.size();i2++){
				s+='0';
			}
			
			sort(s.begin(), s.end());
			min=toInt(s);
			sort(s.begin(), s.end(),greater<int>());
			max=toInt(s);
			
			a=max-min;
			it=find(v.begin(), v.end(),a);
			if(it!=v.end()) break;

			v.push_back(a);

		}
		j=distance(v.begin(),it);
		cout<<j<<" "<<a<<" "<<i-j<<endl;


	}

	return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:35:25: error: 'sort' was not declared in this scope; did you mean 'short'?
   35 |                         sort(s.begin(), s.end());
      |                         ^~~~
      |                         short
a.cc:41:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   41 |                         it=find(v.begin(), v.end(),a);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:41:32: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   41 |                         it=find(v.begin(), v.end(),a);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<strstream>
#include<utility>
#include<cstdio>
#include<vector>
#include<cmath>
#include<climits>
#include<map>
#include<string>
#include<sstream>

using namespace std;

#define mp make_pair
#define rep(i,n) for( int i = 0; i < n; i++ )
typedef vector<int,int> V;
typedef long long int ll;


int StringToInt(string str)
{
    istrstream istr(str.data());
    int i;
    istr>>i;
    return i;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

int main()
{
	string a;
	int L;

	while( cin >> a >> L, L )
	{
		if( a == "0" ) 
		{
			puts("0 0 1");
			continue;
		}
		map< string,int > container;
		for( int i = 1; i <= 20; i++ )
		{
			while( a.size() < L )
			a = '0' + a;
			int k;
			sort( a.begin() , a.end() , greater<int>() );
			k = StringToInt(a);
			sort( a.begin() , a.end() );
			k -= StringToInt(a);
			a = IntToString(k); 
			if( !container.insert( mp(a,i) ).second )
			{
				map< string,int >::iterator itr = container.begin();
				itr = container.find(a);
				cout << itr->second << " " << k << " " << i - itr->second << endl; 
				break;
			}
		}

	}
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/backward/strstream:50,
                 from a.cc:2:
/usr/include/c++/14/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
   32 | #warning \
      |  ^~~~~~~
a.cc: In function 'int main()':
a.cc:53:25: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   53 |                         sort( a.begin() , a.end() , greater<int>() );
      |                         ^~~~
      |                         sqrt
Language: C++

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cstdlib>
#include <functional>
using namespace std;


string IntToString(int number) {
    stringstream ss;
    ss << number;
    return ss.str();
}

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<int> nums, numList;
        nums.push_back(n);
        numList.push_back(n);
        string s = IntToString(n);
        while(1){
            for(int i=0; i < s.size()-m; i++) s += "0";
            sort(s.begin(), s.end());
            int minNum = atoi(s.c_str());
            sort(s.begin(), s.end(), greater<int>());
            int maxNum = atoi(s.c_str());

            n = maxNum - minNum;
            if(binary_search(nums.begin(), nums.end(), n)){numList.push_back(n); break;}
            else {nums.push_back(n); numList.push_back(n);}
            s = IntToString(n);
            sort(nums.begin(), nums.end());
        }
        int firstPoint=0, secondPoint=0;
        bool isFirst = true;
        for(int i=0; i < numList.size(); i++){
            if(numList[i] == n && isFirst){firstPoint = i; isFirst = false;}
            else if(numList[i] == n && !isFirst){secondPoint = i; break;}
        }
        cout << secondPoint-1 << " " << n << " " << secondPoint-firstPoint << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: 'sort' was not declared in this scope; did you mean 'short'?
   25 |             sort(s.begin(), s.end());
      |             ^~~~
      |             short
a.cc:31:16: error: 'binary_search' was not declared in this scope
   31 |             if(binary_search(nums.begin(), nums.end(), n)){numList.push_back(n); break;}
      |                ^~~~~~~~~~~~~