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

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string str;
    for (int i = 0; i < 12; ++i){
        cin >> str;
        if(i==3){
            cout << " ";
        }
        cout << str;
    }
}
    return 0;
}

Compiler output:
a.cc:18:5: error: expected unqualified-id before 'return'
   18 |     return 0;
      |     ^~~~~~
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: C

#include <stdio.h>
#include <string.h>

int mian(){
char ary[14];
fgets(ary,sizeof(char)*4,stdin);
strcat(ary," ");
fgets(ary,sizeof(char)*8,stdin);
printf("%s\n",ary);
return 0;
}

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

#include <string>
string insertSpace(string s){
    string res = s.insert(4, " ");
    res = res.append("\n");
    return res;
}

Compiler output:
a.cc:2:1: error: 'string' does not name a type; did you mean 'stdin'?
    2 | string insertSpace(string s){
      | ^~~~~~
      | stdin
Language: C++

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

void main() {
	char s[100];
	string a;
	cin >> s;
	for (int i = 0; s[i] != '\0'; ++i) {
		if (i == 4)	
			a = a + " ";
		a = a + s[i];
	}
	cout << a;
}

Compiler output:
a.cc:5:1: error: '::main' must return 'int'
    5 | void main() {
      | ^~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <stack>
#define SIZE 12
using namespace std;
typedef long long int ll;
typedef pair <int,int> 
int main(void){
string str;
scanf("%s",str);
cout << str.substr(1,4) << " " << str.substr(5,8);
return 0;
}


Compiler output:
a.cc:16:9: error: two or more data types in declaration of 'main'
   16 | typedef pair <int,int>
      |         ^~~~~~~~~~~~~~
Language: C

#include <stdio.h>
#include <string.h>
int mian(){
char ary[14];
fgets(ary,sizeof(char)*4,stdin);
strcat(ary," ");
fgets(ary,sizeof(char)*8,stdin);
printf("%s\n",ary);
return 0;
}

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

int main(){
	
	int num;
	int counter=0;
	scanf("%d",num);
	int array[num];
	for (int i=0;i<num;i++){
		scanf("%d",&array[i]);
	}
	for (int i=0;i<num;i++){
		if(array[array[i]]=array[i]){
			count++;
		}
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |         scanf("%d",num);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(){
main.c:5:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |         scanf("%d",num);
      |         ^~~~~
main.c:5:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:12:25: error: 'count' undeclared (first use in this function); did you mean 'counter'?
   12 |                         count++;
      |                         ^~~~~
      |                         counter
main.c:12:25: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <stack>
#define SIZE 12
using namespace std;
typedef long long int ll;
typedef pair <int,int> 
int main(void){
int string str;
scanf("%s",str);
cout << str.substr(1.4) << " " << str.substr(5.8);
return 0;
}


Compiler output:
a.cc:16:9: error: two or more data types in declaration of 'main'
   16 | typedef pair <int,int>
      |         ^~~~~~~~~~~~~~
Language: Java

Public class Main{

  import java.util.*;

  public static void main(String [] args){
    Scanner sc = new Scanner (System.in);
    String in = sc.next();
    return in.substring(0,4) + " " + in.substring(4);
  }

}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
Public class Main{
^
Main.java:3: error: illegal start of type
  import java.util.*;
  ^
Main.java:3: error: <identifier> expected
  import java.util.*;
                   ^
3 errors
Language: Java

import java.util.*;
import java.io.*;
public class Test {// Main
    public static void main(String[] args){
       String Str = new String("CODEFESTIVAL");
       String a = Str.substring(0,4);
       String b = Str.substring(3);
       a = a.concat(" ");
       b = b.concat("\n");
       System.out.println(a.concat(b));
    }
}	

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

int main(){
	
	int num;
	int counter=0;
	scanf("%d",num);
	int array[num];
	for (int i=0;i<num;i++){
		scanf("%d",array[i]);
	}
	for (int i=0;i<num;i++){
		if(array[array[i]]=array[i]){
			count++;
		}
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |         scanf("%d",num);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(){
main.c:5:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |         scanf("%d",num);
      |         ^~~~~
main.c:5:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:12:25: error: 'count' undeclared (first use in this function); did you mean 'counter'?
   12 |                         count++;
      |                         ^~~~~
      |                         counter
main.c:12:25: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <string.h>
int mian(){
char ary[14];
fgets(ary,sizeof(char)*4,stdin);
ary[4]=" ";
fgets(ary,sizeof(char)*8,stdin);
printf("%d\n",ary);
return 0;
}

Compiler output:
main.c: In function 'mian':
main.c:6:7: error: assignment to 'char' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
    6 | ary[4]=" ";
      |       ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <stack>
#define SIZE 12
using namespace std;
typedef long long int ll;
typedef pair <int,int> 
int main(){
int string str;
scanf("%s",str);
cout << str.substr(1,4) << " " << str.substr(5,8);
return 0;
}


Compiler output:
a.cc:16:9: error: two or more data types in declaration of 'main'
   16 | typedef pair <int,int>
      |         ^~~~~~~~~~~~~~
Language: C++

s = input()
for i in range(12):
	if i == 4:
		print('', s[i], end = '')
	else:
		print(s[i], end = '')
print()

Compiler output:
a.cc:4:23: error: empty character constant
    4 |                 print('', s[i], end = '')
      |                       ^~
a.cc:4:39: error: empty character constant
    4 |                 print('', s[i], end = '')
      |                                       ^~
a.cc:6:35: error: empty character constant
    6 |                 print(s[i], end = '')
      |                                   ^~
a.cc:1:1: error: 's' does not name a type
    1 | s = input()
      | ^
Language: C++

public class Main {

	public static void main(String[] args) {
		String firstPart = args[0].substring(0, 4);
		String secondPart = args[0].substring(4, 12);
		System.out.println(firstPart + " " + secondPart);
	}

}


Compiler output:
a.cc:1:1: error: expected unqualified-id before 'public'
    1 | public class Main {
      | ^~~~~~
Language: Java

import java.io.*;
import java.util.*;
public class Sample{
    public static void main (String[] args) throws IOException {
        //BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Scanner s=new Scanner(System.in);
        String str=s.nextLine();
        for(int i=0;i<12;i++){
            if(i==4) System.out.print(" ");
            System.out.print(str.charAt(i));
        }
    }
    
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] lst = new char[12];
		String tmp = sc.nextLine();
		lst = tmp.toCharArray();
		String result = "";
		for (int i = 0; i < 12; i++) {
			result += lst[i];
			if (i == 3) {
				result += " ";
			}
		}
		System.out.println(result);

	}
}


Compiler output:
Main.java:4: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string str;
    cin >> str;
    for (auto itr = str.begin(); itr != str.end(); ++ itr){
        if (*(itr - str.begin()) == 4){
            cout << " ";
        }
        cout << *itr;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: invalid type argument of unary '*' (have '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >::difference_type' {aka 'long int'})
   12 |         if (*(itr - str.begin()) == 4){
      |             ^~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
 
int main()
{
    // get a string
    string s;
    cin >> s;
    char *schar = s.c_str();
    

    // output
for(i=0; i<schar.length(); i++) 
{
    if (i=3)
    cout<<' ';
cout<<schar[i];
}
cout<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:26: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
    9 |     char *schar = s.c_str();
      |                   ~~~~~~~^~
      |                          |
      |                          const char*
a.cc:13:5: error: 'i' was not declared in this scope
   13 | for(i=0; i<schar.length(); i++)
      |     ^
a.cc:13:18: error: request for member 'length' in 'schar', which is of non-class type 'char*'
   13 | for(i=0; i<schar.length(); i++)
      |                  ^~~~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <stack>
#define SIZE 12
using namespace std;
typedef long long int ll;
typedef pair <int,int> 
int main(){
string str;
scanf("%s",str);
cout << str.substr(1.4) << " " << str.substr(5.8);
return 0;
}


Compiler output:
a.cc:16:9: error: two or more data types in declaration of 'main'
   16 | typedef pair <int,int>
      |         ^~~~~~~~~~~~~~
Language: C++

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stdio.h>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

#define SIZE(x) (int((x).size()))
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#ifndef ONLINE_JUDGE
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }
#else
#define debug(x) {}
#endif

void lemon()
{
	char buf[100]; gets(buf);
	rep(i,0,3) printf("%c",buf[i]);
	printf(" ");
	rep(i,4,11) printf("%c",buf[i]);
}

int main()
{
	ios::sync_with_stdio(true);
	lemon();
	return 0;
}



Compiler output:
a.cc: In function 'void lemon()':
a.cc:30:24: error: 'gets' was not declared in this scope; did you mean 'getw'?
   30 |         char buf[100]; gets(buf);
      |                        ^~~~
      |                        getw
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{

    cin >> str;
    for (auto itr = str.begin(); itr != str.end(); ++ itr){
        if (*(itr - str.begin()) == 4){
            cout << " ";
        }
        cout << *itr;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: 'str' was not declared in this scope; did you mean 'std'?
   10 |     cin >> str;
      |            ^~~
      |            std
Language: C++

#include <cstdio>

using namespace std;

int main()
{
    char s[20];
    gets(s);

    for (int i = 0; i < 4; ++i)
        putchar(s[i]);
    printf(" ");
    for (int i = 4; i < 12; ++i)
        putchar(s[i]);
    printf("\n");

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
    8 |     gets(s);
      |     ^~~~
      |     getw
Language: C

#include<stdio.h>

void main(){
	scanf("%s", &s);
	int i;
	char　t[12];
	for ( i = 0; i < 12; i++ ){
		if (i < 4) {
			t[i] = s[i];
		}else if ( i == 4 ) {
			t[i] = ' ';
		}else{
			t[i+1] = s[i];
		}
	}
			
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:22: error: 's' undeclared (first use in this function)
    4 |         scanf("%s", &s);
      |                      ^
main.c:4:22: note: each undeclared identifier is reported only once for each function it appears in
main.c:6:13: error: stray '\343' in program
    6 |         char<U+3000>t[12];
      |             ^~~~~~~~
main.c:17:16: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   17 |         return 0;
      |                ^
main.c:3:6: note: declared here
    3 | void main(){
      |      ^~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    cin >> str;
    for (auto itr = str.begin(); itr != str.end(); ++ itr){
        if (*(itr - str.begin()) == 4){
            cout << " ";
        }
        cout << *itr;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: 'str' was not declared in this scope; did you mean 'std'?
    9 |     cin >> str;
      |            ^~~
      |            std
Language: C

#include <string>
#include <iostream>

int main()
{
    char s[13];
    scanf("%s", s);
    for(int i = 0; i < 13; i++) {
        if (i == 3) printf(" ");
        printf("%c", s[i]);
    }
    return 0;
}

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

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

#define SIZE(x) (int((x).size()))
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#ifndef ONLINE_JUDGE
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }
#else
#define debug(x) {}
#endif

void lemon()
{
	char buf[100]; gets(buf);
	rep(i,0,3) printf("%c",buf[i]);
	printf(" ");
	rep(i,4,11) printf("%c",buf[i]);
}

int main()
{
	ios::sync_with_stdio(true);
	lemon();
	return 0;
}



Compiler output:
a.cc: In function 'void lemon()':
a.cc:29:24: error: 'gets' was not declared in this scope; did you mean 'getw'?
   29 |         char buf[100]; gets(buf);
      |                        ^~~~
      |                        getw
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<windows.h>
using namespace std;
#define USINT_MAX 4294967295

int main(){
	char a[13];
	cin >> a;
	for (int i = 13; i > 5; i--) {
		a[i] = a[i - 1];
	}
	a[5] = ' ';
	cout << a << endl;
	return 0;
}

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

#include <bits/stdc++.h>

#define _ ios::sync_with_stdio(0);
#define __ cin.tie(0);
#define ___ cout.tie(0);
#define endl "\n";
#define fr first
#define se second

using namespace std;

int main() { _ __ ___

	string s;
cin >> s;
for(int i=0; i<12; i++) {
cout << s[i];
if(i == 3) cout << " ";
}	
cout << endll;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'endll' was not declared in this scope; did you mean 'endl'?
   20 | cout << endll;
      |         ^~~~~
      |         endl
Language: C

#include<stdio.h>
int main(){
  char s[20];
  int i;
  scanf("%s",s);
  for(i=0;s[i];i++){
    if(i==4)printf(" ");
    printf("%c",s[i]);
  }prinf("\n");
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:9:4: error: implicit declaration of function 'prinf'; did you mean 'printf'? [-Wimplicit-function-declaration]
    9 |   }prinf("\n");
      |    ^~~~~
      |    printf
Language: Java

import java.util.Scanner;


public class A {

	/**
	 * @param args
	 */

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		String t = in.nextLine();
		
		for(int i=0;i<t.length();i++){
			System.out.print(t.charAt(i));
			if(i==3)
				System.out.print(" ");
		}
		System.out.println();
	}

}


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

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

int main ( void ) {
    int i = 0;

    for (i = 0; i < 4; i++) {
         putchar(getchar());
    }

    putchar(' ');

    int c = getchar();
    while (c != '\n' && c != EOF) {
         putchar(c);
         getchar(c);
    } 

    return EXIT_SUCCESS;
}

Compiler output:
main.c: In function 'main':
main.c:16:10: error: too many arguments to function 'getchar'
   16 |          getchar(c);
      |          ^~~~~~~
In file included from main.c:2:
/usr/include/stdio.h:582:12: note: declared here
  582 | extern int getchar (void);
      |            ^~~~~~~
Language: C

int main(){
	
	scanf("%s",s);
	printf("%c%c%c%c %c%c%c%c%c%c%c%c",s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12]);
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:3:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 |         scanf("%s",s);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(){
main.c:3:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    3 |         scanf("%s",s);
      |         ^~~~~
main.c:3:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:3:20: error: 's' undeclared (first use in this function)
    3 |         scanf("%s",s);
      |                    ^
main.c:3:20: note: each undeclared identifier is reported only once for each function it appears in
main.c:4:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    4 |         printf("%c%c%c%c %c%c%c%c%c%c%c%c",s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12]);
      |         ^~~~~~
main.c:4:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:4:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:4:9: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C++

import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		// output
		System.out.println(a.substring(0,3)+ " " + a.substring(4,11));
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: Java

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


public class Main {

	/**
	 * Q1
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String hoge = br.readLine();
		hoge = hoge.substring(0, 3)+" "+hoge.substring(4,11);
				
		System.out.println();

	}

}


Compiler output:
Main.java:14: error: unreported exception IOException; must be caught or declared to be thrown
		String hoge = br.readLine();
		                         ^
1 error
Language: C++

#define FNAME ""

#include <bits/stdc++.h>

#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;

template <class T> T sqr(const T &a) {return a * a;}

char s[1000];

int main()
{
#ifdef LOCAL
    freopen(FNAME".in", "r", stdin);
    freopen(FNAME".out", "w", stdout);
#endif
    gets(s);
    forn(i, 4)
    	printf("%c", s[i]);
    printf(" " );
    forn(i, 8)
    	printf("%c", s[i + 4]);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:44:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   44 |     gets(s);
      |     ^~~~
      |     getw
Language: Java

mport java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String answer = line.substring(0,4) + " " + line.substring(4);
        System.out.println(answer);
    }
}
 

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.io.BufferedReader;
^
Main.java:2: error: class, interface, enum, or record expected
import java.io.InputStreamReader;
^
2 errors
Language: C++

#include <bits/stdc++.h> 

using namespace std;
 
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(x) (int) ((x).size()) 
#define forn(i, n) for (int i = 0; (i) < (n); ++i)
#define fornr(i, n) for (int i = (n) - 1; (i) >= 0; --i)
#define forab(i, a, b) for (int i = (a); (i) < (b); ++i)
#define forba(i, a, b) for (int i = (b) - 1; (i) >= (a); --i)
#define forit(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end() 

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) static_cast<void>(0)   
#endif

#ifdef _WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector <int> vi;
typedef pair <int, int> pii;

#define FNAME ""

int main() {
#ifdef LOCAL    
	freopen(FNAME".in", "r", stdin);
	freopen(FNAME".out", "w", stdout); 
#endif    

	char s[100];

	gets(s);
	forn (i, 4)
		printf("%c", s[i]);
	printf(" ");
	forab (i, 4, 12)
		printf("%c", s[i]);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   46 |         gets(s);
      |         ^~~~
      |         getw
Language: C++

#include <iostream>

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

using namespace std;

int main(){
	string str;
	cin >> str;
	rep(i,4){
		cout << str[i] 
	}
	cout << " ";
	rep(i,8){
		cout << str[i+4];
	}
	cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:30: error: expected ';' before '<' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                              ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:11:9: note: in expansion of macro 'rep'
   11 |         rep(i,4){
      |         ^~~
a.cc:3:30: error: expected primary-expression before '<' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                              ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:11:9: note: in expansion of macro 'rep'
   11 |         rep(i,4){
      |         ^~~
a.cc:3:40: error: expected ')' before ';' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                        ~               ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:11:9: note: in expansion of macro 'rep'
   11 |         rep(i,4){
      |         ^~~
a.cc:11:13: error: 'i' was not declared in this scope
   11 |         rep(i,4){
      |             ^
a.cc:3:41: note: in definition of macro 'reep'
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                                         ^
a.cc:11:9: note: in expansion of macro 'rep'
   11 |         rep(i,4){
      |         ^~~
a.cc:3:30: error: expected ';' before '<' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                              ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:15:9: note: in expansion of macro 'rep'
   15 |         rep(i,8){
      |         ^~~
a.cc:3:30: error: expected primary-expression before '<' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                              ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:15:9: note: in expansion of macro 'rep'
   15 |         rep(i,8){
      |         ^~~
a.cc:3:40: error: expected ')' before ';' token
    3 | #define reep(i,n,m) for(int i<(n);i<(m);i++)
      |                        ~               ^
a.cc:4:18: note: in expansion of macro 'reep'
    4 | #define rep(i,n) reep(i,0,n)
      |                  ^~~~
a.cc:15:9: note: in expansion of macro 'rep'
   15 |         rep(i,8){
      |         ^~~
Language: C++

http://blog-imgs-85.fc2.com/e/r/o/erog/20160331_img_02_020.jpg

Compiler output:
a.cc:1:1: error: 'http' does not name a type
    1 | http://blog-imgs-85.fc2.com/e/r/o/erog/20160331_img_02_020.jpg
      | ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <Windows.h>
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> P;

int main() {
	string s; cin >> s;
	s.insert(4, " ");
	cout << s << endl;
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
	string s;
	cin >> s;
	REP(i,4) cout <	< s[i];
	cout << " ";
	FOR(i,4,12) cout << s[i];
	cout << endl; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:25: error: expected primary-expression before '<' token
   20 |         REP(i,4) cout < < s[i];
      |                         ^
Language: C++

#Include <string>
#include <iostream>

using namespace std;

int main() {
    string s;
cin >> s;
cout << s.substr(0, 4) << ' ' << s.substr(4, 8) << "\n";
return 0;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #Include; did you mean #include?
    1 | #Include <string>
      |  ^~~~~~~
      |  include
Language: C++

#include <bits/stdc++.h>

int main(){
string s;
cin >> s;
for(int i=0; i<4; i++) putchar(s[i]);
putchar(' ');
for(int i=4; i<12; i++) putchar(s[i]);
puts("");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:1: error: 'string' was not declared in this scope
    4 | string s;
      | ^~~~~~
a.cc:4:1: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:5:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 | cin >> s;
      | ^~~
      | std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:5:8: error: 's' was not declared in this scope
    5 | cin >> s;
      |        ^
Language: C++

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

int main() {
  std::string s;
  std::getline(std::cin, s);
  std::cout << s.substr(0, 4) << " " << s.substr(4) << std::endl;
  return 0;
}
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

int main() {
  std::string s;
  std::getline(std::cin, s);
  std::cout << s.substr(0, 4) << " " << s.substr(4) << std::endl;
  return 0;
}

Compiler output:
a.cc:37:5: error: redefinition of 'int main()'
   37 | int main() {
      |     ^~~~
a.cc:16:5: note: 'int main()' previously defined here
   16 | int main() {
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  int n;cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int counter = 0;
  
  //compute
  for(int i = 0; i < n; i++) a[i] = a[i] - 1;
  for(int i = 0;i < n; i++) {
         if(a[a[i]] == i){
           counter += 1;
         }
  }
  int ans;
  ans = counter / 2;
 
  //output
  cout << ans << endl;
  

Compiler output:
a.cc: In function 'int main()':
a.cc:26:23: error: expected '}' at end of input
   26 |   cout << ans << endl;
      |                       ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: C++

n = int(input())
a = [int(x) for x in input().split()]

# print(n)
# print(a)
count = 0


for i in range(n - 1):
    if(i == a[a[i - 1] - 1]):
        count += 1

print(count)
# print(int(count/2))


Compiler output:
a.cc:4:3: error: invalid preprocessing directive #print
    4 | # print(n)
      |   ^~~~~
a.cc:5:3: error: invalid preprocessing directive #print
    5 | # print(a)
      |   ^~~~~
a.cc:14:3: error: invalid preprocessing directive #print
   14 | # print(int(count/2))
      |   ^~~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int main() {
  int N, ans;
  cin >> N;
  ans=0;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  for (int j=0; j<N; j++) {
    if (a[a[i]-1]==i+1) {
      ans=ans+1;
    }
  }
  cout << ans/2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: 'i' was not declared in this scope
   17 |     if (a[a[i]-1]==i+1) {
      |             ^
Language: Java

import java.util.*;
import java.math.*;
public class Main {
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		List<Integer> a = new ArrayList<>();
		
		for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
			a.add(d);
		}
		for (int i = 0; i < N; i++) {
			int r = a.get(i+1);
			if ((i+1) == a,get(r)) ans++;
		}
		
		ans = ans/2;
		
	 
		System.out.println(ans);
	
	}
}
			

Compiler output:
Main.java:18: error: ')' expected
			if ((i+1) == a,get(r)) ans++;
			              ^
Main.java:18: error: ';' expected
			if ((i+1) == a,get(r)) ans++;
			                     ^
2 errors
Language: Java

import java.util.*;
public class Main {
	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.nextLong();
       }
      //カウント
      int count=0;
      //両想いうさぎ
      for(int i=0;i<N;i++){
        if(A[A[i]-1]==i+1){
          count++;
        }
      }              
       System.out.println(count/2);
    }
}

Compiler output:
Main.java:9: error: incompatible types: possible lossy conversion from long to int
        A[i] = sc.nextLong();
                          ^
1 error
Language: Java

import java.util.*;
public class Main {
	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.nextLong();
       }
      //カウント
      int count=0;
      //両想いうさぎ
      for(int i=0;i<N;i++){
        if((A[A[i]-1)==i+1){
          count++;
        }
      }              
       System.out.println(count/2);
    }
}

Compiler output:
Main.java:15: error: ']' expected
        if((A[A[i]-1)==i+1){
                    ^
1 error
Language: Java

import java.util.*;
public class Main {
	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.nextLong();
       }
      //カウント
      int count=0;
      //両想いうさぎ
      for(int i=0;i<N;i++){
        if((A[A[i]-1)= i+1)){
          count++;
        }
      }              
       System.out.println(count/2);
    }
}

Compiler output:
Main.java:15: error: ']' expected
        if((A[A[i]-1)= i+1)){
                    ^
Main.java:15: error: illegal start of expression
        if((A[A[i]-1)= i+1)){
                           ^
2 errors
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int count = 0;
        int i = 0;
		for(i = 0;i < N; i++){
          A[i] = sc.nextInt();
        }
        for(i = 0;i < N; i++){
          if(i == A[A[i]]){
            count += 1;
          }
        }
        count /2;
		System.out.println(count);            
    }
}

Compiler output:
Main.java:17: error: not a statement
        count /2;
              ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll c=0;
for(ll i=0; i<n; i++){
cin>>a[i];}
for(ll i=0; i<n; i++){
if(a[a[i]]==i+1){
c++;}}
cout<<c<<endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:6: error: 'a' was not declared in this scope
   24 | cin>>a[i];}
      |      ^
a.cc:26:4: error: 'a' was not declared in this scope
   26 | if(a[a[i]]==i+1){
      |    ^
Language: Java

import java.util.*;
public class Main{
  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();}
    int ans =0;
    for(int j=0;j<n;j++){
      if(A[A[i]-1]==i){ans =ans+1;}}
    System.out.println(ans/2);
  }
}

Compiler output:
Main.java:10: error: cannot find symbol
    for(int j=0;j<n;j++){
                  ^
  symbol:   variable n
  location: class Main
Main.java:11: error: cannot find symbol
      if(A[A[i]-1]==i){ans =ans+1;}}
             ^
  symbol:   variable i
  location: class Main
Main.java:11: error: cannot find symbol
      if(A[A[i]-1]==i){ans =ans+1;}}
                    ^
  symbol:   variable i
  location: class Main
3 errors
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力]
		int N = sc.nextInt();
		int[] number = new int[N];
		boolean[] notpair = new boolean[N];
		int count = 0;
      
		for(int i=0; i<N; i++){
			number[i] = sc.nextInt();
        }
		for(int i=0; i<N; i++){
			if(i==number[number[i]-1]-1){
				count++;
        }
      	count /= 2;
		System.out.println(count);
	}
}

Compiler output:
Main.java:21: error: reached end of file while parsing
}
 ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;


int main(){
int rab[20000];
int N;
cin>>N;
for(int i = 1;i<N;i++)cin>>rab[i];
int cnt=0;
for(int i = 1;i<N;i++){
if(i == rab[i])rab++;
}
cnt=/2;
cout<<cnt<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: lvalue required as increment operand
   13 | if(i == rab[i])rab++;
      |                ^~~
a.cc:15:5: error: expected primary-expression before '/' token
   15 | cnt=/2;
      |     ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;

int main(){
	int n;
    int ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
      cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		if(i==a[a[i]]){
          ans++;
        }
	}
	cout<<ans/2<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'a' was not declared in this scope
   11 |       cin>>a[i];
      |            ^
a.cc:14:23: error: 'a' was not declared in this scope
   14 |                 if(i==a[a[i]]){
      |                       ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;

int main(){
	int n,
    int ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		if(i==a[a[i]]){
          ans++;
        }
	}
	cout<<ans/2<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: expected unqualified-id before 'int'
    8 |     int ans=0;
      |     ^~~
a.cc:11:22: error: 'a' was not declared in this scope
   11 |                 cin>>a[i];
      |                      ^
a.cc:14:23: error: 'a' was not declared in this scope
   14 |                 if(i==a[a[i]]){
      |                       ^
a.cc:15:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |           ans++;
      |           ^~~
      |           abs
a.cc:18:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |         cout<<ans/2<<endl;
      |               ^~~
      |               abs
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin>>N;
  int a[N];
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    for(int j=0;j<N;j++){
      cin>>a[j]
        if(a[j]==i&&a[i]==j){
          ans++;
        }
    }
  }
  cout<<ans/2<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: expected ';' before 'if'
   12 |       cin>>a[j]
      |                ^
      |                ;
   13 |         if(a[j]==i&&a[i]==j){
      |         ~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a;
  cin >> a;
  vector<int> arr(a);
  rep(i,a){
    cin >> arr[i];
  }
  var sum = 0;
  rep(i,a){
  if(arr[arr[i]-1] == i+1) sum++;
  }
  cout << (sum/2) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'var' was not declared in this scope
   11 |   var sum = 0;
      |   ^~~
a.cc:13:28: error: 'sum' was not declared in this scope
   13 |   if(arr[arr[i]-1] == i+1) sum++;
      |                            ^~~
a.cc:15:12: error: 'sum' was not declared in this scope
   15 |   cout << (sum/2) << endl;
      |            ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    int N;
    cin >> N;
    int ans = 0;
    int a[N + 1];
    for(int i = 1; i <= N; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= N; i++){
        if(a.at(i) < N){
            if(a[a[i]] == i){
                ans++;
            }
        }
    }
    cout << ans / 2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:14: error: request for member 'at' in 'a', which is of non-class type 'int [(N + 1)]'
   13 |         if(a.at(i) < N){
      |              ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    int N;
    cin >> N;
    int ans = 0;
    int(a[N + 1])
    for(int i = 1; i <= N; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= N; i++){
        if(a.at(i) < N){
            if(a[a[i]] == i){
                ans++;
            }
        }
    }
    cout << ans / 2 << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'a' was not declared in this scope
    8 |     int(a[N + 1])
      |         ^
a.cc:9:20: error: 'i' was not declared in this scope
    9 |     for(int i = 1; i <= N; i++){
      |                    ^
Language: C++


import java.util.*;
public class Main{
  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();
    }
    int ans=0;
    for(int i=0;i<N;i++){
      if(a[a[i]-1]==i+1){
        ans++;
      }

    }
    System.out.println(ans/2);
  }
    


}


Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n,i,ans;cin >> n;ans = 0;
  int a[n];
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<n;i++){
    if (a[a[i]-1]-1 == i) ans += 1;
  }
  cout << a/2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: invalid operands of types 'int [n]' and 'int' to binary 'operator/'
   10 |   cout << a/2 << endl;
      |           ~^~
      |           | |
      |           | int
      |           int [n]
Language: Java

#include <bits/stdc++.h>

using namespace std;

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

    vector<int> vec;
    int cnt = 0;
    for(int i = 0; i < x; i++){
        int lover;
        cin >> lover; lover--;
        vec.push_back(lover);
        if(lover < i){
            if(i == vec.at(lover)){
                cnt++;
            }
        }
    }
    cout << cnt;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:7: error: not a statement
    cin >> x;
        ^
Main.java:13: error: not a statement
        cin >> lover; lover--;
            ^
Main.java:21: error: not a statement
    cout << cnt;
         ^
Main.java:5: error: unnamed classes are a preview feature and are disabled by default.
int main(){
^
  (use --enable-preview to enable unnamed classes)
6 errors
Language: Java

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

public class CodeFes2016AB {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<Integer> al = new ArrayList<Integer>();

        int n = scanner.nextInt();
        int cnt = 0;
        for(int i = 0; i < n; i++ ){
            int lover = scanner.nextInt() - 1;
            if(lover < i){
                if(al.get(lover)==i){
                    cnt++;
                }
            }
            al.add(lover);
        }

        System.out.println(cnt);
    }
}



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