Language: C++

#include <vector>
#include <iostream>
#include <algorithm>
using namespece std;
vector<int> P;
const int pmax=1299709;
bool iscomp[pmax+1];
void init()
{
	P.reserve(100000);
	for(int i=2;i<pmax+1;i++){
		if(iscomp[i])continue;
		P.push_back(i);
		for(int j=2;i*j<pmax+1;j++)
			iscomp[i*j]=true;
	}
}
int main()
{
	init();
	while(true){
		int n;
		cin>>n;
		if(n==0)return;
		int pos=lower_bound(n)-R.begin();
		if(P[pos]==n)cout<<0<<endl;
		else{
			cout<<P[pos+1]-P[pos]<<endl;
		}
	}
}

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namespece'
    4 | using namespece std;
      |       ^~~~~~~~~
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<int> P;
      | ^~~~~~
a.cc: In function 'void init()':
a.cc:10:9: error: 'P' was not declared in this scope
   10 |         P.reserve(100000);
      |         ^
a.cc: In function 'int main()':
a.cc:23:17: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   23 |                 cin>>n;
      |                 ^~~
      |                 std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:24:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
   24 |                 if(n==0)return;
      |                         ^~~~~~
a.cc:25:25: error: 'lower_bound' was not declared in this scope; did you mean 'std::lower_bound'?
   25 |                 int pos=lower_bound(n)-R.begin();
      |                         ^~~~~~~~~~~
      |                         std::lower_bound
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: 'std::lower_bound' declared here
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
a.cc:25:40: error: 'R' was not declared in this scope
   25 |                 int pos=lower_bound(n)-R.begin();
      |                                        ^
a.cc:26:20: error: 'P' was not declared in this scope
   26 |                 if(P[pos]==n)cout<<0<<endl;
      |                    ^
a.cc:26:30: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |                 if(P[pos]==n)cout<<0<<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:26:39: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   26 |                 if(P[pos]==n)cout<<0<<endl;
      |                                       ^~~~
      |                                       std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:28:25: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   28 |                         cout<<P[pos+1]-P[pos]<<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:28:48: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   28 |                         cout<<P[pos+1]-P[pos]<<endl;
      |                                                ^~~~
      |                                                std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~