#include //#include using namespace std; // using namespace atcoder; // using mint = modint1000000007; // const int mod = 1000000007; // using mint = modint998244353; // const int mod = 998244353; // const int INF = 1e9; // const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i, l, r) for (int i = (l); i < (r); ++i) #define rrep(i, n) for (int i = (n)-1; i >= 0; --i) #define rrep2(i, l, r) for (int i = (r)-1; i >= (l); --i) #define all(x) (x).begin(), (x).end() #define allR(x) (x).rbegin(), (x).rend() #define P pair template inline bool chmax(A &a, const B &b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A &a, const B &b) { if (a > b) { a = b; return true; } return false; } #ifndef KWM_T_ALGORITHM_SEARCH_BINARYSEARCH_HPP #define KWM_T_ALGORITHM_SEARCH_BINARYSEARCH_HPP #include namespace kwm_t::algorithm::search { /** * @brief 二分探索 (整数) * * @details * 単調性を持つ述語 f(x) に対して、f(x)=true となる境界を探索する。 * 初期状態で ok は true、ng は false を満たしている必要がある。 * * Typical Use: * 最大/最小の条件を満たす整数を探す * * Complexity: * Time: O(log |ok-ng|) * * Template Parameters: * T : 整数型 (int / long long など) * F : bool f(T) を返す関数オブジェクト * * Parameters: * ok : 条件を満たす値 * ng : 条件を満たさない値 * f : 判定関数 * * Return: * 条件を満たす境界値 * * Requirements: * f(ok) == true * f(ng) == false * * Notes: * ok と ng の大小関係は問わない * * Example: * ```cpp * auto f = [&](long long x){ * return x * x <= 100; * }; * * long long ans = binarySearch(0LL, 11LL, f); * ``` * * Verified: * */ template T binarySearch(T ok, T ng, const F &f) { while (std::abs(ok - ng) > 1) { T mid = (ok + ng) / 2; (f(mid) ? ok : ng) = mid; } return ok; } /** * @brief 二分探索 (実数) * * @details * 実数値に対する二分探索。 * 回数固定で探索を行う。 * * Typical Use: * 実数解の近似探索 * * Complexity: * Time: O(counter) * * Template Parameters: * T : 浮動小数点型 (double / long double) * F : bool f(T) を返す関数オブジェクト * * Parameters: * ok : 条件を満たす値 * ng : 条件を満たさない値 * f : 判定関数 * counter : 反復回数 * * Return: * 条件を満たす近似値 * * Requirements: * f(ok) == true * f(ng) == false * * Example: * ```cpp * auto f = [&](double x){ * return x * x <= 2.0; * }; * * double ans = binarySearchDouble(0.0, 2.0, f); * ``` * * Verified: * */ template T binarySearchDouble(T ok, T ng, const F &f, int counter = 100) { while (counter--) { T mid = (ok + ng) / 2; (f(mid) ? ok : ng) = mid; } return ok; } } // namespace kwm_t::algorithm::search #endif // KWM_T_ALGORITHM_SEARCH_BINARYSEARCH_HPP #ifdef _MSC_VER using int128 = long long; #else using int128 = __int128; #endif long long solve(long long a, long long b, long long c, long long n) { auto f = [&](const long long x) { long long p = x / b; long long q = x % b; int128 f = a; int128 e = a + (int128)c * (p - 1); int128 val = (f + e) * p / 2 * b; if (q) { e += c; val += e * (int128)q; } return val >= (int128)n; }; auto val = kwm_t::algorithm::search::binarySearch(n + 1, 0, f); return val; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); long long n; cin >> n; long long a, b, c; cin >> a >> b >> c; long long d, e, f; cin >> d >> e >> f; auto dx = solve(a, b, c, n); auto dy = solve(d, e, f, n); //cout << dx << " " << dy << endl; if (dx < dy)cout << "KCPC" << endl; else if (dx > dy)cout << "KUPC" << endl; else cout << "Same" << endl; return 0; }