Language: C++

#include <iostream>                                                                                                                      
#include <vector>                                                                                                                        
#include <algorithm>                                                                                                                     
using namespace std;                                                                                                                     
                                                                                                                                         
int main() {                                                                                                                             
  long long X, K, D;                                                                                                                     
  cin >> X >> K >> D;                                                                                                                    
                                                                                                                                         
  long long tmp = abs(X) - K*D;                                                                                                          
  long long check = 0;                                                                                                                   
                                                                                                                                         
  if (tmp >= 0) min = abs(X) - K*D;                                                                                                      
  else {                                                                                                                                 
    for (int i = 1; i <= K; i++) {                                                                                                       
      tmp = abs(X) - i*D;                                                                                                                
      if (tmp < 0) {check = i; break;}                                                                                                   
    }                                                                                                                                    
    //cout << "check:" << check << endl;                                                                                                 
    if (K - check % 2 == 0) tmp = tmp + D;                                                                                               
    else tmp = tmp;                                                                                                                      
                                                                                                                                         
  }                                                                                                                                      
                                                                                                                                         
                                                                                                                                         
  cout << abs(tmp) << endl;                                                                                                              
                                                                                                                                         
  return 0;                                                                                                                              
}                                                                                                                                        
                                                                                                                                         
                                                                                                                                         
                                                                                                                                         
                                                                                                                                         
                      

Compiler output:
a.cc: In function 'int main()':
a.cc:13:34: error: overloaded function with no contextual type information
   13 |   if (tmp >= 0) min = abs(X) - K*D;
      |                                  ^