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

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



int main() {

	int n, k;
	cin >> n >> k;

	while(){
		if(n <= abs(n-k)){
			break;
		}
		n = abs(n-k);
	}

	cout << n << endl;
}


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

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



int main() {

	int n, k;
	cin >> n >> k;

	for(){
		if(n <= abs(n-k)){
			break;
		}
		n = abs(n-k);
	}

	cout << n << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: expected primary-expression before ')' token
   11 |         for(){
      |             ^
a.cc:19:1: error: expected primary-expression before '}' token
   19 | }
      | ^
a.cc:18:27: error: expected ')' before '}' token
   18 |         cout << n << endl;
      |                           ^
      |                           )
   19 | }
      | ~                          
a.cc:11:12: note: to match this '('
   11 |         for(){
      |            ^
a.cc:19:1: error: expected primary-expression before '}' token
   19 | }
      | ^
Language: C++

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



int main(voi) {

	int n, k;
	cin >> n >> k;

	for(){
		if(n <= abs(n-k)){
			break;
		}
		n = abs(n-k);
	}

	cout << n << endl;
}


Compiler output:
a.cc:6:5: error: cannot declare '::main' to be a global variable
    6 | int main(voi) {
      |     ^~~~
a.cc:6:10: error: 'voi' was not declared in this scope; did you mean 'void'?
    6 | int main(voi) {
      |          ^~~
      |          void
Language: C++

#include<iostream>
using namespace std;

int main()
{
    long long int n,k,m,p,x;
    cin>>n>>k;
    m=n%k;
    p=k-n%k;
    x=min(m,p)
    cout<<x;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: expected ';' before 'cout'
   10 |     x=min(m,p)
      |               ^
      |               ;
   11 |     cout<<x;
      |     ~~~~
Language: C++

int main() {
    int64_t N, K;
    cin >> N >> K;
    int64_t s = N % K;
    if (N == 0) {
        cout << 0;
    } else if (s < K - s) {
        cout << s;
    } else {
        cout << K - s;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:5: error: 'int64_t' was not declared in this scope
    2 |     int64_t N, K;
      |     ^~~~~~~
a.cc:1:1: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
  +++ |+#include <cstdint>
    1 | int main() {
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> N >> K;
      |     ^~~
a.cc:3:12: error: 'N' was not declared in this scope
    3 |     cin >> N >> K;
      |            ^
a.cc:3:17: error: 'K' was not declared in this scope
    3 |     cin >> N >> K;
      |                 ^
a.cc:4:12: error: expected ';' before 's'
    4 |     int64_t s = N % K;
      |            ^~
      |            ;
a.cc:6:9: error: 'cout' was not declared in this scope
    6 |         cout << 0;
      |         ^~~~
a.cc:7:16: error: 's' was not declared in this scope
    7 |     } else if (s < K - s) {
      |                ^
a.cc:8:9: error: 'cout' was not declared in this scope
    8 |         cout << s;
      |         ^~~~
a.cc:10:9: error: 'cout' was not declared in this scope
   10 |         cout << K - s;
      |         ^~~~
Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS
#define _CRT_INTERNAL_NONSTDC_NAMES 
int main(void) {
	long long int N, K;
	int a = 0;
	int b = 0;
	scanf("%lld%lld", &N, &K);
	a = N % K;
	b = K - a;
	printf("%d", min(a, b));
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:14:22: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
   14 |         printf("%d", min(a, b));
      |                      ^~~
      |                      main
Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

int main(void) {
	long long int N, K;
	int a = 0;
	int b = 0;
	scanf("%lld%lld", &N, &K);
	a = N % K;
	b = K - a;
	printf("%d", min(a, b));
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:14:22: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
   14 |         printf("%d", min(a, b));
      |                      ^~~
      |                      main
Language: C

#include <cstdio>
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
	ll i,n, k;
	scanf("%lld", &n);
	scanf("%lld", &k);

	ll p = n % k;
	ll pp = -1 * (p - k);
	if(p > pp)
		printf("%lld", pp);
	else 
		printf("%lld", p);
	return 0;
}


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

#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	long long n,k,i,t,tt,x;
	scanf("%lld %lld",&n,&k);
	for(;;)
	{
		t=abs(n-k);
		tt=abs(t-k);
		if(t+tt==k)
		{
			if(t>=tt) x=tt;
			else x=t;
			printf("%lld",x);
			break;
		}
		else n=t;
	}
	return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,k,i,t,tt,x;
	scanf("%lld %lld",&n,&k);
	for(;;)
	{
		t=abs(n-k);
		tt=abs(t-k);
		if(t+tt==k)
		{
			if(t>=tt) x=tt;
			else x=t;
			printf("%lld",x);
			break;
		}
		else n=t;
	}
	return 0;
}

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

#include<cstdio>

int main(){
    int N, K;
    scanf("%d %d", &N, &K);
    int ans = min(N%K, K-N%K);
    printf("%d", ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:15: error: 'min' was not declared in this scope; did you mean 'main'?
    6 |     int ans = min(N%K, K-N%K);
      |               ^~~
      |               main
Language: C++

import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long N = nextLong();
        long K = nextLong();

        println((long)Math.abs(N - K*Math.ceil((long)(N/(double)K)*10.0)/10.0));
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import javax.print.DocFlavor;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.awt.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.io.PrintWriter;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.lang.reflect.Array;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.math.BigInteger;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import java.util.*;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import java.util.List;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: expected unqualified-id before 'public'
    9 | public class Main {
      | ^~~~~~
Language: C++

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

int main(){
  long int N;
  long int K;
  cin >> N >> K;
  int J = N % K;
  cout << min(J,K-J) << endl;
}

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:6:11: error: 'k' was not declared in this scope
    6 |   cin>>n>>k;
      |           ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:5:11: error: 'k' was not declared in this scope
    5 |   cin>>n>>k;
      |           ^
Language: Java

mport java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		System.out.println(Math.min(n%k, gcd(n, k)));
	}
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.Scanner;
^
1 error
Language: C++

if __name__ == "__main__":
    n, k = map(int, input().split())
    tmp = n // k
    print(min(n - tmp*k, abs(n-(tmp+1)*k)))

Compiler output:
a.cc:1:1: error: expected unqualified-id before 'if'
    1 | if __name__ == "__main__":
      | ^~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cour' was not declared in this scope
    7 |   cour<<min(t,k-t)<<endl;
      |   ^~~~
Language: C

#include <stdio.h>

int main(void) {
	long long int n, k;
	long long int num, pre_num, a, b;

	scanf_s("%lld%lld", &n, &k);

	num = n % k;

	a = k - num;
	b = num - k;

	pre_num = (a > b)? b : a;

	if (pre_num < num)
		num = pre_num;

	printf("%lld", num);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    7 |         scanf_s("%lld%lld", &n, &k);
      |         ^~~~~~~
      |         scanf
Language: C

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

int main(void) {
	long long int n, k;
	long long int num, pre_num;

	scanf_s("%lld%lld", &n, &k);

	num = n;

	while (1) {
		pre_num = abs(num - k);

		if (pre_num < num)
			num = pre_num;
		else
			break;
	}

	printf("%lld", num);

	return 0;
}



Compiler output:
main.c: In function 'main':
main.c:8:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    8 |         scanf_s("%lld%lld", &n, &k);
      |         ^~~~~~~
      |         scanf
main.c:13:27: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   13 |                 pre_num = abs(num - k);
      |                           ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:13:35: warning: 'abs' argument 1 type is 'long long int' where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
   13 |                 pre_num = abs(num - k);
      |                               ~~~~^~~
<built-in>: note: built-in 'abs' declared here
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  LL n, k;
  cin >> n >> k;

  if (n - k == 0) {
    cout << n << endl;
    return 0;
  }

  LL d = abs(n - k);
  LL x = n / d;
  LL ans = min(n - x * d, abs(n - (x + 1) * d);

  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:47: error: expected ')' before ';' token
   18 |   LL ans = min(n - x * d, abs(n - (x + 1) * d);
      |               ~                               ^
      |                                               )
Language: C++

#include <iostream>
#include <stdlib.h>
using namespace std;

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

    int t = N % K;

    std::cout << min(t,abs(K-t)) << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:21: error: no matching function for call to 'min(int&, long long int)'
   11 |     std::cout << min(t,abs(K-t)) << endl;
      |                  ~~~^~~~~~~~~~~~
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:11:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   11 |     std::cout << min(t,abs(K-t)) << endl;
      |                  ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <iostream>
#include <stdlib.h>
using namespace std;

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

    int t = N % K;

    std::cout << min(t, abs(k-t)) << endl;


/*愚策ってかタイムアウト
    while(llabs(N-K) <= N){
        N = llabs(N-K);
    }
    std::cout << N <<endl;
*/

}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:29: error: 'k' was not declared in this scope
   11 |     std::cout << min(t, abs(k-t)) << endl;
      |                             ^
Language: C

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

int main()
{
int x,k,n,tmp;

scanf("%d%d",&n,&k);
tmp=n%k;
if(abs(tmp-k)<tmp){tmp=abs(tmp-k);} 
prrintf("%d\n",tmp);
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:11:1: error: implicit declaration of function 'prrintf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   11 | prrintf("%d\n",tmp);
      | ^~~~~~~
      | printf
Language: C++

#include <bits/stdc++.h>
using namespace std;
int zet(int i, int k) {
  int answer = i - k;
  if (answer < 0) {
    answer = answer * (-1);
  }
  return answer;
}
int main() {
  int N, K, t;
  cin >> N >> K;
  N / K = t;
  cout << min(zet(t, K), t) << endl;
}
  
    
  


   
  

      
    
  


Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: lvalue required as left operand of assignment
   13 |   N / K = t;
      |   ~~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int zet(i, k) {
  int answer = i - k;
  if (answer < 0) {
    answer = answer * (-1);
  }
  return answer;
}
int main() {
  int N, K, t;
  cin >> N >> K;
  N / K = t;
  cout << min(zet(t, K), t) << endl;
}
  
    
  


   
  

      
    
  


Compiler output:
a.cc:3:9: error: 'i' was not declared in this scope
    3 | int zet(i, k) {
      |         ^
a.cc:3:12: error: 'k' was not declared in this scope
    3 | int zet(i, k) {
      |            ^
a.cc:3:13: error: expression list treated as compound expression in initializer [-fpermissive]
    3 | int zet(i, k) {
      |             ^
a.cc: In function 'int main()':
a.cc:13:5: error: lvalue required as left operand of assignment
   13 |   N / K = t;
      |   ~~^~~
a.cc:14:18: error: 'zet' cannot be used as a function
   14 |   cout << min(zet(t, K), t) << endl;
      |               ~~~^~~~~~
Language: C++

#include <bits/std.h++>
using namespace std;
int zet(i,K) {
  int k = i - K;
  if (k < 0) {
    k = k * (-1);
  }
  return k;
}
int zet2(i,K) {
  int minimum = K;
  if (i == N) {
    return zet(N,K);
  }
   = min(minimum, zet2(z,k));
  return minium;
}
   
  
int main()　{
  int N,K;
  int minimum = 0;
  cin >> N >> K;
  for (j = 0; j < N; j++) {    
    minimum = min(minimum, zet(

      
    
  


Compiler output:
a.cc:1:10: fatal error: bits/std.h++: No such file or directory
    1 | #include <bits/std.h++>
      |          ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/std.h++>
using namespace std;
int zet(i,j) {
  int k = i - j;
  if (k < 0) {
    k = k * (-1);
  }
  return k;
}

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

Compiler output:
a.cc:1:10: fatal error: bits/std.h++: No such file or directory
    1 | #include <bits/std.h++>
      |          ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

 #include<stdio.h>
 int main(void)
 {
     int N,K,s,t;
     scanf("%d%d",&N,&K);
     if(N%K==0) printf("0\n");

      while(N>K)
       N+=-K;

     if(N<K) s=K-N;

     if(N<s) printf("%d\n",N);
     else    printf("%d\n",t);
     }
     return 0;
 }


Compiler output:
a.cc:16:6: error: expected unqualified-id before 'return'
   16 |      return 0;
      |      ^~~~~~
a.cc:17:2: error: expected declaration before '}' token
   17 |  }
      |  ^
Language: C++


#include<iostream>
using namespace std;
//流れ
//2つ数字入力・引き算の絶対値とそれをNに入れる繰り返す
//前のNより大きくなったらループ終わり・答え出力


int main() {
	long long n,N, K;//nは前の入れる
	scanf_s("%d", &N);
	scanf_s("%d", &K);
	n = N;
	while(N < n) {
		n = N;
		N = abs(N - K);
		
	}

	cout << n;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   11 |         scanf_s("%d", &N);
      |         ^~~~~~~
      |         scanf
Language: C++

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

int main() {
  long int  n,k;
  cin >> n>>k;
 
  long int a=n%k;
  long int b=labs(a-k);
  
  if(a<b) cout << a << endl;
  else cout << b<< endl;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inlcude; did you mean #include?
    1 | #inlcude <bits/stdc++.h>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> n>>k;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inlcude <bits/stdc++.h>
a.cc:9:14: error: 'labs' was not declared in this scope
    9 |   long int b=labs(a-k);
      |              ^~~~
a.cc:11:11: error: 'cout' was not declared in this scope
   11 |   if(a<b) cout << a << endl;
      |           ^~~~
a.cc:11:11: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:11:24: error: 'endl' was not declared in this scope
   11 |   if(a<b) cout << a << endl;
      |                        ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #inlcude <bits/stdc++.h>
a.cc:12:8: error: 'cout' was not declared in this scope
   12 |   else cout << b<< endl;
      |        ^~~~
a.cc:12:8: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:12:20: error: 'endl' was not declared in this scope
   12 |   else cout << b<< endl;
      |                    ^~~~
a.cc:12:20: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

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

int main(){
	long long n, k;
	cin >> n >> k;
	
	if (n % k > k - n % k) {
		cout <<  k - n % k << endl;
	} else {
		clut << n % k << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'clut' was not declared in this scope
   11 |                 clut << n % k << endl;
      |                 ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  ll n,k,t,ans;
  scanf("%d",&n);
  scanf("%d",&k);
  
  t = n % k;
  if(t > k-t){
  	ans = k-t;
  }
  else{
  	ans = t;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'll' was not declared in this scope
    4 |   ll n,k,t,ans;
      |   ^~
a.cc:5:15: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 |   scanf("%d",&n);
      |               ^
      |               yn
a.cc:6:15: error: 'k' was not declared in this scope
    6 |   scanf("%d",&k);
      |               ^
a.cc:8:3: error: 't' was not declared in this scope; did you mean 'tm'?
    8 |   t = n % k;
      |   ^
      |   tm
a.cc:10:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 |         ans = k-t;
      |         ^~~
      |         abs
a.cc:13:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |         ans = t;
      |         ^~~
      |         abs
a.cc:15:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

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

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


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

#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,i,d,temp;
cin>>a>>b;
d=a;

 if(b==1){ d=0;}

else {
    while(1){

        temp=abs(d-b);
    if(temp>d) break;
       else if(temp<d) d=temp;

    }
}
cout<<d;
return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:20:10: error: expected '}' at end of input
   20 | return 0;
      |          ^
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;
  int rem = n % k;
  int ans = min (rem, k - rem);
  cout << ans << endl;
}

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

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

int main() {
  
    long long N, K;

	cin >> N >> K;

    int a = N%K;
	cout << min(a, K-a) << endl;

    return 0;
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: expected '}' before 'else'
   10 |   else if(n>k/2){
      |   ^~~~
a.cc:8:13: note: to match this '{'
    8 |   if(n==k/2){
      |             ^
Language: C++

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;

    long long min = LLONG_MAX;

    if (n >= k)
    {
        n %= k;
        long long diff = abs(n % k - k);
        if (diff >= n)
            min = n;
        else
            min = diff;
    }
    else
        min = n;

    cout << min << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:21: error: 'LLONG_MAX' was not declared in this scope
   11 |     long long min = LLONG_MAX;
      |                     ^~~~~~~~~
a.cc:3:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <cmath>
  +++ |+#include <climits>
    3 |
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int N,K;
    int ans,t=1;
    while(t -->0)
    {
        cin>>N>>K;
         ans=N%K;
         cout<<min(ans,abs(ans-K));
    }
    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:19: error: no matching function for call to 'min(int&, long long int)'
   12 |          cout<<min(ans,abs(ans-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:12:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   12 |          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,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:12:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |          cout<<min(ans,abs(ans-K));
      |                ~~~^~~~~~~~~~~~~~~~
Language: Java

import java.util.*;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      for (int i=0; i<1000000000000000000; i++){
      	N = Math.abs(N-K);
      }
      System.out.println(N);
    }
}

Compiler output:
Main.java:8: error: integer number too large
      for (int i=0; i<1000000000000000000; i++){
                      ^
1 error
Language: C++

package main

import "fmt"

func abs(a int) int {
  if a < 0 {
    return -a
  }
  return a
}

func main() {
  var N, K, count int
  fmt.Scan(&N, &K)
  Nmin := N
  N = N%K
  
  for {
    N = abs(N-K)
    if N < Nmin {
      Nmin = N
      count = 0
    }
    if Nmin == N{
      count++
      if count >1 {
        break
      }
    }
  }
  fmt.Println(Nmin) 
}

Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package main
      | ^~~~~~~
a.cc:12:1: error: 'func' does not name a type
   12 | func main() {
      | ^~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    ans = min(N%K, abs(N%K - K));
    cout << ans << endl;
    return 0;
       
}


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

#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main(){
    lli N,K;
    cin>>N>>K;
        if(abs(N-K)<N){
            N>K?cout<<N%(abs(N-K)):cout<<K%(abs(N-K));
        }
    }
    return 0;
}

Compiler output:
a.cc:12:5: error: expected unqualified-id before 'return'
   12 |     return 0;
      |     ^~~~~~
a.cc:13:1: error: expected declaration before '}' token
   13 | }
      | ^
Language: C++

#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main(){
    lli N,K;
    cin>>N>>K;
    while(true){
        N = abs(N-K)<N?abs(N-K):break;
    }
    cout<<N;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:33: error: expected primary-expression before 'break'
    9 |         N = abs(N-K)<N?abs(N-K):break;
      |                                 ^~~~~
Language: C++

#include <iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;

int main()
{

long long int i,n,m,min1=0,min2;


cin>>n;
cin>>m;
min2=n;
if(n<m&&!(m-n<n))
    {

        cout<<n;

    }
else if (n%m==0)
   {

     cout<<0;

   }
else if (n>m)
    min2=n%m;
    
else 
    {
  while(1){
    min1=abs(m-n);
    n=min1;

    if(min1>=min2)
        break;
    min2=min1;



}





cout<<min2;

}




}
#include <iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;

int main()
{

long long int i,n,m,min1=0,min2;


cin>>n;
cin>>m;
min2=n;
if(n<m&&!(m-n<n))
    {

        cout<<n;

    }
else if (n%m==0)
   {

     cout<<0;

   }
else if (n>m)
    min2=n%m;
    
else 
    {
  while(1){
    min1=abs(m-n);
    n=min1;

    if(min1>=min2)
        break;
    min2=min1;



}





cout<<min2;

}




}


Compiler output:
a.cc:61:5: error: redefinition of 'int main()'
   61 | int main()
      |     ^~~~
a.cc:6:5: note: 'int main()' previously defined here
    6 | int main()
      |     ^~~~
Language: C++

#include <stdio.h>

int main(){

  	long n, k;
    long x = 0;
    long t;
  
    scanf("%ld %ld", &n, &k);
    
    t = n % k;
  
    if(t < abs(t-k)){
    	printf("%ld", t);
    }else{
        printf("%ld", abs(t-k));
    }
  
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: 'abs' was not declared in this scope
   13 |     if(t < abs(t-k)){
      |            ^~~
Language: Java

import java.util.*;
public class Main {//ここが Main になっている
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Long N = Long.parseLong(sc.next());
        Long K = Long.parseLong(sc.next());
        Long next_n;
        t = N % K;
        k_t = k - t;
        if (t<k_t){
            System.out.println(t);
        }
        if (t>=k_t){
            System.out.println(k_t);
        }
    }
}


Compiler output:
Main.java:8: error: cannot find symbol
        t = N % K;
        ^
  symbol:   variable t
  location: class Main
Main.java:9: error: cannot find symbol
        k_t = k - t;
        ^
  symbol:   variable k_t
  location: class Main
Main.java:9: error: cannot find symbol
        k_t = k - t;
              ^
  symbol:   variable k
  location: class Main
Main.java:9: error: cannot find symbol
        k_t = k - t;
                  ^
  symbol:   variable t
  location: class Main
Main.java:10: error: cannot find symbol
        if (t<k_t){
            ^
  symbol:   variable t
  location: class Main
Main.java:10: error: cannot find symbol
        if (t<k_t){
              ^
  symbol:   variable k_t
  location: class Main
Main.java:11: error: cannot find symbol
            System.out.println(t);
                               ^
  symbol:   variable t
  location: class Main
Main.java:13: error: cannot find symbol
        if (t>=k_t){
            ^
  symbol:   variable t
  location: class Main
Main.java:13: error: cannot find symbol
        if (t>=k_t){
               ^
  symbol:   variable k_t
  location: class Main
Main.java:14: error: cannot find symbol
            System.out.println(k_t);
                               ^
  symbol:   variable k_t
  location: class Main
10 errors
Language: C++

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ips = br.readLine().split(" ");
        long n = Long.parseLong(ips[0]);
        long k = Long.parseLong(ips[1]);
        if(n >= k)
            n %= k;
        long res = Math.min(n, k-n);
        System.out.println(res);
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main {
      | ^~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define X first
#define Y second
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
const int maxn=1e4+10;
int a[maxn];

ll ABS(ll a,ll b){
	if(a>b){
		return a-b;
	}else return b-a;
}

int main(){
	ll n,k;
	cin>>n>>k;
	if(n<k/2){
		cout<<n<<endl;
		return 0;
	}
	if(n%k==0){
		cout<<0<<endl;
		return 0;
	}
	cout<<min(n%k,ABS(n%k-k))<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:26: error: too few arguments to function 'll ABS(ll, ll)'
   39 |         cout<<min(n%k,ABS(n%k-k))<<endl;
      |                       ~~~^~~~~~~
a.cc:22:4: note: declared here
   22 | ll ABS(ll a,ll b){
      |    ^~~
Language: C++

import numpy as np
n,k = map(int,input().split())
n %= k
print(min(n,np.abs(n-k)))

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

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

int main(void){
    double n,k,r;
    int a;
    scanf("%lf %lf",&n,&k);
    r=n-k*floor(n/k);
    if(r<fbs(k-r)){
        a=r;
    }else{
        a=fbs(k-r);
    }
    printf("%d",a);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:10: error: implicit declaration of function 'fbs'; did you mean 'fabs'? [-Wimplicit-function-declaration]
    9 |     if(r<fbs(k-r)){
      |          ^~~
      |          fabs
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:6:24: error: 'K' was not declared in this scope
    6 |   long long ans, n = N%K;
      |                        ^
Language: C++

/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >>n >>k;
	n %= k;
	cout <<min(n, m - n);
	return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:35:23: error: 'm' was not declared in this scope
   35 |         cout <<min(n, m - n);
      |                       ^
Language: Java

import java.util.Scanner;
import java.lang.Math;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        sc.close();

        while(n>=k){
            n = n-k;
        }
        // System.out.println(n);
        System.out.println(Math.min(n,abs(k-n)));
        // n=Math.min(n,k-n);
        // System.out.println(n);
    }
        
    public static int[] sort(int[] a){
        int x;
        for(int i=0;i<a.length;i++){
            x = a[i];
            for(int j=0;j<a.length;j++){
                if(x == Math.max(x,a[j])){
                    a[i]=a[j];
                    a[j]=x;
                    x=a[i];
                }
            }
        }
        return a;
    }
}

Compiler output:
Main.java:14: error: cannot find symbol
        System.out.println(Math.min(n,abs(k-n)));
                                      ^
  symbol:   method abs(long)
  location: class Main
1 error
Language: C++

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: expected ';' before 'cout'
    9 |     n = n%k
      |            ^
      |            ;
   10 |     cout << abs(n-k) <<endl;
      |     ~~~~
Language: C++

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

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

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


 return 0;
}

Compiler output:
a.cc:12:2: error: expected unqualified-id before 'return'
   12 |  return 0;
      |  ^~~~~~
a.cc:13:1: error: expected declaration before '}' token
   13 | }
      | ^
Language: Java

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long N = stdIn.nextLong();
		long K = stdIn.nextLong();
		long sub;
		
		while(true) {
			sub = Math.abs(N - K);
			if(N < sub) {
				break;
			}else {
				N = sub;
			}
		}
	}
  System.out.println(N);
}

Compiler output:
Main.java:19: error: <identifier> expected
  System.out.println(N);
                    ^
Main.java:19: error: <identifier> expected
  System.out.println(N);
                      ^
2 errors
Language: C++

#include<bits/stdc++.h>
#define ll long long
const int N =1e3 + 5 ;
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
 if(n<k){
  	cout<<n<<endl;
  break;
}
  else{
  while(n>0) {
  	n=n-k;
  }
cout<<abs(n)<<endl;
}
return 0;
}



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

#include <iostream >
using namespace std;



int lunlun(long long num){
	for(int i = 0; num >= pow10(i) ; i++){ //position i has digit 
      if(!lunlunAdjacent(num,i)) return 0;
    }
  return 1;
}

int lunlunAdjacent(long long num,int i){
	//has upper digit (no need to judge)
 // if(num >=  pow10(i+1)){
  //    if(!lunlunDigit(getDigit(num,i+1),getDigit(num,i)))
   //     return 0;
  //  }
  //has lower digit
  if(i-1 >=0){
    if(!lunlunDigit(getDigit(num,i-1),getDigit(num,i)))
      return 0;
  }
  return 1;
}

int getDigit(long long num,int i){//start from 0
	num = (num % pow10(i+1)) /pow10(i);
  return (int)num;
}

long long pow10(int n){ //10^n
	if(n == 0) return 1;
  return pow10(n-1)*10;
}

int lunlunDigit(int dg1,int dg2){
 int diff = dg1-dg2;
  if(diff<=1&&diff>=-1} return 1;
     else return 0;
}

int main(){
 int k;
  cin>>k;
  long long num = 1;
  for(int i= 0; i < k ;num++){
   if(lunlun(num))i++; 
  }
  cout<<num;
  return 0;
}

Compiler output:
a.cc:1:10: fatal error: iostream : No such file or directory
    1 | #include <iostream >
      |          ^~~~~~~~~~~
compilation terminated.