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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: expected primary-expression before '<' token
    7 |   if(n%k=<abs((n%k)-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:12:2: error: invalid preprocessing directive #typedef
   12 | #typedef long long LL;
      |  ^~~~~~~
a.cc:14:1: error: 'LL' does not name a type
   14 | LL gcd(LL a, LL b)
      | ^~
Language: C++

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

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

    int A,B;

    while(A > B){
        A = N;
        N = N-K;
        N = |N|
        B = N;
    }

    cout << N << endl;

    return 0;
}

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

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int>a(100000000000);
  a.at(0)=n;
  for (int i=1;i<100000000000;i++){
    a.at(i)==abs(a.at(i-1)-k)
  }
  sort(a.begin(), a.end());
  cout<<a.at(0)<<endl;
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:10:30: error: expected ';' before '}' token
   10 |     a.at(i)==abs(a.at(i-1)-k)
      |                              ^
      |                              ;
   11 |   }
      |   ~
Language: C++

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

int main() {
  
  int64_t N, K;
  cin >> N >> K;
  
  int64_t M = 1000000000000000000
  
  vector<int64_t> A(M);
  A.at(0) = N;
  
  for (int64_t i = 0; i < M; i++) {
    if (A.at(i - 1) < K) {
      A.at(i) = K - A.at(i - 1);
    }
    else {
      A.at(i) = A.at(i - 1) - K;
    }
    
    if (A.at(i) == 0) {
      cout << 0 << endl;
      break;
    }
  }
  
  sort(A.begin(), A.end());
  cout << A.at(0) << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: expected ',' or ';' before 'vector'
   11 |   vector<int64_t> A(M);
      |   ^~~~~~
a.cc:12:3: error: 'A' was not declared in this scope
   12 |   A.at(0) = N;
      |   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n,k;
  cin>>n>>k;
  int b=abs(n-k);
  while(b<ans){
    n=min(n,b);
  }
  cout<<n<<endl; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |   while(b<ans){
      |           ^~~
      |           abs
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:29: error: expected ')' before '{' token
    7 |   if(N-(N/K)*K>((N/K+1)*K-N){
      |     ~                       ^
      |                             )
a.cc:13:1: error: expected primary-expression before '}' token
   13 | }
      | ^
Language: C++

			#include <bits/stdc++.h>
			using namespace std;
			#define rep(i,a,n) for (int i=a;i<n;i++)
			#define per(i,a,n) for (int i=n-1;i>=a;i--)
			#define pb push_back
			#define mp make_pair
			#define all(x) (x).begin(),(x).end()
			#define fi first
			#define se second
			#define SZ(x) ((int)(x).size())
			typedef vector<int> VI;
			typedef long long ll;
			typedef pair<int,int> PII;
			typedef double db;
			mt19937 mrand(random_device{}()); 
			const ll mod=1000000007;
			int rnd(int x) { return mrand() % x;}
			ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
			ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
			int main() {
				 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
				 unsigned long long n,k;
				 cin>>n>>k;
				else if(n==k || k==1 || n==0)
				cout<<"0"<<"\n";
				else if(n>k)
				cout<<n/k<<"\n";
				
				else
				{
					cout<<n%k<<"\n";
				}
			}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:33: error: 'else' without a previous 'if'
   24 |                                 else if(n==k || k==1 || n==0)
      |                                 ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long n=0,k=0;
  int df; 
 
  cin>>n>>k;
  df = abs(n - k); 
 
  if(k==1){
    cout<<0<<endl;
    return 0;
  }
 
  for(int i=0;i<n;i++){
    if(df > abs(df - k)){
      df = abs(df - k); 
    }   
  }

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

#define DBG 1

#include<bits/stdc++.h>
 
#define fi first
#define se second
 
#define mp make_pair
#define pb push_back
 
#define all(x) (x).begin(), (x).end()
 
#define F return

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)

#define debug(x) if(DBG) cerr << #x << " is " << x << '\n';

typedef long long ll;

using namespace std;                             

typedef pair<int, int> pii;
typedef pair<ll, ll> pll; 

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int,int>> vpii;

const int MAXN = 2e5 + 500;
const int INF = 1e9 + 23;
    
const int MOD = 1e9 + 7;

int n, d[MAXN];

//Real Code Started from Here;


void solve() {
    //code here;
	ll n,k;
  	int count=0;ans=INT_MIN;
  	while(ans!=0 || ans==1){
  		ans=abs(n-k);
      	count++;
    }
  cout<<count-1;
  
}

//Main Function;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

//if test cases is not given;
	
	solve();

//if no of test cases is given;
    
/*
	
	int tt;cin>>tt;
	while (tt--) {
		solve();
	}
	
*/

    // you should actually read the stuff at the bottom
return 0;
}
/*
logic






*/


Compiler output:
a.cc: In function 'void solve()':
a.cc:44:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |         int count=0;ans=INT_MIN;
      |                     ^~~
      |                     abs
Language: Java

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);

        long N = scanner.nextLong();
        long K = scanner.nextLong();
        long min = N;

        if(N >= K) {
            N %= K;
            while(true){
                long next = Math.abs(N - K);
                if(min > next) {
                    min = next;
                } else {
                    break;
                }
                N = next;
            }
            System.out.println(N);
        }else{
            System.out.println(N);
        }

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

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

int bubble(int *r, int n){
    int flag=1;
    int tmp;
    while(flag){
        flag=0;
        for(int i=n-1;i>0;i--){
            if(r[i]<r[i-1]){
                tmp=r[i];
                r[i]=r[i-1];
                r[i-1]=tmp;
                flag=1;
               
            }
        }
    }

    //for(int k=0;k<n;k++){
      //  if(k!=n-1) cout<<r[k]<<' ';
        //else cout<<r[k]<<endl;
    //}
    return 0;

}

long long int drr(long long int n, long long int k){
    long long int a, b;
    a = abs(n-k);
    b = abs(n+k);
    if(n<a && n<b && n>0) return n;
    else if(a<b) return drr(a, k);
    else return drr(b, k);
}


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

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


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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'll' was not declared in this scope
    5 |   ll n,k;
      |   ^~
a.cc:6:8: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 |   cin>>n>>k;
      |        ^
      |        yn
a.cc:6:11: error: 'k' was not declared in this scope
    6 |   cin>>n>>k;
      |           ^
a.cc:7:5: error: expected ';' before 'temp'
    7 |   ll temp=n%k;
      |     ^~~~~
      |     ;
a.cc:8:13: error: 'temp' was not declared in this scope; did you mean 'tm'?
    8 |   cout<<min(temp,abs(temp-k))<<endl;
      |             ^~~~
      |             tm
Language: Java

import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		long ans = N;
		if(N > M){
			N = N - (K * (N / K));
			for(int i = 0;i < 2;i++){
				N = Math.abs(N - K);
				if(N < ans){
					ans = N;
				}
			}
		}
		System.out.println(ans);
	}
}

Compiler output:
Main.java:8: error: cannot find symbol
		if(N > M){
		       ^
  symbol:   variable M
  location: class Main
1 error
Language: C++

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

#define int long long

int32_t main(){
	int n , k ;
	cin >> n >> k ;
	cout << min((n%k),k-n%k) ;
	return 0 ;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc:6:1: error: 'int32_t' does not name a type
    6 | int32_t main(){
      | ^~~~~~~
a.cc:1:1: note: 'int32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
  +++ |+#include <cstdint>
    1 | include <bits/stdc++.h>
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n,k;
  cin>>n>>k;
  int ans=min(n,abs(n-k);
  int b=abs(ans-k);
  while(b<ans){
    ans=min(ans,b);
  }
  cout<<ans<<endl; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: expected ')' before ';' token
   11 |   int ans=min(n,abs(n-k);
      |              ~          ^
      |                         )
Language: C++

#include<cstdio>
#include<algorithm>
using namespace std;

int a[1005];
int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	int minn=n%m;
	minn=min(minn,abs(minn-m));
	printf("%lld\n",minn);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: no matching function for call to 'min(int&, long long int)'
   11 |         minn=min(minn,abs(minn-m));
      |              ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/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:11:17: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   11 |         minn=min(minn,abs(minn-m));
      |              ~~~^~~~~~~~~~~~~~~~~~
/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:11:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   11 |         minn=min(minn,abs(minn-m));
      |              ~~~^~~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
int N;
int K;
cin>>N>>K;
if(N%K==0){
	cout<<"0"<<endl;
break;
}
vector<int>vec;
int f;
if(N-K<0){
		f=0-N+K;
	}
	else{
f=N-K;	
}
for(int i=0; i<100000; i++){	
if(f-K<0){
		f=0-f+K;
	}
	else{
f=f-K;	
}
vec.at(i)=f;
}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:1: error: break statement not within loop or switch
   10 | break;
      | ^~~~~
Language: C++

#include <iostream>

unsigned long long aoki(unsigned long long  x, unsigned long long K){
	return x>K ? x-K : K-x;
}

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

	int n = 0;
	unsigned long long x = N;
	while(x < K){
		x = aoki(x, K)
		n++;
	}

	std::cout << x << std::endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:31: error: expected ';' before 'n'
   14 |                 x = aoki(x, K)
      |                               ^
      |                               ;
   15 |                 n++;
      |                 ~
Language: C++

#include<bits/stdc++.h>
#define int long long

using namespace std;

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


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:13:9: error: return-statement with no value, in function returning 'int32_t' {aka 'int'} [-fpermissive]
   13 |         return;
      |         ^~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define gc() getchar()
#define scanf scanf_s
typedef unsigned long long ull;
typedef  long long ll;
int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}
int comp(const void* a, const void* b)//用来做比较的函数。
{
	return *(int*)a - *(int*)b;
}
int main()
{
	ll n, k,m,t;
	scanf("%lld %lld", &n, &k);
	if (n == k) { printf("0\n"); return 0; }
	if (n < k) n += k;
	m = n % k;
	t = abs(m - k);
	printf("%lld", m < t ? m : t);
}

Compiler output:
main.c: In function 'main':
main.c:5:15: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    5 | #define scanf scanf_s
      |               ^~~~~~~
main.c:21:9: note: in expansion of macro 'scanf'
   21 |         scanf("%lld %lld", &n, &k);
      |         ^~~~~
Language: C++

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

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,K;
  cin >> N >> K:
  for (int i = 0; i < 1000000; i++) {
  if(N > 1000000000000*K) {
    N -= 1000000000000*K;
  }
  else {
    break;
  }
  }
  for (int i = 0; i < 1000000; i++) {
  if(N > 1000000*K) {
    N -= 1000000*K;
  }
  else {
    break;
  }
  }
  while(N > 0) {
    N -= K;
  }//NはKで引き続け、はじめて負になったときの値
  if((-N) < (N+K)) cout << -N << endl;
  else cout << N+K << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:16: error: expected ';' before ':' token
    5 |   cin >> N >> K:
      |                ^
      |                ;
a.cc:6:19: error: 'i' was not declared in this scope
    6 |   for (int i = 0; i < 1000000; i++) {
      |                   ^
Language: C++

#include <iostream>

unsigned long long aoki(int x, K){
	return x>K ? x-K : K-x;
}

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

	int n = 0;
	unsigned long long x = N;
	while(x < K){
		aoki(x, K)
		n++;
	}

	std::cout << x << std::endl;

	return 0;
}

Compiler output:
a.cc:3:32: error: 'K' has not been declared
    3 | unsigned long long aoki(int x, K){
      |                                ^
a.cc: In function 'long long unsigned int aoki(int, int)':
a.cc:4:18: error: 'K' was not declared in this scope
    4 |         return x>K ? x-K : K-x;
      |                  ^
a.cc: In function 'int main()':
a.cc:14:27: error: expected ';' before 'n'
   14 |                 aoki(x, K)
      |                           ^
      |                           ;
   15 |                 n++;
      |                 ~
Language: Java

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

        String S = sc.next();
        BigInteger N = new BigInteger(S);
        S = sc.next();
        BigInteger K = new BigInteger(S);
        sc.close();

        BigInteger min = N;
        BigInteger MONE = new BigInteger("-1");
        boolean f = true;
        while(f){
            N = N.subtract(K);
            if(N.compareTo(BigInteger.ZERO) == -1)
                N = N.multiply(MONE);
            if(N.compareTo(min) == -1){
                min = N;
            }else{
                break;
            }
            if(min.compareTo(BigInteger.ZERO) == 0)
                break;
        }
        System.out.println(min.toString());
    }
}

Compiler output:
Main.java:7: error: cannot find symbol
        BigInteger N = new BigInteger(S);
        ^
  symbol:   class BigInteger
  location: class Main
Main.java:7: error: cannot find symbol
        BigInteger N = new BigInteger(S);
                           ^
  symbol:   class BigInteger
  location: class Main
Main.java:9: error: cannot find symbol
        BigInteger K = new BigInteger(S);
        ^
  symbol:   class BigInteger
  location: class Main
Main.java:9: error: cannot find symbol
        BigInteger K = new BigInteger(S);
                           ^
  symbol:   class BigInteger
  location: class Main
Main.java:12: error: cannot find symbol
        BigInteger min = N;
        ^
  symbol:   class BigInteger
  location: class Main
Main.java:13: error: cannot find symbol
        BigInteger MONE = new BigInteger("-1");
        ^
  symbol:   class BigInteger
  location: class Main
Main.java:13: error: cannot find symbol
        BigInteger MONE = new BigInteger("-1");
                              ^
  symbol:   class BigInteger
  location: class Main
Main.java:17: error: cannot find symbol
            if(N.compareTo(BigInteger.ZERO) == -1)
                           ^
  symbol:   variable BigInteger
  location: class Main
Main.java:24: error: cannot find symbol
            if(min.compareTo(BigInteger.ZERO) == 0)
                             ^
  symbol:   variable BigInteger
  location: class Main
9 errors
Language: C++

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


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

    int amari = N % K;

    cout << N << endl;
    cout << K << endl;


    if (amari > K-amari) {
        if (amari - K < 0) {
            cout << (amari - K)*-1 << endl;
        }else{
            cout << amari - K << endl;
        }
    }
    else {
        cout << amari << endl;
    }


}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: '_int64' was not declared in this scope; did you mean 'sinf64'?
    6 |     _int64 N, K;
      |     ^~~~~~
      |     sinf64
a.cc:7:12: error: 'N' was not declared in this scope
    7 |     cin >> N >> K;
      |            ^
a.cc:7:17: error: 'K' was not declared in this scope
    7 |     cin >> N >> K;
      |                 ^
Language: C++

#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;


int main() {


    cin.tie(0);
    ios::sync_with_stdio(false);
 
 
    ll n,k;
    int tmp=0, ans=0;
    cin >> n >> k;

    tmp = min(n%k, k-n%k);

    ans = min(tmp, k);

    cout << ans << endl;
   
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:14: error: no matching function for call to 'min(int&, ll&)'
   27 |     ans = min(tmp, 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:27:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   27 |     ans = min(tmp, 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,
                 from a.cc:6:
/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:27:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |     ans = min(tmp, k);
      |           ~~~^~~~~~~~
Language: C++

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

typedef unsigned long long  ULL;
typedef long long LL;

#define pb push_back
#define mp make_pair
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define F first 
#define S second

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
//    cin>>T;
    T=1;
    while(T--){
       
       ULL n,k;
       cin>>n>>k;
       
       ULL r= n%k;
       
       ULL x=min(r, abs(r-k));
       
       cout<<x;
       
       
       
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:24: error: call of overloaded 'abs(ULL)' is ambiguous
   30 |        ULL x=min(r, abs(r-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 <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;


int main() {


    cin.tie(0);
    ios::sync_with_stdio(false);
 
 
    ll n,k, 
    int tmp=0, ans=0;
    cin >> n >> k;

    tmp = min(n%k, k-n%k);

    ans = min(tmp, k);

    cout << ans << endl;
   
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: expected unqualified-id before 'int'
   22 |     int tmp=0, ans=0;
      |     ^~~
a.cc:25:5: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   25 |     tmp = min(n%k, k-n%k);
      |     ^~~
      |     tm
a.cc:27:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |     ans = min(tmp, k);
      |     ^~~
      |     abs
Language: C++

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main(){
    IOS;
    long long n,k;
    cin >> n >> k;
    cout<<min(n%k,abs((n%k)-k))
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:32: error: expected ';' before '}' token
   30 |     cout<<min(n%k,abs((n%k)-k))
      |                                ^
      |                                ;
   31 | }
      | ~
Language: C++

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

int main(){ 
  ll n, k;
  cin >> n >> k;
  if (n < k) {
    cout << n << endl;
    return 0;@
  }
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (n % k == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1 << endl;
  return 0;
} 

Compiler output:
a.cc:13:14: error: stray '@' in program
   13 |     return 0;@
      |              ^
Language: C++

#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   ll n, k; cin >> n >> k;
   if(n==k){
      cout << 0 << endl;
      return 0;
   }

   ll ans = n;
   if(n>k){
      if(n%k==0){
         cout << 0 << endl;
         return 0;
      }

      ll tmp = n/k;
      ll tmp2 = n%k;
      dump(tmp);
      dump(tmp2);
      ans = min(tmp2, (ll)abs(tmp2-k));
   }
   else{
      ans = min(n, min((ll)abs(n-k), (ll)abs(k-n)));
   }

   cout << ans << endl;
   return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:33:13: error: expected '}' at end of input
   33 |    return 0;
      |             ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class newclas {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] lo = reader.readLine().split(" ");
        long N = Long.parseLong(lo[0]);
        long K = Long.parseLong(lo[1]);
        if(K==1) System.out.println(0);
        else {
            HashSet<Long> hs = new HashSet<Long>();
            while (!hs.contains(N)) {
                hs.add(N);
                N = Math.abs(N - K);
            }
            long min = Long.MAX_VALUE;
            for (Long t :
                    hs) {
                min = Math.min(min, t);
            }
            System.out.println(min);
        }
    }
}


Compiler output:
Main.java:6: error: class newclas is public, should be declared in a file named newclas.java
public class newclas {
       ^
1 error
Language: C++

#include<iostream>
using namespace std;
int main(){
 long long n,k;
 cin >> n >> k;
  if(k==1){
    cout << 0;
    break;
  }
 long long min = n;
 while(n>abs(n-k)){
  n = abs(n-k);
 }
  cout << n;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: break statement not within loop or switch
    8 |     break;
      |     ^~~~~
Language: C++

#include<stdio.h>
int main(){
	__int64 n,k;
	scanf("%l64d%l64d", &n, &k);
	__int64 t = n%k;
	printf("%d", t>(t-k)?k-t:t);
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
    3 |         __int64 n,k;
      |         ^~~~~~~
      |         __int64_t
a.cc:4:30: error: 'n' was not declared in this scope
    4 |         scanf("%l64d%l64d", &n, &k);
      |                              ^
a.cc:4:34: error: 'k' was not declared in this scope
    4 |         scanf("%l64d%l64d", &n, &k);
      |                                  ^
a.cc:5:16: error: expected ';' before 't'
    5 |         __int64 t = n%k;
      |                ^~
      |                ;
a.cc:6:22: error: 't' was not declared in this scope
    6 |         printf("%d", t>(t-k)?k-t:t);
      |                      ^
Language: C++

typedef long long ll;
ll n,k;
int main()
{
    cin>>n>>k;
    if(n%k==0)
    {
        cout<<"0"<<endl;
    }
    else if(n>k)
    {
        cout<<min(n%k,k-n%k)<<endl;
    }
    else if(n<k)
    {
        cout<<min(n,k-n)<<endl;
    }



}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin>>n>>k;
      |     ^~~
a.cc:8:9: error: 'cout' was not declared in this scope
    8 |         cout<<"0"<<endl;
      |         ^~~~
a.cc:8:20: error: 'endl' was not declared in this scope
    8 |         cout<<"0"<<endl;
      |                    ^~~~
a.cc:12:9: error: 'cout' was not declared in this scope
   12 |         cout<<min(n%k,k-n%k)<<endl;
      |         ^~~~
a.cc:12:15: error: 'min' was not declared in this scope; did you mean 'main'?
   12 |         cout<<min(n%k,k-n%k)<<endl;
      |               ^~~
      |               main
a.cc:12:31: error: 'endl' was not declared in this scope
   12 |         cout<<min(n%k,k-n%k)<<endl;
      |                               ^~~~
a.cc:16:9: error: 'cout' was not declared in this scope
   16 |         cout<<min(n,k-n)<<endl;
      |         ^~~~
a.cc:16:15: error: 'min' was not declared in this scope; did you mean 'main'?
   16 |         cout<<min(n,k-n)<<endl;
      |               ^~~
      |               main
a.cc:16:27: error: 'endl' was not declared in this scope
   16 |         cout<<min(n,k-n)<<endl;
      |                           ^~~~
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

void solve() {
    Bint n, k;
    cin >> n >> k;

    Bint old = n;

    do {
        old = n;
        n %= k;
    } while (old > n);

    n = min(n, (n - k >= 0 ? n - k : k - n));

    cout << n << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_dec_float.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
  ll n,k,x;
  cin >> n >> k;

  n = n%k;

  bool flag = true;
  while(flag){
    x = max(n,k) - min(n,k);
    x < n ? n = x : flag = false;    
  }

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

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


#define ll long long
#define ull unsigned ll
#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define vll vector <ll>
#define vull vector <ull>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF (int)1e9
#define EPS 1e-9
#define pb push_back
#define PI acos(-1.0)
#define DEBUG 0


int main ()

{
    fast;
    
    ll n, k, news = n;
    cin >> n >> k;
    
   cout << min(n%k, ((n/k)+1)*k - n << endl;
    	
    	return 0;
}


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

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

int double(int x) {
  return x * x;
}

int main() {
  int N, K, b, c;
  cin >> N >> K;
  int a = 0;
  while (true) {
    b = double (N);
    c = double (N - K);
    if (b < c) {
      cout << a << endl;
      break;
    }
    else {
      N = max(N, K) - min(N, K);
      a++;
    }
  }
}

Compiler output:
a.cc:4:12: error: expected unqualified-id before 'int'
    4 | int double(int x) {
      |            ^~~
a.cc:4:12: error: expected ')' before 'int'
    4 | int double(int x) {
      |           ~^~~
      |            )
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

void solve() {
    Bint n, k;
    cin >> n >> k;

    Bint old = n;

    do {
        old = n;
        //n = abs(n - k);
        n %= k;
    } while (old > n);

    n = min(n, abs(n - k));

    cout << n << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_dec_float.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:7: error: redeclaration of 'int N'
    6 |   int N = N % K;
      |       ^
a.cc:4:7: note: 'int N' previously declared here
    4 |   int N,K;
      |       ^
Language: C++

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: redeclaration of 'long long int N'
    6 |   long long N = N % K;
      |             ^
a.cc:4:13: note: 'long long int N' previously declared here
    4 |   long long N,K;
      |             ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    ll N K; cin >> N >> K;
    cout << GCD(N, K) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:10: error: expected initializer before 'K'
   22 |     ll N K; cin >> N >> K;
      |          ^
a.cc:22:20: error: 'N' was not declared in this scope
   22 |     ll N K; cin >> N >> K;
      |                    ^
a.cc:22:25: error: 'K' was not declared in this scope
   22 |     ll N K; cin >> N >> K;
      |                         ^
Language: C++

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: redeclaration of 'long long int N'
    6 |   long long N = N % K;
      |             ^
a.cc:4:13: note: 'long long int N' previously declared here
    4 |   long long N,K;
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int a[maxn],b[maxn];
ll sum[maxn][55];

int main()
{
    ll n, m;
    cin >> n >> m;
    if(n<m) {
        cout << min(n, m-n);
    else{
        cout << min(n-(1ll)*(n/m)*m, (1ll)*(n/m+1)*m-n);
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: expected '}' before 'else'
   15 |     else{
      |     ^~~~
a.cc:13:13: note: to match this '{'
   13 |     if(n<m) {
      |             ^
Language: Java

import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextInt(),k = sc.nextInt();
    if(n%k==0){
      pl("0");
    }else{
      if(n<k){
        int aa=n;n=k;k=aa;
      }
      pl(zz(n,k)+"");
    }
  }

  public static long zz(long a,long b){
    int c=0;
    while(a%b!=0){
      c = a%b;
      a=b;b=c;
    }
    return b;
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Compiler output:
Main.java:10: error: incompatible types: possible lossy conversion from long to int
        int aa=n;n=k;k=aa;
               ^
Main.java:19: error: incompatible types: possible lossy conversion from long to int
      c = a%b;
           ^
2 errors
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include<iostream>
#include<stack>
using namespace std;
#define ll long long
const ll maxn = 1005;
const ll mod = 1e9 + 7;
const ll inf = 1 << 30;
int main()
{
	ll n,k;
	scanf("%lld%lld",&n,&k)
	ll x=n%k;
	printf("%lld",min(x,abs(x-k)));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:32: error: expected ';' before 'long'
   21 |         scanf("%lld%lld",&n,&k)
      |                                ^
      |                                ;
a.cc:23:27: error: 'x' was not declared in this scope
   23 |         printf("%lld",min(x,abs(x-k)));
      |                           ^
Language: C++

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

int main(){
  ll N, i, K, min = 1000000000000000001;
  cin >> N >> K;
  min = N;
  while(1){
    N = longlongabs(N - K);
    if(N < min){
      min = N;
    } eles {
      break;
    }
  }

  cout << min << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'longlongabs' was not declared in this scope
   13 |     N = longlongabs(N - K);
      |         ^~~~~~~~~~~
a.cc:16:7: error: 'eles' was not declared in this scope
   16 |     } eles {
      |       ^~~~
Language: Java

import java.util*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    int K =sc.nextInt();
    int C =N%K;
    int D =K/2;
    if(C<=K/2){System.out.println(C);}
    else{System.out.println(K-C);}
  }
}

Compiler output:
Main.java:1: error: ';' expected
import java.util*;
                ^
1 error
Language: Java

import java.util.Scanner;

public class C {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		long n =scn.nextLong();
		long k=scn.nextLong();
		if(n%k==0){
			System.out.println(0);
			return ;
		}
		n = n%k;
		long res= Math.min(n, Math.abs(n-k));
		System.out.println(res);

	}

}

Compiler output:
Main.java:3: error: class C is public, should be declared in a file named C.java
public class C {
       ^
1 error
Language: C++

#include<bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
#define mod 1000000007
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
int a[maxn];
int main()
{
	ll x, k;cin >> x >> k;
	ll ans = 0;
	if (x == 1 || k == 1)x = 0;
	else {
		while (1)a {
			if (abs(x - k) < x)x = abs(x - k);
			else break;
		}
	}
	printf("%I64d\n", x);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: expected ';' before '{' token
   17 |                 while (1)a {
      |                           ^~
      |                           ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    ll n,k; cin>>n>>k;
    ll ans=n%k;
    ll ans=min(ans, ans%4);
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: redeclaration of 'll ans'
   15 |     ll ans=min(ans, ans%4);
      |        ^~~
a.cc:14:8: note: 'll ans' previously declared here
   14 |     ll ans=n%k;
      |        ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n,k;
  cin >> n >> k;
  if(n>=k){
    int64_t y=n/k;
    n-=y*k
  }
  cout << min(n,k-n) << endl;
}  


Compiler output:
a.cc: In function 'int main()':
a.cc:9:11: error: expected ';' before '}' token
    9 |     n-=y*k
      |           ^
      |           ;
   10 |   }
      |   ~
Language: C++

import sys
sys.setrecursionlimit(1000000)


if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    M = N % K
    print(min(abs(K - M), M))


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	if(n==k){
		cout<<0<<endl;
	}else if(n<k){
		cout<<min(n,k-n)<<endl;
	}else if(n%k==0){
		cout<<0<<endl;	
	}else{
		int ans=n-k;
		int hoge=n/k;
		hoge*=k;
		n-=hoge;
		ans=min(ans,k-n);
		cout<<ans<<endl;
	}
	return 0;
}

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