criyle/codenet-compile-errors huggingface dataset:
Language: C++

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

int main(){
  unsigned long x,y; cin >> x >> y;
  unsigned long ans = min(x-y*(x/y),abs(x-(y+1)*(x/y)));
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:40: error: call of overloaded 'abs(long unsigned int)' is ambiguous
    6 |   unsigned long ans = min(x-y*(x/y),abs(x-(y+1)*(x/y)));
      |                                     ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Language: C

#include<stdio.h>
#include<stdlib.h>
int main(void){
  long long n,k;
  scanf("%lld%lld",&n,&k);
  if(n<k){
    long long m=llabs(n-k);
    if(n<m)printf("%lld",n);
    else printf("%lld",m);
  }
  else {
    if(n%k==0)
      printf("0");
    else {
      long long m=n%k;
      if(m<llabs(m-k))printf("%lld",m);
      else printf("%lld",llabs(m-k));
    }
    return 0;
  }

Compiler output:
main.c: In function 'main':
main.c:20:3: error: expected declaration or statement at end of input
   20 |   }
      |   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n,k;
  cin >> n >> k;
  cout <min(n%k,n-n%k) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:24: error: invalid operands of types 'const long long int' and '<unresolved overloaded function type>' to binary 'operator<<'
    7 |   cout <min(n%k,n-n%k) << endl;
      |         ~~~~~~~~~~~~~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n,k;
  cin >> n >> k;
  cout <min(n%k,fabs(n-n%k)) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:12: error: no matching function for call to 'min(long long int, __gnu_cxx::__enable_if<true, double>::__type)'
    7 |   cout <min(n%k,fabs(n-n%k)) << endl;
      |         ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:7:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
    7 |   cout <min(n%k,fabs(n-n%k)) << endl;
      |         ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:7:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    7 |   cout <min(n%k,fabs(n-n%k)) << endl;
      |         ~~~^~~~~~~~~~~~~~~~~
Language: C++

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

void fnInput(int64_t& nNumN, int64_t& nNumK)
{
  cin >> nNumN >> nNumK;
}
  
int64_t fnMinRepNum(int64_t nNumN, int64_t nNumK)
{
  if (nNumN < nNumK)
  {
    int64_t n1stRepNum = nNumK - nNumN;
    return min(nNumN, n1stRepNum);
  else
  {
    int64_t n1stRepNum = nNumN % nNumK;

    int64_t n2ndRepNum = n1stRepNum;
    if (n1stRepNum)
      n2ndRepNum = nNumK % n1stRepNum;

    return min(n1stRepNum, n2ndRepNum);
  }
}
  
int main()
{
  int64_t nNumN, nNumK;

  fnInput(nNumN, nNumK);
  cout << fnMinRepNum(nNumN, nNumK) << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int64_t fnMinRepNum(int64_t, int64_t)':
a.cc:15:3: error: expected '}' before 'else'
   15 |   else
      |   ^~~~
a.cc:12:3: note: to match this '{'
   12 |   {
      |   ^
Language: C

#include<stdio.h>
int main(void)
{
  long int N,K;
  if(N%K<(K-N%K))
    printf("%ld",N%K);
  else
    printf("%ld",k-N%K);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:18: error: 'k' undeclared (first use in this function)
    8 |     printf("%ld",k-N%K);
      |                  ^
main.c:8:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <stdio.h>
int main(void)
{
  long N,K,sa;
  scanf("%l %l",&N,&K);
  sa=N%K;
  if(K-sa>sa)
    printf("%l\n",sa);
  else
    printf("%l"\n,K-sa);
 return 0;
}

Compiler output:
a.cc:10:16: error: stray '\' in program
   10 |     printf("%l"\n,K-sa);
      |                ^
a.cc: In function 'int main()':
a.cc:10:16: error: expected ')' before 'n'
   10 |     printf("%l"\n,K-sa);
      |           ~    ^~
      |                )
Language: C++

#include <stdio.h>
int main(void)
{
  long N,K,sa;
  scanf("%l %l",&N,&K);
  sa=N%K;
  if(K-sa>sa)
    printf("%d\n",sa);
  else
    printf("%d"\n,K-sa);
 return 0;
}

Compiler output:
a.cc:10:16: error: stray '\' in program
   10 |     printf("%d"\n,K-sa);
      |                ^
a.cc: In function 'int main()':
a.cc:10:16: error: expected ')' before 'n'
   10 |     printf("%d"\n,K-sa);
      |           ~    ^~
      |                )
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
ll N,K,a;
cin >> N >> K;
a=N%K;
if(N%K=0){
  cout << "0" << endl;
}else{
if(K/2>N){
  cout << N << endl;
}else{
  if(a<K){
    cout << K-a << endl;
  }else{
    cout << N%K << endl;
  }
}
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: lvalue required as left operand of assignment
   25 | if(N%K=0){
      |    ~^~
Language: C

#include<stdio.h>
int main(void){
  long int N,K,A,I;
  scanf("%d %d",&lN,&lK);
  while(1){
    if(N>=K){
      A =N;
      I = K;
    }else{
      A=K;
      I=N;
    }
    if(N<=(A-I))
      break;
    N = A-I;
  }
  printf("%d",N);
}


Compiler output:
main.c: In function 'main':
main.c:4:18: error: 'lN' undeclared (first use in this function); did you mean 'N'?
    4 |   scanf("%d %d",&lN,&lK);
      |                  ^~
      |                  N
main.c:4:18: note: each undeclared identifier is reported only once for each function it appears in
main.c:4:22: error: 'lK' undeclared (first use in this function); did you mean 'K'?
    4 |   scanf("%d %d",&lN,&lK);
      |                      ^~
      |                      K
Language: C++

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

int64_t main(){
  int N,K;
  cin>>N>>K;
  set<int> x;
  for(;!x.count(N);){
    x.insert(N);
    if(N>K)
      N-=K;
    else
      N=K-N;
  }
  cout<<*begin(x)<<endl;
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | int64_t main(){
      | ^~~~~~~
Language: C

#include <stdio.h>
int main(void){
  long long int n,k;
  long long int tmp;
  scanf("%lld %lld",&n,%k);
  
  while(1){
    tmp =(n>k ? n-k : k-n);
    if(n>tmp)
      n=tmp;
    else 
      break;
  }
  
  printf("%lld",n);
}

Compiler output:
main.c: In function 'main':
main.c:5:24: error: expected expression before '%' token
    5 |   scanf("%lld %lld",&n,%k);
      |                        ^
Language: C

#include "stdio.h"

int main(void)
{
    int N;
    int K;
    float harf;
    int saisyou;

    scanf("%d",&N);
    scanf("%d",&K);
    saisyou = N;
    harf = k/2;
    while(saisyou >= harf)
    {
        N = N - K;
        if(N < 0)
        {
            N = N*(-1);
        }
        saisyou = N;
    }
    printf("%d",saisyou);
}

Compiler output:
main.c: In function 'main':
main.c:13:12: error: 'k' undeclared (first use in this function)
   13 |     harf = k/2;
      |            ^
main.c:13:12: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
 
int main(void)
{
  int N, K, num, min;
  int flag = 0;
  
  scanf("%d %d", &N, &K);
  
  num = N;
  min = N;
  do
  {
    num -= K;
    if(num < 0)
      num *= -1;
    
    if(flag == 0 || num < min)
    {
      min = num;
      flag = 1
    }
    
    else if(num == min || num > min)
      flag = 2;
  } while(flag != 2);
  
  printf("%d\n", min);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:21:15: error: expected ';' before '}' token
   21 |       flag = 1
      |               ^
      |               ;
   22 |     }
      |     ~
Language: C++

#include <iostream>
using namespace std;

int main(void)
{
  int n,k;
  int a,b;
  
  cin >>　n >> k;
  
  a = n%k;
  if(a<0)	a = -a;
  b = k-(n%k);
  if(b<0)	b = -b;
  
  /*
  if(a < b){
    cout << a << endl;
  }
  else{
    cout << b << endl;
  }
  */
  
  cout << n << " " << k;
  //cout << n%k << " " << k - (n%k)<< endl;
  
  return 0;
}

Compiler output:
a.cc:9:9: error: extended character 　 is not valid in an identifier
    9 |   cin >>　n >> k;
      |         ^
a.cc: In function 'int main()':
a.cc:9:9: error: '\U00003000n' was not declared in this scope
    9 |   cin >>　n >> k;
      |         ^~~
Language: C

include<stdio.h>
 
int main(void)
{
  int N, K, num, min;
  int flag = 0;
  
  scanf("%d %d", &N, &K);
  
  num = N;
  do
  {
    num -= K;
    if(num < 0)
      num *= -1;
    
    if(flag == 0 || num < min)
    {
      min = num;
      flag = 1;
    }
    
    else if(num == min || num > min)
      flag = 2;
  } while(flag != 2);
  
  printf("%d\n", min);
  
  return 0;
}

Compiler output:
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
Language: C

#include<stdio.h>

int main(void)
{
  int N, K, num, min;
  
  scanf("%d %d", &N, &K);
  
  num = N;
  min = N;
  do
  {
    num -= K;
    if(num < 0)
      num *= -1;
    
    if(num < min)
    {
      min = num;
    }
    
    else
      flag = 2;
  } while(flag != 2);
  
  printf("%d\n", min);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:23:7: error: 'flag' undeclared (first use in this function)
   23 |       flag = 2;
      |       ^~~~
main.c:23:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>

int main(void)
{
  int N, K, num, min;
  int flag = 0;
  
  scanf("%d %d", &N, &K);
  
  do
  {
    num = N - K;
    if(num < 0)
      num *= -1;
    
    N = num
    
    if(flag == 0 || num < min)
    {
      min = num;
      flag = 1;
    }
    
    else if(num == min || num > min)
      flag = 2;
  } while(flag != 2);
  
  printf("%d\n", min);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:16:12: error: expected ';' before 'if'
   16 |     N = num
      |            ^
      |            ;
   17 | 
   18 |     if(flag == 0 || num < min)
      |     ~~
Language: C

#include <stdio.h>
int main(){
  int n,k;
  int x;
  scanf("%d %d",&n,&k);
  x=n;
  while(|x-k|<x)
    x=|x-k|;
  printf("%d",x);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:9: error: expected expression before '|' token
    7 |   while(|x-k|<x)
      |         ^
main.c:8:7: error: expected expression before '|' token
    8 |     x=|x-k|;
      |       ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
ll N,K,a;
cin>>N>>K;
  if(N%K=0){
    cout<<"0"<<endl;
    }else{
      if(K/2<N){
    cout<<abs(K-N)<<endl;
}else{
    a=N%K;
    if(K/2<a){
      cout<<abs(K-a)<<endl;
    }else{
      cout<<abs(N%K)<<endl;
    }
  }
}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:7: error: lvalue required as left operand of assignment
   23 |   if(N%K=0){
      |      ~^~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
ll N,K,a;
cin>>N>>K;
  if(K/2<N){
    cout<<K-N<<endl;
}else{
    a=N%K
    if(K/2<a){
      cout<<K-a<<endl;
    }else{
      cout<<N%K<<endl;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:10: error: expected ';' before 'if'
   26 |     a=N%K
      |          ^
      |          ;
   27 |     if(K/2<a){
      |     ~~    
a.cc:29:6: error: 'else' without a previous 'if'
   29 |     }else{
      |      ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n, k;
  cin>>n>>k;
  ll m;
  bool d=true
  while(d==true) {
    ll n2=n;
    n2=max(n, k)-min(n, k);
    if(n2>=n) {
      cout << n2 << endl;
      d=false;
    }
    else n=n2;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: expected ',' or ';' before 'while'
   10 |   while(d==true) {
      |   ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n, k;
  cin>>n>>k;
  ll m;
  while() {
    ll n2=n;
    n2=max(n, k)-min(n, k);
    if(n2>=n) {
      cout << n2 << endl;
      break;
    }
    else n=n2;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: expected primary-expression before ')' token
    9 |   while() {
      |         ^
Language: C++

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

int main(){
  int N , K ;
  cin >> N >> K ;
  int x = N%K;
  int y = K%N;
  if(N>=K){
  cout << min(x,K-x) << endl;
  }
  else cout << min(y,N-y) << endl;
  
}
  
}


Compiler output:
a.cc:16:1: error: expected declaration before '}' token
   16 | }
      | ^
Language: C++

#include <bits/stdc++.h> 	


#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(arr) arr.begin(),arr.end()
#define INF 2000000000
#define MOD 1000000007
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define um unordered_map
#define us unordered_set
#define ff first
#define ss second
#define FOR(i,n,m) for(int i = (n); i < (m); i++)
#define REP(i,n) FOR(i,0,n)



using namespace std; 
void solve(); 
int main() 
{ 
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 

/*
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("error.txt", "w", stderr); 
	freopen("output.txt", "w", stdout); 
#endif 
*/
	ll n,k;
	cin>>n>>k;
	int x = n%k;
	cout<<min(x,k-x)<<"\n"	;
	//cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0; 
} 
void solve() 
{ 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:39:18: error: no matching function for call to 'min(int&, long long int)'
   39 |         cout<<min(x,k-x)<<"\n"  ;
      |               ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:39:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   39 |         cout<<min(x,k-x)<<"\n"  ;
      |               ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:39:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   39 |         cout<<min(x,k-x)<<"\n"  ;
      |               ~~~^~~~~~~
Language: C++

#include ‹iostream›
# define ll long long int
using  namespace std;
int main(){
ll n, k;
cin >> n >> k;
cout << n % k;
}

Compiler output:
a.cc:1:10: error: extended character ‹ is not valid in an identifier
    1 | #include ‹iostream›
      |          ^
a.cc:1:10: error: extended character › is not valid in an identifier
a.cc:1:10: error: #include expects "FILENAME" or <FILENAME>
    1 | #include ‹iostream›
      |          ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:6:1: error: 'cin' was not declared in this scope
    6 | cin >> n >> k;
      | ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #include ‹iostream›
a.cc:7:1: error: 'cout' was not declared in this scope
    7 | cout << n % k;
      | ^~~~
a.cc:7:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include‹iostream›
# define ll long long int
using  nameapace std;
int main(){
ll n, k;
cin >> n >> k;
cout << n % k;
}

Compiler output:
a.cc:1:2: error: extended character ‹ is not valid in an identifier
    1 | #include‹iostream›
      |  ^
a.cc:1:2: error: extended character › is not valid in an identifier
a.cc:1:2: error: invalid preprocessing directive #include\U00002039iostream\U0000203a
    1 | #include‹iostream›
      |  ^~~~~~~~~~~~~~~~~
a.cc:3:8: error: expected nested-name-specifier before 'nameapace'
    3 | using  nameapace std;
      |        ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:6:1: error: 'cin' was not declared in this scope
    6 | cin >> n >> k;
      | ^~~
a.cc:7:1: error: 'cout' was not declared in this scope
    7 | cout << n % k;
      | ^~~~
Language: C++

#include <iostream>


#include <vector>


using namespace std;

typedef long long ll;

int main(){
    ll N,K,min;
    cin>>N>>K;
    //cout<<N<<endl;
    
    N=N%K;
    min=N;
    vector<ll> vc;
    
    vc.push_back(N);
    
    int M=1;
    bool flag=false;
    
    while(true){
       
        N=abs(N-K);
        min=(min>N)?N:min;
        vc.push_back(N);
        ++M;
        
        sort(vc.begin(),vc.end());
        for(int i=0;i!=M;++i){
            if(vc[i]==vc[i+1]){
                flag=true;
                break;
            }
        }
        if(flag) break;
    }
    
    cout<<min<<endl;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   32 |         sort(vc.begin(),vc.end());
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

int main(){
    ll n,k;
    cin >> n >> k;
    n %= k;
    int c = abs(n - k);
    cout << min(c,n) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: no matching function for call to 'min(int&, ll&)'
   12 |     cout << min(c,n) << endl;
      |             ~~~^~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:12:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   12 |     cout << min(c,n) << endl;
      |             ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:12:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |     cout << min(c,n) << endl;
      |             ~~~^~~~~
Language: Java

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        Long N = sc.nextLong();
        Long K = sc.nextLong();
        
        Long result1=N%K;
        Long result2=Math.abs(K-result1);

        System.out.println((Math.min(result1, result2));
    }
}

Compiler output:
Main.java:13: error: ')' or ',' expected
        System.out.println((Math.min(result1, result2));
                                                       ^
1 error
Language: C

#include<stdio.h>
#include<stdlib.h>
int main() {
  long int n,k;
  scanf("%ld %ld",&n,&k);
  int dvide;
  dvide = n / k;
  if (dvide != 0) {
    if (n == dvide * k) {
      n = 0;
      break;
    }
    n = n - dvide * k;
    if (abs(n - k) < n) {
      n = abs(n - k);
    }
  }
  else {
    for (;abs(n - k) < n;) {
      n = abs(n - k);
    }
  }
  printf("%ld",n);
}


Compiler output:
main.c: In function 'main':
main.c:11:7: error: break statement not within loop or switch
   11 |       break;
      |       ^~~~~
Language: C++

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
  long int x,y;
  cin>>x>>y;
 
     long  int r=y%x;
      
      ans=min(x-r,r);
      
    cout<<ans;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |       ans=min(x-r,r);
      |       ^~~
      |       abs
Language: C++

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

int main() {
  int64_t n, k;
  cin >> n >> k;
  
  int x;
  x = n % k;
  if (x > abs(x - k)) {
    cout << abx(x - k) << endl;
  }
  else {
    cout << x << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: 'abx' was not declared in this scope; did you mean 'abs'?
   11 |     cout << abx(x - k) << endl;
      |             ^~~
      |             abs
Language: C

#include<bits/stdc++.h>
int main(){
    long long n,k,x,y;
    scanf("%lld %lld", &n,&k );
    x = n%k; y = abs(x-k);
    if (x>y)
    printf("%lld\n",y);
    else
    printf("%lld\n",x );
}


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

include<iostream>
using namespace std;
 
int main(){
    long long n,k,ans;
    cin >> n >> k;
    n%=k;
    
    ans=min(n,k-n);
    cout << ans << endl;
 
    return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope
    6 |     cin >> n >> k;
      |     ^~~
a.cc:9:9: error: 'min' was not declared in this scope; did you mean 'main'?
    9 |     ans=min(n,k-n);
      |         ^~~
      |         main
a.cc:10:5: error: 'cout' was not declared in this scope
   10 |     cout << ans << endl;
      |     ^~~~
a.cc:10:20: error: 'endl' was not declared in this scope
   10 |     cout << ans << endl;
      |                    ^~~~
Language: C++

clude <iostream>
using namespace std;
 
int main(){
    long long n,k,ans;
    cin >> n >> k;
    n%=k;
    
    ans=min(n,k-n);
    cout << ans << endl;
 
    return 0;
}

Compiler output:
a.cc:1:1: error: 'clude' does not name a type
    1 | clude <iostream>
      | ^~~~~
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope
    6 |     cin >> n >> k;
      |     ^~~
a.cc:9:9: error: 'min' was not declared in this scope; did you mean 'main'?
    9 |     ans=min(n,k-n);
      |         ^~~
      |         main
a.cc:10:5: error: 'cout' was not declared in this scope
   10 |     cout << ans << endl;
      |     ^~~~
a.cc:10:20: error: 'endl' was not declared in this scope
   10 |     cout << ans << endl;
      |                    ^~~~
Language: C

#include <stdio.h>
#include <math.h>

int main(){
long long N,K,min,tmp;
  scanf("%lld %lld",&N,&K);
  min=N;
  tmp=N%K;
  if(tmp<N){min=tmp;}
  if(long long int i=0;i<K;i++){
  tmp=abs(tmp-K);
  if(tmp<min){min=tmp;}
  }
  printf("%lld",min);
  return 0;



}

Compiler output:
main.c: In function 'main':
main.c:10:6: error: expected expression before 'long'
   10 |   if(long long int i=0;i<K;i++){
      |      ^~~~
main.c:11:7: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   11 |   tmp=abs(tmp-K);
      |       ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:11:14: warning: 'abs' argument 1 type is 'long long int' where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
   11 |   tmp=abs(tmp-K);
      |           ~~~^~
<built-in>: note: built-in 'abs' declared here
Language: C

#include <stdio.h>
#include <math.h>

int main(){
long long N,K,min,tmp;
  scanf("%lld %lld",&N,&K);
  min=N;
  tmp=N%K;
  if(tmp<N){min=tmp};
  if(int i=0;i<K;i++){
  tmp=abs(tmp-K);
  if(tmp<min){min=tmp};
  }
  printf("%lld",min);
  return 0;



}

Compiler output:
main.c: In function 'main':
main.c:9:20: error: expected ';' before '}' token
    9 |   if(tmp<N){min=tmp};
      |                    ^
      |                    ;
main.c:10:6: error: expected expression before 'int'
   10 |   if(int i=0;i<K;i++){
      |      ^~~
main.c:11:7: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   11 |   tmp=abs(tmp-K);
      |       ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:11:14: warning: 'abs' argument 1 type is 'long long int' where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
   11 |   tmp=abs(tmp-K);
      |           ~~~^~
<built-in>: note: built-in 'abs' declared here
main.c:12:22: error: expected ';' before '}' token
   12 |   if(tmp<min){min=tmp};
      |                      ^
      |                      ;
Language: C++

#include<stdio.h>
int main()
{
   long long int n,k,s;
    scanf("%lld%lld",&n,&k);
    if (n==0){
        printf("%d\n",k);
    }
    else{
        while(1){
            s=abs(n-k);
            if(n>k){
                n=s;
            }
            else{
                printf("%d\n",s);
                break;
            }
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:15: error: 'abs' was not declared in this scope
   11 |             s=abs(n-k);
      |               ^~~
Language: C

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

#define ll long long
#define fr(n) for(i=0;i<n;i++)
#define frr(n) for(i=n;i>=0;i--)

int main(){
        ll n,k;
        cin>>n>>k;
        if(n>k&&n%k==0||k>n&&k%n==0){
                cout<<k<<endl;
        }
        else{
                ll a,b;
                a=abs(n-k);
                b=abs(a-k);
                if(a<b) cout<<a<<endl;
                else cout<<b<<endl;

        }
        return 0;

}



Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{

    ll  n,k,mi,f1,a;
    scanf("%lld %lld",&n,&k);
    a=n%k;
    f1=abs(k-a);
    mi=min(a,f1);
    cout<<mi<<"\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'll' was not declared in this scope
    6 |     ll  n,k,mi,f1,a;
      |     ^~
a.cc:7:24: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |     scanf("%lld %lld",&n,&k);
      |                        ^
      |                        yn
a.cc:7:27: error: 'k' was not declared in this scope
    7 |     scanf("%lld %lld",&n,&k);
      |                           ^
a.cc:8:5: error: 'a' was not declared in this scope
    8 |     a=n%k;
      |     ^
a.cc:9:5: error: 'f1' was not declared in this scope; did you mean 'y1'?
    9 |     f1=abs(k-a);
      |     ^~
      |     y1
a.cc:10:5: error: 'mi' was not declared in this scope
   10 |     mi=min(a,f1);
      |     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//	freopen("output.txt", "w", stdout);
int main ()
{
    unsigned ll n,k;
    scanf("%llu %llu",&n,&k);
    if((n-k)==0)
    {
        cout<<0<<endl;
    }
    else if(n<k)
    {
        ll z=k&n;
        if(z==0)
            printf("%llu\n",n);
        else
        {
            llv=k/n;
            if(n>1)
            {
                printf("%llu\n",n);
            }
            else
            {
                 unsigned ll x=k-n;
                printf("%lld\n",x);
            }
        }
       /* unsigned ll x=n-k;
        if(x<0)
            x*=-1;
        if(n>x)
        printf("%llu\n",x);
        else
             printf("%llu\n",n);*/
    }
    else
    {
        ll c=n%k;
        if(c==0)
        {
            cout<<0<<endl;
        }
       else
       {
        ll q;
        if(c>(k-c))
        {
            q=k-c;
        }
        else
            q=c;
            printf("%lld\n",q);
       }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:13: error: 'llv' was not declared in this scope; did you mean 'll'?
   20 |             llv=k/n;
      |             ^~~
      |             ll
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
//	freopen("output.txt", "w", stdout);
int main ()
{
    unsigned ll n,k;
    scanf("%llu %llu",&n,&k);
    if((n-k)==0)
    {
        cout<<0<<endl;
    }
    else if(n<k)
    {
        printf("%llu\n",n);
    }
    else
    {
        ll c=n%k;
         if(c==0)
            {
                cout<<0<<endl;
            }
            else
       {
           ll q=min(c,k-c);
            printf("%llu\n",q);
       }
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:20: error: no matching function for call to 'min(long long int&, long long unsigned int)'
   26 |            ll q=min(c,k-c);
      |                 ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:26:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   26 |            ll q=min(c,k-c);
      |                 ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:26:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |            ll q=min(c,k-c);
      |                 ~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
//	freopen("output.txt", "w", stdout);
int main ()
{
    unsigned ll n,k;
    scanf("%llu %llu",&n,&k)
    if(k==1)
    {
        cout<<0<<endl;
    }
    else if(k>n)
    {
        printf("%llu\n",n);
    }
    else if(n>k)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:8:29: error: expected ';' before 'if'
    8 |     scanf("%llu %llu",&n,&k)
      |                             ^
      |                             ;
    9 |     if(k==1)
      |     ~~                       
a.cc:13:5: error: 'else' without a previous 'if'
   13 |     else if(k>n)
      |     ^~~~
Language: C

#include<stdio.h>

int main(){
  long int n,k;
  char buff[1000];#include<stdio.h>

int main(){
  long int n,k;
  char buff[1000];

  if(fgets(buff,sizeof(buff),stdin)!=NULL){
    sscanf(buff,"%ld%ld",&n,&k);
  }

  n = n % k;
  if(k-n >= n){
    printf("%ld",n);
    return 0;
  }else{
    printf("%ld",k-n);
    return 0;
  }
}


  if(fgets(buff,sizeof(buff),stdin)!=NULL){
    sscanf(buff,"%ld%ld",&n,&k);
  }

  n = n % k;
  printf("%ld\n",n);
  if(k-n >= n){
    printf("%ld",n);
    return 0;
  }else{
    printf("%ld",k-n);
    return 0;
  }
}


Compiler output:
main.c: In function 'main':
main.c:5:19: error: stray '#' in program
    5 |   char buff[1000];#include<stdio.h>
      |                   ^
main.c:5:20: error: 'include' undeclared (first use in this function)
    5 |   char buff[1000];#include<stdio.h>
      |                    ^~~~~~~
main.c:5:20: note: each undeclared identifier is reported only once for each function it appears in
main.c:5:28: error: 'stdio' undeclared (first use in this function); did you mean 'stdin'?
    5 |   char buff[1000];#include<stdio.h>
      |                            ^~~~~
      |                            stdin
main.c:7:1: error: expected expression before 'int'
    7 | int main(){
      | ^~~
Language: C++

int main()
{
    ll N;
    float K;
    cin >> N >> K;
    ll small;
    if (N <= (K / 2)) {
        small = N;
    } else if (K == 1) {
        small = 0;
    } 
    else {
        do {
            N = abs(N - K);
        } while(N > (K / 2));
        small = N;
    }
    cout << small << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'll' was not declared in this scope
    3 |     ll N;
      |     ^~
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> N >> K;
      |     ^~~
a.cc:5:12: error: 'N' was not declared in this scope
    5 |     cin >> N >> K;
      |            ^
a.cc:6:7: error: expected ';' before 'small'
    6 |     ll small;
      |       ^~~~~~
      |       ;
a.cc:8:9: error: 'small' was not declared in this scope
    8 |         small = N;
      |         ^~~~~
a.cc:10:9: error: 'small' was not declared in this scope
   10 |         small = 0;
      |         ^~~~~
a.cc:14:17: error: 'abs' was not declared in this scope
   14 |             N = abs(N - K);
      |                 ^~~
a.cc:16:9: error: 'small' was not declared in this scope
   16 |         small = N;
      |         ^~~~~
a.cc:18:5: error: 'cout' was not declared in this scope
   18 |     cout << small << endl;
      |     ^~~~
a.cc:18:13: error: 'small' was not declared in this scope
   18 |     cout << small << endl;
      |             ^~~~~
a.cc:18:22: error: 'endl' was not declared in this scope
   18 |     cout << small << endl;
      |                      ^~~~
Language: C++

#include<bits/stdc++.h>

//#define FILEIO

using namespace std;

const int SZ = 52;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
     return (a > b);
}

int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
    
    cin >> n >> k;
    if(k == 1)
    {
        ans = 0;
    }
    else
    {
        ans = n % k;
    }
    cout << ans << endl;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:30:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   30 |     cin >> n >> k;
      |            ^
      |            yn
a.cc:30:17: error: 'k' was not declared in this scope
   30 |     cin >> n >> k;
      |                 ^
a.cc:33:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |         ans = 0;
      |         ^~~
      |         abs
a.cc:37:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |         ans = n % k;
      |         ^~~
      |         abs
a.cc:39:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C

/* In the name of Allah */

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

// const int INF = 20000000;

#define ll long long
#define _SetBit(A, k) (A[(k / 32)] |= (1 << (k % 32)))
#define _ClearBit(A, k) (A[(k / 32)] &= ~(1 << (k % 32)))
#define _CheckBit(A, k) (A[(k / 32)] & (1 << (k % 32)))
#define SetBit(x, k) (x |= (1 << k))
#define ClearBit(x, k) (x &= ~(1 << k))
#define CheckBit(x, k) (x & (1 << k))

int main()
{
  unsigned ll n, k;
  cin >> n >> k;
  while (n > k)
  {
    n = n % k;
  }

  if (n < k - n)
    cout << n << "\n";
  else
    cout << k - n << "\n";

  return 0;
}

Compiler output:
main.c:3:10: fatal error: bits/stdc++.h: No such file or directory
    3 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
  int N,K,a,b;
  cin >> N >> K;
  a = N%k ;
  b= -a+K ;
  cout >> min(a.b) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'k' was not declared in this scope
    7 |   a = N%k ;
      |         ^
a.cc:9:17: error: request for member 'b' in 'a', which is of non-class type 'int'
    9 |   cout >> min(a.b) << endl;
      |                 ^
Language: C++

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

int main()
{
    double N, K, tmp1, tmp2, ans;
    cin >> N >> K;
    if(N==0){
        cout << K << endl;
        return 0;
    }

    if(N>K){
        tmp1 = K-(N % K);
        tmp2 = (N % K);
        //cout << N % K << endl;
    }
    else{
        tmp1 = N-(K % N);
        tmp2 = (K % N);
        //cout << K % N << endl;
    }
    ans = min(tmp1, tmp2);

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   15 |         tmp1 = K-(N % K);
      |                   ~ ^ ~
      |                   |   |
      |                   |   double
      |                   double
a.cc:16:19: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   16 |         tmp2 = (N % K);
      |                 ~ ^ ~
      |                 |   |
      |                 |   double
      |                 double
a.cc:20:21: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   20 |         tmp1 = N-(K % N);
      |                   ~ ^ ~
      |                   |   |
      |                   |   double
      |                   double
a.cc:21:19: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   21 |         tmp2 = (K % N);
      |                 ~ ^ ~
      |                 |   |
      |                 |   double
      |                 double
Language: Java

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Long N = input.nextLong();
        Long K = input.nextLong();
        long ans;

        if (N % K == 0) {
            ans = 0;
        } else {
            ans = ((N % K) <= (K / 2)) ? (N % K) : (K - (N % K));
        }
        System.out.println(ans);
    }
}


Compiler output:
Main.java:3: error: cannot find symbol
        Scanner input = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
        Scanner input = new Scanner(System.in);
                            ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Long N = input.nextLong();
        Long K = input.nextLong();
        long ans;

        if (N % K == 0) {
            ans = 0;
        } else {
            ans = ((N % K) <= (K / 2)) ? (N % K) : (K - (N % K));
        }
        System.out.println(ans);
    }
  

Compiler output:
Main.java:16: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back

int main()
{
    ll n, q, m, a = 2, k, x, i, tc, j, ans = 1, l, sum = 0;
    cin >> n >> k;
    if(n % k == 0)
        cout << 0 << endl;
    else if(n < k)
        cout << n << endl;
    else if(abs(n - k) >= n)
        cout << n << endl;
    else{
        cout << min(n % k, k - (n % k) << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:40: error: invalid operands of types 'll' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator<<'
   17 |         cout << min(n % k, k - (n % k) << endl;
      |                            ~~~~~~~~~~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<int,int> P;
const int INF = 100000000;

int gcd(int a, int b) {

    if (a%b==0) {
        return b;
    }
    else {
        return gcd(b,a%b);
    }

}

int main() {
    ll N,K;
    cin >> N >> K;
    ll tmp = N%K;

    cout << min(tmp,K-tmp) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: 'll' was not declared in this scope
   20 |     ll N,K;
      |     ^~
a.cc:21:12: error: 'N' was not declared in this scope
   21 |     cin >> N >> K;
      |            ^
a.cc:21:17: error: 'K' was not declared in this scope
   21 |     cin >> N >> K;
      |                 ^
a.cc:22:7: error: expected ';' before 'tmp'
   22 |     ll tmp = N%K;
      |       ^~~~
      |       ;
a.cc:24:17: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   24 |     cout << min(tmp,K-tmp) << endl;
      |                 ^~~
      |                 tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
using Int = int64_t;
using Float = double;

int main() {
  Int N, K;
  cin >> N >> K;

  auto X = N;
  if (X == K) {
    cout << 0 << endl;
  } else if (X > K) {
    X = X - (floor((Float)(X-K)/K) - 10) * K;
    while (X+K < K) {
      X += K
    }
    while (X-K >= K) {
      X -= K;
    }
    cout << min({X, X-K, K-(X-K)}) << endl;
  } else {
  	cout << min(X, K-X) << endl;  
  }
    
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:13: error: expected ';' before '}' token
   16 |       X += K
      |             ^
      |             ;
   17 |     }
      |     ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
  long N,K;
  int N1, N2;
  cin >> N >> K;
  N1=abs(N%K);
  N2=abs(K-N1);
  if(N<K)
  {
    N1=N;
    N2=abs(N-K)
  }
  cout << min(N1,N2)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: expected ';' before '}' token
   13 |     N2=abs(N-K)
      |                ^
      |                ;
   14 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
  long N,K;
  cin >> N >> K;
  if(N>K)
  {
  int N1=N%K;
  int N2=N-N1;
  }
  else
  {
  int N1=N;
  int N2=abs(N-K);
  }
  cout << min(N1,N2)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:15: error: 'N1' was not declared in this scope; did you mean 'N'?
   17 |   cout << min(N1,N2)<<endl;
      |               ^~
      |               N
a.cc:17:18: error: 'N2' was not declared in this scope; did you mean 'N'?
   17 |   cout << min(N1,N2)<<endl;
      |                  ^~
      |                  N