Language: C++

/*
ID: kiwio
LANG: C++14
TASK: 
*/
 
#include <bits/stdc++.h>
using namespace std;
 
int n, num, x[200005], yay, dist, nd, ans, ind;
 
int main () {
	ios_base::sync_with_stdio(0); cin.tie(NULL);/*
#ifndef turtle
	ofstream cout (".out");
	ifstream cin (".in");
#endif*/
	cin >> num;
	for (int i=1; i<=num; i++) {
		cin >> x[i];
		n=max(n, x[i]);
		if (x[i]==n) {
			ind=i;
		}
	}
	cout << n << " ";
	dist=1000000000;
	for (int i=1; i<=num; i++) {
		if (i!=ind) {
			if (abs(n/2-x[i])<dist and x[i]<=n) {
				dist=abs(n/2-x[i]);
				nd=x[i];
			}
		}
	}
	cout << nd;
 
 }
/*
ID: kiwio
LANG: C++14
TASK: 
*/

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

int n, num, x[200005], yay, dist, nd, ans, ind;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(NULL);/*
#ifndef turtle
	ofstream cout (".out");
	ifstream cin (".in");
#endif*/
	cin >> num;
	for (int i=1; i<=num; i++) {
		cin >> x[i];
		n=max(n, x[i]);
		if (x[i]==n) {
			ind=i;
		}
	}
	cout << n << " ";
	dist=1000000000;
	for (int i=1; i<=num; i++) {
		if (i!=ind) {
			if (abs(n/2-x[i])<dist and x[i]<=n) {
				dist=abs(n/2-x[i]);
				nd=x[i];
			}
		}
	}
	cout << nd;

 }

Compiler output:
a.cc:48:5: error: redefinition of 'int n'
   48 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |     ^
a.cc:10:5: note: 'int n' previously declared here
   10 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |     ^
a.cc:48:8: error: redefinition of 'int num'
   48 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |        ^~~
a.cc:10:8: note: 'int num' previously declared here
   10 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |        ^~~
a.cc:48:13: error: redefinition of 'int x [200005]'
   48 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |             ^
a.cc:10:13: note: 'int x [200005]' previously declared here
   10 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |             ^
a.cc:48:24: error: redefinition of 'int yay'
   48 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                        ^~~
a.cc:10:24: note: 'int yay' previously declared here
   10 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                        ^~~
a.cc:48:29: error: redefinition of 'int dist'
   48 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                             ^~~~
a.cc:10:29: note: 'int dist' previously declared here
   10 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                             ^~~~
a.cc:48:35: error: redefinition of 'int nd'
   48 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                                   ^~
a.cc:10:35: note: 'int nd' previously declared here
   10 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                                   ^~
a.cc:48:39: error: redefinition of 'int ans'
   48 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                                       ^~~
a.cc:10:39: note: 'int ans' previously declared here
   10 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                                       ^~~
a.cc:48:44: error: redefinition of 'int ind'
   48 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                                            ^~~
a.cc:10:44: note: 'int ind' previously declared here
   10 | int n, num, x[200005], yay, dist, nd, ans, ind;
      |                                            ^~~
a.cc:50:5: error: redefinition of 'int main()'
   50 | int main () {
      |     ^~~~
a.cc:12:5: note: 'int main()' previously defined here
   12 | int main () {
      |     ^~~~