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
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" int arr[100]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); double x, k, d; cin >> x >> k >> d; // x-nd=0 double prod = abs(x) / d; if (prod > k) { if (x < 0) cout << (ll)(x + d * k) << endl; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" int arr[100]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); double x, k, d; cin >> x >> k >> d; // x-nd=0 double prod = abs(x) / d; if (prod > k) { if (x < 0) cout << (ll)(abs(x + d * k)) << endl...
[["+", 31, 16, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24]]
1
287
x, k , d = map(int, input().split()) y = abs(x) count = x // d e = x % d f = abs(e-d) if e > f: min1 = f min2 = e count += 1 else: min1 = e min2 = f if count > k: print(y - d * k) else: if (k - count)%2 == 0: print(min1) else: print(min2)
x, k , d = map(int, input().split()) y = abs(x) count = y // d e = y % d f = abs(e-d) if e > f: min1 = f min2 = e count += 1 else: min1 = e min2 = f if count > k: print(y - d * k) else: if (k - count)%2 == 0: print(min1) else: print(min2)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22]]
5
100
package main import ( "fmt" "math" ) func main() { // Code for C - Walking Takahashi var X, K, D float64 fmt.Scanf("%f %f %f", &X, &K, &D) A := math.Abs(X) B := float64(int(X) % int(D)) C := math.Min(B, math.Abs(B-2*D)) Z := math.Min(math.Abs(B-D), math.Abs(B+D)) E := float64(int(X) / int(D)) if A >= K*...
package main import ( "fmt" "math" ) func main() { // Code for C - Walking Takahashi var X, K, D float64 fmt.Scanf("%f %f %f", &X, &K, &D) A := math.Abs(X) B := float64(int(A) % int(D)) C := math.Min(B, math.Abs(B-2*D)) Z := math.Min(math.Abs(B-D), math.Abs(B+D)) E := float64(int(A) / int(D)) if A >= K*...
[["-", 3, 4, 0, 16, 31, 2, 3, 4, 0, 22], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 22]]
7
195
#include <algorithm> #include <bits/stdc++.h> using namespace std; #define ll long long int #define ull unsigned long long int #define db double #define ld long double #define MOD 1000000007 #define inf (1LL << 62) #define pi acos(-1.0) #define si(a) scanf("%lld", &a) #define sd(n) scanf("%lf", &n) #define for1(i, sto...
#include <algorithm> #include <bits/stdc++.h> using namespace std; #define ll long long int #define ull unsigned long long int #define db double #define ld long double #define MOD 1000000007 #define inf (1LL << 62) #define pi acos(-1.0) #define si(a) scanf("%lld", &a) #define sd(n) scanf("%lf", &n) #define for1(i, sto...
[["+", 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], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
1
374
X, K, D = map(int, input().split()) X = abs(X) n = X // D m = K - n A1 = abs(X - n*D) A2 = abs(X - (n+1)*D) Ans = A2 if m > 1: if A1 <= A2: if m % 2 == 0: Ans = A1 else: if m-1 % 2 != 0: Ans = A1 else: Ans = abs(X - K*D) print(Ans)
X, K, D = map(int, input().split()) X = abs(X) n = X // D m = K - n A1 = abs(X - n*D) A2 = abs(X - (n+1)*D) Ans = A2 if m > 1: if A1 <= A2: if m % 2 == 0: Ans = A1 else: if m % 2 == 0: Ans = A1 else: Ans = abs(X - K*D) print(Ans)
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["-", 0, 57, 15, 666, 0, 657, 12, 657, 31, 612], ["-", 75, 76, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 667, 60]]
5
111
x,k,d=map(int,input().split()) if abs(x)>=k*d: print(abs(x)-k*d) else: if (x//d)%2==k%2: print((abs(abs(x)%d))) else: print(abs(abs(x)%d-d))
x,k,d=map(int,input().split()) if abs(x)>=k*d: print(abs(x)-k*d) else: if (abs(x)//d)%2==k%2: print((abs(abs(x)%d))) else: print(abs(abs(x)%d-d))
[["+", 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
84
X, K, D = map(int, input().split()) if(X > 0): if(X-K*D >= 0): print(X-K*D) else: l = X//D X = X-D*(l+1) K = K-l-1 if(K % 2 == 0): print(abs(X)) else: print(abs(X+D)) elif(X < 0): if((X+K*D) <= 0): print(abs(X+K*D)) else: ...
X, K, D = map(int, input().split()) if(X > 0): if(X-K*D >= 0): print(X-K*D) else: l = X//D X = X-D*(l+1) K = K-l-1 if(K % 2 == 0): print(abs(X)) else: print(abs(X+D)) elif(X < 0): if((X+K*D) <= 0): print(abs(X+K*D)) else: ...
[["+", 0, 1, 0, 662, 12, 657, 31, 664, 17, 33]]
5
203
def main(): x, k, d = map(int, input().split()) if x > 0: if x - d * k >= 0: print(x - d * k) else: a = abs(x - d * k) % d b = abs(x - d * k) / d if b % 2 == 0: print(a) else: print(d - a) else: ...
def main(): x, k, d = map(int, input().split()) if x > 0: if x - d * k >= 0: print(x - d * k) else: a = abs(x - d * k) % d b = abs(x - d * k) // d if b % 2 == 0: print(a) else: print(d - a) else: ...
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 676]]
5
163
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { ll X, K, D; cin >> X >> K >> D; int cnt; int mod; X = abs(X); if (K <= 1000000000000000 / D && K * D <= X) { cout << X - K * D << endl; return 0; } cnt = X / D; m...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { ll X, K, D; cin >> X >> K >> D; ll cnt; ll mod; X = abs(X); if (K <= 1000000000000000 / D && K * D <= X) { cout << X - K * D << endl; return 0; } cnt = X / D; mod...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
132
from math import ceil x,k,d = list(map(int,input().split())) xi = abs(x) if abs(x) > d*k: m = min(abs(x+d*k),abs(x-d*k)) else: n = ceil(xi // d) if (n+k) % 2 == 0: m = abs(xi-d*n) else: m = abs(xi-d*(n-1)) print(m)
from math import ceil x,k,d = list(map(int,input().split())) xi = abs(x) if abs(x) > d*k: m = min(abs(x+d*k),abs(x-d*k)) else: n = ceil(xi / d) if (n+k) % 2 == 0: m = abs(xi-d*n) else: m = abs(xi-d*(n-1)) print(m)
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 676], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 85]]
5
114
x,k,d=map(int,input().split()) if x>=k*d: print(x-k*d) elif -x>=k*d: print(x+k*d) else: x=abs(x) a,b=divmod(x,d) if k%2==a%2: print(b) else: print(abs(b-d))
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: x=abs(x) a,b=divmod(x,d) if k%2==a%2: print(b) else: print(abs(b-d))
[["+", 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
91
#include <bits/stdc++.h> using namespace std; typedef long long int ll; void solve() { ll x, k, d; cin >> x >> k >> d; if (x < 0) x = -x; if (x == 0) { if (k % 2ll == 0ll) cout << 0; else cout << d; } else if (x > 0) { ll p = x / d; if (p == k) { cout << x - p * d; ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; void solve() { ll x, k, d; cin >> x >> k >> d; if (x < 0) x = -x; if (x == 0) { if (k % 2ll == 0ll) cout << 0; else cout << d; } else if (x > 0) { ll p = x / d; if (p == k) { cout << x - p * d; ...
[["+", 0, 57, 75, 76, 0, 1, 0, 16, 31, 22], ["+", 0, 57, 75, 76, 0, 1, 0, 16, 17, 151]]
1
237
X, K, D = map(int, input().split()) q, mod = divmod(abs(X), abs(D)) ans = 0 if q < K: amari = K - q l = amari % 2 if l == 0: ans = mod else: ans = D + mod else: div = q - K ans = div * D + mod print(ans)
X, K, D = map(int, input().split()) q, mod = divmod(abs(X), abs(D)) ans = 0 if q < K: amari = K - q l = amari % 2 if l == 0: ans = mod else: ans = D - mod else: div = q - K ans = div * D + mod print(ans)
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33]]
5
85
#C x,k,d=map(int, input().split()) #直線のみに進行すればいい場合の回数 s = x//d #最短回数よりも移動可能回数の方が少ない場合 if s >= k: print(abs(x) - k*d) #最短経路回数よりも多く移動する場合 else: if (k-s) %2 == 0: print(abs(x) - s*d) else: print(d-(abs(x) - s*d))
#C x,k,d=map(int, input().split()) #直線のみに進行すればいい場合の回数 s = abs(x)//d #最短回数よりも移動可能回数の方が少ない場合 if s >= k: print(abs(x) - k*d) #最短回数よりも多く移動する場合 else: if (k-s) %2 == 0: print(abs(x) - s*d) else: print(d-(abs(x) - s*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
84
X,K,D = map(int,input().split()) if abs(X) >= D: minX = abs(X) % D if abs(X) / D <= K and abs(X) >= D: if (K - (abs(X) / D)) % 2 == 0: print(minX) else: if abs(minX - D) < abs(minX + D): print(abs(minX - D)) else: print(abs(minX + D)) elif abs(X) / D > K and ...
X,K,D = map(int,input().split()) if abs(X) >= D: minX = abs(X) % D if abs(X) / D <= K and abs(X) >= D: if (K - int((abs(X) / D))) % 2 == 0: print(minX) else: if abs(minX - D) < abs(minX + D): print(abs(minX - D)) else: print(abs(minX + D)) elif abs(X) / D > K...
[["+", 0, 657, 31, 23, 0, 657, 12, 652, 63, 22], ["+", 0, 657, 12, 652, 3, 4, 0, 23, 0, 24], ["+", 0, 657, 12, 652, 3, 4, 0, 23, 0, 25]]
5
182
#include <bits/stdc++.h> #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++) #define ALL(x) (x).begin(), (x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) using namespace std; using ll = long long; using vel = vector<ll>; using ves =...
#include <bits/stdc++.h> #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++) #define ALL(x) (x).begin(), (x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) using namespace std; using ll = long long; using vel = vector<ll>; using ves =...
[["-", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22]]
1
413
#include <bits/stdc++.h> #define nl endl #define dbg(a) cout << #a << "=" << a << endl #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> #define nl endl #define dbg(a) cout << #a << "=" << a << endl #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
[["-", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 31, 22]]
1
127
import java.lang.Math; 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(); long m = x / d; if (Math.abs(m) > k) { if (m > 0) { x = x - k * d;...
import java.lang.Math; 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(); long m = x / d; if (Math.abs(m) > k) { if (m > 0) { x = x - k * d;...
[["+", 0, 1, 0, 492, 3, 4, 0, 492, 500, 22], ["+", 0, 1, 0, 492, 3, 4, 0, 492, 0, 131], ["+", 0, 1, 0, 492, 3, 4, 0, 492, 141, 22], ["+", 0, 492, 3, 4, 0, 492, 3, 4, 0, 24], ["+", 0, 492, 3, 4, 0, 492, 3, 4, 0, 25]]
3
192
#include <bits/stdc++.h> #include <iostream> using namespace std; long long absolute(long long int num) { if (num < 0) return -1 * num; else return num; } int main() { long long int x, k, d; cin >> x >> k >> d; if (x < 0) x *= -1; long long int alpha = x / d; if (x - k * d >= 0) cout <...
#include <bits/stdc++.h> #include <iostream> using namespace std; long long absolute(long long int num) { if (num < 0) return -1 * num; else return num; } int main() { long long int x, k, d; cin >> x >> k >> d; if (x < 0) x *= -1; long long int alpha = x / d; if (alpha >= k) cout << x ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 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], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, ...
1
139
X , K ,D = map(int, input().split()) if X>0: S = int(abs(X) / D) aX = X -D * S if S>=K: print(X-D*K) elif (K-S)%2==0: print(abs(aX)) else: print(abs(aX-D)) else: S = int(abs(X) / D) aX = X + D * S if S>=K: print(abs(X+D*K)) elif (K-S)%2==0: p...
X , K ,D = map(int, input().split()) if X>0: S = int(abs(X) / D) aX = X -D * S if S>=K: print(X-D*K) elif (K-S)%2==0: print(abs(aX)) else: print(abs(aX-D)) else: S = int(abs(X) / D) aX = X + D * S if S>=K: print(abs(X+D*K)) elif (K-S)%2==0: p...
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72]]
5
148
X, K, D = map(int, input().split()) X = abs(X) n = round(X/D) if K<=n: ans = abs(X-K*D) else: tmp = X-D*n if (K-n)%2==0: ans = abs(tmp) else: ans = abs(tmp-D) print(ans)
import math X, K, D = map(int, input().split()) X = abs(X) #n = roundup(X/D) n = math.floor(X/D) if K<=n: ans = abs(X-K*D) else: tmp = X-D*n if (K-n)%2==0: ans = abs(tmp) else: ans = abs(tmp-D) print(ans)
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
87
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; void Main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); if (x < d) { if (k % 2 == 0) { cout << abs(x) << endl; } else { cout << abs(x - d) << endl;...
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; void Main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); if (x < d) { if (k % 2 == 0) { cout << abs(x) << endl; } else { cout << abs(x - d) << endl;...
[["+", 0, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 0, 9, 0, 57, 64, 9, 0, 37, 0, 35]]
1
223
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = (ll)1e15; int main() { ll X, K, D; cin >> X >> K >> D; ll res; if (abs(X) / D > K) { if (X > 0) { res = abs(X - D * K); } else { res = abs(X + D * K); } } else { // ll num, amari; // if(X%D > ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = (ll)1e15; int main() { ll X, K, D; cin >> X >> K >> D; ll res; if (abs(X) / D > K) { if (X > 0) { res = abs(X - D * K); } else { res = abs(X + D * K); } } else { // ll num, amari; // if(X%D > ...
[["+", 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
155
#include <cmath> #include <ctype.h> #include <iostream> #include <limits.h> #include <sstream> #include <stdio.h> #include <string.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; typedef vector<int> vi; //最大公約数 int gcd(int a, int b) ...
#include <cmath> #include <ctype.h> #include <iostream> #include <limits.h> #include <sstream> #include <stdio.h> #include <string.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; typedef vector<int> vi; //最大公約数 int gcd(int a, int b) ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
441
#include <bits/stdc++.h> using namespace std; int main() { long long int x, k, d, w; cin >> x >> k >> d; if (x < 0) { x = -x; } w = x / d; if (w <= k) { if ((k - w) % 2 == 0) { cout << x % d << endl; } else { cout << d - x % d << endl; } } else { cout << x % k + (w - k) ...
#include <bits/stdc++.h> using namespace std; int main() { long long int x, k, d, w; cin >> x >> k >> d; if (x < 0) { x = -x; } w = x / d; if (w <= k) { if ((k - w) % 2 == 0) { cout << x % d << endl; } else { cout << d - x % d << endl; } } else { cout << x % d + (w - k) ...
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22]]
1
112
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; using ll = long long; using db = double; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 2e5 + 10; const ll inf = 1e15 + 42; #define endl "\n" const ll mod = 1000000007; typedef tree<...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; using ll = long long; using db = double; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 2e5 + 10; const ll inf = 1e15 + 42; #define endl "\n" const ll mod = 1000000007; typedef tree<...
[["+", 0, 11, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 64, 1, 0, 11, 12, 2, 3, 4, 0, 25], ["-", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22]]
1
372
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long int ll; using names...
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long int ll; using names...
[["+", 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
196
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 998244353; const int M = 1e9 + 7; #define inf 0x3f3f3f3f // std::ios::sync_with_stdio(0); int main() { std::ios::sync_with_stdio(0); ll x, k, d; cin >> x >> k >> d; if (x >= 0) { if (x / d >= k) { x = x - k * d; k ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 998244353; const int M = 1e9 + 7; #define inf 0x3f3f3f3f // std::ios::sync_with_stdio(0); int main() { std::ios::sync_with_stdio(0); ll x, k, d; cin >> x >> k >> d; if (x >= 0) { if (x / d >= k) { x = x - k * d; k ...
[["+", 0, 1, 0, 11, 12, 16, 31, 2, 63, 22], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 11, 12, 16, 12, 16, 31, 2, 63, 22]]
1
204
X, K, D = [int(i) for i in input().strip().split(' ')] tmp = X // D d1 = X - (D * tmp) d2 = X - (D * (tmp + 1)) if tmp >= K: ans = X - (D * K) else: if (tmp % 2) ^ (K % 2) == 0: ans = d1 else: ans = d2 print(abs(ans))
X, K, D = [abs(int(i)) for i in input().strip().split(' ')] tmp = X // D d1 = X - (D * tmp) d2 = X - (D * (tmp + 1)) if tmp >= K: ans = X - (D * K) else: if (tmp % 2) ^ (K % 2) == 0: ans = d1 else: ans = d2 print(abs(ans))
[["+", 0, 1, 0, 662, 12, 658, 8, 652, 63, 22], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 24], ["+", 8, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
102
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i) #define all(n) begin(n), end(n) using ll = long long; using P = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vs = ve...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i) #define all(n) begin(n), end(n) using ll = long long; using P = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vs = ve...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 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, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
206
X,K,D=map(int,input().split()) if K>=0: if K<int(X/D): print(abs(X-K*D)) else: if abs(X-(int(X/D)+1)*D)<abs(X-int(X/D)*D): A=X-(int(X/D)+1)*D if (K-(int(X/D)+1))%2==0: print(abs(A)) else: if abs(A+D)<abs(A-D): ...
X,K,D=map(int,input().split()) if X>=0: if K<int(X/D): print(abs(X-K*D)) else: if abs(X-(int(X/D)+1)*D)<abs(X-int(X/D)*D): A=X-(int(X/D)+1)*D if (K-(int(X/D)+1))%2==0: print(abs(A)) else: if abs(A+D)<abs(A-D): ...
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]]
5
474
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); ll x, k, d; cin >> x >> k >> d; ll time = abs(x) / d; ll yv = x % d; ll res = 0; if (time > k) { if (x < 0) res = x + k * d; ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); ll x, k, d; cin >> x >> k >> d; ll time = abs(x) / d; ll yv = x % d; ll res = 0; if (time > k) { if (x < 0) res = x + k * d; ...
[["+", 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
178
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) using namespace std; using ll = long long; using ld = long dou...
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) using namespace std; using ll = long long; using ld = long dou...
[["+", 64, 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
298
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll, ll>; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() c...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll, ll>; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() c...
[["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 85], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22]]
1
182
X, K, D = map(int, input().split()) if K * D < abs(X): if X < 0: print(X + K * D) else: print(abs(X - K * D)) else: a = abs(X // D) if (K - a) % 2 == 0: print(X % D) else: print(abs(X % D - D))
X, K, D = map(int, input().split()) if K * D < abs(X): if X < 0: print(abs(X + K * D)) else: print(X - K * D) else: a = abs(X // D) if (K - a) % 2 == 0: print(X % D) else: print(abs(X % D - D))
[["+", 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], ["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
94
#include <bits/stdc++.h> using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; long long s = abs(X) / D; if (s >= K) { if (X < 0) cout << X + D * K << endl; else cout << abs(X - D * K) << endl; return 0; } K -= s; if (X < 0) X += s * D; else X -= s * D;...
#include <bits/stdc++.h> using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; long long s = abs(X) / D; if (s >= K) { if (X < 0) cout << abs(X + D * K) << endl; else cout << abs(X - D * K) << endl; return 0; } K -= s; if (X < 0) X += s * D; else X -= s...
[["+", 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]]
1
166
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["-", 51, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["-", 51, 2, 3, 4, 0, 16, 12, 16, 17, 48], ["-", 51, 2, 3, 4, 0, 16, 12, 16, 12, 22]]
1
797
#include <bits/stdc++.h> using namespace std; #define int long long template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } signed main() { int x, k, d; c...
#include <bits/stdc++.h> using namespace std; #define int long long template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } signed main() { int x, k, d; c...
[["+", 8, 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
214
def resolve(): X,K,D = map(int,input().split()) X = abs(X) if K * D <= X: print(X-K*D) return K = X//D X %= D if K %2 ==0: print(X) else: print(abs(X-D)) resolve()
def resolve(): X,K,D = map(int,input().split()) X = abs(X) if K * D <= X: print(X-K*D) return K -= X//D X %= D if K %2 ==0: print(X) else: print(abs(X-D)) resolve()
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 14, 8, 196, 0, 1, 0, 677, 17, 110]]
5
78
#include <bits/stdc++.h> using namespace std; #define LL long long LL x, k, d; int main() { cin >> x >> k >> d; int fg = x < 0 ? -1 : 1; LL c = abs(x) / d; if (k <= c) { x = fg * (abs(x) - k * d); } else { k -= c; x = fg * (abs(x) % d); if (k & 1) x = x < 0 ? x + d : x - d; } cout <...
#include <bits/stdc++.h> using namespace std; #define LL long long LL x, k, d; int main() { cin >> x >> k >> d; int fg = x < 0 ? -1 : 1; LL c = abs(x) / d; if (k <= c) { x = fg * (abs(x) - k * d); } else { k -= c; x = fg * (abs(x) % d); if (k & 1) x = x < 0 ? x + d : x - d; } cout <...
[["+", 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
123
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; typedef tuple<ll, ll, ll, ll, ll> t5; #define rep(a, n) for (ll ...
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; typedef tuple<ll, ll, ll, ll, ll> t5; #define rep(a, n) for (ll ...
[["+", 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
379
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NUL...
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NUL...
[["+", 0, 43, 49, 50, 51, 16, 31, 23, 0, 24], ["+", 0, 43, 49, 50, 51, 16, 31, 23, 0, 25], ["+", 64, 9, 0, 1, 0, 16, 12, 2, 63, 22], ["+", 0, 1, 0, 16, 12, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
1
240
import sys sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inl = lambda: [int(x) for x in sys.stdin.readline().split()] ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) X, K, D = inl() def solve(): if X >...
import sys sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inl = lambda: [int(x) for x in sys.stdin.readline().split()] ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) X, K, D = inl() def solve(): if X >...
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 31, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 22]]
5
221
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
[["+", 12, 664, 28, 23, 0, 657, 31, 664, 17, 33]]
5
791
#include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #includ...
#include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #includ...
[["-", 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
1,180
x,k,d=map(int,input().split()) s=x%d t=x//d if k<t: print(x-k*d) else: print(abs(s-(k-t)%2*d))
x,k,d=map(int,input().split()) x=abs(x) s=x%d t=x//d if k<t: print(x-k*d) else: print(abs(s-(k-t)%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
60
X, K, D=map(int, input().split()) if D*K<=abs(X): print(X-D*K) exit() if (abs(X)//D)%2==0: if K%2==0: print(abs(X)%D) else: print(D-abs(X)%D) else: if K%2==1: print(abs(X)%D) else: print(D-abs(X)%D)
X, K, D=map(int, input().split()) if D*K<=abs(X): print(abs(X)-D*K) exit() if (abs(X)//D)%2==0: if K%2==0: print(abs(X)%D) else: print(D-abs(X)%D) else: if K%2==1: print(abs(X)%D) else: print(D-abs(X)%D)
[["+", 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
113
def main(): X, K, D = map(int, input().split()) X = abs(X) k = X // D if k >= K: return X - D * K K -= k X -= D * k if k & 1: return D - X return X print(main())
def main(): X, K, D = map(int, input().split()) X = abs(X) k = X // D if k >= K: return X - D * K K -= k X -= D * k if K & 1: return D - X return X print(main())
[["-", 0, 14, 8, 196, 0, 57, 15, 657, 31, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 657, 31, 22]]
5
70
#include <algorithm> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(i, a, n) fo...
#include <algorithm> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(i, a, n) fo...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["-", 75, 76, 0, 9, 0, 57, 15, 339, 51, 22], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 51, 22]]
1
207
#include <bits/stdc++.h> //#include <ext/pb_ds/detail/standard_policies.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define ll long long #define int long long #define pb push_back #define ins insert #define rs resize #define br break; #define cont continue; #define vi vector<i...
#include <bits/stdc++.h> //#include <ext/pb_ds/detail/standard_policies.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define ll long long #define int long long #define pb push_back #define ins insert #define rs resize #define br break; #define cont continue; #define vi vector<i...
[["-", 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], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
319
#include <bits/stdc++.h> using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; long long ans = abs(X) / D; if (K < ans) { cout << abs(X - D * K) << endl; return 0; } long long pos = abs(X) - D * ans; K -= ans; if (K % 2 == 0) cout << pos << endl; else cout << abs(po...
#include <bits/stdc++.h> using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; long long ans = abs(X) / D; if (K < ans) { cout << abs(X) - D * K << endl; return 0; } long long pos = abs(X) - D * ans; K -= ans; if (K % 2 == 0) cout << pos << endl; else cout << abs(po...
[["+", 31, 16, 12, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
106
#include <bits/stdc++.h> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; if (x < 0) x *= -1; long long step = x / d; if (k <= step) cout << x - step * d; else { k -= step; if (k % 2 == 0) cout << x - step * d; else cout << step * d + d - x; } }
#include <bits/stdc++.h> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; if (x < 0) x *= -1; long long step = x / d; if (k <= step) cout << x - d * k; else { k -= step; if (k % 2 == 0) cout << x - step * d; else cout << step * d + d - x; } }
[["-", 64, 1, 0, 16, 12, 16, 12, 16, 31, 22], ["-", 64, 1, 0, 16, 12, 16, 12, 16, 17, 48], ["+", 64, 1, 0, 16, 12, 16, 12, 16, 17, 48], ["+", 64, 1, 0, 16, 12, 16, 12, 16, 12, 22]]
1
94
from sys import stdin, setrecursionlimit #input = stdin.buffer.readline setrecursionlimit(10 ** 7) from heapq import heappush, heappop from bisect import bisect_left, bisect_right from collections import deque, defaultdict, Counter from itertools import combinations, permutations, combinations_with_replacement from it...
from sys import stdin, setrecursionlimit #input = stdin.buffer.readline setrecursionlimit(10 ** 7) from heapq import heappush, heappop from bisect import bisect_left, bisect_right from collections import deque, defaultdict, Counter from itertools import combinations, permutations, combinations_with_replacement from it...
[["+", 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
155
# import sys; input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) #処理内容 def main(): X, K, D = getlist() if X - K * D >= 0: print(X - K * D) elif X + K * D <= 0: print(ab...
# import sys; input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) #処理内容 def main(): X, K, D = getlist() if X - K * D >= 0: print(X - K * D) elif X + K * D <= 0: print(ab...
[["-", 0, 14, 8, 196, 0, 57, 75, 665, 0, 683], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 0, 22], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 20], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 0, 612], ["+", 0, 14, 8, 196, 0, 57, 75, 76, 0, 95]]
5
145
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.InputMismatchException; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) throws Exception { Thread th...
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.InputMismatchException; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) throws Exception { Thread th...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["-", 0, 57, 15, 15, 0, 16, 12, 16, 12, 22], ["+", 15, 15, 0, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]]
3
563
#include <bits/stdc++.h> #include <unistd.h> #if __has_include(<local.h>) #include <local.h> #endif using namespace std; typedef long long int LL; typedef long long int LLint; // Faster Program #define endl "\n" // Faster Coding #define ED return #define GET(a) ...
#include <bits/stdc++.h> #include <unistd.h> #if __has_include(<local.h>) #include <local.h> #endif using namespace std; typedef long long int LL; typedef long long int LLint; // Faster Program #define endl "\n" // Faster Coding #define ED return #define GET(a) ...
[["+", 8, 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
469
X, K, D = map(int, input().split()) if abs(X) >= K * D: if X > 0: ans = X - K * D else: ans = X + K * D print(abs(ans)) else: count = int(X / D) if X > 0: one = X - D * count two = one - D if (K - count) % 2 == 0: print(abs(one)) else: print(abs(two)) else: one = X +...
X, K, D = map(int, input().split()) if abs(X) >= K * D: if X > 0: ans = X - K * D else: ans = X + K * D print(abs(ans)) else: count = int(abs(X) / D) if X > 0: one = X - D * count two = one - D if (K - count) % 2 == 0: print(abs(one)) else: print(abs(two)) else: one ...
[["+", 12, 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
151
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #includ...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #includ...
[["+", 0, 2, 3, 4, 0, 16, 12, 2, 63, 22], ["+", 3, 4, 0, 16, 12, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 12, 2, 3, 4, 0, 25]]
1
583
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int x, k, d; cin >> x >> k >> d; x = llabs(x); if (k * d < x) cout << x - k * d; else if (x / d % 2 == k % 2) cout << x % d; else cout << d - x % d; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int x, k, d; cin >> x >> k >> d; x = llabs(x); if (k < x / d) cout << x - k * d; else if (x / d % 2 == k % 2) cout << x % d; else cout << d - x % d; return 0; }
[["-", 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
84
import sys import heapq import math import fractions import bisect import itertools from collections import Counter from collections import deque from operator import itemgetter def input(): return sys.stdin.readline().strip() def mp(): return map(int,input().split()) def lmp(): return list(map(int,input().split())) x...
import sys import heapq import math import fractions import bisect import itertools from collections import Counter from collections import deque from operator import itemgetter def input(): return sys.stdin.readline().strip() def mp(): return map(int,input().split()) def lmp(): return list(map(int,input().split())) x...
[["+", 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
153
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int Inf = 1000000010; constexpr ll INF = 2000000000000000000; constexpr ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<int, int> P; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int Inf = 1000000010; constexpr ll INF = 2000000000000000000; constexpr ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<int, int> P; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
460
x,k,d=map(int,input().split()) if abs(x)>=k*d:print(abs(abs(x)-k*d)) else: k-=abs(x)//d x=x%d if x>0 else -(x%d) if k%2: print(abs(x-d) if x>0 else d+x) else: print(abs(x))
x,k,d=map(int,input().split()) if abs(x)>=k*d:print(abs(abs(x)-k*d)) else: k-=abs(x)//d x=x%d if x>0 else -(-x%d) if k%2: print(abs(x-d) if x>0 else d+x) else: print(abs(x))
[["+", 0, 664, 28, 23, 0, 657, 31, 664, 17, 33]]
5
99
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back using namespace std; typedef long long ll; const int MAXN = 1000 * 1000 + 7; const int SS = 1 << 20; const int INF = 1000 * 1000 * 1000 + 7; int t[MAXN]; int n, m, q; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int T; ...
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back using namespace std; typedef long long ll; const int MAXN = 1000 * 1000 + 7; const int SS = 1 << 20; const int INF = 1000 * 1000 * 1000 + 7; int t[MAXN]; int n, m, q; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int T; ...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["-", 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 = map(int, input().split()) X = abs(X) if K*D <= X: print(X - K*D) else: m = X // D re = K - m if re % 2 == 0: print(abs(X - K*m)) else: print(abs(X - K*(m+1)))
X, K, D = map(int, input().split()) X = abs(X) if K*D <= X: print(abs(X - K*D)) else: m = X // D re = K - m if re % 2 == 0: print(abs(X - D*m)) else: print(abs(X - D*(m+1)))
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22]]
5
86
public class Main { private static void solve() { long x = nl(); long k = nl(); long d = nl(); long y = x / d; long ans = x - y * d; if (y >= k) { System.out.println(x - k * d); } else { long z = k - y; if (z % 2 == 0) { System.out.println(ans); } else ...
public class Main { private static void solve() { long x = Math.abs(nl()); long k = nl(); long d = nl(); long y = x / d; long ans = x - y * d; if (y >= k) { System.out.println(x - k * d); } else { long z = k - y; if (z % 2 == 0) { System.out.println(ans); ...
[["+", 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
767
LI = lambda: list(map(int, input().split())) X, K, D = LI() def main(): x = abs(X) a = x // D if K <= a: ans = x - K * D print(ans) return x -= a * D k = K - a if k % 2 == 0: ans = x - a * D else: ans = abs(x - D) print(ans) if __...
LI = lambda: list(map(int, input().split())) X, K, D = LI() def main(): x = abs(X) a = x // D if K <= a: ans = x - K * D print(ans) return x -= a * D k = K - a if k % 2 == 0: ans = x else: ans = abs(x - D) print(ans) if __name__ =...
[["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 31, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 17, 48], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22]]
5
109
X,K,D = map(int,input().split()) if X - K*D > 0: print(X-K*D) exit() K -= X//D X %= D if K % 2 == 1: X = D-X print(X)
X,K,D = map(int,input().split()) X = abs(X) if X - K*D > 0: print(X-K*D) exit() K -= X//D X %= D if K % 2 == 1: X = D-X print(X)
[["+", 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
62
#include <bits/stdc++.h> using namespace std; #pragma region macros_and_aliases #define rep(i, n) for (long long i = 0; i < (n); i++) #define rrep(i, n) for (long long i = (n)-1; i > -1; i--) #define Rep(i, m, n) for (long long i = (m); i < (n); i++) #define rRep(i, m, n) for (long long i = (n)-1; i >= (m); i--) #defin...
#include <bits/stdc++.h> using namespace std; #pragma region macros_and_aliases #define rep(i, n) for (long long i = 0; i < (n); i++) #define rrep(i, n) for (long long i = (n)-1; i > -1; i--) #define Rep(i, m, n) for (long long i = (m); i < (n); i++) #define rRep(i, m, n) for (long long i = (n)-1; i >= (m); i--) #defin...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 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, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
3,430
X, K, D = map(int, input().split()) k = (D*K-X)//(2*D) ans = min(abs(X+D*K), abs(X-D*K)) for i in range(k-10, k+10): if 0<=k<=K: ans = min(ans, abs(X+k*D-(K-k)*D)) print(ans)
X, K, D = map(int, input().split()) k = (D*K-X)//(2*D) ans = min(abs(X+D*K), abs(X-D*K)) for i in range(k-10, k+10): if 0<=i<=K: ans = min(ans, abs(X+i*D-(K-i)*D)) print(ans)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 3, 4, 0, 657, 31, 657, 12, 657, 31, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 657, 31, 22], ["-", 0, 657, 12, 657, 31, 23, 0, 657, 12, 22], ["+", 0, 657, 12, 657, 31, 23, 0, 657, 12, 22]]
5
103
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; ll INF = (ll)1e20; int iINF = (int)1e20; ll mod = (ll)1e9 + 7; mt19937 gen(chrono::steady_clock::now().time_since_epoch().count()); signed main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll num = ((x + d - 1) / d...
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; ll INF = (ll)1e20; int iINF = (int)1e20; ll mod = (ll)1e9 + 7; mt19937 gen(chrono::steady_clock::now().time_since_epoch().count()); signed main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll num = ((x + d - 1) / d...
[["+", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 31, 23, 0, 25], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 12, 13]]
1
267
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define sint int32_t #define int long long int #define all(v) v.begin(), v.end() #define vii vector<int> #define pb push_back #define pii pair<int, int> #define F fi...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define sint int32_t #define int long long int #define all(v) v.begin(), v.end() #define vii vector<int> #define pb push_back #define pii pair<int, int> #define F fi...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22]]
1
177
x, k, d = map(int, input().split()) temp = (0 - -x//d) if temp > k: ans = x - d*k else: ref1 = x - temp*d #0かマイナス ref2 = x - (temp - 1)*d #プラス k = k - temp if k%2 == 0: ans = ref1 else: ans = ref2 print(abs(ans))
x, k, d = map(int, input().split()) x = abs(x) temp = (0 - -x//d) if temp > k: ans = x - d*k else: ref1 = x - temp*d #0かマイナス ref2 = x - (temp - 1)*d #プラス k = k - temp if k%2 == 0: ans = ref1 else: ans = ref2 print(abs(ans))
[["+", 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
89
#include <bits/stdc++.h> using namespace std; #define AB_BHI_NI_DEGI \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define int l...
#include <bits/stdc++.h> using namespace std; #define AB_BHI_NI_DEGI \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define int l...
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72]]
1
317
X, K, D = list(map(int, input().split())) t = X // D if K <= t: print(X - K * D) exit() K -= t X -= t * D if K % 2 == 0: print(X) else: print(abs(X - D))
X, K, D = list(map(int, input().split())) X = abs(X) t = X // D if K <= t: print(X - K * D) exit() K -= t X -= t * D 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
72
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll x, k, d; cin >> x >> k >> d; if (x < 0) x *= -1; if (k <= x / d) cout << x - d * k << endl; else { k -= x / d; x %= d; if (x % 2 == 0) cout << d - x << endl; else cout << x << endl; } }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll x, k, d; cin >> x >> k >> d; if (x < 0) x *= -1; if (k <= x / d) cout << x - d * k << endl; else { k -= x / d; x %= d; if (k % 2) cout << d - x << endl; else cout << x << endl; } }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
97
#include <bits/stdc++.h> using namespace std; typedef long long int lli; typedef unsigned long long int ulli; typedef long double ld; const lli INF = 1e9 + 100; const lli INF64 = (1LL << 61) + 100; const lli MOD = 1e9 + 7; const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; lli b...
#include <bits/stdc++.h> using namespace std; typedef long long int lli; typedef unsigned long long int ulli; typedef long double ld; const lli INF = 1e9 + 100; const lli INF64 = (1LL << 61) + 100; const lli MOD = 1e9 + 7; const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; lli b...
[["+", 15, 339, 51, 16, 31, 16, 31, 2, 63, 22], ["+", 51, 16, 31, 16, 31, 2, 3, 4, 0, 24], ["+", 51, 16, 31, 16, 31, 2, 3, 4, 0, 25]]
1
400
#include <iostream> using namespace std; #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <vector> #define MOD1 1000000007 #define MOD2 998244353 #define LIMIT1 200002 #define LIMIT2 500002 typedef long long ll; typedef long double ld; typedef con...
#include <iostream> using namespace std; #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <vector> #define MOD1 1000000007 #define MOD2 998244353 #define LIMIT1 200002 #define LIMIT2 500002 typedef long long ll; typedef long double ld; typedef con...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 75, 76, 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
595
#include "bits/stdc++.h" using namespace std; int64_t z(int64_t p) { if (p >= 0) return p; else return p * -1; } int main() { int64_t x, k, d, di, ans, a; cin >> x >> k >> d; di = x / d; if (di >= k) ans = z(x) - k * d; else { if (x > 0) { a = x - di * d; if ((k - di) % 2 == ...
#include "bits/stdc++.h" using namespace std; int64_t z(int64_t p) { if (p >= 0) return p; else return p * -1; } int main() { int64_t x, k, d, di, ans, a; cin >> x >> k >> d; di = z(x) / d; if (di >= k) ans = z(x) - k * d; else { if (x > 0) { a = x - di * d; if ((k - di) % 2 ...
[["+", 0, 1, 0, 11, 12, 16, 31, 2, 63, 22], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 25]]
1
191
X, K, D = map(int, input().split()) if K*D <= X: print(X-K*D) exit() near0_X = X % D after_K = K - X//D if after_K % 2 == 0: print(near0_X) else: print(D-near0_X)
X, K, D = map(int, input().split()) X = abs(X) if K*D <= X: print(X-K*D) exit() near0_X = X % D after_K = K - X//D if after_K % 2 == 0: print(near0_X) else: print(D-near0_X)
[["+", 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
67
/* Author: Alam Khan AUST CSE 40th Batch */ #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef long long ll; typedef tree<ll, null_type, less_equal<ll...
/* Author: Alam Khan AUST CSE 40th Batch */ #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef long long ll; typedef tree<ll, null_type, less_equal<ll...
[["+", 8, 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
256
#include <bits/stdc++.h> //#include <time.h> // #include<set> // #include<vector> // #include<algorithm> // #include<iostream> using namespace std; #include <math.h> // to increase precision // std::cout<<std::fixed; // std::cout<<std::setprecision(6)<<z; // clock_t tStart = clock(); // printf("Time taken: %.9fs\n", (...
#include <bits/stdc++.h> //#include <time.h> // #include<set> // #include<vector> // #include<algorithm> // #include<iostream> using namespace std; #include <math.h> // to increase precision // std::cout<<std::fixed; // std::cout<<std::setprecision(6)<<z; // clock_t tStart = clock(); // printf("Time taken: %.9fs\n", (...
[["+", 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
214
#include <bits/stdc++.h> using namespace std; // Made with <3 by MinumCoklatPanas typedef long long ll; const int INF = 1e9; const ll INFF = 1e18; const int MAXN = 510; const int MOD = 1e9 + 7; const double PI = acos(-1.0); const double INFD = 1E9; const double EPS = 1e-9; void process(ll x, ll k, ll d) { if (k % 2...
#include <bits/stdc++.h> using namespace std; // Made with <3 by MinumCoklatPanas typedef long long ll; const int INF = 1e9; const ll INFF = 1e18; const int MAXN = 510; const int MOD = 1e9 + 7; const double PI = acos(-1.0); const double INFD = 1E9; const double EPS = 1e-9; void process(ll x, ll k, ll d) { if (k % 2...
[["+", 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]]
1
373
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //required #include <ext/pb_ds/tree_policy.hpp> //required using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //required #include <ext/pb_ds/tree_policy.hpp> //required using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order...
[["-", 51, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 51, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72]]
1
574
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; int main(void) { long long x, k, d; cin >> x >> k >> d; long long s = x / d; long long p, q; if (x >= 0) { p = x - d * s; q = p - d; } else { p = x + d * s; q = p + d; } ...
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; int main(void) { long long x, k, d; cin >> x >> k >> d; long long s = abs(x) / d; long long p, q; if (x >= 0) { p = x - d * s; q = p - d; } else { p = x + d * s; q = p + 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
210
#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; #define PI acos(-1) #define Mod (int)1000000007 #define INFTY (int)INT_MAX #define Rep(i, n) for (int i = 0; i < (int)(n); i++) #define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++) #define All(vec) vec.begin(), vec.end...
#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; #define PI acos(-1) #define Mod (int)1000000007 #define INFTY (int)INT_MAX #define Rep(i, n) for (int i = 0; i < (int)(n); i++) #define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++) #define All(vec) vec.begin(), vec.end...
[["+", 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
249
#include <bits/stdc++.h> #define lld long long int #define vec vector<lld> #define pll pair<lld, lld> #define pb push_back #define ss second #define ff first #define mp make_pair #define mod 1000000007 #define answer(x) cout << endl << "answer : " << x << endl << endl; #define op(x) cout << x << endl; #define maxn 1000...
#include <bits/stdc++.h> #define lld long long int #define vec vector<lld> #define pll pair<lld, lld> #define pb push_back #define ss second #define ff first #define mp make_pair #define mod 1000000007 #define answer(x) cout << endl << "answer : " << x << endl << endl; #define op(x) cout << x << endl; #define maxn 1000...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
241
package main import ( "bufio" "fmt" "os" "strconv" ) var ( finv, inv, fac [MAX]int ) func COM(n, k int) int { MOD := int(MOD) if n < k { return 0 } if n < 0 || k < 0 { return 0 } return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD } func init() { MOD := int(MOD) fac[0] = 1 fac[1] = 1 finv[0] = 1 f...
package main import ( "bufio" "fmt" "os" "strconv" ) var ( finv, inv, fac [MAX]int ) func COM(n, k int) int { MOD := int(MOD) if n < k { return 0 } if n < 0 || k < 0 { return 0 } return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD } func init() { MOD := int(MOD) fac[0] = 1 fac[1] = 1 finv[0] = 1 f...
[["-", 8, 196, 0, 57, 64, 196, 0, 436, 17, 110], ["+", 8, 196, 0, 57, 64, 196, 0, 436, 17, 32], ["+", 64, 196, 0, 436, 12, 432, 0, 91, 17, 33]]
7
1,733
X,K,D = map(int,input().split()) Xmin = X - D*K Xmax = X + D*K if Xmin * Xmax <= 0: ans = min(X%(2*D), 2*D - X%(2*D)) elif Xmin > 0: ans = Xmin else: ans = -Xmax print(ans)
X,K,D = map(int,input().split()) Xmin = X - D*K Xmax = X + D*K if Xmin * Xmax <= 0: ans = min(Xmax%(2*D), 2*D - (Xmax%(2*D))) elif Xmin > 0: ans = Xmin else: ans = -Xmax print(ans)
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 12, 652, 3, 4, 0, 657, 12, 657, 31, 22], ["+", 12, 652, 3, 4, 0, 657, 12, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 23, 0, 657, 31, 22], ["+", 0, 657, 12, 23, 0, 657, 12, 23, 0, 25]]
5
81
X, K, D, = map(int, input().split()) ans = 0 step = abs(X) // D if step >= K: ans = abs(X) - D*K else: cur = X%D rest = K - step # print(cur) # print(rest) if rest%2 != 0: ans = min(abs(cur+D), abs(cur-D)) # ans = min(abs(cur-D), abs(cur+D)) else: ans = cur print(an...
X, K, D, = map(int, input().split()) ans = 0 step = abs(X) // D if step >= K: ans = abs(X) - D*K else: cur = abs(X)%D rest = K - step # print(cur) # print(rest) if rest%2 != 0: ans = min(abs(cur+D), abs(cur-D)) else: ans = cur 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
94
#include <bits/stdc++.h> #define boost_io \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define num(a) a - '0' #define rep(i, ...
#include <bits/stdc++.h> #define boost_io \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define num(a) a - '0' #define rep(i, ...
[["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["-", 12, 23, 0, 16, 12, 16, 31, 23, 0, 24], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 17, 85], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 72], ["-", 12, 23, 0, 16, 12, 16, 31, 23, 0, 25]]
1
420
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 13; int a[maxn]; int main() { ll x, k, d; scanf("%lld%lld%lld", &x, &k, &d); if (x < 0) x = -x; ll cal = x / d; if (cal >= k) { printf("%lld", x - cal * d); } else { ll res = x - cal * d; ll way = k - ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 13; int a[maxn]; int main() { ll x, k, d; scanf("%lld%lld%lld", &x, &k, &d); if (x < 0) x = -x; ll cal = x / d; if (cal >= k) { printf("%lld", abs(x - k * d)); } else { ll res = x - cal * d; ll way = k...
[["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["-", 0, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
143
#pragma GCC optimize(2) #pragma GCC optimize(3) #include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (int i = a; i <= n; i++) #define per(i, a, n) for (int i = n; i >= a; i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sz(...
#pragma GCC optimize(2) #pragma GCC optimize(3) #include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (int i = a; i <= n; i++) #define per(i, a, n) for (int i = n; i >= a; i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sz(...
[["-", 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
317
/** * Author : Deep Raval * There are no two words in the English language more harmful than "good job". * 1729 0_0 **/ #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #incl...
/** * Author : Deep Raval * There are no two words in the English language more harmful than "good job". * 1729 0_0 **/ #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #incl...
[["+", 49, 50, 51, 2, 3, 4, 0, 2, 63, 22], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
391
x,k,d=map(int,input().split()) ans=0 if x//d>=k: ans=x-d*k else: if ((x//d)%2==0 and k%2==0) or ((x//d)%2==1 and k%2==1): ans=x%d else: ans=abs(x%d-d) print(ans)
x,k,d=map(int,input().split()) x=abs(x) ans=0 if x//d>=k: ans=x-d*k else: if ((x//d)%2==0 and k%2==0) or ((x//d)%2==1 and k%2==1): ans=x%d else: ans=abs(x%d-d) print(ans)
[["+", 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
95
#include <algorithm> #include <bits/stdc++.h> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <iomanip> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #in...
#include <algorithm> #include <bits/stdc++.h> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <iomanip> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #in...
[["+", 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
540
X, K, D = map(int,input().split()) X = abs(X) if K*D<X: print(X-K*D) else: mod = X%D div = X//D if (K-D)%2==1: print(mod) else: print(abs(mod-D))
X, K, D = map(int,input().split()) X = abs(X) if K*D<X: print(X-K*D) else: mod = X%D div = X//D if (K-div)%2==0: print(mod) else: print(abs(mod-D))
[["-", 15, 666, 0, 657, 31, 23, 0, 657, 12, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 12, 22], ["-", 75, 76, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 0, 612]]
5
77
#pragma GCC optimize("Ofast") #include <algorithm> #include <bitset> #include <cctype> #include <cstdint> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <...
#pragma GCC optimize("Ofast") #include <algorithm> #include <bitset> #include <cctype> #include <cstdint> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <...
[["+", 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
165
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 5; const int MOD = 1e9 + 7; int a[maxn]; ll f[maxn]; int first[maxn]; ll ans1[maxn]; int cmp(int a, int b) { return a > b; } string s; map<ll, int> mp; vector<int> v; int main() { ll x, k, d; cin >> x >> k >> d; ll x1 = abs...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 5; const int MOD = 1e9 + 7; int a[maxn]; ll f[maxn]; int first[maxn]; ll ans1[maxn]; int cmp(int a, int b) { return a > b; } string s; map<ll, int> mp; vector<int> v; int main() { ll x, k, d; cin >> x >> k >> d; ll x1 = abs...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22]]
1
169
#include <algorithm> #include <array> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <v...
#include <algorithm> #include <array> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <v...
[["+", 64, 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
252
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; using namespace std; const long long int INF = 1e18; const long long int MOD = 1e9 + 7; typedef pair<ll, ll> pairs; typedef vector<pairs> p; struct edge { ll to, cost; }; ll gcd(ll a, ll b) { if (b == 0) { return a; } else { ret...
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; using namespace std; const long long int INF = 1e18; const long long int MOD = 1e9 + 7; typedef pair<ll, ll> pairs; typedef vector<pairs> p; struct edge { ll to, cost; }; ll gcd(ll a, ll b) { if (b == 0) { return a; } else { ret...
[["+", 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
648