about summary refs log tree commit diff
path: root/codechef/mmax.py
blob: e62fc7d12802a08f20a4a5b93b34b401b9e93661 (plain) (blame)
1
2
3
4
5
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))