Language: C++

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long ll;

/////////////////////////////////DEBUG/////////////////////////////////
void printd(const char* format)
{
  #ifdef DEBUG
    std::cout << format;
  #endif
}
template<typename T, typename... Targs>
void printd(const char* format, T value, Targs... Fargs)
{
  #ifdef DEBUG
    for ( ; *format != '\0'; format++ ) {
        if ( *format == '%' ) {
           std::cout << value;
           printd(format+1, Fargs...);
           return;
        }
        std::cout << *format;

    }
  #endif
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef DEBUG
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////// YAY /////////////////////////////////
void solve()
{
  int n; cin>>n;
  cout<<((n/1000)+1)*1000 -n))<<endl;
}

int main(int argc, char const *argv[]) {
  int t;
  t=1;

  #ifdef DEBUG
    freopen("input.txt","r", stdin);
    clock_t start, end;
    start = clock();
    cin>>t;
  #endif


  for(int i = 1; i<=t; i++)
  {
    // std::cout << "Case "<<i<<": " << '\n';
    solve();
  }

  #ifdef DEBUG
    end = clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    time_taken *= 1000;
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " ms " << endl;
  #endif
}
#include <iostream> #include <iomanip> #include <cstdio> #include <cstdlib> #include <climits> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <stack> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <bitset> using namespace std; typedef long double ld; typedef long long ll; /////////////////////////////////DEBUG///////////////////////////////// void printd(const char* format) { #ifdef DEBUG std::cout << format; #endif } template<typename T, typename... Targs> void printd(const char* format, T value, Targs... Fargs) { #ifdef DEBUG for ( ; *format != '\0'; format++ ) { if ( *format == '%' ) { std::cout << value; printd(format+1, Fargs...); return; } std::cout << *format; } #endif } void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifdef DEBUG #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif ///////////////////////////////// YAY ///////////////////////////////// void solve() { int n; cin>>n; 
int x = ((n/1000)+1)*1000 -n);
cout<<x<<endl; } 


int main(int argc, char const *argv[]) { int t; t=1; #ifdef DEBUG freopen("input.txt","r", stdin); clock_t start, end; start = clock(); cin>>t; #endif for(int i = 1; i<=t; i++) { // std::cout << "Case "<<i<<": " << '\n'; solve(); } #ifdef DEBUG end = clock(); double time_taken = double(end - start) / double(CLOCKS_PER_SEC); time_taken *= 1000; cout << "Time taken by program is : " << fixed << time_taken << setprecision(5); cout << " ms " << endl; #endif } 


Compiler output:
a.cc:110:21: warning: extra tokens at end of #include directive
  110 | #include <iostream> #include <iomanip> #include <cstdio> #include <cstdlib> #include <climits> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <stack> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <bitset> using namespace std; typedef long double ld; typedef long long ll; /////////////////////////////////DEBUG///////////////////////////////// void printd(const char* format) { #ifdef DEBUG std::cout << format; #endif } template<typename T, typename... Targs> void printd(const char* format, T value, Targs... Fargs) { #ifdef DEBUG for ( ; *format != '\0'; format++ ) { if ( *format == '%' ) { std::cout << value; printd(format+1, Fargs...); return; } std::cout << *format; } #endif } void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifdef DEBUG #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif ///////////////////////////////// YAY ///////////////////////////////// void solve() { int n; cin>>n;
      |                     ^
a.cc:115:54: error: stray '#' in program
  115 | int main(int argc, char const *argv[]) { int t; t=1; #ifdef DEBUG freopen("input.txt","r", stdin); clock_t start, end; start = clock(); cin>>t; #endif for(int i = 1; i<=t; i++) { // std::cout << "Case "<<i<<": " << '\n'; solve(); } #ifdef DEBUG end = clock(); double time_taken = double(end - start) / double(CLOCKS_PER_SEC); time_taken *= 1000; cout << "Time taken by program is : " << fixed << time_taken << setprecision(5); cout << " ms " << endl; #endif }
      |                                                      ^
a.cc:115:145: error: stray '#' in program
  115 | int main(int argc, char const *argv[]) { int t; t=1; #ifdef DEBUG freopen("input.txt","r", stdin); clock_t start, end; start = clock(); cin>>t; #endif for(int i = 1; i<=t; i++) { // std::cout << "Case "<<i<<": " << '\n'; solve(); } #ifdef DEBUG end = clock(); double time_taken = double(end - start) / double(CLOCKS_PER_SEC); time_taken *= 1000; cout << "Time taken by program is : " << fixed << time_taken << setprecision(5); cout << " ms " << endl; #endif }
      |                                                                                                                                                 ^
a.cc: In function 'void solve()':
a.cc:81:29: error: expected ';' before ')' token
   81 |   cout<<((n/1000)+1)*1000 -n))<<endl;
      |                             ^
      |                             ;
a.cc: At global scope:
a.cc:111:11: error: 'n' was not declared in this scope; did you mean 'yn'?
  111 | int x = ((n/1000)+1)*1000 -n);
      |           ^
      |           yn
a.cc:111:28: error: 'n' was not declared in this scope; did you mean 'yn'?
  111 | int x = ((n/1000)+1)*1000 -n);
      |                            ^
      |                            yn
a.cc:112:1: error: 'cout' does not name a type
  112 | cout<<x<<endl; }
      | ^~~~
a.cc:112:16: error: expected declaration before '}' token
  112 | cout<<x<<endl; }
      |                ^
a.cc:115:5: error: redefinition of 'int main(int, const char**)'
  115 | int main(int argc, char const *argv[]) { int t; t=1; #ifdef DEBUG freopen("input.txt","r", stdin); clock_t start, end; start = clock(); cin>>t; #endif for(int i = 1; i<=t; i++) { // std::cout << "Case "<<i<<": " << '\n'; solve(); } #ifdef DEBUG end = clock(); double time_taken = double(end - start) / double(CLOCKS_PER_SEC); time_taken *= 1000; cout << "Time taken by program is : " << fixed << time_taken << setprecision(5); cout << " ms " << endl; #endif }
      |     ^~~~
a.cc:84:5: note: 'int main(int, const char**)' previously defined here
   84 | int main(int argc, char const *argv[]) {
      |     ^~~~
a.cc: In function 'int main(int, const char**)':
a.cc:115:55: error: 'ifdef' was not declared in this scope
  115 | int main(int argc, char const *argv[]) { int t; t=1; #ifdef DEBUG freopen("input.txt","r", stdin); clock_t start, end; start = clock(); cin>>t; #endif for(int i = 1; i<=t; i++) { // std::cout << "Case "<<i<<": " << '\n'; solve(); } #ifdef DEBUG end = clock(); double time_taken = double(end - start) / double(CLOCKS_PER_SEC); time_taken *= 1000; cout << "Time taken by program is : " << fixed << time_taken << setprecision(5); cout << " ms " << endl; #endif }
      |                                                       ^~~~~
a.cc:115:146: error: 'endif' was not declared in this scope; did you mean 'end'?
  115 | int main(int argc, char const *argv[]) { int t; t=1; #ifdef DEBUG freopen("input.txt","r", stdin); clock_t start, end; start = clock(); cin>>t; #endif for(int i = 1; i<=t; i++) { // std::cout << "Case "<<i<<": " << '\n'; solve(); } #ifdef DEBUG end = clock(); double time_taken = double(end - start) / double(CLOCKS_PER_SEC); time_taken *= 1000; cout << "Time taken by program is : " << fixed << time_taken << setprecision(5); cout << " ms " << endl; #endif }
      |                                                                                                                                                  ^~~~~
      |                                                                                                                                                  end
a.cc:115:167: error: 'i' was not declared in this scope
  115 | int main(int argc, char const *argv[]) { int t; t=1; #ifdef DEBUG freopen("input.txt","r", stdin); clock_t start, end; start = clock(); cin>>t; #endif for(int i = 1; i<=t; i++) { // std::cout << "Case "<<i<<": " << '\n'; solve(); } #ifdef DEBUG end = clock(); double time_taken = double(end - start) / double(CLOCKS_PER_SEC); time_taken *= 1000; cout << "Time taken by program is : " << fixed << time_taken << setprecision(5); cout << " ms " << endl; #endif }
      |                                                                                                                                                                       ^
a.cc:115:179: error: expected '}' at end of input
  115 | int main(int argc, char const *argv[]) { int t; t=1; #ifdef DEBUG freopen("input.txt","r", stdin); clock_t start, end; start = clock(); cin>>t; #endif for(int i = 1; i<=t; i++) { // std::cout << "Case "<<i<<": " << '\n'; solve(); } #ifdef DEBUG end = clock(); double time_taken = double(end - start) / double(CLOCKS_PER_SEC); time_taken *= 1000; cout << "Time taken by program is : " << fixed << time_taken << setprecision(5); cout << " ms " << endl; #endif }
      |                                        ~                                                                                                                                          ^