buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
#include <bits/stdc++.h>
#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;
x = abs(x);
ll ans;
if (x / d <= k) {
// x までたどり着かない
ans = x - d * k;
} else {
ll time = x / d;
k -= ti... | #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;
x = abs(x);
ll ans;
if (x / d > k) {
// x までたどり着かない
ans = x - d * k;
} else {
ll time = x / d;
k -= tim... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 130 |
def walking():
x, k, d = map(int, input().split())
x = abs(x)
r = 0
if x > k * d:
return x - k * d
else:
r = x//d
if (k - r)%2 == 0:
return x - r * d
else:
return x - (r + 1 ) * d
loc = walking()
print(loc) |
def walking():
x, k, d = map(int, input().split())
x = abs(x)
r = 0
if x > k * d:
return x - k * d
else:
r = x//d
if (k - r)%2 == 0:
return x - r * d
else:
return abs(x - (r + 1 ) * d)
loc = walking()
print(loc) | [["+", 75, 76, 8, 196, 0, 37, 0, 652, 63, 22], ["+", 8, 196, 0, 37, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 37, 0, 652, 3, 4, 0, 25]] | 5 | 90 |
#include <bits/stdc++.h>
using namespace std;
template <typename T> T Abs(T num) { return num < 0 ? -num : num; }
template <typename T> T Min(T x, T y) { return x < y ? x : y; }
typedef long long ll;
ll X, K, D, t1, t2, d1, d2, res;
int main() {
cin >> X >> K >> D;
X = Abs(X);
t1 = X / (D + D);
t2 = t1 + 1;
i... | #include <bits/stdc++.h>
using namespace std;
template <typename T> T Abs(T num) { return num < 0 ? -num : num; }
template <typename T> T Min(T x, T y) { return x < y ? x : y; }
typedef long long ll;
ll X, K, D, t1, t2, d1, d2, res;
int main() {
cin >> X >> K >> D;
X = Abs(X);
t1 = X / (D + D);
t2 = t1 + 1;
i... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]] | 1 | 227 |
x, k, d = gets.split.map(&:to_i)
t, m = x.divmod(d)
if k <= t
puts (x - k * d).abs
elsif (k - t).even?
puts m
else
puts (m - d).abs
end
| x, k, d = gets.split.map(&:to_i)
x = x.abs
t, m = x.divmod(d)
if k <= t
puts (x - k * d).abs
elsif (k - t).even?
puts m
else
puts (m - d).abs
end
| [["+", 36, 36, 36, 36, 0, 493, 0, 662, 31, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 486, 22], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22]] | 4 | 59 |
// 公式解説
#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 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 - d);
}
ans = x;
}
cou... | // 公式解説
#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 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 - d);
}
ans = x;
}
cout... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 113 |
x, k ,d = gets.chomp.split(" ").map(&:to_i)
#今いる座標
#kkaisuu
#d idou
x = x.abs
kyori = x - k * d
if x > 0
if kyori > 0
puts kyouri
elsif kyori == 0
puts "0"
elsif kyori < 0
mae = x / d
maekyori = x - d * mae
usiro = x - d * (mae + 1)
kaizuu = k - mae
i... | x, k ,d = gets.chomp.split(" ").map(&:to_i)
#今いる座標
#kkaisuu
#d idou
x = x.abs
kyori = x - k * d
if x > 0
if kyori > 0
puts kyori
elsif kyori == 0
puts "0"
elsif kyori < 0
mae = x / d
maekyori = x - d * mae
usiro = x - d * (mae + 1)
kaizuu = k - mae
if... | [["-", 0, 121, 64, 749, 0, 652, 3, 4, 0, 22], ["+", 0, 121, 64, 749, 0, 652, 3, 4, 0, 22]] | 4 | 162 |
#include <cstdio>
#define abs(x) ((x) < 0 ? -(x) : (x))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
int main() {
ll x, k, d;
scanf("%lld%lld%lld", &x, &k, &d);
if (abs(x / d) >= k) {
printf("%lld", (x < 0 ? x + d * k : x - d * k));
} else { // abs(x/d)<k
if (x > 0) {
printf("%l... | #include <cstdio>
#define abs(x) ((x) < 0 ? -(x) : (x))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
int main() {
ll x, k, d;
scanf("%lld%lld%lld", &x, &k, &d);
if (abs(x / d) >= k) {
printf("%lld\n", abs(x < 0 ? x + d * k : x - d * k));
} else { // abs(x/d)<k
if (x > 0) {
print... | [["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22]] | 1 | 220 |
x, k, d = map(int, input().split())
cnt = x // d
if k < cnt:
ans = abs(x) - d * k
else:
k -= cnt
if k % 2:
ans = d * (cnt + 1) - abs(x)
else:
ans = abs(x) - d * cnt
print(ans)
| x, k, d = map(int, input().split())
cnt = abs(x) // d
if k < cnt:
ans = abs(x) - d * k
else:
k -= cnt
if k % 2:
ans = d * (cnt + 1) - abs(x)
else:
ans = abs(x) - d * cnt
print(ans)
| [["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]] | 5 | 78 |
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
static final long MOD = 1000000007L;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
long X = sc.nl();
long K = sc.nl();
long D = sc.nl();
... | import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
static final long MOD = 1000000007L;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
long X = sc.nl();
long K = sc.nl();
long D = sc.nl();
... | [["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 20], ["+", 64, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 64, 196, 0, 503, 49, 200, 51, 492, 0, 131], ["+", 64, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 51, 492, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 0, 503, 49, 200, 51, 492, 3... | 3 | 418 |
X, K, D = map(int, input().split())
if int(abs(X) / D) > K:
if abs(X) < abs(X) % D:
if K % 2 == 0:
print(abs(X))
else:
print(min(abs(X - D), abs(X + D)))
else:
if int(K - int(abs(X) / D)) % 2 == 0:
print(abs(X) % D)
else:
print(min... | X, K, D = map(int, input().split())
if int(abs(X) / D) < K:
if abs(X) < abs(X) % D:
if K % 2 == 0:
print(abs(X))
else:
print(min(abs(X - D), abs(X + D)))
else:
if int(K - int(abs(X) / D)) % 2 == 0:
print(abs(X) % D)
else:
print(min... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]] | 5 | 154 |
X,K,D = map(int,input().split())
X = abs(X)
if X-K*D <= 0:
d = X//D
K -= d
x -= D*d
if K%2 == 0:
print(a)
else:
print(abs(a-d))
else:
print(X-K*D) | X,K,D = map(int,input().split())
X = abs(X)
if X-K*D <= 0:
d = X//D
K -= d
X -= D*d
if K%2 == 0:
print(X)
else:
print(abs(X-D))
else:
print(X-K*D)
| [["-", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0,... | 5 | 78 |
#include <bits/stdc++.h>
#include <unistd.h>
#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define dame ... | #include <bits/stdc++.h>
#include <unistd.h>
#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define dame ... | [["-", 8, 9, 0, 57, 64, 1, 0, 16, 17, 48], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 108], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25]] | 1 | 1,774 |
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll, ll>>
#define vvl vector<vector<ll>> // a(縦行,vector<ll>(横列));
#include <algorithm> //__gcd(a,b)
#include <cst... | #include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll, ll>>
#define vvl vector<vector<ll>> // a(縦行,vector<ll>(横列));
#include <algorithm> //__gcd(a,b)
#include <cst... | [["-", 31, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["+", 31, 16, 31, 23, 0, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 243 |
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll, ll>>
#define vvl vector<vector<ll>> // a(縦行,vector<ll>(横列));
#include <algorithm> //__gcd(a,b)
#include <cst... | #include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll, ll>>
#define vvl vector<vector<ll>> // a(縦行,vector<ll>(横列));
#include <algorithm> //__gcd(a,b)
#include <cst... | [["-", 31, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["+", 31, 16, 31, 23, 0, 16, 12, 16, 17, 85]] | 1 | 291 |
list = list(map(int, input().split()))
hajime=list[0]
kaisuu=list[1]
hohaba=list[2]
if hajime>=0:
ayumi=hajime//hohaba
nokori=kaisuu-ayumi
kouho_1=hajime-hohaba*kaisuu
kouho_2=hajime-hohaba*ayumi
kouho_3=hajime-hohaba*(ayumi+1)
if kaisuu <= ayumi:
print(kouho_1)
else:
if nokori%2==0:
... | list = list(map(int, input().split()))
hajime=list[0]
kaisuu=list[1]
hohaba=list[2]
if hajime>=0:
ayumi=hajime//hohaba
nokori=kaisuu-ayumi
kouho_1=hajime-hohaba*kaisuu
kouho_2=hajime-hohaba*ayumi
kouho_3=hajime-hohaba*(ayumi+1)
if kaisuu <= ayumi:
print(kouho_1)
else:
if nokori%2==0:
... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22]] | 5 | 178 |
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
ll x, ... | #include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
ll x, ... | [["+", 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 | 314 |
x, k, d = map(int, input().split())
n = abs(x) // d
if k - n <= 0:
print(abs(x)-k*d)
elif k-n % 2 == 0:
print(abs(x) - n * d)
else:
print(abs(abs(x)-n*d-d))
| x, k, d = map(int, input().split())
n = abs(x) // d
if k - n <= 0:
print(abs(x)-k*d)
elif (k-n) % 2 == 0:
print(abs(x) - n * d)
else:
print(abs(abs(x)-n*d-d))
| [["+", 75, 665, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 75, 665, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 82 |
x, k, d= map(int, input().split())
x = abs(x)
if x - k * d >= 0:
print(x - k * d)
else:
ans1 = x % d
check = x // d
ans2 = ans1 - d
if((k-check)%2==0):
print(ans1)
else:
print(ans2)
| x, k, d= map(int, input().split())
x = abs(x)
if x - k * d >= 0:
print(x - k * d)
else:
ans1 = x % d
check = x // d
ans2 = ans1 - d
if((k-check)%2==0):
print(ans1)
else:
print(abs(ans2))
| [["+", 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 | 81 |
x, k, d= map(int, input().split())
x = abs(x)
if x - k * d >= 0:
print(x - k * d)
else:
ans1 = x % d
check = x // d
ans2 = ans1 - d
if(ans1 + ans2 > 0 and(k - (check + 1))%2==0):
print(abs(ans2))
elif(ans1 + ans2 > 0 and (k - (check + 1))%2==0==1):
print(ans1)
elif(ans1 + ans... | x, k, d= map(int, input().split())
x = abs(x)
if x - k * d >= 0:
print(x - k * d)
else:
ans1 = x % d
check = x // d
ans2 = ans1 - d
if(ans1 + ans2 > 0 and(k - (check + 1))%2==0):
print(abs(ans2))
elif(ans1 + ans2 > 0 and (k - (check + 1))%2==1):
print(ans1)
elif(ans1 + ans2 <... | [["-", 75, 665, 15, 23, 0, 679, 12, 666, 0, 612], ["-", 75, 665, 15, 23, 0, 679, 12, 666, 667, 60]] | 5 | 149 |
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
int main() {
ll X, K, D;
cin >> X >> K >> D;
if (ab... | #include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
int main() {
ll X, K, D;
cin >> X >> K >> D;
if (ab... | [["+", 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 | 144 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x;
long long k, d;
cin >> x >> k >> d;
x = fabs(x);
long long go = x / d;
long long ans = x;
if (k < go) {
go = k;
k = 0;
} else {
k -= go;
}
ans -= d * go;
if (k % 2 == 0) {
cout << fabs(ans) << endl;
} else ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x;
long long k, d;
cin >> x >> k >> d;
x = fabs(x);
long long go = x / d;
long long ans = x;
if (k < go) {
go = k;
k = 0;
} else {
k -= go;
}
ans -= d * go;
if (k % 2 == 0) {
cout << abs(ans) << endl;
} else {
... | [["-", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22]] | 1 | 113 |
meta = [int(s) for s in input().split(' ')]
now = meta[0]
times = meta[1]
distance = meta[2]
out = 0
i = 0
while i < times:
time = min([int(abs(now) / distance), times])
i += time
if time == 0:
if i % 2 == 0:
print(abs(now))
exit()
else:
time = 1
... | meta = [int(s) for s in input().split(' ')]
now = meta[0]
times = meta[1]
distance = meta[2]
out = 0
i = 0
while i < times:
#何回移動するか決める
#残り距離を移動距離で割った数と移動可能回数の少ない方を回数にする
time = min([int(abs(now) / distance), times])
#移動回数分カウンタ回す
i += time
#残り距離 < 移動距離になる時
if time == 0:
#残り移動可能回数が偶... | [["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 127 |
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//----------------------- Print Function ----------------------//
inline void print() { cout << endl; }
template <typename First, typename... Rest>
void print(const First &first, const Rest &...rest) {
cout << first << ' ';
print(rest...);
}
... | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//----------------------- Print Function ----------------------//
inline void print() { cout << endl; }
template <typename First, typename... Rest>
void print(const First &first, const Rest &...rest) {
cout << first << ' ';
print(rest...);
}
... | [["+", 12, 91, 28, 23, 0, 16, 31, 91, 17, 33]] | 1 | 293 |
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i, a, b) for (int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ \
ios_base::sync_with_stdio(0); ... | #include <bits/stdc++.h>
#define f first
#define s second
#define fore(i, a, b) for (int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ \
ios_base::sync_with_stdio(0); ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22]] | 1 | 812 |
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
long long int x, k, d;
cin >> x >> k >> d;
if (x > 0) {
if (k < x / d) {
cout << llabs(x - k * d) << endl;
} else {
k = k - (x / d);
x = x - (x / d) * d;
if (k % 2 == 0)... | #include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
long long int x, k, d;
cin >> x >> k >> d;
if (x > 0) {
if (k < x / d) {
cout << llabs(x - k * d) << endl;
} else {
k = k - (x / d);
x = x - (x / d) * d;
if (k % 2 == 0)... | [["+", 0, 57, 15, 339, 51, 16, 12, 2, 63, 22], ["+", 15, 339, 51, 16, 12, 2, 3, 4, 0, 24], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 0, 25], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 33]] | 1 | 208 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(long long X, long long K, long long D) {
ll ans = 0;
if (log10(abs(K)) + log10(abs(D)) > 16 or K * D > abs(X)) {
if (((K - abs(X) / D) & 1) == 1)
ans = X - (X / D + 1) * D;
else
ans = X - (X / D) * D;
} else {
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(long long X, long long K, long long D) {
ll ans = 0;
if (log10(abs(K)) + log10(abs(D)) > 16 or K * D > abs(X)) {
if (((K - abs(X) / D) & 1) == 1)
ans = X - (X / D + 1) * D;
else
ans = X - (X / D) * D;
} else {
... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22]] | 1 | 373 |
X, K, D = list(map(int, input().split()))
temp = abs(X) // D
if K%2 != temp%2:
temp = temp + 1
if temp > K:
temp = K
temp = D * temp
print(abs(X - temp))
| X, K, D = list(map(int, input().split()))
X = abs(X)
temp = X // D
if K%2 != temp%2:
temp = temp + 1
if temp > K:
temp = K
temp = D * temp
print(abs(X - temp))
| [["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22]] | 5 | 65 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll ans;
if ((ll)k < abs((ll)(x / d)))
ans = abs(abs((ll)x) - abs((ll)d * k));
else {
if (x > 0) {
if (abs(x) ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll ans;
if ((ll)k < abs((ll)(x / d)))
ans = abs(abs((ll)x) - abs((ll)d * k));
else {
if (x >= 0) {
if (abs(x)... | [["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 490 |
import sys
X, K, D = map(int, input().split())
num = X - K*D
if 0<num:
print(num)
sys.exit(0)
k2 = X//D
if (K-k2)%2==0:
print(X - k2*D)
elif K<k2+1:
print(X - (k2-1)*D)
else:
print((k2+1)*D - X)
| import sys
X, K, D = map(int, input().split())
X = abs(X)
num = X - K*D
if 0<num:
print(num)
sys.exit(0)
k2 = X//D
if (K-k2)%2==0:
print(X - k2*D)
elif K<k2+1:
print(X - (k2-1)*D)
else:
print((k2+1)*D - X)
| [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 99 |
X, K, D = map(int, input().split())
x = abs(X)
cnt = x // D
if K < cnt:
ans = x - (K * D)
else:
ans = x - (cnt * D)
if cnt % 2 != 0:
ans -= D
print(abs(ans)) | X, K, D = map(int, input().split())
x = abs(X)
cnt = x // D
if K < cnt:
ans = x - (K * D)
else:
ans = x - (cnt * D)
if (K - cnt) % 2 != 0:
ans -= D
print(abs(ans)) | [["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 71 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define inf ll(1e18)
using namespace std;
typedef long long ll;
int main() {
ll a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
a = abs(a);
ll d = a / c;
if (d >= b) {
printf("%lld", a - b * c);
... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define inf ll(1e18)
using namespace std;
typedef long long ll;
int main() {
ll a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
a = abs(a);
ll d = a / c;
if (d >= b) {
printf("%lld", a - b * c);
... | [["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 33], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 17, 48]] | 1 | 137 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
using namespace std;
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x - 0);
if (x >= k * d) {
cout << x - k * d << endl;
} else {
ll A = x - x / d * d;
k = k - x / d;
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
using namespace std;
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x - 0);
if (x / d >= k) {
cout << x - k * d << endl;
} else {
ll A = x - x / d * d;
k = k - 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 | 149 |
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int, int> pii;
#if (WIN32) || ... | // #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int, int> pii;
#if (WIN32) || ... | [["-", 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]] | 1 | 435 |
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
function Main(input) {
tmp = input.split(" ");
x = parseInt(tmp[0], 10);
k = parseInt(tmp[1], 10);
d = parseInt(tmp[2], 10);
count = 0;
count += Math.floor(Math.abs(x) / d);
if (count > k) {
count = k;
}
if (x > 0) {
x = x - (d * count)... | Main(require("fs").readFileSync("/dev/stdin", "utf8"));
function Main(input) {
tmp = input.split(" ");
x = parseInt(tmp[0], 10);
k = parseInt(tmp[1], 10);
d = parseInt(tmp[2], 10);
count = 0;
count += Math.floor(Math.abs(x) / d);
if (count > k) {
count = k;
}
if (x > 0) {
x = x - (d * count)... | [["+", 15, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 23, 0, 16, 31, 16, 31, 23, 0, 25]] | 2 | 196 |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop ... | #include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop ... | [["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 85], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22]] | 1 | 927 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
int main() {
ll X, K, D;
cin >> X >> K >> D;
if (X < 0)
X = -X;
if (D * ... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
int main() {
ll X, K, D;
cin >> X >> K >> D;
if (X < 0)
X = -X;
if (K <=... | [["-", 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 | 142 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
#define ran(x) (x).begin(), (x).end()
using namespace std;
int main() {
int64_t x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x > k * d) {
return cout << x - (k * d) << endl, 0;
}
if (x == d) {
... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
#define ran(x) (x).begin(), (x).end()
using namespace std;
int main() {
int64_t x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d > k) {
return cout << x - (k * d) << endl, 0;
}
if (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 | 251 |
#include <bits/stdc++.h>
using namespace std;
// long long
using ll = long long;
// pair<int, int>
using PII = pair<int, int>;
//最大値、mod
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
//出力系
#define print(x) cout << x << endl
#... | #include <bits/stdc++.h>
using namespace std;
// long long
using ll = long long;
// pair<int, int>
using PII = pair<int, int>;
//最大値、mod
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
//出力系
#define print(x) cout << x << endl
#... | [["+", 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 | 2,299 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t X, K, D, TX;
int64_t cou = 0;
cin >> X >> K >> D;
int64_t ZX = abs(X);
TX = ZX;
if (K <= TX / D) {
cout << TX << endl;
} else {
int64_t ZXE;
ZXE = ZX;
while (D <= ZXE) {
ZXE = ZXE - D;
cou++;
}
if ((... | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t X, K, D, TX;
int64_t cou = 0;
cin >> X >> K >> D;
int64_t ZX = abs(X);
TX = ZX;
if (K <= TX / D) {
cout << TX - K * D << endl;
} else {
int64_t ZXE;
ZXE = ZX;
while (D <= ZXE) {
ZXE = ZXE - D;
cou++;
}
... | [["+", 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 | 120 |
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long int ll;
ll ab(ll a) { return a < 0 ? -a : a; }
int main() {
ll X, K, D;
scanf("%lld %lld %lld", &X, &K, &D);
ll ans;
if (ab(X) - K * D >= -D) {
ans = ab(ab(X) - K * D);
} else {
ll a = ab(X) % D;
... | #include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long int ll;
ll ab(ll a) { return a < 0 ? -a : a; }
int main() {
ll X, K, D;
scanf("%lld %lld %lld", &X, &K, &D);
ll ans;
if (ab(X) / D >= K) {
ans = ab(ab(X) - K * D);
} else {
ll a = ab(X) % D;
ll b ... | [["-", 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], ["-", 0, 57, 15, 339, 51, 16, 12, 91, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 91, 28, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16,... | 1 | 160 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, val) for (int i = 0; i < val; i++)
const long long INF = 1LL << 60;
const ll MOD = ll(1e9) + 7;
bool has_key(unordered_map<string, ll> &m, string s) {
if (m.find(s) == m.end()) {
return false;
} else {
return true;
}
}
b... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, val) for (int i = 0; i < val; i++)
const long long INF = 1LL << 60;
const ll MOD = ll(1e9) + 7;
bool has_key(unordered_map<string, ll> &m, string s) {
if (m.find(s) == m.end()) {
return false;
} else {
return true;
}
}
b... | [["-", 15, 339, 51, 16, 31, 23, 0, 16, 17, 33], ["+", 51, 16, 31, 23, 0, 16, 31, 16, 17, 85], ["-", 51, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["+", 15, 339, 51, 16, 31, 23, 0, 16, 17, 33], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 15, 339, 51, 16, 31, 23, 0, 16, 17,... | 1 | 973 |
#include <bits/stdc++.h>
#ifdef DEBUG
#define PRINT(x) \
cout << "func " << __func__ << ": line " << __LINE__ << ": " << #x << " = " \
<< (x) << endl;
#define PRINTA(a, first, last) \
cout << "func... | #include <bits/stdc++.h>
#ifdef DEBUG
#define PRINT(x) \
cout << "func " << __func__ << ": line " << __LINE__ << ": " << #x << " = " \
<< (x) << endl;
#define PRINTA(a, first, last) \
cout << "func... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 85]] | 1 | 552 |
from sys import stdin
def f(x, k, d):
if k == 0:
return x
absX = abs(x)
tmp = absX / d
if tmp > k:
return absX - d * k
else:
absX = absX - d * tmp
k = k - tmp
if k % 2 == 0:
return absX
else:
return absX - d
if __name__ ==... | from sys import stdin
def f(x, k, d):
if k == 0:
return x
absX = abs(x)
tmp = absX // d
if tmp > k:
return absX - d * k
else:
absX = absX - d * tmp
k = k - tmp
if k % 2 == 0:
return absX
else:
return abs(absX - d)
if __nam... | [["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 676], ["+", 75, 76, 8, 196, 0, 37, 0, 652, 63, 22], ["+", 8, 196, 0, 37, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 37, 0, 652, 3, 4, 0, 25]] | 5 | 118 |
x,k,d = map(int, input().split())
x1=abs(x)
if x>=k*d:
print(x-k*d)
else:
if (k-x//d)%2 == 0:
print(x%d)
else:
print(d-x%d) | x,k,d = map(int, input().split())
x1=abs(x)
if x1>=k*d:
print(x1-k*d)
else:
if (k-x1//d)%2 == 0:
print(x1%d)
else:
print(d-x1%d) | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 657, 31, 23, 0, 657, 12, 657, 31, 22], ["+", 0, 657, 31, 23, 0, 657, 12, 657, 31, 22], ["-", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22],... | 5 | 70 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 51, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["-", 51, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 23, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12,... | 1 | 269 |
#include <bits/stdc++.h>
using namespace std;
using lli = long long;
int main() {
lli X, K, D;
cin >> X >> K >> D;
if (X < 0LL)
X -= X;
if ((X + D) / D >= K) {
X -= D * K;
cout << llabs(X) << "\n";
return 0;
}
lli t = X / D;
X -= D * (X / D);
K -= t;
if (K % 2)
X -= D;
cout ... | #include <bits/stdc++.h>
using namespace std;
using lli = long long;
int main() {
lli X, K, D;
cin >> X >> K >> D;
if (X < 0LL)
X = -X;
if ((X + D) / D >= K) {
X -= D * K;
cout << llabs(X) << "\n";
return 0;
}
lli t = X / D;
X -= D * (X / D);
K -= t;
if (K % 2)
X -= D;
cout ... | [["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 110], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 1, 0, 11, 12, 91, 17, 33]] | 1 | 122 |
X, K, D = map(int, input().split())
if X == 0:
if K % 2 == 0:
print(0)
else:
print(abs(D))
exit(0)
if X > 0:
k = X - K * D
if k >= 0:
print(k)
else:
kouho1 = X % D
kouho2 = abs(kouho1 - D)
sho = X // D
if (K - sho) % 2 == 0:
p... | X, K, D = map(int, input().split())
if X == 0:
if K % 2 == 0:
print(0)
else:
print(abs(D))
exit(0)
X = abs(X)
if X > 0:
k = X - K * D
if k >= 0:
print(k)
else:
kouho1 = X % D
kouho2 = abs(kouho1 - D)
sho = X // D
if (K - sho) % 2 == 0:
... | [["+", 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 | 185 |
x,n,d=map(int, input().split())
opt=x//d
if (n-opt)%2==0 and opt<n:
print(x-(d*opt))
elif opt>=n:
print(x-(d*n))
else:
a=x-(d*opt)
a=d-a
print(a) | x,n,d=map(int, input().split())
x=abs(x)
opt=x//d
if (n-opt)%2==0 and opt<n:
print(x-(d*opt))
elif opt>=n:
print(x-(d*n))
else:
a=x-(d*opt)
a=d-a
print(a) | [["+", 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 |
from sys import exit, stdin
# import copy
# from collections import deque,Counter
# import numpy as np
input = stdin.readline
X, K, D = map(int, input().split())
if abs(X) >= K * D:
print(abs(X - K * D))
else:
A1 = abs(X) % D
A2 = abs(A1 - D)
n = int((abs(X) - A1)/D)
if (K - n) % 2 == 0:
... | from sys import exit, stdin
# import copy
# from collections import deque,Counter
# import numpy as np
input = stdin.readline
X, K, D = map(int, input().split())
if abs(X) >= K * D:
print((abs(X) - K * D))
else:
A1 = abs(X) % D
A2 = abs(A1 - D)
n = int((abs(X) - A1)/D)
if (K - n) % 2 == 0:
... | [["+", 0, 1, 0, 652, 3, 4, 0, 23, 0, 24], ["+", 0, 23, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 107 |
X, K, D = map(int, input().split())
X = abs(X)
if X == D:
if K % 2 != 0:
print('0')
else:
print(D)
else:
span = X // D
if span < K:
if (K - span) % 2 == 0:
print(X % D)
else:
print(abs(X % K - K))
else:
print(X - K * D) | X, K, D = map(int, input().split())
X = abs(X)
if X == D:
if K % 2 != 0:
print('0')
else:
print(D)
else:
span = X // D
if span < K:
if (K - span) % 2 == 0:
print(X % D)
else:
print(abs(X % D - D))
else:
print(X - K * D) | [["-", 0, 652, 3, 4, 0, 657, 31, 657, 12, 22], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 12, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 100 |
#include <cmath>
#include <iostream>
int main() {
long long X, K, D;
std::cin >> X >> K >> D;
X = std::abs(X);
if (K * D <= X) {
std::cout << X - K * D << std::endl;
} else {
long long K_ = X / D;
long long X_ = X - K_ * D;
if ((K - K_) % 2 == 0) {
std::cout << X_ << std::endl;
} el... | #include <cmath>
#include <iostream>
int main() {
long long X, K, D;
std::cin >> X >> K >> D;
X = std::abs(X);
if (K <= X / D) {
std::cout << X - K * D << std::endl;
} else {
long long K_ = X / D;
long long X_ = X - K_ * D;
if ((K - K_) % 2 == 0) {
std::cout << X_ << std::endl;
} el... | [["-", 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 | 122 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
long x, k, d;
cin >> x >> k >> d;
long ans;
x = abs(x);
if (x == 0) {
if (k % 2 == 0)
ans = 0;
if (k % 2 == 1)
ans = d;
} else if (x > 0) {
// if (x - k * d >= 0) {
if ((x - ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
long x, k, d;
cin >> x >> k >> d;
long ans;
x = abs(x);
if (x == 0) {
if (k % 2 == 0)
ans = 0;
if (k % 2 == 1)
ans = d;
} else if (x > 0) {
// if (x - k * d >= 0) {
if ((x - ... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 109], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72]] | 1 | 173 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int X;
long long int K;
long long int D;
//入力
cin >> X >> K >> D;
long long int ans;
int mo;
int n;
long long int m;
long long int p;
if (abs(X) / D <= K) {
mo = abs(X) % D;
n = abs(X) / D;
ans = mo;
if ((K - n... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int X;
long long int K;
long long int D;
//入力
cin >> X >> K >> D;
long long int ans;
long long int mo;
long long int n;
long long int m;
long long int p;
if (abs(X) / D <= K) {
mo = abs(X) % D;
n = abs(X) / D;
ans ... | [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 168 |
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from math import gcd
#input=sys.stdin.readline
#import bisect
x,k,d=map(int,input().split())
if x<0 and x+d*k<=0:
print(abs(x+d*k))
elif x>0 and x-d... | #import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from math import gcd
#input=sys.stdin.readline
#import bisect
x,k,d=map(int,input().split())
if x<0 and x+d*k<=0:
print(abs(x+d*k))
elif x>0 and x-d... | [["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25], ["-", 64, 196, 0, 57, 15, 666, 0, 23, 0, 25]] | 5 | 227 |
#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;
} else {
k -= x / d;
if (k % 2 == 1) {
cout << abs(d - x % d) << endl;
} else {
cout << x % d << endl;
}
... | #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;
} else {
k -= x / d;
if (k % 2 == 1) {
cout << abs(d - x % d) << endl;
} else {
cout << x % d << endl;
}
... | [["+", 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 | 102 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int read() {
int x;
scanf("%lld", &x);
return x;
}
const int maxn = 1e6 + 10;
const int INF = 1e9;
int mod = 1e9 + 7;
#define ll long long
main() {
#ifdef LOCAL
freopen("1.in", "r", stdin);
#endif
int x = read(), k = read(), d = read();
in... | #include <bits/stdc++.h>
using namespace std;
#define int long long
int read() {
int x;
scanf("%lld", &x);
return x;
}
const int maxn = 1e6 + 10;
const int INF = 1e9;
int mod = 1e9 + 7;
#define ll long long
main() {
#ifdef LOCAL
freopen("1.in", "r", stdin);
#endif
int x = abs(read()), k = read(), d = read();
... | [["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 183 |
#include <bits/stdc++.h>
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define endl "\n"
#define ll long ... | #include <bits/stdc++.h>
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define endl "\n"
#define ll long ... | [["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46], ["-", 0, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]] | 1 | 529 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 100;
ll ma = 1e18;
void solve() {
ll n, m, k;
cin >> n >> m >> k;
if (n < 0)
n = -n;
ll kk = n / k;
if (kk < m) {
int d = n % k;
m -= kk;
if (m % 2)
cout << k - d << endl;
else
cout << d ... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 100;
ll ma = 1e18;
void solve() {
ll n, m, k;
cin >> n >> m >> k;
if (n < 0)
n = -n;
ll kk = n / k;
if (kk < m) {
ll d = n % k;
ll mm = m - kk;
if (mm % 2)
cout << k - d << endl;
else
cou... | [["-", 8, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 57, 64, 9, 0, 43, 39, 78], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 64, 9, 0... | 1 | 132 |
X, K, D = map(int, input().split())
k = round(X / D)
if k > K:
if k == 1:
print(abs(abs(X) - K * D))
else:
print(min(abs(abs(X) - K * D), abs(abs(X) - (K - 2) * D)))
else:
if k % 2 == K % 2:
print(min(abs(abs(X) - k * D), abs(abs(X) - (k + 2) * D), abs(abs(X) - (k - 2) * D)))
... | X, K, D = map(int, input().split())
k = round(abs(X) / D)
if k > K:
if k == 1:
print(abs(abs(X) - K * D))
else:
print(min(abs(abs(X) - K * D), abs(abs(X) - (K - 2) * D)))
else:
if k % 2 == K % 2:
print(min(abs(abs(X) - k * D), abs(abs(X) - (k + 2) * D), abs(abs(X) - (k - 2) * D)))... | [["+", 12, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 216 |
#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 << endl;
else {
ll n = x / d;
x = x - n * d;
if ((k - n) % 2 == 0)
cout << x << endl;
else
cout << d - x << endl;
}
} | #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 / d > k)
cout << x - k * d << endl;
else {
ll n = x / d;
x = x - n * d;
if ((k - n) % 2 == 0)
cout << x << endl;
else
cout << d - x << endl;
}
} | [["-", 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, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 100 |
a,b,c=map(int,input().split())
a1=(abs(a)-0)%c
if(a==0):
if(b%2==0):
print(0)
else:
print(c)
if(a>0):
a2=a1-c
ma1=int(a/c)
ma2=ma1+1
a3=abs(a2)
if(b>=ma2 and b>ma1):
if((b-ma1)%2==0):
print(a1)
else:
print(abs(a2))
if(b==ma1):
... | a,b,c=map(int,input().split())
a1=(abs(a)-0)%c
if(a==0):
if(b%2==0):
print(0)
else:
print(c)
if(a>0):
a2=a1-c
ma1=int(a/c)
ma2=ma1+1
a3=abs(a2)
if(b>=ma2 and b>ma1):
if((b-ma1)%2==0):
print(a1)
else:
print(abs(a2))
if(b==ma1):
... | [["-", 0, 662, 12, 23, 0, 657, 12, 23, 0, 22], ["+", 0, 662, 12, 23, 0, 657, 12, 23, 0, 22]] | 5 | 265 |
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, x, n) for (int i = x; i < n; i++)
#define breps(i, x, n) for (int i = ... | // #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, x, n) for (int i = x; i < n; i++)
#define breps(i, x, n) for (int i = ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 188 |
import sys
input=lambda: sys.stdin.readline().rstrip()
x,k,d=map(int,input().split())
if k%2==1:
if x>0:
x-=d
else:
x+=d
k-=1
a=x%(2*d)
b=a-2*d
ans=abs(x-k*d)
if abs(x-a)//d<=k:
ans=min(ans,abs(a))
if abs(x-b)//d<=k:
ans=min(ans,abs(b))
print(ans)
| import sys
input=lambda: sys.stdin.readline().rstrip()
x,k,d=map(int,input().split())
if k%2==1:
if x>0:
x-=d
else:
x+=d
k-=1
a=x%(2*d)
b=a-2*d
ans=abs(abs(x)-k*d)
if abs(x-a)//d<=k:
ans=min(ans,abs(a))
if abs(x-b)//d<=k:
ans=min(ans,abs(b))
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]] | 5 | 134 |
#include <bits/stdc++.h>
using namespace std;
long x, k, d;
int main() {
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k)
cout << x - d * k << endl;
else
cout << abs(x % d - (x / d) % 2 == k % 2 ? 0 : d) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
long x, k, d;
int main() {
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k)
cout << x - d * k << endl;
else
cout << abs(x % d - ((x / d) % 2 == k % 2 ? 0 : d)) << endl;
}
| [["+", 0, 41, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25]] | 1 | 80 |
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP2(i, a, b) for (int i = a; i <= b; i++)
#define REPR(i, a, b) for (int i = a; i >= b; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#de... | #include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP2(i, a, b) for (int i = a; i <= b; i++)
#define REPR(i, a, b) for (int i = a; i >= b; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#de... | [["-", 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 | 338 |
X, K, D = map( int, input().split())
Y = X // D
if K <= Y:
print( min( abs( X - K * D ) , abs( X + K * D ) ))
else:
if ( K - Y ) % 2 == 0:
print( min( abs( X - Y * D ) , abs( X + Y * D ),
abs( X - ( Y - 2 ) * D ), abs( X - ( Y + 2 ) * D ),
abs( X + ( Y - 2 ) * D ), abs( X + ( Y... | X, K, D = map( int, input().split())
Y = abs( X ) // D
if K <= Y:
print( min( abs( X - K * D ) , abs( X + K * D ) ))
else:
if ( K - Y ) % 2 == 0:
print( min( abs( X - Y * D ) , abs( X + Y * D ),
abs( X - ( Y - 2 ) * D ), abs( X - ( Y + 2 ) * D ),
abs( X + ( Y - 2 ) * D ), abs( ... | [["+", 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 | 198 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i, l, r) for (i = l; i < r; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define P pair<ll, ll>
#define F first
#define S second
signed main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X > K * D)... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i, l, r) for (i = l; i < r; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define P pair<ll, ll>
#define F first
#define S second
signed main() {
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X / D > K)... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 134 |
#include <bits/stdc++.h>
using namespace std;
// DEFINE and
// TYPEDEF--------------------------------------------------------------
// For actual content check from line 85
#define FORG(i, a, n) \
for (lld i = (lld)a; a < n ? i < (lld)n : (lld)n < i; ... | #include <bits/stdc++.h>
using namespace std;
// DEFINE and
// TYPEDEF--------------------------------------------------------------
// For actual content check from line 85
#define FORG(i, a, n) \
for (lld i = (lld)a; a < n ? i < (lld)n : (lld)n < i; ... | [["+", 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 | 824 |
x, k, d = map(int,input().split())
if x < 0: x = -x
mv = x // d
if mv >= k:
# なるべく0に近づけば良い
print(abs(x)-d*k)
else:
nearest = x % d
if mv % 2 == 1:
print(abs(nearest - d))
else:
print(nearest)
| x, k, d = map(int,input().split())
if x < 0: x = -x
mv = x // d
if mv >= k:
# なるべく0に近づけば良い
print(abs(x)-d*k)
else:
nearest = x % d
if (k - mv) % 2 == 1:
print(abs(nearest - d))
else:
print(nearest)
| [["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 78 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
using ll = long long;
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
ll a = x / d;
ll ans;
if (x >= 0) {
if (a < k) {
ans = x - k * d;
} el... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
using ll = long long;
using namespace std;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
ll a = x / d;
ll ans;
if (x >= 0) {
if (a > k) {
ans = x - k * d;
} el... | [["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 135 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
using namespace std;
int main() {
long long a, b, c, p, q;
cin >> a >> b >> c;
a = abs(a);
if (abs(a / c) > b)
cout << abs(a - (b * c));
else {
if (a < 0)
a = -a;
p = (a % c);
q = abs(p - c);
if (p < q) {
... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
using namespace std;
int main() {
long long a, b, c, p, q;
cin >> a >> b >> c;
a = abs(a);
if (abs(a / c) > b)
cout << abs(a - (b * c));
else {
if (a < 0)
a = -a;
p = (a % c);
q = abs(p - c); // cout<<p<<" "<<q;
... | [["-", 0, 9, 0, 57, 64, 1, 0, 16, 12, 22], ["+", 0, 9, 0, 57, 64, 1, 0, 16, 12, 22], ["-", 0, 57, 75, 76, 0, 1, 0, 16, 12, 22], ["+", 0, 57, 75, 76, 0, 1, 0, 16, 12, 22]] | 1 | 161 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long k = sc.nextLong();
long d = sc.nextLong();
x = Math.abs(x);
long p = x % d;
long q = x / d;
if (q > k) {
System.out.println(x ... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long k = sc.nextLong();
long d = sc.nextLong();
x = Math.abs(x);
long p = x % d;
long q = x / d;
if (q > k) {
System.out.println(x ... | [["-", 0, 57, 15, 15, 0, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 31, 22]] | 3 | 164 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
ll X, K, D;
cin >> X >> K >> D;
ll x = abs(X);
ll a = x / D;
if (K <= a) {
cout << abs(X - K * D) << endl;
} else {
x = x - a * D;
if ((K - a) % 2 == 0) {
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
ll X, K, D;
cin >> X >> K >> D;
ll x = abs(X);
ll a = x / D;
if (K <= a) {
cout << abs(x - K * D) << endl;
} else {
x = x - a * D;
if ((K - a) % 2 == 0) {
... | [["-", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22]] | 1 | 158 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll k, x, d;
cin >> x >> k >> d;
if (x >= 0 && (double)sqrt(x) >= (double)sqrt(k) * (double)sqrt(d))
cout << x - k * d;
else if (x <= 0 && (double)sqrt(k) * (double)sqrt(d) <= sqrt(abs(x)))
cout << x + k * d;
else {
l... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll k, x, d;
cin >> x >> k >> d;
if (x >= 0 && (double)sqrt(x) >= (double)sqrt(k) * (double)sqrt(d))
cout << x - k * d;
else if (x <= 0 && (double)sqrt(k) * (double)sqrt(d) <= sqrt(abs(x)))
cout << abs(x + k * d);
else {
... | [["+", 0, 57, 64, 1, 0, 16, 12, 2, 63, 22], ["+", 64, 1, 0, 16, 12, 2, 3, 4, 0, 24], ["+", 64, 1, 0, 16, 12, 2, 3, 4, 0, 25]] | 1 | 225 |
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def solve():
global x,k,d
i = min(k,abs(x//d))
if abs(x-d*i)<abs(x+d*i):
x -= d*k
else:
x += d*i
k -= i
if k%2==1:
if abs(x-d)<abs(x+d):
print(abs(x-d))
else:
print... | import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def solve():
global x,k,d
i = min(k,abs(x//d))
if abs(x-d*i)<abs(x+d*i):
x -= d*i
else:
x += d*i
k -= i
if k%2==1:
if abs(x-d)<abs(x+d):
print(abs(x-d))
else:
print... | [["-", 64, 196, 0, 1, 0, 677, 12, 657, 12, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12, 22]] | 5 | 157 |
#include <stdio.h>
int main() {
long long x, k, d;
scanf("%lld %lld %lld", &x, &k, &d);
if (x < 0) {
x = -x;
}
long long a = x - (d * (x / d));
k = k - (x / d);
if (k <= 0) {
printf("%lld", x - k * d);
return 0;
}
if (k % 2 == 0) {
printf("%lld", a);
return 0;
}
printf("... | #include <stdio.h>
int main() {
long long x, k, d;
scanf("%lld %lld %lld", &x, &k, &d);
if (x < 0) {
x = -x;
}
long long a = x - (d * (x / d));
long long l = k - (x / d);
if (l <= 0) {
printf("%lld", x - k * d);
return 0;
}
if (l % 2 == 0) {
printf("%lld", a);
return 0;
}
... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["-", 0, 57, 15, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 31, 22]] | 0 | 131 |
function Main(input) {
const row = input.split(" ");
const X = parseInt(row[0], 10);
const K = parseInt(row[1], 10);
const D = parseInt(row[2], 10);
const even = num => num % 2 === 0;
const av_x = X < 0 ? X * -1 : X;
if (av_x > K * D) {
console.log(av_x - K * D);
} else {
for (let i = 1; i <= K... | function Main(input) {
const row = input.split(" ");
const X = parseInt(row[0], 10);
const K = parseInt(row[1], 10);
const D = parseInt(row[2], 10);
const even = num => num % 2 === 0;
const av_x = X < 0 ? X * -1 : X;
if (av_x >= K * D) {
console.log(av_x - K * D);
} else {
for (let i = 1; i <= ... | [["-", 8, 556, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 556, 0, 57, 15, 23, 0, 16, 17, 20], ["-", 8, 556, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 8, 556, 0, 57, 15, 23, 0, 16, 17, 19], ["+", 15, 23, 0, 2, 3, 3, 0, 16, 31, 22], ["+", 15, 23, 0, 2, 3, 3, 0, 16, 17, 33]] | 2 | 195 |
X, K, D = map(int, input().split())
if abs(X) >= K * D:
print(abs(X) - (K * D))
else:
k = abs(X) // D
Y = abs(X) % D
if K - k % 2 == 0:
print(Y)
else:
print(abs(Y - D))
| X, K, D = map(int, input().split())
if abs(X) >= K * D:
print(abs(X) - (K * D))
else:
k = abs(X) // D
Y = abs(X) % D
if (K - k) % 2 == 0:
print(Y)
else:
print(abs(Y - D))
| [["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 83 |
x,k,d=map(int,input().split())
ans=0
if x>k*d:
ans=(x-k*d)
else:
temp=k-(x//d)
if temp %2==0:
ans=x%d
else:
ans=d-x%d
print(ans)
| x,k,d=map(int,input().split())
ans=0
if abs(x)>k*d:
ans=(abs(x)-k*d)
else:
temp=k-(x//d)
if temp %2==0:
ans=x%d
else:
ans=d-x%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], ["+", 64, 196, 0, 1, 0, 662, 12, 23, 0, 24], ["+", 0, 662, 12, 23, 0, 657, 31, 652, 63, 22], ["+", 12, 23, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 73 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if ((x - k * d) >= 0)
cout << x - k * d << endl;
else {
long long m = x % d, n = k - x / d;
if (n % 2 == 0)
cout << m << endl;
else
cout << d - m << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k)
cout << x - k * d << endl;
else {
long long m = x % d, n = k - x / d;
if (n % 2 == 0)
cout << m << endl;
else
cout << d - m << endl;
}
} | [["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["-", 15, 339, 51, 16, 31, 23, 0, 16, 17, 33], ["-", 51, 16, 31, 23, 0, 16, 12, 16, 31, 22], ["-", 51, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 1... | 1 | 99 |
/*
Jai Shree Krishna !!
Radhe Radhe !!
उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति
मृगाः।।
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define loop(i, n) ... | /*
Jai Shree Krishna !!
Radhe Radhe !!
उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति
मृगाः।।
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define loop(i, n) ... | [["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 270 |
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ll long long int
#define mkp make_pair
#define mod 1000000007
#define maxn 100001
#define ff first
#define ss second
using namespace std;
int32_t main() {
int x, k, d;
cin >> x >> k >> d;
if (x < 0)
x *= -1;
int mn = x / d;
if (k <= mn) {
x... | #include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ll long long int
#define mkp make_pair
#define mod 1000000007
#define maxn 100001
#define ff first
#define ss second
using namespace std;
int32_t main() {
ll x, k, d;
cin >> x >> k >> d;
if (x < 0)
x *= -1;
ll mn = x / d;
if (k <= mn) {
x -... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 139 |
#include <bits/stdc++.h>
#define int long long
using namespace std;
int Size = 1e14;
int check(int a, int b, int c) {
if (a + b > c)
return 1;
else
return 0;
}
int32_t main() {
int x, k, d;
cin >> x >> k >> d;
x = abs(x);
int can = x / d;
// cout<<can<<endl;
int left = 0;
int update = ... | #include <bits/stdc++.h>
#define int long long
using namespace std;
int Size = 1e14;
int check(int a, int b, int c) {
if (a + b > c)
return 1;
else
return 0;
}
int32_t main() {
int x, k, d;
cin >> x >> k >> d;
x = abs(x);
int can = x / d;
// cout<<can<<endl;
int left = 0;
int update = ... | [["-", 0, 43, 49, 50, 51, 23, 0, 16, 31, 22], ["-", 0, 43, 49, 50, 51, 23, 0, 16, 17, 33], ["+", 0, 43, 49, 50, 51, 23, 0, 16, 17, 33], ["+", 0, 43, 49, 50, 51, 23, 0, 16, 12, 22]] | 1 | 177 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int x, d, k;
cin >> x >> k >> d;
x = abs(x);
long long int steps = k - min(k, x / d);
x -= min(k * d, (x / d) * d);
k = steps;
if (k % 2 == 0)
cout << abs(x) << endl;
else
cout << abs(x - d) << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int x, d, k;
cin >> x >> k >> d;
x = abs(x);
long long int steps = k - min(k, x / d);
x -= (min(k, (x / d)) * d);
k = steps;
if (k % 2 == 0)
cout << abs(x) << endl;
else
cout << abs(x - d) << endl;
}
| [["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 24], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 48], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 16, 31, 2, 3, 4, 0, 23, 0, 25]] | 1 | 102 |
X,K,D=map(int,input().split())
Y=X%D
if abs(X)-K*D>0:
ans=abs(X)-K*D
else:
Z=(K-abs(X)//D)%2
if Z==0:
ans=Y
else:
ans=Y-D
print(abs(ans)) | X,K,D=map(int,input().split())
Y=X%D
if abs(X)-K*D>0:
ans=abs(X)-K*D
else:
Z=(K-abs(Y-X)//D)%2
if Z==0:
ans=Y
else:
ans=Y-D
print(abs(ans)) | [["+", 12, 657, 31, 652, 3, 4, 0, 657, 31, 22], ["+", 12, 657, 31, 652, 3, 4, 0, 657, 17, 33]] | 5 | 83 |
// C - Waking Takahashi
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll absx = abs(x);
ll rep = absx / d;
if (rep >= k) {
cout << absx - (k * d) << endl;
return 0;
}
absx -= absx - ... | // C - Waking Takahashi
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
ll x, k, d;
cin >> x >> k >> d;
ll absx = abs(x);
ll rep = absx / d;
if (rep >= k) {
cout << absx - (k * d) << endl;
return 0;
}
absx -= (d * re... | [["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]] | 1 | 123 |
import itertools
X, K, D = list(map(int, input().split()))
l = 0
r = K
min_distance = float('inf')
diff_set = set()
while (l <= r):
n = (r + l) // 2
diff = (2 * n - K) * D + X
if min_distance == float('inf'):
min_distance = abs(diff)
if abs(diff) < min_distance :
min_distance = abs(di... | import itertools
X, K, D = list(map(int, input().split()))
l = 0
r = K
min_distance = float('inf')
diff_set = set()
while (l <= r):
n = (r + l) // 2
diff = (2 * n - K) * D + X
if min_distance == float('inf'):
min_distance = abs(diff)
if abs(diff) < min_distance :
min_distance = abs(di... | [["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 132 |
#include <cmath>
#include <iostream>
using namespace std;
int main() {
long long k, x, d;
cin >> x >> k >> d;
if (x > 0) {
if (x / d >= k) {
cout << x - k * d << endl;
} else {
long long ans = x - x / d * d;
long long ans1 = x - x / d * d - d;
if ((k - x / d) % 2 == 1) {
co... | #include <cmath>
#include <iostream>
using namespace std;
int main() {
long long k, x, d;
cin >> x >> k >> d;
if (x > 0) {
if (x / d >= k) {
cout << abs(x - k * d) << endl;
} else {
long long ans = x - x / d * d;
long long ans1 = x - x / d * d - d;
if ((k - x / d) % 2 == 1) {
... | [["+", 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 | 220 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, a, b, c, d, e, f, g, h, p, q, r, fr, sc, tr, sz, tz, i, j, k,
mx = LLONG_MIN, mn = LLONG_MAX;
long long x, y = 0, cnt = 0, res = 0, ttl = 0, ans = 0, sum = 0;
long long flg = 0, flag = 1, na = 0, as = 1;
vector<long long> u, v, w... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, a, b, c, d, e, f, g, h, p, q, r, fr, sc, tr, sz, tz, i, j, k,
mx = LLONG_MIN, mn = LLONG_MAX;
long long x, y = 0, cnt = 0, res = 0, ttl = 0, ans = 0, sum = 0;
long long flg = 0, flag = 1, na = 0, as = 1;
vector<long long> u, v, w... | [["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22]] | 1 | 266 |
X, K, D = map(int, input().split())
k = abs(int(X / D))
k = min(k, K)
if X > 0:
x = X - k * D
else:
x = X + k * D
diff = K - k
if diff % 2 == 0:
print(x)
else:
x_plus = x + D
x_minus = x - D
print(min(abs(x_plus), abs(x_minus))) | X, K, D = map(int, input().split())
k = abs(int(X / D))
k = min(k, K)
if X > 0:
x = X - k * D
else:
x = X + k * D
diff = K - k
if diff % 2 == 0:
print(abs(x))
else:
x_plus = x + D
x_minus = x - D
print(min(abs(x_plus), abs(x_minus))) | [["+", 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 | 101 |
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
signed main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
__int128_t _x = x, _k = k, _d = d;
if (_x > _k * _d) {
cout << x - k * d << endl;
} else {
k -= x / d;
x -= x / d * d;
cout << (k & 1 ? abs(x - d) : d) << endl;
... | #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
signed main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
__int128_t _x = x, _k = k, _d = d;
if (_x > _k * _d) {
cout << x - k * d << endl;
} else {
k -= x / d;
x -= x / d * d;
cout << (k & 1 ? abs(x - d) : x) << endl;
... | [["-", 0, 16, 31, 16, 12, 23, 0, 41, 75, 22], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 75, 22]] | 1 | 108 |
#if loc || local
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = int_fast64_t;
using pll = pair<ll, ll>;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
... | #if loc || local
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = int_fast64_t;
using pll = pair<ll, ll>;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22]] | 1 | 589 |
// header files
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char const *argv[]) {
long long x, k, d, pos, sto0;
long long final, final1, winner;
cin >> x >> k >> d;
if (k * d <= abs(x))
cout << abs(x) - (k * d);
else {
sto0 ... | // header files
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char const *argv[]) {
long long x, k, d, pos, sto0;
long long final, final1, winner;
cin >> x >> k >> d;
if (k <= abs(x) / d)
cout << abs(x) - (k * d);
else {
sto0 ... | [["-", 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 | 176 |
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
a=x//d
b=x-a*d
c=(x-b)/d
i=int(c)
if k<=i:
print(abs(x)-d*k)
else:
if (k-(i))%2==0:
print(abs(x)-d*(i))
else:
print(abs(abs(x)-d*(i+1))) | x,k,d=input().split()
x=abs(int(x))
k=int(k)
d=int(d)
a=x//d
b=x-a*d
c=(x-b)/d
i=int(c)
if k<=i:
print(abs(x)-d*k)
else:
if (k-(i))%2==0:
print(abs(x)-d*(i))
else:
print(abs(abs(x)-d*(i+1))) | [["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 122 |
X, K, D = map(int, input().split())
import numpy as np
res = 0
count = abs(X) // D
pseudo = np.sign(X) * (abs(X) - count * D)
if abs(X) >= K * D:
res = abs(X - K * D)
elif (K-count) % 2 == 0:
res = abs(pseudo)
else:
res = min(abs(pseudo + D), abs(pseudo - D))
print(res) | X, K, D = map(int, input().split())
import numpy as np
res = 0
count = abs(X) // D
pseudo = np.sign(X) * (abs(X) - count * D)
if abs(X) >= K * D:
res = abs(abs(X) - K * D)
elif (K-count) % 2 == 0:
res = abs(pseudo)
else:
res = min(abs(pseudo + D), abs(pseudo - D))
print(res) | [["+", 12, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 113 |
x,k,d=map(int,input().split())
def sign(x):
if x> 0:return 1
elif x<0 :return -1
return 0
if x>0:
x_distance = x - k*d
else:
x_distance = x + k*d
if sign(x)==sign(x_distance):
print(x_distance)
exit()
x_r= x_distance % d
x_l=x_r -d
kairi=(abs(x-x_r)//d) %2
if k%2==kairi:
print(abs(x_... | x,k,d=map(int,input().split())
def sign(x):
if x> 0:return 1
elif x<0 :return -1
return 0
if x>0:
x_distance = x - k*d
else:
x_distance = x + k*d
if sign(x)==sign(x_distance):
print(abs(x_distance))
exit()
x_r= x_distance % d
x_l=x_r -d
kairi=(abs(x-x_r)//d) %2
if k%2==kairi:
print(a... | [["+", 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 | 127 |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int x, k, d, mini, p, l, no;
cin >> x >> k >> d;
p = (long long int)abs((long double)x);
if (p >= k * d) {
mini = p - k * d;
} else {
l = p % d;
no = p /... | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int x, k, d, mini, p, l, no;
cin >> x >> k >> d;
p = (long long int)abs((long double)x);
if (p / d >= k) {
mini = p - k * d;
} else {
l = p % d;
no = p /... | [["+", 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 | 148 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef ... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 16, 31, 16, 12, 16, 12, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 16, 12, 16, 31, 22], ["-", 0, 16, 31, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 31, 22]] | 1 | 197 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long k = sc.nextLong();
long d = sc.nextLong();
long X = Math.abs(x);
if (X / d >= k) {
System.out.print(X - k * d);
} else {
long near... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long k = sc.nextLong();
long d = sc.nextLong();
long X = Math.abs(x);
if (X / d >= k) {
System.out.print(X - k * d);
} else {
long near... | [["-", 3, 4, 0, 16, 12, 16, 31, 23, 0, 24], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 12, 499], ["-", 3, 4, 0, 16, 12, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 3, 4, 0, 492, 3, 4, 0, 16, 17, 33]] | 3 | 162 |
a=list(map(int,input().split()))
if a[0]<0:
a[0]=-a[0]
x=a[0]%a[2]
y=a[0]/a[2]
if y>=a[1]:
print(a[0]-a[1]*a[2])
elif (a[1]-y)%2==1:
print(a[2]-x)
else:
print(x) | a=list(map(int,input().split()))
if a[0]<0:
a[0]=-a[0]
x=a[0]%a[2]
y=a[0]//a[2]
if y>=a[1]:
print(a[0]-a[1]*a[2])
elif (a[1]-y)%2==1:
print(a[2]-x)
else:
print(x) | [["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676]] | 5 | 111 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.