Language: C++

#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int1024_t X, K, D;
  cin >> X >> K >> D;
  if (K%2==0) {
    vector<int1024_t> P(K+1);
    for (int1024_t i=0; i<=K/2; i++) {
      P[i]=abs(X+i*2*D);
    }
    for (int1024_t i=1; i<=K/2; i++) {
      P[i+K/2]=abs(X-i*2*D);
    }
    sort(P.begin(),P.end());
    cout << P[0] << endl;
  }
  else {
    vector<int1024_t> P(K+1);
    for (int1024_t i=0; i<=(K-1)/2; i++) {
      P[i]=abs(X+(2*i+1)*D);
    }
    for (int1024_t i=0; i<=(K-1)/2; i++) {
      P[i+(K-1)/2]=abs(X-(2*i+1)*D);
    }
    sort(P.begin(),P.end());
    cout << P[0] << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:3: error: 'int1024_t' was not declared in this scope; did you mean 'int64_t'?
   21 |   int1024_t X, K, D;
      |   ^~~~~~~~~
      |   int64_t
a.cc:22:10: error: 'X' was not declared in this scope
   22 |   cin >> X >> K >> D;
      |          ^
a.cc:22:15: error: 'K' was not declared in this scope
   22 |   cin >> X >> K >> D;
      |               ^
a.cc:22:20: error: 'D' was not declared in this scope
   22 |   cin >> X >> K >> D;
      |                    ^
a.cc:24:21: error: template argument 2 is invalid
   24 |     vector<int1024_t> P(K+1);
      |                     ^
a.cc:25:19: error: expected ';' before 'i'
   25 |     for (int1024_t i=0; i<=K/2; i++) {
      |                   ^~
      |                   ;
a.cc:25:25: error: 'i' was not declared in this scope
   25 |     for (int1024_t i=0; i<=K/2; i++) {
      |                         ^
a.cc:28:19: error: expected ';' before 'i'
   28 |     for (int1024_t i=1; i<=K/2; i++) {
      |                   ^~
      |                   ;
a.cc:28:25: error: 'i' was not declared in this scope
   28 |     for (int1024_t i=1; i<=K/2; i++) {
      |                         ^
a.cc:31:12: error: request for member 'begin' in 'P', which is of non-class type 'int'
   31 |     sort(P.begin(),P.end());
      |            ^~~~~
a.cc:31:22: error: request for member 'end' in 'P', which is of non-class type 'int'
   31 |     sort(P.begin(),P.end());
      |                      ^~~
a.cc:32:14: error: invalid types 'int[int]' for array subscript
   32 |     cout << P[0] << endl;
      |              ^
a.cc:35:21: error: template argument 2 is invalid
   35 |     vector<int1024_t> P(K+1);
      |                     ^
a.cc:36:19: error: expected ';' before 'i'
   36 |     for (int1024_t i=0; i<=(K-1)/2; i++) {
      |                   ^~
      |                   ;
a.cc:36:25: error: 'i' was not declared in this scope
   36 |     for (int1024_t i=0; i<=(K-1)/2; i++) {
      |                         ^
a.cc:39:19: error: expected ';' before 'i'
   39 |     for (int1024_t i=0; i<=(K-1)/2; i++) {
      |                   ^~
      |                   ;
a.cc:39:25: error: 'i' was not declared in this scope
   39 |     for (int1024_t i=0; i<=(K-1)/2; i++) {
      |                         ^
a.cc:42:12: error: request for member 'begin' in 'P', which is of non-class type 'int'
   42 |     sort(P.begin(),P.end());
      |            ^~~~~
a.cc:42:22: error: request for member 'end' in 'P', which is of non-class type 'int'
   42 |     sort(P.begin(),P.end());
      |                      ^~~
a.cc:43:14: error: invalid types 'int[int]' for array subscript
   43 |     cout << P[0] << endl;
      |              ^