Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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


#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    mem(a)       memset(a,0,sizeof(a))
const ll mod = 1000000007;

void fio()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
}

template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}


//BFS CODE===================================================================

const int N = 2e6 + 5;

vector<ll> adj[N];
bool visited[N];
ll val[N];
ll depth[N];
ll parent[N];


void clear_all() {
    for (auto& v : adj) {
        v.clear();
    }
    mem(visited);
    mem(val);
    mem(depth);
    mem(parent);
   
}


 
 
void bfs(ll s) {
    queue<ll> q;
    q.push(s);
    visited[s] = true;
    depth[s] = 0;
    while (!q.empty()) {
        ll v = q.front();
        q.pop();
        for (ll u : adj[v]) {
            if (!visited[u]) {
                visited[u] = true;
                parent[u] = v;
                q.push(u);
                depth[u] = depth[v] + 1;
            }
        }
    }
}


void dfs(ll v) {
    visited[v] = true;
    for (ll u : adj[v]) {
        if (!visited[u])
            dfs(u);
    }
}


// left shift << multiply by 2
// right shift >> divide by 2


//MODULAR EXPONENTION (pow(x,y)%p)=========================================================================
ll modexp(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result; 
} 


bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
} 





void solve(){
    __rintf64 x,d,k,f,c, ans,moves;

    cin>>x>>k>>d;

    f = x/d;

    // cout<<f<<'\n';
    c= f+1;



    if(k<=f)
    {
        if(x<=0){
            ans = x+ k*d;
            cout<<abs(ans);
        }
        else{
            ans = x - k*d;
            cout<<abs(ans);
        }
    }else{
            int e = (k-f)%2;
            if(e==0){

                if(x<=0){
                ans = x+ f*d;
                cout<<abs(ans);
            }
            else{
                ans = x - f*d;
                cout<<abs(ans);
            }

            }else{

                if(x<=0){
                ans = x+ c*d;
                cout<<abs(ans);
            }
            else{
                ans = x - c*d;
                cout<< abs(ans);
            }

        }

    }




}


int main()
{
    // auto start = chrono::high_resolution_clock::now();
    boost;
    fio();
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    
      
    // auto end = chrono::high_resolution_clock::now();
    // TIME(start, end);
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:137:14: error: expected ';' before 'x'
  137 |     __rintf64 x,d,k,f,c, ans,moves;
      |              ^~
      |              ;
a.cc:139:10: error: 'x' was not declared in this scope
  139 |     cin>>x>>k>>d;
      |          ^
a.cc:139:13: error: 'k' was not declared in this scope
  139 |     cin>>x>>k>>d;
      |             ^
a.cc:139:16: error: 'd' was not declared in this scope
  139 |     cin>>x>>k>>d;
      |                ^
a.cc:141:5: error: 'f' was not declared in this scope
  141 |     f = x/d;
      |     ^
a.cc:144:5: error: 'c' was not declared in this scope
  144 |     c= f+1;
      |     ^
a.cc:151:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
  151 |             ans = x+ k*d;
      |             ^~~
      |             abs
a.cc:155:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
  155 |             ans = x - k*d;
      |             ^~~
      |             abs
a.cc:163:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  163 |                 ans = x+ f*d;
      |                 ^~~
      |                 abs
a.cc:167:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  167 |                 ans = x - f*d;
      |                 ^~~
      |                 abs
a.cc:174:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  174 |                 ans = x+ c*d;
      |                 ^~~
      |                 abs
a.cc:178:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  178 |                 ans = x - c*d;
      |                 ^~~
      |                 abs