Language: C++

	/*
	 
	                              Jai Shree Krishna !!
	                                 Radhe Radhe !!
	                                 
	             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
	             
	*/
	   
	   
	#include <bits/stdc++.h>
	using namespace std;
	 
	#define int long long
	typedef long long ll;
	#define loop(i,n)  for(int i=0;i<n;i++)
	#define read(a) int a; cin >>a;
	#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
	#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
	#define pb push_back
	#define ff first
	#define ss second
	#define vi vector<int>
	#define pi pair<int,int>
	#define vvi vector<vector<int>>
	#define sti set<int>
	#define vpi vector<pair<int,int>>
	#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
	#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
	#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
	#define endl "\n"
	#define mp make_pair
	#define ins insert
	#define rep(i,s,e)   for(int i=s;i<=e;i++)
	#define repd(i,s,e)  for(int i=e;i>=s;i--)
	#define vb vector<bool>
	#define read2(n,m) int n,m; cin >> n >> m;
	#define range(v) v.begin(),v.end()
	#define sortd(v) sort(v.begin(),v.end(),greater<int>())
	#define sorti(v) sort(v.begin(),v.end())
	 
	const ll inf = 1e18;
	const ll mod = 1e9 + 7;


vector<int> parent(1000000),size(1000000);	 
void make_set(int v) {
    parent[v] = v;
    size[v]=1;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (size[a] < size[b])
            swap(a, b);
        parent[b] = a;
        size[a] += size[b];
    }
} 

// int pr;
	signed main()
	{
	 
	    fast;
		read(n);
		
	    int c = n/1000;
	    int r = n%1000;
	    if(r==0) cout<<0<<endl;
	    else{
	    	cout<<(1000-r)<<endl;
	    	
	    }
	    
	    return 0;
	}
	 
	/* Pooja Yadav */

Compiler output:
a.cc: In function 'void make_set(long long int)':
a.cc:49:5: error: reference to 'size' is ambiguous
   49 |     size[v]=1;
      |     ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:11:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:46:29: note:                 'std::vector<long long int> size'
   46 | vector<int> parent(1000000),size(1000000);
      |                             ^~~~
a.cc: In function 'void union_sets(long long int, long long int)':
a.cc:62:13: error: reference to 'size' is ambiguous
   62 |         if (size[a] < size[b])
      |             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:46:29: note:                 'std::vector<long long int> size'
   46 | vector<int> parent(1000000),size(1000000);
      |                             ^~~~
a.cc:62:23: error: reference to 'size' is ambiguous
   62 |         if (size[a] < size[b])
      |                       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:46:29: note:                 'std::vector<long long int> size'
   46 | vector<int> parent(1000000),size(1000000);
      |                             ^~~~
a.cc:65:9: error: reference to 'size' is ambiguous
   65 |         size[a] += size[b];
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:46:29: note:                 'std::vector<long long int> size'
   46 | vector<int> parent(1000000),size(1000000);
      |                             ^~~~
a.cc:65:20: error: reference to 'size' is ambiguous
   65 |         size[a] += size[b];
      |                    ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:46:29: note:                 'std::vector<long long int> size'
   46 | vector<int> parent(1000000),size(1000000);
      |                             ^~~~