Language: C++

#include <iostream>
#include <algorithm>

int gcd(int x, int y){
  if (x < y) swap(x, y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

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

Compiler output:
a.cc: In function 'int gcd(int, int)':
a.cc:5:14: error: 'swap' was not declared in this scope
    5 |   if (x < y) swap(x, y);
      |              ^~~~
a.cc:5:14: note: suggested alternatives:
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/tuple:2823:5: note:   'std::swap'
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
/usr/include/c++/14/bits/exception_ptr.h:229:5: note:   'std::__exception_ptr::swap'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:12:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   12 |   cin >> n;
      |   ^~~
      |   std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:13:3: error: 'vector' was not declared in this scope
   13 |   vector<int> a(n);
      |   ^~~~~~
a.cc:13:10: error: expected primary-expression before 'int'
   13 |   vector<int> a(n);
      |          ^~~
a.cc:14:20: error: expected ';' before '<' token
   14 |   for (int i = 0, i < n, i++) cin >> a(i);
      |                    ^~
      |                    ;
a.cc:14:21: error: expected primary-expression before '<' token
   14 |   for (int i = 0, i < n, i++) cin >> a(i);
      |                     ^
a.cc:14:29: error: expected ';' before ')' token
   14 |   for (int i = 0, i < n, i++) cin >> a(i);
      |                             ^
      |                             ;
a.cc:14:38: error: 'a' was not declared in this scope
   14 |   for (int i = 0, i < n, i++) cin >> a(i);
      |                                      ^
a.cc:15:10: error: expected primary-expression before 'int'
   15 |   vector<int> l(n), r(n);
      |          ^~~
a.cc:16:33: error: 'l' was not declared in this scope
   16 |   for (int i = 0; i < n-1; i++) l[i+1] = gcd(l[i], a[i]);
      |                                 ^
a.cc:16:52: error: 'a' was not declared in this scope
   16 |   for (int i = 0; i < n-1; i++) l[i+1] = gcd(l[i], a[i]);
      |                                                    ^
a.cc:17:33: error: 'r' was not declared in this scope
   17 |   for (int i = n-1; i >= 1;i--) r[i-1] = gcd(r[i], a[i]);
      |                                 ^
a.cc:17:52: error: 'a' was not declared in this scope
   17 |   for (int i = n-1; i >= 1;i--) r[i-1] = gcd(r[i], a[i]);
      |                                                    ^
a.cc:20:24: error: 'l' was not declared in this scope
   20 |     ans = max(ans, gcd(l[i],r[i]));
      |                        ^
a.cc:20:29: error: 'r' was not declared in this scope
   20 |     ans = max(ans, gcd(l[i],r[i]));
      |                             ^
a.cc:20:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   20 |     ans = max(ans, gcd(l[i],r[i]));
      |           ^~~
      |           std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:22:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 |   cout << ans << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:22:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   22 |   cout << ans << endl;
      |                  ^~~~
      |                  std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~