Language: C++

#include <bits/stdc++.h>


int main(){
    ll X, K, D;
    ll x, cnt;
    cin >> X >> K >> D;
    X = abs(X);
    if(X/D>K){
        cout << X-K*D << endl;
        return 0;
    }
    else{
        cnt = X/D;
        x = X-(cnt+1)*D;
    }
    if((K-cnt+1)%2) cout << abs(x+D) << endl;
    else cout << abs(x) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'll' was not declared in this scope
    5 |     ll X, K, D;
      |     ^~
a.cc:6:7: error: expected ';' before 'x'
    6 |     ll x, cnt;
      |       ^~
      |       ;
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |     cin >> X >> K >> D;
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 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:7:12: error: 'X' was not declared in this scope
    7 |     cin >> X >> K >> D;
      |            ^
a.cc:7:17: error: 'K' was not declared in this scope
    7 |     cin >> X >> K >> D;
      |                 ^
a.cc:7:22: error: 'D' was not declared in this scope
    7 |     cin >> X >> K >> D;
      |                      ^
a.cc:10:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   10 |         cout << X-K*D << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:10:26: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   10 |         cout << X-K*D << endl;
      |                          ^~~~
      |                          std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:14:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   14 |         cnt = X/D;
      |         ^~~
      |         int
a.cc:15:9: error: 'x' was not declared in this scope
   15 |         x = X-(cnt+1)*D;
      |         ^
a.cc:17:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
   17 |     if((K-cnt+1)%2) cout << abs(x+D) << endl;
      |           ^~~
      |           int
a.cc:17:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   17 |     if((K-cnt+1)%2) cout << abs(x+D) << endl;
      |                     ^~~~
      |                     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:17:33: error: 'x' was not declared in this scope
   17 |     if((K-cnt+1)%2) cout << abs(x+D) << endl;
      |                                 ^
a.cc:17:41: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   17 |     if((K-cnt+1)%2) cout << abs(x+D) << endl;
      |                                         ^~~~
      |                                         std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:18:10: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |     else cout << abs(x) << endl;
      |          ^~~~
      |          std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:18:22: error: 'x' was not declared in this scope
   18 |     else cout << abs(x) << endl;
      |                      ^
a.cc:18:28: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   18 |     else cout << abs(x) << endl;
      |                            ^~~~
      |                            std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~