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 |
|---|---|---|---|---|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long x = scan.nextLong();
long k = scan.nextLong();
long d = scan.nextLong();
long num = Math.abs(x) / d;
if (k <= num) {
if (x > 0)
x -= k * d;
else
... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
long x = scan.nextLong();
long k = scan.nextLong();
long d = scan.nextLong();
long num = Math.abs(x) / d;
if (k <= num) {
if (x > 0)
x -= k * d;
else
... | [["+", 0, 1, 0, 492, 3, 4, 0, 492, 500, 22], ["+", 0, 1, 0, 492, 3, 4, 0, 492, 0, 131], ["+", 0, 1, 0, 492, 3, 4, 0, 492, 141, 22], ["+", 0, 492, 3, 4, 0, 492, 3, 4, 0, 24], ["+", 0, 492, 3, 4, 0, 492, 3, 4, 0, 25]] | 3 | 175 |
#!/usr/bin/env python3
import sys
def solve(X: int, K: int, D: int):
X=abs(X)
mostl = X - K * D
if mostl > 0:
print(mostl)
exit()
if K%2 == 1:
X -= D
ans = min(ans, abs(X), abs(X+2*D))
else:
ans = min(X, abs(X - K * D))
Kh = K // 2
N = X // (D*2)... | #!/usr/bin/env python3
import sys
def solve(X: int, K: int, D: int):
X=abs(X)
mostl = X - K * D
if mostl > 0:
print(mostl)
exit()
if K%2 == 1:
X -= D
ans = min(abs(X), abs(X+2*D))
else:
ans = min(X, abs(X - K * D))
Kh = K // 2
N = X // (D*2)
... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21]] | 5 | 256 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, d, k;
cin >> x >> k >> d;
x = abs(x);
if (x <= d) {
if (k % 2 == 0) {
cout << x << endl;
return 0;
} else {
cout << d - x << endl;
return 0;
}
}
if (x > d * k && k > 10000000000) {
cout << x - d ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t x, d, k;
cin >> x >> k >> d;
x = abs(x);
if (x <= d) {
if (k % 2 == 0) {
cout << x << endl;
return 0;
} else {
cout << d - x << endl;
return 0;
}
}
if (x > d * k && k > 100000000000000 && d < 100) {
... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 185 |
import math
x, k, d = map(int, input().split())
ans = []
a = math.floor(abs(x) / d)
if a > k:
a = k
if x > 0:
ans = (abs(x - d * k))
else:
ans = (abs(x - d * k))
else:
if x > 0:
tmp = (abs(x - d * a))
if (k - a) % 2 == 1:
ans = (abs(x - d * (a + 1)))
else:
ans = tmp
else:
t... | import math
x, k, d = map(int, input().split())
ans = []
a = math.floor(abs(x) / d)
if a > k:
a = k
if x > 0:
ans = (abs(x - d * k))
else:
ans = (abs(x + d * k))
else:
if x > 0:
tmp = (abs(x - d * a))
if (k - a) % 2 == 1:
ans = (abs(x - d * (a + 1)))
else:
ans = tmp
else:
t... | [["-", 12, 23, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 12, 23, 0, 652, 3, 4, 0, 657, 17, 72]] | 5 | 177 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpi = vector<pii>;
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using pll = pair<long, long>;
using vpi = vector<pii>;
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v... | [["+", 64, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25]] | 1 | 345 |
x,k,d=gets.split.map(&:to_i)
ans1=x%d
ans2=ans1-d
ans=0
if ans1<=x-k*d
ans=x-k*d
elsif x%d==0
kai=(x)/d
if k%2==0
if kai%2==0
ans=ans1
else
ans=ans2
end
else
if kai%2==0
ans=ans2
else
ans=ans1
end
end
elsif k%2==0
kai=(x+ans2.abs)/d
if kai%2==0
ans=ans2
... | x,k,d=gets.split.map(&:to_i)
x=x.abs
ans1=x%d
ans2=ans1-d
ans=0
if ans1<=x-k*d
ans=x-k*d
elsif x%d==0
kai=(x)/d
if k%2==0
if kai%2==0
ans=ans1
else
ans=ans2
end
else
if kai%2==0
ans=ans2
else
ans=ans1
end
end
elsif k%2==0
kai=(x+ans2.abs)/d
if kai%2==0
a... | [["+", 36, 36, 36, 36, 0, 493, 0, 662, 31, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 486, 22], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22]] | 4 | 154 |
import math
def func():
# a=int(input())
i1=list(map(int,input().split()))
#print(a)
#for i in range(a):
# print(b[i])
a=i1[0]
b=i1[1]
c=i1[2]
# print(a,b,c)
l=math.floor(a/c)
m=b-l
n=a-c*l
if l>=b: z=a-c*b
else:
z=a-(c*l)
if m%2==1:
z... | import math
def func():
# a=int(input())
i1=list(map(int,input().split()))
#print(a)
#for i in range(a):
# print(b[i])
a=abs(i1[0])
b=i1[1]
c=i1[2]
# print(a,b,c)
l=math.floor(a/c)
m=b-l
n=a-c*l
if l>=b: z=a-c*b
else:
z=a-(c*l)
if m%2==1:
... | [["+", 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, 25]] | 5 | 114 |
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;... | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;... | [["+", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 25]] | 1 | 181 |
x, k, d = map(int, input().split(' '))
if x - k * d >= 0:
print(x - k * d)
elif (k - x//d) % 2 == 0:
print( x%d )
else:
print(abs(x%d - d)) | x, k, d = map(int, input().split(' '))
x = abs(x)
if x - k * d >= 0:
print(x - k * d)
elif (k - x//d) % 2 == 0:
print( x%d )
else:
print(abs(x%d - d)) | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 70 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll t = -x / d, f = k % 2, ans = 1e18;
ll mi, ma;
mi = -k, ma = k;
if (abs(t) <= k) {
if (mi > ma)
swap(mi, ma);
ll l = max(mi, t - 10), r = min(ma, t + 10);
for (ll i = l; i ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll t = -x / d, f = k % 2, ans = 1e18;
ll mi, ma;
mi = -k, ma = k;
if (abs(t) <= k) {
if (mi > ma)
swap(mi, ma);
ll l = max(mi, t - 10), r = min(ma, t + 10);
for (ll i = l; i ... | [["+", 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, 25]] | 1 | 187 |
x, k, d = [int(i) for i in input().split()]
x = abs(x)
if k * d <= x:
print(x - k*d)
else:
t = x
x %= d
k = (t - x)//d
if k & 1:
print(abs(d - x))
else:
print(x) | x, k, d = [int(i) for i in input().split()]
x = abs(x)
if k * d <= x:
print(x - k*d)
else:
t = x
x %= d
k = k - (t - x)//d
if k & 1:
print(abs(d - x))
else:
print(x) | [["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33]] | 5 | 80 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll X, K, D, N;
cin >> X >> K >> D;
if (X > 0) {
N = X / D;
if (N > K) {
X = X - K * D;
} else {
X = X - N * D;
N = (K - N) % 2;
if (N != 0) {
X = X - D;
}
}
} else {
N = (-1... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll X, K, D, N;
cin >> X >> K >> D;
if (X > 0) {
N = X / D;
if (N > K) {
X = X - K * D;
} else {
X = X - N * D;
N = (K - N) % 2;
if (N != 0) {
X = X - D;
}
}
} else {
N = (-1... | [["+", 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 | 167 |
X,K,D=map(int,input().split())
def valid(value1, value2, diff):
if diff%2==0:
return value1
else:
return value2
if abs(X)>K:
tmp = abs(X)//D
if D>K:
tmp=K
if X < 0:
X += tmp*D
else:
X -= tmp*D
K -= tmp
min_score = abs(X)
for i in range(K):
if ab... | X,K,D=map(int,input().split())
def valid(value1, value2, diff):
if diff%2==0:
return value1
else:
return value2
if abs(X)>K:
tmp = abs(X)//D
if tmp>K:
tmp=K
if X < 0:
X += tmp*D
else:
X -= tmp*D
K -= tmp
min_score = abs(X)
for i in range(K):
if ... | [["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22]] | 5 | 182 |
n, k, d = map(int, input().split())
if k > n // d:
d1 = n % d
d2 = n % d - d
if k % 2 == (n // d) % 2:
print(abs(d1))
else:
print(abs(d2))
else:
print(abs(n) - k * d)
| n, k, d = map(int, input().split())
if k >= abs(n // d):
d1 = n % d
d2 = n % d - d
if k % 2 == (n // d) % 2:
print(abs(d1))
else:
print(abs(d2))
else:
print(abs(n) - k * d) | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["+", 0, 656, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25]] | 5 | 79 |
def solve():
arr=[int(i)for i in input().split()]
n=arr[0];k=arr[1];d=arr[2]
diff=n//d
if(diff>k):
print(n-(d*k))
return
else:
if((k-diff)%2==0):
print(n-(diff*d))
else:
print(abs((n-(diff*d))-d))
#test=int(input())
test=1
while test:
solve()
test-=1
... |
def solve():
arr=[int(i)for i in input().split()]
n=abs(arr[0]);k=arr[1];d=arr[2]
diff=n//d
if(diff>k):
print(n-(d*k))
return
else:
if((k-diff)%2==0):
print(n-(diff*d))
else:
print(abs((n-(diff*d))-d))
#test=int(input())
test=1
while test:
solve()
test-=1
... | [["+", 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, 25]] | 5 | 123 |
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define bit(x, i) (x & (1 << i)) // select the bit of position i of x
#define lowbit(x) ((x) & ((x) ^ ((x)-1))) // get the lowest bit of x
#define hBit(msb, n) \
asm("bsrl %1,%0" ... | #include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define bit(x, i) (x & (1 << i)) // select the bit of position i of x
#define lowbit(x) ((x) & ((x) ^ ((x)-1))) // get the lowest bit of x
#define hBit(msb, n) \
asm("bsrl %1,%0" ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 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, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 589 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t X, K, D;
cin >> X >> K >> D;
int64_t chk = (X / D);
int64_t ans;
if (abs(chk) >= K) {
if (X >= 0) {
ans = X - D * K;
}
if (X < 0) {
ans = X + D * K;
}
cout << abs(ans) << endl;
return 0;
}
if ((K - chk)... | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t X, K, D;
cin >> X >> K >> D;
int64_t chk = abs(X / D);
int64_t ans;
if (abs(chk) >= K) {
if (X > 0) {
ans = X - D * K;
}
if (X < 0) {
ans = X + D * K;
}
cout << abs(ans) << endl;
return 0;
}
if ((K - ch... | [["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 210 |
#include <bits/stdc++.h>
using namespace std;
using V_2 = vector<vector<int>>;
using ll = long long;
ll x, k, d, ans;
int main() {
cin >> x >> k >> d;
if (x < 0)
x = -1 * x;
ll syou = x / d;
ll sa = k - syou;
if (syou < k && sa % 2 == 0)
ans = x - syou * d;
else if (syou < k && sa % 2 != 0)
an... | #include <bits/stdc++.h>
using namespace std;
using V_2 = vector<vector<int>>;
using ll = long long;
ll k, x, d, ans;
int main() {
cin >> x >> k >> d;
if (x < 0)
x = -1 * x;
ll syou = x / d;
ll sa = k - syou;
if (syou <= k && sa % 2 == 0)
ans = x - syou * d;
else if (syou <= k && sa % 2 != 0)
... | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19]] | 1 | 140 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
int main(void) {
ll x, k, d;
ll kaisu;
cin >> x >> k >> d;
if (abs(x) >= abs(k * d)) {
cout << abs(x) - abs(k * d) << endl;
} else {
kaisu = x / d;
if ((k - kaisu) % 2 =... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
int main(void) {
ll x, k, d;
ll kaisu;
cin >> x >> k >> d;
if (abs(x) >= abs(k * d)) {
cout << abs(x) - abs(k * d) << endl;
} else {
kaisu = abs(x) / d;
if ((k - kaisu) ... | [["+", 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 | 157 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll t = abs(x) % d;
ll c = x / ... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll t = abs(x) % d;
ll c = abs(... | [["+", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22]] | 1 | 171 |
X,K,D = map(int,input().split())
#十分に原点から離れている場合
if abs(X) >= K*D:
ans = abs(X) - K*D
else:
t = (abs(X) - D*(K//2)) // (2*D)
t = 2*t + K//2
if X > 0:
t = -t
A = [t-2,t,t+2]
ans = 3*D
for a in A:
if abs(X+D*a)<ans:
ans = abs(X+D*a)
print(ans) | X,K,D = map(int,input().split())
#十分に原点から離れている場合
if abs(X) >= K*D:
ans = abs(X) - K*D
else:
t = (abs(X) - D*(K%2)) // (2*D)
t = 2*t + K%2
if X > 0:
t = -t
A = [t-2,t,t+2]
ans = 3*D
for a in A:
if abs(X+D*a)<ans:
ans = abs(X+D*a)
print(ans) | [["-", 0, 657, 12, 657, 12, 23, 0, 657, 17, 676], ["+", 0, 657, 12, 657, 12, 23, 0, 657, 17, 109], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 17, 676], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 17, 109]] | 5 | 130 |
X, K, D = list(map(int, input().split()))
if D * K < abs(X):
print(abs(X) - D * K)
elif D * K > abs(X):
D *= 2
if K % 2 == 0:
print(min(abs(X) % D, abs((abs(X) % D) - D)))
else:
print(min((abs(X) + abs(D)) % D, abs((abs(X) + abs(D)) % D - D)))
else:
print(0) | X, K, D = list(map(int, input().split()))
if D * K < abs(X):
print(abs(X) - D * K)
elif D * K > abs(X):
D *= 2
if K % 2 == 0:
print(min(abs(X) % D, abs((abs(X) % D) - D)))
else:
print(min((abs(X) + abs(D // 2)) % D, abs((abs(X) + abs(D // 2)) % D - D)))
else:
print(0) | [["+", 0, 657, 12, 652, 3, 4, 0, 657, 17, 676], ["+", 0, 657, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 134 |
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF... | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF... | [["-", 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, 22], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 472 |
x, k, d = map(int, input().split())
ans = x
if x//d>=k:
ans = abs(ans)
ans= min(ans-(k*d), abs((ans-(k*d))+d))
else:
ans-=(x//d)*d
k-=x//d
#print(k, ans, (x//d)*d)
if k%2==1:
ans=min(ans+d, abs(ans-d))
print(abs(ans))
| x, k, d = map(int, input().split())
ans = x
if abs(x)//d>=k:
ans = abs(ans)
ans= min(ans-(k*d), (ans-(k*d))+d)
else:
ans-=(x//d)*d
k-=x//d
#print(k, ans, (x//d)*d)
if k%2==1:
ans=min(ans+d, abs(ans-d))
print(abs(ans))
| [["+", 0, 57, 15, 666, 0, 657, 31, 652, 63, 22], ["+", 15, 666, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 15, 666, 0, 657, 31, 652, 3, 4, 0, 25], ["-", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 107 |
x,k,d = map(int,input().split())
if 0 < x:
if 0 < x - d * k:
print(abs(x - d * k))
elif x - d * k == 0:
print(0)
else:
judge = x //d
j1 = x - judge * d
count = k - judge
if count % 2 == 0:
print(abs(j1))
else:
print(abs(j1-d))
... | x,k,d = map(int,input().split())
if 0 < x:
if 0 < x - d * k:
print(abs(x - d * k))
elif x - d * k == 0:
print(0)
else:
judge = x //d
j1 = x - judge * d
count = k - judge
if count % 2 == 0:
print(abs(j1))
else:
print(abs(j1-d))
... | [["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72]] | 5 | 205 |
X, K ,D = map(int,input().split())
ans = 0
M = X // D
if M > K:
ans = X - K * D
else :
if (K - M) % 2 == 1:
ans = X - D * (M + 1)
else:
ans = X - D * M
print(abs(ans))
| X, K ,D = map(int,input().split())
ans = 0
X = abs(X)
M = X // D
if M > K:
ans = X - K * D
else :
if (K - M) % 2 == 1:
ans = X - D * (M + 1)
else:
ans = X - D * M
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 | 78 |
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test \
ll t; \
c... | //----------BHAVIK DIWANI(PICT_COMP)---------------
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test \
ll t; \
c... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]] | 1 | 693 |
x,k,d=map(int, input().split())
if x>d*k:
ans=x-k*d
else:
k=k-x//d
if k%2==0:
ans=x%d
else:
ans=abs(x%d-d)
print(ans) | x,k,d=map(int, input().split())
if abs(x)>d*k:
ans=abs(x)-k*d
else:
k=k-x//d
if k%2==0:
ans=x%d
else:
ans=abs(x%d-d)
print(ans) | [["+", 0, 656, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]] | 5 | 69 |
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
retu... | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
retu... | [["-", 0, 11, 12, 41, 64, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 41, 64, 23, 0, 16, 31, 22]] | 1 | 303 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long int;
int main() {
ll X, K, D;
cin >> X >> K >> D;
ll ans = 0;
if (X < 0) {
X = abs(X);
}
if (K * D >= X) {
K -= X / D;
X -= (X / D) * D;
if (K % 2 == 0) {
ans = X;
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long int;
int main() {
ll X, K, D;
cin >> X >> K >> D;
ll ans = 0;
if (X < 0) {
X = abs(X);
}
if (K >= X / D) {
K -= X / D;
X -= (X / D) * D;
if (K % 2 == 0) {
ans = X;
... | [["-", 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 | 129 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll x, k, d, a, b, y;
cin >> x >> k >> d;
a = x % d;
b = x / d;
if (b > k) {
if (x >= 0)
cout << abs(x - (d * k));
else
cout << abs(x + (d * k));
} else i... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll x, k, d, a, b, y;
cin >> x >> k >> d;
a = x % d;
b = x / d;
if (abs(b) > k) {
if (x >= 0)
cout << abs(x - (d * k));
else
cout << abs(x + (d * k));
} e... | [["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24]] | 1 | 185 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
long x = sc.nextLong(), k = sc.nextLong(), d = s... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
long x = sc.nextLong(), k = sc.nextLong(), d = s... | [["-", 49, 200, 51, 492, 3, 4, 0, 16, 12, 22], ["+", 49, 200, 51, 492, 3, 4, 0, 16, 12, 22], ["-", 75, 196, 0, 57, 15, 15, 0, 16, 12, 22], ["+", 75, 196, 0, 57, 15, 15, 0, 16, 12, 22], ["-", 0, 57, 75, 57, 15, 15, 0, 16, 12, 22], ["+", 0, 57, 75, 57, 15, 15, 0, 16, 12, 22]] | 3 | 526 |
#include <algorithm>
#include <assert.h>
#include <bit>
#include <bitset>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
using namespace std;
int main() {
int64_t X = ... | #include <algorithm>
#include <assert.h>
#include <bit>
#include <bitset>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
using namespace std;
int main() {
int64_t X = ... | [["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 0, 24]] | 1 | 202 |
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long m;
if (llabs(x) / d < k) {
m = llabs(x) % d;
if ((k - (x / d)) % 2 != 0) {
m = llabs(m - d);
}
} else {
m =... | #include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
long long m;
if (llabs(x) / d < k) {
m = llabs(x) % d;
if ((k - (x / d)) % 2 != 0) {
m = llabs(m - d);
}
} else {
m =... | [["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]] | 1 | 110 |
from math import ceil, floor
X, K, D = map(int, input().split())
ans = abs(X)
fapp = (K*D - X)/(2*D)
if fapp <= 0:
list = [0]
elif fapp >= K:
list = [K]
else:
list = [ceil(fapp), floor(fapp)]
for f in list:
abso = abs(X + f*D - (K-f)*D)
if abso < ans:
ans = abso
print(ans) | from math import ceil, floor
X, K, D = map(int, input().split())
ans = abs(X + K*D)
fapp = (K*D - X)/(2*D)
if fapp <= 0:
list = [0]
elif fapp >= K:
list = [K]
else:
list = [ceil(fapp), floor(fapp)]
for f in list:
abso = abs(X + f*D - (K-f)*D)
if abso < ans:
ans = abso
print(ans) | [["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 12, 652, 3, 4, 0, 657, 12, 657, 31, 22], ["+", 12, 652, 3, 4, 0, 657, 12, 657, 17, 48], ["+", 12, 652, 3, 4, 0, 657, 12, 657, 12, 22]] | 5 | 115 |
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll N = 1e3 + 5;
int n, m, sx, sy, ex, ey;
int vis[N][N... | #include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll N = 1e3 + 5;
int n, m, sx, sy, ex, ey;
int vis[N][N... | [["+", 31, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 12, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22]] | 1 | 455 |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
ty... | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
ty... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]] | 1 | 699 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define all(A) A.begin(), A.end()
typedef long long ll;
int main() {
int h, w;
cin >> h >> w;
int ch, cw, dh, dw;
cin >> ch >> cw >> dh >> dw;
vector<vector<char>> ma... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define all(A) A.begin(), A.end()
typedef long long ll;
int main() {
int h, w;
cin >> h >> w;
int ch, cw, dh, dw;
cin >> ch >> cw >> dh >> dw;
vector<vector<char>> ma... | [["-", 0, 57, 64, 1, 0, 2, 63, 118, 119, 120], ["+", 0, 57, 64, 1, 0, 2, 63, 118, 119, 120], ["-", 75, 76, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 75, 76, 0, 1, 0, 2, 63, 118, 119, 120]] | 1 | 518 |
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int H, W;
char S[1000][1000];
ll cnt[1000][1000];
bool flags[1000][1000];
bool cond(int h, int w) {
if (h < 0 || h >= H || w < 0 || w >= W)
return false;
if (S[h][w] == '... | #include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int H, W;
char S[1000][1000];
ll cnt[1000][1000];
bool flags[1000][1000];
bool cond(int h, int w) {
if (h < 0 || h >= H || w < 0 || w >= W)
return false;
if (S[h][w] == '... | [["-", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["+", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["-", 12, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 83, 0, 9... | 1 | 805 |
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define REP(i, s, n) for (int i = s; i < n; i++)
#define NUM 2520
#define INF (1LL << 50)
#define DEBUG 0
#define mp(a, b) make_pair(a, b)
#define SORT(V) sort(V.begin(), V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) #Var... | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define REP(i, s, n) for (int i = s; i < n; i++)
#define NUM 2520
#define INF (1LL << 50)
#define DEBUG 0
#define mp(a, b) make_pair(a, b)
#define SORT(V) sort(V.begin(), V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) #Var... | [["-", 8, 9, 0, 37, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 37, 0, 16, 31, 16, 12, 22]] | 1 | 993 |
def main():
from sys import setrecursionlimit, stdin, stderr
from os import environ
from collections import defaultdict, deque, Counter
from math import ceil, floor
from itertools import accumulate, combinations, combinations_with_replacement
setrecursionlimit(10**6)
dbg = (lambda *something... | def main():
from sys import setrecursionlimit, stdin, stderr
from os import environ
from collections import defaultdict, deque, Counter
from math import ceil, floor
from itertools import accumulate, combinations, combinations_with_replacement
setrecursionlimit(10**6)
dbg = (lambda *something... | [["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 48], ["-", 0, 652, 3, 4, 0, 657, 12, 23, 0, 24], ["-", 0, 652, 3, 4, 0, 657, 12, 23, 0, 25]] | 5 | 224 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (x < 0)
x = -x;
long long s = x / d;
if (s > k)
printf("%lld\n", x - s * d);
else {
if ((k - s) % 2 == 0)
printf("%lld\n", x - s * d);
else
printf("%lld\n", -(x - s * d - d));
... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
if (x < 0)
x = -x;
long long s = x / d;
if (s > k)
printf("%lld\n", x - k * d);
else {
if ((k - s) % 2 == 0)
printf("%lld\n", x - s * d);
else
printf("%lld\n", -(x - s * d - d));
... | [["-", 0, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 31, 22]] | 1 | 116 |
# AtCoder Beginner Contest 175
# C - Walking Takahashi
X,K,D =map(int,input().split())
X=abs(X)
q=X//D
r=X%D
if K<=q:
print(X-q*D)
exit()
else :
if (K-q)%2==0:
print(r)
else :
print(abs(r-D)) | # AtCoder Beginner Contest 175
# C - Walking Takahashi
X,K,D =map(int,input().split())
X=abs(X)
q=X//D
r=X%D
if K<=q:
print(X-K*D)
exit()
else :
if (K-q)%2==0:
print(r)
else :
print(abs(r-D)) | [["-", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22]] | 5 | 80 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x ... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 109], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 131 |
x,k,d=map(int,input().split())
if d>=abs(x):
if k%2==0:
p=abs(x)
else:
if x>=0:
p=abs(x-d)
else:
p=abs(x+d)
print(p)
exit(0)
else:
cnt=abs(x)//d
if cnt>=k:
cnt=k
if x>=0:
p=x-d*cnt
else:
p=x+d*cnt
k-=cnt
... | x,k,d=map(int,input().split())
if d>=abs(x):
if k%2==0:
p=abs(x)
else:
if x>=0:
p=abs(x-d)
else:
p=abs(x+d)
print(p)
exit(0)
else:
cnt=abs(x)//d
if cnt>=k:
cnt=k
if x>=0:
p=x-d*cnt
else:
p=x+d*cnt
k-=cnt
... | [["+", 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 | 167 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
void solve() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if ((x / d) >= k) {
ll y = x / d;
x -= k *... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
void solve() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if ((x / d) >= k) {
ll y = x / d;
x -= k *... | [["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151]] | 1 | 187 |
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i, x, n) for (int i = x; i < n; i++)
#define repd(i, x, n) for (int i = x; i <= n; i++)
#define pii pair<int, int>
#define pll pair<long long, long long>
#def... | #include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i, x, n) for (int i = x; i < n; i++)
#define repd(i, x, n) for (int i = x; i <= n; i++)
#define pii pair<int, int>
#define pll pair<long long, long long>
#def... | [["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]] | 1 | 903 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x > k * d) {
cout << x - k * d;
return 0;
} else {
ll y = x % d;
ll i = (x - y) / d;
if ((k - i) % 2)
y = abs(y - d);
cout << y;
return 0;
}
r... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x > __int128(k) * d) {
cout << x - k * d;
return 0;
} else {
ll y = x % d;
ll i = (x - y) / d;
if ((k - i) % 2)
y = abs(y - d);
cout << y;
return ... | [["+", 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 | 108 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll simu(ll x, ll k, ll d) {
if (k == 0) {
// cout<<x<<endl;
return x;
}
if (x > 0) {
if (x - d < 0) {
if (k % 2 == 0)
return x;
else
return x - d;
}
// cout<<x<<" "<<k<<" "<<endl;
ll n = min(x... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll simu(ll x, ll k, ll d) {
if (k == 0) {
// cout<<x<<endl;
return x;
}
if (x > 0) {
if (x - d < 0) {
if (k % 2 == 0)
return x;
else
return x - d;
}
// cout<<x<<" "<<k<<" "<<endl;
ll n = min(x... | [["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 109], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 85]] | 1 | 200 |
x, k, d = map(int, input().split())
x = abs(x)
a = x // d
if a >= k:
print(x - d * k)
elif (k - a) % 2:
print(d * (a + 1) - a)
else:
print(a - d * a)
| x, k, d = map(int, input().split())
x = abs(x)
a = x // d
if a >= k:
print(x - d * k)
elif (k - a) % 2:
print(d * (a + 1) - x)
else:
print(x - d * a)
| [["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22]] | 5 | 73 |
x, k, d = map(int, input().split())
if x < 0:
flag = -1
else:
flag = 1
if abs(x) >= k * d:
ans = x - k * d * flag
else:
k -= abs(x) // d
x = abs(x) % d
ans = x if k % 2 == 0 else x - d * flag
print(abs(ans))
| x, k, d = map(int, input().split())
if x < 0:
flag = -1
else:
flag = 1
if abs(x) >= k * d:
ans = x - k * d * flag
else:
k -= abs(x) // d
x = abs(x) % d * flag
ans = x if k % 2 == 0 else x - d * flag
print(abs(ans))
| [["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]] | 5 | 91 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii ve... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii ve... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 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, 12, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]... | 1 | 352 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define lpri(n) printf("%lld", n)
#define pri(n) printf("%d", n)
#define pln() printf("\n")
#define priln(n) printf("%d\n", n)
#define lpriln(n) printf("%lld\n", n)
#define rep(i, init, n)... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define lpri(n) printf("%lld", n)
#define pri(n) printf("%d", n)
#define pln() printf("\n")
#define priln(n) printf("%d\n", n)
#define lpriln(n) printf("%lld\n", n)
#define rep(i, init, n)... | [["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]] | 1 | 208 |
#include <bits/stdc++.h>
const int MAX = 1e6 + 10;
const int modn = 1e9 + 7;
typedef long long ll;
#define endl '\n'
#define cwk \
freopen("D:\\workplace\\CLion\\in.in", "r", stdin), \
freopen("D:\\workplace\\CLion\\out.... | #include <bits/stdc++.h>
const int MAX = 1e6 + 10;
const int modn = 1e9 + 7;
typedef long long ll;
#define endl '\n'
#define cwk \
freopen("D:\\workplace\\CLion\\in.in", "r", stdin), \
freopen("D:\\workplace\\CLion\\out.... | [["+", 0, 16, 12, 16, 31, 16, 31, 91, 17, 33]] | 1 | 227 |
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i, x, y) for (int i = x; i < y; i++)
#define rel(i, x, y) for (int i = x - 1; i >= y; i--)
#define all(x) x.begin(), x.end()
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
... | #include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i, x, y) for (int i = x; i < y; i++)
#define rel(i, x, y) for (int i = x - 1; i >= y; i--)
#define all(x) x.begin(), x.end()
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
... | [["-", 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, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]] | 1 | 170 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = Math.abs(sc.nextLong());
long k = sc.nextLong();
long d = sc.nextLong();
if (x >= k * d) {
System.out.println(x - k * d);
return;
}
k -= x / d;
... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = Math.abs(sc.nextLong());
long k = sc.nextLong();
long d = sc.nextLong();
if (x / d >= k) {
System.out.println(x - k * d);
return;
}
k -= x / d;
... | [["+", 0, 57, 15, 15, 0, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 15, 0, 16, 12, 16, 12, 22]] | 3 | 149 |
#include <algorithm>
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
ll X, K, D;
cin >> X >> K >> D;
ll ans;
X = abs(X);
if (X / D > K) {
ans = X - (K * D);
} else {
ll e = (X / D);
K -= e;
X -= e * D;
if (K % 2 == 1)
abs(X - D);
... | #include <algorithm>
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
ll X, K, D;
cin >> X >> K >> D;
ll ans;
X = abs(X);
if (X / D > K) {
ans = X - (K * D);
} else {
ll e = (X / D);
K -= e;
X -= e * D;
if (K % 2 == 1)
X = abs(X - D... | [["+", 0, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 9, 0, 57, 64, 1, 0, 11, 17, 32]] | 1 | 118 |
#include <algorithm>
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X >= K * D) {
cout << X - (K * D) << endl;
} else {
ll e = (X / D);
K -= e;
X -= e * D;
if (K % 2 == 0)
cout << X <... | #include <algorithm>
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X / D > K) {
cout << X - (K * D) << endl;
} else {
ll e = (X / D);
K -= e;
X -= e * D;
if (K % 2 == 0)
cout << X <<... | [["-", 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 | 117 |
X,K,D=map(int,input().split())
x=abs(X)
a=x//D
b=x%D
c=abs(b-D)
if a%2==0:
even=b
odd=c
else:
odd=b
even=c
if a>K:
print(X-K*D)
elif K%2==0:
print(even)
else:
print(odd) | X,K,D=map(int,input().split())
x=abs(X)
a=x//D
b=x%D
c=abs(b-D)
if a%2==0:
even=b
odd=c
else:
odd=b
even=c
if a>K:
print(abs(X)-K*D)
elif K%2==0:
print(even)
else:
print(odd) | [["+", 0, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 93 |
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
typedef long long ll;
using namespace std;
ll x, k, d;
int main() {
cin >> x >> k >> d;
if (x < 0)
x = -x;
ll ans = 0;
if (x >= k * d) {
ans = x - k * d;
} else {
ll num = x / d;
ll a = x - num * d;
ll b = abs(a... | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
typedef long long ll;
using namespace std;
ll x, k, d;
int main() {
cin >> x >> k >> d;
if (x < 0)
x = -x;
ll ans = 0;
if (x / d >= k) {
ans = x - k * d;
} else {
ll num = x / d;
ll a = x - num * d;
ll b = abs(a... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 152 |
/*
* Created By: 'Present_Sir'
* Created On: Sunday 16 August 2020 12:24:48 PM IST
*/
#include <bits/stdc++.h>
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define int long long
usin... |
/*
* Created By: 'Present_Sir'
* Created On: Sunday 16 August 2020 12:24:48 PM IST
*/
#include <bits/stdc++.h>
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define int long long
usin... | [["+", 49, 50, 51, 16, 31, 23, 0, 2, 63, 22], ["+", 51, 16, 31, 23, 0, 2, 3, 4, 0, 24], ["+", 51, 16, 31, 23, 0, 2, 3, 4, 0, 25]] | 1 | 220 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[]) {
ll x, k, d;
scanf("%lld%lld%lld", &x, &k, &d);
x = abs(x);
if (x >= k * d)
return 0 * printf("%lld\n", x - k * d);
printf("%lld\n", abs(x - (x /... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[]) {
ll x, k, d;
scanf("%lld%lld%lld", &x, &k, &d);
x = abs(x);
if (x / d >= k)
return 0 * printf("%lld\n", x - k * d);
printf("%lld\n", abs(x - (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 | 133 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[]) {
ll x, k, d;
scanf("%lld%lld%lld", &x, &k, &d);
x = abs(x);
if (x >= k * d)
return 0 * printf("%lld\n", x - k * d);
ll block = x / d;
printf("%... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[]) {
ll x, k, d;
scanf("%lld%lld%lld", &x, &k, &d);
x = abs(x);
if (x / d >= k)
return 0 * printf("%lld\n", x - k * d);
ll block = x / d;
printf("%... | [["+", 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 | 136 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const stat... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const stat... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48]] | 1 | 729 |
x,k,d = map(int, input().split())
x,m = abs(x), min(k,x//d)
x -= m*d
k -= m
x = abs(x-d) if k%2 else x
print(x) | x,k,d=map(int,input().split())
x=abs(x)
m=min(k,x//d)
x-=m*d
k-=m
x=abs(x-d) if k%2 else x
print(x) | [["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 21], ["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 432, 0, 21], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32]] | 5 | 61 |
x,k,d = map(int, input().split())
x,m = abs(x), min(k,x//d)
x -= m*d
k -= m
if k%2:
x = abs(x-d)
print(x) | x,k,d=map(int,input().split())
x=abs(x)
m=min(k,x//d)
x-=m*d
k-=m
if k%2:
x=abs(x-d)
print(x) | [["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 21], ["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 432, 0, 21], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32]] | 5 | 60 |
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout \
if (false) \
cout
#define debug()... | #include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout \
if (false) \
cout
#define debug()... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22]] | 1 | 329 |
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ... | #include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 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, 47]] | 1 | 246 |
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ... | #include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 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, 47]] | 1 | 232 |
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
def power(x, p,m):
res = 1
while p:
if p ... | import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
def power(x, p,m):
res = 1
while p:
if p ... | [["+", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 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], ["+", 8, 196, 0, 1, 0, 677, 12, 652, 63, 22]] | 5 | 700 |
X, K, D = map(int, input().split())
q, r = divmod(X, D)
if X >= K*D:
print(X-K*D)
elif abs(K-q) % 2 == 0:
print(r)
else:
print(abs(r-D))
| X, K, D = map(int, input().split())
q, r = divmod(X, D)
if abs(X) >= K*D:
print(abs(X)-K*D)
elif abs(K-q) % 2 == 0:
print(r)
else:
print(abs(r-D))
| [["+", 0, 656, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 70 |
// Problem :
// C - Walking Takahashi
// Editorial
//
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
// #pragma GCC optimize("Ofast")
/... |
// Problem :
// C - Walking Takahashi
// Editorial
//
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
// #pragma GCC optimize("Ofast")
/... | [["+", 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 | 483 |
A = input().split()
X = float(A[0])
K = int(A[1])
D = int(A[2])
if abs(X) - K * D > 0:
print(int(abs(X) - K*D))
else:
K2 = abs(X)//D
if K - K2 % 2 == 0:
print(int(abs(abs(X) - D * K2)))
else:
print(int(abs(abs(abs(X) - D * K2) - D)))
|
A = input().split()
X = float(A[0])
K = int(A[1])
D = int(A[2])
if abs(X) - K * D > 0:
print(int(abs(X) - K*D))
else:
K2 = abs(X)//D
if (K - K2) % 2 == 0:
print(int(abs(abs(X) - D * K2)))
else:
print(int(abs(abs(abs(X) - D * K2) - D)))
| [["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 122 |
x, k, d = gets.chomp.split(" ").map(&:to_i)
min = 0
if x.abs > k*d
min = x.abs - k*d
if x < 0
min *= -1
end
else
if (k - x/d).even?
#偶数の場合
min = x - d * (x / d)
elsif
#奇数の場合
min = (x - d * (x / d + 1)).abs
end
end
puts min | x, k, d = gets.chomp.split(" ").map(&:to_i)
min = 0
x = x.abs
if x > k*d
min = x - k*d
if x < 0
min *= -1
end
else
if (k - x/d).even?
#偶数の場合
min = x - d * (x / d)
elsif
#奇数の場合
min = (x - d * (x / d + 1)).abs
end
end
puts min | [["-", 36, 36, 36, 36, 0, 493, 0, 121, 0, 121], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 486, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 121, 0, 121], ["+", 36, 36, 0, 493, 0, 121, 15, 738, 31, 22], ["-", 64, 749, 0, 662, 12, 738, 31, 652, 17, 131], ["-", 64, 749, 0, 662, 12, 738,... | 4 | 97 |
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <deque> // deque
#include <iomanip> // fixed, setprecis... | #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <deque> // deque
#include <iomanip> // fixed, setprecis... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 12, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 12, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 12, 22]] | 1 | 175 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll x, d, k, need;
cin >> x >> k >> d;
need = abs(x) / d;
if (need > k) {
if (x < 0)
printf("%lld\n", x + (k * d));
else
printf("%lld\n", x - (k * d));
} else {
ll baki = abs(x) % d;
if (baki == 0) {
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll x, d, k, need;
cin >> x >> k >> d;
need = abs(x) / d;
if (need > k) {
if (x < 0)
printf("%lld\n", abs(x + (k * d)));
else
printf("%lld\n", x - (k * d));
} else {
ll baki = abs(x) % d;
if (baki == 0)... | [["+", 64, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 25]] | 1 | 180 |
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespac... | #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespac... | [["+", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 25]] | 1 | 315 |
#include <bits/stdc++.h>
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) rep2(i, 0, n)
#define FOR(i) for (cin >> i; i > 0; i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(), x.end()
#define re(x) ... | #include <bits/stdc++.h>
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) rep2(i, 0, n)
#define FOR(i) for (cin >> i; i > 0; i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(), x.end()
#define re(x) ... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 145 |
#include <bits/stdc++.h>
int main(void) {
int64_t x, k, d;
std::cin >> x >> k >> d;
int64_t posi_ans = x;
int64_t k_cnt = std::abs(x / d);
if (k_cnt > k) {
posi_ans -= d * k;
} else {
k -= k_cnt;
posi_ans -= d * k_cnt;
if (k & 0x01) {
posi_ans -= d;
}
}
posi_ans = std::ab... | #include <bits/stdc++.h>
int main(void) {
int64_t x, k, d;
std::cin >> x >> k >> d;
int64_t posi_ans = std::abs(x);
int64_t k_cnt = std::abs(x / d);
if (k_cnt > k) {
posi_ans -= d * k;
} else {
k -= k_cnt;
posi_ans -= d * k_cnt;
if (k & 0x01) {
posi_ans -= d;
}
}
posi_ans... | [["+", 0, 43, 49, 50, 51, 2, 63, 343, 345, 348], ["+", 0, 43, 49, 50, 51, 2, 63, 343, 0, 349], ["+", 0, 43, 49, 50, 51, 2, 63, 343, 141, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]] | 1 | 104 |
x,k,d = map(int,input().split())
if abs(x)//abs(d) >= k:
print(abs(x)-abs(d)*k)
exit()
step = abs(x)//abs(d)
y = abs(x)-abs(d)*step
k = k-step
if k%2 == 0:
print(y)
else:
print(y+d) | x,k,d = map(int,input().split())
if abs(x)//abs(d) >= k:
print(abs(x)-abs(d)*k)
exit()
step = abs(x)//abs(d)
y = abs(x)-abs(d)*step
k = k-step
if k%2 == 0:
print(y)
else:
print(abs(y-d)) | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 96 |
#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;
ll quo = x / d;
ll mod = x % d;
ll ans;
if (d == x) {
if (k % 2 == 0) {
ans = x;
} else {
ans = 0;
}
} else {
if (quo <= k) {
if (... | #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;
ll quo = x / d;
ll mod = x % d;
ll ans;
if (d == x) {
if (k % 2 == 0) {
ans = x;
} else {
ans = 0;
}
} else {
if (quo <= k) {
if (... | [["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 155 |
X, K, D = map(int,input().split())
l = X - K * D
r = X + K * D
if l >= 0:
print(l)
elif r <= 0:
print(r)
else:
X = abs(X)
k = X // D
if (K - k) % 2 == 0:
print(X - X // D * D)
else:
print(-(X - (X // D + 1) * D)) | X, K, D = map(int,input().split())
l = X - K * D
r = X + K * D
if l >= 0:
print(l)
elif r <= 0:
print(-r)
else:
X = abs(X)
k = X // D
if (K - k) % 2 == 0:
print(X - X // D * D)
else:
print(-(X - (X // D + 1) * D)) | [["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33]] | 5 | 103 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = ... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = ... | [["+", 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 | 385 |
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdi... | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdi... | [["-", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22]] | 5 | 175 |
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(), x.end()
#define MOD (1000000000 + 7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x, y) make_pair(x, y)
int main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X >= D * K) {
cout << X - D * K ... | #include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(), x.end()
#define MOD (1000000000 + 7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x, y) make_pair(x, y)
int main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X / D >= K) {
cout << X - D * K ... | [["-", 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 | 132 |
# ABC175
# C
# 座標XからK回正または負にD移動
# できない
x, k, d = map(int, input().split())
c = x // d
c
if c > k:
print(abs(x) - d * k)
else:
x = abs(x) - d * c
c = k - c
if c % 2 == 0:
print(abs(x))
else:
print(abs(abs(x)-d))
| # ABC175
# C
# 座標XからK回正または負にD移動
# できない
x, k, d = map(int, input().split())
c = abs(x) // d
if c > k:
print(abs(x) - d * k)
else:
x = abs(x) - d * c
c = k - c
if c % 2 == 0:
print(abs(x))
else:
print(abs(abs(x)-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], ["-", 36, 36, 36, 36, 0, 656, 0, 1, 0, 22]] | 5 | 89 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define fo(a, b, c) for (int i = a; i < b... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define fo(a, b, c) for (int i = a; i < b... | [["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22]] | 1 | 662 |
x,k,d=map(int,input().split())
mini=0
if abs(x)>=k*d:
mini=abs(x)-k*d
print(mini)
else:
q=abs(x)//d
s=abs(x)%d
if (k-q)%2==0:
print(s)
else:
print(s-d) | x,k,d=map(int,input().split())
mini=0
if abs(x)>=k*d:
mini=abs(x)-k*d
print(mini)
else:
q=abs(x)//d
s=abs(x)%d
if (k-q)%2==0:
print(s)
else:
print(abs(s-d)) | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 86 |
<?php
//dが速度 kが時間 d*k<x場合はx-$d*k
//d*k>x場合 kが偶数の時 $x/$k kが奇数の時 $x/$k+1回
fscanf(STDIN,"%d%d%d",$x,$k,$d);
if(abs($x)>$k*$d){
echo (abs($x)-$k*$d);
}else{
if((int)($x/$d)%2==0){
echo abs(abs($x)-$d*abs((int)($x/$d)));
}else{
// echo "hoge".($d*(int)($x/$d));
echo abs(a... | <?php
//dが速度 kが時間 d*k<x場合はx-$d*k
//d*k>x場合 kが偶数の時 $x/$k kが奇数の時 $x/$k+1回
fscanf(STDIN,"%d%d%d",$x,$k,$d);
if(abs($x)>$k*$d){
echo (abs($x)-$k*$d);
}else{
if(($k-(int)($x/$d))%2==0){
echo abs(abs($x)-$d*abs((int)($x/$d)));
}else{
// echo "hoge".($d*(int)($x/$d));
echo ... | [["+", 31, 16, 31, 23, 0, 16, 31, 606, 0, 607], ["+", 31, 16, 31, 23, 0, 16, 31, 606, 0, 141], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 23, 0, 16, 12, 74, 0, 24], ["+", 31, 23, 0, 16, 12, 74, 51, 23, 0, 25]] | 6 | 135 |
X,K,D=map(int,input().split())
x=min(K,abs(X)//D)
if X>0:
X_=X-(D*x)
else:
X_=X+(D*x)
k=K-x
if k%2!=0:
ans=min(abs(X_-D),abs(X_+D))
else:
ans=X_
print(ans) | X,K,D=map(int,input().split())
x=min(K,abs(X)//D)
if X>0:
X_=X-(D*x)
else:
X_=X+(D*x)
k=K-x
if k%2!=0:
ans=min(abs(X_-D),abs(X_+D))
else:
ans=abs(X_)
print(ans) | [["+", 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, 25]] | 5 | 95 |
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int main() {
ll x, k, d;
scanf("%lld %lld %lld", &x, &k, &d);
x = llabs(x);
ll r = x / d;
ll q = x % d;
ll ans;
if (x - k * d >= 0) {
// ll min = MIN(llabs(x + k * d), llabs(x -... | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int main() {
ll x, k, d;
scanf("%lld %lld %lld", &x, &k, &d);
x = llabs(x); // x >= 0として良い
ll r = x / d;
ll q = x % d;
ll ans;
if (x / d >= k) { // 0を越えない
ans = (x - k * d);
}... | [["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 33], ["-", 15, 23, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 23, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 85], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22]] | 0 | 139 |
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define true 1
#define false 0
typedef long long ll;
typedef unsigned char Uchar;
int main(void) {
int i, j;
ll x, k, d;
scanf("%lld %lld %lld", &x, &k, &d);
x = abs(x);
ll ans = 0;
if (x / d > k) {
ans = x - d * k;
} else ... | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define true 1
#define false 0
typedef long long ll;
typedef unsigned char Uchar;
int main(void) {
int i, j;
ll x, k, d;
scanf("%lld %lld %lld", &x, &k, &d);
x = fabsl(x);
ll ans = 0;
if (x / d >= k) {
ans = x - d * k;
} el... | [["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["-", 0, 57, 64, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 2, 63, 22]] | 0 | 140 |
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long x, k, d, f, lef;
cin >> x >> k >> d;
x = abs(x);
if (x >= k * d) {
cout << abs(x - k * d) << endl;
} else {
f = floor(x / d);
lef = k - f;
x -= d * f;
... | #include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long x, k, d, f, lef;
cin >> x >> k >> d;
x = abs(x);
if (x / d > k) {
cout << abs(x - k * d) << endl;
} else {
f = floor(x / d);
lef = k - f;
x -= d * f;
... | [["-", 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 | 118 |
X, K, D = map(int,input().split())
time = X // D
time = min(K, time)
X = X - (D * time)
K = K - time
if K % 2 == 0:
print(X)
else:
print(abs(X - D)) | X, K, D = map(int,input().split())
X = abs(X)
time = X // D
time = min(K, time)
X = X - (D * time)
K = K - time
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 | 67 |
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
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 - k * d;
} else {
ll e = x / d;
k -= e;
x -= e * d;
if (k % 2 == 1) {
... | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
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 - k * d;
} else {
ll e = x / d;
k -= e;
x -= e * d;
if (k % 2 == 1) {
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 120 |
x,k,d = gets.chomp.split(" ").map(&:to_i)
num = [x / d, k].min
if x >= 0
x -= num * d
else
x += num * d
end
k -= num
if k % 2 == 0
puts x.abs
elsif x >= 0
puts (x - d).abs
else
puts (x + d).abs
end
| x,k,d = gets.chomp.split(" ").map(&:to_i)
num = [(x / d).abs, k].min
if x >= 0
x -= num * d
else
x += num * d
end
k -= num
if k % 2 == 0
puts x.abs
elsif x >= 0
puts (x - d).abs
else
puts (x + d).abs
end
| [["+", 12, 652, 486, 516, 0, 652, 486, 739, 0, 24], ["+", 12, 652, 486, 516, 0, 652, 486, 739, 0, 25], ["+", 0, 662, 12, 652, 486, 516, 0, 652, 17, 131], ["+", 0, 662, 12, 652, 486, 516, 0, 652, 735, 22]] | 4 | 84 |
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i... | // https://atcoder.jp/contests/abc175/tasks/abc175_c
#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22]] | 1 | 534 |
#include <bits/stdc++.h>
using namespace std;
int main() {
double X, K, D;
cin >> X >> K >> D;
if (0 > X)
X = -X;
double num, buf1, buf2;
num = floor(X / D);
if (num > K) {
printf("%.0lf\n", X - num * D);
return 0;
}
buf1 = abs(X - num * D);
buf2 = abs(X - (num + 1) * D);
if (buf2 > ... | #include <bits/stdc++.h>
using namespace std;
int main() {
double X, K, D;
cin >> X >> K >> D;
if (0 > X)
X = -X;
double num, buf1, buf2;
num = floor(X / D);
if (num > K) {
printf("%.0lf\n", X - K * D);
return 0;
}
buf1 = abs(X - num * D);
buf2 = abs(X - (num + 1) * D);
if (buf2 > buf... | [["-", 0, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 31, 22]] | 1 | 215 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll X, K, D, f, left;
cin >> X >> K >> D;
X = abs(X);
if (K <= X / D) {
cout << abs(X - K * D) << endl;
} else {
f = floor(X / D);
left = K - f;
X -= D * f;
cout << (K % 2 == 0 ? X : abs(X - D)) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll X, K, D, f, left;
cin >> X >> K >> D;
X = abs(X);
if (K <= X / D) {
cout << abs(X - K * D) << endl;
} else {
f = floor(X / D);
left = K - f;
X -= D * f;
cout << (left % 2 == 0 ? X : abs(X - D)) << endl;
... | [["-", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22]] | 1 | 112 |
#include <algorithm>
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#includ... | #include <algorithm>
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#includ... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 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 | 498 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.