Language: C++

#define int long long
using namespace std;

signed main()
{
  int N; cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  vector<int> b=a;
  sort(a.begin(),a.end());

  int max_cnt=0;
  for(int i=0;i<N;i++){
    if(a[i]==a[N-1]) max_cnt++;
  }
//  cout<<max_cnt<<endl;

  if(max_cnt==1){
    for(int i=0;i<N;i++){
      if(b[i]==a[N-1]){
        cout<<a[N-2]<<endl;
      }else{
        cout<<a[N-1]<<endl;
      }
    }
  }else{
    for(int i=0;i<N;i++){
      cout<<a[N-1]<<endl;
    }
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: 'cin' was not declared in this scope
    6 |   int N; cin>>N;
      |          ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define int long long
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> a(N);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #define int long long
a.cc:1:13: error: expected primary-expression before 'long'
    1 | #define int long long
      |             ^~~~
a.cc:7:10: note: in expansion of macro 'int'
    7 |   vector<int> a(N);
      |          ^~~
a.cc:9:10: error: 'a' was not declared in this scope
    9 |     cin>>a[i];
      |          ^
a.cc:1:13: error: expected primary-expression before 'long'
    1 | #define int long long
      |             ^~~~
a.cc:11:10: note: in expansion of macro 'int'
   11 |   vector<int> b=a;
      |          ^~~
a.cc:12:8: error: 'a' was not declared in this scope
   12 |   sort(a.begin(),a.end());
      |        ^
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |   sort(a.begin(),a.end());
      |   ^~~~
      |   short
a.cc:22:10: error: 'b' was not declared in this scope
   22 |       if(b[i]==a[N-1]){
      |          ^
a.cc:23:9: error: 'cout' was not declared in this scope
   23 |         cout<<a[N-2]<<endl;
      |         ^~~~
a.cc:23:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:23:23: error: 'endl' was not declared in this scope
   23 |         cout<<a[N-2]<<endl;
      |                       ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define int long long
a.cc:25:9: error: 'cout' was not declared in this scope
   25 |         cout<<a[N-1]<<endl;
      |         ^~~~
a.cc:25:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:25:23: error: 'endl' was not declared in this scope
   25 |         cout<<a[N-1]<<endl;
      |                       ^~~~
a.cc:25:23: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:30:7: error: 'cout' was not declared in this scope
   30 |       cout<<a[N-1]<<endl;
      |       ^~~~
a.cc:30:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:21: error: 'endl' was not declared in this scope
   30 |       cout<<a[N-1]<<endl;
      |                     ^~~~
a.cc:30:21: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'