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 |
|---|---|---|---|---|
//
// Created by RAJ SHAH on 18-08-2020.
//
#include <bits/stdc++.h>
using namespace std;
long long solve(long long x, long long k, long long d) {
x = abs(x);
if (k == 0) {
return x;
}
if (k % 2 == 1) {
return min(solve(x - d, k - 1, d), solve(x + d, k - 1, d));
}
d *= 2;
k /= 2;
if (x / k >= ... | //
// Created by RAJ SHAH on 18-08-2020.
//
#include <bits/stdc++.h>
using namespace std;
long long solve(long long x, long long k, long long d) {
x = abs(x);
if (k == 0) {
return x;
}
if (k % 2 == 1) {
return min(solve(x - d, k - 1, d), solve(x + d, k - 1, d));
}
d *= 2;
k /= 2;
if (x / k >= ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 158 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x >= k * d) {
cout << x - k * d << endl;
return 0;
} else ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
cout << x - k * d << endl;
return 0;
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 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 | 135 |
X, K, D = [int(a) for a in list(input().split())]
X = abs(X)
q = X/D
r = X%D
if q >= K:
print(X - D*K)
exit()
rem = K - q
if rem % 2 == 0:
print(r)
else:
print(abs(D-r)) | X, K, D = [int(a) for a in list(input().split())]
X = abs(X)
q = X//D
r = X%D
if q >= K:
print(X - D*K)
exit()
rem = K - q
if rem % 2 == 0:
print(r)
else:
print(abs(D-r)) | [["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676]] | 5 | 84 |
a=input().split(" ")
b=[x,k,d]= [int(a[0]),int(a[1]),int(a[2])]
ans = 0
if x - k*d > 0:
ans = x - k*d
elif x + k*d < 0:
ans = k*d -x
else:
if k%2==0:
ans= x%(2*d)
if d<x%(2*d):
ans= 2*d-x%(2*d)
elif k%2==1:
ans= (x+d)%(2*d)
if d<(x+d)%(2*d):
ans= 2*d-(x+d)%(2*d)
print(ans) | a=input().split(" ")
b=[x,k,d]= [int(a[0]),int(a[1]),int(a[2])]
ans = 0
if x - k*d > 0:
ans = x - k*d
elif x + k*d < 0:
ans = - k*d -x
else:
if k%2==0:
ans= x%(2*d)
if d<x%(2*d):
ans= 2*d-x%(2*d)
elif k%2==1:
ans= (x+d)%(2*d)
if d<(x+d)%(2*d):
ans= 2*d-(x+d)%(2*d)
print(ans) | [["+", 0, 662, 12, 657, 31, 657, 31, 664, 17, 33]] | 5 | 180 |
#include <bits/stdc++.h>
using namespace std;
//=====================================================
// マクロ定義部
//=====================================================
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR_EQ(i, a, b) for (ll i = (a); i <= (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rep_... | #include <bits/stdc++.h>
using namespace std;
//=====================================================
// マクロ定義部
//=====================================================
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR_EQ(i, a, b) for (ll i = (a); i <= (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rep_... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22]] | 1 | 1,209 |
X, K, D =map(int,input().split())
X = abs(X)
if X > K*D:
print(X-K*D)
else:
greed = X//D
if (X - greed)%2 == 0:
print(X-greed*D)
else:
print((1+greed)*D -X) | X, K, D =map(int,input().split())
X = abs(X)
if X > K*D:
print(X-K*D)
else:
greed = X//D
if (K - greed)%2 == 0:
print(X-greed*D)
else:
print((1+greed)*D -X) | [["-", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22]] | 5 | 79 |
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A, long long B) {
if (B == 0) {
return A;
} else {
return GCD(B, A % B);
}
}
long long LCM(long long A, long long B) {
long long g = GCD(A, B);
return A / ... | #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A, long long B) {
if (B == 0) {
return A;
} else {
return GCD(B, A % B);
}
}
long long LCM(long long A, long long B) {
long long g = GCD(A, B);
return A / ... | [["-", 0, 9, 0, 52, 15, 339, 51, 16, 31, 22], ["+", 0, 9, 0, 52, 15, 339, 51, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 1, 0, 16, ... | 1 | 362 |
# abc175_c.py
X,K,D = map(int,input().split())
if X-D*K>0:
print(X-D*K)
else:
if (X//D)%2==K%2:
print(X%D)
else:
print(D-X%D)
| # abc175_c.py
X,K,D = map(int,input().split())
X=abs(X)
if X-D*K>0:
print(X-D*K)
else:
if (X//D)%2==K%2:
print(X%D)
else:
print(D-X%D)
| [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 67 |
#include <bits/stdc++.h>
#define Phuong_ \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define REP(i, a, b) for (int i = a; i <= b; ++i)
/// easy access -------------
using namespace std;
using ll = long l... | #include <bits/stdc++.h>
#define Phuong_ \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define REP(i, a, b) for (int i = a; i <= b; ++i)
/// easy access -------------
using namespace std;
using ll = long l... | [["+", 0, 57, 64, 1, 0, 16, 12, 2, 63, 22], ["+", 0, 16, 12, 2, 3, 4, 0, 23, 0, 24], ["+", 3, 4, 0, 23, 0, 41, 75, 23, 0, 25], ["+", 64, 1, 0, 16, 12, 2, 3, 4, 0, 24]] | 1 | 287 |
import math
y, k, d = map(int, input().split())
if y >= 0:
x = y
else:
x = -y
i = math.floor(x / d)
if i >= k:
p = x - k * d
elif i == x / d:
if i + k == 2 * int(i + k):
p = 0
else:
p = d
else:
if (2 * i + 1) * d == 2 * x:
p = x - i * d
else:
if i + k == 2 * i... | import math
y, k, d = map(int, input().split())
if y >= 0:
x = y
else:
x = -y
i = math.floor(x / d)
if i >= k:
p = x - k * d
elif i == x / d:
if i + k == 2 * int((i + k) / 2):
p = 0
else:
p = d
else:
if (2 * i + 1) * d == 2 * x:
p = x - i * d
else:
if i + k ==... | [["+", 12, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 12, 652, 3, 4, 0, 657, 31, 23, 0, 25], ["+", 0, 657, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 657, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 156 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(c) begin(c), end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template <typename T1, typename T2> bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(c) begin(c), end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template <typename T1, typename T2> bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
... | [["+", 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 | 218 |
#include <iostream>
using namespace std;
long long x, k, d;
int main() {
cin >> x >> k >> d;
if (x / d <= k) {
k -= (x / d);
x -= d * (x / d);
if (k) {
if (x >= 0 && abs(x - d) < abs(x)) {
x -= d;
k--;
} else if (x < 0 && abs(x + d) < abs(x)) {
x += d;
k--;
... | #include <iostream>
using namespace std;
long long x, k, d;
int main() {
cin >> x >> k >> d;
if (abs(x / d) <= k) {
k -= (x / d);
x -= d * (x / d);
if (k) {
if (x >= 0 && abs(x - d) < abs(x)) {
x -= d;
k--;
} else if (x < 0 && abs(x + d) < abs(x)) {
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 | 184 |
#include "bits/stdc++.h"
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x > k * d) {
cout << x - k * d << endl;
} else {
long long ans = x % d;
long long f = k - x / d;
if (f & 1)
ans = abs((d - ans));
... | #include "bits/stdc++.h"
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
cout << x - k * d << endl;
} else {
long long ans = x % d;
long long f = k - x / d;
if (f & 1)
ans = abs((d - ans));... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 115 |
X,K,D = map(int,input().split())
if X >= K*D:
print(X-K*D)
else:
if (K - X//D) % 2 == 0:
print(X-X//D*D)
else:
print((X//D+1)*D-X) | X,K,D = map(int,input().split())
X = abs(X)
if X >= K*D:
print(X-K*D)
else:
if (K - X//D) % 2 == 0:
print(X-X//D*D)
else:
print((X//D+1)*D-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 | 74 |
#include <iostream>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
long long ans;
if (x / k >= d)
ans = x - k * d;
else {
if ((k - x / d) % 2 == 0)
ans = x - x / d * d;
else
ans == d - x + x / d *d;
}
cout << ans << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
long long ans;
if (x / d >= k)
ans = x - k * d;
else {
if ((k - x / d) % 2 == 0)
ans = x - x / d * d;
else
ans = d - x + x / d * d;
}
cout << ans << endl;
return 0;
} | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 57, 75, 76, 0, 1, 0, 16, 17, 60], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 17, 32]] | 1 | 104 |
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
ll X, k, d;
cin >> X >> k >> d;
int x =... | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
ll X, k, d;
cin >> X >> k >> d;
ll x = ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 124 |
#include <bits/stdc++.h>
using namespace std;
long long x, k, d;
int main() {
scanf("%lld%lld%lld", &x, &k, &d);
x = abs(x);
if (x >= k * d)
return 0 * printf("%lld\n", x - k * d);
long long cnt = k - x / d;
if (cnt % 2 == 0)
printf("%lld\n", x % d);
else
printf("%lld\n", d - x % d);
}
| #include <bits/stdc++.h>
using namespace std;
long long x, k, d;
int main() {
scanf("%lld%lld%lld", &x, &k, &d);
x = abs(x);
if (x / d >= k)
return 0 * printf("%lld\n", x - k * d);
long long cnt = k - x / d;
if (cnt % 2 == 0)
printf("%lld\n", x % d);
else
printf("%lld\n", d - x % d);
}
| [["+", 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 | 113 |
x,k,d=map(int,input().split())
x=abs(x)
if k<=k//d:
print(x-d*k)
elif (k-x//d)%2==0:
print(x%d)
else:
print(d-x%d) | x,k,d=map(int,input().split())
x=abs(x)
if k*d<=x:
print(x-d*k)
elif (k-x//d)%2==0:
print(x%d)
else:
print(d-x%d) | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 31, 22], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 17, 676], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 48], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]] | 5 | 68 |
x, k, d = map(int,input().split())
x = x if x>=0 else -x
if k >= x//d:
if (x//d)%2 == k%2:
print(x%d)
else:
print(min(abs(x%d-k),abs(x%d+k)))
else:
print(abs(x-d*k))
| x, k, d = map(int,input().split())
x = x if x>=0 else -x
if k >= x//d:
if (x//d)%2 == k%2:
print(x%d)
else:
print(min(abs(x%d-d),abs(x%d+d)))
else:
print(abs(x-d*k))
| [["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 92 |
#include <cmath>
#include <iostream>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X >= K * D) {
cout << (X - (K * D));
} else {
long long cnt = X / D;
long long step = K - cnt; // 残回数
long long near = X % D;
if (step % 2 == 0) {
cout << n... | #include <cmath>
#include <iostream>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X / D >= K) {
cout << (X - (K * D));
} else {
long long cnt = X / D;
long long step = K - cnt; // 残回数
long long near = X % D;
if (step % 2 == 0) {
cout << 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 | 114 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x >= k * d)
cout << x - k * d << endl;
else if ((k - x / d) % 2 == 0)
cout << x % d << endl;
else if (x % d - d <= 0)
cout << abs(x % d - d) << endl;
else
cout << x % d + d <... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k)
cout << x - k * d << endl;
else if ((k - x / d) % 2 == 0)
cout << x % d << endl;
else if (x % d - d <= 0)
cout << abs(x % d - d) << endl;
else
cout << x % d + d <... | [["+", 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 | 114 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
long long x, k, d;
cin >> x >> k >> d;
long long ax = abs(x);
long long res = min(k, x / d);
long long ns = ax - d ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
long long x, k, d;
cin >> x >> k >> d;
long long ax = abs(x);
long long res = min(k, ax / d);
long long ns = ax - d... | [["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22]] | 1 | 109 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
if (X < 0)
X = -X;
if (X - K * D >= 0) {
cout << X - K * D << endl;
} else if ((K - X / D) % 2 == 0) {
cout << X % D << endl;
} else {
cout << D - X % D << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
if (X < 0)
X = -X;
if (X / D - K >= 0) {
cout << X - K * D << endl;
} else if ((K - X / D) % 2 == 0) {
cout << X % D << endl;
} else {
cout << D - X % D << endl;
}
} | [["+", 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 | 99 |
x,k,d=map(int,input().split())
x=abs(x)
if x//d <=k:
ans=x%d
if (x//d)%2==1:
ans=abs(ans-d)
print(ans)
else:
ans=x-d*k
print(ans) | x,k,d=map(int,input().split())
x=abs(x)
if x//d <=k:
ans=x%d
if (k-x//d)%2==1:
ans=abs(ans-d)
print(ans)
else:
ans=x-d*k
print(ans) | [["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 33]] | 5 | 72 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
... | [["+", 15, 339, 51, 16, 12, 16, 31, 23, 0, 24], ["+", 51, 16, 12, 16, 31, 23, 0, 16, 17, 85], ["+", 51, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 15, 339, 51, 16, 12, 16, 31, 23, 0, 25], ["-", 15, 339, 51, 16, 12, 16, 12, 16, 17, 48], ["-", 15, 339, 51, 16, 12, 16, 12, 16, 12, 22]] | 1 | 198 |
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH
*RANJAN******************************************************
*******************************... | /**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH
*RANJAN******************************************************
*******************************... | [["-", 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 | 159 |
X,K,D=map(int,input().split())
if X<=K*D:
if (K-X//D)%2==0:X=X%D
else:X=abs(X%D-D)
else:
X=X-K*D
print(X) | X,K,D=map(int,input().split())
X=abs(X)
if X<=K*D:
if (K-X//D)%2==0:X=X%D
else:X=abs(X%D-D)
else:
X=X-K*D
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 | 68 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x, k, d;
int main() {
std::ios::sync_with_stdio(false);
cin >> x >> k >> d;
if (x < 0)
x = -x;
if (x >= k * d) {
cout << x - k * d << endl;
return 0;
}
if (x / d % 2 == k % 2)
cout << x % d << endl;
else
cout << d -... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x, k, d;
int main() {
std::ios::sync_with_stdio(false);
cin >> x >> k >> d;
if (x < 0)
x = -x;
if (x / d >= k) {
cout << x - k * d << endl;
return 0;
}
if (x / d % 2 == k % 2)
cout << x % d << endl;
else
cout << d -... | [["+", 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 | 109 |
X, K, D = map(int, input().split())
X = abs(X)
if K%2 == 1:
K -= 1
X -= K
K_ = K // 2
min_Y = X - K_ * (2 * D)
if min_Y > 0:
print(min_Y)
else:
min_Y_p = X % (2 * D)
min_Y_m = 2 * D - X % (2 * D)
print(min(min_Y_p, min_Y_m )) | X, K, D = map(int, input().split())
X = abs(X)
if K%2 == 1:
K -= 1
X -= D
K_ = K // 2
min_Y = X - K_ * (2 * D)
if min_Y > 0:
print(min_Y)
else:
min_Y_p = X % (2 * D)
min_Y_m = 2 * D - X % (2 * D)
print(min(min_Y_p, min_Y_m )) | [["-", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22]] | 5 | 95 |
#include <bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define loop(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 0x3f3f3f40;
const long... | #include <bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define loop(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 0x3f3f3f40;
const long... | [["+", 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 | 237 |
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
long long X, K, D;
int main() {
cin >> X >> K >> D;
long long tmp_cnt = 0;
X = abs(X);
//整数
tmp_cnt = X / D;
if (tmp_cnt > K) {
cout << abs(X - K * D);
return 0;
} else {
long near_v... | #include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
long long X, K, D;
int main() {
cin >> X >> K >> D;
long long tmp_cnt = 0;
X = abs(X);
//整数
tmp_cnt = X / D;
if (tmp_cnt >= K) {
cout << abs(X - K * D);
return 0;
} else {
long near_... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 170 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) \
for (int i = 0; i < (int)(n); i++) \
;
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0
int main() {
long x, k, d;
cin >> x >> k >> d;
long... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) \
for (int i = 0; i < (int)(n); i++) \
;
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0
int main() {
long x, k, d;
cin >> x >> k >> d;
long... | [["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25]] | 1 | 140 |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
long long int x, k, d, min;
cin >> x >> k >> d;
int m = abs(x);
if (k <= m / d) {
min = m - k * d;
} else {
if ((k - (m / d)) % 2 == 0) {
min = m % d;
} else {
min = d - (m % d);
}
}
cout << min;
} | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
long long int x, k, d, min;
cin >> x >> k >> d;
long long int m = abs(x);
if (k <= m / d) {
min = m - k * d;
} else {
if ((k - (m / d)) % 2 == 0) {
min = m % d;
} else {
min = d - (m % d);
}
}
cout... | [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 103 |
X, K, D = map(int, input().split())
if abs(X) // D > K:
print(abs(X - K * D))
exit()
mod = abs(X) % D
if (K - (abs(X) // D)) % 2 == 0:
print(mod)
else:
print(abs(mod - D))
| X, K, D = map(int, input().split())
if abs(X) // D > K:
print(abs(X) - K * D)
exit()
mod = abs(X) % D
if (K - (abs(X) // D)) % 2 == 0:
print(mod)
else:
print(abs(mod - D))
| [["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 83 |
x, k, d = [int(x) for x in input().split(' ')]
q = x // d
r = x % d
if k >= q:
if k%2 == q%2:
print(r)
else:
print(d - r)
else:
print(x - d*k)
| x, k, d = [int(x) for x in input().split(' ')]
x = abs(x)
q = x // d
r = x % d
if k >= q:
if k%2 == q%2:
print(r)
else:
print(d - r)
else:
print(x - d*k) | [["+", 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 | 71 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long X = sc.nextInt();
long K = sc.nextInt();
long D = sc.nextInt();
long res;
long tika = Math.abs(X) / D;
if (K <= tika) {
res = Math.abs(X) - D * K;
} el... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long X = sc.nextLong();
long K = sc.nextLong();
long D = sc.nextLong();
long res;
long tika = Math.abs(X) / D;
if (K <= tika) {
res = Math.abs(X) - D * K;
}... | [["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]] | 3 | 155 |
X, K, D = map(int,input().split())
res = 0
if X >= K * D:
res = X - K * D
else:
i = X // D
j = K - i
if j % 2 == 0:
res = X - D * i
else:
res = X - D * (i + 1)
print(abs(res)) | X, K, D = map(int,input().split())
res = 0
X = abs(X)
if X >= K * D:
res = X - K * D
else:
i = X // D
j = K - i
if j % 2 == 0:
res = X - D * i
else:
res = X - D * (i + 1)
print(abs(res)) | [["+", 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 | 81 |
X, K, D = list(map(int, input().split()))
X = abs(X)
if(X >= K * D):
print(X - K * D)
else:
q = X // D
r = X // D
if((K - q) % 2 == 0):
print(r)
else:
print(abs(r - D)) | X, K, D = list(map(int, input().split()))
X = abs(X)
if(X >= K * D):
print(X - K * D)
else:
q = X // D
r = X % D
if((K - q) % 2 == 0):
print(r)
else:
print(abs(r - D))
| [["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 676], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109]] | 5 | 84 |
#include <bits/stdc++.h>
#include <stdio.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)... | #include <bits/stdc++.h>
#include <stdio.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)... | [["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33]] | 1 | 253 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, k, d, ans;
cin >> x >> k >> d;
x = abs(x);
int c = x / d;
ans = x - min(k, c) * d;
if (k <= c || (k - c) % 2 == 0) {
cout << abs(ans);
} else
cout << abs(ans - d);
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d, ans;
cin >> x >> k >> d;
x = abs(x);
long long c = x / d;
ans = x - min(k, c) * d;
if (k <= c || (k - c) % 2 == 0) {
cout << abs(ans);
} else
cout << abs(ans - d);
}
| [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 91 |
x,k,d=map(int,input().split())
a=x//d
if a>=k:
ans=x-(k*d)
else:
b=x%d
c=d-b
if b<=c:
if (k-a)%2==0:
ans=b
else:
ans=c
else:
if (k-a)%2==0:
ans=b
else:
ans=c
print(ans) | x,k,d=map(int,input().split())
x=abs(x)
a=x//d
if a>=k:
ans=x-(k*d)
else:
b=x%d
c=d-b
if b<=c:
if (k-a)%2==0:
ans=b
else:
ans=c
else:
if (k-a)%2==0:
ans=b
else:
ans=c
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 | 98 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) begin(v), end(v)
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll n = abs(x) / d, ans1 = abs(x) % d, ans2 = abs(ans1 - d);
if (k > n) {
if ((k - n) % 2 == 1)
cout << ans2 ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) begin(v), end(v)
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll n = abs(x) / d, ans1 = abs(x) % d, ans2 = abs(ans1 - d);
if (k > n) {
if ((k - n) % 2 == 1)
cout << ans2 ... | [["+", 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 | 124 |
x, k, d = map(int,input().split())
x = abs(x)
if x>k*d:
ans = x-k*d
else:
cnt = x//d#xに最も近づくための移動回数
if (k-cnt)%2==0:
ans = x-cnt*d
else:
if x > 0:
ans = x-cnt*d-d
else:
ans = x-cnt*d+d
print(ans) | x, k, d = map(int,input().split())
x = abs(x)
if x>k*d:
ans = x-k*d
else:
cnt = x//d#xに最も近づくための移動回数
if (k-cnt)%2==0:
ans = x-cnt*d
else:
if x>0:
ans = abs(x-cnt*d-d)
else:
ans = abs(x-cnt*d+d)
print(ans) | [["+", 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], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22]] | 5 | 95 |
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-10;
const int mod = 1000000007;
#define fio \
ios_base::sync_with_stdio(0); \
cin.tie(... | #include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-10;
const int mod = 1000000007;
#define fio \
ios_base::sync_with_stdio(0); \
cin.tie(... | [["+", 15, 339, 51, 16, 12, 16, 31, 2, 63, 22], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 25]] | 1 | 668 |
x ,k ,d = map(int,input().split())
x = abs(x)
c = x // d
# 必要な移動回数
k_r = k - c
# 移動した後の残りの移動回数
ans_2 = x - d * c
#残り移動回数が偶数のときのxからの距離
if c >= k:
print(x - k * c )
exit()
x_l = x - d * c
#xまでの残りの距離
if k_r % 2 == 0:
print(ans_2)
exit()
else :
x_l -= d
x_l =abs(x_l)
print(x_l)
| x ,k ,d = map(int,input().split())
x = abs(x)
c = x // d
# 必要な移動回数
k_r = k - c
# 移動した後の残りの移動回数
ans_2 = x - d * c
#残り移動回数が偶数のときのxからの距離
if c >= k:
print(x - k * d )
exit()
x_l = x - d * c
#xまでの残りの距離
if k_r % 2 == 0:
print(ans_2)
exit()
else :
x_l -= d
x_l =abs(x_l)
print(x_l) | [["-", 0, 652, 3, 4, 0, 657, 12, 657, 12, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 657, 12, 22]] | 5 | 97 |
x, k, d = map(int, input().split())
x = abs(x)
if x>k*d:
print(x-k*d)
else:
a = x//d
if (k-a)%2==0:
print(x-a*d)
else:
print(abs(x-a*2*d))
| x, k, d = map(int, input().split())
x = abs(x)
if x>k*d:
print(x-k*d)
else:
a = x//d
if (k-a)%2==0:
print(x-a*d)
else:
print(abs(x-a*d-d))
| [["-", 3, 4, 0, 657, 12, 657, 31, 657, 12, 612], ["-", 0, 652, 3, 4, 0, 657, 12, 657, 17, 48], ["+", 3, 4, 0, 657, 31, 657, 12, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33]] | 5 | 80 |
X, K, D=(map(int, input().split()))
X=abs(X)
N=int(X/D)
if N==0:
if K%2==0:
print(X)
else:
print(D-X)
else:
if N>K:
print(X-K*D)
if (K-N)%2==0:
print(X-N*D)
else:
print((N+1)*D-X) | X, K, D=(map(int, input().split()))
X=abs(X)
N=int(X/D)
if N==0:
if K%2==0:
print(X)
else:
print(D-X)
else:
if N>K:
print(X-K*D)
elif (K-N)%2==0:
print(X-N*D)
else:
print((N+1)*D-X) | [["-", 0, 57, 75, 76, 8, 196, 0, 57, 0, 121], ["+", 75, 76, 8, 196, 0, 57, 75, 665, 0, 683]] | 5 | 106 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast \
ios::sync_with_stdio(false); \
cin.tie(NULL);
#define rep(n) for (int i = 0; i < n; i++)
#define rep1... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast \
ios::sync_with_stdio(false); \
cin.tie(NULL);
#define rep(n) for (int i = 0; i < n; i++)
#define rep1... | [["+", 0, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 12, 13]] | 1 | 148 |
X,K,D = map(int,input().split())
X = abs(X)
# Dだけ原点に向かって移動したとき,最も原点に近い座標
r = X%D
# 残り移動可能回数
q = X//D
# rに到達後は残りの移動回数が偶数か奇数かで場合分け
# K回を超えている場合
if K <= q:
print(X-D*K)
# 残り移動可能回数
rem = K - q
# 残り移動可能回数が偶数なら,その場所にとどまることできる
if rem%2 == 0:
print(r)
# 奇数なら,絶対に負の側でゴールすることになる.よってr-Dの絶対値であるD-rが解
else:
print(D-r)... | X,K,D = map(int,input().split())
X = abs(X)
# Dだけ原点に向かって移動したとき,最も原点に近い座標
r = X%D
# rまでに要した移動回数
q = X//D
# rに到達後は残りの移動回数が偶数か奇数かで場合分け
# K回を超えている場合
if K <= q:
print(X-D*K)
else:
# 残り移動可能回数
rem = K - q
# 残り移動可能回数が偶数なら,その場所にとどまることできる
if rem%2 == 0:
print(r)
# 奇数なら,絶対に負の側でゴールすることになる.よってr-D... | [["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 95], ["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 102]] | 5 | 78 |
X, K, D = map(int, input().split())
if X >= K * D:
ans = X - K * D
else:
n, d = divmod(X, D)
ans = d
if (K - n) % 2:
ans = D - d
print(ans) | X, K, D = map(int, input().split())
X = abs(X)
if X >= K * D:
ans = X - K * D
else:
n, d = divmod(X, D)
ans = d
if (K - n) % 2:
ans = 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 | 65 |
X, K, D = map(int, input().split())
X = abs(X)
if(D * K < X):
print(X - D * K)
else:
N = (X + D - 1) // D
if N % 2 == K % 2:
print(abs(X - N * D))
else:
print(abs(X - N * (D - 1)))
| X, K, D = map(int, input().split())
X = abs(X)
if(D * K < X):
print(X - D * K)
else:
N = (X + D - 1) // D
if N % 2 == K % 2:
print(abs(X - N * D))
else:
print(abs(X - (N - 1) * D))
| [["-", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22], ["-", 0, 652, 3, 4, 0, 657, 12, 657, 17, 48], ["-", 0, 657, 12, 657, 12, 23, 0, 657, 31, 22], ["+", 0, 657, 12, 657, 31, 23, 0, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 657, 17, 48], ["+", 0, 652, 3, 4, 0, 657, 12, 657, 12, 22]] | 5 | 91 |
x,k,d=list(map(int,input().split()))
if d>=abs(x)//k:
y=abs(x)//k
ans=abs(abs(x)-y*d)
ans=abs(ans-((k-y)%2)*d)
else:
ans=abs(abs(x)-k*d)
print(ans) | x,k,d=list(map(int,input().split()))
if k>=abs(x)//d:
y=abs(x)//d
ans=abs(abs(x)-y*d)
ans=abs(ans-((k-y)%2)*d)
else:
ans=abs(abs(x)-k*d)
print(ans) | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 12, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 12, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22]] | 5 | 89 |
n, k, d = map(int,input().split())
if abs(n) - k * d < 0:
j = abs(n)//d
z = k - j
if z % 2 == 0:
print(n-j*d)
else:
print(d-(n-j*d))
else:
print(abs(n) - k * d) | n, k, d = map(int,input().split())
if abs(n) - k * d < 0:
j = abs(n)//d
z = k - j
if z % 2 == 0:
print(abs(n)-j*d)
else:
print(d-(abs(n)-j*d))
else:
print(abs(n) - k * 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], ["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 24], ["+", 0, 657, 12, 23, 0, 657, 31, 652, 63, 22], ["+", 12, 23, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 85 |
#include <bits/stdc++.h>
#define boost \
ios_base::sync_with_stdio(0); \
cin.tie(); \
cout.tie()
#define all(x) x.begin(), x.end()
#defi... | #include <bits/stdc++.h>
#define boost \
ios_base::sync_with_stdio(0); \
cin.tie(); \
cout.tie()
#define all(x) x.begin(), x.end()
#defi... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 258 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
int main() {
ll x, k, d;
cin >> x >> k >> d;
l... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
int main() {
ll x, k, d;
cin >> x >> k >> d;
l... | [["-", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 0, 9, 0, 57, 75, 76, 0, 1, 0, 35]] | 1 | 218 |
X, K, D = gets.split.map(&:to_i)
x = X.abs
k = K - x / D
if k < 0
puts x - K * D
exit
end
x = X % D
if k % 2 == 0
puts x
else
puts D - x
end
| X, K, D = gets.split.map(&:to_i)
x = X.abs
k = K - x / D
if k < 0
puts x - K * D
exit
end
x = x % D
if k % 2 == 0
puts x
else
puts D - x
end
| [["-", 36, 36, 0, 493, 0, 662, 12, 738, 31, 743], ["+", 36, 36, 0, 493, 0, 662, 12, 738, 31, 22]] | 4 | 58 |
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()
def main():
x, k, d = map(int, input().split())
desired = abs(x) // d
if k <= desired:
if x < 0:
x += k * d
else:
x -= k * d
print(abs(x))
return
if x < 0:
... | import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()
def main():
x, k, d = map(int, input().split())
desired = abs(x) // d
if k <= desired:
if x < 0:
x += k * d
else:
x -= k * d
print(abs(x))
return
if x < 0:
... | [["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 171 |
X,D,K = map(int,input().split())
X = abs(X)
if X >= K*D:
ans = X - K*D
else:
k = X // D
if (K - k) % 2 == 0:
ans = X - k*D
else:
ans = abs(X-(k+1)*D)
print(ans)
| X,K,D = map(int,input().split())
X = abs(X)
if X >= K*D:
ans = X - K*D
else:
k = X // D
if (K - k) % 2 == 0:
ans = X - k*D
else:
ans = abs(X-(k+1)*D)
print(ans)
| [["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 21], ["+", 0, 656, 0, 1, 0, 662, 31, 684, 0, 21], ["+", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22]] | 5 | 83 |
#include <algorithm>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
ll res;
int main() {
cin.tie(nullptr);
io... | #include <algorithm>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
ll res;
int main() {
cin.tie(nullptr);
io... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 129 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9 + 7;
int main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if ((__uint128_t)D * (__uint128_t)K <= K) {
cout << X - D * K ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9 + 7;
int main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if ((__uint128_t)D * (__uint128_t)K <= X) {
cout << X - D * K ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 137 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
long x = Math.abs(s.nextLong());
long k = s.nextLong();
long d = s.nextLong();
long ans = x / d;
if (ans > k) {
System.out.println(x - k * d);
} else {
k -= ... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
long x = Math.abs(s.nextLong());
long k = s.nextLong();
long d = s.nextLong();
long ans = x / d;
if (ans > k) {
System.out.println(x - k * d);
} else {
k -= ... | [["-", 3, 4, 0, 16, 12, 16, 31, 16, 12, 499], ["-", 0, 492, 3, 4, 0, 16, 12, 16, 17, 48], ["+", 3, 4, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 3, 4, 0, 492, 3, 4, 0, 16, 17, 33]] | 3 | 148 |
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
long long ans;
if (X < 0) {
X = -1 * X;
}
long count = X / D; // 残り距離が正としたときの試行回数
if (X >= count) {
ans = X - K * D;
cout << ans << endl;
return 0;
}
long distance = X % D; /... | #include <iostream>
#include <vector>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
long long ans;
if (X < 0) {
X = -1 * X;
}
long count = X / D; // 残り距離が正としたときの試行回数
if (count > K) {
ans = X - K * D;
cout << ans << endl;
return 0;
}
long distance = X % D; //... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 128 |
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
from itertools import product
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI_(): return list(... | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
from itertools import product
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI_(): return list(... | [["+", 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 | 443 |
X, K, D = map(int, input().split())
absX = abs(X)
a = absX - K * D
minX = absX % D
if a > 0:
print(a)
elif a <= 0:
Kmin = (X - minX) / D
Krem = K - Kmin
if Krem % 2 == 0:
print(min(abs(minX), abs(minX - 2 * D)))
else:
print(min(abs(minX + D), abs(minX - D))) | X, K, D = map(int, input().split())
absX = abs(X)
a = absX - K * D
minX = absX % D
if a > 0:
print(a)
elif a <= 0:
Kmin = (absX - minX) / D
Krem = K - Kmin
if Krem % 2 == 0:
print(min(abs(minX), abs(minX - 2 * D)))
else:
print(min(abs(minX + D), abs(minX - D)))
| [["-", 0, 662, 12, 657, 31, 23, 0, 657, 31, 22], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 31, 22]] | 5 | 111 |
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define P pair<int, int>
typedef vector<int> vec;
typedef vector<vec> mat;
ll abs_... | #include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define P pair<int, int>
typedef vector<int> vec;
typedef vector<vec> mat;
ll abs_... | [["+", 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 | 166 |
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define INF 2e18
#define eps 1e-9
#define FastRead \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define fRead freopen("input.txt", "r", ... | #include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define INF 2e18
#define eps 1e-9
#define FastRead \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define fRead freopen("input.txt", "r", ... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 306 |
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define INF 2e18
#define eps 1e-9
#define FastRead \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define fRead freopen("input.txt", "r", ... | #include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define INF 2e18
#define eps 1e-9
#define FastRead \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define fRead freopen("input.txt", "r", ... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 304 |
position,moves,distance=[int(x) for x in input().split()]
if position>=distance*moves:
print(abs(position-distance*moves))
else:
variable=moves-position//distance
if variable%2==0:
print(abs((position-distance*(position//distance))))
else:
print(abs(position-distance*((position//distance) + 1))) | position,moves,distance=[int(x) for x in input().split()]
position=abs(position)
if position>=distance*moves:
print(abs(position-distance*moves))
else:
variable=moves-position//distance
if variable%2==0:
print(abs((position-distance*(position//distance))))
else:
print(abs(position-distance*((position//distance)... | [["+", 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 | 94 |
// C.cpp : このファイルには 'main'
// 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <cmath>
#include <iostream>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (abs(x) > k * d) {
cout << abs(x) - k * d << endl;
} else {
long long a = abs(x) % d;
long long b = abs(x) / d;
... | // C.cpp : このファイルには 'main'
// 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <cmath>
#include <iostream>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (abs(x) / d > k) {
cout << abs(x) - k * d << endl;
} else {
long long a = abs(x) % d;
long long b = abs(x) / d;
... | [["+", 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 | 134 |
x,k,d=map(int,input().split())
if x>=0:
if x//d>=k:
print(abs(x-k*d))
else:
if (k-(x//d))%2==0:
print(abs(x-(x//d)*d))
else:
print(abs((x-(x//d)*d-d)))
else:
if -x//d>=k:
print(abs(x+k*d))
else:
if (k-(-x//d))%2==0:
print(abs(x+(-x//d)*d))
else:
print(abs(x+(-x//d... | x,k,d=map(int,input().split())
if x>=0:
if x//d>=k:
print(abs(x-k*d))
else:
if (k-(x//d))%2==0:
print(abs(x-(x//d)*d))
else:
print(abs(x-(x//d)*d-d))
else:
if -x//d>=k:
print(abs(x+k*d))
else:
if (k-(-x//d))%2==0:
print(abs(x+(-x//d)*d))
else:
print(abs(x+(-x//d)*... | [["-", 3, 4, 0, 652, 3, 4, 0, 23, 0, 24], ["-", 3, 4, 0, 652, 3, 4, 0, 23, 0, 25], ["-", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 169 |
# coding: utf-8
# Your code here!
X,K,D=map(int,input().split())
move=min(abs(X)//D,K)
ans=X-move*D
if move==K:
print(ans)
else:
if (K-move)%2==0:
print(ans)
else:
print(abs(ans-D)) | # coding: utf-8
# Your code here!
X,K,D=map(int,input().split())
move=min(abs(X)//D,K)
ans=abs(X)-move*D
if move==K:
print(ans)
else:
if (K-move)%2==0:
print(ans)
else:
print(abs(ans-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 | 77 |
#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>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
#define PI 3.14159265358979323846264338327950L
int main() {
ll X, K,... | #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>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
#define PI 3.14159265358979323846264338327950L
int main() {
ll X, K,... | [["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 22]] | 1 | 212 |
import numpy as np
import matplotlib.pyplot as plt
inpt = input()
inpt_list = inpt.split(" ")
X, K, D = [int(x) for x in inpt_list]
X_abs = np.abs(X)
num = X_abs // D
rem = K - num
if rem < 0:
out = X_abs - D*K
else:
if rem%2==0:
out = X_abs - num*D
else:
out = np.abs(X_abs - num*D - D)
pr... | import numpy as np
inpt = input()
inpt_list = inpt.split(" ")
X, K, D = [int(x) for x in inpt_list]
X_abs = np.abs(X)
num = X_abs // D
rem = K - num
if rem < 0:
out = X_abs - D*K
else:
if rem%2==0:
out = X_abs - num*D
else:
out = np.abs(X_abs - num*D - D)
print(out) | [["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["-", 0, 656, 0, 596, 141, 704, 141, 673, 0, 22], ["-", 0, 656, 0, 596, 141, 704, 141, 673, 0, 131], ["-", 36, 36, 0, 656, 0, 596, 141, 704, 0, 272], ["-", 36, 36, 0, 656, 0, 596, 141, 704, 705, 22]] | 5 | 107 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k, d;
cin >> n >> k >> d;
n = abs(n);
if (n / d >= k) {
n = n - d * k;
cout << n;
return 0;
}
int x = n / d;
n = n - x * d;
k = k - x; // Hope's are left
if (k % 2 =... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int64_t n, k, d;
cin >> n >> k >> d;
n = abs(n);
if (n / d >= k) {
n = n - d * k;
cout << n;
return 0;
}
int64_t x = n / d;
n = n - x * d;
k = k - x; // Hope's are left
if ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]] | 1 | 141 |
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>... | #define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>... | [["+", 8, 9, 0, 1, 0, 16, 12, 2, 63, 22], ["+", 0, 1, 0, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 16, 12, 2, 3, 4, 0, 25]] | 1 | 138 |
X, K, D = map(int, input().split())
if X // D <= K:
print(min(abs(X % D - (K - (X // D))%2*D), abs(X % D + (K - (X // D))%2*D)))
else:
print(min(abs(X - K*D), abs(X + K*D)))
| X, K, D = map(int, input().split())
X = abs(X)
if X // D <= K:
print(min(abs(X % D - (K - (X // D))%2*D), abs(X % D + (K - (X // D))%2*D)))
else:
print(min(abs(X - K*D), 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 | 97 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll IN... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll IN... | [["+", 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 | 1,426 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
ll x, k, d;
cin >> x >> k >> d;
if (x > 0) {
if (k < x / d)
cout <... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
ll x, k, d;
cin >> x >> k >> d;
if (x > 0) {
if (k < x / d)
cout <... | [["+", 64, 1, 0, 16, 12, 16, 31, 91, 17, 33], ["-", 0, 57, 64, 1, 0, 16, 12, 16, 17, 72], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 17, 33]] | 1 | 168 |
def solve(string):
x, k, d = map(int, string.split())
x = abs(x)
if k % 2:
x = min(x, x - d, x + d, key=abs)
k -= 1
if x < k * d:
return str(min(x % (2 * d), abs((x % (2 * d)) - 2 * d)))
else:
return str(x - k * d)
if __name__ == '__main__':
import sys
print... | def solve(string):
x, k, d = map(int, string.split())
x = abs(x)
if k % 2:
x = min(x - d, x + d, key=abs)
k -= 1
if x < k * d:
return str(min(x % (2 * d), abs((x % (2 * d)) - 2 * d)))
else:
return str(x - k * d)
if __name__ == '__main__':
import sys
print(so... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22]] | 5 | 129 |
#include <stdio.h>
#include <stdlib.h>
int main(void) {
long long int x, k, d;
long long int q, r;
scanf("%lld%lld%lld", &x, &k, &d);
x = llabs(x);
d = llabs(d);
q = x / d;
r = x % d;
if (k <= q) {
printf("%lld", x - d * k);
return 0;
}
if (k - q % 2 == 0) {
printf("%lld", r);
r... | #include <stdio.h>
#include <stdlib.h>
int main(void) {
long long int x, k, d;
long long int q, r;
scanf("%lld%lld%lld", &x, &k, &d);
x = llabs(x);
d = llabs(d);
q = x / d;
r = x % d;
if (k <= q) {
printf("%lld", x - d * k);
return 0;
}
if ((k - q) % 2 == 0) {
printf("%lld", r);
... | [["+", 15, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 23, 0, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 14, 8, 9, 0, 57, 15, 23, 0, 24]] | 0 | 143 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
ll t = ceil(1.0 * x / d);
if (t > k) {
cout << (x - k * d);
} else {
if ((k - t) % 2 == 0) {
;
} else {
t--;
}
cout << (x - t * d);
}
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
ll t = ceil(1.0 * x / d);
if (t > k) {
cout << (x - k * d);
} else {
if ((k - t) % 2 == 0) {
;
} else {
t--;
}
cout << (abs(x - t * d));
}
return 0... | [["+", 0, 1, 0, 16, 12, 23, 0, 2, 63, 22], ["+", 0, 16, 12, 23, 0, 2, 3, 4, 0, 24], ["+", 0, 16, 12, 23, 0, 2, 3, 4, 0, 25]] | 1 | 104 |
x, k, d = map(int,input().split())
x =abs(x)
s = x//d
if x-k*d>0:
print(x-k*d>0)
else:
if (k-s)%2==0:
print(x-s*d)
else:
print(abs(-x+(s+1)*d))
| x, k, d = map(int,input().split())
x =abs(x)
s = x//d
if x-k*d>0:
print(x-k*d)
else:
if (k-s)%2==0:
print(x-s*d)
else:
print(-x+(s+1)*d)
| [["-", 0, 1, 0, 652, 3, 4, 0, 666, 667, 47], ["-", 0, 1, 0, 652, 3, 4, 0, 666, 0, 612], ["-", 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 | 87 |
#include <bits/stdc++.h>
#include <sstream>
#define rep2(i, x, y) for (int i = x; i < (y); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll x, k, d;
cin >> x >> k >> d... | #include <bits/stdc++.h>
#include <sstream>
#define rep2(i, x, y) for (int i = x; i < (y); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll x, k, d;
cin >> x >> k >> d... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109]] | 1 | 144 |
# ABC172 C - Walking Takahashi
X,K,D=map(int,input().split())
X=abs(X)
q=X//D
if q>K:
print(X-K*D)
else:
if (K-q)%2==0:
print(X-q*D)
else:
print(X-(q+1)*D) | # ABC172 C - Walking Takahashi
X,K,D=map(int,input().split())
X=abs(X)
q=X//D
if q>K:
print(X-K*D)
else:
if (K-q)%2==0:
print(X-q*D)
else:
print(-X+(q+1)*D) | [["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 657, 31, 664, 28, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72]] | 5 | 78 |
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define square(x) pow(x, 2.0)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue... | #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define square(x) pow(x, 2.0)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 17, 109], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 12, 22]] | 1 | 315 |
X,K,D = map(int,input().split())
A = abs(X)
ans = 0
if A >= D*K:
print( A - (D * K))
else :
e = A//D
K -= e
x %= D
if K%2 == 0:
print(x)
else:
print(D-x) | X,K,D = map(int,input().split())
A = abs(X)
ans = 0
if A >= D*K:
print( A - (D * K))
else :
e = A//D
K -= e
A %= D
if K%2 == 0:
print(A)
else:
print(D-A) | [["-", 75, 76, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 31, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 76 |
//بسم الله الرحمن الرحيم
/// *** --- ||| In the name of ALLAH ||| --- ***
/// ///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ \
int t; ... | //بسم الله الرحمن الرحيم
/// *** --- ||| In the name of ALLAH ||| --- ***
/// ///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ \
int t; ... | [["-", 0, 57, 15, 339, 51, 16, 31, 91, 17, 111], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 228 |
//بسم الله الرحمن الرحيم
/// *** --- ||| In the name of ALLAH ||| --- ***
/// ///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ \
int t; ... | //بسم الله الرحمن الرحيم
/// *** --- ||| In the name of ALLAH ||| --- ***
/// ///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ \
int t; ... | [["-", 0, 57, 15, 339, 51, 16, 31, 91, 17, 111], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 225 |
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <algorithm>
#include <deque>
#include <iostream>
#include <iterator> // std::back_inserter
#include <tuple>
#include <vector>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
long long mod = x % d;
long long d... | // https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <algorithm>
#include <deque>
#include <iostream>
#include <iterator> // std::back_inserter
#include <tuple>
#include <vector>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
long long mod = x % d;
long long d... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 131 |
x, k, d = map(int, input().split())
if x > 0:
if x < k * d:
if x // d % 2 == k % 2:
g = x % d
else:
g = abs(d - (x % d))
else:
g = x - k * d
elif x == 0:
if k % 2:
g = d
else:
g = 0
else:
if x < k * d:
if abs(x) // d % 2 == k %... | x, k, d = map(int, input().split())
if x > 0:
if x < k * d:
if x // d % 2 == k % 2:
g = x % d
else:
g = abs(d - (x % d))
else:
g = x - k * d
elif x == 0:
if k % 2:
g = d
else:
g = 0
else:
if abs(x) < k * d:
if abs(x) // d % 2 =... | [["+", 8, 196, 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 | 148 |
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x < 0)
x = -x;
if (x / d >= k)
cout << x - x / d * k << endl;
else {
if ((k - x / d) % 2 == 0)
cout << x % d << endl;
else
cout << d - x % d << endl;
}
return 0;... | #include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x < 0)
x = -x;
if (x / d >= k)
cout << x - d * k << endl;
else {
if ((k - x / d) % 2 == 0)
cout << x % d << endl;
else
cout << d - x % d << endl;
}
return 0;
} | [["-", 31, 16, 12, 16, 12, 16, 31, 16, 31, 22], ["-", 31, 16, 12, 16, 12, 16, 31, 16, 17, 85]] | 1 | 102 |
x,k,d=map(int,input().split())
x=abs(x)
t=x-k*d
if t>=0:
print(t)
else:
td=x%d
tk=x//d
if (k-tk)%2==0:
print(tk)
else:
print(abs(td-d)) | x,k,d=map(int,input().split())
x=abs(x)
t=x-k*d
if t>=0:
print(t)
else:
td=x%d
tk=x//d
if (k-tk)%2==0:
print(td)
else:
print(abs(td-d)) | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 78 |
x, k ,d = map(int, input().split())
if k*d <= x:
print(x-k*d)
else:
xx = x
x -= min(k, x//d)*d
k -= min(k, xx//d)
if k % 2 != 0:
ans = min(abs(x-d),abs(x+d))
else:
ans = min(abs(x), abs(x-2*d))
print(ans) | x, k ,d = map(int, input().split())
x=abs(x)
if k*d <= x:
print(x-k*d)
else:
xx = x
x -= min(k, x//d)*d
k -= min(k, xx//d)
if k % 2 != 0:
ans = min(abs(x-d),abs(x+d))
else:
ans = min(abs(x), abs(x-2*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 | 109 |
X, K, D = map(int, input().split())
if K - (X // D) < 0:
X -= K * D
print(X)
else:
K = K - (X // D)
X -= D * (X // D)
if K % 2 == 0:
print(abs(X))
else:
print(abs(X-D)) | X, K, D = map(int, input().split())
X = abs(X)
if K - (X // D) < 0:
X -= K * D
print(X)
else:
K = K - (X // D)
X -= D * (X // D)
if K % 2 == 0:
print(abs(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 | 83 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
c... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
c... | [["+", 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, 16, 12, 16, 31, 22], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]] | 1 | 303 |
x,k,d=map(int,input().split())
cur=abs(x)
count=min(cur//d,k)
cur-=d*count
s=k-count
if s%2==1:
cur-=-d
print(abs(cur))
| x,k,d=map(int,input().split())
cur=abs(x)
count=min(cur//d,k)
cur-=d*count
k-=count
if k%2==1:
cur-=d
print(abs(cur))
| [["-", 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, 657, 17, 33], ["+", 36, 36, 0, 656, 0, 1, 0, 677, 17, 110], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 31, 22], ["-", 64, 196, 0, 1, 0, 677, 12, 664, 17, 33... | 5 | 62 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
if (X < 0) {
X *= -1;
}
if (X - K * D >= 0) {
cout << X - K * D << endl;
} else {
K -= X / D;
X -= (X / D) * D;
if (K % 2) {
cout << D - X << endl;
} else {
cout << X << en... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
if (X < 0) {
X *= -1;
}
if (X / D - K >= 0) {
cout << X - K * D << endl;
// cout << 1 << endl;
} else {
K -= X / D;
X -= (X / D) * D;
if (K % 2) {
cout << D - X << endl;
} el... | [["+", 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 | 107 |
x,k,d = map(int,input().split())
x = abs(x)
if (x//d) > k:
ans = x - d*k
elif (x//d)%2 == 0:
y = x-(x//d)*d
ans = y
else:
y = x-(x//d)*d
ans = y-d
print(abs(ans)) | #移動の最小値(高速化問題)
x,k,d = map(int,input().split())
x = abs(x)
if (x//d) > k:
ans = x - d*k
elif (k-(x//d))%2 == 0:
y = x-(x//d)*d
ans = y
else:
y = x-(x//d)*d
ans = y-d
print(abs(ans)) | [["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 657, 31, 23, 0, 657, 12, 23, 0, 24], ["+", 0, 657, 31, 23, 0, 657, 12, 23, 0, 25]] | 5 | 90 |
#include <bits/stdc++.h>
using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> V) {
os << "[ ";
for (auto v : V)
os << v << " ";
return os << "]";
}
template <class T> ostream &operator<<(ostream &os, set<T> S) {
os << "{ ";
for (auto s : S)
os << s << " ";
return os << ... | #include <bits/stdc++.h>
using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> V) {
os << "[ ";
for (auto v : V)
os << v << " ";
return os << "]";
}
template <class T> ostream &operator<<(ostream &os, set<T> S) {
os << "{ ";
for (auto s : S)
os << s << " ";
return os << ... | [["-", 64, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 11, 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, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 841 |
# C - Walking Takahashi
X, K, D = map(int, input().split())
d = X // D
m = X % D
if K <= d:
ans = X - (D * K)
elif (K - d) % 2 == 0:
ans = X - (D * d)
else:
ans = X - (D * (d+1))
print(abs(ans)) | # C - Walking Takahashi
X, K, D = map(int, input().split())
X = abs(X)
d = X // D
m = X % D
if K <= d:
ans = X - (D * K)
elif (K - d) % 2 == 0:
ans = X - (D * d)
else:
ans = X - (D * (d+1))
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 | 85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.