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> using namespace std; #define ll long long #define ld long double #define pb push_back #define lb lower_bound #define ub upper_bound #define endl '\n' #define mod 1000000007 #define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower) #define tou(s) transform(s.begin(), s.end(), s.begin(),...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define lb lower_bound #define ub upper_bound #define endl '\n' #define mod 1000000007 #define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower) #define tou(s) transform(s.begin(), s.end(), s.begin(),...
[["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
341
N = int(input()) L = list(map(int, input().split())) L.sort() cnt = 0 print(L) for i in range(len(L)): for j in range(i+1,len(L)): for k in range(j+1,len(L)): if L[k] < (L[j] + L[i]) and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]: cnt = cnt + 1 print(cnt)
N = int(input()) L = list(map(int, input().split())) L.sort() cnt = 0 for i in range(len(L)): for j in range(i+1,len(L)): for k in range(j+1,len(L)): if L[k] < (L[j] + L[i]) and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]: cnt = cnt + 1 print(cnt)
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
135
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; //...
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; //...
[["+", 64, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
559
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define mp make_pair #define pb push_back #define yes "YES" #define no "NO" #define F first #define S second #define sorta(a) sort(a.begin(), a.end()) #define all(a) (a.begin(), a.end()) #define forn(i, a, b) for (i = a; i < b; i+...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define mp make_pair #define pb push_back #define yes "YES" #define no "NO" #define F first #define S second #define sorta(a) sort(a.begin(), a.end()) #define all(a) (a.begin(), a.end()) #define forn(i, a, b) for (i = a; i < b; i+...
[["+", 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], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
479
#include <bits/stdc++.h> #define pb push_back #define ll int #define mp make_pair #define int long long #define ff first #define ss second const int p = 1e9 + 7; const int mod = 1e9 + 7; const int Mod = 1e9 + 7; const int INF = 1e9 + 7; const int Maxn = 1000000; using namespace std; void solve() { int n; cin >> n;...
#include <bits/stdc++.h> #define pb push_back #define ll int #define mp make_pair #define int long long #define ff first #define ss second const int p = 1e9 + 7; const int mod = 1e9 + 7; const int Mod = 1e9 + 7; const int INF = 1e9 + 7; const int Maxn = 1000000; using namespace std; void solve() { int n; cin >> n;...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
264
#include <algorithm> #include <cstdio> using namespace std; int n, cnt; int l[102]; bool triangle(int i, int j, int k) { if (l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) return false; return l[i] + l[j] > l[k]; } int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d", l + i); sort(l, l ...
#include <algorithm> #include <cstdio> using namespace std; int n, cnt; int l[102]; bool triangle(int i, int j, int k) { if (l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) return false; return l[i] + l[j] > l[k]; } int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d", l + i); sort(l, l ...
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 8, 9, 0, 57, 75, 76, 0, 93, 0, 94], ["-", 8, 9, 0, 57, 75, 76, 0, 93, 0, 35]]
1
220
#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...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79]]
1
282
N = int(input()) L = list(map(int, input().split())) cnt = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): a = L[i] b = L[j] c = L[k] if a == b or b == c or c == a: continue if a + b < c or b + c < a or c + a < b: continue cnt += 1 prin...
N = int(input()) L = list(map(int, input().split())) cnt = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): a = L[i] b = L[j] c = L[k] if a == b or b == c or c == a: continue if a + b <= c or b + c <= a or c + a <= b: continue cnt += 1 p...
[["-", 0, 57, 15, 679, 31, 679, 31, 666, 667, 18], ["+", 0, 57, 15, 679, 31, 679, 31, 666, 667, 19], ["-", 0, 57, 15, 679, 31, 679, 12, 666, 667, 18], ["+", 0, 57, 15, 679, 31, 679, 12, 666, 667, 19], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 18], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 19]]
5
119
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
474
vn = int(input()) ll = list(map(int, input().split())) cnt = 0 for i in range(n): for j in range(i+1,n): for k in range(j+1,n): a,b,c = ll[i], ll[j], ll[k] if a == b or b == c or c == a: continue vs = [a,b,c] vs.sort() if vs[0] + vs...
n = int(input()) ll = list(map(int, input().split())) cnt = 0 for i in range(n): for j in range(i+1,n): for k in range(j+1,n): a,b,c = ll[i], ll[j], ll[k] if a == b or b == c or c == a: continue vs = [a,b,c] vs.sort() if vs[0] + vs[...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22]]
5
132
n = int(input()) ans = 0 lis = list(map(int,input().split())) for i in range(n): for j in range(n): for k in range(n): if i != j and j != k and i != k: if lis[i] != lis[j] and lis[j] != lis[k] and lis[i] != lis[k]: if max(lis[i],lis[j],lis[k]) < lis[i]+lis[j]+lis[k]-max(lis[i],lis[j],lis[k...
n = int(input()) ans = 0 lis = list(map(int,input().split())) for i in range(n): for j in range(i,n): for k in range(j,n): if i != j and j != k and i != k: if lis[i] != lis[j] and lis[j] != lis[k] and lis[i] != lis[k]: if max(lis[i],lis[j],lis[k]) < lis[i]+lis[j]+lis[k]-max(lis[i],lis[j],l...
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21]]
5
155
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // #define debug(a) cout << "["; rep(i,a.size()) cout ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // #define debug(a) cout << "["; rep(i,a.size()) cout ...
[["+", 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
197
#include <bits/stdc++.h> #define ll long long #define PI acos(-1) using namespace std; const ll N = 1e5 + 100; const ll MOD = 1e9 + 7; ll n, m, T; ll X, K, D; int main() { /*scanf("%d",&T); while(T--) { } */ cin >> X >> K >> D; if (X > D && K) { ll M = X / D; if (M <= K) { X = X % D; ...
#include <bits/stdc++.h> #define ll long long #define PI acos(-1) using namespace std; const ll N = 1e5 + 100; const ll MOD = 1e9 + 7; ll n, m, T; ll X, K, D; int main() { /*scanf("%d",&T); while(T--) { } */ cin >> X >> K >> D; if (X > D && K) { ll M = X / D; if (M <= K) { X = X % D; ...
[["+", 64, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
1
200
x,k,d=map(int, input().split()) if abs(x)//d>=k: #print("ひ") print(abs(x-d*k)) elif (k-abs(x)//d)%2==0: #print("fu") print(abs(x)%d) else: #print("mi") print(d-abs(x)%d)
x,k,d=map(int, input().split()) if abs(x)//d>=k: #print("ひ") print(abs(x)-d*k) elif (k-abs(x)//d)%2==0: #print("fu") print(abs(x)%d) else: #print("mi") print(d-abs(x)%d)
[["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
80
#include <bits/stdc++.h> using namespace std; #define int long long main() { int x, k, d, val; cin >> x >> k >> d; if (x == 0) { if (k % 2) cout << d; else cout << x; } else if (x > 0) { if (k > (x + d - 1) / d) { val = x - ((x + d - 1) / d) * d; k -= (x + d - 1) / d; ...
#include <bits/stdc++.h> using namespace std; #define int long long main() { int x, k, d, val; cin >> x >> k >> d; if (x == 0) { if (k % 2) cout << d; else cout << x; } else if (x > 0) { if (k > (x + d - 1) / d) { val = x - ((x + d - 1) / d) * d; k -= (x + d - 1) / d; ...
[["-", 0, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 17, 48]]
1
241
x ,K, D = map(int, input().split()) if abs(x) >= K * D: print(abs(x) - K * D) else: n = abs(x) // D x = abs(x) - D * n x = x if K - n % 2 == 0 else abs(x - D) print(x)
x ,K, D = map(int, input().split()) if abs(x) >= K * D: print(abs(x) - K * D) else: n = abs(x) // D x = abs(x) - D * n x = x if (K - n) % 2 == 0 else abs(x - D) print(x)
[["+", 12, 41, 0, 666, 0, 657, 31, 23, 0, 24], ["+", 12, 41, 0, 666, 0, 657, 31, 23, 0, 25]]
5
81
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define pii pair<int, int> #define que pair<pii, pii> int X, K, D; signed main() { cin >> X >> K >> D; if (X < 0) X *= -1; if (X - K * D >= 0) { cout << X - K * D << endl; return 0; ...
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define pii pair<int, int> #define que pair<pii, pii> int X, K, D; signed main() { cin >> X >> K >> D; if (X < 0) X *= -1; if (X / D > K) { cout << X - K * D << endl; return 0; } ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17,...
1
126
#include <iostream> using namespace std; typedef long long ll; int main(void) { ll X, K, D; cin >> X >> K >> D; ll ans = 0; if (X == 0) { if (K % 2 == 0) { ans = 0; } else { ans = D; } } else { ll m = 1; if (X < 0) { m = -1; } ll n = X / D; if (n >= K) { ...
#include <iostream> using namespace std; typedef long long ll; int main(void) { ll X, K, D; cin >> X >> K >> D; ll ans = 0; if (X == 0) { if (K % 2 == 0) { ans = 0; } else { ans = D; } } else { ll m = 1; if (X < 0) { m = -1; } ll n = abs(X) / D; if (n >= ...
[["+", 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
221
#include <iostream> using namespace std; typedef long long ll; int main(void) { ll X, K, D; cin >> X >> K >> D; ll ans = 0; if (X == 0) { if (K % 2 == 0) { ans = 0; } else { ans = D; } } else if (X > 0) { ll n = X / D; if (n >= K) { ans = X - K * D; } else { ...
#include <iostream> using namespace std; typedef long long ll; int main(void) { ll X, K, D; cin >> X >> K >> D; ll ans = 0; if (X == 0) { if (K % 2 == 0) { ans = 0; } else { ans = D; } } else if (X > 0) { ll n = X / D; if (n >= K) { ans = X - K * D; } else { ...
[["+", 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
311
def main(): x,k,d = map(int,input().split(" ")) if abs(x) % d == 0: exceed_num = (abs(x) // d) else: exceed_num = (abs(x) // d) + 1 if k <= exceed_num : print(abs( abs(x) - (d*k) )) else: if (k - exceed_num) % 2 == 0: print(abs( abs(x) - (d*k) )) ...
def main(): x,k,d = map(int,input().split(" ")) if abs(x) % d == 0: exceed_num = (abs(x) // d) else: exceed_num = (abs(x) // d) + 1 if k <= exceed_num : print(abs( abs(x) - (d*k) )) else: if (k - exceed_num) % 2 == 0: print(abs( abs(x) - (d*exceed_num) ...
[["-", 3, 4, 0, 657, 12, 23, 0, 657, 12, 22], ["+", 3, 4, 0, 657, 12, 23, 0, 657, 12, 22]]
5
142
#include <bits/stdc++.h> #define rep(i, n) for (ll 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); if (x >= k * d) { cout << x - k * d << endl; return 0; } if ((k - x / d) % 2 == 0) cout << x % d ...
#include <bits/stdc++.h> #define rep(i, n) for (ll 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); if (x / d >= k) { cout << x - k * d << endl; return 0; } if ((k - (x / d)) % 2 == 0) cout << 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], ["+", 31, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 31, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
117
X, K, D = map(int, input().split()) N = X // D if K < abs(N): ans = abs(X - K * D) else: if (K - abs(N)) % 2 == 0: ans = abs(X - N * D) else: ans = abs(X - (N+1) * D) print(ans)
X, K, D = map(int, input().split()) N = X // D if K < abs(N): ans = abs(abs(X) - K * D) else: if (K - abs(N)) % 2 == 0: ans = abs(X - N * D) else: ans = abs(X - (N+1) * D) 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
87
X, K, D = map(int, input().split()) X = abs(X) div, mod = divmod(X, D) if X > D * div: ans = X - D * div elif (K - div) % 2 == 0: ans = mod else: ans = D - mod print(ans)
X, K, D = map(int, input().split()) X = abs(X) div, mod = divmod(X, D) if X > D * K: ans = X - D * K elif (K - div) % 2 == 0: ans = mod else: ans = D - mod print(ans)
[["-", 0, 656, 0, 57, 15, 666, 0, 657, 12, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 12, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 12, 22]]
5
73
#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 N = X / D; // count ll d = X % D; // distance ll ans; if (X - K * D >= 0) { ans = X - K * D; } else if (K % 2 == 0) { if (N % 2 == 0) { ans = d; } else { ...
#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 N = X / D; // count ll d = X % D; // distance ll ans; if (N >= K) { ans = X - K * D; } else if (K % 2 == 0) { if (N % 2 == 0) { ans = d; } else { ans =...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 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], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, ...
1
144
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using ll = long long; const long long INF = 1LL << 60; const int MOD = 1e9 + 7; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; r...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using ll = long long; const long long INF = 1LL << 60; const int MOD = 1e9 + 7; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; r...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17,...
1
216
import sys # x = abs(int(input())) # k = int(input()) # d = int(input()) array = list(map(int, input().strip().split())) x = array[0] k = array[1] d = array[2] if (d == 0): amari = abs(x) else: move_cnt = int(x / d) if (move_cnt <= k): k -= move_cnt amari = x - move_cnt * d else: ...
import sys # x = abs(int(input())) # k = int(input()) # d = int(input()) array = list(map(int, input().strip().split())) x = abs(array[0]) k = array[1] d = array[2] if (d == 0): amari = abs(x) else: move_cnt = int(x / d) if (move_cnt <= k): k -= move_cnt amari = x - move_cnt * d else...
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
134
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll x, k, d; cin >> x >> k >> d; x = x > 0 ? x : -x; ll temp = min(k, x / d); k -= temp; x -= temp * d; if (k > 0 && k % 2 == 0) { x -= d; } cout << abs(x); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll x, k, d; cin >> x >> k >> d; x = x > 0 ? x : -x; ll temp = min(k, x / d); k -= temp; x -= temp * d; if (k > 0 && k % 2 == 1) { x -= d; } cout << abs(x); return 0; }
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
93
#include <iostream> using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; long long S = abs(X) / D; if (S >= K) { cout << X + ((X > 0) ? -1 : 1) * D * K << endl; } else { if (X > 0) { X -= D * S; K -= S; cout << abs(X - ((K % 2) ? D : 0)) << endl; } else { ...
#include <iostream> using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; long long S = abs(X) / D; if (S >= K) { cout << abs(X + ((X > 0) ? -1 : 1) * D * K) << endl; } else { if (X > 0) { X -= D * S; K -= S; cout << abs(X - ((K % 2) ? D : 0)) << endl; } else ...
[["+", 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
145
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } #define all(x) (x).beg...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } #define all(x) (x).beg...
[["+", 0, 16, 31, 16, 12, 16, 12, 2, 63, 22], ["+", 31, 16, 12, 16, 12, 2, 3, 4, 0, 24], ["+", 31, 16, 12, 16, 12, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
14,869
#include <iostream> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; x = abs(x); if (k * d <= x) { cout << x - k * d << endl; return 0; } k = (k - x / d) % 2; x %= d; for (int i = 0; i < k; ++i) x = abs(x - d); cout << x << endl; }
#include <iostream> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; x = abs(x); if (k <= x / d) { cout << x - k * d << endl; return 0; } k = (k - x / d) % 2; x %= d; for (int i = 0; i < k; ++i) x = abs(x - d); cout << x << endl; }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
103
#include <bits/stdc++.h> using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; bool a = false; if (X > 0) { long long A = X / D; if (K < A) { X -= K * D; cout << abs(X) << endl; a = true; } X -= A * D; K -= A; if (abs(X - D) < abs(X) && K > 0) { ...
#include <bits/stdc++.h> using namespace std; int main() { long long X, K, D; cin >> X >> K >> D; bool a = false; if (X > 0) { long long A = X / D; if (K < A) { X -= K * D; cout << abs(X) << endl; a = true; } X -= A * D; K -= A; if (abs(X - D) < abs(X) && K > 0) { ...
[["+", 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
264
x,k,d=(int(x) for x in input().split()) mincount = x // d if mincount < k: k = (k-mincount)%2 result = x - d*mincount -d*k else: result = x - k*d print(abs(result))
x,k,d=(int(x) for x in input().split()) x = abs(x) mincount = x // d if mincount < k: k = (k-mincount)%2 result = x - d*mincount -d*k else: result = x - k*d print(abs(result))
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
68
#include <bits/stdc++.h> using namespace std; #define ll long long const int M = 1000000007; ll mod(ll x) { return ((x % M + M) % M); } ll add(ll a, ll b) { return mod(mod(a) + mod(b)); } ll mul(ll a, ll b) { return mod(mod(a) * mod(b)); } ll minu(ll a, ll b) { return mod(mod(a) - mod(b)); } ll power(ll a, ll b) { ll...
#include <bits/stdc++.h> using namespace std; #define ll long long const int M = 1000000007; ll mod(ll x) { return ((x % M + M) % M); } ll add(ll a, ll b) { return mod(mod(a) + mod(b)); } ll mul(ll a, ll b) { return mod(mod(a) * mod(b)); } ll minu(ll a, ll b) { return mod(mod(a) - mod(b)); } ll power(ll a, ll b) { ll...
[["+", 75, 76, 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
242
#include <bits/stdc++.h> #define ABS(x) ((x) > 0 ? (x) : -(x)) using namespace std; const int ARR_SIZE = 1e2 + 5; // int arr[ARR_SIZE]; int main() { long long x, k, d; scanf("%lld%lld%lld", &x, &k, &d); long long maxMove = ABS(x) / d; if (maxMove >= k) { if (x > 0) printf("%lld\n", x - k * d); ...
#include <bits/stdc++.h> #define ABS(x) ((x) > 0 ? (x) : -(x)) using namespace std; const int ARR_SIZE = 1e2 + 5; // int arr[ARR_SIZE]; int main() { long long x, k, d; scanf("%lld%lld%lld", &x, &k, &d); long long maxMove = ABS(x) / d; if (maxMove >= k) { if (x > 0) printf("%lld\n", x - k * d); ...
[["+", 0, 2, 3, 4, 0, 16, 31, 91, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33]]
1
198
x,k,d = input().split() x = int(x) k = int(k) d = int(d) ans = 0 if abs(x) >= abs(k*d): ans = abs(x) - abs(k*d) else: kaisuu = abs(x)/d k_2 = k - kaisuu if k_2/2 == 0: ans = abs(x) - d*kaisuu else: ans = abs((abs(x) - d*kaisuu) - abs(d)) print(int(ans))
x,k,d = input().split() x = int(x) k = int(k) d = int(d) ans = 0 if abs(x) >= abs(k*d): ans = abs(x) - abs(k*d) else: kaisuu = int(abs(x)/d) k_2 = k - kaisuu if k_2%2 == 0: ans = abs(x) - d*kaisuu else: ans = abs((abs(x) - d*kaisuu) - abs(d)) print(int(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], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 85], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 109]]
5
121
import java.util.Scanner; public class Main { public static void main(String[] args) { long X, K, D; Scanner sc = new Scanner(System.in); X = sc.nextLong(); K = sc.nextLong(); D = sc.nextLong(); long Xa = Math.abs(X); long ans = 0; long n = Xa / D; if (n >= K) { ans = X...
import java.util.Scanner; public class Main { public static void main(String[] args) { long X, K, D; Scanner sc = new Scanner(System.in); X = sc.nextLong(); K = sc.nextLong(); D = sc.nextLong(); long Xa = Math.abs(X); long ans = 0; long n = Xa / D; if (n >= K) { ans = X...
[["+", 15, 15, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 15, 15, 0, 16, 31, 16, 31, 23, 0, 25]]
3
154
import sys X, K, D = map(int, input().split()) if X // D >= K: print(X - K*D) sys.exit() K = K - (X // D) A = X - X//D*D if K % 2 == 0: print(A) else: print(abs(A - D))
import sys X, K, D = map(int, input().split()) X = abs(X) if X // D >= K: print(X - K*D) sys.exit() K = K - (X // D) A = X - X//D*D if K % 2 == 0: print(A) else: print(abs(A - 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
80
x, k, d = map(int, input().split()) if x < 0: if x + k * d < 0: print(x + k * d) else: a = -x // d x += a * d if (k - a) % 2 == 0: print(-x) else: print(x + d) else: if x - k * d > 0: print(x - k * d) else: a =...
x, k, d = map(int, input().split()) if x < 0: if x + k * d < 0: print(-x - k * d) else: a = -x // d x += a * d if (k - a) % 2 == 0: print(-x) else: print(x + d) else: if x - k * d > 0: print(x - k * d) else: a ...
[["+", 0, 652, 3, 4, 0, 657, 31, 664, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33]]
5
131
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vint; typedef vector<vector<ll>> vvint; #define rep(i, n) for (ll i = 0; i < n; i++) #define repf(i, f, n) for (ll i = f; i < n; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define mp make_pair #define mt make_tuple #de...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vint; typedef vector<vector<ll>> vvint; #define rep(i, n) for (ll i = 0; i < n; i++) #define repf(i, f, n) for (ll i = f; i < n; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define mp make_pair #define mt make_tuple #de...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
311
#include <algorithm> #include <iostream> using namespace std; using ll = long long; int main() { ll X, K, D; cin >> X >> K >> D; X = abs(X); ll straight = min(K, X / D); K -= straight; X -= straight * D; if ((K - min(K, X / D)) % 2 == 0) { cout << X - X / D * D << endl; } else { cout << D - (...
#include <algorithm> #include <iostream> using namespace std; using ll = long long; int main() { ll X, K, D; cin >> X >> K >> D; X = abs(X); ll straight = min(K, X / D); K -= straight; X -= straight * D; if ((K - min(K, X / D)) % 2 == 0) { cout << X - min(X / D, K) * D << endl; } else { cout ...
[["+", 31, 16, 12, 16, 12, 16, 31, 2, 63, 22], ["+", 12, 16, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 12, 16, 12, 16, 31, 2, 3, 4, 0, 21], ["+", 12, 16, 12, 16, 31, 2, 3, 4, 0, 22], ["+", 12, 16, 12, 16, 31, 2, 3, 4, 0, 25]]
1
119
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { long long X, K, D, tmp = 0; cin >> X >> K >> D; X = abs(X); D = abs(D); tmp = X / D; if (K <= tmp) { X = X - D * K; } else { X = X - D * tmp; K = K - tmp; } if (K % 2 == 0) { ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { long long X, K, D, tmp = 0; cin >> X >> K >> D; X = abs(X); D = abs(D); tmp = X / D; if (K <= tmp) { X = X - D * K; K = 0; } else { X = X - D * tmp; K = K - tmp; } if (K % 2...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
123
#include <iostream> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; x = abs(x); if (k * d <= x) { cout << x - k * d << endl; return 0; } k -= x / d; x %= d; if (k % 2) { cout << abs(x - d) << endl; } else { cout << x << endl; } }
#include <iostream> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; x = abs(x); if (k <= x / d) { cout << x - k * d << endl; return 0; } k -= x / d; x %= d; if (k % 2) { cout << abs(x - d) << endl; } else { cout << x << endl; } }
[["-", 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
96
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <string.h> #include <vector> const long long INF = 1e6 + 7; const long long MOD = 1e9 + 7; using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; long lon...
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <string.h> #include <vector> const long long INF = 1e6 + 7; const long long MOD = 1e9 + 7; using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; long lon...
[["-", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22]]
1
245
from __future__ import division, print_function # import threading # threading.stack_size(2**27) # import sys # sys.setrecursionlimit(10**7) # sys.stdin = open('inpy.txt', 'r') # sys.stdout = open('outpy.txt', 'w') from sys import stdin, stdout import bisect #c++ upperbound import math import heapq i_m=92233...
from __future__ import division, print_function # import threading # threading.stack_size(2**27) # import sys # sys.setrecursionlimit(10**7) # sys.stdin = open('inpy.txt', 'r') # sys.stdout = open('outpy.txt', 'w') from sys import stdin, stdout import bisect #c++ upperbound import math import heapq i_m=92233...
[["+", 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
648
x, k, d = gets.split.map(&:to_i) x = x.abs result = if x < k * d if k.even? n = x / (2 * d) a = x - n * 2 * d b = x - 2 * d [a.abs, b.abs].min else a0 = (x - d).abs if k == 1 a0 else x -= d n = x / (2 * d) a = x - n * 2 * d b = x - 2 * d [a.abs, b.ab...
x, k, d = gets.split.map(&:to_i) x = x.abs result = if x < k * d if k.even? n = x / (2 * d) a = x - n * 2 * d b = a - 2 * d [a.abs, b.abs].min else a0 = (x - d).abs if x <= d a0 else x -= d n = x / (2 * d) a = x - n * 2 * d b = a - 2 * d [a.abs, b....
[["-", 0, 121, 64, 749, 0, 662, 12, 738, 31, 22], ["+", 0, 121, 64, 749, 0, 662, 12, 738, 31, 22], ["-", 0, 121, 75, 95, 0, 121, 15, 738, 31, 22], ["-", 0, 121, 75, 95, 0, 121, 15, 738, 17, 60], ["-", 0, 121, 75, 95, 0, 121, 15, 738, 12, 612], ["+", 0, 121, 75, 95, 0, 121, 15, 738, 31, 22], ["+", 0, 121, 75, 95, 0, 121...
4
134
#include <stdio.h> #include <stdlib.h> long X, K, D; int main() { scanf("%ld%ld%ld", &X, &K, &D); X = labs(X); if (X >= K * D) { printf("%ld\n", X - K * D); return 0; } K = (K - (X / D)) & 1; X -= X / D * D; if (K) X = labs(X - D); printf("%ld\n", X); return 0; }
#include <stdio.h> #include <stdlib.h> long X, K, D; int main() { scanf("%ld%ld%ld", &X, &K, &D); X = labs(X); if (X / D >= K) { printf("%ld\n", X - K * D); return 0; } K = (K - (X / D)) % 2; X -= X / D * D; if (K) X = labs(X - D); printf("%ld\n", X); return 0; }
[["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 67], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, ...
0
115
X,K,D=map(int,input().split()) a=abs(X//D) b=abs(X)-a*D if K<a: print(abs(X)-K*D) else: if (K-a)%2==0: print(b) else: print(min(abs(b-D),abs(b+D)))
X,K,D=map(int,input().split()) a=abs(X)//D b=abs(X)-a*D if K<a: print(abs(X)-K*D) else: if (K-a)%2==0: print(b) else: print(min(abs(b-D),abs(b+D)))
[["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
90
#include <algorithm> // sort #include <cstring> #include <fstream> #include <iostream> #include <math.h> #include <queue> #include <vector> #define DEBUG 0 #define REP(i, n) for (long long i = 0; i < (n); i++) typedef long long ll; static const ll MOD = 1000000007; static const ll INF = 1000000000000000000LL; // 9999...
#include <algorithm> // sort #include <cstring> #include <fstream> #include <iostream> #include <math.h> #include <queue> #include <vector> #define DEBUG 0 #define REP(i, n) for (long long i = 0; i < (n); i++) typedef long long ll; static const ll MOD = 1000000007; static const ll INF = 1000000000000000000LL; // 9999...
[["-", 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
175
/* Welcome to my Code */ #include <bits/stdc++.h> #define ll long long int #define i(a, n) int a = n; #define l(a, n) ll a = n; #define d(a, n) double a = n; #define s(a) string a; #define c(a) \ ll a; ...
/* Welcome to my Code */ #include <bits/stdc++.h> #define ll long long int #define i(a, n) int a = n; #define l(a, n) ll a = n; #define d(a, n) double a = n; #define s(a) string a; #define c(a) \ ll a; ...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
254
#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() { ll x; cin >> x; x = abs(x); ll k, d; cin >> k >> d; if (k <= (x + d - 1) / d) { //原点にたどり着けない場合 ...
#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() { ll x; cin >> x; x = abs(x); ll k, d; cin >> k >> d; if (k < (x + d - 1) / d) { //原点にたどり着けない場合 ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
185
# -*- coding: utf-8 -*- x, k, d = map(int, input().split()) x = abs(x) t = x // d if t >= k: answer = x - (k * d) else: if (k - t) % 2 == 0: answer = x - (t * d) else: answer = x - (t - 1) * d print(answer)
# -*- coding: utf-8 -*- x, k, d = map(int, input().split()) x = abs(x) t = x // d if t >= k: answer = x - (k * d) else: if (k - t) % 2 == 0: answer = x - (t * d) else: answer = x - (t + 1) * d print(abs(answer))
[["-", 12, 657, 12, 657, 31, 23, 0, 657, 17, 33], ["+", 12, 657, 12, 657, 31, 23, 0, 657, 17, 72], ["+", 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
83
import java.io.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.lang.*; import java.math.BigInteger; import java.util.Arrays; import java.util.HashSet; import java.util.Random;...
import java.io.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.lang.*; import java.math.BigInteger; import java.util.Arrays; import java.util.HashSet; import java.util.Random;...
[["+", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 0, 131], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 24], ["+", 51, 492, 3, 4, 0, 492, 3, 4, 0, 25]]
3
993
#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 a = x / d; if (k < a) { cout << x - k * d << '\n'; } else { long long r = k - a; long long m = x % d; if (r % 2 == 0) cout << x - a * d << '\n'; else...
#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 a = x / d; if (k < a) { cout << x - k * d << '\n'; } else { long long r = k - a; long long m = x % d; if (r % 2 == 0) cout << x - a * d << '\n'; else...
[["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33]]
1
127
#include <bits/stdc++.h> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; x = abs(x); long long a, b; if (x % d == 0) a = x / d - 1; else a = x / d; b = a + 1; // cout<<a<<" "<<b<<"\n"; if (k < a) { cout << x - k * d << "\n"; return 0; } long long x1 = x - ...
#include <bits/stdc++.h> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; x = abs(x); long long a, b; if (x % d == 0) a = x / d - 1; else a = x / d; b = a + 1; // cout<<a<<" "<<b<<"\n"; if (k < a) { cout << x - k * d << "\n"; return 0; } long long x1 = x - ...
[["-", 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], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
147
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll ce(ll a, ll b) { return (a + b - 1) / b; } int main() { ll x, k, d, l; scanf("%lld%lld%lld", &x, &k, &d); l = ce(abs(x), d); if (k >= l) printf("%I64d\n", llabs((k - l) % 2 ? llabs(x) - (l - 1) * d : llabs(x) - l * d)); e...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll ce(ll a, ll b) { return (a + b - 1) / b; } int main() { ll x, k, d, l; scanf("%lld%lld%lld", &x, &k, &d); l = ce(abs(x), d); if (k >= l) printf("%lld\n", llabs((k - l) % 2 ? llabs(x) - (l - 1) * d : llabs(x) - l * d)); el...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
144
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits.h> #include <map> #include <math.h> #include <numeric> #include <queue> #include <random> #...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits.h> #include <map> #include <math.h> #include <numeric> #include <queue> #include <random> #...
[["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25]]
1
1,687
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define rep(i, n) for (int i = 0; i < n; i++) #define UNIQUE(v) \ v.erase(unique(v.begin(), v.end()), v.end()) // sortしてから使う #define INF 2147483647 #define LLINF...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define rep(i, n) for (int i = 0; i < n; i++) #define UNIQUE(v) \ v.erase(unique(v.begin(), v.end()), v.end()) // sortしてから使う #define INF 2147483647 #define LLINF...
[["+", 15, 339, 51, 16, 31, 16, 31, 2, 63, 22], ["+", 51, 16, 31, 16, 31, 2, 3, 4, 0, 24], ["+", 51, 16, 31, 16, 31, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
146
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define rep(i, n) for (int i = 0; i < n; i++) #define UNIQUE(v) \ v.erase(unique(v.begin(), v.end()), v.end()) // sortしてから使う #define INF 2147483647 #define LLINF...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define rep(i, n) for (int i = 0; i < n; i++) #define UNIQUE(v) \ v.erase(unique(v.begin(), v.end()), v.end()) // sortしてから使う #define INF 2147483647 #define LLINF...
[["+", 0, 1, 0, 16, 12, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 12, 16, 12, 16, 12, 22]]
1
137
#include <bits/stdc++.h> #include <stdlib.h> #include <sys/time.h> #include <unistd.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> T; typedef pair<long double, ll> Ps; typedef pair<ll, bool> Pb; const ll INF = 1e18; const ll fact_table = 3200008; long double Pi = 3.14159265...
#include <bits/stdc++.h> #include <stdlib.h> #include <sys/time.h> #include <unistd.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> T; typedef pair<long double, ll> Ps; typedef pair<ll, bool> Pb; const ll INF = 1e18; const ll fact_table = 3200008; long double Pi = 3.14159265...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 12, 13]]
1
766
X, K, D = map(int, input().split()) if abs(X) - K * D < 0: d = abs(X) // D if (D - d) % 2 == 0: print(abs(abs(X) - d * D)) else: print(abs(abs(X) - (d+1) * D)) else: print(abs(X) - K * D)
X, K, D = map(int, input().split()) if abs(X) - K * D < 0: d = abs(X) // D if (K - d) % 2 == 0: print(abs(abs(X) - d * D)) else: print(abs(abs(X) - (d+1) * D)) else: print(abs(X) - K * D)
[["-", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22]]
5
96
import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out, true); long x = in.nextLong(); long k = in.nextLong(); long d = in.nextLong(); long step = Math.min(k, x / d); k =...
import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out, true); long x = Math.abs(in.nextLong()); long k = in.nextLong(); long d = in.nextLong(); long step = Math.min(k, x / d...
[["+", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 0, 131], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 24], ["+", 51, 492, 3, 4, 0, 492, 3, 4, 0, 25]]
3
165
input_line = input() data = input_line.split(" ") x = abs(int(data[0])) k = int(data[1]) d = int(data[2]) a = x // d b = x % d res = abs(a) if res >= k : ans = x - k * d else : num = k - res if num % 2 == 1 : ans = abs(res - d) else : ans = res print(ans)
input_line = input() data = input_line.split(" ") x = abs(int(data[0])) k = int(data[1]) d = int(data[2]) a = x // d b = x % d res = abs(a) if res >= k : ans = x - k * d else : num = k - res if num % 2 == 1 : ans = abs(b - d) else : ans = b print(ans)
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 75, 76, 8, 196, 0, 1, 0, 662, 12, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 12, 22]]
5
104
#include <bits/stdc++.h> using namespace std; long long x, k, d, p, q, kurang; long long absol(long long a) { if (a < 0) { return a *= -1; } else { return a; } } int main() { cin >> x >> k >> d; kurang = min(k, x / d); if (x > 0) { k = k - kurang; x = x - kurang * d; } else { k = k ...
#include <bits/stdc++.h> using namespace std; long long x, k, d, p, q, kurang; long long absol(long long a) { if (a < 0) { return a *= -1; } else { return a; } } int main() { cin >> x >> k >> d; kurang = min(k, absol(x / d)); if (x > 0) { k = k - kurang; x = x - kurang * d; } else { ...
[["+", 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
199
#include <bits/stdc++.h> #include <iostream> using namespace std; // FILE *fi = freopen("1.txt", "r", stdin); // FILE *fo = freopen("1", "w", stdout); long long a, b, c; long long ans; long long calc(long long t) { return abs(a + c * t); } int main() { cin >> a >> b >> c; a = abs(a); // ans = a; // long long l ...
#include <bits/stdc++.h> #include <iostream> using namespace std; // FILE *fi = freopen("1.txt", "r", stdin); // FILE *fo = freopen("1", "w", stdout); long long a, b, c; long long ans = 1e18; long long calc(long long t) { return abs(a + c * t); } int main() { cin >> a >> b >> c; a = abs(a); // ans = a; // long ...
[["+", 36, 36, 0, 30, 0, 43, 49, 50, 0, 32], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
147
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define fs first #define se second #define M 1000000007 #define pii pair<long long, long long> int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; unordered_map<char, pii> dir; ll D = 1e9; bool check(ll x, ll y, ll z, ll X, ll Y...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define fs first #define se second #define M 1000000007 #define pii pair<long long, long long> int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; unordered_map<char, pii> dir; ll D = 1e9; bool check(ll x, ll y, ll z, ll X, ll Y...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22]]
1
211
x, k, d = map(int, input().split(" ")) def y(l): return abs(x + l * d - (k - l) * d) lf = max(0, (k - x / d) / 2) l = int(lf) if lf - l > 0 and l + 1 <= k: print(min(y(l), y(l + 1))) else: print(y(l))
x, k, d = map(int, input().split(" ")) def y(l): return abs(x + l * d - (k - l) * d) lf = min(max(0, (k - x / d) / 2), k) l = int(lf) if lf - l > 0 and l + 1 <= k: print(min(y(l), y(l + 1))) else: print(y(l))
[["+", 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], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
105
var = input() x = int(var.split()[0]) k = int(var.split()[1]) d = int(var.split()[2]) cnt = x // d if (k <= cnt) : print(x - d * k) else : kk = k - cnt if (kk % 2 == 0) : print(x - d * cnt) else : print(d - (x - d * cnt))
var = input() x = int(var.split()[0]) k = int(var.split()[1]) d = int(var.split()[2]) x = abs(x) cnt = x // d if (k <= cnt) : print(x - d * k) else : kk = k - cnt if (kk % 2 == 0) : print(x - d * cnt) else : print(d - (x - d * cnt))
[["+", 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
102
X,K,D=map(int,input().split()) sub_even=abs(X)//D sub_odd=sub_even+1 if sub_even%2==1: sub_odd=sub_even sub_even=sub_odd+1 if K%2==0: if K>= sub_even: print(abs(X-sub_even*D)) else: print(abs(abs(X)-K*D)) else: if K>= sub_odd: print(abs(X-sub_odd*D)) else: print(abs(abs(X)-K*D))
X,K,D=map(int,input().split()) sub_even=abs(X)//D sub_odd=sub_even+1 if sub_even%2==1: sub_odd=sub_even sub_even=sub_odd+1 if K%2==0: if K>= sub_even: print(abs(abs(X)-sub_even*D)) else: print(abs(abs(X)-K*D)) else: if K>= sub_odd: print(abs(abs(X)-sub_odd*D)) else: print(abs(abs(X)-K*D))
[["+", 0, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22]]
5
119
A = list(map(int, input().split())) x = A[0] k = A[1] d = A[2] first_k = abs(x) // d if k < first_k: final_min = abs(x - k * d) else: first_min = abs(x) % d second_min = abs(x) - d * (first_k + 1) if abs(first_min) < abs(second_min): first_k += 1 final_min = second_min else: final_min = first_...
A = list(map(int, input().split())) x = A[0] k = A[1] d = A[2] first_k = abs(x) // d if k < first_k: final_min = abs(x) - k * d else: first_min = abs(x) % d second_min = abs(x) - d * (first_k + 1) if abs(first_min) < abs(second_min): first_k += 1 final_min = second_min else: final_min = first_...
[["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
158
#include <cmath> #include <cstdint> #include <iostream> using int64 = std::int64_t; int main() { int64 X, K, D, x; // initial position, time of act, distance per move std::cin >> X >> K >> D; if (X > 0) x = X; else x = -X; int64 min_step = x / D; if (min_step > K) min_step = K; else if (0 ...
#include <cmath> #include <cstdint> #include <iostream> using int64 = std::int64_t; int main() { int64 X, K, D, x; // initial position, time of act, distance per move std::cin >> X >> K >> D; if (X > 0) x = X; else x = -X; int64 min_step = x / D; if (min_step >= K) min_step = K; else if (0...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
145
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long using P = pair<int, int>; #define LOG(variable) cerr << #variable ":\t" << (variable) << endl #define LOGCON(i, container) \ for (int(i) = 0; (i) < (container).size(); ++(i)) ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long using P = pair<int, int>; #define LOG(variable) cerr << #variable ":\t" << (variable) << endl #define LOGCON(i, container) \ for (int(i) = 0; (i) < (container).size(); ++(i)) ...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
294
# import itertools # import math import sys # sys.setrecursionlimit(500*500) # import numpy as np # N = int(input()) # S = input() # n, *a = map(int, open(0)) X, K, D = map(int, input().split()) # A = list(map(int, input().split())) # B = list(map(int, input().split())) # tree = [[] for _ in range(N + 1)] # B_C = [lis...
# import itertools # import math import sys # sys.setrecursionlimit(500*500) # import numpy as np # N = int(input()) # S = input() # n, *a = map(int, open(0)) X, K, D = map(int, input().split()) # A = list(map(int, input().split())) # B = list(map(int, input().split())) # tree = [[] for _ in range(N + 1)] # B_C = [lis...
[["+", 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
111
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll tempAns = x / 2 * d; tempAns += k / 2; tempAns = min(tempAns, k); ll ans = 1e18; ll mi = 0; ll low = max(tempAns - 4, mi); for (ll i = low; i <= k && i <= low + 10; i++) ...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll tempAns = x / (2 * d); tempAns += k / 2; tempAns = min(tempAns, k); ll ans = 1e18; ll mi = 0; ll low = max(tempAns - 4, mi); for (ll i = low; i <= k && i <= low + 10; i++...
[["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 24], ["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 25]]
1
134
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> //#include<unordered_map> using namespace std; #define ll long long #define dd cout << endl const long long int inf = 1e18 + 7;...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> //#include<unordered_map> using namespace std; #define ll long long #define dd cout << endl const long long int inf = 1e18 + 7;...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22]]
1
397
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> //#include<unordered_map> using namespace std; #define ll long long #define dd cout << endl const long long int inf = 1e18 + 7;...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> //#include<unordered_map> using namespace std; #define ll long long #define dd cout << endl const long long int inf = 1e18 + 7;...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22]]
1
267
def c_walking_takahashi(): X, K, D = [int(i) for i in input().split()] x = abs(X) need_move, r = divmod(x, D) # 位置 r に到達するには need_move 回の移動が必要 if need_move >= K: return X - K * D # r には到達できない。動ける限り動いた結果がこれ can_move = K - need_move # 動ける回数が偶数回だと位置 r で、奇数回だと abs(r-D)=D-r で終了する if can...
def c_walking_takahashi(): X, K, D = [int(i) for i in input().split()] x = abs(X) need_move, r = divmod(x, D) # 位置 r に到達するには need_move 回の移動が必要 if need_move >= K: return x - K * D # r には到達できない。動ける限り動いた結果がこれ can_move = K - need_move # 動ける回数が偶数回だと位置 r で、奇数回だと abs(r-D)=D-r で終了する if can...
[["-", 0, 57, 64, 196, 0, 37, 0, 657, 31, 22], ["+", 0, 57, 64, 196, 0, 37, 0, 657, 31, 22]]
5
81
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll fa = x / d; ll rm = x % d; if (fa == k) { cout << rm << "\n"; } if (fa > k) { cout << x - (d * k) << "\n"; } else { k -= fa; if (k & 1) cout << a...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll fa = x / d; ll rm = x % d; if (fa == k) { cout << rm << "\n"; } else if (fa > k) { cout << x - (d * k) << "\n"; } else { k -= fa; if (k & 1ll) cout...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 64, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
130
#include <bits/stdc++.h> using namespace std; using ll = long long int; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cou...
#include <bits/stdc++.h> using namespace std; using ll = long long int; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cou...
[["-", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["-", 12, 23, 0, 16, 31, 23, 0, 16, 31, 22], ["-", 12, 23, 0, 16, 31, 23, 0, 16, 17, 85], ["-", 12, 16, 12, 23, 0, 16, 31, 23, 0, 25]]
1
149
#include <bits/stdc++.h> using namespace std; #define int long long #define M 1000000007 #define INF ((1LL << 62LL) - 1) signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x, k, d; cin >> x >> k >> d; x = abs(x); int times = x / d; if (times >= k) { cout << x - d * k << "\n"; ...
#include <bits/stdc++.h> using namespace std; #define int long long #define M 1000000007 #define INF ((1LL << 62LL) - 1) signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x, k, d; cin >> x >> k >> d; x = abs(x); int times = x / d; if (times >= k) { cout << x - d * k << "\n"; ...
[["-", 64, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
128
X,K,D = map(int,input().split()) if X==0: if K%2==0: print(0) exit() else: print(D) exit() if X>0: if (X-K*D)>=0: print(X-D*K) else: cnt = X//D val = X%D if (K-cnt)%2==0: print(val) else: print(abs(D-val)) ...
X,K,D = map(int,input().split()) if X==0: if K%2==0: print(0) exit() else: print(D) exit() if X>0: if (X-K*D)>=0: print(X-D*K) else: cnt = X//D val = X%D if (K-cnt)%2==0: print(val) else: print(abs(D-val)) ...
[["+", 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
178
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" int main() { int t; t = 1; ; while (t--) { ll a, b, c; cin >> a >> b >> c; // 800 -800 // kuch bhi least or say close to give gnerate it ll k = a / c; if (k > b) { k = b; } b = b - k; l...
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" int main() { int t; t = 1; ; while (t--) { ll a, b, c; cin >> a >> b >> c; // 800 -800 // kuch bhi least or say close to give gnerate it ll k = a / c; if (abs(k) > b) { k = b; } b = b - k; ...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25]]
1
250
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(void) { ll X, K, D; cin >> X >> K >> D; X = abs(X); ll a = X / D; ll b = X - a * D; ll c = K - a; if (c <= 0) { X -= D * K; cout << X << endl; return 0; } else if (X % D == 0) { if (K % 2 == 0) { cout ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(void) { ll X, K, D; cin >> X >> K >> D; X = abs(X); ll a = X / D; ll b = X - a * D; ll c = K - a; if (c <= 0) { X -= D * K; cout << X << endl; return 0; } else if (X % D == 0) { if (K % 2 == 0) { cout ...
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22]]
1
200
X,K,D = map(int,input().split()) b = 0 b = abs(X)//D if b <= K: K -= b else: b = K K = 0 if X > 0: X -= D*b elif X < 0: X += D*b if K == 0: print(X) else: if X == 0: if K % 2 == 0: print(X) else: print(D) elif X > 0: if abs(...
X,K,D = map(int,input().split()) b = 0 b = abs(X)//D if b <= K: K -= b else: b = K K = 0 if X > 0: X -= D*b elif X < 0: X += D*b if K == 0: print(abs(X)) else: if X == 0: if K % 2 == 0: print(X) else: print(D) elif X > 0: if...
[["+", 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
216
X, K, D = (int(x) for x in input().split()) X = abs(X) straight = min(K, X // D) K -= straight X -= straight * D if K % 2 == 0: print(X) else: print(D+X)
X, K, D = (int(x) for x in input().split()) X = abs(X) straight = min(K, X // D) K -= straight X -= straight * D if K % 2 == 0: print(X) else: print(D-X)
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33]]
5
65
""" X, K , D = map(int, input().split()) ans=1e+15 for i in range(K): init_X=X init_X+=i*D-(K-i)*D if abs(init_X)<ans: ans=abs(init_X) print(ans) """ X, K , D = map(int, input().split()) left=X-K*D right=X+K*D if left<0<right: k=abs(X)//D X-=D * k print(X if (K-k)%2==0 else abs(X-D)) elif right<=0: print...
""" X, K , D = map(int, input().split()) ans=1e+15 for i in range(K): init_X=X init_X+=i*D-(K-i)*D if abs(init_X)<ans: ans=abs(init_X) print(ans) """ X, K , D = map(int, input().split()) left=X-K*D right=X+K*D if left<0<right: k=abs(X)//D X=abs(X)-D * k print(X if (K-k)%2==0 else abs(X-D)) elif right<=0: ...
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 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, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 33...
5
92
#include <algorithm> #include <iostream> #include <stdio.h> #include <stdlib.h> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, j, k) for (int i = j; i < k; i++) #define ll long long using namespace std; int main() { ll X, K, D; cin >> X >> K >> D; X = abs(X); ...
#include <algorithm> #include <iostream> #include <stdio.h> #include <stdlib.h> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, j, k) for (int i = j; i < k; i++) #define ll long long using namespace std; int main() { ll X, K, D; cin >> X >> K >> D; X = abs(X); ...
[["+", 75, 76, 0, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 12, 22], ["+", 0, 9, 0, 57, 75, 76, 0, 1, 0, 35]]
1
136
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 1e9 + 5, mod = 1e9 + 7; void solve() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll mn = x % d; if (x < d) { if (k & 1) { cout << abs(d - x) << endl; } else { cout << d << en...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 1e9 + 5, mod = 1e9 + 7; void solve() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll mn = x % d; if (x < d) { if (k & 1) { cout << abs(d - x) << endl; } else { cout << x << en...
[["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
225
#include <algorithm> #include <cstdlib> #include <iostream> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; if ((k - min(k, abs(x) / d)) % 2 == 0) { cout << x - min(k, abs(x) / d) * d << endl; } else { cout << d - x + min(k, abs(x) / d) * d << endl; } }
#include <algorithm> #include <cstdlib> #include <iostream> using namespace std; int main() { long long x, k, d; cin >> x >> k >> d; if ((k - min(k, abs(x) / d)) % 2 == 0) { cout << abs(x) - min(k, abs(x) / d) * d << endl; } else { cout << d - abs(x) + min(k, abs(x) / d) * d << endl; } }
[["+", 0, 16, 31, 16, 12, 16, 31, 2, 63, 22], ["+", 31, 16, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 16, 12, 16, 31, 2, 3, 4, 0, 25], ["+", 31, 16, 12, 16, 31, 16, 12, 2, 63, 22], ["+", 12, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 12, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
101
#include <bits/stdc++.h> using namespace std; int main(void) { long long x, k, d, o, p; cin >> x >> k >> d; x = abs(x); o = x / d; p = x % d; if (o <= k) { if ((k - o) % 2 == 0) cout << p << endl; else cout << abs(d - k - o) << endl; } else { cout << x - d * k << endl; } return...
#include <bits/stdc++.h> using namespace std; int main(void) { long long x, k, d, o, p; cin >> x >> k >> d; x = abs(x); o = x / d; p = x % d; if (o <= k) { if ((k - o) % 2 == 0) cout << p << endl; else cout << abs(p - d) << endl; } else { cout << x - d * k << endl; } return 0; ...
[["-", 12, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["-", 12, 2, 3, 4, 0, 16, 31, 16, 17, 33], ["-", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
108
X, K, D = map(int, input().split()) if abs(X) < (K * D): a = abs(X) % D b = abs(D - a) c = abs(X) // D + 1 if c % 2 == 0: goal = b else: goal = a else: goal = abs(X) - ( D * K ) print(goal)
X, K, D = map(int, input().split()) if abs(X) < (K * D): a = abs(X) % D b = abs(D - a) c = abs(X) // D + 1 if (K - c) % 2 == 0: goal = b else: goal = a else: goal = abs(X) - ( D * K ) print(goal)
[["+", 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
89
X,K,D = map(int,input().split()) X = abs(X) if X >= K*D: print(X-K*D) else: if (K-X//D) % 2 ==1: print(D-(X-K*D)) else: print(X-X//D*D)
X,K,D = map(int,input().split()) X = abs(X) if X >= K*D: print(X-K*D) else: if (K-X//D) % 2 == 1: print(D-(X-X//D*D)) else: print(X-X//D*D)
[["-", 0, 657, 12, 23, 0, 657, 12, 657, 31, 22], ["+", 12, 23, 0, 657, 12, 657, 31, 657, 31, 22], ["+", 12, 23, 0, 657, 12, 657, 31, 657, 17, 676], ["+", 12, 23, 0, 657, 12, 657, 31, 657, 12, 22]]
5
78
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define fastAF \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define fastAF \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
[["-", 64, 9, 0, 1, 0, 16, 12, 16, 31, 22], ["+", 64, 9, 0, 1, 0, 16, 12, 16, 31, 22]]
1
187
X, K, D = map(int,input().split()) if X - K*D >= 0: ans = X - K*D else: plus = X % D minus = plus - D rem = K - X//D if rem%2 == 0: ans = plus else: ans = abs(minus) print(ans)
X, K, D = map(int,input().split()) X = abs(X) if X - K*D >= 0: ans = X - K*D else: plus = X % D minus = plus - D rem = K - X//D if rem%2 == 0: ans = plus else: ans = abs(minus) print(ans)
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
75
def main(): import sys input = sys.stdin.readline X, K, D = [int(x) for x in input().strip().split()] ans = 0 if abs(X) >= K * D: print(abs(X-K*D)) else: X, K = X - D * (X // D), K - X // D if K % 2: print(abs(X-D)) else: print(X) if __nam...
def main(): import sys input = sys.stdin.readline X, K, D = [int(x) for x in input().strip().split()] ans = 0 X = abs(X) if X >= K * D: print(abs(X-K*D)) else: X, K = X - D * (X // D), K - X // D if K % 2: print(abs(X-D)) else: print(X)...
[["-", 0, 656, 0, 14, 8, 196, 0, 57, 0, 121], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 14, 8, 196, 0, 57, 0, 121], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22]]
5
115
# 間違いコード x,k,d = map(int,input().split()) ans = 0 if x>0: if x-k*d > 0: ans = x-k*d else: if (k-(x//d))%2 == 0: #右 ans = x-(x//d)*d else: ans = abs(x-(x//d+1)*d) else: if x<0 and x+k*d < 0: ans = x+k*d else: if (k-(-x//d))%2 == 0: #左 ans = abs(x + (-x//d)*d ) els...
# 間違いコード x,k,d = map(int,input().split()) ans = 0 if x>0: if x-k*d > 0: ans = x-k*d else: if (k-(x//d))%2 == 0: #右 ans = x-(x//d)*d else: ans = abs(x-(x//d+1)*d) else: if x<0 and x+k*d < 0: ans = abs(x+k*d) else: if (k-(-x//d))%2 == 0: #左 ans = abs(x + (-x//d)*d ) ...
[["+", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
169
#include <algorithm> #include <bits/stdc++.h> #include <cstdlib> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { ll X, K, D, f, ans = 0; cin >> X >> K >> D; f = X / D; if (f > K) { if (X > 0) ans = abs(X - K * D); else ans = abs(X + K ...
#include <algorithm> #include <bits/stdc++.h> #include <cstdlib> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { ll X, K, D, f, ans = 0; cin >> X >> K >> D; f = X / D; if (abs(f) > K) { if (X > 0) ans = abs(X - K * D); else ans = abs(X...
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25]]
1
161
x,k,d=map(int,input().split()) #x zahyo k k kaisu d hohaba if abs(x)-k*d>0: print(abs(x)-k*d) else: nearZeroHosu=abs(x)//d if nearZeroHosu%2==0: print(abs(x)-d*nearZeroHosu) else: print(abs(abs(x)-d*(nearZeroHosu+1)))
x,k,d=map(int,input().split()) #x zahyo k k kaisu d hohaba if abs(x)-k*d>0: print(abs(x)-k*d) else: nearZeroHosu=abs(x)//d if (k-nearZeroHosu)%2==0: print(abs(x)-d*nearZeroHosu) else: print(abs(abs(x)-d*(nearZeroHosu+1)))
[["+", 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
90
#include <algorithm> #include <iostream> using namespace std; using ll = long long; int main() { ll x, k, d; cin >> x >> k >> d; abs(x); ll move = min(k, x / d); k -= move; x -= move * d; if (k % 2 == 0) cout << x; else cout << d - x; }
#include <algorithm> #include <iostream> using namespace std; using ll = long long; int main() { ll x, k, d; cin >> x >> k >> d; x = abs(x); ll move = min(k, x / d); k -= move; x -= move * d; if (k % 2 == 0) cout << x; else cout << d - x; }
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32]]
1
81
// bismillahir rahmanir rahim //Author:Fayed Anik #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; //#define ordered_set tree<int, null_type,less<int>, //rb_tree_tag,tree_order_statistics_...
// bismillahir rahmanir rahim //Author:Fayed Anik #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; //#define ordered_set tree<int, null_type,less<int>, //rb_tree_tag,tree_order_statistics_...
[["+", 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
297
inp = list(map(int,input().split(" "))) location = inp[0] times = inp[1] distance = inp[2] x = float(abs(location / distance)) if x >= times: print(abs(location - (times*distance))) elif (times - int(x))%2 == 0: print(abs(location - abs(int(x)*distance))) else: print(abs(location - abs(int(x)*distance)-d...
inp = list(map(int,input().split(" "))) location = abs(inp[0]) times = inp[1] distance = inp[2] x = float(abs(location / distance)) if x >= times: print(abs(location - (times*distance))) elif (times-int(x))%2==0: print(abs(location-abs(int(x)*distance))) else: print(abs(location-abs(int(x)*distance)-dist...
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
119