about summary refs log tree commit diff
path: root/codechef/mmax.py
diff options
context:
space:
mode:
Diffstat (limited to 'codechef/mmax.py')
-rwxr-xr-xcodechef/mmax.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/codechef/mmax.py b/codechef/mmax.py
new file mode 100755
index 0000000..e62fc7d
--- /dev/null
+++ b/codechef/mmax.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+for _ in range(int(input())):
+    n = int(input())
+    k = int(input())
+    m = k % n
+    print(min(m * 2, (n - m) * 2, n - 1))