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

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

#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)>(b))?(b):(a)

typedef long long ll;
typedef unsigned long long ull;

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

    ll res = n % k;
    if (res <= k - res)
    {
        printf("%lld", res);
    }
    else
    {
        printf("%lld", k - res);
    }


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

#include <iostream>


uint64_t myabs(uint64_t a, uint64_t b) {
	if(a < b) {
    	auto t = a; a = b; b = a;
    }
	return a - b;
}


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

	uint64_t x = N;
	while(1) {
		uint64_t diff = myabs(K-x);
		if(x <= diff)
        	break;
		x = diff;
    }

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


Compiler output:
a.cc:4:1: error: 'uint64_t' does not name a type
    4 | uint64_t myabs(uint64_t a, uint64_t b) {
      | ^~~~~~~~
a.cc:2:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    1 | #include <iostream>
  +++ |+#include <cstdint>
    2 | 
a.cc: In function 'int main()':
a.cc:13:9: error: 'uint64_t' was not declared in this scope
   13 |         uint64_t N, K;
      |         ^~~~~~~~
a.cc:13:9: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:14:21: error: 'N' was not declared in this scope
   14 |         std::cin >> N >> K;
      |                     ^
a.cc:14:26: error: 'K' was not declared in this scope
   14 |         std::cin >> N >> K;
      |                          ^
a.cc:16:17: error: expected ';' before 'x'
   16 |         uint64_t x = N;
      |                 ^~
      |                 ;
a.cc:18:25: error: expected ';' before 'diff'
   18 |                 uint64_t diff = myabs(K-x);
      |                         ^~~~~
      |                         ;
a.cc:19:20: error: 'x' was not declared in this scope
   19 |                 if(x <= diff)
      |                    ^
a.cc:19:25: error: 'diff' was not declared in this scope
   19 |                 if(x <= diff)
      |                         ^~~~
a.cc:21:17: error: 'x' was not declared in this scope
   21 |                 x = diff;
      |                 ^
a.cc:21:21: error: 'diff' was not declared in this scope
   21 |                 x = diff;
      |                     ^~~~
a.cc:24:22: error: 'x' was not declared in this scope
   24 |         std::cout << x << std::endl;
      |                      ^
Language: C

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

int main(void)
{ long long int n,k,mod;
  mod=n%k
   if (mod<k-mod)
    printf("%lld", mod);
   else
    printf("%lld", k-mod); 

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:10: error: expected ';' before 'if'
    6 |   mod=n%k
      |          ^
      |          ;
    7 |    if (mod<k-mod)
      |    ~~     
main.c:9:4: error: 'else' without a previous 'if'
    9 |    else
      |    ^~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: 'm' was not declared in this scope
   10 |     n = n%m;
      |           ^
Language: C++

#include <iostream>
#include <math.h>
using namespace std;
void a(int n, int k);
int main(){
    int n, k;
    cin>>n>>k;
    a(n, k);
    return o;
}
void a(int n, int k){
    int x;
    while(1){
        x = n;
        n = abs(n-k);
        if(n > x) cout<<x;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: 'o' was not declared in this scope
    9 |     return o;
      |            ^
Language: C++

#include <iostream>
#include <math.h>
void a(int n, int k);
int main(){
    int n, k;
    cin>>n>>k;
    a(n, k);
    return o;
}
void a(int n, int k){
    int x;
    while(1){
        x = n;
        n = abs(n-k);
        if(n > x) cout<<x;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |     cin>>n>>k;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:12: error: 'o' was not declared in this scope
    8 |     return o;
      |            ^
a.cc: In function 'void a(int, int)':
a.cc:15:19: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   15 |         if(n > x) cout<<x;
      |                   ^~~~
      |                   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <iostream.h>
#include <math.h>
void a(int n, int k);
int main(){
    int n, k;
    cin>>n>>k;
    a(n, k);
    return o;
}
void a(int n, int k){
    int x;
    while(1){
        x = n;
        n = abs(n-k);
        if(n > x) cout<<x;
    }
}

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

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

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

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

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

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

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

Compiler output:
a.cc:5:5: error: cannot declare '::main' to be a global variable
    5 | int main{
      |     ^~~~
a.cc:6:3: error: expected primary-expression before 'long'
    6 |   long long N,K;
      |   ^~~~
a.cc:6:3: error: expected '}' before 'long'
a.cc:5:9: note: to match this '{'
    5 | int main{
      |         ^
a.cc:7:3: error: 'cin' does not name a type
    7 |   cin >> N >> K;
      |   ^~~
a.cc:8:17: error: 'N' was not declared in this scope
    8 |   long long a = N % K;
      |                 ^
a.cc:8:21: error: 'K' was not declared in this scope
    8 |   long long a = N % K;
      |                     ^
a.cc:9:3: error: 'cout' does not name a type
    9 |   cout << min(a,k-a) << endl;
      |   ^~~~
a.cc:10:1: error: expected declaration before '}' token
   10 | }
      | ^
Language: C++

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


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


Compiler output:
a.cc:5:5: error: cannot declare '::main' to be a global variable
    5 | int main{
      |     ^~~~
a.cc:6:10: error: 'N' was not declared in this scope
    6 |   cin >> N >> K;
      |          ^
a.cc:6:15: error: 'K' was not declared in this scope
    6 |   cin >> N >> K;
      |               ^
a.cc:6:16: error: expected '}' before ';' token
    6 |   cin >> N >> K;
      |                ^
a.cc:5:9: note: to match this '{'
    5 | int main{
      |         ^
a.cc:7:11: error: 'N' was not declared in this scope
    7 |   int a = N / K;
      |           ^
a.cc:7:15: error: 'K' was not declared in this scope
    7 |   int a = N / K;
      |               ^
a.cc:8:11: error: 'N' was not declared in this scope
    8 |   int A = N - K * a;
      |           ^
a.cc:8:15: error: 'K' was not declared in this scope
    8 |   int A = N - K * a;
      |               ^
a.cc:9:3: error: expected unqualified-id before 'if'
    9 |   if(A > N / 2){
      |   ^~
a.cc:11:4: error: expected unqualified-id before 'else'
   11 |   }else{
      |    ^~~~
a.cc:14:1: error: expected declaration before '}' token
   14 | }
      | ^
Language: C++

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

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

Compiler output:
a.cc:6:9: error: ISO C++ forbids declaration of 'diff' with no type [-fpermissive]
    6 |         diff()
      |         ^~~~
a.cc: In function 'int diff()':
a.cc:17:5: warning: no return statement in function returning non-void [-Wreturn-type]
   17 |     }
      |     ^
Language: Java


public class Main {

    static double N, K;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextDouble();
        K = sc.nextDouble();
        if(N / K >= 100){
            N -= K * ((int)(N / K) - 100);
        }
        double newN = N;
        while(K / 2 <= newN){
            newN = (newN - K > 0)?(newN - K):(K - newN);
        };
        System.out.println((int)newN);
    }
}

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

#include<iostream>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  for(int i=0;;i++){
    if(0<=N<=K/2){
      cout <<  N << endl;
      break;
    }
    else if(K <= 2*N <= 2*K){
      cout << K-N << endl;
      break;
    }
    else if(2*K<=2*N<=3*K){
      cout << N-K << endl;
      break;
    }
    else if{
        N=N-K;
      }
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:12: error: expected '(' before '{' token
   20 |     else if{
      |            ^
      |            (
a.cc: At global scope:
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^
Language: C++

#include <iostream>
#include <utility>
#include <algorithm>

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |     cin >> N >> K;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    8 |     cout << min(N%K, abs(K-N%K));
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:8:13: error: 'min' was not declared in this scope; did you mean 'std::min'?
    8 |     cout << min(N%K, abs(K-N%K));
      |             ^~~
      |             std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> N >> K;
      |     ^~~
a.cc:4:5: error: 'cout' was not declared in this scope
    4 |     cout << min(N%K, abs(K-N%K));
      |     ^~~~
a.cc:4:22: error: 'abs' was not declared in this scope
    4 |     cout << min(N%K, abs(K-N%K));
      |                      ^~~
a.cc:4:13: error: 'min' was not declared in this scope; did you mean 'main'?
    4 |     cout << min(N%K, abs(K-N%K));
      |             ^~~
      |             main
Language: C++

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

int main()
{
 int N,K;
  cin>>N>>K;
  int new;
 new = abs(N-K) ;
while(new<N){
    N = new ;
    new = abs(new-K);}
  
cout << N;
  
  
  
  
  
  
  
  
  
  
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: expected unqualified-id before 'new'
    8 |   int new;
      |       ^~~
a.cc:9:6: error: expected type-specifier before '=' token
    9 |  new = abs(N-K) ;
      |      ^
a.cc:10:10: error: expected type-specifier before '<' token
   10 | while(new<N){
      |          ^
a.cc:11:13: error: expected type-specifier before ';' token
   11 |     N = new ;
      |             ^
a.cc:12:9: error: expected type-specifier before '=' token
   12 |     new = abs(new-K);}
      |         ^
a.cc:12:18: error: expected type-specifier before '-' token
   12 |     new = abs(new-K);}
      |                  ^
Language: C++

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

int main()
{
 int N,K;
  cin>>N>>K;
  int new;
 new = abs(N-K) ;
while(new<N){
    N = new ;
    new = abs(new-K);}
  
cout << N;
  
  
  
  
  
  
  
  
  
  
  
}

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

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

ll n,k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    if (n>=k){
        if (n%k==0)
            cout<<0;
        else{
            n=n%k;
            cout<<abs(n-k);
        }
    }
    else{
        if (n==0) cout<<0
        else cout<<n%k;
    }
    
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:26: error: expected ';' before 'else'
   19 |         if (n==0) cout<<0
      |                          ^
      |                          ;
   20 |         else cout<<n%k;
      |         ~~~~
Language: C++

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

    int main() {
            int N, K;
int a; 

        while(true){
                if(abs(N-K) < 0){
cout << a;
                }
a =abs(N-K);
                
    } 
}
~                     

Compiler output:
a.cc:16:2: error: expected class-name at end of input
   16 | ~
      |  ^
Language: Java

import java.util.*;
import java.io.*;
public class Solution
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        long n=Long.parseLong(str[0]);
        long k=Long.parseLong(str[1]);
        if(n%k==0)
        pw.println(0);
        else
        {
            n=n%k;
            pw.println(Math.min((long)Math.abs(n-k),(long)Math.abs(n)));
        }
        pw.flush();
        pw.close();
    }
}

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

#include<stdio.h>
int main()
{
unsigned long long int a,b,c,d;
  scanf("%lld %lld",&a,&b);
c=a%b;
d=max(c,b-c);
printf("%lld",d);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'max' was not declared in this scope
    7 | d=max(c,b-c);
      |   ^~~
Language: C++

#include<stdio.h>
int main()
{
long long int a,b,c,;
  scanf("%lld %lld",&a,&b);
c=a%b;
if(b%2==1 && c>(b-1)/2) c=b-c;
else if(c>=b) c=b-c;
  
printf("%lld",c);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:21: error: expected unqualified-id before ';' token
    4 | long long int a,b,c,;
      |                     ^
Language: C++

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

int main(){
  long long n, k;
  cin >> n >> k;
  long long tmp;
  do {
    tmp = n;
  	n = abs(n, k);
  } while(n < tmp || n == tmp);
  cout << n << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: no matching function for call to 'abs(long long int&, long long int&)'
   11 |         n = abs(n, k);
      |             ~~~^~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:980:12: note:   candidate expects 1 argument, 2 provided
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:137:3: note:   candidate expects 1 argument, 2 provided
/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:85:3: note:   candidate expects 1 argument, 2 provided
/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:79:3: note:   candidate expects 1 argument, 2 provided
/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:75:3: note:   candidate expects 1 argument, 2 provided
/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:71:3: note:   candidate expects 1 argument, 2 provided
/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:61:3: note:   candidate expects 1 argument, 2 provided
/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); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note:   candidate expects 1 argument, 2 provided
Language: C++

#include <iostream>
using namespace std;

int main(){
  long long n, k;
  cin >> n >> k;
  long long tmp;
  do {
    tmp = n;
  	n = abs(n, k);
  } while(n < tmp || n == tmp);
  cout << n << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: no matching function for call to 'abs(long long int&, long long int&)'
   10 |         n = abs(n, k);
      |             ~~~^~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:980:12: note:   candidate expects 1 argument, 2 provided
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:137:3: note:   candidate expects 1 argument, 2 provided
/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:85:3: note:   candidate expects 1 argument, 2 provided
/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:79:3: note:   candidate expects 1 argument, 2 provided
/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:75:3: note:   candidate expects 1 argument, 2 provided
/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:71:3: note:   candidate expects 1 argument, 2 provided
/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:61:3: note:   candidate expects 1 argument, 2 provided
/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); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note:   candidate expects 1 argument, 2 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    ll n,k;
    cin>>n>>k;
    cout<<n%k
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: expected ';' before '}' token
    9 |     cout<<n%k
      |              ^
      |              ;
   10 | }
      | ~
Language: C++

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

    }
return 0;
}


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

#include<vector>
using namespace std;

int main(){
        int N, M;
        cin >> N >> M;
        int i;
        int count = 0;
        std::vector<int> numbers;
        int total = 0;
        while(cin>>i){
                numbers.push_back(i);
                total += i;
        }
        for(int number : numbers){
                if(number > total/(4*M)){
                        count++;
                }
        }

        if(count < M){
                cout << "No";
        }else{
                cout << "Yes";
        }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'cin' was not declared in this scope
    6 |         cin >> N >> M;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<vector>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:22:17: error: 'cout' was not declared in this scope
   22 |                 cout << "No";
      |                 ^~~~
a.cc:22:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:24:17: error: 'cout' was not declared in this scope
   24 |                 cout << "Yes";
      |                 ^~~~
a.cc:24:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: 'cin' was not declared in this scope
    3 |         cin >> N >> K;
      |         ^~~
a.cc:6:20: error: 'abs' was not declared in this scope
    6 |                 if(abs(N-K) >= N){
      |                    ^~~
a.cc:9:21: error: 'abs' was not declared in this scope
    9 |                 N = abs(N-K);
      |                     ^~~
a.cc:11:9: error: 'cout' was not declared in this scope
   11 |         cout << N;
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    ll x,y;
    cin >> x >> y
        ll rem = x%y;
        if(rem==0){
            cout << 0 << endl;
            return 0;
        }

        ll rem1 = abs(rem-y);

        cout << min(rem1,rem) << endl;

    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:18: error: expected ';' before 'll'
   30 |     cin >> x >> y
      |                  ^
      |                  ;
   31 |         ll rem = x%y;
      |         ~~        
a.cc:32:12: error: 'rem' was not declared in this scope; did you mean 'drem'?
   32 |         if(rem==0){
      |            ^~~
      |            drem
a.cc:37:23: error: 'rem' was not declared in this scope; did you mean 'rem1'?
   37 |         ll rem1 = abs(rem-y);
      |                       ^~~
      |                       rem1
Language: C++

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

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin >> n >> k;
      |     ^~~
a.cc:8:5: error: 'cout' was not declared in this scope
    8 |     cout << min(n%k, k-n%k) << endl;
      |     ^~~~
a.cc:8:13: error: 'min' was not declared in this scope; did you mean 'main'?
    8 |     cout << min(n%k, k-n%k) << endl;
      |             ^~~
      |             main
a.cc:8:32: error: 'endl' was not declared in this scope
    8 |     cout << min(n%k, k-n%k) << endl;
      |                                ^~~~
Language: C

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double d;

int main()
{
	ll n,k;
	cin>>n>>k;
	ll ans=n;
	if(n>0&&k==1){
        cout<<"0";
	}
	else{
	while(1){
        ans=abs(ans-k);
        if(ans<k)
            break;
	}
	cout<<k-ans;}
	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 <iostream>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int t=N%K;
  int u=min(t,K-t)
    cout<<u<<endl;
}

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

#include <iostream>
using namespace std;

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

	a=N%K;
	b=K-a;
	
	if(a<=b)cout<<a<<endl;
	else cout<<b<<endl;
	
	return0;
}

//REとは? 

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'return0' was not declared in this scope
   14 |         return0;
      |         ^~~~~~~
Language: C++

/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000005
#define N 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;for(ll testi=1;testi<=t;testi++)
#define djokovic  freopen("input00.txt", "r", stdin);freopen("output00.txt", "w", stdout);
ll zero = 0;
ll one = 1;
ll gcd(ll a, ll b) {    if (b == 0) return a;    return gcd(b, a % b);}
ll lcm(ll a, ll b) {    return (a / gcd(a, b) * b);}
ll expo(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) {
        if (y & 1)res = (1ll * res * x) % mod;
        y = y >> 1; x = (1ll * x * x) % mod;
    } return res;
}
ll ncr(ll n, ll r) { ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
bool prime(ll n) {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{   if (a.second == b.second)
        return a.first < b.first;
    return (a.second < b.second);
}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1,};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll n, m, x, k, a[MAXN], p[MAXN];
void solve()
{
    ll n, k; cin >> n >> k;
    if(n==k)    return cout<<n,0;
    cout << min(n % k, n % (n - k));
}
signed main()
{
    bolt;
    //djokovic;
    solve();
}








Compiler output:
a.cc: In function 'void solve()':
a.cc:55:31: error: return-statement with a value, in function returning 'void' [-fpermissive]
   55 |     if(n==k)    return cout<<n,0;
      |                        ~~~~~~~^~
Language: C++

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int first = N mod K;
  int second = K - first;
  
  cout << (first < second ? first : second) << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: expected ',' or ';' before 'mod'
   12 |   int first = N mod K;
      |                 ^~~
Language: C++

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

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

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: expected ';' before 'return'
   10 |   cout<<min(x,y)
      |                 ^
      |                 ;
   11 |   return 0;
      |   ~~~~~~
Language: C

#include <stdio.h>

int main(){
  int n,k;
  if(n>k){
  int d=n-k;
    if(d<k){
      printf("%d",k-d);
    }else{
      while(d>k){
        d=n-k;
         printf("%d",k-d);
    }
  }
  else{
    printf("%d",n);
  }
    return 0;
  }
    

Compiler output:
main.c: In function 'main':
main.c:15:3: error: expected '}' before 'else'
   15 |   else{
      |   ^~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
  int n,k;
  cin >>n>>k;
  int minimum=n%k;
  while (minimum>k%n){
    minimum=k%n;
    n=n%k;}
  cout << minimum;

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

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

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

Compiler output:
a.cc:4:12: error: 'Long' does not name a type; did you mean 'long'?
    4 | using ll = Long Long;
      |            ^~~~
      |            long
a.cc: In function 'int main()':
a.cc:8:3: error: 'll' was not declared in this scope
    8 |   ll n, k;
      |   ^~
a.cc:9:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    9 |   cin >> n >> k;
      |          ^
      |          yn
a.cc:9:15: error: 'k' was not declared in this scope
    9 |   cin >> n >> k;
      |               ^
a.cc:10:5: error: expected ';' before 'a'
   10 |   ll a = n % k;
      |     ^~
      |     ;
a.cc:11:5: error: expected ';' before 'ans'
   11 |   ll ans = min(a, k-a);
      |     ^~~~
      |     ;
a.cc:12:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: Java

import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    
    int ans = min(n%k , (k-n)%k);
    System.out.println(ans);
  }
}



Compiler output:
Main.java:9: error: cannot find symbol
    int ans = min(n%k , (k-n)%k);
              ^
  symbol:   method min(int,int)
  location: class Main
1 error
Language: Java

import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    
    ans = min(n%k , (k-n)%k);
    System.out.println(ans);
  }
}



Compiler output:
Main.java:9: error: cannot find symbol
    ans = min(n%k , (k-n)%k);
    ^
  symbol:   variable ans
  location: class Main
Main.java:9: error: cannot find symbol
    ans = min(n%k , (k-n)%k);
          ^
  symbol:   method min(int,int)
  location: class Main
Main.java:10: error: cannot find symbol
    System.out.println(ans);
                       ^
  symbol:   variable ans
  location: class Main
3 errors
Language: Java

import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    
    int ans = dfs(n,k);
    System.out.println(ans);
  }
  public static int dfs(int a,int b){
    int temp = Math.abs(a-b);
    if(temp < a){
      a = temp;
      dfs(a , b);
    }else{
      return a;
    }
    retrun 0;
  }
}



Compiler output:
Main.java:20: error: not a statement
    retrun 0;
    ^
Main.java:20: error: ';' expected
    retrun 0;
          ^
2 errors
Language: Java

import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    
    int ans = dfs(n,k);
    System.out.println(ans);
  }
  public static int dfs(int a,int b){
    int temp = Math.abs(a-b);
    if(temp < a){
      a = temp;
      dfs(a , b);
    }else{
      return a;
    }
  }
}



Compiler output:
Main.java:20: error: missing return statement
  }
  ^
1 error
Language: Java

import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int ans = n;
    
    while(true){
      int temp = Math.abs(ans-k);
      if(ans > temp){
        ans = temp;
      }else{
        break;
      }
    }
    System.out.println(ans);
  }
}
-

Compiler output:
Main.java:21: error: class, interface, enum, or record expected
-
^
1 error
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    long n = scanner.nextDouble();
    long k = scanner.nextDouble();
    long r = n%k;
    
    long ans = Math.min(r, (k-r));
    System.out.println(ans);
    scanner.close();
  }

	
}


Compiler output:
Main.java:6: error: incompatible types: possible lossy conversion from double to long
    long n = scanner.nextDouble();
                               ^
Main.java:7: error: incompatible types: possible lossy conversion from double to long
    long k = scanner.nextDouble();
                               ^
2 errors
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = scanner.nextInt();
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    int r = n%k;
    int ans = Math.min(r, k-r);
    System.out.println(ans);
  }

	
}


Compiler output:
Main.java:5: error: incompatible types: int cannot be converted to Scanner
    Scanner scanner = scanner.nextInt();
                                     ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
	long long int n, m;
	cin >> n >> m;
	long long int check = 0;
	int ct = 0;

	int dd = n % m;

	cout << max(dd, n - dd) << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: no matching function for call to 'max(int&, long long int)'
   11 |         cout << max(dd, n - dd) << "\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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:11:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   11 |         cout << max(dd, n - dd) << "\n";
      |                 ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:11:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   11 |         cout << max(dd, n - dd) << "\n";
      |                 ~~~^~~~~~~~~~~~
Language: C++

long long Temp(long long n, long long k) {
	long long a = n; long long b = k;
	long long z1 = a;

	while (true) {
		if (a % b == 0 && a != 1)
			a = b;
		else if (a > b)
			a %= b;
		else
			a = abs(a - b);

		if (a > z1)
			return z1;
		else
			z1 = a;
	}
}

int main() {
	long long n = 0, m = 0;
	cin >> n >> m;
	
	cout << Temp(n, m) << endl;

	return 0;
}

Compiler output:
a.cc: In function 'long long int Temp(long long int, long long int)':
a.cc:11:29: error: 'abs' was not declared in this scope
   11 |                         a = abs(a - b);
      |                             ^~~
a.cc: In function 'int main()':
a.cc:22:9: error: 'cin' was not declared in this scope
   22 |         cin >> n >> m;
      |         ^~~
a.cc:24:9: error: 'cout' was not declared in this scope
   24 |         cout << Temp(n, m) << endl;
      |         ^~~~
a.cc:24:31: error: 'endl' was not declared in this scope
   24 |         cout << Temp(n, m) << endl;
      |                               ^~~~
Language: C

#include <stdio.h>

int main()
{
	long long int N,K;
	scanf("%lld %lld",&N,&K);

	N %= K;

	if ((llabs)(N - K) < N){
		N = (llabs)(N - K);
	}
	printf("%lld\n",N);
}


Compiler output:
main.c: In function 'main':
main.c:10:14: error: 'llabs' undeclared (first use in this function)
   10 |         if ((llabs)(N - K) < N){
      |              ^~~~~
main.c:10:14: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:4:1: error: 'cin' was not declared in this scope
    4 | 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 | using namespace std;
a.cc:6:16: error: 'min' was not declared in this scope; did you mean 'main'?
    6 | long long ans =min(a,k-a);
      |                ^~~
      |                main
a.cc:7:1: error: 'cout' was not declared in this scope
    7 | cout<<ans;
      | ^~~~
a.cc:7:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>

int main (int, char**) {
    unsigned long long int N;
    unsigned long long int K;
    std::cin >> N >> K;
    std::cout << N << std::endl;
    std::cout << K << std::endl;
    unsigned long long int amari;
    amari = N%K;
    unsigned long long int answer = std::min(amari, std::abs(amari - K));
    std::cout << answer << std::endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:13:61: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
   13 |     unsigned long long int answer = std::min(amari, std::abs(amari - K));
      |                                                     ~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __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:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
Language: C

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

long long int main(void){
	long long int n,k;
	scanf("%lld %lld",&n,&k);
	n=n%k;
	if(n>abs(n-k)){
		//n=k-n;
		n=absll(n-k);
	}
	printf("%lld\n",n);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:10:19: error: implicit declaration of function 'absll'; did you mean 'abs'? [-Wimplicit-function-declaration]
   10 |                 n=absll(n-k);
      |                   ^~~~~
      |                   abs
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
    9 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
int replaceInteger(int ,int);
int main(){
   int n,k;
  cin>>n>>k;
  cout<<replaceInteger(n,k)<<endl;
    return 0;
}
int replaceInteger(int x,int k){
  if(x<k)
    return x;
  int n=x;
  //int minimum = INT_MAX;
  
    if( n % 2 == 0){
      for(int i=0;i<n;i++){
        n = abs(n-k);
        if(n<=0)
          return abs(n);
        n = abs(n);
        //minimum = min(minimum,n);
      }
    }
    else{
      for(int i=0;i<n-1;i++){
        n = (n-k);
        if(n<=0)
          return abs(n);
        n = abs(n);
        
      }
    }
     

Compiler output:
a.cc: In function 'int replaceInteger(int, int)':
a.cc:33:6: error: expected '}' at end of input
   33 |     }
      |      ^
a.cc:10:32: note: to match this '{'
   10 | int replaceInteger(int x,int k){
      |                                ^
a.cc:33:6: warning: control reaches end of non-void function [-Wreturn-type]
   33 |     }
      |      ^