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

#include<iostream>
using namespace std;

struct card{
    char suit;
    int value;
};

void bubbleSort(card c[],int n){
    int flag=1;
    for(int i=0;i<n-1;++i){
        if(!flag)break;
        flag=0;
        for(int j=n-1;j>i;j--){
            if(a[j]<a[j-1]){
                flag=1;
                card t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
}

void selectionSort(card c[],int n){
   int min;
    for(int i=0;i<n-1;++i){
        min=i;
        for(int j=i+1;j<n;++j){
            if(a[j]<a[min])
                min=j;
        }
        if(min!=i){card t=a[i];a[i]=a[min];a[min]=t;}
    }
}

bool isStable(card c1[],card c2[];int n){
    for(int i=0;i<n;++i)
      if(c1[i]!=c2[i])return false;
    
    return true;
}
void print(card c[],n){
    for(int i=0;i<n;i++){
        if(i>0)cout<<' ';
        cout<<c[i].suit<<c[i].value;
    }
    cout<<endl;
}
int main(){
    int n;
    cin>>n;
    card c1[36],c2[36];
    for(int i=0;i<n;i++){
        cin>>c1.suit>>c1.value;
        c2[i]=c1[i];
    }
    
    bubbleSort(c1,n);
    selectionSort(c2,n);
    print(c1,n);
    cout<<"stable"<<endl;
    print(c2,n);
    if(isStable(c1,c2,n))
        cout<<"stable"<<endl;
        else
        cout<<"Not stable"<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'void bubbleSort(card*, int)':
a.cc:15:16: error: 'a' was not declared in this scope
   15 |             if(a[j]<a[j-1]){
      |                ^
a.cc: In function 'void selectionSort(card*, int)':
a.cc:30:16: error: 'a' was not declared in this scope
   30 |             if(a[j]<a[min])
      |                ^
a.cc:33:27: error: 'a' was not declared in this scope
   33 |         if(min!=i){card t=a[i];a[i]=a[min];a[min]=t;}
      |                           ^
a.cc: At global scope:
a.cc:37:34: error: expected ')' before ';' token
   37 | bool isStable(card c1[],card c2[];int n){
      |              ~                   ^
      |                                  )
a.cc:37:40: error: expected initializer before ')' token
   37 | bool isStable(card c1[],card c2[];int n){
      |                                        ^
a.cc:43:21: error: 'n' has not been declared
   43 | void print(card c[],n){
      |                     ^
a.cc: In function 'void print(card*, int)':
a.cc:44:19: error: 'n' was not declared in this scope
   44 |     for(int i=0;i<n;i++){
      |                   ^
a.cc: In function 'int main()':
a.cc:55:17: error: request for member 'suit' in 'c1', which is of non-class type 'card [36]'
   55 |         cin>>c1.suit>>c1.value;
      |                 ^~~~
a.cc:55:26: error: request for member 'value' in 'c1', which is of non-class type 'card [36]'
   55 |         cin>>c1.suit>>c1.value;
      |                          ^~~~~
a.cc:64:16: error: too many arguments to function 'bool isStable(card*, card*)'
   64 |     if(isStable(c1,c2,n))
      |        ~~~~~~~~^~~~~~~~~
a.cc:37:6: note: declared here
   37 | bool isStable(card c1[],card c2[];int n){
      |      ^~~~~~~~
Language: C++

#include<iostream>
using namespace std;

struct card{
    char suit;
    int value;
};

void bubbleSort(card a[],int n){
    int flag=1;
    for(int i=0;i<n-1;++i){
        if(!flag)break;
        flag=0;
        for(int j=n-1;j>i;j--){
            if(a[j].value<a[j-1].value){
                flag=1;
                card t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
}

void selectionSort(card c[],int n){
   int min;
    for(int i=0;i<n-1;++i){
        min=i;
        for(int j=i+1;j<n;++j){
            if(c[j].value<c[min].value)
                min=j;
        }
        if(min!=i){card t=c[i];c[i]=c[min];c[min]=t;}
    }
}

bool isStable(card c1[],card c2[];int n){
    for(int i=0;i<n;++i)
      if(c1[i]!=c2[i])return false;
    
    return true;
}
void print(card c[],n){
    for(int i=0;i<n;i++){
        if(i>0)cout<<' ';
        cout<<c[i].suit<<c[i].value;
    }
    cout<<endl;
}
int main(){
    int n;
    cin>>n;
    card c1[36],c2[36];
    for(int i=0;i<n;i++){
        cin>>c1.suit>>c1.value;
        c2[i]=c1[i];
    }
    
    bubbleSort(c1,n);
    selectionSort(c2,n);
    print(c1,n);
    cout<<"stable"<<endl;
    print(c2,n);
    if(isStable(c1,c2,n))
        cout<<"stable"<<endl;
        else
        cout<<"Not stable"<<endl;
    return 0;
}


Compiler output:
a.cc:37:34: error: expected ')' before ';' token
   37 | bool isStable(card c1[],card c2[];int n){
      |              ~                   ^
      |                                  )
a.cc:37:40: error: expected initializer before ')' token
   37 | bool isStable(card c1[],card c2[];int n){
      |                                        ^
a.cc:43:21: error: 'n' has not been declared
   43 | void print(card c[],n){
      |                     ^
a.cc: In function 'void print(card*, int)':
a.cc:44:19: error: 'n' was not declared in this scope
   44 |     for(int i=0;i<n;i++){
      |                   ^
a.cc: In function 'int main()':
a.cc:55:17: error: request for member 'suit' in 'c1', which is of non-class type 'card [36]'
   55 |         cin>>c1.suit>>c1.value;
      |                 ^~~~
a.cc:55:26: error: request for member 'value' in 'c1', which is of non-class type 'card [36]'
   55 |         cin>>c1.suit>>c1.value;
      |                          ^~~~~
a.cc:64:16: error: too many arguments to function 'bool isStable(card*, card*)'
   64 |     if(isStable(c1,c2,n))
      |        ~~~~~~~~^~~~~~~~~
a.cc:37:6: note: declared here
   37 | bool isStable(card c1[],card c2[];int n){
      |      ^~~~~~~~
Language: C++

#include<iostream>
using namespace std;

struct card{
    char suit;
    int value;
};

void bubbleSort(card a[],int n){
    int flag=1;
    for(int i=0;i<n-1;++i){
        if(!flag)break;
        flag=0;
        for(int j=n-1;j>i;j--){
            if(a[j].value<a[j-1].value){
                flag=1;
                card t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
}

void selectionSort(card c[],int n){
   int min;
    for(int i=0;i<n-1;++i){
        min=i;
        for(int j=i+1;j<n;++j){
            if(c[j].value<c[min].value)
                min=j;
        }
        if(min!=i){card t=c[i];c[i]=c[min];c[min]=t;}
    }
}

bool isStable(card c1[],card c2[],int n){
    for(int i=0;i<n;++i)
      if(c1[i].suit!=c2[i].suit)return false;
    
    return true;
}
void print(card c[],int n){
    for(int i=0;i<n;i++){
        if(i>0)cout<<' ';
        cout<<c[i].suit<<c[i].value;
    }
    cout<<endl;
}
int main(){
    int n;
    cin>>n;
    card c1[36],c2[36];
    for(int i=0;i<n;i++){
        cin>>c1.suit>>c1.value;
        c2[i]=c1[i];
    }
    
    bubbleSort(c1,n);
    selectionSort(c2,n);
    print(c1,n);
    cout<<"stable"<<endl;
    print(c2,n);
    if(isStable(c1,c2,n))
        cout<<"stable"<<endl;
        else
        cout<<"Not stable"<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:17: error: request for member 'suit' in 'c1', which is of non-class type 'card [36]'
   55 |         cin>>c1.suit>>c1.value;
      |                 ^~~~
a.cc:55:26: error: request for member 'value' in 'c1', which is of non-class type 'card [36]'
   55 |         cin>>c1.suit>>c1.value;
      |                          ^~~~~
Language: C++

#include <iostream>
using namespace std;

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N ; i++ ){
        for (int j = N - 1; j >= i + 1; j-- ){
            if(A[j].value < A[j-1].value){
                Card t = A[i]; A[i] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for ( int i = 0; i < N; i++){
        int minj = i;
        for ( int j =i; j<= N-1; j++){
            if (A[j].value < A[minj].value){
                minj = j;
            }
        card t = A[i]; A[i]=A[minj]; A[minj]=t;
        }
    }
}

void print(struct Card A[], int N){
    for ( int i = 0; i<N; i++){
        if (i>0) cout << " ";
        cout << A[i.suit] <<A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i< N ; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for ( int i =0; i< N ;i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i<N; i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout<< "Stable"<<endl;
    print(C2,N);
    if (isStable(C1,C2,N)){
        cout<< "Stable"<<endl;
    } else {
        cout<< "Not stable"<<endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'void selection(Card*, int)':
a.cc:23:9: error: 'card' was not declared in this scope; did you mean 'Card'?
   23 |         card t = A[i]; A[i]=A[minj]; A[minj]=t;
      |         ^~~~
      |         Card
a.cc:23:46: error: 't' was not declared in this scope
   23 |         card t = A[i]; A[i]=A[minj]; A[minj]=t;
      |                                              ^
a.cc: In function 'void print(Card*, int)':
a.cc:31:21: error: request for member 'suit' in 'i', which is of non-class type 'int'
   31 |         cout << A[i.suit] <<A[i].value;
      |                     ^~~~
Language: C++

#include <iostream>
using namespace std;

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N ; i++ ){
        for (int j = N - 1; j >= i + 1; j-- ){
            if(A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for ( int i = 0; i < N; i++){
        int minj = i;
        for ( int j =i; j<= N-1; j++){
            if (A[j].value < A[minj].value){
                minj = j;
            }
        card t = A[i]; A[i]=A[minj]; A[minj]=t;
        }
    }
}

void print(struct Card A[], int N){
    for ( int i = 0; i<N; i++){
        if (i>0) cout << " ";
        cout << A[i.suit] <<A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i< N ; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for ( int i =0; i< N ;i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i<N; i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout<< "Stable"<<endl;
    print(C2,N);
    if (isStable(C1,C2,N)){
        cout<< "Stable"<<endl;
    } else {
        cout<< "Not stable"<<endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'void selection(Card*, int)':
a.cc:23:9: error: 'card' was not declared in this scope; did you mean 'Card'?
   23 |         card t = A[i]; A[i]=A[minj]; A[minj]=t;
      |         ^~~~
      |         Card
a.cc:23:46: error: 't' was not declared in this scope
   23 |         card t = A[i]; A[i]=A[minj]; A[minj]=t;
      |                                              ^
a.cc: In function 'void print(Card*, int)':
a.cc:31:21: error: request for member 'suit' in 'i', which is of non-class type 'int'
   31 |         cout << A[i.suit] <<A[i].value;
      |                     ^~~~
Language: C++

#include <iostream>
using namespace std;

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N ; i++ ){
        for (int j = N - 1; j >= i + 1; j-- ){
            if(A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for ( int i = 0; i < N; i++){
        int minj = i;
        for ( int j =i; j<= N-1; j++){
            if (A[j].value < A[minj].value){
                minj = j;
            }
        card t = A[i]; A[i] = A[minj]; A[minj]=t;
        }
    }
}

void print(struct Card A[], int N){
    for ( int i = 0; i<N; i++){
        if (i>0) cout << " ";
        cout << A[i.suit] <<A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i< N ; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for ( int i =0; i< N ;i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i<N; i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout<< "Stable"<<endl;
    print(C2,N);
    if (isStable(C1,C2,N)){
        cout<< "Stable"<<endl;
    } else {
        cout<< "Not stable"<<endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'void selection(Card*, int)':
a.cc:23:9: error: 'card' was not declared in this scope; did you mean 'Card'?
   23 |         card t = A[i]; A[i] = A[minj]; A[minj]=t;
      |         ^~~~
      |         Card
a.cc:23:48: error: 't' was not declared in this scope
   23 |         card t = A[i]; A[i] = A[minj]; A[minj]=t;
      |                                                ^
a.cc: In function 'void print(Card*, int)':
a.cc:31:21: error: request for member 'suit' in 'i', which is of non-class type 'int'
   31 |         cout << A[i.suit] <<A[i].value;
      |                     ^~~~
Language: C++

#include <iostream>
using namespace std;

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N ; i++ ){
        for (int j = N - 1; j >= i + 1; j-- ){
            if(A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for ( int i = 0; i < N; i++){
        int minj = i;
        for ( int j =i; j < N; j++){
            if (A[j].value < A[minj].value){
                minj = j;
            }
        card t = A[i]; A[i] = A[minj]; A[minj]=t;
        }
    }
}

void print(struct Card A[], int N){
    for ( int i = 0; i<N; i++){
        if (i>0) cout << " ";
        cout << A[i.suit] <<A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i< N ; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for ( int i =0; i< N ;i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i<N; i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout<< "Stable"<<endl;
    print(C2,N);
    if (isStable(C1,C2,N)){
        cout<< "Stable"<<endl;
    } else {
        cout<< "Not stable"<<endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'void selection(Card*, int)':
a.cc:23:9: error: 'card' was not declared in this scope; did you mean 'Card'?
   23 |         card t = A[i]; A[i] = A[minj]; A[minj]=t;
      |         ^~~~
      |         Card
a.cc:23:48: error: 't' was not declared in this scope
   23 |         card t = A[i]; A[i] = A[minj]; A[minj]=t;
      |                                                ^
a.cc: In function 'void print(Card*, int)':
a.cc:31:21: error: request for member 'suit' in 'i', which is of non-class type 'int'
   31 |         cout << A[i.suit] <<A[i].value;
      |                     ^~~~
Language: C++

#include <iostream>
using namespace std;

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N ; i++ ){
        for (int j = N - 1; j >= i + 1; j-- ){
            if(A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for ( int i = 0; i < N; i++){
        int minj = i;
        for ( int j =i; j < N; j++){
            if (A[j].value < A[minj].value){
                minj = j;
            }
        Card t = A[i]; A[i] = A[minj]; A[minj]=t;
        }
    }
}

void print(struct Card A[], int N){
    for ( int i = 0; i<N; i++){
        if (i>0) cout << " ";
        cout << A[i.suit] <<A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i< N ; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for ( int i =0; i< N ;i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i<N; i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout<< "Stable"<<endl;
    print(C2,N);
    if (isStable(C1,C2,N)){
        cout<< "Stable"<<endl;
    } else {
        cout<< "Not stable"<<endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'void print(Card*, int)':
a.cc:31:21: error: request for member 'suit' in 'i', which is of non-class type 'int'
   31 |         cout << A[i.suit] <<A[i].value;
      |                     ^~~~
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> svector;

void stablesort(svector &A){
	stable_sort(A.begin(), A.end(), [](string x, string y) { return (x[1]) < (y[1]);});
	return 0;
}

int bubblesort(svector &A){
    int n = A.size();
    for (int i=0; i<n; i++)
        for (int j=n-1; j>i; j--)
            if (A[j][1] < A[j-1][1]){
                swap(A[j], A[j-1]);
            }
    return 0;
}

int selectionsort(svector &A){
	int n = A.size(), mini;
	for (int i=0; i<n; i++){
		mini = i;
		for (int j=i; j<n; j++)
			if (A[j][1] < A[mini][1])
				mini = j;
		if (i!=mini){
			swap(A[i], A[mini]);
		}
	}
	return 0;
}


int nums_out(svector &A){
    int n=A.size();
    for (int i=0; i<n; i++){
        cout << A[i];
        if (i!= n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

int main(void){
	int n;
	cin>>n;
	svector tmp, A(n), B(n), C(n);
		
	for (int i=0; i<n; i++){
		cin >> A[i];
	}

	B = A;
	C = A;

	stablesort(A);
	bubblesort(B);
	selectionsort(C);

	nums_out(B);
	if (A == B) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	nums_out(C);
	if (A == C) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void stablesort(svector&)':
a.cc:10:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   10 |         return 0;
      |                ^
Language: Java

import java.util.*;

import static javafx.scene.input.KeyCode.G;

public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);
        int total = inp.nextInt();

        int[] b = new int[total];

        for (int k = 0; k < total; k++) {
            int a = inp.nextInt();

            b[k] = a;
        }

        shellSort(b, total);
    }

    public static int insertionSort(int[] b, int n, int g) {
        int counter = 0;
        for (int i = g; i < n; i++) {
            int v = b[i];
            int j = i - g;
            while (j >= 0 && b[j] > v) {
                b[j + g] = b[j];
                j = j - g;
                counter++;
            }

            b[j + g] = v;
        }

        return counter;
    }

    public static void shellSort(int[] b, int n) {
        int counter = 0;
        int m = 0;
        int g[] = new int[100];

        for (int i = 1; i <= n; i=i*3+1) {
            g[m] = i;
            m++;
        }

        System.out.println(m);

        m--;

        for (int i = m; i >= 0; i--) {
            counter += insertionSort(b, n, g[i]);

            if (i == 0) {
                System.out.printf(" %d", g[i]);
            } else {
                System.out.printf("%d", g[i]);
            }
        }

        System.out.println("\n" + counter);

        for (int i = 0; i < n; i++) {
            System.out.println(b[i]);
        }
    }
}



Compiler output:
Main.java:3: error: package javafx.scene.input does not exist
import static javafx.scene.input.KeyCode.G;
                                ^
Main.java:3: error: static import only from classes and interfaces
import static javafx.scene.input.KeyCode.G;
^
2 errors
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ShellSort {
	private final static StringBuilder sortedSeq = new StringBuilder();
	private final static String lb = System.getProperty("line.separator");

	private static int count;
	public static void main(String[] args) throws IOException {
		int[] seq = getSequence();
		shellSort(seq);
		printSequence(seq);
	}

	public static void insertionSort(final int[] seq, final int gap) {
		for (int i = gap; i < seq.length; ++i) {
			final int key = seq[i];
			int j = i - gap;
			while (0 <= j && key < seq[j]) {
				seq[j+gap] = seq[j];
				j = j - gap;
				++count;
			}
			seq[j+gap] = key;
		}
	}

	public static void shellSort(final int[] seq) {
		count = 0;
		
		final int greatestSize = seq.length/3 + 1;
		int gap = 0;
		int sizeOfGaps = 0;
		for (int tmp = 1; tmp <= greatestSize; tmp = 3*gap + 1) {
			gap = tmp;
			++sizeOfGaps;
		}
		sortedSeq.append(sizeOfGaps).append(lb);

		int[] gaps = new int[sizeOfGaps];
		for (int i = 0; i < sizeOfGaps; ++i) {
			gaps[i] = gap;
			sortedSeq.append(gap).append(i < sizeOfGaps-1 ? " " : lb);
			insertionSort(seq, gap);
			
			gap = (gap-1)/3;
		}
		sortedSeq.append(count).append(lb);
	}

	public static void printSequence(final int[] seq) {
		for (int i = 0; i < seq.length; i++) {
			sortedSeq.append(seq[i]).append(lb);
		}
		System.out.print(sortedSeq.toString());
	}

	public static int[] getSequence() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final int seqLength = Integer.parseInt(reader.readLine());

		final int[] seq = new int[seqLength];
		for (int i = 0; i < seqLength; ++i) {
			seq[i] = Integer.parseInt(reader.readLine());
		}
		reader.close();

		return seq;
	}
}

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

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

class Main {
  public static int cnt = 0;
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
  	int n = sc.nextInt();
  	int[] a = new int[n];
  	for(int i = 0; i < n; ++i) {
  		a[i] = sc.nextInt();
  	}
  	
  	//insertionSort(a, 1);
  	shellSort(a);
  	System.out.println(3)//cnt);
  	for(int i = 0; i < n; ++i) {
  		System.out.println(a[i]);
  	}
  }
  
  public static void insertionSort(int[] a, int g){
  	for(int i = g; i < a.length; ++i) {
  		int v = a[i];
  		int j = i - g;
  		while(j >= 0 && a[j] > v) {
  			a[j + g] = a[j];
  			j = j - g;
  			cnt += 1;
  		}
  		a[j + g] = v;
  	}
  }
  
  public static void shellSort(int[] a) {
  	List<Integer> g = new ArrayList<Integer>();
  	int t = 1;
  	while(t < a.length){
  		g.add(t);
  		t = 3*t + 1;
  	}
  	int m = g.size();
  	System.out.println(m);
	
	for(int i = 0; i < g.size(); ++i) {
		System.out.print(i == 0 ? "" : " ");
		System.out.print(g.get(g.size() - 1 - i));
	}
  	System.out.println();
  	
  	for(int i = 0; i < m; ++i) {
  		insertionSort(a, g.get(i));
  	}
  }
}

Compiler output:
Main.java:17: error: ';' expected
  	System.out.println(3)//cnt);
  	                     ^
1 error
Language: Java

import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	static int N;

	public static void main(String[] args){

		int n = scan.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = scan.nextInt();
		}

		shellSort(arr, n);
	}

	static int inserSort(int[] a, int n, int g, int cnt){
		int v, j;
		for(int i = g; i < n; i++){
			v = a[i];
			j = i - g;
			while(j >= 0 && a[j] > v){
				a[j+g] = a[j];
				j = j - g;
				cnt++;
			}
			a[j+g] = v;
		}
		return cnt;
	}

	static void shellSort(int[] a, int n){
		int cnt, m, count, gCheck;
		cnt = 0;
		count = 0;
		gCheck = 1;

		while(n > gCheck){
			gCheck = gCheck * 2 + 1;
			count++;
		}
		if(count == 0)
			count = 1;
		m = count;
		int[] g = new int[m];
		g[m-1] = 1;

		for(int i = 1; i < m; i++){
			g[m-i-1] = g[m-i] * 2 + 1;
		}

		for(int i = 0; i < m; i++){
			cnt = insertSort(arr, n, g[i], cnt);
		}

		System.out.println(m);
		for(int i = 0; i < m; i++){
			System.out.printf(i != m-1? "%d " : "%d\n", g[i]);
		}
		System.out.printf("%d\n", cnt);
		for(int i = 0; i < n; i++){
			System.out.printf("%d\n", arr[i]);
		}
	}
}

Compiler output:
Main.java:54: error: cannot find symbol
			cnt = insertSort(arr, n, g[i], cnt);
			                 ^
  symbol:   variable arr
  location: class Main
Main.java:63: error: cannot find symbol
			System.out.printf("%d\n", arr[i]);
			                          ^
  symbol:   variable arr
  location: class Main
2 errors
Language: Java

import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	static int N;

	public static void main(String[] args){

		int n = scan.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = scan.nextInt();
		}

		shellSort(arr, n);
	}

	static int inserSort(int[] a, int n, int g, int cnt){
		int v, j;
		for(int i = g; i < n; i++){
			v = a[i];
			j = i - g;
			while(j >= 0 && a[j] > v){
				a[j+g] = a[j];
				j = j - g;
				cnt++;
			}
			a[j+g] = v;
		}
		return cnt;
	}

	static void shellSort(int[] a, int n){
		int cnt, m, count, gCheck;
		cnt = 0;
		count = 0;
		gCheck = 1;

		while(n > gCheck){
			gCheck = gCheck * 2 + 1;
			count++;
		}
		if(count == 0)
			count = 1;
		m = count;
		int[] g = new int[m];
		g[m-1] = 1;

		for(int i = 1; i < m; i++){
			g[m-i-1] = g[m-i] * 2 + 1;
		}

		for(int i = 0; i < m; i++){
			cnt = insertSort(a, n, g[i], cnt);
		}

		System.out.println(m);
		for(int i = 0; i < m; i++){
			System.out.printf(i != m-1? "%d " : "%d\n", g[i]);
		}
		System.out.printf("%d\n", cnt);
		for(int i = 0; i < n; i++){
			System.out.printf("%d\n", a[i]);
		}
	}
}

Compiler output:
Main.java:54: error: cannot find symbol
			cnt = insertSort(a, n, g[i], cnt);
			      ^
  symbol:   method insertSort(int[],int,int,int)
  location: class Main
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Shellsort {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	 int cnt;
	 int m = 2;
	 int [] G = new int[m];
	 G[0] = 4;
     G[1] = 1;


    int n = Integer.parseInt( br.readLine() );
    int [] A = new int[n];
    for(int i = 0; i < n ; i++){
          A[i] = Integer.parseInt( br.readLine() );
    }

    cnt = 0;
    for(int i = 0; i < m ; i++){

       for( int j = G[i]; j < n ; j++ ){
    	   int v = A[j];
    	   int x = j - G[i];

    	   while( x >= 0 && A[x] > v ){
    		   A[x+G[i]] = A[x];
               x = x-G[i];
               cnt++;
    	   }
    	   A[x+G[i]] = v;

       }

    }

     System.out.println(m);
    for(int i = 0; i < m ; i++){
    	System.out.print(G[i]);
        if(i < m-1){
            System.out.print(" ");
        }
    }
    System.out.println();
    System.out.println(cnt);

    for(int i = 0; i < n ; i++){
    	System.out.println(A[i]);

    }

 }
}

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

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class ShellSort {

	static int count = 0;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		shellSort(a);
		System.out.println(count);

		for (int i = 0; i < a.length; i++) {
			System.out.println(a[i]);
		}

	}
	static void shellSort(int[] a) {

		List<Integer> glist = new ArrayList<Integer>();
		for (int i = 1; i < a.length; i=i*3+1) {
			glist.add(i);
		}
		Collections.reverse(glist);
		System.out.println(glist.size());
		Integer[] g = glist.toArray(new Integer[glist.size()]);
		for (int i = g.length-1; i >= 0; i--) {
			if (i != 0) {
				System.out.print(g[i]+" ");
			} else {
				System.out.println(g[i]);
			}
		}

		for (int i = 0; i < g.length; i++) {
			insertionSort(a, g[i]);
		}

	}
	static void insertionSort(int[] a, int g) {
		for (int i = g; i < a.length; i++) {
			int v = a[i];
			int j = i-g;
			while (j >= 0 && a[j] > v) {
				a[j+g] = a[j];
				j=j-g;
				count++;
			}
			a[j+g] = v;
		}
	}
}


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

import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		int array[] = new int[num];
		
		for(int i = 0; i < num; i ++ ){
			array[i] = scanner.nextInt();
		}
		
		shellSort(array, num);
		
		scanner.close();
	}

	public static int insertionSort( int[] array, int num, int g ,int count){ // N個の要素を含む0-オリジンの配列A
		int sub;
		int comp = 0;
		int i;
		
		for( i = 1; i <=  num - 1; i ++ ){
			sub = array[i];
			comp = i - g;
			while( -1 < j && sub < array[j] ){
				array[comp + g] = array[comp];
				j = j - g;
				count ++;
			}
			array[comp + 1] = sub;
			
		}
	}
	
	public static int[] shellSort(int[] array, inrt num){
		int cnt = 0;
		int m;
		int arrayG[100];
		for( int i = 0; i < 100; i ++ ){
			if( i == 0 ){
				arrayG[i] = num / 2 + 1;
			}else{
				arrayG[i] = arrayG[i-1] / 2 - 1;
			}
			
			if( arrayG[i] < 0 ){
				arrayG[i - 1] = 1;
				arrayG[i] = 0;
				m = i;
				
				break;
			}
			for( int i = 0; i < m; ++i ){
				insertionSort(A, n, arrayG[i], cnt);
			}
		}
		
		
		System.out.println(m);
		for(int cou = 0; cou < m; cou ++ ){
			System.out.print(array[cou]);
			if( cou == num - 1) {
			System.out.print("\n");
			}else {
				System.out.print(" ");
			}
		}
		System.out.println(cnt);
		for(int cou = 0; cou < num; cou ++ ){
			System.out.println(array[cou]);
		}
	}
	
}




Compiler output:
Main.java:39: error: ']' expected
		int arrayG[100];
		           ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      for(int i=0; i!=n; i++)
        seq[i] = Integer.parseInt(br.readLine());

      int cnt = shellSort(seq, n);
      System.out.println(cnt);
      StringBuilder str = new StringBuilder(n*2);
      for (int i : seq)
        str.append(i).append("\n");
      str.setLength(str.length()-1);
      System.out.println(str);
    }
  }

  public static int shellSort(int a[], int n) {
    int cnt=0;
    int m = 0;
    int k = Double.valueOf( Math.sqrt(num) ).intValue();
    int[] aG = new int[k];
    for (int i=0,d=1; d <= n; i++,d=(d*3+1)) {
      aG[i] = d; m++;
    }
    System.out.println(m);
    StringBuilder str = new StringBuilder(m*2);

    for(int i=(m-1); i!=-1; i--){
      cnt += insertionSort(a, n,aG[i]);
      str.append(aG[i]).append(" ");
    }

    str.setLength(str.length()-1);
    System.out.println(str);

    return cnt;
  }
  
  public static int insertionSort(int a[], int max, int g) {
    int cnt=0;

    for (int i=g,j=0,v=0; i < max; i++) {
      for( j=(i-g), v=a[i]; j>=0 && a[j]>v; j=j-g ) {
        a[j+g] = a[j];
        cnt++;
      }
      a[j+g] = v;
    }

    return cnt;
  }
}


Compiler output:
Main.java:29: error: cannot find symbol
    int k = Double.valueOf( Math.sqrt(num) ).intValue();
                                      ^
  symbol:   variable num
  location: class Main
1 error
Language: C

#include<stdio.h>
#include<stdlib.h>
#define N 1000000
int count=0,l*S;
 
void insertionSort(int A[], int n, int m){
int i,v,j;
  for(i=m;i<n;i++){
    v=A[i];
    j=i-m;
    while(j>=0&&A[j]>v){
      A[j+m]=A[j];
      j-=m;
      count++;
    }
    A[j+m]=v;
  }
}
 
void Sort(int A[],int n){
  int i=0,a;
 
  S=(int *)malloc(n * sizeof(int));
 
  for(a=1; ; ){
    if(a>n) break;
    S[i]=a;
    i++;
    a=3*a+1;
  }
  l=i;
  for(i=l-1;i>=0;i--){
    insertionSort(A,n,S[i]);
  }
}
 
 
 
int main(){
  int i,A[N],n;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
 
  Sort(A,n);
 
  printf("%d\n",l);
 
  for(i=l-1;i>=0;i--){
    printf("%d",S[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  for(i=0;i<n;i++)printf("%d\n",A[i]);
 
  free(S);
  return 0;
}



Compiler output:
main.c:4:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    4 | int count=0,l*S;
      |              ^
main.c: In function 'Sort':
main.c:23:3: error: 'S' undeclared (first use in this function)
   23 |   S=(int *)malloc(n * sizeof(int));
      |   ^
main.c:23:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:31:3: error: 'l' undeclared (first use in this function)
   31 |   l=i;
      |   ^
main.c: In function 'main':
main.c:46:17: error: 'l' undeclared (first use in this function)
   46 |   printf("%d\n",l);
      |                 ^
main.c:49:17: error: 'S' undeclared (first use in this function)
   49 |     printf("%d",S[i]);
      |                 ^
Language: C

#include<iostream>
using namespace std;


 int InsertionSort(int* a, int n, int g)
{
	int tmp, j, count = 0;
	for (int i = g; i < n; i++)
	{
		tmp = a[i];
		for (j = i - g; j >= 0 && a[j] > tmp; j -= g)
		{
			a[j + g] = a[j];
			count++;
		}
		a[j + g] = tmp;
	}
	return count;
}

int ShellSort(int* a, int n)
{
	int m, g[1000],count = 0;
	m = n / 2;
	cout << m << endl;
	for (int i = 0; i < m; i++)
	{
		g[i] = m - i;
		if (i)
			cout << " ";
		cout << g[i];
	}
	for (int i = 0; i < m; i++)
		count += InsertionSort(a, n, g[i]);

	return count;
}

int main()
{
	int n, a[1000000], count;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	count = ShellSort(a, n);
	cout << endl << count << endl;
	for (int i = 0; i < n; i++)
		cout << a[i] << endl;

	return 0;
}


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

#include<iostream>
using namespace std;


 int InsertionSort(int* a, int n, int g)
{
	int tmp, j, count = 0;
	for (int i = g; i < n; i++)
	{
		tmp = a[i];
		for (j = i - g; j >= 0 && a[j] > tmp; j -= g)
		{
			a[j + g] = a[j];
			count++;
		}
		a[j + g] = tmp;
	}
	return count;
}

int ShellSort(int* a, int n)
{
	int m, g[1000],count = 0;
	for (m = 1; m * m * m * m < n; m++)
		continue;
	cout << m << endl;
	for (int i = 0; i < m; i++)
	{
		g[i] = m - i;
		if (i)
			cout << " ";
		cout << g[i];
	}
	for (int i = 0; i < m; i++)
		count += InsertionSort(a, n, g[i]);

	return count;
}

int main()
{
	int n, a[1000000], count;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	count = ShellSort(a, n);
	cout << endl << count << endl;
	for (int i = 0; i < n; i++)
		cout << a[i] << endl;

	return 0;
}


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

#include<iostream>
using namespace std;


 int InsertionSort(int* a, int n, int g)
{
	int tmp, j, count = 0;
	for (int i = g; i < n; i++)
	{
		tmp = a[i];
		for (j = i - g; j >= 0 && a[j] > tmp; j -= g)
		{
			a[j + g] = a[j];
			count++;
		}
		a[j + g] = tmp;
	}
	return count;
}

int ShellSort(int* a, int n)
{
	int m, g[1000],count = 0, tmp;
	tmp = n;
	for (m = 0; tmp > 0; m++)
		tmp /= 10;
	cout << m << endl;
	g[m - 1] = 1;
	for (int i = m - 1; i > 0; i++)
		g[i - 1] = g[i] * 2;
	for (int i = 0; i < m; i++)
	{
		if (i)
			cout << " ";
		cout << g[i];
	}
	for (int i = 0; i < m; i++)
		count += InsertionSort(a, n, g[i]);

	return count;
}

int main()
{
	int n, a[1000000], count;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	count = ShellSort(a, n);
	cout << endl << count << endl;
	for (int i = 0; i < n; i++)
		cout << a[i] << endl;

	return 0;
}


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

#include<stdio.h>

 int cnt;
 
 void insertionSort(int A[],int n,int g);
 void shellSort(int A[],int n;

 int n;
 int A[1000000];

 int main(){
            int i;
            scanf("%d",&n);
            for(i=0;i<n;i++)scanf("%d",A+i);
            shellSort(A,n);
            printf("%d\n",cnt);
            for(i=0;i<n;i++)printf("%d\n",A[i]);
            return 0;
            }

 void insertionSort(int A[],int n,int g){
            int tmp;
            int i,j;
            for(i=g;i<n;i++){
                             tmp=A[i];
                             j=i-g;
                             while(j>=0&&A[j]>tmp){
                                                   A[j+g]=A[j];
                                                   j-=g;
                                                   ++cnt;
                                                   } 
                             A[j+g]=tmp;
                             }
             }

 void shellSort(int A[],int n){
                               int m=0;
                               int G[100];
                               int i;
                               G[0]=1;
                               for(m=1;3*G[m-1]+1<=n;m++)G[m]=3*G[m-1]+1;
                               printf("%d\n",m);
                               cnt=0;
                               for(i=m-1;i>=0;i--){
                                                   printf("%d%c",G[i]);
                                                   insertionSort(A,n,G[i]);
                                                   }
                               }


Compiler output:
main.c:11:12: error: expected ';', ',' or ')' before '{' token
   11 |  int main(){
      |            ^
Language: C

#include<stdio.h>
#define N 1000000
 
int a[N];
int cnt=0;
int G[N];
int m=1;
 
void insertionSort(int n,int g){
    for(int i=g;i<n;i++){
        int v=a[i];
        int j=i-g;
        while(j>=0 && a[j] > v){
            a[j+g]=a[j];
            cnt++;
            j=j-g;
        }
        a[j+g]=v;
    }
    return;
}
 
 
void shellSort(int n){
    int temp=n;
     
    G[0]=1;
     
    while(1){
        G[m]=G[m-1]*3+1;
        if(G[m] > n)break;
        m++;
    }
     
    for(int i=m-1;i>=0;i--)
        insertionSort(n,G[i]);
     
    return;
}
 
 
 
int main(){
    int n,i;
     
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
     
    shellSort(n);
     
     
    printf("%d\n",m);
    for(i=m-1;i>0;i--)
        printf("%d ",G[i]);
    printf("%d\n",G[0]);
     
    printf("%d\n",cnt);
     
    for(i=0;i<n;i++)
        printf("%d\n",a[i]);
     
    return 0;


Compiler output:
main.c: In function 'main':
main.c:63:5: error: expected declaration or statement at end of input
   63 |     return 0;
      |     ^~~~~~
Language: C

#include<stdio.h>
int main()
{
  int n, i, j, k, v, x, cnt=0, m=0;
  int A[1000000];
  int G[1000000];

  scanf("%d", &n);
   
  for(i = 0 ; i < n ; i++) {
    scanf("%d", &A[i]);
  }
   
  G[0 =1 ;
  for(i = 1 ; G[i-1] <= n ; i++) {
    m++;
    G[i] = G[i-1] * 3 + 1;
    if(m > 100) break;
  }
  for(i = 0 ; i< m/2 ; i++) {
    x = G[i];
    G[i] = G[m-i-1];
    G[m-i-1] = x;
  }
   
   
  for(i = 0 ; i < m ; i++) {
    for(j = G[i] ; j < n ; j++) {
      v = A[j];
      k = j - G[i];
      while(k >= 0 && A[k] > v) {
        A[k+G[i]] = A[k];
        k = k - G[i];
        cnt++;
      }
      A[k+G[i]] = v;
    }
  }
   
  printf("\n%d\n", m);
  for(i = 0  ; i < m ; i++) {
    printf("%d ", G[i]);
  }
  printf("\n%d\n", cnt);
  for(i = 0 ; i < n ; i++) {
    printf("%d\n", A[i]);
  
}
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:14:7: error: lvalue required as left operand of assignment
   14 |   G[0 =1 ;
      |       ^
main.c:14:9: error: expected ']' before ';' token
   14 |   G[0 =1 ;
      |         ^~
      |         ]
main.c:49:12: error: expected ';' before '}' token
   49 |   return 0;
      |            ^
      |            ;
   50 | }
      | ~
Language: C

#include <stdio.h>
 
int g[102], m;
int cnt;

void shell_sort(int n,int *a)
{
  int i,j,h,lim;
  int key;

  lim=n/9;
  if(lim<40) lim=40;

  g[0]=1;
  m=0;
  do m++,g[m]=3*g[m-1]+1;
  while(g[m]<n&&g[m]<=lim);
  cnt=0,h=g[m-1];
  while(h>0){
    for(i=h,i<n;i++){
      key=a[i];
      j=i-h;
      while(j>=0&&a[j]>key){
        cnt++;
        a[j+h]=a[j];
        j-=h;
      }
      a[j+h]=key;
    }
    h/=3;
  }
}

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
char buf[20];
void mypr(int n)
{
    int i;
    if (n == 0) { pc('0'); return; }
    i = 0; while (n) buf[i++] = n%10 +'0', n /= 10;
    while (i) pc(buf[--i]);
}
 
int a[1000002];

int main()
{
    int N, i;
 
    N = in(); for (i = 0; i < N; i++) a[i] = in();
 
    shell_sort(N, a);
     
    mypr(m), pc('\n');
    mypr(g[m-1]); for (i = m-2; i >= 0; i--) pc(' '), mypr(g[i]); pc('\n');
    mypr(cnt), pc('\n');
    for (i = 0; i < N; i++) mypr(a[i]), pc('\n');
 
    return 0;
}


Compiler output:
main.c: In function 'shell_sort':
main.c:20:20: error: expected ';' before ')' token
   20 |     for(i=h,i<n;i++){
      |                    ^
      |                    ;
Language: C

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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return (k % m)/* your task */; }
int h2(int key){ return (1 + k % (m - 1))/* your task */; }

int find(char str[]){

    /* your task */

}

int insert(char str[]){
  static int i = 0;
  H[i] = str;
  i++;
    /* your task */

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

#include <iostream>
#include <utility>
#include <cstdio>
using namespace std;

void insertionSort(int A[], const int n, const int g, int *cnt)
{
    for( int i = g; i < n; ++i ){
        int tmp = A[i];
        int j = i - g;
        while( -1 < j && tmp < A[j] ){
            //cout << A[j+g] << "<-->" << A[j] << endl;
            A[j+g] = A[j];
            j = j - g;
            ++*cnt;
        }
        A[j+g] = tmp;
    }
}

void shellSort(int A[], const int n)
{
    int cnt = 0;
    int m;
    int G[100];
    for( int i = 0; i < 100; ++i ){
        if( i == 0 ) G[i] = n / 2 + 1;
        else G[i] = G[i-1] / 2 - 1;
        if( G[i] < 0 ){
            G[i-1] = 1;
            G[i] = 0;
            m = i;
            break;
        }
    }

    for( int i = 0; i < m; ++i )
        insertionSort(A, n, G[i], &cnt);

    //出力
    printf("%d\n", m);
    for( int i = 0; i < m; ++i ){
        if( i ) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n%d\n", cnt);
    for( int i = 0; i < n; ++i )
        printf("%d\n", A[i]);
}

int main()
{
    //入力
    int n;
    scanf("%d", &n);
    int A[n];
    for( int i = 0; i < n; ++i )
        scanf("%d", &A[i]);

    //シェルソート
    shellSort(A, n);

    return 0;
}



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

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

#define ArrayNum 100

vector<int> g;

int insertionSort(int a[],int n,int g){
  int i,j,cnt=0,v;

  for(i=g;i<n;i++){
    v= a[i];
    j=i-g;
    while(j>=0 && a[j]>v){
      a[j+g]=a[j];
      j=j-g;
      cnt++;
    }
    a[j+g]=v;
  }
  return cnt;
}

void shellSort(int a[], int n){
  int i,cnt=0,m;
  
  for(int h=1;;){
    if(h>n)
      break;
  g.push_back(h);
  h=3*h+1;
  }
  m=g.size();
  for(i=m-1;i>=0;i--)
    cnt=cnt+insertionSort(a,n,g[i]);

  for(i=0;i<m-1;i++)
    cout << g[i] << " ";
  cout << c[m-1] << "\n";
  for(i=0;i<n;i++)
    cout << a[i] << "\n";
  cout << cnt << "\n";
}

int main(void){
  int i,n,a[ArrayNum];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  shellSort(a,n);

}



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

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

#define ArrayNum 100

vector<int> g;

int insertionSort(int a[],int n,int g){
  int i,j,cnt=0,v;

  for(i=g;i<n;i++){
    v= a[i];
    j=i-g;
    while(j>=0 && a[j]>v){
      a[j+g]=a[j];
      j=j-g;
      cnt++;
    }
    a[j+g]=v;
  }
  return cnt;
}

void shellSort(int a[], int n){
  int i,cnt=0,m;
  
  for(int h=1;;){
    if(h>n)
      break;
  g.push_back(h);
  h=3*h+1;
  }
  m=g.size();
  for(i=m-1;i>=0;i--)
    cnt=cnt+insertionSort(a,n,g[i]);

  for(i=0;i<m-1;i++)
    cout << g[i] << " ";
  cout << g[m-1] << "\n";
  for(i=0;i<n;i++)
    cout << a[i] << "\n";
  cout << cnt << "\n";
}

int main(void){
  int i,n,a[ArrayNum];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  shellSort(a,n);

}



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

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

#define ArrayNum 100

vector<int> g;

int insertionSort(int a[],int n,int g){
  int i,j,cnt=0,v;

  for(i=g;i<n;i++){
    v= a[i];
    j=i-g;
    while(j>=0 && a[j]>v){
      a[j+g]=a[j];
      j=j-g;
      cnt++;
    }
    a[j+g]=v;
  }
  return cnt;
}

void shellSort(int a[], int n){
  int i,cnt=0,m;
  
  for(int h=1;;){
    if(h>n)
      break;
  g.push_back(h);
  h=3*h+1;
  }
  m=g.size();
  for(i=m-1;i>=0;i--)
    cnt=cnt+insertionSort(a,n,g[i]);

  for(i=m-1;i>0;i--)
    cout << g[i] << " ";
  cout << g[0] << "\n";
  for(i=0;i<n;i++)
    cout << a[i] << "\n";
  cout << cnt << "\n";
}

int main(void){
  int i,n,a[ArrayNum];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  shellSort(a,n);

}



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

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

#define ArrayNum 100

vector<int> g;

int insertionSort(int a[],int n,int g){
  int i,j,cnt=0,v;

  for(i=g;i<n;i++){
    v= a[i];
    j=i-g;
    while(j>=0 && a[j]>v){
      a[j+g]=a[j];
      j=j-g;
      cnt++;
    }
    a[j+g]=v;
  }
  return cnt;
}

void shellSort(int a[], int n){
  int i,cnt=0,m;
  
  for(int h=1;;){
    if(h>n)
      break;
  g.push_back(h);
  h=3*h+1;
  }
  m=g.size();
  for(i=m-1;i>=0;i--)
    cnt=cnt+insertionSort(a,n,g[i]);

  for(i=m-1;i>0;i--)
    cout << g[i] << " ";
  cout << g[0] << "\n";
  cout << cnt << "\n";
  for(i=0;i<n;i++)
    cout << a[i] << "\n";

}

int main(void){
  int i,n,a[ArrayNum];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  shellSort(a,n);

}



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