criyle/codenet-compile-errors huggingface dataset:
Language: Java


#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <algorithm>

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while( 1 ) {
		stringstream a_0;
		int a,L;
		cin >> a >> L;
		if( a == 0 && L == 0 ) break;
		a_0 << a;
		vector<int> v;
		

		while(1) {
			vector<char> ch[2];
			//頭を埋める
			for(int i = 0; i < L - a_0.str().length(); i++)
				a_0 << 0;

			int k = atoi(a_0.str().c_str());

			int ans[3] = {-1,0,0};
			for(int i = 0; i < v.size(); i++) {
				if( k == v.at(i) ) {
					ans[0] = i;
					ans[1] = k;
					ans[2] = v.size() - i;
				}
			}
			if(ans[0] != -1) {
				cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
				break;
			}

			v.push_back(atoi(a_0.str().c_str()));
			//桁を取得
			for(int i = 0; i < a_0.str().length(); i++)
				ch[0].push_back(a_0.str().at(i));
			
			sort( ch[0].begin(), ch[0].end() );

			for(int i = a_0.str().length() - 1; i >= 0; i--)
				ch[1].push_back(ch[0].at(i));

			string s[2];
			for(int i = 0; i < a_0.str().length(); i++) {
				s[0] += ch[0].at(i);
				s[1] += ch[1].at(i);
			}

			int d = atoi(s[1].c_str()) - atoi(s[0].c_str());

			a_0.clear();
			a_0.str("");
			a_0 << d;

		}
	}

	//while(1){}
	return 0;
}

Compiler output:
Main.java:2: error: illegal character: '#'
#include <iostream>
^
Main.java:3: error: illegal character: '#'
#include <stdio.h>
^
Main.java:4: error: illegal character: '#'
#include <string>
^
Main.java:5: error: illegal character: '#'
#include <sstream>
^
Main.java:6: error: illegal character: '#'
#include <vector>
^
Main.java:7: error: illegal character: '#'
#include <stdlib.h>
^
Main.java:8: error: illegal character: '#'
#include <math.h>
^
Main.java:9: error: illegal character: '#'
#include <list>
^
Main.java:10: error: illegal character: '#'
#include <algorithm>
^
Main.java:20: error: not a statement
		cin >> a >> L;
		         ^
Main.java:22: error: not a statement
		a_0 << a;
		    ^
Main.java:30: error: not a statement
				a_0 << 0;
				    ^
Main.java:34: error: not a statement
			int ans[3] = {-1,0,0};
			              ^
Main.java:43: error: not a statement
				cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
				                                                 ^
Main.java:67: error: not a statement
			a_0 << d;
			    ^
Main.java:14: error: unnamed classes are a preview feature and are disabled by default.
int main(void){
^
  (use --enable-preview to enable unnamed classes)
Main.java:14: error: <identifier> expected
int main(void){
             ^
Main.java:27: error: ']' expected
			vector<char> ch[2];
			                ^
Main.java:34: error: ']' expected
			int ans[3] = {-1,0,0};
			        ^
Main.java:34: error: ';' expected
			int ans[3] = {-1,0,0};
			                ^
Main.java:57: error: ']' expected
			string s[2];
			         ^
21 errors
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int[] a = new int[21];
			a[0] = cin.nextInt();
			int L = cin.nextInt();
			if(a[0]==0&&L==0){
				break;
			}
			int i = 1;
			label:while(true){
				String s = a[i-1]+"";
				while(s.length()<L)s+="0";
				char[] c = s.toCharArray();
				Arrays.sort(c);
				int max=0, min=0;
				for(int j=0;j<L;j++)min=min*10+(c[j]-'0');
				for(int j=L-1;j>=0;j--)max=max*10+(c[j]-'0');
				a[i] = max-min;
				//System.out.println(max + " " + min);
				for(int j = i-1; j >= 0;j--){
					if(a[j]==a[i]){
						System.out.println(j+" "+a[i]+" "+(i-j));
						break label;
					}
				}
				i++;
			}
			
		}
	}

}

Compiler output:
Main.java:4: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
       ^
1 error
Language: Java

import java.util.*;
public class AOJ_1180_2{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            String[] A = new String[21];
            String a = sc.next();
            int L = sc.nextInt();
            if(a.equals("0") && L == 0){
                break;
            }
            while(a.length() < L){
                a = "0" + a;
            }
            A[0] = a;
            for(int i = 1; i <= 20; i++){
                A[i] = func(A[i-1],L);
            }
            //System.out.println(Arrays.toString(A));
            String ans = ""; 
            for(int i = 0; i <= 20; i++){
                for(int ii = i+1; ii <= 20; ii++){
                    if(A[i].equals(A[ii])){
                        ans = i + " " + Integer.parseInt(A[i]) + " " + (ii - i);
                        break;
                    }
                }
                if(ans != ""){
                    break;
                }
            }
            System.out.println(ans);
        }    
    }
    String func(String a, int L){
        int[] array = new int[a.length()];
        for(int i = 0; i < a.length(); i++){
            array[i] = Integer.parseInt("" + a.charAt(i));
        }
        Arrays.sort(array);
        String big = "";
        String small = "";
        for(int num: array){
            big = num + big;
            small = small + num;
        }
        String next_a = "" + (Integer.parseInt(big) - Integer.parseInt(small));
        while(next_a.length() < L){
            next_a = "0" + next_a;
        }
        return next_a;
    }
    public static void main(String[] args){
        new AOJ_1180_2().run();
    }
}

Compiler output:
Main.java:2: error: class AOJ_1180_2 is public, should be declared in a file named AOJ_1180_2.java
public class AOJ_1180_2{
       ^
1 error
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,l=0;
		int as=0,am=0; // テ・ツ、ツァテ」ツ?催」ツ??ヲツ閉ーテ」ツ?ィテ・ツーツ湘」ツ?陛」ツ??ヲツ閉ー
		
		while(sc.hasNext()){
			a = sc.nextInt();
			l = sc.nextInt();
			
			if(a == 0 && l == 0) break;
			
			System.out.println();
			
			int[] array = new int[l];

			// 20テ・ツ崢榲ァツケツーテ」ツつ甘ィツソツ氾」ツ?凖」ツ?づァツュツ氾」ツ?暗」ツ?古・ツ?コテ」ツ?淌」ツつ叡reak
			
			int[] result = new int[21];
			result[0] = a;
			for(int i = 1;i<result.length;i++){
				makeArray(array,a); // テ」ツ?禿」ツ?禿」ツ?ァテゥツ?催・ツ按療」ツつ津」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				Arrays.sort(array); // テ」ツ?禿」ツ?禿」ツ?ァテ、ツクツヲテ」ツ?ウテヲツ崢ソテ」ツ?暗」ツ?ヲ
				am = makeAM(array); // テ・ツ、ツァテ」ツ?催」ツ??」ツ?ョテ」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				as = makeAS(array); // テ・ツーツ湘」ツ?陛」ツ??」ツ?ョテ」ツつづ」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				a = Math.abs(am - as);
				result[i] = a;
				if(isSolved(result,i)!=-1){
					System.out.print(isSolved(result,i) + " " + result[i] + " " + (i - isSolved(result,i)));
					break;
				}
			}
			
			check = true;
		}
		
	}
	
	// テ・ツ、ツァテ」ツ?催」ツ??ゥツ??
	static int makeAM(int[] array){
		int m = 1;
		int am = 0;
		for(int i = array.length-1;i>=0;i--){
			am += array[i]*m;
			m *= 10;
		}
		return am;
	}
	
	// テ・ツーツ湘」ツ?陛」ツ??ゥツ??
	static int makeAS(int[] array){
		int m = 1;
		int am = 0;
		for(int i = 0;i<array.length;i++){
			am += array[i]*m;
			m *= 10;
		}
		return am;
	}

	// テゥツ?催・ツ按療」ツ?ォテ」ツ?敕」ツつ古」ツ?榲」ツつ古・ツ?・テ」ツつ古」ツ?ヲテ」ツ??
	static void makeArray(int[] array,int a){
		for(int i = 0;i<array.length;i++){
			array[i] = a%10;
			a /= 10;
		}
	}
	
	// テ・ツ青古」ツ?佚ヲツ閉ーテ・ツュツ療」ツ?古」ツ?づ」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ?凝・ツ?ィテゥツδィテ」ツ?ソテ」ツ?ヲテ」ツ??
	static int isSolved(int[] result,int n){
		for(int i = 0;i<n;i++){
			if(i!=n && result[i]==result[n]) return i;
		}
		return -1;
	}
}

Compiler output:
Main.java:38: error: cannot find symbol
			check = true;
			^
  symbol:   variable check
  location: class Main
1 error
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,l=0;
		int as=0,am=0; // テ・ツ、ツァテ」ツ?催」ツ??ヲツ閉ーテ」ツ?ィテ・ツーツ湘」ツ?陛」ツ??ヲツ閉ーテァツ板ィ
		
		while(sc.hasNext()){
			a = sc.nextInt();
			l = sc.nextInt();
			
			if(a == 0 && l == 0) break;
			
			System.out.println();
			
			int[] array = new int[l];

			// 20テ・ツ崢榲ァツケツーテ」ツつ甘ィツソツ氾」ツ?凖」ツ?づァツュツ氾」ツ?暗」ツ?古・ツ?コテ」ツ?淌」ツつ叡reak
			
			int[] result = new int[21];
			result[0] = a;
			for(int i = 1;i<result.length;i++){
				makeArray(array,a); // テ」ツ?禿」ツ?禿」ツ?ァテゥツ?催・ツ按療」ツつ津」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				Arrays.sort(array); // テ」ツ?禿」ツ?禿」ツ?ァテ、ツクツヲテ」ツ?ウテヲツ崢ソテ」ツ?暗」ツ?ヲ
				am = makeAM(array); // テ・ツ、ツァテ」ツ?催」ツ??」ツ?ョテ」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				as = makeAS(array); // テ・ツーツ湘」ツ?陛」ツ??」ツ?ョテ」ツつづ」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				a = Math.abs(am - as);
				result[i] = a;
				if(isSolved(result,i)!=-1){
					System.out.print(isSolved(result,i) + " " + result[i] + " " + (i - isSolved(result,i)));
					break;
				}
			}
			
			check = true;
		}
		
	}
	
	// テ・ツ、ツァテ」ツ?催」ツ??ゥツ??
	static int makeAM(int[] array){
		int m = 1;
		int am = 0;
		for(int i = array.length-1;i>=0;i--){
			am += array[i]*m;
			m *= 10;
		}
		return am;
	}
	
	// テ・ツーツ湘」ツ?陛」ツ??ゥツ??
	static int makeAS(int[] array){
		int m = 1;
		int am = 0;
		for(int i = 0;i<array.length;i++){
			am += array[i]*m;
			m *= 10;
		}
		return am;
	}

	// テゥツ?催・ツ按療」ツ?ォテ」ツ?敕」ツつ古」ツ?榲」ツつ古・ツ?・テ」ツつ古」ツ?ヲテ」ツ??
	static void makeArray(int[] array,int a){
		for(int i = 0;i<array.length;i++){
			array[i] = a%10;
			a /= 10;
		}
	}
	
	// テ・ツ青古」ツ?佚ヲツ閉ーテ・ツュツ療」ツ?古」ツ?づ」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ?凝・ツ?ィテゥツδィテ」ツ?ソテ」ツ?ヲテ」ツ??
	static int isSolved(int[] result,int n){
		for(int i = 0;i<n;i++){
			if(i!=n && result[i]==result[n]) return i;
		}
		return -1;
	}
}

Compiler output:
Main.java:38: error: cannot find symbol
			check = true;
			^
  symbol:   variable check
  location: class Main
1 error
Language: Java

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by Reopard on 2014/06/26.
 */
public class RecurringDecimals{
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        int[] a, accend, decend;
        int a_first, L, max, min, j, hoge;
        while((a_first = sc.nextInt()) != 0 | (L = sc.nextInt()) != 0){
            hoge = 0;
            j = 0;
            a = new int[21];
            a[0] = a_first;
            accend = new int[L];
            decend = new int[L];
            outer:
            while(true){
                max = 0;
                min = 0;
                if(j > 0) a_first = a[j];
                for(int i = 0; i < L; i++){
                    accend[i] = a_first%10;
                    a_first /= 10;
                }
                Arrays.sort(accend);
                for(int i = 0; i < L; i++) decend[i] = accend[L - (i + 1)];
                for(int i = 0; i < L; i++){
                    min += accend[i]*Math.pow(10, L - (i + 1));
                    max += decend[i]*Math.pow(10, L - (i + 1));
                }
                a[++j] = max - min;
                for(int i = 0; i < j; i++){
                    if(a[j] == a[i]){
                        hoge = i;
                        break outer;
                    }
                }
            }
            System.out.println(hoge + " " + a[j] + " " + (j - hoge));
        }
    }
}

Compiler output:
Main.java:7: error: class RecurringDecimals is public, should be declared in a file named RecurringDecimals.java
public class RecurringDecimals{
       ^
1 error
Language: C

#include <stdio.h>

int main(void) {
    
    
    a[20][i]
}


Compiler output:
main.c: In function 'main':
main.c:6:5: error: 'a' undeclared (first use in this function)
    6 |     a[20][i]
      |     ^
main.c:6:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:6:11: error: 'i' undeclared (first use in this function)
    6 |     a[20][i]
      |           ^
main.c:6:13: error: expected ';' before '}' token
    6 |     a[20][i]
      |             ^
      |             ;
    7 | }
      | ~
Language: C

#include <algorithm>
#include <cstdio>
#include <map>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

string to_string(int a, int l) {
    string s;
    repeat (i, l) {
        s += a % 10 + '0';
        a /= 10;
    }
    whole(reverse, s);
    return s;
}
int from_string(string const & s) {
    int a = 0;
    for (char c : s) {
        a *= 10;
        a += c - '0';
    }
    return a;
}
string updated(string const & s) {
    string down = s;
    whole(sort, down);
    string up = down;
    whole(reverse, up);
    int l = s.length();
    return to_string(from_string(up) - from_string(down), l);
}
int main() {
    while (true) {
        int a, l; scanf("%d%d", &a, &l);
        if (a == 0 and l == 0) break;
        int i = 0;
        string s = to_string(a, l);
        map<string, int> used;
        while (not used.count(s)) {
            used[s] = i;
            ++ i;
            s = updated(s);
        }
        printf("%d %d %d\n", used[s], from_string(s), i - used[s]);
    }
    return 0;
}



Compiler output:
main.c:1:10: fatal error: algorithm: No such file or directory
    1 | #include <algorithm>
      |          ^~~~~~~~~~~
compilation terminated.
Language: C

#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int main(){
	while(1){
		char a[20];
		int L;
		cin>>a>>L; 
		if(!L) break;

		int hist[30], after=0, count=1;
		int ans1, ans2;
		hist[0] =atoi(a);
		while(1){
			fill(a+strlen(a), a+L, '0');
			vector<int> max(L, 0), min(L, 0);
			for(int i=L-1; i>=0; i--){
				max[i] = min[i] = a[i]-'0';
			}
			sort(max.begin(), max.end());
			sort(min.begin(), min.end(),greater<int>());
			int imax=0, imin=0;
			for(int i=0; i<L; i++){
				if(max[i] == 0) imax*=10;
				else imax += max[i]*pow(10, i);
				imin += min[i]*pow(10, i);
			}
			after = imax - imin;
			bool flag=false;
			for(int i=0; i<count; i++){
				if(hist[i] == after){
					flag =true;
					ans1 = i;
					break;
				}
			}
			if(flag) break;
			hist[count++] = after;
			itoa(after, a, 10);
		}
		cout << ans1 << " " << after << " " << count-ans1 << endl;
	}
	return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include<stdilib.h>

int cmp1(const void *a, const void *b){
	return *((char *)a) - *((char *)b);
}
int cmp2(const void *a, const void *b){
	return *((char *)b) - *((char *)a);
}

int ff(int a,int b){
	int m,mm;
	int i;
	char s[7]={0};
	for(i = 5;i >= 0;i--){
		s[i] = a%10;
		a /= 10;
		if(a==0)break;
	}
	for(;i >= 0;i--)a[i] = 0;

	qsort(s,b,sizeof(char),cmp1);
	m = atoi(s);
	qsort(s,b,sizeof(char),cmp2);
	mm = atoi(s);

	return mm-m;
}

int main(){
	int i,j,a[100],l,ii,jj;
	int q,w,e,r,t,y;

	while(scanf("%d%d",&a[0],&l),l){
		for(i = 1;1;i++){
			a[i] = ff(a[i-1],l);
			q = 0;
			for(j = 0;j < i;j++){
				if(a[i] == a[j]){
					ii = i;
					jj = j;
					q = 1;
				}
			}
			if(q)break;
		}
		printf("%d %d %d \n",jj,a[jj],ii-jj);
	}
	return 0;
}







			

Compiler output:
main.c:2:9: fatal error: stdilib.h: No such file or directory
    2 | #include<stdilib.h>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include<stdlib.h>

int cmp1(const void *a, const void *b){
	return *((char *)a) - *((char *)b);
}
int cmp2(const void *a, const void *b){
	return *((char *)b) - *((char *)a);
}

int ff(int a,int b){
	int m,mm;
	int i;
	char s[7]={0};
	for(i = 5;i >= 0;i--){
		s[i] = a%10;
		a /= 10;
		if(a==0)break;
	}
	for(;i >= 0;i--)a[i] = 0;

	qsort(s,b,sizeof(char),cmp1);
	m = atoi(s);
	qsort(s,b,sizeof(char),cmp2);
	mm = atoi(s);

	return mm-m;
}

int main(){
	int i,j,a[100],l,ii,jj;
	int q,w,e,r,t,y;

	while(scanf("%d%d",&a[0],&l),l){
		for(i = 1;1;i++){
			a[i] = ff(a[i-1],l);
			q = 0;
			for(j = 0;j < i;j++){
				if(a[i] == a[j]){
					ii = i;
					jj = j;
					q = 1;
				}
			}
			if(q)break;
		}
		printf("%d %d %d \n",jj,a[jj],ii-jj);
	}
	return 0;
}







			

Compiler output:
main.c: In function 'ff':
main.c:20:26: error: subscripted value is neither array nor pointer nor vector
   20 |         for(;i >= 0;i--)a[i] = 0;
      |                          ^
Language: C

#include<stdio.h>
#include<stdilib.h>

int cmp1(const void *a, const void *b){
	return *((char *)a) - *((char *)b);
}
int cmp2(const void *a, const void *b){
	return *((char *)b) - *((char *)a);
}

int ff(int a,int b){
	int m,mm;
	int i;
	char s[7]={0};
	for(i = 5;i >= 0;i--){
		s[i] = a%10;
		a /= 10;
		if(a==0)break;
	}
	for(;i >= 0;i--)a[i] = 0;

	qsort(s,b,sizeof(char),cmp1);
	m = atoi(s);
	qsort(s,b,sizeof(char),cmp2);
	mm = atoi(s);

	return mm-m;
}

int main(){
	int i,j,a[100],l,ii,jj;
	int q,w,e,r,t,y;

	while(scanf("%d%d",&a[0],&l),l){
		for(i = 1;1;i++){
			a[i] = ff(a[i-1],l);
			q = 0;
			for(j = 0;j < i;j++){
				if(a[i] == a[j]){
					ii = i;
					jj = j;
					q = 1;
					break;
				}
			}
			if(q)break;
		}
		printf("%d %d %d \n",jj,a[jj],ii-jj);
	}
	return 0;
}







			

Compiler output:
main.c:2:9: fatal error: stdilib.h: No such file or directory
    2 | #include<stdilib.h>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include<stdlib.h>

int cmp1(const void *a, const void *b){
	return *((char *)a) - *((char *)b);
}
int cmp2(const void *a, const void *b){
	return *((char *)b) - *((char *)a);
}

int ff(int a,int b){
	int m,mm;
	int i;
	char s[7]={0};
	/*
	for(i = 5;i >= 0;i--){
		s[i] = a%10 + '0';
		a /= 10;
		if(a==0)break;
	}
	for(;i >= 0;i--)s[i] = '0';
	*/
	srintf(s,"%000000d",a);
	s[l] = '\0';

	qsort(s,b,sizeof(char),cmp1);
	m = atoi(s);
	qsort(s,b,sizeof(char),cmp2);
	mm = atoi(s);

	return mm-m;
}

int main(){
	int i,j,a[100],l,ii,jj;
	int q,w,e,r,t,y;

	while(scanf("%d%d",&a[0],&l),l){
		for(i = 1;1;i++){
			a[i] = ff(a[i-1],l);
			q = 0;
			for(j = 0;j < i;j++){
				if(a[i] == a[j]){
					ii = i;
					jj = j;
					q = 1;
					break;
				}
			}
			if(q)break;
		}
		printf("%d %d %d \n",jj,a[jj],ii-jj);
	}
	return 0;
}







			

Compiler output:
main.c: In function 'ff':
main.c:23:9: error: implicit declaration of function 'srintf'; did you mean 'sprintf'? [-Wimplicit-function-declaration]
   23 |         srintf(s,"%000000d",a);
      |         ^~~~~~
      |         sprintf
main.c:24:11: error: 'l' undeclared (first use in this function)
   24 |         s[l] = '\0';
      |           ^
main.c:24:11: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#include<stdlib.h>

int cmp1(const void *a, const void *b){
	return *((char *)a) - *((char *)b);
}
int cmp2(const void *a, const void *b){
	return *((char *)b) - *((char *)a);
}

int ff(int a,int b){
	int m,mm;
	int i;
	char s[7]={0};
	/*
	for(i = 5;i >= 0;i--){
		s[i] = a%10 + '0';
		a /= 10;
		if(a==0)break;
	}
	for(;i >= 0;i--)s[i] = '0';
	*/
	srintf(s,"%000000d",a);
	s[b] = '\0';

	qsort(s,b,sizeof(char),cmp1);
	m = atoi(s);
	qsort(s,b,sizeof(char),cmp2);
	mm = atoi(s);

	return mm-m;
}

int main(){
	int i,j,a[100],l,ii,jj;
	int q,w,e,r,t,y;

	while(scanf("%d%d",&a[0],&l),l){
		for(i = 1;1;i++){
			a[i] = ff(a[i-1],l);
			q = 0;
			for(j = 0;j < i;j++){
				if(a[i] == a[j]){
					ii = i;
					jj = j;
					q = 1;
					break;
				}
			}
			if(q)break;
		}
		printf("%d %d %d \n",jj,a[jj],ii-jj);
	}
	return 0;
}







			

Compiler output:
main.c: In function 'ff':
main.c:23:9: error: implicit declaration of function 'srintf'; did you mean 'sprintf'? [-Wimplicit-function-declaration]
   23 |         srintf(s,"%000000d",a);
      |         ^~~~~~
      |         sprintf
Language: C

#include <stdio.h>
#include <stdbool.h>
 
int l;
int sr[10]={0};
int min[10];
int mi=0,ma=0,ci=0;
int memo[20];
bool ch=0;
 
int main(void){
  int i,j,n,k=0;
 
  while(1){
    scanf("%d %d",&memo[0],&l);
    if(memo[0]+l==0)break;
    k=1;
    while(1){
      for(i=0;i<10;i++)sr[i]=0;
      mi=0;
      ma=0;
      ci=0;
      n=memo[k-1];
      for(i=0;i<l;i++){
    sr[n%10]++;
    n/=10;
      }
      for(i=0;i<10;i++){
    for(j=ci;j<ci+sr[i];j++)min[j]=i;
    ci+=sr[i];
      }
      j=1;
      for(i=0;i<l;i++){
    mi+=min[l-1-i]*j;
    ma+=min[i]*j;
    j*=10;
      }
      for(i=0;i<k;i++){
    if(memo[i]==ma-mi){
      printf("%d %d %d\n",i,ma-mi,k-i);
      ch++;
      break;
    }
    if(i==k-1){
      memo[k]=ma-mi;
      k++;
      break;
    }
      }
      if(ch==1){
    ch=0;
    break;
      }
    }
  }
  return 0;
}

Compile Error Logs:

ステータス
Judge: 2/2	C	CPU: 00:00 sec	Memory: 2064 KB	Length: 782 B	2018-06-17 19:39
テストケースの判定結果
Case #	Verdict	CPU Time	Memory	In	Out	Case Name
Case #1	: Accepted	00:00	2052	574	776	testcase_00
Case #2	: Accepted	00:00	2064	548	746	testcase_01

< prev |		/		| next >	 		
 
Judge Input #  ( | )		Judge Output #  ( | )



Compiler output:
main.c:59:1: error: unknown type name 'Compile'
   59 | Compile Error Logs:
      | ^~~~~~~
main.c:59:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Logs'
   59 | Compile Error Logs:
      |               ^~~~
main.c:64:6: error: stray '#' in program
   64 | Case #  Verdict CPU Time        Memory  In      Out     Case Name
      |      ^
main.c:65:6: error: stray '#' in program
   65 | Case #1 : Accepted      00:00   2052    574     776     testcase_00
      |      ^
main.c:66:6: error: stray '#' in program
   66 | Case #2 : Accepted      00:00   2064    548     746     testcase_01
      |      ^
main.c:70:13: error: stray '#' in program
   70 | Judge Input #  ( | )            Judge Output #  ( | )
      |             ^
main.c:70:46: error: stray '#' in program
   70 | Judge Input #  ( | )            Judge Output #  ( | )
      |                                              ^
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N[100],L,f,i,j,t,F[1000000];
int c(const void *a,const void *b)
{
	return f?*(char*)a-*(char*)b:*(char*)b-*(char*)a;
}
int main()
{
	for(;scanf("%d%d",&N[0],&L),L;)
	{
		memset(F,0,sizeof(F));
		F[N[0]]=1;
		for(i=0;;i++)
		{
			char m[9]={0},M[9]={0};
			itoa(N[i],m,10);
			for(j=0;j<L;j++)m[j]=!m[j]?'0':m[j];
			strcpy(M,m);
			f=0;qsort(M,L,sizeof(char),c);
			f=1;qsort(m,L,sizeof(char),c);
			N[i+1]=atoi(M)-atoi(m);
			if(F[N[i+1]]==1)break;
			else F[N[i+1]]=1;
		}
		for(j=0;N[j]!=N[i+1];j++);
		printf("%d %d %d\n",j,N[j],i-j+1);
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:25: error: implicit declaration of function 'itoa' [-Wimplicit-function-declaration]
   18 |                         itoa(N[i],m,10);
      |                         ^~~~
Language: C++

#include <algorithm>
#include <cstdio>
#include <map>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

string to_string(int a, int l) {
    string s;
    repeat (i, l) {
        s += a % 10 + '0';
        a /= 10;
    }
    whole(reverse, s);
    return s;
}
int from_string(string const & s) {
    int a = 0;
    for (char c : s) {
        a *= 10;
        a += c - '0';
    }
    return a;
}
string updated(string const & s) {
    string down = s;
    whole(sort, down);
    string up = down;
    whole(reverse, up);
    int l = s.length();
    return to_string(from_string(up) - from_string(down), l);
}
int main() {
    while (true) {
        int a, l; scanf("%d%d", &a, &l);
        if (a == 0 and l == 0) break;
        int i = 0;
        string s = to_string(a, l);
        map<string, int> used;
        while (not used.count(s)) {
            used[s] = i;
            ++ i;
            s = updated(s);
        }
        printf("%d %d %d\n", used[s], from_string(s), i - used[s]);
    }
    return 0;
}



Compiler output:
a.cc:8:1: error: 'string' does not name a type; did you mean 'stdin'?
    8 | string to_string(int a, int l) {
      | ^~~~~~
      | stdin
a.cc:17:17: error: 'string' was not declared in this scope
   17 | int from_string(string const & s) {
      |                 ^~~~~~
a.cc:4:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    3 | #include <map>
  +++ |+#include <string>
    4 | #define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
a.cc:25:1: error: 'string' does not name a type; did you mean 'stdin'?
   25 | string updated(string const & s) {
      | ^~~~~~
      | stdin
a.cc: In function 'int main()':
a.cc:38:9: error: 'string' was not declared in this scope
   38 |         string s = to_string(a, l);
      |         ^~~~~~
a.cc:38:9: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:39:24: error: template argument 3 is invalid
   39 |         map<string, int> used;
      |                        ^
a.cc:39:24: error: template argument 4 is invalid
a.cc:40:25: error: request for member 'count' in 'used', which is of non-class type 'int'
   40 |         while (not used.count(s)) {
      |                         ^~~~~
a.cc:40:31: error: 's' was not declared in this scope
   40 |         while (not used.count(s)) {
      |                               ^
a.cc:43:17: error: 'updated' was not declared in this scope
   43 |             s = updated(s);
      |                 ^~~~~~~
a.cc:45:35: error: 's' was not declared in this scope
   45 |         printf("%d %d %d\n", used[s], from_string(s), i - used[s]);
      |                                   ^
a.cc:45:50: error: 'from_string' cannot be used as a function
   45 |         printf("%d %d %d\n", used[s], from_string(s), i - used[s]);
      |                                       ~~~~~~~~~~~^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;


int main(){
	while(1){
		char a[20];
		int L;
		cin>>a>>L; 
		if(!L) break;

		int hist[30], after=0, count=1;
		int ans1, ans2;
		hist[0] =atoi(a);
		while(1){
			fill(a+strlen(a), a+L, '0');
			vector<int> max(L, 0), min(L, 0);
			for(int i=L-1; i>=0; i--){
				max[i] = min[i] = a[i]-'0';
			}
			sort(max.begin(), max.end());
			sort(min.begin(), min.end(),greater<int>());
			int imax=0, imin=0;
			for(int i=0; i<L; i++){
				if(max[i] == 0) imax*=10;
				else imax += max[i]*pow(10, i);
				imin += min[i]*pow(10, i);
			}
			after = imax - imin;
			bool flag=false;
			for(int i=0; i<count; i++){
				if(hist[i] == after){
					flag =true;
					ans1 = i;
					break;
				}
			}
			if(flag) break;
			hist[count++] = after;
			itoa(after, a, 10);
		}
		cout << ans1 << " " << after << " " << count-ans1 << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:53: error: 'pow' was not declared in this scope
   30 |                                 else imax += max[i]*pow(10, i);
      |                                                     ^~~
a.cc:31:48: error: 'pow' was not declared in this scope
   31 |                                 imin += min[i]*pow(10, i);
      |                                                ^~~
a.cc:44:25: error: 'itoa' was not declared in this scope
   44 |                         itoa(after, a, 10);
      |                         ^~~~
Language: C++

#include "pch.h"
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int main(){
	while(1){
		char a[20];
		int L;
		cin>>a>>L; 
		if(!L) break;

		int hist[30], after=0, count=1;
		int ans1, ans2;
		hist[0] =atoi(a);
		while(1){
			fill(a+strlen(a), a+L, '0');
			vector<int> max(L, 0), min(L, 0);
			for(int i=L-1; i>=0; i--){
				max[i] = min[i] = a[i]-'0';
			}
			sort(max.begin(), max.end());
			sort(min.begin(), min.end(),greater<int>());
			int imax=0, imin=0;
			for(int i=0; i<L; i++){
				if(max[i] == 0) imax*=10;
				else imax += max[i]*pow(10, i);
				imin += min[i]*pow(10, i);
			}
			after = imax - imin;
			bool flag=false;
			for(int i=0; i<count; i++){
				if(hist[i] == after){
					flag =true;
					ans1 = i;
					break;
				}
			}
			if(flag) break;
			hist[count++] = after;
			itoa(after, a, 10);
		}
		cout << ans1 << " " << after << " " << count-ans1 << endl;
	}
	return 0;
}


Compiler output:
a.cc:1:10: fatal error: pch.h: No such file or directory
    1 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int main(){
	while(1){
		char a[20];
		int L;
		cin>>a>>L; 
		if(!L) break;

		int hist[30], after=0, count=1;
		int ans1, ans2;
		hist[0] =atoi(a);
		while(1){
			fill(a+strlen(a), a+L, '0');
			vector<int> max(L, 0), min(L, 0);
			for(int i=L-1; i>=0; i--){
				max[i] = min[i] = a[i]-'0';
			}
			sort(max.begin(), max.end());
			sort(min.begin(), min.end(),greater<int>());
			int imax=0, imin=0;
			for(int i=0; i<L; i++){
				if(max[i] == 0) imax*=10;
				else imax += max[i]*pow(10, i);
				imin += min[i]*pow(10, i);
			}
			after = imax - imin;
			bool flag=false;
			for(int i=0; i<count; i++){
				if(hist[i] == after){
					flag =true;
					ans1 = i;
					break;
				}
			}
			if(flag) break;
			hist[count++] = after;
			itoa(after, a, 10);
		}
		cout << ans1 << " " << after << " " << count-ans1 << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:53: error: 'pow' was not declared in this scope
   29 |                                 else imax += max[i]*pow(10, i);
      |                                                     ^~~
a.cc:30:48: error: 'pow' was not declared in this scope
   30 |                                 imin += min[i]*pow(10, i);
      |                                                ^~~
a.cc:43:25: error: 'itoa' was not declared in this scope
   43 |                         itoa(after, a, 10);
      |                         ^~~~
Language: C++

#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int main(){
	while(1){
		char a[20];
		int L;
		cin>>a>>L; 
		if(!L) break;

		int hist[30], after=0, count=1;
		int ans1, ans2;
		hist[0] =atoi(a);
		while(1){
			fill(a+strlen(a), a+L, '0');
			vector<int> max(L, 0), min(L, 0);
			for(int i=L-1; i>=0; i--){
				max[i] = min[i] = a[i]-'0';
			}
			sort(max.begin(), max.end());
			sort(min.begin(), min.end(),greater<int>());
			int imax=0, imin=0;
			for(int i=0; i<L; i++){
				if(max[i] == 0) imax*=10;
				else imax += max[i]*pow(10, i);
				imin += min[i]*pow(10, i);
			}
			after = imax - imin;
			bool flag=false;
			for(int i=0; i<count; i++){
				if(hist[i] == after){
					flag =true;
					ans1 = i;
					break;
				}
			}
			if(flag) break;
			hist[count++] = after;
			itoa(after, a, 10);
		}
		cout << ans1 << " " << after << " " << count-ans1 << endl;
	}
	return 0;
}


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

#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int main(){
	while(1){
		char a[20];
		int L;
		cin>>a>>L; 
		if(!L) break;

		int hist[30], after=0, count=1;
		int ans1, ans2;
		hist[0] =atoi(a);
		while(1){
			fill(a+strlen(a), a+L, '0');
			vector<int> max(L, 0), min(L, 0);
			for(int i=L-1; i>=0; i--){
				max[i] = min[i] = a[i]-'0';
			}
			sort(max.begin(), max.end());
			sort(min.begin(), min.end(),greater<int>());
			int imax=0, imin=0;
			for(int i=0; i<L; i++){
				if(max[i] == 0) imax*=10;
				else imax += max[i]*pow(10, i);
				imin += min[i]*pow(10, i);
			}
			after = imax - imin;
			bool flag=false;
			for(int i=0; i<count; i++){
				if(hist[i] == after){
					flag =true;
					ans1 = i;
					break;
				}
			}
			if(flag) break;
			hist[count++] = after;
			itoa(after, a, 10);
		}
		cout << ans1 << " " << after << " " << count-ans1 << endl;
	}
	return 0;
}


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

#include <iostream>
#include <cmath>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int main(){
	while(1){
		char a[20];
		int L;
		cin>>a>>L; 
		if(!L) break;

		int hist[30], after=0, count=1;
		int ans1, ans2;
		hist[0] =atoi(a);
		while(1){
			fill(a+strlen(a), a+L, '0');
			vector<int> max(L, 0), min(L, 0);
			for(int i=L-1; i>=0; i--){
				max[i] = min[i] = a[i]-'0';
			}
			sort(max.begin(), max.end());
			sort(min.begin(), min.end(),greater<int>());
			int imax=0, imin=0;
			for(int i=0; i<L; i++){
				if(max[i] == 0) imax*=10;
				else imax += max[i]*pow(10, i);
				imin += min[i]*pow(10, i);
			}
			after = imax - imin;
			bool flag=false;
			for(int i=0; i<count; i++){
				if(hist[i] == after){
					flag =true;
					ans1 = i;
					break;
				}
			}
			if(flag) break;
			hist[count++] = after;
			itoa(after, a, 10);
		}
		cout << ans1 << " " << after << " " << count-ans1 << endl;
	}
	return 0;
}


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

#include<iostream>
using namespace std;
int d(int n,int l);
int a[100],ar[10];
bool q;
int main(){
int a0,l;
    while(1){
        q=false;
        cin>>a0>>l;  
    if(a0==0&&l==0)return 0;
    a[0]=a0; 
    int j=1;
    while(1){
        a[j]=d(a[j-1],l);
        for(int k=0;k<j;k++){
            if(a[k]==a[j])
            {
                cout<<k<<" "<<a[k]<<" "<<j-k<<endl;
                q=true;
                break;
            }
        }
        if(q)break;
        j++;
    }
    }
}

int d(int n,int l){
    for(int i=0;i<l;i++){
        ar[i]=n%10;
        n/=10;
    }
    sort(ar,ar+l);
    int max=0,min=0;
    for(int i=0;i<l;i++){
        min*=10;
        min+=ar[i];
    }
    for(int i=l-1;i>-1;i--){
        max*=10;
        max+=ar[i];
    }
    return max-min;
}



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

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int p(int in)
{
	int ret = 1;
	for (int i = 0; i < in; ++i)
		ret *= 10;
	return ret;
}

int to10(vector<int>& in)
{
	int ret = 0;
	for (int i = 0; i < in.size(); ++i)
	{
		ret *= 10;
		ret += in.at(i);
	}

	return ret;
}

vector<int> toVec(int input, int L)
{
	vector<int> in;
	for (int i = 1; i <= L; ++i){
		in.push_back((input % p(i)) / p(i - 1));
	}

	reverse(in.begin(), in.end());

	return in;
}

int getLarge(vector<int> in)
{
	int ret = 0;
	while (!in.empty()){
		ret *= 10;
		auto it = max_element(in.begin(), in.end());
		ret += *it;
		in.erase(it);
	}
	return ret;
}

int getSmall(vector<int> in)
{
	int ret=0;
	while (!in.empty()){
		ret *= 10;
		auto it = min_element(in.begin(), in.end());
		ret += *it;
		in.erase(it);
	}
	return ret;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<sstream>
#include<functional>
using namespace std;
string hiku(string a,string b){
	stringstream t1,t2,t3;
	int x=0,y=0,ans=0;
	t1<<a;
	t2<<b;
	t1>>x;
	t2>>y;
	ans=x-y;
	t3<<ans;
	string tmp=t3.str();
	return tmp;
	
}
int main(){
	string a;
	int k;
	while(true){
		vector<pair<string,int> >y;
		y.clear();
		cin>>a>>k;
		if(a=="0"&&k==0)break;
		for(int jf=0;jf<21;jf++){
		for(int i=0;i<k-a.size();i++)a="0"+a;
			pair<string,int>tmp=make_pair(a,jf);
			y.push_back(tmp);
			string t1,t2;
			sort(a.begin(),a.end());
			t1=a;
			sort(a.begin(),a.end(),greater<char>());
			t2=a;
			a=hiku(t2,t1);
		}
		int I=0,J=0;
		for(int i=0;i<y.size();i++){
			int cnt=0;
			while(y[i].first[cnt]=='0'){
			if(y[i].first=="0")break;
			y[i].first.erase(y[i].first.begin());
			}
		}			
		bool f=1;
		for(int i=0;i<y.size();i++){
			for(int j=0;j<y.size();j++){
				if(i==j)continue;
				if(y[i].first==y[j].first&&f){
				I=i,J=j;
				f=0;
				}
			}
		}
		if(I<J)swap(I,J);
		cout<<J<<" "<<y[I].first<<" "<<I-J<<endl;
	}
	return 0;
}

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

#include <iostream>
#include <vector>
#include <cstdio>
#include <stack>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long int ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back

string solve(string s){
    sort(s.begin(),s.end());
    string a=s;
    string b="";
    for(int i=s.size()-1;i>=0;i--)b+=s[i];
    
    int res=stoi(b)-stoi(a);
    return to_string(res);
}


int main(){
    string s;
    int l;
    while(cin>>s>>l){
        if(s=="0" && l==0)break;
        string tmp="";
        for(int i=0;i<l-s.size();i++)tmp+='0';
        s=tmp+s;
        
        string data[50]={};
        data[0]=s;
        
        for(int i=1;i<30;i++){
            s=solve(s);
            if(s!="0"){
                string tmp="";
                for(int i=0;i<l-s.size();i++)tmp+='0';
                s=tmp+s;
            }
            data[i]=s;
            rep(j,i){
                if(data[j]==data[i]){
                    cout<<j<<" "<<s<<" "<<i-j<<endl;
                    goto end;

                }
            }
        }
    end:;
        
    }
    return 0;
}

Compiler output:
a.cc: In function 'std::string solve(std::string)':
a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |     sort(s.begin(),s.end());
      |     ^~~~
      |     short
Language: C++

#include <cstdio>
#include <algorithm>

using namespace std;

int a, L;
int ans_j, ans_ai, ans_i_j;

int A[22];
int N[6];

int get_greatest() {
    sort(&N[0], &N[L]);
    int r = 0;
    for (int i = L - 1; i >= 0; i--) {
        r *= 10;
        r += N[i];
    }
    //printf("greatest: %d\n", r);
    return r;
}

int get_least() {
    sort(&N[0], &N[L]);
    int r = 0;
    for (int i = 0; i < L; i++) {
        r *= 10;
        r += N[i];
    }
    //printf("least   : %d\n", r);
    return r;
}

void solve() {
    A[0] = a;
    for (int i = 0; i <= 20; i++) {
        int b = A[i];
        for (int j = 0; j < L; j++) {
            N[j] = b % 10;
            b /= 10;
        }
        A[i + 1] = get_greatest() - get_least();
    }
    int ans_i = INT_MAX;
    for (int j = 0; j <= 20; j++) {
        for (int i = j + 1; i <= 20; i++) {
            if (A[i] == A[j]) {
                if (ans_i > i) {
                    ans_i = i;
                    ans_j = j;
                    ans_ai = A[i];
                    ans_i_j = i - j;
                }
            }
        }
    }
}

int main() {
    for (;;) {
        scanf("%d%d", &a, &L);
        if (!a && !L) { break; }
        solve();
        printf("%d %d %d\n", ans_j, ans_ai, ans_i_j);
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:44:17: error: 'INT_MAX' was not declared in this scope
   44 |     int ans_i = INT_MAX;
      |                 ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <algorithm>
  +++ |+#include <climits>
    3 |
Language: C++

#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <map>

using namespace std;

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

int main()
{
  int a, L;
  while(cin >> a >> L, (a|L)) {
    map<int, int> map;
    int idx = 0;
    for(;;) {
    string str = to_string(a);
    if( map.find(a) != map.end() ) {
      int v = map[a];
      cout << v << " " << a << " " << (idx - v) << endl;
      break;
    }
    map[a] = idx++;

    while(str.size() < (unsigned long)L) {
      str.append("0");
    }

    string left( str ); sort(left.begin(), left.end(), greater<char>());
    string right( str ); sort(right.begin(), right.end());

    a = stoi(left) - stoi(right);
    }
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:25: error: 'sort' was not declared in this scope; did you mean 'short'?
   30 |     string left( str ); sort(left.begin(), left.end(), greater<char>());
      |                         ^~~~
      |                         short
Language: C++

#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <map>

using namespace std;

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

int main()
{
  int a, L;
  while(cin >> a >> L, (a|L)) {
    map<int, int> m;
    int idx = 0;
    for(;;) {
    string str = to_string(a);
    if( m.find(a) != m.end() ) {
      int v = m[a];
      cout << v << " " << a << " " << (idx - v) << endl;
      break;
    }
    m[a] = idx++;

    while(str.size() < (unsigned long)L) {
      str.append("0");
    }

    string left( str ); sort(left.begin(), left.end(), greater<char>());
    string right( str ); sort(right.begin(), right.end());

    a = stoi(left) - stoi(right);
    }
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:25: error: 'sort' was not declared in this scope; did you mean 'short'?
   30 |     string left( str ); sort(left.begin(), left.end(), greater<char>());
      |                         ^~~~
      |                         short
Language: C++

#include<iostream>
#include<vector>

using namespace std;

vector<int>cur;
vector<int>his;
int main()
{
    int a,l,count,now;
    while(true){
        count=0;
        his.clear();
        cin>>a>>l;
        his.push_back(a);
        if(a==0&&l==0)
            break;
        while(true){
            count++;
            int big=0,small=0;
            cur.clear();
            while(a>0){
                cur.push_back(a%10);
                a/=10;
            }
            while(cur.size()<l)
                cur.push_back(0);
            sort(cur.begin(),cur.end());
            for(int i=0;i<l;i++){
                small+=cur[i];
                big+=cur[l-i-1];
                if(i<l-1){
                    big*=10;
                    small*=10;
                }
            }
            now=big-small;
            unsigned long f=find(his.begin(), his.end(), now)-his.begin();
            if(f!=his.size()){
                cout<<f<<" "<<now<<" "<<count-f<<endl;
                break;
            }
            his.push_back(now);
            a=now;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:13: error: 'sort' was not declared in this scope; did you mean 'short'?
   28 |             sort(cur.begin(),cur.end());
      |             ^~~~
      |             short
a.cc:38:33: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   38 |             unsigned long f=find(his.begin(), his.end(), now)-his.begin();
      |                             ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:38:33: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   38 |             unsigned long f=find(his.begin(), his.end(), now)-his.begin();
      |                             ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
int memo[1000000];
using namespace std;

int next(int a,int keta){
  int tbl[6]={};
  int p = 0;
  while(a){
    tbl[p++] = a%10;
    a/=10;
  }
  int Max = 0, Min = 0;
  sort(tbl,tbl+keta);
  int pow10 = 1;
  for(int i=0;i<keta;++i){
    Max+=pow10*tbl[i];
    Min+=pow10*tbl[keta-1-i];
    pow10*=10;
  }
  return Max-Min;
}


int main(){
  int a,keta;
  while(cin>>a>>keta,a||keta){
    memset(memo,-1,sizeof(memo));
    int i = 0;
    while(true){
      if(memo[a]!=-1){
	break;
      }
      memo[a] = i;
      i++;
      a = next(a,keta);
    }
    cout << memo[a] << " " << a << " " << i-memo[a] << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'memset' was not declared in this scope
   29 |     memset(memo,-1,sizeof(memo));
      |     ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 | int memo[1000000];
Language: C++

#include<iostream>
#include<string>
#include<stdlib>
using namespace std;
void toStr(int n, int L,char c[])
{
	int i = 0;
	for (i = 0; i < L; i++)
	{
		c[L - 1 - i] = n % 10 + '0';
		n /= 10;
  	}
	return;
}

int toNum(char c[])
{
	int index = 0;
	while (c[index] != '\0')
	{
		
	}
	return 0;
}

int getMax(char c[],int L)
{
	for (int i = 0; i < L - 1; i++)
	{
		for (int j = i + 1; j < L; j++)
		{
			if (c[i] < c[j])
			{
				char tmp = c[i];
				c[i] = c[j];
				c[j] = tmp;
			}
		}
	}
	return atoi(c);
}

int getMin(char c[] , int L)
{
	for (int i = 0; i < L - 1; i++)
	{
		for (int j = i + 1; j < L; j++)
		{
			if (c[i] > c[j])
			{
				char tmp = c[i];
				c[i] = c[j];
				c[j] = tmp;
			}
		}
	}
	return atoi(c);
}
int main()
{
	int a0, L;
	while (cin >> a0 >> L && (a0 != 0 || L != 0))
	{
		int iset[20 + 1] = {};
		int isetIndex = 1;
		int ansA = -1;
		int ansJ = -1;
		int ansIJ = -1;
		iset[0] = a0;
		while (isetIndex <= 20 && ansA == -1)
		{
			char str[20] = {};
			toStr(a0, L, str);
			int ma = getMax(str, L);
			int mi = getMin(str, L);
			int diff = ma - mi;
			a0 = diff;
			iset[isetIndex] = diff;
			isetIndex++;
		}

		bool flag = false;

		for (int i = 20;i > 0;i--)
		{
			for (int j = i - 1; j >= 0; j--)
			{
				if (iset[i] == iset[j])
				{
					flag = true;
					ansJ = j;
					ansA = iset[i];
					ansIJ = i - j;
					break;
				}
			}
		}

		cout << ansJ << " " << ansA << " " << ansIJ << endl;
	}
	return 0;
}

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

#include<iostream>
#include<string>
using namespace std;
int main(){
  string a[32],b,c,z;
  int L;
  while(cin>>a[0]>>L){
    for(int j=0;j<L-a[0].size();j++)z+='0';
    if(L==0)break;
    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++;
      cout<<b[0]<<endl;
      cout<<c[0]<<endl;
      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());
      |       ^~~~~~~