Language: C++

#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
int main()
{
	sync;
	ll x, k, d;
	cin >> x >> k >> d;
	ll ans = abs(x);
	k = min(k, 1e17 / d + 1);
	if(x < 0)
		d = abs(d);
	if(x > 0)
		d = -abs(d);
	ll low = k & 1, high = (k + 1) / 2;
	while(low <= high)
	{
		ll mid = (low + high) / 2, pt = 2 * mid;
		if(k & 1)
			pt--;
		ll pos = x + pt * d;
		if(1e16 / pt  <= abs(d))
			pos = (d > 0 ? 1e18 : -1e18);
		if(x < 0 && pos <= 0)
		{
			ans = min(ans, abs(pos));
			low = mid + 1;
		}
		else if(x > 0 && pos >= 0)
		{
			
			ans = min(ans, abs(pos));
			low = mid + 1;
		}
		else
			high = mid - 1;
			
	}
	low = k & 1, high = (k + 1) / 2;
	while(low <= high)
	{
		ll mid = (low + high) / 2, pt = 2 * mid;
		if(k & 1)
			pt--;
		ll pos = x + pt * d;
		if(1e16 / pt  <= abs(d))
			pos = (d > 0 ? 1e18 : -1e18);	
		if(x < 0 && pos >= 0)
		{
			ans = min(ans, abs(pos));
			high = mid - 1;
		}
		else if(x > 0 && pos <= 0)
		{
			
			ans = min(ans, abs(pos));
			high = mid - 1;
		}
		else
			low = mid + 1;
			
	}
	cout << ans;
}
	

Compiler output:
a.cc: In function 'int main()':
a.cc:26:16: error: no matching function for call to 'min(ll&, double)'
   26 |         k = min(k, 1e17 / d + 1);
      |             ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:26:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   26 |         k = min(k, 1e17 / d + 1);
      |             ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:26:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |         k = min(k, 1e17 / d + 1);
      |             ~~~^~~~~~~~~~~~~~~~~