You are given a problemset consisting of $$$n$$$ problems. The difficulty of the $$$i$$$-th problem is $$$a_i$$$. It is guaranteed that all difficulties are distinct and are given in the increasing order.You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let $$$a_{i_1}, a_{i_2}, \dots, a_{i_p}$$$ be the difficulties of the selected problems in increasing order. Then for each $$$j$$$ from $$$1$$$ to $$$p-1$$$ $$$a_{i_{j + 1}} \le a_{i_j} \cdot 2$$$ should hold. It means that the contest consisting of only one problem is always valid.Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of problems in the problemset. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.

Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.

NoteDescription of the first example: there are $$$10$$$ valid contests consisting of $$$1$$$ problem, $$$10$$$ valid contests consisting of $$$2$$$ problems ($$$[1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]$$$), $$$5$$$ valid contests consisting of $$$3$$$ problems ($$$[5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]$$$) and a single valid contest consisting of $$$4$$$ problems ($$$[5, 6, 7, 10]$$$).In the second example all the valid contests consist of $$$1$$$ problem.In the third example are two contests consisting of $$$3$$$ problems: $$$[4, 7, 12]$$$ and $$$[100, 150, 199]$$$.

// var n = readline();
// var nums = readline();
// nums = nums.split(' ').map(function (ele) {
//     return +ele;
// });
// function check(low, hei) {
//     if (low <= hei && hei <= low * 2) {
//         return true;
//     }
//     return false;
// }
// //ssss
// function solve() {
//     var slow = 0, fast = 1, max = 1;
//     if (nums.length < 2) {
//         return 1;
//     }
//     while (fast < +n) {
//         if (fast === slow) {
//             fast++;
//             continue;
//         }
//         var temp_rst = check(nums[slow], nums[fast]);
//         if (temp_rst) {
//             max = Max(max, fast - slow + 1);
//             fast++;
//         } else {
//             slow++;
//         }

//     }
//     return max;
// }

// function Max(a, b) {
//     return a > b ? a : b;
// }
// print(solve());
function check(low, hei) {
    if (low <= hei && hei <= low * 2) {
        return true;
    }
    return false;
}
var n = readline();
var nums = readline();
nums = nums.split(' ').map(function (ele) {
    return +ele;
});

function solve() {
    var slow = 0, fast = 1, max = 1;
    if (nums.length < 2) {
        return 1;
    }
    var tempLen = 1
    while (fast < +n) {
        if (check(nums[slow], nums[fast])) {
            tempLen++;
        } else {
            max = Math.max(tempLen, max);
            tempLen = 1;
        }
        fast++;
        slow++;
    }
    max = Math.max(tempLen, max);
    return max;
}
print(solve());

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
	inputString += inputStdin;
});

process.stdin.on('end', (_) => {
	inputString = inputString.trim().split('\n').map((string) => {
		return string.trim();
	});

	main();
});

function readline() {
	return inputString[currentLine++];
}

function main() {
	let n = +readline();
	let a = readline().split(' ').map(Number);
	let max = 0;
	let sum = 0;
	for (let i = 0; i < n; i++) {
		let j = i;
		while (j + 1 < n && a[j + 1] <= a[j] * 2) {
			j++;
		}
		max = Math.max(j - i + 1, max);
		i = j;
	}
	console.log(max);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
	inputString += inputStdin;
});

process.stdin.on('end', (_) => {
	inputString = inputString.trim().split('\n').map((string) => {
		return string.trim();
	});

	main();
});

function readline() {
	return inputString[currentLine++];
}

function main() {
	let n = +readline();
	let a = readline().split(' ').map(Number);
	let max = 0;
	let sum = 0;
	for (let i = 1; i < n; i++) {
		if (a[i - 1] * 2 >= a[i]) {
			sum++;
			if (sum > max) max = sum;
		} else sum = 0;
	}
	console.log(max + 1);
}

var n = readline();
var nums = readline();
nums = nums.split(' ').map(function (ele) {
    return +ele;
});
function check(low, hei) {
    if (low <= hei && hei <= low * 2) {
        return true;
    }
    return false;
}

function solve() {
    var slow = 0, fast = 1, max = 1;
    if (nums.length < 2) {
        return 1;
    }
    while (fast < +n) {
        if (fast === slow) {
            fast++;
        }
        var temp_rst = check(nums[slow], nums[fast]);
        if (temp_rst) {
            max = Max(max, fast - slow + 1);
            fast++;
        } else {
            slow++;
        }

    }
    return max;
}

function Max(a, b) {
    return a > b ? a : b;
}
print(solve());

var n = readline();
var nums = readline();
nums = nums.split(' ').map(function (ele) {
    return +ele;
});
function check(low, hei) {
    if (low < hei && hei <= low * 2) {
        return true;
    }
    return false;
}

function solve() {
    var slow = 0, fast = 1, max = 1;
    if (nums.length < 2) {
        return 1;
    }
    while (fast < nums.length) {
        if (fast === slow) {
            fast++;
        }
        var temp_rst = check(nums[slow], nums[fast]);
        if (temp_rst) {
            max = Max(max, fast - slow + 1);
            fast++;
        } else {
            slow++;
        }

    }
    return max;
}

function Max(a, b) {
    return a > b ? a : b;
}
print(solve());

var n = readline();
var nums = readline();
nums = nums.split(' ').map(function (ele) {
    return +ele;
});
function check(low, hei) {
    if (low <= hei && hei <= low * 2) {
        return true;
    }
    return false;
}
//ssss
function solve() {
    var slow = 0, fast = 1, max = 1;
    if (nums.length < 2) {
        return 1;
    }
    while (fast < +n) {
        if (fast === slow) {
            fast++;
        }
        var temp_rst = check(nums[slow], nums[fast]);
        if (temp_rst) {
            max = Max(max, fast - slow + 1);
            fast++;
        } else {
            slow++;
        }

    }
    return max;
}

function Max(a, b) {
    return a > b ? a : b;
}
print(solve());

// var n = readline();
// var nums = readline();
// nums = nums.split(' ').map(function (ele) {
//     return +ele;
// });
// function check(low, hei) {
//     if (low <= hei && hei <= low * 2) {
//         return true;
//     }
//     return false;
// }
// //ssss
// function solve() {
//     var slow = 0, fast = 1, max = 1;
//     if (nums.length < 2) {
//         return 1;
//     }
//     while (fast < +n) {
//         if (fast === slow) {
//             fast++;
//             continue;
//         }
//         var temp_rst = check(nums[slow], nums[fast]);
//         if (temp_rst) {
//             max = Max(max, fast - slow + 1);
//             fast++;
//         } else {
//             slow++;
//         }

//     }
//     return max;
// }

// function Max(a, b) {
//     return a > b ? a : b;
// }
// print(solve());
function check(low, hei) {
    if (low <= hei && hei <= low * 2) {
        return true;
    }
    return false;
}
var n = readline();
var nums = readline();
nums = nums.split(' ').map(function (ele) {
    return +ele;
});

function solve() {
    var slow = 0, fast = 1, max = 1;
    if (nums.length < 2) {
        return 1;
    }
    var tempLen = 1
    while (fast < +n) {
        if (check(nums[slow], nums[fast])) {
            tempLen++;
        } else {
            max = Math.max(tempLen, max);
            tempLen = 1;
        }
        fast++;
        slow++;
    }
    return max;
}
print(solve());

var n = readline();
var nums = readline();
nums = nums.split(' ').map(function (ele) {
    return +ele;
});
function check(low, hei) {
    if (low <= hei && hei <= low * 2) {
        return true;
    }
    return false;
}
//ssss
function solve() {
    var slow = 0, fast = 1, max = 1;
    if (nums.length < 2) {
        return 1;
    }
    while (fast < +n) {
        if (fast === slow) {
            fast++;
            continue;
        }
        var temp_rst = check(nums[slow], nums[fast]);
        if (temp_rst) {
            max = Max(max, fast - slow + 1);
            fast++;
        } else {
            slow++;
        }

    }
    return max;
}

function Max(a, b) {
    return a > b ? a : b;
}
print(solve());

var n = readline();
var nums = readline();
nums = nums.split(' ').map(function (ele) {
    return +ele;
});
function check(low, hei) {
    if (low <= hei && hei <= low * 2) {
        return true;
    }
    return false;
}

function solve() {
    var slow = 0, fast = 1, max = 1;
    if (nums.length < 2) {
        return 1;
    }
    while (fast < nums.length) {
        if (fast === slow) {
            fast++;
        }
        var temp_rst = check(nums[slow], nums[fast]);
        if (temp_rst) {
            max = Max(max, fast - slow + 1);
            fast++;
        } else {
            slow++;
        }

    }
    return max;
}

function Max(a, b) {
    return a > b ? a : b;
}
print(solve());

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
	inputString += inputStdin;
});

process.stdin.on('end', (_) => {
	inputString = inputString.trim().split('\n').map((string) => {
		return string.trim();
	});

	main();
});

function readline() {
	return inputString[currentLine++];
}

function main() {
	let n = +readline();
	let a = readline().split(' ').map(Number);
	let max = 0;
	let sum = 0;
	for (let i = 1; i < n; i++) {
		if (sum > max) max = sum;
		if (a[i - 1] * 2 >= a[i]) sum++;
		else sum = 0;
	}
	console.log(max + 1);
}


Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n - 1 remaining vertices has a parent in the tree. Vertex is connected with its parent by an edge. The parent of vertex i is vertex pi, the parent index is always less than the index of the vertex (i.e., pi < i).The depth of the vertex is the number of nodes on the path from the root to v along the edges. In particular, the depth of the root is equal to 1.We say that vertex u is in the subtree of vertex v, if we can get from u to v, moving from the vertex to the parent. In particular, vertex v is in its subtree.Roma gives you m queries, the i-th of which consists of two numbers vi, hi. Let's consider the vertices in the subtree vi located at depth hi. Determine whether you can use the letters written at these vertices to make a string that is a palindrome. The letters that are written in the vertexes, can be rearranged in any order to make a palindrome, but all letters should be used.

The first line contains two integers n, m (1 ≤ n, m ≤ 500 000) — the number of nodes in the tree and queries, respectively. The following line contains n - 1 integers p2, p3, ..., pn — the parents of vertices from the second to the n-th (1 ≤ pi < i). The next line contains n lowercase English letters, the i-th of these letters is written on vertex i. Next m lines describe the queries, the i-th line contains two numbers vi, hi (1 ≤ vi, hi ≤ n) — the vertex and the depth that appear in the i-th query.

Print m lines. In the i-th line print "Yes" (without the quotes), if in the i-th query you can make a palindrome from the letters written on the vertices, otherwise print "No" (without the quotes).

NoteString s is a palindrome if reads the same from left to right and from right to left. In particular, an empty string is a palindrome.Clarification for the sample test.In the first query there exists only a vertex 1 satisfying all the conditions, we can form a palindrome "z".In the second query vertices 5 and 6 satisfy condititions, they contain letters "с" and "d" respectively. It is impossible to form a palindrome of them.In the third query there exist no vertices at depth 1 and in subtree of 4. We may form an empty palindrome.In the fourth query there exist no vertices in subtree of 6 at depth 1. We may form an empty palindrome.In the fifth query there vertices 2, 3 and 4 satisfying all conditions above, they contain letters "a", "c" and "c". We may form a palindrome "cac".

'use strict';

let _in = readline().split(/\s+/);
const n = (_in[0]|0), m = (_in[1]|0);
const par = new Int32Array(n);
_in = readline().split(/\s+/);
for (let i = 1; i < n; i++) {
    par[i] = ((_in[i - 1]|0) - 1)|0;
}
const t = readline();
const a = new Uint32Array(n);
const CODE_A = 'a'.charCodeAt(0);
for (let i = 0; i < n; i++) {
    a[i] = 1 << (t.charCodeAt(i) - CODE_A);
}
const d = new Int32Array(n);
d[0] = 0|0;
for (let v = 1; v < n; v++) {
    d[v] = (d[par[v]] + 1)|0;
}
const hs = new Int32Array(m);
const vs = new Int32Array(m);
const ct = new Int32Array(n + 1);
const iter = new Int32Array(n);
const qs = new Int32Array(m);
const ans = new Array(m);
for (let i = 0; i < m; i++) {
    let _in = readline().split(/\s+/);
    const v = ((_in[0]|0) - 1)|0, h = ((_in[1]|0) - 1)|0;
    hs[i] = (h - d[v])|0;
    vs[i] = v;
    ct[v + 1]++;
}
for (let i = 0; i < n; i++) {
    ct[i + 1] += ct[i];
}
for (let i = 0; i < m; i++) {
    let v = vs[i];
    qs[ct[v] + iter[v]] = i;
    iter[v]++;
}
const dp = new Array(n);
for (let v = n - 1; v >= 0; v--) {
    if (!dp[v]) dp[v] = new Array;
    let t1 = dp[v];
    t1.push(a[v]);
    for (let p = ct[v]; p < ct[v + 1]; p++) {
        const i = qs[p];
        const h = hs[i];
        if (h < 0 || t1.length <= h) {
            ans[i] = 'Yes';
        } else {
            const len = t1.length;
            const x = t1[len - 1 - h];
            ans[i] = ((x === 0) || ((x & (x - 1)) === 0))
                ? 'Yes' : 'No';
        }
    }
    if (v == 0) break;
    const p = par[v];
    let t2 = dp[p];
    if (!t2) {
        dp[p] = t1;
    } else {
        if (t1.length > t2.length) {
            let t = t1;
            t1 = t2;
            t2 = t;
        }
        const len1 = t1.length, len2 = t2.length;
        for (let i = 0; i < len1; i++) {
            t2[len2 - i - 1] ^= t1[len1 - i - 1];
        }
        dp[p] = t2;
    }
}
print(ans.join('\n'));

'use strict';
const _in = (function*() {
    for (;;) {
        let line = readline().split(/\s+/);
        for (let word of line) {
            yield word;
        }
    }
})();
const next = () => _in.next().value;
const nextInt = () => next()|0;
const nextFloat = () => +next();

const n = nextInt(), m = nextInt();
const par = new Int32Array(n);
for (let i = 1; i < n; i++) {
    par[i] = (nextInt() - 1)|0;
}
const t = next();
const a = new Uint32Array(n);
const CODE_A = 'a'.charCodeAt(0);
for (let i = 0; i < n; i++) {
    a[i] = 1 << (t.charCodeAt(i) - CODE_A);
}
const d = new Int32Array(n);
d[0] = 0|0;
for (let v = 1; v < n; v++) {
    d[v] = (d[par[v]] + 1)|0;
}
const hs = new Int32Array(m);
const vs = new Int32Array(m);
const ct = new Int32Array(n + 1);
const iter = new Int32Array(n);
const qs = new Int32Array(m);
const ans = new Array(m);
for (let i = 0; i < m; i++) {
    const v = (nextInt() - 1)|0, h = (nextInt() - 1)|0;
    hs[i] = (h - d[v])|0;
    vs[i] = v;
    ct[v + 1]++;
}
for (let i = 0; i < n; i++) {
    ct[i + 1] += ct[i];
}
for (let i = 0; i < m; i++) {
    let v = vs[i];
    qs[ct[v] + iter[v]] = i;
    iter[v]++;
}
const dp = new Array(n);
for (let v = n - 1; v >= 0; v--) {
    if (!dp[v]) dp[v] = new Array;
    let t1 = dp[v];
    t1.push(a[v]);
    for (let p = ct[v]; p < ct[v + 1]; p++) {
        const i = qs[p];
        const h = hs[i];
        if (h < 0 || t1.length <= h) {
            ans[i] = 'Yes';
        } else {
            const len = t1.length;
            const x = t1[len - 1 - h];
            ans[i] = ((x === 0) || ((x & (x - 1)) === 0))
                ? 'Yes' : 'No';
        }
    }
    if (v == 0) break;
    const p = par[v];
    let t2 = dp[p];
    if (!t2) {
        dp[p] = t1;
    } else {
        if (t1.length > t2.length) {
            let t = t1;
            t1 = t2;
            t2 = t;
        }
        const len1 = t1.length, len2 = t2.length;
        for (let i = 0; i < len1; i++) {
            t2[len2 - i - 1] ^= t1[len1 - i - 1];
        }
        dp[p] = t2;
    }
}
write(ans.join('\n'));

'use strict';
let _in = (function*() {
    for (;;) {
        let line = readline().split(/\s+/);
        for (let word of line) {
            yield word;
        }
    }
})();
let next = () => _in.next().value;
let nextInt = () => parseInt(next());
let nextFloat = () => parseFloat(next());
let binarySearch = (lb, ub, f) => {
    while (ub - lb > 1) {
        let mid = (ub + lb) >> 1;
        if (f(mid)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    return ub;
}

let n = nextInt(), m = nextInt();
let g = new Array(n);
let vs = new Array(n);
for (let i = 0; i < n; i++) {
    g[i] = new Array;
    vs[i] = new Array;
}
for (let i = 1; i < n; i++) {
    let p = nextInt() - 1;
    g[p].push(i);
}
let t = next();
let a = new Uint32Array(n);
const CODE_A = 'a'.charCodeAt(0);
for (let i = 0; i < n; i++) {
    a[i] = 1 << (t.charCodeAt(i) - CODE_A);
}
let d = new Int32Array(n);
let D = 0;
d[0] = 0;
for (let v = 0; v < n; v++) {
    vs[d[v]].push(v);
    D = Math.max(D, d[v]);
    for (let u of g[v]) {
        d[u] = d[v] + 1;
    }
}
D++;

let lid = new Int32Array(n);
let rid = new Int32Array(n);
let st = new Int32Array(2 * n);
let p = 0;
let id = 0;
st[p++] = 0;
while (p > 0) {
    let v = st[--p];
    if (v < n) {
        lid[v] = id++;
        st[p++] = v + n;
        for (let u of g[v]) {
            st[p++] = u;
        }
    } else {
        v -= n;
        rid[v] = id++;
    }
}

let s = new Array(n);
for (let d = 0; d < D; d++) {
    s[d] = new Uint32Array(vs[d].length + 1);
}
for (let d = 0; d < D; d++) {
    for (let i = 0; i < vs[d].length; i++) {
        s[d][i + 1] ^= a[vs[d][i]] ^ s[d][i];
    }
}

let buf = [];
while (m--) {
    let v = nextInt() - 1, h = nextInt() - 1;
    let l = binarySearch(-1, vs[h].length, function (mid) {
        return lid[vs[h][mid]] < lid[v];
    });
    let r = binarySearch(-1, vs[h].length, function (mid) {
        return lid[vs[h][mid]] < rid[v];
    });
    let x = s[h][r] ^ s[h][l];
    if (x == 0 || (x & (x - 1)) == 0) {
        buf.push('Yes');
    } else {
        buf.push('No');
    }
}
print(buf.join('\n'));

'use strict';
let _in = (function*() {
    for (;;) {
        let line = readline().split(/\s+/);
        for (let word of line) {
            yield word;
        }
    }
})();
let next = () => _in.next().value;
let nextInt = () => parseInt(next());
let nextFloat = () => parseFloat(next());
let upperBound = (a, v) => {
    let ub = a.length, lb = 0;
    while (ub - lb > 1) {
        let mid = (ub + lb) >> 1;
        if (a[mid] <= v) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    return ub;
}

let n = nextInt(), m = nextInt();
let g = new Array(n);
let vs = new Array(n);
for (let i = 0; i < n; i++) {
    g[i] = new Array;
    vs[i] = new Array;
}
for (let i = 1; i < n; i++) {
    let p = nextInt() - 1;
    g[p].push(i);
}
let t = next();
let a = new Uint32Array(n);
const CODE_A = 'a'.charCodeAt(0);
for (let i = 0; i < n; i++) {
    a[i] = 1 << (t.charCodeAt(i) - CODE_A);
}
let d = new Int32Array(n);
let D = 0;
d[0] = 0;
for (let v = 0; v < n; v++) {
    for (let u of g[v]) {
        d[u] = d[v] + 1;
        vs[d[u]].push(u);
        D = Math.max(D, d[u]);
    }
}
D++;

let lid = new Int32Array(n);
let rid = new Int32Array(n);
function dfs(v, id) {
    lid[v] = id;
    for (let u of g[v]) {
        id = dfs(u, id + 1);
    }
    return rid[v] = id + 1;
};
dfs(0, 0);

let s = new Array(D);
for (let d = 0; d < D; d++) {
    s[d] = new Uint32Array(vs[d].length + 1);
}
for (let d = 0; d < D; d++) {
    for (let i = 0; i < vs[d].length; i++) {
        s[i + 1] ^= a[i];
    }
}

let buf = [];
while (m--) {
    let v = nextInt() - 1, h = nextInt() - 1;
    let l = upperBound(vs[h], lid[v]);
    let r = upperBound(vs[h], rid[v]) - 1;
    if (l == r) {
        buf.push('No');
        continue;
    }
    let x = s[r] ^ s[l];
    if (x == 0 || (x & (x - 1)) == 0) {
        buf.push('Yes');
    } else {
        buf.push('No');
    }
}
print(buf.join('\n'));

'use strict';
let _in = (function*() {
    for (;;) {
        let line = readline().split(/\s+/);
        for (let word of line) {
            yield word;
        }
    }
})();
let next = () => _in.next().value;
let nextInt = () => parseInt(next());
let nextFloat = () => parseFloat(next());
let upperBound = (a, v) => {
    let ub = a.length, lb = 0;
    while (ub - lb > 1) {
        let mid = (ub + lb) >> 1;
        if (a[mid] <= v) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    return ub;
}

let n = nextInt(), m = nextInt();
let g = new Array(n);
let vs = new Array(n);
for (let i = 0; i < n; i++) {
    g[i] = new Array;
    vs[i] = new Array;
}
for (let i = 1; i < n; i++) {
    let p = nextInt() - 1;
    g[p].push(i);
}
let t = next();
let a = new Uint32Array(n);
const CODE_A = 'a'.charCodeAt(0);
for (let i = 0; i < n; i++) {
    a[i] = 1 << (t.charCodeAt(i) - CODE_A);
}
let d = new Int32Array(n);
let D = 0;
d[0] = 0;
for (let v = 0; v < n; v++) {
    for (let u of g[v]) {
        d[u] = d[v] + 1;
        vs[d[u]].push(u);
        D = Math.max(D, d[u]);
    }
}
D++;

let lid = new Int32Array(n);
let rid = new Int32Array(n);
function dfs(v, id) {
    lid[v] = id;
    for (let u of g[v]) {
        id = dfs(u, id + 1);
    }
    return rid[v] = id + 1;
};
dfs(0, 0);
for (let v = 0; v < n; v++) {
    print(v, lid[v], rid[v]);
}

let s = new Array(D);
for (let d = 0; d < D; d++) {
    s[d] = new Uint32Array(vs[d].length + 1);
}
for (let d = 0; d < D; d++) {
    for (let i = 0; i < vs[d].length; i++) {
        s[i + 1] ^= a[i];
    }
}

let buf = [];
while (m--) {
    let v = nextInt() - 1, h = nextInt() - 1;
    let l = upperBound(vs[h], lid[v]);
    let r = upperBound(vs[h], rid[v]) - 1;
    if (l == r) {
        buf.push('No');
        continue;
    }
    let x = s[r] ^ s[l];
    if (x == 0 || (x & (x - 1)) == 0) {
        buf.push('Yes');
    } else {
        buf.push('No');
    }
}
print(buf.join('\n'));

'use strict';
let _in = (function*() {
    for (;;) {
        let line = readline().split(/\s+/);
        for (let word of line) {
            yield word;
        }
    }
})();
let next = () => _in.next().value;
let nextInt = () => next()|0;
let nextFloat = () => +next();

let n = nextInt(), m = nextInt();
let par = new Int32Array(n);
for (let i = 1; i < n; i++) {
    par[i] = nextInt() - 1;
}
let t = next();
let a = new Uint32Array(n);
const CODE_A = 'a'.charCodeAt(0);
for (let i = 0; i < n; i++) {
    a[i] = 1 << (t.charCodeAt(i) - CODE_A);
}
let d = new Int32Array(n);
d[0] = 0;
for (let v = 1; v < n; v++) {
    d[v] = d[par[v]] + 1;
}
let hs = new Int32Array(m);
let qs = new Array(n);
let ans = new Array(m);
for (let i = 0; i < m; i++) {
    let v = nextInt() - 1, h = nextInt() - 1;
    hs[i] = h - d[v];
    if (!qs[v]) qs[v] = new Array;
    qs[v].push(i);
}
let dp = new Array(n);
for (let v = n - 1; v >= 0; v--) {
    if (!dp[v]) {
        dp[v] = new Array;
    }
    dp[v].push(a[v]);
    if (qs[v] != null) {
        for (let i of qs[v]) {
            let h = hs[i];
            if (h < 0 || dp[v].length <= h) {
                ans[i] = 'Yes';
            } else {
                let len = dp[v].length;
                let x = dp[v][len - 1 - h];
                ans[i] = ((x === 0) || ((x & (x - 1)) === 0))
                    ? 'Yes' : 'No';
            }
        }
    }
    if (v == 0) break;
    let p = par[v];
    if (!dp[p]) {
        dp[p] = dp[v];
    } else {
        let t1 = dp[v], t2 = dp[p];
        if (t1.length > t2.length) {
            let t = t1;
            t1 = t2;
            t2 = t;
        }
        let len = t2.length;
        for (let i = 0; i < t1.length; i++) {
            t2[i] ^= t1[len - 1 - i];
        }
        dp[p] = t2;
    }
}
print(ans.join('\n'));


Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expressed as the sum of a number in the same row and a number in the same column. In other words, for every x, y such that 1 ≤ x, y ≤ n and ax, y ≠ 1, there should exist two indices s and t so that ax, y = ax, s + at, y, where ai, j denotes the integer in i-th row and j-th column.Help Okabe determine whether a given lab is good!

The first line of input contains the integer n (1 ≤ n ≤ 50) — the size of the lab.  The next n lines contain n space-separated integers denoting a row of the grid. The j-th integer in the i-th row is ai, j (1 ≤ ai, j ≤ 105).

Print "Yes" if the given lab is good and "No" otherwise. You can output each letter in upper or lower case.

NoteIn the first sample test, the 6 in the bottom left corner is valid because it is the sum of the 2 above it and the 4 on the right. The same holds for every number not equal to 1 in this table, so the answer is "Yes".In the second sample test, the 5 cannot be formed as the sum of an integer in the same row and an integer in the same column. Thus the answer is "No".

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
const lab = [];

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  lab.push(d.split(' ').map(Number));

  c++;
});

rl.on('close', () => {
  let ans = 'YES';

  isDone:
  for (let i = 0; i < lab.length; i++) {
    for (let j = 0; j < lab[i].length; j++) {
      if (lab[i][j] !== 1) {

          ans = 'NO';
          for (let t = 0; t < lab.length; t++) {
            for (let s = 0; s < lab[t].length; s++) {
              let sum = lab[t][j] + lab[i][s];

              if (t !== i && s !== j) {
                if (sum === lab[i][j]) {
                  ans = 'YES';
                }
              }
            }
          }

          if (ans === 'NO') {
            break isDone;
          }

      }
    }
  }

  console.log(ans);
});

var n = parseInt(readline()),
	arr = [],
	flag = true;
function mapper(x) {return parseInt(x);}
for (var i = 0; i < n; i++) {
	var temp = [];
	var inp = readline().split(" ").map(mapper);
	arr.push(inp);
}

function checker(i, j) {
	for (var c = 0; c < n; c++) {
		if (c == j)
			continue;
		for (var r = 0; r < n; r++) {
			if (r == i)
				continue;
			if (arr[i][c] + arr[r][j] == arr[i][j])
				return true;
		}
	}
	return false;
}

for (var i = 0; i < n; i++) {
	for (var j = 0; j < n && flag; j++) {
		if (arr[i][j] != 1 && !checker(i, j)) {
			flag = false;
			break;
		}
	}
}

print((flag ? "Yes": "No"));

var n = Number(readline());
var arr = [];
for(var i=0; i<n; i++) {
    var line = readline().split(" ").map(Number);
    arr.push(line);
}

var res = 'Yes';
cyclePar:
for(var i=0; i<n; i++) {
    for(var j=0; j<n; j++) {
        var cur = arr[i][j];
        if (cur!=1) {
            var found = false;
            cycle:
            for(var k=0; k<n; k++) {
                for(var z=0; z<n; z++) {
                    if (i!=k && j!=z) {
                        if (arr[k][j] + arr[i][z] == cur){
                            found = true;
                            break cycle;
                        }
                    }
                }
            }
            if (!found) {
                res = 'No';
                break cyclePar;
            }
        }
    }
}

print(res);

var n = Number(readline());
var arr = [];
for(var i=0; i<n; i++) {
    var line = readline().split(" ").map(Number);
    arr.push(line);
}

var res = 'Yes';
for(var i=0; i<n; i++) {
    for(var j=0; j<n; j++) {
        var cur = arr[i][j];
        if (cur!=1) {
            var found = false;
            for(var k=0; k<n; k++) {
                for(var z=0; z<n; z++) {
                    if (i!=k && j!=z) {
                        if (arr[k][j] + arr[i][z] == cur){
                            found = true;
                            break;
                        }
                    }
                }

            }
        if (!found) {
            res = 'No';
            break;
        }
        }
    }
}

print(res);

var n = +readline();
var tab = [];
var ans = 'Yes';
for (var i=0; i<n; i++){
	tab[i] = readline().split(' ').map(Number);
}
for (var i=0; i<n; i++){
	next: for (var j=0; j<n; j++){
		if (tab[i][j] != 1) {
			for (var k=0; k<n; k++){
				for (var l=0; l<n; l++){
					if (i != l && j != k){
						if (tab[i][j] == tab[i][k] + tab[l][j]) {
							continue next;
						}
					}
				}
			}
		}
		if (tab[i][j] != 1) {
			ans = 'No';
			break;
		}
	}
}
print(ans);


Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers.Unfortunately, the size of a is too small. You want a bigger array! Your friends agree to give you a bigger array, but only if you are able to answer the following question correctly: is it possible to sort the array a (in increasing order) by reversing exactly one segment of a? See definitions of segment and reversing in the notes.

The first line of the input contains an integer n (1 ≤ n ≤ 105) — the size of array a. The second line contains n distinct space-separated integers: a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ 109).

Print "yes" or "no" (without quotes), depending on the answer. If your answer is "yes", then also print two space-separated integers denoting start and end (start must not be greater than end) indices of the segment to be reversed. If there are multiple ways of selecting these indices, print any of them.

NoteSample 1. You can reverse the entire array to get [1, 2, 3], which is sorted.Sample 3. No segment can be reversed such that the array will be sorted.DefinitionsA segment [l, r] of array a is the sequence a[l], a[l + 1], ..., a[r].If you have an array a of size n and you reverse its segment [l, r], the array will become:a[1], a[2], ..., a[l - 2], a[l - 1], a[r], a[r - 1], ..., a[l + 1], a[l], a[r + 1], a[r + 2], ..., a[n - 1], a[n].

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
    let clone = [...a]
    clone.sort((a1,a2)=>a1 - a2)
    let left = -1
    let right = -1
    for (let i = 0; i < n; i++) {
        if (a[i] !== clone[i]) {
            left = i
            break;
        }
    }

    for (let i = n - 1; i >= 0; i--) {
        if (a[i] !== clone[i]) {
            right = i
            break;
        }
    }

    if (left === -1 && right === -1) {
        console.log('yes')
        console.log(1 + ' ' + 1)
        return
    }

    for (let i = 0; i < Math.floor(right - left); i++) {
        if (a[left + i] !== clone[right - i]) {
            console.log('no')
            return
        }
    }

    console.log('yes')
    console.log((left + 1) + ' ' + (right + 1))
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const n = parseInt(readLine(), 10);
    const arr = readLine().split(' ').map(Number);

    const result = sortTheArray(n, arr);
    printResult(result);
}

function reverseByIndex(a, left, right) {
    const temp = [];
    for (let i = left, j = right; i <= right; i++, j--) temp[i] = a[j];
    for (let i = left; i <= right; i++) a[i] = temp[i];
}

const sortTheArray = (n, a) => {
    let left = 0;
    let right = 0;
    let flag = false;
    for (let i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            left = i;
            break;
        }
    }

    for (let i = n - 1; i >= left; i--) {
        if (a[i] < a[i - 1]) {
            right = i;
            break;
        }
    }

    reverseByIndex(a, left, right);

    for (let i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            return `no`;
        }
    }

    return `yes\n${left + 1} ${right + 1}`;
};

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const n = parseInt(readLine(), 10);
    const arr = readLine().split(' ').map(Number);

    const result = sortTheArray(n, arr);
    printResult(result);
}

function reverseByIndex(a, left, right) {
    const temp = new Array(a.length);
    for (let i = left, j = right; i <= right; i++, j--) temp[i] = a[j];
    for (let i = left; i <= right; i++) a[i] = temp[i];
}

const sortTheArray = (n, a) => {
    let left = 0;
    let right = 0;
    for (let i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            left = i;
            break;
        }
    }

    for (let i = n - 1; i >= left; i--) {
        if (a[i] < a[i - 1]) {
            right = i;
            break;
        }
    }

    reverseByIndex(a, left, right);

    for (let i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            return `no`;
        }
    }

    return `yes\n${left + 1} ${right + 1}`;
};

let isSorted = arr => arr.every((v, i, a) => !i || a[i - 1] <= v)
const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        sortedArr = lines[1].split(" ").map(Number),
        mas = []
    if (isSorted(arr)) {
        console.log(`yes\n1 1`)
        return 0
    }
    sortedArr.sort((a, b) => a - b)
    for (let i in arr) {
        if (arr[i] != sortedArr[i])
            mas.push(+i + 1)
    }
    mas.sort((a, b) => a - b)
    arr = arr.slice(mas[0] - 1, mas[mas.length - 1])
    sortedArr = sortedArr.slice(mas[0] - 1, mas[mas.length - 1]).reverse()
    if (arr.join(" ") == sortedArr.join(" ")) console.log(`yes\n${mas[0]} ${mas[mas.length - 1]}`)
    else console.log(`no`)
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

let isSorted = arr => arr.every((v, i, a) => !i || a[i - 1] <= v)
const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        sortedArr = lines[1].split(" ").map(Number),
        n = arr.length,
        cnt = 0,
        mas = []
    if (isSorted(arr)) {
        console.log(`yes\n1 1`)
        return 0
    }
    sortedArr.sort((a, b) => a - b)
    for (let i in arr) {
        if (arr[i] != sortedArr[i]) {
            cnt++;
            mas.push(+i + 1)
        }
    }
    mas.sort((a, b) => a - b)
    arr = arr.slice(mas[0] - 1, mas[mas.length - 1])
    sortedArr = sortedArr.slice(mas[0] - 1, mas[mas.length - 1]).reverse()
    if (arr.join(" ") == sortedArr.join(" ")) console.log(`yes\n${mas[0]} ${mas[mas.length - 1]}`)
    else console.log(`no`)
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function processData(input) {
    //Enter your code here
     input = input.split('\n')
    var n = Number(input[0])
    var arr = input[1].split(' ').map(a=>parseInt(a))
    var tempArr = [...arr]
    // console.log(tempArr)
    tempArr.sort((a,b)=>(a-b))
    // console.log(tempArr,arr)
    var ans
    var res = checkReverse(arr,tempArr,n)    //finding first mismatch

    if(res){
        console.log("yes")
    }
    else{
        console.log("no")
    }
    function checkReverse(arr,tempArr,n){
        //to find the first index mismatch
        for(var first = 0;first < n;first++){
            if(tempArr[first] != arr[first]){
                break
            }
        }
        //to find the last mismatch
        for(var last = n-1;last >=0 ;last--){
              if(tempArr[last] != arr[last]){
                break
            }
        }
    if(first >= last){
                ans = [first-n+1,first-n+1]
            return true
        }
        //to check decreasing array
        ans = [first+1,last+1]
        while(first != last){
            first++
            if(arr[first-1] < arr[first]){
                return false
            }

        }

        return true
    }
    if(res){
            console.log(ans.join(' '))

    }
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

		var l=readline();
	var s=readline().split(" ");
	var f=0,max=0,min=0,maxi=1,mini=1;

		for(var i=0;i<s.length-1;i++){
			if(parseInt(s[i])>parseInt(s[i+1])){if(parseInt(s[i])>max){max=parseInt(s[i]);f++;mini=i+1;}
			if(i===s.length-2){min=parseInt(s[i+1]);maxi=i+2;}}
			else{if(f===1&&min===0&&max<parseInt(s[i+1])){min=parseInt(s[i]);maxi=i+1;}else if(f>1||parseInt(s[i+1])<max){break;}}
		}
	if(f===0){print("yes\n"+mini+" "+maxi);}
	else if(f===1&&max!==0&&min!==0){if(mini>1){if(min>parseInt(s[mini-2])){print("yes\n"+mini+" "+maxi);}else{print("no");}}else{print("yes\n"+mini+" "+maxi);}}
	else{print("no");}

;(function() {

	print((function (n, x) {
		for (var i = 0; i < n; i++) if (x[i] !== i) break;
		for (var j = n - 1; j >= 0; j--) if (x[j] !== j) break;
		if (i === n && j === -1) return 'yes\n1 1';
		for (var k = i; k < j; k++) if (x[k] - x[k+1] !== 1) return 'no';
		if (x[j] === i && x[i] === j) return 'yes\n' + (i + 1) + ' ' + (j + 1);
		return 'no';
	})(+readline(), readline().split(' ').map(function (e, i) { return {n: parseInt(e), i: i}; })
		.sort(function (a, b) { return a.n - b.n; }).map(function (e) { return e.i; })));

}).call(this);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline()),
		a = tokenizeIntegers(readline());
	if (n == 1) {
		return 'yes\n1 1';
	}
	for (var i = 1; i < n; ++i) {
		if (a[i] < a[i-1]) {
			for (var j = i; a[j] < a[j-1] && j < n; ++j) {
			}
			var start = i-1, finish = j-1;
			for (var p = Math.floor((start+finish)/2); p >= start; --p) {
				var q = finish - p + start,
					t = a[p];
				a[p] = a[q];
				a[q] = t;
			}
			for (var k = 1; k < n; ++k) {
				if (a[k] < a[k-1]) {
					return 'no';
				}
			}
			return 'yes\n'+(start+1)+' '+(finish+1);
		}
	}
	return 'yes\n1 1';
}

print(main());

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
  let clone = [...a]
  clone.sort((a1, a2) => a1 - a2)
  let differences = []
  for (let i = 0; i < n; i++) {
    if (a[i] !== clone[i]) {
      differences.push(i + 1)
    }
    if (differences.length > 2) {
      console.log('no')
      return
    }
  }

  if (differences.length === 2) {
    console.log('yes')
    console.log(differences[0] + ' ' + differences[1])
  } else {
    console.log('no')
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
  let clone = [...a]
  clone.sort((a1, a2) => a1 - a2)
  let left = -1
  let right = -1
  for (let i = 0; i < n; i++) {
    if (a[i] !== clone[i]) {
      if (left === -1) {
        left = i
        right = i
      } else {
        right = i
      }
    }
  }

  if (left === -1 && right === -1) {
    console.log('yes')
    console.log(1 + ' ' + 1)
    return
  }

  for (let i = 0; i <= Math.floor((right - left) / 2); i++) {
    if (a[left + i] !== clone[right - i]) {
      console.log('no')
      return
    }
  }

  console.log('yes')
  console.log((left + 1) + ' ' + (right + 1))
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
    let clone = [...a]
    clone.sort((a1,a2)=>a1 - a2)
    let left = -1
    let right = -1
    for (let i = 0; i < n; i++) {
        if (a[i] !== clone[i]) {
            left = i
            break;
        }
    }

    for (let i = n - 1; i >= 0; i--) {
        if (a[i] !== clone[i]) {
            right = i
            break;
        }
    }

    if (left === -1 && right === -1) {
        console.log('yes')
        console.log(1 + ' ' + 1)
        return
    }

    for (let i = 0; i <= Math.floor((right - left) / 2); i++) {
        if (a[left + i] !== clone[right - i]) {
            console.log('no')
            return
        }
    }

    console.log('yes')
    console.log((left + 1) + ' ' + (right + 1))
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
    let clone = [...a]
    clone.sort((a1,a2)=>a1 - a2)
    let left = -1
    let right = -1
    for (let i = 0; i < n; i++) {
        if (a[i] !== clone[i]) {
            left = i
            break;
        }
    }

    for (let i = n - 1; i >= 0; i--) {
        if (a[i] !== clone[i]) {
            right = i
            break;
        }
    }

    if (left === -1 && right === -1) {
        console.log('yes')
        console.log(1 + ' ' + 1)
        return
    }

    for (let i = 0; i < Math.floor((right - left) / 2); i++) {
        if (a[left + i] !== clone[right - i]) {
            console.log('no')
            return
        }
    }

    console.log('yes')
    console.log((left + 1) + ' ' + (right + 1))
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
  let clone = [...a]
  clone.sort((a1, a2) => a1 - a2)
  let differences = []
  for (let i = 0; i < n; i++) {
    if (a[i] !== clone[i]) {
      differences.push(i + 1)
    }
    if (differences.length > 2) {
      console.log('no')
      return
    }
  }

  if (differences.length === 2) {
    console.log('yes')
    console.log(differences[0] + ' ' + differences[1])
  } else if (differences.length === 0) {
    console.log('yes')
    console.log(1 + ' ' + 1)
  } else {
    console.log('no')
  }
}

let isSorted = arr => arr.every((v, i, a) => !i || a[i - 1] <= v)
const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        sortedArr = lines[1].split(" ").map(Number),
        n = arr.length,
        cnt = 0,
        mas = []
    if (isSorted(arr)) {
        console.log(`yes\n1 1`)
        return 0
    }
    sortedArr.sort((a, b) => a - b)
    for (let i in arr) {
        if (arr[i] != sortedArr[i]) {
            cnt++;
            mas.push(+i + 1)
        }
    }
    mas.sort((a, b) => a - b)
    console.log(mas)
    arr = arr.slice(mas[0] - 1, mas[mas.length - 1])
    sortedArr = sortedArr.slice(mas[0] - 1, mas[mas.length - 1]).reverse()
    console.log(arr, sortedArr)
    if (arr.join(" ") == sortedArr.join(" ")) console.log(`yes\n${mas[0]} ${mas[mas.length - 1]}`)
    else console.log(`no`)
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

	var l=readline();
	var s=readline().split(" ");
	var f=0,max=0,min=0,maxi=1,mini=1;

		for(var i=0;i<s.length-1;i++){
			if(parseInt(s[i])>parseInt(s[i+1])){if(parseInt(s[i])>max){max=parseInt(s[i]);f++;mini=i+1;}
			if(i===s.length-2){if(mini-2>=0){if(parseInt(s[i+1])>parseInt(s[mini-2])){min=parseInt(s[i+1]);maxi=i+2;}}else if(mini-2===-1){min=parseInt(s[i+1]);maxi=i+2;}}}
			else{if(f===1&&min===0&&max<parseInt(s[i+1])&&parseInt(s[i])>parseInt(s[mini-2])){min=parseInt(s[i]);maxi=i+1;}else if(f>1||parseInt(s[i+1])<max){break;}}
		}
	if(f===0){print("yes\n"+mini+" "+maxi);}
	else if(f===1&&max!==0&&min!==0){print("yes\n"+mini+" "+maxi);}
	else{print("no");}

 	var l=readline();
	var s=readline().split(" ");
	var f=0,max=0,min=0;

		for(var i=0;i<s.length-1;i++){
			if(parseInt(s[i])>parseInt(s[i+1])){if(parseInt(s[i])>max){max=parseInt(s[i]);f++;}if(i===s.length-2){min=parseInt(s[i+1]);}}
			else{if(f===1&&min===0&&max<parseInt(s[i+1])){min=parseInt(s[i]);}else if(f>1||parseInt(s[i+1])<max){break;}}
		}
	if(f===0){print("yes\n"+s[0]+" "+s[0]);}
	else if(f===1&&max!==0&&min!==0){print("yes\n"+min+" "+max);}
	else{print("no");}

	var l=readline();
	var s=readline().split(" ");
	var f=0,max=0,min=0,maxi=1,mini=1;

		for(var i=0;i<s.length-1;i++){
			if(parseInt(s[i])>parseInt(s[i+1])){if(parseInt(s[i])>max){max=parseInt(s[i]);f++;mini=i+1;}
			if(i===s.length-2){if(mini-2>=0){if(parseInt(s[i+1])>parseInt(s[mini-2])){min=parseInt(s[i+1]);maxi=i+2;}}}}
			else{if(f===1&&min===0&&max<parseInt(s[i+1])&&parseInt(s[i])>parseInt(s[mini-2])){min=parseInt(s[i]);maxi=i+1;}else if(f>1||parseInt(s[i+1])<max){break;}}
		}
	if(f===0){print("yes\n"+mini+" "+maxi);}
	else if(f===1&&max!==0&&min!==0){print("yes\n"+mini+" "+maxi);}
	else{print("no");}

var l=readline();
	var s=readline().split(" ");
	var f=0,max=0,min=0,maxi=1,mini=1;

		for(var i=0;i<s.length-1;i++){
			if(parseInt(s[i])>parseInt(s[i+1])){if(parseInt(s[i])>max){max=parseInt(s[i]);f++;mini=i+1;}
			if(i===s.length-2){min=parseInt(s[i+1]);maxi=i+2;}}
			else{if(f===1&&min===0&&max<parseInt(s[i+1])){min=parseInt(s[i]);maxi=i+1;}else if(f>1||parseInt(s[i+1])<max){break;}}
		}
	if(f===0){print("yes\n"+mini+" "+maxi);}
	else if(f===1&&max!==0&&min!==0){if(mini>1){if(min>parseInt(s[mini-2])){print("yes\n"+mini+" "+maxi);}}else{print("yes\n"+mini+" "+maxi);}}
	else{print("no");}

	var l=readline();
	var s=readline().split(" ");
	var f=0,max=0,min=0,maxi=1,mini=1;

		for(var i=0;i<s.length-1;i++){
			if(parseInt(s[i])>parseInt(s[i+1])){if(parseInt(s[i])>max){max=parseInt(s[i]);f++;mini=i+1;}
			if(i===s.length-2){min=parseInt(s[i+1]);maxi=i+2;}}
			else{if(f===1&&min===0&&max<parseInt(s[i+1])){min=parseInt(s[i]);maxi=i+1;}else if(f>1||parseInt(s[i+1])<max){break;}}
		}
	if(f===0){print("yes\n"+mini+" "+maxi);}
	else if(f===1&&max!==0&&min!==0){print("yes\n"+mini+" "+maxi);}
	else{print("no");}

	var l=readline();
	var s=readline().split(" ");
	var f=0,max=0,min=0;

		for(var i=0;i<s.length-1;i++){
			if(parseInt(s[i])>parseInt(s[i+1])){if(parseInt(s[i])>max){max=parseInt(s[i]);f++;}if(i===s.length-2){min=parseInt(s[i+1]);}}
			else{if(f===1&&min===0&&max<parseInt(s[i+1])){min=parseInt(s[i]);}else if(f>1||parseInt(s[i+1])<max){break;}}
		}
	if(f===0){print(s[0]+" "+s[0]);}
	else if(f===1&&max!==0&&min!==0){print("yes\n"+min+" "+max);}
	else{print("no");}

;(function() {

	print((function (n, x) {
		for (var i = 0; i < n; i++) if (x[i] !== i) break;
		for (var j = n - 1; j >= 0; j--) if (x[j] !== j) break;
		if (i === n - 1 && j === 1) return 'yes\n1 1';
		for (var k = i; k < j; k++) if (x[k] - x[k+1] !== 1) return 'no';
		return (x[j] === i && x[i] === j) ? 'yes\n' + (i + 1) + ' ' + (j + 1) : 'no';
	})(+readline(), readline().split(' ').map(function (e, i) { return {n: parseInt(e), i: i}; })
		.sort(function (a, b) { return a.n - b.n; }).map(function (e) { return e.i; })));

}).call(this);

;(function() {

	print((function (n, x) {
		for (var i = 0; i < n; i++) if (x[i] !== i) break;
		for (var j = n - 1; j >= 0; j--) if (x[j] !== j) break;
		if (i === n && j === -1) return 'yes\n1 1';
		for (var k = j; k < i; k++) if (x[j] - x[j-1] !== 1) return 'no';
		if (x[j] === i && x[i] === j) return 'yes\n' + (i + 1) + ' ' + (j + 1);
		return 'no';
	})(+readline(), readline().split(' ').map(function (e, i) { return {n: parseInt(e), i: i}; })
		.sort(function (a, b) { return a.n - b.n; }).map(function (e) { return e.i; })));

}).call(this);

;(function() {

	var n = +readline(),
		x = readline().split(' ')
			.map(function (e, i) { return {n: parseInt(e), i: i}; })
			.sort(function (a, b) { return a.n - b.n; })
			.map(function (e) { return e.i; });

	print((function () {
		for (var i = 0; i < n; i++) if (x[i] !== i) break;
		for (var j = n - 1; j >= 0; j--) if (x[j] !== j) break;
		if (i === (n - 2) && j === 1) return 'yes\n1 1';
		for (var k = j; k < i; k++) if (x[j] - x[j-1] !== 1) return 'no';
		if (x[j] === i && x[i] === j) return 'yes\n' + (i + 1) + ' ' + (j + 1);
		return 'no';
	})());

}).call(this);

;(function() {

	var n = +readline(),
		a = readline().split(' ').map(Number).reduce(function (p, e, i, a) {
			if (p.push(i) !== a.length) return p;
			p = p.sort(function (_, $) { return a[_] - a[$]; });

			var max = [], min = [];

			if (p[0] > p[1]) max.push(1);

			for (var i = 1; i < n - 1; i++)
				if (p[i] > p[i+1] && p[i] > p[i-1]) max.push(i + 1);
				else if (p[i] < p[i+1] && p[i] < p[i-1]) min.push(i + 1);

			if (p[n - 1]  < p[n - 2]) min.push(n);

			return [max, min];
		}, []);

		print((function () {
			if (!a[0].length && !a[1].length) return 'yes\n1 1';
			if (a[0].length > 1) return 'no';
			return 'yes\n' + a[0][0] + ' ' + a[1][0];
		})());

}).call(this);


Vasya commutes by train every day. There are n train stations in the city, and at the i-th station it's possible to buy only tickets to stations from i + 1 to ai inclusive. No tickets are sold at the last station.Let ρi, j be the minimum number of tickets one needs to buy in order to get from stations i to station j. As Vasya is fond of different useless statistic he asks you to compute the sum of all values ρi, j among all pairs 1 ≤ i < j ≤ n.

The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of stations. The second line contains n - 1 integer ai (i + 1 ≤ ai ≤ n), the i-th of them means that at the i-th station one may buy tickets to each station from i + 1 to ai inclusive.

Print the sum of ρi, j among all pairs of 1 ≤ i < j ≤ n.

NoteIn the first sample it's possible to get from any station to any other (with greater index) using only one ticket. The total number of pairs is 6, so the answer is also 6.Consider the second sample:   ρ1, 2 = 1  ρ1, 3 = 2  ρ1, 4 = 3  ρ1, 5 = 3  ρ2, 3 = 1  ρ2, 4 = 2  ρ2, 5 = 2  ρ3, 4 = 1  ρ3, 5 = 1  ρ4, 5 = 1 Thus the answer equals 1 + 2 + 3 + 3 + 1 + 2 + 2 + 1 + 1 + 1 = 17.

(function () {
	var n = parseInt(readline());
	var a = readline().split(' ').map(function (ele) {
		return parseInt(ele);
	});
	a.push(n);
	var dp = [];
	var tr = (function (n, a) {
		var arr = [];
		for(var i = 0 ;i<n;++i) {
			arr.push(-1);
		}
		function add (p, v) {
			while(p<n) {
				var tmp = arr[p]==-1? 0 : a[arr[p]];
				//print(p);
				arr[p] = a[v]>tmp?v:arr[p];
				p+=p&(-p);
			}
		}
		function find (p) {
			var ret = p-1;
			while(p>0) {
				var tmp = arr[p]==-1? 0 : a[arr[p]];
				ret = a[ret]>tmp?ret:arr[p];
				p-=p&(-p);
			}
			return ret;
		}
		return {
			add: add,
			find: find
		}
	})(n+1, a);
	dp[n-1] = 0;
	tr.add(n,n-1);
	//print(dp[n]);
	for(var i=n-2;i>=0;--i) {
		var p = tr.find(a[i]);
		dp[i] = dp[p] + n - i - 1 - (a[i] - p - 1);
		//print(p);
		//print(dp[i]);
		tr.add(i+1,i);
	}
	for(i=1;i<n;++i)
		dp[i]+=dp[i-1];
	print(dp[n-1]);
})();


Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.

The first line contains integer n (1 ≤ n ≤ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.

In a single line print the answer to the problem — the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.

NoteIn the first test you can make only one number that is a multiple of 90 — 0.In the second test you can make number 5555555550, it is a multiple of 90.

var n=+readline();
var a=readline().split(' ');

var five=0;
var zero=0;
a.forEach(function(v){
	if(v==='5'){
		five++;
	}else{
		zero++;
	}
});

five=Math.floor(five/9);
if(zero==0){
	print(-1);
}else if(five==0){
	print(0)
}else{
	var ans=[];
	//var k=Math.min(five,zero);
	for(var i=0;i<five;i++){
		ans.push('555555555');
	}
	while(zero--){
		ans.push('0')
	}
	print(ans.join(''));
}

;(function () {
	var n = +readline();

	var c = 0;
	var d = 0;

	readline().split(' ').map(function (e) {
		if (e == 0) c++;
		else d++;
	});

	if (!c) {
		print(-1);
		return;
	}

	var str = '';
	for (var i = 0; i < Math.floor(d / 9); i++)
		for (var j = 0; j < 9; j++)
			str += '5';

	if (!str) {
		print(0);
		return;
	}

	for (var i = 0; i < c; i++)
		str += '0';

	print(str);
}).call(this);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var numDigits = parseInt(readline()),
		digits = tokenizeIntegers(readline()),
		counts = { 0: 0, 5: 0 };
	for (var i = 0; i < numDigits; ++i) {
		counts[digits[i]] += 1;
	}
	if (counts[0] == 0) {
		print(-1);
		return;
	}
	if (counts[5] < 9) {
		print(0);
		return;
	}
	digits.sort(function (a, b) {
		return b-a;
	});
	for (var i = counts[5]%9; i != 0; --i) {
		digits.shift();
	}
	print(digits.join(''));
}

main();

var n = parseInt( readline(), 10 );
var a = readline().split( " " ).map( ai => parseInt( ai, 10 ) );
// Prime factors of 90 are 2, 3^2 and 5.
// In our case number is divisible by 2 if at least one zero at the end.
// Number is divisible by 9 if its digits sum divisible by 9. In our case that is repeated 555555555 only.
// Number is divisible by 5 if last digit is zero.
var fives = a.filter( ai => ai === 5);
var zeros = a.filter( ai => ai === 0);
var answer = -1;
if ( zeros.length > 0 ) {
  if ( fives.length >= 9 ) {
    answer = [ ...fives.slice( 0, fives.length - fives.length % 9), ...zeros ].join( "" );
  } else {
    answer = 0;
  }
}

print( answer );

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let len = +readLine();
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  arr.sort((a, b) => b - a);

  let [count0, count5] = [0, 0];
  for (let i = 0; i < len; i++) {
    if (arr[i] === 0) count0++;
    if (arr[i] === 5) count5++;
  }
  count5 = count5 - (count5 % 9);
  if (count5 > 0 && count0 > 0) {
    console.log([...Array(count5).fill(5), ...Array(count0).fill(0)].join(""));
  } else if (count0 > 0) {
    console.log(0);
  } else {
    console.log(-1);
  }
}

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

function main() {
	let n = readLine() >> 0;
	let cnt = {};
	let c = readLine()
		.split(' ')
		.map(x => {
			x = x >> 0;
			cnt[x] = (cnt[x] || 0) + 1;
			return x;
		});
	if (cnt[0] === undefined) {
		console.log(-1);
	} else {
		if (cnt[5] === undefined || cnt[5] < 9) console.log(0);
		else {
			let q = Math.floor(cnt[5] / 9);
			console.log('5'.repeat(q * 9) + '0'.repeat(cnt[0]));
		}
	}
}

var n=+readline();
var a=readline().split(' ');

var five=0;
var zero=0;
a.forEach(function(v){
	if(v==='5'){
		five++;
	}else{
		zero++;
	}
});

five=Math.floor(five/9);
if(five==0||zero==0){
	print(0);
}else{
	var ans=[];
	var k=Math.min(five,zero);
	for(var i=0;i<k;i++){
		ans.push('5555555550');
	}
	print(ans.join(''));
}

var n=+readline();
var a=readline().split(' ');

var five=0;
var zero=0;
a.forEach(function(v){
	if(v==='5'){
		five++;
	}else{
		zero++;
	}
});

five=Math.floor(five/9);
if(zero==0){
	print(-1);
}else if(five==0){
	print(0)
}else{
	var ans=[];
	var k=Math.min(five,zero);
	for(var i=0;i<k;i++){
		ans.push('5555555550');
	}
	print(ans.join(''));
}

var n=+readline();
var a=readline().split(' ');

var five=0;
var zero=0;
a.forEach(function(v){
	if(v==='5'){
		five++;
	}else{
		zero++;
	}
});

five=Math.floor(five/9);
if(zero==0){
	print(-1);
}else if(five==0){
	print(0)
}else{
	var ans=[];
	var k=Math.min(five,zero);
	for(var i=0;i<k;i++){
		ans.push('555555555');
	}
	while(zero--){
		ans.push('0')
	}
	print(ans.join(''));
}

var n=+readline();
var a=readline().split(' ');

var five=0;
var zero=0;
a.forEach(function(v){
	if(v==='5'){
		five++;
	}else{
		zero++;
	}
});

five=Math.floor(five/9);
print(Math.min(five,zero));

;(function () {
	var n = +readline();

	var c = 0;
	var d = 0;

	readline().split(' ').map(function (e) {
		if (e == 0) c++;
		else d++;
	});

	if (!c) {
		print(-1);
	}

	var str = '';
	for (var i = 0; i < Math.floor(d / 3); i++)
		for (var j = 0; j < 3; j++)
			str += '5';

	if (!str) {
		print(0);
		return;
	}

	for (var i = 0; i < c; i++)
		str += '0';

	print(str);
}).call(this);

;(function () {
	var n = +readline();

	var c = 0;
	var d = 0;

	readline().split(' ').map(function (e) {
		if (e == 0) c++;
		else d++;
	});

	if (!c) {
		print(-1);
		return;
	}

	var str = '';
	for (var i = 0; i < Math.floor(d / 3); i++)
		for (var j = 0; j < 3; j++)
			str += '5';

	if (!str) {
		print(0);
		return;
	}

	for (var i = 0; i < c; i++)
		str += '0';

	print(str);
}).call(this);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline()), apples = tokenizeIntegers(readline()),
		counts = { 100: 0, 200: 0 };
	for (var i = 0; i < n; ++i) {
		counts[apples[i]] += 1;
	}
	if (counts[200] % 2 == 0) {
		print(counts[100] % 2 == 0 ? "YES" : "NO");
	} else {
		if (counts[100] < 2) {
			print("NO");
		} else {
			print((counts[100] - 2) % 2 == 0 ? "YES": "NO");
		}
	}
}

main();

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var numDigits = parseInt(readline()),
		digits = tokenizeIntegers(readline()),
		counts = { 0: 0, 5: 0 };
	for (var i = 0; i < numDigits; ++i) {
		counts[digits[i]] += 1;
	}
	if (counts[0] == 0) {
		print(-1);
		return;
	}
	if (counts[5] < 9) {
		print(0);
	}
	digits.sort(function (a, b) {
		return b-a;
	});
	for (var i = counts[5]%9; i != 0; --i) {
		digits.shift();
	}
	print(digits.join(''));
}

main();

var n = parseInt( readline(), 10 );
var a = readline().split( " " ).map( ai => parseInt( ai, 10 ) );
// Prime factors of 90 are 2, 3 and 5.
// In our case number is divisible by 2 if at least one zero at the end.
// Number is divisible by 3 if its digits sum divisible by 3. In our case that is repeated 555 only.
// Number is divisible by 5 if last digit is zero.
var fives = a.filter( ai => ai === 5);
var zeros = a.filter( ai => ai === 0);
var answer = -1;
if ( zeros.length > 0 ) {
  if ( fives.length >= 3 ) {
    answer = [ ...fives.slice( 0, fives.length - fives.length % 3), ...zeros ].join( "" );
  } else {
    answer = 0;
  }
}

print( answer );

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

function main() {
	let n = readLine() >> 0;
	let cnt = {};
	let c = readLine()
		.split(' ')
		.map(x => {
			x = x >> 0;
			cnt[x] = (cnt[x] || 0) + 1;
			return x;
		});
	if (cnt[0] === undefined) {
		console.log(-1);
	} else {
		if (n < 9) console.log(0);
		else {
			let q = Math.floor(cnt[5] / 9);
			console.log('5'.repeat(q * 9) + '0');
		}
	}
}

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

function main() {
	let n = readLine() >> 0;
	let cnt = {};
	let c = readLine()
		.split(' ')
		.map(x => {
			x = x >> 0;
			cnt[x] = (cnt[x] || 0) + 1;
			return x;
		});
	if (cnt[0] === undefined) {
		console.log(-1);
	} else {
		if (n < 9) console.log(0);
		else {
			let q = Math.floor(cnt[5] / 9);
			console.log('5'.repeat(q * 9) + '0'.repeat(cnt[0]));
		}
	}
}


This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of n computers, some of them are connected by a cable. The computers are indexed by integers from 1 to n. It's known that any two computers connected by cable directly or through other computersPolycarpus decided to find out the network's topology. A network topology is the way of describing the network configuration, the scheme that shows the location and the connections of network devices.Polycarpus knows three main network topologies: bus, ring and star. A bus is the topology that represents a shared cable with all computers connected with it. In the ring topology the cable connects each computer only with two other ones. A star is the topology where all computers of a network are connected to the single central node.Let's represent each of these network topologies as a connected non-directed graph. A bus is a connected graph that is the only path, that is, the graph where all nodes are connected with two other ones except for some two nodes that are the beginning and the end of the path. A ring is a connected graph, where all nodes are connected with two other ones. A star is a connected graph, where a single central node is singled out and connected with all other nodes. For clarifications, see the picture.    (1) — bus, (2) — ring, (3) — star You've got a connected non-directed graph that characterizes the computer network in Polycarpus' corporation. Help him find out, which topology type the given network is. If that is impossible to do, say that the network's topology is unknown.

The first line contains two space-separated integers n and m (4 ≤ n ≤ 105; 3 ≤ m ≤ 105) — the number of nodes and edges in the graph, correspondingly. Next m lines contain the description of the graph's edges. The i-th line contains a space-separated pair of integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of nodes that are connected by the i-the edge. It is guaranteed that the given graph is connected. There is at most one edge between any two nodes. No edge connects a node with itself.

In a single line print the network topology name of the given graph. If the answer is the bus, print "bus topology" (without the quotes), if the answer is the ring, print "ring topology" (without the quotes), if the answer is the star, print "star topology" (without the quotes). If no answer fits, print "unknown topology" (without the quotes).

bus topology
ring topology
star topology
unknown topology

function main(str) {
    var arr = str.split(' ');
    var num1 = +arr[0];
    var num2 = +arr[1];

    var myNetwork;

    // конструктор графа
    var Graph = function (nodes, edges) {
        var instance = this;
        this.nodesNumber = nodes;
        this.edgesNumber = edges;
        this.nodes = new Array(this.nodesNumber);

        for (var i = 0; i < this.nodes.length; i++) {
            this.nodes[i] = [];
        }

        this.connectNodes = function (node1, node2) {
            this.nodes[node1].push(node2);
            this.nodes[node2].push(node1);
        }

        // singleton
        Graph = function (v, w) {
            instance.connectNodes(v - 1, w - 1);
            return instance;
        };
    }

    function createOneStep(a, b) {
        myNetwork = new Graph(a, b);
    }

    function createGraph(n, e) {
        var i = 0;
        createOneStep(n, e);
        for (i;i<e;i++) {
            var graphConfig = readline();
            var arr = graphConfig.split(' ');
            var num1 = +arr[0];
            var num2 = +arr[1];
            createOneStep(num1, num2);
        }
    }

    function logic() {
        createGraph(num1, num2);
        var nodes = myNetwork.nodesNumber;
        var edges = myNetwork.edgesNumber;
        var nodesMinusOne = nodes - 1;

        var nodesDegree = {
            1: 0,
            2: 0,
            [nodesMinusOne]: 0
        };

        var i = 0;

        for (i; i < myNetwork.nodes.length; i++) {
            var degree = myNetwork.nodes[i].length;
            if (degree in nodesDegree && nodesDegree.hasOwnProperty(degree)) {
                nodesDegree[degree]++;
            } else {
                return 'unknown topology';
            }
        }

        if (edges === nodes && nodesDegree[1] === 0 && nodesDegree[2] === nodes && nodesDegree[nodesMinusOne] === 0) {
            return 'ring topology';
        } else if (edges === nodes - 1) {
            if (nodesDegree[1] === 2 && nodesDegree[2] === (nodes - 2) && nodesDegree[nodesMinusOne] === 0) {
                return 'bus topology';
            } else if (nodesDegree[1] === (nodes - 1) && nodesDegree[2] === 0 && nodesDegree[nodesMinusOne] === 1) {
                return 'star topology';
            } else {
                return 'unknown topology';
            }
        } else {
            return 'unknown topology';
        }
    }

    return logic();
}

var data = readline();
write(main(data));


The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good.Heidi knows that the lair can be represented as a rectangle on a lattice, with sides parallel to the axes. Each vertex of the polygon occupies an integer point on the lattice. For each cell of the lattice, Heidi can check the level of Zombie Contamination. This level is an integer between 0 and 4, equal to the number of corners of the cell that are inside or on the border of the rectangle.As a test, Heidi wants to check that her Zombie Contamination level checker works. Given the output of the checker, Heidi wants to know whether it could have been produced by a single non-zero area rectangular-shaped lair (with axis-parallel sides).

The first line of each test case contains one integer N, the size of the lattice grid (5 ≤ N ≤ 50). The next N lines each contain N characters, describing the level of Zombie Contamination of each cell in the lattice. Every character of every line is a digit between 0 and 4. Cells are given in the same order as they are shown in the picture above: rows go in the decreasing value of y coordinate, and in one row cells go in the order of increasing x coordinate. This means that the first row corresponds to cells with coordinates (1, N), ..., (N, N) and the last row corresponds to cells with coordinates (1, 1), ..., (N, 1).

The first line of the output should contain Yes if there exists a single non-zero area rectangular lair with corners on the grid for which checking the levels of Zombie Contamination gives the results given in the input, and No otherwise.

NoteThe lair, if it exists, has to be rectangular (that is, have corners at some grid points with coordinates (x1, y1), (x1, y2), (x2, y1), (x2, y2)), has a non-zero area and be contained inside of the grid (that is, 0 ≤ x1 < x2 ≤ N, 0 ≤ y1 < y2 ≤ N), and result in the levels of Zombie Contamination as reported in the input.

(function()
{
  var n = parseInt(readline());

  var f=[], ai=n, aj=n, bi=-1, bj=-1;
  for (var i=0 ; i<n ; i++)
  {
    f[i] = new Uint32Array(readline().split("").map(function(x){return parseInt(x);}));
    for (var j=0 ; j<n ; j++)
    {
      if (f[i][j] == 4)
      {
        if (i<ai) ai=i;
        if (i>bi) bi=i;
        if (j<aj) aj=j;
        if (j>bj) bj=j;
      }
    }
  }

  var ok = ai<=bi && aj<=bj;
  for (var i=0 ; i<n ; i++)
  {
    for (var j=0 ; j<n ; j++)
    {
      var sx = Math.max(0, Math.min(2, 2+i-ai, 2+bi-i));
      var sy = Math.max(0, Math.min(2, 2+j-aj, 2+bj-j));

      ok = ok && f[i][j]==sx*sy;
    }
  }

  print(ok ? "Yes" : "No");
})();

function mapInt(x) { return parseInt(x); }

(function()
{
  var n = parseInt(readline());

  var f=[], sumsh=new Uint32Array(n).fill(0), sumsv=new Uint32Array(n).fill(0), sum=0;
  for (var i=0 ; i<n ; i++)
  {
    f[i] = new Uint32Array(readline().split("").map(mapInt));

    sumsh[i] = f[i].reduce(function(a,b)
    {
      return a+b;
    }, 0);
    sum += sumsh[i];

    for (var j=0 ; j<n ; j++)
    {
      sumsv[j] += f[i][j];
    }
  }

  var ok = false;
  if (sum == 16)
  {
    var mh = [], mv = [];
    for (var i=0 ; i<n ; i++)
    {
      if (sumsh[i] == 4)
      {
        mh.push(i);
        sumsh[i+1] -= 4;
      }
      if (sumsv[i] == 4)
      {
        mv.push(i);
        sumsv[i+1] -= 4;
      }
    }

    if (mh.length == 2 && mv.length == 2)
    {
      for (var i=0 ; i<2 ; i++)
      {
        for (var j=0 ; j<2 ; j++)
        {
          var x=mh[i], y=mv[j];
          f[x][y]--;
          f[x][y+1]--;
          f[x+1][y]--;
          f[x+1][y+1]--;
        }
      }

      ok = true;
      for (var i=0 ; i<n ; i++)
        for (var j=0 ; j<n ; j++)
          ok = ok && !f[i][j];
    }
  }

  print(ok ? "Yes" : "No");
})();

function mapInt(x) { return parseInt(x); }

(function()
{
  var n = parseInt(readline());

  var f=[], s=[];
  var ok = false;

  for (var i=0 ; i<n ; i++)
  {
    f[i] = new Uint32Array(readline().split("").map(mapInt));
    s[i] = new Uint32Array(n);
  }

  var krn = [[1,2,1], [2,4,2], [1,2,1]];
  for (var i=0 ; i<n ; i++)
  {
    for (var j=0 ; j<n ; j++)
    {
      if (f[i][j] == 4)
      {
        for (var x=-1 ; x<=1 ; x++)
        {
          for (var y=-1 ; y<=1 ; y++)
          {
            s[i+x][j+y] = Math.max(f[i+x][j+y], krn[x+1][y+1]);
          }
        }
      }
    }
  }

  //console.log(s.map(function(x){return x.join("")}).join("\n"));
  var ok = true;
  for (var i=0 ; i<n ; i++)
  {
    for (var j=0 ; j<n ; j++)
    {
      ok = ok && f[i][j]-s[i][j]==0;
    }
  }

  print(ok ? "Yes" : "No");
})();


Your favorite shop sells $$$n$$$ Kinder Surprise chocolate eggs. You know that exactly $$$s$$$ stickers and exactly $$$t$$$ toys are placed in $$$n$$$ eggs in total.Each Kinder Surprise can be one of three types:  it can contain a single sticker and no toy;  it can contain a single toy and no sticker;  it can contain both a single sticker and a single toy. But you don't know which type a particular Kinder Surprise has. All eggs look identical and indistinguishable from each other.What is the minimum number of Kinder Surprise Eggs you have to buy to be sure that, whichever types they are, you'll obtain at least one sticker and at least one toy?Note that you do not open the eggs in the purchasing process, that is, you just buy some number of eggs. It's guaranteed that the answer always exists.

The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$T$$$ lines contain three integers $$$n$$$, $$$s$$$ and $$$t$$$ each ($$$1 \le n \le 10^9$$$, $$$1 \le s, t \le n$$$, $$$s + t \ge n$$$) — the number of eggs, stickers and toys. All queries are independent.

Print $$$T$$$ integers (one number per query) — the minimum number of Kinder Surprise Eggs you have to buy to be sure that, whichever types they are, you'll obtain at least one sticker and one toy

NoteIn the first query, we have to take at least $$$6$$$ eggs because there are $$$5$$$ eggs with only toy inside and, in the worst case, we'll buy all of them.In the second query, all eggs have both a sticker and a toy inside, that's why it's enough to buy only one egg.In the third query, we have to buy both eggs: one with a sticker and one with a toy.

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [n, s, t] = d.split(' ').map(Number);
  const min = Math.min(s, t);
  const ans = n - min + 1;

  console.log(ans);

  c++;
});

const testInput = [
    [3],
    [10, 5, 7],
    [10, 10, 10],
    [2, 1, 1]
]
const {EOL} = require('os')

function getInput(test = false) {
    return new Promise((res,rej) => {
        if (test) return res(testInput);
        let i = ''
        process.stdin.on('data', c => i += c)
        process.stdin.on('end', () => {
            res(i.split(EOL).map(line => line.split(' ').map(str => parseInt(str))));
        })
    })
}

function output(lines) {
    console.log(lines.join(EOL));
}

getInput(false).then(lines => {
    if(isNaN(lines[lines.length-1][0])) lines.pop();
    lines.shift();
    const answer = lines.map(line => line[0] + 1 - Math.min(line[1],line[2]))
    output(answer);
})

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };
    var q = read.number();
    var res = '';

    for(var i = 0; i < q; i++) {
        var line = read.arrNumber(' ');
        if(line[0] === line[1] && line[0] === line[2]) {
            res += '1 \n';
        }
        else {
            var a = line[2] + line[1] - line[0];
            res += Math.min(line[0], Math.max(line[1], line[2]) - a + 1) + '\n';
        }
    }

    print(res);

}());

"use strict";

// readline().split(' ').map(value => +value);
var T = +readline();

while(T--) {
    var input = readline().split(' ').map(value => +value);
    var n = input[0];
    var s = input[1];
    var t = input[2];

    var d = (s+t) - n;
    var ds = s - d;
    var dt = t - d;

    write(Math.max(ds, dt) + 1, '\n');
}

const testInput = [
    [3],
    [10, 5, 7],
    [10, 10, 10],
    [2, 1, 1]
]

function getInput(test = false) {
    return new Promise((res,rej) => {
        if (test) return res(testInput);
        let i = ''
        process.stdin.on('data', c => i += c)
        process.stdin.on('end', () => {
            const {EOL} = require('os')
            res(i.split(EOL).map(line => line.split(' ').map(str => parseInt(str))));
        })
    })
}

function output(lines) {
    console.log(lines.join('\r\n'));
}

getInput(true).then(lines => {
    if(isNaN(lines[lines.length-1][0])) lines.pop();
    lines.shift();
    const answer = lines.map(line => line[0] + 1 - Math.min(line[1],line[2]))
    output(answer);
})

const testInput = [
    [3],
    [10, 5, 7],
    [10, 10, 10],
    [2, 1, 1]
]

function getInput(test = false) {
    return new Promise((res,rej) => {
        if (test) return res(testInput);
        let i = ''
        process.stdin.on('data', c => i += c)
        process.stdin.on('end', () => {
            res(i.split('\r\n').map(line => line.split(' ').map(str => BigInt(str))));
        })
    })
}

function output(lines) {
    console.log(lines.join('\r\n'));
}

getInput(true).then(lines => {
    lines.shift();
    const answer = lines.map(line => line[0] + 1 - Math.min(line[1],line[2]))
    output(answer);
})

const testInput = [
    [3],
    [10, 5, 7],
    [10, 10, 10],
    [2, 1, 1]
]

function getInput(test = false) {
    return new Promise((res,rej) => {
        if (test) return res(testInput);
        let i = ''
        process.stdin.on('data', c => i += c)
        process.stdin.on('end', () => {
            res(i.split('\r\n').map(line => line.split(' ').map(str => parseInt(str))));
        })
    })
}

function output(lines) {
    console.log(lines.join('\r\n'));
}

getInput(false).then(lines => {
    lines.shift();
    const answer = lines.map(line => line[0] + 1 - Math.min(line[1],line[2]))
    output(answer);
})

const testInput = [
    [3],
    [10, 5, 7],
    [10, 10, 10],
    [2, 1, 1]
]
const {EOL} = require('os')

function getInput(test = false) {
    return new Promise((res,rej) => {
        if (test) return res(testInput);
        let i = ''
        process.stdin.on('data', c => i += c)
        process.stdin.on('end', () => {
            res(i.split(EOL).map(line => line.split(' ').map(str => parseInt(str))));
        })
    })
}

function output(lines) {
    console.log(lines.join(EOL));
}

getInput(true).then(lines => {
    if(isNaN(lines[lines.length-1][0])) lines.pop();
    lines.shift();
    const answer = lines.map(line => line[0] + 1 - Math.min(line[1],line[2]))
    output(answer);
})

const testInput = [
    [3],
    [10, 5, 7],
    [10, 10, 10],
    [2, 1, 1]
]

function getInput(test = false) {
    return new Promise((res,rej) => {
        if (test) return res(testInput);
        let i = ''
        process.stdin.on('data', c => i += c)
        process.stdin.on('end', () => {
            res(i.split('\r\n').map(line => line.split(' ').map(str => parseInt(str))));
        })
    })
}

function output(lines) {
    console.log(lines.join('\r\n'));
}

getInput(true).then(lines => {
    if(isNaN(lines[lines.length-1][0])) lines.pop();
    lines.shift();
    const answer = lines.map(line => line[0] + 1 - Math.min(line[1],line[2]))
    output(answer);
})

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };
    var q = read.number();
    var res = '';

    for(var i = 0; i < q; i++) {
        var line = read.arrNumber(' ');
        if((line[0] === line[1] && line[2]  > 0) || (line[0] === line[2] && line[1]  > 0)) {
            res += '1 \n';
        }
        else {
            res += Math.min(line[0], Math.min(line[1], line[2]) + 1) + '\n';
        }
    }

    print(res);

}());

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };
    var q = read.number();
    var res = '';

    for(var i = 0; i < q; i++) {
        var line = read.arrNumber(' ');
        if(line[0] === line[1] || line[0] === line[2]) {
            res += '1 \n';
        }
        else {
            var a = line[2] + line[1] - line[0];
            res += Math.min(line[0], Math.max(line[1], line[2]) - a + 1) + '\n';
        }
    }

    print(res);

}());


A number $$$a_2$$$ is said to be the arithmetic mean of two numbers $$$a_1$$$ and $$$a_3$$$, if the following condition holds: $$$a_1 + a_3 = 2\cdot a_2$$$. We define an arithmetic mean deviation of three numbers $$$a_1$$$, $$$a_2$$$ and $$$a_3$$$ as follows: $$$d(a_1, a_2, a_3) = |a_1 + a_3 - 2 \cdot a_2|$$$.Arithmetic means a lot to Jeevan. He has three numbers $$$a_1$$$, $$$a_2$$$ and $$$a_3$$$ and he wants to minimize the arithmetic mean deviation $$$d(a_1, a_2, a_3)$$$. To do so, he can perform the following operation any number of times (possibly zero):  Choose $$$i, j$$$ from $$$\{1, 2, 3\}$$$ such that $$$i \ne j$$$ and increment $$$a_i$$$ by $$$1$$$ and decrement $$$a_j$$$ by $$$1$$$ Help Jeevan find out the minimum value of $$$d(a_1, a_2, a_3)$$$ that can be obtained after applying the operation any number of times.

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 5000)$$$  — the number of test cases. The first and only line of each test case contains three integers $$$a_1$$$, $$$a_2$$$ and $$$a_3$$$ $$$(1 \le a_1, a_2, a_3 \le 10^{8})$$$.

For each test case, output the minimum value of $$$d(a_1, a_2, a_3)$$$ that can be obtained after applying the operation any number of times.

NoteNote that after applying a few operations, the values of $$$a_1$$$, $$$a_2$$$ and $$$a_3$$$ may become negative.In the first test case, $$$4$$$ is already the Arithmetic Mean of $$$3$$$ and $$$5$$$.$$$d(3, 4, 5) = |3 + 5 - 2 \cdot 4| = 0$$$In the second test case, we can apply the following operation:$$$(2, 2, 6)$$$ $$$\xrightarrow[\text{increment $$$a_2$$$}]{\text{decrement $$$a_1$$$}}$$$ $$$(1, 3, 6)$$$$$$d(1, 3, 6) = |1 + 6 - 2 \cdot 3| = 1$$$It can be proven that answer can not be improved any further.In the third test case, we can apply the following operations:$$$(1, 6, 5)$$$ $$$\xrightarrow[\text{increment $$$a_3$$$}]{\text{decrement $$$a_2$$$}}$$$ $$$(1, 5, 6)$$$ $$$\xrightarrow[\text{increment $$$a_1$$$}]{\text{decrement $$$a_2$$$}}$$$ $$$(2, 4, 6)$$$$$$d(2, 4, 6) = |2 + 6 - 2 \cdot 4| = 0$$$

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
	for(i = 1; i <= t; i++){
	    var k = lines[i].split(' ').map(Number);
	    var a = k[0], b = k[1], c = k[2];
	    b *= 2;
	    a += c;
	    console.log(Math.abs(a - b) % 3 === 0 ? 0 : 1);
	}
});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
	var t = lines[0];
	for(i = 1; i <= t; i++){
	    var k = lines[i].split(' ').map(Number);
	    var a = k[0], b = k[1], c = k[2];
	    b *= 2;
	    a += c;
	    var d = Math.abs(a - b);
	    console.log(d % 3 === 0 ? 0 : 1);
	}
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});
process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });
  solve();
  // cmd: node solution.js < input.txt > output.txt
});
function readLine() {
  return inputString[currentLine++];
}

function solve() {
  let t = parseInt(readLine());
  while (t--) {
    let arr = readLine().split(" ");
    let a1 = parseInt(arr[0]), a2 = parseInt(arr[1]), a3 = parseInt(arr[2])
    if ((a1 + a3 - 2 * a2) % 3 == 0) {
      console.log(0)
    } else {
      console.log(1)
    }
  }
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [a, b, c] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(a, b, c)
    }
    console.log(output.join('\n'))
// })()
})

function solve(a, b, c) {
    if (!h(a, b, c)) return 0
    if (!h(b, c, a)) return 0
    if (!h(c, a, b)) return 0
    return 1
}
function h(a, b, c) {
    return !!(Math.abs(a + b - 2 * c) % 3)
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var sum = nextInt() + nextInt() + nextInt();
		if(sum % 3 == 0){
			myout(0);
		}else{
			myout(1);
		}
	}
}


You are given two strings $$$a$$$ and $$$b$$$ consisting of lowercase English letters, both of length $$$n$$$. The characters of both strings have indices from $$$1$$$ to $$$n$$$, inclusive. You are allowed to do the following changes:   Choose any index $$$i$$$ ($$$1 \le i \le n$$$) and swap characters $$$a_i$$$ and $$$b_i$$$;  Choose any index $$$i$$$ ($$$1 \le i \le n$$$) and swap characters $$$a_i$$$ and $$$a_{n - i + 1}$$$;  Choose any index $$$i$$$ ($$$1 \le i \le n$$$) and swap characters $$$b_i$$$ and $$$b_{n - i + 1}$$$. Note that if $$$n$$$ is odd, you are formally allowed to swap $$$a_{\lceil\frac{n}{2}\rceil}$$$ with $$$a_{\lceil\frac{n}{2}\rceil}$$$ (and the same with the string $$$b$$$) but this move is useless. Also you can swap two equal characters but this operation is useless as well.You have to make these strings equal by applying any number of changes described above, in any order. But it is obvious that it may be impossible to make two strings equal by these swaps.In one preprocess move you can replace a character in $$$a$$$ with another character. In other words, in a single preprocess move you can choose any index $$$i$$$ ($$$1 \le i \le n$$$), any character $$$c$$$ and set $$$a_i := c$$$.Your task is to find the minimum number of preprocess moves to apply in such a way that after them you can make strings $$$a$$$ and $$$b$$$ equal by applying some number of changes described in the list above.Note that the number of changes you make after the preprocess moves does not matter. Also note that you cannot apply preprocess moves to the string $$$b$$$ or make any preprocess moves after the first change is made.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of strings $$$a$$$ and $$$b$$$. The second line contains the string $$$a$$$ consisting of exactly $$$n$$$ lowercase English letters. The third line contains the string $$$b$$$ consisting of exactly $$$n$$$ lowercase English letters.

Print a single integer — the minimum number of preprocess moves to apply before changes, so that it is possible to make the string $$$a$$$ equal to string $$$b$$$ with a sequence of changes from the list above.

NoteIn the first example preprocess moves are as follows: $$$a_1 := $$$'b', $$$a_3 := $$$'c', $$$a_4 := $$$'a' and $$$a_5:=$$$'b'. Afterwards, $$$a = $$$"bbcabba". Then we can obtain equal strings by the following sequence of changes: $$$swap(a_2, b_2)$$$ and $$$swap(a_2, a_6)$$$. There is no way to use fewer than $$$4$$$ preprocess moves before a sequence of changes to make string equal, so the answer in this example is $$$4$$$.In the second example no preprocess moves are required. We can use the following sequence of changes to make $$$a$$$ and $$$b$$$ equal: $$$swap(b_1, b_5)$$$, $$$swap(a_2, a_4)$$$.

var n = (+ readline ());
var a = readline ();
var b = readline ();
var one = a.trim ().split ( '' );
var two = b.trim ().split ( '' );
var preprocess = 0;
var i = 0;
var ch, k;
while ( i < Math.floor ( n / 2 ) ) {
    ch = { };
    if ( ! ( one [ i ] in ch ) ) ch [ one [ i ] ] = 0;
    ch [ one [ i ] ] ++;
    if ( ! ( one [ n - i - 1 ] in ch ) ) ch [ one [ n - i - 1 ] ] = 0;
    ch [ one [ n - i - 1 ] ] ++;
    if ( ! ( two [ i ] in ch ) ) ch [ two [ i ] ] = 0;
    ch [ two [ i ] ] ++;
    if ( ! ( two [ n - i - 1 ] in ch ) ) ch [ two [ n - i - 1 ] ] = 0;
    ch [ two [ n - i - 1 ] ] ++;
    k = [ ];
    k = Object.keys ( ch );
    if ( k.length == 2 ) {
        if ( ch [ k [ 0 ] ] == 1 || ch [ k [ 0 ] ] == 3 ) {
            preprocess += 1;
        }
    }
    else if ( k.length == 3 ) {
        if ( one [ i ] == one [ n - i - 1 ] ) preprocess += 2;
        else preprocess += 1;
    }
    else if ( k.length == 4 ) { preprocess += 2; }
    i ++;
}
if ( n % 2 == 1 ) {
    if ( one [ Math.floor ( n / 2 ) ] != two [ Math.floor ( n / 2 ) ] )
        preprocess ++;
}
print ( preprocess );