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 <iostream>
using namespace std;
int main() {
long long int x, k, d;
cin >> x >> k >> d;
x = abs(x);
int step = x / d;
if (step >= k)
cout << (x - k * d);
else {
int pos = x % d;
k = k - step;
if (k % 2 == 0) {
cout << abs(pos);
} else {
cout << min(abs(pos - d), abs... | #include <iostream>
using namespace std;
int main() {
long long int x, k, d;
cin >> x >> k >> d;
x = abs(x);
long long int step = x / d;
if (step >= k)
cout << (x - k * d);
else {
long long int pos = x % d;
k = k - step;
if (k % 2 == 0) {
cout << abs(pos);
} else {
cout << m... | [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 75, 76, 0, 9, 0, 43, 39, 86, 0, 96]] | 1 | 117 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll a = x / d;
ll ans;
if (x / d > k)
ans = abs(x) - d * k;
else if ((a % 2) == (k % 2))
ans = abs(x) % d;
else... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll a = abs(x) / d;
ll ans;
if (abs(x) / d > k)
ans = abs(x) - d * k;
else if ((a % 2) == (k % 2))
ans = abs(x) %... | [["+", 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], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 15, 339, 51, 16, 31, 16, 31, 2, 63, 22], ["+", 51, 16, 31, 16, 31, 2, 3, 4, 0, 25]] | 1 | 130 |
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"strconv"
)
var DEBUG = true
// -----------------------------------------------------------------------------
// IO helper functions
// Returns next token from input. It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]... | package main
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"strconv"
)
var DEBUG = true
// -----------------------------------------------------------------------------
// IO helper functions
// Returns next token from input. It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]... | [["+", 8, 196, 0, 431, 12, 432, 0, 2, 63, 22], ["+", 0, 431, 12, 432, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 7 | 1,962 |
X,K,D = map(int,input().split())
X=abs(X)
q=X//D
mod=X%D
if q>=K:
if (K-q)%2==0:
ans=mod
else:
ans=D-mod
else:
ans=X-q*D
print(ans)
| X,K,D = map(int,input().split())
X=abs(X)
q=X//D
mod=X%D
if q <= K:
if (K-q)%2==0:
ans=mod
else:
ans=D-mod
else:
ans=X-K*D
print(ans)
| [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 31, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 31, 22]] | 5 | 73 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x / d > k) {
if (x < 0)
cout << abs(x + k * d) << endl;
else
cout << abs(x - k * d) << endl;
} else {
k -= abs(x / d);
i... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (abs(x / d) > k) {
if (x < 0)
cout << abs(x + k * d) << endl;
else
cout << abs(x - k * d) << endl;
} else {
k -= abs(x / d);
... | [["+", 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]] | 1 | 160 |
_x, _k, d = map(int, input().split())
x = abs(_x)
k = _k
if x >= d:
i = x // d
if i <= k:
k -= k - i
x -= i * d
else:
x -= k * d
k = 0
if k % 2 != 0:
x -= d
print(abs(x))
| _x, _k, d = map(int, input().split())
x = abs(_x)
k = _k
if x >= d:
i = x // d
if i <= k:
k -= i
x -= i * d
else:
x -= k * d
k = 0
if k % 2 != 0:
x -= d
print(abs(x))
| [["-", 64, 196, 0, 1, 0, 677, 12, 657, 31, 22], ["-", 64, 196, 0, 1, 0, 677, 12, 657, 17, 33]] | 5 | 79 |
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_1 (i, j, n) for (int i = j; i < n; i++)
typedef long long ll;
typedef ... | #include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_1 (i, j, n) for (int i = j; i < n; i++)
typedef long long ll;
typedef ... | [["+", 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 | 249 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, k, d;
cin >> x >> k >> d;
x = abs(x);
if ((x / d) > k) {
x -= d * k;
k = 0;
} else {
x -= d * (x / d);
k -= (x / d);
}
if (k > 0) {
if (k % 2 == 1)
x = min(abs(x - d), abs(x + d));
else
x = min(min(a... | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, k, d;
cin >> x >> k >> d;
x = abs(x);
if ((x / d) > k) {
x -= d * k;
k = 0;
} else {
k -= (x / d);
x -= d * (x / d);
}
if (k > 0) {
if (k % 2 == 1)
x = min(abs(x - d), abs(x + d));
else
x = min(min(a... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 48]] | 1 | 156 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll X, K, D;
cin >> X >> K >> D;
// X >= 0として一般性を失わない!
X = abs(X);
ll ans;
if (X - K * D > 0) {
// 原点まで至らない場合
ans = X - K * D;
} else {
ll di = X / D; // 引ける回数
ll x0 = X - di * D; // x >= 0 側で最接近したときの座標... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll X, K, D;
cin >> X >> K >> D;
// X >= 0として一般性を失わない!
X = abs(X);
ll ans;
if (X / D - K > 0) {
// 原点まで至らない場合 K * D < X <= 10^15 が保証されるので掛け算OK
ans = X - K * D;
} else {
ll di = X / D; // 引ける回数
ll x0 = X... | [["+", 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 | 124 |
XKD = list(map(int, input().split()))
posi = XKD[0]
count = 0
factor = 0
if (XKD[1] > int(abs(posi) / XKD[2])):
time = XKD[1] - int(abs(posi) / XKD[2])
factor = int(abs(posi) / XKD[2])
else:
time = 0
factor = XKD[1]
if (posi >= 0):
posi -= XKD[2] * factor
else:
posi += XKD[2] * factor
if (po... | XKD = list(map(int, input().split()))
posi = XKD[0]
count = 0
factor = 0
if (XKD[1] > int(abs(posi) / XKD[2])):
time = XKD[1] - int(abs(posi) / XKD[2])
factor = int(abs(posi) / XKD[2])
else:
time = 0
factor = XKD[1]
if (posi >= 0):
posi -= XKD[2] * factor
else:
posi += XKD[2] * factor
if (po... | [["+", 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]] | 5 | 182 |
X, K, D = map(int, input().split())
count1 = X // D
count2 = (X // D)+1
if count1 < K:
if (K - count1) %2 ==0:
print(abs(abs(X)-abs(D*count1)))
else:
print(abs(abs(X)-abs(D*count2)))
else:
print(abs(abs(X)-abs(D*K))) | X, K, D = map(int, input().split())
count1 = abs(X) // D
count2 = (abs(X) // D)+1
if count1 < K:
if (K - count1) %2 ==0:
print(abs(abs(X)-abs(D*count1)))
else:
print(abs(abs(X)-abs(D*count2)))
else:
print(abs(abs(X)-abs(D*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], ["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 24], ["+", 12, 657, 31, 23, 0, 657, 31, 652, 63, 22], ["+", 31, 23, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 103 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;
int main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
ll max... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;
int main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
ll max... | [["-", 51, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 196 |
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template <class T> inline bool chmin(T &a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if ... | #include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template <class T> inline bool chmin(T &a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if ... | [["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]] | 1 | 285 |
x,k,d=gets.split.map(&:to_i)
if x>=k*d
puts x-k*d
else
if (x/d+k).even?
puts x%d
else
puts d-x%d
end
end
| x,k,d=gets.split.map(&:to_i)
x=x.abs
if x>=k*d
puts x-k*d
else
if (x/d+k).even?
puts x%d
else
puts d-x%d
end
end
| [["+", 36, 36, 36, 36, 0, 493, 0, 662, 31, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 486, 22], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22]] | 4 | 51 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for (ll i = 0; i < n; i++)
#define revf(i, n) for (ll i = n - 1; i >= 0; i -= 2)
#define REP(i, a, b) for (ll i = a; i < b; i+... | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for (ll i = 0; i < n; i++)
#define revf(i, n) for (ll i = n - 1; i >= 0; i -= 2)
#define REP(i, a, b) for (ll i = a; i < b; i+... | [["+", 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 | 304 |
import math
x, k, d = map(int, input().split())
if abs(x) >= d * k:
print(abs(x-d*k))
else:
temp = math.ceil(abs(x)/d)
if temp % 2 == 1:
if k % 2 == 1:
print(abs(abs(x)-temp*d))
else:
print(abs(abs(x)-temp*d+d))
elif temp % 2 == 0:
if k % 2 == 0:
... | import math
x, k, d = map(int, input().split())
if abs(x) >= d * k:
print(abs(abs(x)-d*k))
else:
temp = math.ceil(abs(x)/d)
if temp % 2 == 1:
if k % 2 == 1:
print(abs(abs(x)-temp*d))
else:
print(abs(abs(x)-temp*d+d))
elif temp % 2 == 0:
if k % 2 == 0:
... | [["+", 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 | 148 |
x,k,d = map(int,input().split())
ans = 0
if x < 0:
if k <= (x//d):
ans = abs(x+(k*d))
else:
a = abs((x//d))-1
x = x+(a*d)
k -= a
if k%2 == 0:
ans = abs(x)
else:
ans = abs(x+d)
elif x > 0:
if k <= (x//d):
ans = abs(x-(k*d))
... | x,k,d = map(int,input().split())
ans = 0
if x < 0:
if k <= abs((x//d))-1:
ans = abs(x+(k*d))
else:
a = abs((x//d))-1
x = x+(a*d)
k -= a
if k%2 == 0:
ans = abs(x)
else:
ans = abs(x+d)
elif x > 0:
if k <= (x//d):
ans = abs(x-(k*d... | [["+", 0, 57, 15, 666, 0, 657, 31, 652, 63, 22], ["+", 15, 666, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 15, 666, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 64, 196, 0, 57, 15, 666, 0, 657, 12, 612]] | 5 | 185 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, k, d;
cin >> x >> k >> d;
// |x|-k*d = 0
// |x| = k*d
// |x|/d = k
// 0を超えてしまったら戻ってを繰り返せばよい。
if (abs(x) / d > k)
cout << abs(x) - k * d << endl;
else if ((abs(x) / d) % 2 == 0)
cout << abs(abs(x) - (abs(x) / d) * d) << end... | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, k, d;
cin >> x >> k >> d;
// |x|-k*d = 0
// |x| = k*d
// |x|/d = k
// 0を超えてしまったら戻ってを繰り返せばよい。
if (abs(x) / d >= k)
cout << abs(x) - k * d << endl;
else if ((k - abs(x) / d) % 2 == 0)
cout << abs(abs(x) - (abs(x) / d) * d) <... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 17, 33]] | 1 | 123 |
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions... | import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions... | [["+", 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 | 364 |
x,k,d = map(int, input().split())
if x>0:
if x>k*d:
ans=x-k*d
else:
X = x-round(x//d)*d
if (k-round(x//d))%2==0:
ans=abs(X)
else:
ans=abs(X-d)
else:
if abs(x)>k*d:
ans=x+k*d
else:
X=x+round(abs(x)//d)*d
if (k-round(abs(x)//... | x,k,d = map(int, input().split())
if x>0:
if x>k*d:
ans=x-k*d
else:
X = x-round(x//d)*d
if (k-round(x//d))%2==0:
ans=abs(X)
else:
ans=abs(X-d)
else:
if abs(x)>k*d:
ans=abs(x+k*d)
else:
X=x+round(abs(x)//d)*d
if (k-round(abs... | [["+", 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 | 158 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, k, d, ans, tmp;
cin >> x >> k >> d;
if (x < d) {
if (k % 2 == 0) {
cout << abs(x) << endl;
return 0;
} else {
cout << min(abs(x - d), abs(x + d)) << endl;
return 0;
}
}
if (abs(x) / d >= k) {
cout << ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, k, d, ans;
cin >> x >> k >> d;
if (abs(x) < d) {
if (k % 2 == 0) {
cout << abs(x) << endl;
return 0;
} else {
cout << min(abs(x - d), abs(x + d)) << endl;
return 0;
}
}
if (abs(x) / d >= k) {
cout << ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 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]] | 1 | 250 |
class InputLine
def self.to_s
gets.chomp
end
def self.to_i
InputLine.to_s.to_i
end
def self.to_f
InputLine.to_s.to_f
end
def self.to_sa
InputLine.to_s.split(' ')
end
def self.to_ia
InputLine.to_sa.map(&:to_i)
end
def self.to_fa
InputLine.to_sa.map(&:to_f)
end
end... | class InputLine
def self.to_s
gets.chomp
end
def self.to_i
InputLine.to_s.to_i
end
def self.to_f
InputLine.to_s.to_f
end
def self.to_sa
InputLine.to_s.split(' ')
end
def self.to_ia
InputLine.to_sa.map(&:to_i)
end
def self.to_fa
InputLine.to_sa.map(&:to_f)
end
end... | [["-", 8, 170, 0, 121, 64, 749, 0, 662, 12, 22], ["+", 8, 170, 0, 121, 64, 749, 0, 662, 12, 22], ["-", 8, 170, 0, 121, 75, 95, 0, 662, 12, 22], ["+", 8, 170, 0, 121, 75, 95, 0, 662, 12, 22], ["-", 0, 662, 12, 652, 486, 516, 0, 738, 12, 612], ["+", 0, 662, 12, 652, 486, 516, 0, 738, 12, 612]] | 4 | 269 |
x, k, d= [int(i) for i in input().split()]
l = x // d
if k >= l:
k -= l
if x >= 0:
x -= d*l
else:
x += d*l
k = k % 2
if k:
if x >= 0:
x -= d
else:
x += d
else:
if x >= 0:
x -= d*k
else:
x += d*k
print(abs(x)) | x, k, d= [int(i) for i in input().split()]
l = abs(x) // d
if k > l:
k -= l
if x >= 0:
x -= d*l
else:
x += d*l
k = k % 2
if k:
if x >= 0:
x -= d
else:
x += d
else:
if x >= 0:
x -= d*k
else:
x += d*k
print(abs(x)) | [["+", 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], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47]] | 5 | 99 |
// AUTHOR: RAVAN_2070
// PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
I ♥ CLARICE STARLING...
EXPLAINATION BELOW->
*/
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vii;
typ... | // AUTHOR: RAVAN_2070
// PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
I ♥ CLARICE STARLING...
EXPLAINATION BELOW->
*/
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vii;
typ... | [["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["+", 0, 57, 75, 76, 0, 9, 0, 43, 39, 78]] | 1 | 301 |
from sys import stdin
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]
def solve(x,k,d):
di = abs(int(x//d))
if di >= k:
return abs(x) - (k*d)
x = x - (di*d)
k -= di
if k % 2 == 0:
return abs(x)
else:
... | from sys import stdin
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]
def solve(x,k,d):
di = int(x//d)
if di >= k:
return abs(x) - (k*d)
x = x - (di*d)
k -= di
if k % 2 == 0:
return abs(x)
else:
re... | [["-", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 142 |
from sys import stdin,stdout
for _ in range(1):#int(stdin.readline())):
# n=int(stdin.readline())
x,k,d=list(map(int,stdin.readline().split()))
'''if x==k==d:
print(0 if k&1 else x)
continue'''
des=x%d
op=x//d
a=[des,des-d]
if k<op:#check for eq
print(x-k*d)
else:... | from sys import stdin,stdout
for _ in range(1):#int(stdin.readline())):
# n=int(stdin.readline())
x,k,d=list(map(int,stdin.readline().split()))
'''if x==k==d:
print(0 if k&1 else x)
continue'''
x=abs(x)
des=x%d
op=x//d
# print(des,op)
a=[des,des-d]
if k<op:#check for ... | [["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 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 | 93 |
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(), x.end()
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>... | #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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(), x.end()
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>... | [["+", 64, 37, 0, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 57, 64, 37, 0, 2, 3, 4, 0, 25]] | 1 | 271 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
X == abs(X);
long long count = X / D;
if (count > K) {
cout << X - K * D << endl;
} else {
X -= count * D;
K -= count;
if (K % 2 == 1) {
X = abs(X - D);
}
cout << X << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
X = abs(X);
long long count = X / D;
if (count > K) {
cout << X - K * D << endl;
} else {
X -= count * D;
K -= count;
if (K % 2 == 1) {
X = abs(X - D);
}
cout << X << endl;
}
} | [["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32]] | 1 | 99 |
/*
<3 <3 <3 Rose <3 <3 <3
BLACKPINK!
Ah yeah, ay yeah!
BLACKPINK!b
Ah yeah, ay yeah!
[Verse 1: Jennie]
Chakan eolgure geureochi mothan taedo
Ganyeorin mommae sok garyeojin volumeeun du baero
Geochimeopsi jikjin guji bojin anchi nunchi
Black hamyeon Pink urin yeppeujanghan Savage
[Verse 2: Lisa]
Wonhal ttaen daenoko ... | /*
<3 <3 <3 Rose <3 <3 <3
BLACKPINK!
Ah yeah, ay yeah!
BLACKPINK!b
Ah yeah, ay yeah!
[Verse 1: Jennie]
Chakan eolgure geureochi mothan taedo
Ganyeorin mommae sok garyeojin volumeeun du baero
Geochimeopsi jikjin guji bojin anchi nunchi
Black hamyeon Pink urin yeppeujanghan Savage
[Verse 2: Lisa]
Wonhal ttaen daenoko ... | [["+", 15, 339, 51, 16, 31, 16, 31, 91, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["-", 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, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, ... | 1 | 717 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public class Main {
static BufferedReader reader;
final static boolean MODE_DEBUG = false;
static... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public class Main {
static BufferedReader reader;
final static boolean MODE_DEBUG = false;
static... | [["+", 0, 1, 0, 492, 3, 4, 0, 91, 17, 33], ["+", 12, 23, 0, 16, 31, 492, 3, 4, 0, 24], ["+", 0, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 23, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 3, 4, 0, 23, 0, 16, 31, 23, 0, 25]] | 3 | 1,245 |
x,k,d = map(int,input().split())
n = x//d
if n <= k :
x -= d*n
count = k-n+2
if count % 2 == 0 :
now = x
else :
now = d-x
else :
now = x - k*d
print(abs(now))
| x,k,d = map(int,input().split())
x = abs(x)
n = x//d
if n <= k :
x -= d*n
count = k-n+2
if count % 2 == 0 :
now = x
else :
now = d-x
else :
now = x - k*d
print(abs(now))
| [["+", 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 |
x,k,d=map(int,input().split())
if x>k*d:
print(x-k*d)
else:
k-=x//d
x-=(x//d)*d
rem=k%2
if rem:
print(d-x%d)
else:
print(x%d)
| x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
print(x-k*d)
else:
k-=x//d
x-=(x//d)*d
rem=k%2
if rem:
print(d-x%d)
else:
print(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 | 73 |
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include <algorithm> //sort,二分探索,など
#include <bits/stdc++.h>
#include <bitset> //固定長bit集合
#include <chrono> //実行時間計測
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー... | //コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include <algorithm> //sort,二分探索,など
#include <bits/stdc++.h>
#include <bitset> //固定長bit集合
#include <chrono> //実行時間計測
#include <cmath> //pow,logなど
#include <complex> //複素数
#include <deque> //両端アクセスのキュー... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 528 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
struct edge {
int to, id;
};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
using graph = vector<vector<ll>>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll dist = x;
if (x <= 0) {
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
struct edge {
int to, id;
};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
using graph = vector<vector<ll>>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll dist = x;
if (x <= 0) {
... | [["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 0, 24]] | 1 | 212 |
#include <bits/stdc++.h>
#define forp(x, a, b) for (int x = a; x < b; x++)
#define forn(x, a, b) for (int x = a; x > b; x--)
#define SZ(a) ((int)(a).size())
#define pb push_back
#define vec(x) vector<x>
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define umpii unordered_map<int,... | #include <bits/stdc++.h>
#define forp(x, a, b) for (int x = a; x < b; x++)
#define forn(x, a, b) for (int x = a; x > b; x--)
#define SZ(a) ((int)(a).size())
#define pb push_back
#define vec(x) vector<x>
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define umpii unordered_map<int,... | [["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["+", 0, 57, 75, 76, 0, 9, 0, 43, 39, 78]] | 1 | 232 |
x, k, d = map(int, input().split())
if x == 0:
if k % 2 == 0:
ans = 0
else:
ans = d
elif x > 0:
amari = x % d
kouho1 = amari
kouho2 = amari - d
kyori1 = abs(x - kouho1)
kyori2 = abs(x - kouho2)
if kyori1 // d > k:
ans = x - k * d
elif (kyori1 // d) % 2 ==... | x, k, d = map(int, input().split())
if x == 0:
if k % 2 == 0:
ans = 0
else:
ans = d
elif x > 0:
amari = x % d
kouho1 = amari
kouho2 = amari - d
kyori1 = abs(x - kouho1)
kyori2 = abs(x - kouho2)
if kyori1 // d > k:
ans = x - k * d
elif (kyori1 // d) % 2 ==... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 252 |
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:
if x > 0:
a = x-(x//d)*d
if (k-x//d)%2 == 0:
print(abs(a))
else:
print(abs(a-d))
else:
a = x+(-x//d)*d
if (k-(-x//d))%2 == 0:
print(abs(a))
else:
print(abs(a+... | x,k,d = map(int,input().split())
if abs(x) > k*d:
if x > 0:
print(abs(x-k*d))
else:
print(abs(x+k*d))
else:
if x > 0:
a = x-(x//d)*d
if (k-x//d)%2 == 0:
print(abs(a))
else:
print(abs(a-d))
else:
a = x+(-x//d)*d
if (k-(-x//d))%2 == 0:
print(abs(a))
else:
pr... | [["+", 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 | 148 |
x,k,d = gets.chomp.split(" ").map(&:to_i)
minus = false
if x < 0
minus = true
x *= -1
end
ans = x
y = x/d
r = x%d
if k < y
ans -= k*d
else
ans = r
if (k-y%2) == 1
ans -= d
end
end
if minus
ans *= -1
end
puts("#{ans.abs}") | x,k,d = gets.chomp.split(" ").map(&:to_i)
minus = false
if x < 0
minus = true
x *= -1
end
ans = x
y = x/d
r = x%d
if k < y
ans -= k*d
else
ans = r
if ((k-y)%2) == 1
ans -= d
end
end
if minus
ans *= -1
end
puts("#{ans.abs}") | [["+", 15, 738, 31, 739, 0, 738, 31, 739, 0, 24], ["+", 15, 738, 31, 739, 0, 738, 31, 739, 0, 25]] | 4 | 95 |
X, K, D = map(int, input().split())
def solve():
if X // D >= K:
return X - D*K
if ((X//D)%2 == 0) ^ (K%2 == 0):
return D - (X - D*(X//D))
else:
return X - D*(X//D)
if __name__ == "__main__":
print(solve())
| X, K, D = map(int, input().split())
X = abs(X)
def solve():
if X // D >= K:
return X - D*K
if ((X//D)%2 == 0) ^ (K%2 == 0):
return D - (X - D*(X//D))
else:
return X - D*(X//D)
if __name__ == "__main__":
print(solve())
| [["+", 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 | 96 |
x, k, d = map(int, input().split())
t = abs(x)//d
if k*d <= abs(x):
print(abs(x) - k*d)
else:
print(abs(d*(max(0, k-t)%2) - (x-t*d)))
| x, k, d = map(int, input().split())
t = abs(x)//d
if k*d <= abs(x):
print(abs(x) - k*d)
else:
print(abs(d*(max(0, k-t)%2) - (abs(x)-t*d)))
| [["+", 0, 657, 12, 23, 0, 657, 31, 652, 63, 22], ["+", 12, 23, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 12, 23, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 77 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long steps = abs(x / d);
if (steps > k) {
if (x > 0)
cout << x - k * d << endl;
else
cout << x + k * d << endl;
return 0;
}
if (x > 0)
x = x - steps * d;
else
x = x + ste... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long steps = abs(x / d);
if (steps > k) {
if (x > 0)
cout << abs(x - k * d) << endl;
else
cout << abs(x + k * d) << endl;
return 0;
}
if (x > 0)
x = x - steps * d;
else
x... | [["+", 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 | 195 |
def resolve():
'''
code here
'''
X, K, D = [int(item) for item in input().split()]
if K*D > abs(X):
temp = K - X // D
if temp % 2 == 1:
print(D - X%D)
else:
print(X%D)
else:
print(X - K*D)
if __name__ == "__main__":
resolve()
| def resolve():
'''
code here
'''
X, K, D = [int(item) for item in input().split()]
if K*D > abs(X):
temp = K - X // D
if temp % 2 == 1:
print(D - X%D)
else:
print(X%D)
else:
print(abs(X) - K*D)
if __name__ == "__main__":
resolve()
| [["+", 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 | 90 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll X, K, D;
cin >> X >> K >> D;
if (X < 0)
X = -X;
if ... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll X, K, D;
cin >> X >> K >> D;
if (X < 0)
X = -X;
if ... | [["+", 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 | 152 |
#include <algorithm>
#include <iostream>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
long long X, K, D;
scanf("%lld %lld %lld", &X, &K, &D);
long long p = ... | #include <algorithm>
#include <iostream>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
long long X, K, D;
scanf("%lld %lld %lld", &X, &K, &D);
long long p = ... | [["+", 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 | 251 |
#include <stdio.h>
int main(void) {
// Your code here!
long long int x, k, kk, dd, d, i, ii, tmp = 0;
scanf("%lld%lld%lld", &x, &k, &d);
if (x < 0)
x *= -1;
kk = k;
dd = d;
while (kk > 0) {
kk /= 10;
tmp++;
}
while (dd > 0) {
dd /= 10;
tmp++;
}
if (x > k * d || tmp > 16)
pr... | #include <stdio.h>
int main(void) {
// Your code here!
long long int x, k, kk, dd, d, i, ii, tmp = 0;
scanf("%lld%lld%lld", &x, &k, &d);
if (x < 0)
x *= -1;
kk = k;
dd = d;
while (kk > 0) {
kk /= 10;
tmp++;
}
while (dd > 0) {
dd /= 10;
tmp++;
}
if (x > k * d && tmp < 18)
pr... | [["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 98], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 47], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]] | 0 | 158 |
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <fstream>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cct... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <fstream>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cct... | [["-", 12, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 31, 13]] | 1 | 795 |
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true... | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true... | [["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25]] | 1 | 196 |
X,K,D= map(int,input().split())
X = abs(X)
X2 = X
I = 0
K2 = X//D
if X == 0:
if K%2 ==0:
print(0)
else:
print(D)
if K <= K2:
print(X - K*D)
else:
X = X - K2*D
for i in range(K2,K+1):
X -= D
X2 = X
if X <= 0:
X += D
I = i
bre... | X,K,D= map(int,input().split())
X = abs(X)
X2 = X
I = 0
K2 = X//D
if X == 0:
if K%2 ==0:
print(0)
else:
print(D)
elif K <= K2:
print(X - K*D)
else:
X = X - K2*D
for i in range(K2,K+1):
X -= D
X2 = X
if X <= 0:
X += D
I = i
b... | [["-", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 75, 665, 0, 683]] | 5 | 136 |
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String a... | import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String a... | [["-", 0, 11, 12, 16, 31, 492, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 492, 3, 4, 0, 25]] | 3 | 348 |
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
int hugo = 1;
if (x < 0) {
hugo = -1;
}
if ((hugo * x) / d >= k) ... | #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
int hugo = 1;
if (x < 0) {
hugo = -1;
}
if ((hugo * x) / d >= k) ... | [["+", 51, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 51, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 51, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22]] | 1 | 137 |
#include <iostream>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
int n = x / d * (x < 0 ? -1 : 1);
if (n > k)
n = k;
k -= n;
x += n * d * (x > 0 ? -1 : 1);
k %= 2;
if (k)
x += n * d * (x > 0 ? -1 : 1);
cout << x * (x < 0 ? -1 : 1);
return 0;
} | #include <iostream>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long n = x / d * (x < 0 ? -1 : 1);
if (n > k)
n = k;
k -= n;
x += n * d * (x > 0 ? -1 : 1);
k %= 2;
if (k)
x += d * (x > 0 ? -1 : 1);
cout << x * (x < 0 ? -1 : 1);
return 0;
}
| [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 17, 48]] | 1 | 116 |
#include <algorithm>
#include <cfenv>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unorde... | #include <algorithm>
#include <cfenv>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unorde... | [["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 60]] | 1 | 2,719 |
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>
#include <set>
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll abx = abs(x);
ll q, qq... | #include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>
#include <set>
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll abx = abs(x);
ll q, qq... | [["-", 0, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["-", 0, 9, 0, 1, 0, 16, 12, 16, 12, 22]] | 1 | 237 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;
ll l[200];
int solve() {
ll x, k, d, m;
cin >> x >> k >> d;
if (x == 0) {
if (k % 2 == 0)
return cout << 0 << endl, 0;
else
return cout << d << endl, 0;
}
if (x < 0)
x = -x;
ll n = x / d;
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;
ll l[200];
int solve() {
ll x, k, d, m;
cin >> x >> k >> d;
if (x == 0) {
if (k % 2 == 0)
return cout << 0 << endl, 0;
else
return cout << d << endl, 0;
}
if (x < 0)
x = -x;
ll n = x / d;
... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 231 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll, ll>
ll INF = 1000000007;
//-----------------//
#define amin main
//-----------------//
int amin() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t,... | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll, ll>
ll INF = 1000000007;
//-----------------//
#define amin main
//-----------------//
int amin() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t,... | [["-", 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], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 64, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 31, 22]] | 1 | 150 |
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author NikuKyabe
*/
#include "bits/stdc++.h"
using namespace std;
#define int long long
class CWalkingTakahashi {
public:
void solve(std::istream &in, std::ostream &out) {
int x, k, d;
in >> x >> k >> d;
int a ... | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author NikuKyabe
*/
#include "bits/stdc++.h"
using namespace std;
#define int long long
class CWalkingTakahashi {
public:
void solve(std::istream &in, std::ostream &out) {
int x, k, d;
in >> x >> k >> d;
int a ... | [["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]] | 1 | 230 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x > 0) {
ll butuh = ceil((double)x / (double)d);
ll kecil = x - (d * butuh);
ll besar = kecil + d;
ll sisa = k - butuh;
if (sisa < 0)
cout << abs(x - (d * k)) << '\n';
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x > 0) {
ll butuh = ceil((double)x / (double)d);
ll kecil = x - (d * butuh);
ll besar = kecil + d;
ll sisa = k - butuh;
if (sisa < 0)
cout << abs(x - (d * k)) << '\n';
... | [["-", 0, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 74, 51, 2, 63, 22], ["+", 0, 16, 31, 74, 51, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 74, 51, 2, 3, 4, 0, 25], ["-", 51, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 236 |
x, k, d = gets.chomp.split.map(&:to_i)
x = x.abs
t = x / d
a = x - t * d
res =
if t <= k
if (k - t) % 2 == 0
a
else
d - a
end
else
(k - t) * d + a
end
puts res.abs | x, k, d = gets.chomp.split.map(&:to_i)
x = x.abs
t = x / d
a = x - t * d
res =
if t <= k
if (k - t) % 2 == 0
a
else
d - a
end
else
(t - k) * d + a
end
puts res | [["-", 0, 738, 31, 738, 31, 739, 0, 738, 31, 22], ["-", 0, 738, 31, 738, 31, 739, 0, 738, 17, 33], ["+", 0, 738, 31, 738, 31, 739, 0, 738, 17, 33], ["+", 0, 738, 31, 738, 31, 739, 0, 738, 12, 22], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 17, 131], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 735, 22]] | 4 | 71 |
x,k,d=map(int, input().split())
if abs(k*d)>abs(x):
if k%2==0:
a=x%(2*d)
print(min(abs(a),abs(a-2+d)))
else:
a=x%(2*d)
print(min(abs(a-d),abs(a+d)))
else:
print(abs(x)-abs(k*d)) | x,k,d=map(int, input().split())
if abs(k*d)>abs(x):
if k%2==0:
a=x%(2*d)
print(min(abs(a),abs(a-2*d)))
else:
a=x%(2*d)
print(min(abs(a-d),abs(a+d)))
else:
print(abs(x)-abs(k*d)) | [["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 652, 3, 4, 0, 657, 12, 657, 17, 48]] | 5 | 112 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d, t;
cin >> x >> k >> d;
x = abs(x);
if (k <= x / d)
cout << t;
else {
k = k - (x / d);
x %= d;
if (k % 2 == 0)
cout << x;
else
cout << d - x;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d, t;
cin >> x >> k >> d;
x = abs(x);
if (k <= x / d)
cout << x - k * d;
else {
k = k - (x / d);
x %= d;
if (k % 2 == 0)
cout << x;
else
cout << d - x;
}
} | [["-", 8, 9, 0, 57, 64, 1, 0, 16, 12, 22], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 17, 33], ["+", 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, 12, 22]] | 1 | 85 |
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long int l;
#define mod 1000000007
#define t1 \
l t; \
cin >> t; ... | #include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long int l;
#define mod 1000000007
#define t1 \
l t; \
cin >> t; ... | [["+", 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]] | 1 | 308 |
import sys
import numpy as np
X, K, D = list(map(int, input().split()))
x = int(X)
D = int(D)
j = 0
j = X//D
if j > K:
j = K
if x > 0:
x = x - (D*j)
else:
x = x + (D*j)
j = (K-j) % 2
if j==0:
print(abs(x))
else:
if x > 0:
x = x - D
else:
x = x + D
print(abs(x))
| import sys
import numpy as np
X, K, D = list(map(int, input().split()))
x = int(X)
D = int(D)
j = 0
j = abs(X//D)
if j > K:
j = K
if x > 0:
x = x - (D*j)
else:
x = x + (D*j)
j = (K-j) % 2
if j==0:
print(abs(x))
else:
if x > 0:
x = x - D
else:
x = x + D
print(abs(x))
| [["+", 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, 25]] | 5 | 127 |
x,k,d=map(int,input().split())
k_min=abs(x//d)
if k_min>=k:
k_min=k
if x>0:
d_min=x-((k_min)*d)
else:
d_min=x+((k_min)*d)
dk=k-k_min
if dk%2==0:
print(d_min)
else:
print(min(abs(d_min+d),abs(d_min-d))) | x,k,d=map(int,input().split())
k_min=abs(x//d)
if k_min>=k:
k_min=k
if x>0:
d_min=x-((k_min)*d)
else:
d_min=x+((k_min)*d)
dk=k-k_min
if dk%2==0:
print(abs(d_min))
else:
print(min(abs(d_min+d),abs(d_min-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 | 100 |
X, K , D = map(int, input().split())
move_count = 0
D = abs(D)
X = abs(X)
q = X // D
mod = X % D
vi = X //2
if q > K:
print(X - D*K)
else:
if (K-q) // 2 == 0:
print(X- D*q)
else:
print(abs(X-D*(q+1))) | X, K , D = map(int, input().split())
move_count = 0
D = abs(D)
X = abs(X)
q = X // D
mod = X % D
vi = X //2
if q > K:
print(X - D*K)
else:
if (K-q) % 2 == 0:
print(X- D*q)
else:
print(abs(X-D*(q+1))) | [["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 676], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 109]] | 5 | 99 |
// This is free and unencumbered software released into the public domain.
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
// In jurisdictions that... | // This is free and unencumbered software released into the public domain.
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
// In jurisdictions that... | [["+", 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 | 925 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
if (K * D <= abs(X)) {
cout << abs(X) - (K * D);
} else {
K = K - (abs(X) / D);
// cout << K << endl;
if (K % 2 == 0)
cout << abs(X) % D;
else
cout << abs(abs(X) % D - D);
}
... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
if (K <= abs(X) / D) {
cout << abs(X) - (K * D);
} else {
K = K - (abs(X) / D);
// cout << K << endl;
if (K % 2 == 0)
cout << abs(X) % D;
else
cout << abs(abs(X) % D - D);
}
... | [["-", 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 | 103 |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func nextInt() int {
sc.Scan()
i, e := strconv.Atoi(sc.Text())
if e != nil {
panic(e)
}
return i
}
func nextFloat64() float64 {
sc.Scan()
i, e := strconv.ParseFloat(sc.Text(), 64)
if e != nil {
panic(e)
}
retu... | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func nextInt() int {
sc.Scan()
i, e := strconv.Atoi(sc.Text())
if e != nil {
panic(e)
}
return i
}
func nextFloat64() float64 {
sc.Scan()
i, e := strconv.ParseFloat(sc.Text(), 64)
if e != nil {
panic(e)
}
retu... | [["+", 0, 431, 12, 432, 0, 16, 31, 2, 63, 22], ["+", 12, 432, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 12, 432, 0, 16, 31, 2, 3, 4, 0, 25]] | 7 | 363 |
x,k,d = gets.split.map(&:to_i)
if x / d < k
if (k - (x / d)) % 2 == 0
puts (x - (x / d) * d).abs
else
puts ((x - (x / d) * d).abs - d).abs
end
else
puts (x - k * d).abs
end
| x,k,d = gets.split.map(&:to_i)
x = x.abs
if x / d < k
if (k - (x / d)) % 2 == 0
puts (x - (x / d) * d).abs
else
puts ((x - (x / d) * d).abs - d).abs
end
else
puts (x - k * d).abs
end
| [["+", 36, 36, 36, 36, 0, 493, 0, 662, 31, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 486, 22], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22]] | 4 | 83 |
x, k, d = map(int, input().split())
x = abs(x)
a = x % d
b = x % d - d
ans = min(x, abs(x - k * d))
if (x - a) // d <= k and ((x - a) // d - k) % 2 == 0:
ans = min(ans, a)
if (x - b) // d <= k and ((x - b) // d - k) % 2 == 0:
ans = min(ans, -b)
print(ans) | x, k, d = map(int, input().split())
x = abs(x)
a = x % d
b = x % d - d
ans = abs(x - k * d)
if (x - a) // d <= k and ((x - a) // d - k) % 2 == 0:
ans = min(ans, a)
if (x - b) // d <= k and ((x - b) // d - k) % 2 == 0:
ans = min(ans, -b)
print(ans) | [["-", 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, 21], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 126 |
x, k, d = map(int, input().split())
out = 0
m = abs(x) // d
if m > k:
out = x - k * d if x >= 0 else x + k * d
else:
if (k - m) % 2 == 0:
out = x - m * d if x >= 0 else x + m *d
else:
out = (m + 1) * d - x if x >= 0 else (m + 1) * d + x
print(out)
| x, k, d = map(int, input().split())
out = 0
m = abs(x) // d
if m > k:
out = x - k * d if x >= 0 else abs(x + k * d)
else:
if (k - m) % 2 == 0:
out = x - m * d if x >= 0 else abs(x + m * d)
else:
out = (m + 1) * d - x if x >= 0 else (m + 1) * d + x
print(out)
| [["+", 0, 1, 0, 662, 12, 41, 0, 652, 63, 22], ["+", 0, 662, 12, 41, 0, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 41, 0, 652, 3, 4, 0, 25]] | 5 | 112 |
#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>;
// #define NDEBUG
#include <assert.h>
const int INF = 1001001001;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll x, k, d;
cin >> x >> k >> d;
ll times = 0;
... | #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>;
// #define NDEBUG
#include <assert.h>
const int INF = 1001001001;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll x, k, d;
cin >> x >> k >> d;
ll times = 0;
... | [["+", 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 | 236 |
package main
import (
"bufio"
"os"
"strconv"
"fmt"
)
var sc = bufio.NewScanner(os.Stdin)
func init() {
sc.Split(bufio.ScanWords)
sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}
//func nextString() string {
// sc.Scan()
// return sc.Text()
//}
//func nextInt() int {
// sc.Scan()
// i, e := strcon... | package main
import (
"bufio"
"os"
"strconv"
"fmt"
)
var sc = bufio.NewScanner(os.Stdin)
func init() {
sc.Split(bufio.ScanWords)
sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}
//func nextString() string {
// sc.Scan()
// return sc.Text()
//}
//func nextInt() int {
// sc.Scan()
// i, e := strcon... | [["+", 8, 196, 0, 431, 12, 432, 0, 2, 63, 22], ["+", 0, 431, 12, 432, 0, 2, 3, 4, 0, 24], ["+", 0, 431, 12, 432, 0, 2, 3, 4, 0, 25]] | 7 | 305 |
x, k, d = map(int, input().split())
if x > 0:
if x-(k*d)>=0:
print(abs(x-k*d))
else:
a = x//d
k -= a+1
res = x-(a+1)*d
if k%2==0:
print(abs(res))
else:
print(abs(res+d))
elif x < 0:
if x+(k*d)<=0:
print(abs(x+k*d))
else:
a = x//d
k -= a+1
res = x+(a+1)*d
... | x, k, d = map(int, input().split())
if x > 0:
if x-(k*d)>=0:
print(abs(x-k*d))
else:
a = x//d
k -= a+1
res = x-(a+1)*d
if k%2==0:
print(abs(res))
else:
print(abs(res+d))
elif x < 0:
if x+(k*d)<=0:
print(abs(x+k*d))
else:
a = abs(x)//d
k -= a+1
res = x+(a+1)*... | [["+", 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 | 187 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
////////////////////////////////////////////////
int main() {
ll x, k, d, a;
cin >> x >> k >> d;
x = abs(x);
if (x / d < k) {
a = x - (x / d) * d;
k -= x / d;
} else {
a -= k * ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
////////////////////////////////////////////////
int main() {
ll x, k, d, a;
cin >> x >> k >> d;
x = abs(x);
if (x / d < k) {
a = x - (x / d) * d;
k -= x / d;
} else {
a = x - k... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 110], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 33]] | 1 | 114 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll var = abs(x / d);
if (x > 0) {
if (var >= k) {
cout << x - (var * d);
} else {
k -= var;
if (k % 2 == 0) {
cout << x - (var)*d << '\n';
} else {
cou... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll var = abs(x / d);
if (x > 0) {
if (var >= k) {
cout << x - (k * d);
} else {
k -= var;
if (k % 2 == 0) {
cout << x - (var)*d << '\n';
} else {
cout ... | [["-", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 12, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 31, 22]] | 1 | 239 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long ans, m;
x = labs(x);
m = floor(x / d);
if (m >= d)
ans = x - k * d;
else if ((m % 2) == (k % 2))
ans = x % d;
else
ans = d - (x % d);
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long ans, m;
x = labs(x);
m = floor(x / d);
if (m > k)
ans = x - k * d;
else if ((m % 2) == (k % 2))
ans = x % d;
else
ans = d - (x % d);
cout << ans << endl;
return 0;
} | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 105 |
x,k,d = map(int,input().split())
if abs(x) >= k*d:
print(abs(x)-k*d)
exit()
x = abs(x)
r = x%d
if ((x-r)//d)%2 == k%2:
print(r)
else:
print(abs(r-k)) | x,k,d = map(int,input().split())
if abs(x) >= k*d:
print(abs(x)-k*d)
exit()
x = abs(x)
r = x%d
if ((x-r)//d)%2 == k%2:
print(r)
else:
print(abs(r-d)) | [["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 85 |
# 2020/08/15
# AtCoder Beginner Contest 175 - C
# Input
x, k, d = map(int,input().split())
# Calc
# d * k < x -> 足りない場合
if d * k < x:
# 足りない場合:
ans = x - k * d
else:
# 飛び越す場合:
# 0に近い正の値までの回数
wkc = x // d
if k % 2 == 0:
# kが偶数の場合:留まれるのは偶数回目
if wkc % 2 == 0:
ans ... | # 2020/08/15
# AtCoder Beginner Contest 175 - C
# Input
x, k, d = map(int,input().split())
# Calc
# d * k < x -> 足りない場合
if d * k < abs(x):
# 足りない場合:
ans = abs(x) - k * d
else:
# 飛び越す場合:
# 0に近い正の値までの回数
wkc = x // d
if k % 2 == 0:
# kが偶数の場合:留まれるのは偶数回目
if wkc % 2 == 0:
... | [["+", 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], ["+", 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 | 111 |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
int main() {
long long x;
long long k, d;
cin >> x >> k >> d;
long long now = abs(x);
long long ans = 0;
long long cnt = 0;
cnt = now / d;
if (k >= cnt) {
now = now - d * cnt;
cnt = k - cnt;
if... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
int main() {
long long x;
long long k, d;
cin >> x >> k >> d;
long long now = abs(x);
long long ans = 0;
long long cnt = 0;
cnt = now / d;
if (k >= cnt) {
now = now - d * cnt;
cnt = k - cnt;
if... | [["-", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["-", 51, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["-", 51, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25]] | 1 | 174 |
x, k, d = map(int,input().split())
a = x//d
y = x - a*d
b = k - a
if k >= a:
if b % 2 == 0:
print(abs(y))
elif abs(y - d) > abs(y - 2*d):
print(abs(y-2*d))
else:
print(abs(y-d))
else:
print(abs(x - k*d)) | x, k, d = map(int,input().split())
x = abs(x)
a = x//d
y = x - a*d
b = k - a
if k >= a:
if b % 2 == 0:
print(abs(y))
elif abs(y - d) > abs(y - 2*d):
print(abs(y-2*d))
else:
print(abs(y-d))
else:
print(abs(x - k*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 | 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 pre = x / d;
if (k > pre) {
if (min(x - d * pre, -x + d * (pre + 1)) == x - d * pre) {
if ((k - pre) % 2 == 0) {
cout << x - d * pre << endl;
} els... | #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 pre = x / d;
if (k > pre) {
if (min(x - d * pre, -x + d * (pre + 1)) == x - d * pre) {
if ((k - pre) % 2 == 0) {
cout << x - d * pre << endl;
} els... | [["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 91, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72]] | 1 | 190 |
x, k, d = map(int,input().split())
if (x >= k*d):
print(x - k*d)
else:
nokori = k - x//d
if (nokori%2 == 0):
print(abs(x%d))
else:
print(abs(x%d - d))
| x, k, d = map(int,input().split())
x = abs(x)
if (x >= k*d):
print(x - k*d)
else:
nokori = k - x//d
if (nokori%2 == 0):
print(abs(x%d))
else:
print(abs(x%d - 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 | 75 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<in... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<in... | [["+", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22]] | 1 | 326 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t X, K, D;
cin >> X >> K >> D;
if (K < abs(X / D)) {
cout << abs(X) - K * D;
} else if ((K - abs(X / D)) % 2 == 0) {
cout << abs(X - (X / D) * D);
} else {
cout << abs(X - (X / D + 1) * D);
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t X, K, D;
cin >> X >> K >> D;
if (K < abs(X / D)) {
cout << abs(X) - K * D;
} else if ((K - abs(X / D)) % 2 == 0) {
cout << abs(X - (X / D) * D);
} else {
cout << abs(abs(X) - (abs(X / D) + 1) * D);
}
} | [["+", 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], ["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 2, 63, 22], ["+", 31, 23, 0, 16, 31, 2, 3, 4, 0, 25]] | 1 | 106 |
X, K, D = map(int, input().split())
n, x= divmod(X, D)
if n > K:
print(min(abs(X - D * K), abs(X + D * K)))
exit()
K = K - n
if K % 2 == 0:
print(abs(x))
else:
print(min(abs(D - x), abs(D + x))) | X, K, D = map(int, input().split())
n, x= divmod(abs(X), D)
if n > K:
print(min(abs(X - D * K), abs(X + D * K)))
exit()
K = K - n
if K % 2 == 0:
print(abs(x))
else:
print(min(abs(D - x), abs(D + x))) | [["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 99 |
import math
X, K, D = map(int, input().split())
mini = math.ceil(X/D)
if mini >= K:
print(abs(X-D*K))
else:
if (K-mini)%2 == 0:
print(abs(X-D*mini))
else:
print(X-D*(mini-1)) | import math
X, K, D = map(int, input().split())
X = abs(X)
mini = math.ceil(X/D)
if mini >= K:
print(abs(X-D*K))
else:
if (K-mini)%2 == 0:
print(abs(X-D*mini))
else:
print(X-D*(mini-1)) | [["+", 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 | 84 |
// Code by Mukul Totla
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void sublime() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int main() {
// sublime();
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, i;
ll a, b, c;
... | // Code by Mukul Totla
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void sublime() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int main() {
// sublime();
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, i;
ll a, b, c;
... | [["-", 0, 43, 49, 50, 51, 16, 12, 74, 51, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 74, 51, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 74, 51, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 74, 51, 22], ["-", 51, 2, 3, 4, 0, 16, 12, 16, 12, 22], ["+", 51, 2, 3, 4, 0, 16, 12, 16, 12, 22]] | 1 | 204 |
import sys
x,k,d = map(int,input().split())
if abs(x) >= k*d:
ans = abs(x) - k*d
print(ans)
sys.exit()
else:
n = int(x/d)
dist = x - n*d
if (k - n)%2 == 0:
print(dist)
sys.exit()
else:
print(abs(d-dist)) | import sys
import math
x,k,d = map(int,input().split())
if abs(x) >= k*d:
ans = abs(x) - k*d
print(ans)
sys.exit()
else:
n = math.floor(x/d)
dist = x - n*d
if (k - n)%2 == 0:
print(dist)
sys.exit()
else:
print(abs(d-dist)) | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 8, 196, 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 | 97 |
A = list(map(int,input().split()))
X,K,D = A[0], A[1], A[2]
if abs(X) >= K*D:
print(abs(X)-K*D)
elif X == 0:
if K % 2 == 0:
print(0)
else:
print(D)
else:
d = abs(X) // K
amari = abs(X) % K
hantai = K - amari
if K - d % 2 == 0:
print(amari)
else:
prin... | A = list(map(int,input().split()))
X,K,D = A[0], A[1], A[2]
if abs(X) >= K*D:
print(abs(X)-K*D)
elif X == 0:
if K % 2 == 0:
print(0)
else:
print(D)
else:
d = abs(X) // D
amari = abs(X) % D
hantai = D - amari
if (K - d) % 2 == 0:
print(amari)
e... | [["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 122 |
x,k,d= list(map(int, input().split()))
a=x//d
if k>=a:
if (k-a)%2==0:
print(x%d)
else:
print(d-(x%d))
else:
print(x-(k*d))
| x,k,d= list(map(int, input().split()))
x=abs(x)
a=x//d
if k>=a:
if (k-a)%2==0:
print(x%d)
else:
print(d-(x%d))
else:
print(x-(k*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 <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) ... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) ... | [["+", 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 | 293 |
// -- Nitin
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a, n) for (int i = a; i < (int)n; i++)
#define foj(a, n) for (int j = a; j < (int)n; j++)
#define foin(a, n) for (int i = n; i >= a; i--)
#define foj... | // -- Nitin
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a, n) for (int i = a; i < (int)n; i++)
#define foj(a, n) for (int j = a; j < (int)n; j++)
#define foin(a, n) for (int i = n; i >= a; i--)
#define foj... | [["-", 0, 57, 64, 1, 0, 16, 12, 16, 31, 22], ["-", 0, 57, 64, 1, 0, 16, 12, 16, 17, 33], ["+", 75, 76, 0, 1, 0, 16, 12, 16, 31, 22], ["+", 75, 76, 0, 1, 0, 16, 12, 16, 17, 33]] | 1 | 424 |
#include <bits/stdc++.h>
using namespace std;
long long x, k, d;
int main() {
cin >> x >> k >> d;
if (k == 0) {
cout << abs(x);
return 0;
} else {
long long t = abs(x / d);
if (t > k) {
if (x >= 0) {
cout << x - t * d;
return 0;
} else {
cout << abs(x + t * d);
... | #include <bits/stdc++.h>
using namespace std;
long long x, k, d;
int main() {
cin >> x >> k >> d;
if (k == 0) {
cout << abs(x);
return 0;
} else {
long long t = abs(x / d);
if (t > k) {
if (x >= 0) {
cout << x - k * d;
return 0;
} else {
cout << abs(x + k * d);
... | [["-", 0, 1, 0, 16, 12, 16, 12, 16, 31, 22], ["+", 0, 1, 0, 16, 12, 16, 12, 16, 31, 22], ["-", 12, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35], ["+", 0, 57, 75, 76, 0, 9, 0, 37, 0, 38], ["+", 0, 57, 75, 76, 0, 9, 0, 37, 0, 13]] | 1 | 163 |
// It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include <bits/stdc++.h>
using namespace std;
#define Fast_as_duck \
ios::sync_with_stdio(false); \
cin.tie(0); ... | // It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include <bits/stdc++.h>
using namespace std;
#define Fast_as_duck \
ios::sync_with_stdio(false); \
cin.tie(0); ... | [["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 44]] | 1 | 231 |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (x > 0 && x / d > k)
cout << x - k * d << endl;
else if (x <= 0 && (-x) / d > k)
cout << x + k * d << endl;
else if (x > 0) {
k -= x / d;
x -= (x / d) * d;
if (k % 2... | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (x > 0 && x / d > k)
cout << x - k * d << endl;
else if (x <= 0 && (-x) / d > k)
cout << abs(x + k * d) << endl;
else if (x > 0) {
k -= x / d;
x -= (x / d) * d;
if (... | [["+", 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 | 180 |
x,k,d = list(map(int,input().split()))
mst = x//d
if mst&1 != k&1:
mst+=1
print(abs(x-(min(mst,k))*d)) | x,k,d = list(map(int,input().split()))
x = abs(x)
mst = x//d
if mst&1 != k&1:
mst+=1
print(abs(x-(min(mst,k))*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 | 56 |
import java.util.*;
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 minx = 0;
if (X > 0) {
if ((X / D) >= K) {
minx = X - (D * K);
} else {
if (... | import java.util.*;
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 minx = 0;
if (X >= 0) {
if ((X / D) >= K) {
minx = X - (D * K);
} else {
if ... | [["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 20], ["-", 0, 1, 0, 492, 3, 4, 0, 91, 17, 33]] | 3 | 219 |
def abc175c_walking_takahashi():
x, k, d = map(int, input().split())
x = -x if x < 0 else x
num = math.ceil(x / d)
if num > k:
print(x-k*d)
return
else:
k -= num
x -= num*d
if k % 2 == 0:
print(abs(x))
else:
print(x+d)
abc175c_w... | import math
def abc175c_walking_takahashi():
x, k, d = map(int, input().split())
x = -x if x < 0 else x
num = math.ceil(x / d)
if num > k:
print(x-k*d)
return
else:
k -= num
x -= num*d
if k % 2 == 0:
print(abs(x))
else:
print(x... | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]] | 5 | 92 |
x,k,d=map(int,input().split())
if x>k*d:
print(x-k*d)
elif x%d==0:
t=x//d
print(d if (k-t)%2 else 0)
else:
t=x//d
m=x%d
print(abs(m-d) if (k-t)%2 else m) | x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
print(x-k*d)
elif x%d==0:
t=x//d
print(d if (k-t)%2 else 0)
else:
t=x//d
m=x%d
print(abs(m-d) if (k-t)%2 else m) | [["+", 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 | 90 |
x,k,d = map(int,input().split())
if x < 0:
x *= -1
if x-k*d < 0:
if (k-(math.floor(x/d)))%2 == 0:
print(x%d)
else:
print(abs(x%d-d))
else:
print(x-k*d) | import math
x,k,d = map(int,input().split())
if x < 0:
x *= -1
if x-k*d < 0:
if (k-(math.floor(x/d)))%2 == 0:
print(x%d)
else:
print(abs(x%d-d))
else:
print(x-k*d) | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]] | 5 | 85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.