Language: C++

#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define ls x << 1
#define rs x << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
ll dfs(ll a,ll b)
{
	if(a > b) swap(a, b);
	if(b % a == 0) return (a * ((b / a) * 2 - 1));
	ll res = get(a, b % a) + (a + a) * (b / a);
	return res;
}

ll n,x;
int main(void)
{
	scanf("%lld%lld", &n, &x);
	if(n == x * 2) printf("%lld\n", x * 3);
	else
	{
		ll ans = 0;
		if(x * 2 < n)
		{
			ans = x + (n - x) + x + x;
			ans += dfs(x, n - 2 * x);
		}
		else
		{
			ans = x + n - x;
			ans += dfs(x, n - x);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Compiler output:
a.cc: In function 'long long int dfs(long long int, long long int)':
a.cc:29:21: error: no matching function for call to 'get(long long int&, long long int)'
   29 |         ll res = get(a, b % a) + (a + a) * (b / a);
      |                  ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
 1250 |     get(pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
 1255 |     get(pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
 1260 |     get(const pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
 1265 |     get(const pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
 2445 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2445:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
 2451 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2451:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
 2457 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2457:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
 2466 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2466:5: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/functional:65,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/array:390:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
  390 |     get(array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/14/array:390:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:399:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
  399 |     get(array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/14/array:399:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:408:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)'
  408 |     get(const array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/14/array:408:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/array:417:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)'
  417 |     get(const array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/14/array:417:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
 1272 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
 1277 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)'
 1282 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1282:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)'
 1287 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1287:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)'
 1292 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)'
 1297 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)'
 1302 |     get(pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1302:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)'
 1307 |     get(const pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1307:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2476:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&)' (deleted)
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
/usr/include/c++/14/tuple:2476:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2483:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_Elements ...>&)'
 2483 |     get(tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2483:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2494:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_Elements ...>&&)'
 2494 |     get(tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2494:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2505:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_Elements ...>&)'
 2505 |     get(const tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2505:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2517:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_Elements ...>&&)'
 2517 |     get(const tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2517:5: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80:
/usr/include/c++/14/variant:1715:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(variant<_Types ...>&)'
 1715 |     get(variant<_Types...>& __v)
      |     ^~~
/usr/include/c++/14/variant:1715:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/variant:1726:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(variant<_Types ...>&&)'
 1726 |     get(variant<_Types...>&& __v)
      |     ^~~
/usr/include/c++/14/variant:1726:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/variant:1737:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const variant<_Types ...>&)'
 1737 |     get(const variant<_Types...>& __v)
      |     ^~~
/usr/include/c++/14/variant:1737:5: note:   candidate expects 1 argument, 2 p