Language: C++

import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long K = sc.nextLong();
		long D = sc.nextLong();
		sc.close();
		long c = 0;
		long x_ = X;
		c = (-(X % D) + x_) / D;
		x_ -= D*c;
		if(c==K){
			System.out.println(Math.abs(x_));
		}else if(c<0){
			x_ += D*(c*(-1));
			System.out.println(Math.abs(x_));
		}else{
			if((K-c) % 2 == 0){
				System.out.println(Math.abs(x_));
			}else{
				if(x_>0){
					System.out.println(Math.abs(x_-D));
				}else{
					System.out.println(Math.abs(x_+D));
				}
			}
		}
	}
}



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:15: error: expected ':' before 'static'
    4 |         public static void main(String[] args) {
      |               ^~~~~~~
      |               :
a.cc:4:33: error: 'String' has not been declared
    4 |         public static void main(String[] args) {
      |                                 ^~~~~~
a.cc:4:42: error: expected ',' or '...' before 'args'
    4 |         public static void main(String[] args) {
      |                                          ^~~~
a.cc:31:2: error: expected ';' after class definition
   31 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:5:17: error: 'Scanner' was not declared in this scope
    5 |                 Scanner sc = new Scanner(System.in);
      |                 ^~~~~~~
a.cc:6:26: error: 'sc' was not declared in this scope
    6 |                 long X = sc.nextLong();
      |                          ^~
a.cc:15:25: error: 'System' was not declared in this scope
   15 |                         System.out.println(Math.abs(x_));
      |                         ^~~~~~
a.cc:15:44: error: 'Math' was not declared in this scope
   15 |                         System.out.println(Math.abs(x_));
      |                                            ^~~~
a.cc:18:25: error: 'System' was not declared in this scope
   18 |                         System.out.println(Math.abs(x_));
      |                         ^~~~~~
a.cc:18:44: error: 'Math' was not declared in this scope
   18 |                         System.out.println(Math.abs(x_));
      |                                            ^~~~
a.cc:21:33: error: 'System' was not declared in this scope
   21 |                                 System.out.println(Math.abs(x_));
      |                                 ^~~~~~
a.cc:21:52: error: 'Math' was not declared in this scope
   21 |                                 System.out.println(Math.abs(x_));
      |                                                    ^~~~
a.cc:24:41: error: 'System' was not declared in this scope
   24 |                                         System.out.println(Math.abs(x_-D));
      |                                         ^~~~~~
a.cc:24:60: error: 'Math' was not declared in this scope
   24 |                                         System.out.println(Math.abs(x_-D));
      |                                                            ^~~~
a.cc:26:41: error: 'System' was not declared in this scope
   26 |                                         System.out.println(Math.abs(x_+D));
      |                                         ^~~~~~
a.cc:26:60: error: 'Math' was not declared in this scope
   26 |                                         System.out.println(Math.abs(x_+D));
      |                                                            ^~~~