public static long gcd(long a, long b) {a = Math.abs(a);b = Math.abs(b);if (a == 0) {return b;} else if (b == 0) {return a;}final int commonTrailingZeros = Long.numberOfTrailingZeros(a | b);a >>>= Long.numberOfTrailingZeros(a);while (true) {b >>>= Long.numberOfTrailingZeros(b);if (a == b) {break;} else if (a > b || a == Long.MIN_VALUE) { final long tmp = a;a = b;b = tmp;}if (a == 1) {break;}b -= a;}return a << commonTrailingZeros;}

public static long Gcd(long a, long b){a = a < 0 ? -a : a;b = b < 0 ? -b : b;if (a == 0){return b;}else if (b == 0){return a;}int commonTrailingZeros = (a | b).TrailingZeroCount();a = (long)((ulong)a >> a.TrailingZeroCount());while (true){b = (long)((ulong)b >> b.TrailingZeroCount());if (a == b){break;} else if (a > b || a == long.MinValue){long tmp = a;a = b;b = tmp;}if (a == 1){break;}b -= a;}return a << commonTrailingZeros;}
