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

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int x1 = N % K;
  int x2 = N - K*(N / K + 1);
  
  if (|x1| > |x2|) {
    cout << |x2| <<endl;
  } else {
    cout << |x1| <<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:7: error: expected primary-expression before '|' token
   11 |   if (|x1| > |x2|) {
      |       ^
a.cc:11:12: error: expected primary-expression before '>' token
   11 |   if (|x1| > |x2|) {
      |            ^
a.cc:11:14: error: expected primary-expression before '|' token
   11 |   if (|x1| > |x2|) {
      |              ^
a.cc:11:18: error: expected primary-expression before ')' token
   11 |   if (|x1| > |x2|) {
      |                  ^
a.cc:12:13: error: expected primary-expression before '|' token
   12 |     cout << |x2| <<endl;
      |             ^
a.cc:12:18: error: expected primary-expression before '<<' token
   12 |     cout << |x2| <<endl;
      |                  ^~
a.cc:14:13: error: expected primary-expression before '|' token
   14 |     cout << |x1| <<endl;
      |             ^
a.cc:14:18: error: expected primary-expression before '<<' token
   14 |     cout << |x1| <<endl;
      |                  ^~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  lint n,k;
  cin>>n>>k;
  if(n<k){
    cout<<n;
  }
  else{
    lint x,y,a,b;
    x=n/k;
    y=x+1;
    a=k*x;
    b=k*y;
    a=abs(n-a);
    b=abs(n-b);
    cout<<min(a,b,n);
  }
}

Compiler output:
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:54:14:   required from here
   54 |     cout<<min(a,b,n);
      |           ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: C++

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

int main() {
  int N=0, K=0;
  scanf ("%d %d", &N, &K);
  while(1) {
    int tmp = (int)fabs(N-K);
    if (N < tmp) {
      break;
    }
    N = tmp;
  }
  printf(N);
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
   14 |   printf(N);
      |          ^
      |          |
      |          int
In file included from a.cc:1:
/usr/include/stdio.h:363:43: note:   initializing argument 1 of 'int printf(const char*, ...)'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Language: C++

n,m = map(int, input().split(' '))
re = 0
if n > m:
    while re >= 0:
        re = n - m
        n = m
        m = re
else: 
    print(n)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,m = map(int, input().split(' '))
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.
 
int main()
{
	int N,K;
	cin>>N>>K;

	while(abs(N)>0)({
		abs(N)-abs(K);}
}}
	

Compiler output:
a.cc: In function 'int main()':
a.cc:13:32: error: expected ')' before '}' token
   13 |                 abs(N)-abs(K);}
      |                                ^
      |                                )
   14 | }}
      | ~                               
a.cc:12:24: note: to match this '('
   12 |         while(abs(N)>0)({
      |                        ^
a.cc:13:32: error: expected ';' before '}' token
   13 |                 abs(N)-abs(K);}
      |                                ^
      |                                ;
   14 | }}
      | ~                               
a.cc: At global scope:
a.cc:14:2: error: expected declaration before '}' token
   14 | }}
      |  ^
Language: C++


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

int main(){
	int n, k;
	cin >> n >> k;
	if (n % k == 0) cout << 0;
	else cout << k - n % k
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:31: error: expected ';' before 'return'
    9 |         else cout << k - n % k
      |                               ^
      |                               ;
   10 |         return 0;
      |         ~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.
 
int main()
{
	int N,K;
	cin>>N>>K;

	while(abs(N)>0)({
		abs(N)-abs(K);}
}
	

Compiler output:
a.cc: In function 'int main()':
a.cc:13:32: error: expected ')' before '}' token
   13 |                 abs(N)-abs(K);}
      |                                ^
      |                                )
   14 | }
      | ~                               
a.cc:12:24: note: to match this '('
   12 |         while(abs(N)>0)({
      |                        ^
a.cc:13:32: error: expected ';' before '}' token
   13 |                 abs(N)-abs(K);}
      |                                ^
      |                                ;
   14 | }
      | ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long k;
long calc(long n){
    long result = abs(n-k);
    if(n<result) return n;
    return calc(result);
}

int main() {
    long n;
    cin >> n >> k;
    
    //if(k==1) cout << 0 << endl;
    else if(n<k) cout << n << endl;
    else{
        while(n>k){
        n=n%k;
        }
        cout << calc(n) << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'else' without a previous 'if'
   18 |     else if(n<k) cout << n << endl;
      |     ^~~~
Language: C++

#include<iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N,K1;
    cin>>N>>K;
    if(N>K){
        N=N-(N-K)/K*K;
    }
    if(N==K){
        cout<<"0\n";
        return 0;
    }
    if(N>K)
    N-=K;
    if(K-N>N){
        cout<<N<<"\n";
    }else cout<<K-N<<"\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: 'K' was not declared in this scope; did you mean 'K1'?
    7 |     cin>>N>>K;
      |             ^
      |             K1
Language: C

#include <stdio.h>
#include <stdlib.h>
int main(void){
int N,K;
scanf("%d %d", &N,&K);
int Min=N;
while (True){
    int x=abs(Min-K):
    if(Min<x){
        printf("%d",Min);
        break;
    }
    else{
        Min=x;
    }

    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:8: error: 'True' undeclared (first use in this function)
    7 | while (True){
      |        ^~~~
main.c:7:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:8:21: error: expected ',' or ';' before ':' token
    8 |     int x=abs(Min-K):
      |                     ^
main.c:13:5: error: 'else' without a previous 'if'
   13 |     else{
      |     ^~~~
main.c:18:1: error: expected declaration or statement at end of input
   18 | }
      | ^
Language: C++


vector<ll> res;
int turn;
void dfs(int r, ll now, int last) {
	if (r == turn) {
		res.push_back(now);
		return;
	}
	int p = last - 1;
	int q = last + 1;
	now *= 10;
	if (p >= 0)
		dfs(r + 1, now + p, p);
	dfs(r + 1, now + last, last);
	if (q <= 9)
		dfs(r + 1, now + q, q);
}

Compiler output:
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<ll> res;
      | ^~~~~~
a.cc:4:17: error: 'll' has not been declared
    4 | void dfs(int r, ll now, int last) {
      |                 ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:6:17: error: 'res' was not declared in this scope
    6 |                 res.push_back(now);
      |                 ^~~
Language: C++

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

int main() {
  int N=0, K=0;
  scanf ("%d %d", &N, &K);
  int tmp = 0, res = 0;
  while(1) {
    tmp = (int)fabs(N-K);
    if (N < tmp) {
      break;
    }
    N = tmp;
  }
  printf(N);
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:10: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
   15 |   printf(N);
      |          ^
      |          |
      |          int
In file included from a.cc:1:
/usr/include/stdio.h:363:43: note:   initializing argument 1 of 'int printf(const char*, ...)'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, K;
  int M;
  cin >> N >> K;
  while(1) {
  M = N - K;
  if (M < 0) {
    M = -M;
  }
  if (M >= N) {
    cout << N;
  	break;
  }
    if (M == 0) {
      cout << M
    };
  if (M < N) {
    N = M;
  }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:16: error: expected ';' before '}' token
   18 |       cout << M
      |                ^
      |                ;
   19 |     };
      |     ~
Language: C++

#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>

using namespace std;

int main() {
    int n , k = 0 ;
    int min , temp;
    cin >> n >> k;
    min = n;
    temp = n;
    for (int i = 0; i < 10^18; i++){
        temp = abs(temp - k);
        if temp < min {
            min = temp;
        }
    }
    cout << min << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:16:12: error: expected '(' before 'temp'
   16 |         if temp < min {
      |            ^~~~
      |            (
Language: C++

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

long long int gcd(long long int a, long long int b) { return b ? gcd(b, a%b) : a;}

int main(){

    long long int n,k,a,b;

    cin >> n >> k;

    a=max(n,k)-min(n,k);

    if(n<=k){
        n=min(a,n);
    }else{
        n=gcd(n,k);
        a=max(n,k)-min(n,k);
        n=min(n,a)
    }

    cout << n << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:19: error: expected ';' before '}' token
   19 |         n=min(n,a)
      |                   ^
      |                   ;
   20 |     }
      |     ~
Language: C++

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

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

    long long int A,B;

    A = N;
    B = N-1;

    do while(A > B){
        A = N;
        N = N-K;
        long long llabs(N);
        B = N;
    }

    cout << N << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: expected 'while' before 'cout'
   20 |     cout << N << endl;
      |     ^~~~
a.cc:20:5: error: expected '(' before 'cout'
   20 |     cout << N << endl;
      |     ^~~~
      |     (
a.cc:20:22: error: expected ')' before ';' token
   20 |     cout << N << endl;
      |     ~~~~             ^
      |                      )
Language: C++

#include <stdio.h>

int main() {
  int N=0, K=0;
  int A[1001];
  scanf ("%d %d", &N, &K);
  int tmp = 0, res = 0;
  while(1) {
    tmp = N-K;
    if (N < tmp) {
      break;
    }
    N = tmp;
  }
  printf(N);
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:10: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
   15 |   printf(N);
      |          ^
      |          |
      |          int
In file included from a.cc:1:
/usr/include/stdio.h:363:43: note:   initializing argument 1 of 'int printf(const char*, ...)'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Language: C++

#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>

using namespace std;

int main() {
    int n , k = 0 ;
    int min , temp;
    cin >> n >> k;
    min = n;
    temp = n;
    for (int i = 0, i < 10^18 , i++){
        temp = abs(temp - k);
        if temp < min {
            min = temp;
        }
    }
    cout << min << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: expected ';' before '<' token
   14 |     for (int i = 0, i < 10^18 , i++){
      |                      ^~
      |                      ;
a.cc:14:23: error: expected primary-expression before '<' token
   14 |     for (int i = 0, i < 10^18 , i++){
      |                       ^
a.cc:14:36: error: expected ';' before ')' token
   14 |     for (int i = 0, i < 10^18 , i++){
      |                                    ^
      |                                    ;
a.cc:16:12: error: expected '(' before 'temp'
   16 |         if temp < min {
      |            ^~~~
      |            (
Language: C

#include <stdio.h>

int main(void) {  
 int N=0, K=0;
  scanf("%d%d",&N,&K);

 N = N-int(N/K)*K;

  while (1){
    int dif =N-K;
    if (dif < 0) dif *= -1;

    if (N >= dif) N = dif;
    else break;

  }

  printf ("%d",N);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:8: error: expected expression before 'int'
    7 |  N = N-int(N/K)*K;
      |        ^~~
Language: C++

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

long long int gcd(long long int a, long long int b) { return b ? gcd(b, a%b) : a;}

int main(){

    long long int n,k,a,b;

    cin >> n >> k;

    a=max(n,k)-min(n,k);

    if(n<=k){
        n=min(a,n);
    }else{
        n=gcd(n,k);
        n=min(n,max(n,k)-min(n,k))
    }

    cout << n << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:35: error: expected ';' before '}' token
   18 |         n=min(n,max(n,k)-min(n,k))
      |                                   ^
      |                                   ;
   19 |     }
      |     ~
Language: C

#include <stdio.h>

int main(void) {  
 int N=0, K=0;
  scanf("%d%d",&N,&K);

 N = N-int(N/K)*K;

  while (1){
    int dif =N-K;
    if (dif < 0) dif *= -1;

    if (N >= dif) N = dif;
    else break;

  }

  printf ("%lf",N);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:8: error: expected expression before 'int'
    7 |  N = N-int(N/K)*K;
      |        ^~~
Language: C

#include <stdio.h>
#include <stdlib.h>
int main (){
  int N=0;
  int K=0;
  int i=0;
  int j=0;
  scanf("%d %d", &N, &K);
  while(){
  	i = N - K;
  	j = abs(i);
  	N = j;
  }
  printf("%d", N);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:9: error: expected expression before ')' token
    9 |   while(){
      |         ^
Language: C

#include <stdio.h>
#include <stdlib.h>
int main(void){
int N,K;
scanf("%d %d", &N,&K);
Min=N;
while (True){
    x=abs(Min-K):
    if(Min<x){
        print(Min);
        break;
    }
    else{
        Min=x;
    }

    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:1: error: 'Min' undeclared (first use in this function)
    6 | Min=N;
      | ^~~
main.c:6:1: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:8: error: 'True' undeclared (first use in this function)
    7 | while (True){
      |        ^~~~
main.c:8:5: error: 'x' undeclared (first use in this function)
    8 |     x=abs(Min-K):
      |     ^
main.c:8:17: error: expected ';' before ':' token
    8 |     x=abs(Min-K):
      |                 ^
      |                 ;
main.c:18:1: error: expected declaration or statement at end of input
   18 | }
      | ^
Language: C++

#include <stdio.h>

int main() {
  int N=0, K=0;
  int A[1001];
  scanf ("%d %d", &N, &K);
  tmp = 0;
  while(1) {
    tmp = N-K;
    K = tmp;
    if (K > tmp) {
      break;
    }
  }
  printf(tmp);
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'tmp' was not declared in this scope
    7 |   tmp = 0;
      |   ^~~
Language: C++

N, K = map(int,input().split(" "))

if K > N :
    print( min(N, K-N) )
else :
    temp = N//K
    N = N-(temp*K)
    print( min(N, K-N))



Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N, K = map(int,input().split(" "))
      | ^
Language: C++

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

int main() {
  int n,k;
  cin >> n >> k;
  if(n == 0) cout << 0 <<endl;
  else if(k == 1)cout << 0 <<endl;
  else if((n+k)%2 == 0) cout << 2 << endl;
  else cout << 1 << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:10:26: error: expected '}' at end of input
   10 |   else cout << 1 << endl;
      |                          ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, K;
  cin >> N >> K;
  int M = N - K;
  while(1) {
 
  if (M < 0) {
    M = -M;
  }
  if (M >= N) {
    cout << N;
  	break;
  }
  if (M < N) {
    N = M;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:2: error: expected '}' at end of input
   20 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <iostream>
using namespace std;
int main(){
    __int64 N ,K;
    cin >> N >> K;

    while(true){
        __int64 x = abs(N - K);
        if (x < N) N = x;
        else break;
    }
    
    cout << N << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
    4 |     __int64 N ,K;
      |     ^~~~~~~
      |     __int64_t
a.cc:5:12: error: 'N' was not declared in this scope
    5 |     cin >> N >> K;
      |            ^
a.cc:5:17: error: 'K' was not declared in this scope
    5 |     cin >> N >> K;
      |                 ^
a.cc:8:16: error: expected ';' before 'x'
    8 |         __int64 x = abs(N - K);
      |                ^~
      |                ;
a.cc:9:13: error: 'x' was not declared in this scope
    9 |         if (x < N) N = x;
      |             ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
 
int main() {
    unsigned long N, K;
    cin >> N >> K;
    unsigned long x,y;
  
    if (N % K){
      x = N/K + 1;
    }else{
      x = N/K;
    }
    y = N - x*K;
    cout << min(abs(y), y + K) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:20: error: call of overloaded 'abs(long unsigned int&)' is ambiguous
   16 |     cout << min(abs(y), y + K) << endl;
      |                 ~~~^~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,k;
  cin>>n>>k;
  int m=n-(n/k)*k;
  int ans=abs(m-k);
  cout<<min(ans,abs(ans-k));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: no matching function for call to 'min(int&, long long int)'
    9 |   cout<<min(ans,abs(ans-k));
      |         ~~~^~~~~~~~~~~~~~~~
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:9:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
    9 |   cout<<min(ans,abs(ans-k));
      |         ~~~^~~~~~~~~~~~~~~~
/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:9:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    9 |   cout<<min(ans,abs(ans-k));
      |         ~~~^~~~~~~~~~~~~~~~
Language: Java

import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int x = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());
        int temp = 0;
        int min = 0;
        while(true) {
            temp = x;
            x = x - k;
            
            
            if(x<=0) {
                x = Math.abs(x);
                if(x<=temp) {
                    System.out.println(x.toString());
                } else {
                    System.out.println(temp.toString());
                }
                break;
            }
            
        }
    }
}

Compiler output:
Main.java:17: error: int cannot be dereferenced
                    System.out.println(x.toString());
                                        ^
Main.java:19: error: int cannot be dereferenced
                    System.out.println(temp.toString());
                                           ^
2 errors
Language: Java

import java.util.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            int n = Integer.parseInt(sc.next());
            int k = Integer.parseInt(sc.next());

            if(n >= k){
                if((n % k) == 0){
                    System.out.println(0);
                    System.exit(0);
                }else{
                    if((n % k) < abs((n % k) - k)){
                        System.out.println(n % k);
                        System.exit(0);
                    }else{
                        System.out.println(abs((n % k) - k));
                        System.exit(0);
                    }
                }
            }else{
                System.out.println(n);
                System.exit(0);
            }
 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Compiler output:
Main.java:16: error: cannot find symbol
                    if((n % k) < abs((n % k) - k)){
                                 ^
  symbol:   method abs(int)
  location: class Main
Main.java:20: error: cannot find symbol
                        System.out.println(abs((n % k) - k));
                                           ^
  symbol:   method abs(int)
  location: class Main
2 errors
Language: C

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

int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	
	int a = n/k;
	n = fabs(n-a*k);
	int m;
	m = fabs(n-k);
	
	if(n>m){
		printf("%d",m);
	}
	if(n=<m){
		printf("%d",n);
	}	
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:17:14: error: expected expression before '<' token
   17 |         if(n=<m){
      |              ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>
#include <iomanip>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long n, k;
	cin >> n >> k;

	if (k >= 2 * n) {
		cout << n << "\n";
	}
	else if (k < 2 * n && k >= n) {
		cout << k - n << "\n";
	} else {
		if (n - k >= k) {
			cout << n % k << "\n";
		} else {
			long long curr = n % k;
			cout << min(curr, abs(curr - k)) << "\n"
		}
	}

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:65: error: expected ';' before '}' token
   62 |                         cout << min(curr, abs(curr - k)) << "\n"
      |                                                                 ^
      |                                                                 ;
   63 |                 }
      |                 ~
Language: C++

#include <iostream>
#include<vector>
using namespace std;
long long mod(string num, long long a) 
{ 
    // Initialize result 
    longlong res = 0; 
  
    // One by one process all digits of 'num' 
    for (long long i = 0; i < num.length(); i++) 
         res = (res*10 + (int)num[i] - '0') %a; 
  
    return res; 
} 
  
int main()
{   long long k,diff,last;
string n;
cin>>n>>k;
cout<<mod(n,k);
return 0;

}

Compiler output:
a.cc: In function 'long long int mod(std::string, long long int)':
a.cc:7:5: error: 'longlong' was not declared in this scope
    7 |     longlong res = 0;
      |     ^~~~~~~~
a.cc:11:10: error: 'res' was not declared in this scope
   11 |          res = (res*10 + (int)num[i] - '0') %a;
      |          ^~~
a.cc:13:12: error: 'res' was not declared in this scope
   13 |     return res;
      |            ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  if(A<B){
    cout << A << endl;
  }
  else{
    if(A%B==0){
      cout << 0 << endl;
    }
    else{
      cout << A << endl;
    }
  }
      
    

Compiler output:
a.cc: In function 'int main()':
a.cc:17:4: error: expected '}' at end of input
   17 |   }
      |    ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

int main(){
  long N,K;
  cin >> N >> K;
  if(N % K == 0) N = 0;
  while(abs(N-K) < N){
    if(N % K == 0){
      N = 0;
      break;
    } 
    N = abs(N-K);
  } 
  cout << N << endl;
  return 0;
}

Compiler output:
a.cc:1:5: error: stray '#' in program
    1 |   1 #include <bits/stdc++.h>
      |     ^
a.cc:1:3: error: expected unqualified-id before numeric constant
    1 |   1 #include <bits/stdc++.h>
      |   ^
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> N >> K;
      |   ^~~
a.cc:8:9: error: 'abs' was not declared in this scope
    8 |   while(abs(N-K) < N){
      |         ^~~
a.cc:15:3: error: 'cout' was not declared in this scope
   15 |   cout << N << endl;
      |   ^~~~
a.cc:15:16: error: 'endl' was not declared in this scope
   15 |   cout << N << endl;
      |                ^~~~
Language: C++

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

int64_t abso(int64_t v)
{
    return (v < 0) ? -v : v;
}

int main(int argc, const char * argv[]) {
    uint64_t N, K;
    cin >> N;
    cin >> K;

    uint64_t ans = N;
    uint64_t prev;
    do {
        prev = ans;
        ans = min(ans, abso(ans - K));
    }while(ans != prev);
    
    std::cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:12:5: error: 'uint64_t' was not declared in this scope
   12 |     uint64_t N, K;
      |     ^~~~~~~~
a.cc:4:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    3 | #include <algorithm>
  +++ |+#include <cstdint>
    4 | using namespace std;
a.cc:13:12: error: 'N' was not declared in this scope
   13 |     cin >> N;
      |            ^
a.cc:14:12: error: 'K' was not declared in this scope
   14 |     cin >> K;
      |            ^
a.cc:16:13: error: expected ';' before 'ans'
   16 |     uint64_t ans = N;
      |             ^~~~
      |             ;
a.cc:17:13: error: expected ';' before 'prev'
   17 |     uint64_t prev;
      |             ^~~~~
      |             ;
a.cc:19:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         prev = ans;
      |                ^~~
      |                abs
a.cc:21:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |     }while(ans != prev);
      |            ^~~
      |            abs
Language: Java

import java.util.*;
import java.math.*;
public class Main{
    public static void main(String args[]){
       Scanner cin = new Scanner(System.in);
       BigInteger a, b;
       while (cin.hasNext()){
           a = cin.nextBigInteger();
           b = cin.nextBigInteger();
       while(a>0){
       	   a.subtract(b);
       }
       if(a.compareTo(0) == 0)
           System.out.println(0);
       else{
        	if((a.add(b)).compareTo(a.abs()) > 0)
            	System.out.println(a.abs());
        	else
            	System.out.println(a.add(b));
       }
       }
    }
}

Compiler output:
Main.java:10: error: bad operand types for binary operator '>'
       while(a>0){
              ^
  first type:  BigInteger
  second type: int
Main.java:13: error: incompatible types: int cannot be converted to BigInteger
       if(a.compareTo(0) == 0)
                      ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, K;
  cin >> N >> K;
  int M;
  while(1) {
  if (N - K > 0) {
    M = N - K;
  }
  else {
    M = K - N;
  }
  if (M > N) 
    cout << N;
  	break;
  }
  else {
    N = M;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: 'else' without a previous 'if'
   19 |   else {
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, K;
  cin >> N >> K;
  int M;
  while(1) {
  if (N - K > 0) {
    M = N - K;
  }
  else {
    M = K - N;
  }
  if (M > N) 
    cout << N;
  	break;
  }
  else {
    N = M;
  }
}
d

Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: 'else' without a previous 'if'
   19 |   else {
      |   ^~~~
a.cc: At global scope:
a.cc:23:1: error: 'd' does not name a type
   23 | d
      | ^
Language: Java

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
    	long N = sc.nextInt();
    	long K = sc.nextInt();

    	long a = N%K;

    	long b = K - a;

    	if(a<=b){
    	   	System.out.println(a);
    	} else {
    		System.out.println(b);
    	}



    }
}

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

import java.util.*;
import java.math.*;
public class Main{
    public static void main(String args[]){
       Scanner cin = new Scanner(System.in);
       BigInteger a, b;
       while (cin.hasNext()){
           a = cin.nextBigInteger();
           b = cin.nextBigInteger();
       while(a>0){
       	   a.subtract(b)
       }
       if(a.compareTo(0) == 0)
           System.out.println(0);
       else{
        	if((a.add(b)).compareTo(a.abs()) > 0)
            	System.out.println(a.abs());
        	else
            	System.out.println(a.add(b));
       }
       }
    }
}

Compiler output:
Main.java:11: error: ';' expected
       	   a.subtract(b)
       	                ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
  while(1)
  { if(n%k==0){cout<<n;break;}
    else if(n>k){n=n%k;
                 continue;}
    else if(n<k){a=k-n;
                 if(a<=n){cout<<a;break;}
                 else{cout<<n;break;}
                }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: 'a' was not declared in this scope
    9 |     else if(n<k){a=k-n;
      |                  ^
Language: C++

#include<iostream>
#include<vector> 
#include<algorithm>
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;
    int x,y;
  
    if (N % K){
      x = N/K + 1;
    }else{
      x = N/K;
    }
 　 y = N - x*K;
    cout << min(abs(y), y + K) << endl;
}

Compiler output:
a.cc:16:2: error: extended character 　 is not valid in an identifier
   16 |  　 y = N - x*K;
      |  ^
a.cc: In function 'int main()':
a.cc:16:2: error: '\U00003000' was not declared in this scope
   16 |  　 y = N - x*K;
      |  ^~
Language: Java

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
    	double N = sc.nextInt();
    	double K = sc.nextInt();

    	double a = N%K;

    	double b = K - a;

    	if(a<=b){
    	   	System.out.println(a);
    	} else {
    		System.out.println(b);
    	}



    }
}

Compiler output:
Main.java:4: error: cannot find symbol
    	Scanner sc = new Scanner(System.in);
    	^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
    	Scanner sc = new Scanner(System.in);
    	                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <iostream>
#include <string.h>
using namespace std;
long long difference[1000000000000000001];
int main(){
    long long x, n ,k;
    long long i=1;
    long long x = 1000000000000000001;
    cin >> n >> k;
    x = n; 
    while(x > k){
        difference[i] = abs(n - k);
        i += 1;
        x = abs(x - k);  
    }
    for(int j=1;j<=i;j++){
        if(difference[j] < x){
            x = difference[j];
        }
    }
    cout << x;
    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: redeclaration of 'long long int x'
    8 |     long long x = 1000000000000000001;
      |               ^
a.cc:6:15: note: 'long long int x' previously declared here
    6 |     long long x, n ,k;
      |               ^
Language: C

#include<stdio.h>
int main()
{
  long long N,K,tmp;
  scanf("%lld %lld",&N,&K);
  while(1){
    tmp=N
    N=N-K;
    if(N<0){
      N=-N;
    }
    if(tmp>=N){
      break;
    }
  }
  printf("%lld",tmp);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:7:10: error: expected ';' before 'N'
    7 |     tmp=N
      |          ^
      |          ;
    8 |     N=N-K;
      |     ~
Language: Java

import java.util.Scanner;
import java.lang.Math;
public class Main{
  public static void main(String[] args){
    Scanner a = new Scanner(System.in);
    long k = a.nextLong();
    long n = a.nextLong();
    if(n == 0){
            System.out.print(k);
            break;
        }
    while(k>=0){
        
        if(n == 1){
            System.out.print(0);
            break;
        }
        
        
        if(k<0){
            System.out.print(Math.abs(k));
        }
        if(k < n ){
            System.out.print(Math.min(k, Math.abs(k-n)));
        }
        k -= n;
    }
  }

}


Compiler output:
Main.java:10: error: break outside switch or loop
            break;
            ^
1 error
Language: C++

#include<iostream>
#include<vector> 
#include<algorithm>
using namespace std;

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

    int x = ceil(N / K);
    int y = (int)N - x*K

    cout << min(abs(y), N + K) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: 'ceil' was not declared in this scope
   10 |     int x = ceil(N / K);
      |             ^~~~
a.cc:13:5: error: expected ',' or ';' before 'cout'
   13 |     cout << min(abs(y), N + K) << endl;
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin>>n>>k;
  if(k==1 && n>1)
    cout<<0;
  else{
    d=(n/k);
    cout<<d;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'd' was not declared in this scope
   10 |     d=(n/k);
      |     ^
a.cc:13:2: error: expected '}' at end of input
   13 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

 #include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	lint n, k; cin>>n>>k;
	if(n>1&&k>1) cout<<euclidean_gcd(n,k)<<endl;
	else if cout<<0<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:17: error: expected '(' before 'cout'
   41 |         else if cout<<0<<endl;
      |                 ^~~~
      |                 (
Language: C++

// 2020 0404 161 C Replacing integer
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;

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

    int x;
    is(N == K){
        cout << "0" << endl;
        return 0;
    }else if (N > K) {
        x = N % K;
    }else{
        x = K % N;
    }

    int ans;
    int tmp;
    if(x >= K) {
        tmp = x - K;
    }else{
        tmp = K - x;
    }

    ans = min(x, tmp);

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'is' was not declared in this scope
   15 |     is(N == K){
      |     ^~
a.cc:18:6: error: 'else' without a previous 'if'
   18 |     }else if (N > K) {
      |      ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	uint64_t n, k;
	cin >> n >> k;

	if (k == 1) {
		cout << n << '\n';
		return 0;
	}
	uint64_t lv = min(__gcd(n, k), abs(n - __gcd(n, k) * k - k));
	cout << lv << '\n';
	// |7-4| = 3
	// |3-4| = 1
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:43: error: call of overloaded 'abs(uint64_t)' is ambiguous
   16 |         uint64_t lv = min(__gcd(n, k), abs(n - __gcd(n, k) * k - k));
      |                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
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<bits/stdc++.h>
using namespace std;

int main() {
  int64_t n,k;
  cin >> n >> k;
  if(k == 1) cout << 0 << endl;
  else if((n+k)%2 == 0) cout << 2 << endl;
  else cout << 1 << endl:
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:25: error: expected ';' before ':' token
    9 |   else cout << 1 << endl:
      |                         ^
      |                         ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long n,k;
int main(){
	scanf("%lld%lld",&n,&k);
	
	n%=k; 
	printf("%lld\n",min1(n,k-n));
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:25: error: 'min1' was not declared in this scope
    8 |         printf("%lld\n",min1(n,k-n));
      |                         ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
  long long int n,k;
  cin >> n >> k;
  
  long long int hel = min(n%k, k - (n%k))
	cout << hel  << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: expected ',' or ';' before 'cout'
   10 |         cout << hel  << endl;
      |         ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N ,K, A, B;
  cin >> N >> K;
  A=N%K;
  B=(A-K>0)?A-K:K-A;
  cout << ((A>K)?K:A;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:21: error: expected ')' before ';' token
    8 |   cout << ((A>K)?K:A;
      |           ~         ^
      |                     )
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  long long n, k; cin >> n >> k;
  int res = n;
  long long N = 1000000000000000000;
  for(int i=0 i<N; i++){
    long long front = res;
    res = min(res, abs(res - k) );
  }
  cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: expected ';' before 'i'
   12 |   for(int i=0 i<N; i++){
      |              ^~
      |              ;
a.cc:14:14: error: no matching function for call to 'min(int&, long long int)'
   14 |     res = min(res, abs(res - k) );
      |           ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:14:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   14 |     res = min(res, abs(res - k) );
      |           ~~~^~~~~~~~~~~~~~~~~~~~
/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
Language: C

#include<stdio.h>
int main()
{
  long long N,K,tmp;
  scanf("%lld %lld",&N,&K);
  while(1){
    tmp=N
    N=N-K;
    if(N<0){
      N=-N;
    }
    if(tmp>=N){
      break;
    }
  }
  printf("%d",tmp);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:10: error: expected ';' before 'N'
    7 |     tmp=N
      |          ^
      |          ;
    8 |     N=N-K;
      |     ~
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
typedef long long LL;
 
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
} 
 
int main(){
	fast;
	lli n, k;
	cin>>n>>k;
	lli prev;
	if(n%k==0) cout<<0;
	else{
	while(1){
	    prev=abs(n-k);
	    n=prev;
	    if(abs(n-k)>prev) break;
	}
	cout<<n;
	}
	return 0;
}

Compiler output:
a.cc: In function 'LL gcd(LL, LL)':
a.cc:17:28: error: 'mod' was not declared in this scope; did you mean 'modf'?
   17 |                 return b % mod;
      |                            ^~~
      |                            modf
a.cc:18:30: error: 'mod' was not declared in this scope; did you mean 'modf'?
   18 |         return gcd(b%a, a) % mod;
      |                              ^~~
      |                              modf
Language: C++

#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
 
#define T long long
 
T Abs(T n){
	return n>0?n:-n;
}
 
int main(){
	T n,k;
	std::cin>>n>>k;
	while(1){
		if(Abs(n-k)>=n){
			std::cout<<n<<std::endl;
			return 0;
		}else(n%k==0){
			std::cout<<0<<std::endl;
			return 0;
		}
		n=Abs(n-k);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:30: error: expected ';' before '{' token
   19 |                 }else(n%k==0){
      |                              ^
      |                              ;