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

#include <stdio.h>
 
int main(){
  long long int　N,K,S;
  scanf("%lld %lld",&N,&K);
  do{
    N-=K;
  }while(N>K);
  
  
  if(N<(double)(K/2)){
    S=N;
  }else{
    S=K-N;
  }
  printf("%lld",S);
  return 0;
}
    
  


Compiler output:
main.c: In function 'main':
main.c:4:16: error: stray '\343' in program
    4 |   long long int<U+3000>N,K,S;
      |                ^~~~~~~~
Language: C

#include <stdio.h>
 
int main(){
  long long int　N,K,S;
  scanf("%lld %lld",N,K);
  do{
    N-=K;
  }while(N>K);
  
  
  if(N<(double)(K/2)){
    S=N;
  }else{
    S=K-N;
  }
  printf("%lld",S);
  return 0;
}
    
  


Compiler output:
main.c: In function 'main':
main.c:4:16: error: stray '\343' in program
    4 |   long long int<U+3000>N,K,S;
      |                ^~~~~~~~
Language: Java

import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		long N=scan.nextLong();
		long K=scan.nextLong();
		
		
		
	
		if(N==0||N%K==0) {
			System.out.println("0");
		}
		else {
			List<Long> list=new ArrayList<Long>();
			boolean flag=false,flagb=false;
			if(N>K)N=N%K;
			for(;;) {
				long A=Math.abs(N-K);
				
				N=A;
				if(A==1) {
					flag=true;
					flagb=true;
				}
				for(Long i:list) {
					if(i==A)flag=true;
				}
				if(flag)break;
				list.add(A);
			}
			if(flagb) {
				System.out.println("1");
			}
			else {
				long min=list.get(0);
				for(Long i:list) {
					if(min>i)min=i;
				}
				System.out.println(min);
			}
		}

	}

}


Compiler output:
Main.java:16: error: cannot find symbol
			List<Long> list=new ArrayList<Long>();
			^
  symbol:   class List
  location: class Main
Main.java:16: error: cannot find symbol
			List<Long> list=new ArrayList<Long>();
			                    ^
  symbol:   class ArrayList
  location: class Main
2 errors
Language: C++

#include<bits.stdc++.h>

int main()
{long long int n,k,cmp;
 scanf("%llu%llu",&n,&k);
 if((n==k)||(n%k==0))
   printf("0");
 else
 {cmp=n;
  while(n<=cmp)
  {n=abs(n-k);
   if(n<cmp)
     cmp=n;
  }printf("%llu",cmp);
 }
}


Compiler output:
a.cc:1:9: 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;
//useful library
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    int long long N, K, A;
    cin >> N >> K;
    vector<int long long> V(900);
    V.push_back(N);
    A = 0;
    if(N % K == 0){
        goto ABC;
    }
    for(int i = 0; i < 5; i++){
        V.reserve(i + 1);
        V.emplace_back(floor(abs(V.at(i) - K)));
    }
    DEF:
    if((V.at(A) < V.at(A + 1)) && (V.at(A) < V.at(A + 2)) && (V.at(A) < V.at(A + 3)) && (V.at(A) < V.at(A + 4))){
        goto ABC;
    }
    A = 4;
    else{
        V.emplace_back(floor(abs(V.at(A - 1) - K)));
        A = A + 1;
        goto DEF;
    }
    ABC:
    cout << V.at(A) << endl;
    return 0;
}

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

#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;
#include <stdlib.h>
 
int main()
{
    int N,K;
    int min,x,bx;
  
  	scanf("%d %d",&N,&K);
  
	x=N;
	min=x;
    while(x!=bx&&min!=0)
    {
      bx=x;
      x=abs(x-K);
        if(x<min)
          min=x
    }
    printf("%d",min);
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;//N初期値　Kそれから引く
int main() {
  int N, K;
  cin >> N >> K;
 if (K > 0){
  int M = N % K; //+max
  
  if (K - M < M) {
    cout << K - M << endl;
  }
  else if (K - M = M){
    cout << 0 << endl;
  }
  else {
    cout << M << endl;
  }
 }
  else {
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: lvalue required as left operand of assignment
   12 |   else if (K - M = M){
      |            ~~^~~
Language: Java

import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   long n =kbd.nextLong();
   long k =kbd.nextLong();
   long x=0;
   long y=0;
   if(k=0){
     x=0;
   }else{
   if(n>=k){
   y=n/k;
   x=k*(y+1)-n;
 }else{
    x=n;
 }
}
  System.out.println(x);
}
 }


Compiler output:
Main.java:9: error: incompatible types: long cannot be converted to boolean
   if(k=0){
       ^
1 error
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define OUT(s) cout << s << "\n";

using namespace std;
// https://atcoder.jp/contests/abc161

long N,K;

void Main()
{
    long a,a1,a2;
    if (K < N) {
        a1 = N;
        a2 = K;
    } else {
        a1 = K;
        a2 = N;
    }
    a = a1 % a2;
    OUT(t);
}

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	// cout << fixed << setprecision(15);
    cin >> N >> K;
	Main();
    return 0;
}

Compiler output:
a.cc: In function 'void Main()':
a.cc:23:9: error: 't' was not declared in this scope
   23 |     OUT(t);
      |         ^
a.cc:5:24: note: in definition of macro 'OUT'
    5 | #define OUT(s) cout << s << "\n";
      |                        ^
Language: C++

n, k = [int(i) for i in input().split()]

def a(x):
    return abs(x - k)

if n > k:
    tmp = k 
    while not (n - tmp) % k == 0:
        tmp -= 1
    n = tmp

while True:
    tmp = n
    n = a(n)
    if tmp < n:
        print(tmp)
        break


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, k = [int(i) for i in input().split()]
      | ^
Language: C++

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

int abs(int x){
  if(x>=0){
    return x;
  }
  else{
    x*=-1;
    return x;
  }
}

int main(){
  int N,x,K,t;
  cin>>N>>K;
  x=N;
  t=x/K+1;
  vector<int> box(t+10);
  box[0]=x;
  box[1]=abs(x-K)
  int i=1;
  while(box[i]<=box[i-1]){
    box[i]=abs(box[i-1]-K);
    i+=1;
  }
  int result=box[i-1];
  cout<<result<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:18: error: expected ';' before 'int'
   22 |   box[1]=abs(x-K)
      |                  ^
      |                  ;
   23 |   int i=1;
      |   ~~~             
a.cc:24:13: error: 'i' was not declared in this scope
   24 |   while(box[i]<=box[i-1]){
      |             ^
a.cc:28:18: error: 'i' was not declared in this scope
   28 |   int result=box[i-1];
      |                  ^
Language: C++

#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;

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

void CReplacingInteger(std::istream& in, std::ostream& out) {
  llong n, k;
  in >> n >> k;
  llong mod = n % k;
  llong nmod = k - mod;
  llong nnmod = n - mod;
  if (mod == 0) {
    out << "0\n";
    return;
  }
  llong g = gcd(mod, nmod);
//  g = min(g, nmod);
//  g = min(g, mod);
  g = min(g, gcd(mod, nnmod));
  out << g << endl;
}

// int main(int argc, char** argv) { CReplacingInteger(cin, cout); return 0; }


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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

int abs(int x){
  if(x>=0){
    return x;
  }
  else{
    x*=-1
    return x;
  }
}

int main(){
  int N,x,K,t;
  cin>>N>>K;
  x=N;
  t=x/K+1;
  vector<int> box(t+10);
  box[0]=x;
  box[1]=abs(x-K)
  int i=1;
  while(box[i]<=box[i-1]){
    box[i]=abs(box[i-1]-K);
    i+=1;
  }
  int result=box[i-1];
  cout<<result<<endl;
}


Compiler output:
a.cc: In function 'int abs(int)':
a.cc:10:10: error: expected ';' before 'return'
   10 |     x*=-1
      |          ^
      |          ;
   11 |     return x;
      |     ~~~~~~
a.cc: In function 'int main()':
a.cc:22:18: error: expected ';' before 'int'
   22 |   box[1]=abs(x-K)
      |                  ^
      |                  ;
   23 |   int i=1;
      |   ~~~             
a.cc:24:13: error: 'i' was not declared in this scope
   24 |   while(box[i]<=box[i-1]){
      |             ^
a.cc:28:18: error: 'i' was not declared in this scope
   28 |   int result=box[i-1];
      |                  ^
a.cc: In function 'int abs(int)':
a.cc:10:6: warning: control reaches end of non-void function [-Wreturn-type]
   10 |     x*=-1
      |     ~^~~~
Language: C++

#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;
#include <stdlib.h>
 
int main()
{
    int N,K;
    int min,x,bx;
  
  	scanf("%d %d",&N,&K);
  
	x=N;
	min=x;
    while(x!=bx)
    {
      bx=x
      x=abs(x-K);
        if(x<min)
          min=x
    }
    printf("%d",min);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:11: error: expected ';' before 'x'
   17 |       bx=x
      |           ^
      |           ;
   18 |       x=abs(x-K);
      |       ~    
a.cc:20:16: error: expected ';' before '}' token
   20 |           min=x
      |                ^
      |                ;
   21 |     }
      |     ~
Language: C

#include<stdio.h>
#include<stdlib.h>
int main()
{
 unsigned long long int N,K;
 x=N;
 scanf("%llu%llu",&N,&K);
 N=abs((N-K));

 N=abs((N-K));

 if(N<=N && N<=6)
    printf("%llu\n",N);

 else
 printf("0\n");
 return 0;
}


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

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

int main(){
  long long n, k;
  cin >> n >> k;
  long long x = n;
  
  while(x < abs(x-k)){
    if(abs(x-k) == n){
      x=n;
      continue;
    }
  	x = abs(x-k);
  }
  
  cout << x << endl;
  return0;
}

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

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

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

    while(True){
        if(n < k){
            break;
        }
        if(n>=k){
            a = n - k;
        }else{
            a = k - n;
        }
        n = a;
        
    }
    cout << n << endl;
}

Compiler output:
a.cc:2:20: error: expected ';' before 'int'
    2 | using namespace std
      |                    ^
      |                    ;
    3 | 
    4 | int main(){
      | ~~~                 
a.cc: In function 'int main()':
a.cc:9:11: error: 'True' was not declared in this scope
    9 |     while(True){
      |           ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>

using namespace std;
typedef long long ll;

int main(void){
  ll n,k;
  cin>>n>>k;
  if(n>k){
    ll ans = min(n%k,llabs(n-(n%k));
    cout<<ans;
  }

  else{
    ll ans = min(k%n,llabs(k-(k%n));
    cout<<ans;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:36: error: expected ')' before ';' token
   13 |     ll ans = min(n%k,llabs(n-(n%k));
      |                 ~                  ^
      |                                    )
a.cc:18:36: error: expected ')' before ';' token
   18 |     ll ans = min(k%n,llabs(k-(k%n));
      |                 ~                  ^
      |                                    )
Language: C++

print("Enter N and K value below:")
N = input()
K = input()
print(N + " " + K)
while 0 <= int(N) <= 10**8 and 0 <= int(K) <= 10**8:
    N = abs(N-M)
    N = 0
print(N)


Compiler output:
a.cc:1:6: error: expected constructor, destructor, or type conversion before '(' token
    1 | print("Enter N and K value below:")
      |      ^
Language: C++

#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>

using namespace std;
typedef long long ll;

int main(void){
  ll n,k;
  cin>>n>>k;
  if(n>k){
    ll ans = min(n%k,llabs(n-(n%k));
    cout<<ans;
  }

  else{
    ll ans = min(k%n,llabs(k-(k%n)));
    cout<<ans;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:36: error: expected ')' before ';' token
   13 |     ll ans = min(n%k,llabs(n-(n%k));
      |                 ~                  ^
      |                                    )
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long N,K;
  cin >> N >> K;
  if(N % K == 0) N = 0;
  
  int x = N * M;
  int n = N;
  int m = M;
  int r = n % m;
  while(r != 0){
    n = m;
    m = r;
    r = n % m;
  }
  r = x / m;
  
  while(abs(N-K) < N){
    if(N % K == 0){
      N = 0;
      break;
    }
    if(N % r == 0 && M % r == 0){
      N = 0;
      break;
    }
    N = abs(N-K);
  }
  cout << N << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:15: error: 'M' was not declared in this scope
    9 |   int x = N * M;
      |               ^
Language: C++

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

int main(){
    long long n,k,tmp;
    int i = 0;

    cin >> n;
    cin >> k;

    while(i == 0){
        tmp = llabs(n - k);
        if(tmp > n){7 
            i = 1;
        }
        else{
            n = tmp;
        }
    }
        
    cout << n << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:22: error: expected ';' before 'i'
   13 |         if(tmp > n){7
      |                      ^
      |                      ;
   14 |             i = 1;
      |             ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  int N,K;
  cin >> N >> K;
  int x=N;
  for(int i=0;i<N;i++) {
    if(x(i)<xi+1)) {
      break;}
    else {
    if(N-K>0) {
      x=N-K;}
    else {
      x=K-N;}
      }
    }
  cout << x << endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'x' cannot be used as a function
    9 |     if(x(i)<xi+1)) {
      |        ~^~~
a.cc:9:13: error: 'xi' was not declared in this scope; did you mean 'i'?
    9 |     if(x(i)<xi+1)) {
      |             ^~
      |             i
a.cc:9:18: error: expected primary-expression before ')' token
    9 |     if(x(i)<xi+1)) {
      |                  ^
Language: C++

#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
int n,m,k,x;
  cin>>n>>k;
  m=n/k;
  if(n>=k){
    x=n
  for(int i=0;i<m;i++){
  x-=k  
  }
    cout<<x<<endl;
  }
  else cout<<n<<endl; 
  



}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:8: error: expected ';' before 'for'
   16 |     x=n
      |        ^
      |        ;
   17 |   for(int i=0;i<m;i++){
      |   ~~~   
a.cc:17:15: error: 'i' was not declared in this scope
   17 |   for(int i=0;i<m;i++){
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  int N,K;
  cin >> N >> K;
  int x=N;
  for(int i=0;i<N;i++) {
    if(x[i]<x[i+1]) {
      break;}
    else {
    if(N-K>0) {
      x=N-K;}
    else {
      x=K-N;}
      }
    }
  cout << x << endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: invalid types 'int[int]' for array subscript
    9 |     if(x[i]<x[i+1]) {
      |         ^
a.cc:9:14: error: invalid types 'int[int]' for array subscript
    9 |     if(x[i]<x[i+1]) {
      |              ^
Language: Java

//package bleh;
	//package bleh;
    import java.io.BufferedReader;
import java.util.Collections;
import java.util.HashMap;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.Scanner;
     
    public class Main {
     
      public static void solve(Scanner in) {
//        int t = in.nextInt();
//        while (t-- > 0) {
//   		//enter code here
//
//        }
    	  int n=in.nextInt();
    	  int k=in.nextInt();
    	  HashMap<Integer,Integer>map=new HashMap<>();
    	  if(Math.abs(n-k)==n||Math.abs(n-k)==k)
    		  System.out.print(n);
    	  else {
    		  while(true) {
    			  int x=Math.abs(n-k);
    			  if(map.containsKey(x)) {
    				  break;
    			  }
    			  else {
    				  map.put(x, 1);
    			  }
    			  n=x;
    		  }
    	  }
    	  int min=Collections.min(map.values());
    	  System.out.println(min);
      }
     
      public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        Solution sol = new Solution();
        sol.solve(in);
      }
    }


Compiler output:
Main.java:41: error: cannot find symbol
        Solution sol = new Solution();
        ^
  symbol:   class Solution
  location: class Main
Main.java:41: error: cannot find symbol
        Solution sol = new Solution();
                           ^
  symbol:   class Solution
  location: class Main
2 errors
Language: C

#include<stdio.h>
#include<math.h>
int main()
{
	unsigned long long int K,N,t;
    scanf("%lld%lld",&N,&K);
    t=N%K;
    if(t*2>K) a=abs(t-K);
    else a=t;
    printf("%lld",a);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:15: error: 'a' undeclared (first use in this function)
    8 |     if(t*2>K) a=abs(t-K);
      |               ^
main.c:8:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:8:17: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
    8 |     if(t*2>K) a=abs(t-K);
      |                 ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | int main()
main.c:8:22: warning: 'abs' argument 1 type is 'long long unsigned int' where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
    8 |     if(t*2>K) a=abs(t-K);
      |                     ~^~
<built-in>: note: built-in 'abs' declared here
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  int N,K;
  cin >> N >> K;
  int x=N;
  for(int i=0;i<N;i++) {
    if(x.at(i)<x.at(i+1)) {
      break;}
    else {
    if(N-K>0) {
      x=N-K;}
    else {
      x=K-N;}
      }
    }
  cout << x << endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: request for member 'at' in 'x', which is of non-class type 'int'
    9 |     if(x.at(i)<x.at(i+1)) {
      |          ^~
a.cc:9:18: error: request for member 'at' in 'x', which is of non-class type 'int'
    9 |     if(x.at(i)<x.at(i+1)) {
      |                  ^~
Language: C

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

Compiler output:
main.c: In function 'main':
main.c:17:3: error: expected declaration or statement at end of input
   17 |   return 0;
      |   ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main ( ) 
{
	int m,n;
	cin>>n>>m;
	if(n%m==0)
	{
		cout<<"0";
		return 0;
	} 
	else
	{
		if(n%m>=m/2)
		for(int i=1;i<=n;i++)
		{
			int a[i];
			cin>>a[i];
			else
			{
				cout<< 
                  fhghg
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:25: error: 'else' without a previous 'if'
   19 |                         else
      |                         ^~~~
a.cc:22:19: error: 'fhghg' was not declared in this scope
   22 |                   fhghg
      |                   ^~~~~
a.cc:25:2: error: expected '}' at end of input
   25 | }
      |  ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: Java

import java.util.Scanner;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long x = scanner.nextLong(); 
    long y = scanner.nextLong();
    if(x<y){
      int d = Math.abs(x-y);
      if(x>d){
      	System.out.print(d);
       }
   	   else{
     	 System.out.print(x);}
    }
    else{
      long a = x%y;
      if(a==0){
        System.out.print(a);
      }
      else{
        long b = Math.abs(a-y);
        if(a>b){
      		System.out.print(b);
        }
        else{
          System.out.print(a);
        }
      }
    }
  }
}

Compiler output:
Main.java:11: error: incompatible types: possible lossy conversion from long to int
      int d = Math.abs(x-y);
                      ^
1 error
Language: C++

#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
int ke (int n){
    n--;
    if(n == 1 )return 0;
    int ans = 1;
    while (0 < n){
        ans *= n;
        n--;
    }
    return ans ;

}

void go(ll n , ll k){
    ll mi = INF;
    REP(i,3){
        mi = min(mi, abs(n-k));
        n = abs(n-k);
    }

    cout << mi <<endl;
    
    return  ;


}
int main(){
    int64_t n,k;
    cin  >> n >>k;

    int64_t su = n/k;
    
    if(n < k){
        int64_t mi = nanf128;
    REP(i,3){
        mi = min(mi, abs(n-k));
        n = abs(n-k);
    }

    cout << mi <<endl;
    
    return 0 ;

    
    } else{
        n -= su*k;
        while(true){
            int64_t l = n;
            int64_t r = abs(l - k);
            if(l <= r){
                n = l;
                int64_t mi = n;
                REP(i,3){
                    mi = min(mi, abs(n-k));
                    n = abs(n-k);
                }
                cout << mi <<endl;
                return 0 ;
            }
            n = r;     
        }
    }

    return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:120:22: error: invalid conversion from '_Float128 (*)(const char*) noexcept' to 'int64_t' {aka 'long int'} [-fpermissive]
  120 |         int64_t mi = nanf128;
      |                      ^~~~~~~
      |                      |
      |                      _Float128 (*)(const char*) noexcept
Language: C++

#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>

using namespace std;
typedef long long ll;

int main(void){
  ll n,k;
  cin>>n>>k;
  ll temp=n;
  
  while(temp>llabs(temp-k)){
    temp=llabs(temp-k);
  }

  ll ans = min(temp,llabs(temp-k))
  
  cout<<ans;
  return 0;
}

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

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

Compiler output:
main.c: In function 'main':
main.c:15:14: error: expected ';' before 'printf'
   15 |    while(d>n)
      |              ^
      |              ;
   16 |      printf("%d",d);
      |      ~~~~~~   
main.c:17:3: error: expected declaration or statement at end of input
   17 |   return 0;
      |   ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  int N,K;
  cin >> N >> K;
  int x=N;
  for(int i=0;x.at(i)<N;i++) {
    if(N-K>0) {
      x=N-K;}
    else {
      x=K-N;}
    }
  cout << x << endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: request for member 'at' in 'x', which is of non-class type 'int'
    8 |   for(int i=0;x.at(i)<N;i++) {
      |                 ^~
Language: Java

//package bleh;
	//package bleh;
    import java.io.BufferedReader;
import java.util.Collections;
import java.util.HashMap;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.Scanner;
     
    public class Solution {
     
      public static void solve(Scanner in) {
//        int t = in.nextInt();
//        while (t-- > 0) {
//   		//enter code here
//
//        }
    	  int n=in.nextInt();
    	  int k=in.nextInt();
    	  HashMap<Integer,Integer>map=new HashMap<>();
    	  if(Math.abs(n-k)==n||Math.abs(n-k)==k)
    		  System.out.print(n);
    	  else {
    		  while(true) {
    			  int x=Math.abs(n-k);
    			  if(map.containsKey(x)) {
    				  break;
    			  }
    			  else {
    				  map.put(x, 1);
    			  }
    			  n=x;
    		  }
    	  }
    	  int min=Collections.min(map.values());
    	  System.out.println(min);
      }
     
      public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        Solution sol = new Solution();
        sol.solve(in);
      }
    }


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

using namespace std;
int  main(){
    long long int N;
    int K;
    cin>>N>>K;
        N%=K;
    if(N==0) cout<<"0";
    else if (N>fabs(N-K)) cout<<fabs(N-K);
    else cout<<N;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin>>N>>K;
      |     ^~~
a.cc: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:7:14: error: 'cout' was not declared in this scope
    7 |     if(N==0) cout<<"0";
      |              ^~~~
a.cc:7:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:8:16: error: 'fabs' was not declared in this scope
    8 |     else if (N>fabs(N-K)) cout<<fabs(N-K);
      |                ^~~~
a.cc:8:27: error: 'cout' was not declared in this scope
    8 |     else if (N>fabs(N-K)) cout<<fabs(N-K);
      |                           ^~~~
a.cc:8:27: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:9:10: error: 'cout' was not declared in this scope
    9 |     else cout<<N;
      |          ^~~~
a.cc:9:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

int abs(int x){
  if(x>=0){
    return x;
  }
  else{
    return -x;
  }
}

int main(){
  int N,x,K,t;
  cin>>N>>K;
  x=N;
  t=x/K+1;
  vector<int> box(t+1);
  for (int i=0;i<t+1;i++){
    x=abs(x-K);
    box[i]=x;
  }
  int result;
  if(t>=2){
    result=min(min(N,min(box[t],box[t-1])),box[t-2]);
  }
  else{
    result=min(N,min(box[0],box[1]);
  } 
  cout<<result<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:36: error: expected ')' before ';' token
   29 |     result=min(N,min(box[0],box[1]);
      |               ~                    ^
      |                                    )
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long int n,k,min,num1,num2;
    cin>>n>>k;
    min=n;
   long long double d2,d1=( long long double)n/k;
    d2=d1;
    d2=floor(d2);
    d1=ceil(d1);
  // cout<<d<<endl;
    if(min<k)
    cout<<min;
    // else{
    // while (true)
    // {
    //     n-=d;
    //     if(min>n)
    //     min=n;
    //     if(min<=0)
    //     {min*=(-1);break;}
    // }
    // cout<<min;
    // }
    else{
        num1=n-(k*d1);
        num2=n-(k*d2);
      if(num1<min)
      {
        if(num1<=0)
         cout<<num1*(-1);
        else
         cout<<num1;
      }
      else
      {
         if(num2<=0)
       cout<<num2*(-1);
       else
       cout<<num2;
      }
    }
    
    

}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'long long' specified with 'double'
    9 |    long long double d2,d1=( long long double)n/k;
      |         ^~~~
a.cc:9:9: error: 'long long' specified with 'double'
a.cc:9:34: error: 'long long' specified with 'double'
    9 |    long long double d2,d1=( long long double)n/k;
      |                                  ^~~~
Language: C

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

Compiler output:
main.c:1:1: error: invalid suffix "include" on integer constant
    1 | 3include<stdio.h>
      | ^~~~~~~~
main.c:1:1: error: expected identifier or '(' before numeric constant
Language: C

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

int main(void){
  long n,k,tmp;
  scanf("%ld %ld", &n, &k);
  
  if(n>k) n=n%k;
  
  tmp=n-k;
  n=labs(tmp);
  
  if(n>=k){
    printf("%ld", n);
  }else(n<k){
    printf("%ld", k);
  }
  return 0;
}



Compiler output:
main.c: In function 'main':
main.c:15:13: error: expected ';' before '{' token
   15 |   }else(n<k){
      |             ^
      |             ;
Language: C

#include<stdio.h>

int main(void)
{
	long a, b, c;
	long check = 0;

	scanf("%lo %lo", &a, &b);

	a = a % b;
	c = a / b;
	if (c != 0) {
		a = a + b
	}

	for (;;) {
		check = a - b;
		if (check < 0) {
			check = check * (-1);
		}

		if (a > check) {
			a = check;
		}

		else {
			printf("%lo", a);
			break;
		}
	}

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:13:26: error: expected ';' before '}' token
   13 |                 a = a + b
      |                          ^
      |                          ;
   14 |         }
      |         ~
Language: C++

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

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

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

int abs(int x){
  if(x>=0){
    return x;
  }
  else{
    return -x;
  }
}

int main(){
  int N,x,K,t;
  cin>>N>>K;
  x=N;
  t=x/K+1;
  vector<int> box(t);
  for (int i=0;i<t;i++){
    x=abs(x-K);
    box[i]=x;
  }
  int result;
  if(t>=2){
    result=min(box[t-1],box[t-2]);
  }
  else{
    result=min(N,box(t-1));
  } 
  cout<<result<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:21: error: no match for call to '(std::__debug::vector<int>) (int)'
   29 |     result=min(N,box(t-1));
      |                  ~~~^~~~~
Language: C++

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

int abs(int x){
  if(x>=0){
    return x;
  }
  else{
    return -x;
  }
}

int main(){
  int N,x,K,t;
  cin>>N>>K;
  x=N;
  t=x/K+1;
  vector<int> box(t);
  for (int i=0;i<t;i++){
    x=abs(x-K);
    box[i]=x;
  }
  int result;
  if(t>=2){
    result=min(box[t-1],box[t-2]);
  }
  else{
    result=min(N,box(0));
  } 
  cout<<result<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:21: error: no match for call to '(std::__debug::vector<int>) (int)'
   29 |     result=min(N,box(0));
      |                  ~~~^~~
Language: C++

#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    
    long long int n,k;
    
    cin >> n;
    cin >> k;
 
    // cout << k << endl;
    if(k==1 && n%k==0){
        cout<<0<<endl;
       
    {
        
    }else{
 
        // vector<long long int> v;
    
        // v.push_back(n);
        long long int i=0;
        while(i<1000000000000000){
            if(n<=abs(n-k)){
                break;
            }
            // v.push_back(abs(n-k));
            n=abs(n-k);
            i++;
        }
    
 
        // cout << *std::min_element(v.begin(), v.end());
        cout << n;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:6: error: expected '}' before 'else'
   20 |     }else{
      |      ^~~~
a.cc:15:23: note: to match this '{'
   15 |     if(k==1 && n%k==0){
      |                       ^
Language: C++

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

int abs(int x){
  if(x>=0){
    return x;
  }
  else{
    return -x;
  }
}

int main(){
  int N,x,K,t;
  cin>>N>>K;
  x=N
  t=x/K+1;
  vector<int> box(t);
  for (int i=0;i<t;i++){
    x=abs(x-K);
    box[i]=x;
  }
  int result;
  if(t>=2){
    result=min(box[t-1],box[t-2]);
  }
  else{
    result=min(N,box(0));
  } 
  cout<<result<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:6: error: expected ';' before 't'
   17 |   x=N
      |      ^
      |      ;
   18 |   t=x/K+1;
      |   ~   
a.cc:29:21: error: no match for call to '(std::__debug::vector<int>) (int)'
   29 |     result=min(N,box(0));
      |                  ~~~^~~
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;
    if(a == 0) {
        cout << 0 << endl;
        return 0;
    } else {
        ll b = abs(a - k);
        if(a > b) {
            cout << b << endl;
            return 0
        } else {
            cout << a << endl;
            return 0;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:21: error: expected ';' before '}' token
   18 |             return 0
      |                     ^
      |                     ;
   19 |         } else {
      |         ~
Language: C++

#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
using namespace std;



int main(){
   
   int N,K,ans,switchdayo=0,now;
   cin>>N>>K;
   now=N;
   while(switchdayo==0){
       now=now-K
       if(now<0) break;      
   }
   if(abs(now)<now+K) ans=abs(now);
   else ans=now+K;
   if(ans>N) ans=N;
   
   cout<<ans<<endl;



    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: expected ';' before 'if'
   17 |        now=now-K
      |                 ^
      |                 ;
   18 |        if(now<0) break;
      |        ~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n,k; cin >> n >> k;

  if(n<k){
    cout << min(n,ans(n-k));
  }
  else{
    
    int x = n/k;

    if(n%k==0){
      cout << 0;
    }else{
      int a = x - 1;
      int b = x;
      int c = x + 1;
      vector<int> ans;
      ans.pb(abs(n - a*k));
      ans.pb(abs(n - b*k));
      ans.pb(abs(n - c*k));
      sort(all(ans));
      cout << ans[0];
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:22:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |     cout << min(n,ans(n-k));
      |                   ^~~
      |                   abs
Language: C++

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

int main() {
    int N;
    int K;

    cin >> N >> K;
    for(int i; i < K; i++) {
        if (N == K) {
            cout << 0 << endl;
            break;

        }
        else if (N > K) {
            if (N < N - K) {
                cout << N << endl;
                break;
            }
            N = N - K;

        }
        else if (N < K) {
            if (N < K - N) {
                cout << N << endl;
                break
            }
            N = K - N;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:22: error: expected ';' before '}' token
   26 |                 break
      |                      ^
      |                      ;
   27 |             }
      |             ~
Language: C++

#include <>
int main()
{
    long long  a,b,c ;
    scanf("%lld %lld",&a,&b) ;
    if(a == 0)
    	printf("b\n") ;
    else if(a%b == 0 || b%a == 0)
    	printf("0\n") ;
    else
    {
    	while(a%b!=0)
	    {
	        c=a%b;a=b;b=c;
	    }
	    printf("%lld\n",b);
	}
    return 0;
}

Compiler output:
a.cc:1:10: error: empty filename in #include
    1 | #include <>
      |          ^~
a.cc: In function 'int main()':
a.cc:5:5: error: 'scanf' was not declared in this scope
    5 |     scanf("%lld %lld",&a,&b) ;
      |     ^~~~~
a.cc:7:9: error: 'printf' was not declared in this scope
    7 |         printf("b\n") ;
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #include <>
a.cc:9:9: error: 'printf' was not declared in this scope
    9 |         printf("0\n") ;
      |         ^~~~~~
a.cc:9:9: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:16:13: error: 'printf' was not declared in this scope
   16 |             printf("%lld\n",b);
      |             ^~~~~~
a.cc:16:13: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#include<iosream>
using namespace std;
int main(){
  	uint64_t n,k;
	cin>>n>>k;
  	if(n>k/2) cout<<n;
  else
  	cout<<n%(k/2);
}


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

int main() {
int N, K;
cin >> N >> K;
int J;
int ans;
if(K == 0){
ans = N;
}

if(N > K){
J = N % K;
K -= J;
ans = K;
}
else{
    ans = 100000000;
for(int i = 0; i < J; i++){
    ans = min(N, ans);
if(N > K) N -= K;
else N = K-N;
ans = min(N, ans);
 
}
}

cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:1: error: 'cin' was not declared in this scope
    3 | cin >> N >> K;
      | ^~~
a.cc:18:11: error: 'min' was not declared in this scope; did you mean 'main'?
   18 |     ans = min(N, ans);
      |           ^~~
      |           main
a.cc:26:1: error: 'cout' was not declared in this scope
   26 | cout << ans << endl;
      | ^~~~
a.cc:26:16: error: 'endl' was not declared in this scope
   26 | cout << ans << endl;
      |                ^~~~
Language: C++

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

  else {
    int ams = gcd(n, k);
    cout << ams << endl;
  }
}


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

// using no_way as a way
// using no_limitation as a limitation

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define RT(x) return cout<<x, 0;
//#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
// const int dx[] = {1,-1,0,0,1,-1,1,-1};
// const int dy[] = {0,0,1,-1,1,-1,-1,1};
// const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
// const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());


int main(int argc, char const *argv[])
{
    // file();
    fast();
    
    ull x, y;cin>>x>>y;
    if(!n)RT(0);
    if (x < y)
    {
        if( y % x == 0)
            RT(x);
        RT(min(x , y - x));
    }
    if(x % y == 0)
        RT(0);
    RT(y - (x % y));
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:53:9: error: 'n' was not declared in this scope
   53 |     if(!n)RT(0);
      |         ^
Language: C++

#include <iostream>

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>vec;
    n = n%k;
    int nn=k-n;
    cout<<min(n,nn)<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'vector' was not declared in this scope
    8 |     vector<int>vec;
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:8:12: error: expected primary-expression before 'int'
    8 |     vector<int>vec;
      |            ^~~
Language: C++

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


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

#include<bits/stdc++.h>
using namespace std;
int main();
{long long int n,k;
 cin>>n>>k;
 
 if((k==1)&&(n>=k))
   cout<<"0";
 else 
 {long long int h=INT_MAX;
  do
  {if(h>abs(n-k))
  {h=abs(n-k);
   n=n-k;}}
   while(h<(abs(n-k)));
   cout<<h;}
}

Compiler output:
a.cc:4:1: error: expected unqualified-id before '{' token
    4 | {long long int n,k;
      | ^
Language: C

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

int min(int x, int y){
    if(x < y){
        return x;
    }else{
        return y;
    }
}

int main(int argc, char const *argv[])
{
    int n,k;
    scanf("%d %d",&n,&k);

    if(k == 1){
        printf("%d",0);
    }else if(n % k == 0 && n > k){
        printf("%d",0);
    }else if(n == k){
        printf("%d",0);
    }else{
        int i,minx,premin,tmp;
        tmp = n;
        minx = n;
        premin = n;

        for(i=0;i < 100;i++){
            tmp = fabs(tmp - k);
            minx = min(minx,tmp);
            if(minx == 0 || premin == tmp){
                printf("%d",tmp);
                return 0;
            }else{
                premin = minx;
            }
        }
        if(i > 100){
            printf("%d",tmp)
        }
    }
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:40:29: error: expected ';' before '}' token
   40 |             printf("%d",tmp)
      |                             ^
      |                             ;
   41 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int substract(int a,int b){//差の絶対値　3項演算
  int num=(a-b);
  return (num > 0) ? num : -num;}
int main() {
  long long N,K,m;
  cin>>N>>K;
  m=N;

  }
  if(N%K==0){
    cout<<0;
    return 0;
  }
    m=N%K;
    if(m<substract(m,K)){
      cout<<m;
      return 0;
    }
    else{
      m=substract(m,K);
      cout<<m;
  }
}
      
  


Compiler output:
a.cc:12:3: error: expected unqualified-id before 'if'
   12 |   if(N%K==0){
      |   ^~
a.cc:16:5: error: 'm' does not name a type; did you mean 'tm'?
   16 |     m=N%K;
      |     ^
      |     tm
a.cc:17:5: error: expected unqualified-id before 'if'
   17 |     if(m<substract(m,K)){
      |     ^~
a.cc:21:5: error: expected unqualified-id before 'else'
   21 |     else{
      |     ^~~~
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^
Language: C++

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

using namespace std;

int main() {
    int n , k = 0 ;
    int min , temp;
    cin >> n >> k;
    min = n;
    temp = n;
    if (n % k ==0 ){
        min = 0;
    }
    n = n % k;
    else {
    for (int i = 0; i < 1000; i++){
        temp = abs(temp - k);
        if (temp < min) {
            min = temp;
        }

    }
    }
    cout << min << endl;
}



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

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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: expected ';' before 'if'
    8 |   x = n%k
      |          ^
      |          ;
    9 |   if (n>k-n){
      |   ~~      
a.cc:12:3: error: 'else' without a previous 'if'
   12 |   else {
      |   ^~~~