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

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


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

	vector<int>A(N);
	
		for (int i = 0; i < N; i++) {
			cin >> A.at(i);
			A.erase(i);
		}
		sort(A.begin(), A.end());
		reverse(A.begin(), A.end());

		cout << A[1] << endl;
		
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:32: error: no matching function for call to 'std::vector<int>::erase(int&)'
   29 |                         A.erase(i);
      |                         ~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;


int main(){

 int n; cin>>n;
 vector<int>a(n);

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

vector<int>left(n,0);
vector<int>right(n,0);

for(int i=1;i<n;i++)
    left[i] = max(left[i-1],v[i-1]);

 for(int i=n-2;i>=0;i--)
    right[i] = max(right[i+1],v[i+1]);

 for(int i=0;i<n;i++)
 cout<<max(left[i],right[i])<<endl;


return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:15:10: error: 'v' was not declared in this scope
   15 |     cin>>v[i];
      |          ^
a.cc:21:29: error: 'v' was not declared in this scope
   21 |     left[i] = max(left[i-1],v[i-1]);
      |                             ^
a.cc:24:31: error: 'v' was not declared in this scope
   24 |     right[i] = max(right[i+1],v[i+1]);
      |                               ^
Language: Java

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

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		int[] B = A.clone();
		Arrays.sort(B);
		int max = B[N-1];
		int nextmax = B[N-2];
		for(int i=0;i<N;i++) {
			if(A[i]==max) {
				System.out.println(nextmax);
			} else {
				System.out.println(max);
			}
		}
	}
}

Compiler output:
Main.java:5: error: cannot find symbol
	public static void main(String[] args) throws FileNotFoundException {
	                                              ^
  symbol:   class FileNotFoundException
  location: class Main
1 error
Language: Java

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();		//数字列
		
		ArrayList<Integer>a= new ArrayList<>();
		
		for(int i=0;i<n;i++) {
			a.add(sc.nextInt());
		}
		ArrayList<Integer>b=new ArrayList<>(a);
		Collections.sort(b,Collections.reverseOrder());
		int max=Collections.max(b);
		
		for(int i=0;i<n;i++) {
			if(max==a.get(i)) {
				System.out.println(b.get(1));
			}else {
				System.out.println(max);
			}
		}
		sc.close();
	}
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();		//数字列
		
		ArrayList<Integer>a= new ArrayList<>();
		
		for(int i=0;i<n;i++) {
			a.add(sc.nextInt());
		}
		ArrayList<Integer>b=new ArrayList<>(a);
		Collections.sort(b);
		int max=Collections.max(b);
		
		for(int i=0;i<n;i++) {
			if(max==a.get(i)) {
				System.out.println(b.get(1));
			}else {
				System.out.println(max);
			}
		}
		sc.close();
	}
}

Compiler output:
Main.java:32: error: class, interface, enum, or record expected
import java.util.ArrayList;
^
Main.java:33: error: class, interface, enum, or record expected
import java.util.Collections;
^
Main.java:34: error: class, interface, enum, or record expected
import java.util.Scanner;
^
3 errors
Language: C++

#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
 
using ll = long long;
 
class Stream{
public:
    Stream(){
 
    }
    //配列以外の入力を受け取る
    void read(){
 
    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

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

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

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> arr;
    for(int i=0;i<n;i++)
        {
            int temp;
            scanf("%d",&temp);
            arr.push_back(temp);
        }

    for(int i=0;i<n;i++)
    {
        int mx=-1;
        for(int j=0;j<i;j++)
            if(arr[j]>mx)
                mx=arr[j];
        for(int j=i+1;j<n;j++)
            if(arr[j]>mx)
                mx=arr[j];
        printf("%d\n",mx);
    }
arr.erase(arr.begin(),arr.end);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:10: error: no matching function for call to 'std::vector<int>::erase(std::vector<int>::iterator, <unresolved overloaded function type>)'
   29 | arr.erase(arr.begin(),arr.end);
      | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:52: note:   no known conversion for argument 2 from '<unresolved overloaded function type>' to 'std::vector<int>::const_iterator'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |                                     ~~~~~~~~~~~~~~~^~~~~~
Language: C

#include <stdio.h>

int main(void)
{
        int n,i,j,fst,sec;

        scanf("%d",&n);

        int a[n];

        for(i=0;i<n;i++)
                scanf("%d",&a[i]);

        for(i=0;i<n;i++){
                fst=a[i];sec=a[i];
                for(j=0;j<n;j++){
                        if(a[j]>max) max=a[j];
                        else if(a[j]>sec) sec=a[j];
                }
        }
        for(i=0;i<n;i++){
                if(fst!=a[i]) printf("%d\n",fst);
                else printf("%d\n",sec);
        }
        return 0;
}


Compiler output:
main.c: In function 'main':
main.c:17:33: error: 'max' undeclared (first use in this function)
   17 |                         if(a[j]>max) max=a[j];
      |                                 ^~~
main.c:17:33: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef pair<int ,int> P;
int inf = 100000000;

int main(){
    int n;
    cin >> n;
    vector<P> vec(n);
    for(int i=0;i<n;i++) {
        cin >> vec[i].first;
        vec[i].second = i;
    }
    sort(vec.begin() ,vec.end());
    reverse(vec.begin() ,vec.end());
    for(int i=0;i<n;i++){
        if(i == vec[i].second)cout << vec[1].first << endl
        else cout << vec[0].first << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:59: error: expected ';' before 'else'
   17 |         if(i == vec[i].second)cout << vec[1].first << endl
      |                                                           ^
      |                                                           ;
   18 |         else cout << vec[0].first << endl;
      |         ~~~~
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for(int i = 0;i < n;i++){
        cin >> a.at(i);
        b.at(i) = a.at(i);
    }
    /**/
    sort(a.begin(),a.end());
    for(int i = 0;i < n;i++){
        if(b.at(i) == a.at(n - 1)){
            cout << a.at(n - 2) << endl;
        }
        else{
            cout << a.at(n - 1) << endl;
        }
    }
    return 0;
}



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

#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> b = a;
	sort(b.begin(), b.end());
	int first = b[n - 1], second = b[n-2];
	rep(i, n) {
		int now = a[i];
		if (now == first) cout << second << endl;
		else cout << first << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'cin' was not declared in this scope
   20 |         cin >> n;
      |         ^~~
a.cc:12:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   11 | #include "ctime"
  +++ |+#include <iostream>
   12 | 
a.cc:24:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   24 |         sort(b.begin(), b.end());
      |         ^~~~
      |         sqrt
a.cc:28:35: error: 'cout' was not declared in this scope
   28 |                 if (now == first) cout << second << endl;
      |                                   ^~~~
a.cc:28:35: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:29:22: error: 'cout' was not declared in this scope
   29 |                 else cout << first << endl;
      |                      ^~~~
a.cc:29:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

int main() {
  int n; cin >> n;
  int a[n]; for (int i = 0; i < n; ++i) cin >> a[i];
  auto sorted_a = a; sort(sorted_a, sorted_a + n);
  
  for (int a_i = 0; a_i < n; ++a_i) {
    int ans = sorted_a[n - 1];
    if (ans == a[i]) ans = sorted_a[n - 2]:
    cout << ans << endl;
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: 'i' was not declared in this scope
   12 |     if (ans == a[i]) ans = sorted_a[n - 2]:
      |                  ^
a.cc:12:43: error: expected ';' before ':' token
   12 |     if (ans == a[i]) ans = sorted_a[n - 2]:
      |                                           ^
      |                                           ;
Language: C++

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

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

  vector<int> a(n), cp_a(n);

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

  sort(cp_a.begin(), cp_a.end(), greater<int>());

  int mx, mx1;
  bool flag = false;
  for(int i=0; i<cp_a.size(); ++i){
    mx = cp_a[0];
    if(cp_a[0] > cp_a[i]){
      mx1 = cp_a[i];
      flag = true;
      break;
    }
  }
  for(int i=0; i<n; ++i){
    if(flag){
      if(mx != a[i]) cout << mx << endl;
      if (mx == a[i]) cout << mx1 << endl;
    }
    return 0;
    else cout << mx << endl;
  }

  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: 'else' without a previous 'if'
   35 |     else cout << mx << endl;
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n) copy(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a.at(i);
    copy.at(i)=a.at(i);
  }
  sort(copy.begin(),copy.end());
  reverse(copy.begin(),copy.end());
  int p_1=copy.at(0),p_2=copy.at(1);
  for(i=0;i<n;i++){
    if(a.at(i)!=p_1){
      cout << p_2<<endl;
    }else{
      cout << p_1 <<endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:20: error: expected ',' or ';' before 'copy'
    6 |   vector<int> a(n) copy(n);
      |                    ^~~~
a.cc:10:10: error: overloaded function with no contextual type information
   10 |     copy.at(i)=a.at(i);
      |          ^~
a.cc:12:13: error: overloaded function with no contextual type information
   12 |   sort(copy.begin(),copy.end());
      |             ^~~~~
a.cc:12:26: error: overloaded function with no contextual type information
   12 |   sort(copy.begin(),copy.end());
      |                          ^~~
a.cc:13:16: error: overloaded function with no contextual type information
   13 |   reverse(copy.begin(),copy.end());
      |                ^~~~~
a.cc:13:29: error: overloaded function with no contextual type information
   13 |   reverse(copy.begin(),copy.end());
      |                             ^~~
a.cc:14:16: error: overloaded function with no contextual type information
   14 |   int p_1=copy.at(0),p_2=copy.at(1);
      |                ^~
a.cc:17:15: error: 'p_2' was not declared in this scope; did you mean 'p_1'?
   17 |       cout << p_2<<endl;
      |               ^~~
      |               p_1
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n), copy(n);
  rep(i,n){
  	cin >> a[i];
  	copy[i] = a[i]
  }

  sort(copy.begin(), copy.end(), greater<int>());
  rep(i,n){
  	if(a[i] == copy[0]) cout << copy[1] << endl;
  	else cout << copy[0] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:23: error: expected ';' before '}' token
   15 |         copy[i] = a[i]
      |                       ^
      |                       ;
   16 |   }
      |   ~
Language: C++

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


int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i]; 
  }

  vector<int> left(N);
  vector<int> right(N);
  int max = -10;
  for(int i = 0; i < N - 1; i++) {
     left[i + 1] = max(A[i], left[i]);
  }

  for(int i = N - 2; i >= 0; i--) {
    right[i] = max(right[i + 1], A[i + 1]);
  }

  for(int i = 0; i < N; i++) {
    cout << max(left[i], right[i]) << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:23: error: 'max' cannot be used as a function
   18 |      left[i + 1] = max(A[i], left[i]);
      |                    ~~~^~~~~~~~~~~~~~~
a.cc:22:19: error: 'max' cannot be used as a function
   22 |     right[i] = max(right[i + 1], A[i + 1]);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:26:16: error: 'max' cannot be used as a function
   26 |     cout << max(left[i], right[i]) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i< N; i++) cin >> A[i];
  auto B = A;
  sort(B.begin(), B.end());
  int ma1 = B.back();
  int ma2 = B[B.size()-2];
  
  for(int i=0; i < N; i++){
    if(A[i] == ma) cout << ma2 << endl;
    else cout << ma << endl;
  }
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:15:16: error: 'ma' was not declared in this scope; did you mean 'ma2'?
   15 |     if(A[i] == ma) cout << ma2 << endl;
      |                ^~
      |                ma2
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i< N; i++) cin >> A[i];
  auto B = A;
  sort(B.begin(), B.end());
  int ma1 = B.back();
  int ma2 = B[B.size()-2];
  
  for(int i=0; i < N; i++){
    if(A[i] == ma) cout << ma2 << endl;
    else cout << ma << endl;
  }
}
  


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

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i< N; i++) cin >> A[i];
  auto B = A;
  sort(B.begin(), B.end());
  int ma1 = B.back();
  int ma2 = B[B.size()-2];
  
  for(int i=0; i < N; i++){
    if(A[i] == ma) cout << ma2 << endl;
    else cout << ma << endl;
  }
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   18 |   sort(B.begin(), B.end());
      |   ^~~~
      |   sqrt
a.cc:23:16: error: 'ma' was not declared in this scope; did you mean 'ma2'?
   23 |     if(A[i] == ma) cout << ma2 << endl;
      |                ^~
      |                ma2
Language: C++

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i< N; i++) cin >> A[i];
  auto B = A;
  sort(B.begin(), B.end());
  int ma1 = B.back();
  int ma2 = B[B.size()-2];
  
  for(int i=0; i < N; i++){
    if(A[i] == ma) cout << ma2 << endl;
    else cout << ma << endl;
  }
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:18:10: error: request for member 'begin' in 'B', which is of non-class type 'int*'
   18 |   sort(B.begin(), B.end());
      |          ^~~~~
a.cc:18:21: error: request for member 'end' in 'B', which is of non-class type 'int*'
   18 |   sort(B.begin(), B.end());
      |                     ^~~
a.cc:18:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   18 |   sort(B.begin(), B.end());
      |   ^~~~
      |   sqrt
a.cc:19:15: error: request for member 'back' in 'B', which is of non-class type 'int*'
   19 |   int ma1 = B.back();
      |               ^~~~
a.cc:20:17: error: request for member 'size' in 'B', which is of non-class type 'int*'
   20 |   int ma2 = B[B.size()-2];
      |                 ^~~~
a.cc:23:16: error: 'ma' was not declared in this scope; did you mean 'ma2'?
   23 |     if(A[i] == ma) cout << ma2 << endl;
      |                ^~
      |                ma2
Language: C++

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

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i< N; i++) cin >> A[i];
  auto B = A;
  sort(B.begin(), B.end());
  int ma1 = B.back();
  int ma2 = B[B.size()-2];
  
  for(int i=0; i < N; i++){
    if(A[i] == ma) cout << ma2 << endl;
    else cout << ma << endl;
  }
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:10:10: error: request for member 'begin' in 'B', which is of non-class type 'int*'
   10 |   sort(B.begin(), B.end());
      |          ^~~~~
a.cc:10:21: error: request for member 'end' in 'B', which is of non-class type 'int*'
   10 |   sort(B.begin(), B.end());
      |                     ^~~
a.cc:11:15: error: request for member 'back' in 'B', which is of non-class type 'int*'
   11 |   int ma1 = B.back();
      |               ^~~~
a.cc:12:17: error: request for member 'size' in 'B', which is of non-class type 'int*'
   12 |   int ma2 = B[B.size()-2];
      |                 ^~~~
a.cc:15:16: error: 'ma' was not declared in this scope; did you mean 'ma2'?
   15 |     if(A[i] == ma) cout << ma2 << endl;
      |                ^~
      |                ma2
Language: C++

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

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i< N; i++) cin >> A[i];
  int B = A;
  sort(B.begin(), B.end());
  int ma1 = B.back();
  int ma2 = B[B.size()-2];
  
  for(int i=0; i < N; i++){
    if(A[i] == ma) cout << ma2 << endl;
    else cout << ma << endl;
  }
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:9:11: error: invalid conversion from 'int*' to 'int' [-fpermissive]
    9 |   int B = A;
      |           ^
      |           |
      |           int*
a.cc:10:10: error: request for member 'begin' in 'B', which is of non-class type 'int'
   10 |   sort(B.begin(), B.end());
      |          ^~~~~
a.cc:10:21: error: request for member 'end' in 'B', which is of non-class type 'int'
   10 |   sort(B.begin(), B.end());
      |                     ^~~
a.cc:11:15: error: request for member 'back' in 'B', which is of non-class type 'int'
   11 |   int ma1 = B.back();
      |               ^~~~
a.cc:12:17: error: request for member 'size' in 'B', which is of non-class type 'int'
   12 |   int ma2 = B[B.size()-2];
      |                 ^~~~
a.cc:15:16: error: 'ma' was not declared in this scope; did you mean 'ma2'?
   15 |     if(A[i] == ma) cout << ma2 << endl;
      |                ^~
      |                ma2
Language: C++

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

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0; i < N; i++) cin >> a[i];
  
  sort(a.begin(), a.end());
  
  for(int i=0; i < N; i++){
    if(a[i] == a[N]) cout << a[N-1] << endl;
    else cout << a[N] << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:10: error: request for member 'begin' in 'a', which is of non-class type 'int [N]'
   10 |   sort(a.begin(), a.end());
      |          ^~~~~
a.cc:10:21: error: request for member 'end' in 'a', which is of non-class type 'int [N]'
   10 |   sort(a.begin(), a.end());
      |                     ^~~
Language: C++

import numpy as np

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

max_idx = np.argmax(a)
first = a[max_idx]
a[max_idx] = 0
second = max(a)
a[max_idx] = first

for i in range(n):
  if a[i] == first:
    print(second)
  else:
    print(first)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int max = 0;
        int point = -1;
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                             if(max<=in[i]){max = in[i];point=i;}
                            }
        Arrays.sort(in);        		
        for(int i=0;i<a;i++){if(in[a-2]<in[a-1] && i==point)
                            {System.out.println(in[a-2]);}
                            else{System.out.println(in[a-1]);}}        
	}
}


Compiler output:
Main.java:9: error: cannot find symbol
                             in[i] = sc.nextInt();
                             ^
  symbol:   variable in
  location: class Main
Main.java:10: error: cannot find symbol
                             if(max<=in[i]){max = in[i];point=i;}
                                     ^
  symbol:   variable in
  location: class Main
Main.java:10: error: cannot find symbol
                             if(max<=in[i]){max = in[i];point=i;}
                                                  ^
  symbol:   variable in
  location: class Main
Main.java:12: error: cannot find symbol
        Arrays.sort(in);        		
                    ^
  symbol:   variable in
  location: class Main
Main.java:13: error: cannot find symbol
        for(int i=0;i<a;i++){if(in[a-2]<in[a-1] && i==point)
                                ^
  symbol:   variable in
  location: class Main
Main.java:13: error: cannot find symbol
        for(int i=0;i<a;i++){if(in[a-2]<in[a-1] && i==point)
                                        ^
  symbol:   variable in
  location: class Main
Main.java:14: error: cannot find symbol
                            {System.out.println(in[a-2]);}
                                                ^
  symbol:   variable in
  location: class Main
Main.java:15: error: cannot find symbol
                            else{System.out.println(in[a-1]);}}        
                                                    ^
  symbol:   variable in
  location: class Main
8 errors
Language: C++

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

int getMaxElement(int b[],int size)
{
     int j = 1, max =INT_MIN; 
    if(j < size) 
    {
        if(max < b[j])
        max = b[j];

        j++; 
        getMaxElement(b);
    }
    return max;
}
int main(){
  int n;
  cin>>n;
  int a[n],b[n-1];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    getMaxElement(b,n-1);
    swap(a[0],a[i]);
  }
  return 0;
}


Compiler output:
a.cc: In function 'int getMaxElement(int*, int)':
a.cc:13:22: error: too few arguments to function 'int getMaxElement(int*, int)'
   13 |         getMaxElement(b);
      |         ~~~~~~~~~~~~~^~~
a.cc:4:5: note: declared here
    4 | int getMaxElement(int b[],int size)
      |     ^~~~~~~~~~~~~
Language: C++

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

int getMaxElement(int b[],int size)
{
     int j = 1, max =INT_MIN; 
    if(j < size) 
    {
        if(max < b[j])
        max = b[j];

        j++; 
        getMaxElement(b);
    }
    return max;
}
int main(){
  int n;
  cin>>n;
  int a[n],b[n-1];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    getMaxElement(b[n-1]);
    swap(a[0],a[i]);
  }
  return 0;
}


Compiler output:
a.cc: In function 'int getMaxElement(int*, int)':
a.cc:13:22: error: too few arguments to function 'int getMaxElement(int*, int)'
   13 |         getMaxElement(b);
      |         ~~~~~~~~~~~~~^~~
a.cc:4:5: note: declared here
    4 | int getMaxElement(int b[],int size)
      |     ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:25:24: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   25 |     getMaxElement(b[n-1]);
      |                   ~~~~~^
      |                        |
      |                        int
a.cc:25:18: error: too few arguments to function 'int getMaxElement(int*, int)'
   25 |     getMaxElement(b[n-1]);
      |     ~~~~~~~~~~~~~^~~~~~~~
a.cc:4:5: note: declared here
    4 | int getMaxElement(int b[],int size)
      |     ^~~~~~~~~~~~~
Language: C++

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

int getMaxElement(int b[],int size)
{
     int j = 1, max =INT_MIN; 
    if(j < size) 
    {
        if(max < b[j])
        max = b[j];

        j++; 
        getMaxElement(b);
    }
    return max;
}
int main(){
  int n;
  cin>>n;
  long long int a[n],b[n-1];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    getMaxElement(b[n-1]);
    swap(a[0],a[i]);
  }
  return 0;
}


Compiler output:
a.cc: In function 'int getMaxElement(int*, int)':
a.cc:13:22: error: too few arguments to function 'int getMaxElement(int*, int)'
   13 |         getMaxElement(b);
      |         ~~~~~~~~~~~~~^~~
a.cc:4:5: note: declared here
    4 | int getMaxElement(int b[],int size)
      |     ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:25:24: error: invalid conversion from 'long long int' to 'int*' [-fpermissive]
   25 |     getMaxElement(b[n-1]);
      |                   ~~~~~^
      |                        |
      |                        long long int
a.cc:25:18: error: too few arguments to function 'int getMaxElement(int*, int)'
   25 |     getMaxElement(b[n-1]);
      |     ~~~~~~~~~~~~~^~~~~~~~
a.cc:4:5: note: declared here
    4 | int getMaxElement(int b[],int size)
      |     ^~~~~~~~~~~~~
Language: C++

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

int getMaxElement(int b[],int size)
{
     int j = 1, max =INT_MIN; 
    if(j < size) 
    {
        if(max < b[j])
        max = b[j];

        j++; 
        getMaxElement(b);
    }
    return max;
}
int main(){
  int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){
    getMaxElement(b[n-1]);
    swap(a[0],a[i]);
  }
  return 0;
}


Compiler output:
a.cc: In function 'int getMaxElement(int*, int)':
a.cc:13:22: error: too few arguments to function 'int getMaxElement(int*, int)'
   13 |         getMaxElement(b);
      |         ~~~~~~~~~~~~~^~~
a.cc:4:5: note: declared here
    4 | int getMaxElement(int b[],int size)
      |     ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:24:7: error: 'i' was not declared in this scope
   24 |   for(i=0;i<n;i++){
      |       ^
a.cc:25:19: error: 'b' was not declared in this scope
   25 |     getMaxElement(b[n-1]);
      |                   ^
Language: C++

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

int getMaxElement(int b[],int n-1)
{
     int j = 1, max =INT_MIN; 
    if(i < size) 
    {
        if(max < b[j])
        max = b[j];

        j++; 
        getMaxElement(b);
    }
    return max;
}
int main(){
  int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){
    getMaxElement(b[n-1]);
    swap(a[0],a[i]);
  }
  return 0;
}

Compiler output:
a.cc:4:32: error: expected ',' or '...' before '-' token
    4 | int getMaxElement(int b[],int n-1)
      |                                ^
a.cc: In function 'int getMaxElement(int*, int)':
a.cc:7:8: error: 'i' was not declared in this scope
    7 |     if(i < size)
      |        ^
a.cc:13:22: error: too few arguments to function 'int getMaxElement(int*, int)'
   13 |         getMaxElement(b);
      |         ~~~~~~~~~~~~~^~~
a.cc:4:5: note: declared here
    4 | int getMaxElement(int b[],int n-1)
      |     ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:24:7: error: 'i' was not declared in this scope
   24 |   for(i=0;i<n;i++){
      |       ^
a.cc:25:19: error: 'b' was not declared in this scope
   25 |     getMaxElement(b[n-1]);
      |                   ^
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int s=0;
  int t;
  for(int i=0;i<n;i++){
    s=max(s,a.at(i));
    if(s==a.at(i)){
      t=i;
    }
  }
  int b=0;
  int c;
  for(int i=0;i<n;i++){
    if(i==t){
      continue;
    }
    b=max(b,a.at(i));
    if(b==a.at(i)){
      c=i;
    }
  }
  for(int i=0;i<n;i++){
    if(i==t){
      cout<<a.at(c);<<endl;
    }
    else{
      cout<<a.at(t)<<endl;
    }
  }
  
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:21: error: expected primary-expression before '<<' token
   32 |       cout<<a.at(c);<<endl;
      |                     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
vector<int>A(N);
for(int i=0;i<N;i++)
{cin>>A[i];}
vector<int>B(N);
for(int i=0;i<N;i++)
{B[i]=A[i];}
sort(A.begin(),A.end());
for(int i=0;i<N;i++)
{if(B[i]==A[N-1]){cout<<A[N-2]<<endl;
}
else{cout<<A[N-1]<<endl;
}
}



Compiler output:
a.cc: In function 'int main()':
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, a[N] = {}, b[N] = {}, ans = 0;
   cin >> n;
   for (int i = 0; i < n; i++)
   {
      cin >> a[i];
      b[i] = a[i];
   }
   sort(b, b + n);
   for (int i = 0; i < n; i++)
   {
      int mx;
      for (int j = n - 1; i >= 0; i--)
        if(b[j]!=a[i])
        {
           mx = b[j]
            break;
        }
      cout << mx << endl;
   }
   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:21: error: expected ';' before 'break'
   31 |            mx = b[j]
      |                     ^
      |                     ;
   32 |             break;
      |             ~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int scnum(vector<int>x(n)){
  sort(rall(x));
  return x[1];
int main()	{
  int n;
  cin>>n;
  vector<int>a(n);
  int cm=0;
  rep(i,n) {
    cin>>a[i];
    cm=max(cm,a[i]);
  }
  cm2=scnum(a);
  rep(i,n){
    if(cm==a[i])
      cout<<cm2<<endl;
    else
      cout<<cm<<endl;
  }
}

Compiler output:
a.cc:15:23: error: expected ',' or '...' before '(' token
   15 | int scnum(vector<int>x(n)){
      |                       ^
a.cc: In function 'int scnum(std::vector<int>)':
a.cc:18:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   18 | int main()      {
      |         ^~
a.cc:18:9: note: remove parentheses to default-initialize a variable
   18 | int main()      {
      |         ^~
      |         --
a.cc:18:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:18:17: error: a function-definition is not allowed here before '{' token
   18 | int main()      {
      |                 ^
a.cc:34:2: error: expected '}' at end of input
   34 | }
      |  ^
a.cc:15:27: note: to match this '{'
   15 | int scnum(vector<int>x(n)){
      |                           ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i;i<n;++i) cin>>a[i];
  vector<int>lm(n);
  vector<int>lr(n);
  for(int i=1;i<n;i++) lm=max(lm[i-1],a[i-1]);
  for(int i=n-2;i>=0;i--) rm[i]=max(rm[i+1],a[i+1]);
  for(int i=0;i<n;i++){
    cout<<max(lm[i],rm[i])<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:45: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'const int')
   11 |   for(int i=1;i<n;i++) lm=max(lm[i-1],a[i-1]);
      |                                             ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:2:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'const int' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'const int' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'const int' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:12:27: error: 'rm' was not declared in this scope; did you mean 'lm'?
   12 |   for(int i=n-2;i>=0;i--) rm[i]=max(rm[i+1],a[i+1]);
      |                           ^~
      |                           lm
a.cc:14:21: error: 'rm' was not declared in this scope; did you mean 'lm'?
   14 |     cout<<max(lm[i],rm[i])<<endl;
      |                     ^~
      |                     lm
Language: C++

#include<iosream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i;i<n;++i) cin>>a[i];
  vector<int>lm(n);
  vector<int>lr(n);
  for(int i=1;i<n;i++) lm=max(lm[i-1],a[i-1]);
  for(int i=n-2;i>=0;i--) rm[i]=max(rm[i+1],a[i+1]);
  for(int i=0;i<n;i++){
    cout<<max(lm[i],rm[i])<<endl;
  }
  return 0;
}

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

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


int main()
{


    int n;
    cin>>n;

    vector<int> A(n);
    int max_wk=0;
    for(int i=0;i<n;i++){
        cin>>A.at(i);
        max_wk = max(max_wk,A.at(i));
    }

    int max_wk2=0;
    for(int i=0;i<n;i++){
        if(A.at(i)!=max_wk)
           max_wk2 = max(max_wk2,A.at(i));
    }

    for(int i=0;i<n;i++){
        if(max_wk!=A.at(i))
            cout<<max_wk<<endl;
        else
            cout<<max_wk2<<endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:30:6: error: expected '}' at end of input
   30 |     }
      |      ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: C

#include<stdio.h>
int main()
{
int a,j,max,smax;
  scanf("%d",&a);
int b[a];
  scanf("%d %d",&b[0],&b[1]);
  if(b[0]>b[1]){max=b[0];
                smax=b[1];}
  else         {max=b[1];
                smax=b[0];}
  for(j=2;j<a;++j)
  {
  scanf("%d",&b[i]);
  if(b[j]>max) max=b[j];
  else if(b[j]>smax) smax=b[j];
  }
  
for(j=0;j<a;++j)  
{if(b[j]==max) printf("%d\n",smax);
else printf("%d\n",max);
}
  
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:14:17: error: 'i' undeclared (first use in this function)
   14 |   scanf("%d",&b[i]);
      |                 ^
main.c:14:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    ll Max = 0 , max = 0 , N , A;
    vector <int> t;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A;
        if(A > Max){
            max = Max;
            Max = A;
        }
        else if(A > Max * 2){
            max = A;
            t.push_back{A};
        }
    }
    for(int i = 0; i < N; i++){
        if(v.at(i) == Max){
            cout << Max << endl;
        }
        else{
            cout << max << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:24: error: expected ';' before '{' token
   16 |             t.push_back{A};
      |                        ^
      |                        ;
a.cc:16:15: error: statement cannot resolve address of overloaded function
   16 |             t.push_back{A};
      |             ~~^~~~~~~~~
a.cc:20:12: error: 'v' was not declared in this scope
   20 |         if(v.at(i) == Max){
      |            ^
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;++i) cin >> a[i];
  vector<int> s=a;//コピーした配列を用意
  sort(s.rbegin(),s.rend())//降順でソートしたいときはrをつける。beginとendはイテレータと呼ばれるもの。
  for (int i=0;i<n;++i){
    int ans = s[0];
    if (s[0]==a[i]) ans=s[1];
    cout << ans << endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:10:28: error: expected ';' before 'for'
   10 |   sort(s.rbegin(),s.rend())//降順でソートしたいときはrをつける。beginとendはイテレータと呼ばれるもの。
      |                            ^
      |                            ;
   11 |   for (int i=0;i<n;++i){
      |   ~~~                       
a.cc:11:16: error: 'i' was not declared in this scope
   11 |   for (int i=0;i<n;++i){
      |                ^
a.cc:15:4: error: expected '}' at end of input
   15 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |       ans=max(ans,a[i+1]);
      |       ^~~
      |       abs
a.cc:14:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

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

int main(){
 int n;
 vector<int> a(n);
 for(int i=0; i<n; i++){
     cin >> a[i];
 }
 vector<int> s = a;
 sort(s.rbegin(), s.end());
 for(int i=0; i<n; i++){
     int ans = s[0];
     if(s[0] == a[i]) cout << s[i] << endl;
     cout << ans << endl;
 }
return 0;
   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:6: error: no matching function for call to 'sort(std::vector<int>::reverse_iterator, std::vector<int>::iterator)'
   11 |  sort(s.rbegin(), s.end());
      |  ~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   template argument deduction/substitution failed:
a.cc:11:6: note:   deduced conflicting types for parameter '_RAIter' ('std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
   11 |  sort(s.rbegin(), s.end());
      |  ~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int>B=A;
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  int Max=B.at(0);
  int Max1=B.at(1);
  for(int i=0;i<N-1;i++){
  if(A.at(i)!=Max)
    cout<<Max<<" ";
    else
      cout<<Max1<<" ";
  
  }if(A.at(N-1)!=Max);
      cout<<Max<<endl;
  else
    cout<<Max1<<endl;

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:3: error: 'else' without a previous 'if'
   21 |   else
      |   ^~~~
Language: C++

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


int main(){
  int n;
  int f = 0;
  int s = 0;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];


  }
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(j!=i && f<a[j]){f=a[j];}
    }
    cout << f << endl;
    f = 0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:22:4: error: expected '}' at end of input
   22 |   }
      |    ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード↓

ll n, a[200010],tmp[200010];
ll ;


int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		tmp[i] = a[i];
	}
	sort(tmp, tmp + n);
	rep(i, n) {
		if (tmp[n - 1] != a[i]) cout << tmp[n - 1] << endl;
		else cout << tmp[n - 2] << endl;
	}

	return 0;
}



Compiler output:
a.cc:12:22: error: declaration does not declare anything [-fpermissive]
   12 | #define ll long long int
      |                      ^~~
a.cc:23:1: note: in expansion of macro 'll'
   23 | ll ;
      | ^~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i].first;
    v[i].second = i;
  }

  sort(v.begin(), v.end());
  for(int i = 0; i < n; i++){
    if(i == v[n - 1].second){
      cout << v[n - 2].first << endl;
    }
    else{
      cout << v[n - 1].first << endl;
    }
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:21:4: error: expected '}' at end of input
   21 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^