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

#include<iostream>
using namespace std;
static int cnt = 0;

void insertionSort(int A[], int n, int g) {
    int v, i, j;

    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;
    }
}

void print(int m, int G[], int A[], int n) {
    cout << m << endl;
    for (int i=0; i<m; i++) {
        if (i>0) cout << " ";
        cout << G[i];
    cout << endl;
    cout << cnt << endl;
    for (int i=0; i<n; i++) {
        cout << G[i] << endl;
    }
}

void shellSort(int A[], int n) {
    int i, G[100];
    int g=0;
    int m=0;
    
    while (m<100 && g<=n) {
        g = 3*g+1;
        m++;
    }
    g = 0;
    for (i=m-1; i>=0; m--) {
        g = 3*g+1;
        G[i] = g;
    }

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

    print(m, G, A, n);
}

int main() {
    int A[1000000], n;

    cin >> n;

    for (int i=0; i<n; i++) cin >> A[i];

    shellSort(A, n);

    return 0;
}


Compiler output:
a.cc: In function 'void print(int, int*, int*, int)':
a.cc:32:32: error: a function-definition is not allowed here before '{' token
   32 | void shellSort(int A[], int n) {
      |                                ^
a.cc:52:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   52 | int main() {
      |         ^~
a.cc:52:9: note: remove parentheses to default-initialize a variable
   52 | int main() {
      |         ^~
      |         --
a.cc:52:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:52:12: error: a function-definition is not allowed here before '{' token
   52 | int main() {
      |            ^
a.cc:62:2: error: expected '}' at end of input
   62 | }
      |  ^
a.cc:20:44: note: to match this '{'
   20 | void print(int m, int G[], int A[], int n) {
      |                                            ^
Language: C++

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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

// 間隔gを指定した挿入ソート
void insertionSort(int A[], 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];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    //数列G = {1, 4, 13, 40, 121, 364, 1093,...}を生成
    for ( int h = 1;; ) {
        if ( h > n ) break;
        G.push_back(h);
        h = 3*h + 1;
    }
    
    for ( int i = G.size()-1; i >= 0; i-- ) { // 逆順にG[i] = gを指定
    insertionSort(A, n, G[i]);
    }
}

int main(void) {
    cin >> n;
    // より速い入力scanf関数を使用
    for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for ( int i = G.size() - 1; i >= 0; i-- ) {
        printf("%d", G[i]);
        if( i ) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

    return
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:1: error: expected primary-expression before '}' token
   59 | }
      | ^
a.cc:58:11: error: expected ';' before '}' token
   58 |     return
      |           ^
      |           ;
   59 | }
      | ~
Language: C++

#include <iostream>
#include <iomanip>
#include <math.h>
#include <fstream>
#include <string>
#include <time.h>
#include <ctime>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cstdlib>
using namespace std;

int cnt;

void insertionSort(int A[],int n,int g){
	
	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;
	}
	
}

void shellSort(int A[],int n){
	cnt = 0;
	int n=1000000;
	int G[1000];
	int i=0;
	int m;
	
	while(n){
		
		G[i] = n/2;
		n /= 2;
		i++;

	}
	m = i;


	for(int i=0;i<m;i++){
		insertionSort(A,n,G[i]);
	}
	cout << m << endl;
	for(int i=0;i<m;i++){
		if(i)cout << ' ';
		cout << G[i];
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0;i<n;i++){
		if(i)cout << " ";
		cout << A[i] << endl;
	}
}

int main(){

	int n,A[1000000];

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	shellSort(A,n);

	return 0;
}

Compiler output:
a.cc: In function 'void shellSort(int*, int)':
a.cc:40:13: error: declaration of 'int n' shadows a parameter
   40 |         int n=1000000;
      |             ^
a.cc:38:28: note: 'int n' previously declared here
   38 | void shellSort(int A[],int n){
      |                        ~~~~^
Language: C++

/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D&lang=jp*/
#include <iostream>
#include <algorithm>

using namespace std;

void insertionSort(int *a,int n,int g,int *cnt){
    for(int i=g;i<n;i++){
        int v=a[i];
        int j=i-g;
        while(-1<j && v<a[j]){
            a[j+g]=a[j];
            j-=g;
            (*cnt)++;
        }
        a[j+g]=v;
    }
}

void shellSort(int *a,int n){
    int cnt=0;
    vector<int> g(1,1);

    while(3*g.back()+1<=n){
        g.push_back(3*g.back()+1);
    }
    reverse(begin(g),end(g));
    cout<<g.size()<<endl;
    vector<int>::iterator it=g.begin();
    cout<<*it;
    it++;
    while(it!=g.end()){
        cout<<" "<<*it;
        it++;
    }
    cout<<endl;
    for(int i:g){
        insertionSort(a,n,i,&cnt);
    }
    cout<<cnt<<endl;
    for(int i=0;i<n;i++){
        cout<<a[i]<<endl;
    }
}

int main(){
    int n;
    int a[1000000];

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    shellSort(a,n);
    return 0;
}

Compiler output:
a.cc: In function 'void shellSort(int*, int)':
a.cc:22:5: error: 'vector' was not declared in this scope
   22 |     vector<int> g(1,1);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <algorithm>
  +++ |+#include <vector>
    4 | 
a.cc:22:12: error: expected primary-expression before 'int'
   22 |     vector<int> g(1,1);
      |            ^~~
a.cc:24:13: error: 'g' was not declared in this scope
   24 |     while(3*g.back()+1<=n){
      |             ^
a.cc:27:19: error: 'g' was not declared in this scope
   27 |     reverse(begin(g),end(g));
      |                   ^
a.cc:29:12: error: expected primary-expression before 'int'
   29 |     vector<int>::iterator it=g.begin();
      |            ^~~
a.cc:30:12: error: 'it' was not declared in this scope; did you mean 'int'?
   30 |     cout<<*it;
      |            ^~
      |            int
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int cnt = 0;
void insertionSort( vector<int> &elems, int n, int g )
{
	int i, j, v;
	for( i=0; i<n; i++ ) {
		v = elems[i];
		j = i - g;
		while( 0 <= j and v < elems[j] ) {
			elems[ j+g ] = elems[j];
			j -= g;
			cnt++;
		}
		elems[ j+g ] = v;
	}
	return;
}

void shellSort( vector<int> &elems, int n )
{
	cnt = 0;
	int m;
	vector<int> G(100);
	
	G[0] = 1;
	for( int i=1; ; i++ ) {
		m = G[ i-1 ]*3+1;
		if( m < n ) { 
			G[i] = m;
		} else {
			m = i;
			break;
		}
	}
	cout<<m<< '\n';	
	sort( G.rbegin( ), G.rend( ) );
	for( int i=0; i<m; i++ ) {
		cout<<G[i];
		if( i != G.size( )-1 ) { cout<<" "; }
	}
	cout<<'\n';
	
	for( int i=0; i<m; i++ ) {
		insertionSort( elems, n, G[i] );
	}
	cout<<cnt<<'\n';
	
	return;
}

int main( )
{	
    int n;
    cin>>n;
    
    vector<int> elems(n);
    for( int i=0; i<n; i++ ) {
    	cin>>elems[i];
    }
    
    shellSort( elems, n );
    for( int i=0; i<n; i++ ) {
    	cout<<elems[i]<<'\n';
    }	
	return 0;
}

Compiler output:
a.cc: In function 'void shellSort(std::vector<int>&, int)':
a.cc:40:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   40 |         sort( G.rbegin( ), G.rend( ) );
      |         ^~~~
      |         short
Language: C++

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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], 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];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n){
	for(int h = 1; ;){
		if( h > n ) break;
		G.push_back(h);
		h = 3*h + 1;
	}

	for(int i = G.size() - 1; i >= 0; i-- ){
		insertionSort( A, n, G[i]);
	}
}

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

	cout << G.size() << endl;
	for(int i = G.size() - 1; i >= 0; i-- ){
		printf("%d", G[i]);
		if(i) printf(" ");
	}
	printf("\n");
	printf("%d\n", cnt);
	for(int i = 0; i < n; i++ ) printf("%d\n", A[i]);

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:16: error: expected ';' before 'shellSort'
   42 |         cnt = 0
      |                ^
      |                ;
   43 | 
   44 |         shellSort(A, n);
      |         ~~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using mamespace std;

long long cnt;
int l;
int A[10000000];
int n;
vector<int> G;

void insert(int A[],int n,int g){
  int i,j,v,cnt=0;
  for(i=g;i<n-1;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;
  }
}

void shellsort(A[],n){
  int i;
  for(i=1;;){
    if(i>n)break;
    G.push_back(i);
    i=i*3+1;
  }
  for(j=G.size()-1;j>=0;j--){
    insert(A,n,G[i]);
  }
}
int main(){
  int i,j;

  cin >> n;
  for(i=0;i<n;i++){
    cin >> A[i];
  }
  cnt=0;
  shellsort(A,n);

  cout<<G.size()<<endl;

  for(i=G.size();i>=0;i--){
    cout << G[i];
    if(i){
    cout << " ";
    }
  }
  cout << endl;
  cout << cnt<<endl;

  for(i=0;i<n;i++){
    cout << A[i]<< endl;
  }
}

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'mamespace'
    4 | using mamespace std;
      |       ^~~~~~~~~
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<int> G;
      | ^~~~~~
a.cc: In function 'void insert(int*, int, int)':
a.cc:20:12: error: expected ';' before ':' token
   20 |       cnt++:
      |            ^
      |            ;
a.cc: At global scope:
a.cc:26:6: error: variable or field 'shellsort' declared void
   26 | void shellsort(A[],n){
      |      ^~~~~~~~~
a.cc:26:18: error: expected primary-expression before ']' token
   26 | void shellsort(A[],n){
      |                  ^
a.cc: In function 'int main()':
a.cc:40:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   40 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:45:3: error: 'shellsort' was not declared in this scope
   45 |   shellsort(A,n);
      |   ^~~~~~~~~
a.cc:47:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   47 |   cout<<G.size()<<endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:47:9: error: 'G' was not declared in this scope
   47 |   cout<<G.size()<<endl;
      |         ^
a.cc:47:19: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   47 |   cout<<G.size()<<endl;
      |                   ^~~~
      |                   std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <iostream>
#include <algorithm>

std::vector<unsigned> gaps;

unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap = 1){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

void make_gap_table(unsigned n){
  unsigned h = 1;
  unsigned i = 1;
  while(h <= n){
    gaps.push_back(h);
    h = pow(4,i) + 3*pow(2,i-1) + 1;
    i++;
  }
}

void shell_sort(unsigned a[], unsigned n){
  make_gap_table(n);
  unsigned count = 0;
  for(int i=gaps.size()-1;i;i--){
    count += insertion_sort(a,n,v);
  }

  std::cout << gaps.size() << '\n';

  for(int i=gaps.size()-1;i-1;i--){
    std::cout << gaps[i] << ' ';
  }
  std::cout << gaps[0] << '\n';

  std::cout << count << '\n';
}

int main(){
  unsigned n;
  unsigned buf;
  std::vector<unsigned> a;
  std::cin >> n;
  for(unsigned i = 0; i < n; i++){
    std::cin >> buf;
    a.push_back(buf);
  }

  shell_sort(a.data(),a.size());
  for(auto &v : a){
    std::cout << v << '\n';
  }
}

Compiler output:
a.cc:4:6: error: 'vector' in namespace 'std' does not name a template type
    4 | std::vector<unsigned> gaps;
      |      ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | 
a.cc: In function 'void make_gap_table(unsigned int)':
a.cc:25:5: error: 'gaps' was not declared in this scope
   25 |     gaps.push_back(h);
      |     ^~~~
a.cc:26:9: error: 'pow' was not declared in this scope
   26 |     h = pow(4,i) + 3*pow(2,i-1) + 1;
      |         ^~~
a.cc: In function 'void shell_sort(unsigned int*, unsigned int)':
a.cc:34:13: error: 'gaps' was not declared in this scope
   34 |   for(int i=gaps.size()-1;i;i--){
      |             ^~~~
a.cc:35:33: error: 'v' was not declared in this scope
   35 |     count += insertion_sort(a,n,v);
      |                                 ^
a.cc:38:16: error: 'gaps' was not declared in this scope
   38 |   std::cout << gaps.size() << '\n';
      |                ^~~~
a.cc: In function 'int main()':
a.cc:51:8: error: 'vector' is not a member of 'std'
   51 |   std::vector<unsigned> a;
      |        ^~~~~~
a.cc:51:8: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:51:15: error: expected primary-expression before 'unsigned'
   51 |   std::vector<unsigned> a;
      |               ^~~~~~~~
a.cc:55:5: error: 'a' was not declared in this scope
   55 |     a.push_back(buf);
      |     ^
a.cc:58:14: error: 'a' was not declared in this scope
   58 |   shell_sort(a.data(),a.size());
      |              ^
Language: C++

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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

// ??????g ????????????????????\?????????
void insertionSort(int A[], int n, intg) {
  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];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  // ??°???G = {1, 4, 13, 40, 121, 364, 1093, ...} ?????????
  for ( int h = 1; ;  ) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i-- ) { // ?????????G[i] = g ?????????
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  // ??????????????\???scanf ??¢??°????????¨
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  for ( int i = G.size() - 1; i >= 0; i-- ) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}

Compiler output:
a.cc:15:36: error: 'intg' has not been declared
   15 | void insertionSort(int A[], int n, intg) {
      |                                    ^~~~
a.cc: In function 'void insertionSort(int*, int, int)':
a.cc:16:17: error: 'g' was not declared in this scope
   16 |   for ( int i = g; i < n; i++ ) {
      |                 ^
Language: C++

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

unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913};
// generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

void shell_sort(unsigned a[], unsigned n){
  unsigned gap_num = 0;
  while(gaps[++gap_num] < n);
  gap_num--;

  unsigned count = 0;
  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);

  printf("%d\n",(gap_num+1));

  for(int i = gap_num; i; i--) printf("%d ",gaps[i]);
  printf("%d\n",gaps[0]);

  printf("%d\n",count);
}

int main(){
  unsigned n;
  scanf("%u",&n);
  unsigned* a = malloc(sizeof(unsigned)*n);
  for(unsigned i = 0; i < n; i++) scanf("%u",&a[i]);
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) printf("%d\n",a[i]);
  free(a);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:23: error: invalid conversion from 'void*' to 'unsigned int*' [-fpermissive]
   41 |   unsigned* a = malloc(sizeof(unsigned)*n);
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~
      |                       |
      |                       void*
Language: C++


#include <utility>

using namespace std;

#define ELEMENT_MAX 1000000

int elements[ELEMENT_MAX];

void output(int n, int elements[])
{
	for (int i = 0; i < n; i++)
		cout << elements[i] << endl;
}

int insertion_sort(int n, int elements[], int g)
{
	int cnt = 0;
	for (int i = g; i < n; i++) {
		int key = elements[i], j = i - g;
		while (key < elements[j] && 0 <= j) {
			elements[j + g] = elements[j];
			j -= g;
			cnt++;
		}
		elements[j + g] = key;
	}
	return cnt;
}

void shell_sort(int n, int elements[])
{
	int cnt = 0, m = 0, g_calc = 1, g[100];
	while (g_calc <= n) {
		g[m] = g_calc;
		g_calc *= 4;
		m++;
	}
	cout << m << endl;
	for (int i = m - 1; 0 <= i; i--) {
		cout << g[i] << (i == 0 ? "" :  " ");
		cnt += insertion_sort(n, elements, g[i]);
	}
	cout << endl;
	cout << cnt << endl;
}

int main()
{
	int n;

	// input
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> elements[i];

	// sort
	shell_sort(n, elements);
	output(n, elements);
	return 0;
}

Compiler output:
a.cc: In function 'void output(int, int*)':
a.cc:13:17: error: 'cout' was not declared in this scope
   13 |                 cout << elements[i] << endl;
      |                 ^~~~
a.cc:3:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <utility>
  +++ |+#include <iostream>
    3 | 
a.cc:13:40: error: 'endl' was not declared in this scope
   13 |                 cout << elements[i] << endl;
      |                                        ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <utility>
  +++ |+#include <ostream>
    3 | 
a.cc: In function 'void shell_sort(int, int*)':
a.cc:39:9: error: 'cout' was not declared in this scope
   39 |         cout << m << endl;
      |         ^~~~
a.cc:39:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:22: error: 'endl' was not declared in this scope
   39 |         cout << m << endl;
      |                      ^~~~
a.cc:39:22: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc: In function 'int main()':
a.cc:53:9: error: 'cin' was not declared in this scope
   53 |         cin >> n;
      |         ^~~
a.cc:53:9: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
#include <utility>

using namespace std;

#define ELEMENT_MAX 1000000

int elements[ELEMENT_MAX];

void output(int n)
{
	for (int i = 0; i < n; i++)
		cout << elements[i] << endl;
}

int insertion_sort(int n, int g)
{
	int cnt = 0;
	for (int i = g; i < n; i++) {
		int key = elements[i],
			j = i - g;
		while (key < elements[j] && 0 <= j) {
			elements[j + g] = elements[j];
			j -= g;
			cnt++;
		}
		elements[j + g] = key;
	}
	return cnt;
}

void shell_sort(int n)
{
	int cnt = 0, m = 0, g[13] = { 1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161 };
	
	for (; g[m] <= n; m++);
	cout << m << endl;
	for (int i = m - 1; 0 <= i; i--) {
		cout << g[i] << (i == 0 ? "" :  " ");
		cnt += insertion_sort(n, g[i]);
	}
	cout << endl;
	cout << cnt << endl;
}

int main()
{
	int n;

	// input
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> elements[i];

	// sort
	shell_sort(n);
	output(n);
	return 0;
}}

Compiler output:
a.cc:59:2: error: expected declaration before '}' token
   59 | }}
      |  ^
Language: C++

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

int cnt;
int l;
int A[100000];
vector<int> G;


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

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

int main(){
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> A[i];
    }
    cnt = 0;

    shellSort(A,n);

    cout << G.size() << endl;
    for (int i = G.size() -1 ; i >= 0 ; i--) {
        cout << G[i];
        if(i) cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n ; ++i) {
        cout << a[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc:11:28: error: 'n' has not been declared
   11 | void insertionSort(int A[],n,g){
      |                            ^
a.cc:11:30: error: 'g' has not been declared
   11 | void insertionSort(int A[],n,g){
      |                              ^
a.cc: In function 'void insertionSort(int*, int, int)':
a.cc:12:18: error: 'g' was not declared in this scope
   12 |     for (int i = g; i < n-1 ; ++i) {
      |                  ^
a.cc:12:25: error: 'n' was not declared in this scope
   12 |     for (int i = g; i < n-1 ; ++i) {
      |                         ^
a.cc: At global scope:
a.cc:24:24: error: 'n' has not been declared
   24 | void shellSort(int A[],n){
      |                        ^
a.cc: In function 'void shellSort(int*, int)':
a.cc:26:12: error: 'n' was not declared in this scope
   26 |     if(h > n)break;
      |            ^
a.cc:31:25: error: 'n' was not declared in this scope
   31 |         insertionSort(A,n,G[i]);
      |                         ^
a.cc: In function 'int main()':
a.cc:36:12: error: 'n' was not declared in this scope
   36 |     cin >> n;
      |            ^
a.cc:52:17: error: 'a' was not declared in this scope
   52 |         cout << a[i] << endl;
      |                 ^
Language: C++

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

int cnt;
int n;
int l;
int A[100000];
vector<int> G;


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

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

int main(){
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> A[i];
    }
    cnt = 0;

    shellSort(A,n);

    cout << G.size() << endl;
    for (int i = G.size() -1 ; i >= 0 ; i--) {
        cout << G[i];
        if(i) cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n ; ++i) {
        cout << a[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc:12:28: error: 'n' is not a type
   12 | void insertionSort(int A[],n,g){
      |                            ^
a.cc:12:30: error: 'g' has not been declared
   12 | void insertionSort(int A[],n,g){
      |                              ^
a.cc: In function 'void insertionSort(int*, int, int)':
a.cc:13:18: error: 'g' was not declared in this scope
   13 |     for (int i = g; i < n-1 ; ++i) {
      |                  ^
a.cc: At global scope:
a.cc:25:24: error: 'n' is not a type
   25 | void shellSort(int A[],n){
      |                        ^
a.cc: In function 'int main()':
a.cc:53:17: error: 'a' was not declared in this scope
   53 |         cout << a[i] << endl;
      |                 ^
Language: C++

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

int cnt;
int n;
int l;
int A[100000];
vector<int> G;


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

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

int main(){
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> A[i];
    }
    cnt = 0;

    shellSort(A,n);

    cout << G.size() << endl;
    for (int i = G.size() -1 ; i >= 0 ; i--) {
        cout << G[i];
        if(i) cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n ; ++i) {
        cout << a[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:17: error: 'a' was not declared in this scope
   53 |         cout << a[i] << endl;
      |                 ^
Language: C++

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

int cnt;
int n;
int l;
int A[1000000];
vector<int> G;


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

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

int main(){
    cin >> n;
	for (long i = 0; i < n; i++) cin >> A[i];
    cnt = 0;

    shellSort(A,n);

    cout << G.size() << endl;
    for (int i = G.size() -1 ; i >= 0 ; i--) {
        cout << G[i];
        if(i) cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n ; ++i) {
        cout << a[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:17: error: 'a' was not declared in this scope
   51 |         cout << a[i] << endl;
      |                 ^
Language: C++

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

int cnt;
int n;
int l;
int A[1000000];
vector<int> G;

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

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

int main(){
    cin >> n;
	for (long i = 0; i < n; i++) cin >> A[i];
    cnt = 0;

    shellSort(A,n);

    cout << G.size() << endl;
    for (int i = G.size() -1 ; i >= 0 ; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n ; ++i) {
        cout << a[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:17: error: 'a' was not declared in this scope
   53 |         cout << a[i] << endl;
      |                 ^
Language: C++

#include<iostream>
using namespace std;

long long pow(int x, int n){ //x^n
	if (n==0)
		return 1;
	else
		return x * pow(x, n-1);

}

void show(int arr[], int N){
	for(int i=0; i<N; i++)
		if(i<N-1)
			cout<<arr[i]<<' '<<flush;
		else
			cout<<arr[i]<<flush;
	cout<<endl;
}


void swap(int& a, int& b){
	int t=a;
	a=b;
	b=t;
}


int ShellSort(int* arr, int N);
int InsertionSort_r(int* arr, int N, int range);

int main()
{
	int N;cin>>N;

	int* arr= new int[N];

	for(int i=0; i<N; i++)
		cin>>arr[i];

	int count=ShellSort(arr, N);

	cout<<count<<endl;
	for(int i=0; i<N; i++)
		cout<<arr[i]<<endl;
}


int ShellSort(int* arr, int N)
{
	int counter;

	int i;
	for(i=1; pow(2, i)-1 < N; i++);

	int* range=new int[i];

	for(int j=1; j<i; j++)
		range[i - j]=pow(2, j)-1; 

	range[0] = i;  //range = { 4,(<-?????????????´???°)  1, 3, 7 }

	cout<<range[0] - 1 <<endl;
	for(int i=1; i<range[0]; i++)
		cout<<range[i]<<' '<<flush;
	cout<<endl;

	for( int i=1; i<range[0]; i++) 
		counter=InsertionSort_r(arr, N, range[ i ]);
	
	
	return counter;
	
	



	
}

int InsertionSort_r(int arr[], int N, int range)
{

	
	int cnt=0, comp, j;

	
	for( int i=0; i<range && ; i++) {


		for( int compindex =range ; compindex < N && conpindex+range <N; compindex += range ) {


			comp=arr[compindex];

			j=range;

			for( ; compindex - j >= 0 ; j+=range ) {

				if( comp < arr[ compindex - j ] )
					arr[ compindex - j + range ] = arr[ compindex - j ];
					cnt++;
				else 
					break;
			}

			arr[ compindex - j + range ] = comp;

		}

	}

	return cnt;
}














		



		

Compiler output:
a.cc: In function 'int InsertionSort_r(int*, int, int)':
a.cc:88:34: error: expected primary-expression before ';' token
   88 |         for( int i=0; i<range && ; i++) {
      |                                  ^
a.cc:91:62: error: 'conpindex' was not declared in this scope; did you mean 'compindex'?
   91 |                 for( int compindex =range ; compindex < N && conpindex+range <N; compindex += range ) {
      |                                                              ^~~~~~~~~
      |                                                              compindex
a.cc:103:33: error: 'else' without a previous 'if'
  103 |                                 else
      |                                 ^~~~
Language: C++

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

void show(int arr[], int N){
	for(int i=0; i<N; i++)
		if(i<N-1)
			cout<<arr[i]<<' '<<flush;
		else
			cout<<arr[i]<<flush;
	cout<<endl;
}


void swap(int& a, int& b){
	int t=a;
	a=b;
	b=t;
}


int ShellSort(int* arr, int N);
int InsertionSort_r(int* arr, int N, int r);

int main()
{
	int N;cin>>N;

	int* arr= new int[N];

	for(int i=0; i<N; i++)
		cin>>arr[i];

	int count=ShellSort(arr, N);

	cout<<count<<endl;

	for( int i=0; i<N; i++)
		cout<<arr[i]<<endl;

	delete[] arr;
}


int ShellSort(int* arr, int N)
{
	int counter=0;


	vector<int> range;

	for( int i=1; i<N; i= i*3 +1 )
		range.push_back(i);






	
	cout<<range.size()<<endl;

	for( int i=range.size() -1; i >=0; i-- )
		cout<<range[ i ]<<' '<<flush;
	cout<<endl;







	 

	for( int i=range.size() -1; i>=0; i-- ) 
		counter=InsertionSort_r(arr, N, range[ i ]);
	
	return counter;

	
	



	
}

int InsertionSort_r(int arr[], int N, int r)
{

	static int counter=0;
	int compindex;
	int comp;
	int j;

	
	for( int i=0; i<r; i++) {


		for( int compindex=N- r -1 -i ; compindex> -1; compindex-=r ){
			
			comp=arr[compindex];
			j=r;
			for( ; compindex+j<N; j+=r ){

				if(comp > arr[compindex+j]){
					arr[compindex + j -r] = arr[compindex + j];
					counter++;
				}
				else
					break;
				
			}
			arr[compindex + j - r] = comp;

		


		}
	}
	return counter;
}
/* ?§£??????????????????????????????
	  o x x o x x x *
	  o x x o x x o *
	  x o x x o x x
	  x x o x x o x
  ??¨???????????????????????????????????????????????§???
  	  o x x o x x x *
	  x o x x o x x
	  x x o x x o x
	  o x x o x x o *
?????¨?????????????§£?????????
????????????????????¨????????????????????????(0.2?§????????§£?????????????????????????)
   
int InsertionSort_r(int arr[], int N, int r)
{
	static int cnt=0;
	bool changed=false;
	for( int compindex=r; compindex<N; compindex++) {

		int comp= arr[compindex];

		int j=compindex - r;

		for( ; j>=0; j-=r ) {
			if(arr[j] > comp){
				arr[ j+r ]=arr[j];
				cnt++;
				changed=true;
			}
			else
				break;
		}

		arr[ j+r ] =comp;


		changed=false;
	}
	return cnt;
}
*

Compiler output:
a.cc:123:1: error: unterminated comment
  123 | /* ?§£??????????????????????????????
      | ^
Language: C++

int cnt;

void insertionSort(int A[], 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];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n)
{
	cnt = 0;
	int m = n > 2 ? n / 2 : n;
	int G[100];
	
	G[0] = 1;
	for (int i = 1; i < m; i++)
		G[i] = 3 * G[i - 1] + 1;

	cout << m << "\n";
	for (int i = m - 1; i >= 0; i--) {
		cout << G[i];
		if (i != 0) cout << " ";
	}
	cout << "\n";

	for (int i = m - 1; i >= 0; i--)
		insertionSort(A, n, G[i]);
}

int main()
{
	int n;
	cin >> n;
	int *p = new int[n];

	for (int i = 0; i < n; i++) cin >> p[i];

	shellSort(p, n);
	cout << cnt << "\n";
	for (int i = 0; i < n; i++)
		cout << p[i] << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'void shellSort(int*, int)':
a.cc:27:9: error: 'cout' was not declared in this scope
   27 |         cout << m << "\n";
      |         ^~~~
a.cc: In function 'int main()':
a.cc:41:9: error: 'cin' was not declared in this scope
   41 |         cin >> n;
      |         ^~~
a.cc:47:9: error: 'cout' was not declared in this scope
   47 |         cout << cnt << "\n";
      |         ^~~~
Language: C++

using System;
using System.Collections.Generic;

public class ShellSort
{

	public int cnt = 0;

	// ?????§???????????????????????¢?????´?????????
	public void sort (int[] T, int n)
	{		

		//int[] G = new int[m];
		List<int> G = new List<int>();
					
		// G????¨????
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				//G [i] = 1; // G_0 = ??¨????????????
				G.Add(1);					
				continue;
			}
			int next = 3 * G [i - 1] + 1;
			if (n < next) {
				break;
			}
			G.Add (next);
		}

//		// G???????¨????
//		for (int i = 0; i < n; i++) {
//			if (G [i] > n) {
//				G.RemoveAt (i);
//			}
//		}

		int m = G.Count;

		Console.WriteLine (m);
			
		// G??????????????????????????????(???????????§????????????????????????????????????)		
		G.Reverse ();
				
		for (int i = 0; i < G.Count; i++) {
			insertionSort (T, n, G [i]);
		}			

		// ???????????? 1:m?????? 2:G?????????????????? 3:cnt?????? 4?????\???:?????????????????????
		// 1:m
		Console.WriteLine (m);
		for (int i = 0; i < G.Count; i++) {
			// 2:G
			if (i == G.Count - 1) {
				Console.WriteLine (G [i]);
				continue;
			}
			Console.Write (G [i] + " ");
		}
		// 3:cnt
		Console.WriteLine (cnt);

		// 4:?????????????????????
		for (int i = 0; i < n; i++) {
			Console.WriteLine (T [i]);
		}
	}

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

	public static void Main ()
	{
		int N = int.Parse (Console.ReadLine ());
		int[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input [i] = int.Parse (Console.ReadLine ());
		}		
		ShellSort shellSort = new ShellSort ();
		shellSort.sort (input, N);
	}
    
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class ShellSort
      | ^~~~~~
Language: C++

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

typedef vector<int> List;

int InsertionSort(List& A, int n, int g);
void ShellSort(List& A, int n);
List GetG(int n);
void OutputG(List G);
void Output(List A);

int InsertionSort(List& A, int n, int g)
{
    int count = 0;
    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];
            j = j - g;
            count++;
        }
        A[j+g] = v;
    }
    return count;
}

void ShellSort(List& A, int n)
{
    int count = 0;
    List G = GetG(n);
    OutputG(G);
    for(int i = 0; i < G.size(); i++){
        count += InsertionSort(A, n, G[i]);
    }
    cout << count << endl;
}

List GetG(int n)
{
    int h = 1;
    List G;
    while(h < n){
        G.push_back(h);
        h = h * 3 + 1;
    }
    reverse(G.begin(), G.end());
    cout << G.size() << endl;
    return G;
}

int main(){
    int n;
	List Num;
	
    cin >> n;

    Num.clear();
	for(int i = 0; i < n; i++){
		int Value;
		cin >> Value; 
		Num.push_back(Value);
	}
    ShellSort(Num, n);
    
    Output(Num);
}

void OutputG(List G)
{
    for(int i = 0; i < G.size(); i++){
        if(i > 0)   cout << " ";
        cout << G[i];
    }
    cout << endl;
}

void Output(List A)
{
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << endl;
    }
}

Compiler output:
a.cc: In function 'List GetG(int)':
a.cc:49:5: error: 'reverse' was not declared in this scope
   49 |     reverse(G.begin(), G.end());
      |     ^~~~~~~
Language: C++

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

typedef vector<int> List;

int InsertionSort(List& A, int n, int g);
void ShellSort(List& A, int n);
List GetG(int n);
void OutputG(List G);
void Output(List A);

int InsertionSort(List& A, int n, int g)
{
    int count = 0;
    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];
            j = j - g;
            count++;
        }
        A[j+g] = v;
    }
    return count;
}

void ShellSort(List& A, int n)
{
    int count = 0;
    List G = GetG(n);
    OutputG(G);
    for(int i = 0; i < G.size(); i++){
        count += InsertionSort(A, n, G[i]);
    }
    cout << count << endl;
}

List GetG(int n)
{
    int h = 1;
    List G;
    while(h < n){
        G.push_back(h);
        h = h * 3 + 1;
    }
    reverse(G.begin(), G.end());
    cout << G.size() << endl;
    return G;
}

int main(){
    int n;
	List Num;
	
    cin >> n;

    Num.clear();
	for(int i = 0; i < n; i++){
		int Value;
		cin >> Value; 
		Num.push_back(Value);
	}
    ShellSort(Num, n);
    
    Output(Num);
}

void OutputG(List G)
{
    for(int i = 0; i < G.size(); i++){
        if(i > 0)   cout << " ";
        cout << G[i];
    }
    cout << endl;
}

void Output(List A)
{
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << endl;
    }
}

Compiler output:
a.cc: In function 'List GetG(int)':
a.cc:48:5: error: 'reverse' was not declared in this scope
   48 |     reverse(G.begin(), G.end());
      |     ^~~~~~~
Language: C++

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

int InsertionSort(vector<int>& A, int n, int g);
void ShellSort(vector<int>& A, int n);
vector<int> GetG(int n);
void OutputG(vector<int> G);
void Output(vector<int> A);

int InsertionSort(vector<int>& A, int n, int g)
{
    int count = 0;
    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];
            j = j - g;
            count++;
        }
        A[j+g] = v;
    }
    return count;
}

void ShellSort(vector<int>& A, int n)
{
    int count = 0;
    vector<int> G = GetG(n);
    OutputG(G);
    for(int i = 0; i < G.size(); i++){
        count += InsertionSort(A, n, G[i]);
    }
    cout << count << endl;
}

vector<int> GetG(int n)
{
    int h = 1;
    vector<int> G;
    while(h < n){
        G.push_back(h);
        h = h * 3 + 1;
    }
    reverse(G.begin(), G.end());
    cout << G.size() << endl;
    return G;
}

int main(){
    int n;
	vector<int> Num;
	
    cin >> n;

    Num.clear();
	for(int i = 0; i < n; i++){
		int Value;
		cin >> Value; 
		Num.push_back(Value);
	}
    ShellSort(Num, n);
    
    Output(Num);
}

void OutputG(vector<int> G)
{
    for(int i = 0; i < G.size(); i++){
        if(i > 0)   cout << " ";
        cout << G[i];
    }
    cout << endl;
}

void Output(vector<int> A)
{
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << endl;
    }
}

Compiler output:
a.cc: In function 'std::vector<int> GetG(int)':
a.cc:47:5: error: 'reverse' was not declared in this scope
   47 |     reverse(G.begin(), G.end());
      |     ^~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int tst_count;

void inserSort(int A[], int n, int g){
    if (g > n) return;
    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;
            tst_count++;
        }
        A[j + g] = v;
    }
}

void shell(int A[],int n){
    tst_count = 0;
    m = 6;
    int G[6] = {364,121,40,13,4,1};
    
    while (G[m-1] > n) {
        m--;
    }
    
    for (int i = 0; i < m; i++) {
        inserSort(A,n,G[i]);
    }
    
    cout << m << endl << G[0];
    for (int i = 1; i < m; i++) {
        cout << " " << G[i];
    }
    cout << endl;
}

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

Compiler output:
a.cc: In function 'void inserSort(int*, int, int)':
a.cc:13:9: error: 'v' was not declared in this scope
   13 |         v = A[i];
      |         ^
a.cc:14:9: error: 'j' was not declared in this scope
   14 |         j = i - g;
      |         ^
a.cc: In function 'void shell(int*, int)':
a.cc:26:5: error: 'm' was not declared in this scope
   26 |     m = 6;
      |     ^
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int tst_count;

void inserSort(int A[], int n, int g){
    if (g > n) return;
    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];
            j = j - g;
            tst_count++;
        }
        A[j + g] = v;
    }
}

void shell(int A[],int n){
    tst_count = 0;
    int m = 7;
    int G[6] = {1,4,13,40,121,364,1093};
    
    while (G[m-1] > n) {
        m--;
    }

    for (int i = m-1; i >= 0; i--) {
        inserSort(A,n,G[i]);
    }
    
    cout << m << endl << G[m-1];
    for (int i = m-2; i >= 0; i--) {
        cout << " " << G[i];
    }
    cout << endl << tst_count << endl;
}

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

Compiler output:
a.cc: In function 'void shell(int*, int)':
a.cc:27:39: error: too many initializers for 'int [6]'
   27 |     int G[6] = {1,4,13,40,121,364,1093};
      |                                       ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int n, a[1111111], c, g[20];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	g[0] = 1; c = 1;
	while(true) {
		g[c + 1] = g[c] * 3 + 1;
		if(g[c + 1] >= n) break;
		c++;
	}
	int ret = 0;
	for(int i = c - 1; i >= 0; i--) {
		for(int j = g[i]; j < n; j--) {
			int v = a[j], w = j - g[i];
			while(w >= 0 && a[w] > v) {
				a[w + g[i]] = a[w];
				w -= g[i];
				ret++;
			}
			a[w + g] = v;
		}
	}
	cout << c << endl;
	for(int i = c - 1; i >= 0; i++) {
		if(i) cout << g[i] << ' ';
		else cout << g[i] << endl;
	}
	cout << ret << endl;
	for(int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:26: error: invalid types 'int [1111111][int*]' for array subscript
   27 |                         a[w + g] = v;
      |                          ^
Language: C++

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

int ShellSort(int elem[], int num)
{
    int i, j, k;
    int h;
    long long target;
    long long cnt = 0;
    vector<long long> vect;

    for (i = 0; i < num; i++) {
        h = 3 * i + 1;
        if (h <= num) {
            vect.push_back(h);
        }
        else {
            break;
        }
    }

    h = vect.size() - 1;
    cout << h+1 << endl;
    for (i = h; i >= 0; i--) {
        int g = vect[i];
        if (i != h) {
            cout << " ";
        }
        cout << g;
        for (j = g; j < num; j++) {
            target = elem[j];
            for (k = j - g; k >= 0; k -= g) {
                if (elem[k] > target) {
                    elem[k + g] = elem[k];
                    ++cnt;
                }
                else {
                    break;
                }
            }
            elem[k + g] = target;
        }
    }
    cout << endl;

    return cnt;
}

int main(void)
{
    int i;
    long long cnt;
    int num;
    long long elem[1000000];

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d", &elem[i]);
    }

    cnt = ShellSort(elem, num);

    cout << cnt << endl;
    for (i = 0; i < num; i++) {
        cout << elem[i] << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:21: error: cannot convert 'long long int*' to 'int*'
   63 |     cnt = ShellSort(elem, num);
      |                     ^~~~
      |                     |
      |                     long long int*
a.cc:6:19: note:   initializing argument 1 of 'int ShellSort(int*, int)'
    6 | int ShellSort(int elem[], int num)
      |               ~~~~^~~~~~
Language: C++

#include<stdio.h>
#include<math.h>
int A[1000000],n,cnt=0;
void insertionSort(int A[],int g){
  int i,j;
  int 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 -= g;
      cnt++;
      A[j+g] = v;
    }
  }
}

main(){
  int i;
  int m;
  double prem;
  int G[100];
  scanf("%d",&n);
  m = floor(log2(n*1.0))
  printf("%d\n",m);
  for(i=0;i<=m;i++){
    G[i]=pow(2,m-i);
    printf("%d",G[i]);
    if(i==m){
      printf("\n")
    }else{
      printf(" ")
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<m;i++){
    insertionSort(A[],G[i]);
  }
  printf("%d",cnt);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
}

Compiler output:
a.cc:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:25:25: error: expected ';' before 'printf'
   25 |   m = floor(log2(n*1.0))
      |                         ^
      |                         ;
   26 |   printf("%d\n",m);
      |   ~~~~~~                 
a.cc:31:19: error: expected ';' before '}' token
   31 |       printf("\n")
      |                   ^
      |                   ;
   32 |     }else{
      |     ~              
a.cc:33:18: error: expected ';' before '}' token
   33 |       printf(" ")
      |                  ^
      |                  ;
   34 |     }
      |     ~             
a.cc:40:21: error: expected primary-expression before ']' token
   40 |     insertionSort(A[],G[i]);
      |                     ^