buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
X, K, D = map(int, input().split()) ans = None if K*D <= abs(X): print(abs(X)-abs(K*D)) else: times0 = abs(X) // D X = abs(X) - times0 * D K -= times0 if times0 % 2 == 0: print(X) else: print(abs(X-D))
X, K, D = map(int, input().split()) ans = None if K*D <= abs(X): print(abs(X)-abs(K*D)) else: times0 = abs(X) // D X = abs(X) - times0 * D K -= times0 if K % 2 == 0: print(X) else: print(abs(X-D))
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22]]
5
90
#include <bits/stdc++.h> #define int long long typedef long long ll; using namespace std; const ll MAX = 200000; const ll INF = 1001001001; const ll MOD = 1000000007; const double PI = 3.1415926535897932; ll X, K, D, ans = 0, tmp = 0; vector<ll> A; signed main() { cin >> X >> K >> D; tmp = X % D; if (tmp < 0) ...
#include <bits/stdc++.h> #define int long long typedef long long ll; using namespace std; const ll MAX = 200000; const ll INF = 1001001001; const ll MOD = 1000000007; const double PI = 3.1415926535897932; ll X, K, D, ans = 0, tmp = 0; vector<ll> A; signed main() { cin >> X >> K >> D; tmp = X % D; if (tmp < 0) ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
206
x, k, d = map(int,input().split()) if (x // d) > k: print(x - k*d) else: if (k - (x // d)) % 2 == 0: print(x % d) else: print(d - (x % d))
x, k, d = map(int,input().split()) x = abs(x) if (x // d) > k: print(x - k*d) else: if (k - (x // d)) % 2 == 0: print(x % d) else: print(d - (x % d))
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
70
import sys import math x, k, d = map(int, input().split()) a = x-k*d b = x+k*d if(a >= 0): print(abs(a)) elif(b <= 0): print(b) else: b = b % (d * 2) print(min(abs(b), abs(b - d * 2)))
import sys import math x, k, d = map(int, input().split()) a = x-k*d b = x+k*d if(a >= 0): print(a) elif(b <= 0): print(abs(b)) else: b = b % (d * 2) print(min(abs(b), abs(b - d * 2)))
[["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
91
#include <stdio.h> int main() { long long int X, K, D; scanf("%lld %lld %lld", &X, &K, &D); if (X < 0LL) X = -X; if (X >= K * D) X -= K * D; else { long long int Y = X / D; K -= Y; X -= Y * D; if (K % 2LL == 1LL) X = D - X; } printf("%lld\n", X); return 0; }
#include <stdio.h> int main() { long long int X, K, D; scanf("%lld %lld %lld", &X, &K, &D); if (X < 0LL) X = -X; if (X / D >= K) X -= K * D; else { long long int Y = X / D; K -= Y; X -= Y * D; if (K % 2LL == 1LL) X = D - X; } printf("%lld\n", X); return 0; }
[["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 22]]
0
107
x,k,d=map(int,input().split()) if abs(x)>=k*d: print(abs(x)-k*d) else: t=abs(x)%d n=k-x//d if n%2==0: print(t) else: print(abs(t-d))
x,k,d=map(int,input().split()) if abs(x)>=k*d: print(abs(x)-k*d) else: t=abs(x)%d n=k-abs(x)//d if n%2==0: print(t) else: print(abs(t-d))
[["+", 0, 662, 12, 657, 12, 657, 31, 652, 63, 22], ["+", 12, 657, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 12, 657, 12, 657, 31, 652, 3, 4, 0, 25]]
5
78
x,k,d = map(int,input().split()) passSinaiCount = abs(x)//d if passSinaiCount >= k: print(abs(x) - k*d) exit() passSinaiDistance = x - passSinaiCount * d passSuruDistance = d - passSinaiDistance nokoriCount = k - passSinaiCount if nokoriCount % 2 == 0: print(passSinaiDistance) else: print(passSuruD...
x,k,d = map(int,input().split()) passSinaiCount = abs(x)//d if passSinaiCount >= k: print(abs(x) - k*d) exit() passSinaiDistance = abs(x) - passSinaiCount * d passSuruDistance = d - passSinaiDistance nokoriCount = k - passSinaiCount if nokoriCount % 2 == 0: print(passSinaiDistance) else: print(pass...
[["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]]
5
79
# -*- coding: utf-8 -*- X, K, D = map(int, input().split()) quotient = X // D if quotient >= K: print(X - K * D) else: X -= quotient * D K -= quotient if K % 2 == 0: print(X) else: print(abs(X - D))
# -*- coding: utf-8 -*- X, K, D = map(int, input().split()) X = abs(X) quotient = X // D if quotient >= K: print(X - K * D) else: X -= quotient * D K -= quotient if K % 2 == 0: print(X) else: print(abs(X - D))
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
69
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Main { static BufferedReader br; static int cin() throws Exception { return Integer.valueOf(br.readLine().replaceAll("\\s", "")); } sta...
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Main { static BufferedReader br; static int cin() throws Exception { return Integer.valueOf(br.readLine().replaceAll("\\s", "")); } sta...
[["+", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 0, 131], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 24], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 25]]
3
486
#include <algorithm> #include <bits/stdc++.h> #include <iomanip> #include <iostream> #include <math.h> #include <set> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; int main(void) { long long int x, k, d; cin >> x >> k >> d; if (x == 0) { if (k % 2 == 0) { ...
#include <algorithm> #include <bits/stdc++.h> #include <iomanip> #include <iostream> #include <math.h> #include <set> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; int main(void) { long long int x, k, d; cin >> x >> k >> d; if (x == 0) { if (k % 2 == 0) { ...
[["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
240
#include <bits/stdc++.h> using namespace std; long long x, k, d; int main() { scanf("%lld%lld%lld", &x, &k, &d); x = abs(x); if (x > k * d) printf("%lld\n", x - k * d); else printf("%lld\n", x / d & 1 ^ k & 1 ? (x / d + 1) * d - x : x % d); return 0; }
#include <bits/stdc++.h> using namespace std; long long x, k, d; int main() { scanf("%lld%lld%lld", &x, &k, &d); x = abs(x); if (x / d >= k) printf("%lld\n", x - k * d); else printf("%lld\n", x / d & 1 ^ k & 1 ? (x / d + 1) * d - x : x % d); return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
103
import copy import math import time import statistics import math import itertools import bisect from decimal import * # a = get_int() def get_int(): return int(input()) # a = get_string() def get_string(): return input() # a_list = get_int_list() def get_int_list(): return [int(x) for x in input().split()...
import copy import math import time import statistics import math import itertools import bisect from decimal import * # a = get_int() def get_int(): return int(input()) # a = get_string() def get_string(): return input() # a_list = get_int_list() def get_int_list(): return [int(x) for x in input().split()...
[["+", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
217
#include <bits/stdc++.h> #define re register #define int long long using namespace std; int n, a[100002], b, head[10002], cnt, ans, m, x, k, d; inline int read() { re int t = 0; re char v = getchar(); while (v < '0') v = getchar(); while (v >= '0') t = (t << 3) + (t << 1) + v - 48, v = getchar(); retu...
#include <bits/stdc++.h> #define re register #define int long long using namespace std; int n, a[100002], b, head[10002], cnt, ans, m, x, k, d; inline int read() { re int t = 0; re char v = getchar(); while (v < '0') v = getchar(); while (v >= '0') t = (t << 3) + (t << 1) + v - 48, v = getchar(); retu...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
195
#include <stdio.h> long long MIN(long long a, long long b) { return a < b ? a : b; } int main() { long long n, m, d; scanf("%lld %lld %lld", &n, &m, &d); if (n < 0) n = -n; if (n / m > d) { printf("%lld\n", n - (m * d)); return 0; } m -= n / d; n %= d; // printf("%lld %lld\n",d,n); printf("%...
#include <stdio.h> long long MIN(long long a, long long b) { return a < b ? a : b; } int main() { long long n, m, d; scanf("%lld %lld %lld", &n, &m, &d); if (n < 0) n = -n; if (n / d > m) { printf("%lld\n", n - (m * d)); return 0; } m -= n / d; n %= d; // printf("%lld %lld\n",d,n); printf("%...
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22]]
0
127
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long x = sc.nextLong(); long k = sc.nextLong(); long d = sc.nextLong(); sc.close(); if (x / d > k) { System.out.println(x - d * k); } else { long yono = x / d; ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long x = Math.abs(sc.nextLong()); long k = sc.nextLong(); long d = sc.nextLong(); sc.close(); if (x / d > k) { System.out.println(x - d * k); } else { long yono...
[["+", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 0, 131], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 24], ["+", 51, 492, 3, 4, 0, 492, 3, 4, 0, 25]]
3
144
#include <bits/stdc++.h> using namespace std; #pragma region void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print...
#include <bits/stdc++.h> using namespace std; #pragma region void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print...
[["+", 64, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22]]
1
623
X, K, D = map(int, input().split()) aX = abs(X) if aX >= K * D: ans = aX - K * D else: x = aX % D k = aX // D ans = x if k % 2 == 0 else D - x print(ans)
X, K, D = map(int, input().split()) aX = abs(X) if aX >= K * D: ans = aX - K * D else: x = aX % D k = K - aX // D ans = x if k % 2 == 0 else D - x print(ans)
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33]]
5
67
#include <bits/stdc++.h> using namespace std; using ll = long long; ll md = 1000000007; typedef vector<vector<ll>> vvl; typedef vector<ll> vl; vl p, B, fac(2, 1), ifac(2, 1); ll ad(ll a, ll b, ll mod = md) { return (a % mod + b % mod + mod) % mod; } ll ml(ll a, ll b, ll mod = md) { return ((a % mod) * (b % mod)) % mo...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll md = 1000000007; typedef vector<vector<ll>> vvl; typedef vector<ll> vl; vl p, B, fac(2, 1), ifac(2, 1); ll ad(ll a, ll b, ll mod = md) { return (a % mod + b % mod + mod) % mod; } ll ml(ll a, ll b, ll mod = md) { return ((a % mod) * (b % mod)) % mo...
[["+", 51, 2, 3, 4, 0, 16, 31, 2, 63, 22], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25]]
1
1,757
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vii = vector<vector<int>>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const int MOD = 1e9 + 7; template <typename T> boo...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vii = vector<vector<int>>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const int MOD = 1e9 + 7; template <typename T> boo...
[["-", 0, 1, 0, 11, 12, 16, 31, 91, 17, 33]]
1
320
x, k, d = map(int, input().split()) if x > k * d: print(x - k * d) else: k -= x // d print(abs(x % d - k % 2 * d))
x, k, d = map(int, input().split()) x = abs(x) if x > k * d: print(x - k * d) else: k -= x // d print(abs(x % d - k % 2 * d))
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
55
x , k , d= map(int, input().split()) t = abs(x)/d t2 = abs(x)//d if t>=k: print(x-k*d) else: x = abs(x)-t2*d if (k-t2)%2==0: print(x) else: print(d-x)
x , k , d= map(int, input().split()) t = abs(x)/d t2 = abs(x)//d if t>=k: print(abs(x)-k*d) else: x = abs(x)-t2*d if (k-t2)%2==0: print(x) else: print(d-x)
[["+", 0, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]]
5
82
#include <bits/stdc++.h> using namespace std; typedef long long ll; // int/long: -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31) // long/long long: -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 // (-2^63 <= long < 2^63) #define INF (1 << 30) // 1,073,741,824 //= 536,870,912 *2 #define M...
#include <bits/stdc++.h> using namespace std; typedef long long ll; // int/long: -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31) // long/long long: -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 // (-2^63 <= long < 2^63) #define INF (1 << 30) // 1,073,741,824 //= 536,870,912 *2 #define M...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
149
X, K,D = map(int, input().split()) if X >= K * D: print(X - K * D) elif X <= K * (- D): print(abs(X + K * D)) else: if X >= 0: pos = X % D neg = X % D - D if K % 2 == (X // D) % 2: print(pos) else: print(abs(neg)) if X <= 0: pos = D - (abs...
X, K,D = map(int, input().split()) if X >= K * D: print(X - K * D) elif X <= K * (- D): print(abs(X + K * D)) else: if X >= 0: pos = X % D neg = X % D - D if K % 2 == (X // D) % 2: print(pos) else: print(abs(neg)) elif X <= 0: pos = D - (a...
[["-", 0, 57, 75, 76, 8, 196, 0, 57, 0, 121], ["+", 75, 76, 8, 196, 0, 57, 75, 665, 0, 683], ["+", 0, 657, 31, 23, 0, 657, 31, 652, 63, 22], ["+", 31, 23, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 31, 23, 0, 657, 31, 652, 3, 4, 0, 25]]
5
153
X, K, D = map(int,input().split()) if X + K*D < 0: print(abs(X + K*D)) elif X - K*D > 0: print(X - K*D) else: if abs(X)//D%2 == 0: print(abs(abs(X)%D)) else: print(abs(D-abs(X)%D))
X, K, D = map(int,input().split()) if X + K*D < 0: print(abs(X + K*D)) elif X - K*D > 0: print(X - K*D) else: if abs(X)//D%2 == K%2: print(abs(abs(X)%D)) else: print(abs(D-abs(X)%D))
[["-", 75, 76, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 109], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
97
#include <bits/stdc++.h> #define ll long long int using namespace std; void code() { ll x, k, d; cin >> x >> k >> d; if (x > 0) { ll diff = x; ll mov = diff / d; if (k <= mov) { cout << x - k * d << endl; return; } else { ll lft = k - mov; if (lft % 2 == 0) { cout...
#include <bits/stdc++.h> #define ll long long int using namespace std; void code() { ll x, k, d; cin >> x >> k >> d; if (x >= 0) { ll diff = x; ll mov = diff / d; if (k <= mov) { cout << x - k * d << endl; return; } else { ll lft = k - mov; if (lft % 2 == 0) { cou...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
1
250
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef pa...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef pa...
[["+", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 25]]
1
247
X,K,D = map(int,input().split()) ans = 0 if abs(X) > K * D: ans = abs(abs(X) - K * D) else: if (K - (abs(X) // D)) % 2 == 0: ans = abs(abs(X) - (X // D) * D) else: ans = abs(abs(X) - (X // D + 1) * D) print(ans)
X,K,D = map(int,input().split()) ans = 0 if abs(X) > K * D: ans = abs(abs(X) - K * D) else: if (K - (abs(X) // D)) % 2 == 0: ans = abs(abs(X) - (abs(X) // D) * D) else: ans = abs(abs(X) - (abs(X) // D + 1) * D) print(ans)
[["+", 12, 657, 31, 23, 0, 657, 31, 652, 63, 22], ["+", 31, 23, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 31, 23, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 3, 4, 0, 657, 12, 657, 31, 23, 0, 24], ["+", 31, 23, 0, 657, 31, 657, 31, 652, 63, 22], ["+", 0, 657, 31, 657, 31, 652, 3, 4, 0, 25]]
5
106
''' Auther: ghoshashis545 Ashis Ghosh College: jalpaiguri Govt Enggineering College ''' from os import path import sys from functools import cmp_to_key as ctk from collections import deque,defaultdict as dd from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right from itertools impor...
''' Auther: ghoshashis545 Ashis Ghosh College: jalpaiguri Govt Enggineering College ''' from os import path import sys from functools import cmp_to_key as ctk from collections import deque,defaultdict as dd from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right from itertools impor...
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22]]
5
324
#include <bits/stdc++.h> using namespace std; #define ll long long int #define db double #define fl float #define endl '\n' #define mod (ll)(1000000007) #define mod1 (ll)998242353 #define mod2 (ll)998244353 #define PI 3.1415926535897932384626433832795 #define pii pair<int, int> #define pll pair<ll, ll> #define fi fi...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define db double #define fl float #define endl '\n' #define mod (ll)(1000000007) #define mod1 (ll)998242353 #define mod2 (ll)998244353 #define PI 3.1415926535897932384626433832795 #define pii pair<int, int> #define pll pair<ll, ll> #define fi fi...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
600
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define eb emplace_back #define mp make_pair #define mset(x, y) memset((x), (y), sizeof(x)) #define sz(x) ((int)(x).size()) #define rep(i, a, b) for (i = a; i < b; i++) #define per(i, a, b) for (i = a; i >= b; i--) #define all(x) (x).begin...
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define eb emplace_back #define mp make_pair #define mset(x, y) memset((x), (y), sizeof(x)) #define sz(x) ((int)(x).size()) #define rep(i, a, b) for (i = a; i < b; i++) #define per(i, a, b) for (i = a; i >= b; i--) #define all(x) (x).begin...
[["-", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
676
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include ...
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include ...
[["+", 15, 339, 51, 16, 31, 16, 31, 2, 63, 22]]
1
385
x, k, d = map(int, input().split()) x = max(x, -x) if (k * d <= x): print(x-k*d) else: k -= x / d x %= d if k % 2 == 1: print(d-x) else: print(x)
x, k, d = map(int, input().split()) x = max(x, -x) if (k * d <= x): print(x-k*d) else: k -= x // d x %= d if k % 2 == 1: print(d-x) else: print(x)
[["-", 8, 196, 0, 1, 0, 677, 12, 657, 17, 85], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 17, 676]]
5
73
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <stdio.h> using namespace std; #include <vector> #define rep(i, n) for (ll i = 0; i < (n); i++) #define INF 1e9 #define llINF 1e18 #define base10_4 10000 // 1e4 #define base10_5 100000 // 1e5 #define base10_6 1000000 // 1e6 ...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <stdio.h> using namespace std; #include <vector> #define rep(i, n) for (ll i = 0; i < (n); i++) #define INF 1e9 #define llINF 1e18 #define base10_4 10000 // 1e4 #define base10_5 100000 // 1e5 #define base10_6 1000000 // 1e6 ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
298
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("sse4") #include <algorithm> #include <bitset> #include <cassert> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stac...
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("sse4") #include <algorithm> #include <bitset> #include <cassert> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stac...
[["-", 0, 16, 12, 23, 0, 41, 15, 16, 31, 22], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 31, 22]]
1
309
#include <algorithm> #include <cmath> #include <ctime> #include <deque> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <vector> using namespace std; #define int long long int #define rep(i, n) for (int ...
#include <algorithm> #include <cmath> #include <ctime> #include <deque> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <vector> using namespace std; #define int long long int #define rep(i, n) for (int ...
[["-", 0, 43, 49, 50, 51, 16, 12, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 16, 31, 22]]
1
322
#import sys MOD = 10 ** 9 + 7 INFI = 10**10 #input = sys.stdin.readline import math from collections import deque import itertools import heapq #import bisect from fractions import Fraction import copy from functools import lru_cache from collections import defaultdict import pprint #oo=list("ABCDEFGHIJKLMNOPQRSTUVWXY...
#import sys MOD = 10 ** 9 + 7 INFI = 10**10 #input = sys.stdin.readline import math from collections import deque import itertools import heapq #import bisect from fractions import Fraction import copy from functools import lru_cache from collections import defaultdict import pprint #oo=list("ABCDEFGHIJKLMNOPQRSTUVWXY...
[["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]]
5
628
X, K, D = map(int, input().split()) if X // D > K: result = X - D*K else: n = X//D rem_jump = K - n p1 = X % D p2 = D - p1 if rem_jump % 2 == 0: result = p1 else: result = p2 print(result)
X, K, D = map(int, input().split()) X = abs(X) if X // D > K: result = X - D*K else: n = X//D rem_jump = K - n p1 = X % D p2 = D - p1 if rem_jump % 2 == 0: result = p1 else: result = p2 print(result)
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
73
#!/usr/bin/env python3 import collections as cl import sys def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def main(): x, k, d = MI() min_idou = x // d amari = x % d if ...
#!/usr/bin/env python3 import collections as cl import sys def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def main(): x, k, d = MI() x = abs(x) min_idou = x // d amari =...
[["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
146
#include <bits/stdc++.h> using namespace std; void fastio() { cin.tie(nullptr); cin.sync_with_stdio(false); } using LL = long long; using LD = long double; const LL MOD = 1e9 + 7; const LL INF = LLONG_MAX; const LL N = 1e6 + 1; int main() { fastio(); LL x, k, d; cin >> x >> k >> d; if (d < 0) d =...
#include <bits/stdc++.h> using namespace std; void fastio() { cin.tie(nullptr); cin.sync_with_stdio(false); } using LL = long long; using LD = long double; const LL MOD = 1e9 + 7; const LL INF = LLONG_MAX; const LL N = 1e6 + 1; int main() { fastio(); LL x, k, d; cin >> x >> k >> d; if (x < 0) x =...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 12, 91, 28, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 91, 28, 22]]
1
199
// Problem : // C - Walking Takahashi // // // Contest : AtCoder - AtCoder Beginner Contest 175 // URL : https://atcoder.jp/contests/abc175/tasks/abc175_c // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) /* “Whether you think you can, or you t...
// Problem : // C - Walking Takahashi // // // Contest : AtCoder - AtCoder Beginner Contest 175 // URL : https://atcoder.jp/contests/abc175/tasks/abc175_c // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) /* “Whether you think you can, or you t...
[["+", 64, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22]]
1
868
#include "bits/stdc++.h" using namespace std; #define int long long #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i) #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i) #define ALL(a) a.begin(), a.en...
#include "bits/stdc++.h" using namespace std; #define int long long #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i) #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i) #define ALL(a) a.begin(), a.en...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22...
1
1,261
X, K, D = map(int, input().split()) T = X // D if T > K: print(abs(abs(X) - K*D)) else: if (K - T) % 2 == 0: print(abs(abs(X) - T*D)) else: print(abs(abs(X) - (T+1)*D))
X, K, D = map(int, input().split()) T = abs(X) // D if T > K: print(abs(abs(X) - K*D)) else: if (K - T) % 2 == 0: print(abs(abs(X) - T*D)) else: print(abs(abs(X) - (T+1)*D))
[["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]]
5
89
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using ii = pai...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using ii = pai...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
199
X, K, D = map(int, input().split()) now = 0 if abs(X) - abs(D)*K >= 0: now = abs(X) - abs(D)*K print(now) else: t = abs(X) // abs(D) remain = K - t now = abs(X) % abs(D) if t % 2 == 0: print(now) else: print(abs(now - abs(D)))
X, K, D = map(int, input().split()) now = 0 if abs(X) - abs(D)*K >= 0: now = abs(X) - abs(D)*K print(now) else: t = abs(X) // abs(D) remain = K - t now = abs(X) % abs(D) if remain % 2 == 0: print(now) else: print(abs(now - abs(D)))
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22]]
5
107
#ifdef _MSC_VER #include <__msvc_all_public_headers.hpp> #undef min #undef max #else #define NDEBUG #include <bits/stdc++.h> #endif using namespace std; using large = long long; int main() { large x, k, d; cin >> x >> k >> d; x = abs(x); auto n = x / d; x %= d; if (n >= k) { x += (n - k) * d; } e...
#ifdef _MSC_VER #include <__msvc_all_public_headers.hpp> #undef min #undef max #else #define NDEBUG #include <bits/stdc++.h> #endif using namespace std; using large = long long; int main() { large x, k, d; cin >> x >> k >> d; x = abs(x); auto n = x / d; x %= d; if (n >= k) { x += (n - k) * d; } e...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
112
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll INF = 1LL << 60; const double EPS = 1e-10; const ll mod = 1000000007; // const ll mod=998244353; int main(void) { ll x, k, d; cin >> x >> k >> d; x = abs(x); if (k * d <= x) cout << x - k * d << endl; else...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll INF = 1LL << 60; const double EPS = 1e-10; const ll mod = 1000000007; // const ll mod=998244353; int main(void) { ll x, k, d; cin >> x >> k >> d; x = abs(x); if (k <= x / d) cout << x - k * d << endl; else...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
140
#include <algorithm> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; usi...
#include <algorithm> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; usi...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
645
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; signed main() { ll x, k, d; cin >> x >> k >> d; if (x < 0) x =...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; signed main() { ll x, k, d; cin >> x >> k >> d; if (x < 0) x =...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
153
import sys def _ia(): return map(int, sys.stdin.readline().strip().split()) def main(): x, k, d = _ia() xm = x % d n = (x-xm)//d if k >= n: if n % 2 == k % 2: return xm else: return -xm + d else: return x - k * d if __name__ == "__main__": p...
import sys def _ia(): return map(int, sys.stdin.readline().strip().split()) def main(): x, k, d = _ia() x = abs(x) xm = x % d n = (x-xm)//d if k >= n: if n % 2 == k % 2: return xm else: return -xm + d else: return x - k * d if __name__ == "_...
[["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
100
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef pair<int, int> P; int main() { ll X, K, D; cin >> X >> K >> D; ll cnt = (X + D - 1) / D; if (K < cnt) { cnt = K; } if (0 < X) { X -= cnt * D; } else { X += cnt * D; ...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef pair<int, int> P; int main() { ll X, K, D; cin >> X >> K >> D; ll cnt = abs(X) / D; if (K < cnt) { cnt = K; } if (0 < X) { X -= cnt * D; } else { X += cnt * D; } ...
[["+", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22], ["-", 51, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["-", 51, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 17, 33], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 12, 13]]
1
171
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll x, k, d; cin >> x >> k >> d; if (x < 0) { x *= -1; } if (x >= k * d) { cout << x - k * d << endl; return 0; } if ((x / d) % 2 == k % 2) { cout << x % d << endl; } else { cout << d - x % d << endl; ...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll x, k, d; cin >> x >> k >> d; if (x < 0) { x *= -1; } if (x / d >= k) { cout << x - k * d << endl; return 0; } if ((x / d) % 2 == k % 2) { cout << x % d << endl; } else { cout << d - x % d << endl; ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
102
X,K,D = map(int,input().split()) t = X // D if K <= t : print(X-D*K) else : X -= D*t K -= t if K%2 == 0 : print(X) else : print(abs(X-D))
X,K,D = map(int,input().split()) X = abs(X) t = X // D if K <= t : print(X-D*K) else : X -= D*t K -= t if K%2 == 0 : print(X) else : print(abs(X-D))
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
68
#include <algorithm> #include <bits/stdc++.h> #include <chrono> #include <map> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <thread> #include <vector> #define rep(i, n) for (ll i = 0; i < n; i++) #define repu(i, k, n) for (ll i = k; i <= n; i++) #define repd(i, k, n) for (ll i ...
#include <algorithm> #include <bits/stdc++.h> #include <chrono> #include <map> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <thread> #include <vector> #define rep(i, n) for (ll i = 0; i < n; i++) #define repu(i, k, n) for (ll i = k; i <= n; i++) #define repd(i, k, n) for (ll i ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
740
def main(): X, K, D = map(int, input().split()) if abs(X) >= K*D: if X <= 0: print(X+K*D) else: print(X-K*D) else: K -= abs(X) // D if K % 2 == 0: print(abs(X)%D) else: print(D-abs(X)%D) if __name__ == "__main__": m...
def main(): X, K, D = map(int, input().split()) if abs(X) >= K*D: if X <= 0: print(abs(X+K*D)) else: print(X-K*D) else: K -= abs(X) // D if K % 2 == 0: print(abs(X)%D) else: print(D-abs(X)%D) if __name__ == "__main__": ...
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
105
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq x,k,d =ma() if abs(x) > k*d: ans = x-k*d el...
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq x,k,d =ma() if abs(x) > k*d: ans = abs(x)-k...
[["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]]
5
176
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import bisect import math import fractions import sys import copy def L(): return s...
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import bisect import math import fractions import sys import copy def L(): return s...
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24]]
5
566
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<ll>; using vvi = vector<vi>; using pll = pair<ll, ll>; #define all(a) a.begin(), a.end() #define pb push_back #define mp make_pair template <typename T> using vv = vector<vector<T>>; void solve() { ll x,...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<ll>; using vvi = vector<vi>; using pll = pair<ll, ll>; #define all(a) a.begin(), a.end() #define pb push_back #define mp make_pair template <typename T> using vv = vector<vector<T>>; void solve() { ll x,...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
190
#include <bits/stdc++.h> using namespace std; #define ll long long #define ll_s long #define mod 1000000007 #define forn(i, start, lim) for (ll i = start; i < lim; i++) #define forn_d(i, start, lim) for (ll i = start; i >= lim; i--) #define f first #define s second #define pb push_back #define pf push_front #define mp ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ll_s long #define mod 1000000007 #define forn(i, start, lim) for (ll i = start; i < lim; i++) #define forn_d(i, start, lim) for (ll i = start; i >= lim; i--) #define f first #define s second #define pb push_back #define pf push_front #define mp ...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22]]
1
234
// created by mtnshh #include <algorithm> #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i, a, b) for (ll i = a; i < b; i++) #define repb(i, a, b) for (ll i = a; i >= b; i--) #define err() cout << "--------------------------" << endl; #define errA(A) ...
// created by mtnshh #include <algorithm> #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i, a, b) for (ll i = a; i < b; i++) #define repb(i, a, b) for (ll i = a; i >= b; i--) #define err() cout << "--------------------------" << endl; #define errA(A) ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
284
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define ll long long #define maxheap priority_queue<int> #define minheap priority_queue<int, vector<int>, greater<int>> const long double pi = acos(-1.0); const double eps = 1e-9; using namespace std; void solve() { ll x, k, d; cin >>...
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define ll long long #define maxheap priority_queue<int> #define minheap priority_queue<int, vector<int>, greater<int>> const long double pi = acos(-1.0); const double eps = 1e-9; using namespace std; void solve() { ll x, k, d; cin >>...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
254
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define lli long long int #define llu unsigned long long int #define pb push_back #define rt return 0 #define endln "\n" #define all(x) x.begin(), x.end() #def...
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define lli long long int #define llu unsigned long long int #define pb push_back #define rt return 0 #define endln "\n" #define all(x) x.begin(), x.end() #def...
[["+", 64, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
250
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> VI; typedef vector<vector<int>> VVI; typedef vector<ll> VLL; typedef vector<vector<ll>> VVLL; typedef pair<ll, ll> Pair; template <class T> T input() { T t; cin >> t; return t; } #define FOR(i, ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> VI; typedef vector<vector<int>> VVI; typedef vector<ll> VLL; typedef vector<vector<ll>> VVLL; typedef pair<ll, ll> Pair; template <class T> T input() { T t; cin >> t; return t; } #define FOR(i, ...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 109], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 85]]
1
523
X, K, D = map(int, input().split()) d = abs(X) // D if d >= K: if X >= 0: ans = X - K * D else: ans = X + K * D print(ans) exit() if X >= 0: ans = X - d * D else: ans = X + d * D n = K - d if n % 2 == 1: if ans >= 0: ans -= D else: ans += D print(abs(ans))
X, K, D = map(int, input().split()) d = abs(X) // D if d >= K: if X >= 0: ans = X - K * D else: ans = X + K * D print(abs(ans)) exit() if X >= 0: ans = X - d * D else: ans = X + d * D n = K - d if n % 2 == 1: if ans >= 0: ans -= D else: ans += D print(abs(ans))
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
112
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll X, K, D; ll ans = 0; int main() { cin >> X >> K >> D; if (X >= 0) { ll low = 0, high = K + 1, res = K + 1; while (low < high) { // cout<<low<<" "<<high<<endl; ll mid = (low + high) >> 1; if (X / D + 10 <= mid) { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll X, K, D; ll ans = 0; int main() { cin >> X >> K >> D; if (X >= 0) { ll low = 0, high = K + 1, res = K + 1; while (low < high) { // cout<<low<<" "<<high<<endl; ll mid = (low + high) >> 1; if (X / D + 10 <= mid) { ...
[["+", 0, 57, 15, 339, 51, 16, 12, 91, 17, 33]]
1
356
x, k, d = map(int, input().split()) q = abs(x) // d if q >= k: print(abs(x) - (d * k)) exit() mod = abs(x) % d if q % 2 == 0: print(mod) else: print(abs(d) - mod)
x, k, d = map(int, input().split()) q = abs(x) // d if q >= k: print(abs(x) - (d * k)) exit() mod = abs(x) % d if (k - q) % 2 == 0: print(mod) else: print(abs(d) - mod)
[["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]]
5
77
X, K, D = map(int, input().split()) if X > K*D: print(X - K*D) else: if (K - (X // D)) % 2 == 0: print(X % D) else: print(D - X % D)
X, K, D = map(int, input().split()) if abs(X) > K*D: print(abs(X) - K*D) else: if (K - (X // D)) % 2 == 0: print(X % D) else: print(D - X % D)
[["+", 0, 656, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]]
5
66
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #inc...
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #inc...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
326
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<ll>>; struct edge { ll to; ll cost; }; using graph = vector<vector<edge>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, n...
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<ll>>; struct edge { ll to; ll cost; }; using graph = vector<vector<edge>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, n...
[["+", 51, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 23, 0, 91, 17, 33], ["+", 51, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 16, 31, 16, 12, 16, 31, 91, 17, 33], ["-", 64, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 64, 1, 0, 16, 31, 16, 12, 16, 17, 33]]
1
425
#include "bits/stdc++.h" using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; if (X < 0) { X -= X; } long long count = X / D; if (count >= K) { cout << X - K * D << endl; return 0; } if (1 == K % 2) { long long x = X + D; cout << min(x % (2 * D), abs(2 * D - x % ...
#include "bits/stdc++.h" using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; if (X < 0) { X = -X; } long long count = X / D; if (count >= K) { cout << X - K * D << endl; return 0; } if (1 == K % 2) { long long x = X + D; cout << min(x % (2 * D), abs(2 * D - x % ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 64, 9, 0, 1, 0, 11, 12, 91, 17, 33]]
1
155
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define ff first #define ss second #define boost \ ios::sync_with_stdio(false); \ cin.tie(nullptr) #define en...
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define ff first #define ss second #define boost \ ios::sync_with_stdio(false); \ cin.tie(nullptr) #define en...
[["+", 31, 16, 12, 16, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 31, 16, 12, 16, 12, 16, 31, 23, 0, 25]]
1
123
#include <bits/stdc++.h> #pragma region Macro #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define SORT(v) sort(v.begin(), v.end()) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define vi vector<int> #define vvi vector<vector<int>> #define chmax(x, y...
#include <bits/stdc++.h> #pragma region Macro #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define SORT(v) sort(v.begin(), v.end()) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define vi vector<int> #define vvi vector<vector<int>> #define chmax(x, y...
[["+", 0, 43, 49, 50, 51, 16, 31, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 17, 33], ["-", 0, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 17, 33]]
1
234
#include <bits/stdc++.h> #define ll long long using namespace std; template <class T> inline void read(T &res) { char c; T flag = 1; while ((c = getchar()) < '0' || c > '9') if (c == '-') flag = -1; res = c - '0'; while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0'; res *= flag...
#include <bits/stdc++.h> #define ll long long using namespace std; template <class T> inline void read(T &res) { char c; T flag = 1; while ((c = getchar()) < '0' || c > '9') if (c == '-') flag = -1; res = c - '0'; while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0'; res *= flag...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25]]
1
494
x, k, d = map(int, input().split()) ans = 0 if k * d < abs(x): if x >= 0: ans = x - k*d else: ans = x + k*d print(ans) exit() xd = x // (2*d) if k % 2: tmp = x - 2*d*xd l = [abs(tmp-d), abs(tmp+d), abs(tmp+3*d)] ans = min(l) else: tmp = x - 2*d*xd l = [abs(tmp-2...
x, k, d = map(int, input().split()) ans = 0 if k * d < abs(x): if x >= 0: ans = x - k*d else: ans = x + k*d print(abs(ans)) exit() xd = x // (2*d) if k % 2: tmp = x - 2*d*xd l = [abs(tmp-d), abs(tmp+d), abs(tmp+3*d)] ans = min(l) else: tmp = x - 2*d*xd l = [abs(...
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
161
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll mod = 1e9 + 7; int main() { ll x, k, d; cin >> x >> k >> d; ll m = abs(x) % d; ll n = abs(x) / d; if (k < n) { cout << abs(x - k * d) << endl; } else if ((k - n) % 2 == 0) { cout << m << endl; } else { cout << ab...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll mod = 1e9 + 7; int main() { ll x, k, d; cin >> x >> k >> d; ll m = abs(x) % d; ll n = abs(x) / d; if (k < n) { cout << abs(abs(x) - k * d) << endl; } else if ((k - n) % 2 == 0) { cout << m << endl; } else { cout ...
[["+", 12, 2, 3, 4, 0, 16, 31, 2, 63, 22], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25]]
1
117
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC target("avx,avx2,fma") typedef long long LL; typedef pair<int, int> PII; typedef vector<int> VI; typedef long double db; #define MP make_pair #define PB push_back #define X first #define Y second #define FOR(i, ...
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC target("avx,avx2,fma") typedef long long LL; typedef pair<int, int> PII; typedef vector<int> VI; typedef long double db; #define MP make_pair #define PB push_back #define X first #define Y second #define FOR(i, ...
[["-", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
425
x,k,d=(int(x) for x in input().split()) if x>k*d: print(x-k*d) else: ki=x//d kj=x-d*ki if (k-ki)%2==0: print(kj) else: print(d-kj)
x,k,d=(int(x) for x in input().split()) x=abs(x) if x>k*d: print(x-k*d) else: ki=x//d kj=x-d*ki if (k-ki)%2==0: print(kj) else: print(d-kj)
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
74
#include "algorithm" #include "cmath" #include "cstdio" #include "cstring" #include "iostream" #include "queue" #include "stack" using namespace std; #define read(x) scanf("%d", &x) #define readl(x) scanf("%lld", &x) #define ll long long #define ull unsigned long long #define MAXN 1000005 ll n, k, d; int main() { ...
#include "algorithm" #include "cmath" #include "cstdio" #include "cstring" #include "iostream" #include "queue" #include "stack" using namespace std; #define read(x) scanf("%d", &x) #define readl(x) scanf("%lld", &x) #define ll long long #define ull unsigned long long #define MAXN 1000005 ll n, k, d; int main() { ...
[["+", 0, 1, 0, 16, 31, 16, 12, 91, 17, 33], ["+", 0, 16, 31, 16, 12, 91, 28, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 91, 28, 23, 0, 25]]
1
235
#include <bits/stdc++.h> using namespace std; void solve() { long long x, k, d; cin >> x >> k >> d; x = abs(x); if (x > 0) { long long y = x / d; if (y >= k) { cout << x - d * k << '\n'; return; } else { long long temp = x - y * d; long long rem = k - y; if (rem & 1) ...
#include <bits/stdc++.h> using namespace std; void solve() { long long x, k, d; cin >> x >> k >> d; x = abs(x); if (x >= 0) { long long y = x / d; if (y >= k) { cout << x - d * k << '\n'; return; } else { long long temp = x - y * d; long long rem = k - y; if (rem & 1) ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
166
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define ll long long int #define mk make_pair #define pb push_back #define ff first #define ss second #define ar array #define del 1e-8 double pi = 3.141592653589793238; const int M = 1e9 + 7; const int Nmax = 5005; const int MM = 998244353; const in...
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define ll long long int #define mk make_pair #define pb push_back #define ff first #define ss second #define ar array #define del 1e-8 double pi = 3.141592653589793238; const int M = 1e9 + 7; const int Nmax = 5005; const int MM = 998244353; const in...
[["-", 64, 1, 0, 11, 12, 23, 0, 16, 17, 72], ["-", 64, 1, 0, 11, 12, 23, 0, 16, 12, 22]]
1
205
import sys sys.setrecursionlimit(10**9) def mi(): return map(int,input().split()) def ii(): return int(input()) def isp(): return input().split() def deb(text): print("-------\n{}\n-------".format(text)) INF=10**20 def main(): X,K,D=mi() if X == 0: ans = D if K % 2 == 1 else 0 print(ans) ...
import sys sys.setrecursionlimit(10**9) def mi(): return map(int,input().split()) def ii(): return int(input()) def isp(): return input().split() def deb(text): print("-------\n{}\n-------".format(text)) INF=10**20 def main(): X,K,D=mi() if X == 0: ans = D if K % 2 == 1 else 0 print(ans) ...
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
258
#include <bits/stdc++.h> #define INF 0x3f3f3f3f #define rep(i, a, n) for (int i = (a); i < (n); i++) #define per(i, a, n) for (int i = (a); i > (n); i--) typedef long long ll; const int maxn = 2e5 + 5; const int mod = 1e9 + 7; using namespace std; void solve() { ll x, k, d; cin >> x >> k >> d; x = abs(x); { ...
#include <bits/stdc++.h> #define INF 0x3f3f3f3f #define rep(i, a, n) for (int i = (a); i < (n); i++) #define per(i, a, n) for (int i = (a); i > (n); i--) typedef long long ll; const int maxn = 2e5 + 5; const int mod = 1e9 + 7; using namespace std; void solve() { ll x, k, d; cin >> x >> k >> d; x = abs(x); { ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
207
X,K,D=list(map(int,input().split())) if abs(X)//D<K: if (K-abs(X)//D)%2==0: print(abs(X%D)) else: print(abs(abs(X%D)-D)) else: print(abs(X)-D*K)
X,K,D=list(map(int,input().split())) if abs(X)//D<K: if (K-abs(X)//D)%2==0: print(abs(X)%D) else: print(abs(abs(X)%D-D)) else: print(abs(X)-D*K)
[["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 657, 31, 657, 31, 652, 3, 4, 0, 25], ["-", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]]
5
85
x,k,d=map(int,input().split()) x=abs(x) ans=10**15 r=x%d if x>d*k: ans=x-d*k else: k-=r if k%2==0: ans=abs(x-d*r) else: ans=abs(x-d*(r+1)) print(ans)
x,k,d=map(int,input().split()) x=abs(x) ans=10**15 r=x//d if x>=d*k: ans=x-d*k else: k-=r if k%2==0: ans=abs(x-d*r) else: ans=abs(x-d*(r+1)) print(ans)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 109], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20]]
5
90
x, k, d = map(int, input().split()) if x >= 0: if x - k*d >= 0: ans = x - k*d else: pre = x//d x -= pre*d k -= pre if k%2 == 0: ans = abs(x) elif k%2 == 1: ans = min(abs(x-d), abs(x+d)) elif x <= 0: if x + k*d <= 0: ans = x + k*...
x, k, d = map(int, input().split()) if x >= 0: if x - k*d >= 0: ans = abs(x - k*d) else: pre = x//d x -= pre*d k -= pre if k%2 == 0: ans = abs(x) elif k%2 == 1: ans = min(abs(x-d), abs(x+d)) elif x <= 0: if x + k*d <= 0: ans = a...
[["+", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
173
#include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; #define prec(i) cout << fixed << setprecision(i) void outP...
#include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; #define prec(i) cout << fixed << setprecision(i) void outP...
[["+", 0, 2, 3, 4, 0, 16, 31, 2, 63, 22], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25]]
1
608
x, k, d = map(int, input().split()) if abs(k * d) > abs(x): pos = x % d left_turn = k - abs(x) // d if left_turn % 2 == 1: ans = d - pos else: ans = pos else: ans = abs(x) - abs(k * d) print(ans)
x, k, d = map(int, input().split()) if abs(k * d) > abs(x): pos = abs(x) % d left_turn = k - abs(x) // d if left_turn % 2 == 1: ans = d - pos else: ans = pos else: ans = abs(x) - abs(k * d) print(ans)
[["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]]
5
82
def main(): X, K, D = list(map(int, input().split())) right = X % D left = right - D if X in [left, right]: if K % 2 == 0: print(abs(X)) else: if X == left: print(right) else: print(abs(left)) return if X > r...
def main(): X, K, D = list(map(int, input().split())) right = X % D left = right - D if X in [left, right]: if K % 2 == 0: print(abs(X)) else: if X == left: print(right) else: print(abs(left)) return if X > ...
[["-", 15, 666, 0, 657, 31, 23, 0, 657, 12, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 12, 22]]
5
199
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define llint long ...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define llint long ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
233
X, K, D = map(int, input().split()) x = X % D k = K - X//D if k < 0: print(min(abs(X + K * D), abs(X - K * D))) else: if k % 2 == 0: print(abs(x)) else: print(abs(abs(x)-D))
X, K, D = map(int, input().split()) x = X % D k = K - abs(X//D) # print(x, k) if k < 0: print(min(abs(X + K * D), abs(X - K * D))) else: if k % 2 == 0: print(abs(x)) else: print(abs(abs(x)-D))
[["+", 0, 1, 0, 662, 12, 657, 12, 652, 63, 22], ["+", 0, 662, 12, 657, 12, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 12, 652, 3, 4, 0, 25]]
5
88
def readinput(): x,k,d=map(int,input().split()) return x,k,d def main(x,k,d): q=x//d r=x%d if k<q: ans=x-k*d else: if (k-q)%2==0: ans=r else: ans=d-r return ans if __name__=='__main__': x,k,d=readinput() ans=main(x,k,d) print(ans)...
def readinput(): x,k,d=map(int,input().split()) return x,k,d def main(x,k,d): x=abs(x) q=x//d r=x%d if k<q: ans=x-k*d else: if (k-q)%2==0: ans=r else: ans=d-r return ans if __name__=='__main__': x,k,d=readinput() ans=main(x,k,d) ...
[["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
116
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include ...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include ...
[["+", 0, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
249
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll x, k, d, kk, X; cin >> x >> k >> d; kk = k; if (x == 0) { if (k & 1) { cout << d << '\n'; } else { cout << 0 << '\n'; } return 0; } ll tt = (abs(x)) ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll x, k, d, kk, X; cin >> x >> k >> d; kk = k; if (x == 0) { if (k & 1) { cout << d << '\n'; } else { cout << 0 << '\n'; } return 0; } ll tt = (abs(x)) ...
[["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
257
x, k, d = map(int, input().split()) k_i = abs(x//d) # l = [abs(abs(x)-d*k_i), abs(abs(x)-d*(k_i+1))] if k >= k_i+1: if k%2==0: if k_i%2==0: print(abs(abs(x)-d*k_i)) else: print(abs(abs(x)-d*(k_i+1))) else: if k_i%2==0: print(abs(abs(x)-d*(k_i+1))) ...
x, k, d = map(int, input().split()) k_i = abs(x)//d if k >= k_i+1: if k%2==0: if k_i%2==0: print(abs(abs(x)-d*k_i)) else: print(abs(abs(x)-d*(k_i+1))) else: if k_i%2==0: print(abs(abs(x)-d*(k_i+1))) else: print(abs(abs(x)-d*k_i)) ...
[["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
138
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long X = sc.nextLong(); long K = sc.nextLong(); long D = sc.nextLong(); if (X == 0) { if (K % 2 == 0) { System.out.println(0); } else { System.o...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long X = sc.nextLong(); long K = sc.nextLong(); long D = sc.nextLong(); if (X == 0) { if (K % 2 == 0) { System.out.println(0); } else { System.o...
[["+", 0, 57, 15, 15, 0, 16, 12, 91, 17, 33]]
3
295
X, K, D = gets.split.map(&:to_i) pos = X.abs if K * D < pos then puts pos - K * D else a = pos / D pos = pos - D * a i = a % 2 if i == 0 puts pos else puts (pos - K).abs end end
X, K, D = gets.split.map(&:to_i) pos = X.abs if K * D < pos then puts pos - K * D else a = pos / D pos = pos - D * a i = (K - a) % 2 if i == 0 puts pos else puts (pos - D).abs end end
[["+", 75, 95, 0, 662, 12, 738, 31, 739, 0, 24], ["+", 0, 662, 12, 738, 31, 739, 0, 738, 31, 743], ["+", 0, 662, 12, 738, 31, 739, 0, 738, 17, 33], ["+", 75, 95, 0, 662, 12, 738, 31, 739, 0, 25], ["-", 3, 4, 0, 652, 486, 739, 0, 738, 12, 743], ["+", 3, 4, 0, 652, 486, 739, 0, 738, 12, 743]]
4
68
x, k, d = map(int, input().split()) if abs(x)>k*d: print(abs(x)-k*d) quit() onaji = abs(x)%d nokori = k-onaji if nokori%2==0: print(abs(x)-k*onaji) else: print(abs(abs(x)-k*(onaji+1)))
x, k, d = map(int, input().split()) if abs(x)>k*d: print(abs(x)-k*d) quit() onaji = abs(x)//d nokori = k-onaji if nokori%2==0: print(abs(x)-d*onaji) else: print(abs(abs(x)-d*(onaji+1)))
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 109], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676], ["-", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22]]
5
93
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll inf = 1e18; #define rep(i, a, b) for (int i = a; i < b; i++) #define per(i, a, b) for (int i = b - 1; i >= a; i--) #define int ll using pint = pair<int, int>; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; signed main() { int x, k, d; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll inf = 1e18; #define rep(i, a, b) for (int i = a; i < b; i++) #define per(i, a, b) for (int i = b - 1; i >= a; i--) #define int ll using pint = pair<int, int>; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; signed main() { int x, k, d; ...
[["+", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 25]]
1
227
X, K, D = map(int, input().split()) def f(C): NX = float("inf") if C > K: return NX if K % 2 == 0: if C % 2 == 0: NX = abs(abs(X) - C * D) else: NX = abs(abs(X) - (C + 1) * D) if C > 0: NX = min(NX, abs(abs(X) - (C - 1) * D)) ...
X, K, D = map(int, input().split()) def f(C): NX = float("inf") if C > K: return NX if K % 2 == 0: if C % 2 == 0: NX = abs(abs(X) - C * D) else: NX = abs(abs(X) - (C + 1) * D) if C > 0: NX = min(NX, abs(abs(X) - (C - 1) * D)) ...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21]]
5
214
X,K,D = map(int, input().split()) if (abs(X)>K*D): ans = abs(abs(X)-K*D) else: m = abs(X)//K remk = K - m now = abs(X)-m*K if remk%2==0: ans = now else: ans = abs(now-K) print(ans)
X,K,D = map(int, input().split()) if (abs(X)>=K*D): ans = abs(abs(X)-K*D) else: m = abs(X)//D remk = K - m now = abs(X)-m*D if remk%2==0: ans = now else: ans = abs(now-D) print(ans)
[["-", 0, 656, 0, 57, 15, 23, 0, 666, 667, 47], ["+", 0, 656, 0, 57, 15, 23, 0, 666, 667, 20], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 12...
5
92
#define LOCAL #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = (n - 1); i >= 0; --i) #define rep2(i, s, n) for (int i = s; i < (n); ++i) #define ALL(v) (v).begin(), (v).end() #define memr(dp, val) memset(dp, val, sizeof(dp)) using namespace std; typedef long long ...
#define LOCAL #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = (n - 1); i >= 0; --i) #define rep2(i, s, n) for (int i = s; i < (n); ++i) #define ALL(v) (v).begin(), (v).end() #define memr(dp, val) memset(dp, val, sizeof(dp)) using namespace std; typedef long long ...
[["+", 64, 9, 0, 57, 15, 339, 51, 16, 31, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
704