buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
x,k,d=map(int,input().split())
p=k*d-x
q=p//(2*d)
r=p/(2*d)
if r<=0:
print(-p)
elif 0<r<k:
s=min(p-2*d*q,-p+2*d*(q+1))
print(s)
else:
print(x+k*d)
| x,k,d=map(int,input().split())
p=k*d-x
q=p//(2*d)
r=p/(2*d)
if r<=0:
print(-p)
elif 0<r<k:
s=min(p-2*d*q,-p+2*d*(q+1))
print(s)
else:
print(-x-k*d)
| [["+", 0, 652, 3, 4, 0, 657, 31, 664, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33]] | 5 | 99 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pvec(v) \
for (auto e : v) ... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pvec(v) \
for (auto e : v) ... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]] | 1 | 361 |
#input of int(split by space)
def get_i()
return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
retu... | #input of int(split by space)
def get_i()
return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
retu... | [["+", 0, 652, 3, 4, 0, 738, 31, 652, 17, 131], ["+", 0, 652, 3, 4, 0, 738, 31, 652, 735, 22], ["+", 3, 4, 0, 738, 12, 738, 31, 652, 17, 131], ["+", 3, 4, 0, 738, 12, 738, 31, 652, 735, 22]] | 4 | 242 |
startX, countK, distanceD = map(int, input().split())
n = int(startX / distanceD)
ans = startX % distanceD
if n > countK:
ans += distanceD * (n - countK)
else:
if (countK - n) % 2 == 1:
ans= abs(ans - distanceD)
print(ans)
|
startX, countK, distanceD = map(int, input().split())
n = int(abs(startX) / distanceD)
ans = abs(startX) % distanceD
if n > countK:
ans += distanceD * (n - countK)
else:
if (countK - n) % 2 == 1:
ans= abs(ans - distanceD)
print(ans)
| [["+", 12, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 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 | 70 |
def solve(X, D, lb, ub):
# min abs(X + t * D) (lb <= t <= ub)
t = round(-X / D)
ans = abs(X)
for i in [-2, -1, 0, +1, +2]:
tt = t + i
tt = min(tt, ub)
tt = max(tt, lb)
y = X + tt * D
ans = min(ans, abs(y))
return ans
X, K, D = map(int, input().split())
y1 = ... | def solve(X, D, lb, ub):
# min abs(X + t * D) (lb <= t <= ub)
t = round(-X / D)
ans = abs(X)
for i in [-2, -1, 0, +1, +2]:
tt = t + i
tt = min(tt, ub)
tt = max(tt, lb)
y = X + tt * D
ans = min(ans, abs(y))
return ans
X, K, D = map(int, input().split())
y1 = ... | [["-", 0, 57, 15, 679, 12, 23, 0, 679, 17, 354], ["+", 0, 57, 15, 679, 12, 23, 0, 679, 17, 355]] | 5 | 272 |
X, K, D = map(int, input().split())
X = abs(X)
point = X % D
q = X // D
ans = 0
if q >= K:
ans = abs(X-D*K)
if (K - q) % 2 == 0:
ans = point
else:
ans = D-point
print(ans) | X, K, D = map(int, input().split())
X = abs(X)
point = X % D
q = X // D
ans = 0
if q >= K:
ans = abs(X-D*K)
elif (K - q) % 2 == 0:
ans = point
else:
ans = D-point
print(ans) | [["-", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 75, 665, 0, 683]] | 5 | 77 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll X, K, D;
cin >> X >> K >> D;
ll now = abs(X);
ll num = min(K, X / D);
K -= num;
X -= num * D;
if (K % 2 == 0) {
cout << X << endl;
} else {
cout << D - X << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll X, K, D;
cin >> X >> K >> D;
ll now = abs(X);
ll num = min(K, now / D);
K -= num;
now -= num * D;
if (K % 2 == 0) {
cout << now << endl;
} else {
cout << D - now << endl;
}
} | [["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 1, 0, 16, 31... | 1 | 90 |
// 2020/08/23
// Walking Takahashi
#include <fstream>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long quo; // quotient
quo = x / d;
// cout << "quo=" << quo << endl;
long long ans, tmp1, tmp2;
if (k <= quo) {
... | // 2020/08/23
// Walking Takahashi
#include <fstream>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long quo; // quotient
quo = abs(x) / d;
// cout << "quo=" << quo << endl;
long long ans, tmp1, tmp2;
if (k <= qu... | [["+", 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 | 133 |
x, k, d = map(int, input().split())
if abs(x) // d >= k:
if x > 0:
print(x - k * d)
else:
print(k * d + x)
exit()
div = abs(x) // d
k -= div
if x > 0:
x -= div * d
else:
x += div * d
if k % 2 == 0:
print(abs(x))
else:
print(abs(x - d))
| x, k, d = map(int, input().split())
if abs(x) // d >= k:
if x > 0:
print(x - k * d)
else:
print(abs(k * d + x))
exit()
div = abs(x) // d
k -= div
if x > 0:
x -= div * d
else:
x += div * d
if k % 2 == 0:
print(abs(x))
else:
print(abs(abs(x) - d))
| [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 107 |
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
switch (c) {
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case... | #include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
switch (c) {
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 226 |
X, K, D = map(int, input().split())
# 移動できる距離の max は KD
if abs(X) >= K*D:
ans = abs(X) - K*D
else:
if (K - X//D)%2 == 0:
ans = X%D
else:
ans = X%D - D
print(ans) | X, K, D = map(int, input().split())
# 移動できる距離の max は KD
if abs(X) >= K*D:
ans = abs(X) - K*D
else:
if (K - X//D)%2 == 0:
ans = X%D
else:
ans = X%D - D
ans = abs(ans)
print(ans) | [["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 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 | 72 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
ll t = X / D;
ll p = K - t;
if (K * D > X) {
if (p % 2 == 0)
cout << X - t * D;
else
cout << (t + 1) * D - X;
} else {
cout << X - K * D;
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
ll t = X / D;
ll p = K - t;
if (K >= t) {
if (p % 2 == 0)
cout << X - t * D;
else
cout << (t + 1) * D - X;
} else {
cout << X - K * D;
}
} | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 103 |
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL x, k, d;
int main() {
cin >> x >> k >> d;
x = max(x, -x);
LL divv = x / d;
if (divv >= k)
cout << x - k * d;
else {
LL rem = x % d;
if (divv % 2 == k % 2)
cout << rem;
else
cout << (d - rem) % d;
}
return ... | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL x, k, d;
int main() {
cin >> x >> k >> d;
x = max(x, -x);
LL divv = x / d;
if (divv >= k)
cout << x - k * d;
else {
LL rem = x % d;
if (divv % 2 == k % 2)
cout << rem;
else
cout << d - rem;
}
return 0;
} | [["-", 0, 1, 0, 16, 12, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 16, 12, 16, 31, 23, 0, 25], ["-", 75, 76, 0, 1, 0, 16, 12, 16, 17, 109], ["-", 75, 76, 0, 1, 0, 16, 12, 16, 12, 22]] | 1 | 101 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x < 0)
x = -x;
if (x >= k * d)
cout << x - k * d;
else {
cout << (((k - x / d) % 2 == 0) ? x % d : d - x % d);
}
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x < 0)
x = -x;
if (x / d >= k)
cout << x - k * d;
else {
cout << (((k - x / d) % 2 == 0) ? x % d : 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 | 88 |
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i, a, b) for (int i = a; i <= b; i++)
#define Rev(i, a, b) f... | #include <bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i, a, b) for (int i = a; i <= b; i++)
#define Rev(i, a, b) f... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 232 |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x < 0) {
x *= -1;
}
if (x >= k * d) {
cout << x - k * d;
}
else {
ll m;
while (x >= 0) {
m = x;
x -= d;
k--;
}
if (k % 2 == 0) {
cout << a... | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x < 0) {
x *= -1;
}
if (x / d > k) {
cout << x - k * d;
}
else {
ll m;
while (x >= 0) {
m = x;
x -= d;
k--;
}
if (k % 2 == 0) {
cout << ab... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 119 |
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define INF 1001001001001001001
#define MAX 2001001
#define rep(i, n, m) for (int i = n; i < m; i++)
u... | #include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define INF 1001001001001001001
#define MAX 2001001
#define rep(i, n, m) for (int i = n; i < m; i++)
u... | [["+", 15, 339, 51, 16, 31, 16, 31, 2, 63, 22], ["+", 51, 16, 31, 16, 31, 2, 3, 4, 0, 24], ["+", 51, 16, 31, 16, 31, 2, 3, 4, 0, 25], ["+", 64, 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 | 194 |
n,k,d=map(int,input().split())
q=n//d
r=n%d
if(k<=q):
print(n-k*d)
else:
rem=k-q
if(rem%2==0):
print(r)
else:
print(min(abs(r-d),abs(r+d))) | n,k,d=map(int,input().split())
n=abs(n)
q=n//d
r=n%d
if(k<=q):
print(n-k*d)
else:
rem=k-q
if(rem%2==0):
print(r)
else:
print(min(abs(r-d),abs(r+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 | 84 |
#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>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll l = -x / d;
ll ans;
if (l < -k) {
ans = min(abs(x - k * d), abs(x - (k - 2) * d));
} else if (l > k) {
ans =... | #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>;
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll l = -x / d;
ll ans;
if (l < -... | [["+", 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 | 237 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void) {
ll x;
ll k;
ll d;
ll c;
cin >> x >> k >> d;
x = abs(x);
c = x / d;
if (c == k) {
cout << 0 << endl;
} else if (c > k) {
cout << x - d * k << endl;
} else ... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void) {
ll x;
ll k;
ll d;
ll c;
cin >> x >> k >> d;
x = abs(x);
c = x / d;
if (c == k) {
cout << x - d * k << endl;
} else if (c > k) {
cout << x - d * k << endl;
... | [["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 16, 12, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 16, 12, 16, 17, 48], ["+", 0, 16, 31, 16, 12, 16, 12, 16, 12, 22]] | 1 | 139 |
def main():
x,k,d = map(int,input().split())
if x < k*d:
# minimum = min(d-(x%d),x % d)
cnt, amari = divmod(x,d)
if abs(amari-d) < amari:
amari = abs(amari - d)
cnt += 1
if (k-cnt)%2==0:
print(amari)
else:
print(abs(amari-d)... | def main():
x,k,d = map(int,input().split())
x = abs(x)
if x < k*d:
# minimum = min(d-(x%d),x % d)
cnt, amari = divmod(x,d)
if abs(amari-d) < amari:
amari = abs(amari - d)
cnt += 1
if (k-cnt)%2==0:
print(amari)
else:
pri... | [["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 109 |
x, k,d = map(int, input().split())
x = abs(x)
print(x)
ans = 0
if x//d>0:
ans = abs(x-d*k)
else:
tmp = x//d
k -= tmp
x -= tmp*d
if k%2 == 1:
ans = abs(x-d)
else:
ans = abs(x)
print(ans) | x, k,d = map(int, input().split())
x = abs(x)
ans = 0
if x//d>k:
ans = abs(x-d*k)
else:
tmp = x//d
k -= tmp
x -= tmp*d
if k%2 == 1:
ans = abs(x-d)
else:
ans = abs(x)
print(ans) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]] | 5 | 90 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void print(ll x, ll k, ll d) {
if (k & 1) {
cout << min(abs(x - d), abs(x + d));
} else
cout << abs(x);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll x, k, d;
cin >> x >> k >> d;
if (abs(x) <= d) {
... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
void print(ll x, ll k, ll d) {
if (k & 1) {
cout << min(abs(x - d), abs(x + d));
} else
cout << abs(x);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll x, k, d;
cin >> x >> k >> d;
if (abs(x) <= d) {
... | [["+", 0, 57, 64, 1, 0, 16, 12, 2, 63, 22], ["+", 64, 1, 0, 16, 12, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25]] | 1 | 238 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
if (x < 0)
x = -x;
if (x >= k * d) {
cout << x - k * d << endl;
} else {
ll t = x / d;
... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
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 - k * d << endl;
} else {
ll t = 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 | 125 |
X, K, D = gets.chomp.split(' ').map(&:to_i)
if X/D > K
ans = X - D * K
elsif (K - X/D) % 2 == 0
ans = X - X/D*D
else
ans = (X - X/D*D - D) * -1
end
puts ans | X, K, D = gets.chomp.split(' ').map(&:to_i)
X = X.abs
if X/D > K
ans = X - D * K
elsif (K - X/D) % 2 == 0
ans = X - X/D*D
else
ans = (X - X/D*D - D) * -1
end
puts ans | [["+", 36, 36, 36, 36, 0, 493, 0, 662, 31, 743], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 486, 743], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22]] | 4 | 76 |
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <vector>
long long int mod = 1000000007;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
using namespace std;
int main() {
// C
long long in... | #include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <vector>
long long int mod = 1000000007;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
using namespace std;
int main() {
// C
long long in... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 268 |
x,k,d=map(int,input().split())
if x>=0:
if x>=k*d:
x-=k*d
print(x)
else:
n=x//d
k-=n
if k%2==0:
print(x-n*d)
else:
print(abs(x-n*d-d))
else:
if abs(x)>=k*d:
x+=k*d
print(x)
else:
n=abs(x)//d
k-=n
if k%2==0:
print(abs(x+n*d))
else:
print(ab... | x,k,d=map(int,input().split())
if x>=0:
if x>=k*d:
x-=k*d
print(x)
else:
n=x//d
k-=n
if k%2==0:
print(x-n*d)
else:
print(abs(x-n*d-d))
else:
if abs(x)>=k*d:
x+=k*d
print(abs(x))
else:
n=abs(x)//d
k-=n
if k%2==0:
print(abs(x+n*d))
else:
pri... | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 652, 3, 4, 0, 657, 31, 657, 17, 33], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 17, 72]] | 5 | 146 |
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = int(n); i < i##_len; ++i)
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
int main() {
ll X, K, D;
cin >> X >> K ... | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = int(n); i < i##_len; ++i)
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
int main() {
ll X, K, D;
cin >> X >> K ... | [["+", 64, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]] | 1 | 135 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int X, K, D;
cin >> X;
cin >> K;
cin >> D;
if (X < 0) {
X = -X;
}
if (X / D < K) {
cout << X - K * D << endl;
} else if ((K - X / D) % 2 == 0) {
cout << X % D << endl;
} else {
cout << D - X % D << endl;
}
return... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int X, K, D;
cin >> X;
cin >> K;
cin >> D;
if (X < 0) {
X = -X;
}
if (X / D > K) {
cout << X - K * D << endl;
} else if ((K - X / D) % 2 == 0) {
cout << X % D << endl;
} else {
cout << D - X % D << endl;
}
return... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 107 |
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#defi... | #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#defi... | [["-", 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], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 288 |
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
long long X, K, D;
cin >> X >> K >... | #include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
long long X, K, D;
cin >> X >> K >... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 108], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]] | 1 | 140 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
template <typename T> void fin(T a) {
cout << a << endl;
exit(0);
}
signed main() {
int x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d > k)
fin(x - d * k);
if ((x / d + k) & 1)
fin((x - x % d) % d);
fin(x % d);
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
template <typename T> void fin(T a) {
cout << a << endl;
exit(0);
}
signed main() {
int x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d > k)
fin(x - d * k);
if ((x / d + k) & 1)
fin(d - x % d);
fin(x % d);
}
| [["-", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["-", 3, 4, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 64, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["-", 0, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["-", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25]] | 1 | 110 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x >= k * d) {
cout << x - k * d << endl;
return... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
cout << x - k * d << endl;
return... | [["+", 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 |
#include <bits/stdc++.h>
using namespace std;
#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int... | #include <bits/stdc++.h>
using namespace std;
#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int... | [["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22]] | 1 | 545 |
#include <bits/stdc++.h>
/*...
...
author
@
Aman Kothari
.....
.....*/
using namespace std;
#define ll long long
#define dl double
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
ll ans = x - (k * ... | #include <bits/stdc++.h>
/*...
...
author
@
Aman Kothari
.....
.....*/
using namespace std;
#define ll long long
#define dl double
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
ll ans = x - (k * ... | [["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 22]] | 1 | 159 |
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (decltype(n) i = 0; i < n; ++i)
inline constexpr ll Inf = (1ULL << 62) - 1;
template <class T> void updatemax(T &a, T b) {
... | #include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (decltype(n) i = 0; i < n; ++i)
inline constexpr ll Inf = (1ULL << 62) - 1;
template <class T> void updatemax(T &a, T b) {
... | [["+", 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 | 195 |
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a ... | #include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a ... | [["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 17, 48]] | 1 | 299 |
//
// main.cpp
// ervb
//
// Created by Kanak Gautam on 21/04/20.
// Copyright © 2020 Kanak Gautam. All rights reserved.
//
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#includ... | //
// main.cpp
// ervb
//
// Created by Kanak Gautam on 21/04/20.
// Copyright © 2020 Kanak Gautam. All rights reserved.
//
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#includ... | [["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]] | 1 | 550 |
x,k,d=map(int,input().split())
x=abs(x)
v=x//d
if v>=k:
print(x-k*d)
else:
f=x-d*v
s=x-d*(v+1)
f=abs(f)
s=abs(s)
if f<s:
if (k-v)%2==0:
print(f)
else:print(s)
else:
if (k-(v+1))%2==0:
print(s)
else:
print(v) | x,k,d=map(int,input().split())
x=abs(x)
v=x//d
if v>=k:
print(x-k*d)
else:
f=x-d*v
s=x-d*(v+1)
f=abs(f)
s=abs(s)
if f<s:
if (k-v)%2==0:
print(f)
else:print(s)
else:
if (k-(v+1))%2==0:
print(s)
else:
print(f) | [["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 127 |
X, K, D = map(int, input().split())
Xa = abs(X)
Xs = X // D
Xm = X % D
if (K <= Xs):
print(abs(Xa-D*K))
elif (K-Xs) % 2 == 0:
print(abs(Xm))
else:
print(abs(D-Xm))
| X, K, D = map(int, input().split())
Xa = abs(X)
Xs = Xa // D
Xm = Xa % D
if (K <= Xs):
print(abs(Xa-D*K))
elif (K-Xs) % 2 == 0:
print(abs(Xm))
else:
print(abs(D-Xm))
| [["-", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22]] | 5 | 81 |
import sys
import numpy as np
import math
import collections
import copy
from collections import deque
from functools import reduce
from itertools import product
from itertools import combinations
# input = sys.stdin.readline
Xa, K, D = map(int, input().split())
X = abs(Xa)
Xs = X // D
Xm = X % D
if K < Xs:
# pri... | import sys
import numpy as np
import math
import collections
import copy
from collections import deque
from functools import reduce
from itertools import product
from itertools import combinations
# input = sys.stdin.readline
Xa, K, D = map(int, input().split())
X = abs(Xa)
Xs = X // D
Xm = X % D
if K < Xs:
# pri... | [["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 157 |
# -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
X, K, D = list(map(int, input().split()))
return X, K, D
def main(X: int, K: int, D: int) -> None:
"""
メイン処理.
Args:\n
X (int): 座標(-10^{15} <= X <= 10^{15})
K (int... | # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
X, K, D = list(map(int, input().split()))
return X, K, D
def main(X: int, K: int, D: int) -> None:
"""
メイン処理.
Args:\n
X (int): 座標(-10^{15} <= X <= 10^{15})
K (int... | [["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 141 |
import static java.lang.Math.*;
import static java.lang.System.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(in);
long x, k, d;
x = abs(sc.nextLong());
k = sc.nextLong();
d = sc.nextLong();
long devide = x / d;
if (x ... | import static java.lang.Math.*;
import static java.lang.System.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(in);
long x, k, d;
x = abs(sc.nextLong());
k = sc.nextLong();
d = sc.nextLong();
long devide = x / d;
if (de... | [["-", 0, 57, 15, 15, 0, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 15, 0, 16, 31, 16, 17, 33], ["-", 15, 15, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 15, 0, 16, 31, 16, 12, 16, 17, 48], ["-", 15, 15, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ... | 3 | 161 |
x, k, d = list(map(int, input().split()))
x = abs(x)
p = 0
if x/d > k:
p = x-(k*d)
else:
p = x%d
if (k - x/d)%2 == 1:
p = p-d
print(abs(p)) | x, k, d = list(map(int, input().split()))
x = abs(x)
p = 0
if x/d >= k:
p = x-(k*d)
else:
p = x%d
if (k - int(x/d))%2 == 1:
p = p-d
print(abs(p))
| [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["+", 0, 657, 31, 23, 0, 657, 12, 652, 63, 22], ["+", 31, 23, 0, 657, 12, 652, 3, 4, 0, 24], ["+", 31, 23, 0, 657, 12, 652, 3, 4, 0, 25]] | 5 | 78 |
def ii():
return int(input())
def mi():
return map(int, input().split())
def li():
return list(mi())
l = li()
x, k, d = l[0], l[1], l[2]
calc = x // d
mi = min(k, calc)
k -= mi
x -= mi * d
if k % 2 == 0:
print(x)
else:
print(abs(x-d)) | def ii():
return int(input())
def mi():
return map(int, input().split())
def li():
return list(mi())
l = li()
x, k, d = l[0], l[1], l[2]
x = abs(x)
calc = x // d
mi = min(k, calc)
k -= mi
x -= mi * d
if k % 2 == 0:
print(x)
else:
print(abs(x-d)) | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 110 |
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define COUT(x) cout << #x << " = " << (x) << " (L" << __... | #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define COUT(x) cout << #x << " = " << (x) << " (L" << __... | [["-", 75, 76, 0, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 17, 151], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 12, 13]] | 1 | 543 |
#include <bits/stdc++.h>
using namespace std;
int main(void) {
long long X, K, D;
long long ans = 0;
cin >> X >> K >> D;
if (K * D < abs(X)) {
ans = abs(X) - K * D;
} else {
if ((abs(X) / D) % 2 == 0) {
if (K % 2 == 0) {
ans = abs(X) % D;
} else {
ans = abs(abs(X) % D - D... | #include <bits/stdc++.h>
using namespace std;
int main(void) {
long long X, K, D;
long long ans = 0;
cin >> X >> K >> D;
if (K < abs(X) / D) {
ans = abs(X) - K * D;
} else {
if ((abs(X) / D) % 2 == 0) {
if (K % 2 == 0) {
ans = abs(X) % D;
} else {
ans = 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 | 160 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector<ll> adj[100005];
#define ari \
for (int i = 0; i < n; i++) \
cin >> a[i];
#d... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector<ll> adj[100005];
#define ari \
for (int i = 0; i < n; i++) \
cin >> a[i];
#d... | [["+", 3, 4, 0, 16, 31, 16, 31, 2, 63, 22], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25]] | 1 | 236 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long cur = abs(x);
int rem = k;
long long cnt = min(cur / d, k);
cur -= d * cnt;
rem -= cnt;
if (rem > 0) {
if (rem % 2 == 1) {
cur =... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long cur = abs(x);
long long rem = k;
long long cnt = min(cur / d, k);
cur -= d * cnt;
rem -= cnt;
if (rem > 0) {
if (rem % 2 == 1) {
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 109 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
int ans;
if (x / d > k) {
ans = x - d * k;
} else {
int a = k - x / d;
if (a % 2)
ans = x - d * (x / d + 1);
else
ans = x - d * (x / d);
}
cout << abs(ans) << endl;
... | #include <bits/stdc++.h>
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 - d * k;
} else {
long long a = k - x / d;
if (a % 2)
ans = x - d * (x / d + 1);
else
ans = x - d * (x / d);
}
cout << abs(an... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["+", 75, 76, 0, 9, 0, 43, 39, 86, 0, 96]] | 1 | 110 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long a = x / d;
if (0 > a) {
a = 0 - a;
}
if (x < 0) {
x += min(a, k);
} else {
x -= min(a, k) * d;
}
k -= min(a, k);
if (x > 0) {
x -= (k % 2) * d;
} else {
x += (k % 2) * d;... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long a = x / d;
if (0 > a) {
a = 0 - a;
}
if (x < 0) {
x += min(a, k) * d;
} else {
x -= min(a, k) * d;
}
k -= min(a, k);
if (x > 0) {
x -= (k % 2) * d;
} else {
x += (k % 2) ... | [["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 145 |
x, k, d = map(int, input().split())
x = abs(x)
a = x / d
b = x % d
if a > k:
ans = x - (k * d)
else:
if (k - a) % 2 == 0:
ans = b
else:
ans = d - b
print(ans) | x, k, d = map(int, input().split())
x = abs(x)
a = x // d
b = x % d
if a > k:
ans = x - (k * d)
else:
if (k - a) % 2 == 0:
ans = b
else:
ans = d - b
print(ans) | [["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676]] | 5 | 75 |
import sys
sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)... | import sys
sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,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 | 186 |
// Create by JJL
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
... | // Create by JJL
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
... | [["+", 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 | 155 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「sからnまで」の降順の繰り返... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「sからnまで」の降順の繰り返... | [["-", 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 | 154 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「sからnまで」の降順の繰り返... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「sからnまで」の降順の繰り返... | [["-", 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 | 163 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (x < 0)
abs(x);
if (x / d >= k)
cout << x - k * d;
else if (x / d % 2 != k % 2)
cout << d - x % d;
else
cout << x % d;
return 0;
} | #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)
cout << x - k * d;
else if (x / d % 2 != k % 2)
cout << d - x % d;
else
cout << x % d;
return 0;
} | [["-", 8, 9, 0, 57, 64, 1, 0, 2, 63, 22], ["-", 0, 57, 64, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 57, 64, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 1, 0, 11, 12, 91, 17, 33], ["+", 0, 57, 64, 1, 0, 11, 12, 91, 28, 22]] | 1 | 86 |
#include <algorithm>
#include <iostream>
using namespace std;
long long longabs(long long x) {
if (x < 0)
x *= -1;
return x;
}
int main() {
long long pos;
long long n, d;
cin >> pos >> n >> d;
pos = longabs(pos);
if (pos >= n * d) {
cout << pos - n * d << endl;
return 0;
}
else {
... | #include <algorithm>
#include <iostream>
using namespace std;
long long longabs(long long x) {
if (x < 0)
x *= -1;
return x;
}
int main() {
long long pos;
long long n, d;
cin >> pos >> n >> d;
pos = longabs(pos);
if (pos / d >= n) {
cout << pos - n * d << endl;
return 0;
}
else {
... | [["+", 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 | 131 |
x,k,d=map(int, input().split())
x=abs(x)
a=x%d
b=(x-a)//d
if b <= k:
if (b ^ k) & 1:
print(-x%d)
else:
print(x%d)
else:
print(x-k*d)
| x,k,d=map(int, input().split())
x=abs(x)
a=x%d
b=(x-a)//d
if b <= k:
if (b ^ k) & 1:
print(abs(d-a))
else:
print(x%d)
else:
print(x-k*d)
| [["-", 0, 652, 3, 4, 0, 657, 31, 664, 17, 33], ["-", 0, 652, 3, 4, 0, 657, 31, 664, 28, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 652... | 5 | 77 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (x > 0) {
long long t = x / d;
if (t >= k) {
cout << x - k * d;
} else {
x = x - t * d;
k = k - t;
if (k % 2 == 0) {
cout << x;
} else
cout << d - x;
... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (x > 0) {
long long t = x / d;
if (t >= k) {
cout << x - k * d;
} else {
x = x - t * d;
k = k - t;
if (k % 2 == 0) {
cout << x;
} else
cout << d - x;
... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]] | 1 | 173 |
def C():
X, K, D = map(int, input().split())
if X//D >= K:
return X - K*D
pos1 = abs(X - (X//D)*D)
pos2 = abs(X - (X//D+1)*D)
if pos1 > pos2:
K -= X//D+1
else:
K -= X//D
if K % 2 == 0:
return min(pos1, pos2)
else:
return abs(min(pos1, pos2) ... | def C():
X, K, D = map(int, input().split())
X = abs(X)
if X//D >= K:
return X - K*D
pos1 = abs(X - (X//D)*D)
pos2 = abs(X - (X//D+1)*D)
if pos1 > pos2:
K -= X//D+1
else:
K -= X//D
if K % 2 == 0:
return min(pos1, pos2)
else:
return abs(m... | [["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 119 |
x, k, d = gets.split(" ").map(&:to_i)
x = x.abs
m = x % d
s = x / d
if s > k
ans = x - k*d
puts ans
exit
end
if k.even?
puts m
else
m_1 = m - d
m_2 = m_1.abs
puts m_2
end
| x, k, d = gets.split(" ").map(&:to_i)
x = x.abs
m = x % d
s = x / d
if s > k
ans = x - k*d
puts ans
exit
end
t = k-s
if t.even?
puts m
else
m_1 = m - d
m_2 = m_1.abs
puts m_2
end
| [["-", 36, 36, 36, 36, 0, 493, 0, 121, 0, 121], ["+", 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, 738, 17, 33], ["+", 36, 36, 0, 493, 0, 662, 12, 738, 12, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 121, 0, 121], ["+", 36, 36, 0, 493, 0, 121, 15, 65... | 4 | 70 |
x,k,d = map(int,input().split())
x = abs(x)
num = x//d
if k >= num:
x -= num*d
cnt = k-num
else:
x -= k*d
print(x)
exit()
if abs(x) > abs(x-d):
x -= d
cnt -= 1
if cnt%2 == 0:
print(abs(x))
else:
print(abs(x-d)) | x,k,d = map(int,input().split())
x = abs(x)
num = x//d
if k >= num:
x -= num*d
cnt = k-num
else:
x -= k*d
print(x)
exit()
if abs(x) > abs(x-d):
x -= d
cnt -= 1
if cnt%2 == 0:
print(abs(x))
else:
print(abs(abs(x)-abs(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, 652, 63, 22], ["+", 3, 4, 0, 657, 12, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 12, 652, 3, 4, 0, 25]] | 5 | 102 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
void solve() {
ll X, K, D, res = 0;
cin >> X >> K >> D;
X = abs(X);
if (X / D >= K)
res = X - D * K;
else {
ll temp = X / D;
K = K - temp;
X = X - temp * K;
if (K % 2)
X = abs(X - D);
res... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
void solve() {
ll X, K, D, res = 0;
cin >> X >> K >> D;
X = abs(X);
if (X / D >= K)
res = X - D * K;
else {
ll temp = X / D;
K = K - temp;
X = X - temp * D;
if (K % 2)
X = abs(X - D);
res... | [["-", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22]] | 1 | 136 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
long solve(long x, long k, long d) {
if (x < 0)
d = -d;
auto a = std::abs(x / d);
if (x % d)
++a;
if (a > k)
return x - d * k;
const auto b = x - d * a;
return std::abs((k - a) % 2... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
long solve(long x, long k, long d) {
if (x < 0)
d = -d;
auto a = std::abs(x / d);
if (x % d)
++a;
if (a > k)
return std::abs(x - d * k);
const auto b = x - d * a;
return std::abs((... | [["+", 0, 57, 64, 37, 0, 2, 63, 343, 345, 348], ["+", 0, 57, 64, 37, 0, 2, 63, 343, 0, 349], ["+", 0, 57, 64, 37, 0, 2, 63, 343, 141, 22], ["+", 0, 57, 64, 37, 0, 2, 3, 4, 0, 24], ["+", 0, 57, 64, 37, 0, 2, 3, 4, 0, 25]] | 1 | 152 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
ll ans;
if (x / d > k)
ans = x - d * k;
else {
ll e = x / d;
k -= e;
x -= e * d;
if (k % 2 == 1)
x = abs(x ... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
ll ans;
if (x / d > k)
ans = x - d * k;
else {
ll e = x / d;
k -= e;
x -= e * d;
if (k % 2 == 1)
x = abs(x ... | [["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33]] | 1 | 112 |
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size()
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n) for (int i = n; i >= 0; i--)
#define REP(i... | #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size()
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n) for (int i = n; i >= 0; i--)
#define REP(i... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17,... | 1 | 255 |
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
int main(int argc, char *argv[]) {
long long X, K, D;
cin >> X >> K >> D;
X = abs(X);
long long ans = 0;
if (X >= K * D) {
ans = X - (K * D);
} else {
long long temae_made = (X / D);
... | #include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
int main(int argc, char *argv[]) {
long long X, K, D;
cin >> X >> K >> D;
X = abs(X);
long long ans = 0;
if (X / D >= K) {
ans = X - (K * D);
} else {
long long temae_made = (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 | 133 |
from math import *
x, k, d = map(int, input().split())
z = ceil(x/d)
if x-k*d >= 0:
print(x-k*d)
else:
if (k-z)%2 == 0:
print(abs(x-z*d))
else:
print(x-z*d+d) | from math import *
x, k, d = map(int, input().split())
x = abs(x)
z = ceil(x/d)
if x-k*d >= 0:
print(x-k*d)
else:
if (k-z)%2 == 0:
print(abs(x-z*d))
else:
print(x-z*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 | 83 |
x,k,d = map(int,input().split())
q,mod = divmod(x,d)
if k <= q:
ans = x - k*d
else:
ans = mod
ans -= (k-q)%2*d
print(abs(ans)) | x,k,d = map(int,input().split())
x = abs(x)
q,mod = divmod(x,d)
if k <= q:
ans = x - k*d
else:
ans = mod
ans -= (k-q)%2*d
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 | 63 |
#include <bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL << ((ll)n))
#define SUBS(s, f, t) ((s).substr((f), (t) - (f)))
#define ALL... | #include <bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL << ((ll)n))
#define SUBS(s, f, t) ((s).substr((f), (t) - (f)))
#define ALL... | [["-", 0, 16, 31, 16, 12, 16, 12, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 16, 12, 16, 31, 22]] | 1 | 184 |
x, k, d = map(int, input().split())
x = abs(x)
s = x//d
if s>k:
print(x-d*k)
elif s<k:
if (k-s)%2==0:
print(x-d*s)
elif (k-s)%2==1:
print(abs(x-d*(s+1))) | x, k, d = map(int, input().split())
x = abs(x)
s = x//d
if s>k:
print(x-d*k)
elif s<=k:
if (k-s)%2==0:
print(x-d*s)
elif (k-s)%2==1:
print(abs(x-d*(s+1))) | [["-", 0, 656, 0, 57, 75, 665, 15, 666, 667, 18], ["+", 0, 656, 0, 57, 75, 665, 15, 666, 667, 19]] | 5 | 92 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 {
k -= x / d;
if (k % 2 == 0) {
cout << x - d * (x / d) << endl;
} else {
cout << abs(x -... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
cout << x - k * d << endl;
return 0;
} else {
k -= x / d;
if (k % 2 == 0) {
cout << x - d * (x / d) << endl;
} else {
cout << abs(x -... | [["+", 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 | 120 |
x, k, d = map(int, input().split())
q = x // d
r = x % d
if k <= q:
print(x - k * d)
else:
if (k-q) % 2 == 0:
print(r)
else:
print(abs(x - d * (q + 1))) | x, k, d = map(int, input().split())
x = abs(x)
q = x // d
r = x % d
if k <= q:
print(x - k * d)
else:
if (k-q) % 2 == 0:
print(r)
else:
print(abs(x - d * (q + 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 | 75 |
#include <bits/stdc++.h>
#define fint register int
#define h 5001
#define p 4859345
#define int long long
using namespace std;
signed main() {
int x, k, d;
cin >> x >> k >> d;
int steps = abs(x) / d;
int now = x;
now -= (steps * d);
if (steps == k)
cout << now;
else if (steps > k) {
cout << abs(x)... | #include <bits/stdc++.h>
#define fint register int
#define h 5001
#define p 4859345
#define int long long
using namespace std;
signed main() {
int x, k, d;
cin >> x >> k >> d;
int steps = abs(x) / d;
int now = abs(x);
now -= (steps * d);
if (steps == k)
cout << now;
else if (steps > k) {
cout << a... | [["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25], ["-", 0, 16, 12, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 16, 12, 2, 3, 4, 0, 25]] | 1 | 124 |
#define CPP17
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstddef>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>... | #define CPP17
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstddef>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>... | [["-", 0, 57, 64, 37, 0, 16, 12, 16, 12, 22], ["+", 0, 57, 64, 37, 0, 16, 12, 16, 12, 22]] | 1 | 803 |
inp=list(map(int,input().split()))
x=inp[0]
k=inp[1]
d=inp[2]
if x<0:
flag=1
else:
flag=0
if x==0:
if k%2==0:
print (0)
else:
print (d)
else:
x=abs(x)
a=x%d
z=(x-a)//d
if z>=k:
if flag==1:
final=x+k*d
else:
final=x-k*d
print... | inp=list(map(int,input().split()))
x=inp[0]
k=inp[1]
d=inp[2]
if x<0:
flag=1
else:
flag=0
if x==0:
if k%2==0:
print (0)
else:
print (d)
else:
ini=x
x=abs(x)
a=x%d
z=(x-a)//d
if z>=k:
if flag==1:
final=ini+k*d
else:
final=ini-k*d... | [["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22]] | 5 | 187 |
n , k ,d = map(int,input().split())
if(n> k*d):
print(n - k*d)
else:
rem = n%d
if((k - (n//d))%2==0):
print(rem)
else:
print(abs(rem - d)) | n , k ,d = map(int,input().split())
n = abs(n)
if(n> k*d):
print(n - k*d)
else:
rem = n%d
if((k - (n//d))%2==0):
print(rem)
else:
print(abs(rem - 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 | 74 |
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define r... | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define r... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 187 |
X, K, D = map(int, input().split())
X = abs(X)
time = X//D
rest = K - time
if rest <= 0:
print(X-K*D)
elif rest%2 == 0:
print(min(X-time*D, abs(X-(time+2)*D)))
else:
print(min(X-time*D, abs(X-(time+1)*D))) | X, K, D = map(int, input().split())
X = abs(X)
time = X//D
rest = K - time
if rest <= 0:
print(X-K*D)
elif rest%2 == 0:
print(min(X-time*D, abs(X-(time+2)*D)))
else:
print(min(X-(time-1)*D, abs(X-(time+1)*D))) | [["+", 3, 4, 0, 657, 12, 657, 31, 23, 0, 24], ["+", 0, 657, 12, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 657, 12, 657, 31, 23, 0, 657, 12, 612], ["+", 3, 4, 0, 657, 12, 657, 31, 23, 0, 25]] | 5 | 104 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define MOD 10000000... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define MOD 10000000... | [["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 1, 0, 11, 12, 91, 17, 33], ["+", 0, 57, 64, 1, 0, 11, 12, 91, 28, 22]] | 1 | 158 |
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-16 22:37
# @url:https://atcoder.jp/contests/abc175/tasks/abc175_c
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio
BUFSIZE = 8192
BUFSIZE = 8192
class ... | # @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-16 22:37
# @url:https://atcoder.jp/contests/abc175/tasks/abc175_c
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio
BUFSIZE = 8192
BUFSIZE = 8192
class ... | [["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 589 |
#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) {
cout << x - d * k << endl;
} else {
k -= x / d;
x %= d;
if (k % 2 == 0) {
cout << x << endl;
} else {
cout << d - x << 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) {
cout << x - d * k << endl;
} else {
k -= x / d;
x %= d;
if (k % 2 == 0) {
cout << x << endl;
} else {
cout << d - x << endl;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 101 |
x, k ,d = map(int, input().split())
x = abs(x)
y = k * d
ans = x
if(x > y):
ans = min(x , x - y)
else:
mar = x % d
if (x // d) % 2 == k % 2:
ans = min(ans , mar)
else:
ans = min(ans , abs(d - mar))
print(ans)
| x, k ,d = map(int, input().split())
x = abs(x)
y = k * d
ans = x + d
if(x > y):
ans = min(ans , x - y)
else:
mar = x % d
if (x // d) % 2 == (k % 2):
ans = min(ans , mar)
else:
ans = min(ans , abs(d - mar))
print(ans)
| [["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 23, 0, 24], ["+", 8, 196, 0, 57, 15, 666, 0, 23, 0, 25]] | 5 | 96 |
//
// Created by 27420 on 2020/8/16.
//
#include <iostream>
#include <stdio.h>
typedef long long ll;
using namespace std;
void solve(ll x, ll k, ll d) {
if (x < 0)
x = abs(x); // x可以取负数
else {
if ((x / d) > k) {
printf("%lld", x - k * d);
} else if ((k - x / d) % 2 == 1) {
printf("%lld", ab... | //
// Created by 27420 on 2020/8/16.
//
#include <iostream>
#include <stdio.h>
typedef long long ll;
using namespace std;
void solve(ll x, ll k, ll d) {
if (x < 0)
x = abs(x); // x可以取负数
if ((x / d) > k) {
printf("%lld", x - k * d);
} else {
if ((k - x / d) % 2 == 1) {
printf("%lld", abs(x % d -... | [["-", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45]] | 1 | 157 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
scanf("%lld %lld %lld", &x, &k, &d);
x = abs(x);
if (x / d > k) {
printf("%lld\n", x % d + d * (x / d - k));
} else {
printf("%lld\n", k % 2 == 0 ? x % d : abs(x % d - d));
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
scanf("%lld %lld %lld", &x, &k, &d);
x = abs(x);
if (x / d > k) {
printf("%lld\n", x % d + d * (x / d - k));
} else {
printf("%lld\n", (k - x / d) % 2 == 0 ? x % d : abs(x % d - d));
}
return 0;
}
| [["+", 0, 41, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 23, 0, 16, 12, 16, 31, 22], ["+", 31, 16, 31, 23, 0, 16, 12, 16, 17, 85], ["+", 31, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["+", 0, 41, 15, 16, 31, 16, 31, 23, 0, 25]] | 1 | 108 |
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++) // rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
int ans;
x = abs(x); //原点からーや+であっても同じ
//往復せずに終わる場合
if (x / d > k) {
ans = x - d * k;
... | #include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++) // rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll ans;
x = abs(x); //原点からーや+であっても同じ
//往復せずに終わる場合
if (x / d > k) {
ans = x - d * k;
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 150 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d <= k)
cout << x - d * k << endl;
else {
long r1 = x % d;
if ((k - (x - r1) / d) % 2 == 0) {
cout << r1 << endl;
} else {
cout << (d - r1) << end... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
cout << x - d * k << endl;
} else {
long r1 = x % d;
if ((k - (x - r1) / d) % 2 == 0) {
cout << r1 << endl;
} else {
cout << (d - r1) <<... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]] | 1 | 108 |
line = input()
strL = line.split()
X = abs(int(strL[0]))
K = int(strL[1])
D = int(strL[2])
mod = X % D
div = int(X / D)
if div > K:
ans = X - K * D
elif (K - div) % 2 != 0:
ans = mod - D
else:
ans = mod
print(int(ans)) | line = input()
strL = line.split()
X = abs(int(strL[0]))
K = int(strL[1])
D = int(strL[2])
mod = X % D
div = int(X / D)
if div > K:
ans = X - K * D
elif (K - div) % 2 != 0:
ans = mod - D
else:
ans = mod
print(abs(int(ans))) | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 95 |
x, k, d = map(int,input().split())
a = abs(x % d)
a_sho = abs(x // d)
b = abs(a-d)
if k <= a_sho:
ans = abs(x - (k*d))
else:
#if a < b:
if (k - a_sho) %2 == 0:
ans = a
else:
ans = b
print(ans)
| x, k, d = map(int,input().split())
a = abs(x % d)
a_sho = abs(x // d)
b = abs(a-d)
if k <= a_sho:
ans = abs(x) - (k*d)
else:
#if a < b:
if (k - a_sho) %2 == 0:
ans = a
else:
ans = b
print(ans)
| [["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25], ["-", 12, 652, 3, 4, 0, 657, 12, 23, 0, 25]] | 5 | 85 |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func main() {
scanInit()
x := nextInt()
x = abs(x)
k := nextInt()
d := nextInt()
// 臨界に届かない場合
if k*d < x {
fmt.Println(x - k*d)
return
}
k2 := x / d
if (k-k2)%2 == 0 {
fmt.Println(x % d)
return
}
fmt.Pr... | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func main() {
scanInit()
x := nextInt()
x = abs(x)
k := nextInt()
d := nextInt()
// 臨界に届かない場合
if k < x/d {
fmt.Println(x - k*d)
return
}
k2 := x / d
if (k-k2)%2 == 0 {
fmt.Println(x % d)
return
}
fmt.Pr... | [["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 85], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]] | 7 | 272 |
X,K,D=map(int,input().split(' '))
if X>=0:
time=X//D
if time>K:
print(X-K*D)
elif (K-time)%2==0:
print(X%D)
else:
print(abs((X%D)-D))
else:
time=-X//D
if time>K:
print(abs(X+K*D))
elif (K-time)%2==0:
print(X%D)
else:
print(abs((X%D)-D)) | X,K,D=map(int,input().split(' '))
if X>=0:
time=X//D
if time>K:
print(X-K*D)
elif (K-time)%2==0:
print(X%D)
else:
print(abs((X%D)-D))
else:
time=-(X//D)
if time>K:
print(abs(X+K*D))
elif (K-time)%2==0:
print(X%D)
else:
print(abs((X%D)-D)) | [["+", 0, 1, 0, 662, 12, 664, 28, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 664, 28, 23, 0, 25]] | 5 | 132 |
x,k,d = list(map(int, input().split(' ')))
if k*d<=x:
print(x-k*d)
elif -k*d>=x:
print(x+k*d)
else:
rem = x%(d)
div = x//d
if (k-div)%2==0:
print(rem)
else:
print(d-rem) | x,k,d = list(map(int, input().split(' ')))
if k*d<=x:
print(abs(x-k*d))
elif -k*d>=x:
print(abs(x+k*d))
else:
rem = x%(d)
div = x//d
if (k-div)%2==0:
print(rem)
else:
print(d-rem) | [["+", 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 | 92 |
import sys
X,K,D = map(int,input().split())
if (abs(X)>abs(K*D)):
print(abs(X)-abs(K*D))
sys.exit()
alpha = X%D
count = X//D
if(alpha>abs(alpha-D)):
count +=1
alpha = abs(alpha-D)
beta = count%2
if beta==1:
print(abs(alpha-D))
else:
print(alpha) | import sys
X,K,D = map(int,input().split())
if (abs(X)>abs(K*D)):
print(abs(X)-abs(K*D))
sys.exit()
alpha = X%D
count = K-(X//D)
if(alpha>abs(alpha-D)):
count +=1
alpha = abs(alpha-D)
beta = count%2
if beta==1:
print(abs(alpha-D))
else:
print(alpha) | [["+", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25]] | 5 | 112 |
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef LOCAL
freopen("in", "r", stdin);
#endif // LOCAL
ios::sync_with_stdio(0);
cin.tie(0);
int64_t x, k, d;
cin >> x >> k >> d;
int64_t step = abs(x) / d;
if (step > k)
cout << abs(x) - k * d;
else {
if (step % 2 == 0)
cout << ... | #include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef LOCAL
freopen("in", "r", stdin);
#endif // LOCAL
ios::sync_with_stdio(0);
cin.tie(0);
int64_t x, k, d;
cin >> x >> k >> d;
int64_t step = abs(x) / d;
if (step > k)
cout << abs(x) - k * d;
else {
if ((k - step) % 2 == 0)
co... | [["+", 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 | 136 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int factorial(int n);
int factorial(int n) {
if (n == 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}
bool is_prime(ll n) {
// Assumes that n is a positive natural number
// We know 1 is not a prime number
if (n == 1) {
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int factorial(int n);
int factorial(int n) {
if (n == 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}
bool is_prime(ll n) {
// Assumes that n is a positive natural number
// We know 1 is not a prime number
if (n == 1) {
... | [["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]] | 1 | 578 |
<?php
# スペース区切りの整数の入力
fscanf(STDIN, "%s %s %s", $x, $k, $d);
$x = intval($x);
$k = intval($k);
$d = intval($d);
$maxCount = floor($x / $d);
if ($x > 0) {
if ($maxCount >= $k) {
$newX = $x - $k * $d;
} else {
$newX = $x - $maxCount * $d;
$newK = $k - $maxCount;
if ($newK % 2 != 0) {
if (abs($newX - $d) < ... | <?php
# スペース区切りの整数の入力
fscanf(STDIN, "%s %s %s", $x, $k, $d);
$x = intval($x);
$k = intval($k);
$d = intval($d);
$maxCount = intval(floor($x / $d));
if ($x > 0) {
if ($maxCount >= $k) {
$newX = $x - $k * $d;
} else {
$newX = $x - $maxCount * $d;
$newK = $k - $maxCount;
if ($newK % 2 != 0) {
if (abs($newX ... | [["+", 0, 493, 0, 1, 0, 11, 12, 613, 63, 141], ["+", 0, 1, 0, 11, 12, 613, 3, 3, 0, 24], ["+", 3, 3, 0, 28, 0, 613, 3, 3, 0, 25], ["+", 0, 11, 12, 16, 12, 16, 31, 613, 63, 141], ["+", 12, 16, 12, 16, 31, 613, 3, 3, 0, 24], ["+", 12, 16, 12, 16, 31, 613, 3, 3, 0, 25]] | 6 | 284 |
x, k, d = map(int, input().split())
wantk = x // d
if wantk > k:
print(abs(x - k * d))
exit()
x -= wantk * d
k -= wantk
if k % 2 == 0:
print(abs(x))
else:
print(abs(x - d))
| x, k, d = map(int, input().split())
x = abs(x)
wantk = x // d
if wantk > k:
print(abs(x - k * d))
exit()
x -= wantk * d
k -= wantk
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 | 75 |
#include <iostream>
using namespace std;
int main(void) {
long X, K, D;
cin >> X >> K >> D;
long now_place = X;
long times = now_place / D + 1;
if (times < 0) {
times *= -1;
}
if (times > K) {
times = K;
}
if (now_place > 0) {
now_place -= D * times;
K -= times;
} else {
now... | #include <iostream>
using namespace std;
int main(void) {
long X, K, D;
cin >> X >> K >> D;
long now_place = X;
long times = now_place / D;
if (times < 0) {
times *= -1;
}
if (times > K) {
times = K;
}
if (now_place > 0) {
now_place -= D * times;
K -= times;
} else {
now_pla... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]] | 1 | 204 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long X;
long long K;
long long D;
cin >> X >> K >> D;
long long ans = 0;
if (abs(abs(X) / D) >= K) {
if (X > 0) {
ans = X - K * D;
cout << abs(ans) << endl;
return 0;
}
if (X < 0) {
ans = X + K * D;
c... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long X;
long long K;
long long D;
cin >> X >> K >> D;
long long ans = 0;
if (abs(abs(X) / D) >= K) {
if (X > 0) {
ans = X - K * D;
cout << abs(ans) << endl;
return 0;
}
if (X < 0) {
ans = X + K * D;
c... | [["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 31, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 57, 75, 76, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 12, 22]] | 1 | 222 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.