Language: C++

#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <array>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int,int> pii;
typedef array<int,3> ai3;

const double EPS = 1e-8;

vector<ai3> pts;

bool lessthan(int a, int b){
	return pts[a] < pts[b];
}

bool lessthan(const pii &a, const pii &b){
	if(lessthan(a.first, b.first)){
		return true;
	}
	if(lessthan(b.first, a.first)){
		return false;
	}
	return lessthan(a.second, b.second);
}

double abs(const ai3 &p){
	return sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2] + 0.0);
}

double eucdist(int a, int b){
	double ta = abs(pts[a]), tb = abs(pts[b]);
	double sum = 0.0;
	for(int i = 0; i < 3; ++i){
		double d = pts[a][i] / ta - pts[b][i] / tb;
		sum += d * d;
	}
	return sqrt(sum);
}

ai3 grid(int a, double d){
	d *= abs(pts[a]);
	ai3 ret;
	for(int i = 0; i < 3; ++i){
		ret[i] = pts[a][i] / d;
	}
	return ret;
}

pii solve(int m, int n, int S, int W){
	pts.resize(m + n);
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d", &pts[i][0], &pts[i][1], &pts[i][2]);
	}
	int g = S;
	for(int i = m; i < m + n; ++i){
		pts[i] = {(g / 7) % 100 + 1, (g / 700) % 100 + 1, (g / 70000) % 100 + 1};
		if(g % 2 == 0){ g /= 2; }
		else{ g = (g / 2) ^ W; }
	}
	
	random_shuffle(pts.begin(), pts.end());

	map<ai3,vector<int> > mp;
	pii ans;
	double mdis = 1e8;
	for(int i = 0; i < m + n; ++i){
		double tdis = mdis;
		ai3 gi = grid(i, mdis);
		for(int dx = -1; dx <= 1; ++dx)
		for(int dy = -1; dy <= 1; ++dy)
		for(int dz = -1; dz <= 1; ++dz){
			auto it = mp.find(ai3{gi[0] + dx, gi[1] + dy, gi[2] + dz});
			if(it != mp.end()){
				for(int k : it->second){
					double ds = eucdist(i, k);
					if(ds < EPS){ continue; }
					pii pr = (lessthan(i, k) ? pii(i, k) : pii(k, i));
					if(ds + EPS < tdis){
						tdis = ds;
						ans = pr;
					}
					else if(abs(ds - tdis) < EPS && lessthan(pr, ans)){
						ans = pr;
					}
				}
			}
		}
		
		if(tdis + EPS < mdis){
			mdis = tdis;
			mp.clear();
			for(int j = 0; j < i; ++j){
				mp[grid(j, mdis)].push_back(j);
			}
		}
		mp[grid(i, mdis)].push_back(i);
	}
	
	return ans;
}

int main(){
	srand(time(0));

	int m, n, S, W;
	while(scanf("%d%d%d%d", &m, &n, &S, &W), S){
		pii ans = solve(m, n, S, W);
		int a = ans.first, b = ans.second;
		printf("%d %d %d %d %d %d\n",
			pts[a][0], pts[a][1], pts[a][2], pts[b][0], pts[b][1], pts[b][2]);
	}
}

Compiler output:
a.cc:16:1: error: 'vector' does not name a type
   16 | vector<ai3> pts;
      | ^~~~~~
a.cc: In function 'bool lessthan(int, int)':
a.cc:19:16: error: 'pts' was not declared in this scope; did you mean 'puts'?
   19 |         return pts[a] < pts[b];
      |                ^~~
      |                puts
a.cc: In function 'double eucdist(int, int)':
a.cc:37:25: error: 'pts' was not declared in this scope; did you mean 'puts'?
   37 |         double ta = abs(pts[a]), tb = abs(pts[b]);
      |                         ^~~
      |                         puts
a.cc:40:57: error: 'tb' was not declared in this scope; did you mean 'ta'?
   40 |                 double d = pts[a][i] / ta - pts[b][i] / tb;
      |                                                         ^~
      |                                                         ta
a.cc: In function 'ai3 grid(int, double)':
a.cc:47:18: error: 'pts' was not declared in this scope; did you mean 'puts'?
   47 |         d *= abs(pts[a]);
      |                  ^~~
      |                  puts
a.cc: In function 'pii solve(int, int, int, int)':
a.cc:56:9: error: 'pts' was not declared in this scope; did you mean 'puts'?
   56 |         pts.resize(m + n);
      |         ^~~
      |         puts
a.cc:69:17: error: 'vector' was not declared in this scope
   69 |         map<ai3,vector<int> > mp;
      |                 ^~~~~~
a.cc:9:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    8 | #include <utility>
  +++ |+#include <vector>
    9 | using namespace std;
a.cc:69:27: error: template argument 2 is invalid
   69 |         map<ai3,vector<int> > mp;
      |                           ^
a.cc:69:27: error: template argument 4 is invalid
a.cc:69:29: error: expected unqualified-id before '>' token
   69 |         map<ai3,vector<int> > mp;
      |                             ^
a.cc:78:35: error: 'mp' was not declared in this scope; did you mean 'm'?
   78 |                         auto it = mp.find(ai3{gi[0] + dx, gi[1] + dy, gi[2] + dz});
      |                                   ^~
      |                                   m
a.cc:97:25: error: 'mp' was not declared in this scope; did you mean 'm'?
   97 |                         mp.clear();
      |                         ^~
      |                         m
a.cc:102:17: error: 'mp' was not declared in this scope; did you mean 'm'?
  102 |                 mp[grid(i, mdis)].push_back(i);
      |                 ^~
      |                 m
a.cc: In function 'int main()':
a.cc:116:25: error: 'pts' was not declared in this scope; did you mean 'puts'?
  116 |                         pts[a][0], pts[a][1], pts[a][2], pts[b][0], pts[b][1], pts[b][2]);
      |                         ^~~
      |                         puts