fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. long long a, b;
  6. cin >> a >> b;
  7.  
  8. cout << min(a - a / b * b, a - (a / b - 1) * b);
  9.  
  10. return 0;
  11. }
Success #stdin #stdout 0s 5328KB
stdin
-15 4
stdout
-3