Language: C++

#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000
#define INF 1000000 
#define M 1000000007
using namespace std;
/*
bool isPowerOfTwo(ll x){
    return (x && !(x & (x - 1)));
}
// counts no. of 1 in binary representation
ll count_one (ll n){
    ll count = 0;
    while( n ){
        n = n&(n-1);
        count++;
    }
    return count;
}
// checks ith bit is set 
bool is_bit_set(ll n ,ll i){
    if( n & (1<<i) ){
        return true;
    }
    else{
        return false;
    }
}
// generating subset using bit technique ; n -> no. of elements
void subset(char a[], ll n){
   for(ll i = 0;i < (1<<n);i++){
         for(ll j = 0;j<n;j++){
             if(i & (1 << j)){
                 cout<<a[j]<<" ";
             }
         }
         cout<<endl;
   }
}
// Properties  of Modular:
//  1. (a+b)%c = (a%c + b%c)%c
//  2. (a*b)%c = (a%c * b%c)%c
//  3. (a-b)%c = (a%c - b%c)%c
//  4. (a/b)%c = ((a%c) * ( inverse(b)%c ))%c

ll binaryExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
ll modularExponentiation(ll x,ll n,ll m)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)% m;
        n=n/2;
    }
    return result;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else{
        return gcd(b,a%b);
    }
}
ll d, x, y;
void extendedEuclid(ll A, ll B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        extendedEuclid(B, A%B);
        ll temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}
// when a and m are co prime
ll modInverse(ll A, ll m){
    extendedEuclid(A,m);
    return (x%m+m)%m;   
}
ll countDivisors(ll n) 
{ 
    int cnt = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
            else 
                cnt = cnt + 2; 
        } 
    }
    return cnt; 
} 
*/
int main(){
    FAST
    ll x,k,d;
    cin>>x>>k>>d;
    if(x == 0){
        if(k%2 == 0){
           cout<<0<<endl;
        }
        else{
           cout<d<<endl;
        }
    }
    else{
        ll y = ceil( (long double ) x/ (long double)d );
        ll y1 = x/d;
        if(y > k){
            y = k;
        }
        if(y1 > k){
            y1 = k;
        }
        ll h = y1*d;
        ll c = y*d;
        ll ans = abs(x-c);
        ll ans1 = abs(x-h);
        if(ans1 < ans){
            ll u = k-y1;
            if(u%2 != 0){
                ans1 = min(abs(ans1+d),abs(ans1-d));
            }
            cout<<ans1<<endl;
        }
        else{
            ll u = k-y;
            if(u%2 != 0){
                ans = min(abs(ans+d),abs(ans-d));
            }
            cout<<ans<<endl;
        }
    }
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:120:18: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<<'
  120 |            cout<d<<endl;
      |                 ~^~~~~~