id
stringlengths 6
117
| description
stringlengths 29
13k
| code
stringlengths 9
465k
| language
class label 4
classes | test_samples
sequence | source
class label 5
classes |
---|---|---|---|---|---|
1216_D. Swords_1200 | There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people might have taken different types of swords. Note that the values x, y and z are unknown for you.
The next morning the director of the theater discovers the loss. He counts all swords β exactly a_i swords of the i-th type are left untouched.
The director has no clue about the initial number of swords of each type in the basement, the number of people who have broken into the basement and how many swords each of them have taken.
For example, if n=3, a = [3, 12, 6] then one of the possible situations is x=12, y=5 and z=3. Then the first three people took swords of the first type and the other two people took swords of the third type. Note that you don't know values x, y and z beforehand but know values of n and a.
Thus he seeks for your help. Determine the minimum number of people y, which could have broken into the theater basement, and the number of swords z each of them has taken.
Input
The first line of the input contains one integer n (2 β€ n β€ 2 β
10^{5}) β the number of types of swords.
The second line of the input contains the sequence a_1, a_2, ..., a_n (0 β€ a_i β€ 10^{9}), where a_i equals to the number of swords of the i-th type, which have remained in the basement after the theft. It is guaranteed that there exists at least one such pair of indices (j, k) that a_j β a_k.
Output
Print two integers y and z β the minimum number of people which could have broken into the basement and the number of swords each of them has taken.
Examples
Input
3
3 12 6
Output
5 3
Input
2
2 9
Output
1 7
Input
7
2 1000000000 4 6 8 4 2
Output
2999999987 2
Input
6
13 52 0 13 26 52
Output
12 13
Note
In the first example the minimum value of y equals to 5, i.e. the minimum number of people who could have broken into the basement, is 5. Each of them has taken 3 swords: three of them have taken 3 swords of the first type, and two others have taken 3 swords of the third type.
In the second example the minimum value of y is 1, i.e. the minimum number of people who could have broken into the basement, equals to 1. He has taken 7 swords of the first type. | #include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long z) {
long long ret = 1;
while (y > 0) {
if (y & 1) ret = (ret * x) % z;
x = (x * x) % z;
y >>= 1;
}
return ret;
}
const long long N = 2e5 + 5;
long long A[N];
long long __gcd(long long a, long long b) {
if (!b) return a;
return __gcd(b, a % b);
}
int main() {
long long n;
scanf("%lld", &n);
for (long long i = 1; i <= n; ++i) scanf("%lld", &A[i]);
sort(A + 1, A + 1 + n);
long long x = A[1], y = 0, z = 0, sum = A[1];
for (long long i = 2; i <= n; ++i) {
if (A[i] != A[i - 1]) {
z = __gcd(z, A[i] - A[i - 1]);
}
x = max(x, A[i]);
sum += A[i];
}
long long l1 = sum % z, l2 = n % z;
long long pz = z, tz = z;
for (long long i = 2; i < N; ++i) {
if (tz % i == 0) {
while (tz % i == 0) tz /= i;
pz -= pz / i;
}
}
if (tz > 1) pz -= pz / tz;
long long l3 = power(l2, pz - 1, z);
l3 = (l3 * l1) % z;
long long lo = 1, hi = 1e10, mid, tx = x;
while (lo <= hi) {
mid = (lo + hi) >> 1;
if ((l3 + z * mid) >= tx)
hi = mid - 1, x = (l3 + z * mid);
else
lo = mid + 1;
}
long long ts = n * x - sum;
y = (n * x - sum) / z;
if (__gcd(l2, z) != 1) y = (n * tx - sum) / z;
printf("%lld %lld\n", y, z);
return 0;
}
| 2C++
| {
"input": [
"2\n2 9\n",
"3\n3 12 6\n",
"7\n2 1000000000 4 6 8 4 2\n",
"6\n13 52 0 13 26 52\n",
"10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 1 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 0\n",
"10\n1000000000 1 2 3 4 5 6 7 8 9\n",
"3\n1000000000 1 1000000000\n",
"10\n100000000 200000000 300000000 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 -1\n",
"10\n1000000000 1 2 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1000000000\n",
"2\n1 9\n",
"3\n3 8 6\n",
"7\n2 1000000000 4 6 8 1 2\n",
"6\n13 52 0 13 26 31\n",
"10\n100000000 200000000 99172297 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 2 1 1 1 1 1\n",
"5\n0 0 1 -1 -1\n",
"10\n1000000000 1 0 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1000100000\n",
"2\n1 15\n",
"3\n3 8 0\n",
"7\n2 1000000000 4 6 7 1 2\n",
"6\n5 52 0 13 26 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 2 1 2 1 1 1\n",
"10\n0000000000 1 0 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1001100000\n",
"2\n0 15\n",
"7\n2 1000000000 4 6 7 1 0\n",
"6\n5 52 0 20 26 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 800000000 900000000 1000010000\n",
"10\n0000000000 1 0 3 4 5 2 7 2 9\n",
"3\n0000000001 1 1001100000\n",
"2\n0 13\n",
"3\n3 6 0\n",
"7\n2 1000000000 4 6 11 1 0\n",
"6\n5 52 0 20 51 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"5\n0 2 1 -1 -1\n",
"10\n0000000000 2 0 3 4 5 2 7 2 9\n",
"3\n0000000000 1 1001100100\n",
"6\n5 70 0 20 51 31\n",
"10\n100000010 200000000 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"5\n-1 2 1 -1 -1\n",
"10\n0000100000 2 0 3 4 5 2 7 2 9\n",
"3\n0000000000 1 1011100100\n",
"7\n1 1000000100 4 6 11 1 0\n",
"6\n1 70 0 20 51 31\n",
"10\n100000010 23436524 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"10\n1 1000000000 0 1 2 1 2 2 -1 1\n",
"5\n-1 4 1 -1 -1\n",
"10\n0000100000 2 0 3 4 5 2 7 4 9\n",
"3\n0000010000 1 1011100100\n",
"7\n1 1000000100 4 6 10 1 0\n",
"6\n1 70 0 20 51 53\n",
"10\n100000010 23436524 171013924 28 985204834 600000000 700000000 667029535 900000000 1000010000\n",
"10\n0000100000 2 0 0 4 5 2 7 4 9\n",
"3\n0000010000 0 1011100100\n",
"3\n5 7 -1\n",
"6\n1 70 -1 20 51 53\n",
"10\n100000010 23436524 225774845 28 985204834 600000000 700000000 667029535 900000000 1000010000\n",
"10\n0000100000 2 0 0 4 5 1 7 4 9\n",
"3\n0100010000 0 1011100100\n",
"3\n5 11 -1\n",
"7\n1 1000000100 6 6 10 1 0\n",
"6\n1 70 -1 19 51 53\n",
"10\n100000010 23436524 225774845 28 985204834 600000000 700000000 667029535 518484041 1000010000\n",
"10\n0000100000 2 0 0 4 10 1 7 4 9\n",
"3\n0100010001 0 1011100100\n",
"3\n7 11 -1\n",
"7\n2 1000000100 6 6 10 1 0\n",
"6\n1 70 -1 19 51 6\n",
"10\n100000010 23436524 225774845 0 985204834 600000000 700000000 667029535 518484041 1000010000\n",
"10\n1 1010000000 0 0 4 1 2 2 -1 1\n",
"3\n0100010001 0 1011100101\n",
"3\n7 0 -1\n",
"6\n1 70 -1 38 51 6\n",
"10\n100000010 23436524 225774845 0 1237987973 600000000 700000000 667029535 518484041 1000010000\n",
"10\n1 1010001000 0 0 4 1 2 2 -1 1\n",
"10\n0000100000 2 0 0 0 10 1 7 4 17\n",
"3\n0100010001 -1 1011100101\n",
"7\n0 1000000100 6 6 16 1 0\n",
"6\n1 70 -1 38 51 4\n",
"10\n100000010 23436524 225774845 0 1237987973 600000000 700000000 667029535 518484041 1000011000\n",
"10\n1 1010001000 0 0 4 1 2 2 -1 0\n",
"10\n0000101000 2 0 0 0 10 1 7 4 17\n",
"5\n0 0 1 -2 -1\n",
"3\n3 4 0\n",
"10\n1 1000000000 0 1 2 1 2 1 1 1\n",
"5\n0 1 1 -1 -1\n",
"10\n1 1000000000 0 1 2 1 2 2 1 1\n",
"2\n-1 13\n",
"3\n5 6 0\n",
"7\n1 1000000000 4 6 11 1 0\n",
"10\n1 1000000000 0 1 2 1 2 2 0 1\n",
"3\n5 4 0\n",
"3\n5 4 -1\n",
"10\n1 1000000000 0 1 3 1 2 2 -1 1\n",
"5\n-1 0 1 -1 -1\n",
"7\n1 1000000100 5 6 10 1 0\n",
"10\n1 1000000000 0 0 3 1 2 2 -1 1\n",
"5\n0 0 1 -1 0\n",
"10\n1 1000000000 0 0 4 1 2 2 -1 1\n",
"5\n0 -1 1 -1 0\n",
"10\n0000100000 2 0 0 0 10 1 7 4 9\n"
],
"output": [
"1 7\n",
"5 3\n",
"2999999987 2\n",
"12 13\n",
"244999999 20\n",
"9 999999999\n",
"4 1\n",
"8999999955 1\n",
"1 999999999\n",
"1224999993 4\n",
"8999999990 1\n",
"5 1\n",
"8999999961 1\n",
"1999999999 1\n",
"1 8\n",
"7 1\n",
"5999999977 1\n",
"177 1\n",
"5100827675 1\n",
"8999999989 1\n",
"6 1\n",
"8999999963 1\n",
"2000199999 1\n",
"1 14\n",
"13 1\n",
"5999999978 1\n",
"185 1\n",
"1257246512 4\n",
"8999999988 1\n",
"53 1\n",
"2002199999 1\n",
"1 15\n",
"5999999980 1\n",
"178 1\n",
"1257269012 4\n",
"57 1\n",
"2 1001099999\n",
"1 13\n",
"3 3\n",
"5999999976 1\n",
"153 1\n",
"5162046513 1\n",
"9 1\n",
"56 1\n",
"2002200199 1\n",
"243 1\n",
"5162046503 1\n",
"10 1\n",
"899966 1\n",
"2022200199 1\n",
"6000000577 1\n",
"247 1\n",
"5338609979 1\n",
"8999999991 1\n",
"18 1\n",
"899964 1\n",
"2022190199 1\n",
"6000000578 1\n",
"225 1\n",
"4853405145 1\n",
"899967 1\n",
"20221902 100\n",
"5 2\n",
"226 1\n",
"4798644224 1\n",
"899968 1\n",
"19221902 100\n",
"3 6\n",
"6000000576 1\n",
"227 1\n",
"5180160183 1\n",
"899963 1\n",
"1922190199 1\n",
"4 4\n",
"6000000575 1\n",
"274 1\n",
"5180160211 1\n",
"9089999990 1\n",
"640730067 3\n",
"15 1\n",
"255 1\n",
"7307156802 1\n",
"9090008990 1\n",
"899959 1\n",
"961095101 2\n",
"6000000571 1\n",
"257 1\n",
"7307155802 1\n",
"9090008991 1\n",
"908959 1\n",
"7 1\n",
"5 1\n",
"8999999990 1\n",
"5 1\n",
"8999999989 1\n",
"1 14\n",
"7 1\n",
"5999999977 1\n",
"8999999990 1\n",
"6 1\n",
"7 1\n",
"8999999990 1\n",
"7 1\n",
"6000000577 1\n",
"8999999991 1\n",
"5 1\n",
"8999999990 1\n",
"6 1\n",
"899967 1\n"
]
} | 2CODEFORCES
|
1216_D. Swords_1201 | There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people might have taken different types of swords. Note that the values x, y and z are unknown for you.
The next morning the director of the theater discovers the loss. He counts all swords β exactly a_i swords of the i-th type are left untouched.
The director has no clue about the initial number of swords of each type in the basement, the number of people who have broken into the basement and how many swords each of them have taken.
For example, if n=3, a = [3, 12, 6] then one of the possible situations is x=12, y=5 and z=3. Then the first three people took swords of the first type and the other two people took swords of the third type. Note that you don't know values x, y and z beforehand but know values of n and a.
Thus he seeks for your help. Determine the minimum number of people y, which could have broken into the theater basement, and the number of swords z each of them has taken.
Input
The first line of the input contains one integer n (2 β€ n β€ 2 β
10^{5}) β the number of types of swords.
The second line of the input contains the sequence a_1, a_2, ..., a_n (0 β€ a_i β€ 10^{9}), where a_i equals to the number of swords of the i-th type, which have remained in the basement after the theft. It is guaranteed that there exists at least one such pair of indices (j, k) that a_j β a_k.
Output
Print two integers y and z β the minimum number of people which could have broken into the basement and the number of swords each of them has taken.
Examples
Input
3
3 12 6
Output
5 3
Input
2
2 9
Output
1 7
Input
7
2 1000000000 4 6 8 4 2
Output
2999999987 2
Input
6
13 52 0 13 26 52
Output
12 13
Note
In the first example the minimum value of y equals to 5, i.e. the minimum number of people who could have broken into the basement, is 5. Each of them has taken 3 swords: three of them have taken 3 swords of the first type, and two others have taken 3 swords of the third type.
In the second example the minimum value of y is 1, i.e. the minimum number of people who could have broken into the basement, equals to 1. He has taken 7 swords of the first type. | n= int(input())
s = list(map(int,input().split()))
s.sort()
maxm = s[n-1]
ans = 0
def computeGCD(x, y):
while(y):
x, y = y, x % y
return x
a = maxm-s[0]
for i in range(1,n-1):
a = computeGCD(a,maxm-s[i])
for i in range(0,n-1):
ans += maxm - s[i]
print(ans//a,a)
| 3Python3
| {
"input": [
"2\n2 9\n",
"3\n3 12 6\n",
"7\n2 1000000000 4 6 8 4 2\n",
"6\n13 52 0 13 26 52\n",
"10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 1 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 0\n",
"10\n1000000000 1 2 3 4 5 6 7 8 9\n",
"3\n1000000000 1 1000000000\n",
"10\n100000000 200000000 300000000 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 -1\n",
"10\n1000000000 1 2 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1000000000\n",
"2\n1 9\n",
"3\n3 8 6\n",
"7\n2 1000000000 4 6 8 1 2\n",
"6\n13 52 0 13 26 31\n",
"10\n100000000 200000000 99172297 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 2 1 1 1 1 1\n",
"5\n0 0 1 -1 -1\n",
"10\n1000000000 1 0 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1000100000\n",
"2\n1 15\n",
"3\n3 8 0\n",
"7\n2 1000000000 4 6 7 1 2\n",
"6\n5 52 0 13 26 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 2 1 2 1 1 1\n",
"10\n0000000000 1 0 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1001100000\n",
"2\n0 15\n",
"7\n2 1000000000 4 6 7 1 0\n",
"6\n5 52 0 20 26 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 800000000 900000000 1000010000\n",
"10\n0000000000 1 0 3 4 5 2 7 2 9\n",
"3\n0000000001 1 1001100000\n",
"2\n0 13\n",
"3\n3 6 0\n",
"7\n2 1000000000 4 6 11 1 0\n",
"6\n5 52 0 20 51 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"5\n0 2 1 -1 -1\n",
"10\n0000000000 2 0 3 4 5 2 7 2 9\n",
"3\n0000000000 1 1001100100\n",
"6\n5 70 0 20 51 31\n",
"10\n100000010 200000000 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"5\n-1 2 1 -1 -1\n",
"10\n0000100000 2 0 3 4 5 2 7 2 9\n",
"3\n0000000000 1 1011100100\n",
"7\n1 1000000100 4 6 11 1 0\n",
"6\n1 70 0 20 51 31\n",
"10\n100000010 23436524 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"10\n1 1000000000 0 1 2 1 2 2 -1 1\n",
"5\n-1 4 1 -1 -1\n",
"10\n0000100000 2 0 3 4 5 2 7 4 9\n",
"3\n0000010000 1 1011100100\n",
"7\n1 1000000100 4 6 10 1 0\n",
"6\n1 70 0 20 51 53\n",
"10\n100000010 23436524 171013924 28 985204834 600000000 700000000 667029535 900000000 1000010000\n",
"10\n0000100000 2 0 0 4 5 2 7 4 9\n",
"3\n0000010000 0 1011100100\n",
"3\n5 7 -1\n",
"6\n1 70 -1 20 51 53\n",
"10\n100000010 23436524 225774845 28 985204834 600000000 700000000 667029535 900000000 1000010000\n",
"10\n0000100000 2 0 0 4 5 1 7 4 9\n",
"3\n0100010000 0 1011100100\n",
"3\n5 11 -1\n",
"7\n1 1000000100 6 6 10 1 0\n",
"6\n1 70 -1 19 51 53\n",
"10\n100000010 23436524 225774845 28 985204834 600000000 700000000 667029535 518484041 1000010000\n",
"10\n0000100000 2 0 0 4 10 1 7 4 9\n",
"3\n0100010001 0 1011100100\n",
"3\n7 11 -1\n",
"7\n2 1000000100 6 6 10 1 0\n",
"6\n1 70 -1 19 51 6\n",
"10\n100000010 23436524 225774845 0 985204834 600000000 700000000 667029535 518484041 1000010000\n",
"10\n1 1010000000 0 0 4 1 2 2 -1 1\n",
"3\n0100010001 0 1011100101\n",
"3\n7 0 -1\n",
"6\n1 70 -1 38 51 6\n",
"10\n100000010 23436524 225774845 0 1237987973 600000000 700000000 667029535 518484041 1000010000\n",
"10\n1 1010001000 0 0 4 1 2 2 -1 1\n",
"10\n0000100000 2 0 0 0 10 1 7 4 17\n",
"3\n0100010001 -1 1011100101\n",
"7\n0 1000000100 6 6 16 1 0\n",
"6\n1 70 -1 38 51 4\n",
"10\n100000010 23436524 225774845 0 1237987973 600000000 700000000 667029535 518484041 1000011000\n",
"10\n1 1010001000 0 0 4 1 2 2 -1 0\n",
"10\n0000101000 2 0 0 0 10 1 7 4 17\n",
"5\n0 0 1 -2 -1\n",
"3\n3 4 0\n",
"10\n1 1000000000 0 1 2 1 2 1 1 1\n",
"5\n0 1 1 -1 -1\n",
"10\n1 1000000000 0 1 2 1 2 2 1 1\n",
"2\n-1 13\n",
"3\n5 6 0\n",
"7\n1 1000000000 4 6 11 1 0\n",
"10\n1 1000000000 0 1 2 1 2 2 0 1\n",
"3\n5 4 0\n",
"3\n5 4 -1\n",
"10\n1 1000000000 0 1 3 1 2 2 -1 1\n",
"5\n-1 0 1 -1 -1\n",
"7\n1 1000000100 5 6 10 1 0\n",
"10\n1 1000000000 0 0 3 1 2 2 -1 1\n",
"5\n0 0 1 -1 0\n",
"10\n1 1000000000 0 0 4 1 2 2 -1 1\n",
"5\n0 -1 1 -1 0\n",
"10\n0000100000 2 0 0 0 10 1 7 4 9\n"
],
"output": [
"1 7\n",
"5 3\n",
"2999999987 2\n",
"12 13\n",
"244999999 20\n",
"9 999999999\n",
"4 1\n",
"8999999955 1\n",
"1 999999999\n",
"1224999993 4\n",
"8999999990 1\n",
"5 1\n",
"8999999961 1\n",
"1999999999 1\n",
"1 8\n",
"7 1\n",
"5999999977 1\n",
"177 1\n",
"5100827675 1\n",
"8999999989 1\n",
"6 1\n",
"8999999963 1\n",
"2000199999 1\n",
"1 14\n",
"13 1\n",
"5999999978 1\n",
"185 1\n",
"1257246512 4\n",
"8999999988 1\n",
"53 1\n",
"2002199999 1\n",
"1 15\n",
"5999999980 1\n",
"178 1\n",
"1257269012 4\n",
"57 1\n",
"2 1001099999\n",
"1 13\n",
"3 3\n",
"5999999976 1\n",
"153 1\n",
"5162046513 1\n",
"9 1\n",
"56 1\n",
"2002200199 1\n",
"243 1\n",
"5162046503 1\n",
"10 1\n",
"899966 1\n",
"2022200199 1\n",
"6000000577 1\n",
"247 1\n",
"5338609979 1\n",
"8999999991 1\n",
"18 1\n",
"899964 1\n",
"2022190199 1\n",
"6000000578 1\n",
"225 1\n",
"4853405145 1\n",
"899967 1\n",
"20221902 100\n",
"5 2\n",
"226 1\n",
"4798644224 1\n",
"899968 1\n",
"19221902 100\n",
"3 6\n",
"6000000576 1\n",
"227 1\n",
"5180160183 1\n",
"899963 1\n",
"1922190199 1\n",
"4 4\n",
"6000000575 1\n",
"274 1\n",
"5180160211 1\n",
"9089999990 1\n",
"640730067 3\n",
"15 1\n",
"255 1\n",
"7307156802 1\n",
"9090008990 1\n",
"899959 1\n",
"961095101 2\n",
"6000000571 1\n",
"257 1\n",
"7307155802 1\n",
"9090008991 1\n",
"908959 1\n",
"7 1\n",
"5 1\n",
"8999999990 1\n",
"5 1\n",
"8999999989 1\n",
"1 14\n",
"7 1\n",
"5999999977 1\n",
"8999999990 1\n",
"6 1\n",
"7 1\n",
"8999999990 1\n",
"7 1\n",
"6000000577 1\n",
"8999999991 1\n",
"5 1\n",
"8999999990 1\n",
"6 1\n",
"899967 1\n"
]
} | 2CODEFORCES
|
1216_D. Swords_1202 | There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people might have taken different types of swords. Note that the values x, y and z are unknown for you.
The next morning the director of the theater discovers the loss. He counts all swords β exactly a_i swords of the i-th type are left untouched.
The director has no clue about the initial number of swords of each type in the basement, the number of people who have broken into the basement and how many swords each of them have taken.
For example, if n=3, a = [3, 12, 6] then one of the possible situations is x=12, y=5 and z=3. Then the first three people took swords of the first type and the other two people took swords of the third type. Note that you don't know values x, y and z beforehand but know values of n and a.
Thus he seeks for your help. Determine the minimum number of people y, which could have broken into the theater basement, and the number of swords z each of them has taken.
Input
The first line of the input contains one integer n (2 β€ n β€ 2 β
10^{5}) β the number of types of swords.
The second line of the input contains the sequence a_1, a_2, ..., a_n (0 β€ a_i β€ 10^{9}), where a_i equals to the number of swords of the i-th type, which have remained in the basement after the theft. It is guaranteed that there exists at least one such pair of indices (j, k) that a_j β a_k.
Output
Print two integers y and z β the minimum number of people which could have broken into the basement and the number of swords each of them has taken.
Examples
Input
3
3 12 6
Output
5 3
Input
2
2 9
Output
1 7
Input
7
2 1000000000 4 6 8 4 2
Output
2999999987 2
Input
6
13 52 0 13 26 52
Output
12 13
Note
In the first example the minimum value of y equals to 5, i.e. the minimum number of people who could have broken into the basement, is 5. Each of them has taken 3 swords: three of them have taken 3 swords of the first type, and two others have taken 3 swords of the third type.
In the second example the minimum value of y is 1, i.e. the minimum number of people who could have broken into the basement, equals to 1. He has taken 7 swords of the first type. |
import java.io.*;
import java.util.*;
public class CodeForce{
static long gcd(long a,long b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
// Function to find gcd of array of
// numbers
static long findGCD(long arr[],int n)
{
long result = arr[0];
for (int i = 1; i < n; i++){
result = gcd(arr[i], result);
if(result == 1)
{
return 1;
}
}
return result;
}
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
String[] str=br.readLine().split(" ");
String s="";
long[] arr=new long[n];
long max=Long.MIN_VALUE;
for(int i=0;i<n;i++){
arr[i]=Long.parseLong(str[i]);
if(max<arr[i])
max=arr[i];
}
long[] temp=new long[n];
long sum=0;
for(int i=0;i<n;i++){
temp[i]=max-arr[i];
sum+=temp[i];
}
long gc=findGCD(temp, n);
System.out.println(sum/gc+" "+gc);
}
} | 4JAVA
| {
"input": [
"2\n2 9\n",
"3\n3 12 6\n",
"7\n2 1000000000 4 6 8 4 2\n",
"6\n13 52 0 13 26 52\n",
"10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 1 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 0\n",
"10\n1000000000 1 2 3 4 5 6 7 8 9\n",
"3\n1000000000 1 1000000000\n",
"10\n100000000 200000000 300000000 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 -1\n",
"10\n1000000000 1 2 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1000000000\n",
"2\n1 9\n",
"3\n3 8 6\n",
"7\n2 1000000000 4 6 8 1 2\n",
"6\n13 52 0 13 26 31\n",
"10\n100000000 200000000 99172297 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 2 1 1 1 1 1\n",
"5\n0 0 1 -1 -1\n",
"10\n1000000000 1 0 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1000100000\n",
"2\n1 15\n",
"3\n3 8 0\n",
"7\n2 1000000000 4 6 7 1 2\n",
"6\n5 52 0 13 26 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 2 1 2 1 2 1 1 1\n",
"10\n0000000000 1 0 3 4 5 6 7 2 9\n",
"3\n0000000000 1 1001100000\n",
"2\n0 15\n",
"7\n2 1000000000 4 6 7 1 0\n",
"6\n5 52 0 20 26 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 800000000 900000000 1000010000\n",
"10\n0000000000 1 0 3 4 5 2 7 2 9\n",
"3\n0000000001 1 1001100000\n",
"2\n0 13\n",
"3\n3 6 0\n",
"7\n2 1000000000 4 6 11 1 0\n",
"6\n5 52 0 20 51 31\n",
"10\n100000000 200000000 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"5\n0 2 1 -1 -1\n",
"10\n0000000000 2 0 3 4 5 2 7 2 9\n",
"3\n0000000000 1 1001100100\n",
"6\n5 70 0 20 51 31\n",
"10\n100000010 200000000 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"5\n-1 2 1 -1 -1\n",
"10\n0000100000 2 0 3 4 5 2 7 2 9\n",
"3\n0000000000 1 1011100100\n",
"7\n1 1000000100 4 6 11 1 0\n",
"6\n1 70 0 20 51 31\n",
"10\n100000010 23436524 171013924 28 500000000 600000000 700000000 667029535 900000000 1000010000\n",
"10\n1 1000000000 0 1 2 1 2 2 -1 1\n",
"5\n-1 4 1 -1 -1\n",
"10\n0000100000 2 0 3 4 5 2 7 4 9\n",
"3\n0000010000 1 1011100100\n",
"7\n1 1000000100 4 6 10 1 0\n",
"6\n1 70 0 20 51 53\n",
"10\n100000010 23436524 171013924 28 985204834 600000000 700000000 667029535 900000000 1000010000\n",
"10\n0000100000 2 0 0 4 5 2 7 4 9\n",
"3\n0000010000 0 1011100100\n",
"3\n5 7 -1\n",
"6\n1 70 -1 20 51 53\n",
"10\n100000010 23436524 225774845 28 985204834 600000000 700000000 667029535 900000000 1000010000\n",
"10\n0000100000 2 0 0 4 5 1 7 4 9\n",
"3\n0100010000 0 1011100100\n",
"3\n5 11 -1\n",
"7\n1 1000000100 6 6 10 1 0\n",
"6\n1 70 -1 19 51 53\n",
"10\n100000010 23436524 225774845 28 985204834 600000000 700000000 667029535 518484041 1000010000\n",
"10\n0000100000 2 0 0 4 10 1 7 4 9\n",
"3\n0100010001 0 1011100100\n",
"3\n7 11 -1\n",
"7\n2 1000000100 6 6 10 1 0\n",
"6\n1 70 -1 19 51 6\n",
"10\n100000010 23436524 225774845 0 985204834 600000000 700000000 667029535 518484041 1000010000\n",
"10\n1 1010000000 0 0 4 1 2 2 -1 1\n",
"3\n0100010001 0 1011100101\n",
"3\n7 0 -1\n",
"6\n1 70 -1 38 51 6\n",
"10\n100000010 23436524 225774845 0 1237987973 600000000 700000000 667029535 518484041 1000010000\n",
"10\n1 1010001000 0 0 4 1 2 2 -1 1\n",
"10\n0000100000 2 0 0 0 10 1 7 4 17\n",
"3\n0100010001 -1 1011100101\n",
"7\n0 1000000100 6 6 16 1 0\n",
"6\n1 70 -1 38 51 4\n",
"10\n100000010 23436524 225774845 0 1237987973 600000000 700000000 667029535 518484041 1000011000\n",
"10\n1 1010001000 0 0 4 1 2 2 -1 0\n",
"10\n0000101000 2 0 0 0 10 1 7 4 17\n",
"5\n0 0 1 -2 -1\n",
"3\n3 4 0\n",
"10\n1 1000000000 0 1 2 1 2 1 1 1\n",
"5\n0 1 1 -1 -1\n",
"10\n1 1000000000 0 1 2 1 2 2 1 1\n",
"2\n-1 13\n",
"3\n5 6 0\n",
"7\n1 1000000000 4 6 11 1 0\n",
"10\n1 1000000000 0 1 2 1 2 2 0 1\n",
"3\n5 4 0\n",
"3\n5 4 -1\n",
"10\n1 1000000000 0 1 3 1 2 2 -1 1\n",
"5\n-1 0 1 -1 -1\n",
"7\n1 1000000100 5 6 10 1 0\n",
"10\n1 1000000000 0 0 3 1 2 2 -1 1\n",
"5\n0 0 1 -1 0\n",
"10\n1 1000000000 0 0 4 1 2 2 -1 1\n",
"5\n0 -1 1 -1 0\n",
"10\n0000100000 2 0 0 0 10 1 7 4 9\n"
],
"output": [
"1 7\n",
"5 3\n",
"2999999987 2\n",
"12 13\n",
"244999999 20\n",
"9 999999999\n",
"4 1\n",
"8999999955 1\n",
"1 999999999\n",
"1224999993 4\n",
"8999999990 1\n",
"5 1\n",
"8999999961 1\n",
"1999999999 1\n",
"1 8\n",
"7 1\n",
"5999999977 1\n",
"177 1\n",
"5100827675 1\n",
"8999999989 1\n",
"6 1\n",
"8999999963 1\n",
"2000199999 1\n",
"1 14\n",
"13 1\n",
"5999999978 1\n",
"185 1\n",
"1257246512 4\n",
"8999999988 1\n",
"53 1\n",
"2002199999 1\n",
"1 15\n",
"5999999980 1\n",
"178 1\n",
"1257269012 4\n",
"57 1\n",
"2 1001099999\n",
"1 13\n",
"3 3\n",
"5999999976 1\n",
"153 1\n",
"5162046513 1\n",
"9 1\n",
"56 1\n",
"2002200199 1\n",
"243 1\n",
"5162046503 1\n",
"10 1\n",
"899966 1\n",
"2022200199 1\n",
"6000000577 1\n",
"247 1\n",
"5338609979 1\n",
"8999999991 1\n",
"18 1\n",
"899964 1\n",
"2022190199 1\n",
"6000000578 1\n",
"225 1\n",
"4853405145 1\n",
"899967 1\n",
"20221902 100\n",
"5 2\n",
"226 1\n",
"4798644224 1\n",
"899968 1\n",
"19221902 100\n",
"3 6\n",
"6000000576 1\n",
"227 1\n",
"5180160183 1\n",
"899963 1\n",
"1922190199 1\n",
"4 4\n",
"6000000575 1\n",
"274 1\n",
"5180160211 1\n",
"9089999990 1\n",
"640730067 3\n",
"15 1\n",
"255 1\n",
"7307156802 1\n",
"9090008990 1\n",
"899959 1\n",
"961095101 2\n",
"6000000571 1\n",
"257 1\n",
"7307155802 1\n",
"9090008991 1\n",
"908959 1\n",
"7 1\n",
"5 1\n",
"8999999990 1\n",
"5 1\n",
"8999999989 1\n",
"1 14\n",
"7 1\n",
"5999999977 1\n",
"8999999990 1\n",
"6 1\n",
"7 1\n",
"8999999990 1\n",
"7 1\n",
"6000000577 1\n",
"8999999991 1\n",
"5 1\n",
"8999999990 1\n",
"6 1\n",
"899967 1\n"
]
} | 2CODEFORCES
|
1239_E. Turtle_1203 | Kolya has a turtle and a field of size 2 Γ n. The field rows are numbered from 1 to 2 from top to bottom, while the columns are numbered from 1 to n from left to right.
Suppose in each cell of the field there is a lettuce leaf. The energy value of lettuce leaf in row i and column j is equal to a_{i,j}. The turtle is initially in the top left cell and wants to reach the bottom right cell. The turtle can only move right and down and among all possible ways it will choose a way, maximizing the total energy value of lettuce leaves (in case there are several such paths, it will choose any of them).
Kolya is afraid, that if turtle will eat too much lettuce, it can be bad for its health. So he wants to reorder lettuce leaves in the field, so that the energetic cost of leaves eaten by turtle will be minimized.
Input
The first line contains an integer n (2 β€ n β€ 25) β the length of the field.
The second line contains n integers a_{1, i} (0 β€ a_{1, i} β€ 50 000), the energetic cost of lettuce leaves in the first row of the field.
The third line contains n integers a_{2, i} (0 β€ a_{2, i} β€ 50 000), the energetic cost of lettuce leaves in the second row of the field.
Output
Print two lines with n integers in each β the optimal reordering of lettuce from the input data.
In case there are several optimal ways to reorder lettuce, print any of them.
Examples
Input
2
1 4
2 3
Output
1 3
4 2
Input
3
0 0 0
0 0 0
Output
0 0 0
0 0 0
Input
3
1 0 1
0 0 0
Output
0 0 1
0 1 0
Note
In the first example, after reordering, the turtle will eat lettuce with total energetic cost 1+4+2 = 7.
In the second example, the turtle will eat lettuce with energetic cost equal 0.
In the third example, after reordering, the turtle will eat lettuce with total energetic cost equal 1. | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
using namespace std;
long long poww(long long a, long long b, long long md) {
return (!b ? 1
: (b & 1 ? a * poww(a * a % md, b / 2, md) % md
: poww(a * a % md, b / 2, md) % md));
}
const int maxn = 27;
const int mxa = 50000 + 5;
const long long inf = 9223372036854775807;
const long long mod = 1e9 + 7;
int n, a[maxn * 2], ans, s, cnt[mxa];
pair<int, int> dp[maxn][maxn * mxa];
vector<int> v;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
cin >> n;
for (int i = 1; i <= 2 * n; i++) {
cin >> a[i];
s += a[i];
cnt[a[i]]++;
}
sort(a + 1, a + 2 * n + 1);
s -= (a[1] + a[2]);
dp[0][0] = {1, 0};
for (int i = 3; i <= 2 * n; i++) {
for (int j = n - 1; j >= 1; j--) {
for (int k = s; k >= a[i]; k--) {
if (dp[j - 1][k - a[i]].first && !dp[j][k].first) {
dp[j][k] = {1, a[i]};
}
}
}
}
for (int i = 0; i < maxn * mxa; i++) {
if (dp[n - 1][i].first != 0 && i >= s - i) {
ans = i;
break;
}
}
v.push_back(a[1]);
cnt[a[1]]--;
int cur = n - 1;
while (cur) {
v.push_back(dp[cur][ans].second);
cnt[dp[cur][ans].second]--;
ans = ans - dp[cur][ans].second;
cur--;
}
sort((v).begin(), (v).end());
for (auto u : v) cout << u << " ";
cout << endl;
for (int i = mxa - 1; i >= 0; i--) {
while (cnt[i]--) {
cout << i << " ";
}
}
}
| 2C++
| {
"input": [
"3\n1 0 1\n0 0 0\n",
"2\n1 4\n2 3\n",
"3\n0 0 0\n0 0 0\n",
"25\n11632 6805 12792 25513 4573 48789 42308 23247 17502 23125 43597 22173 45527 8637 33001 23532 16047 26169 49458 32012 44865 11178 34515 12381 2780\n21476 20495 26007 43987 19150 12922 29730 13310 19333 34685 25982 10775 25880 20230 34685 37998 34685 31622 37732 18470 31163 15361 33966 37477 11438\n",
"3\n5 7 9\n1 7 5\n",
"25\n2 1 4 8 16 32 64 128 256 512 1024 2048 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096\n8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192\n",
"2\n94 90\n95 91\n",
"25\n40321 8224 46399 47202 45976 43985 9392 42528 43798 43478 4346 3696 8157 48675 3994 8213 6569 49528 2650 5545 42931 42873 47208 40056 5659\n3076 6610 41778 5413 45030 3460 1985 47223 47891 315 2029 4762 40918 43297 1544 45019 9368 41211 3040 3382 4727 49072 41951 41761 4945\n",
"4\n3 5 5 10\n1 10 7 2\n",
"2\n3 2\n9 5\n",
"18\n1 1 30000 30000 30000 30000 30000 29999 30000 29998 30000 29996 30000 29992 30000 29984 30000 29968\n30000 29936 30000 29872 30000 29744 30000 29488 30000 28976 30000 27952 30000 25904 30000 21808 46383 30000\n",
"25\n13977 30242 43050 42153 44819 30157 36826 23817 18165 46936 31719 39722 40685 30360 45403 43785 31317 10755 47610 45223 37780 12391 42520 25823 36757\n12196 48393 13248 19606 41733 48213 44610 13884 14898 12547 26987 32860 28550 24452 16129 32525 23443 15076 33711 25375 42750 41296 11487 34323 42693\n",
"25\n11009 2662 12189 33929 46684 2981 8987 15612 22416 13273 4211 27609 16684 19297 17005 10715 1186 34832 14534 40381 32664 976 31854 13874 4314\n17610 40315 16287 28534 12943 26965 11759 40622 42707 15112 13502 21850 37340 17525 31663 13779 19175 3984 35095 16201 21924 34643 32271 4623 43733\n",
"25\n37275 2688 1397 35711 39231 33595 36747 34613 32372 36724 32452 4194 38356 6842 1220 33629 6533 34068 33738 1612 35852 32495 881 36971 6735\n32010 39499 35821 7877 3198 7991 38932 32571 4346 4422 3810 4600 6853 2888 32359 1252 36791 4078 5756 32576 38169 6788 6413 786 6453\n",
"25\n1 1 30000 29999 30000 29998 30000 29996 30000 29992 30000 29984 30000 29968 30000 29936 30000 29872 30000 29744 30000 29488 30000 28976 30000\n27952 30000 25900 30000 21799 46396 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000\n",
"25\n19998 36286 21814 1570 42044 23367 27679 36621 34859 45784 35654 12579 4502 17297 35398 41236 49352 46882 38830 10197 23300 49570 8897 13885 12702\n1548 24070 25322 9856 7005 24057 38330 41654 18631 48185 41602 4754 24338 45672 4779 12265 39909 3070 3263 48627 17521 4694 11073 911 31495\n",
"3\n8 3 4\n1 7 7\n",
"25\n1 1 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17\n17 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19\n",
"3\n31 12 29\n2 30 83\n",
"25\n43901 43374 14505 14673 2058 47319 35130 11897 29214 22239 6206 20731 17816 41322 40525 8747 11877 6050 6645 42632 31917 17232 289 39403 19467\n35472 17417 37829 21702 33137 31089 14259 25210 44642 18053 4485 2128 14754 37701 6455 44012 48838 21897 10275 5910 28659 7403 6213 28739 1909\n",
"3\n6 22 16\n12 22 14\n",
"25\n9790 41713 2729 20709 35806 30489 34948 15677 26025 13107 11730 5358 13329 10465 2061 19274 24802 34067 33829 17147 44658 265 19313 19829 183\n44891 6955 43270 22945 24419 45909 33598 11934 8802 2826 46593 36606 47203 44915 23592 32097 16349 40003 13734 19060 48781 35528 49644 23177 6860\n",
"25\n1 1 30000 29999 30000 29998 30000 29996 30000 29992 30000 29984 30000 29968 30000 29936 30000 29872 30000 29744 30000 29488 30000 28976 30000\n27952 30000 25904 30000 21808 46383 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000\n",
"25\n46378 31855 44594 35085 36193 49567 31839 37491 35630 33765 47191 33062 47980 37926 30090 37115 48243 44011 42363 30754 37170 35533 39212 35351 34517\n45225 32806 35507 31447 44370 48167 49955 49119 38617 30402 34673 34242 46059 31068 40003 37226 45903 41331 48851 47764 40589 46313 34490 36370 36942\n",
"5\n92 94 93 98 100\n93 93 91 100 92\n",
"25\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096\n8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192\n",
"2\n22 10\n16 22\n",
"3\n100 90 95\n95 93 92\n",
"4\n19 3 1 17\n27 18 20 7\n",
"25\n14338 37278 15777 19818 23996 13301 28977 27561 41831 24870 48337 38229 16175 32982 35518 32972 25729 26085 19289 37040 30937 14500 17541 44382 17863\n13191 39151 33210 11239 17775 41307 11428 39247 32216 42196 30054 20734 40862 27518 10332 34762 35961 33475 21186 44511 27254 34745 35353 44831 22019\n",
"25\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096\n8192 4096 8191 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192\n",
"2\n100 53\n28 1\n",
"4\n90 99 98 98\n92 96 90 90\n",
"25\n1731 9940 462 4548 1847 2706 6142 3532 7787 6089 9340 8582 5445 5730 6631 3599 7680 7882 5740 9562 524 9137 5073 8967 4295\n4024 2087 821 8897 3956 4333 767 3334 6342 4261 9207 7112 4328 6766 6511 3585 412 3425 2287 7256 6636 678 5796 946 2226\n",
"4\n5 4 7 5\n10 3 0 4\n",
"25\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
"12\n1 2 4 8 16 32 64 128 256 512 1024 2048\n4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096\n",
"25\n35136 31275 19006 14997 20200 41665 29053 35049 49312 40514 25948 15317 27233 40528 13749 13647 16853 39122 42800 38451 19249 16567 25511 23573 20227\n39407 40592 48909 32508 29786 29645 29367 27747 46774 41568 38339 36482 41110 33651 36588 37086 45222 14647 18361 40631 18489 21793 23159 30297 22824\n",
"25\n50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000\n50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000\n",
"5\n6 2 9 1 3\n6 8 9 5 2\n",
"4\n98 27 62 3\n81 66 79 79\n",
"25\n14699 24238 46280 17407 41024 18520 18977 31305 25646 22730 27105 16811 11742 37906 23634 44385 42366 43717 11044 48783 44018 16608 30414 45015 39121\n16336 29909 11021 40875 33819 16626 20398 22460 29457 11919 35271 48608 11023 30585 44536 16923 30554 14023 30886 23645 13909 28344 19218 37564 43497\n",
"5\n9 9 2 7 7\n9 9 7 10 4\n",
"25\n13616 23205 12548 44563 45718 27089 46826 20073 34501 29152 32875 43215 45270 45513 17285 34522 34756 33125 15854 35630 24699 32357 27498 27339 15650\n29127 17633 35437 10047 45766 15117 35640 48598 17657 20750 21770 22760 38464 41310 44002 12363 28850 14452 46237 48390 38169 47696 47547 41590 21215\n",
"5\n12 15 26 28 28\n25 17 8 9 7\n",
"2\n1 1\n1 2\n",
"5\n89 85 47 89 91\n77 100 75 9 30\n",
"25\n8178 18841 11754 22254 17557 1342 15857 26381 25823 14587 22990 23263 21088 5050 5436 26755 6981 5261 2965 2023 941 1310 22020 12691 19143\n9479 27085 12176 4137 3374 19314 22705 25577 24963 17562 28959 20274 25712 16723 22455 10455 18359 21635 2238 11384 23456 25294 16882 20888 19354\n",
"25\n24114 46559 40804 40930 39129 49505 18453 33358 22440 29777 37814 35048 41988 47225 12324 47524 47055 14565 46508 14139 14908 19912 16369 22323 11922\n45809 30314 23813 39806 37964 25473 14603 24414 32187 42137 30819 14382 47520 11653 21851 25587 14420 24131 32070 19898 13019 49551 20925 34197 38847\n",
"25\n11632 6805 12792 25513 4573 48789 42308 23247 17502 23125 43597 22173 52717 8637 33001 23532 16047 26169 49458 32012 44865 11178 34515 12381 2780\n21476 20495 26007 43987 19150 12922 29730 13310 19333 34685 25982 10775 25880 20230 34685 37998 34685 31622 37732 18470 31163 15361 33966 37477 11438\n",
"3\n4 7 9\n1 7 5\n",
"25\n2 1 4 8 16 32 64 128 256 512 1024 2048 4096 8192 4096 7323 4096 8192 4096 8192 4096 8192 4096 8192 4096\n8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192\n",
"2\n94 90\n183 91\n",
"25\n40321 8224 46399 47202 45976 43985 9392 42528 43798 43478 4346 3696 8157 48675 3994 8213 6569 49528 2650 5545 42931 42873 47208 40056 5659\n3076 6610 41778 5413 45030 3460 1985 47223 47891 315 2029 4762 40918 43297 1544 45019 9368 41211 3040 3382 4727 49072 73370 41761 4945\n",
"4\n3 6 5 10\n1 10 7 2\n",
"2\n3 2\n9 10\n",
"18\n1 1 30000 30000 30000 30000 30000 29999 30000 29998 30000 29996 30000 29992 30000 29984 30000 29968\n30000 29936 30000 15086 30000 29744 30000 29488 30000 28976 30000 27952 30000 25904 30000 21808 46383 30000\n",
"25\n13977 30242 43050 42153 44819 30157 36826 23817 18165 46936 31719 39722 40685 30360 45403 43785 31317 10755 47610 45223 37780 12391 42520 25823 36757\n12196 48393 13248 19606 41733 48213 44610 13884 2894 12547 26987 32860 28550 24452 16129 32525 23443 15076 33711 25375 42750 41296 11487 34323 42693\n",
"25\n11009 2662 12189 33929 46684 2981 8987 15612 22416 13273 4211 27609 16684 19297 17005 10715 1186 34832 14534 40381 32664 976 31854 13874 4314\n17610 40315 16287 28534 12943 26965 11759 40622 42707 15112 12991 21850 37340 17525 31663 13779 19175 3984 35095 16201 21924 34643 32271 4623 43733\n",
"25\n37275 2688 1397 35711 39231 33595 36747 34613 32372 36724 32452 4194 38356 6842 1220 33629 6533 34068 33738 1612 35852 32495 881 36971 6735\n32010 39499 35821 7877 3198 7991 38932 32571 4346 4422 3810 4600 6853 2888 39016 1252 36791 4078 5756 32576 38169 6788 6413 786 6453\n",
"25\n1 1 30000 29999 30000 29998 30000 29996 30000 29992 30000 29984 30000 29968 30000 29936 30000 29872 30000 29744 30000 29488 30000 28976 30000\n27952 30000 25900 30000 21799 46396 30000 30000 30000 20394 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000\n",
"25\n19998 36286 21814 1570 42044 23367 27679 36621 34859 45784 35654 12579 4502 17297 35398 41236 49352 46882 38830 10197 23300 49570 8897 13885 12702\n1548 24070 25322 9856 7005 24057 53073 41654 18631 48185 41602 4754 24338 45672 4779 12265 39909 3070 3263 48627 17521 4694 11073 911 31495\n",
"3\n8 2 4\n1 7 7\n",
"25\n1 1 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 33 17 17 17\n17 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19\n",
"3\n31 0 29\n2 30 83\n",
"25\n43901 43374 14505 14673 2058 47319 35130 11897 29214 22239 6206 20731 17816 41322 40525 8747 11877 6050 6645 42632 31917 17232 289 39403 19467\n35472 17417 37829 21702 33137 31089 14259 25210 44642 18053 4485 2128 14754 37701 6455 44012 48838 21897 10275 5910 28659 7403 6213 27362 1909\n",
"3\n6 39 16\n12 22 14\n",
"25\n9790 41713 2729 20709 35806 30489 34948 15677 26025 13107 11730 5358 13329 10465 2061 35792 24802 34067 33829 17147 44658 265 19313 19829 183\n44891 6955 43270 22945 24419 45909 33598 11934 8802 2826 46593 36606 47203 44915 23592 32097 16349 40003 13734 19060 48781 35528 49644 23177 6860\n",
"25\n1 1 30000 29999 30000 29998 30000 29996 30000 29992 30000 29984 30000 29968 30000 29936 30000 42230 30000 29744 30000 29488 30000 28976 30000\n27952 30000 25904 30000 21808 46383 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000\n",
"25\n46378 31855 44594 35085 36193 49567 31839 37491 35630 33765 47191 33062 47980 37926 30090 37115 48243 44011 42363 30754 37170 35533 39212 35351 34517\n45225 32806 35507 31447 44370 48167 62365 49119 38617 30402 34673 34242 46059 31068 40003 37226 45903 41331 48851 47764 40589 46313 34490 36370 36942\n",
"5\n92 94 104 98 100\n93 93 91 100 92\n",
"25\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096\n8192 4096 8192 4096 8192 8013 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192 4096 8192\n",
"2\n20 10\n16 22\n",
"3\n000 90 95\n95 93 92\n",
"4\n19 3 1 17\n40 18 20 7\n",
"25\n14338 37278 15777 19818 23996 13301 28977 27561 41831 24870 48337 38229 16175 32982 35518 32972 25729 26085 19289 37040 30937 14500 29384 44382 17863\n13191 39151 33210 11239 17775 41307 11428 39247 32216 42196 30054 20734 40862 27518 10332 34762 35961 33475 21186 44511 27254 34745 35353 44831 22019\n",
"2\n100 9\n28 1\n",
"4\n90 99 98 98\n61 96 90 90\n",
"25\n71 9940 462 4548 1847 2706 6142 3532 7787 6089 9340 8582 5445 5730 6631 3599 7680 7882 5740 9562 524 9137 5073 8967 4295\n4024 2087 821 8897 3956 4333 767 3334 6342 4261 9207 7112 4328 6766 6511 3585 412 3425 2287 7256 6636 678 5796 946 2226\n",
"4\n3 4 7 5\n10 3 0 4\n",
"12\n1 2 4 8 16 32 64 128 256 512 1024 2048\n4096 2035 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096\n",
"25\n35136 31275 19006 14997 20200 41665 29053 35049 49312 40514 25948 15317 27233 40528 13749 13647 16853 39122 42800 38451 19249 16567 25511 23573 20227\n39407 40592 48909 32508 29786 29645 29367 27747 46774 41568 38339 36482 41110 33651 36588 37086 45222 14647 18361 40631 18489 30494 23159 30297 22824\n",
"25\n50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 42052 50000 50000 50000 50000 50000\n50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000\n",
"5\n6 2 9 1 3\n2 8 9 5 2\n",
"4\n98 27 62 3\n81 66 79 136\n",
"25\n14699 24238 46280 17407 41024 18520 18977 31305 25646 22730 27105 16811 11742 37906 23634 44385 42366 43717 11044 48783 44018 16608 30414 45015 39121\n16336 29909 11021 40875 33819 16626 20398 22460 29457 11919 35271 48608 11023 4216 44536 16923 30554 14023 30886 23645 13909 28344 19218 37564 43497\n",
"5\n9 9 2 7 7\n9 9 7 12 4\n"
],
"output": [
"0 0 1 \n1 0 0 ",
"1 3\n4 2\n",
"0 0 0 \n0 0 0 ",
"2780 6805 8637 10775 11178 11438 11632 12381 12792 13310 15361 17502 21476 23125 23532 37477 37732 37998 42308 43597 43987 44865 45527 48789 49458\n34685 34685 34685 34515 33966 33001 32012 31622 31163 29730 26169 26007 25982 25880 25513 23247 22173 20495 20230 19333 19150 18470 16047 12922 4573\n",
"1 5 9\n7 7 5\n",
"1 4 8 16 32 64 128 256 512 1024 2048 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192\n8192 8192 8192 8192 8192 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 2\n",
"90 94\n95 91\n",
"315 1985 2029 2650 3076 3382 3696 3994 4346 4762 5545 6610 9392 43985 45019 45030 45976 46399 47202 47208 47223 47891 48675 49072 49528\n43798 43478 43297 42931 42873 42528 41951 41778 41761 41211 40918 40321 40056 9368 8224 8213 8157 6569 5659 5413 4945 4727 3460 3040 1544\n",
"1 3 7 10\n10 5 5 2\n",
"2 5\n9 3\n",
"1 21808 25904 27952 28976 29488 29744 29872 29936 29968 29984 29992 29996 29998 29999 30000 30000 46383\n30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 1\n",
"10755 12196 12391 12547 13248 13884 13977 14898 16129 19606 25823 32860 34323 42693 42750 43050 43785 44610 44819 45223 45403 46936 47610 48213 48393\n42520 42153 41733 41296 40685 39722 37780 36826 36757 33711 32525 31719 31317 30360 30242 30157 28550 26987 25375 24452 23817 23443 18165 15076 11487\n",
"976 2662 2981 3984 4211 4314 4623 8987 10715 11759 12189 13273 13779 15612 16287 31854 34832 35095 37340 40315 40381 40622 42707 43733 46684\n34643 33929 32664 32271 31663 28534 27609 26965 22416 21924 21850 19297 19175 17610 17525 17005 16684 16201 15112 14534 13874 13502 12943 11009 1186\n",
"786 1220 1252 1397 1612 2688 2888 4078 4194 4422 6413 6842 7877 35821 35852 36724 36747 36791 36971 37275 38169 38356 38932 39231 39499\n35711 34613 34068 33738 33629 33595 32576 32571 32495 32452 32372 32359 32010 7991 6853 6788 6735 6533 6453 5756 4600 4346 3810 3198 881\n",
"1 21799 25900 27952 28976 29488 29744 29872 29936 29968 29984 29992 29996 29998 29999 30000 30000 30000 30000 30000 30000 30000 30000 30000 46396\n30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 1\n",
"911 1570 3070 3263 4502 4754 4779 7005 9856 10197 11073 12265 17297 19998 41236 41602 41654 42044 45672 45784 46882 48185 48627 49352 49570\n39909 38830 38330 36621 36286 35654 35398 34859 31495 27679 25322 24338 24070 24057 23367 23300 21814 18631 17521 13885 12702 12579 8897 4694 1548\n",
"1 4 8\n7 7 3\n",
"1 17 17 17 17 17 17 17 17 17 17 17 17 19 19 19 19 19 19 19 19 19 19 19 19 \n19 19 19 19 19 19 19 19 19 19 19 19 17 17 17 17 17 17 17 17 17 17 17 17 1 ",
"2 30 31\n83 29 12\n",
"289 2058 2128 4485 5910 6206 6213 6455 6645 7403 8747 10275 14673 14754 28659 39403 40525 41322 42632 43374 43901 44012 44642 47319 48838\n37829 37701 35472 35130 33137 31917 31089 29214 28739 25210 22239 21897 21702 20731 19467 18053 17816 17417 17232 14505 14259 11897 11877 6050 1909\n",
"6 14 22\n22 16 12\n",
"183 2061 2729 2826 5358 6860 6955 8802 9790 11730 11934 13329 13734 19060 35528 41713 43270 44658 44891 44915 45909 46593 47203 48781 49644\n40003 36606 35806 34948 34067 33829 33598 32097 30489 26025 24802 24419 23592 23177 22945 20709 19829 19313 19274 17147 16349 15677 13107 10465 265\n",
"1 21808 25904 27952 28976 29488 29744 29872 29936 29968 29984 29992 29996 29998 29999 30000 30000 30000 30000 30000 30000 30000 30000 30000 46383\n30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 1\n",
"30090 30754 31068 31447 31839 32806 33062 33765 34242 34490 34517 34673 35085 35351 38617 46378 47191 47764 47980 48167 48243 48851 49119 49567 49955\n46313 46059 45903 45225 44594 44370 44011 42363 41331 40589 40003 39212 37926 37491 37226 37170 37115 36942 36370 36193 35630 35533 35507 31855 30402\n",
"91 93 93 94 100\n100 98 93 92 92\n",
"1 4 8 16 32 64 128 256 512 1024 2048 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192\n8192 8192 8192 8192 8192 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 2\n",
"10 22 \n22 16 ",
"90 95 95\n100 93 92\n",
"1 7 20 27\n19 18 17 3\n",
"10332 11428 13191 13301 14338 14500 16175 17775 19289 19818 20734 21186 22019 35518 38229 39151 39247 40862 41307 41831 42196 44382 44511 44831 48337\n37278 37040 35961 35353 34762 34745 33475 33210 32982 32972 32216 30937 30054 28977 27561 27518 27254 26085 25729 24870 23996 17863 17541 15777 11239\n",
"1 4 8 16 32 64 128 256 512 1024 2048 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192\n8192 8192 8192 8192 8191 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 2\n",
"1 53\n100 28\n",
"90 92 96 98\n99 98 90 90\n",
"412 524 678 767 821 946 1731 1847 2087 2226 3334 3599 3956 4548 7680 7787 7882 8582 8897 8967 9137 9207 9340 9562 9940\n7256 7112 6766 6636 6631 6511 6342 6142 6089 5796 5740 5730 5445 5073 4333 4328 4295 4261 4024 3585 3532 3425 2706 2287 462\n",
"0 5 5 7\n10 4 4 3\n",
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
"1 64 128 256 512 1024 4096 4096 4096 4096 4096 4096\n4096 4096 4096 4096 4096 4096 2048 32 16 8 4 2\n",
"13647 14647 14997 15317 16567 16853 18489 19006 19249 20227 21793 23159 27747 39122 40528 40592 40631 41110 41568 41665 42800 45222 46774 48909 49312\n40514 39407 38451 38339 37086 36588 36482 35136 35049 33651 32508 31275 30297 29786 29645 29367 29053 27233 25948 25511 23573 22824 20200 18361 13749\n",
"50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 \n50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 ",
"1 2 5 8 9\n9 6 6 3 2\n",
"3 66 79 81\n98 79 62 27\n",
"11021 11044 11742 11919 13909 14023 14699 16608 16626 16811 16923 18520 22460 23634 31305 42366 43497 43717 44018 44385 44536 45015 46280 48608 48783\n41024 40875 39121 37906 37564 35271 33819 30886 30585 30554 30414 29909 29457 28344 27105 25646 24238 23645 22730 20398 19218 18977 17407 16336 11023\n",
"2 7 7 9 10\n9 9 9 7 4\n",
"10047 12548 13616 14452 15117 15854 17633 17657 20073 20750 21215 21770 27089 35630 44563 45270 45513 45718 45766 46237 46826 47547 47696 48390 48598\n44002 43215 41590 41310 38464 38169 35640 35437 34756 34522 34501 33125 32875 32357 29152 29127 28850 27498 27339 24699 23205 22760 17285 15650 12363\n",
"7 9 15 28 28\n26 25 17 12 8\n",
"1 1\n2 1\n",
"9 75 77 85 89\n100 91 89 47 30\n",
"941 1342 2023 2965 3374 4137 5050 5261 5436 8178 11754 15857 22705 22990 23263 23456 24963 25294 25577 25712 25823 26381 26755 27085 28959\n22455 22254 22020 21635 21088 20888 20274 19354 19314 19143 18841 18359 17562 17557 16882 16723 14587 12691 12176 11384 10455 9479 6981 2238 1310\n",
"11653 12324 13019 14139 14382 14420 14565 14603 14908 18453 21851 22323 23813 24131 40930 42137 45809 46508 46559 47055 47225 47520 47524 49505 49551\n41988 40804 39806 39129 38847 37964 37814 35048 34197 33358 32187 32070 30819 30314 29777 25587 25473 24414 24114 22440 20925 19912 19898 16369 11922\n",
"2780 6805 8637 10775 11178 11438 11632 12381 12792 12922 13310 17502 20230 23532 26007 34685 37732 37998 42308 43597 43987 44865 48789 49458 52717 \n37477 34685 34685 34515 33966 33001 32012 31622 31163 29730 26169 25982 25880 25513 23247 23125 22173 21476 20495 19333 19150 18470 16047 15361 4573 \n",
"1 5 9 \n7 7 4 \n",
"1 16 32 128 256 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 7323 8192 8192 8192 8192 8192 8192 8192 8192 \n8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 4096 4096 4096 4096 4096 4096 4096 4096 2048 1024 512 64 8 4 2 \n",
"90 94 \n183 91 \n",
"315 1985 3382 4762 4945 5545 5659 6569 6610 8157 8213 8224 9368 9392 45030 45976 46399 47202 47208 47223 47891 48675 49072 49528 73370 \n45019 43985 43798 43478 43297 42931 42873 42528 41778 41761 41211 40918 40321 40056 5413 4727 4346 3994 3696 3460 3076 3040 2650 2029 1544 \n",
"1 3 7 10 \n10 6 5 2 \n",
"2 9 \n10 3 \n",
"1 25904 27952 28976 29744 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 \n46383 30000 30000 30000 30000 30000 30000 29999 29998 29996 29992 29984 29968 29936 29488 21808 15086 1 \n",
"2894 12196 12391 12547 13248 13884 13977 15076 16129 19606 24452 25375 41296 42693 42750 43050 43785 44610 44819 45223 45403 46936 47610 48213 48393 \n42520 42153 41733 40685 39722 37780 36826 36757 34323 33711 32860 32525 31719 31317 30360 30242 30157 28550 26987 25823 23817 23443 18165 11487 10755 \n",
"976 2662 2981 3984 4211 4314 4623 8987 11009 11759 12189 12991 13779 14534 16287 32664 34832 35095 37340 40315 40381 40622 42707 43733 46684 \n34643 33929 32271 31854 31663 28534 27609 26965 22416 21924 21850 19297 19175 17610 17525 17005 16684 16201 15612 15112 13874 13273 12943 10715 1186 \n",
"786 1220 1252 1397 1612 2688 3198 3810 4078 4194 6735 6842 7991 35852 36724 36747 36791 36971 37275 38169 38356 38932 39016 39231 39499 \n35821 35711 34613 34068 33738 33629 33595 32576 32571 32495 32452 32372 32010 7877 6853 6788 6533 6453 6413 5756 4600 4422 4346 2888 881 \n",
"1 20394 21799 27952 28976 29744 29936 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 46396 \n30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 29999 29998 29996 29992 29984 29968 29872 29488 25900 1 \n",
"911 1570 3070 3263 4502 4754 4779 7005 9856 10197 11073 12579 13885 18631 41602 41654 42044 45672 45784 46882 48185 48627 49352 49570 53073 \n41236 39909 38830 36621 36286 35654 35398 34859 31495 27679 25322 24338 24070 24057 23367 23300 21814 19998 17521 17297 12702 12265 8897 4694 1548 \n",
"1 4 8 \n7 7 2 \n",
"1 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 19 19 19 19 19 19 19 19 33 \n19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 17 17 17 17 17 17 17 17 1 \n",
"0 30 31 \n83 29 2 \n",
"289 2058 2128 4485 5910 6050 6206 6213 6455 6645 7403 11897 14505 14754 29214 39403 40525 41322 42632 43374 43901 44012 44642 47319 48838 \n37829 37701 35472 35130 33137 31917 31089 28659 27362 25210 22239 21897 21702 20731 19467 18053 17816 17417 17232 14673 14259 11877 10275 8747 1909 \n",
"6 16 22 \n39 14 12 \n",
"183 2061 2729 2826 5358 6860 6955 8802 9790 10465 11730 13329 19313 22945 35792 41713 43270 44658 44891 44915 45909 46593 47203 48781 49644 \n40003 36606 35806 35528 34948 34067 33829 33598 32097 30489 26025 24802 24419 23592 23177 20709 19829 19060 17147 16349 15677 13734 13107 11934 265 \n",
"1 21808 27952 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 46383 \n42230 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 30000 29999 29998 29996 29992 29984 29968 29936 29744 29488 28976 25904 1 \n",
"30090 30754 31068 31447 31839 31855 32806 33062 33765 34517 34673 35351 35533 35630 37226 42363 47191 47764 47980 48167 48243 48851 49119 49567 62365 \n46378 46313 46059 45903 45225 44594 44370 44011 41331 40589 40003 39212 38617 37926 37491 37170 37115 36942 36370 36193 35507 35085 34490 34242 30402 \n",
"91 92 93 98 104 \n100 100 94 93 92 \n",
"1 4 32 128 256 512 1024 4096 4096 4096 4096 4096 4096 4096 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 \n8192 8192 8192 8192 8192 8192 8192 8192 8013 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 2048 64 16 8 2 \n",
"10 20 \n22 16 \n",
"0 92 95 \n95 93 90 \n",
"1 18 19 20 \n40 17 7 3 \n",
"10332 11428 13191 13301 14338 14500 15777 16175 17775 19289 21186 24870 26085 37278 38229 39151 39247 40862 41307 41831 42196 44382 44511 44831 48337 \n37040 35961 35518 35353 34762 34745 33475 33210 32982 32972 32216 30937 30054 29384 28977 27561 27518 27254 25729 23996 22019 20734 19818 17863 11239 \n",
"1 28 \n100 9 \n",
"61 90 96 99 \n98 98 90 90 \n",
"71 462 524 678 767 821 946 1847 2226 2287 2706 3425 4295 5445 7680 7787 7882 8582 8897 8967 9137 9207 9340 9562 9940 \n7256 7112 6766 6636 6631 6511 6342 6142 6089 5796 5740 5730 5073 4548 4333 4328 4261 4024 3956 3599 3585 3532 3334 2087 412 \n",
"0 4 5 7 \n10 4 3 3 \n",
"1 32 64 128 256 512 4096 4096 4096 4096 4096 4096 \n4096 4096 4096 4096 4096 2048 2035 1024 16 8 4 2 \n",
"13647 14647 14997 15317 16567 16853 18361 19006 19249 20227 23159 23573 29053 40514 40528 40592 40631 41110 41568 41665 42800 45222 46774 48909 49312 \n39407 39122 38451 38339 37086 36588 36482 35136 35049 33651 32508 31275 30494 30297 29786 29645 29367 27747 27233 25948 25511 22824 20200 18489 13749 \n",
"42052 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 \n50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 50000 \n",
"1 2 2 9 9 \n8 6 5 3 2 \n",
"3 79 81 98 \n136 66 62 27 \n",
"4216 11023 11044 11742 11919 13909 14023 14699 16336 16626 17407 18520 18977 20398 33819 42366 43497 43717 44018 44385 44536 45015 46280 48608 48783 \n41024 40875 39121 37906 37564 35271 31305 30886 30554 30414 29909 29457 28344 27105 25646 24238 23645 23634 22730 22460 19218 16923 16811 16608 11021 \n",
"2 7 9 9 9 \n12 9 7 7 4 \n"
]
} | 2CODEFORCES
|
1257_G. Divisor Set_1204 | You are given an integer x represented as a product of n its prime divisors p_1 β
p_2, β
β¦ β
p_n. Let S be the set of all positive integer divisors of x (including 1 and x itself).
We call a set of integers D good if (and only if) there is no pair a β D, b β D such that a β b and a divides b.
Find a good subset of S with maximum possible size. Since the answer can be large, print the size of the subset modulo 998244353.
Input
The first line contains the single integer n (1 β€ n β€ 2 β
10^5) β the number of prime divisors in representation of x.
The second line contains n integers p_1, p_2, ..., p_n (2 β€ p_i β€ 3 β
10^6) β the prime factorization of x.
Output
Print the maximum possible size of a good subset modulo 998244353.
Examples
Input
3
2999999 43 2999957
Output
3
Input
6
2 3 2 3 2 2
Output
3
Note
In the first sample, x = 2999999 β
43 β
2999957 and one of the maximum good subsets is \{ 43, 2999957, 2999999 \}.
In the second sample, x = 2 β
3 β
2 β
3 β
2 β
2 = 144 and one of the maximum good subsets is \{ 9, 12, 16 \}. | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1000000007;
long double EPS = 1e-9;
long long binpow(long long b, long long p, long long mod) {
long long ans = 1;
b %= mod;
for (; p; p >>= 1) {
if (p & 1) ans = ans * b % mod;
b = b * b % mod;
}
return ans;
}
void pre() {}
namespace GetPrimitve {
vector<long long> Divisors;
vector<long long> Divisor(long long x) {
vector<long long> ans;
for (long long i = 2; i * i <= x; i++) {
if (x % i == 0) {
ans.emplace_back(i);
while (x % i == 0) x /= i;
}
}
if (x > 1) ans.emplace_back(x);
return ans;
}
bool check(int prim, int p, vector<long long>& divs) {
for (auto v : divs) {
if (binpow(prim, (p - 1) / v, p) == 1) return 0;
}
return 1;
}
int getRoot(int p) {
int ans = 2;
vector<long long> divs = Divisor(p - 1);
while (!check(ans, p, divs)) ans++;
return ans;
}
}; // namespace GetPrimitve
namespace POLYMUL {
using polybase = long long;
const long long NTTMOD = 998244353, PRIMITIVE_ROOT = 3;
const long long MAXB = 1 << 21;
long long modInv(long long a) {
return a <= 1
? a
: (long long)(NTTMOD - NTTMOD / a) * modInv(NTTMOD % a) % NTTMOD;
}
void NTT(polybase P[], long long n, long long oper) {
for (int i = 1, j = 0; i < n - 1; i++) {
for (int s = n; j ^= s >>= 1, ~j & s;)
;
if (i < j) swap(P[i], P[j]);
}
for (int d = 0; (1 << d) < n; d++) {
int m = 1 << d, m2 = m * 2;
long long unit_p0 = binpow(PRIMITIVE_ROOT, (NTTMOD - 1) / m2, NTTMOD);
if (oper < 0) unit_p0 = modInv(unit_p0);
for (int i = 0; i < n; i += m2) {
long long unit = 1;
for (int j = 0; j < m; j++) {
polybase &P1 = P[i + j + m], &P2 = P[i + j];
polybase t = unit * P1 % NTTMOD;
P1 = (P2 - t + NTTMOD) % NTTMOD;
P2 = (P2 + t) % NTTMOD;
unit = unit * unit_p0 % NTTMOD;
}
}
}
}
vector<polybase> mul(const vector<polybase>& a, const vector<polybase>& b) {
vector<polybase> ret(max(0LL, (long long)a.size() + (long long)b.size() - 1),
0);
static polybase A[MAXB], B[MAXB], C[MAXB];
int len = 1;
while (len < (long long)ret.size()) len <<= 1;
for (int i = 0; i < len; i++) A[i] = i < (int)a.size() ? a[i] : 0;
for (int i = 0; i < len; i++) B[i] = i < (int)b.size() ? b[i] : 0;
NTT(A, len, 1);
NTT(B, len, 1);
for (long long i = 0; i < len; i++) C[i] = (polybase)A[i] * B[i] % NTTMOD;
NTT(C, len, -1);
for (long long i = 0, inv = modInv(len); i < (long long)ret.size(); i++)
ret[i] = (long long)C[i] * inv % NTTMOD;
return ret;
}
vector<long long> binpow(vector<long long> b, long long p) {
vector<long long> ans = vector<long long>(1, 1);
for (; p; p >>= 1) {
if (p & 1) ans = mul(ans, b);
b = mul(b, b);
}
return ans;
}
vector<long long> calc(vector<long long>& arr, int l, int r) {
if (l == r) {
return vector<long long>(arr[l] + 1, 1);
}
int mid = (l + r) >> 1;
vector<long long> x = calc(arr, l, mid), y = calc(arr, mid + 1, r);
return mul(x, y);
}
} // namespace POLYMUL
using namespace POLYMUL;
void solve() {
long long n;
cin >> n;
map<int, int> freq;
for (long long i = 0; i < (n); ++i) {
int x;
cin >> x;
freq[x]++;
}
vector<long long> vals;
for (auto v : freq) {
vals.emplace_back(v.second);
}
sort((vals).begin(), (vals).end());
vector<long long> pp = calc(vals, 0, vals.size() - 1);
cout << pp[n / 2] << '\n';
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
pre();
long long _t = 1;
for (long long i = 1; i <= _t; i++) {
solve();
}
}
| 2C++
| {
"input": [
"3\n2999999 43 2999957\n",
"6\n2 3 2 3 2 2\n",
"16\n2 2 2 2 2 3 3 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 2 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 3 3 5 7 11 13 17\n",
"1\n2999999\n",
"16\n2 2 2 2 2 2 2 2 2 3 3 5 7 11 13 17\n",
"16\n2 2 2 3 3 3 5 5 5 7 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 3 5 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 3 3 3 3 5 5 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 3 3 3 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 3 3 3 5 5 5 7 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 3 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 2 2 2 2 2 3 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 2 3 3 3 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 5 5 5 7 11 13 17\n",
"16\n2 2 2 2 3 3 3 3 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 5 5 7 7 11 11 13 13 17\n",
"16\n2 2 2 2 3 3 3 5 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 3 3 5 5 5 7 11 13 17\n",
"16\n2 2 2 2 3 3 5 5 7 7 11 11 13 13 17 17\n",
"16\n2 2 2 2 3 3 3 5 5 7 7 11 11 13 13 17\n",
"23\n2 2 2 2 2 2 2 2 3 3 3 3 3 5 5 5 5 7 7 11 11 13 13\n",
"16\n2 2 2 3 3 3 5 5 5 7 7 11 11 13 13 17\n",
"16\n2 2 2 2 2 2 2 3 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 3 3 3 3 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 3 3 3 5 5 7 7 11 11 13 13 17 17\n",
"16\n2 2 2 2 3 3 3 3 5 5 5 7 7 11 13 17\n",
"1\n297754\n",
"16\n2 2 2 3 5 3 5 5 5 7 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 5 5 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 5 5 2 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 5 3 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 3 5 3 5 5 7 7 11 11 13 13 17\n",
"16\n2 2 2 2 2 2 2 3 3 3 3 5 7 2 13 17\n",
"16\n2 2 3 2 3 3 3 3 5 5 7 7 11 11 13 17\n",
"1\n482100\n",
"1\n148685\n",
"1\n179970\n",
"1\n355734\n",
"1\n202567\n",
"1\n25373\n",
"1\n35333\n",
"1\n58153\n",
"1\n69259\n",
"1\n109442\n",
"1\n179431\n",
"1\n205261\n",
"1\n45715\n",
"1\n79511\n",
"1\n14306\n",
"1\n11289\n",
"1\n3574\n",
"1\n3059\n",
"1\n1078\n",
"1\n284\n",
"1\n68\n",
"1\n52\n",
"1\n53\n",
"1\n97\n",
"1\n66\n",
"1\n85\n",
"1\n161\n",
"1\n248\n"
],
"output": [
"3\n",
"3\n",
"310\n",
"144\n",
"274\n",
"178\n",
"1\n",
"96\n",
"478\n",
"334\n",
"288\n",
"240\n",
"226\n",
"386\n",
"310\n",
"380\n",
"64\n",
"128\n",
"242\n",
"406\n",
"432\n",
"440\n",
"272\n",
"573\n",
"502\n",
"736\n",
"546\n",
"190\n",
"158\n",
"214\n",
"624\n",
"356\n",
"1\n",
"440\n",
"310\n",
"214\n",
"380\n",
"502\n",
"80\n",
"380\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n"
]
} | 2CODEFORCES
|
1257_G. Divisor Set_1205 | You are given an integer x represented as a product of n its prime divisors p_1 β
p_2, β
β¦ β
p_n. Let S be the set of all positive integer divisors of x (including 1 and x itself).
We call a set of integers D good if (and only if) there is no pair a β D, b β D such that a β b and a divides b.
Find a good subset of S with maximum possible size. Since the answer can be large, print the size of the subset modulo 998244353.
Input
The first line contains the single integer n (1 β€ n β€ 2 β
10^5) β the number of prime divisors in representation of x.
The second line contains n integers p_1, p_2, ..., p_n (2 β€ p_i β€ 3 β
10^6) β the prime factorization of x.
Output
Print the maximum possible size of a good subset modulo 998244353.
Examples
Input
3
2999999 43 2999957
Output
3
Input
6
2 3 2 3 2 2
Output
3
Note
In the first sample, x = 2999999 β
43 β
2999957 and one of the maximum good subsets is \{ 43, 2999957, 2999999 \}.
In the second sample, x = 2 β
3 β
2 β
3 β
2 β
2 = 144 and one of the maximum good subsets is \{ 9, 12, 16 \}. | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author anand.oza
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
GDivisorSet solver = new GDivisorSet();
solver.solve(1, in, out);
out.close();
}
static class GDivisorSet {
NumberTheory.Mod998 mod = new NumberTheory.Mod998();
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
int[] primeFactors = in.readIntArray(n);
HashMap<Integer, Integer> count = new HashMap<>();
for (int x : primeFactors) {
count.merge(x, 1, Integer::sum);
}
int[] p = new int[count.size()];
int index = 0;
for (int x : count.values()) {
p[index++] = x;
}
long answer = solve(p);
out.println(answer);
}
private long solve(int[] p) {
int total = 0;
for (int x : p) {
total += x;
}
int k = total / 2;
HashMap<Integer, Integer> count = new HashMap<>();
for (int x : p) {
count.merge(x, 1, Integer::sum);
}
PriorityQueue<Polynomial<NumberTheory.Mod998>> polynomials = new PriorityQueue<>(Comparator.comparingInt(x -> x.n));
for (Entry<Integer, Integer> entry : count.entrySet()) {
Polynomial<NumberTheory.Mod998> poly = make(entry.getKey());
poly = poly.powFFT(entry.getValue());
polynomials.add(poly);
}
while (polynomials.size() >= 2) {
polynomials.add(polynomials.poll().multFFT(polynomials.poll()));
}
return polynomials.peek().coeff[k];
}
private Polynomial<NumberTheory.Mod998> make(int degree) {
long[] next = new long[degree + 1];
Arrays.fill(next, 1);
return mod.create(next);
}
}
static class NumberTheory {
private static void ASSERT(boolean assertion) {
if (!assertion)
throw new AssertionError();
}
public abstract static class Modulus<M extends NumberTheory.Modulus<M>> {
ArrayList<Long> factorial = new ArrayList<>();
ArrayList<Long> invFactorial = new ArrayList<>();
public abstract long modulus();
public Modulus() {
super();
factorial.add(1L);
invFactorial.add(1L);
}
public long normalize(long x) {
x %= modulus();
if (x < 0)
x += modulus();
return x;
}
public long add(long a, long b) {
long v = a + b;
return v < modulus() ? v : v - modulus();
}
public long subtract(long a, long b) {
long v = a - b;
return v < 0 ? v + modulus() : v;
}
public long mult(long a, long b) {
return normalize(a * b);
}
public long pow(long x, long e) {
if (e < 0) {
x = inv(x);
e *= -1;
}
if (e == 0)
return 1;
if ((e & 1) > 0)
return mult(x, pow(x, e - 1));
return pow(mult(x, x), e / 2);
}
public long inv(long value) {
long g = modulus(), x = 0, y = 1;
for (long r = value; r != 0; ) {
long q = g / r;
g %= r;
long temp = g;
g = r;
r = temp;
x -= q * y;
temp = x;
x = y;
y = temp;
}
ASSERT(g == 1);
ASSERT(y == modulus() || y == -modulus());
return normalize(x);
}
public Polynomial<M> create(long... coeff) {
return new Polynomial(this, coeff);
}
public long totient() {
throw new UnsupportedOperationException("need to implement this");
}
public long generator() {
throw new UnsupportedOperationException("need to implement this");
}
public long unityRoot(int degree) {
ASSERT(totient() % degree == 0);
return pow(generator(), totient() / degree);
}
}
public static class Mod998 extends NumberTheory.Modulus<NumberTheory.Mod998> {
public long modulus() {
return 998_244_353L;
}
public long totient() {
return modulus() - 1;
}
public long generator() {
return 3;
}
}
}
static class Polynomial<M extends NumberTheory.Modulus<M>> {
public final long[] coeff;
public final int n;
public final M m;
public Polynomial(int degree, M modulus, long... coeff) {
m = modulus;
n = degree;
this.coeff = new long[n + 1];
for (int i = 0; i < Math.min(this.coeff.length, coeff.length); i++) {
this.coeff[i] = coeff[i];
}
}
public Polynomial(M modulus, long... coeff) {
m = modulus;
n = coeff.length - 1;
this.coeff = new long[n + 1];
for (int i = 0; i <= n; i++) {
this.coeff[i] = coeff[i];
}
}
public Polynomial<M> mult(Polynomial<M> other) {
long[] result = new long[n + other.n + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= other.n; j++) {
result[i + j] = m.add(result[i + j], m.mult(coeff[i], other.coeff[j]));
}
}
return m.create(result);
}
public Polynomial<M> powFFT(int e) {
if (e == 0)
return m.create(new long[]{1});
if (e == 1)
return this;
if ((e & 1) > 0)
return this.multFFT(this.powFFT(e - 1));
return this.multFFT(this).powFFT(e / 2);
}
public Polynomial<M> multFFT(Polynomial<M> other) {
if (Math.min(n, other.n) < 100) {
return this.mult(other);
}
int resultDegree = n + other.n;
int resultLength = resultDegree + 1;
int resultLengthBig = Integer.highestOneBit(resultLength);
if (resultLengthBig == resultLength)
resultLengthBig *= 2;
resultLengthBig *= 2;
int resultDegreeBig = resultLengthBig - 1;
boolean eq = Arrays.equals(coeff, other.coeff);
Polynomial<M> a = new Polynomial<>(resultDegreeBig, m, coeff);
a.inPlaceFFT(false);
if (!eq) {
Polynomial<M> b = new Polynomial<>(resultDegreeBig, m, other.coeff);
b.inPlaceFFT(false);
for (int i = 0; i < a.coeff.length; i++) {
a.coeff[i] = m.mult(a.coeff[i], b.coeff[i]);
}
} else {
for (int i = 0; i < a.coeff.length; i++) {
a.coeff[i] = m.mult(a.coeff[i], a.coeff[i]);
}
}
a.inPlaceFFT(true);
return new Polynomial<>(resultDegree, m, a.coeff);
}
public void inPlaceFFT(boolean inverse) {
Util.ASSERT(Integer.bitCount(n + 1) == 1);
for (int i = 1, j = 0; i < n + 1; i++) {
for (int k = (n + 1) >> 1; (j ^= k) < k; k >>= 1)
;
if (i < j)
Util.swap(coeff, i, j);
}
for (int l = 1; l < n + 1; l <<= 1) {
long[] unityRoots = new long[2 * l + 1];
unityRoots[0] = 1;
unityRoots[1] = m.unityRoot(2 * l);
for (int i = 2; i < unityRoots.length; i++) {
unityRoots[i] = m.mult(unityRoots[i - 1], unityRoots[1]);
}
for (int i = 0; i < n + 1; i += 2 * l) {
for (int j = 0; j < l; j++) {
int wIndex = inverse ? 2 * l - j : j;
long w = unityRoots[wIndex];
long u = coeff[i + j];
long v = m.mult(coeff[i + j + l], w);
coeff[i + j] = m.add(u, v);
coeff[i + j + l] = m.subtract(u, v);
}
}
}
if (inverse) {
long nInv = m.inv(n + 1);
for (int i = 0; i < n + 1; i++) {
coeff[i] = m.mult(coeff[i], nInv);
}
}
}
public String toString() {
return Arrays.toString(coeff);
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public int[] readIntArray(int n) {
int[] x = new int[n];
for (int i = 0; i < n; i++) {
x[i] = nextInt();
}
return x;
}
}
static class Util {
public static void swap(long[] x, int i, int j) {
long t = x[i];
x[i] = x[j];
x[j] = t;
}
public static void ASSERT(boolean assertion) {
if (!assertion)
throw new AssertionError();
}
}
}
| 4JAVA
| {
"input": [
"3\n2999999 43 2999957\n",
"6\n2 3 2 3 2 2\n",
"16\n2 2 2 2 2 3 3 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 2 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 3 3 5 7 11 13 17\n",
"1\n2999999\n",
"16\n2 2 2 2 2 2 2 2 2 3 3 5 7 11 13 17\n",
"16\n2 2 2 3 3 3 5 5 5 7 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 3 5 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 3 3 3 3 5 5 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 3 3 3 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 3 3 3 5 5 5 7 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 3 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 2 2 2 2 2 3 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 2 3 3 3 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 5 5 5 7 11 13 17\n",
"16\n2 2 2 2 3 3 3 3 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 5 5 7 7 11 11 13 13 17\n",
"16\n2 2 2 2 3 3 3 5 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 3 3 5 5 5 7 11 13 17\n",
"16\n2 2 2 2 3 3 5 5 7 7 11 11 13 13 17 17\n",
"16\n2 2 2 2 3 3 3 5 5 7 7 11 11 13 13 17\n",
"23\n2 2 2 2 2 2 2 2 3 3 3 3 3 5 5 5 5 7 7 11 11 13 13\n",
"16\n2 2 2 3 3 3 5 5 5 7 7 11 11 13 13 17\n",
"16\n2 2 2 2 2 2 2 3 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 3 3 3 3 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 3 3 3 5 5 7 7 11 11 13 13 17 17\n",
"16\n2 2 2 2 3 3 3 3 5 5 5 7 7 11 13 17\n",
"1\n297754\n",
"16\n2 2 2 3 5 3 5 5 5 7 7 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 3 5 5 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 5 5 2 7 11 11 13 17\n",
"16\n2 2 2 2 2 3 5 3 5 5 7 7 11 11 13 17\n",
"16\n2 2 2 2 3 5 3 5 5 7 7 11 11 13 13 17\n",
"16\n2 2 2 2 2 2 2 3 3 3 3 5 7 2 13 17\n",
"16\n2 2 3 2 3 3 3 3 5 5 7 7 11 11 13 17\n",
"1\n482100\n",
"1\n148685\n",
"1\n179970\n",
"1\n355734\n",
"1\n202567\n",
"1\n25373\n",
"1\n35333\n",
"1\n58153\n",
"1\n69259\n",
"1\n109442\n",
"1\n179431\n",
"1\n205261\n",
"1\n45715\n",
"1\n79511\n",
"1\n14306\n",
"1\n11289\n",
"1\n3574\n",
"1\n3059\n",
"1\n1078\n",
"1\n284\n",
"1\n68\n",
"1\n52\n",
"1\n53\n",
"1\n97\n",
"1\n66\n",
"1\n85\n",
"1\n161\n",
"1\n248\n"
],
"output": [
"3\n",
"3\n",
"310\n",
"144\n",
"274\n",
"178\n",
"1\n",
"96\n",
"478\n",
"334\n",
"288\n",
"240\n",
"226\n",
"386\n",
"310\n",
"380\n",
"64\n",
"128\n",
"242\n",
"406\n",
"432\n",
"440\n",
"272\n",
"573\n",
"502\n",
"736\n",
"546\n",
"190\n",
"158\n",
"214\n",
"624\n",
"356\n",
"1\n",
"440\n",
"310\n",
"214\n",
"380\n",
"502\n",
"80\n",
"380\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n"
]
} | 2CODEFORCES
|
1281_B. Azamon Web Services_1206 | Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better names than his competitors, then he'll be at the top of the search results and will be a millionaire.
After doing some research, you find out that search engines only sort their results lexicographically. If your friend could rename his products to lexicographically smaller strings than his competitor's, then he'll be at the top of the rankings!
To make your strategy less obvious to his competitors, you decide to swap no more than two letters of the product names.
Please help Jeff to find improved names for his products that are lexicographically smaller than his competitor's!
Given the string s representing Jeff's product name and the string c representing his competitor's product name, find a way to swap at most one pair of characters in s (that is, find two distinct indices i and j and swap s_i and s_j) such that the resulting new name becomes strictly lexicographically smaller than c, or determine that it is impossible.
Note: String a is strictly lexicographically smaller than string b if and only if one of the following holds:
* a is a proper prefix of b, that is, a is a prefix of b such that a β b;
* There exists an integer 1 β€ i β€ min{(|a|, |b|)} such that a_i < b_i and a_j = b_j for 1 β€ j < i.
Input
The first line of input contains a single integer t (1 β€ t β€ 1500) denoting the number of test cases. The next lines contain descriptions of the test cases.
Each test case consists of a single line containing two space-separated strings s and c (2 β€ |s| β€ 5000, 1 β€ |c| β€ 5000). The strings s and c consists of uppercase English letters.
It is guaranteed that the sum of |s| in the input is at most 5000 and the sum of the |c| in the input is at most 5000.
Output
For each test case, output a single line containing a single string, which is either
* the new name which is obtained after swapping no more than one pair of characters that is strictly lexicographically smaller than c. In case there are many possible such strings, you can output any of them;
* three dashes (the string "---" without quotes) if it is impossible.
Example
Input
3
AZAMON APPLE
AZAMON AAAAAAAAAAALIBABA
APPLE BANANA
Output
AMAZON
---
APPLE
Note
In the first test case, it is possible to swap the second and the fourth letters of the string and the resulting string "AMAZON" is lexicographically smaller than "APPLE".
It is impossible to improve the product's name in the second test case and satisfy all conditions.
In the third test case, it is possible not to swap a pair of characters. The name "APPLE" is lexicographically smaller than "BANANA". Note that there are other valid answers, e.g., "APPEL". | def solve(s, t):
mns = list(s)
for i in range(len(s)-2,-1,-1): mns[i] = min(mns[i], mns[i + 1])
for i in range(len(s)):
if s[i] != mns[i]:
j = max(j for j, v in enumerate(s[i:], i) if v == mns[i])
s = s[:i] + s[j] + s[i+1:j] + s[i] + s[j+1:]
break
return s if s < t else '---'
total_string = int(input())
string = []
for i in range(total_string):
string.append(raw_input())
final_string = []
for i in range(total_string):
break_point = string[i].index(' ')
swaping = False
done = False
last = False
s = string[i][0:break_point]
c = string[i][break_point+1:] #equal wala check karna bake he
print(solve(s,c))
| 1Python2
| {
"input": [
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEPPLA BANANA\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEPPLA ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nEPPLA ANANAB\n",
"3\nAOAMNZ APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nZABMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPFL ANAMAB\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZANOM APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPOLE ANANAB\n",
"3\nZABMON ELPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAQPLF ANANAB\n",
"3\nZABMNN APPLE\nANMOZA AAALAAAAAAAAIBABA\nAOPFL ANAMAB\n",
"3\nZABMNN ELPPA\nAZOMNA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAOPLE BAN@NA\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nELPPA BAAANN\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAQPKF ANANAB\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nPLEPA BAAANN\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nAPPLE ANAOAB\n",
"3\nAZANOM APPLE\nAAZMON ABABILAAAAAAAAAAA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAABLIBABA\nALPPE BANANA\n",
"3\nZAAMON APPLE\nAZAMON ABABHLAAAA@AAAAAA\nAPPLF ANANAB\n",
"3\nZAAMON APPLE\nOZAMAN AAAAAAAAAAAKIBABA\nAPPMF ANANAB\n",
"3\nAZAMON ALPOE\nAZOMAN ABABILAAAAAAAAAAA\nALPOE ANANAB\n",
"3\nZABNOM FLPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMNN APPLE\nAOMNZA AAALAAAAAAAAIBABA\nAOPEL ANAMAB\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nZAAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nZABMNN APPLE\nAZOMNA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BAN@NA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BAAANN\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BAOANA\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAAALIBABA\nEPPLA BANANA\n",
"3\nAZAMNO APPLE\nNOMAZA AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAAAAAAALHBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEOPLA ANANAB\n",
"3\nZAAMON APPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nEOPLA ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAABLIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nAPPLE BANANA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLF\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE ANAOAB\n",
"3\nAZAMNO EPPLA\nAZAMON AAAAAAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZANOM APPLE\nAAZMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAABLIBABA\nEPPLA BANANA\n",
"3\nAZAMNO APPLE\nNZMAOA AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAA@AAAALHBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nZAOMAN AAAAAAAAAAALIBABA\nEOPLA ANANAB\n",
"3\nAZAMNO APOLE\nAZAMON AAAAAAAAAAALIBABA\nAPOLE ANANAB\n",
"3\nZAAMON APPLE\nOZAMAN AAAAAAAAAAAKIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPOE\nAZOMAN ABABILAAAAAAAAAAA\nEOPLA ANANAB\n",
"3\nZABMON FLPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLF\nANMOZA AAAAAAAAAABLIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN LPPAE\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nZABMNN APPLE\nAOMNZA AAALAAAAAAAAIBABA\nAOPFL ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nPAPLE BANANA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLE BAAANN\n",
"3\nAZAMON APPLF\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANBA\n",
"3\nAZAMNO EPPLA\nAZAMON AAA@AAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZAMNO APPLE\nNZMAOA AA@AAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON ALPPE\nZAOMAN AAAAAAAAAAALIBABA\nEOPMA ANANAB\n",
"3\nZABMON APPLE\nZAOMNA AAAAAAAAAAALIBABA\nAQPKF ANANAB\n",
"3\nZABMON APPLF\nANMOZA AAAAAAAAAABMIBABA\nAPPLF ANANAB\n",
"3\nZABMOM APPLE\nAZOMNA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN EAPPL\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nPAPLE ANANAB\n"
],
"output": [
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMON\n---\n---\n",
"AAZMON\nAAOMZN\n---\n",
"AAOMNZ\n---\nAEPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"AAZMNO\n---\nAEPMP\n",
"AAZNOM\n---\nAFPLP\n",
"AAZMNO\n---\nAEOLP\n",
"AZBMON\n---\nAFPLP\n",
"---\n---\nAFPLQ\n",
"---\n---\nAFPOL\n",
"AZBMNN\n---\nAFPPL\n",
"AAZMON\n---\nAEPLO\n",
"AAZMON\n---\nALPPE\n",
"---\n---\nAFPKQ\n",
"AAZMON\n---\nALEPP\n",
"AAZMON\nAAOMZN\nAEPLP\n",
"AAZNOM\nAAMZON\nAFPLP\n",
"AAZMON\n---\nAEPPL\n",
"AAZMON\nAAZMON\nAFPLP\n",
"AAZMON\n---\nAFPMP\n",
"AAZMON\nAAOMZN\nAEPOL\n",
"AZBNOM\n---\nAFPLP\n",
"---\n---\nAEPOL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"---\n---\nAFPPL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\nAAOMZN\n---\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPMP\n",
"AAZNOM\n---\nAFPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\n---\n",
"AAZMNO\n---\nAEOLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\nAAOMZN\n---\n",
"AZBMON\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"AZBMNN\n---\nAFPPL\n",
"---\n---\nAFPOL\n",
"AAZMON\n---\nAPPLE\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMNO\n---\nAEPMP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"---\n---\nAFPKQ\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"AZBMNN\n---\nAFPPL\n",
"AAZMON\n---\n---\n"
]
} | 2CODEFORCES
|
1281_B. Azamon Web Services_1207 | Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better names than his competitors, then he'll be at the top of the search results and will be a millionaire.
After doing some research, you find out that search engines only sort their results lexicographically. If your friend could rename his products to lexicographically smaller strings than his competitor's, then he'll be at the top of the rankings!
To make your strategy less obvious to his competitors, you decide to swap no more than two letters of the product names.
Please help Jeff to find improved names for his products that are lexicographically smaller than his competitor's!
Given the string s representing Jeff's product name and the string c representing his competitor's product name, find a way to swap at most one pair of characters in s (that is, find two distinct indices i and j and swap s_i and s_j) such that the resulting new name becomes strictly lexicographically smaller than c, or determine that it is impossible.
Note: String a is strictly lexicographically smaller than string b if and only if one of the following holds:
* a is a proper prefix of b, that is, a is a prefix of b such that a β b;
* There exists an integer 1 β€ i β€ min{(|a|, |b|)} such that a_i < b_i and a_j = b_j for 1 β€ j < i.
Input
The first line of input contains a single integer t (1 β€ t β€ 1500) denoting the number of test cases. The next lines contain descriptions of the test cases.
Each test case consists of a single line containing two space-separated strings s and c (2 β€ |s| β€ 5000, 1 β€ |c| β€ 5000). The strings s and c consists of uppercase English letters.
It is guaranteed that the sum of |s| in the input is at most 5000 and the sum of the |c| in the input is at most 5000.
Output
For each test case, output a single line containing a single string, which is either
* the new name which is obtained after swapping no more than one pair of characters that is strictly lexicographically smaller than c. In case there are many possible such strings, you can output any of them;
* three dashes (the string "---" without quotes) if it is impossible.
Example
Input
3
AZAMON APPLE
AZAMON AAAAAAAAAAALIBABA
APPLE BANANA
Output
AMAZON
---
APPLE
Note
In the first test case, it is possible to swap the second and the fourth letters of the string and the resulting string "AMAZON" is lexicographically smaller than "APPLE".
It is impossible to improve the product's name in the second test case and satisfy all conditions.
In the third test case, it is possible not to swap a pair of characters. The name "APPLE" is lexicographically smaller than "BANANA". Note that there are other valid answers, e.g., "APPEL". | #include <bits/stdc++.h>
using namespace std;
int caseno = 0;
void yesno(bool okk) { cout << (okk ? "YES" : "NO") << '\n'; }
const int primemod = 1000000007;
const long long maxsize = 1 * 1000000 + 9;
const double eps = 1e-10;
const int N = 210;
void solve() {
string t, s;
cin >> s >> t;
if (s < t) {
cout << s << '\n';
return;
}
string temp = s;
sort(temp.begin(), temp.end());
for (__typeof(((s.size()) < (t.size()) ? (s.size()) : (t.size()))) i =
(0) - ((0) > (((s.size()) < (t.size()) ? (s.size()) : (t.size()))));
i != (((s.size()) < (t.size()) ? (s.size()) : (t.size()))) -
((0) > (((s.size()) < (t.size()) ? (s.size()) : (t.size()))));
i +=
1 - 2 * ((0) > (((s.size()) < (t.size()) ? (s.size()) : (t.size()))))) {
if (temp[i] < s[i])
for (__typeof(s.size()) j = (i + 1) - ((i + 1) > (s.size()));
j != (s.size()) - ((i + 1) > (s.size()));
j += 1 - 2 * ((i + 1) > (s.size()))) {
swap(s[i], s[j]);
if (s < t) {
goto h;
}
swap(s[i], s[j]);
}
}
h:;
if (s < t)
cout << s << '\n';
else
cout << "---" << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
| 2C++
| {
"input": [
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEPPLA BANANA\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEPPLA ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nEPPLA ANANAB\n",
"3\nAOAMNZ APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nZABMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPFL ANAMAB\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZANOM APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPOLE ANANAB\n",
"3\nZABMON ELPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAQPLF ANANAB\n",
"3\nZABMNN APPLE\nANMOZA AAALAAAAAAAAIBABA\nAOPFL ANAMAB\n",
"3\nZABMNN ELPPA\nAZOMNA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAOPLE BAN@NA\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nELPPA BAAANN\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAQPKF ANANAB\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nPLEPA BAAANN\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nAPPLE ANAOAB\n",
"3\nAZANOM APPLE\nAAZMON ABABILAAAAAAAAAAA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAABLIBABA\nALPPE BANANA\n",
"3\nZAAMON APPLE\nAZAMON ABABHLAAAA@AAAAAA\nAPPLF ANANAB\n",
"3\nZAAMON APPLE\nOZAMAN AAAAAAAAAAAKIBABA\nAPPMF ANANAB\n",
"3\nAZAMON ALPOE\nAZOMAN ABABILAAAAAAAAAAA\nALPOE ANANAB\n",
"3\nZABNOM FLPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMNN APPLE\nAOMNZA AAALAAAAAAAAIBABA\nAOPEL ANAMAB\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nZAAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nZABMNN APPLE\nAZOMNA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BAN@NA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BAAANN\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BAOANA\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAAALIBABA\nEPPLA BANANA\n",
"3\nAZAMNO APPLE\nNOMAZA AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAAAAAAALHBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEOPLA ANANAB\n",
"3\nZAAMON APPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nEOPLA ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAABLIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nAPPLE BANANA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLF\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE ANAOAB\n",
"3\nAZAMNO EPPLA\nAZAMON AAAAAAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZANOM APPLE\nAAZMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAABLIBABA\nEPPLA BANANA\n",
"3\nAZAMNO APPLE\nNZMAOA AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAA@AAAALHBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nZAOMAN AAAAAAAAAAALIBABA\nEOPLA ANANAB\n",
"3\nAZAMNO APOLE\nAZAMON AAAAAAAAAAALIBABA\nAPOLE ANANAB\n",
"3\nZAAMON APPLE\nOZAMAN AAAAAAAAAAAKIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPOE\nAZOMAN ABABILAAAAAAAAAAA\nEOPLA ANANAB\n",
"3\nZABMON FLPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLF\nANMOZA AAAAAAAAAABLIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN LPPAE\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nZABMNN APPLE\nAOMNZA AAALAAAAAAAAIBABA\nAOPFL ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nPAPLE BANANA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLE BAAANN\n",
"3\nAZAMON APPLF\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANBA\n",
"3\nAZAMNO EPPLA\nAZAMON AAA@AAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZAMNO APPLE\nNZMAOA AA@AAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON ALPPE\nZAOMAN AAAAAAAAAAALIBABA\nEOPMA ANANAB\n",
"3\nZABMON APPLE\nZAOMNA AAAAAAAAAAALIBABA\nAQPKF ANANAB\n",
"3\nZABMON APPLF\nANMOZA AAAAAAAAAABMIBABA\nAPPLF ANANAB\n",
"3\nZABMOM APPLE\nAZOMNA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN EAPPL\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nPAPLE ANANAB\n"
],
"output": [
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMON\n---\n---\n",
"AAZMON\nAAOMZN\n---\n",
"AAOMNZ\n---\nAEPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"AAZMNO\n---\nAEPMP\n",
"AAZNOM\n---\nAFPLP\n",
"AAZMNO\n---\nAEOLP\n",
"AZBMON\n---\nAFPLP\n",
"---\n---\nAFPLQ\n",
"---\n---\nAFPOL\n",
"AZBMNN\n---\nAFPPL\n",
"AAZMON\n---\nAEPLO\n",
"AAZMON\n---\nALPPE\n",
"---\n---\nAFPKQ\n",
"AAZMON\n---\nALEPP\n",
"AAZMON\nAAOMZN\nAEPLP\n",
"AAZNOM\nAAMZON\nAFPLP\n",
"AAZMON\n---\nAEPPL\n",
"AAZMON\nAAZMON\nAFPLP\n",
"AAZMON\n---\nAFPMP\n",
"AAZMON\nAAOMZN\nAEPOL\n",
"AZBNOM\n---\nAFPLP\n",
"---\n---\nAEPOL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"---\n---\nAFPPL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\nAAOMZN\n---\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPMP\n",
"AAZNOM\n---\nAFPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\n---\n",
"AAZMNO\n---\nAEOLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\nAAOMZN\n---\n",
"AZBMON\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"AZBMNN\n---\nAFPPL\n",
"---\n---\nAFPOL\n",
"AAZMON\n---\nAPPLE\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMNO\n---\nAEPMP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"---\n---\nAFPKQ\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"AZBMNN\n---\nAFPPL\n",
"AAZMON\n---\n---\n"
]
} | 2CODEFORCES
|
1281_B. Azamon Web Services_1208 | Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better names than his competitors, then he'll be at the top of the search results and will be a millionaire.
After doing some research, you find out that search engines only sort their results lexicographically. If your friend could rename his products to lexicographically smaller strings than his competitor's, then he'll be at the top of the rankings!
To make your strategy less obvious to his competitors, you decide to swap no more than two letters of the product names.
Please help Jeff to find improved names for his products that are lexicographically smaller than his competitor's!
Given the string s representing Jeff's product name and the string c representing his competitor's product name, find a way to swap at most one pair of characters in s (that is, find two distinct indices i and j and swap s_i and s_j) such that the resulting new name becomes strictly lexicographically smaller than c, or determine that it is impossible.
Note: String a is strictly lexicographically smaller than string b if and only if one of the following holds:
* a is a proper prefix of b, that is, a is a prefix of b such that a β b;
* There exists an integer 1 β€ i β€ min{(|a|, |b|)} such that a_i < b_i and a_j = b_j for 1 β€ j < i.
Input
The first line of input contains a single integer t (1 β€ t β€ 1500) denoting the number of test cases. The next lines contain descriptions of the test cases.
Each test case consists of a single line containing two space-separated strings s and c (2 β€ |s| β€ 5000, 1 β€ |c| β€ 5000). The strings s and c consists of uppercase English letters.
It is guaranteed that the sum of |s| in the input is at most 5000 and the sum of the |c| in the input is at most 5000.
Output
For each test case, output a single line containing a single string, which is either
* the new name which is obtained after swapping no more than one pair of characters that is strictly lexicographically smaller than c. In case there are many possible such strings, you can output any of them;
* three dashes (the string "---" without quotes) if it is impossible.
Example
Input
3
AZAMON APPLE
AZAMON AAAAAAAAAAALIBABA
APPLE BANANA
Output
AMAZON
---
APPLE
Note
In the first test case, it is possible to swap the second and the fourth letters of the string and the resulting string "AMAZON" is lexicographically smaller than "APPLE".
It is impossible to improve the product's name in the second test case and satisfy all conditions.
In the third test case, it is possible not to swap a pair of characters. The name "APPLE" is lexicographically smaller than "BANANA". Note that there are other valid answers, e.g., "APPEL". | for _ in range(int(input())):
a,c=input().split()
a=list(a)
b=sorted(a)
if a!=b:
for i,x in enumerate(b):
if a[i]!=x:
tmp=a[i]
a[i]=x
break
for i in range(len(a)-1,-1,-1):
if a[i]==x:
a[i]=tmp
break
a=''.join(a)
if a<c:
print(a)
else:
print('---') | 3Python3
| {
"input": [
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEPPLA BANANA\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEPPLA ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nEPPLA ANANAB\n",
"3\nAOAMNZ APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nZABMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPFL ANAMAB\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZANOM APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPOLE ANANAB\n",
"3\nZABMON ELPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAQPLF ANANAB\n",
"3\nZABMNN APPLE\nANMOZA AAALAAAAAAAAIBABA\nAOPFL ANAMAB\n",
"3\nZABMNN ELPPA\nAZOMNA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAOPLE BAN@NA\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nELPPA BAAANN\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAQPKF ANANAB\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nPLEPA BAAANN\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nAPPLE ANAOAB\n",
"3\nAZANOM APPLE\nAAZMON ABABILAAAAAAAAAAA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAABLIBABA\nALPPE BANANA\n",
"3\nZAAMON APPLE\nAZAMON ABABHLAAAA@AAAAAA\nAPPLF ANANAB\n",
"3\nZAAMON APPLE\nOZAMAN AAAAAAAAAAAKIBABA\nAPPMF ANANAB\n",
"3\nAZAMON ALPOE\nAZOMAN ABABILAAAAAAAAAAA\nALPOE ANANAB\n",
"3\nZABNOM FLPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMNN APPLE\nAOMNZA AAALAAAAAAAAIBABA\nAOPEL ANAMAB\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nZAAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nZABMNN APPLE\nAZOMNA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BAN@NA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BAAANN\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BAOANA\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAAALIBABA\nEPPLA BANANA\n",
"3\nAZAMNO APPLE\nNOMAZA AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAAAAAAALHBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEOPLA ANANAB\n",
"3\nZAAMON APPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nEOPLA ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAABLIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nAPPLE BANANA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLF\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE ANAOAB\n",
"3\nAZAMNO EPPLA\nAZAMON AAAAAAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZANOM APPLE\nAAZMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAABLIBABA\nEPPLA BANANA\n",
"3\nAZAMNO APPLE\nNZMAOA AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAA@AAAALHBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nZAOMAN AAAAAAAAAAALIBABA\nEOPLA ANANAB\n",
"3\nAZAMNO APOLE\nAZAMON AAAAAAAAAAALIBABA\nAPOLE ANANAB\n",
"3\nZAAMON APPLE\nOZAMAN AAAAAAAAAAAKIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPOE\nAZOMAN ABABILAAAAAAAAAAA\nEOPLA ANANAB\n",
"3\nZABMON FLPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLF\nANMOZA AAAAAAAAAABLIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN LPPAE\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nZABMNN APPLE\nAOMNZA AAALAAAAAAAAIBABA\nAOPFL ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nPAPLE BANANA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLE BAAANN\n",
"3\nAZAMON APPLF\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANBA\n",
"3\nAZAMNO EPPLA\nAZAMON AAA@AAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZAMNO APPLE\nNZMAOA AA@AAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON ALPPE\nZAOMAN AAAAAAAAAAALIBABA\nEOPMA ANANAB\n",
"3\nZABMON APPLE\nZAOMNA AAAAAAAAAAALIBABA\nAQPKF ANANAB\n",
"3\nZABMON APPLF\nANMOZA AAAAAAAAAABMIBABA\nAPPLF ANANAB\n",
"3\nZABMOM APPLE\nAZOMNA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN EAPPL\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nPAPLE ANANAB\n"
],
"output": [
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMON\n---\n---\n",
"AAZMON\nAAOMZN\n---\n",
"AAOMNZ\n---\nAEPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"AAZMNO\n---\nAEPMP\n",
"AAZNOM\n---\nAFPLP\n",
"AAZMNO\n---\nAEOLP\n",
"AZBMON\n---\nAFPLP\n",
"---\n---\nAFPLQ\n",
"---\n---\nAFPOL\n",
"AZBMNN\n---\nAFPPL\n",
"AAZMON\n---\nAEPLO\n",
"AAZMON\n---\nALPPE\n",
"---\n---\nAFPKQ\n",
"AAZMON\n---\nALEPP\n",
"AAZMON\nAAOMZN\nAEPLP\n",
"AAZNOM\nAAMZON\nAFPLP\n",
"AAZMON\n---\nAEPPL\n",
"AAZMON\nAAZMON\nAFPLP\n",
"AAZMON\n---\nAFPMP\n",
"AAZMON\nAAOMZN\nAEPOL\n",
"AZBNOM\n---\nAFPLP\n",
"---\n---\nAEPOL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"---\n---\nAFPPL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\nAAOMZN\n---\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPMP\n",
"AAZNOM\n---\nAFPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\n---\n",
"AAZMNO\n---\nAEOLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\nAAOMZN\n---\n",
"AZBMON\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"AZBMNN\n---\nAFPPL\n",
"---\n---\nAFPOL\n",
"AAZMON\n---\nAPPLE\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMNO\n---\nAEPMP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"---\n---\nAFPKQ\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"AZBMNN\n---\nAFPPL\n",
"AAZMON\n---\n---\n"
]
} | 2CODEFORCES
|
1281_B. Azamon Web Services_1209 | Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better names than his competitors, then he'll be at the top of the search results and will be a millionaire.
After doing some research, you find out that search engines only sort their results lexicographically. If your friend could rename his products to lexicographically smaller strings than his competitor's, then he'll be at the top of the rankings!
To make your strategy less obvious to his competitors, you decide to swap no more than two letters of the product names.
Please help Jeff to find improved names for his products that are lexicographically smaller than his competitor's!
Given the string s representing Jeff's product name and the string c representing his competitor's product name, find a way to swap at most one pair of characters in s (that is, find two distinct indices i and j and swap s_i and s_j) such that the resulting new name becomes strictly lexicographically smaller than c, or determine that it is impossible.
Note: String a is strictly lexicographically smaller than string b if and only if one of the following holds:
* a is a proper prefix of b, that is, a is a prefix of b such that a β b;
* There exists an integer 1 β€ i β€ min{(|a|, |b|)} such that a_i < b_i and a_j = b_j for 1 β€ j < i.
Input
The first line of input contains a single integer t (1 β€ t β€ 1500) denoting the number of test cases. The next lines contain descriptions of the test cases.
Each test case consists of a single line containing two space-separated strings s and c (2 β€ |s| β€ 5000, 1 β€ |c| β€ 5000). The strings s and c consists of uppercase English letters.
It is guaranteed that the sum of |s| in the input is at most 5000 and the sum of the |c| in the input is at most 5000.
Output
For each test case, output a single line containing a single string, which is either
* the new name which is obtained after swapping no more than one pair of characters that is strictly lexicographically smaller than c. In case there are many possible such strings, you can output any of them;
* three dashes (the string "---" without quotes) if it is impossible.
Example
Input
3
AZAMON APPLE
AZAMON AAAAAAAAAAALIBABA
APPLE BANANA
Output
AMAZON
---
APPLE
Note
In the first test case, it is possible to swap the second and the fourth letters of the string and the resulting string "AMAZON" is lexicographically smaller than "APPLE".
It is impossible to improve the product's name in the second test case and satisfy all conditions.
In the third test case, it is possible not to swap a pair of characters. The name "APPLE" is lexicographically smaller than "BANANA". Note that there are other valid answers, e.g., "APPEL". | import java.io.*;
import java.util.*;
@SuppressWarnings("unused")
public class Main {
FastScanner in;
PrintWriter out;
int MOD = (int)1e9+7;
long ceil(long a, long b){return (a + b - 1) / b;}
long gcd(long a, long b){return b == 0 ? a : gcd(b, a % b);}
long lcm(long a, long b){return a / gcd(a, b) * b;}
void solve() {
int t = in.nextInt();
for(int i = 0; i < t; i++){
solveMain();
}
}
void solveMain(){
char[] s = in.nextStr().toCharArray();
String c = in.nextStr();
int[] idx = new int[s.length];
int now = s.length-1;
for(int i = s.length-1; i >= 0; i--){
if(s[now] > s[i]) now = i;
idx[i] = now;
}
for(int i = 0; i < s.length-1; i++){
if(s[i] > s[idx[i+1]]){
char tmp = s[i];
s[i] = s[idx[i+1]];
s[idx[i+1]] = tmp;
break;
}
}
String S = String.valueOf(s);
out.println(S.compareTo(c) < 0 ? S : "---");
}
public static void main(String[] args) {
new Main().m();
}
private void m() {
in = new FastScanner(System.in);
out = new PrintWriter(System.out);
/*
try {
String path = "output.txt";
out = new PrintWriter(new BufferedWriter(new FileWriter(new File(path))));
}catch (IOException e){
e.printStackTrace();
}
*/
solve();
out.flush();
in.close();
out.close();
}
static class FastScanner {
private Reader input;
public FastScanner() {this(System.in);}
public FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}
public void close() {
try {
this.input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public int nextInt() {return (int) nextLong();}
public long nextLong() {
try {
int sign = 1;
int b = input.read();
while ((b < '0' || '9' < b) && b != '-' && b != '+') {
b = input.read();
}
if (b == '-') {
sign = -1;
b = input.read();
} else if (b == '+') {
b = input.read();
}
long ret = b - '0';
while (true) {
b = input.read();
if (b < '0' || '9' < b) return ret * sign;
ret *= 10;
ret += b - '0';
}
} catch (IOException e) {
e.printStackTrace();
return -1;
}
}
public double nextDouble() {
try {
double sign = 1;
int b = input.read();
while ((b < '0' || '9' < b) && b != '-' && b != '+') {
b = input.read();
}
if (b == '-') {
sign = -1;
b = input.read();
} else if (b == '+') {
b = input.read();
}
double ret = b - '0';
while (true) {
b = input.read();
if (b < '0' || '9' < b) break;
ret *= 10;
ret += b - '0';
}
if (b != '.') return sign * ret;
double div = 1;
b = input.read();
while ('0' <= b && b <= '9') {
ret *= 10;
ret += b - '0';
div *= 10;
b = input.read();
}
return sign * ret / div;
} catch (IOException e) {
e.printStackTrace();
return Double.NaN;
}
}
public char nextChar() {
try {
int b = input.read();
while (Character.isWhitespace(b)) {
b = input.read();
}
return (char) b;
} catch (IOException e) {
e.printStackTrace();
return 0;
}
}
public String nextStr() {
try {
StringBuilder sb = new StringBuilder();
int b = input.read();
while (Character.isWhitespace(b)) {
b = input.read();
}
while (b != -1 && !Character.isWhitespace(b)) {
sb.append((char) b);
b = input.read();
}
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
public String nextLine() {
try {
StringBuilder sb = new StringBuilder();
int b = input.read();
while (b != -1 && b != '\n') {
sb.append((char) b);
b = input.read();
}
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
public int[] nextIntArray(int n) {
int[] res = new int[n];
for (int i = 0; i < n; i++) {
res[i] = nextInt();
}
return res;
}
public int[] nextIntArrayDec(int n) {
int[] res = new int[n];
for (int i = 0; i < n; i++) {
res[i] = nextInt() - 1;
}
return res;
}
public int[] nextIntArray1Index(int n) {
int[] res = new int[n + 1];
for (int i = 0; i < n; i++) {
res[i + 1] = nextInt();
}
return res;
}
public long[] nextLongArray(int n) {
long[] res = new long[n];
for (int i = 0; i < n; i++) {
res[i] = nextLong();
}
return res;
}
public long[] nextLongArrayDec(int n) {
long[] res = new long[n];
for (int i = 0; i < n; i++) {
res[i] = nextLong() - 1;
}
return res;
}
public long[] nextLongArray1Index(int n) {
long[] res = new long[n + 1];
for (int i = 0; i < n; i++) {
res[i + 1] = nextLong();
}
return res;
}
public double[] nextDoubleArray(int n) {
double[] res = new double[n];
for (int i = 0; i < n; i++) {
res[i] = nextDouble();
}
return res;
}
}
} | 4JAVA
| {
"input": [
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEPPLA BANANA\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEPPLA ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nEPPLA ANANAB\n",
"3\nAOAMNZ APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nZABMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPFL ANAMAB\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZANOM APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPOLE ANANAB\n",
"3\nZABMON ELPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAQPLF ANANAB\n",
"3\nZABMNN APPLE\nANMOZA AAALAAAAAAAAIBABA\nAOPFL ANAMAB\n",
"3\nZABMNN ELPPA\nAZOMNA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAOPLE BAN@NA\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nELPPA BAAANN\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAQPKF ANANAB\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nPLEPA BAAANN\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nAPPLE ANAOAB\n",
"3\nAZANOM APPLE\nAAZMON ABABILAAAAAAAAAAA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAABLIBABA\nALPPE BANANA\n",
"3\nZAAMON APPLE\nAZAMON ABABHLAAAA@AAAAAA\nAPPLF ANANAB\n",
"3\nZAAMON APPLE\nOZAMAN AAAAAAAAAAAKIBABA\nAPPMF ANANAB\n",
"3\nAZAMON ALPOE\nAZOMAN ABABILAAAAAAAAAAA\nALPOE ANANAB\n",
"3\nZABNOM FLPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMNN APPLE\nAOMNZA AAALAAAAAAAAIBABA\nAOPEL ANAMAB\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMNO APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE ANANAB\n",
"3\nZAAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nZABMNN APPLE\nAZOMNA AAALAAAAAAAAIBABA\nAPPFL ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BAN@NA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BAAANN\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BAOANA\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAAALIBABA\nEPPLA BANANA\n",
"3\nAZAMNO APPLE\nNOMAZA AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAAAAAAALHBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nEOPLA ANANAB\n",
"3\nZAAMON APPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nEOPLA ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAAABLIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nANMOZA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN APPLE\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nAPPLE BANANA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLF\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANAB\n",
"3\nAZAMON ALPPE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE ANAOAB\n",
"3\nAZAMNO EPPLA\nAZAMON AAAAAAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZANOM APPLE\nAAZMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nAZOMBN AAAAAAAAAABLIBABA\nEPPLA BANANA\n",
"3\nAZAMNO APPLE\nNZMAOA AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nZAAMON APPLE\nAZAMON AAAAAA@AAAALHBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPPE\nZAOMAN AAAAAAAAAAALIBABA\nEOPLA ANANAB\n",
"3\nAZAMNO APOLE\nAZAMON AAAAAAAAAAALIBABA\nAPOLE ANANAB\n",
"3\nZAAMON APPLE\nOZAMAN AAAAAAAAAAAKIBABA\nAPPLF ANANAB\n",
"3\nAZAMON ALPOE\nAZOMAN ABABILAAAAAAAAAAA\nEOPLA ANANAB\n",
"3\nZABMON FLPPA\nAZOMAN AAAAAAAAAAALIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLF\nANMOZA AAAAAAAAAABLIBABA\nAPPLF ANANAB\n",
"3\nZABMON APPLE\nAZOMNA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN LPPAE\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nZABMNN APPLE\nAOMNZA AAALAAAAAAAAIBABA\nAOPFL ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nPAPLE BANANA\n",
"3\nAZAMON PAPLE\nAZOMAN AAAAAAAAAAAKIBABA\nAPPLE BAAANN\n",
"3\nAZAMON APPLF\nAZAMON AAAAAAAAAAALIBABA\nBPPLE ANANBA\n",
"3\nAZAMNO EPPLA\nAZAMON AAA@AAAAAAALIBABA\nAPPME BANANA\n",
"3\nAZAMNO APPLE\nNZMAOA AA@AAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON ALPPE\nZAOMAN AAAAAAAAAAALIBABA\nEOPMA ANANAB\n",
"3\nZABMON APPLE\nZAOMNA AAAAAAAAAAALIBABA\nAQPKF ANANAB\n",
"3\nZABMON APPLF\nANMOZA AAAAAAAAAABMIBABA\nAPPLF ANANAB\n",
"3\nZABMOM APPLE\nAZOMNA AAAAAAAAA@ALIBABA\nAPPLF ANAMAB\n",
"3\nZABMNN EAPPL\nANMOZA AAAAAAAAAAALIBABA\nALPPF ANAMAB\n",
"3\nAZAMON LPPAE\nAZAMON AAAAAAAAA@ALIBABA\nPAPLE ANANAB\n"
],
"output": [
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMON\n---\n---\n",
"AAZMON\nAAOMZN\n---\n",
"AAOMNZ\n---\nAEPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"AAZMNO\n---\nAEPMP\n",
"AAZNOM\n---\nAFPLP\n",
"AAZMNO\n---\nAEOLP\n",
"AZBMON\n---\nAFPLP\n",
"---\n---\nAFPLQ\n",
"---\n---\nAFPOL\n",
"AZBMNN\n---\nAFPPL\n",
"AAZMON\n---\nAEPLO\n",
"AAZMON\n---\nALPPE\n",
"---\n---\nAFPKQ\n",
"AAZMON\n---\nALEPP\n",
"AAZMON\nAAOMZN\nAEPLP\n",
"AAZNOM\nAAMZON\nAFPLP\n",
"AAZMON\n---\nAEPPL\n",
"AAZMON\nAAZMON\nAFPLP\n",
"AAZMON\n---\nAFPMP\n",
"AAZMON\nAAOMZN\nAEPOL\n",
"AZBNOM\n---\nAFPLP\n",
"---\n---\nAEPOL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"---\n---\nAFPPL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\nAAOMZN\n---\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPPL\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMON\n---\nAEPLP\n",
"AAZMNO\n---\nAEPMP\n",
"AAZNOM\n---\nAFPLP\n",
"AAZMON\n---\nAPPLE\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\n---\n---\n",
"AAZMNO\n---\nAEOLP\n",
"AAZMON\n---\nAFPLP\n",
"AAZMON\nAAOMZN\n---\n",
"AZBMON\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"AZBMNN\n---\nAFPPL\n",
"---\n---\nAFPOL\n",
"AAZMON\n---\nAPPLE\n",
"AAZMON\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"AAZMNO\n---\nAEPMP\n",
"AAZMNO\n---\nAEPLP\n",
"AAZMON\n---\n---\n",
"---\n---\nAFPKQ\n",
"---\n---\nAFPLP\n",
"---\n---\nAFPLP\n",
"AZBMNN\n---\nAFPPL\n",
"AAZMON\n---\n---\n"
]
} | 2CODEFORCES
|
1301_B. Motarack's Birthday_1210 | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.
Dark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high absolute difference between them. He doesn't have much time so he wants to choose an integer k (0 β€ k β€ 10^{9}) and replaces all missing elements in the array a with k.
Let m be the maximum absolute difference between all adjacent elements (i.e. the maximum value of |a_i - a_{i+1}| for all 1 β€ i β€ n - 1) in the array a after Dark replaces all missing elements with k.
Dark should choose an integer k so that m is minimized. Can you help him?
Input
The input consists of multiple test cases. The first line contains a single integer t (1 β€ t β€ 10^4) β the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer n (2 β€ n β€ 10^{5}) β the size of the array a.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (-1 β€ a_i β€ 10 ^ {9}). If a_i = -1, then the i-th integer is missing. It is guaranteed that at least one integer is missing in every test case.
It is guaranteed, that the sum of n for all test cases does not exceed 4 β
10 ^ {5}.
Output
Print the answers for each test case in the following format:
You should print two integers, the minimum possible value of m and an integer k (0 β€ k β€ 10^{9}) that makes the maximum absolute difference between adjacent elements in the array a equal to m.
Make sure that after replacing all the missing elements with k, the maximum absolute difference between adjacent elements becomes m.
If there is more than one possible k, you can print any of them.
Example
Input
7
5
-1 10 -1 12 -1
5
-1 40 35 -1 35
6
-1 -1 9 -1 3 -1
2
-1 -1
2
0 -1
4
1 -1 3 -1
7
1 -1 7 5 2 -1 5
Output
1 11
5 35
3 6
0 42
0 0
1 2
3 4
Note
In the first test case after replacing all missing elements with 11 the array becomes [11, 10, 11, 12, 11]. The absolute difference between any adjacent elements is 1. It is impossible to choose a value of k, such that the absolute difference between any adjacent element will be β€ 0. So, the answer is 1.
In the third test case after replacing all missing elements with 6 the array becomes [6, 6, 9, 6, 3, 6].
* |a_1 - a_2| = |6 - 6| = 0;
* |a_2 - a_3| = |6 - 9| = 3;
* |a_3 - a_4| = |9 - 6| = 3;
* |a_4 - a_5| = |6 - 3| = 3;
* |a_5 - a_6| = |3 - 6| = 3.
So, the maximum difference between any adjacent elements is 3. | import math
import heapq
import sys
num = int(raw_input())
for i in range(num):
n = int(raw_input())
a = [int(x) for x in raw_input().split(" ")]
nums_to_look = set()
for j in range(len(a)):
if a[j] == -1:
if j==0:
if a[j+1]!=-1:
nums_to_look.add(a[j+1])
elif j==len(a)-1:
if a[j-1]!=-1:
nums_to_look.add(a[j-1])
else:
if a[j-1]!=-1:
nums_to_look.add(a[j-1])
if a[j+1]!=-1:
nums_to_look.add(a[j+1])
if len(nums_to_look)==0:
print("0 1")
continue
gint = (max(nums_to_look)+min(nums_to_look))/2
gintc = gint+1
agint = [x if x!=-1 else gint for x in a]
agintc = [x if x!=-1 else gintc for x in a]
gintmax = 0
gintcmax = 0
for j in range(1,len(a)):
gintmax = max(abs(agint[j]-agint[j-1]),gintmax)
gintcmax = max(abs(agintc[j]-agintc[j-1]), gintcmax)
if gintmax >= gintcmax:
print(str(gintcmax)+" "+str(gintc))
else:
print(str(gintmax)+" "+str(gint))
| 1Python2
| {
"input": [
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n0 -1 7 5 2 -1 5\n",
"7\n5\n-1 16 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 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n0 0\n0 0\n1 2\n4 3\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n0 0\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"3 21\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"1 11\n40 35\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 4\n",
"2 14\n20 30\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n4 4\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n1 2\n0 0\n0 0\n0 0\n3 4\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"1 15\n5 37\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n3 6\n0 0\n0 0\n1 2\n5 3\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n5 4\n",
"5 15\n13 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"12 11\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n8 4\n",
"5 15\n7 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"14 12\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"16 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"2 18\n7 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"14 12\n11 40\n4 5\n0 0\n0 0\n3 2\n4 4\n",
"14 12\n11 40\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"14 12\n35 46\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n7 3\n",
"12 11\n5 37\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"16 20\n20 30\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"1 11\n40 35\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"1 11\n5 37\n9 7\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n3 3\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n3 3\n7 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n9 2\n",
"2 14\n62 51\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"1 11\n40 35\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n6 3\n",
"2 14\n19 18\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n40 35\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n3 3\n4 3\n",
"5 15\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"16 14\n20 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"1 11\n40 35\n3 6\n0 0\n0 1\n2 2\n3 4\n",
"1 11\n5 37\n9 9\n0 0\n0 0\n1 2\n4 3\n",
"4 20\n25 45\n2 4\n0 0\n0 0\n1 2\n3 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 1\n",
"2 14\n50 45\n4 5\n0 0\n0 0\n1 2\n9 2\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n3 3\n3 3\n",
"2 14\n58 53\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"6 6\n40 35\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n3 3\n6 3\n",
"2 14\n40 35\n3 6\n0 0\n0 0\n2 1\n7 6\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n3 3\n5 3\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"3 12\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n6 3\n",
"11 13\n20 30\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"16 14\n18 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"1 11\n40 43\n3 6\n0 0\n0 1\n2 2\n3 4\n",
"4 20\n25 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"12 28\n20 30\n2 4\n0 0\n0 0\n1 2\n3 1\n",
"2 14\n58 53\n3 6\n0 0\n0 1\n1 2\n7 4\n",
"6 6\n40 28\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n3 3\n6 4\n",
"5 15\n5 37\n1 2\n0 0\n0 0\n3 3\n5 3\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n2 3\n",
"15 14\n18 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"9 15\n25 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 2\n",
"11 13\n26 27\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"2 14\n58 53\n3 6\n0 0\n0 1\n1 2\n8 4\n",
"9 15\n40 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"14 12\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"14 12\n11 40\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"12 11\n5 37\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"3 12\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n"
]
} | 2CODEFORCES
|
1301_B. Motarack's Birthday_1211 | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.
Dark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high absolute difference between them. He doesn't have much time so he wants to choose an integer k (0 β€ k β€ 10^{9}) and replaces all missing elements in the array a with k.
Let m be the maximum absolute difference between all adjacent elements (i.e. the maximum value of |a_i - a_{i+1}| for all 1 β€ i β€ n - 1) in the array a after Dark replaces all missing elements with k.
Dark should choose an integer k so that m is minimized. Can you help him?
Input
The input consists of multiple test cases. The first line contains a single integer t (1 β€ t β€ 10^4) β the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer n (2 β€ n β€ 10^{5}) β the size of the array a.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (-1 β€ a_i β€ 10 ^ {9}). If a_i = -1, then the i-th integer is missing. It is guaranteed that at least one integer is missing in every test case.
It is guaranteed, that the sum of n for all test cases does not exceed 4 β
10 ^ {5}.
Output
Print the answers for each test case in the following format:
You should print two integers, the minimum possible value of m and an integer k (0 β€ k β€ 10^{9}) that makes the maximum absolute difference between adjacent elements in the array a equal to m.
Make sure that after replacing all the missing elements with k, the maximum absolute difference between adjacent elements becomes m.
If there is more than one possible k, you can print any of them.
Example
Input
7
5
-1 10 -1 12 -1
5
-1 40 35 -1 35
6
-1 -1 9 -1 3 -1
2
-1 -1
2
0 -1
4
1 -1 3 -1
7
1 -1 7 5 2 -1 5
Output
1 11
5 35
3 6
0 42
0 0
1 2
3 4
Note
In the first test case after replacing all missing elements with 11 the array becomes [11, 10, 11, 12, 11]. The absolute difference between any adjacent elements is 1. It is impossible to choose a value of k, such that the absolute difference between any adjacent element will be β€ 0. So, the answer is 1.
In the third test case after replacing all missing elements with 6 the array becomes [6, 6, 9, 6, 3, 6].
* |a_1 - a_2| = |6 - 6| = 0;
* |a_2 - a_3| = |6 - 9| = 3;
* |a_3 - a_4| = |9 - 6| = 3;
* |a_4 - a_5| = |6 - 3| = 3;
* |a_5 - a_6| = |3 - 6| = 3.
So, the maximum difference between any adjacent elements is 3. | #include <bits/stdc++.h>
using namespace std;
int f(const vector<int>& a, int v, int cur_max) {
return max(cur_max, max(abs(a[0] - v), abs(a.back() - v)));
}
int main() {
srand(chrono::duration_cast<chrono::nanoseconds>(
chrono::high_resolution_clock::now().time_since_epoch())
.count());
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
for (int& e : a) {
cin >> e;
}
int cur_max = 0;
for (int i = 1; i < n; ++i) {
if (a[i - 1] == -1 || a[i] == -1) {
continue;
}
cur_max = max(cur_max, abs(a[i] - a[i - 1]));
}
vector<int> z;
for (int i = 0; i < n; ++i) {
if (a[i] != -1) {
continue;
}
if (i > 0 && a[i - 1] != -1) {
z.push_back(a[i - 1]);
}
if (i + 1 < n && a[i + 1] != -1) {
z.push_back(a[i + 1]);
}
}
if (z.empty()) {
cout << "0 0\n";
continue;
}
sort(z.begin(), z.end());
int q = (z[0] + (long long)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\n5 37\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n3 6\n0 0\n0 0\n1 2\n5 3\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n5 4\n",
"5 15\n13 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"12 11\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n8 4\n",
"5 15\n7 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"14 12\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"16 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"2 18\n7 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"14 12\n11 40\n4 5\n0 0\n0 0\n3 2\n4 4\n",
"14 12\n11 40\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"14 12\n35 46\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n7 3\n",
"12 11\n5 37\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"16 20\n20 30\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"1 11\n40 35\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"1 11\n5 37\n9 7\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n3 3\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n3 3\n7 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n9 2\n",
"2 14\n62 51\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"1 11\n40 35\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n6 3\n",
"2 14\n19 18\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n40 35\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n3 3\n4 3\n",
"5 15\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"16 14\n20 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"1 11\n40 35\n3 6\n0 0\n0 1\n2 2\n3 4\n",
"1 11\n5 37\n9 9\n0 0\n0 0\n1 2\n4 3\n",
"4 20\n25 45\n2 4\n0 0\n0 0\n1 2\n3 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 1\n",
"2 14\n50 45\n4 5\n0 0\n0 0\n1 2\n9 2\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n3 3\n3 3\n",
"2 14\n58 53\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"6 6\n40 35\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n3 3\n6 3\n",
"2 14\n40 35\n3 6\n0 0\n0 0\n2 1\n7 6\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n3 3\n5 3\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"3 12\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n6 3\n",
"11 13\n20 30\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"16 14\n18 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"1 11\n40 43\n3 6\n0 0\n0 1\n2 2\n3 4\n",
"4 20\n25 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"12 28\n20 30\n2 4\n0 0\n0 0\n1 2\n3 1\n",
"2 14\n58 53\n3 6\n0 0\n0 1\n1 2\n7 4\n",
"6 6\n40 28\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n3 3\n6 4\n",
"5 15\n5 37\n1 2\n0 0\n0 0\n3 3\n5 3\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n2 3\n",
"15 14\n18 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"9 15\n25 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 2\n",
"11 13\n26 27\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"2 14\n58 53\n3 6\n0 0\n0 1\n1 2\n8 4\n",
"9 15\n40 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"14 12\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"14 12\n11 40\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"12 11\n5 37\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"3 12\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n"
]
} | 2CODEFORCES
|
1301_B. Motarack's Birthday_1212 | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.
Dark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high absolute difference between them. He doesn't have much time so he wants to choose an integer k (0 β€ k β€ 10^{9}) and replaces all missing elements in the array a with k.
Let m be the maximum absolute difference between all adjacent elements (i.e. the maximum value of |a_i - a_{i+1}| for all 1 β€ i β€ n - 1) in the array a after Dark replaces all missing elements with k.
Dark should choose an integer k so that m is minimized. Can you help him?
Input
The input consists of multiple test cases. The first line contains a single integer t (1 β€ t β€ 10^4) β the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer n (2 β€ n β€ 10^{5}) β the size of the array a.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (-1 β€ a_i β€ 10 ^ {9}). If a_i = -1, then the i-th integer is missing. It is guaranteed that at least one integer is missing in every test case.
It is guaranteed, that the sum of n for all test cases does not exceed 4 β
10 ^ {5}.
Output
Print the answers for each test case in the following format:
You should print two integers, the minimum possible value of m and an integer k (0 β€ k β€ 10^{9}) that makes the maximum absolute difference between adjacent elements in the array a equal to m.
Make sure that after replacing all the missing elements with k, the maximum absolute difference between adjacent elements becomes m.
If there is more than one possible k, you can print any of them.
Example
Input
7
5
-1 10 -1 12 -1
5
-1 40 35 -1 35
6
-1 -1 9 -1 3 -1
2
-1 -1
2
0 -1
4
1 -1 3 -1
7
1 -1 7 5 2 -1 5
Output
1 11
5 35
3 6
0 42
0 0
1 2
3 4
Note
In the first test case after replacing all missing elements with 11 the array becomes [11, 10, 11, 12, 11]. The absolute difference between any adjacent elements is 1. It is impossible to choose a value of k, such that the absolute difference between any adjacent element will be β€ 0. So, the answer is 1.
In the third test case after replacing all missing elements with 6 the array becomes [6, 6, 9, 6, 3, 6].
* |a_1 - a_2| = |6 - 6| = 0;
* |a_2 - a_3| = |6 - 9| = 3;
* |a_3 - a_4| = |9 - 6| = 3;
* |a_4 - a_5| = |6 - 3| = 3;
* |a_5 - a_6| = |3 - 6| = 3.
So, the maximum difference between any adjacent elements is 3. | # import sys
# file = open('test1')
# sys.stdin = file
def ii(): return int(input())
def ai(): return list(map(int, input().split()))
def mi(): return map(int, input().split())
for _ in range(int(input())):
n = ii()
lst = ai()
nlst = []
for ind, ele in enumerate(lst):
if ele==-1:
if ind!=0 and lst[ind-1]!=-1: nlst.append(lst[ind-1])
if ind!=n-1 and lst[ind+1]!=-1: nlst.append(lst[ind+1])
if len(nlst)!=0:
mx,mn = max(nlst), min(nlst)
k = (mx+mn)//2
nlst = [k if i==-1 else i for i in lst]
m = 0
for i in range(1,n):
m = max(m, abs(nlst[i]-nlst[i-1]))
print(m, k)
else: print(0, 1)
| 3Python3
| {
"input": [
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n0 -1 7 5 2 -1 5\n",
"7\n5\n-1 16 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 16 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n0 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 0 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 16 -1 12 -1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\n",
"1 11\n40 35\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 4\n",
"2 14\n20 30\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n4 4\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n1 2\n0 0\n0 0\n0 0\n3 4\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"1 15\n5 37\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n3 6\n0 0\n0 0\n1 2\n5 3\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n5 4\n",
"5 15\n13 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"12 11\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n8 4\n",
"5 15\n7 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"14 12\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"16 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"2 18\n7 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"14 12\n11 40\n4 5\n0 0\n0 0\n3 2\n4 4\n",
"14 12\n11 40\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"14 12\n35 46\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n7 3\n",
"12 11\n5 37\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"16 20\n20 30\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"1 11\n40 35\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"1 11\n5 37\n9 7\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n3 3\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n3 3\n7 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n9 2\n",
"2 14\n62 51\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"1 11\n40 35\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n6 3\n",
"2 14\n19 18\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n40 35\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n3 3\n4 3\n",
"5 15\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"16 14\n20 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"1 11\n40 35\n3 6\n0 0\n0 1\n2 2\n3 4\n",
"1 11\n5 37\n9 9\n0 0\n0 0\n1 2\n4 3\n",
"4 20\n25 45\n2 4\n0 0\n0 0\n1 2\n3 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 1\n",
"2 14\n50 45\n4 5\n0 0\n0 0\n1 2\n9 2\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n3 3\n3 3\n",
"2 14\n58 53\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"6 6\n40 35\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n3 3\n6 3\n",
"2 14\n40 35\n3 6\n0 0\n0 0\n2 1\n7 6\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n3 3\n5 3\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"3 12\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n6 3\n",
"11 13\n20 30\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"16 14\n18 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"1 11\n40 43\n3 6\n0 0\n0 1\n2 2\n3 4\n",
"4 20\n25 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"12 28\n20 30\n2 4\n0 0\n0 0\n1 2\n3 1\n",
"2 14\n58 53\n3 6\n0 0\n0 1\n1 2\n7 4\n",
"6 6\n40 28\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n3 3\n6 4\n",
"5 15\n5 37\n1 2\n0 0\n0 0\n3 3\n5 3\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n2 3\n",
"15 14\n18 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"9 15\n25 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 2\n",
"11 13\n26 27\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"2 14\n58 53\n3 6\n0 0\n0 1\n1 2\n8 4\n",
"9 15\n40 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"14 12\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"14 12\n11 40\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"12 11\n5 37\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"3 12\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n"
]
} | 2CODEFORCES
|
1301_B. Motarack's Birthday_1213 | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.
Dark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high absolute difference between them. He doesn't have much time so he wants to choose an integer k (0 β€ k β€ 10^{9}) and replaces all missing elements in the array a with k.
Let m be the maximum absolute difference between all adjacent elements (i.e. the maximum value of |a_i - a_{i+1}| for all 1 β€ i β€ n - 1) in the array a after Dark replaces all missing elements with k.
Dark should choose an integer k so that m is minimized. Can you help him?
Input
The input consists of multiple test cases. The first line contains a single integer t (1 β€ t β€ 10^4) β the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer n (2 β€ n β€ 10^{5}) β the size of the array a.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (-1 β€ a_i β€ 10 ^ {9}). If a_i = -1, then the i-th integer is missing. It is guaranteed that at least one integer is missing in every test case.
It is guaranteed, that the sum of n for all test cases does not exceed 4 β
10 ^ {5}.
Output
Print the answers for each test case in the following format:
You should print two integers, the minimum possible value of m and an integer k (0 β€ k β€ 10^{9}) that makes the maximum absolute difference between adjacent elements in the array a equal to m.
Make sure that after replacing all the missing elements with k, the maximum absolute difference between adjacent elements becomes m.
If there is more than one possible k, you can print any of them.
Example
Input
7
5
-1 10 -1 12 -1
5
-1 40 35 -1 35
6
-1 -1 9 -1 3 -1
2
-1 -1
2
0 -1
4
1 -1 3 -1
7
1 -1 7 5 2 -1 5
Output
1 11
5 35
3 6
0 42
0 0
1 2
3 4
Note
In the first test case after replacing all missing elements with 11 the array becomes [11, 10, 11, 12, 11]. The absolute difference between any adjacent elements is 1. It is impossible to choose a value of k, such that the absolute difference between any adjacent element will be β€ 0. So, the answer is 1.
In the third test case after replacing all missing elements with 6 the array becomes [6, 6, 9, 6, 3, 6].
* |a_1 - a_2| = |6 - 6| = 0;
* |a_2 - a_3| = |6 - 9| = 3;
* |a_3 - a_4| = |9 - 6| = 3;
* |a_4 - a_5| = |6 - 3| = 3;
* |a_5 - a_6| = |3 - 6| = 3.
So, the maximum difference between any adjacent elements is 3. | import java.io.*;
import java.util.*;
public class sm {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
long arr[]=new long[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextLong();
}
int mn=Integer.MAX_VALUE;
int mx=Integer.MIN_VALUE;
for(int i=0;i<n;i++){
if(arr[i]==-1)
continue;
if(i - 1 >= 0 && arr[i-1] == -1 || i + 1 < n && arr[i+1] == -1) {
mx = (int)Math.max(mx, arr[i]);
mn = (int)Math.min(mn, arr[i]);
}
}
long ans=(mx+mn)/2;
for(int i=0;i<n;i++){
if(arr[i]==-1){
arr[i]=ans;
}
}
long abs=0;
for(int i=0;i<n-1;i++){
if((long)Math.abs(arr[i+1]-arr[i])>abs){
abs=(long)Math.abs(arr[i+1]-arr[i]);
}
}
System.out.println(abs+" "+ans);
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong()
{
return Long.parseLong(next());
}
}
} | 4JAVA
| {
"input": [
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1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3\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n5 4\n",
"5 15\n13 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"12 11\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n8 4\n",
"5 15\n7 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"14 12\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"16 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"2 18\n7 28\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"14 12\n11 40\n4 5\n0 0\n0 0\n3 2\n4 4\n",
"14 12\n11 40\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"14 12\n35 46\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n7 3\n",
"12 11\n5 37\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"16 20\n20 30\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"1 11\n40 35\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"1 11\n5 37\n9 7\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n3 3\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n3 3\n7 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n9 2\n",
"2 14\n62 51\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"1 11\n40 35\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n6 3\n",
"2 14\n19 18\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n40 35\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n3 3\n4 3\n",
"5 15\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n",
"4 20\n20 30\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"16 14\n20 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"1 11\n40 35\n3 6\n0 0\n0 1\n2 2\n3 4\n",
"1 11\n5 37\n9 9\n0 0\n0 0\n1 2\n4 3\n",
"4 20\n25 45\n2 4\n0 0\n0 0\n1 2\n3 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 1\n",
"2 14\n50 45\n4 5\n0 0\n0 0\n1 2\n9 2\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n3 3\n3 3\n",
"2 14\n58 53\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"6 6\n40 35\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n3 3\n6 3\n",
"2 14\n40 35\n3 6\n0 0\n0 0\n2 1\n7 6\n",
"5 15\n5 37\n3 6\n0 0\n0 0\n3 3\n5 3\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"3 12\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n6 3\n",
"11 13\n20 30\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"16 14\n18 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"1 11\n40 43\n3 6\n0 0\n0 1\n2 2\n3 4\n",
"4 20\n25 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"12 28\n20 30\n2 4\n0 0\n0 0\n1 2\n3 1\n",
"2 14\n58 53\n3 6\n0 0\n0 1\n1 2\n7 4\n",
"6 6\n40 28\n3 6\n0 0\n0 0\n1 2\n5 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n3 3\n6 4\n",
"5 15\n5 37\n1 2\n0 0\n0 0\n3 3\n5 3\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n2 3\n",
"15 14\n18 22\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"9 15\n25 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"13 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 2\n",
"11 13\n26 27\n3 3\n0 0\n0 0\n1 2\n10 4\n",
"2 14\n58 53\n3 6\n0 0\n0 1\n1 2\n8 4\n",
"9 15\n40 45\n6 3\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"1 11\n5 37\n3 6\n0 0\n0 0\n1 2\n4 3\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n1 2\n3 4\n",
"2 14\n5 37\n3 6\n0 0\n0 0\n2 1\n3 4\n",
"2 14\n50 45\n3 6\n0 0\n0 0\n1 2\n7 4\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"4 20\n20 30\n2 4\n0 0\n0 0\n1 2\n3 3\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n3 4\n",
"12 11\n5 37\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"2 14\n20 30\n1 2\n0 0\n0 0\n1 2\n5 3\n",
"14 12\n11 40\n3 6\n0 0\n0 0\n3 2\n4 4\n",
"14 12\n11 40\n4 5\n0 0\n0 1\n3 2\n4 4\n",
"12 11\n5 37\n3 6\n0 0\n0 1\n1 2\n3 4\n",
"3 12\n13 28\n3 6\n0 0\n0 0\n1 2\n7 6\n"
]
} | 2CODEFORCES
|
1325_B. CopyCopyCopyCopyCopy_1214 | Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (possibly, zero or all) elements. The longest increasing subsequence of an array is the longest subsequence such that its elements are ordered in strictly increasing order.
Input
The first line contains an integer t β the number of test cases you need to solve. The description of the test cases follows.
The first line of each test case contains an integer n (1 β€ n β€ 10^5) β the number of elements in the array a.
The second line contains n space-separated integers a_1, a_2, β¦, a_{n} (1 β€ a_i β€ 10^9) β the elements of the array a.
The sum of n across the test cases doesn't exceed 10^5.
Output
For each testcase, output the length of the longest increasing subsequence of a if you concatenate it to itself n times.
Example
Input
2
3
3 2 1
6
3 1 4 1 5 9
Output
3
5
Note
In the first sample, the new array is [3,2,1,3,2,1,3,2,1]. The longest increasing subsequence is marked in bold.
In the second sample, the longest increasing subsequence will be [1,3,4,5,9]. | from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = xrange
t= int(read())
while t > 0:
n = int(read())
a = set(map(int,read().split()))
print len(a)
t -= 1 | 1Python2
| {
"input": [
"2\n3\n3 2 1\n6\n3 1 4 1 5 9\n",
"1\n5\n1 3 4 5 2\n",
"1\n3\n1 1 274005660\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n",
"2\n3\n1 1 1\n2\n1 1\n",
"2\n2\n1 1\n1\n1\n",
"2\n5\n5 5 5 5 5\n3\n1 2 5\n",
"2\n5\n1 2 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 3 3\n3\n1 2 3\n",
"1\n5\n2 3 4 5 2\n",
"1\n3\n1 1 129021590\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 20 2\n",
"2\n3\n2 1 1\n2\n1 1\n",
"2\n5\n5 5 5 5 4\n3\n1 2 5\n",
"2\n4\n1 3 6 3\n3\n1 2 3\n",
"2\n3\n3 2 1\n6\n3 2 4 1 5 9\n",
"2\n3\n3 2 1\n6\n5 2 4 1 5 9\n",
"2\n5\n1 2 3 8 5\n4\n2 3 4 5\n",
"2\n3\n3 2 1\n6\n5 1 4 1 5 9\n",
"1\n3\n1 2 129021590\n",
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3\n",
"4\n3\n",
"2\n2\n",
"3\n5\n",
"2\n5\n",
"3\n4\n",
"2\n2\n",
"2\n5\n",
"3\n5\n",
"2\n6\n",
"3\n3\n",
"3\n5\n",
"4\n3\n",
"4\n3\n",
"4\n",
"3\n3\n",
"2\n2\n",
"3\n5\n",
"2\n3\n",
"2\n6\n",
"2\n5\n",
"3\n5\n",
"5\n3\n",
"5\n3\n",
"4\n",
"3\n3\n",
"3\n2\n",
"3\n4\n"
]
} | 2CODEFORCES
|
1325_B. CopyCopyCopyCopyCopy_1215 | Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (possibly, zero or all) elements. The longest increasing subsequence of an array is the longest subsequence such that its elements are ordered in strictly increasing order.
Input
The first line contains an integer t β the number of test cases you need to solve. The description of the test cases follows.
The first line of each test case contains an integer n (1 β€ n β€ 10^5) β the number of elements in the array a.
The second line contains n space-separated integers a_1, a_2, β¦, a_{n} (1 β€ a_i β€ 10^9) β the elements of the array a.
The sum of n across the test cases doesn't exceed 10^5.
Output
For each testcase, output the length of the longest increasing subsequence of a if you concatenate it to itself n times.
Example
Input
2
3
3 2 1
6
3 1 4 1 5 9
Output
3
5
Note
In the first sample, the new array is [3,2,1,3,2,1,3,2,1]. The longest increasing subsequence is marked in bold.
In the second sample, the longest increasing subsequence will be [1,3,4,5,9]. | #include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(const T &a) {
return a < 0 ? -a : a;
}
template <typename T>
inline T min(const T &b, const T &a) {
return a < b ? a : b;
}
template <typename T>
inline T max(const T &a, const T &b) {
return a < b ? b : a;
}
int read() {
int x = 0;
bool f = 0;
char ch = getchar();
while (ch < '0' || ch > '9') {
f = (ch == '-');
ch = getchar();
}
while (ch <= '9' && ch >= '0') {
x = (x << 1) + (x << 3) + (ch - '0');
ch = getchar();
}
return f ? -x : x;
}
void write(int x) {
if (x < 0) {
x = abs(x);
putchar('-');
}
if (x < 10) {
putchar(x + 48);
return;
}
write(x / 10);
putchar(x % 10 + 48);
}
const int Maxn = 1e5 + 11;
int t, n, a[Maxn];
int main() {
ios::sync_with_stdio(false);
cin >> t;
while (t--) {
int cnt = 1;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 1; i < n; ++i)
if (a[i] != a[i - 1]) cnt++;
cout << cnt << endl;
}
}
| 2C++
| {
"input": [
"2\n3\n3 2 1\n6\n3 1 4 1 5 9\n",
"1\n5\n1 3 4 5 2\n",
"1\n3\n1 1 274005660\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n",
"2\n3\n1 1 1\n2\n1 1\n",
"2\n2\n1 1\n1\n1\n",
"2\n5\n5 5 5 5 5\n3\n1 2 5\n",
"2\n5\n1 2 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 3 3\n3\n1 2 3\n",
"1\n5\n2 3 4 5 2\n",
"1\n3\n1 1 129021590\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 20 2\n",
"2\n3\n2 1 1\n2\n1 1\n",
"2\n5\n5 5 5 5 4\n3\n1 2 5\n",
"2\n4\n1 3 6 3\n3\n1 2 3\n",
"2\n3\n3 2 1\n6\n3 2 4 1 5 9\n",
"2\n3\n3 2 1\n6\n5 2 4 1 5 9\n",
"2\n5\n1 2 3 8 5\n4\n2 3 4 5\n",
"2\n3\n3 2 1\n6\n5 1 4 1 5 9\n",
"1\n3\n1 2 129021590\n",
"2\n4\n1 3 6 3\n3\n2 2 3\n",
"2\n3\n1 2 1\n6\n5 2 4 1 5 9\n",
"2\n5\n2 5 5 5 5\n3\n2 2 5\n",
"2\n5\n3 7 5 5 4\n3\n1 2 5\n",
"2\n5\n3 7 2 5 4\n3\n1 2 5\n",
"1\n5\n1 3 4 8 2\n",
"2\n3\n1 1 1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 1\n6\n4 2 4 1 10 11\n",
"2\n5\n13 7 6 5 4\n3\n1 2 6\n",
"2\n5\n3 6 1 7 4\n3\n1 2 5\n",
"1\n5\n1 3 2 9 2\n",
"2\n5\n5 5 6 1 5\n3\n1 2 4\n",
"2\n4\n1 5 1 3\n3\n2 2 6\n",
"2\n3\n3 2 1\n6\n3 1 3 2 2 14\n"
],
"output": [
"3\n5\n",
"5\n",
"2\n",
"2\n1\n5\n5\n",
"1\n1\n",
"1\n1\n",
"1\n3\n",
"5\n4\n",
"2\n3\n",
"4\n",
"2\n",
"2\n1\n5\n5\n",
"2\n1\n",
"2\n3\n",
"3\n3\n",
"3\n6\n",
"3\n5\n",
"5\n4\n",
"3\n4\n",
"3\n",
"3\n2\n",
"2\n5\n",
"2\n2\n",
"4\n3\n",
"5\n3\n",
"5\n",
"1\n2\n",
"4\n4\n",
"3\n1\n",
"2\n6\n",
"3\n1\n5\n5\n",
"4\n1\n5\n5\n",
"3\n5\n",
"3\n5\n",
"4\n",
"2\n3\n",
"2\n3\n",
"4\n",
"2\n3\n",
"3\n6\n",
"3\n6\n",
"3\n3\n",
"3\n3\n",
"3\n2\n",
"3\n6\n",
"2\n3\n",
"3\n3\n",
"3\n5\n",
"3\n3\n",
"3\n4\n",
"2\n",
"2\n3\n",
"2\n2\n",
"3\n4\n",
"3\n",
"3\n",
"2\n1\n5\n5\n",
"3\n5\n",
"3\n5\n",
"2\n3\n",
"5\n4\n",
"3\n5\n",
"3\n6\n",
"3\n2\n",
"3\n3\n",
"3\n5\n",
"2\n3\n",
"2\n5\n",
"3\n3\n",
"5\n3\n",
"5\n",
"3\n",
"2\n3\n",
"4\n3\n",
"2\n2\n",
"3\n5\n",
"2\n5\n",
"3\n4\n",
"2\n2\n",
"2\n5\n",
"3\n5\n",
"2\n6\n",
"3\n3\n",
"3\n5\n",
"4\n3\n",
"4\n3\n",
"4\n",
"3\n3\n",
"2\n2\n",
"3\n5\n",
"2\n3\n",
"2\n6\n",
"2\n5\n",
"3\n5\n",
"5\n3\n",
"5\n3\n",
"4\n",
"3\n3\n",
"3\n2\n",
"3\n4\n"
]
} | 2CODEFORCES
|
1325_B. CopyCopyCopyCopyCopy_1216 | Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (possibly, zero or all) elements. The longest increasing subsequence of an array is the longest subsequence such that its elements are ordered in strictly increasing order.
Input
The first line contains an integer t β the number of test cases you need to solve. The description of the test cases follows.
The first line of each test case contains an integer n (1 β€ n β€ 10^5) β the number of elements in the array a.
The second line contains n space-separated integers a_1, a_2, β¦, a_{n} (1 β€ a_i β€ 10^9) β the elements of the array a.
The sum of n across the test cases doesn't exceed 10^5.
Output
For each testcase, output the length of the longest increasing subsequence of a if you concatenate it to itself n times.
Example
Input
2
3
3 2 1
6
3 1 4 1 5 9
Output
3
5
Note
In the first sample, the new array is [3,2,1,3,2,1,3,2,1]. The longest increasing subsequence is marked in bold.
In the second sample, the longest increasing subsequence will be [1,3,4,5,9]. | t = int(input())
for i in range(t):
n = int(input())
a = input().split()
s_a = set(a)
print(f"{len(s_a)}\n")
| 3Python3
| {
"input": [
"2\n3\n3 2 1\n6\n3 1 4 1 5 9\n",
"1\n5\n1 3 4 5 2\n",
"1\n3\n1 1 274005660\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n",
"2\n3\n1 1 1\n2\n1 1\n",
"2\n2\n1 1\n1\n1\n",
"2\n5\n5 5 5 5 5\n3\n1 2 5\n",
"2\n5\n1 2 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 3 3\n3\n1 2 3\n",
"1\n5\n2 3 4 5 2\n",
"1\n3\n1 1 129021590\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 20 2\n",
"2\n3\n2 1 1\n2\n1 1\n",
"2\n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\n4\n",
"2\n",
"2\n3\n",
"2\n2\n",
"3\n4\n",
"3\n",
"3\n",
"2\n1\n5\n5\n",
"3\n5\n",
"3\n5\n",
"2\n3\n",
"5\n4\n",
"3\n5\n",
"3\n6\n",
"3\n2\n",
"3\n3\n",
"3\n5\n",
"2\n3\n",
"2\n5\n",
"3\n3\n",
"5\n3\n",
"5\n",
"3\n",
"2\n3\n",
"4\n3\n",
"2\n2\n",
"3\n5\n",
"2\n5\n",
"3\n4\n",
"2\n2\n",
"2\n5\n",
"3\n5\n",
"2\n6\n",
"3\n3\n",
"3\n5\n",
"4\n3\n",
"4\n3\n",
"4\n",
"3\n3\n",
"2\n2\n",
"3\n5\n",
"2\n3\n",
"2\n6\n",
"2\n5\n",
"3\n5\n",
"5\n3\n",
"5\n3\n",
"4\n",
"3\n3\n",
"3\n2\n",
"3\n4\n"
]
} | 2CODEFORCES
|
1325_B. CopyCopyCopyCopyCopy_1217 | Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (possibly, zero or all) elements. The longest increasing subsequence of an array is the longest subsequence such that its elements are ordered in strictly increasing order.
Input
The first line contains an integer t β the number of test cases you need to solve. The description of the test cases follows.
The first line of each test case contains an integer n (1 β€ n β€ 10^5) β the number of elements in the array a.
The second line contains n space-separated integers a_1, a_2, β¦, a_{n} (1 β€ a_i β€ 10^9) β the elements of the array a.
The sum of n across the test cases doesn't exceed 10^5.
Output
For each testcase, output the length of the longest increasing subsequence of a if you concatenate it to itself n times.
Example
Input
2
3
3 2 1
6
3 1 4 1 5 9
Output
3
5
Note
In the first sample, the new array is [3,2,1,3,2,1,3,2,1]. The longest increasing subsequence is marked in bold.
In the second sample, the longest increasing subsequence will be [1,3,4,5,9]. | import java.util.HashSet;
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for(int i=0; i<t; i++) {
HashSet<Integer> numbers = new HashSet<>();
int n = input.nextInt();
for(int j=0; j<n; j++)
numbers.add(input.nextInt());
System.out.println(numbers.size());
}
}
}
| 4JAVA
| {
"input": [
"2\n3\n3 2 1\n6\n3 1 4 1 5 9\n",
"1\n5\n1 3 4 5 2\n",
"1\n3\n1 1 274005660\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n",
"2\n3\n1 1 1\n2\n1 1\n",
"2\n2\n1 1\n1\n1\n",
"2\n5\n5 5 5 5 5\n3\n1 2 5\n",
"2\n5\n1 2 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 3 3\n3\n1 2 3\n",
"1\n5\n2 3 4 5 2\n",
"1\n3\n1 1 129021590\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 20 2\n",
"2\n3\n2 1 1\n2\n1 1\n",
"2\n5\n5 5 5 5 4\n3\n1 2 5\n",
"2\n4\n1 3 6 3\n3\n1 2 3\n",
"2\n3\n3 2 1\n6\n3 2 4 1 5 9\n",
"2\n3\n3 2 1\n6\n5 2 4 1 5 9\n",
"2\n5\n1 2 3 8 5\n4\n2 3 4 5\n",
"2\n3\n3 2 1\n6\n5 1 4 1 5 9\n",
"1\n3\n1 2 129021590\n",
"2\n4\n1 3 6 3\n3\n2 2 3\n",
"2\n3\n1 2 1\n6\n5 2 4 1 5 9\n",
"2\n5\n2 5 5 5 5\n3\n2 2 5\n",
"2\n5\n3 7 5 5 4\n3\n1 2 5\n",
"2\n5\n3 7 2 5 4\n3\n1 2 5\n",
"1\n5\n1 3 4 8 2\n",
"2\n3\n1 1 1\n2\n1 2\n",
"2\n5\n1 3 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 6 3\n3\n2 2 2\n",
"2\n3\n1 2 1\n6\n10 2 4 1 5 9\n",
"4\n7\n6 6 12 8 6 6 6\n1\n2\n5\n4 5 9 2 7\n7\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3\n2 2 6\n",
"2\n3\n3 2 1\n6\n3 1 3 2 2 14\n"
],
"output": [
"3\n5\n",
"5\n",
"2\n",
"2\n1\n5\n5\n",
"1\n1\n",
"1\n1\n",
"1\n3\n",
"5\n4\n",
"2\n3\n",
"4\n",
"2\n",
"2\n1\n5\n5\n",
"2\n1\n",
"2\n3\n",
"3\n3\n",
"3\n6\n",
"3\n5\n",
"5\n4\n",
"3\n4\n",
"3\n",
"3\n2\n",
"2\n5\n",
"2\n2\n",
"4\n3\n",
"5\n3\n",
"5\n",
"1\n2\n",
"4\n4\n",
"3\n1\n",
"2\n6\n",
"3\n1\n5\n5\n",
"4\n1\n5\n5\n",
"3\n5\n",
"3\n5\n",
"4\n",
"2\n3\n",
"2\n3\n",
"4\n",
"2\n3\n",
"3\n6\n",
"3\n6\n",
"3\n3\n",
"3\n3\n",
"3\n2\n",
"3\n6\n",
"2\n3\n",
"3\n3\n",
"3\n5\n",
"3\n3\n",
"3\n4\n",
"2\n",
"2\n3\n",
"2\n2\n",
"3\n4\n",
"3\n",
"3\n",
"2\n1\n5\n5\n",
"3\n5\n",
"3\n5\n",
"2\n3\n",
"5\n4\n",
"3\n5\n",
"3\n6\n",
"3\n2\n",
"3\n3\n",
"3\n5\n",
"2\n3\n",
"2\n5\n",
"3\n3\n",
"5\n3\n",
"5\n",
"3\n",
"2\n3\n",
"4\n3\n",
"2\n2\n",
"3\n5\n",
"2\n5\n",
"3\n4\n",
"2\n2\n",
"2\n5\n",
"3\n5\n",
"2\n6\n",
"3\n3\n",
"3\n5\n",
"4\n3\n",
"4\n3\n",
"4\n",
"3\n3\n",
"2\n2\n",
"3\n5\n",
"2\n3\n",
"2\n6\n",
"2\n5\n",
"3\n5\n",
"5\n3\n",
"5\n3\n",
"4\n",
"3\n3\n",
"3\n2\n",
"3\n4\n"
]
} | 2CODEFORCES
|
1344_A. Hilbert's Hotel_1218 | Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself, decides he wants to shuffle the guests around because he thinks this will create a vacancy (a room without a guest).
For any integer k and positive integer n, let kmod n denote the remainder when k is divided by n. More formally, r=kmod n is the smallest non-negative integer such that k-r is divisible by n. It always holds that 0β€ kmod nβ€ n-1. For example, 100mod 12=4 and (-1337)mod 3=1.
Then the shuffling works as follows. There is an array of n integers a_0,a_1,β¦,a_{n-1}. Then for each integer k, the guest in room k is moved to room number k+a_{kmod n}.
After this shuffling process, determine if there is still exactly one guest assigned to each room. That is, there are no vacancies or rooms with multiple guests.
Input
Each test consists of multiple test cases. The first line contains a single integer t (1β€ tβ€ 10^4) β the number of test cases. Next 2t lines contain descriptions of test cases.
The first line of each test case contains a single integer n (1β€ nβ€ 2β
10^5) β the length of the array.
The second line of each test case contains n integers a_0,a_1,β¦,a_{n-1} (-10^9β€ a_iβ€ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2β
10^5.
Output
For each test case, output a single line containing "YES" if there is exactly one guest assigned to each room after the shuffling process, or "NO" otherwise. You can print each letter in any case (upper or lower).
Example
Input
6
1
14
2
1 -1
4
5 5 5 1
3
3 2 1
2
0 1
5
-239 -2 -100 -3 -11
Output
YES
YES
YES
NO
NO
YES
Note
In the first test case, every guest is shifted by 14 rooms, so the assignment is still unique.
In the second test case, even guests move to the right by 1 room, and odd guests move to the left by 1 room. We can show that the assignment is still unique.
In the third test case, every fourth guest moves to the right by 1 room, and the other guests move to the right by 5 rooms. We can show that the assignment is still unique.
In the fourth test case, guests 0 and 1 are both assigned to room 3.
In the fifth test case, guests 1 and 2 are both assigned to room 2. | from __future__ import division, print_function
_interactive = False
def main():
for _ in range(int(input())):
n = int(input())
ar = input_as_list()
exists = array_of(bool, n)
for i, e in enumerate(ar):
exists[(i+e)%n] = True
print("YES" if all(exists) else "NO")
# Constants
INF = float('inf')
MOD = 10**9+7
alphabets = 'abcdefghijklmnopqrstuvwxyz'
# Python3 equivalent names
import os, sys, itertools
if sys.version_info[0] < 3:
input = raw_input
range = xrange
filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip
# print-flush in interactive problems
if _interactive:
flush = sys.stdout.flush()
def printf(*args, **kwargs):
print(*args, **kwargs)
flush()
# Debug print, only works on local machine
LOCAL = "LOCAL_" in os.environ
debug_print = (print) if LOCAL else (lambda *x, **y: None)
# Fast IO
if (not LOCAL) and (not _interactive):
from io import BytesIO
from atexit import register
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
# Some utility functions(Input, N-dimensional lists, ...)
def input_as_list():
return [int(x) for x in input().split()]
def input_with_offset(o):
return [int(x)+o for x in input().split()]
def input_as_matrix(n, m):
return [input_as_list() for _ in range(n)]
def array_of(f, *dim):
return [array_of(f, *dim[1:]) for _ in range(dim[0])] if dim else f()
main()
| 1Python2
| {
"input": [
"6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n12 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1942221517\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n0 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n0 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 2\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 2\n2\n2 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 -1\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n0 1000100000\n2\n1000000000 1\n2\n2 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n1 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000100000 0\n2\n-1 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n1\n1000000000\n1\n-1786824094\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 4 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n13\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -19\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -92 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000100000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 20 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000001\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -92 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 43 22 -44\n",
"10\n1\n1001000000\n1\n-1000000000\n2\n1000100000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -7\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 20 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-1 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-2 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-2 1000000100\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -16\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -28 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -16\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -81 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 3\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 3\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n55 -66 113 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -83 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 107 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n22 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -28 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n12 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 1\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1987984062\n2\n-1000000000 1\n2\n1 -1942221517\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -11\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000010000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -3 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 0\n2\n1 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1356927426 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 15 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-199 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -11 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-13744782\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 4 -93 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-436 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 46 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000010000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 5 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-29\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 4\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 0\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -79 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 -1 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -19\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 4 -86 88 -25 96 22 -44\n"
],
"output": [
"YES\nYES\nYES\nNO\nNO\nYES\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nYES\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nYES\n",
"YES\nYES\nNO\nNO\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nYES\nYES\n",
"YES\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nYES\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nYES\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n"
]
} | 2CODEFORCES
|
1344_A. Hilbert's Hotel_1219 | Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself, decides he wants to shuffle the guests around because he thinks this will create a vacancy (a room without a guest).
For any integer k and positive integer n, let kmod n denote the remainder when k is divided by n. More formally, r=kmod n is the smallest non-negative integer such that k-r is divisible by n. It always holds that 0β€ kmod nβ€ n-1. For example, 100mod 12=4 and (-1337)mod 3=1.
Then the shuffling works as follows. There is an array of n integers a_0,a_1,β¦,a_{n-1}. Then for each integer k, the guest in room k is moved to room number k+a_{kmod n}.
After this shuffling process, determine if there is still exactly one guest assigned to each room. That is, there are no vacancies or rooms with multiple guests.
Input
Each test consists of multiple test cases. The first line contains a single integer t (1β€ tβ€ 10^4) β the number of test cases. Next 2t lines contain descriptions of test cases.
The first line of each test case contains a single integer n (1β€ nβ€ 2β
10^5) β the length of the array.
The second line of each test case contains n integers a_0,a_1,β¦,a_{n-1} (-10^9β€ a_iβ€ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2β
10^5.
Output
For each test case, output a single line containing "YES" if there is exactly one guest assigned to each room after the shuffling process, or "NO" otherwise. You can print each letter in any case (upper or lower).
Example
Input
6
1
14
2
1 -1
4
5 5 5 1
3
3 2 1
2
0 1
5
-239 -2 -100 -3 -11
Output
YES
YES
YES
NO
NO
YES
Note
In the first test case, every guest is shifted by 14 rooms, so the assignment is still unique.
In the second test case, even guests move to the right by 1 room, and odd guests move to the left by 1 room. We can show that the assignment is still unique.
In the third test case, every fourth guest moves to the right by 1 room, and the other guests move to the right by 5 rooms. We can show that the assignment is still unique.
In the fourth test case, guests 0 and 1 are both assigned to room 3.
In the fifth test case, guests 1 and 2 are both assigned to room 2. | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void input(vector<T>& v, T n) {
for (T i = 0; i < n; i++) {
cin >> v[i];
}
}
int main() {
int t;
long long n;
cin >> t;
int Case = 0;
while (t--) {
cin >> n;
map<long long, long long> mp1;
vector<long long> v(n), v2(n);
for (int i = 0; i < n; i++) {
mp1.insert({i, 0});
cin >> v[i];
if (v[i] >= 0) {
v2[i] = v[i] % n;
} else {
v2[i] = n - (abs(v[i])) % n;
}
long long z = (v2[i] + i) % n;
mp1[z]++;
}
int flag = 1;
for (int i = 0; i < n; i++) {
if (mp1[i] == 0) {
flag = 0;
break;
}
}
if (flag == 0) {
cout << "NO\n";
} else {
cout << "YES\n";
}
}
return 0;
}
| 2C++
| {
"input": [
"6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n12 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1942221517\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n0 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n0 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 2\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 2\n2\n2 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 -1\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n0 1000100000\n2\n1000000000 1\n2\n2 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n1 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000100000 0\n2\n-1 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n1\n1000000000\n1\n-1786824094\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 4 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n13\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -19\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -92 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000100000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 20 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000001\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -92 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 43 22 -44\n",
"10\n1\n1001000000\n1\n-1000000000\n2\n1000100000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -7\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 20 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-1 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-2 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-2 1000000100\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -16\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -28 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -16\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -81 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 3\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 3\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n55 -66 113 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -83 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 107 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n22 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -28 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n12 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 1\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1987984062\n2\n-1000000000 1\n2\n1 -1942221517\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -11\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000010000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -3 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 0\n2\n1 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1356927426 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 15 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-199 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -11 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-13744782\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 4 -93 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-436 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 46 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000010000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 5 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-29\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 4\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 0\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -79 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 -1 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -19\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 4 -86 88 -25 96 22 -44\n"
],
"output": [
"YES\nYES\nYES\nNO\nNO\nYES\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nYES\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nYES\n",
"YES\nYES\nNO\nNO\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nYES\nYES\n",
"YES\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nYES\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nYES\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n"
]
} | 2CODEFORCES
|
1344_A. Hilbert's Hotel_1220 | Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself, decides he wants to shuffle the guests around because he thinks this will create a vacancy (a room without a guest).
For any integer k and positive integer n, let kmod n denote the remainder when k is divided by n. More formally, r=kmod n is the smallest non-negative integer such that k-r is divisible by n. It always holds that 0β€ kmod nβ€ n-1. For example, 100mod 12=4 and (-1337)mod 3=1.
Then the shuffling works as follows. There is an array of n integers a_0,a_1,β¦,a_{n-1}. Then for each integer k, the guest in room k is moved to room number k+a_{kmod n}.
After this shuffling process, determine if there is still exactly one guest assigned to each room. That is, there are no vacancies or rooms with multiple guests.
Input
Each test consists of multiple test cases. The first line contains a single integer t (1β€ tβ€ 10^4) β the number of test cases. Next 2t lines contain descriptions of test cases.
The first line of each test case contains a single integer n (1β€ nβ€ 2β
10^5) β the length of the array.
The second line of each test case contains n integers a_0,a_1,β¦,a_{n-1} (-10^9β€ a_iβ€ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2β
10^5.
Output
For each test case, output a single line containing "YES" if there is exactly one guest assigned to each room after the shuffling process, or "NO" otherwise. You can print each letter in any case (upper or lower).
Example
Input
6
1
14
2
1 -1
4
5 5 5 1
3
3 2 1
2
0 1
5
-239 -2 -100 -3 -11
Output
YES
YES
YES
NO
NO
YES
Note
In the first test case, every guest is shifted by 14 rooms, so the assignment is still unique.
In the second test case, even guests move to the right by 1 room, and odd guests move to the left by 1 room. We can show that the assignment is still unique.
In the third test case, every fourth guest moves to the right by 1 room, and the other guests move to the right by 5 rooms. We can show that the assignment is still unique.
In the fourth test case, guests 0 and 1 are both assigned to room 3.
In the fifth test case, guests 1 and 2 are both assigned to room 2. | # cook your dish here
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
d={}
f=0
for i in range(n):
l[i]=i+a[i%n]
d[l[i]]=d.get(l[i],0)+1
if d[l[i]]==2:
f=1
break
r={}
for i in range(n):
r[l[i]%n]=r.get(l[i]%n,0)+1
if r[l[i]%n]==2:
f=1
break
if f:
print('NO')
else:
print('YES') | 3Python3
| {
"input": [
"6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n12 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1942221517\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n0 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n0 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 2\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 2\n2\n2 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 -1\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n0 1000100000\n2\n1000000000 1\n2\n2 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n1 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000100000 0\n2\n-1 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n1\n1000000000\n1\n-1786824094\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 4 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n13\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -19\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -92 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000100000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 20 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000001\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -92 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 43 22 -44\n",
"10\n1\n1001000000\n1\n-1000000000\n2\n1000100000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -7\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 20 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-1 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-2 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-2 1000000100\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -16\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -28 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -16\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -81 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 3\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 3\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n55 -66 113 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -83 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 107 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n22 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -28 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n12 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 1\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1987984062\n2\n-1000000000 1\n2\n1 -1942221517\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -11\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000010000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -3 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 0\n2\n1 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1356927426 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 15 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-199 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -11 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-13744782\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 4 -93 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-436 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 46 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000010000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 5 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-29\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 4\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 0\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -79 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 -1 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -19\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 4 -86 88 -25 96 22 -44\n"
],
"output": [
"YES\nYES\nYES\nNO\nNO\nYES\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nYES\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nYES\n",
"YES\nYES\nNO\nNO\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nYES\nYES\n",
"YES\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nYES\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nYES\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n"
]
} | 2CODEFORCES
|
1344_A. Hilbert's Hotel_1221 | Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself, decides he wants to shuffle the guests around because he thinks this will create a vacancy (a room without a guest).
For any integer k and positive integer n, let kmod n denote the remainder when k is divided by n. More formally, r=kmod n is the smallest non-negative integer such that k-r is divisible by n. It always holds that 0β€ kmod nβ€ n-1. For example, 100mod 12=4 and (-1337)mod 3=1.
Then the shuffling works as follows. There is an array of n integers a_0,a_1,β¦,a_{n-1}. Then for each integer k, the guest in room k is moved to room number k+a_{kmod n}.
After this shuffling process, determine if there is still exactly one guest assigned to each room. That is, there are no vacancies or rooms with multiple guests.
Input
Each test consists of multiple test cases. The first line contains a single integer t (1β€ tβ€ 10^4) β the number of test cases. Next 2t lines contain descriptions of test cases.
The first line of each test case contains a single integer n (1β€ nβ€ 2β
10^5) β the length of the array.
The second line of each test case contains n integers a_0,a_1,β¦,a_{n-1} (-10^9β€ a_iβ€ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2β
10^5.
Output
For each test case, output a single line containing "YES" if there is exactly one guest assigned to each room after the shuffling process, or "NO" otherwise. You can print each letter in any case (upper or lower).
Example
Input
6
1
14
2
1 -1
4
5 5 5 1
3
3 2 1
2
0 1
5
-239 -2 -100 -3 -11
Output
YES
YES
YES
NO
NO
YES
Note
In the first test case, every guest is shifted by 14 rooms, so the assignment is still unique.
In the second test case, even guests move to the right by 1 room, and odd guests move to the left by 1 room. We can show that the assignment is still unique.
In the third test case, every fourth guest moves to the right by 1 room, and the other guests move to the right by 5 rooms. We can show that the assignment is still unique.
In the fourth test case, guests 0 and 1 are both assigned to room 3.
In the fifth test case, guests 1 and 2 are both assigned to room 2. | import java.io.*;
import java.util.*;
public class Template {
static int mod = 1000000007;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int yo = sc.nextInt();
while (yo-- > 0) {
int n = sc.nextInt();
long[] a = new long[n];
for(int i = 0; i < n; i++) a[i] = sc.nextLong();
Map<Long,Integer> map = new HashMap<>();
for(int i = 0; i < n; i++) {
long move = (i + a[i]) % n;
if(move < 0) move += n;
map.put(move, map.getOrDefault(move, 0)+1);
}
boolean yes = true;
for(int val : map.values()) {
if(val > 1) {
yes = false;
}
}
if(yes) {
out.println("YES");
}
else {
out.println("NO");
}
}
out.close();
}
static class Pair {
int x;
int y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
}
static void ruffleSort(int[] a) {
int n = a.length;
Random r = new Random();
for (int i = 0; i < a.length; i++) {
int oi = r.nextInt(n), temp = a[i];
a[i] = a[oi];
a[oi] = temp;
}
Arrays.sort(a);
}
static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
static boolean[] sieve(int N) {
boolean[] sieve = new boolean[N + 1];
for (int i = 2; i <= N; i++)
sieve[i] = true;
for (int i = 2; i <= N; i++) {
if (sieve[i]) {
for (int j = 2 * i; j <= N; j += i) {
sieve[j] = false;
}
}
}
return sieve;
}
static long pow(int a, long b) {
if (b == 0) {
return 1;
}
if (b == 1) {
return a;
}
if (b % 2 == 0) {
long ans = pow(a, b / 2);
return ans * ans;
} else {
long ans = pow(a, (b - 1) / 2);
return a * ans * ans;
}
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
// For Input.txt and Output.txt
// FileInputStream in = new FileInputStream("input.txt");
// FileOutputStream out = new FileOutputStream("output.txt");
// PrintWriter pw = new PrintWriter(out);
// Scanner sc = new Scanner(in);
}
| 4JAVA
| {
"input": [
"6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n12 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1942221517\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n0 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n0 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 2\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 2\n2\n2 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 -1\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n0 1000100000\n2\n1000000000 1\n2\n2 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n1 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000100000 0\n2\n-1 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n1\n1000000000\n1\n-1786824094\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 4 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n13\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-239 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -19\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -92 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000100000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 20 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n0 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000001\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000100000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -92 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 43 22 -44\n",
"10\n1\n1001000000\n1\n-1000000000\n2\n1000100000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 2\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 5 -52 -55 66 33 -7\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 20 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-1 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-2 1000000000\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 66 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000100 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n-2 1000000100\n2\n-1000000000 0\n2\n0 -1732378972\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -16\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 21 69 -85 93 -28 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -53 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -16\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -81 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 28\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -76 5 3\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 3\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n55 -66 63 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n55 -66 113 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 0 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -83 57 8 -86 67 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -83 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n92 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 59 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 107 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n22 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -28 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n12 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 1\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1987984062\n2\n-1000000000 1\n2\n1 -1942221517\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -11\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000010000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -3 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 0\n2\n1 1\n5\n-313 -2 -100 -3 -11\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000000000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1356927426 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 15 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-199 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 67 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -11 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-13744782\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-852737322 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 4 -93 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"6\n1\n14\n2\n1 -1\n4\n5 5 3 1\n3\n3 2 1\n2\n1 1\n5\n-436 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 46 8 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 -1\n2\n-1 1000100000\n2\n1000000000 1\n2\n1 1000010000\n2\n-586829011 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -1000000000\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 5 -44\n",
"10\n3\n-15 -33 79\n16\n56 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-29\n1\n-8\n12\n32 34 43 -83 57 13 -86 88 -25 96 22 -44\n",
"10\n1\n1000000000\n1\n-1000000000\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 1\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-698912274 4\n2\n1 -1000000000\n",
"10\n1\n1000000000\n1\n-1226724342\n2\n1000000000 0\n2\n0 1000000000\n2\n1000000000 0\n2\n1 1000000000\n2\n-1000000000 0\n2\n0 -1000000000\n2\n-1000000000 1\n2\n1 -319516196\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -79 0 -53 5 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 -1 -53 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 58 -66 -35\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n34 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
"10\n3\n-15 -33 79\n16\n45 -84 35 85 69 -64 93 -70 0 -24 2 -52 -55 66 33 -98\n2\n14 0\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -19\n5\n-125 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 4 -86 88 -25 96 22 -44\n"
],
"output": [
"YES\nYES\nYES\nNO\nNO\nYES\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nYES\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nYES\n",
"YES\nYES\nNO\nNO\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nYES\nYES\n",
"YES\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nYES\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nYES\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"YES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\n",
"YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n",
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n"
]
} | 2CODEFORCES
|
1366_A. Shovels and Swords_1222 | Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types β shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has a sticks and b diamonds?
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The only line of each test case contains two integers a and b (0 β€ a, b β€ 10^9) β the number of sticks and the number of diamonds, respectively.
Output
For each test case print one integer β the maximum number of emeralds Polycarp can earn.
Example
Input
4
4 4
1000000000 0
7 15
8 7
Output
2
0
7
5
Note
In the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.
In the second test case Polycarp does not have any diamonds, so he cannot craft anything. | T = int(raw_input())
for _ in xrange(T):
a, b = map(int, raw_input().split())
print min(a, b, (a + b) / 3)
| 1Python2
| {
"input": [
"4\n4 4\n1000000000 0\n7 15\n8 7\n",
"1\n656 656\n",
"1\n666 666\n",
"2\n7 4\n1 5\n",
"1\n33993 5\n",
"1\n1656 5\n",
"1\n1319 1777\n",
"1\n667 666\n",
"1\n656 281\n",
"1\n666 760\n",
"2\n10 4\n1 5\n",
"1\n33993 6\n",
"1\n1656 9\n",
"1\n1425 1777\n",
"1\n667 288\n",
"4\n4 4\n1000000000 0\n12 15\n8 7\n",
"1\n666 1297\n",
"1\n33993 2\n",
"1\n1656 15\n",
"1\n892 1777\n",
"1\n682 214\n",
"1\n1133 1297\n",
"1\n33993 0\n",
"1\n1030 1777\n",
"1\n682 154\n",
"1\n1133 1185\n",
"2\n10 4\n0 16\n",
"1\n738 13\n",
"1\n1030 1968\n",
"1\n1013 118\n",
"1\n1133 1275\n",
"1\n1019 1968\n",
"1\n168 118\n",
"1\n1133 867\n",
"2\n7 4\n0 8\n",
"1\n1019 987\n",
"1\n168 180\n",
"1\n710 292\n",
"1\n971 867\n",
"2\n4 4\n0 8\n",
"1\n1019 528\n",
"1\n84 180\n",
"1\n91 292\n",
"1\n971 1709\n",
"1\n1777 11\n",
"1\n528 528\n",
"1\n89 180\n",
"1\n971 88\n",
"1\n1777 20\n",
"1\n528 993\n",
"1\n89 109\n",
"1\n60 993\n",
"1\n89 121\n",
"1\n35 276\n",
"1\n1403 56\n",
"1\n1403 93\n",
"1\n29 1115\n",
"1\n1403 99\n",
"1\n49 1115\n",
"1\n73 176\n",
"1\n989 50\n",
"1\n543 1\n",
"1\n989 59\n",
"1\n682 281\n",
"2\n10 4\n1 9\n",
"1\n940 288\n",
"4\n4 4\n1010000000 0\n12 15\n8 7\n",
"2\n10 4\n1 16\n",
"1\n738 15\n",
"1\n1013 288\n",
"1\n428 154\n",
"2\n10 4\n0 8\n",
"1\n675 13\n",
"1\n710 154\n",
"1\n1158 13\n",
"1\n1777 13\n",
"2\n4 4\n0 12\n",
"1\n91 255\n",
"1\n91 276\n",
"1\n1403 88\n",
"1\n3433 20\n",
"1\n1913 20\n",
"1\n60 1115\n",
"1\n89 189\n",
"1\n35 383\n",
"1\n531 20\n",
"1\n89 176\n",
"1\n35 686\n",
"1\n531 2\n",
"1\n35 763\n",
"1\n1490 99\n",
"1\n531 0\n",
"1\n49 815\n",
"1\n6 176\n",
"1\n35 949\n",
"1\n989 99\n",
"1\n543 0\n",
"1\n89 815\n",
"1\n2 176\n",
"1\n35 819\n",
"1\n89 787\n",
"1\n2 75\n",
"1\n13 819\n",
"1\n723 1\n"
],
"output": [
"2\n0\n7\n5\n",
"437\n",
"444\n",
"3\n1\n",
"5\n",
"5\n",
"1032\n",
"444\n",
"281\n",
"475\n",
"4\n1\n",
"6\n",
"9\n",
"1067\n",
"288\n",
"2\n0\n9\n5\n",
"654\n",
"2\n",
"15\n",
"889\n",
"214\n",
"810\n",
"0\n",
"935\n",
"154\n",
"772\n",
"4\n0\n",
"13\n",
"999\n",
"118\n",
"802\n",
"995\n",
"95\n",
"666\n",
"3\n0\n",
"668\n",
"116\n",
"292\n",
"612\n",
"2\n0\n",
"515\n",
"84\n",
"91\n",
"893\n",
"11\n",
"352\n",
"89\n",
"88\n",
"20\n",
"507\n",
"66\n",
"60\n",
"70\n",
"35\n",
"56\n",
"93\n",
"29\n",
"99\n",
"49\n",
"73\n",
"50\n",
"1\n",
"59\n",
"281\n",
"4\n1\n",
"288\n",
"2\n0\n9\n5\n",
"4\n1\n",
"15\n",
"288\n",
"154\n",
"4\n0\n",
"13\n",
"154\n",
"13\n",
"13\n",
"2\n0\n",
"91\n",
"91\n",
"88\n",
"20\n",
"20\n",
"60\n",
"89\n",
"35\n",
"20\n",
"88\n",
"35\n",
"2\n",
"35\n",
"99\n",
"0\n",
"49\n",
"6\n",
"35\n",
"99\n",
"0\n",
"89\n",
"2\n",
"35\n",
"89\n",
"2\n",
"13\n",
"1\n"
]
} | 2CODEFORCES
|
1366_A. Shovels and Swords_1223 | Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types β shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has a sticks and b diamonds?
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The only line of each test case contains two integers a and b (0 β€ a, b β€ 10^9) β the number of sticks and the number of diamonds, respectively.
Output
For each test case print one integer β the maximum number of emeralds Polycarp can earn.
Example
Input
4
4 4
1000000000 0
7 15
8 7
Output
2
0
7
5
Note
In the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.
In the second test case Polycarp does not have any diamonds, so he cannot craft anything. | #include <bits/stdc++.h>
using namespace std;
long long choice(long long a, long long b) {
long long opt1 = min(a / 2, b);
a -= 2 * opt1;
b -= opt1;
long long opt2 = min(a, b / 2);
return opt1 + opt2;
}
void solve() {
long long a, b;
cin >> a >> b;
if ((a + b) / 3 <= min(a, b)) {
cout << (a + b) / 3 << endl;
return;
};
cout << min(a, b) << endl;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
| 2C++
| {
"input": [
"4\n4 4\n1000000000 0\n7 15\n8 7\n",
"1\n656 656\n",
"1\n666 666\n",
"2\n7 4\n1 5\n",
"1\n33993 5\n",
"1\n1656 5\n",
"1\n1319 1777\n",
"1\n667 666\n",
"1\n656 281\n",
"1\n666 760\n",
"2\n10 4\n1 5\n",
"1\n33993 6\n",
"1\n1656 9\n",
"1\n1425 1777\n",
"1\n667 288\n",
"4\n4 4\n1000000000 0\n12 15\n8 7\n",
"1\n666 1297\n",
"1\n33993 2\n",
"1\n1656 15\n",
"1\n892 1777\n",
"1\n682 214\n",
"1\n1133 1297\n",
"1\n33993 0\n",
"1\n1030 1777\n",
"1\n682 154\n",
"1\n1133 1185\n",
"2\n10 4\n0 16\n",
"1\n738 13\n",
"1\n1030 1968\n",
"1\n1013 118\n",
"1\n1133 1275\n",
"1\n1019 1968\n",
"1\n168 118\n",
"1\n1133 867\n",
"2\n7 4\n0 8\n",
"1\n1019 987\n",
"1\n168 180\n",
"1\n710 292\n",
"1\n971 867\n",
"2\n4 4\n0 8\n",
"1\n1019 528\n",
"1\n84 180\n",
"1\n91 292\n",
"1\n971 1709\n",
"1\n1777 11\n",
"1\n528 528\n",
"1\n89 180\n",
"1\n971 88\n",
"1\n1777 20\n",
"1\n528 993\n",
"1\n89 109\n",
"1\n60 993\n",
"1\n89 121\n",
"1\n35 276\n",
"1\n1403 56\n",
"1\n1403 93\n",
"1\n29 1115\n",
"1\n1403 99\n",
"1\n49 1115\n",
"1\n73 176\n",
"1\n989 50\n",
"1\n543 1\n",
"1\n989 59\n",
"1\n682 281\n",
"2\n10 4\n1 9\n",
"1\n940 288\n",
"4\n4 4\n1010000000 0\n12 15\n8 7\n",
"2\n10 4\n1 16\n",
"1\n738 15\n",
"1\n1013 288\n",
"1\n428 154\n",
"2\n10 4\n0 8\n",
"1\n675 13\n",
"1\n710 154\n",
"1\n1158 13\n",
"1\n1777 13\n",
"2\n4 4\n0 12\n",
"1\n91 255\n",
"1\n91 276\n",
"1\n1403 88\n",
"1\n3433 20\n",
"1\n1913 20\n",
"1\n60 1115\n",
"1\n89 189\n",
"1\n35 383\n",
"1\n531 20\n",
"1\n89 176\n",
"1\n35 686\n",
"1\n531 2\n",
"1\n35 763\n",
"1\n1490 99\n",
"1\n531 0\n",
"1\n49 815\n",
"1\n6 176\n",
"1\n35 949\n",
"1\n989 99\n",
"1\n543 0\n",
"1\n89 815\n",
"1\n2 176\n",
"1\n35 819\n",
"1\n89 787\n",
"1\n2 75\n",
"1\n13 819\n",
"1\n723 1\n"
],
"output": [
"2\n0\n7\n5\n",
"437\n",
"444\n",
"3\n1\n",
"5\n",
"5\n",
"1032\n",
"444\n",
"281\n",
"475\n",
"4\n1\n",
"6\n",
"9\n",
"1067\n",
"288\n",
"2\n0\n9\n5\n",
"654\n",
"2\n",
"15\n",
"889\n",
"214\n",
"810\n",
"0\n",
"935\n",
"154\n",
"772\n",
"4\n0\n",
"13\n",
"999\n",
"118\n",
"802\n",
"995\n",
"95\n",
"666\n",
"3\n0\n",
"668\n",
"116\n",
"292\n",
"612\n",
"2\n0\n",
"515\n",
"84\n",
"91\n",
"893\n",
"11\n",
"352\n",
"89\n",
"88\n",
"20\n",
"507\n",
"66\n",
"60\n",
"70\n",
"35\n",
"56\n",
"93\n",
"29\n",
"99\n",
"49\n",
"73\n",
"50\n",
"1\n",
"59\n",
"281\n",
"4\n1\n",
"288\n",
"2\n0\n9\n5\n",
"4\n1\n",
"15\n",
"288\n",
"154\n",
"4\n0\n",
"13\n",
"154\n",
"13\n",
"13\n",
"2\n0\n",
"91\n",
"91\n",
"88\n",
"20\n",
"20\n",
"60\n",
"89\n",
"35\n",
"20\n",
"88\n",
"35\n",
"2\n",
"35\n",
"99\n",
"0\n",
"49\n",
"6\n",
"35\n",
"99\n",
"0\n",
"89\n",
"2\n",
"35\n",
"89\n",
"2\n",
"13\n",
"1\n"
]
} | 2CODEFORCES
|
1366_A. Shovels and Swords_1224 | Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types β shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has a sticks and b diamonds?
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The only line of each test case contains two integers a and b (0 β€ a, b β€ 10^9) β the number of sticks and the number of diamonds, respectively.
Output
For each test case print one integer β the maximum number of emeralds Polycarp can earn.
Example
Input
4
4 4
1000000000 0
7 15
8 7
Output
2
0
7
5
Note
In the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.
In the second test case Polycarp does not have any diamonds, so he cannot craft anything. | import math
t=int(input())
for i in range(t):
a,b=map(int,input().split())
m=min(a,b,(a+b)/3)
print(math.floor(m))
| 3Python3
| {
"input": [
"4\n4 4\n1000000000 0\n7 15\n8 7\n",
"1\n656 656\n",
"1\n666 666\n",
"2\n7 4\n1 5\n",
"1\n33993 5\n",
"1\n1656 5\n",
"1\n1319 1777\n",
"1\n667 666\n",
"1\n656 281\n",
"1\n666 760\n",
"2\n10 4\n1 5\n",
"1\n33993 6\n",
"1\n1656 9\n",
"1\n1425 1777\n",
"1\n667 288\n",
"4\n4 4\n1000000000 0\n12 15\n8 7\n",
"1\n666 1297\n",
"1\n33993 2\n",
"1\n1656 15\n",
"1\n892 1777\n",
"1\n682 214\n",
"1\n1133 1297\n",
"1\n33993 0\n",
"1\n1030 1777\n",
"1\n682 154\n",
"1\n1133 1185\n",
"2\n10 4\n0 16\n",
"1\n738 13\n",
"1\n1030 1968\n",
"1\n1013 118\n",
"1\n1133 1275\n",
"1\n1019 1968\n",
"1\n168 118\n",
"1\n1133 867\n",
"2\n7 4\n0 8\n",
"1\n1019 987\n",
"1\n168 180\n",
"1\n710 292\n",
"1\n971 867\n",
"2\n4 4\n0 8\n",
"1\n1019 528\n",
"1\n84 180\n",
"1\n91 292\n",
"1\n971 1709\n",
"1\n1777 11\n",
"1\n528 528\n",
"1\n89 180\n",
"1\n971 88\n",
"1\n1777 20\n",
"1\n528 993\n",
"1\n89 109\n",
"1\n60 993\n",
"1\n89 121\n",
"1\n35 276\n",
"1\n1403 56\n",
"1\n1403 93\n",
"1\n29 1115\n",
"1\n1403 99\n",
"1\n49 1115\n",
"1\n73 176\n",
"1\n989 50\n",
"1\n543 1\n",
"1\n989 59\n",
"1\n682 281\n",
"2\n10 4\n1 9\n",
"1\n940 288\n",
"4\n4 4\n1010000000 0\n12 15\n8 7\n",
"2\n10 4\n1 16\n",
"1\n738 15\n",
"1\n1013 288\n",
"1\n428 154\n",
"2\n10 4\n0 8\n",
"1\n675 13\n",
"1\n710 154\n",
"1\n1158 13\n",
"1\n1777 13\n",
"2\n4 4\n0 12\n",
"1\n91 255\n",
"1\n91 276\n",
"1\n1403 88\n",
"1\n3433 20\n",
"1\n1913 20\n",
"1\n60 1115\n",
"1\n89 189\n",
"1\n35 383\n",
"1\n531 20\n",
"1\n89 176\n",
"1\n35 686\n",
"1\n531 2\n",
"1\n35 763\n",
"1\n1490 99\n",
"1\n531 0\n",
"1\n49 815\n",
"1\n6 176\n",
"1\n35 949\n",
"1\n989 99\n",
"1\n543 0\n",
"1\n89 815\n",
"1\n2 176\n",
"1\n35 819\n",
"1\n89 787\n",
"1\n2 75\n",
"1\n13 819\n",
"1\n723 1\n"
],
"output": [
"2\n0\n7\n5\n",
"437\n",
"444\n",
"3\n1\n",
"5\n",
"5\n",
"1032\n",
"444\n",
"281\n",
"475\n",
"4\n1\n",
"6\n",
"9\n",
"1067\n",
"288\n",
"2\n0\n9\n5\n",
"654\n",
"2\n",
"15\n",
"889\n",
"214\n",
"810\n",
"0\n",
"935\n",
"154\n",
"772\n",
"4\n0\n",
"13\n",
"999\n",
"118\n",
"802\n",
"995\n",
"95\n",
"666\n",
"3\n0\n",
"668\n",
"116\n",
"292\n",
"612\n",
"2\n0\n",
"515\n",
"84\n",
"91\n",
"893\n",
"11\n",
"352\n",
"89\n",
"88\n",
"20\n",
"507\n",
"66\n",
"60\n",
"70\n",
"35\n",
"56\n",
"93\n",
"29\n",
"99\n",
"49\n",
"73\n",
"50\n",
"1\n",
"59\n",
"281\n",
"4\n1\n",
"288\n",
"2\n0\n9\n5\n",
"4\n1\n",
"15\n",
"288\n",
"154\n",
"4\n0\n",
"13\n",
"154\n",
"13\n",
"13\n",
"2\n0\n",
"91\n",
"91\n",
"88\n",
"20\n",
"20\n",
"60\n",
"89\n",
"35\n",
"20\n",
"88\n",
"35\n",
"2\n",
"35\n",
"99\n",
"0\n",
"49\n",
"6\n",
"35\n",
"99\n",
"0\n",
"89\n",
"2\n",
"35\n",
"89\n",
"2\n",
"13\n",
"1\n"
]
} | 2CODEFORCES
|
1366_A. Shovels and Swords_1225 | Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types β shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has a sticks and b diamonds?
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The only line of each test case contains two integers a and b (0 β€ a, b β€ 10^9) β the number of sticks and the number of diamonds, respectively.
Output
For each test case print one integer β the maximum number of emeralds Polycarp can earn.
Example
Input
4
4 4
1000000000 0
7 15
8 7
Output
2
0
7
5
Note
In the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.
In the second test case Polycarp does not have any diamonds, so he cannot craft anything. |
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-->0)
{
long X = scan.nextInt(), Y= scan.nextInt();
long a = Math.max(X, Y), b = Math.min(X, Y);
if(a==b)System.out.println(Math.max((a-1-(a-1)/3),0));
else if(a>=2*b)System.out.println(b);
else System.out.println(((2*b-a)-1-((2*b-a)-1)/3)+(a-b));
}
}
}
| 4JAVA
| {
"input": [
"4\n4 4\n1000000000 0\n7 15\n8 7\n",
"1\n656 656\n",
"1\n666 666\n",
"2\n7 4\n1 5\n",
"1\n33993 5\n",
"1\n1656 5\n",
"1\n1319 1777\n",
"1\n667 666\n",
"1\n656 281\n",
"1\n666 760\n",
"2\n10 4\n1 5\n",
"1\n33993 6\n",
"1\n1656 9\n",
"1\n1425 1777\n",
"1\n667 288\n",
"4\n4 4\n1000000000 0\n12 15\n8 7\n",
"1\n666 1297\n",
"1\n33993 2\n",
"1\n1656 15\n",
"1\n892 1777\n",
"1\n682 214\n",
"1\n1133 1297\n",
"1\n33993 0\n",
"1\n1030 1777\n",
"1\n682 154\n",
"1\n1133 1185\n",
"2\n10 4\n0 16\n",
"1\n738 13\n",
"1\n1030 1968\n",
"1\n1013 118\n",
"1\n1133 1275\n",
"1\n1019 1968\n",
"1\n168 118\n",
"1\n1133 867\n",
"2\n7 4\n0 8\n",
"1\n1019 987\n",
"1\n168 180\n",
"1\n710 292\n",
"1\n971 867\n",
"2\n4 4\n0 8\n",
"1\n1019 528\n",
"1\n84 180\n",
"1\n91 292\n",
"1\n971 1709\n",
"1\n1777 11\n",
"1\n528 528\n",
"1\n89 180\n",
"1\n971 88\n",
"1\n1777 20\n",
"1\n528 993\n",
"1\n89 109\n",
"1\n60 993\n",
"1\n89 121\n",
"1\n35 276\n",
"1\n1403 56\n",
"1\n1403 93\n",
"1\n29 1115\n",
"1\n1403 99\n",
"1\n49 1115\n",
"1\n73 176\n",
"1\n989 50\n",
"1\n543 1\n",
"1\n989 59\n",
"1\n682 281\n",
"2\n10 4\n1 9\n",
"1\n940 288\n",
"4\n4 4\n1010000000 0\n12 15\n8 7\n",
"2\n10 4\n1 16\n",
"1\n738 15\n",
"1\n1013 288\n",
"1\n428 154\n",
"2\n10 4\n0 8\n",
"1\n675 13\n",
"1\n710 154\n",
"1\n1158 13\n",
"1\n1777 13\n",
"2\n4 4\n0 12\n",
"1\n91 255\n",
"1\n91 276\n",
"1\n1403 88\n",
"1\n3433 20\n",
"1\n1913 20\n",
"1\n60 1115\n",
"1\n89 189\n",
"1\n35 383\n",
"1\n531 20\n",
"1\n89 176\n",
"1\n35 686\n",
"1\n531 2\n",
"1\n35 763\n",
"1\n1490 99\n",
"1\n531 0\n",
"1\n49 815\n",
"1\n6 176\n",
"1\n35 949\n",
"1\n989 99\n",
"1\n543 0\n",
"1\n89 815\n",
"1\n2 176\n",
"1\n35 819\n",
"1\n89 787\n",
"1\n2 75\n",
"1\n13 819\n",
"1\n723 1\n"
],
"output": [
"2\n0\n7\n5\n",
"437\n",
"444\n",
"3\n1\n",
"5\n",
"5\n",
"1032\n",
"444\n",
"281\n",
"475\n",
"4\n1\n",
"6\n",
"9\n",
"1067\n",
"288\n",
"2\n0\n9\n5\n",
"654\n",
"2\n",
"15\n",
"889\n",
"214\n",
"810\n",
"0\n",
"935\n",
"154\n",
"772\n",
"4\n0\n",
"13\n",
"999\n",
"118\n",
"802\n",
"995\n",
"95\n",
"666\n",
"3\n0\n",
"668\n",
"116\n",
"292\n",
"612\n",
"2\n0\n",
"515\n",
"84\n",
"91\n",
"893\n",
"11\n",
"352\n",
"89\n",
"88\n",
"20\n",
"507\n",
"66\n",
"60\n",
"70\n",
"35\n",
"56\n",
"93\n",
"29\n",
"99\n",
"49\n",
"73\n",
"50\n",
"1\n",
"59\n",
"281\n",
"4\n1\n",
"288\n",
"2\n0\n9\n5\n",
"4\n1\n",
"15\n",
"288\n",
"154\n",
"4\n0\n",
"13\n",
"154\n",
"13\n",
"13\n",
"2\n0\n",
"91\n",
"91\n",
"88\n",
"20\n",
"20\n",
"60\n",
"89\n",
"35\n",
"20\n",
"88\n",
"35\n",
"2\n",
"35\n",
"99\n",
"0\n",
"49\n",
"6\n",
"35\n",
"99\n",
"0\n",
"89\n",
"2\n",
"35\n",
"89\n",
"2\n",
"13\n",
"1\n"
]
} | 2CODEFORCES
|
1386_A. Colors_1226 | Linda likes to change her hair color from time to time, and would be pleased if her boyfriend Archie would notice the difference between the previous and the new color. Archie always comments on Linda's hair color if and only if he notices a difference β so Linda always knows whether Archie has spotted the difference or not.
There is a new hair dye series in the market where all available colors are numbered by integers from 1 to N such that a smaller difference of the numerical values also means less visual difference.
Linda assumes that for these series there should be some critical color difference C (1 β€ C β€ N) for which Archie will notice color difference between the current color color_{new} and the previous color color_{prev} if \left|color_{new} - color_{prev}\right| β₯ C and will not if \left|color_{new} - color_{prev}\right| < C.
Now she has bought N sets of hair dye from the new series β one for each of the colors from 1 to N, and is ready to set up an experiment. Linda will change her hair color on a regular basis and will observe Archie's reaction β whether he will notice the color change or not. Since for the proper dye each set should be used completely, each hair color can be obtained no more than once.
Before the experiment, Linda was using a dye from a different series which is not compatible with the new one, so for the clearness of the experiment Archie's reaction to the first used color is meaningless.
Her aim is to find the precise value of C in a limited number of dyes. Write a program which finds the value of C by experimenting with the given N colors and observing Archie's reactions to color changes.
Interaction
This is an interactive task. In the beginning you are given a single integer T (1 β€ T β€ 100), the number of cases in the test.
For each test case, the input first contains a single integer β the value of N (1 < N β€ 10^{18}). The value of C is kept secret by the grading system.
Then your program should make queries writing output in the following format: "? P", where P is an integer (1 β€ P β€ N) denoting the next color used. For each query the grading system gives an answer in the next line of the input. The answer is 1 if Archie notices the color difference between the last two colors and 0 otherwise. No two queries should have the same P value.
When your program determines C, it should output its value in the following format: "= C". The grading system will not respond to this output and will proceed with the next test case.
Your program may use at most 64 queries "?" for each test case to find the correct value of C.
To establish proper communication between your program and the grading system, you should flush the output stream after each query.
$$$\begin{array}{ll} Language & Command \\\ \hline C++ & std::cout << std::endl; \\\ Java & System.out.flush(); \\\ Python & sys.stdout.flush() \end{array}$$$ Flush commands
Note that std::endl writes a newline and flushes the stream.
It is possible to receive an "Output isn't correct" outcome even after printing a correct answer, if task constraints were violated during the communication. Violating the communication protocol itself may result in an "Execution killed" outcome.
Submitting user tests requires specifying an input file with the testcase parameters. The format of the input file is "T" in the first line, and then "N C" on a single line for each of the T cases.
Scoring
Subtasks:
1. (9 points) N β€ 64
2. (13 points) N β€ 125
3. (21 points) N β€ 1000
4. (24 points) N β€ 10^9
5. (33 points) No further constraints.
Example
Input
1
7
1
1
0
0
1
Output
? 2
? 7
? 4
? 1
? 5
= 4
Note
Comments to the example input line by line:
1. N = 7.
2. Answer to the first query is meaningless (can also be 0).
3. C β€ 5.
4. 3 < C β€ 5. It would be wise to check difference 4. However, this can not be done in the next query since 4 + 4 = 8 and 4 - 4 = 0 both are outside the allowed interval 1 β€ P β€ 7.
5. 3 < C β€ 5.
6. 3 < C β€ 4. Therefore, C = 4. | #include <bits/stdc++.h>
using namespace std;
const int Inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const long double inF = 11451419198101145141919810.1145141919810;
const long double pi = acosl(-1);
long long n;
int ask(long long x) {
printf("? %lld\n", x);
fflush(stdout);
int res;
scanf("%d", &res);
return res;
}
void answer(long long x) {
printf("= %lld\n", x);
fflush(stdout);
}
void solve() {
scanf("%lld", &n);
vector<long long> ps;
long long l = 1, r = n - 1;
while (l <= r) {
long long m = (l + r) >> 1;
ps.push_back(m);
if (l == r && m == n - 1) break;
l = m + 1;
}
reverse((ps).begin(), (ps).end());
long long now = n, pre = n;
bool tol = 1;
for (__typeof((ps).begin()) i = (ps).begin(), _e_D_ = (ps).end(); i != _e_D_;
i++) {
pre = now;
if (tol)
now -= *i;
else
now += *i;
tol ^= 1;
}
if (now > pre)
tol = 1;
else
tol = 0;
l = 1, r = n - 1;
long long res = n;
ask(now);
while (r >= l) {
long long m = (l + r) >> 1;
if (tol)
now -= m;
else
now += m;
if (ask(now)) {
r = m - 1;
res = m;
} else
l = m + 1;
tol ^= 1;
}
answer(res);
}
int main() {
int T;
scanf("%d", &T);
while (T--) solve();
return 0;
}
| 2C++
| {
"input": [
"1\n\n7\n\n1\n\n1\n\n0\n\n0\n\n1\n",
"46\n63 1\n63 63\n123 1\n123 123\n63 2\n63 62\n123 2\n123 122\n63 3\n63 61\n123 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 5\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 4\n75 68\n108 26\n97 94\n106 5\n84 81\n68 46\n89 75\n97 80\n89 78\n72 10\n95 15\n106 6\n107 5\n86 9\n",
"1\n7 4\n",
"48\n992 1\n992 992\n991 1\n991 991\n992 3\n992 990\n991 3\n991 989\n992 5\n992 988\n991 5\n991 987\n992 7\n992 986\n991 7\n991 985\n992 9\n992 984\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 119\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 357\n158 85\n449 447\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"46\n63 1\n63 63\n123 1\n123 123\n63 2\n63 62\n123 2\n123 122\n63 3\n63 61\n123 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 7\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 4\n75 68\n108 26\n97 94\n106 5\n84 81\n68 46\n89 75\n97 80\n89 78\n72 10\n95 15\n106 6\n107 5\n86 9\n",
"1\n4 4\n",
"48\n992 1\n992 992\n991 1\n991 991\n992 3\n992 990\n991 3\n991 989\n992 5\n992 988\n991 5\n991 987\n992 7\n992 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 119\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 357\n158 85\n449 447\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n\n7\n\n1\n\n1\n\n1\n\n0\n\n1\n",
"1\n\n8\n\n1\n\n1\n\n1\n\n0\n\n1\n",
"1\n6 0\n",
"1\n\n8\n\n1\n\n1\n\n2\n\n0\n\n1\n",
"1\n5 0\n",
"1\n5 1\n",
"46\n63 1\n10 63\n123 1\n123 123\n63 3\n63 62\n123 2\n123 122\n63 3\n63 61\n1 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 7\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 2\n75 68\n108 26\n97 94\n106 5\n84 81\n68 46\n89 75\n97 80\n39 78\n72 10\n95 15\n106 6\n107 5\n86 9\n",
"1\n10 0\n",
"1\n\n8\n\n1\n\n2\n\n2\n\n-1\n\n0\n",
"1\n3 -1\n",
"1\n\n6\n\n1\n\n1\n\n0\n\n-1\n\n0\n",
"1\n0 -1\n",
"1\n-1 -2\n",
"1\n1 -1\n",
"1\n\n9\n\n1\n\n-1\n\n0\n\n0\n\n0\n",
"1\n\n9\n\n1\n\n-1\n\n1\n\n0\n\n0\n",
"1\n2 -2\n",
"1\n\n13\n\n0\n\n-1\n\n1\n\n-1\n\n-1\n",
"1\n\n13\n\n-1\n\n-1\n\n2\n\n-1\n\n-2\n",
"1\n\n21\n\n-1\n\n-2\n\n2\n\n-1\n\n1\n",
"1\n-2 -5\n",
"1\n\n37\n\n-1\n\n-2\n\n2\n\n-2\n\n1\n",
"1\n\n58\n\n-1\n\n-2\n\n2\n\n-2\n\n1\n",
"1\n\n80\n\n-1\n\n-2\n\n2\n\n-2\n\n1\n",
"1\n\n80\n\n-1\n\n-2\n\n2\n\n-2\n\n0\n",
"1\n2 1\n",
"1\n4 1\n",
"1\n3 1\n",
"1\n17 0\n",
"1\n15 -1\n",
"1\n19 -1\n",
"1\n21 -1\n",
"1\n24 -1\n",
"1\n43 -1\n",
"1\n16 -1\n",
"1\n20 -1\n",
"1\n-3 0\n",
"1\n-6 0\n",
"1\n-4 0\n",
"1\n-8 -1\n",
"1\n-11 -1\n",
"1\n-18 -1\n",
"1\n-23 -1\n",
"1\n-28 -1\n",
"1\n-35 -1\n",
"1\n-68 1\n",
"1\n-5 -2\n",
"1\n-7 -1\n",
"1\n-12 -1\n",
"1\n-9 -2\n",
"1\n-10 -2\n",
"1\n-24 -2\n",
"1\n-15 -2\n",
"1\n\n7\n\n0\n\n-2\n\n-6\n\n-9\n\n0\n",
"1\n11 -7\n",
"1\n22 -7\n",
"1\n23 -1\n",
"1\n15 1\n",
"1\n11 1\n",
"1\n-14 0\n",
"1\n-16 0\n",
"1\n-25 3\n",
"1\n-39 5\n",
"1\n-70 5\n",
"1\n-30 10\n",
"1\n-17 4\n",
"1\n-19 4\n",
"46\n63 1\n63 63\n123 1\n123 123\n63 2\n63 62\n123 2\n123 122\n63 3\n63 61\n123 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 7\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 2\n75 68\n108 26\n97 94\n106 5\n84 81\n68 46\n89 75\n97 80\n89 78\n72 10\n95 15\n106 6\n107 5\n86 9\n",
"1\n4 0\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n991 3\n991 989\n992 5\n992 988\n991 5\n991 987\n992 7\n992 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 119\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 357\n158 85\n449 447\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"46\n63 1\n63 63\n123 1\n123 123\n63 3\n63 62\n123 2\n123 122\n63 3\n63 61\n123 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 7\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 2\n75 68\n108 26\n97 94\n106 5\n84 81\n68 46\n89 75\n97 80\n89 78\n72 10\n95 15\n106 6\n107 5\n86 9\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n991 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n992 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 119\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 357\n158 85\n449 447\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"46\n63 1\n10 63\n123 1\n123 123\n63 3\n63 62\n123 2\n123 122\n63 3\n63 61\n123 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 7\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 2\n75 68\n108 26\n97 94\n106 5\n84 81\n68 46\n89 75\n97 80\n89 78\n72 10\n95 15\n106 6\n107 5\n86 9\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n991 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n992 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 26\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 357\n158 85\n449 447\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n\n8\n\n1\n\n1\n\n2\n\n0\n\n0\n",
"46\n63 1\n10 63\n123 1\n123 123\n63 3\n63 62\n123 2\n123 122\n63 3\n63 61\n123 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 7\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 2\n75 68\n108 26\n97 94\n106 5\n84 81\n68 46\n89 75\n97 80\n39 78\n72 10\n95 15\n106 6\n107 5\n86 9\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n991 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n992 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 26\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 447\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n\n8\n\n1\n\n1\n\n2\n\n-1\n\n0\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n991 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 26\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 447\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n10 -1\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 26\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 447\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n\n8\n\n1\n\n0\n\n2\n\n-1\n\n0\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n936 935\n938 937\n939 938\n399 6\n825 824\n199 26\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 251\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n\n8\n\n1\n\n1\n\n0\n\n-1\n\n0\n",
"1\n4 -1\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n421 935\n938 937\n939 938\n399 6\n825 824\n199 26\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 251\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n421 935\n938 1372\n939 938\n399 6\n825 824\n199 26\n776 776\n672 131\n376 371\n599 321\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 251\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n\n6\n\n1\n\n0\n\n0\n\n-1\n\n0\n",
"1\n0 -2\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n421 935\n938 1372\n939 938\n399 6\n825 824\n199 26\n776 776\n672 131\n376 371\n599 30\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 251\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n\n6\n\n1\n\n-1\n\n0\n\n-1\n\n0\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n991 985\n992 9\n992 140\n991 9\n991 983\n421 935\n938 1372\n939 938\n399 6\n825 824\n199 26\n776 776\n672 86\n376 371\n599 30\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 251\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n\n6\n\n1\n\n-1\n\n0\n\n0\n\n0\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n1100 985\n992 9\n992 140\n991 9\n991 983\n421 935\n938 1372\n939 938\n399 6\n825 824\n199 26\n776 776\n672 86\n376 371\n599 30\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 251\n400 329\n342 328\n706 311\n861 848\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"1\n1 -2\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n1100 985\n992 9\n992 140\n991 9\n991 983\n421 935\n938 1372\n939 938\n399 6\n825 824\n199 26\n776 776\n672 86\n376 371\n599 30\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 251\n400 329\n342 328\n706 311\n861 671\n343 4\n637 15\n784 7\n272 15\n268 2\n",
"48\n992 1\n992 992\n991 1\n228 991\n992 3\n992 990\n694 3\n991 1852\n992 5\n992 988\n991 5\n991 987\n992 7\n662 986\n991 7\n1100 985\n992 9\n992 140\n991 9\n991 983\n421 935\n938 1372\n939 938\n399 12\n825 824\n199 26\n776 776\n672 86\n376 371\n599 30\n402 396\n781 717\n696 690\n827 246\n989 986\n920 802\n360 665\n158 85\n449 251\n400 329\n342 328\n706 311\n861 671\n343 4\n637 15\n784 7\n272 15\n268 2\n"
],
"output": [
"? 3\n? 6\n? 5\n? 7\n= 3\n",
"? 22\n? 53\n? 6\n? 61\n? 2\n? 59\n? 1\n= 59\n? 22\n? 53\n? 6\n? 61\n? 2\n?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= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n? 2\n? 4\n? 1\n? 5\n= 5\n",
"? 3\n? 6\n? 5\n= 1\n",
"? 331\n? 827\n? 579\n? 703\n? 641\n? 672\n? 657\n? 664\n? 661\n? 662\n= 1\n? 330\n? 825\n? 578\n? 701\n? 640\n? 670\n? 655\n? 662\n? 659\n? 660\n= 1\n? 331\n? 826\n? 579\n? 702\n? 641\n? 671\n? 656\n? 663\n? 660\n? 661\n= 1\n? 4\n? 8\n? 6\n? 7\n= 1\n? 331\n? 826\n? 579\n? 702\n? 641\n? 671\n? 656\n? 663\n? 660\n? 661\n= 1\n? 275\n? 687\n? 481\n? 584\n? 533\n? 558\n? 546\n? 552\n? 549\n? 550\n= 1\n? 134\n? 335\n? 235\n? 285\n? 260\n? 272\n? 266\n? 269\n? 268\n= 1\n? 307\n? 767\n? 537\n? 652\n? 595\n? 623\n? 609\n? 616\n? 613\n? 614\n= 1\n? 109\n? 273\n? 191\n? 232\n? 212\n? 222\n? 217\n? 219\n? 218\n= 1\n? 3\n? 6\n? 5\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2\n= 1\n? 1\n? 2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n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n",
"? 3\n? 1\n? 4\n= 4\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 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 20\n? 49\n? 5\n? 56\n? 1\n? 54\n? 2\n= 52\n",
"? 54\n? 14\n? 74\n? 4\n? 79\n? 6\n? 78\n? 7\n= 71\n",
"? 54\n? 14\n? 74\n? 4\n? 79\n? 1\n? 80\n= 80\n",
"? 1\n? 2\n= 1\n",
"? 3\n? 1\n? 2\n= 1\n",
"? 1\n? 3\n? 2\n= 1\n",
"? 12\n? 3\n? 16\n? 1\n? 17\n= 17\n",
"? 5\n? 13\n? 1\n? 15\n= 15\n",
"? 13\n? 3\n? 18\n? 1\n? 19\n= 19\n",
"? 15\n? 4\n? 20\n? 1\n? 21\n= 21\n",
"? 16\n? 4\n? 22\n? 1\n? 24\n= 24\n",
"? 15\n? 37\n? 4\n? 42\n? 1\n? 43\n= 43\n",
"? 11\n? 3\n? 15\n? 1\n? 16\n= 16\n",
"? 14\n? 4\n? 19\n? 1\n? 20\n= 20\n",
"? -3\n= 1\n",
"? -6\n= 1\n",
"? -4\n= 1\n",
"? -8\n= 1\n",
"? -11\n= 1\n",
"? -18\n= 1\n",
"? -23\n= 1\n",
"? -28\n= 1\n",
"? -35\n= 1\n",
"? -68\n= 1\n",
"? -5\n= 1\n",
"? -7\n= 1\n",
"? -12\n= 1\n",
"? -9\n= 1\n",
"? -10\n= 1\n",
"? -24\n= 1\n",
"? -15\n= 1\n",
"? 5\n? 1\n? 7\n= 7\n",
"? 4\n? 10\n? 1\n? 11\n= 11\n",
"? 15\n? 4\n? 21\n? 1\n? 22\n= 22\n",
"? 16\n? 4\n? 22\n? 1\n? 23\n= 23\n",
"? 5\n? 13\n? 9\n? 11\n? 12\n= 1\n",
"? 4\n? 10\n? 7\n? 9\n? 8\n= 1\n",
"? -14\n= 1\n",
"? -16\n= 1\n",
"? -25\n= 1\n",
"? -39\n= 1\n",
"? -70\n= 1\n",
"? -30\n= 1\n",
"? -17\n= 1\n",
"? -19\n= 1\n",
"? 21\n? 53\n? 5\n? 61\n? 1\n? 59\n? 2\n? 60\n? 3\n? 62\n= 60\n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n= 5\n? 4\n? 1\n? 5\n= 5\n",
"? 3\n? 1\n? 4\n= 4\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 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\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\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= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n=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n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n? 4\n? 1\n? 5\n= 5\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 3\n? 7\n? 5\n? 8\n= 4\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 4\n? 9\n? 1\n? 10\n= 10\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 3\n? 7\n? 1\n? 8\n= 8\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 3\n? 7\n? 5\n? 8\n= 4\n",
"? 3\n? 1\n? 4\n= 4\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 4\n? 1\n? 6\n= 6\n",
"? 0\n= 1\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 4\n? 1\n? 6\n= 6\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 4\n? 1\n? 6\n= 6\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 1\n= 1\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n",
"? 331\n? 827\n? 83\n? 951\n? 21\n? 920\n? 5\n? 928\n? 1\n? 930\n= 930\n? 330\n? 825\n? 82\n? 949\n? 20\n? 980\n? 5\n? 988\n? 1\n? 990\n= 990\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 3\n? 8\n? 1\n? 9\n= 9\n? 330\n? 826\n? 82\n? 950\n? 20\n? 981\n? 5\n? 989\n? 1\n? 991\n= 991\n? 275\n? 687\n? 69\n? 790\n? 17\n? 816\n? 4\n? 822\n? 1\n? 824\n= 824\n? 268\n? 67\n? 369\n? 17\n? 394\n? 4\n? 400\n? 1\n? 402\n= 402\n? 307\n? 767\n? 77\n? 882\n? 19\n? 911\n? 5\n? 918\n? 1\n? 920\n= 920\n? 219\n? 55\n? 301\n? 14\n? 322\n? 4\n? 327\n? 1\n? 328\n= 328\n? 5\n? 1\n? 7\n= 7\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n? 1\n? 2\n= 2\n"
]
} | 2CODEFORCES
|
1408_A. Circle Coloring_1227 | You are given three sequences: a_1, a_2, β¦, a_n; b_1, b_2, β¦, b_n; c_1, c_2, β¦, c_n.
For each i, a_i β b_i, a_i β c_i, b_i β c_i.
Find a sequence p_1, p_2, β¦, p_n, that satisfy the following conditions:
* p_i β \\{a_i, b_i, c_i\}
* p_i β p_{(i mod n) + 1}.
In other words, for each element, you need to choose one of the three possible values, such that no two adjacent elements (where we consider elements i,i+1 adjacent for i<n and also elements 1 and n) will have equal value.
It can be proved that in the given constraints solution always exists. You don't need to minimize/maximize anything, you need to find any proper sequence.
Input
The first line of input contains one integer t (1 β€ t β€ 100): the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 100): the number of elements in the given sequences.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 100).
The third line contains n integers b_1, b_2, β¦, b_n (1 β€ b_i β€ 100).
The fourth line contains n integers c_1, c_2, β¦, c_n (1 β€ c_i β€ 100).
It is guaranteed that a_i β b_i, a_i β c_i, b_i β c_i for all i.
Output
For each test case, print n integers: p_1, p_2, β¦, p_n (p_i β \\{a_i, b_i, c_i\}, p_i β p_{i mod n + 1}).
If there are several solutions, you can print any.
Example
Input
5
3
1 1 1
2 2 2
3 3 3
4
1 2 1 2
2 1 2 1
3 4 3 4
7
1 3 3 1 1 1 1
2 4 4 3 2 2 4
4 2 2 2 4 4 2
3
1 2 1
2 3 3
3 1 2
10
1 1 1 2 2 2 3 3 3 1
2 2 2 3 3 3 1 1 1 2
3 3 3 1 1 1 2 2 2 3
Output
1 2 3
1 2 1 2
1 3 4 3 2 4 2
1 3 2
1 2 3 1 2 3 1 2 3 2
Note
In the first test case p = [1, 2, 3].
It is a correct answer, because:
* p_1 = 1 = a_1, p_2 = 2 = b_2, p_3 = 3 = c_3
* p_1 β p_2 , p_2 β p_3 , p_3 β p_1
All possible correct answers to this test case are: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1].
In the second test case p = [1, 2, 1, 2].
In this sequence p_1 = a_1, p_2 = a_2, p_3 = a_3, p_4 = a_4. Also we can see, that no two adjacent elements of the sequence are equal.
In the third test case p = [1, 3, 4, 3, 2, 4, 2].
In this sequence p_1 = a_1, p_2 = a_2, p_3 = b_3, p_4 = b_4, p_5 = b_5, p_6 = c_6, p_7 = c_7. Also we can see, that no two adjacent elements of the sequence are equal. | for _ in xrange(input()):
n = input()
a = map(int, raw_input().strip().split())
b = map(int, raw_input().strip().split())
c = map(int, raw_input().strip().split())
p = [0] * n
p[0] = a[0]
for i in xrange(1, n - 1):
if a[i] != p[i - 1]: p[i] = a[i]
elif b[i] != p[i - 1]: p[i] = b[i]
elif c[i] != p[i - 1]: p[i] = c[i]
if a[n - 1] not in [p[n - 2], p[0]]: p[n - 1] = a[n - 1]
elif b[n - 1] not in [p[n - 2], p[0]]: p[n - 1] = b[n - 1]
elif c[n - 1] not in [p[n - 2], p[0]]: p[n - 1] = c[n - 1]
print ' '.join(map(str, p))
| 1Python2
| {
"input": [
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 4 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3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1 2 1 2 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 2 3 1 3 2 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 ",
"1 2 3 1 2 1 3 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 "
]
} | 2CODEFORCES
|
1408_A. Circle Coloring_1228 | You are given three sequences: a_1, a_2, β¦, a_n; b_1, b_2, β¦, b_n; c_1, c_2, β¦, c_n.
For each i, a_i β b_i, a_i β c_i, b_i β c_i.
Find a sequence p_1, p_2, β¦, p_n, that satisfy the following conditions:
* p_i β \\{a_i, b_i, c_i\}
* p_i β p_{(i mod n) + 1}.
In other words, for each element, you need to choose one of the three possible values, such that no two adjacent elements (where we consider elements i,i+1 adjacent for i<n and also elements 1 and n) will have equal value.
It can be proved that in the given constraints solution always exists. You don't need to minimize/maximize anything, you need to find any proper sequence.
Input
The first line of input contains one integer t (1 β€ t β€ 100): the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 100): the number of elements in the given sequences.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 100).
The third line contains n integers b_1, b_2, β¦, b_n (1 β€ b_i β€ 100).
The fourth line contains n integers c_1, c_2, β¦, c_n (1 β€ c_i β€ 100).
It is guaranteed that a_i β b_i, a_i β c_i, b_i β c_i for all i.
Output
For each test case, print n integers: p_1, p_2, β¦, p_n (p_i β \\{a_i, b_i, c_i\}, p_i β p_{i mod n + 1}).
If there are several solutions, you can print any.
Example
Input
5
3
1 1 1
2 2 2
3 3 3
4
1 2 1 2
2 1 2 1
3 4 3 4
7
1 3 3 1 1 1 1
2 4 4 3 2 2 4
4 2 2 2 4 4 2
3
1 2 1
2 3 3
3 1 2
10
1 1 1 2 2 2 3 3 3 1
2 2 2 3 3 3 1 1 1 2
3 3 3 1 1 1 2 2 2 3
Output
1 2 3
1 2 1 2
1 3 4 3 2 4 2
1 3 2
1 2 3 1 2 3 1 2 3 2
Note
In the first test case p = [1, 2, 3].
It is a correct answer, because:
* p_1 = 1 = a_1, p_2 = 2 = b_2, p_3 = 3 = c_3
* p_1 β p_2 , p_2 β p_3 , p_3 β p_1
All possible correct answers to this test case are: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1].
In the second test case p = [1, 2, 1, 2].
In this sequence p_1 = a_1, p_2 = a_2, p_3 = a_3, p_4 = a_4. Also we can see, that no two adjacent elements of the sequence are equal.
In the third test case p = [1, 3, 4, 3, 2, 4, 2].
In this sequence p_1 = a_1, p_2 = a_2, p_3 = b_3, p_4 = b_4, p_5 = b_5, p_6 = c_6, p_7 = c_7. Also we can see, that no two adjacent elements of the sequence are equal. | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
void solve();
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t;
cin >> t;
while (t--) {
solve();
cout << "\n";
}
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}
long long ceils(long long x, long long y) { return x / y + ((x % y) != 0); }
long long gcd(long long a, long long b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void solve() {
long long n;
cin >> n;
long long a[n], b[n], c[n];
for (long long i = 0; i < n; i++) cin >> a[i];
for (long long i = 0; i < n; i++) cin >> b[i];
for (long long i = 0; i < n; i++) cin >> c[i];
long long ans[n];
ans[0] = a[0];
for (long long i = 1; i < n; i++) {
ans[i] = a[i];
if (ans[i] == ans[i - 1]) ans[i] = b[i];
if (ans[i] == ans[i - 1]) ans[i] = c[i];
}
long long ok = 0;
for (long long i = 1; i < n; i++) {
if (ans[i] == ans[i - 1]) {
ok = 1;
break;
}
}
if (ok) {
ans[0] = b[0];
for (long long i = 1; i < n; i++) {
ans[i] = b[i];
if (ans[i] == ans[i - 1]) ans[i] = a[i];
if (ans[i] == ans[i - 1]) ans[i] = c[i];
}
ok = 0;
for (long long i = 1; i < n; i++) {
if (ans[i] == ans[i - 1]) {
ok = 1;
break;
}
}
}
if (ok) {
ans[0] = c[0];
for (long long i = 1; i < n; i++) {
ans[i] = c[i];
if (ans[i] == ans[i - 1]) ans[i] = a[i];
if (ans[i] == ans[i - 1]) ans[i] = b[i];
}
ok = 0;
for (long long i = 1; i < n; i++) {
if (ans[i] == ans[i - 1]) {
ok = 1;
break;
}
}
}
if (ans[n - 1] == ans[0]) {
if (ans[n - 1] == a[n - 1]) {
if (ans[n - 2] == b[n - 1])
ans[n - 1] = c[n - 1];
else
ans[n - 1] = b[n - 1];
} else if (ans[n - 1] == b[n - 1]) {
if (ans[n - 2] == a[n - 1])
ans[n - 1] = c[n - 1];
else
ans[n - 1] = a[n - 1];
} else {
if (ans[n - 2] == b[n - 1])
ans[n - 1] = a[n - 1];
else
ans[n - 1] = b[n - 1];
}
}
for (long long i = 0; i < n; i++) cout << ans[i] << " ";
}
| 2C++
| {
"input": [
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10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 2 1 2 3 2 4 3 1 3 1 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 6 2 1 2 3 2 4 6 3 1 3 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 2 3 1 3 2 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 ",
"1 2 3 1 2 1 3 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 "
]
} | 2CODEFORCES
|
1408_A. Circle Coloring_1229 | You are given three sequences: a_1, a_2, β¦, a_n; b_1, b_2, β¦, b_n; c_1, c_2, β¦, c_n.
For each i, a_i β b_i, a_i β c_i, b_i β c_i.
Find a sequence p_1, p_2, β¦, p_n, that satisfy the following conditions:
* p_i β \\{a_i, b_i, c_i\}
* p_i β p_{(i mod n) + 1}.
In other words, for each element, you need to choose one of the three possible values, such that no two adjacent elements (where we consider elements i,i+1 adjacent for i<n and also elements 1 and n) will have equal value.
It can be proved that in the given constraints solution always exists. You don't need to minimize/maximize anything, you need to find any proper sequence.
Input
The first line of input contains one integer t (1 β€ t β€ 100): the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 100): the number of elements in the given sequences.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 100).
The third line contains n integers b_1, b_2, β¦, b_n (1 β€ b_i β€ 100).
The fourth line contains n integers c_1, c_2, β¦, c_n (1 β€ c_i β€ 100).
It is guaranteed that a_i β b_i, a_i β c_i, b_i β c_i for all i.
Output
For each test case, print n integers: p_1, p_2, β¦, p_n (p_i β \\{a_i, b_i, c_i\}, p_i β p_{i mod n + 1}).
If there are several solutions, you can print any.
Example
Input
5
3
1 1 1
2 2 2
3 3 3
4
1 2 1 2
2 1 2 1
3 4 3 4
7
1 3 3 1 1 1 1
2 4 4 3 2 2 4
4 2 2 2 4 4 2
3
1 2 1
2 3 3
3 1 2
10
1 1 1 2 2 2 3 3 3 1
2 2 2 3 3 3 1 1 1 2
3 3 3 1 1 1 2 2 2 3
Output
1 2 3
1 2 1 2
1 3 4 3 2 4 2
1 3 2
1 2 3 1 2 3 1 2 3 2
Note
In the first test case p = [1, 2, 3].
It is a correct answer, because:
* p_1 = 1 = a_1, p_2 = 2 = b_2, p_3 = 3 = c_3
* p_1 β p_2 , p_2 β p_3 , p_3 β p_1
All possible correct answers to this test case are: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1].
In the second test case p = [1, 2, 1, 2].
In this sequence p_1 = a_1, p_2 = a_2, p_3 = a_3, p_4 = a_4. Also we can see, that no two adjacent elements of the sequence are equal.
In the third test case p = [1, 3, 4, 3, 2, 4, 2].
In this sequence p_1 = a_1, p_2 = a_2, p_3 = b_3, p_4 = b_4, p_5 = b_5, p_6 = c_6, p_7 = c_7. Also we can see, that no two adjacent elements of the sequence are equal. | import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
try:
for _ in range(int(input())):
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=[]
ans.append(a[0])
for i in range(1,n):
tem=[a[i],b[i],c[i]]
for j in tem:
if j!=ans[-1]:
ans.append(j)
break
if ans[0]==ans[-1]:
ans.pop()
tem=[a[-1],b[-1],c[-1]]
#print(tem)
for i in tem:
if i!=ans[0] and i!=ans[-1]:
ans.append(i)
break
print(*ans)
else:
print(*ans)
except EOFError as e:
print(e)
| 3Python3
| {
"input": [
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\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 3 2 ",
"1 2 3 2 1 2 1 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 ",
"1 2 3 1 2 1 2 1 3 5 1 2 1 4 1 2 3 1 2 1 2 3 2 3 1 3 2 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 6 1 2 1 2 3 4 3 1 3 2 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 6 2 1 2 3 2 4 3 1 3 1 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 6 2 1 2 3 2 4 6 3 1 3 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 2 3 1 3 2 ",
"1 2 3 1 2 1 2 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 ",
"1 2 3 1 2 1 3 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 "
]
} | 2CODEFORCES
|
1408_A. Circle Coloring_1230 | You are given three sequences: a_1, a_2, β¦, a_n; b_1, b_2, β¦, b_n; c_1, c_2, β¦, c_n.
For each i, a_i β b_i, a_i β c_i, b_i β c_i.
Find a sequence p_1, p_2, β¦, p_n, that satisfy the following conditions:
* p_i β \\{a_i, b_i, c_i\}
* p_i β p_{(i mod n) + 1}.
In other words, for each element, you need to choose one of the three possible values, such that no two adjacent elements (where we consider elements i,i+1 adjacent for i<n and also elements 1 and n) will have equal value.
It can be proved that in the given constraints solution always exists. You don't need to minimize/maximize anything, you need to find any proper sequence.
Input
The first line of input contains one integer t (1 β€ t β€ 100): the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 100): the number of elements in the given sequences.
The second line contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 100).
The third line contains n integers b_1, b_2, β¦, b_n (1 β€ b_i β€ 100).
The fourth line contains n integers c_1, c_2, β¦, c_n (1 β€ c_i β€ 100).
It is guaranteed that a_i β b_i, a_i β c_i, b_i β c_i for all i.
Output
For each test case, print n integers: p_1, p_2, β¦, p_n (p_i β \\{a_i, b_i, c_i\}, p_i β p_{i mod n + 1}).
If there are several solutions, you can print any.
Example
Input
5
3
1 1 1
2 2 2
3 3 3
4
1 2 1 2
2 1 2 1
3 4 3 4
7
1 3 3 1 1 1 1
2 4 4 3 2 2 4
4 2 2 2 4 4 2
3
1 2 1
2 3 3
3 1 2
10
1 1 1 2 2 2 3 3 3 1
2 2 2 3 3 3 1 1 1 2
3 3 3 1 1 1 2 2 2 3
Output
1 2 3
1 2 1 2
1 3 4 3 2 4 2
1 3 2
1 2 3 1 2 3 1 2 3 2
Note
In the first test case p = [1, 2, 3].
It is a correct answer, because:
* p_1 = 1 = a_1, p_2 = 2 = b_2, p_3 = 3 = c_3
* p_1 β p_2 , p_2 β p_3 , p_3 β p_1
All possible correct answers to this test case are: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1].
In the second test case p = [1, 2, 1, 2].
In this sequence p_1 = a_1, p_2 = a_2, p_3 = a_3, p_4 = a_4. Also we can see, that no two adjacent elements of the sequence are equal.
In the third test case p = [1, 3, 4, 3, 2, 4, 2].
In this sequence p_1 = a_1, p_2 = a_2, p_3 = b_3, p_4 = b_4, p_5 = b_5, p_6 = c_6, p_7 = c_7. Also we can see, that no two adjacent elements of the sequence are equal. | import java.util.*;
public class S{
static int[][][] res = new int[21][21][21];
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int q = in.nextInt();
int a[] = new int[105];
int b[] = new int[105];
int c[] = new int[105];
int r[] = new int[105];
for(int t = 0; t < q; t++){
int n = in.nextInt();
for(int i = 0; i < n; i++){
a[i] = in.nextInt();
}
for(int i = 0; i < n; i++){
b[i] = in.nextInt();
}
for(int i = 0; i < n; i++){
c[i] = in.nextInt();
}
r[0] = a[0];
for(int i = 1; i < n - 1; i++){
if(a[i] != r[i - 1]){
r[i] = a[i];
}else if(b[i] != r[i - 1]){
r[i] = b[i];
}else{
r[i] = c[i];
}
}
if(a[n - 1] != r[0] && a[n - 1] != r[n - 2]){
r[n - 1] = a[n - 1];
// System.out.println("1");
}else if(b[n - 1] != r[0] && b[n - 1] != r[n - 2]){
r[n - 1] = b[n - 1];
// System.out.println("2");
}else{
r[n - 1] = c[n - 1];
// System.out.println("3");
}
for(int i = 0; i < n; i++){
System.out.print(r[i] + " ");
}
System.out.println();
}
}
}
| 4JAVA
| {
"input": [
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 4 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 3\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 3 2 2 4 4 2\n3\n1 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 1 2 3 4 3 1 3 2 ",
"1 2 3 1 2 1 3 1 3 4 1 2 1 4 1 2 3 1 2 1 2 3 4 3 1 3 2 "
]
} | 2CODEFORCES
|
1428_D. Bouncing Boomerangs_1231 | To improve the boomerang throwing skills of the animals, Zookeeper has set up an n Γ n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right.
For each column, Zookeeper will throw a boomerang from the bottom of the column (below the grid) upwards. When the boomerang hits any target, it will bounce off, make a 90 degree turn to the right and fly off in a straight line in its new direction. The boomerang can hit multiple targets and does not stop until it leaves the grid.
<image>
In the above example, n=6 and the black crosses are the targets. The boomerang in column 1 (blue arrows) bounces 2 times while the boomerang in column 3 (red arrows) bounces 3 times.
The boomerang in column i hits exactly a_i targets before flying out of the grid. It is known that a_i β€ 3.
However, Zookeeper has lost the original positions of the targets. Thus, he asks you to construct a valid configuration of targets that matches the number of hits for each column, or tell him that no such configuration exists. If multiple valid configurations exist, you may print any of them.
Input
The first line contains a single integer n (1 β€ n β€ 10^5).
The next line contains n integers a_1,a_2,β¦,a_n (0 β€ a_i β€ 3).
Output
If no configuration of targets exist, print -1.
Otherwise, on the first line print a single integer t (0 β€ t β€ 2n): the number of targets in your configuration.
Then print t lines with two spaced integers each per line. Each line should contain two integers r and c (1 β€ r,c β€ n), where r is the target's row and c is the target's column. All targets should be different.
Every row and every column in your configuration should have at most two targets each.
Examples
Input
6
2 0 3 0 1 1
Output
5
2 1
2 5
3 3
3 6
5 6
Input
1
0
Output
0
Input
6
3 2 2 2 1 1
Output
-1
Note
For the first test, the answer configuration is the same as in the picture from the statement.
For the second test, the boomerang is not supposed to hit anything, so we can place 0 targets.
For the third test, the following configuration of targets matches the number of hits, but is not allowed as row 3 has 4 targets.
<image>
It can be shown for this test case that no valid configuration of targets will result in the given number of target hits. | import atexit, io, sys
# A stream implementation using an in-memory bytes
# buffer. It inherits BufferedIOBase.
buffer = io.BytesIO()
sys.stdout = buffer
# print via here
@atexit.register
def write():
sys.__stdout__.write(buffer.getvalue())
for _ in range(1):
n=input()
a=map(int,raw_input().split())
ok=1
v=[]
v2=[]
ans=[]
for i in range(n-1,-1,-1):
if a[i]:
if a[i]==1:
ans.append([i+1,i+1])
v.append(i)
if a[i]==2:
if len(v)==0:
ok=0;break
else:
p=v.pop()
ans.append([p+1,i+1])
v2.append(i)
if a[i]==3:
if (len(v)+len(v2))==0:
ok=0;break
elif len(v2):
p=v2.pop()
ans.append([i+1,i+1])
ans.append([i+1,p+1])
v2.append(i)
else:
p=v.pop()
ans.append([i+1,i+1])
ans.append([i+1,p+1])
v2.append(i)
if ok:
print len(ans)
for i in ans:
print i[0],i[1]
else:
print -1
| 1Python2
| {
"input": [
"1\n0\n",
"6\n2 0 3 0 1 1\n",
"6\n3 2 2 2 1 1\n",
"6\n0 1 3 2 1 2\n",
"4\n1 2 3 1\n",
"4\n1 1 1 2\n",
"4\n3 3 2 1\n",
"4\n1 2 1 1\n",
"4\n1 1 2 1\n",
"1\n3\n",
"6\n1 3 2 0 3 1\n",
"4\n1 3 2 1\n",
"4\n2 3 1 1\n",
"4\n3 1 1 1\n",
"4\n3 2 3 1\n",
"4\n2 1 2 1\n",
"6\n0 2 1 3 2 3\n",
"4\n1 3 3 1\n",
"4\n2 3 3 1\n",
"4\n1 2 1 2\n",
"6\n2 0 3 2 1 0\n",
"4\n2 1 1 2\n",
"4\n2 3 2 1\n",
"4\n2 2 1 2\n",
"6\n0 0 1 3 2 3\n",
"4\n2 1 2 3\n",
"4\n2 2 2 1\n",
"6\n0 0 0 2 1 0\n",
"1\n1\n",
"4\n2 1 3 1\n",
"5\n2 3 1 2 1\n",
"4\n3 1 0 0\n",
"6\n0 2 3 1 0 0\n",
"4\n3 1 2 1\n",
"4\n3 2 1 1\n",
"3\n3 2 1\n",
"4\n3 1 3 1\n",
"6\n0 1 2 0 3 1\n",
"4\n1 3 1 1\n",
"4\n1 2 2 1\n",
"4\n1 1 1 1\n",
"4\n2 2 1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
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n"
]
} | 2CODEFORCES
|
1428_D. Bouncing Boomerangs_1232 | To improve the boomerang throwing skills of the animals, Zookeeper has set up an n Γ n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right.
For each column, Zookeeper will throw a boomerang from the bottom of the column (below the grid) upwards. When the boomerang hits any target, it will bounce off, make a 90 degree turn to the right and fly off in a straight line in its new direction. The boomerang can hit multiple targets and does not stop until it leaves the grid.
<image>
In the above example, n=6 and the black crosses are the targets. The boomerang in column 1 (blue arrows) bounces 2 times while the boomerang in column 3 (red arrows) bounces 3 times.
The boomerang in column i hits exactly a_i targets before flying out of the grid. It is known that a_i β€ 3.
However, Zookeeper has lost the original positions of the targets. Thus, he asks you to construct a valid configuration of targets that matches the number of hits for each column, or tell him that no such configuration exists. If multiple valid configurations exist, you may print any of them.
Input
The first line contains a single integer n (1 β€ n β€ 10^5).
The next line contains n integers a_1,a_2,β¦,a_n (0 β€ a_i β€ 3).
Output
If no configuration of targets exist, print -1.
Otherwise, on the first line print a single integer t (0 β€ t β€ 2n): the number of targets in your configuration.
Then print t lines with two spaced integers each per line. Each line should contain two integers r and c (1 β€ r,c β€ n), where r is the target's row and c is the target's column. All targets should be different.
Every row and every column in your configuration should have at most two targets each.
Examples
Input
6
2 0 3 0 1 1
Output
5
2 1
2 5
3 3
3 6
5 6
Input
1
0
Output
0
Input
6
3 2 2 2 1 1
Output
-1
Note
For the first test, the answer configuration is the same as in the picture from the statement.
For the second test, the boomerang is not supposed to hit anything, so we can place 0 targets.
For the third test, the following configuration of targets matches the number of hits, but is not allowed as row 3 has 4 targets.
<image>
It can be shown for this test case that no valid configuration of targets will result in the given number of target hits. | #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ii = pair<int, int>;
template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
bool done_something = false;
stringstream res;
res << "[";
for (; begin_iter != end_iter and counter; ++begin_iter) {
done_something = true;
counter--;
res << *begin_iter << ", ";
}
string str = res.str();
if (done_something) {
str.pop_back();
str.pop_back();
}
str += "]";
return str;
}
vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
vector<int> ord(size);
for (int i = 0; i < size; i++) ord[i] = i;
sort(ord.begin(), ord.end(), compare);
return ord;
}
template <typename T>
bool MinPlace(T& a, const T& b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T>
bool MaxPlace(T& a, const T& b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T>& p) {
out << "{" << p.first << ", " << p.second << "}";
return out;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
out << "[";
for (int i = 0; i < (int)v.size(); i++) {
out << v[i];
if (i != (int)v.size() - 1) out << ", ";
}
out << "]";
return out;
}
template <class TH>
void _dbg(const char* name, TH val) {
clog << name << ": " << val << endl;
}
template <class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
while (*names != ',') clog << *names++;
clog << ": " << curr_val << ", ";
_dbg(names + 1, vals...);
}
const int MAXN = 1e5 + 100;
int a[MAXN];
vector<ii> ans;
int n;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
int h_free = 1;
vector<ii> req[4];
for (int i = 1; i <= n; i++) {
if (a[i] == 0) continue;
if (a[i] == 1) {
if (req[2].empty() && req[3].empty()) {
ans.emplace_back(i, h_free);
h_free++;
} else {
ii cima;
if (req[2].empty()) {
cima = req[3].back();
req[3].pop_back();
} else {
cima = req[2].back();
req[2].pop_back();
}
ans.emplace_back(i, cima.second);
if (cima.first == 3) {
ans.emplace_back(i, h_free);
h_free++;
}
}
} else {
if (!req[3].empty()) {
auto cima = req[3].back();
req[3].pop_back();
ans.emplace_back(i, cima.second);
}
ans.emplace_back(i, h_free);
req[a[i]].emplace_back(a[i], h_free);
h_free++;
}
}
if (!req[2].empty() || !req[3].empty()) {
cout << -1 << '\n';
} else {
cout << ans.size() << '\n';
for (auto el : ans) cout << el.second << " " << el.first << '\n';
}
return 0;
}
| 2C++
| {
"input": [
"1\n0\n",
"6\n2 0 3 0 1 1\n",
"6\n3 2 2 2 1 1\n",
"6\n0 1 3 2 1 2\n",
"4\n1 2 3 1\n",
"4\n1 1 1 2\n",
"4\n3 3 2 1\n",
"4\n1 2 1 1\n",
"4\n1 1 2 1\n",
"1\n3\n",
"6\n1 3 2 0 3 1\n",
"4\n1 3 2 1\n",
"4\n2 3 1 1\n",
"4\n3 1 1 1\n",
"4\n3 2 3 1\n",
"4\n2 1 2 1\n",
"6\n0 2 1 3 2 3\n",
"4\n1 3 3 1\n",
"4\n2 3 3 1\n",
"4\n1 2 1 2\n",
"6\n2 0 3 2 1 0\n",
"4\n2 1 1 2\n",
"4\n2 3 2 1\n",
"4\n2 2 1 2\n",
"6\n0 0 1 3 2 3\n",
"4\n2 1 2 3\n",
"4\n2 2 2 1\n",
"6\n0 0 0 2 1 0\n",
"1\n1\n",
"4\n2 1 3 1\n",
"5\n2 3 1 2 1\n",
"4\n3 1 0 0\n",
"6\n0 2 3 1 0 0\n",
"4\n3 1 2 1\n",
"4\n3 2 1 1\n",
"3\n3 2 1\n",
"4\n3 1 3 1\n",
"6\n0 1 2 0 3 1\n",
"4\n1 3 1 1\n",
"4\n1 2 2 1\n",
"4\n1 1 1 1\n",
"4\n2 2 1 1\n",
"4\n2 1 1 1\n",
"6\n0 0 2 1 0 3\n",
"4\n1 1 1 3\n",
"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
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n"
]
} | 2CODEFORCES
|
1428_D. Bouncing Boomerangs_1233 | To improve the boomerang throwing skills of the animals, Zookeeper has set up an n Γ n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right.
For each column, Zookeeper will throw a boomerang from the bottom of the column (below the grid) upwards. When the boomerang hits any target, it will bounce off, make a 90 degree turn to the right and fly off in a straight line in its new direction. The boomerang can hit multiple targets and does not stop until it leaves the grid.
<image>
In the above example, n=6 and the black crosses are the targets. The boomerang in column 1 (blue arrows) bounces 2 times while the boomerang in column 3 (red arrows) bounces 3 times.
The boomerang in column i hits exactly a_i targets before flying out of the grid. It is known that a_i β€ 3.
However, Zookeeper has lost the original positions of the targets. Thus, he asks you to construct a valid configuration of targets that matches the number of hits for each column, or tell him that no such configuration exists. If multiple valid configurations exist, you may print any of them.
Input
The first line contains a single integer n (1 β€ n β€ 10^5).
The next line contains n integers a_1,a_2,β¦,a_n (0 β€ a_i β€ 3).
Output
If no configuration of targets exist, print -1.
Otherwise, on the first line print a single integer t (0 β€ t β€ 2n): the number of targets in your configuration.
Then print t lines with two spaced integers each per line. Each line should contain two integers r and c (1 β€ r,c β€ n), where r is the target's row and c is the target's column. All targets should be different.
Every row and every column in your configuration should have at most two targets each.
Examples
Input
6
2 0 3 0 1 1
Output
5
2 1
2 5
3 3
3 6
5 6
Input
1
0
Output
0
Input
6
3 2 2 2 1 1
Output
-1
Note
For the first test, the answer configuration is the same as in the picture from the statement.
For the second test, the boomerang is not supposed to hit anything, so we can place 0 targets.
For the third test, the following configuration of targets matches the number of hits, but is not allowed as row 3 has 4 targets.
<image>
It can be shown for this test case that no valid configuration of targets will result in the given number of target hits. | n, *a = map(int, open(0).read().split())
now = 1
heights = [[] for _ in range(n)]
st0 = []
st1 = []
failed = False
for i in range(n - 1, -1, -1):
if a[i] == 1:
heights[i].append(now)
st0.append((now, i))
now += 1
elif a[i] == 2:
if len(st0):
h, j = st0.pop()
heights[i].append(h)
st1.append(i)
else:
failed = True
break
elif a[i] == 3:
if len(st1):
j = st1.pop()
heights[i].append(now)
heights[j].append(now)
st1.append(i)
now += 1
elif len(st0):
_, j = st0.pop()
heights[i].append(now)
heights[j].append(now)
st1.append(i)
now += 1
else:
failed = True
break
if failed:
print("-1")
else:
ans = []
for i in range(n):
for j in heights[i]:
ans.append(str(n - j + 1) + ' ' + str(i + 1))
print(len(ans), *ans, sep='\n') | 3Python3
| {
"input": [
"1\n0\n",
"6\n2 0 3 0 1 1\n",
"6\n3 2 2 2 1 1\n",
"6\n0 1 3 2 1 2\n",
"4\n1 2 3 1\n",
"4\n1 1 1 2\n",
"4\n3 3 2 1\n",
"4\n1 2 1 1\n",
"4\n1 1 2 1\n",
"1\n3\n",
"6\n1 3 2 0 3 1\n",
"4\n1 3 2 1\n",
"4\n2 3 1 1\n",
"4\n3 1 1 1\n",
"4\n3 2 3 1\n",
"4\n2 1 2 1\n",
"6\n0 2 1 3 2 3\n",
"4\n1 3 3 1\n",
"4\n2 3 3 1\n",
"4\n1 2 1 2\n",
"6\n2 0 3 2 1 0\n",
"4\n2 1 1 2\n",
"4\n2 3 2 1\n",
"4\n2 2 1 2\n",
"6\n0 0 1 3 2 3\n",
"4\n2 1 2 3\n",
"4\n2 2 2 1\n",
"6\n0 0 0 2 1 0\n",
"1\n1\n",
"4\n2 1 3 1\n",
"5\n2 3 1 2 1\n",
"4\n3 1 0 0\n",
"6\n0 2 3 1 0 0\n",
"4\n3 1 2 1\n",
"4\n3 2 1 1\n",
"3\n3 2 1\n",
"4\n3 1 3 1\n",
"6\n0 1 2 0 3 1\n",
"4\n1 3 1 1\n",
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1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n"
]
} | 2CODEFORCES
|
1428_D. Bouncing Boomerangs_1234 | To improve the boomerang throwing skills of the animals, Zookeeper has set up an n Γ n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right.
For each column, Zookeeper will throw a boomerang from the bottom of the column (below the grid) upwards. When the boomerang hits any target, it will bounce off, make a 90 degree turn to the right and fly off in a straight line in its new direction. The boomerang can hit multiple targets and does not stop until it leaves the grid.
<image>
In the above example, n=6 and the black crosses are the targets. The boomerang in column 1 (blue arrows) bounces 2 times while the boomerang in column 3 (red arrows) bounces 3 times.
The boomerang in column i hits exactly a_i targets before flying out of the grid. It is known that a_i β€ 3.
However, Zookeeper has lost the original positions of the targets. Thus, he asks you to construct a valid configuration of targets that matches the number of hits for each column, or tell him that no such configuration exists. If multiple valid configurations exist, you may print any of them.
Input
The first line contains a single integer n (1 β€ n β€ 10^5).
The next line contains n integers a_1,a_2,β¦,a_n (0 β€ a_i β€ 3).
Output
If no configuration of targets exist, print -1.
Otherwise, on the first line print a single integer t (0 β€ t β€ 2n): the number of targets in your configuration.
Then print t lines with two spaced integers each per line. Each line should contain two integers r and c (1 β€ r,c β€ n), where r is the target's row and c is the target's column. All targets should be different.
Every row and every column in your configuration should have at most two targets each.
Examples
Input
6
2 0 3 0 1 1
Output
5
2 1
2 5
3 3
3 6
5 6
Input
1
0
Output
0
Input
6
3 2 2 2 1 1
Output
-1
Note
For the first test, the answer configuration is the same as in the picture from the statement.
For the second test, the boomerang is not supposed to hit anything, so we can place 0 targets.
For the third test, the following configuration of targets matches the number of hits, but is not allowed as row 3 has 4 targets.
<image>
It can be shown for this test case that no valid configuration of targets will result in the given number of target hits. | /*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, Iβm sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
Shining through the city with a little funk and soul
*/
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;
public class x1428D
{
public static void main(String hi[]) throws Exception
{
BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(infile.readLine());
int N = Integer.parseInt(st.nextToken());
int[] arr = new int[N+1];
st = new StringTokenizer(infile.readLine());
for(int i=0; i < N; i++)
arr[i+1] = Integer.parseInt(st.nextToken());
ArrayDeque<Integer>[] q = new ArrayDeque[4];
for(int i=1; i <= 3; i++)
q[i] = new ArrayDeque<Integer>();
ArrayList<Point> points = new ArrayList<Point>();
for(int c=N; c >= 1; c--)
{
if(arr[c] == 1)
{
q[1].add(c);
points.add(new Point(c, c));
}
else if(arr[c] == 2)
{
if(q[1].size() == 0)
shaft();
int right = q[1].poll();
points.add(new Point(right, c));
q[2].add(c);
}
else if(arr[c] == 3)
{
if(q[3].size() > 0)
{
int prev = q[3].poll();
points.add(new Point(c, c));
points.add(new Point(c, prev));
q[3].add(c);
}
else if(q[2].size() > 0)
{
int prev = q[2].poll();
points.add(new Point(c, c));
points.add(new Point(c, prev));
q[3].add(c);
}
else if(q[1].size() > 0)
{
int prev = q[1].poll();
points.add(new Point(c, c));
points.add(new Point(c, prev));
q[3].add(c);
}
else
shaft();
}
}
StringBuilder sb = new StringBuilder(points.size()+"\n");
for(Point p: points)
sb.append(p.r+" "+p.c+"\n");
System.out.print(sb);
}
public static void shaft()
{
System.out.println(-1);
System.exit(0);
}
}
class Point
{
public int r;
public int c;
public Point(int a, int b)
{
r = a;
c = b;
}
} | 4JAVA
| {
"input": [
"1\n0\n",
"6\n2 0 3 0 1 1\n",
"6\n3 2 2 2 1 1\n",
"6\n0 1 3 2 1 2\n",
"4\n1 2 3 1\n",
"4\n1 1 1 2\n",
"4\n3 3 2 1\n",
"4\n1 2 1 1\n",
"4\n1 1 2 1\n",
"1\n3\n",
"6\n1 3 2 0 3 1\n",
"4\n1 3 2 1\n",
"4\n2 3 1 1\n",
"4\n3 1 1 1\n",
"4\n3 2 3 1\n",
"4\n2 1 2 1\n",
"6\n0 2 1 3 2 3\n",
"4\n1 3 3 1\n",
"4\n2 3 3 1\n",
"4\n1 2 1 2\n",
"6\n2 0 3 2 1 0\n",
"4\n2 1 1 2\n",
"4\n2 3 2 1\n",
"4\n2 2 1 2\n",
"6\n0 0 1 3 2 3\n",
"4\n2 1 2 3\n",
"4\n2 2 2 1\n",
"6\n0 0 0 2 1 0\n",
"1\n1\n",
"4\n2 1 3 1\n",
"5\n2 3 1 2 1\n",
"4\n3 1 0 0\n",
"6\n0 2 3 1 0 0\n",
"4\n3 1 2 1\n",
"4\n3 2 1 1\n",
"3\n3 2 1\n",
"4\n3 1 3 1\n",
"6\n0 1 2 0 3 1\n",
"4\n1 3 1 1\n",
"4\n1 2 2 1\n",
"4\n1 1 1 1\n",
"4\n2 2 1 1\n",
"4\n2 1 1 1\n",
"6\n0 0 2 1 0 3\n",
"4\n1 1 1 3\n",
"4\n2 2 3 1\n",
"6\n0 2 0 3 1 0\n",
"1\n2\n",
"4\n3 1 1 2\n",
"4\n3 2 2 1\n",
"4\n3 3 3 1\n",
"4\n3 3 1 1\n",
"6\n2 0 3 0 1 1\n",
"4\n1 1 3 1\n",
"6\n0 1 3 2 2 2\n",
"4\n0 2 1 1\n",
"4\n3 1 1 0\n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]
} | 2CODEFORCES
|
1451_D. Circle Game_1235 | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the player must ensure that the token stays within a (Euclidean) distance d from (0,0).
In other words, if after a move the coordinates of the token are (p,q), then p^2 + q^2 β€ d^2 must hold.
The game ends when a player is unable to make a move. It can be shown that the game will end in a finite number of moves. If both players play optimally, determine who will win.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The only line of each test case contains two space separated integers d (1 β€ d β€ 10^5) and k (1 β€ k β€ d).
Output
For each test case, if Ashish wins the game, print "Ashish", otherwise print "Utkarsh" (without the quotes).
Example
Input
5
2 1
5 2
10 3
25 4
15441 33
Output
Utkarsh
Ashish
Utkarsh
Utkarsh
Ashish
Note
In the first test case, one possible sequence of moves can be
(0, 0) \xrightarrow{Ashish } (0, 1) \xrightarrow{Utkarsh } (0, 2).
Ashish has no moves left, so Utkarsh wins.
<image> | from __future__ import division
from sys import stdin, stdout
# from fractions import gcd
# from math import *
# from operator import mul
# from functools import reduce
# from copy import copy
from collections import deque, defaultdict, Counter
rstr = lambda: stdin.readline().strip()
rstrs = lambda: [str(x) for x in stdin.readline().split()]
rint = lambda: int(stdin.readline())
rints = lambda: [int(x) for x in stdin.readline().split()]
rstr_2d = lambda n: [rstr() for _ in range(n)]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
pr = lambda args, sep: stdout.write(sep.join(map(str, args)) + '\n')
out = []
for _ in range(int(input())):
d, k = rints()
cur, ans = 0, 0
a = [i for i in range(k, d, k)]
d, be, en = pow(d, 2), 1, len(a)
while be <= en:
md = (be + en) >> 1
val = pow(a[md - 1], 2) << 1
if val <= d:
cur = a[md - 1]
be = md + 1
else:
en = md - 1
if pow(cur + k, 2) + pow(cur, 2) <= d:
ans = 1
out.append(['Utkarsh', 'Ashish'][ans])
pr(out, '\n')
| 1Python2
| {
"input": [
"5\n2 1\n5 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 57\n",
"5\n2 1\n9 1\n11 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n46 4\n25479 47\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 47\n",
"5\n4 1\n4 1\n10 3\n55 4\n25479 53\n",
"5\n4 1\n4 1\n20 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n20 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n31 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n58 4\n15769 53\n",
"5\n4 1\n2 2\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n14195 53\n",
"5\n16 1\n2 2\n9 4\n58 19\n14195 55\n",
"5\n22 1\n2 2\n9 1\n26 20\n14195 66\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 36\n",
"5\n2 1\n5 2\n10 4\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 60\n",
"5\n2 1\n9 1\n11 3\n33 4\n25479 57\n",
"5\n2 1\n4 1\n15 3\n55 4\n25479 47\n",
"5\n3 1\n6 1\n20 3\n55 4\n25479 53\n",
"5\n4 2\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n11 1\n11 3\n58 4\n15769 53\n",
"5\n2 1\n3 1\n10 3\n46 7\n25479 33\n",
"5\n2 1\n9 1\n10 3\n9 4\n33374 57\n",
"5\n4 1\n4 1\n20 3\n55 4\n768 53\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 22\n",
"5\n2 2\n9 2\n11 3\n33 4\n25479 57\n",
"5\n2 1\n5 1\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n25479 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n15441 60\n",
"5\n2 1\n4 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 2\n10 3\n38 4\n15441 60\n",
"5\n2 1\n1 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n20 3\n25 4\n25479 57\n",
"5\n2 1\n9 2\n20 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n2 1\n11 3\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 2\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n12041 53\n",
"5\n4 1\n2 1\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 7\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n12663 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n12663 53\n",
"5\n8 1\n2 2\n9 1\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 2\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 6\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n107 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 66\n",
"5\n16 1\n2 2\n9 1\n26 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n26 20\n14195 36\n",
"5\n22 1\n2 2\n9 1\n27 20\n14195 36\n",
"5\n2 1\n4 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n9 1\n10 3\n24 4\n25479 33\n",
"5\n2 1\n3 1\n10 3\n46 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n47353 33\n",
"5\n2 1\n5 3\n10 3\n25 4\n15441 60\n",
"5\n2 1\n5 1\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n33374 57\n",
"5\n2 1\n8 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 2\n10 3\n38 4\n2501 60\n",
"5\n2 1\n1 1\n10 3\n25 5\n25479 33\n",
"5\n2 1\n4 1\n10 1\n46 4\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n25479 57\n",
"5\n2 1\n6 2\n20 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 76\n",
"5\n4 1\n4 1\n20 3\n55 4\n3193 53\n",
"5\n4 1\n12 1\n11 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n22 4\n25479 53\n",
"5\n4 1\n2 1\n11 3\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n58 4\n16476 53\n",
"5\n4 1\n2 1\n11 4\n58 8\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n21825 53\n",
"5\n4 2\n2 1\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n12041 53\n",
"5\n6 1\n2 2\n9 1\n58 4\n12041 53\n",
"5\n4 1\n2 1\n9 1\n58 7\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n15256 53\n",
"5\n4 1\n2 2\n9 1\n61 10\n12663 53\n",
"5\n8 1\n3 2\n9 1\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 10\n14637 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n1308 53\n",
"5\n8 1\n2 2\n9 1\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 2\n41 19\n14195 55\n",
"5\n16 1\n2 2\n9 4\n58 19\n14195 5\n",
"5\n16 1\n2 2\n9 6\n58 19\n7829 55\n",
"5\n16 1\n2 2\n9 1\n37 19\n14195 55\n",
"5\n16 1\n3 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 1\n14195 55\n",
"5\n16 1\n2 2\n9 1\n39 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 91\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 34\n",
"5\n16 1\n2 2\n9 1\n44 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n27 20\n19573 36\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 31\n",
"5\n3 1\n4 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n9 1\n20 3\n24 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n47353 25\n",
"5\n2 2\n5 1\n10 3\n46 3\n25479 33\n",
"5\n2 1\n8 1\n10 4\n46 4\n25479 33\n",
"5\n3 1\n1 1\n10 3\n25 5\n25479 33\n",
"5\n2 1\n9 2\n11 3\n33 4\n25479 57\n",
"5\n2 1\n4 1\n10 1\n46 5\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n46349 57\n",
"5\n2 1\n6 2\n20 3\n25 7\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n30159 76\n",
"5\n3 1\n6 1\n20 3\n55 4\n50296 53\n",
"5\n4 2\n12 1\n11 3\n55 4\n25479 53\n",
"5\n8 1\n6 1\n11 3\n22 4\n25479 53\n",
"5\n4 4\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n11 1\n6 3\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 2\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n58 2\n16476 53\n",
"5\n2 1\n2 1\n11 4\n58 8\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n5538 53\n",
"5\n4 2\n2 1\n11 1\n58 8\n12041 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n12041 54\n",
"5\n6 1\n2 2\n9 1\n58 4\n4776 53\n",
"5\n4 1\n2 1\n17 1\n58 7\n12041 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n15256 53\n",
"5\n7 1\n2 2\n9 1\n61 10\n12663 53\n",
"5\n8 1\n6 2\n9 1\n58 10\n14195 53\n",
"5\n11 1\n2 2\n9 2\n58 10\n14637 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n1308 39\n",
"5\n8 1\n2 2\n9 1\n58 19\n7578 55\n",
"5\n16 1\n2 2\n9 2\n41 13\n14195 55\n",
"5\n16 1\n2 2\n9 4\n112 19\n14195 5\n",
"5\n10 1\n3 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 2\n14195 55\n",
"5\n16 1\n2 2\n15 1\n39 19\n14195 55\n",
"5\n16 1\n4 2\n9 1\n34 20\n14195 91\n",
"5\n16 1\n2 2\n9 1\n34 32\n14195 34\n",
"5\n16 1\n2 2\n9 1\n25 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n27 20\n19573 32\n",
"5\n3 1\n4 2\n10 3\n25 4\n7906 33\n",
"5\n2 1\n1 1\n20 3\n24 4\n25479 33\n",
"5\n1 1\n3 1\n10 3\n46 7\n25479 33\n",
"5\n1 1\n9 2\n10 3\n46 6\n47353 25\n",
"5\n2 2\n5 2\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n9 4\n33374 5\n",
"5\n2 1\n8 1\n10 4\n46 4\n25479 58\n",
"5\n3 1\n1 1\n10 3\n22 5\n25479 33\n",
"5\n2 1\n4 1\n10 1\n46 9\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n46349 19\n",
"5\n2 1\n4 1\n10 3\n57 4\n30159 76\n",
"5\n3 1\n6 1\n20 1\n55 4\n50296 53\n",
"5\n4 2\n12 1\n11 3\n14 4\n25479 53\n",
"5\n8 1\n6 1\n11 4\n22 4\n25479 53\n",
"5\n4 4\n6 1\n11 4\n58 4\n25479 53\n",
"5\n4 1\n11 1\n4 3\n58 4\n15769 53\n",
"5\n4 2\n2 1\n11 2\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n21 2\n16476 53\n",
"5\n4 1\n3 1\n11 4\n58 4\n5538 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n15275 54\n",
"5\n6 1\n3 2\n9 1\n58 4\n4776 53\n",
"5\n4 2\n2 1\n17 1\n58 7\n12041 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n10904 53\n",
"5\n7 1\n2 2\n9 1\n61 19\n12663 53\n",
"5\n8 1\n6 2\n13 1\n58 10\n14195 53\n",
"5\n11 1\n2 2\n9 2\n58 10\n14637 38\n",
"5\n8 1\n2 2\n9 2\n58 19\n2050 39\n",
"5\n16 1\n2 2\n9 2\n41 24\n14195 55\n",
"5\n16 1\n2 2\n9 4\n112 19\n2238 5\n",
"5\n16 2\n2 2\n9 1\n56 2\n14195 55\n",
"5\n16 1\n4 2\n9 1\n34 20\n27663 91\n",
"5\n16 1\n4 2\n9 1\n34 32\n14195 34\n",
"5\n16 1\n2 2\n9 1\n36 20\n14195 66\n",
"5\n28 1\n2 2\n9 1\n27 20\n19573 32\n",
"5\n22 1\n2 1\n9 1\n35 20\n14195 22\n",
"5\n3 1\n4 2\n10 2\n25 4\n7906 33\n",
"5\n2 1\n1 1\n20 3\n19 4\n25479 33\n",
"5\n1 1\n3 1\n10 3\n84 7\n25479 33\n",
"5\n2 2\n3 2\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n13 3\n9 4\n33374 5\n",
"5\n2 1\n8 1\n10 4\n46 4\n50507 58\n",
"5\n2 2\n9 2\n11 3\n33 4\n39110 57\n",
"5\n2 1\n4 1\n10 1\n46 11\n25479 47\n",
"5\n2 1\n9 1\n20 5\n22 4\n46349 19\n",
"5\n2 1\n4 2\n10 3\n57 4\n30159 76\n",
"5\n3 1\n6 1\n22 1\n55 4\n50296 53\n",
"5\n4 1\n12 1\n11 3\n14 4\n25479 53\n",
"5\n4 4\n6 1\n11 4\n58 2\n25479 53\n",
"5\n4 2\n2 1\n6 2\n58 4\n15769 7\n",
"5\n1 1\n2 1\n11 2\n21 2\n16476 53\n"
],
"output": [
"\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nAshish\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n"
]
} | 2CODEFORCES
|
1451_D. Circle Game_1236 | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the player must ensure that the token stays within a (Euclidean) distance d from (0,0).
In other words, if after a move the coordinates of the token are (p,q), then p^2 + q^2 β€ d^2 must hold.
The game ends when a player is unable to make a move. It can be shown that the game will end in a finite number of moves. If both players play optimally, determine who will win.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The only line of each test case contains two space separated integers d (1 β€ d β€ 10^5) and k (1 β€ k β€ d).
Output
For each test case, if Ashish wins the game, print "Ashish", otherwise print "Utkarsh" (without the quotes).
Example
Input
5
2 1
5 2
10 3
25 4
15441 33
Output
Utkarsh
Ashish
Utkarsh
Utkarsh
Ashish
Note
In the first test case, one possible sequence of moves can be
(0, 0) \xrightarrow{Ashish } (0, 1) \xrightarrow{Utkarsh } (0, 2).
Ashish has no moves left, so Utkarsh wins.
<image> | #include<iostream>
#include<cstdio>
#include<cmath>
#define int long long
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
signed main()
{
int t,d,k;
bool flag;
t=read();
for(int greg=1;greg<=t;greg++)
{
d=read();
k=read();
flag=false;
for(int i=0;i<=d/k;i++)
{
if((long long)(sqrt((d*d)/(k*k)-i*i))==i)
{
flag=true;
break;
}
}
if(flag==false)printf("Ashish\n");
else printf("Utkarsh\n");
}
return 0;
}
| 2C++
| {
"input": [
"5\n2 1\n5 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 57\n",
"5\n2 1\n9 1\n11 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n46 4\n25479 47\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 47\n",
"5\n4 1\n4 1\n10 3\n55 4\n25479 53\n",
"5\n4 1\n4 1\n20 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n20 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n31 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n58 4\n15769 53\n",
"5\n4 1\n2 2\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n14195 53\n",
"5\n16 1\n2 2\n9 4\n58 19\n14195 55\n",
"5\n22 1\n2 2\n9 1\n26 20\n14195 66\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 36\n",
"5\n2 1\n5 2\n10 4\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 60\n",
"5\n2 1\n9 1\n11 3\n33 4\n25479 57\n",
"5\n2 1\n4 1\n15 3\n55 4\n25479 47\n",
"5\n3 1\n6 1\n20 3\n55 4\n25479 53\n",
"5\n4 2\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n11 1\n11 3\n58 4\n15769 53\n",
"5\n2 1\n3 1\n10 3\n46 7\n25479 33\n",
"5\n2 1\n9 1\n10 3\n9 4\n33374 57\n",
"5\n4 1\n4 1\n20 3\n55 4\n768 53\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 22\n",
"5\n2 2\n9 2\n11 3\n33 4\n25479 57\n",
"5\n2 1\n5 1\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n25479 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n15441 60\n",
"5\n2 1\n4 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 2\n10 3\n38 4\n15441 60\n",
"5\n2 1\n1 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n20 3\n25 4\n25479 57\n",
"5\n2 1\n9 2\n20 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n2 1\n11 3\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 2\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n12041 53\n",
"5\n4 1\n2 1\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 7\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n12663 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n12663 53\n",
"5\n8 1\n2 2\n9 1\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 2\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 6\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n107 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 66\n",
"5\n16 1\n2 2\n9 1\n26 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n26 20\n14195 36\n",
"5\n22 1\n2 2\n9 1\n27 20\n14195 36\n",
"5\n2 1\n4 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n9 1\n10 3\n24 4\n25479 33\n",
"5\n2 1\n3 1\n10 3\n46 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n47353 33\n",
"5\n2 1\n5 3\n10 3\n25 4\n15441 60\n",
"5\n2 1\n5 1\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n33374 57\n",
"5\n2 1\n8 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 2\n10 3\n38 4\n2501 60\n",
"5\n2 1\n1 1\n10 3\n25 5\n25479 33\n",
"5\n2 1\n4 1\n10 1\n46 4\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n25479 57\n",
"5\n2 1\n6 2\n20 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 76\n",
"5\n4 1\n4 1\n20 3\n55 4\n3193 53\n",
"5\n4 1\n12 1\n11 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n22 4\n25479 53\n",
"5\n4 1\n2 1\n11 3\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n58 4\n16476 53\n",
"5\n4 1\n2 1\n11 4\n58 8\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n21825 53\n",
"5\n4 2\n2 1\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n12041 53\n",
"5\n6 1\n2 2\n9 1\n58 4\n12041 53\n",
"5\n4 1\n2 1\n9 1\n58 7\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n15256 53\n",
"5\n4 1\n2 2\n9 1\n61 10\n12663 53\n",
"5\n8 1\n3 2\n9 1\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 10\n14637 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n1308 53\n",
"5\n8 1\n2 2\n9 1\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 2\n41 19\n14195 55\n",
"5\n16 1\n2 2\n9 4\n58 19\n14195 5\n",
"5\n16 1\n2 2\n9 6\n58 19\n7829 55\n",
"5\n16 1\n2 2\n9 1\n37 19\n14195 55\n",
"5\n16 1\n3 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 1\n14195 55\n",
"5\n16 1\n2 2\n9 1\n39 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 91\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 34\n",
"5\n16 1\n2 2\n9 1\n44 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n27 20\n19573 36\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 31\n",
"5\n3 1\n4 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n9 1\n20 3\n24 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n47353 25\n",
"5\n2 2\n5 1\n10 3\n46 3\n25479 33\n",
"5\n2 1\n8 1\n10 4\n46 4\n25479 33\n",
"5\n3 1\n1 1\n10 3\n25 5\n25479 33\n",
"5\n2 1\n9 2\n11 3\n33 4\n25479 57\n",
"5\n2 1\n4 1\n10 1\n46 5\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n46349 57\n",
"5\n2 1\n6 2\n20 3\n25 7\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n30159 76\n",
"5\n3 1\n6 1\n20 3\n55 4\n50296 53\n",
"5\n4 2\n12 1\n11 3\n55 4\n25479 53\n",
"5\n8 1\n6 1\n11 3\n22 4\n25479 53\n",
"5\n4 4\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n11 1\n6 3\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 2\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n58 2\n16476 53\n",
"5\n2 1\n2 1\n11 4\n58 8\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n5538 53\n",
"5\n4 2\n2 1\n11 1\n58 8\n12041 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n12041 54\n",
"5\n6 1\n2 2\n9 1\n58 4\n4776 53\n",
"5\n4 1\n2 1\n17 1\n58 7\n12041 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n15256 53\n",
"5\n7 1\n2 2\n9 1\n61 10\n12663 53\n",
"5\n8 1\n6 2\n9 1\n58 10\n14195 53\n",
"5\n11 1\n2 2\n9 2\n58 10\n14637 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n1308 39\n",
"5\n8 1\n2 2\n9 1\n58 19\n7578 55\n",
"5\n16 1\n2 2\n9 2\n41 13\n14195 55\n",
"5\n16 1\n2 2\n9 4\n112 19\n14195 5\n",
"5\n10 1\n3 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 2\n14195 55\n",
"5\n16 1\n2 2\n15 1\n39 19\n14195 55\n",
"5\n16 1\n4 2\n9 1\n34 20\n14195 91\n",
"5\n16 1\n2 2\n9 1\n34 32\n14195 34\n",
"5\n16 1\n2 2\n9 1\n25 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n27 20\n19573 32\n",
"5\n3 1\n4 2\n10 3\n25 4\n7906 33\n",
"5\n2 1\n1 1\n20 3\n24 4\n25479 33\n",
"5\n1 1\n3 1\n10 3\n46 7\n25479 33\n",
"5\n1 1\n9 2\n10 3\n46 6\n47353 25\n",
"5\n2 2\n5 2\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n9 4\n33374 5\n",
"5\n2 1\n8 1\n10 4\n46 4\n25479 58\n",
"5\n3 1\n1 1\n10 3\n22 5\n25479 33\n",
"5\n2 1\n4 1\n10 1\n46 9\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n46349 19\n",
"5\n2 1\n4 1\n10 3\n57 4\n30159 76\n",
"5\n3 1\n6 1\n20 1\n55 4\n50296 53\n",
"5\n4 2\n12 1\n11 3\n14 4\n25479 53\n",
"5\n8 1\n6 1\n11 4\n22 4\n25479 53\n",
"5\n4 4\n6 1\n11 4\n58 4\n25479 53\n",
"5\n4 1\n11 1\n4 3\n58 4\n15769 53\n",
"5\n4 2\n2 1\n11 2\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n21 2\n16476 53\n",
"5\n4 1\n3 1\n11 4\n58 4\n5538 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n15275 54\n",
"5\n6 1\n3 2\n9 1\n58 4\n4776 53\n",
"5\n4 2\n2 1\n17 1\n58 7\n12041 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n10904 53\n",
"5\n7 1\n2 2\n9 1\n61 19\n12663 53\n",
"5\n8 1\n6 2\n13 1\n58 10\n14195 53\n",
"5\n11 1\n2 2\n9 2\n58 10\n14637 38\n",
"5\n8 1\n2 2\n9 2\n58 19\n2050 39\n",
"5\n16 1\n2 2\n9 2\n41 24\n14195 55\n",
"5\n16 1\n2 2\n9 4\n112 19\n2238 5\n",
"5\n16 2\n2 2\n9 1\n56 2\n14195 55\n",
"5\n16 1\n4 2\n9 1\n34 20\n27663 91\n",
"5\n16 1\n4 2\n9 1\n34 32\n14195 34\n",
"5\n16 1\n2 2\n9 1\n36 20\n14195 66\n",
"5\n28 1\n2 2\n9 1\n27 20\n19573 32\n",
"5\n22 1\n2 1\n9 1\n35 20\n14195 22\n",
"5\n3 1\n4 2\n10 2\n25 4\n7906 33\n",
"5\n2 1\n1 1\n20 3\n19 4\n25479 33\n",
"5\n1 1\n3 1\n10 3\n84 7\n25479 33\n",
"5\n2 2\n3 2\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n13 3\n9 4\n33374 5\n",
"5\n2 1\n8 1\n10 4\n46 4\n50507 58\n",
"5\n2 2\n9 2\n11 3\n33 4\n39110 57\n",
"5\n2 1\n4 1\n10 1\n46 11\n25479 47\n",
"5\n2 1\n9 1\n20 5\n22 4\n46349 19\n",
"5\n2 1\n4 2\n10 3\n57 4\n30159 76\n",
"5\n3 1\n6 1\n22 1\n55 4\n50296 53\n",
"5\n4 1\n12 1\n11 3\n14 4\n25479 53\n",
"5\n4 4\n6 1\n11 4\n58 2\n25479 53\n",
"5\n4 2\n2 1\n6 2\n58 4\n15769 7\n",
"5\n1 1\n2 1\n11 2\n21 2\n16476 53\n"
],
"output": [
"\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nAshish\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n"
]
} | 2CODEFORCES
|
1451_D. Circle Game_1237 | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the player must ensure that the token stays within a (Euclidean) distance d from (0,0).
In other words, if after a move the coordinates of the token are (p,q), then p^2 + q^2 β€ d^2 must hold.
The game ends when a player is unable to make a move. It can be shown that the game will end in a finite number of moves. If both players play optimally, determine who will win.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The only line of each test case contains two space separated integers d (1 β€ d β€ 10^5) and k (1 β€ k β€ d).
Output
For each test case, if Ashish wins the game, print "Ashish", otherwise print "Utkarsh" (without the quotes).
Example
Input
5
2 1
5 2
10 3
25 4
15441 33
Output
Utkarsh
Ashish
Utkarsh
Utkarsh
Ashish
Note
In the first test case, one possible sequence of moves can be
(0, 0) \xrightarrow{Ashish } (0, 1) \xrightarrow{Utkarsh } (0, 2).
Ashish has no moves left, so Utkarsh wins.
<image> | import sys
input = lambda:sys.stdin.readline().strip()
t = int(input())
while t:
t-=1
d,k = map(int,input().split())
x = 0
y = 0
while 1:
if x<=y and (x+k)*(x+k)+y*y<=d*d:
x+=k
elif x>y and (y+k)*(y+k)+x*x<=d*d:
y+=k
else:
break
if x==y:
print("Utkarsh")
else:
print("Ashish")
| 3Python3
| {
"input": [
"5\n2 1\n5 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 57\n",
"5\n2 1\n9 1\n11 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n46 4\n25479 47\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 47\n",
"5\n4 1\n4 1\n10 3\n55 4\n25479 53\n",
"5\n4 1\n4 1\n20 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n20 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n31 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n58 4\n15769 53\n",
"5\n4 1\n2 2\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n14195 53\n",
"5\n16 1\n2 2\n9 4\n58 19\n14195 55\n",
"5\n22 1\n2 2\n9 1\n26 20\n14195 66\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 36\n",
"5\n2 1\n5 2\n10 4\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 60\n",
"5\n2 1\n9 1\n11 3\n33 4\n25479 57\n",
"5\n2 1\n4 1\n15 3\n55 4\n25479 47\n",
"5\n3 1\n6 1\n20 3\n55 4\n25479 53\n",
"5\n4 2\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n11 1\n11 3\n58 4\n15769 53\n",
"5\n2 1\n3 1\n10 3\n46 7\n25479 33\n",
"5\n2 1\n9 1\n10 3\n9 4\n33374 57\n",
"5\n4 1\n4 1\n20 3\n55 4\n768 53\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 22\n",
"5\n2 2\n9 2\n11 3\n33 4\n25479 57\n",
"5\n2 1\n5 1\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n25479 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n15441 60\n",
"5\n2 1\n4 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 2\n10 3\n38 4\n15441 60\n",
"5\n2 1\n1 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n20 3\n25 4\n25479 57\n",
"5\n2 1\n9 2\n20 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n2 1\n11 3\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 2\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n12041 53\n",
"5\n4 1\n2 1\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 7\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n12663 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n12663 53\n",
"5\n8 1\n2 2\n9 1\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 2\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 6\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n107 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 66\n",
"5\n16 1\n2 2\n9 1\n26 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n26 20\n14195 36\n",
"5\n22 1\n2 2\n9 1\n27 20\n14195 36\n",
"5\n2 1\n4 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n9 1\n10 3\n24 4\n25479 33\n",
"5\n2 1\n3 1\n10 3\n46 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n47353 33\n",
"5\n2 1\n5 3\n10 3\n25 4\n15441 60\n",
"5\n2 1\n5 1\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n33374 57\n",
"5\n2 1\n8 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 2\n10 3\n38 4\n2501 60\n",
"5\n2 1\n1 1\n10 3\n25 5\n25479 33\n",
"5\n2 1\n4 1\n10 1\n46 4\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n25479 57\n",
"5\n2 1\n6 2\n20 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 76\n",
"5\n4 1\n4 1\n20 3\n55 4\n3193 53\n",
"5\n4 1\n12 1\n11 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n22 4\n25479 53\n",
"5\n4 1\n2 1\n11 3\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n58 4\n16476 53\n",
"5\n4 1\n2 1\n11 4\n58 8\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n21825 53\n",
"5\n4 2\n2 1\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n12041 53\n",
"5\n6 1\n2 2\n9 1\n58 4\n12041 53\n",
"5\n4 1\n2 1\n9 1\n58 7\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n15256 53\n",
"5\n4 1\n2 2\n9 1\n61 10\n12663 53\n",
"5\n8 1\n3 2\n9 1\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 10\n14637 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n1308 53\n",
"5\n8 1\n2 2\n9 1\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 2\n41 19\n14195 55\n",
"5\n16 1\n2 2\n9 4\n58 19\n14195 5\n",
"5\n16 1\n2 2\n9 6\n58 19\n7829 55\n",
"5\n16 1\n2 2\n9 1\n37 19\n14195 55\n",
"5\n16 1\n3 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 1\n14195 55\n",
"5\n16 1\n2 2\n9 1\n39 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 91\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 34\n",
"5\n16 1\n2 2\n9 1\n44 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n27 20\n19573 36\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 31\n",
"5\n3 1\n4 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n9 1\n20 3\n24 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n47353 25\n",
"5\n2 2\n5 1\n10 3\n46 3\n25479 33\n",
"5\n2 1\n8 1\n10 4\n46 4\n25479 33\n",
"5\n3 1\n1 1\n10 3\n25 5\n25479 33\n",
"5\n2 1\n9 2\n11 3\n33 4\n25479 57\n",
"5\n2 1\n4 1\n10 1\n46 5\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n46349 57\n",
"5\n2 1\n6 2\n20 3\n25 7\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n30159 76\n",
"5\n3 1\n6 1\n20 3\n55 4\n50296 53\n",
"5\n4 2\n12 1\n11 3\n55 4\n25479 53\n",
"5\n8 1\n6 1\n11 3\n22 4\n25479 53\n",
"5\n4 4\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n11 1\n6 3\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 2\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n58 2\n16476 53\n",
"5\n2 1\n2 1\n11 4\n58 8\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n5538 53\n",
"5\n4 2\n2 1\n11 1\n58 8\n12041 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n12041 54\n",
"5\n6 1\n2 2\n9 1\n58 4\n4776 53\n",
"5\n4 1\n2 1\n17 1\n58 7\n12041 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n15256 53\n",
"5\n7 1\n2 2\n9 1\n61 10\n12663 53\n",
"5\n8 1\n6 2\n9 1\n58 10\n14195 53\n",
"5\n11 1\n2 2\n9 2\n58 10\n14637 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n1308 39\n",
"5\n8 1\n2 2\n9 1\n58 19\n7578 55\n",
"5\n16 1\n2 2\n9 2\n41 13\n14195 55\n",
"5\n16 1\n2 2\n9 4\n112 19\n14195 5\n",
"5\n10 1\n3 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 2\n14195 55\n",
"5\n16 1\n2 2\n15 1\n39 19\n14195 55\n",
"5\n16 1\n4 2\n9 1\n34 20\n14195 91\n",
"5\n16 1\n2 2\n9 1\n34 32\n14195 34\n",
"5\n16 1\n2 2\n9 1\n25 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n27 20\n19573 32\n",
"5\n3 1\n4 2\n10 3\n25 4\n7906 33\n",
"5\n2 1\n1 1\n20 3\n24 4\n25479 33\n",
"5\n1 1\n3 1\n10 3\n46 7\n25479 33\n",
"5\n1 1\n9 2\n10 3\n46 6\n47353 25\n",
"5\n2 2\n5 2\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n9 4\n33374 5\n",
"5\n2 1\n8 1\n10 4\n46 4\n25479 58\n",
"5\n3 1\n1 1\n10 3\n22 5\n25479 33\n",
"5\n2 1\n4 1\n10 1\n46 9\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n46349 19\n",
"5\n2 1\n4 1\n10 3\n57 4\n30159 76\n",
"5\n3 1\n6 1\n20 1\n55 4\n50296 53\n",
"5\n4 2\n12 1\n11 3\n14 4\n25479 53\n",
"5\n8 1\n6 1\n11 4\n22 4\n25479 53\n",
"5\n4 4\n6 1\n11 4\n58 4\n25479 53\n",
"5\n4 1\n11 1\n4 3\n58 4\n15769 53\n",
"5\n4 2\n2 1\n11 2\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n21 2\n16476 53\n",
"5\n4 1\n3 1\n11 4\n58 4\n5538 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n15275 54\n",
"5\n6 1\n3 2\n9 1\n58 4\n4776 53\n",
"5\n4 2\n2 1\n17 1\n58 7\n12041 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n10904 53\n",
"5\n7 1\n2 2\n9 1\n61 19\n12663 53\n",
"5\n8 1\n6 2\n13 1\n58 10\n14195 53\n",
"5\n11 1\n2 2\n9 2\n58 10\n14637 38\n",
"5\n8 1\n2 2\n9 2\n58 19\n2050 39\n",
"5\n16 1\n2 2\n9 2\n41 24\n14195 55\n",
"5\n16 1\n2 2\n9 4\n112 19\n2238 5\n",
"5\n16 2\n2 2\n9 1\n56 2\n14195 55\n",
"5\n16 1\n4 2\n9 1\n34 20\n27663 91\n",
"5\n16 1\n4 2\n9 1\n34 32\n14195 34\n",
"5\n16 1\n2 2\n9 1\n36 20\n14195 66\n",
"5\n28 1\n2 2\n9 1\n27 20\n19573 32\n",
"5\n22 1\n2 1\n9 1\n35 20\n14195 22\n",
"5\n3 1\n4 2\n10 2\n25 4\n7906 33\n",
"5\n2 1\n1 1\n20 3\n19 4\n25479 33\n",
"5\n1 1\n3 1\n10 3\n84 7\n25479 33\n",
"5\n2 2\n3 2\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n13 3\n9 4\n33374 5\n",
"5\n2 1\n8 1\n10 4\n46 4\n50507 58\n",
"5\n2 2\n9 2\n11 3\n33 4\n39110 57\n",
"5\n2 1\n4 1\n10 1\n46 11\n25479 47\n",
"5\n2 1\n9 1\n20 5\n22 4\n46349 19\n",
"5\n2 1\n4 2\n10 3\n57 4\n30159 76\n",
"5\n3 1\n6 1\n22 1\n55 4\n50296 53\n",
"5\n4 1\n12 1\n11 3\n14 4\n25479 53\n",
"5\n4 4\n6 1\n11 4\n58 2\n25479 53\n",
"5\n4 2\n2 1\n6 2\n58 4\n15769 7\n",
"5\n1 1\n2 1\n11 2\n21 2\n16476 53\n"
],
"output": [
"\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nAshish\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n"
]
} | 2CODEFORCES
|
1451_D. Circle Game_1238 | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the player must ensure that the token stays within a (Euclidean) distance d from (0,0).
In other words, if after a move the coordinates of the token are (p,q), then p^2 + q^2 β€ d^2 must hold.
The game ends when a player is unable to make a move. It can be shown that the game will end in a finite number of moves. If both players play optimally, determine who will win.
Input
The first line contains a single integer t (1 β€ t β€ 100) β the number of test cases.
The only line of each test case contains two space separated integers d (1 β€ d β€ 10^5) and k (1 β€ k β€ d).
Output
For each test case, if Ashish wins the game, print "Ashish", otherwise print "Utkarsh" (without the quotes).
Example
Input
5
2 1
5 2
10 3
25 4
15441 33
Output
Utkarsh
Ashish
Utkarsh
Utkarsh
Ashish
Note
In the first test case, one possible sequence of moves can be
(0, 0) \xrightarrow{Ashish } (0, 1) \xrightarrow{Utkarsh } (0, 2).
Ashish has no moves left, so Utkarsh wins.
<image> | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws NumberFormatException, IOException {
// Scanner sc = new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
while (t-- > 0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int d = Integer.parseInt(st.nextToken());
int k = Integer.parseInt(st.nextToken());
int x = (int) Math.sqrt(d * 1l * d / 2.0);
int z = x / k;
int xcor = z * k;
int ycor = (z + 1) * k;
boolean f =xcor*1l*xcor+ycor*1l*ycor <= d * 1l * d;
pw.println(f ? "Ashish" : "Utkarsh");
}
pw.flush();
}
static class Node implements Comparable<Node> {
double d;
int e, f;
Node(double d, int e, int f) {
this.d = d;
this.e = e;
this.f = f;
}
public int compareTo(Node n) {
return d == n.d ? 0 : d < n.d ? -1 : 1;
}
}
} | 4JAVA
| {
"input": [
"5\n2 1\n5 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 57\n",
"5\n2 1\n9 1\n11 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n46 4\n25479 47\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 47\n",
"5\n4 1\n4 1\n10 3\n55 4\n25479 53\n",
"5\n4 1\n4 1\n20 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n20 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n31 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n58 4\n15769 53\n",
"5\n4 1\n2 2\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n14195 53\n",
"5\n16 1\n2 2\n9 4\n58 19\n14195 55\n",
"5\n22 1\n2 2\n9 1\n26 20\n14195 66\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 36\n",
"5\n2 1\n5 2\n10 4\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 60\n",
"5\n2 1\n9 1\n11 3\n33 4\n25479 57\n",
"5\n2 1\n4 1\n15 3\n55 4\n25479 47\n",
"5\n3 1\n6 1\n20 3\n55 4\n25479 53\n",
"5\n4 2\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n11 1\n11 3\n58 4\n15769 53\n",
"5\n2 1\n3 1\n10 3\n46 7\n25479 33\n",
"5\n2 1\n9 1\n10 3\n9 4\n33374 57\n",
"5\n4 1\n4 1\n20 3\n55 4\n768 53\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 22\n",
"5\n2 2\n9 2\n11 3\n33 4\n25479 57\n",
"5\n2 1\n5 1\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n25479 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n15441 60\n",
"5\n2 1\n4 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 2\n10 3\n38 4\n15441 60\n",
"5\n2 1\n1 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n20 3\n25 4\n25479 57\n",
"5\n2 1\n9 2\n20 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n2 1\n11 3\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 2\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n12041 53\n",
"5\n4 1\n2 1\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 7\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n12663 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n12663 53\n",
"5\n8 1\n2 2\n9 1\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 2\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 6\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n107 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 66\n",
"5\n16 1\n2 2\n9 1\n26 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n26 20\n14195 36\n",
"5\n22 1\n2 2\n9 1\n27 20\n14195 36\n",
"5\n2 1\n4 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n9 1\n10 3\n24 4\n25479 33\n",
"5\n2 1\n3 1\n10 3\n46 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n47353 33\n",
"5\n2 1\n5 3\n10 3\n25 4\n15441 60\n",
"5\n2 1\n5 1\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n33374 57\n",
"5\n2 1\n8 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 2\n10 3\n38 4\n2501 60\n",
"5\n2 1\n1 1\n10 3\n25 5\n25479 33\n",
"5\n2 1\n4 1\n10 1\n46 4\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n25479 57\n",
"5\n2 1\n6 2\n20 3\n25 4\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n25479 76\n",
"5\n4 1\n4 1\n20 3\n55 4\n3193 53\n",
"5\n4 1\n12 1\n11 3\n55 4\n25479 53\n",
"5\n4 1\n6 1\n11 3\n22 4\n25479 53\n",
"5\n4 1\n2 1\n11 3\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n58 4\n16476 53\n",
"5\n4 1\n2 1\n11 4\n58 8\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n21825 53\n",
"5\n4 2\n2 1\n11 1\n58 4\n12041 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n12041 53\n",
"5\n6 1\n2 2\n9 1\n58 4\n12041 53\n",
"5\n4 1\n2 1\n9 1\n58 7\n12041 53\n",
"5\n4 1\n2 2\n9 1\n58 10\n15256 53\n",
"5\n4 1\n2 2\n9 1\n61 10\n12663 53\n",
"5\n8 1\n3 2\n9 1\n58 10\n14195 53\n",
"5\n8 1\n2 2\n9 2\n58 10\n14637 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n1308 53\n",
"5\n8 1\n2 2\n9 1\n58 19\n14195 55\n",
"5\n16 1\n2 2\n9 2\n41 19\n14195 55\n",
"5\n16 1\n2 2\n9 4\n58 19\n14195 5\n",
"5\n16 1\n2 2\n9 6\n58 19\n7829 55\n",
"5\n16 1\n2 2\n9 1\n37 19\n14195 55\n",
"5\n16 1\n3 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 1\n14195 55\n",
"5\n16 1\n2 2\n9 1\n39 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 91\n",
"5\n16 1\n2 2\n9 1\n34 20\n14195 34\n",
"5\n16 1\n2 2\n9 1\n44 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n27 20\n19573 36\n",
"5\n22 1\n2 1\n9 1\n27 20\n14195 31\n",
"5\n3 1\n4 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n9 1\n20 3\n24 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 6\n47353 25\n",
"5\n2 2\n5 1\n10 3\n46 3\n25479 33\n",
"5\n2 1\n8 1\n10 4\n46 4\n25479 33\n",
"5\n3 1\n1 1\n10 3\n25 5\n25479 33\n",
"5\n2 1\n9 2\n11 3\n33 4\n25479 57\n",
"5\n2 1\n4 1\n10 1\n46 5\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n46349 57\n",
"5\n2 1\n6 2\n20 3\n25 7\n25479 57\n",
"5\n2 1\n4 1\n10 3\n55 4\n30159 76\n",
"5\n3 1\n6 1\n20 3\n55 4\n50296 53\n",
"5\n4 2\n12 1\n11 3\n55 4\n25479 53\n",
"5\n8 1\n6 1\n11 3\n22 4\n25479 53\n",
"5\n4 4\n6 1\n11 3\n58 4\n25479 53\n",
"5\n4 1\n11 1\n6 3\n58 4\n15769 53\n",
"5\n4 1\n2 1\n11 2\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n58 2\n16476 53\n",
"5\n2 1\n2 1\n11 4\n58 8\n15769 53\n",
"5\n4 1\n2 1\n11 4\n58 4\n5538 53\n",
"5\n4 2\n2 1\n11 1\n58 8\n12041 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n12041 54\n",
"5\n6 1\n2 2\n9 1\n58 4\n4776 53\n",
"5\n4 1\n2 1\n17 1\n58 7\n12041 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n15256 53\n",
"5\n7 1\n2 2\n9 1\n61 10\n12663 53\n",
"5\n8 1\n6 2\n9 1\n58 10\n14195 53\n",
"5\n11 1\n2 2\n9 2\n58 10\n14637 53\n",
"5\n8 1\n2 2\n9 2\n58 19\n1308 39\n",
"5\n8 1\n2 2\n9 1\n58 19\n7578 55\n",
"5\n16 1\n2 2\n9 2\n41 13\n14195 55\n",
"5\n16 1\n2 2\n9 4\n112 19\n14195 5\n",
"5\n10 1\n3 2\n9 1\n65 19\n14195 55\n",
"5\n16 1\n2 2\n9 1\n56 2\n14195 55\n",
"5\n16 1\n2 2\n15 1\n39 19\n14195 55\n",
"5\n16 1\n4 2\n9 1\n34 20\n14195 91\n",
"5\n16 1\n2 2\n9 1\n34 32\n14195 34\n",
"5\n16 1\n2 2\n9 1\n25 20\n14195 66\n",
"5\n22 1\n2 2\n9 1\n27 20\n19573 32\n",
"5\n3 1\n4 2\n10 3\n25 4\n7906 33\n",
"5\n2 1\n1 1\n20 3\n24 4\n25479 33\n",
"5\n1 1\n3 1\n10 3\n46 7\n25479 33\n",
"5\n1 1\n9 2\n10 3\n46 6\n47353 25\n",
"5\n2 2\n5 2\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n9 4\n33374 5\n",
"5\n2 1\n8 1\n10 4\n46 4\n25479 58\n",
"5\n3 1\n1 1\n10 3\n22 5\n25479 33\n",
"5\n2 1\n4 1\n10 1\n46 9\n25479 47\n",
"5\n2 1\n9 1\n20 5\n25 4\n46349 19\n",
"5\n2 1\n4 1\n10 3\n57 4\n30159 76\n",
"5\n3 1\n6 1\n20 1\n55 4\n50296 53\n",
"5\n4 2\n12 1\n11 3\n14 4\n25479 53\n",
"5\n8 1\n6 1\n11 4\n22 4\n25479 53\n",
"5\n4 4\n6 1\n11 4\n58 4\n25479 53\n",
"5\n4 1\n11 1\n4 3\n58 4\n15769 53\n",
"5\n4 2\n2 1\n11 2\n58 4\n15769 7\n",
"5\n4 1\n2 1\n11 2\n21 2\n16476 53\n",
"5\n4 1\n3 1\n11 4\n58 4\n5538 53\n",
"5\n4 1\n2 1\n11 1\n44 4\n15275 54\n",
"5\n6 1\n3 2\n9 1\n58 4\n4776 53\n",
"5\n4 2\n2 1\n17 1\n58 7\n12041 53\n",
"5\n2 1\n2 2\n9 1\n58 10\n10904 53\n",
"5\n7 1\n2 2\n9 1\n61 19\n12663 53\n",
"5\n8 1\n6 2\n13 1\n58 10\n14195 53\n",
"5\n11 1\n2 2\n9 2\n58 10\n14637 38\n",
"5\n8 1\n2 2\n9 2\n58 19\n2050 39\n",
"5\n16 1\n2 2\n9 2\n41 24\n14195 55\n",
"5\n16 1\n2 2\n9 4\n112 19\n2238 5\n",
"5\n16 2\n2 2\n9 1\n56 2\n14195 55\n",
"5\n16 1\n4 2\n9 1\n34 20\n27663 91\n",
"5\n16 1\n4 2\n9 1\n34 32\n14195 34\n",
"5\n16 1\n2 2\n9 1\n36 20\n14195 66\n",
"5\n28 1\n2 2\n9 1\n27 20\n19573 32\n",
"5\n22 1\n2 1\n9 1\n35 20\n14195 22\n",
"5\n3 1\n4 2\n10 2\n25 4\n7906 33\n",
"5\n2 1\n1 1\n20 3\n19 4\n25479 33\n",
"5\n1 1\n3 1\n10 3\n84 7\n25479 33\n",
"5\n2 2\n3 2\n10 3\n46 3\n25479 33\n",
"5\n2 1\n9 1\n13 3\n9 4\n33374 5\n",
"5\n2 1\n8 1\n10 4\n46 4\n50507 58\n",
"5\n2 2\n9 2\n11 3\n33 4\n39110 57\n",
"5\n2 1\n4 1\n10 1\n46 11\n25479 47\n",
"5\n2 1\n9 1\n20 5\n22 4\n46349 19\n",
"5\n2 1\n4 2\n10 3\n57 4\n30159 76\n",
"5\n3 1\n6 1\n22 1\n55 4\n50296 53\n",
"5\n4 1\n12 1\n11 3\n14 4\n25479 53\n",
"5\n4 4\n6 1\n11 4\n58 2\n25479 53\n",
"5\n4 2\n2 1\n6 2\n58 4\n15769 7\n",
"5\n1 1\n2 1\n11 2\n21 2\n16476 53\n"
],
"output": [
"\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nAshish\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Ashish\nAshish\nUtkarsh\nAshish\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nAshish\nAshish\n",
"Utkarsh\nAshish\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Utkarsh\nAshish\nUtkarsh\nAshish\nUtkarsh\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Utkarsh\nUtkarsh\nAshish\nAshish\nUtkarsh\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nAshish\nAshish\n",
"Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nAshish\n",
"Ashish\nUtkarsh\nAshish\nUtkarsh\nAshish\n"
]
} | 2CODEFORCES
|
1475_D. Cleaning the Phone_1239 | Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with the following scoring system β he assigned an integer b_i to each application:
* b_i = 1 β regular application;
* b_i = 2 β important application.
According to this rating system, his phone has b_1 + b_2 + β¦ + b_n convenience points.
Polycarp believes that if he removes applications with numbers i_1, i_2, β¦, i_k, then he will free a_{i_1} + a_{i_2} + β¦ + a_{i_k} units of memory and lose b_{i_1} + b_{i_2} + β¦ + b_{i_k} convenience points.
For example, if n=5, m=7, a=[5, 3, 2, 1, 4], b=[2, 1, 1, 2, 1], then Polycarp can uninstall the following application sets (not all options are listed below):
* applications with numbers 1, 4 and 5. In this case, it will free a_1+a_4+a_5=10 units of memory and lose b_1+b_4+b_5=5 convenience points;
* applications with numbers 1 and 3. In this case, it will free a_1+a_3=7 units of memory and lose b_1+b_3=3 convenience points.
* applications with numbers 2 and 5. In this case, it will free a_2+a_5=7 memory units and lose b_2+b_5=2 convenience points.
Help Polycarp, choose a set of applications, such that if removing them will free at least m units of memory and lose the minimum number of convenience points, or indicate that such a set does not exist.
Input
The first line contains one integer t (1 β€ t β€ 10^4) β the number of test cases. Then t test cases follow.
The first line of each test case contains two integers n and m (1 β€ n β€ 2 β
10^5, 1 β€ m β€ 10^9) β the number of applications on Polycarp's phone and the number of memory units to be freed.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β the number of memory units used by applications.
The third line of each test case contains n integers b_1, b_2, β¦, b_n (1 β€ b_i β€ 2) β the convenience points of each application.
It is guaranteed that the sum of n over all test cases does not exceed 2 β
10^5.
Output
For each test case, output on a separate line:
* -1, if there is no set of applications, removing which will free at least m units of memory;
* the minimum number of convenience points that Polycarp will lose if such a set exists.
Example
Input
5
5 7
5 3 2 1 4
2 1 1 2 1
1 3
2
1
5 10
2 3 2 3 2
1 2 1 2 1
4 10
5 1 3 4
1 2 1 2
4 5
3 2 1 2
2 1 2 1
Output
2
-1
6
4
3
Note
In the first test case, it is optimal to remove applications with numbers 2 and 5, freeing 7 units of memory. b_2+b_5=2.
In the second test case, by removing the only application, Polycarp will be able to clear only 2 of memory units out of the 3 needed.
In the third test case, it is optimal to remove applications with numbers 1, 2, 3 and 4, freeing 10 units of memory. b_1+b_2+b_3+b_4=6.
In the fourth test case, it is optimal to remove applications with numbers 1, 3 and 4, freeing 12 units of memory. b_1+b_3+b_4=4.
In the fifth test case, it is optimal to remove applications with numbers 1 and 2, freeing 5 units of memory. b_1+b_2=3. | #####################################
import atexit, io, sys, collections, math, heapq, fractions
buffer = io.BytesIO()
sys.stdout = buffer
@atexit.register
def write(): sys.__stdout__.write(buffer.getvalue())
#####################################
def g(m,ais, bis):
t = [(u,v) for u,v in zip(ais,bis)]
if sum([e[0] for e in t]) < m: return -1
onepoints = [u for u,v in zip(ais,bis) if v == 1]
onepoints.sort(key = lambda x:-x)
twopoints = [u for u,v in zip(ais,bis) if v == 2]
twopoints.sort(key = lambda x:-x)
if len(onepoints) == 0 or len(twopoints) == 0:
if len(twopoints):
cumula = 0
for i in range(len(twopoints)):
cumula += twopoints[i]
if cumula >= m:
return (i+1) * 2
if len(onepoints):
cumula = 0
for i in range(len(onepoints)):
cumula += onepoints[i]
if cumula >= m:
return i+1
counttwo = 0
cumul = 0
ans = +float('inf')
c = 0
countone = 0
for j in range(len(onepoints)):
if j: onepoints[j] += onepoints[j-1]
if onepoints and onepoints[-1] >= m:
ans = min(ans, len(onepoints))
lo,hi = 0, len(onepoints)-1
while(lo < hi):
med= (lo + hi) //2
if cumul + onepoints[med] >= m:
hi = med
else:
lo = med +1
if cumul + onepoints[lo] >= m:
ans = min(ans, (2 * counttwo) + lo +1)
for e in twopoints:
counttwo += 1
cumul += e
if cumul >= m:
ans = min(ans, 2 * counttwo)
else:
lo,hi = 0, len(onepoints)-1
while(lo < hi):
med= (lo + hi) //2
if cumul + onepoints[med] >= m:
hi = med
else:
lo = med +1
if cumul + onepoints[lo] >= m:
ans = min(ans, (2 * counttwo) + lo +1)
return ans
nt = int(raw_input())
for u in range(nt):
n,m = map(int,raw_input().split())
ais = map(int, raw_input().split())
bis = map(int, raw_input().split())
print g(m,ais,bis)
| 1Python2
| {
"input": [
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n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1\n4\n4\n4\n",
"2\n",
"1\n-1\n4\n1\n2\n",
"3\n1\n1\n4\n1\n",
"2\n",
"2\n",
"2\n-1\n5\n4\n3\n",
"4\n",
"3\n",
"2\n-1\n4\n4\n2\n",
"1\n1\n3\n4\n2\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"3\n-1\n4\n4\n4\n",
"2\n",
"1\n-1\n4\n1\n2\n",
"2\n",
"4\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"2\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"3\n-1\n2\n6\n-1\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"3\n-1\n2\n6\n-1\n",
"2\n-1\n5\n3\n3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"1\n-1\n2\n-1\n-1\n"
]
} | 2CODEFORCES
|
1475_D. Cleaning the Phone_1240 | Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with the following scoring system β he assigned an integer b_i to each application:
* b_i = 1 β regular application;
* b_i = 2 β important application.
According to this rating system, his phone has b_1 + b_2 + β¦ + b_n convenience points.
Polycarp believes that if he removes applications with numbers i_1, i_2, β¦, i_k, then he will free a_{i_1} + a_{i_2} + β¦ + a_{i_k} units of memory and lose b_{i_1} + b_{i_2} + β¦ + b_{i_k} convenience points.
For example, if n=5, m=7, a=[5, 3, 2, 1, 4], b=[2, 1, 1, 2, 1], then Polycarp can uninstall the following application sets (not all options are listed below):
* applications with numbers 1, 4 and 5. In this case, it will free a_1+a_4+a_5=10 units of memory and lose b_1+b_4+b_5=5 convenience points;
* applications with numbers 1 and 3. In this case, it will free a_1+a_3=7 units of memory and lose b_1+b_3=3 convenience points.
* applications with numbers 2 and 5. In this case, it will free a_2+a_5=7 memory units and lose b_2+b_5=2 convenience points.
Help Polycarp, choose a set of applications, such that if removing them will free at least m units of memory and lose the minimum number of convenience points, or indicate that such a set does not exist.
Input
The first line contains one integer t (1 β€ t β€ 10^4) β the number of test cases. Then t test cases follow.
The first line of each test case contains two integers n and m (1 β€ n β€ 2 β
10^5, 1 β€ m β€ 10^9) β the number of applications on Polycarp's phone and the number of memory units to be freed.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β the number of memory units used by applications.
The third line of each test case contains n integers b_1, b_2, β¦, b_n (1 β€ b_i β€ 2) β the convenience points of each application.
It is guaranteed that the sum of n over all test cases does not exceed 2 β
10^5.
Output
For each test case, output on a separate line:
* -1, if there is no set of applications, removing which will free at least m units of memory;
* the minimum number of convenience points that Polycarp will lose if such a set exists.
Example
Input
5
5 7
5 3 2 1 4
2 1 1 2 1
1 3
2
1
5 10
2 3 2 3 2
1 2 1 2 1
4 10
5 1 3 4
1 2 1 2
4 5
3 2 1 2
2 1 2 1
Output
2
-1
6
4
3
Note
In the first test case, it is optimal to remove applications with numbers 2 and 5, freeing 7 units of memory. b_2+b_5=2.
In the second test case, by removing the only application, Polycarp will be able to clear only 2 of memory units out of the 3 needed.
In the third test case, it is optimal to remove applications with numbers 1, 2, 3 and 4, freeing 10 units of memory. b_1+b_2+b_3+b_4=6.
In the fourth test case, it is optimal to remove applications with numbers 1, 3 and 4, freeing 12 units of memory. b_1+b_3+b_4=4.
In the fifth test case, it is optimal to remove applications with numbers 1 and 2, freeing 5 units of memory. b_1+b_2=3. | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
void solve() {
int n, m;
cin >> n >> m;
vector<int> a, b;
vector<int> v(n);
for (int &e : v) {
cin >> e;
}
for (int &e : v) {
int x;
cin >> x;
if (x == 1) {
a.push_back(e);
} else {
b.push_back(e);
}
}
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
ll curSumA = 0;
int r = (int)b.size();
ll curSumB = accumulate(b.begin(), b.end(), 0ll);
int ans = INT_MAX;
for (int l = 0; l <= a.size(); l++) {
while (r > 0 && curSumA + curSumB - b[r - 1] >= m) {
r--;
curSumB -= b[r];
}
if (curSumB + curSumA >= m) {
ans = min(ans, 2 * r + l);
}
if (l != a.size()) {
curSumA += a[l];
}
}
cout << (ans == INT_MAX ? -1 : ans) << "\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}
| 2C++
| {
"input": [
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 17\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n2 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"5\n5 7\n5 3 2 1 2\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 2 1 1 1 6 6 17\n1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2\n",
"5\n5 7\n6 3 2 1 2\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 3 3 3\n1 1 2 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n1 1 2 1\n",
"5\n5 7\n6 3 2 1 2\n2 1 1 2 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2\n",
"3\n1\n1\n4\n2\n",
"2\n",
"3\n",
"5\n",
"2\n",
"2\n",
"2\n",
"4\n",
"2\n-1\n6\n4\n3\n",
"3\n1\n5\n4\n2\n",
"5\n",
"4\n",
"3\n",
"3\n-1\n5\n4\n3\n",
"3\n-1\n4\n4\n2\n",
"2\n-1\n4\n4\n2\n",
"1\n1\n3\n4\n2\n",
"2\n-1\n6\n3\n3\n",
"3\n",
"2\n",
"3\n",
"3\n-1\n4\n4\n4\n",
"2\n",
"1\n-1\n4\n1\n2\n",
"3\n1\n1\n4\n1\n",
"2\n",
"2\n",
"2\n-1\n5\n4\n3\n",
"4\n",
"3\n",
"2\n-1\n4\n4\n2\n",
"1\n1\n3\n4\n2\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"3\n-1\n4\n4\n4\n",
"2\n",
"1\n-1\n4\n1\n2\n",
"2\n",
"4\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"2\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"3\n-1\n2\n6\n-1\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"3\n-1\n2\n6\n-1\n",
"2\n-1\n5\n3\n3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"1\n-1\n2\n-1\n-1\n"
]
} | 2CODEFORCES
|
1475_D. Cleaning the Phone_1241 | Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with the following scoring system β he assigned an integer b_i to each application:
* b_i = 1 β regular application;
* b_i = 2 β important application.
According to this rating system, his phone has b_1 + b_2 + β¦ + b_n convenience points.
Polycarp believes that if he removes applications with numbers i_1, i_2, β¦, i_k, then he will free a_{i_1} + a_{i_2} + β¦ + a_{i_k} units of memory and lose b_{i_1} + b_{i_2} + β¦ + b_{i_k} convenience points.
For example, if n=5, m=7, a=[5, 3, 2, 1, 4], b=[2, 1, 1, 2, 1], then Polycarp can uninstall the following application sets (not all options are listed below):
* applications with numbers 1, 4 and 5. In this case, it will free a_1+a_4+a_5=10 units of memory and lose b_1+b_4+b_5=5 convenience points;
* applications with numbers 1 and 3. In this case, it will free a_1+a_3=7 units of memory and lose b_1+b_3=3 convenience points.
* applications with numbers 2 and 5. In this case, it will free a_2+a_5=7 memory units and lose b_2+b_5=2 convenience points.
Help Polycarp, choose a set of applications, such that if removing them will free at least m units of memory and lose the minimum number of convenience points, or indicate that such a set does not exist.
Input
The first line contains one integer t (1 β€ t β€ 10^4) β the number of test cases. Then t test cases follow.
The first line of each test case contains two integers n and m (1 β€ n β€ 2 β
10^5, 1 β€ m β€ 10^9) β the number of applications on Polycarp's phone and the number of memory units to be freed.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β the number of memory units used by applications.
The third line of each test case contains n integers b_1, b_2, β¦, b_n (1 β€ b_i β€ 2) β the convenience points of each application.
It is guaranteed that the sum of n over all test cases does not exceed 2 β
10^5.
Output
For each test case, output on a separate line:
* -1, if there is no set of applications, removing which will free at least m units of memory;
* the minimum number of convenience points that Polycarp will lose if such a set exists.
Example
Input
5
5 7
5 3 2 1 4
2 1 1 2 1
1 3
2
1
5 10
2 3 2 3 2
1 2 1 2 1
4 10
5 1 3 4
1 2 1 2
4 5
3 2 1 2
2 1 2 1
Output
2
-1
6
4
3
Note
In the first test case, it is optimal to remove applications with numbers 2 and 5, freeing 7 units of memory. b_2+b_5=2.
In the second test case, by removing the only application, Polycarp will be able to clear only 2 of memory units out of the 3 needed.
In the third test case, it is optimal to remove applications with numbers 1, 2, 3 and 4, freeing 10 units of memory. b_1+b_2+b_3+b_4=6.
In the fourth test case, it is optimal to remove applications with numbers 1, 3 and 4, freeing 12 units of memory. b_1+b_3+b_4=4.
In the fifth test case, it is optimal to remove applications with numbers 1 and 2, freeing 5 units of memory. b_1+b_2=3. | #lΓΆsningsmΓ€ngd Γ€r nedΓ₯tbegrΓ€nsad och ordnad. -> optimal minsta existerar i kontext.
#Vet att det Γ€r sant att lΓΆsning bestΓ₯r av x stna 1-cost x tillhΓΆr [0..all(1-cost)]
#fΓΆr x stna 1-cost bestΓ€ms y stna 2-cost entydligt.
#itererar alla x, fΓΆrsΓΆk i varje steg reducera y frΓ₯n mx(2-cost)
#same hold tru if conv points 1 and 3?
#4 number sum in list eq. x?
#scaleas upp till 3? hΓΆr med markus
#n2 , likt hitta tre tal vars summa Γ€r...
#mot knapsack beroende pΓ₯ m
for _ in range(int(input())):
n,m = map(int,input().split())
memoryCost = list(map(int,input().split()))
convPoints = list(map(int,input().split()))
cost1 = list()
cost2 = list()
for mem,conv in zip(memoryCost,convPoints):
if conv == 1:
cost1.append(mem)
else:
cost2.append(mem)
cost1.sort(reverse=True)
cost2.sort(reverse=True)
#vi ska ha x stna 1-cost. DΓ₯ fΓΆljer y-stna 2-cost. (reducerat)
#bΓΆrja med alla 2-cost och iterera alla 0-n stna 1-cost
memory = sum(cost2)
convP = 2*(len(cost2))
twoCostPointer = (len(cost2))-1
ans = float("inf")
#fΓ₯ till 2 extra iter
for x in range(-1,len(cost1)):
#add x, remove maximalt med 2cost
if x >= 0:
convP += 1
memory += cost1[x]
while(twoCostPointer >= 0 and memory - cost2[twoCostPointer] >= m):
memory -= cost2[twoCostPointer]
twoCostPointer -= 1
convP -= 2
#if
if memory >= m:
ans = min(ans,convP)
print(ans if ans != float("inf") else -1)
'''
1
5 7
5 3 2 1 4
2 1 1 2 1
''' | 3Python3
| {
"input": [
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 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n",
"1\n-1\n4\n1\n2\n",
"2\n",
"4\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"2\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"3\n-1\n2\n6\n-1\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"3\n-1\n2\n6\n-1\n",
"2\n-1\n5\n3\n3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"1\n-1\n2\n-1\n-1\n"
]
} | 2CODEFORCES
|
1475_D. Cleaning the Phone_1242 | Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with the following scoring system β he assigned an integer b_i to each application:
* b_i = 1 β regular application;
* b_i = 2 β important application.
According to this rating system, his phone has b_1 + b_2 + β¦ + b_n convenience points.
Polycarp believes that if he removes applications with numbers i_1, i_2, β¦, i_k, then he will free a_{i_1} + a_{i_2} + β¦ + a_{i_k} units of memory and lose b_{i_1} + b_{i_2} + β¦ + b_{i_k} convenience points.
For example, if n=5, m=7, a=[5, 3, 2, 1, 4], b=[2, 1, 1, 2, 1], then Polycarp can uninstall the following application sets (not all options are listed below):
* applications with numbers 1, 4 and 5. In this case, it will free a_1+a_4+a_5=10 units of memory and lose b_1+b_4+b_5=5 convenience points;
* applications with numbers 1 and 3. In this case, it will free a_1+a_3=7 units of memory and lose b_1+b_3=3 convenience points.
* applications with numbers 2 and 5. In this case, it will free a_2+a_5=7 memory units and lose b_2+b_5=2 convenience points.
Help Polycarp, choose a set of applications, such that if removing them will free at least m units of memory and lose the minimum number of convenience points, or indicate that such a set does not exist.
Input
The first line contains one integer t (1 β€ t β€ 10^4) β the number of test cases. Then t test cases follow.
The first line of each test case contains two integers n and m (1 β€ n β€ 2 β
10^5, 1 β€ m β€ 10^9) β the number of applications on Polycarp's phone and the number of memory units to be freed.
The second line of each test case contains n integers a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) β the number of memory units used by applications.
The third line of each test case contains n integers b_1, b_2, β¦, b_n (1 β€ b_i β€ 2) β the convenience points of each application.
It is guaranteed that the sum of n over all test cases does not exceed 2 β
10^5.
Output
For each test case, output on a separate line:
* -1, if there is no set of applications, removing which will free at least m units of memory;
* the minimum number of convenience points that Polycarp will lose if such a set exists.
Example
Input
5
5 7
5 3 2 1 4
2 1 1 2 1
1 3
2
1
5 10
2 3 2 3 2
1 2 1 2 1
4 10
5 1 3 4
1 2 1 2
4 5
3 2 1 2
2 1 2 1
Output
2
-1
6
4
3
Note
In the first test case, it is optimal to remove applications with numbers 2 and 5, freeing 7 units of memory. b_2+b_5=2.
In the second test case, by removing the only application, Polycarp will be able to clear only 2 of memory units out of the 3 needed.
In the third test case, it is optimal to remove applications with numbers 1, 2, 3 and 4, freeing 10 units of memory. b_1+b_2+b_3+b_4=6.
In the fourth test case, it is optimal to remove applications with numbers 1, 3 and 4, freeing 12 units of memory. b_1+b_3+b_4=4.
In the fifth test case, it is optimal to remove applications with numbers 1 and 2, freeing 5 units of memory. b_1+b_2=3. | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class D {
private static FastReader fr = new FastReader();
private static PrintWriter out=new PrintWriter(System.out);
private static Random random = new Random();
public static void main(String[] args) throws IOException {
StringBuilder sb = new StringBuilder();
// code goes here
int t = fr.nextInt();
while (t-- > 0){
int n = fr.nextInt();
long m = fr.nextInt();
int[] a = fr.nextIntArray(n);
int[] b = fr.nextIntArray(n);
List<Integer> ones = new ArrayList<>();
List<Integer> twos = new ArrayList<>();
for(int i = 0; i < n; i++){
if(b[i] == 1){
ones.add(a[i]);
} else {
twos.add(a[i]);
}
}
ones.sort(null);
twos.sort(null);
long sum = 0;
long ans = Long.MAX_VALUE;
List<Long> ll = new ArrayList<>();
long temp = 0;
for(int i = twos.size() - 1; i >= 0; i--){
temp += twos.get(i);
ll.add(temp);
if(temp >= m) {
ans = 2 * (twos.size() -i);
break;
}
}
for(int i = ones.size() - 1; i >= 0; i--){
sum += ones.get(i);
long req = m - sum;
if(req <= 0){
ans = Math.min(ans, ones.size() - i);
} else {
int lo = 0, hi = ll.size() - 1;
while (lo <= hi){
int mid = lo + (hi - lo)/2;
long x = ll.get(mid);
if(x >= req){
ans = Math.min(ans, ones.size() - i + (2 * (mid + 1)));
hi = mid - 1;
} else {
lo = mid + 1;
}
}
}
}
if(ans != Long.MAX_VALUE){
sb.append(ans).append("\n");
} else {
sb.append("-1\n");
}
}
System.out.print(sb.toString());
}
static void ruffleSort(int[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static class FastReader{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
public String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public int[] nextIntArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
public long nextLong() {
return Long.parseLong(next());
}
public long[] nextLongArray(int n) {
long[] a=new long[n];
for (int i=0; i<n; i++) a[i]=nextLong();
return a;
}
}
static class Pair<A, B>{
A first;
B second;
public Pair(A first, B second){
this.first = first;
this.second = second;
}
}
static long mod(String num, long a)
{
// Initialize result
long res = 0;
// One by one process all digits of 'num'
for (int i = 0; i < num.length(); i++)
res = (res*10 + num.charAt(i) - '0') %a;
return res;
}
static long binomialCoeff(long n, long k, long MOD)
{
long res = 1;
// Since C(n, k) = C(n, n-k)
if (k > n - k)
k = n - k;
// Calculate value of
// [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
for (int i = 0; i < k; ++i) {
res *= (n - i);
res /= (i + 1);
res %= MOD;
}
return res;
}
static long power(long x, long y, long p)
{
// Initialize result
long res = 1;
// Update x if it is more than or
// equal to p
x = x % p;
while (y > 0) {
// If y is odd, multiply x
// with result
if (y % 2 == 1)
res = (res * x) % p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
// Returns n^(-1) mod p
static long modInverse(long n, long p)
{
return power(n, p - 2, p);
}
// Returns nCr % p using Fermat's
// little theorem.
static long nCrModPFermat(int n, int r,
long p)
{
// Base case
if (r == 0)
return 1;
// Fill factorial array so that we
// can find all factorial of r, n
// and n-r
long[] fac = new long[n + 1];
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[n] * modInverse(fac[r], p)
% p * modInverse(fac[n - r], p)
% p)
% p;
}
} | 4JAVA
| {
"input": [
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 17\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n2 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"5\n5 7\n5 3 2 1 2\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 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1\n5\n4\n2\n",
"5\n",
"2\n-1\n6\n4\n3\n",
"4\n",
"2\n-1\n6\n4\n3\n",
"3\n",
"3\n-1\n5\n4\n3\n",
"3\n-1\n5\n4\n3\n",
"4\n",
"3\n-1\n5\n4\n2\n",
"2\n-1\n4\n4\n2\n",
"4\n",
"2\n-1\n6\n3\n3\n",
"3\n",
"3\n",
"5\n",
"3\n-1\n5\n4\n2\n",
"3\n1\n1\n4\n2\n",
"2\n",
"3\n",
"5\n",
"2\n",
"2\n",
"2\n",
"4\n",
"2\n-1\n6\n4\n3\n",
"3\n1\n5\n4\n2\n",
"5\n",
"4\n",
"3\n",
"3\n-1\n5\n4\n3\n",
"3\n-1\n4\n4\n2\n",
"2\n-1\n4\n4\n2\n",
"1\n1\n3\n4\n2\n",
"2\n-1\n6\n3\n3\n",
"3\n",
"2\n",
"3\n",
"3\n-1\n4\n4\n4\n",
"2\n",
"1\n-1\n4\n1\n2\n",
"3\n1\n1\n4\n1\n",
"2\n",
"2\n",
"2\n-1\n5\n4\n3\n",
"4\n",
"3\n",
"2\n-1\n4\n4\n2\n",
"1\n1\n3\n4\n2\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"3\n-1\n4\n4\n4\n",
"2\n",
"1\n-1\n4\n1\n2\n",
"2\n",
"4\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"2\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"3\n-1\n2\n6\n-1\n",
"2\n-1\n6\n3\n3\n",
"2\n",
"2\n",
"3\n-1\n2\n6\n-1\n",
"2\n-1\n5\n3\n3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"1\n-1\n2\n-1\n-1\n"
]
} | 2CODEFORCES
|
1500_B. Two chandeliers_1243 | Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: red β brown β yellow β red β brown β yellow and so on.
There are many chandeliers that differs in color set or order of colors. And the person responsible for the light made a critical mistake β they bought two different chandeliers.
Since chandeliers are different, some days they will have the same color, but some days β different. Of course, it looks poor and only annoys Vasya. As a result, at the k-th time when chandeliers will light with different colors, Vasya will become very angry and, most probably, will fire the person who bought chandeliers.
Your task is to calculate the day, when it happens (counting from the day chandeliers were installed). You can think that Vasya works every day without weekends and days off.
Input
The first line contains three integers n, m and k (1 β€ n, m β€ 500 000; 1 β€ k β€ 10^{12}) β the number of colors in the first and the second chandeliers and how many times colors should differ to anger Vasya.
The second line contains n different integers a_i (1 β€ a_i β€ 2 β
max(n, m)) that describe the first chandelier's sequence of colors.
The third line contains m different integers b_j (1 β€ b_i β€ 2 β
max(n, m)) that describe the second chandelier's sequence of colors.
At the i-th day, the first chandelier has a color a_x, where x = ((i - 1) mod n) + 1) and the second one has a color b_y, where y = ((i - 1) mod m) + 1).
It's guaranteed that sequence a differs from sequence b, so there are will be days when colors of chandeliers differs.
Output
Print the single integer β the index of day when Vasya will become angry.
Examples
Input
4 2 4
4 2 3 1
2 1
Output
5
Input
3 8 41
1 3 2
1 6 4 3 5 7 2 8
Output
47
Input
1 2 31
1
1 2
Output
62
Note
In the first example, the chandeliers will have different colors at days 1, 2, 3 and 5. That's why the answer is 5. | #define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include <functional>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<numeric>
#include <chrono>
#include<sstream>
#include <valarray>
#include<list>
#include<complex>
#include<cassert>
//by Skeef79
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define forn(i,n) for(int i = 0;i<n;i++)
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define szof(x) int(x.size())
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
using namespace std;
const int INF = 1000000000 + 1e8;
const ll LINF = 2000000000000000000;
template<typename T> void print(vector<T>& a)
{
for (int i = 0; i < a.size(); i++)
cout << a[i] << ' ';
cout << en;
}
template<typename T> void print(vector<vector<T>>& a)
{
for (int i = 0; i < a.size(); i++)
{
for (int j = 0; j < a[i].size(); j++)
cout << a[i][j] << ' ';
cout << en;
}
}
template <typename T> void input(vector<T>& a)
{
for (int i = 0; i < a.size(); i++)
cin >> a[i];
}
template<typename T> void input(vector<vector<T>>& a)
{
for (int i = 0; i < a.size(); i++)
for (int j = 0; j < a[i].size(); j++)
cin >> a[i][j];
}
ll gcd(ll a, ll b, ll &x, ll &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
ll x1, y1;
ll g = gcd(b, a%b, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
return g;
}
ll crt(ll a1, ll a2, ll n1, ll n2)
{
ll x1, y1;
ll d = gcd(n1, n2, x1, y1);
if ((a1 - a2) % d != 0)
return -1;
ll k1 = (a2 - a1) / d * x1;
ll t = a1 + n1 * (k1%n2);
while (t < 0)
t += n1 * n2 / d;
if (t > (n1*n2) / d)
t %= (n1*n2) / d;
return t;
}
ll lccm;
vector<ll>pos1, pos2;
ll N = 0, n, m, k;
vector<ll>crts;
ll get(ll cnt)
{
ll ans = cnt;
for (int i = 0; i < N; i++)
{
if (pos1[i] == -1 || pos2[i] == -1)
continue;
else
{
ll fst = crts[i];
if (fst != -1)
{
if (cnt - fst > 0)
{
ll t = cnt - fst;
ans -= (t + lccm - 1) / lccm;
}
}
}
}
return ans;
}
void solve()
{
cin >> n >> m >> k;
vector<ll>a(n), b(m);
input(a);
input(b);
N = *max_element(all(a));
N = max(N, *max_element(all(b)));
N++;
input(a);
input(b);
pos1.resize(N);
pos2.resize(N);
fill(all(pos1), -1);
fill(all(pos2), -1);
crts.resize(N);
ll x, y;
lccm = n * m / gcd(n, m, x, y);
for (int i = 0; i < n; i++)
pos1[a[i]] = i;
for (int i = 0; i < m; i++)
pos2[b[i]] = i;
for (int i = 0; i < N; i++)
{
if (pos1[i] == -1 || pos2[i] == -1)
continue;
else
crts[i] = crt(pos1[i], pos2[i], n, m);
}
ll l = 0, r = 1e18;
while (r - l > 1)
{
ll m = (l + r) / 2;
if (get(m) >= k)
r = m;
else
l = m;
}
cout << l + 1;
}
int main()
{
srand(time(0));
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
#endif
//freopen("out.txt", "w", stdout);
//freopen("igoreha.in", "r", stdin);
//freopen("igoreha.out", "w", stdout);
int tst = 1;
//cin >> tst;
while (tst--)
solve();
} | 2C++
| {
"input": [
"3 8 41\n1 3 2\n1 6 4 3 5 7 2 8\n",
"1 2 31\n1\n1 2\n",
"4 2 4\n4 2 3 1\n2 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"2 2 2\n2 1\n1 2\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 2\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"1 2 1\n1\n2 1\n",
"20 1 100\n1 9 19 13 7 4 12 14 20 2 8 3 5 17 6 18 15 16 11 10\n1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 7 34 6 11 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 7 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"1 2 1\n2\n2 1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 11 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"1 2 23\n1\n1 2\n",
"4 2 4\n4 2 3 1\n3 1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n7 25 19 9 4 34 6 22 21 29 12 18 1 2 15 24 20\n",
"4 2 4\n4 4 2 1\n3 1\n",
"4 2 2\n3 7 2 1\n3 1\n",
"10 15 100\n1 4 8 10 9 3 6 5 14 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"4 2 4\n6 2 3 1\n3 2\n",
"4 2 4\n4 6 2 1\n4 1\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 2\n5 11 10 12 2 9 15 21 7 4 8 14 6 1 3\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 7 6 3 4 10 1 3 5 8\n",
"10 10 9\n4 7 10 4 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 3\n3 7 2 1\n3 2\n",
"20 101 110\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 109 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 15 100\n1 4 8 10 13 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 22 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n4 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 4\n4 4 3 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 4 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 4\n4 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 8\n",
"4 2 2\n4 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"4 2 2\n6 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 7 34 6 3 21 29 12 18 1 2 15 24 20\n",
"4 2 4\n6 2 3 1\n3 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 11 21 29 12 18 1 2 15 8 20\n",
"10 15 100\n1 4 8 18 13 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"10 10 10\n8 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 47 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"4 2 4\n4 6 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 5 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 11 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 16\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 105 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 58 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 2 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 10 4 1 5 3 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 47 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 15 1 3\n9 3 6 2 4 10 1 3 10 16\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 15 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 105 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 16 4 1 5 3 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 16 4 1 5 3 8 6 3\n9 3 6 2 4 4 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 133 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 63 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 52 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 16 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 63 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 52 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 40 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 8 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 6 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 16 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 100 100\n1 16 21 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 101 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 8 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 6 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 6 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 16 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 32 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 33 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 82 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 100 100\n1 16 21 3 19 13 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 42 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 76 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 3 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 1 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 1 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 4 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 33 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 153 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 3 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 82 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 42 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 4 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 100 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 76 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 108 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 3 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 21 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 1 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 120 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 1 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 16 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 4 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 4 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 65 78 50 62 55 24 91 35 33 3 29 10\n"
],
"output": [
"\n47\n",
"\n62\n",
"\n5\n",
"101\n",
"2\n",
"107\n",
"1\n",
"106\n",
"105\n",
"11\n",
"101\n",
"104\n",
"2\n",
"105\n",
"10\n",
"46\n",
"6\n",
"106\n",
"5\n",
"3\n",
"100\n",
"8\n",
"7\n",
"102\n",
"107\n",
"11\n",
"9\n",
"4\n",
"111\n",
"101\n",
"104\n",
"105\n",
"10\n",
"6\n",
"101\n",
"10\n",
"101\n",
"10\n",
"5\n",
"101\n",
"10\n",
"2\n",
"101\n",
"10\n",
"101\n",
"2\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"105\n",
"6\n",
"101\n",
"105\n",
"104\n",
"10\n",
"101\n",
"5\n",
"101\n",
"10\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n"
]
} | 2CODEFORCES
|
1500_B. Two chandeliers_1244 | Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: red β brown β yellow β red β brown β yellow and so on.
There are many chandeliers that differs in color set or order of colors. And the person responsible for the light made a critical mistake β they bought two different chandeliers.
Since chandeliers are different, some days they will have the same color, but some days β different. Of course, it looks poor and only annoys Vasya. As a result, at the k-th time when chandeliers will light with different colors, Vasya will become very angry and, most probably, will fire the person who bought chandeliers.
Your task is to calculate the day, when it happens (counting from the day chandeliers were installed). You can think that Vasya works every day without weekends and days off.
Input
The first line contains three integers n, m and k (1 β€ n, m β€ 500 000; 1 β€ k β€ 10^{12}) β the number of colors in the first and the second chandeliers and how many times colors should differ to anger Vasya.
The second line contains n different integers a_i (1 β€ a_i β€ 2 β
max(n, m)) that describe the first chandelier's sequence of colors.
The third line contains m different integers b_j (1 β€ b_i β€ 2 β
max(n, m)) that describe the second chandelier's sequence of colors.
At the i-th day, the first chandelier has a color a_x, where x = ((i - 1) mod n) + 1) and the second one has a color b_y, where y = ((i - 1) mod m) + 1).
It's guaranteed that sequence a differs from sequence b, so there are will be days when colors of chandeliers differs.
Output
Print the single integer β the index of day when Vasya will become angry.
Examples
Input
4 2 4
4 2 3 1
2 1
Output
5
Input
3 8 41
1 3 2
1 6 4 3 5 7 2 8
Output
47
Input
1 2 31
1
1 2
Output
62
Note
In the first example, the chandeliers will have different colors at days 1, 2, 3 and 5. That's why the answer is 5. | def main():
n, m, k = list(map(lambda x: int(x), str(input()).split(' ')))
a = list(map(lambda x: int(x), str(input()).split(' ')))
b = list(map(lambda x: int(x), str(input()).split(' ')))
if n < m:
print(solve(m, n, k, b, a))
return
print(solve(n, m, k, a, b))
def solve(n, m, k, a, b):
# n >= m
d = gcd(n, m)
x, y = 0, 0
# x * n - y * m = d
for i in range(1, m):
if (i * n - d) % m == 0:
x = i
y = (i * n - d) // m
if y == 0:
x += 1
y += 1
break
# print(x, y, d)
common = {}
common_count = 0
colors = {}
for i in range(len(a)):
colors[a[i]] = i
for i in range(len(b)):
if b[i] in colors and (colors[b[i]] - i) % d == 0:
common[colors[b[i]]] = i
common_count += 1
# where the common indices meet
com = []
for key, val in common.items():
z = (val - key) // d
# z * x * n - z * y * m = v - k
com.append(int(((z * x) % (m // d)) * n + key))
new_k = k % (m * n // d - common_count)
s = (k // (m * n // d - common_count)) * m * n // d
if new_k == 0:
new_k = m * n // d - common_count
s -= m * n // d
com = sorted(com)
cur = -1
# print(com, s, new_k, common_count, m * n // d - common_count)
for c in com:
if new_k < c - cur:
s += new_k
return s
new_k -= (c - cur - 1)
s += (c - cur)
cur = c
return s + new_k
def gcd(n, m):
if n == m:
return n
if n < m:
return gcd(m, n)
if n % m == 0:
return m
return gcd(m, n % m)
if __name__ == "__main__":
main() | 3Python3
| {
"input": [
"3 8 41\n1 3 2\n1 6 4 3 5 7 2 8\n",
"1 2 31\n1\n1 2\n",
"4 2 4\n4 2 3 1\n2 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"2 2 2\n2 1\n1 2\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 2\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"1 2 1\n1\n2 1\n",
"20 1 100\n1 9 19 13 7 4 12 14 20 2 8 3 5 17 6 18 15 16 11 10\n1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 7 34 6 11 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 7 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"1 2 1\n2\n2 1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 11 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"1 2 23\n1\n1 2\n",
"4 2 4\n4 2 3 1\n3 1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n7 25 19 9 4 34 6 22 21 29 12 18 1 2 15 24 20\n",
"4 2 4\n4 4 2 1\n3 1\n",
"4 2 2\n3 7 2 1\n3 1\n",
"10 15 100\n1 4 8 10 9 3 6 5 14 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"4 2 4\n6 2 3 1\n3 2\n",
"4 2 4\n4 6 2 1\n4 1\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 2\n5 11 10 12 2 9 15 21 7 4 8 14 6 1 3\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 7 6 3 4 10 1 3 5 8\n",
"10 10 9\n4 7 10 4 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 3\n3 7 2 1\n3 2\n",
"20 101 110\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 109 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 15 100\n1 4 8 10 13 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 22 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n4 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 4\n4 4 3 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 4 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 4\n4 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 8\n",
"4 2 2\n4 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"4 2 2\n6 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 7 34 6 3 21 29 12 18 1 2 15 24 20\n",
"4 2 4\n6 2 3 1\n3 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 11 21 29 12 18 1 2 15 8 20\n",
"10 15 100\n1 4 8 18 13 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"10 10 10\n8 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 47 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"4 2 4\n4 6 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 5 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 11 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 16\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 105 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 58 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 2 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 10 4 1 5 3 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 47 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 15 1 3\n9 3 6 2 4 10 1 3 10 16\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 15 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 105 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 16 4 1 5 3 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 16 4 1 5 3 8 6 3\n9 3 6 2 4 4 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 133 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 63 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 52 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 16 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 63 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 52 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 40 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 8 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 6 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 16 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 100 100\n1 16 21 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 101 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 8 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 6 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 6 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 16 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 32 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 33 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 82 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 100 100\n1 16 21 3 19 13 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 42 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 76 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 3 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 1 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 1 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 4 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 33 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 153 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 3 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 82 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 42 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 4 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 100 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 76 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 108 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 3 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 21 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 1 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 120 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 1 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 16 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 4 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 4 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 65 78 50 62 55 24 91 35 33 3 29 10\n"
],
"output": [
"\n47\n",
"\n62\n",
"\n5\n",
"101\n",
"2\n",
"107\n",
"1\n",
"106\n",
"105\n",
"11\n",
"101\n",
"104\n",
"2\n",
"105\n",
"10\n",
"46\n",
"6\n",
"106\n",
"5\n",
"3\n",
"100\n",
"8\n",
"7\n",
"102\n",
"107\n",
"11\n",
"9\n",
"4\n",
"111\n",
"101\n",
"104\n",
"105\n",
"10\n",
"6\n",
"101\n",
"10\n",
"101\n",
"10\n",
"5\n",
"101\n",
"10\n",
"2\n",
"101\n",
"10\n",
"101\n",
"2\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"105\n",
"6\n",
"101\n",
"105\n",
"104\n",
"10\n",
"101\n",
"5\n",
"101\n",
"10\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n"
]
} | 2CODEFORCES
|
1500_B. Two chandeliers_1245 | Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: red β brown β yellow β red β brown β yellow and so on.
There are many chandeliers that differs in color set or order of colors. And the person responsible for the light made a critical mistake β they bought two different chandeliers.
Since chandeliers are different, some days they will have the same color, but some days β different. Of course, it looks poor and only annoys Vasya. As a result, at the k-th time when chandeliers will light with different colors, Vasya will become very angry and, most probably, will fire the person who bought chandeliers.
Your task is to calculate the day, when it happens (counting from the day chandeliers were installed). You can think that Vasya works every day without weekends and days off.
Input
The first line contains three integers n, m and k (1 β€ n, m β€ 500 000; 1 β€ k β€ 10^{12}) β the number of colors in the first and the second chandeliers and how many times colors should differ to anger Vasya.
The second line contains n different integers a_i (1 β€ a_i β€ 2 β
max(n, m)) that describe the first chandelier's sequence of colors.
The third line contains m different integers b_j (1 β€ b_i β€ 2 β
max(n, m)) that describe the second chandelier's sequence of colors.
At the i-th day, the first chandelier has a color a_x, where x = ((i - 1) mod n) + 1) and the second one has a color b_y, where y = ((i - 1) mod m) + 1).
It's guaranteed that sequence a differs from sequence b, so there are will be days when colors of chandeliers differs.
Output
Print the single integer β the index of day when Vasya will become angry.
Examples
Input
4 2 4
4 2 3 1
2 1
Output
5
Input
3 8 41
1 3 2
1 6 4 3 5 7 2 8
Output
47
Input
1 2 31
1
1 2
Output
62
Note
In the first example, the chandeliers will have different colors at days 1, 2, 3 and 5. That's why the answer is 5. |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
public class TwoChandeliers {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String[] line1 = in.readLine().split(" ");
int n = Integer.parseInt(line1[0]);
int m = Integer.parseInt(line1[1]);
long k = Long.parseLong(line1[2]);
int[] color1 = readColorLine(in, n);
int[] color2 = readColorLine(in, m);
if (color1.length > color2.length) {
int[] swap = color1;
color1 = color2;
color2 = swap;
}
int[] colorMap = buildColorMap(color1, color2);
applyColorMap(color1, colorMap);
applyColorMap(color2, colorMap);
int[] numAngryDaysPerStart = numAngryDaysPerStart(color1.length, color2);
//System.err.println(Arrays.toString(numAngryDaysPerStart));
long numAngryFullLoop = numAngryFullLoop(numAngryDaysPerStart, color1.length);
//System.err.println(numAngryFullLoop);
long numFullLoops = k / numAngryFullLoop;
if (numAngryFullLoop * numFullLoops == k) {
numFullLoops -= 1;
}
BigInteger numDays = BigInteger.valueOf(numDaysFullLoop).multiply(BigInteger.valueOf(numFullLoops));
k -= numAngryFullLoop * numFullLoops;
int nextPos1 = 0;
int nextPos2 = 0;
long numDaysAdd = 0;
while (k > 0) {
if (nextPos1 == 0 && k > numAngryDaysPerStart[nextPos2]) {
k -= numAngryDaysPerStart[nextPos2];
nextPos2 += color1.length;
numDaysAdd += color1.length;
} else {
if (color1[nextPos1] != color2[nextPos2]) {
k -= 1;
}
nextPos1 += 1;
nextPos2 += 1;
numDaysAdd += 1;
}
if (nextPos1 >= color1.length) nextPos1 -= color1.length;
if (nextPos2 >= color2.length) nextPos2 -= color2.length;
}
System.out.println(numDays.add(BigInteger.valueOf(numDaysAdd)));
}
static int[] readColorLine(BufferedReader in, int len) throws IOException {
StringTokenizer line = new StringTokenizer(in.readLine());
int[] res = new int[len];
for (int i = 0; i < len; ++i) {
res[i] = Integer.parseInt(line.nextToken()) - 1;
}
return res;
}
static int[] buildColorMap(int[] color1, int[] color2) {
int[] colorMap = new int[2*Math.max(color1.length,color2.length)];
Arrays.fill(colorMap, -1);
for (int i = 0; i < color1.length; ++i) {
colorMap[color1[i]] = i;
}
return colorMap;
}
static void applyColorMap(int[] color, int[] map) {
for (int i = 0; i < color.length; ++i) {
color[i] = map[color[i]];
}
}
static int[] numAngryDaysPerStart(int jumpLen, int[] color2) {
int[] startPos = new int[color2.length];
for (int i = 0; i < color2.length; ++i) {
if (color2[i] == -1) continue;
int matchStartPos = i - color2[i];
while (matchStartPos < 0) matchStartPos += color2.length;
startPos[matchStartPos] += 1;
}
for (int i = 0; i < startPos.length; ++i) {
startPos[i] = jumpLen - startPos[i];
}
return startPos;
}
static long numDaysFullLoop = 0;
static long numAngryFullLoop(int[] numAngryPerStart, int jump) {
long result = 0;
int i = 0;
do {
result += numAngryPerStart[i];
i += jump;
numDaysFullLoop += jump;
if (numAngryPerStart.length <= i) i -= numAngryPerStart.length;
} while (i != 0);
return result;
}
}
| 4JAVA
| {
"input": [
"3 8 41\n1 3 2\n1 6 4 3 5 7 2 8\n",
"1 2 31\n1\n1 2\n",
"4 2 4\n4 2 3 1\n2 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"2 2 2\n2 1\n1 2\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 2\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"1 2 1\n1\n2 1\n",
"20 1 100\n1 9 19 13 7 4 12 14 20 2 8 3 5 17 6 18 15 16 11 10\n1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 7 34 6 11 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 7 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"1 2 1\n2\n2 1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 11 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"1 2 23\n1\n1 2\n",
"4 2 4\n4 2 3 1\n3 1\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n7 25 19 9 4 34 6 22 21 29 12 18 1 2 15 24 20\n",
"4 2 4\n4 4 2 1\n3 1\n",
"4 2 2\n3 7 2 1\n3 1\n",
"10 15 100\n1 4 8 10 9 3 6 5 14 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"4 2 4\n6 2 3 1\n3 2\n",
"4 2 4\n4 6 2 1\n4 1\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"10 15 100\n1 4 8 10 9 3 6 5 7 2\n5 11 10 12 2 9 15 21 7 4 8 14 6 1 3\n",
"10 10 10\n2 7 10 4 1 5 9 8 6 3\n9 7 6 3 4 10 1 3 5 8\n",
"10 10 9\n4 7 10 4 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 3\n3 7 2 1\n3 2\n",
"20 101 110\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 109 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 15 100\n1 4 8 10 13 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 22 21 29 12 18 1 2 15 24 20\n",
"10 10 10\n4 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 4\n4 4 3 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 4 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"4 2 4\n4 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 8\n",
"4 2 2\n4 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"4 2 2\n6 7 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 7 34 6 3 21 29 12 18 1 2 15 24 20\n",
"4 2 4\n6 2 3 1\n3 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"13 17 100\n7 15 21 29 9 11 34 12 24 25 1 18 6\n27 25 19 9 4 34 6 11 21 29 12 18 1 2 15 8 20\n",
"10 15 100\n1 4 8 18 13 3 6 5 7 1\n5 11 10 12 2 9 15 13 7 4 8 14 6 1 3\n",
"10 10 10\n8 7 10 4 1 5 9 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 47 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"4 2 4\n4 6 2 1\n3 1\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 5 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n4 7 10 3 1 5 11 8 1 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 8 1 3\n9 3 6 2 4 10 1 3 10 16\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 105 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 58 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 2 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 10 4 1 5 3 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 47 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"10 10 10\n4 7 10 3 2 5 9 15 1 3\n9 3 6 2 4 10 1 3 10 16\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 15 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 105 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 16 4 1 5 3 8 6 3\n9 3 6 2 4 10 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 99 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 88 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"10 10 10\n8 7 16 4 1 5 3 8 6 3\n9 3 6 2 4 4 1 3 5 8\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 133 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 63 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 35 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 67 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 52 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 15 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 12\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 16 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 18 36 47 160 35 27 45 12 72 44 52 75 26 31 14 47 63 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 12 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 62 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 43 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 57 6 15 187 79 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 37 27 45 8 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 52 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 40 17 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 100 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 8 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 6 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 16 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 100 100\n1 16 21 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 101 41 38 63 84 96 21 57 83 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 8 34 70 16 22 56 35 60 61 85 28 65 8 10 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 171 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 173 95 62 55 24 91 54 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 20 12 18 5 17 13 6 8 5 2 6 7 27 9 11\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 67 6 3 34 70 16 22 56 6 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 106 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 41 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 16\n69 18 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 37 59 49 80 82 19 18 9 1 2 111 6 11 34 70 16 16 16 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 35 33 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 32 93 95 62 81 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 33 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 82 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 100 100\n1 16 21 3 19 13 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 110 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 5 82 25 18 9 1 2 67 6 26 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 67 37 27 32 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 42 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 10 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 76 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 3 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 27 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 1 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 68 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 1 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 4 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 27 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 14 33 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 89 101 100 41 38 63 84 185 21 57 93 13 25 90 86 7 20 87 154 59 49 80 82 40 18 9 1 2 71 10 15 99 79 16 22 56 19 60 61 85 28 65 8 6 46 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 31 14 47 81 153 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 94 30 58 78 50 62 55 24 91 35 33 3 29 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 3 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 82 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 68 32 74 42 30 4 131 76 54 92 5 71 66 94 17 58 93 50 62 55 24 91 35 33 3 29 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 18 11\n69 18 101 100 41 38 63 47 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 14 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 98 64 42 45 12 72 44 52 75 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 2 77 76 54 92 5 71 66 94 18 58 93 50 62 4 24 91 35 33 3 2 10\n",
"20 101 101\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 15 11\n69 18 101 110 41 38 63 84 96 21 57 93 13 43 90 86 3 20 87 88 59 49 80 82 25 18 9 1 2 67 6 15 34 70 16 22 56 35 60 100 85 28 65 8 6 46 39 25 48 36 47 160 37 13 45 12 72 27 52 75 26 31 14 47 81 95 70 83 97 11 32 73 51 89 68 32 74 42 30 4 77 76 54 92 5 71 66 92 18 58 93 50 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 10 11\n69 18 101 100 76 38 63 57 96 21 57 93 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 111 6 11 34 70 16 22 4 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 108 44 52 75 26 31 14 47 81 95 70 9 97 11 34 73 51 89 68 32 74 42 30 4 77 76 54 92 1 71 66 94 35 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 8 8 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 56 93 13 43 90 86 7 20 87 21 59 97 80 82 25 3 9 1 2 111 6 11 34 70 16 22 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 70 21 45 12 72 44 52 147 26 31 14 47 81 95 70 133 97 11 34 73 51 89 68 32 74 22 30 4 77 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 1 13 6 8 5 2 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 89 13 43 90 86 7 20 87 21 59 97 80 82 25 18 9 1 2 111 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 58 26 31 9 47 81 95 70 83 89 11 34 73 51 89 120 27 74 42 30 4 32 76 54 92 5 71 66 94 18 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 2 15 7 16 9 11\n69 18 101 100 41 2 63 84 96 21 57 93 3 43 90 86 13 20 87 21 59 49 80 82 25 18 9 1 2 111 6 1 34 70 16 16 75 35 60 44 85 28 65 8 6 46 39 25 48 36 47 160 37 27 45 12 72 44 52 143 26 31 14 47 81 95 70 83 97 11 34 73 51 89 68 32 74 42 30 5 77 76 54 92 5 71 66 94 16 58 93 95 62 55 24 91 35 33 3 2 10\n",
"20 101 100\n1 16 20 3 19 8 12 18 4 17 13 6 14 5 4 15 7 16 9 11\n69 18 101 100 41 38 63 84 96 21 57 170 13 43 90 86 7 20 87 21 59 49 80 82 25 18 9 1 2 110 6 11 34 70 16 16 56 35 60 61 85 28 65 8 6 46 39 25 41 36 47 160 35 4 45 12 72 44 52 75 26 31 14 68 81 183 70 83 97 11 34 73 51 89 68 32 74 42 30 4 77 38 54 92 5 71 66 94 18 58 93 95 91 55 24 54 50 33 3 2 10\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 4 3 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 11 1 2 52 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 47 39 25 48 36 64 98 37 27 45 12 72 44 52 75 26 58 14 47 81 162 70 83 97 11 34 73 51 89 68 32 74 42 30 6 77 76 54 92 5 33 66 94 17 65 78 50 62 55 24 91 35 33 3 29 10\n"
],
"output": [
"\n47\n",
"\n62\n",
"\n5\n",
"101\n",
"2\n",
"107\n",
"1\n",
"106\n",
"105\n",
"11\n",
"101\n",
"104\n",
"2\n",
"105\n",
"10\n",
"46\n",
"6\n",
"106\n",
"5\n",
"3\n",
"100\n",
"8\n",
"7\n",
"102\n",
"107\n",
"11\n",
"9\n",
"4\n",
"111\n",
"101\n",
"104\n",
"105\n",
"10\n",
"6\n",
"101\n",
"10\n",
"101\n",
"10\n",
"5\n",
"101\n",
"10\n",
"2\n",
"101\n",
"10\n",
"101\n",
"2\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"105\n",
"6\n",
"101\n",
"105\n",
"104\n",
"10\n",
"101\n",
"5\n",
"101\n",
"10\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"10\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"100\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"101\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n",
"101\n",
"100\n",
"102\n",
"101\n",
"101\n",
"101\n",
"101\n",
"100\n",
"101\n",
"101\n"
]
} | 2CODEFORCES
|
1525_D. Armchairs_1246 | There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.
For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th armchair is occupied by someone and the j-th armchair is not, you can tell the person sitting in the i-th armchair to move to the j-th armchair. The time it takes a person to move from the i-th armchair to the j-th one is |i - j| minutes. You may perform this operation any number of times, but these operations must be done sequentially, i. e. you cannot tell a person to move until the person you asked to move in the last operation has finished moving to their destination armchair.
You want to achieve the following situation: every seat that was initially occupied must be free. What is the minimum time you need to do it?
Input
The first line contains one integer n (2 β€ n β€ 5000) β the number of armchairs.
The second line contains n integers a_1, a_2, ..., a_n (0 β€ a_i β€ 1). a_i = 1 means that the i-th armchair is initially occupied, a_i = 0 means that it is initially free. The number of occupied armchairs is at most n/2.
Output
Print one integer β the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free.
Examples
Input
7
1 0 0 1 0 0 1
Output
3
Input
6
1 1 1 0 0 0
Output
9
Input
5
0 0 0 0 0
Output
0
Note
In the first test, you can perform the following sequence:
1. ask a person to move from armchair 1 to armchair 2, it takes 1 minute;
2. ask a person to move from armchair 7 to armchair 6, it takes 1 minute;
3. ask a person to move from armchair 4 to armchair 5, it takes 1 minute.
In the second test, you can perform the following sequence:
1. ask a person to move from armchair 1 to armchair 4, it takes 3 minutes;
2. ask a person to move from armchair 2 to armchair 6, it takes 4 minutes;
3. ask a person to move from armchair 4 to armchair 5, it takes 1 minute;
4. ask a person to move from armchair 3 to armchair 4, it takes 1 minute.
In the third test, no seat is occupied so your goal is achieved instantly. | from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat, permutations
import math
def inp(force_list=False):
re = map(int, raw_input().split())
if len(re) == 1 and not force_list:
return re[0]
return re
def inst():
return raw_input().strip()
def gcd(x, y):
while(y):
x, y = y, x % y
return x
MOD = 1000000007
def qmod(a, b, mod):
res = 1
while b:
if b&1:
res = (res*a)%mod
b <<= 1
a = (a*a)%mod
return res
def my_main():
kase = 1#inp()
pans = []
for _ in xrange(kase):
n = inp()
da = inp(True)
dp = [[MOD for i in range(n+1)] for i in range(n+1)]
dp[0] = [0] * (n+1)
ok = 0
for i in xrange(1, n+1):
ok |= da[i-1]
if not ok:
dp[i][0] = 0
for j in xrange(1, n+1):
if da[i-1] == 0:
dp[i][j] = dp[i-1][j]
elif da[j-1] == 1:
dp[i][j] = dp[i][j-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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0\n"
],
"output": [
"\n9\n",
"\n0\n",
"\n3\n",
"10\n",
"1\n",
"0\n",
"482\n",
"4\n",
"0\n",
"191\n",
"40\n",
"4\n",
"1\n",
"2\n",
"3\n",
"4\n",
"11\n",
"212\n",
"153\n",
"194\n",
"5\n",
"215\n",
"211\n",
"230\n",
"39\n",
"12\n",
"218\n",
"255\n",
"42\n",
"6\n",
"214\n",
"219\n",
"0\n",
"164\n",
"254\n",
"281\n",
"197\n",
"138\n",
"277\n",
"40\n",
"174\n",
"208\n",
"259\n",
"166\n",
"202\n",
"7\n",
"130\n",
"253\n",
"143\n",
"41\n",
"256\n",
"183\n",
"245\n",
"8\n",
"360\n",
"220\n",
"257\n",
"180\n",
"290\n",
"9\n",
"92\n",
"207\n",
"10\n",
"81\n",
"244\n",
"80\n",
"79\n",
"86\n",
"152\n",
"204\n",
"249\n",
"15\n",
"217\n",
"252\n",
"148\n",
"171\n",
"198\n",
"93\n",
"324\n",
"221\n",
"131\n",
"50\n",
"284\n",
"282\n",
"264\n",
"76\n",
"141\n",
"155\n",
"344\n",
"291\n",
"226\n",
"38\n",
"51\n",
"279\n",
"13\n",
"1\n",
"1\n",
"2\n",
"1\n",
"1\n",
"3\n",
"2\n",
"11\n",
"1\n",
"2\n",
"2\n",
"4\n",
"2\n",
"4\n",
"3\n",
"3\n",
"5\n",
"4\n",
"5\n",
"11\n",
"1\n",
"2\n",
"1\n",
"2\n",
"5\n",
"211\n",
"4\n",
"3\n",
"2\n",
"3\n",
"5\n",
"3\n",
"3\n",
"4\n",
"4\n",
"5\n",
"2\n",
"2\n",
"3\n",
"5\n",
"1\n",
"6\n",
"215\n",
"3\n",
"39\n",
"2\n",
"4\n",
"3\n",
"1\n",
"5\n",
"2\n",
"6\n",
"11\n",
"1\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"2\n",
"211\n",
"2\n",
"4\n",
"12\n",
"5\n",
"6\n",
"3\n",
"218\n",
"4\n",
"4\n",
"6\n",
"5\n",
"12\n",
"2\n",
"6\n",
"5\n",
"4\n",
"4\n",
"5\n",
"5\n",
"4\n",
"6\n",
"2\n",
"3\n",
"5\n",
"6\n",
"5\n",
"6\n",
"7\n",
"3\n",
"6\n",
"5\n",
"5\n",
"6\n",
"2\n",
"3\n",
"6\n",
"143\n",
"8\n",
"7\n",
"4\n",
"5\n",
"9\n",
"259\n",
"5\n",
"6\n",
"10\n",
"230\n",
"6\n",
"7\n",
"1\n",
"202\n",
"2\n",
"12\n",
"3\n",
"6\n",
"4\n"
]
} | 2CODEFORCES
|
1525_D. Armchairs_1247 | There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.
For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th armchair is occupied by someone and the j-th armchair is not, you can tell the person sitting in the i-th armchair to move to the j-th armchair. The time it takes a person to move from the i-th armchair to the j-th one is |i - j| minutes. You may perform this operation any number of times, but these operations must be done sequentially, i. e. you cannot tell a person to move until the person you asked to move in the last operation has finished moving to their destination armchair.
You want to achieve the following situation: every seat that was initially occupied must be free. What is the minimum time you need to do it?
Input
The first line contains one integer n (2 β€ n β€ 5000) β the number of armchairs.
The second line contains n integers a_1, a_2, ..., a_n (0 β€ a_i β€ 1). a_i = 1 means that the i-th armchair is initially occupied, a_i = 0 means that it is initially free. The number of occupied armchairs is at most n/2.
Output
Print one integer β the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free.
Examples
Input
7
1 0 0 1 0 0 1
Output
3
Input
6
1 1 1 0 0 0
Output
9
Input
5
0 0 0 0 0
Output
0
Note
In the first test, you can perform the following sequence:
1. ask a person to move from armchair 1 to armchair 2, it takes 1 minute;
2. ask a person to move from armchair 7 to armchair 6, it takes 1 minute;
3. ask a person to move from armchair 4 to armchair 5, it takes 1 minute.
In the second test, you can perform the following sequence:
1. ask a person to move from armchair 1 to armchair 4, it takes 3 minutes;
2. ask a person to move from armchair 2 to armchair 6, it takes 4 minutes;
3. ask a person to move from armchair 4 to armchair 5, it takes 1 minute;
4. ask a person to move from armchair 3 to armchair 4, it takes 1 minute.
In the third test, no seat is occupied so your goal is achieved instantly. |
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define pb push_back
#define fr(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define done(i) cout<<"done = "<<i<<endl;
#define show(x,y) cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
ll dp[5005][5005];
ll inf= 1e18;
void Test()
{
int n;
cin>>n;
vector<ll>X,Y;
X.pb(0);
Y.pb(0);
for(int i=1; i<=n; i++)
{
int x;
cin>>x;
if(x) X.pb(i);
else Y.pb(i);
}
fr(i,1,n)
fr(j,1,n)
{
dp[i][j]=inf;
dp[i][0]=inf;
}
dp[0][0]=0;
for(int i=1; i<X.size(); i++)
{
for(int j=1; j<Y.size(); j++)
{
ll cost= abs(X[i]-Y[j]) ;
dp[i][j]= min(dp[i][j-1],dp[i-1][j-1]+ cost); ;
}
}
cout<<dp[X.size() - 1 ][Y.size() - 1]<<endl;
}
int main()
{
int t=1;
//cin>>t;
while(t--)
Test();
}
| 2C++
| {
"input": [
"6\n1 1 1 0 0 0\n",
"5\n0 0 0 0 0\n",
"7\n1 0 0 1 0 0 1\n",
"100\n0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 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\n",
"10\n",
"1\n",
"0\n",
"482\n",
"4\n",
"0\n",
"191\n",
"40\n",
"4\n",
"1\n",
"2\n",
"3\n",
"4\n",
"11\n",
"212\n",
"153\n",
"194\n",
"5\n",
"215\n",
"211\n",
"230\n",
"39\n",
"12\n",
"218\n",
"255\n",
"42\n",
"6\n",
"214\n",
"219\n",
"0\n",
"164\n",
"254\n",
"281\n",
"197\n",
"138\n",
"277\n",
"40\n",
"174\n",
"208\n",
"259\n",
"166\n",
"202\n",
"7\n",
"130\n",
"253\n",
"143\n",
"41\n",
"256\n",
"183\n",
"245\n",
"8\n",
"360\n",
"220\n",
"257\n",
"180\n",
"290\n",
"9\n",
"92\n",
"207\n",
"10\n",
"81\n",
"244\n",
"80\n",
"79\n",
"86\n",
"152\n",
"204\n",
"249\n",
"15\n",
"217\n",
"252\n",
"148\n",
"171\n",
"198\n",
"93\n",
"324\n",
"221\n",
"131\n",
"50\n",
"284\n",
"282\n",
"264\n",
"76\n",
"141\n",
"155\n",
"344\n",
"291\n",
"226\n",
"38\n",
"51\n",
"279\n",
"13\n",
"1\n",
"1\n",
"2\n",
"1\n",
"1\n",
"3\n",
"2\n",
"11\n",
"1\n",
"2\n",
"2\n",
"4\n",
"2\n",
"4\n",
"3\n",
"3\n",
"5\n",
"4\n",
"5\n",
"11\n",
"1\n",
"2\n",
"1\n",
"2\n",
"5\n",
"211\n",
"4\n",
"3\n",
"2\n",
"3\n",
"5\n",
"3\n",
"3\n",
"4\n",
"4\n",
"5\n",
"2\n",
"2\n",
"3\n",
"5\n",
"1\n",
"6\n",
"215\n",
"3\n",
"39\n",
"2\n",
"4\n",
"3\n",
"1\n",
"5\n",
"2\n",
"6\n",
"11\n",
"1\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"2\n",
"211\n",
"2\n",
"4\n",
"12\n",
"5\n",
"6\n",
"3\n",
"218\n",
"4\n",
"4\n",
"6\n",
"5\n",
"12\n",
"2\n",
"6\n",
"5\n",
"4\n",
"4\n",
"5\n",
"5\n",
"4\n",
"6\n",
"2\n",
"3\n",
"5\n",
"6\n",
"5\n",
"6\n",
"7\n",
"3\n",
"6\n",
"5\n",
"5\n",
"6\n",
"2\n",
"3\n",
"6\n",
"143\n",
"8\n",
"7\n",
"4\n",
"5\n",
"9\n",
"259\n",
"5\n",
"6\n",
"10\n",
"230\n",
"6\n",
"7\n",
"1\n",
"202\n",
"2\n",
"12\n",
"3\n",
"6\n",
"4\n"
]
} | 2CODEFORCES
|
1525_D. Armchairs_1248 | There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.
For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th armchair is occupied by someone and the j-th armchair is not, you can tell the person sitting in the i-th armchair to move to the j-th armchair. The time it takes a person to move from the i-th armchair to the j-th one is |i - j| minutes. You may perform this operation any number of times, but these operations must be done sequentially, i. e. you cannot tell a person to move until the person you asked to move in the last operation has finished moving to their destination armchair.
You want to achieve the following situation: every seat that was initially occupied must be free. What is the minimum time you need to do it?
Input
The first line contains one integer n (2 β€ n β€ 5000) β the number of armchairs.
The second line contains n integers a_1, a_2, ..., a_n (0 β€ a_i β€ 1). a_i = 1 means that the i-th armchair is initially occupied, a_i = 0 means that it is initially free. The number of occupied armchairs is at most n/2.
Output
Print one integer β the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free.
Examples
Input
7
1 0 0 1 0 0 1
Output
3
Input
6
1 1 1 0 0 0
Output
9
Input
5
0 0 0 0 0
Output
0
Note
In the first test, you can perform the following sequence:
1. ask a person to move from armchair 1 to armchair 2, it takes 1 minute;
2. ask a person to move from armchair 7 to armchair 6, it takes 1 minute;
3. ask a person to move from armchair 4 to armchair 5, it takes 1 minute.
In the second test, you can perform the following sequence:
1. ask a person to move from armchair 1 to armchair 4, it takes 3 minutes;
2. ask a person to move from armchair 2 to armchair 6, it takes 4 minutes;
3. ask a person to move from armchair 4 to armchair 5, it takes 1 minute;
4. ask a person to move from armchair 3 to armchair 4, it takes 1 minute.
In the third test, no seat is occupied so your goal is achieved instantly. | import sys
input = sys.stdin.buffer.readline
import math
n=int(input())
arr=[int(x) for x in input().split()]
h=[]
v=[]
for i in range(n):
if arr[i]:
v.append(i)
else:
h.append(i)
hh=len(h)
vv=len(v)
dp=[[0 for j in range(hh+1)] for i in range(vv+1)]
for i in range(1,vv+1):
dp[i][0]=math.inf
for i in range(1,vv+1):
for j in range(1,hh+1):
dp[i][j]=min(dp[i-1][j-1]+abs(v[i-1]-h[j-1]),dp[i][j-1])
print(dp[vv][hh]) | 3Python3
| {
"input": [
"6\n1 1 1 0 0 0\n",
"5\n0 0 0 0 0\n",
"7\n1 0 0 1 0 0 1\n",
"100\n0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0\n",
"2\n1 0\n",
"2\n0 0\n",
"100\n1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1\n",
"5\n0 0 0 1 1\n",
"100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0\n",
"100\n0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
"100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0\n"
],
"output": [
"\n9\n",
"\n0\n",
"\n3\n",
"10\n",
"1\n",
"0\n",
"482\n",
"4\n",
"0\n",
"191\n",
"40\n",
"4\n",
"1\n",
"2\n",
"3\n",
"4\n",
"11\n",
"212\n",
"153\n",
"194\n",
"5\n",
"215\n",
"211\n",
"230\n",
"39\n",
"12\n",
"218\n",
"255\n",
"42\n",
"6\n",
"214\n",
"219\n",
"0\n",
"164\n",
"254\n",
"281\n",
"197\n",
"138\n",
"277\n",
"40\n",
"174\n",
"208\n",
"259\n",
"166\n",
"202\n",
"7\n",
"130\n",
"253\n",
"143\n",
"41\n",
"256\n",
"183\n",
"245\n",
"8\n",
"360\n",
"220\n",
"257\n",
"180\n",
"290\n",
"9\n",
"92\n",
"207\n",
"10\n",
"81\n",
"244\n",
"80\n",
"79\n",
"86\n",
"152\n",
"204\n",
"249\n",
"15\n",
"217\n",
"252\n",
"148\n",
"171\n",
"198\n",
"93\n",
"324\n",
"221\n",
"131\n",
"50\n",
"284\n",
"282\n",
"264\n",
"76\n",
"141\n",
"155\n",
"344\n",
"291\n",
"226\n",
"38\n",
"51\n",
"279\n",
"13\n",
"1\n",
"1\n",
"2\n",
"1\n",
"1\n",
"3\n",
"2\n",
"11\n",
"1\n",
"2\n",
"2\n",
"4\n",
"2\n",
"4\n",
"3\n",
"3\n",
"5\n",
"4\n",
"5\n",
"11\n",
"1\n",
"2\n",
"1\n",
"2\n",
"5\n",
"211\n",
"4\n",
"3\n",
"2\n",
"3\n",
"5\n",
"3\n",
"3\n",
"4\n",
"4\n",
"5\n",
"2\n",
"2\n",
"3\n",
"5\n",
"1\n",
"6\n",
"215\n",
"3\n",
"39\n",
"2\n",
"4\n",
"3\n",
"1\n",
"5\n",
"2\n",
"6\n",
"11\n",
"1\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"2\n",
"211\n",
"2\n",
"4\n",
"12\n",
"5\n",
"6\n",
"3\n",
"218\n",
"4\n",
"4\n",
"6\n",
"5\n",
"12\n",
"2\n",
"6\n",
"5\n",
"4\n",
"4\n",
"5\n",
"5\n",
"4\n",
"6\n",
"2\n",
"3\n",
"5\n",
"6\n",
"5\n",
"6\n",
"7\n",
"3\n",
"6\n",
"5\n",
"5\n",
"6\n",
"2\n",
"3\n",
"6\n",
"143\n",
"8\n",
"7\n",
"4\n",
"5\n",
"9\n",
"259\n",
"5\n",
"6\n",
"10\n",
"230\n",
"6\n",
"7\n",
"1\n",
"202\n",
"2\n",
"12\n",
"3\n",
"6\n",
"4\n"
]
} | 2CODEFORCES
|
1525_D. Armchairs_1249 | There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.
For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th armchair is occupied by someone and the j-th armchair is not, you can tell the person sitting in the i-th armchair to move to the j-th armchair. The time it takes a person to move from the i-th armchair to the j-th one is |i - j| minutes. You may perform this operation any number of times, but these operations must be done sequentially, i. e. you cannot tell a person to move until the person you asked to move in the last operation has finished moving to their destination armchair.
You want to achieve the following situation: every seat that was initially occupied must be free. What is the minimum time you need to do it?
Input
The first line contains one integer n (2 β€ n β€ 5000) β the number of armchairs.
The second line contains n integers a_1, a_2, ..., a_n (0 β€ a_i β€ 1). a_i = 1 means that the i-th armchair is initially occupied, a_i = 0 means that it is initially free. The number of occupied armchairs is at most n/2.
Output
Print one integer β the minimum number of minutes you have to spend to achieve the following situation: every seat that was initially occupied must be free.
Examples
Input
7
1 0 0 1 0 0 1
Output
3
Input
6
1 1 1 0 0 0
Output
9
Input
5
0 0 0 0 0
Output
0
Note
In the first test, you can perform the following sequence:
1. ask a person to move from armchair 1 to armchair 2, it takes 1 minute;
2. ask a person to move from armchair 7 to armchair 6, it takes 1 minute;
3. ask a person to move from armchair 4 to armchair 5, it takes 1 minute.
In the second test, you can perform the following sequence:
1. ask a person to move from armchair 1 to armchair 4, it takes 3 minutes;
2. ask a person to move from armchair 2 to armchair 6, it takes 4 minutes;
3. ask a person to move from armchair 4 to armchair 5, it takes 1 minute;
4. ask a person to move from armchair 3 to armchair 4, it takes 1 minute.
In the third test, no seat is occupied so your goal is achieved instantly. | import javax.print.DocFlavor;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Solution {
static int N = 5005;
static int[] arr = new int[N];
static long[][] memo = new long[N][N];
static List<Integer> occupiedSeats = new ArrayList<>();
static List<Integer> emptySeats = new ArrayList<>();
static int n, occSize, empSize;
public static void main(String[] args) throws java.lang.Exception {
out = new PrintWriter(new BufferedOutputStream(System.out));
sc = new FastReader();
int test = 1;
for (int t = 0; t < test; t++) {
solve();
}
out.close();
}
private static void solve() {
n = sc.nextInt();
for (int i = 1; i <= n; i++) {
arr[i] = sc.nextInt();
if (arr[i] == 1) {
occupiedSeats.add(i);
}else {
emptySeats.add(i);
}
}
occSize = occupiedSeats.size();
empSize = emptySeats.size();
for (long[] memset : memo) {
Arrays.fill(memset, -1);
}
out.println(minimumTime(0, 0));
}
private static long minimumTime(int occupied, int empty) {
if (occupied == occSize) {
return 0;
}
if (empty == empSize) {
return Integer.MAX_VALUE;
}
if (memo[occupied][empty] != -1) {
return memo[occupied][empty];
}
long curr = Math.abs(occupiedSeats.get(occupied) - emptySeats.get(empty)) + minimumTime(occupied + 1, empty + 1);
curr = Math.min(curr, minimumTime(occupied, empty + 1));
memo[occupied][empty] = curr;
return curr;
}
public static FastReader sc;
public static PrintWriter out;
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
} | 4JAVA
| {
"input": [
"6\n1 1 1 0 0 0\n",
"5\n0 0 0 0 0\n",
"7\n1 0 0 1 0 0 1\n",
"100\n0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0\n",
"2\n1 0\n",
"2\n0 0\n",
"100\n1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1\n",
"5\n0 0 0 1 1\n",
"100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
"100\n0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
"100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0\n"
],
"output": [
"\n9\n",
"\n0\n",
"\n3\n",
"10\n",
"1\n",
"0\n",
"482\n",
"4\n",
"0\n",
"191\n",
"40\n",
"4\n",
"1\n",
"2\n",
"3\n",
"4\n",
"11\n",
"212\n",
"153\n",
"194\n",
"5\n",
"215\n",
"211\n",
"230\n",
"39\n",
"12\n",
"218\n",
"255\n",
"42\n",
"6\n",
"214\n",
"219\n",
"0\n",
"164\n",
"254\n",
"281\n",
"197\n",
"138\n",
"277\n",
"40\n",
"174\n",
"208\n",
"259\n",
"166\n",
"202\n",
"7\n",
"130\n",
"253\n",
"143\n",
"41\n",
"256\n",
"183\n",
"245\n",
"8\n",
"360\n",
"220\n",
"257\n",
"180\n",
"290\n",
"9\n",
"92\n",
"207\n",
"10\n",
"81\n",
"244\n",
"80\n",
"79\n",
"86\n",
"152\n",
"204\n",
"249\n",
"15\n",
"217\n",
"252\n",
"148\n",
"171\n",
"198\n",
"93\n",
"324\n",
"221\n",
"131\n",
"50\n",
"284\n",
"282\n",
"264\n",
"76\n",
"141\n",
"155\n",
"344\n",
"291\n",
"226\n",
"38\n",
"51\n",
"279\n",
"13\n",
"1\n",
"1\n",
"2\n",
"1\n",
"1\n",
"3\n",
"2\n",
"11\n",
"1\n",
"2\n",
"2\n",
"4\n",
"2\n",
"4\n",
"3\n",
"3\n",
"5\n",
"4\n",
"5\n",
"11\n",
"1\n",
"2\n",
"1\n",
"2\n",
"5\n",
"211\n",
"4\n",
"3\n",
"2\n",
"3\n",
"5\n",
"3\n",
"3\n",
"4\n",
"4\n",
"5\n",
"2\n",
"2\n",
"3\n",
"5\n",
"1\n",
"6\n",
"215\n",
"3\n",
"39\n",
"2\n",
"4\n",
"3\n",
"1\n",
"5\n",
"2\n",
"6\n",
"11\n",
"1\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"2\n",
"211\n",
"2\n",
"4\n",
"12\n",
"5\n",
"6\n",
"3\n",
"218\n",
"4\n",
"4\n",
"6\n",
"5\n",
"12\n",
"2\n",
"6\n",
"5\n",
"4\n",
"4\n",
"5\n",
"5\n",
"4\n",
"6\n",
"2\n",
"3\n",
"5\n",
"6\n",
"5\n",
"6\n",
"7\n",
"3\n",
"6\n",
"5\n",
"5\n",
"6\n",
"2\n",
"3\n",
"6\n",
"143\n",
"8\n",
"7\n",
"4\n",
"5\n",
"9\n",
"259\n",
"5\n",
"6\n",
"10\n",
"230\n",
"6\n",
"7\n",
"1\n",
"202\n",
"2\n",
"12\n",
"3\n",
"6\n",
"4\n"
]
} | 2CODEFORCES
|
157_A. Game Outcome_1250 | Sherlock Holmes and Dr. Watson played some game on a checkered board n Γ n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.
<image>
For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 > 19.
Input
The first line contains an integer n (1 β€ n β€ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100.
Output
Print the single number β the number of the winning squares.
Examples
Input
1
1
Output
0
Input
2
1 2
3 4
Output
2
Input
4
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
Output
6
Note
In the first example two upper squares are winning.
In the third example three left squares in the both middle rows are winning:
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
| z=map(lambda x:map(int,raw_input().split()), ' '*input())
h=[sum(s) for s in z]
v=[sum(s) for s in zip(*z)]
print sum([i>j for i in v for j in h]) | 1Python2
| {
"input": [
"1\n1\n",
"2\n1 2\n3 4\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n",
"9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"4\n89 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 83\n",
"4\n1 2 3 4\n8 7 6 5\n9 10 11 12\n16 15 14 13\n",
"1\n31\n",
"1\n53\n",
"5\n42 74 45 85 14\n68 94 11 3 89\n68 67 97 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n92\n",
"9\n33 80 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 57 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"5\n61 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 9 86 24\n",
"2\n7 3\n9 5\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n91 50 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 25 2 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n1 1\n1 1\n",
"3\n1 2 3\n1 1 1\n1 1 1\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 51 35\n17 18 35 47 59\n29 72 35 87 27\n",
"3\n1 2 3\n4 5 6\n7 8 9\n",
"12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 29 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 47\n59 69 72 47 14\n94 91 98 19 54\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n32 88 94 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 15 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 52 43\n11 22 43 36 99 2 11\n",
"3\n4 3 2\n2 2 2\n2 2 2\n",
"5\n77 44 22 21 20\n84 3 35 86 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"9\n40 70 98 28 44 78 15 73 20\n25 74 46 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"3\n1 2 3\n3 1 2\n2 3 1\n",
"3\n41 94 58\n73 61 8\n34 88 89\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 42 12 21 92 36\n56 47 44 6 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"2\n73 99\n13 100\n",
"4\n81 100 38 54\n8 64 39 59\n6 12 53 65\n79 50 99 71\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 20 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 3 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"4\n89 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"1\n16\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 67 97 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"9\n33 80 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"2\n7 3\n9 10\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n91 46 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 2 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n0 1\n1 1\n",
"3\n1 2 3\n1 0 1\n1 1 1\n",
"3\n1 2 3\n4 10 6\n7 8 9\n",
"12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 42 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n32 88 120 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 15 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 100 43\n11 22 43 36 99 2 11\n",
"9\n40 70 98 28 44 78 15 73 20\n25 83 46 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 62 12 21 92 36\n56 47 44 6 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 6 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 3 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 5 4\n9 5 7 3\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 23 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"12\n8 42 23 20 39 5 23 86 26 85 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 42 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"3\n41 18 58\n73 61 16\n34 88 89\n",
"4\n5 3 8 4\n9 5 3 2\n1 6 5 4\n9 5 7 3\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 23 63 95 73\n20 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"9\n33 102 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 11 44 26\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n30 46 2 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 0 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 88 18\n44 78 6 1 41 94 80\n",
"4\n1 2 4 4\n8 7 6 5\n9 10 11 12\n16 15 14 13\n",
"1\n10\n",
"1\n63\n",
"5\n61 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 8 86 24\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 51 35\n3 18 35 47 59\n29 72 35 87 27\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 71\n59 69 72 47 14\n94 91 98 19 54\n",
"3\n4 4 2\n2 2 2\n2 2 2\n",
"5\n77 44 22 21 20\n84 3 35 167 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"3\n1 2 3\n3 1 2\n2 3 2\n",
"3\n41 94 58\n73 61 16\n34 88 89\n",
"2\n73 99\n13 101\n",
"4\n81 100 38 54\n8 64 39 19\n6 12 53 65\n79 50 99 71\n",
"1\n0\n",
"2\n1 2\n3 7\n",
"4\n1 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"4\n1 2 4 4\n8 7 6 3\n9 10 11 12\n16 15 14 13\n",
"1\n27\n",
"1\n20\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 67 105 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n49\n",
"9\n33 102 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"5\n64 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 9 86 24\n",
"2\n7 4\n9 10\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n30 46 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 0 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n0 1\n1 0\n",
"3\n1 2 3\n1 0 1\n2 1 1\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 88 35\n3 18 35 47 59\n29 72 35 87 27\n",
"3\n2 2 3\n4 10 6\n7 8 9\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 65\n59 69 72 47 14\n94 91 98 19 54\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n7 88 120 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 11 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 100 43\n11 22 43 36 99 2 11\n",
"3\n4 4 2\n2 2 2\n2 3 2\n",
"5\n77 44 22 21 20\n84 5 35 167 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"9\n40 70 98 28 44 78 15 73 20\n25 83 68 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"3\n1 2 3\n3 1 4\n2 3 2\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 62 12 21 92 36\n56 47 44 5 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"2\n73 99\n13 111\n",
"4\n59 100 38 54\n8 64 39 19\n6 12 53 65\n79 50 99 71\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 6 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 0 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"1\n2\n",
"2\n1 2\n3 13\n",
"4\n1 79 26 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"4\n0 2 4 4\n8 7 6 3\n9 10 11 12\n16 15 14 13\n",
"1\n43\n",
"1\n4\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 75 105 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n70\n",
"5\n64 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n110 75 66 62 57\n94 74 9 86 24\n",
"2\n7 4\n17 10\n",
"2\n0 2\n1 0\n",
"3\n1 2 3\n1 0 1\n2 1 2\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 68 18 88 35\n3 18 35 47 59\n29 72 35 87 27\n"
],
"output": [
"0\n",
"2\n",
"6\n",
"40\n",
"10\n",
"8\n",
"0\n",
"0\n",
"12\n",
"0\n",
"41\n",
"13\n",
"2\n",
"12\n",
"26\n",
"0\n",
"4\n",
"13\n",
"4\n",
"77\n",
"13\n",
"10\n",
"21\n",
"4\n",
"13\n",
"44\n",
"0\n",
"5\n",
"31\n",
"2\n",
"8\n",
"46\n",
"40\n",
"8\n",
"0\n",
"13\n",
"37\n",
"2\n",
"11\n",
"26\n",
"1\n",
"4\n",
"3\n",
"77\n",
"10\n",
"21\n",
"43\n",
"31\n",
"45\n",
"6\n",
"41\n",
"76\n",
"5\n",
"7\n",
"42\n",
"39\n",
"12\n",
"27\n",
"8\n",
"0\n",
"0\n",
"13\n",
"13\n",
"13\n",
"4\n",
"13\n",
"2\n",
"4\n",
"2\n",
"8\n",
"0\n",
"2\n",
"8\n",
"8\n",
"0\n",
"0\n",
"13\n",
"0\n",
"37\n",
"13\n",
"2\n",
"11\n",
"26\n",
"0\n",
"4\n",
"13\n",
"3\n",
"13\n",
"10\n",
"21\n",
"4\n",
"13\n",
"43\n",
"3\n",
"31\n",
"2\n",
"8\n",
"45\n",
"0\n",
"2\n",
"7\n",
"8\n",
"0\n",
"0\n",
"13\n",
"0\n",
"13\n",
"2\n",
"1\n",
"4\n",
"11\n"
]
} | 2CODEFORCES
|
157_A. Game Outcome_1251 | Sherlock Holmes and Dr. Watson played some game on a checkered board n Γ n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.
<image>
For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 > 19.
Input
The first line contains an integer n (1 β€ n β€ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100.
Output
Print the single number β the number of the winning squares.
Examples
Input
1
1
Output
0
Input
2
1 2
3 4
Output
2
Input
4
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
Output
6
Note
In the first example two upper squares are winning.
In the third example three left squares in the both middle rows are winning:
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
| #include <bits/stdc++.h>
int main() {
int A[31][31];
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++)
for (j = 0; j < n; j++) scanf("%d", &A[i][j]);
int result = 0;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++) {
int column = 0;
int c = 0;
for (; c < n; c++) column += A[c][j];
int row = 0;
int r = 0;
for (; r < n; r++) row += A[i][r];
if (column > row) result++;
}
printf("%d", result);
return 0;
}
| 2C++
| {
"input": [
"1\n1\n",
"2\n1 2\n3 4\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n",
"9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"4\n89 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 83\n",
"4\n1 2 3 4\n8 7 6 5\n9 10 11 12\n16 15 14 13\n",
"1\n31\n",
"1\n53\n",
"5\n42 74 45 85 14\n68 94 11 3 89\n68 67 97 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n92\n",
"9\n33 80 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 57 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"5\n61 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 9 86 24\n",
"2\n7 3\n9 5\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n91 50 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 25 2 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n1 1\n1 1\n",
"3\n1 2 3\n1 1 1\n1 1 1\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 51 35\n17 18 35 47 59\n29 72 35 87 27\n",
"3\n1 2 3\n4 5 6\n7 8 9\n",
"12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 29 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 47\n59 69 72 47 14\n94 91 98 19 54\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n32 88 94 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 15 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 52 43\n11 22 43 36 99 2 11\n",
"3\n4 3 2\n2 2 2\n2 2 2\n",
"5\n77 44 22 21 20\n84 3 35 86 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"9\n40 70 98 28 44 78 15 73 20\n25 74 46 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"3\n1 2 3\n3 1 2\n2 3 1\n",
"3\n41 94 58\n73 61 8\n34 88 89\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 42 12 21 92 36\n56 47 44 6 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"2\n73 99\n13 100\n",
"4\n81 100 38 54\n8 64 39 59\n6 12 53 65\n79 50 99 71\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 20 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 3 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"4\n89 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"1\n16\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 67 97 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"9\n33 80 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"2\n7 3\n9 10\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n91 46 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 2 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n0 1\n1 1\n",
"3\n1 2 3\n1 0 1\n1 1 1\n",
"3\n1 2 3\n4 10 6\n7 8 9\n",
"12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 42 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n32 88 120 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 15 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 100 43\n11 22 43 36 99 2 11\n",
"9\n40 70 98 28 44 78 15 73 20\n25 83 46 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 62 12 21 92 36\n56 47 44 6 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 6 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 3 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 5 4\n9 5 7 3\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 23 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"12\n8 42 23 20 39 5 23 86 26 85 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 42 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"3\n41 18 58\n73 61 16\n34 88 89\n",
"4\n5 3 8 4\n9 5 3 2\n1 6 5 4\n9 5 7 3\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 23 63 95 73\n20 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"9\n33 102 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 11 44 26\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n30 46 2 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 0 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 88 18\n44 78 6 1 41 94 80\n",
"4\n1 2 4 4\n8 7 6 5\n9 10 11 12\n16 15 14 13\n",
"1\n10\n",
"1\n63\n",
"5\n61 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 8 86 24\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 51 35\n3 18 35 47 59\n29 72 35 87 27\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 71\n59 69 72 47 14\n94 91 98 19 54\n",
"3\n4 4 2\n2 2 2\n2 2 2\n",
"5\n77 44 22 21 20\n84 3 35 167 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"3\n1 2 3\n3 1 2\n2 3 2\n",
"3\n41 94 58\n73 61 16\n34 88 89\n",
"2\n73 99\n13 101\n",
"4\n81 100 38 54\n8 64 39 19\n6 12 53 65\n79 50 99 71\n",
"1\n0\n",
"2\n1 2\n3 7\n",
"4\n1 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"4\n1 2 4 4\n8 7 6 3\n9 10 11 12\n16 15 14 13\n",
"1\n27\n",
"1\n20\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 67 105 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n49\n",
"9\n33 102 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"5\n64 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 9 86 24\n",
"2\n7 4\n9 10\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n30 46 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 0 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n0 1\n1 0\n",
"3\n1 2 3\n1 0 1\n2 1 1\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 88 35\n3 18 35 47 59\n29 72 35 87 27\n",
"3\n2 2 3\n4 10 6\n7 8 9\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 65\n59 69 72 47 14\n94 91 98 19 54\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n7 88 120 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 11 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 100 43\n11 22 43 36 99 2 11\n",
"3\n4 4 2\n2 2 2\n2 3 2\n",
"5\n77 44 22 21 20\n84 5 35 167 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"9\n40 70 98 28 44 78 15 73 20\n25 83 68 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"3\n1 2 3\n3 1 4\n2 3 2\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 62 12 21 92 36\n56 47 44 5 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"2\n73 99\n13 111\n",
"4\n59 100 38 54\n8 64 39 19\n6 12 53 65\n79 50 99 71\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 6 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 0 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"1\n2\n",
"2\n1 2\n3 13\n",
"4\n1 79 26 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"4\n0 2 4 4\n8 7 6 3\n9 10 11 12\n16 15 14 13\n",
"1\n43\n",
"1\n4\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 75 105 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n70\n",
"5\n64 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n110 75 66 62 57\n94 74 9 86 24\n",
"2\n7 4\n17 10\n",
"2\n0 2\n1 0\n",
"3\n1 2 3\n1 0 1\n2 1 2\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 68 18 88 35\n3 18 35 47 59\n29 72 35 87 27\n"
],
"output": [
"0\n",
"2\n",
"6\n",
"40\n",
"10\n",
"8\n",
"0\n",
"0\n",
"12\n",
"0\n",
"41\n",
"13\n",
"2\n",
"12\n",
"26\n",
"0\n",
"4\n",
"13\n",
"4\n",
"77\n",
"13\n",
"10\n",
"21\n",
"4\n",
"13\n",
"44\n",
"0\n",
"5\n",
"31\n",
"2\n",
"8\n",
"46\n",
"40\n",
"8\n",
"0\n",
"13\n",
"37\n",
"2\n",
"11\n",
"26\n",
"1\n",
"4\n",
"3\n",
"77\n",
"10\n",
"21\n",
"43\n",
"31\n",
"45\n",
"6\n",
"41\n",
"76\n",
"5\n",
"7\n",
"42\n",
"39\n",
"12\n",
"27\n",
"8\n",
"0\n",
"0\n",
"13\n",
"13\n",
"13\n",
"4\n",
"13\n",
"2\n",
"4\n",
"2\n",
"8\n",
"0\n",
"2\n",
"8\n",
"8\n",
"0\n",
"0\n",
"13\n",
"0\n",
"37\n",
"13\n",
"2\n",
"11\n",
"26\n",
"0\n",
"4\n",
"13\n",
"3\n",
"13\n",
"10\n",
"21\n",
"4\n",
"13\n",
"43\n",
"3\n",
"31\n",
"2\n",
"8\n",
"45\n",
"0\n",
"2\n",
"7\n",
"8\n",
"0\n",
"0\n",
"13\n",
"0\n",
"13\n",
"2\n",
"1\n",
"4\n",
"11\n"
]
} | 2CODEFORCES
|
157_A. Game Outcome_1252 | Sherlock Holmes and Dr. Watson played some game on a checkered board n Γ n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.
<image>
For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 > 19.
Input
The first line contains an integer n (1 β€ n β€ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100.
Output
Print the single number β the number of the winning squares.
Examples
Input
1
1
Output
0
Input
2
1 2
3 4
Output
2
Input
4
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
Output
6
Note
In the first example two upper squares are winning.
In the third example three left squares in the both middle rows are winning:
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
| n = int(input())
r = lambda : list(map(int, input().split()))
arr = []
for i in range(n):
a = r()
arr.append(a)
row = [sum(i) for i in arr]
col = []
for i in range(n):
c = 0
for j in range(n): c+=arr[j][i]
col.append(c)
ans = 0
for i in range(n):
for j in range(n):
if row[i] < col[j]: ans+=1
print(ans)
| 3Python3
| {
"input": [
"1\n1\n",
"2\n1 2\n3 4\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n",
"9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"4\n89 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 83\n",
"4\n1 2 3 4\n8 7 6 5\n9 10 11 12\n16 15 14 13\n",
"1\n31\n",
"1\n53\n",
"5\n42 74 45 85 14\n68 94 11 3 89\n68 67 97 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n92\n",
"9\n33 80 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 57 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"5\n61 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 9 86 24\n",
"2\n7 3\n9 5\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n91 50 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 25 2 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n1 1\n1 1\n",
"3\n1 2 3\n1 1 1\n1 1 1\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 51 35\n17 18 35 47 59\n29 72 35 87 27\n",
"3\n1 2 3\n4 5 6\n7 8 9\n",
"12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 29 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 47\n59 69 72 47 14\n94 91 98 19 54\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n32 88 94 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 15 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 52 43\n11 22 43 36 99 2 11\n",
"3\n4 3 2\n2 2 2\n2 2 2\n",
"5\n77 44 22 21 20\n84 3 35 86 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"9\n40 70 98 28 44 78 15 73 20\n25 74 46 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"3\n1 2 3\n3 1 2\n2 3 1\n",
"3\n41 94 58\n73 61 8\n34 88 89\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 42 12 21 92 36\n56 47 44 6 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"2\n73 99\n13 100\n",
"4\n81 100 38 54\n8 64 39 59\n6 12 53 65\n79 50 99 71\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 20 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 3 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"4\n89 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"1\n16\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 67 97 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"9\n33 80 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"2\n7 3\n9 10\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n91 46 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 2 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n0 1\n1 1\n",
"3\n1 2 3\n1 0 1\n1 1 1\n",
"3\n1 2 3\n4 10 6\n7 8 9\n",
"12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 42 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n32 88 120 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 15 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 100 43\n11 22 43 36 99 2 11\n",
"9\n40 70 98 28 44 78 15 73 20\n25 83 46 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 62 12 21 92 36\n56 47 44 6 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 6 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 3 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 5 4\n9 5 7 3\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 23 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"12\n8 42 23 20 39 5 23 86 26 85 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 42 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"3\n41 18 58\n73 61 16\n34 88 89\n",
"4\n5 3 8 4\n9 5 3 2\n1 6 5 4\n9 5 7 3\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 23 63 95 73\n20 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"9\n33 102 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 11 44 26\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n30 46 2 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 0 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 88 18\n44 78 6 1 41 94 80\n",
"4\n1 2 4 4\n8 7 6 5\n9 10 11 12\n16 15 14 13\n",
"1\n10\n",
"1\n63\n",
"5\n61 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 8 86 24\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 51 35\n3 18 35 47 59\n29 72 35 87 27\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 71\n59 69 72 47 14\n94 91 98 19 54\n",
"3\n4 4 2\n2 2 2\n2 2 2\n",
"5\n77 44 22 21 20\n84 3 35 167 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"3\n1 2 3\n3 1 2\n2 3 2\n",
"3\n41 94 58\n73 61 16\n34 88 89\n",
"2\n73 99\n13 101\n",
"4\n81 100 38 54\n8 64 39 19\n6 12 53 65\n79 50 99 71\n",
"1\n0\n",
"2\n1 2\n3 7\n",
"4\n1 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"4\n1 2 4 4\n8 7 6 3\n9 10 11 12\n16 15 14 13\n",
"1\n27\n",
"1\n20\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 67 105 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n49\n",
"9\n33 102 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"5\n64 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 9 86 24\n",
"2\n7 4\n9 10\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n30 46 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 0 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n0 1\n1 0\n",
"3\n1 2 3\n1 0 1\n2 1 1\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 88 35\n3 18 35 47 59\n29 72 35 87 27\n",
"3\n2 2 3\n4 10 6\n7 8 9\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 65\n59 69 72 47 14\n94 91 98 19 54\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n7 88 120 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 11 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 100 43\n11 22 43 36 99 2 11\n",
"3\n4 4 2\n2 2 2\n2 3 2\n",
"5\n77 44 22 21 20\n84 5 35 167 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"9\n40 70 98 28 44 78 15 73 20\n25 83 68 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"3\n1 2 3\n3 1 4\n2 3 2\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 62 12 21 92 36\n56 47 44 5 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"2\n73 99\n13 111\n",
"4\n59 100 38 54\n8 64 39 19\n6 12 53 65\n79 50 99 71\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 6 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 0 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"1\n2\n",
"2\n1 2\n3 13\n",
"4\n1 79 26 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"4\n0 2 4 4\n8 7 6 3\n9 10 11 12\n16 15 14 13\n",
"1\n43\n",
"1\n4\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 75 105 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n70\n",
"5\n64 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n110 75 66 62 57\n94 74 9 86 24\n",
"2\n7 4\n17 10\n",
"2\n0 2\n1 0\n",
"3\n1 2 3\n1 0 1\n2 1 2\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 68 18 88 35\n3 18 35 47 59\n29 72 35 87 27\n"
],
"output": [
"0\n",
"2\n",
"6\n",
"40\n",
"10\n",
"8\n",
"0\n",
"0\n",
"12\n",
"0\n",
"41\n",
"13\n",
"2\n",
"12\n",
"26\n",
"0\n",
"4\n",
"13\n",
"4\n",
"77\n",
"13\n",
"10\n",
"21\n",
"4\n",
"13\n",
"44\n",
"0\n",
"5\n",
"31\n",
"2\n",
"8\n",
"46\n",
"40\n",
"8\n",
"0\n",
"13\n",
"37\n",
"2\n",
"11\n",
"26\n",
"1\n",
"4\n",
"3\n",
"77\n",
"10\n",
"21\n",
"43\n",
"31\n",
"45\n",
"6\n",
"41\n",
"76\n",
"5\n",
"7\n",
"42\n",
"39\n",
"12\n",
"27\n",
"8\n",
"0\n",
"0\n",
"13\n",
"13\n",
"13\n",
"4\n",
"13\n",
"2\n",
"4\n",
"2\n",
"8\n",
"0\n",
"2\n",
"8\n",
"8\n",
"0\n",
"0\n",
"13\n",
"0\n",
"37\n",
"13\n",
"2\n",
"11\n",
"26\n",
"0\n",
"4\n",
"13\n",
"3\n",
"13\n",
"10\n",
"21\n",
"4\n",
"13\n",
"43\n",
"3\n",
"31\n",
"2\n",
"8\n",
"45\n",
"0\n",
"2\n",
"7\n",
"8\n",
"0\n",
"0\n",
"13\n",
"0\n",
"13\n",
"2\n",
"1\n",
"4\n",
"11\n"
]
} | 2CODEFORCES
|
157_A. Game Outcome_1253 | Sherlock Holmes and Dr. Watson played some game on a checkered board n Γ n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.
<image>
For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 > 19.
Input
The first line contains an integer n (1 β€ n β€ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100.
Output
Print the single number β the number of the winning squares.
Examples
Input
1
1
Output
0
Input
2
1 2
3 4
Output
2
Input
4
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
Output
6
Note
In the first example two upper squares are winning.
In the third example three left squares in the both middle rows are winning:
5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3
|
import java.util.Scanner;
public class cf1 {
static boolean winning(int[][] mat, int i, int j){
int col = 0;
int row = 0;
for(int k = 0; k < mat.length; k++){
row += mat[i][k];
col += mat[k][j];
}
return col > row;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[][] mat = new int[n][n];
for(int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
mat[i][j] = sc.nextInt();
int res = 0;
for(int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if(winning(mat, i, j)) res++;
System.out.println(res);
}
}
| 4JAVA
| {
"input": [
"1\n1\n",
"2\n1 2\n3 4\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n",
"9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"4\n89 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 83\n",
"4\n1 2 3 4\n8 7 6 5\n9 10 11 12\n16 15 14 13\n",
"1\n31\n",
"1\n53\n",
"5\n42 74 45 85 14\n68 94 11 3 89\n68 67 97 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n92\n",
"9\n33 80 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 57 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"5\n61 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 9 86 24\n",
"2\n7 3\n9 5\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n91 50 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 25 2 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n1 1\n1 1\n",
"3\n1 2 3\n1 1 1\n1 1 1\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 51 35\n17 18 35 47 59\n29 72 35 87 27\n",
"3\n1 2 3\n4 5 6\n7 8 9\n",
"12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 29 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 47\n59 69 72 47 14\n94 91 98 19 54\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n32 88 94 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 15 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 52 43\n11 22 43 36 99 2 11\n",
"3\n4 3 2\n2 2 2\n2 2 2\n",
"5\n77 44 22 21 20\n84 3 35 86 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"9\n40 70 98 28 44 78 15 73 20\n25 74 46 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"3\n1 2 3\n3 1 2\n2 3 1\n",
"3\n41 94 58\n73 61 8\n34 88 89\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 42 12 21 92 36\n56 47 44 6 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"2\n73 99\n13 100\n",
"4\n81 100 38 54\n8 64 39 59\n6 12 53 65\n79 50 99 71\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 20 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 3 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"4\n89 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"1\n16\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 67 97 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"9\n33 80 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"2\n7 3\n9 10\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n91 46 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 2 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n0 1\n1 1\n",
"3\n1 2 3\n1 0 1\n1 1 1\n",
"3\n1 2 3\n4 10 6\n7 8 9\n",
"12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 42 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n32 88 120 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 15 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 100 43\n11 22 43 36 99 2 11\n",
"9\n40 70 98 28 44 78 15 73 20\n25 83 46 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 62 12 21 92 36\n56 47 44 6 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 6 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 3 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 5 4\n9 5 7 3\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 23 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"12\n8 42 23 20 39 5 23 86 26 85 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 42 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 10 13 72 59 16\n73 32 37 93 21 94 43 39 27 53 14 15\n86 16 90 91 14 50 73 61 77 36 93 90\n22 56 30 52 81 70 12 92 75 27 38 12\n",
"3\n41 18 58\n73 61 16\n34 88 89\n",
"4\n5 3 8 4\n9 5 3 2\n1 6 5 4\n9 5 7 3\n",
"9\n53 138 94 41 58 49 88 24 42\n85 11 32 64 40 23 63 95 73\n20 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26 15 76 21 70 78\n",
"9\n33 102 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 11 44 26\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n30 46 2 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 0 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 88 18\n44 78 6 1 41 94 80\n",
"4\n1 2 4 4\n8 7 6 5\n9 10 11 12\n16 15 14 13\n",
"1\n10\n",
"1\n63\n",
"5\n61 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 8 86 24\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 51 35\n3 18 35 47 59\n29 72 35 87 27\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 71\n59 69 72 47 14\n94 91 98 19 54\n",
"3\n4 4 2\n2 2 2\n2 2 2\n",
"5\n77 44 22 21 20\n84 3 35 167 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"3\n1 2 3\n3 1 2\n2 3 2\n",
"3\n41 94 58\n73 61 16\n34 88 89\n",
"2\n73 99\n13 101\n",
"4\n81 100 38 54\n8 64 39 19\n6 12 53 65\n79 50 99 71\n",
"1\n0\n",
"2\n1 2\n3 7\n",
"4\n1 79 14 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"4\n1 2 4 4\n8 7 6 3\n9 10 11 12\n16 15 14 13\n",
"1\n27\n",
"1\n20\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 67 105 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n49\n",
"9\n33 102 34 56 56 33 27 74 57\n14 69 78 44 56 70 26 73 47\n13 42 17 33 78 83 94 70 37\n96 78 92 6 16 68 8 31 46\n67 97 21 10 44 64 15 77 28\n34 44 83 96 63 52 29 27 79\n23 23 13 54 35 16 5 64 36\n29 71 36 78 47 81 72 97 36\n24 83 70 58 36 82 42 44 26\n",
"5\n64 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n62 75 66 62 57\n94 74 9 86 24\n",
"2\n7 4\n9 10\n",
"5\n99 77 32 20 49\n93 81 63 7 58\n37 1 17 35 53\n18 94 38 80 23\n30 46 42 61 63\n",
"7\n62 73 50 63 66 92 2\n27 13 83 84 88 81 47\n60 41 32 0 68 32 60\n7 94 18 98 41 25 72\n69 37 4 10 82 49 91\n76 26 67 27 30 49 18\n44 78 6 1 41 94 80\n",
"2\n0 1\n1 0\n",
"3\n1 2 3\n1 0 1\n2 1 1\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 91 18 88 35\n3 18 35 47 59\n29 72 35 87 27\n",
"3\n2 2 3\n4 10 6\n7 8 9\n",
"5\n1 98 22 9 39\n10 9 44 49 66\n79 17 23 8 65\n59 69 72 47 14\n94 91 98 19 54\n",
"5\n4 91 100 8 48\n78 56 61 49 83\n12 21 95 77 78\n40 20 91 79 25\n7 88 120 28 55\n",
"7\n80 81 45 81 72 19 65\n31 24 11 52 47 1 14\n81 35 42 24 96 59 46\n16 2 59 56 60 98 76\n20 95 10 68 68 56 93\n60 16 68 77 89 100 43\n11 22 43 36 99 2 11\n",
"3\n4 4 2\n2 2 2\n2 3 2\n",
"5\n77 44 22 21 20\n84 5 35 167 35\n97 50 1 44 92\n4 88 56 20 3\n32 56 26 17 80\n",
"9\n40 70 98 28 44 78 15 73 20\n25 83 68 3 27 59 33 96 19\n100 47 99 68 68 67 66 87 31\n26 39 8 91 58 20 91 69 81\n77 43 90 60 17 91 78 85 68\n41 46 47 50 96 18 69 81 26\n10 58 2 36 54 64 69 10 65\n6 86 26 7 88 20 43 92 59\n61 76 13 23 49 28 22 79 8\n",
"3\n1 2 3\n3 1 4\n2 3 2\n",
"8\n44 74 25 81 32 33 55 58\n36 13 28 28 20 65 87 58\n8 35 52 59 34 15 33 16\n2 22 42 29 11 66 30 72\n33 47 8 61 31 64 59 63\n79 36 38 62 12 21 92 36\n56 47 44 5 6 1 37 2\n79 88 79 53 50 69 94 39\n",
"2\n73 99\n13 111\n",
"4\n59 100 38 54\n8 64 39 19\n6 12 53 65\n79 50 99 71\n",
"9\n57 70 94 69 77 59 88 63 83\n6 79 46 5 9 43 6 39 48\n46 35 58 22 17 3 81 82 34\n77 10 40 53 71 84 14 58 56\n6 92 77 81 13 20 77 29 40\n59 53 3 97 21 97 22 11 64\n52 91 82 20 6 0 99 17 44\n79 25 43 69 85 55 95 61 31\n89 24 50 84 54 93 54 60 87\n",
"1\n2\n",
"2\n1 2\n3 13\n",
"4\n1 79 26 89\n73 24 58 89\n62 88 69 65\n58 92 18 5\n",
"4\n0 2 4 4\n8 7 6 3\n9 10 11 12\n16 15 14 13\n",
"1\n43\n",
"1\n4\n",
"5\n42 74 45 85 14\n62 94 11 3 89\n68 75 105 62 66\n65 76 96 18 84\n61 98 28 94 74\n",
"1\n70\n",
"5\n64 45 70 19 48\n52 29 98 21 74\n21 66 12 6 55\n110 75 66 62 57\n94 74 9 86 24\n",
"2\n7 4\n17 10\n",
"2\n0 2\n1 0\n",
"3\n1 2 3\n1 0 1\n2 1 2\n",
"5\n23 70 5 36 69\n83 18 19 98 40\n84 68 18 88 35\n3 18 35 47 59\n29 72 35 87 27\n"
],
"output": [
"0\n",
"2\n",
"6\n",
"40\n",
"10\n",
"8\n",
"0\n",
"0\n",
"12\n",
"0\n",
"41\n",
"13\n",
"2\n",
"12\n",
"26\n",
"0\n",
"4\n",
"13\n",
"4\n",
"77\n",
"13\n",
"10\n",
"21\n",
"4\n",
"13\n",
"44\n",
"0\n",
"5\n",
"31\n",
"2\n",
"8\n",
"46\n",
"40\n",
"8\n",
"0\n",
"13\n",
"37\n",
"2\n",
"11\n",
"26\n",
"1\n",
"4\n",
"3\n",
"77\n",
"10\n",
"21\n",
"43\n",
"31\n",
"45\n",
"6\n",
"41\n",
"76\n",
"5\n",
"7\n",
"42\n",
"39\n",
"12\n",
"27\n",
"8\n",
"0\n",
"0\n",
"13\n",
"13\n",
"13\n",
"4\n",
"13\n",
"2\n",
"4\n",
"2\n",
"8\n",
"0\n",
"2\n",
"8\n",
"8\n",
"0\n",
"0\n",
"13\n",
"0\n",
"37\n",
"13\n",
"2\n",
"11\n",
"26\n",
"0\n",
"4\n",
"13\n",
"3\n",
"13\n",
"10\n",
"21\n",
"4\n",
"13\n",
"43\n",
"3\n",
"31\n",
"2\n",
"8\n",
"45\n",
"0\n",
"2\n",
"7\n",
"8\n",
"0\n",
"0\n",
"13\n",
"0\n",
"13\n",
"2\n",
"1\n",
"4\n",
"11\n"
]
} | 2CODEFORCES
|
178_A1. Educational Game_1254 | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequence) equal to zero for some fixed k (k < n), and this should be done in the smallest possible number of moves.
One move is choosing an integer i (1 β€ i β€ n) such that ai > 0 and an integer t (t β₯ 0) such that i + 2t β€ n. After the values of i and t have been selected, the value of ai is decreased by 1, and the value of ai + 2t is increased by 1. For example, let n = 4 and a = (1, 0, 1, 2), then it is possible to make move i = 3, t = 0 and get a = (1, 0, 0, 3) or to make move i = 1, t = 1 and get a = (0, 0, 2, 2) (the only possible other move is i = 1, t = 0).
You are given n and the initial sequence ai. The task is to calculate the minimum number of moves needed to make the first k elements of the original sequence equal to zero for each possible k (1 β€ k < n).
Input
The first input line contains a single integer n. The second line contains n integers ai (0 β€ ai β€ 104), separated by single spaces.
The input limitations for getting 20 points are:
* 1 β€ n β€ 300
The input limitations for getting 50 points are:
* 1 β€ n β€ 2000
The input limitations for getting 100 points are:
* 1 β€ n β€ 105
Output
Print exactly n - 1 lines: the k-th output line must contain the minimum number of moves needed to make the first k elements of the original sequence ai equal to zero.
Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams, or the %I64d specifier.
Examples
Input
4
1 0 1 2
Output
1
1
3
Input
8
1 2 3 4 5 6 7 8
Output
1
3
6
10
16
24
40 | import sys
import math
n = int(sys.stdin.readline())
avec = map(int, sys.stdin.readline().split())
stepstowin = [0]*(n-1)
for i in range(n-1):
avec[i + int(2**math.floor(math.log(n - 1 - i, 2)))] += avec[i]
stepstowin[i] = stepstowin[i-1] + avec[i]
for v in stepstowin:
print(v) | 1Python2
| {
"input": [
"8\n1 2 3 4 5 6 7 8\n",
"4\n1 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"30\n8 17 20 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"5\n4 1 4 7 6\n",
"9\n13 13 7 11 3 9 3 5 5\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 710 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"30\n8 17 33 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"5\n4 1 1 7 6\n",
"9\n13 13 7 11 3 9 3 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"8\n1 2 5 4 5 6 7 8\n",
"4\n0 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"30\n8 17 33 10 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"9\n13 13 7 11 3 9 1 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 1 12 2\n",
"9\n13 13 8 11 3 9 1 5 4\n",
"8\n1 2 5 4 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 0 12 2\n",
"9\n13 13 8 11 3 9 2 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 4 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 15 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 0 1 2\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 7 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 83 20 99 15 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 2 0 1 2\n",
"9\n13 13 8 10 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 7 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n8 2 0 1 2\n",
"9\n13 13 8 12 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 14 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 9 1 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 8 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 3 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 4 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 26 15 18 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 20 3 3 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 2 4 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 10 8 20 3 3 2 5 5\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 2 7 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 10 8 20 3 3 2 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 6 2 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 17 8 20 3 3 2 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 17 8 20 3 3 1 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 64 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 359 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 9 2 7\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 26 98 57 95 20 36 70 66 75 12 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 359 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 334 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 19 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 26 98 57 95 20 36 70 66 75 12 54 96\n",
"5\n4 1 1 7 2\n",
"8\n1 2 5 4 5 6 7 12\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 149\n",
"9\n13 13 8 11 3 9 2 5 5\n",
"9\n10 10 8 20 3 3 2 5 7\n",
"8\n1 4 7 10 5 6 2 9\n",
"8\n1 4 7 10 5 6 2 7\n",
"9\n10 17 8 20 3 3 1 2 8\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 64 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 20\n",
"9\n10 17 8 20 3 3 1 2 12\n"
],
"output": [
"1\n3\n6\n10\n16\n24\n40\n",
"1\n1\n3\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1722\n1775\n1795\n1894\n1905\n1986\n2012\n2053\n2089\n2140\n2161\n2233\n2261\n2361\n2395\n2398\n2431\n2579\n2615\n2719\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4250\n4549\n4775\n5037\n5231\n5465\n5627\n5929\n6460\n7029\n7478\n8085\n9075\n10211\n12070\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1722\n1775\n1795\n1894\n1905\n1986\n2012\n2053\n2089\n2140\n2161\n2233\n2261\n2361\n2395\n2398\n2431\n2579\n2615\n2719\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4250\n4549\n4775\n5037\n5231\n5465\n5627\n5929\n6460\n7029\n7478\n8085\n9075\n10211\n12070\n",
"8\n25\n45\n60\n78\n93\n113\n123\n128\n141\n146\n150\n165\n174\n185\n199\n225\n257\n284\n315\n351\n375\n423\n454\n495\n549\n634\n713\n907\n",
"4\n5\n9\n17\n",
"13\n26\n33\n44\n47\n69\n79\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15827\n16598\n16769\n17096\n17878\n18715\n19018\n19411\n19703\n20042\n20772\n21606\n22400\n23268\n23808\n24059\n24848\n25741\n25764\n26069\n26185\n26405\n27104\n27967\n28547\n29539\n30400\n30793\n30891\n31144\n31688\n31859\n32195\n32402\n32992\n34012\n34748\n36006\n37108\n38267\n39127\n40409\n40847\n42507\n43244\n44526\n45225\n46709\n48284\n49549\n50887\n51988\n52891\n53510\n54561\n55519\n56550\n57215\n58955\n60075\n61618\n63791\n65150\n66185\n66979\n68203\n69497\n71021\n72551\n75410\n77358\n79599\n81241\n83248\n87005\n91313\n94773\n99789\n102521\n105707\n109158\n113129\n119712\n127026\n133562\n142600\n156395\n171618\n199596\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1125\n1158\n1177\n1262\n1354\n1445\n1511\n1594\n1633\n1733\n1786\n1806\n1905\n1916\n1997\n2023\n2064\n2100\n2151\n2172\n2244\n2272\n2372\n2406\n2409\n2442\n2590\n2626\n2730\n2829\n2862\n2878\n2963\n3086\n3204\n3331\n3508\n3625\n3762\n3903\n3991\n4272\n4571\n4797\n5059\n5253\n5487\n5649\n5962\n6493\n7062\n7511\n8118\n9108\n10244\n12103\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n1989\n2040\n2061\n2133\n2161\n2261\n2295\n2298\n2331\n2479\n2515\n2619\n2718\n2751\n2767\n2841\n2964\n3082\n3209\n3386\n3503\n3640\n3781\n3869\n4050\n4349\n4575\n4837\n5031\n5265\n5427\n5729\n6160\n6729\n7178\n7785\n8675\n9811\n11570\n",
"8\n25\n58\n73\n91\n106\n126\n136\n141\n154\n159\n163\n178\n187\n198\n212\n238\n270\n310\n341\n377\n401\n449\n480\n521\n575\n673\n752\n959\n",
"4\n5\n6\n14\n",
"13\n26\n33\n44\n47\n69\n79\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15827\n16598\n16769\n17096\n17878\n18715\n19018\n19411\n19703\n20042\n20772\n21606\n22400\n23268\n23808\n24059\n24848\n25741\n25764\n26069\n26185\n26405\n27104\n27967\n28547\n29539\n30400\n30793\n30891\n31144\n31688\n31859\n32195\n32402\n32992\n34012\n34748\n36006\n37108\n38267\n39127\n40409\n40847\n42507\n43244\n44526\n45225\n46709\n48284\n49549\n50887\n51988\n52891\n53510\n54561\n55519\n56550\n57215\n58955\n59902\n61445\n63618\n64977\n66012\n66806\n68030\n69324\n70848\n72378\n75237\n77185\n79426\n81068\n83075\n86832\n90967\n94427\n99443\n102175\n105361\n108812\n112783\n119366\n126507\n133043\n142081\n155876\n170926\n198904\n",
"1\n3\n8\n12\n18\n26\n44\n",
"0\n0\n1\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1125\n1158\n1177\n1262\n1354\n1445\n1511\n1594\n1633\n1733\n1806\n1826\n1925\n1936\n2017\n2043\n2084\n2120\n2171\n2192\n2264\n2292\n2392\n2426\n2429\n2462\n2610\n2646\n2750\n2849\n2882\n2898\n2983\n3106\n3224\n3351\n3528\n3645\n3782\n3923\n4011\n4292\n4611\n4837\n5099\n5293\n5527\n5689\n6002\n6533\n7122\n7571\n8178\n9168\n10324\n12183\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n1989\n2040\n2061\n2133\n2161\n2261\n2295\n2298\n2331\n2479\n2515\n2619\n2718\n2751\n2767\n2841\n2964\n3082\n3209\n3386\n3503\n3640\n3781\n3869\n4050\n4349\n4575\n4837\n5031\n5265\n5427\n5729\n6160\n6721\n7170\n7777\n8667\n9795\n11554\n",
"8\n25\n58\n68\n86\n101\n121\n131\n136\n149\n154\n158\n173\n182\n193\n207\n233\n265\n305\n331\n367\n391\n439\n470\n511\n565\n663\n737\n944\n",
"13\n26\n33\n44\n47\n69\n77\n115\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171256\n199344\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1113\n1153\n1186\n1205\n1290\n1382\n1473\n1539\n1622\n1661\n1761\n1834\n1854\n1953\n1964\n2045\n2071\n2112\n2148\n2199\n2220\n2292\n2320\n2420\n2454\n2457\n2490\n2638\n2674\n2778\n2877\n2910\n2926\n3011\n3134\n3252\n3379\n3556\n3673\n3810\n3951\n4039\n4320\n4639\n4865\n5127\n5321\n5555\n5717\n6058\n6589\n7178\n7627\n8234\n9224\n10380\n12239\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n2003\n2054\n2075\n2147\n2175\n2275\n2309\n2312\n2345\n2493\n2529\n2633\n2732\n2765\n2781\n2855\n2978\n3096\n3223\n3400\n3517\n3654\n3795\n3883\n4064\n4363\n4589\n4851\n5045\n5279\n5441\n5743\n6188\n6749\n7198\n7805\n8709\n9837\n11610\n",
"4\n5\n6\n19\n",
"13\n26\n34\n45\n48\n70\n79\n117\n",
"1\n3\n8\n12\n18\n26\n43\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1113\n1153\n1186\n1205\n1290\n1382\n1473\n1539\n1622\n1661\n1761\n1834\n1854\n1953\n1964\n2045\n2071\n2112\n2148\n2199\n2220\n2292\n2320\n2420\n2454\n2457\n2490\n2638\n2674\n2778\n2877\n2910\n2926\n3011\n3134\n3252\n3379\n3556\n3673\n3810\n3951\n4039\n4320\n4639\n4865\n5127\n5313\n5547\n5709\n6050\n6581\n7170\n7619\n8226\n9208\n10364\n12215\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1701\n1721\n1820\n1831\n1912\n1938\n1979\n2029\n2080\n2101\n2173\n2201\n2301\n2335\n2338\n2371\n2519\n2555\n2659\n2784\n2817\n2833\n2907\n3030\n3148\n3275\n3452\n3569\n3706\n3847\n3935\n4116\n4415\n4641\n4903\n5123\n5357\n5519\n5821\n6266\n6827\n7276\n7883\n8813\n9941\n11740\n",
"4\n5\n5\n18\n",
"13\n26\n34\n45\n48\n70\n80\n118\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171177\n199265\n",
"0\n2\n7\n11\n16\n24\n40\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2488\n2636\n2672\n2776\n2875\n2908\n2922\n3007\n3130\n3248\n3375\n3552\n3669\n3806\n3947\n4035\n4316\n4635\n4861\n5123\n5309\n5543\n5703\n6044\n6575\n7164\n7613\n8220\n9202\n10358\n12207\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1701\n1721\n1820\n1835\n1916\n1942\n1983\n2033\n2084\n2105\n2177\n2205\n2305\n2339\n2342\n2375\n2523\n2559\n2663\n2788\n2821\n2837\n2911\n3034\n3152\n3279\n3456\n3573\n3710\n3851\n3939\n4120\n4419\n4645\n4907\n5131\n5365\n5527\n5829\n6274\n6835\n7284\n7891\n8825\n9953\n11756\n",
"4\n5\n5\n7\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10709\n11450\n11764\n12500\n12517\n13389\n14360\n14919\n15567\n15900\n16671\n16842\n17169\n17951\n18788\n19091\n19484\n19776\n20115\n20845\n21679\n22473\n23341\n23881\n24132\n24921\n25814\n25837\n26142\n26258\n26478\n27177\n28040\n28620\n29612\n30473\n30866\n30964\n31217\n31761\n31932\n32268\n32475\n33065\n34085\n34821\n36079\n37181\n38340\n39163\n40445\n40883\n42543\n43280\n44562\n45261\n46745\n48320\n49585\n50923\n52024\n52927\n53546\n54597\n55555\n56586\n57251\n58991\n59938\n61481\n63654\n65013\n66048\n66952\n68176\n69470\n70994\n72524\n75383\n77331\n79572\n81177\n83184\n86941\n91076\n94536\n99552\n102284\n105470\n109031\n113002\n119585\n126726\n133262\n142300\n156095\n171066\n199117\n",
"0\n2\n7\n14\n19\n27\n43\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2488\n2636\n2672\n2776\n2875\n2908\n2922\n3007\n3130\n3248\n3375\n3609\n3726\n3863\n4004\n4092\n4373\n4692\n4918\n5180\n5366\n5600\n5760\n6101\n6632\n7221\n7670\n8334\n9316\n10472\n12321\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1731\n1751\n1850\n1865\n1946\n1972\n2013\n2063\n2114\n2135\n2207\n2235\n2335\n2369\n2372\n2405\n2553\n2589\n2693\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4150\n4479\n4705\n4967\n5191\n5425\n5587\n5889\n6334\n6925\n7374\n7981\n8915\n10073\n11876\n",
"4\n6\n6\n9\n",
"13\n26\n34\n44\n47\n69\n79\n116\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19779\n20509\n21343\n22137\n23005\n23545\n23796\n24585\n25478\n25501\n25806\n25922\n26142\n26841\n27704\n28284\n29276\n30137\n30530\n30628\n30881\n31425\n31596\n31932\n32139\n32729\n33749\n34485\n35743\n36845\n38004\n38827\n40109\n40547\n42207\n42944\n44226\n44925\n46409\n47984\n49249\n50587\n51688\n52591\n53210\n54261\n54883\n55914\n56579\n58319\n59266\n60809\n62982\n64341\n65376\n66280\n67504\n68798\n70322\n71852\n74711\n76659\n78900\n80505\n82512\n86269\n90404\n93864\n98880\n101612\n104798\n108359\n112330\n118913\n126054\n132590\n141628\n155423\n170058\n198109\n",
"0\n2\n7\n14\n19\n27\n38\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n916\n1006\n1031\n1050\n1076\n1091\n1101\n1141\n1174\n1193\n1278\n1370\n1461\n1527\n1610\n1649\n1749\n1822\n1842\n1941\n1952\n2033\n2059\n2100\n2136\n2187\n2208\n2280\n2308\n2408\n2442\n2445\n2478\n2626\n2662\n2766\n2865\n2898\n2912\n2997\n3120\n3238\n3365\n3599\n3716\n3853\n3994\n4082\n4363\n4682\n4908\n5160\n5346\n5580\n5740\n6081\n6612\n7201\n7650\n8304\n9286\n10442\n12291\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1731\n1751\n1850\n1865\n1985\n2011\n2052\n2102\n2153\n2174\n2246\n2274\n2374\n2408\n2411\n2444\n2592\n2628\n2732\n2857\n2890\n2906\n2980\n3103\n3221\n3348\n3525\n3642\n3779\n3920\n4008\n4189\n4518\n4744\n5006\n5230\n5503\n5665\n5967\n6412\n7003\n7452\n8059\n8993\n10190\n11993\n",
"8\n10\n10\n13\n",
"13\n26\n34\n46\n49\n71\n81\n120\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19727\n20457\n21291\n22085\n22953\n23493\n23744\n24533\n25426\n25449\n25754\n25870\n26090\n26789\n27652\n28232\n29224\n30085\n30478\n30576\n30829\n31373\n31544\n31880\n32087\n32677\n33697\n34433\n35691\n36793\n37952\n38775\n40057\n40495\n42155\n42892\n44174\n44873\n46357\n47932\n49197\n50535\n51636\n52539\n53158\n54209\n54831\n55862\n56527\n58267\n59214\n60757\n62930\n64289\n65324\n66228\n67452\n68746\n70270\n71800\n74659\n76607\n78848\n80453\n82408\n86165\n90300\n93760\n98776\n101508\n104694\n108255\n112226\n118809\n125950\n132486\n141524\n155319\n169954\n198005\n",
"0\n2\n7\n21\n26\n34\n45\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1045\n1071\n1086\n1096\n1136\n1169\n1188\n1273\n1365\n1456\n1522\n1605\n1644\n1744\n1817\n1837\n1936\n1947\n2028\n2054\n2095\n2131\n2182\n2203\n2275\n2303\n2403\n2437\n2440\n2468\n2616\n2652\n2756\n2855\n2888\n2902\n2987\n3110\n3228\n3355\n3589\n3706\n3843\n3984\n4072\n4348\n4667\n4893\n5145\n5331\n5565\n5725\n6066\n6592\n7181\n7630\n8284\n9261\n10417\n12261\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4764\n5026\n5250\n5523\n5685\n5997\n6442\n7033\n7482\n8089\n9023\n10220\n12023\n",
"10\n23\n31\n43\n46\n68\n78\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19727\n20457\n21291\n22085\n22953\n23493\n23744\n24533\n25426\n25449\n25754\n25870\n26090\n26789\n27652\n28232\n29224\n30085\n30478\n30576\n30829\n31373\n31544\n31880\n32087\n32677\n33697\n34433\n35691\n36793\n37952\n38775\n40057\n40495\n42155\n42892\n44174\n44873\n46357\n47932\n49197\n50535\n51636\n52539\n53158\n54209\n54831\n55862\n56527\n58267\n59214\n60757\n62930\n64289\n65265\n66169\n67393\n68687\n70211\n71741\n74600\n76548\n78789\n80394\n82349\n86106\n90241\n93701\n98717\n101449\n104576\n108137\n112108\n118691\n125832\n132368\n141406\n155201\n169777\n197828\n",
"0\n2\n7\n17\n22\n30\n41\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1045\n1071\n1086\n1096\n1136\n1169\n1188\n1273\n1365\n1456\n1522\n1605\n1644\n1744\n1817\n1837\n1936\n1947\n2028\n2054\n2095\n2131\n2182\n2203\n2275\n2303\n2403\n2437\n2440\n2468\n2616\n2652\n2756\n2855\n2888\n2902\n2987\n3110\n3228\n3355\n3589\n3706\n3843\n3984\n4072\n4348\n4667\n4933\n5185\n5371\n5605\n5765\n6106\n6632\n7221\n7710\n8364\n9341\n10497\n12381\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4844\n5106\n5330\n5603\n5765\n6077\n6522\n7113\n7642\n8249\n9183\n10380\n12263\n",
"10\n23\n31\n43\n46\n68\n77\n116\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42716\n43998\n44697\n46181\n47756\n49021\n50359\n51460\n52363\n52982\n54033\n54479\n55510\n56175\n57915\n58862\n60405\n62578\n63937\n64913\n65817\n67041\n68335\n69859\n71389\n74248\n76196\n78437\n80042\n81997\n85754\n89889\n93349\n98365\n101097\n104224\n107785\n111756\n118339\n125480\n132016\n141054\n154849\n169249\n197300\n",
"0\n2\n10\n20\n25\n33\n47\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1078\n1093\n1103\n1143\n1176\n1195\n1280\n1372\n1463\n1529\n1612\n1651\n1751\n1824\n1844\n1943\n1954\n2035\n2061\n2102\n2138\n2189\n2210\n2282\n2310\n2410\n2444\n2447\n2475\n2623\n2659\n2770\n2869\n2902\n2916\n3001\n3124\n3242\n3369\n3603\n3720\n3857\n3998\n4086\n4362\n4681\n4947\n5206\n5392\n5626\n5786\n6127\n6653\n7242\n7731\n8392\n9369\n10525\n12409\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4844\n5106\n5330\n5700\n5862\n6174\n6619\n7210\n7739\n8346\n9280\n10574\n12457\n",
"10\n23\n31\n43\n46\n62\n72\n105\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42511\n43793\n44492\n45976\n47551\n48816\n50154\n51255\n52158\n52777\n53828\n54274\n55305\n55970\n57710\n58657\n60200\n62373\n63732\n64708\n65612\n66836\n68130\n69654\n71184\n74043\n75991\n78232\n79837\n81792\n85549\n89684\n92939\n97955\n100687\n103814\n107375\n111346\n117929\n125070\n131401\n140439\n154234\n168634\n196480\n",
"0\n2\n6\n16\n21\n29\n39\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1078\n1093\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2483\n2631\n2667\n2778\n2877\n2910\n2932\n3017\n3140\n3258\n3385\n3619\n3736\n3873\n4014\n4102\n4378\n4697\n4963\n5222\n5408\n5642\n5810\n6151\n6677\n7266\n7755\n8416\n9393\n10549\n12441\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1494\n1560\n1643\n1682\n1682\n1765\n1785\n1884\n1899\n2019\n2045\n2086\n2136\n2187\n2208\n2280\n2308\n2408\n2442\n2445\n2478\n2626\n2662\n2766\n2891\n2924\n2940\n3024\n3147\n3265\n3392\n3569\n3710\n3847\n3988\n4076\n4257\n4586\n4892\n5154\n5378\n5748\n5910\n6222\n6667\n7258\n7787\n8394\n9352\n10646\n12553\n",
"10\n23\n31\n51\n54\n70\n80\n121\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42511\n43793\n44492\n45976\n47551\n48816\n50154\n51255\n52158\n52777\n53828\n54274\n55305\n55970\n57710\n58657\n60200\n62373\n63732\n64708\n65612\n66836\n68130\n69654\n71184\n74043\n75991\n78232\n79837\n81792\n85549\n89684\n92939\n97955\n100687\n103814\n107375\n111346\n117929\n125070\n131401\n140439\n154234\n168737\n196583\n",
"1\n3\n7\n17\n23\n31\n42\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1678\n1778\n1851\n1871\n1970\n1981\n2062\n2088\n2129\n2165\n2216\n2237\n2309\n2337\n2437\n2471\n2474\n2502\n2650\n2686\n2797\n2915\n2948\n2970\n3055\n3178\n3296\n3423\n3657\n3774\n3911\n4052\n4140\n4416\n4735\n5001\n5260\n5465\n5699\n5867\n6208\n6734\n7323\n7812\n8473\n9469\n10625\n12536\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n915\n940\n959\n1011\n1026\n1038\n1077\n1110\n1129\n1214\n1306\n1421\n1487\n1570\n1609\n1609\n1692\n1712\n1811\n1826\n1946\n1972\n2013\n2063\n2114\n2135\n2207\n2235\n2335\n2369\n2372\n2405\n2480\n2516\n2620\n2745\n2778\n2794\n2878\n3001\n3119\n3246\n3423\n3564\n3701\n3842\n3930\n4111\n4367\n4673\n4935\n5159\n5529\n5691\n6003\n6448\n6966\n7495\n8102\n9060\n10281\n12188\n",
"10\n20\n28\n48\n51\n64\n74\n112\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26455\n27318\n27898\n28890\n29751\n30144\n30242\n30495\n31039\n31210\n31546\n31753\n32343\n33363\n33941\n35199\n36301\n37460\n38283\n39565\n40003\n41663\n42195\n43477\n44176\n45660\n47235\n48500\n49838\n50939\n51842\n52461\n53512\n53958\n54989\n55654\n57394\n58341\n59884\n62057\n63416\n64392\n65296\n66520\n67814\n69338\n70710\n73569\n75517\n77758\n79363\n81318\n85075\n89210\n92465\n97481\n100213\n103340\n106901\n110872\n117455\n124596\n130769\n139807\n153602\n168105\n195793\n",
"1\n3\n10\n20\n26\n34\n48\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1675\n1775\n1848\n1868\n1967\n1978\n2059\n2085\n2126\n2162\n2213\n2234\n2306\n2334\n2434\n2468\n2471\n2499\n2647\n2683\n2794\n2912\n2945\n2967\n3052\n3175\n3293\n3420\n3654\n3771\n3908\n4049\n4134\n4410\n4729\n4995\n5254\n5459\n5693\n5861\n6202\n6728\n7317\n7806\n8467\n9463\n10619\n12530\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2228\n2328\n2362\n2365\n2398\n2473\n2509\n2613\n2738\n2771\n2787\n2871\n2994\n3112\n3239\n3416\n3557\n3694\n3835\n3923\n4104\n4360\n4666\n4928\n5152\n5522\n5684\n5996\n6441\n6959\n7488\n8095\n9046\n10267\n12167\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26841\n27704\n28284\n29276\n30137\n30530\n30628\n30881\n31425\n31596\n31932\n32139\n32729\n33749\n34327\n35585\n36687\n37846\n38669\n39951\n40389\n42049\n42581\n43863\n44562\n46046\n47621\n48886\n50224\n51325\n52228\n52847\n53898\n54344\n55375\n56040\n57780\n58727\n60270\n62443\n63802\n64778\n65682\n66906\n68200\n69724\n71096\n73955\n75903\n78144\n79749\n81704\n85461\n89596\n92851\n97867\n100599\n103726\n107287\n111258\n117841\n124982\n131155\n140193\n154374\n168877\n196951\n",
"1\n5\n12\n22\n28\n38\n52\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1675\n1775\n1848\n1868\n1967\n1978\n2059\n2085\n2126\n2162\n2213\n2234\n2306\n2334\n2434\n2468\n2471\n2499\n2647\n2683\n2794\n2912\n2945\n2967\n3052\n3188\n3306\n3433\n3667\n3784\n3921\n4062\n4147\n4423\n4742\n5008\n5267\n5472\n5706\n5874\n6215\n6754\n7343\n7832\n8493\n9502\n10658\n12582\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2228\n2328\n2362\n2365\n2398\n2473\n2509\n2613\n2738\n2771\n2787\n2871\n2994\n3112\n3239\n3416\n3557\n3694\n3835\n3923\n4104\n4360\n4666\n4928\n5152\n5522\n5684\n5996\n6441\n6959\n7488\n8095\n9046\n10258\n12158\n",
"10\n20\n28\n48\n51\n64\n74\n109\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26841\n27704\n28284\n29276\n30137\n30916\n31014\n31267\n31811\n31982\n32318\n32525\n33115\n34135\n34713\n35971\n37073\n38232\n39055\n40337\n40775\n42435\n42967\n44249\n44948\n46432\n48007\n49272\n50610\n51711\n52614\n53233\n54284\n54730\n55761\n56426\n58166\n59499\n61042\n63215\n64574\n65550\n66454\n67678\n68972\n70496\n71868\n74727\n76675\n78916\n80521\n82476\n86233\n90754\n94009\n99025\n101757\n104884\n108445\n112416\n118999\n126526\n132699\n141737\n155918\n170807\n198881\n",
"1\n5\n12\n22\n28\n38\n53\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n867\n896\n969\n973\n1063\n1088\n1114\n1159\n1174\n1192\n1232\n1265\n1284\n1369\n1461\n1552\n1618\n1701\n1737\n1837\n1910\n1930\n2029\n2040\n2121\n2147\n2188\n2224\n2275\n2296\n2368\n2396\n2496\n2530\n2533\n2561\n2709\n2745\n2856\n2974\n3007\n3029\n3114\n3250\n3368\n3495\n3729\n3846\n3983\n4124\n4209\n4485\n4804\n5070\n5329\n5534\n5768\n5936\n6277\n6816\n7405\n7894\n8555\n9564\n10782\n12706\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2219\n2319\n2353\n2356\n2389\n2464\n2500\n2604\n2729\n2762\n2778\n2862\n2985\n3103\n3230\n3407\n3548\n3685\n3826\n3914\n4095\n4351\n4657\n4919\n5143\n5513\n5675\n5987\n6432\n6950\n7479\n8086\n9028\n10240\n12131\n",
"10\n27\n35\n55\n58\n78\n88\n130\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n13796\n14444\n14777\n15548\n15719\n16046\n16828\n17665\n17968\n18361\n18653\n18940\n19670\n20504\n21298\n22166\n22706\n22957\n23746\n24639\n24662\n24967\n25083\n25303\n26388\n27251\n27831\n28823\n29684\n30463\n30561\n30814\n31358\n31529\n31865\n32072\n32662\n33682\n34260\n35518\n36620\n37779\n38602\n39884\n40322\n41982\n42514\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75769\n78010\n79615\n81570\n85327\n89848\n93103\n98119\n100398\n103525\n107086\n111057\n117640\n125167\n131340\n140378\n154106\n168995\n196616\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n867\n896\n969\n973\n1063\n1088\n1114\n1159\n1174\n1192\n1232\n1265\n1284\n1369\n1461\n1552\n1618\n1701\n1737\n1837\n1910\n1930\n2029\n2040\n2121\n2147\n2188\n2224\n2275\n2296\n2368\n2396\n2496\n2530\n2533\n2561\n2709\n2745\n2856\n2974\n3007\n3029\n3114\n3250\n3368\n3495\n3729\n3846\n3983\n4124\n4209\n4485\n4804\n5070\n5339\n5544\n5778\n5946\n6287\n6826\n7415\n7904\n8575\n9584\n10802\n12726\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1944\n1970\n2011\n2061\n2112\n2133\n2205\n2224\n2324\n2358\n2361\n2394\n2474\n2510\n2614\n2739\n2772\n2788\n2872\n2995\n3113\n3240\n3417\n3558\n3695\n3836\n3924\n4105\n4366\n4672\n4934\n5158\n5528\n5690\n6002\n6447\n6970\n7499\n8106\n9048\n10265\n12156\n",
"10\n27\n35\n55\n58\n78\n87\n129\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n13796\n14444\n14777\n15548\n15719\n16046\n16828\n17665\n17968\n18361\n18653\n18940\n19670\n20504\n21298\n22166\n22706\n22957\n23746\n24639\n24676\n24981\n25097\n25317\n26402\n27265\n27845\n28837\n29698\n30477\n30575\n30828\n31372\n31543\n31879\n32086\n32676\n33696\n34274\n35532\n36634\n37793\n38616\n39898\n40336\n41996\n42528\n43810\n44509\n45993\n47568\n48833\n50171\n51272\n52175\n52794\n53845\n54291\n55322\n55987\n57727\n59060\n60603\n62776\n63682\n64658\n65562\n66786\n68080\n69604\n70976\n73835\n75783\n78024\n79629\n81584\n85341\n89862\n93117\n98133\n100412\n103539\n107100\n111071\n117668\n125195\n131368\n140406\n154148\n169037\n196672\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n896\n925\n998\n1002\n1092\n1117\n1143\n1188\n1203\n1221\n1261\n1294\n1313\n1398\n1490\n1581\n1647\n1730\n1766\n1866\n1939\n1959\n2058\n2069\n2150\n2176\n2217\n2253\n2304\n2325\n2397\n2425\n2525\n2559\n2562\n2590\n2738\n2774\n2885\n3003\n3036\n3058\n3143\n3279\n3397\n3524\n3758\n3875\n4012\n4153\n4238\n4514\n4833\n5099\n5368\n5602\n5836\n6004\n6345\n6884\n7473\n7962\n8633\n9671\n10889\n12842\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1888\n1914\n1955\n2005\n2056\n2077\n2149\n2168\n2268\n2302\n2305\n2338\n2418\n2454\n2558\n2683\n2716\n2732\n2816\n2939\n3057\n3184\n3361\n3502\n3639\n3780\n3868\n4049\n4310\n4616\n4878\n5102\n5416\n5578\n5890\n6335\n6858\n7387\n7994\n8936\n10097\n11988\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5612\n6220\n7150\n7763\n8078\n8941\n9569\n9666\n9775\n9840\n10032\n10773\n11087\n11823\n11840\n12712\n13683\n13789\n14437\n14770\n15541\n15712\n16039\n16821\n17658\n17961\n18354\n18646\n18933\n19663\n20497\n21291\n22159\n22699\n22950\n23739\n24632\n24669\n24974\n25090\n25310\n26395\n27258\n27838\n28830\n29691\n30470\n30568\n30821\n31365\n31536\n31872\n32079\n32669\n33689\n34267\n35525\n36627\n37786\n38609\n39891\n40329\n41989\n42521\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75769\n78010\n79615\n81570\n85327\n89848\n93103\n98112\n100391\n103518\n107079\n111050\n117647\n125174\n131347\n140378\n154120\n169009\n196644\n",
"1\n5\n12\n22\n28\n41\n56\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n896\n925\n998\n1002\n1092\n1117\n1143\n1188\n1203\n1221\n1261\n1294\n1313\n1398\n1490\n1581\n1647\n1730\n1766\n1866\n1939\n1959\n2058\n2069\n2150\n2176\n2217\n2253\n2304\n2325\n2397\n2425\n2525\n2559\n2562\n2590\n2738\n2774\n2885\n3003\n3036\n3058\n3143\n3279\n3397\n3524\n3758\n3875\n4012\n4153\n4238\n4514\n4833\n5099\n5368\n5596\n5830\n5998\n6339\n6878\n7467\n7956\n8627\n9659\n10877\n12824\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5612\n6220\n7150\n7763\n8078\n8941\n9569\n9666\n9775\n9840\n10032\n10773\n11087\n11823\n11840\n12712\n13683\n13789\n14437\n14770\n15541\n15712\n16039\n16821\n17658\n17961\n18354\n18646\n18933\n19663\n20497\n21291\n22159\n22699\n22950\n23739\n24632\n24669\n24974\n25090\n25310\n26395\n27258\n27838\n28830\n29691\n30470\n30568\n30821\n31365\n31536\n31872\n32079\n32669\n33689\n34267\n35525\n36627\n37786\n38609\n39891\n40329\n41989\n42521\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75560\n77801\n79406\n81361\n85118\n89639\n92894\n97903\n100182\n103309\n106870\n110841\n117438\n124965\n131138\n140169\n153702\n168591\n196017\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n769\n798\n871\n875\n965\n990\n1016\n1061\n1076\n1094\n1134\n1167\n1186\n1271\n1363\n1454\n1520\n1603\n1639\n1739\n1812\n1832\n1931\n1942\n2023\n2049\n2090\n2126\n2177\n2198\n2270\n2298\n2398\n2432\n2435\n2463\n2611\n2647\n2758\n2876\n2909\n2931\n3016\n3152\n3270\n3397\n3631\n3748\n3885\n4026\n4111\n4387\n4706\n4972\n5241\n5469\n5703\n5871\n6212\n6751\n7340\n7829\n8500\n9532\n10623\n12570\n",
"4\n5\n6\n14\n",
"1\n3\n8\n12\n18\n26\n44\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171256\n199344\n",
"13\n26\n34\n45\n48\n70\n80\n118\n",
"10\n20\n28\n48\n51\n64\n74\n112\n",
"1\n5\n12\n22\n28\n38\n53\n",
"1\n5\n12\n22\n28\n38\n53\n",
"10\n27\n35\n55\n58\n78\n87\n129\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1888\n1914\n1955\n2005\n2056\n2077\n2149\n2168\n2268\n2302\n2305\n2338\n2418\n2454\n2558\n2683\n2716\n2732\n2816\n2939\n3057\n3184\n3361\n3502\n3639\n3780\n3868\n4049\n4310\n4616\n4878\n5102\n5416\n5578\n5890\n6335\n6858\n7387\n7994\n8936\n10097\n11988\n",
"10\n27\n35\n55\n58\n78\n87\n129\n"
]
} | 2CODEFORCES
|
178_A1. Educational Game_1255 | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequence) equal to zero for some fixed k (k < n), and this should be done in the smallest possible number of moves.
One move is choosing an integer i (1 β€ i β€ n) such that ai > 0 and an integer t (t β₯ 0) such that i + 2t β€ n. After the values of i and t have been selected, the value of ai is decreased by 1, and the value of ai + 2t is increased by 1. For example, let n = 4 and a = (1, 0, 1, 2), then it is possible to make move i = 3, t = 0 and get a = (1, 0, 0, 3) or to make move i = 1, t = 1 and get a = (0, 0, 2, 2) (the only possible other move is i = 1, t = 0).
You are given n and the initial sequence ai. The task is to calculate the minimum number of moves needed to make the first k elements of the original sequence equal to zero for each possible k (1 β€ k < n).
Input
The first input line contains a single integer n. The second line contains n integers ai (0 β€ ai β€ 104), separated by single spaces.
The input limitations for getting 20 points are:
* 1 β€ n β€ 300
The input limitations for getting 50 points are:
* 1 β€ n β€ 2000
The input limitations for getting 100 points are:
* 1 β€ n β€ 105
Output
Print exactly n - 1 lines: the k-th output line must contain the minimum number of moves needed to make the first k elements of the original sequence ai equal to zero.
Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams, or the %I64d specifier.
Examples
Input
4
1 0 1 2
Output
1
1
3
Input
8
1 2 3 4 5 6 7 8
Output
1
3
6
10
16
24
40 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
long long ans = 0;
for (int i = 0; i < n - 1; ++i) {
int j = 0;
while (i + (1 << (j + 1)) < n) ++j;
a[i + (1 << j)] += a[i];
ans += a[i];
cout << ans << '\n';
}
return 0;
}
| 2C++
| {
"input": [
"8\n1 2 3 4 5 6 7 8\n",
"4\n1 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"30\n8 17 20 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"5\n4 1 4 7 6\n",
"9\n13 13 7 11 3 9 3 5 5\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 710 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"30\n8 17 33 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"5\n4 1 1 7 6\n",
"9\n13 13 7 11 3 9 3 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"8\n1 2 5 4 5 6 7 8\n",
"4\n0 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"30\n8 17 33 10 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"9\n13 13 7 11 3 9 1 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 1 12 2\n",
"9\n13 13 8 11 3 9 1 5 4\n",
"8\n1 2 5 4 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 0 12 2\n",
"9\n13 13 8 11 3 9 2 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 4 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 15 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 0 1 2\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 7 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 83 20 99 15 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 2 0 1 2\n",
"9\n13 13 8 10 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 7 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n8 2 0 1 2\n",
"9\n13 13 8 12 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 14 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 9 1 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 8 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 3 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 4 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 26 15 18 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 20 3 3 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 2 4 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 10 8 20 3 3 2 5 5\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 2 7 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 10 8 20 3 3 2 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 6 2 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 17 8 20 3 3 2 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 17 8 20 3 3 1 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 64 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 359 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 9 2 7\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 26 98 57 95 20 36 70 66 75 12 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 359 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 334 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 19 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 26 98 57 95 20 36 70 66 75 12 54 96\n",
"5\n4 1 1 7 2\n",
"8\n1 2 5 4 5 6 7 12\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 149\n",
"9\n13 13 8 11 3 9 2 5 5\n",
"9\n10 10 8 20 3 3 2 5 7\n",
"8\n1 4 7 10 5 6 2 9\n",
"8\n1 4 7 10 5 6 2 7\n",
"9\n10 17 8 20 3 3 1 2 8\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 64 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 20\n",
"9\n10 17 8 20 3 3 1 2 12\n"
],
"output": [
"1\n3\n6\n10\n16\n24\n40\n",
"1\n1\n3\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1722\n1775\n1795\n1894\n1905\n1986\n2012\n2053\n2089\n2140\n2161\n2233\n2261\n2361\n2395\n2398\n2431\n2579\n2615\n2719\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4250\n4549\n4775\n5037\n5231\n5465\n5627\n5929\n6460\n7029\n7478\n8085\n9075\n10211\n12070\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1722\n1775\n1795\n1894\n1905\n1986\n2012\n2053\n2089\n2140\n2161\n2233\n2261\n2361\n2395\n2398\n2431\n2579\n2615\n2719\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4250\n4549\n4775\n5037\n5231\n5465\n5627\n5929\n6460\n7029\n7478\n8085\n9075\n10211\n12070\n",
"8\n25\n45\n60\n78\n93\n113\n123\n128\n141\n146\n150\n165\n174\n185\n199\n225\n257\n284\n315\n351\n375\n423\n454\n495\n549\n634\n713\n907\n",
"4\n5\n9\n17\n",
"13\n26\n33\n44\n47\n69\n79\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15827\n16598\n16769\n17096\n17878\n18715\n19018\n19411\n19703\n20042\n20772\n21606\n22400\n23268\n23808\n24059\n24848\n25741\n25764\n26069\n26185\n26405\n27104\n27967\n28547\n29539\n30400\n30793\n30891\n31144\n31688\n31859\n32195\n32402\n32992\n34012\n34748\n36006\n37108\n38267\n39127\n40409\n40847\n42507\n43244\n44526\n45225\n46709\n48284\n49549\n50887\n51988\n52891\n53510\n54561\n55519\n56550\n57215\n58955\n60075\n61618\n63791\n65150\n66185\n66979\n68203\n69497\n71021\n72551\n75410\n77358\n79599\n81241\n83248\n87005\n91313\n94773\n99789\n102521\n105707\n109158\n113129\n119712\n127026\n133562\n142600\n156395\n171618\n199596\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1125\n1158\n1177\n1262\n1354\n1445\n1511\n1594\n1633\n1733\n1786\n1806\n1905\n1916\n1997\n2023\n2064\n2100\n2151\n2172\n2244\n2272\n2372\n2406\n2409\n2442\n2590\n2626\n2730\n2829\n2862\n2878\n2963\n3086\n3204\n3331\n3508\n3625\n3762\n3903\n3991\n4272\n4571\n4797\n5059\n5253\n5487\n5649\n5962\n6493\n7062\n7511\n8118\n9108\n10244\n12103\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n1989\n2040\n2061\n2133\n2161\n2261\n2295\n2298\n2331\n2479\n2515\n2619\n2718\n2751\n2767\n2841\n2964\n3082\n3209\n3386\n3503\n3640\n3781\n3869\n4050\n4349\n4575\n4837\n5031\n5265\n5427\n5729\n6160\n6729\n7178\n7785\n8675\n9811\n11570\n",
"8\n25\n58\n73\n91\n106\n126\n136\n141\n154\n159\n163\n178\n187\n198\n212\n238\n270\n310\n341\n377\n401\n449\n480\n521\n575\n673\n752\n959\n",
"4\n5\n6\n14\n",
"13\n26\n33\n44\n47\n69\n79\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15827\n16598\n16769\n17096\n17878\n18715\n19018\n19411\n19703\n20042\n20772\n21606\n22400\n23268\n23808\n24059\n24848\n25741\n25764\n26069\n26185\n26405\n27104\n27967\n28547\n29539\n30400\n30793\n30891\n31144\n31688\n31859\n32195\n32402\n32992\n34012\n34748\n36006\n37108\n38267\n39127\n40409\n40847\n42507\n43244\n44526\n45225\n46709\n48284\n49549\n50887\n51988\n52891\n53510\n54561\n55519\n56550\n57215\n58955\n59902\n61445\n63618\n64977\n66012\n66806\n68030\n69324\n70848\n72378\n75237\n77185\n79426\n81068\n83075\n86832\n90967\n94427\n99443\n102175\n105361\n108812\n112783\n119366\n126507\n133043\n142081\n155876\n170926\n198904\n",
"1\n3\n8\n12\n18\n26\n44\n",
"0\n0\n1\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1125\n1158\n1177\n1262\n1354\n1445\n1511\n1594\n1633\n1733\n1806\n1826\n1925\n1936\n2017\n2043\n2084\n2120\n2171\n2192\n2264\n2292\n2392\n2426\n2429\n2462\n2610\n2646\n2750\n2849\n2882\n2898\n2983\n3106\n3224\n3351\n3528\n3645\n3782\n3923\n4011\n4292\n4611\n4837\n5099\n5293\n5527\n5689\n6002\n6533\n7122\n7571\n8178\n9168\n10324\n12183\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n1989\n2040\n2061\n2133\n2161\n2261\n2295\n2298\n2331\n2479\n2515\n2619\n2718\n2751\n2767\n2841\n2964\n3082\n3209\n3386\n3503\n3640\n3781\n3869\n4050\n4349\n4575\n4837\n5031\n5265\n5427\n5729\n6160\n6721\n7170\n7777\n8667\n9795\n11554\n",
"8\n25\n58\n68\n86\n101\n121\n131\n136\n149\n154\n158\n173\n182\n193\n207\n233\n265\n305\n331\n367\n391\n439\n470\n511\n565\n663\n737\n944\n",
"13\n26\n33\n44\n47\n69\n77\n115\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171256\n199344\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1113\n1153\n1186\n1205\n1290\n1382\n1473\n1539\n1622\n1661\n1761\n1834\n1854\n1953\n1964\n2045\n2071\n2112\n2148\n2199\n2220\n2292\n2320\n2420\n2454\n2457\n2490\n2638\n2674\n2778\n2877\n2910\n2926\n3011\n3134\n3252\n3379\n3556\n3673\n3810\n3951\n4039\n4320\n4639\n4865\n5127\n5321\n5555\n5717\n6058\n6589\n7178\n7627\n8234\n9224\n10380\n12239\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n2003\n2054\n2075\n2147\n2175\n2275\n2309\n2312\n2345\n2493\n2529\n2633\n2732\n2765\n2781\n2855\n2978\n3096\n3223\n3400\n3517\n3654\n3795\n3883\n4064\n4363\n4589\n4851\n5045\n5279\n5441\n5743\n6188\n6749\n7198\n7805\n8709\n9837\n11610\n",
"4\n5\n6\n19\n",
"13\n26\n34\n45\n48\n70\n79\n117\n",
"1\n3\n8\n12\n18\n26\n43\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1113\n1153\n1186\n1205\n1290\n1382\n1473\n1539\n1622\n1661\n1761\n1834\n1854\n1953\n1964\n2045\n2071\n2112\n2148\n2199\n2220\n2292\n2320\n2420\n2454\n2457\n2490\n2638\n2674\n2778\n2877\n2910\n2926\n3011\n3134\n3252\n3379\n3556\n3673\n3810\n3951\n4039\n4320\n4639\n4865\n5127\n5313\n5547\n5709\n6050\n6581\n7170\n7619\n8226\n9208\n10364\n12215\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1701\n1721\n1820\n1831\n1912\n1938\n1979\n2029\n2080\n2101\n2173\n2201\n2301\n2335\n2338\n2371\n2519\n2555\n2659\n2784\n2817\n2833\n2907\n3030\n3148\n3275\n3452\n3569\n3706\n3847\n3935\n4116\n4415\n4641\n4903\n5123\n5357\n5519\n5821\n6266\n6827\n7276\n7883\n8813\n9941\n11740\n",
"4\n5\n5\n18\n",
"13\n26\n34\n45\n48\n70\n80\n118\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171177\n199265\n",
"0\n2\n7\n11\n16\n24\n40\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2488\n2636\n2672\n2776\n2875\n2908\n2922\n3007\n3130\n3248\n3375\n3552\n3669\n3806\n3947\n4035\n4316\n4635\n4861\n5123\n5309\n5543\n5703\n6044\n6575\n7164\n7613\n8220\n9202\n10358\n12207\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1701\n1721\n1820\n1835\n1916\n1942\n1983\n2033\n2084\n2105\n2177\n2205\n2305\n2339\n2342\n2375\n2523\n2559\n2663\n2788\n2821\n2837\n2911\n3034\n3152\n3279\n3456\n3573\n3710\n3851\n3939\n4120\n4419\n4645\n4907\n5131\n5365\n5527\n5829\n6274\n6835\n7284\n7891\n8825\n9953\n11756\n",
"4\n5\n5\n7\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10709\n11450\n11764\n12500\n12517\n13389\n14360\n14919\n15567\n15900\n16671\n16842\n17169\n17951\n18788\n19091\n19484\n19776\n20115\n20845\n21679\n22473\n23341\n23881\n24132\n24921\n25814\n25837\n26142\n26258\n26478\n27177\n28040\n28620\n29612\n30473\n30866\n30964\n31217\n31761\n31932\n32268\n32475\n33065\n34085\n34821\n36079\n37181\n38340\n39163\n40445\n40883\n42543\n43280\n44562\n45261\n46745\n48320\n49585\n50923\n52024\n52927\n53546\n54597\n55555\n56586\n57251\n58991\n59938\n61481\n63654\n65013\n66048\n66952\n68176\n69470\n70994\n72524\n75383\n77331\n79572\n81177\n83184\n86941\n91076\n94536\n99552\n102284\n105470\n109031\n113002\n119585\n126726\n133262\n142300\n156095\n171066\n199117\n",
"0\n2\n7\n14\n19\n27\n43\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2488\n2636\n2672\n2776\n2875\n2908\n2922\n3007\n3130\n3248\n3375\n3609\n3726\n3863\n4004\n4092\n4373\n4692\n4918\n5180\n5366\n5600\n5760\n6101\n6632\n7221\n7670\n8334\n9316\n10472\n12321\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1731\n1751\n1850\n1865\n1946\n1972\n2013\n2063\n2114\n2135\n2207\n2235\n2335\n2369\n2372\n2405\n2553\n2589\n2693\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4150\n4479\n4705\n4967\n5191\n5425\n5587\n5889\n6334\n6925\n7374\n7981\n8915\n10073\n11876\n",
"4\n6\n6\n9\n",
"13\n26\n34\n44\n47\n69\n79\n116\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19779\n20509\n21343\n22137\n23005\n23545\n23796\n24585\n25478\n25501\n25806\n25922\n26142\n26841\n27704\n28284\n29276\n30137\n30530\n30628\n30881\n31425\n31596\n31932\n32139\n32729\n33749\n34485\n35743\n36845\n38004\n38827\n40109\n40547\n42207\n42944\n44226\n44925\n46409\n47984\n49249\n50587\n51688\n52591\n53210\n54261\n54883\n55914\n56579\n58319\n59266\n60809\n62982\n64341\n65376\n66280\n67504\n68798\n70322\n71852\n74711\n76659\n78900\n80505\n82512\n86269\n90404\n93864\n98880\n101612\n104798\n108359\n112330\n118913\n126054\n132590\n141628\n155423\n170058\n198109\n",
"0\n2\n7\n14\n19\n27\n38\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n916\n1006\n1031\n1050\n1076\n1091\n1101\n1141\n1174\n1193\n1278\n1370\n1461\n1527\n1610\n1649\n1749\n1822\n1842\n1941\n1952\n2033\n2059\n2100\n2136\n2187\n2208\n2280\n2308\n2408\n2442\n2445\n2478\n2626\n2662\n2766\n2865\n2898\n2912\n2997\n3120\n3238\n3365\n3599\n3716\n3853\n3994\n4082\n4363\n4682\n4908\n5160\n5346\n5580\n5740\n6081\n6612\n7201\n7650\n8304\n9286\n10442\n12291\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1731\n1751\n1850\n1865\n1985\n2011\n2052\n2102\n2153\n2174\n2246\n2274\n2374\n2408\n2411\n2444\n2592\n2628\n2732\n2857\n2890\n2906\n2980\n3103\n3221\n3348\n3525\n3642\n3779\n3920\n4008\n4189\n4518\n4744\n5006\n5230\n5503\n5665\n5967\n6412\n7003\n7452\n8059\n8993\n10190\n11993\n",
"8\n10\n10\n13\n",
"13\n26\n34\n46\n49\n71\n81\n120\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19727\n20457\n21291\n22085\n22953\n23493\n23744\n24533\n25426\n25449\n25754\n25870\n26090\n26789\n27652\n28232\n29224\n30085\n30478\n30576\n30829\n31373\n31544\n31880\n32087\n32677\n33697\n34433\n35691\n36793\n37952\n38775\n40057\n40495\n42155\n42892\n44174\n44873\n46357\n47932\n49197\n50535\n51636\n52539\n53158\n54209\n54831\n55862\n56527\n58267\n59214\n60757\n62930\n64289\n65324\n66228\n67452\n68746\n70270\n71800\n74659\n76607\n78848\n80453\n82408\n86165\n90300\n93760\n98776\n101508\n104694\n108255\n112226\n118809\n125950\n132486\n141524\n155319\n169954\n198005\n",
"0\n2\n7\n21\n26\n34\n45\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1045\n1071\n1086\n1096\n1136\n1169\n1188\n1273\n1365\n1456\n1522\n1605\n1644\n1744\n1817\n1837\n1936\n1947\n2028\n2054\n2095\n2131\n2182\n2203\n2275\n2303\n2403\n2437\n2440\n2468\n2616\n2652\n2756\n2855\n2888\n2902\n2987\n3110\n3228\n3355\n3589\n3706\n3843\n3984\n4072\n4348\n4667\n4893\n5145\n5331\n5565\n5725\n6066\n6592\n7181\n7630\n8284\n9261\n10417\n12261\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4764\n5026\n5250\n5523\n5685\n5997\n6442\n7033\n7482\n8089\n9023\n10220\n12023\n",
"10\n23\n31\n43\n46\n68\n78\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19727\n20457\n21291\n22085\n22953\n23493\n23744\n24533\n25426\n25449\n25754\n25870\n26090\n26789\n27652\n28232\n29224\n30085\n30478\n30576\n30829\n31373\n31544\n31880\n32087\n32677\n33697\n34433\n35691\n36793\n37952\n38775\n40057\n40495\n42155\n42892\n44174\n44873\n46357\n47932\n49197\n50535\n51636\n52539\n53158\n54209\n54831\n55862\n56527\n58267\n59214\n60757\n62930\n64289\n65265\n66169\n67393\n68687\n70211\n71741\n74600\n76548\n78789\n80394\n82349\n86106\n90241\n93701\n98717\n101449\n104576\n108137\n112108\n118691\n125832\n132368\n141406\n155201\n169777\n197828\n",
"0\n2\n7\n17\n22\n30\n41\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1045\n1071\n1086\n1096\n1136\n1169\n1188\n1273\n1365\n1456\n1522\n1605\n1644\n1744\n1817\n1837\n1936\n1947\n2028\n2054\n2095\n2131\n2182\n2203\n2275\n2303\n2403\n2437\n2440\n2468\n2616\n2652\n2756\n2855\n2888\n2902\n2987\n3110\n3228\n3355\n3589\n3706\n3843\n3984\n4072\n4348\n4667\n4933\n5185\n5371\n5605\n5765\n6106\n6632\n7221\n7710\n8364\n9341\n10497\n12381\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4844\n5106\n5330\n5603\n5765\n6077\n6522\n7113\n7642\n8249\n9183\n10380\n12263\n",
"10\n23\n31\n43\n46\n68\n77\n116\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42716\n43998\n44697\n46181\n47756\n49021\n50359\n51460\n52363\n52982\n54033\n54479\n55510\n56175\n57915\n58862\n60405\n62578\n63937\n64913\n65817\n67041\n68335\n69859\n71389\n74248\n76196\n78437\n80042\n81997\n85754\n89889\n93349\n98365\n101097\n104224\n107785\n111756\n118339\n125480\n132016\n141054\n154849\n169249\n197300\n",
"0\n2\n10\n20\n25\n33\n47\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1078\n1093\n1103\n1143\n1176\n1195\n1280\n1372\n1463\n1529\n1612\n1651\n1751\n1824\n1844\n1943\n1954\n2035\n2061\n2102\n2138\n2189\n2210\n2282\n2310\n2410\n2444\n2447\n2475\n2623\n2659\n2770\n2869\n2902\n2916\n3001\n3124\n3242\n3369\n3603\n3720\n3857\n3998\n4086\n4362\n4681\n4947\n5206\n5392\n5626\n5786\n6127\n6653\n7242\n7731\n8392\n9369\n10525\n12409\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4844\n5106\n5330\n5700\n5862\n6174\n6619\n7210\n7739\n8346\n9280\n10574\n12457\n",
"10\n23\n31\n43\n46\n62\n72\n105\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42511\n43793\n44492\n45976\n47551\n48816\n50154\n51255\n52158\n52777\n53828\n54274\n55305\n55970\n57710\n58657\n60200\n62373\n63732\n64708\n65612\n66836\n68130\n69654\n71184\n74043\n75991\n78232\n79837\n81792\n85549\n89684\n92939\n97955\n100687\n103814\n107375\n111346\n117929\n125070\n131401\n140439\n154234\n168634\n196480\n",
"0\n2\n6\n16\n21\n29\n39\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1078\n1093\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2483\n2631\n2667\n2778\n2877\n2910\n2932\n3017\n3140\n3258\n3385\n3619\n3736\n3873\n4014\n4102\n4378\n4697\n4963\n5222\n5408\n5642\n5810\n6151\n6677\n7266\n7755\n8416\n9393\n10549\n12441\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1494\n1560\n1643\n1682\n1682\n1765\n1785\n1884\n1899\n2019\n2045\n2086\n2136\n2187\n2208\n2280\n2308\n2408\n2442\n2445\n2478\n2626\n2662\n2766\n2891\n2924\n2940\n3024\n3147\n3265\n3392\n3569\n3710\n3847\n3988\n4076\n4257\n4586\n4892\n5154\n5378\n5748\n5910\n6222\n6667\n7258\n7787\n8394\n9352\n10646\n12553\n",
"10\n23\n31\n51\n54\n70\n80\n121\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42511\n43793\n44492\n45976\n47551\n48816\n50154\n51255\n52158\n52777\n53828\n54274\n55305\n55970\n57710\n58657\n60200\n62373\n63732\n64708\n65612\n66836\n68130\n69654\n71184\n74043\n75991\n78232\n79837\n81792\n85549\n89684\n92939\n97955\n100687\n103814\n107375\n111346\n117929\n125070\n131401\n140439\n154234\n168737\n196583\n",
"1\n3\n7\n17\n23\n31\n42\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1678\n1778\n1851\n1871\n1970\n1981\n2062\n2088\n2129\n2165\n2216\n2237\n2309\n2337\n2437\n2471\n2474\n2502\n2650\n2686\n2797\n2915\n2948\n2970\n3055\n3178\n3296\n3423\n3657\n3774\n3911\n4052\n4140\n4416\n4735\n5001\n5260\n5465\n5699\n5867\n6208\n6734\n7323\n7812\n8473\n9469\n10625\n12536\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n915\n940\n959\n1011\n1026\n1038\n1077\n1110\n1129\n1214\n1306\n1421\n1487\n1570\n1609\n1609\n1692\n1712\n1811\n1826\n1946\n1972\n2013\n2063\n2114\n2135\n2207\n2235\n2335\n2369\n2372\n2405\n2480\n2516\n2620\n2745\n2778\n2794\n2878\n3001\n3119\n3246\n3423\n3564\n3701\n3842\n3930\n4111\n4367\n4673\n4935\n5159\n5529\n5691\n6003\n6448\n6966\n7495\n8102\n9060\n10281\n12188\n",
"10\n20\n28\n48\n51\n64\n74\n112\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26455\n27318\n27898\n28890\n29751\n30144\n30242\n30495\n31039\n31210\n31546\n31753\n32343\n33363\n33941\n35199\n36301\n37460\n38283\n39565\n40003\n41663\n42195\n43477\n44176\n45660\n47235\n48500\n49838\n50939\n51842\n52461\n53512\n53958\n54989\n55654\n57394\n58341\n59884\n62057\n63416\n64392\n65296\n66520\n67814\n69338\n70710\n73569\n75517\n77758\n79363\n81318\n85075\n89210\n92465\n97481\n100213\n103340\n106901\n110872\n117455\n124596\n130769\n139807\n153602\n168105\n195793\n",
"1\n3\n10\n20\n26\n34\n48\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1675\n1775\n1848\n1868\n1967\n1978\n2059\n2085\n2126\n2162\n2213\n2234\n2306\n2334\n2434\n2468\n2471\n2499\n2647\n2683\n2794\n2912\n2945\n2967\n3052\n3175\n3293\n3420\n3654\n3771\n3908\n4049\n4134\n4410\n4729\n4995\n5254\n5459\n5693\n5861\n6202\n6728\n7317\n7806\n8467\n9463\n10619\n12530\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2228\n2328\n2362\n2365\n2398\n2473\n2509\n2613\n2738\n2771\n2787\n2871\n2994\n3112\n3239\n3416\n3557\n3694\n3835\n3923\n4104\n4360\n4666\n4928\n5152\n5522\n5684\n5996\n6441\n6959\n7488\n8095\n9046\n10267\n12167\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26841\n27704\n28284\n29276\n30137\n30530\n30628\n30881\n31425\n31596\n31932\n32139\n32729\n33749\n34327\n35585\n36687\n37846\n38669\n39951\n40389\n42049\n42581\n43863\n44562\n46046\n47621\n48886\n50224\n51325\n52228\n52847\n53898\n54344\n55375\n56040\n57780\n58727\n60270\n62443\n63802\n64778\n65682\n66906\n68200\n69724\n71096\n73955\n75903\n78144\n79749\n81704\n85461\n89596\n92851\n97867\n100599\n103726\n107287\n111258\n117841\n124982\n131155\n140193\n154374\n168877\n196951\n",
"1\n5\n12\n22\n28\n38\n52\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1675\n1775\n1848\n1868\n1967\n1978\n2059\n2085\n2126\n2162\n2213\n2234\n2306\n2334\n2434\n2468\n2471\n2499\n2647\n2683\n2794\n2912\n2945\n2967\n3052\n3188\n3306\n3433\n3667\n3784\n3921\n4062\n4147\n4423\n4742\n5008\n5267\n5472\n5706\n5874\n6215\n6754\n7343\n7832\n8493\n9502\n10658\n12582\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2228\n2328\n2362\n2365\n2398\n2473\n2509\n2613\n2738\n2771\n2787\n2871\n2994\n3112\n3239\n3416\n3557\n3694\n3835\n3923\n4104\n4360\n4666\n4928\n5152\n5522\n5684\n5996\n6441\n6959\n7488\n8095\n9046\n10258\n12158\n",
"10\n20\n28\n48\n51\n64\n74\n109\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26841\n27704\n28284\n29276\n30137\n30916\n31014\n31267\n31811\n31982\n32318\n32525\n33115\n34135\n34713\n35971\n37073\n38232\n39055\n40337\n40775\n42435\n42967\n44249\n44948\n46432\n48007\n49272\n50610\n51711\n52614\n53233\n54284\n54730\n55761\n56426\n58166\n59499\n61042\n63215\n64574\n65550\n66454\n67678\n68972\n70496\n71868\n74727\n76675\n78916\n80521\n82476\n86233\n90754\n94009\n99025\n101757\n104884\n108445\n112416\n118999\n126526\n132699\n141737\n155918\n170807\n198881\n",
"1\n5\n12\n22\n28\n38\n53\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n867\n896\n969\n973\n1063\n1088\n1114\n1159\n1174\n1192\n1232\n1265\n1284\n1369\n1461\n1552\n1618\n1701\n1737\n1837\n1910\n1930\n2029\n2040\n2121\n2147\n2188\n2224\n2275\n2296\n2368\n2396\n2496\n2530\n2533\n2561\n2709\n2745\n2856\n2974\n3007\n3029\n3114\n3250\n3368\n3495\n3729\n3846\n3983\n4124\n4209\n4485\n4804\n5070\n5329\n5534\n5768\n5936\n6277\n6816\n7405\n7894\n8555\n9564\n10782\n12706\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2219\n2319\n2353\n2356\n2389\n2464\n2500\n2604\n2729\n2762\n2778\n2862\n2985\n3103\n3230\n3407\n3548\n3685\n3826\n3914\n4095\n4351\n4657\n4919\n5143\n5513\n5675\n5987\n6432\n6950\n7479\n8086\n9028\n10240\n12131\n",
"10\n27\n35\n55\n58\n78\n88\n130\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n13796\n14444\n14777\n15548\n15719\n16046\n16828\n17665\n17968\n18361\n18653\n18940\n19670\n20504\n21298\n22166\n22706\n22957\n23746\n24639\n24662\n24967\n25083\n25303\n26388\n27251\n27831\n28823\n29684\n30463\n30561\n30814\n31358\n31529\n31865\n32072\n32662\n33682\n34260\n35518\n36620\n37779\n38602\n39884\n40322\n41982\n42514\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75769\n78010\n79615\n81570\n85327\n89848\n93103\n98119\n100398\n103525\n107086\n111057\n117640\n125167\n131340\n140378\n154106\n168995\n196616\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n867\n896\n969\n973\n1063\n1088\n1114\n1159\n1174\n1192\n1232\n1265\n1284\n1369\n1461\n1552\n1618\n1701\n1737\n1837\n1910\n1930\n2029\n2040\n2121\n2147\n2188\n2224\n2275\n2296\n2368\n2396\n2496\n2530\n2533\n2561\n2709\n2745\n2856\n2974\n3007\n3029\n3114\n3250\n3368\n3495\n3729\n3846\n3983\n4124\n4209\n4485\n4804\n5070\n5339\n5544\n5778\n5946\n6287\n6826\n7415\n7904\n8575\n9584\n10802\n12726\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1944\n1970\n2011\n2061\n2112\n2133\n2205\n2224\n2324\n2358\n2361\n2394\n2474\n2510\n2614\n2739\n2772\n2788\n2872\n2995\n3113\n3240\n3417\n3558\n3695\n3836\n3924\n4105\n4366\n4672\n4934\n5158\n5528\n5690\n6002\n6447\n6970\n7499\n8106\n9048\n10265\n12156\n",
"10\n27\n35\n55\n58\n78\n87\n129\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n13796\n14444\n14777\n15548\n15719\n16046\n16828\n17665\n17968\n18361\n18653\n18940\n19670\n20504\n21298\n22166\n22706\n22957\n23746\n24639\n24676\n24981\n25097\n25317\n26402\n27265\n27845\n28837\n29698\n30477\n30575\n30828\n31372\n31543\n31879\n32086\n32676\n33696\n34274\n35532\n36634\n37793\n38616\n39898\n40336\n41996\n42528\n43810\n44509\n45993\n47568\n48833\n50171\n51272\n52175\n52794\n53845\n54291\n55322\n55987\n57727\n59060\n60603\n62776\n63682\n64658\n65562\n66786\n68080\n69604\n70976\n73835\n75783\n78024\n79629\n81584\n85341\n89862\n93117\n98133\n100412\n103539\n107100\n111071\n117668\n125195\n131368\n140406\n154148\n169037\n196672\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n896\n925\n998\n1002\n1092\n1117\n1143\n1188\n1203\n1221\n1261\n1294\n1313\n1398\n1490\n1581\n1647\n1730\n1766\n1866\n1939\n1959\n2058\n2069\n2150\n2176\n2217\n2253\n2304\n2325\n2397\n2425\n2525\n2559\n2562\n2590\n2738\n2774\n2885\n3003\n3036\n3058\n3143\n3279\n3397\n3524\n3758\n3875\n4012\n4153\n4238\n4514\n4833\n5099\n5368\n5602\n5836\n6004\n6345\n6884\n7473\n7962\n8633\n9671\n10889\n12842\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1888\n1914\n1955\n2005\n2056\n2077\n2149\n2168\n2268\n2302\n2305\n2338\n2418\n2454\n2558\n2683\n2716\n2732\n2816\n2939\n3057\n3184\n3361\n3502\n3639\n3780\n3868\n4049\n4310\n4616\n4878\n5102\n5416\n5578\n5890\n6335\n6858\n7387\n7994\n8936\n10097\n11988\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5612\n6220\n7150\n7763\n8078\n8941\n9569\n9666\n9775\n9840\n10032\n10773\n11087\n11823\n11840\n12712\n13683\n13789\n14437\n14770\n15541\n15712\n16039\n16821\n17658\n17961\n18354\n18646\n18933\n19663\n20497\n21291\n22159\n22699\n22950\n23739\n24632\n24669\n24974\n25090\n25310\n26395\n27258\n27838\n28830\n29691\n30470\n30568\n30821\n31365\n31536\n31872\n32079\n32669\n33689\n34267\n35525\n36627\n37786\n38609\n39891\n40329\n41989\n42521\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75769\n78010\n79615\n81570\n85327\n89848\n93103\n98112\n100391\n103518\n107079\n111050\n117647\n125174\n131347\n140378\n154120\n169009\n196644\n",
"1\n5\n12\n22\n28\n41\n56\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n896\n925\n998\n1002\n1092\n1117\n1143\n1188\n1203\n1221\n1261\n1294\n1313\n1398\n1490\n1581\n1647\n1730\n1766\n1866\n1939\n1959\n2058\n2069\n2150\n2176\n2217\n2253\n2304\n2325\n2397\n2425\n2525\n2559\n2562\n2590\n2738\n2774\n2885\n3003\n3036\n3058\n3143\n3279\n3397\n3524\n3758\n3875\n4012\n4153\n4238\n4514\n4833\n5099\n5368\n5596\n5830\n5998\n6339\n6878\n7467\n7956\n8627\n9659\n10877\n12824\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5612\n6220\n7150\n7763\n8078\n8941\n9569\n9666\n9775\n9840\n10032\n10773\n11087\n11823\n11840\n12712\n13683\n13789\n14437\n14770\n15541\n15712\n16039\n16821\n17658\n17961\n18354\n18646\n18933\n19663\n20497\n21291\n22159\n22699\n22950\n23739\n24632\n24669\n24974\n25090\n25310\n26395\n27258\n27838\n28830\n29691\n30470\n30568\n30821\n31365\n31536\n31872\n32079\n32669\n33689\n34267\n35525\n36627\n37786\n38609\n39891\n40329\n41989\n42521\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75560\n77801\n79406\n81361\n85118\n89639\n92894\n97903\n100182\n103309\n106870\n110841\n117438\n124965\n131138\n140169\n153702\n168591\n196017\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n769\n798\n871\n875\n965\n990\n1016\n1061\n1076\n1094\n1134\n1167\n1186\n1271\n1363\n1454\n1520\n1603\n1639\n1739\n1812\n1832\n1931\n1942\n2023\n2049\n2090\n2126\n2177\n2198\n2270\n2298\n2398\n2432\n2435\n2463\n2611\n2647\n2758\n2876\n2909\n2931\n3016\n3152\n3270\n3397\n3631\n3748\n3885\n4026\n4111\n4387\n4706\n4972\n5241\n5469\n5703\n5871\n6212\n6751\n7340\n7829\n8500\n9532\n10623\n12570\n",
"4\n5\n6\n14\n",
"1\n3\n8\n12\n18\n26\n44\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171256\n199344\n",
"13\n26\n34\n45\n48\n70\n80\n118\n",
"10\n20\n28\n48\n51\n64\n74\n112\n",
"1\n5\n12\n22\n28\n38\n53\n",
"1\n5\n12\n22\n28\n38\n53\n",
"10\n27\n35\n55\n58\n78\n87\n129\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1888\n1914\n1955\n2005\n2056\n2077\n2149\n2168\n2268\n2302\n2305\n2338\n2418\n2454\n2558\n2683\n2716\n2732\n2816\n2939\n3057\n3184\n3361\n3502\n3639\n3780\n3868\n4049\n4310\n4616\n4878\n5102\n5416\n5578\n5890\n6335\n6858\n7387\n7994\n8936\n10097\n11988\n",
"10\n27\n35\n55\n58\n78\n87\n129\n"
]
} | 2CODEFORCES
|
178_A1. Educational Game_1256 | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequence) equal to zero for some fixed k (k < n), and this should be done in the smallest possible number of moves.
One move is choosing an integer i (1 β€ i β€ n) such that ai > 0 and an integer t (t β₯ 0) such that i + 2t β€ n. After the values of i and t have been selected, the value of ai is decreased by 1, and the value of ai + 2t is increased by 1. For example, let n = 4 and a = (1, 0, 1, 2), then it is possible to make move i = 3, t = 0 and get a = (1, 0, 0, 3) or to make move i = 1, t = 1 and get a = (0, 0, 2, 2) (the only possible other move is i = 1, t = 0).
You are given n and the initial sequence ai. The task is to calculate the minimum number of moves needed to make the first k elements of the original sequence equal to zero for each possible k (1 β€ k < n).
Input
The first input line contains a single integer n. The second line contains n integers ai (0 β€ ai β€ 104), separated by single spaces.
The input limitations for getting 20 points are:
* 1 β€ n β€ 300
The input limitations for getting 50 points are:
* 1 β€ n β€ 2000
The input limitations for getting 100 points are:
* 1 β€ n β€ 105
Output
Print exactly n - 1 lines: the k-th output line must contain the minimum number of moves needed to make the first k elements of the original sequence ai equal to zero.
Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams, or the %I64d specifier.
Examples
Input
4
1 0 1 2
Output
1
1
3
Input
8
1 2 3 4 5 6 7 8
Output
1
3
6
10
16
24
40 | n = int(input())
a = [int(t) for t in input().split()]
c = 0
for i in range(n - 1):
if a[i] > 0:
c += a[i]
print(c)
j = 0
while 2 ** j + i < n:
j += 1
a[2 ** (j - 1) + i] += a[i]
a[i] = 0
else:
print(c) | 3Python3
| {
"input": [
"8\n1 2 3 4 5 6 7 8\n",
"4\n1 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"30\n8 17 20 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"5\n4 1 4 7 6\n",
"9\n13 13 7 11 3 9 3 5 5\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 710 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"30\n8 17 33 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"5\n4 1 1 7 6\n",
"9\n13 13 7 11 3 9 3 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"8\n1 2 5 4 5 6 7 8\n",
"4\n0 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"30\n8 17 33 10 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"9\n13 13 7 11 3 9 1 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 1 12 2\n",
"9\n13 13 8 11 3 9 1 5 4\n",
"8\n1 2 5 4 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 0 12 2\n",
"9\n13 13 8 11 3 9 2 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 4 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 15 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 0 1 2\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 7 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 83 20 99 15 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 2 0 1 2\n",
"9\n13 13 8 10 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 7 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n8 2 0 1 2\n",
"9\n13 13 8 12 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 14 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 9 1 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 8 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 3 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 4 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 26 15 18 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 20 3 3 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 2 4 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 10 8 20 3 3 2 5 5\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 2 7 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 10 8 20 3 3 2 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 6 2 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 17 8 20 3 3 2 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 17 8 20 3 3 1 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 64 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 359 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 9 2 7\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 26 98 57 95 20 36 70 66 75 12 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 359 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 334 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 19 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 26 98 57 95 20 36 70 66 75 12 54 96\n",
"5\n4 1 1 7 2\n",
"8\n1 2 5 4 5 6 7 12\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 149\n",
"9\n13 13 8 11 3 9 2 5 5\n",
"9\n10 10 8 20 3 3 2 5 7\n",
"8\n1 4 7 10 5 6 2 9\n",
"8\n1 4 7 10 5 6 2 7\n",
"9\n10 17 8 20 3 3 1 2 8\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 64 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 20\n",
"9\n10 17 8 20 3 3 1 2 12\n"
],
"output": [
"1\n3\n6\n10\n16\n24\n40\n",
"1\n1\n3\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1722\n1775\n1795\n1894\n1905\n1986\n2012\n2053\n2089\n2140\n2161\n2233\n2261\n2361\n2395\n2398\n2431\n2579\n2615\n2719\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4250\n4549\n4775\n5037\n5231\n5465\n5627\n5929\n6460\n7029\n7478\n8085\n9075\n10211\n12070\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1722\n1775\n1795\n1894\n1905\n1986\n2012\n2053\n2089\n2140\n2161\n2233\n2261\n2361\n2395\n2398\n2431\n2579\n2615\n2719\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4250\n4549\n4775\n5037\n5231\n5465\n5627\n5929\n6460\n7029\n7478\n8085\n9075\n10211\n12070\n",
"8\n25\n45\n60\n78\n93\n113\n123\n128\n141\n146\n150\n165\n174\n185\n199\n225\n257\n284\n315\n351\n375\n423\n454\n495\n549\n634\n713\n907\n",
"4\n5\n9\n17\n",
"13\n26\n33\n44\n47\n69\n79\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15827\n16598\n16769\n17096\n17878\n18715\n19018\n19411\n19703\n20042\n20772\n21606\n22400\n23268\n23808\n24059\n24848\n25741\n25764\n26069\n26185\n26405\n27104\n27967\n28547\n29539\n30400\n30793\n30891\n31144\n31688\n31859\n32195\n32402\n32992\n34012\n34748\n36006\n37108\n38267\n39127\n40409\n40847\n42507\n43244\n44526\n45225\n46709\n48284\n49549\n50887\n51988\n52891\n53510\n54561\n55519\n56550\n57215\n58955\n60075\n61618\n63791\n65150\n66185\n66979\n68203\n69497\n71021\n72551\n75410\n77358\n79599\n81241\n83248\n87005\n91313\n94773\n99789\n102521\n105707\n109158\n113129\n119712\n127026\n133562\n142600\n156395\n171618\n199596\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1125\n1158\n1177\n1262\n1354\n1445\n1511\n1594\n1633\n1733\n1786\n1806\n1905\n1916\n1997\n2023\n2064\n2100\n2151\n2172\n2244\n2272\n2372\n2406\n2409\n2442\n2590\n2626\n2730\n2829\n2862\n2878\n2963\n3086\n3204\n3331\n3508\n3625\n3762\n3903\n3991\n4272\n4571\n4797\n5059\n5253\n5487\n5649\n5962\n6493\n7062\n7511\n8118\n9108\n10244\n12103\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n1989\n2040\n2061\n2133\n2161\n2261\n2295\n2298\n2331\n2479\n2515\n2619\n2718\n2751\n2767\n2841\n2964\n3082\n3209\n3386\n3503\n3640\n3781\n3869\n4050\n4349\n4575\n4837\n5031\n5265\n5427\n5729\n6160\n6729\n7178\n7785\n8675\n9811\n11570\n",
"8\n25\n58\n73\n91\n106\n126\n136\n141\n154\n159\n163\n178\n187\n198\n212\n238\n270\n310\n341\n377\n401\n449\n480\n521\n575\n673\n752\n959\n",
"4\n5\n6\n14\n",
"13\n26\n33\n44\n47\n69\n79\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15827\n16598\n16769\n17096\n17878\n18715\n19018\n19411\n19703\n20042\n20772\n21606\n22400\n23268\n23808\n24059\n24848\n25741\n25764\n26069\n26185\n26405\n27104\n27967\n28547\n29539\n30400\n30793\n30891\n31144\n31688\n31859\n32195\n32402\n32992\n34012\n34748\n36006\n37108\n38267\n39127\n40409\n40847\n42507\n43244\n44526\n45225\n46709\n48284\n49549\n50887\n51988\n52891\n53510\n54561\n55519\n56550\n57215\n58955\n59902\n61445\n63618\n64977\n66012\n66806\n68030\n69324\n70848\n72378\n75237\n77185\n79426\n81068\n83075\n86832\n90967\n94427\n99443\n102175\n105361\n108812\n112783\n119366\n126507\n133043\n142081\n155876\n170926\n198904\n",
"1\n3\n8\n12\n18\n26\n44\n",
"0\n0\n1\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1125\n1158\n1177\n1262\n1354\n1445\n1511\n1594\n1633\n1733\n1806\n1826\n1925\n1936\n2017\n2043\n2084\n2120\n2171\n2192\n2264\n2292\n2392\n2426\n2429\n2462\n2610\n2646\n2750\n2849\n2882\n2898\n2983\n3106\n3224\n3351\n3528\n3645\n3782\n3923\n4011\n4292\n4611\n4837\n5099\n5293\n5527\n5689\n6002\n6533\n7122\n7571\n8178\n9168\n10324\n12183\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n1989\n2040\n2061\n2133\n2161\n2261\n2295\n2298\n2331\n2479\n2515\n2619\n2718\n2751\n2767\n2841\n2964\n3082\n3209\n3386\n3503\n3640\n3781\n3869\n4050\n4349\n4575\n4837\n5031\n5265\n5427\n5729\n6160\n6721\n7170\n7777\n8667\n9795\n11554\n",
"8\n25\n58\n68\n86\n101\n121\n131\n136\n149\n154\n158\n173\n182\n193\n207\n233\n265\n305\n331\n367\n391\n439\n470\n511\n565\n663\n737\n944\n",
"13\n26\n33\n44\n47\n69\n77\n115\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171256\n199344\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1113\n1153\n1186\n1205\n1290\n1382\n1473\n1539\n1622\n1661\n1761\n1834\n1854\n1953\n1964\n2045\n2071\n2112\n2148\n2199\n2220\n2292\n2320\n2420\n2454\n2457\n2490\n2638\n2674\n2778\n2877\n2910\n2926\n3011\n3134\n3252\n3379\n3556\n3673\n3810\n3951\n4039\n4320\n4639\n4865\n5127\n5321\n5555\n5717\n6058\n6589\n7178\n7627\n8234\n9224\n10380\n12239\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n2003\n2054\n2075\n2147\n2175\n2275\n2309\n2312\n2345\n2493\n2529\n2633\n2732\n2765\n2781\n2855\n2978\n3096\n3223\n3400\n3517\n3654\n3795\n3883\n4064\n4363\n4589\n4851\n5045\n5279\n5441\n5743\n6188\n6749\n7198\n7805\n8709\n9837\n11610\n",
"4\n5\n6\n19\n",
"13\n26\n34\n45\n48\n70\n79\n117\n",
"1\n3\n8\n12\n18\n26\n43\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1113\n1153\n1186\n1205\n1290\n1382\n1473\n1539\n1622\n1661\n1761\n1834\n1854\n1953\n1964\n2045\n2071\n2112\n2148\n2199\n2220\n2292\n2320\n2420\n2454\n2457\n2490\n2638\n2674\n2778\n2877\n2910\n2926\n3011\n3134\n3252\n3379\n3556\n3673\n3810\n3951\n4039\n4320\n4639\n4865\n5127\n5313\n5547\n5709\n6050\n6581\n7170\n7619\n8226\n9208\n10364\n12215\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1701\n1721\n1820\n1831\n1912\n1938\n1979\n2029\n2080\n2101\n2173\n2201\n2301\n2335\n2338\n2371\n2519\n2555\n2659\n2784\n2817\n2833\n2907\n3030\n3148\n3275\n3452\n3569\n3706\n3847\n3935\n4116\n4415\n4641\n4903\n5123\n5357\n5519\n5821\n6266\n6827\n7276\n7883\n8813\n9941\n11740\n",
"4\n5\n5\n18\n",
"13\n26\n34\n45\n48\n70\n80\n118\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171177\n199265\n",
"0\n2\n7\n11\n16\n24\n40\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2488\n2636\n2672\n2776\n2875\n2908\n2922\n3007\n3130\n3248\n3375\n3552\n3669\n3806\n3947\n4035\n4316\n4635\n4861\n5123\n5309\n5543\n5703\n6044\n6575\n7164\n7613\n8220\n9202\n10358\n12207\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1701\n1721\n1820\n1835\n1916\n1942\n1983\n2033\n2084\n2105\n2177\n2205\n2305\n2339\n2342\n2375\n2523\n2559\n2663\n2788\n2821\n2837\n2911\n3034\n3152\n3279\n3456\n3573\n3710\n3851\n3939\n4120\n4419\n4645\n4907\n5131\n5365\n5527\n5829\n6274\n6835\n7284\n7891\n8825\n9953\n11756\n",
"4\n5\n5\n7\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10709\n11450\n11764\n12500\n12517\n13389\n14360\n14919\n15567\n15900\n16671\n16842\n17169\n17951\n18788\n19091\n19484\n19776\n20115\n20845\n21679\n22473\n23341\n23881\n24132\n24921\n25814\n25837\n26142\n26258\n26478\n27177\n28040\n28620\n29612\n30473\n30866\n30964\n31217\n31761\n31932\n32268\n32475\n33065\n34085\n34821\n36079\n37181\n38340\n39163\n40445\n40883\n42543\n43280\n44562\n45261\n46745\n48320\n49585\n50923\n52024\n52927\n53546\n54597\n55555\n56586\n57251\n58991\n59938\n61481\n63654\n65013\n66048\n66952\n68176\n69470\n70994\n72524\n75383\n77331\n79572\n81177\n83184\n86941\n91076\n94536\n99552\n102284\n105470\n109031\n113002\n119585\n126726\n133262\n142300\n156095\n171066\n199117\n",
"0\n2\n7\n14\n19\n27\n43\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2488\n2636\n2672\n2776\n2875\n2908\n2922\n3007\n3130\n3248\n3375\n3609\n3726\n3863\n4004\n4092\n4373\n4692\n4918\n5180\n5366\n5600\n5760\n6101\n6632\n7221\n7670\n8334\n9316\n10472\n12321\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1731\n1751\n1850\n1865\n1946\n1972\n2013\n2063\n2114\n2135\n2207\n2235\n2335\n2369\n2372\n2405\n2553\n2589\n2693\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4150\n4479\n4705\n4967\n5191\n5425\n5587\n5889\n6334\n6925\n7374\n7981\n8915\n10073\n11876\n",
"4\n6\n6\n9\n",
"13\n26\n34\n44\n47\n69\n79\n116\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19779\n20509\n21343\n22137\n23005\n23545\n23796\n24585\n25478\n25501\n25806\n25922\n26142\n26841\n27704\n28284\n29276\n30137\n30530\n30628\n30881\n31425\n31596\n31932\n32139\n32729\n33749\n34485\n35743\n36845\n38004\n38827\n40109\n40547\n42207\n42944\n44226\n44925\n46409\n47984\n49249\n50587\n51688\n52591\n53210\n54261\n54883\n55914\n56579\n58319\n59266\n60809\n62982\n64341\n65376\n66280\n67504\n68798\n70322\n71852\n74711\n76659\n78900\n80505\n82512\n86269\n90404\n93864\n98880\n101612\n104798\n108359\n112330\n118913\n126054\n132590\n141628\n155423\n170058\n198109\n",
"0\n2\n7\n14\n19\n27\n38\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n916\n1006\n1031\n1050\n1076\n1091\n1101\n1141\n1174\n1193\n1278\n1370\n1461\n1527\n1610\n1649\n1749\n1822\n1842\n1941\n1952\n2033\n2059\n2100\n2136\n2187\n2208\n2280\n2308\n2408\n2442\n2445\n2478\n2626\n2662\n2766\n2865\n2898\n2912\n2997\n3120\n3238\n3365\n3599\n3716\n3853\n3994\n4082\n4363\n4682\n4908\n5160\n5346\n5580\n5740\n6081\n6612\n7201\n7650\n8304\n9286\n10442\n12291\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1731\n1751\n1850\n1865\n1985\n2011\n2052\n2102\n2153\n2174\n2246\n2274\n2374\n2408\n2411\n2444\n2592\n2628\n2732\n2857\n2890\n2906\n2980\n3103\n3221\n3348\n3525\n3642\n3779\n3920\n4008\n4189\n4518\n4744\n5006\n5230\n5503\n5665\n5967\n6412\n7003\n7452\n8059\n8993\n10190\n11993\n",
"8\n10\n10\n13\n",
"13\n26\n34\n46\n49\n71\n81\n120\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19727\n20457\n21291\n22085\n22953\n23493\n23744\n24533\n25426\n25449\n25754\n25870\n26090\n26789\n27652\n28232\n29224\n30085\n30478\n30576\n30829\n31373\n31544\n31880\n32087\n32677\n33697\n34433\n35691\n36793\n37952\n38775\n40057\n40495\n42155\n42892\n44174\n44873\n46357\n47932\n49197\n50535\n51636\n52539\n53158\n54209\n54831\n55862\n56527\n58267\n59214\n60757\n62930\n64289\n65324\n66228\n67452\n68746\n70270\n71800\n74659\n76607\n78848\n80453\n82408\n86165\n90300\n93760\n98776\n101508\n104694\n108255\n112226\n118809\n125950\n132486\n141524\n155319\n169954\n198005\n",
"0\n2\n7\n21\n26\n34\n45\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1045\n1071\n1086\n1096\n1136\n1169\n1188\n1273\n1365\n1456\n1522\n1605\n1644\n1744\n1817\n1837\n1936\n1947\n2028\n2054\n2095\n2131\n2182\n2203\n2275\n2303\n2403\n2437\n2440\n2468\n2616\n2652\n2756\n2855\n2888\n2902\n2987\n3110\n3228\n3355\n3589\n3706\n3843\n3984\n4072\n4348\n4667\n4893\n5145\n5331\n5565\n5725\n6066\n6592\n7181\n7630\n8284\n9261\n10417\n12261\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4764\n5026\n5250\n5523\n5685\n5997\n6442\n7033\n7482\n8089\n9023\n10220\n12023\n",
"10\n23\n31\n43\n46\n68\n78\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19727\n20457\n21291\n22085\n22953\n23493\n23744\n24533\n25426\n25449\n25754\n25870\n26090\n26789\n27652\n28232\n29224\n30085\n30478\n30576\n30829\n31373\n31544\n31880\n32087\n32677\n33697\n34433\n35691\n36793\n37952\n38775\n40057\n40495\n42155\n42892\n44174\n44873\n46357\n47932\n49197\n50535\n51636\n52539\n53158\n54209\n54831\n55862\n56527\n58267\n59214\n60757\n62930\n64289\n65265\n66169\n67393\n68687\n70211\n71741\n74600\n76548\n78789\n80394\n82349\n86106\n90241\n93701\n98717\n101449\n104576\n108137\n112108\n118691\n125832\n132368\n141406\n155201\n169777\n197828\n",
"0\n2\n7\n17\n22\n30\n41\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1045\n1071\n1086\n1096\n1136\n1169\n1188\n1273\n1365\n1456\n1522\n1605\n1644\n1744\n1817\n1837\n1936\n1947\n2028\n2054\n2095\n2131\n2182\n2203\n2275\n2303\n2403\n2437\n2440\n2468\n2616\n2652\n2756\n2855\n2888\n2902\n2987\n3110\n3228\n3355\n3589\n3706\n3843\n3984\n4072\n4348\n4667\n4933\n5185\n5371\n5605\n5765\n6106\n6632\n7221\n7710\n8364\n9341\n10497\n12381\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4844\n5106\n5330\n5603\n5765\n6077\n6522\n7113\n7642\n8249\n9183\n10380\n12263\n",
"10\n23\n31\n43\n46\n68\n77\n116\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42716\n43998\n44697\n46181\n47756\n49021\n50359\n51460\n52363\n52982\n54033\n54479\n55510\n56175\n57915\n58862\n60405\n62578\n63937\n64913\n65817\n67041\n68335\n69859\n71389\n74248\n76196\n78437\n80042\n81997\n85754\n89889\n93349\n98365\n101097\n104224\n107785\n111756\n118339\n125480\n132016\n141054\n154849\n169249\n197300\n",
"0\n2\n10\n20\n25\n33\n47\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1078\n1093\n1103\n1143\n1176\n1195\n1280\n1372\n1463\n1529\n1612\n1651\n1751\n1824\n1844\n1943\n1954\n2035\n2061\n2102\n2138\n2189\n2210\n2282\n2310\n2410\n2444\n2447\n2475\n2623\n2659\n2770\n2869\n2902\n2916\n3001\n3124\n3242\n3369\n3603\n3720\n3857\n3998\n4086\n4362\n4681\n4947\n5206\n5392\n5626\n5786\n6127\n6653\n7242\n7731\n8392\n9369\n10525\n12409\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4844\n5106\n5330\n5700\n5862\n6174\n6619\n7210\n7739\n8346\n9280\n10574\n12457\n",
"10\n23\n31\n43\n46\n62\n72\n105\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42511\n43793\n44492\n45976\n47551\n48816\n50154\n51255\n52158\n52777\n53828\n54274\n55305\n55970\n57710\n58657\n60200\n62373\n63732\n64708\n65612\n66836\n68130\n69654\n71184\n74043\n75991\n78232\n79837\n81792\n85549\n89684\n92939\n97955\n100687\n103814\n107375\n111346\n117929\n125070\n131401\n140439\n154234\n168634\n196480\n",
"0\n2\n6\n16\n21\n29\n39\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1078\n1093\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2483\n2631\n2667\n2778\n2877\n2910\n2932\n3017\n3140\n3258\n3385\n3619\n3736\n3873\n4014\n4102\n4378\n4697\n4963\n5222\n5408\n5642\n5810\n6151\n6677\n7266\n7755\n8416\n9393\n10549\n12441\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1494\n1560\n1643\n1682\n1682\n1765\n1785\n1884\n1899\n2019\n2045\n2086\n2136\n2187\n2208\n2280\n2308\n2408\n2442\n2445\n2478\n2626\n2662\n2766\n2891\n2924\n2940\n3024\n3147\n3265\n3392\n3569\n3710\n3847\n3988\n4076\n4257\n4586\n4892\n5154\n5378\n5748\n5910\n6222\n6667\n7258\n7787\n8394\n9352\n10646\n12553\n",
"10\n23\n31\n51\n54\n70\n80\n121\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42511\n43793\n44492\n45976\n47551\n48816\n50154\n51255\n52158\n52777\n53828\n54274\n55305\n55970\n57710\n58657\n60200\n62373\n63732\n64708\n65612\n66836\n68130\n69654\n71184\n74043\n75991\n78232\n79837\n81792\n85549\n89684\n92939\n97955\n100687\n103814\n107375\n111346\n117929\n125070\n131401\n140439\n154234\n168737\n196583\n",
"1\n3\n7\n17\n23\n31\n42\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1678\n1778\n1851\n1871\n1970\n1981\n2062\n2088\n2129\n2165\n2216\n2237\n2309\n2337\n2437\n2471\n2474\n2502\n2650\n2686\n2797\n2915\n2948\n2970\n3055\n3178\n3296\n3423\n3657\n3774\n3911\n4052\n4140\n4416\n4735\n5001\n5260\n5465\n5699\n5867\n6208\n6734\n7323\n7812\n8473\n9469\n10625\n12536\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n915\n940\n959\n1011\n1026\n1038\n1077\n1110\n1129\n1214\n1306\n1421\n1487\n1570\n1609\n1609\n1692\n1712\n1811\n1826\n1946\n1972\n2013\n2063\n2114\n2135\n2207\n2235\n2335\n2369\n2372\n2405\n2480\n2516\n2620\n2745\n2778\n2794\n2878\n3001\n3119\n3246\n3423\n3564\n3701\n3842\n3930\n4111\n4367\n4673\n4935\n5159\n5529\n5691\n6003\n6448\n6966\n7495\n8102\n9060\n10281\n12188\n",
"10\n20\n28\n48\n51\n64\n74\n112\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26455\n27318\n27898\n28890\n29751\n30144\n30242\n30495\n31039\n31210\n31546\n31753\n32343\n33363\n33941\n35199\n36301\n37460\n38283\n39565\n40003\n41663\n42195\n43477\n44176\n45660\n47235\n48500\n49838\n50939\n51842\n52461\n53512\n53958\n54989\n55654\n57394\n58341\n59884\n62057\n63416\n64392\n65296\n66520\n67814\n69338\n70710\n73569\n75517\n77758\n79363\n81318\n85075\n89210\n92465\n97481\n100213\n103340\n106901\n110872\n117455\n124596\n130769\n139807\n153602\n168105\n195793\n",
"1\n3\n10\n20\n26\n34\n48\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1675\n1775\n1848\n1868\n1967\n1978\n2059\n2085\n2126\n2162\n2213\n2234\n2306\n2334\n2434\n2468\n2471\n2499\n2647\n2683\n2794\n2912\n2945\n2967\n3052\n3175\n3293\n3420\n3654\n3771\n3908\n4049\n4134\n4410\n4729\n4995\n5254\n5459\n5693\n5861\n6202\n6728\n7317\n7806\n8467\n9463\n10619\n12530\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2228\n2328\n2362\n2365\n2398\n2473\n2509\n2613\n2738\n2771\n2787\n2871\n2994\n3112\n3239\n3416\n3557\n3694\n3835\n3923\n4104\n4360\n4666\n4928\n5152\n5522\n5684\n5996\n6441\n6959\n7488\n8095\n9046\n10267\n12167\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26841\n27704\n28284\n29276\n30137\n30530\n30628\n30881\n31425\n31596\n31932\n32139\n32729\n33749\n34327\n35585\n36687\n37846\n38669\n39951\n40389\n42049\n42581\n43863\n44562\n46046\n47621\n48886\n50224\n51325\n52228\n52847\n53898\n54344\n55375\n56040\n57780\n58727\n60270\n62443\n63802\n64778\n65682\n66906\n68200\n69724\n71096\n73955\n75903\n78144\n79749\n81704\n85461\n89596\n92851\n97867\n100599\n103726\n107287\n111258\n117841\n124982\n131155\n140193\n154374\n168877\n196951\n",
"1\n5\n12\n22\n28\n38\n52\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1675\n1775\n1848\n1868\n1967\n1978\n2059\n2085\n2126\n2162\n2213\n2234\n2306\n2334\n2434\n2468\n2471\n2499\n2647\n2683\n2794\n2912\n2945\n2967\n3052\n3188\n3306\n3433\n3667\n3784\n3921\n4062\n4147\n4423\n4742\n5008\n5267\n5472\n5706\n5874\n6215\n6754\n7343\n7832\n8493\n9502\n10658\n12582\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2228\n2328\n2362\n2365\n2398\n2473\n2509\n2613\n2738\n2771\n2787\n2871\n2994\n3112\n3239\n3416\n3557\n3694\n3835\n3923\n4104\n4360\n4666\n4928\n5152\n5522\n5684\n5996\n6441\n6959\n7488\n8095\n9046\n10258\n12158\n",
"10\n20\n28\n48\n51\n64\n74\n109\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26841\n27704\n28284\n29276\n30137\n30916\n31014\n31267\n31811\n31982\n32318\n32525\n33115\n34135\n34713\n35971\n37073\n38232\n39055\n40337\n40775\n42435\n42967\n44249\n44948\n46432\n48007\n49272\n50610\n51711\n52614\n53233\n54284\n54730\n55761\n56426\n58166\n59499\n61042\n63215\n64574\n65550\n66454\n67678\n68972\n70496\n71868\n74727\n76675\n78916\n80521\n82476\n86233\n90754\n94009\n99025\n101757\n104884\n108445\n112416\n118999\n126526\n132699\n141737\n155918\n170807\n198881\n",
"1\n5\n12\n22\n28\n38\n53\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n867\n896\n969\n973\n1063\n1088\n1114\n1159\n1174\n1192\n1232\n1265\n1284\n1369\n1461\n1552\n1618\n1701\n1737\n1837\n1910\n1930\n2029\n2040\n2121\n2147\n2188\n2224\n2275\n2296\n2368\n2396\n2496\n2530\n2533\n2561\n2709\n2745\n2856\n2974\n3007\n3029\n3114\n3250\n3368\n3495\n3729\n3846\n3983\n4124\n4209\n4485\n4804\n5070\n5329\n5534\n5768\n5936\n6277\n6816\n7405\n7894\n8555\n9564\n10782\n12706\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2219\n2319\n2353\n2356\n2389\n2464\n2500\n2604\n2729\n2762\n2778\n2862\n2985\n3103\n3230\n3407\n3548\n3685\n3826\n3914\n4095\n4351\n4657\n4919\n5143\n5513\n5675\n5987\n6432\n6950\n7479\n8086\n9028\n10240\n12131\n",
"10\n27\n35\n55\n58\n78\n88\n130\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n13796\n14444\n14777\n15548\n15719\n16046\n16828\n17665\n17968\n18361\n18653\n18940\n19670\n20504\n21298\n22166\n22706\n22957\n23746\n24639\n24662\n24967\n25083\n25303\n26388\n27251\n27831\n28823\n29684\n30463\n30561\n30814\n31358\n31529\n31865\n32072\n32662\n33682\n34260\n35518\n36620\n37779\n38602\n39884\n40322\n41982\n42514\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75769\n78010\n79615\n81570\n85327\n89848\n93103\n98119\n100398\n103525\n107086\n111057\n117640\n125167\n131340\n140378\n154106\n168995\n196616\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n867\n896\n969\n973\n1063\n1088\n1114\n1159\n1174\n1192\n1232\n1265\n1284\n1369\n1461\n1552\n1618\n1701\n1737\n1837\n1910\n1930\n2029\n2040\n2121\n2147\n2188\n2224\n2275\n2296\n2368\n2396\n2496\n2530\n2533\n2561\n2709\n2745\n2856\n2974\n3007\n3029\n3114\n3250\n3368\n3495\n3729\n3846\n3983\n4124\n4209\n4485\n4804\n5070\n5339\n5544\n5778\n5946\n6287\n6826\n7415\n7904\n8575\n9584\n10802\n12726\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1944\n1970\n2011\n2061\n2112\n2133\n2205\n2224\n2324\n2358\n2361\n2394\n2474\n2510\n2614\n2739\n2772\n2788\n2872\n2995\n3113\n3240\n3417\n3558\n3695\n3836\n3924\n4105\n4366\n4672\n4934\n5158\n5528\n5690\n6002\n6447\n6970\n7499\n8106\n9048\n10265\n12156\n",
"10\n27\n35\n55\n58\n78\n87\n129\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n13796\n14444\n14777\n15548\n15719\n16046\n16828\n17665\n17968\n18361\n18653\n18940\n19670\n20504\n21298\n22166\n22706\n22957\n23746\n24639\n24676\n24981\n25097\n25317\n26402\n27265\n27845\n28837\n29698\n30477\n30575\n30828\n31372\n31543\n31879\n32086\n32676\n33696\n34274\n35532\n36634\n37793\n38616\n39898\n40336\n41996\n42528\n43810\n44509\n45993\n47568\n48833\n50171\n51272\n52175\n52794\n53845\n54291\n55322\n55987\n57727\n59060\n60603\n62776\n63682\n64658\n65562\n66786\n68080\n69604\n70976\n73835\n75783\n78024\n79629\n81584\n85341\n89862\n93117\n98133\n100412\n103539\n107100\n111071\n117668\n125195\n131368\n140406\n154148\n169037\n196672\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n896\n925\n998\n1002\n1092\n1117\n1143\n1188\n1203\n1221\n1261\n1294\n1313\n1398\n1490\n1581\n1647\n1730\n1766\n1866\n1939\n1959\n2058\n2069\n2150\n2176\n2217\n2253\n2304\n2325\n2397\n2425\n2525\n2559\n2562\n2590\n2738\n2774\n2885\n3003\n3036\n3058\n3143\n3279\n3397\n3524\n3758\n3875\n4012\n4153\n4238\n4514\n4833\n5099\n5368\n5602\n5836\n6004\n6345\n6884\n7473\n7962\n8633\n9671\n10889\n12842\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1888\n1914\n1955\n2005\n2056\n2077\n2149\n2168\n2268\n2302\n2305\n2338\n2418\n2454\n2558\n2683\n2716\n2732\n2816\n2939\n3057\n3184\n3361\n3502\n3639\n3780\n3868\n4049\n4310\n4616\n4878\n5102\n5416\n5578\n5890\n6335\n6858\n7387\n7994\n8936\n10097\n11988\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5612\n6220\n7150\n7763\n8078\n8941\n9569\n9666\n9775\n9840\n10032\n10773\n11087\n11823\n11840\n12712\n13683\n13789\n14437\n14770\n15541\n15712\n16039\n16821\n17658\n17961\n18354\n18646\n18933\n19663\n20497\n21291\n22159\n22699\n22950\n23739\n24632\n24669\n24974\n25090\n25310\n26395\n27258\n27838\n28830\n29691\n30470\n30568\n30821\n31365\n31536\n31872\n32079\n32669\n33689\n34267\n35525\n36627\n37786\n38609\n39891\n40329\n41989\n42521\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75769\n78010\n79615\n81570\n85327\n89848\n93103\n98112\n100391\n103518\n107079\n111050\n117647\n125174\n131347\n140378\n154120\n169009\n196644\n",
"1\n5\n12\n22\n28\n41\n56\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n896\n925\n998\n1002\n1092\n1117\n1143\n1188\n1203\n1221\n1261\n1294\n1313\n1398\n1490\n1581\n1647\n1730\n1766\n1866\n1939\n1959\n2058\n2069\n2150\n2176\n2217\n2253\n2304\n2325\n2397\n2425\n2525\n2559\n2562\n2590\n2738\n2774\n2885\n3003\n3036\n3058\n3143\n3279\n3397\n3524\n3758\n3875\n4012\n4153\n4238\n4514\n4833\n5099\n5368\n5596\n5830\n5998\n6339\n6878\n7467\n7956\n8627\n9659\n10877\n12824\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5612\n6220\n7150\n7763\n8078\n8941\n9569\n9666\n9775\n9840\n10032\n10773\n11087\n11823\n11840\n12712\n13683\n13789\n14437\n14770\n15541\n15712\n16039\n16821\n17658\n17961\n18354\n18646\n18933\n19663\n20497\n21291\n22159\n22699\n22950\n23739\n24632\n24669\n24974\n25090\n25310\n26395\n27258\n27838\n28830\n29691\n30470\n30568\n30821\n31365\n31536\n31872\n32079\n32669\n33689\n34267\n35525\n36627\n37786\n38609\n39891\n40329\n41989\n42521\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75560\n77801\n79406\n81361\n85118\n89639\n92894\n97903\n100182\n103309\n106870\n110841\n117438\n124965\n131138\n140169\n153702\n168591\n196017\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n769\n798\n871\n875\n965\n990\n1016\n1061\n1076\n1094\n1134\n1167\n1186\n1271\n1363\n1454\n1520\n1603\n1639\n1739\n1812\n1832\n1931\n1942\n2023\n2049\n2090\n2126\n2177\n2198\n2270\n2298\n2398\n2432\n2435\n2463\n2611\n2647\n2758\n2876\n2909\n2931\n3016\n3152\n3270\n3397\n3631\n3748\n3885\n4026\n4111\n4387\n4706\n4972\n5241\n5469\n5703\n5871\n6212\n6751\n7340\n7829\n8500\n9532\n10623\n12570\n",
"4\n5\n6\n14\n",
"1\n3\n8\n12\n18\n26\n44\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171256\n199344\n",
"13\n26\n34\n45\n48\n70\n80\n118\n",
"10\n20\n28\n48\n51\n64\n74\n112\n",
"1\n5\n12\n22\n28\n38\n53\n",
"1\n5\n12\n22\n28\n38\n53\n",
"10\n27\n35\n55\n58\n78\n87\n129\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1888\n1914\n1955\n2005\n2056\n2077\n2149\n2168\n2268\n2302\n2305\n2338\n2418\n2454\n2558\n2683\n2716\n2732\n2816\n2939\n3057\n3184\n3361\n3502\n3639\n3780\n3868\n4049\n4310\n4616\n4878\n5102\n5416\n5578\n5890\n6335\n6858\n7387\n7994\n8936\n10097\n11988\n",
"10\n27\n35\n55\n58\n78\n87\n129\n"
]
} | 2CODEFORCES
|
178_A1. Educational Game_1257 | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequence) equal to zero for some fixed k (k < n), and this should be done in the smallest possible number of moves.
One move is choosing an integer i (1 β€ i β€ n) such that ai > 0 and an integer t (t β₯ 0) such that i + 2t β€ n. After the values of i and t have been selected, the value of ai is decreased by 1, and the value of ai + 2t is increased by 1. For example, let n = 4 and a = (1, 0, 1, 2), then it is possible to make move i = 3, t = 0 and get a = (1, 0, 0, 3) or to make move i = 1, t = 1 and get a = (0, 0, 2, 2) (the only possible other move is i = 1, t = 0).
You are given n and the initial sequence ai. The task is to calculate the minimum number of moves needed to make the first k elements of the original sequence equal to zero for each possible k (1 β€ k < n).
Input
The first input line contains a single integer n. The second line contains n integers ai (0 β€ ai β€ 104), separated by single spaces.
The input limitations for getting 20 points are:
* 1 β€ n β€ 300
The input limitations for getting 50 points are:
* 1 β€ n β€ 2000
The input limitations for getting 100 points are:
* 1 β€ n β€ 105
Output
Print exactly n - 1 lines: the k-th output line must contain the minimum number of moves needed to make the first k elements of the original sequence ai equal to zero.
Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams, or the %I64d specifier.
Examples
Input
4
1 0 1 2
Output
1
1
3
Input
8
1 2 3 4 5 6 7 8
Output
1
3
6
10
16
24
40 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CodeC
{
static class Scanner
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public String nextLine()
{
try
{
return br.readLine();
}
catch(Exception e)
{
throw(new RuntimeException());
}
}
public String next()
{
while(!st.hasMoreTokens())
{
String l = nextLine();
if(l == null)
return null;
st = new StringTokenizer(l);
}
return st.nextToken();
}
public int nextInt()
{
return Integer.parseInt(next());
}
public long nextLong()
{
return Long.parseLong(next());
}
public double nextDouble()
{
return Double.parseDouble(next());
}
public int[] nextIntArray(int n)
{
int[] res = new int[n];
for(int i = 0; i < res.length; i++)
res[i] = nextInt();
return res;
}
public long[] nextLongArray(int n)
{
long[] res = new long[n];
for(int i = 0; i < res.length; i++)
res[i] = nextLong();
return res;
}
public double[] nextDoubleArray(int n)
{
double[] res = new double[n];
for(int i = 0; i < res.length; i++)
res[i] = nextDouble();
return res;
}
public void sortIntArray(int[] array)
{
Integer[] vals = new Integer[array.length];
for(int i = 0; i < array.length; i++)
vals[i] = array[i];
Arrays.sort(vals);
for(int i = 0; i < array.length; i++)
array[i] = vals[i];
}
public void sortLongArray(long[] array)
{
Long[] vals = new Long[array.length];
for(int i = 0; i < array.length; i++)
vals[i] = array[i];
Arrays.sort(vals);
for(int i = 0; i < array.length; i++)
array[i] = vals[i];
}
public void sortDoubleArray(double[] array)
{
Double[] vals = new Double[array.length];
for(int i = 0; i < array.length; i++)
vals[i] = array[i];
Arrays.sort(vals);
for(int i = 0; i < array.length; i++)
array[i] = vals[i];
}
public String[] nextStringArray(int n)
{
String[] vals = new String[n];
for(int i = 0; i < n; i++)
vals[i] = next();
return vals;
}
Integer nextInteger()
{
String s = next();
if(s == null)
return null;
return Integer.parseInt(s);
}
int[][] nextIntMatrix(int n, int m)
{
int[][] ans = new int[n][];
for(int i = 0; i < n; i++)
ans[i] = nextIntArray(m);
return ans;
}
static <T> T fill(T arreglo, int val)
{
if(arreglo instanceof Object[])
{
Object[] a = (Object[]) arreglo;
for(Object x : a)
fill(x, val);
}
else if(arreglo instanceof int[])
Arrays.fill((int[]) arreglo, val);
else if(arreglo instanceof double[])
Arrays.fill((double[]) arreglo, val);
else if(arreglo instanceof long[])
Arrays.fill((long[]) arreglo, val);
return arreglo;
}
<T> T[] nextObjectArray(Class <T> clazz, int size)
{
@SuppressWarnings("unchecked")
T[] result = (T[]) java.lang.reflect.Array.newInstance(clazz, size);
for(int c = 0; c < 3; c++)
{
Constructor <T> constructor;
try
{
if(c == 0)
constructor = clazz.getDeclaredConstructor(Scanner.class, Integer.TYPE);
else if(c == 1)
constructor = clazz.getDeclaredConstructor(Scanner.class);
else
constructor = clazz.getDeclaredConstructor();
}
catch(Exception e)
{
continue;
}
try
{
for(int i = 0; i < result.length; i++)
{
if(c == 0)
result[i] = constructor.newInstance(this, i);
else if(c == 1)
result[i] = constructor.newInstance(this);
else
result[i] = constructor.newInstance();
}
}
catch(Exception e)
{
throw new RuntimeException(e);
}
return result;
}
throw new RuntimeException("Constructor not found");
}
}
static long contar(int[] vals, int k)
{
long total = 0;
for(int i = 0; i < k; i++)
{
int cual = 1;
while(i + cual < vals.length)
cual <<= 1;
cual >>= 1;
total += vals[i];
vals[i + cual] += vals[i];
vals[i] = 0;
}
return total;
}
public static void main(String[] args)
{
Scanner sc = new Scanner();
int n = sc.nextInt();
int[] vals = sc.nextIntArray(n);
for(int i = 1; i < n; i++)
System.out.println(contar(vals.clone(), i));
}
} | 4JAVA
| {
"input": [
"8\n1 2 3 4 5 6 7 8\n",
"4\n1 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"30\n8 17 20 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"5\n4 1 4 7 6\n",
"9\n13 13 7 11 3 9 3 5 5\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 710 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"30\n8 17 33 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"5\n4 1 1 7 6\n",
"9\n13 13 7 11 3 9 3 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"8\n1 2 5 4 5 6 7 8\n",
"4\n0 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"30\n8 17 33 10 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16\n",
"9\n13 13 7 11 3 9 1 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 134\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 1 12 2\n",
"9\n13 13 8 11 3 9 1 5 4\n",
"8\n1 2 5 4 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 11 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 0 12 2\n",
"9\n13 13 8 11 3 9 2 5 4\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 4 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 53 20 99 15 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 1 0 1 2\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 7 5 6 6 12\n",
"80\n72 66 82 46 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 83 20 99 15 81 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n4 2 0 1 2\n",
"9\n13 13 8 10 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 7 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 9 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 29 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"5\n8 2 0 1 2\n",
"9\n13 13 8 12 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 14 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 88 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 9 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 368 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 5 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 19 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 98 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 9 1 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 8 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 26 15 10 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 91 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 12 3 3 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 582 943 149\n",
"8\n0 2 4 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 26 15 18 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 13 8 20 3 3 2 5 5\n",
"120\n242 524 420 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 2 4 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 39 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"9\n10 10 8 20 3 3 2 5 5\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 2 7 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 12 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 6 1 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 84 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 10 8 20 3 3 2 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 6 2 12\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 13 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 17 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 17 8 20 3 3 2 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 23 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 44 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 120 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"9\n10 17 8 20 3 3 1 2 7\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 366 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 32 98 57 95 20 36 70 66 75 12 54 96\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 64 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 359 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"8\n1 4 7 10 5 9 2 7\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 146 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 26 98 57 95 20 36 70 66 75 12 54 96\n",
"120\n242 524 262 973 816 432 210 666 134 849 145 359 608 930 613 315 863 628 97 109 65 192 741 314 736 17 872 971 106 648 333 771 171 327 782 837 303 393 292 287 730 834 794 868 540 251 789 893 37 305 116 220 1085 863 580 992 861 779 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 387 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 157 235 246 533 177 12 764 334 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 685 943 149\n",
"80\n72 66 82 36 73 22 63 120 71 65 5 30 45 19 29 73 4 90 25 26 45 15 18 40 33 19 85 92 91 66 83 36 100 73 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 103 99 42 142 26 71 58 49 76 32 128 23 26 98 57 95 20 36 70 66 75 12 54 96\n",
"5\n4 1 1 7 2\n",
"8\n1 2 5 4 5 6 7 12\n",
"120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 333 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 554 962 950 475 473 806 510 986 254 290 351 143 537 573 949 256 216 235 246 533 177 12 764 543 689 490 386 849 694 386 693 134 416 293 589 171 76 527 324 782 661 943 149\n",
"9\n13 13 8 11 3 9 2 5 5\n",
"9\n10 10 8 20 3 3 2 5 7\n",
"8\n1 4 7 10 5 6 2 9\n",
"8\n1 4 7 10 5 6 2 7\n",
"9\n10 17 8 20 3 3 1 2 8\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 38 84 29 73 9 22 25 19 52 15 12 39 33 19 85 92 115 66 83 39 000 83 20 99 15 64 26 41 50 51 21 72 19 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 168 13 40 195 57 95 20 28 70 66 75 3 54 20\n",
"9\n10 17 8 20 3 3 1 2 12\n"
],
"output": [
"1\n3\n6\n10\n16\n24\n40\n",
"1\n1\n3\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1722\n1775\n1795\n1894\n1905\n1986\n2012\n2053\n2089\n2140\n2161\n2233\n2261\n2361\n2395\n2398\n2431\n2579\n2615\n2719\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4250\n4549\n4775\n5037\n5231\n5465\n5627\n5929\n6460\n7029\n7478\n8085\n9075\n10211\n12070\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1722\n1775\n1795\n1894\n1905\n1986\n2012\n2053\n2089\n2140\n2161\n2233\n2261\n2361\n2395\n2398\n2431\n2579\n2615\n2719\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4250\n4549\n4775\n5037\n5231\n5465\n5627\n5929\n6460\n7029\n7478\n8085\n9075\n10211\n12070\n",
"8\n25\n45\n60\n78\n93\n113\n123\n128\n141\n146\n150\n165\n174\n185\n199\n225\n257\n284\n315\n351\n375\n423\n454\n495\n549\n634\n713\n907\n",
"4\n5\n9\n17\n",
"13\n26\n33\n44\n47\n69\n79\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15827\n16598\n16769\n17096\n17878\n18715\n19018\n19411\n19703\n20042\n20772\n21606\n22400\n23268\n23808\n24059\n24848\n25741\n25764\n26069\n26185\n26405\n27104\n27967\n28547\n29539\n30400\n30793\n30891\n31144\n31688\n31859\n32195\n32402\n32992\n34012\n34748\n36006\n37108\n38267\n39127\n40409\n40847\n42507\n43244\n44526\n45225\n46709\n48284\n49549\n50887\n51988\n52891\n53510\n54561\n55519\n56550\n57215\n58955\n60075\n61618\n63791\n65150\n66185\n66979\n68203\n69497\n71021\n72551\n75410\n77358\n79599\n81241\n83248\n87005\n91313\n94773\n99789\n102521\n105707\n109158\n113129\n119712\n127026\n133562\n142600\n156395\n171618\n199596\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1125\n1158\n1177\n1262\n1354\n1445\n1511\n1594\n1633\n1733\n1786\n1806\n1905\n1916\n1997\n2023\n2064\n2100\n2151\n2172\n2244\n2272\n2372\n2406\n2409\n2442\n2590\n2626\n2730\n2829\n2862\n2878\n2963\n3086\n3204\n3331\n3508\n3625\n3762\n3903\n3991\n4272\n4571\n4797\n5059\n5253\n5487\n5649\n5962\n6493\n7062\n7511\n8118\n9108\n10244\n12103\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n1989\n2040\n2061\n2133\n2161\n2261\n2295\n2298\n2331\n2479\n2515\n2619\n2718\n2751\n2767\n2841\n2964\n3082\n3209\n3386\n3503\n3640\n3781\n3869\n4050\n4349\n4575\n4837\n5031\n5265\n5427\n5729\n6160\n6729\n7178\n7785\n8675\n9811\n11570\n",
"8\n25\n58\n73\n91\n106\n126\n136\n141\n154\n159\n163\n178\n187\n198\n212\n238\n270\n310\n341\n377\n401\n449\n480\n521\n575\n673\n752\n959\n",
"4\n5\n6\n14\n",
"13\n26\n33\n44\n47\n69\n79\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15827\n16598\n16769\n17096\n17878\n18715\n19018\n19411\n19703\n20042\n20772\n21606\n22400\n23268\n23808\n24059\n24848\n25741\n25764\n26069\n26185\n26405\n27104\n27967\n28547\n29539\n30400\n30793\n30891\n31144\n31688\n31859\n32195\n32402\n32992\n34012\n34748\n36006\n37108\n38267\n39127\n40409\n40847\n42507\n43244\n44526\n45225\n46709\n48284\n49549\n50887\n51988\n52891\n53510\n54561\n55519\n56550\n57215\n58955\n59902\n61445\n63618\n64977\n66012\n66806\n68030\n69324\n70848\n72378\n75237\n77185\n79426\n81068\n83075\n86832\n90967\n94427\n99443\n102175\n105361\n108812\n112783\n119366\n126507\n133043\n142081\n155876\n170926\n198904\n",
"1\n3\n8\n12\n18\n26\n44\n",
"0\n0\n1\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1125\n1158\n1177\n1262\n1354\n1445\n1511\n1594\n1633\n1733\n1806\n1826\n1925\n1936\n2017\n2043\n2084\n2120\n2171\n2192\n2264\n2292\n2392\n2426\n2429\n2462\n2610\n2646\n2750\n2849\n2882\n2898\n2983\n3106\n3224\n3351\n3528\n3645\n3782\n3923\n4011\n4292\n4611\n4837\n5099\n5293\n5527\n5689\n6002\n6533\n7122\n7571\n8178\n9168\n10324\n12183\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n1989\n2040\n2061\n2133\n2161\n2261\n2295\n2298\n2331\n2479\n2515\n2619\n2718\n2751\n2767\n2841\n2964\n3082\n3209\n3386\n3503\n3640\n3781\n3869\n4050\n4349\n4575\n4837\n5031\n5265\n5427\n5729\n6160\n6721\n7170\n7777\n8667\n9795\n11554\n",
"8\n25\n58\n68\n86\n101\n121\n131\n136\n149\n154\n158\n173\n182\n193\n207\n233\n265\n305\n331\n367\n391\n439\n470\n511\n565\n663\n737\n944\n",
"13\n26\n33\n44\n47\n69\n77\n115\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171256\n199344\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1113\n1153\n1186\n1205\n1290\n1382\n1473\n1539\n1622\n1661\n1761\n1834\n1854\n1953\n1964\n2045\n2071\n2112\n2148\n2199\n2220\n2292\n2320\n2420\n2454\n2457\n2490\n2638\n2674\n2778\n2877\n2910\n2926\n3011\n3134\n3252\n3379\n3556\n3673\n3810\n3951\n4039\n4320\n4639\n4865\n5127\n5321\n5555\n5717\n6058\n6589\n7178\n7627\n8234\n9224\n10380\n12239\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1058\n1073\n1085\n1114\n1147\n1166\n1251\n1343\n1434\n1500\n1583\n1622\n1622\n1675\n1695\n1794\n1805\n1886\n1912\n1953\n2003\n2054\n2075\n2147\n2175\n2275\n2309\n2312\n2345\n2493\n2529\n2633\n2732\n2765\n2781\n2855\n2978\n3096\n3223\n3400\n3517\n3654\n3795\n3883\n4064\n4363\n4589\n4851\n5045\n5279\n5441\n5743\n6188\n6749\n7198\n7805\n8709\n9837\n11610\n",
"4\n5\n6\n19\n",
"13\n26\n34\n45\n48\n70\n79\n117\n",
"1\n3\n8\n12\n18\n26\n43\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1113\n1153\n1186\n1205\n1290\n1382\n1473\n1539\n1622\n1661\n1761\n1834\n1854\n1953\n1964\n2045\n2071\n2112\n2148\n2199\n2220\n2292\n2320\n2420\n2454\n2457\n2490\n2638\n2674\n2778\n2877\n2910\n2926\n3011\n3134\n3252\n3379\n3556\n3673\n3810\n3951\n4039\n4320\n4639\n4865\n5127\n5313\n5547\n5709\n6050\n6581\n7170\n7619\n8226\n9208\n10364\n12215\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1701\n1721\n1820\n1831\n1912\n1938\n1979\n2029\n2080\n2101\n2173\n2201\n2301\n2335\n2338\n2371\n2519\n2555\n2659\n2784\n2817\n2833\n2907\n3030\n3148\n3275\n3452\n3569\n3706\n3847\n3935\n4116\n4415\n4641\n4903\n5123\n5357\n5519\n5821\n6266\n6827\n7276\n7883\n8813\n9941\n11740\n",
"4\n5\n5\n18\n",
"13\n26\n34\n45\n48\n70\n80\n118\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171177\n199265\n",
"0\n2\n7\n11\n16\n24\n40\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2488\n2636\n2672\n2776\n2875\n2908\n2922\n3007\n3130\n3248\n3375\n3552\n3669\n3806\n3947\n4035\n4316\n4635\n4861\n5123\n5309\n5543\n5703\n6044\n6575\n7164\n7613\n8220\n9202\n10358\n12207\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1701\n1721\n1820\n1835\n1916\n1942\n1983\n2033\n2084\n2105\n2177\n2205\n2305\n2339\n2342\n2375\n2523\n2559\n2663\n2788\n2821\n2837\n2911\n3034\n3152\n3279\n3456\n3573\n3710\n3851\n3939\n4120\n4419\n4645\n4907\n5131\n5365\n5527\n5829\n6274\n6835\n7284\n7891\n8825\n9953\n11756\n",
"4\n5\n5\n7\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10709\n11450\n11764\n12500\n12517\n13389\n14360\n14919\n15567\n15900\n16671\n16842\n17169\n17951\n18788\n19091\n19484\n19776\n20115\n20845\n21679\n22473\n23341\n23881\n24132\n24921\n25814\n25837\n26142\n26258\n26478\n27177\n28040\n28620\n29612\n30473\n30866\n30964\n31217\n31761\n31932\n32268\n32475\n33065\n34085\n34821\n36079\n37181\n38340\n39163\n40445\n40883\n42543\n43280\n44562\n45261\n46745\n48320\n49585\n50923\n52024\n52927\n53546\n54597\n55555\n56586\n57251\n58991\n59938\n61481\n63654\n65013\n66048\n66952\n68176\n69470\n70994\n72524\n75383\n77331\n79572\n81177\n83184\n86941\n91076\n94536\n99552\n102284\n105470\n109031\n113002\n119585\n126726\n133262\n142300\n156095\n171066\n199117\n",
"0\n2\n7\n14\n19\n27\n43\n",
"72\n138\n220\n266\n310\n332\n395\n515\n586\n651\n656\n686\n731\n815\n844\n917\n926\n1016\n1041\n1060\n1086\n1101\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2488\n2636\n2672\n2776\n2875\n2908\n2922\n3007\n3130\n3248\n3375\n3609\n3726\n3863\n4004\n4092\n4373\n4692\n4918\n5180\n5366\n5600\n5760\n6101\n6632\n7221\n7670\n8334\n9316\n10472\n12321\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1731\n1751\n1850\n1865\n1946\n1972\n2013\n2063\n2114\n2135\n2207\n2235\n2335\n2369\n2372\n2405\n2553\n2589\n2693\n2818\n2851\n2867\n2941\n3064\n3182\n3309\n3486\n3603\n3740\n3881\n3969\n4150\n4479\n4705\n4967\n5191\n5425\n5587\n5889\n6334\n6925\n7374\n7981\n8915\n10073\n11876\n",
"4\n6\n6\n9\n",
"13\n26\n34\n44\n47\n69\n79\n116\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19779\n20509\n21343\n22137\n23005\n23545\n23796\n24585\n25478\n25501\n25806\n25922\n26142\n26841\n27704\n28284\n29276\n30137\n30530\n30628\n30881\n31425\n31596\n31932\n32139\n32729\n33749\n34485\n35743\n36845\n38004\n38827\n40109\n40547\n42207\n42944\n44226\n44925\n46409\n47984\n49249\n50587\n51688\n52591\n53210\n54261\n54883\n55914\n56579\n58319\n59266\n60809\n62982\n64341\n65376\n66280\n67504\n68798\n70322\n71852\n74711\n76659\n78900\n80505\n82512\n86269\n90404\n93864\n98880\n101612\n104798\n108359\n112330\n118913\n126054\n132590\n141628\n155423\n170058\n198109\n",
"0\n2\n7\n14\n19\n27\n38\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n916\n1006\n1031\n1050\n1076\n1091\n1101\n1141\n1174\n1193\n1278\n1370\n1461\n1527\n1610\n1649\n1749\n1822\n1842\n1941\n1952\n2033\n2059\n2100\n2136\n2187\n2208\n2280\n2308\n2408\n2442\n2445\n2478\n2626\n2662\n2766\n2865\n2898\n2912\n2997\n3120\n3238\n3365\n3599\n3716\n3853\n3994\n4082\n4363\n4682\n4908\n5160\n5346\n5580\n5740\n6081\n6612\n7201\n7650\n8304\n9286\n10442\n12291\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1140\n1173\n1192\n1277\n1369\n1460\n1526\n1609\n1648\n1648\n1731\n1751\n1850\n1865\n1985\n2011\n2052\n2102\n2153\n2174\n2246\n2274\n2374\n2408\n2411\n2444\n2592\n2628\n2732\n2857\n2890\n2906\n2980\n3103\n3221\n3348\n3525\n3642\n3779\n3920\n4008\n4189\n4518\n4744\n5006\n5230\n5503\n5665\n5967\n6412\n7003\n7452\n8059\n8993\n10190\n11993\n",
"8\n10\n10\n13\n",
"13\n26\n34\n46\n49\n71\n81\n120\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19727\n20457\n21291\n22085\n22953\n23493\n23744\n24533\n25426\n25449\n25754\n25870\n26090\n26789\n27652\n28232\n29224\n30085\n30478\n30576\n30829\n31373\n31544\n31880\n32087\n32677\n33697\n34433\n35691\n36793\n37952\n38775\n40057\n40495\n42155\n42892\n44174\n44873\n46357\n47932\n49197\n50535\n51636\n52539\n53158\n54209\n54831\n55862\n56527\n58267\n59214\n60757\n62930\n64289\n65324\n66228\n67452\n68746\n70270\n71800\n74659\n76607\n78848\n80453\n82408\n86165\n90300\n93760\n98776\n101508\n104694\n108255\n112226\n118809\n125950\n132486\n141524\n155319\n169954\n198005\n",
"0\n2\n7\n21\n26\n34\n45\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1045\n1071\n1086\n1096\n1136\n1169\n1188\n1273\n1365\n1456\n1522\n1605\n1644\n1744\n1817\n1837\n1936\n1947\n2028\n2054\n2095\n2131\n2182\n2203\n2275\n2303\n2403\n2437\n2440\n2468\n2616\n2652\n2756\n2855\n2888\n2902\n2987\n3110\n3228\n3355\n3589\n3706\n3843\n3984\n4072\n4348\n4667\n4893\n5145\n5331\n5565\n5725\n6066\n6592\n7181\n7630\n8284\n9261\n10417\n12261\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4764\n5026\n5250\n5523\n5685\n5997\n6442\n7033\n7482\n8089\n9023\n10220\n12023\n",
"10\n23\n31\n43\n46\n68\n78\n117\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10373\n11114\n11428\n12164\n12181\n13053\n14024\n14583\n15231\n15564\n16335\n16506\n16833\n17615\n18452\n18755\n19148\n19440\n19727\n20457\n21291\n22085\n22953\n23493\n23744\n24533\n25426\n25449\n25754\n25870\n26090\n26789\n27652\n28232\n29224\n30085\n30478\n30576\n30829\n31373\n31544\n31880\n32087\n32677\n33697\n34433\n35691\n36793\n37952\n38775\n40057\n40495\n42155\n42892\n44174\n44873\n46357\n47932\n49197\n50535\n51636\n52539\n53158\n54209\n54831\n55862\n56527\n58267\n59214\n60757\n62930\n64289\n65265\n66169\n67393\n68687\n70211\n71741\n74600\n76548\n78789\n80394\n82349\n86106\n90241\n93701\n98717\n101449\n104576\n108137\n112108\n118691\n125832\n132368\n141406\n155201\n169777\n197828\n",
"0\n2\n7\n17\n22\n30\n41\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1045\n1071\n1086\n1096\n1136\n1169\n1188\n1273\n1365\n1456\n1522\n1605\n1644\n1744\n1817\n1837\n1936\n1947\n2028\n2054\n2095\n2131\n2182\n2203\n2275\n2303\n2403\n2437\n2440\n2468\n2616\n2652\n2756\n2855\n2888\n2902\n2987\n3110\n3228\n3355\n3589\n3706\n3843\n3984\n4072\n4348\n4667\n4933\n5185\n5371\n5605\n5765\n6106\n6632\n7221\n7710\n8364\n9341\n10497\n12381\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4844\n5106\n5330\n5603\n5765\n6077\n6522\n7113\n7642\n8249\n9183\n10380\n12263\n",
"10\n23\n31\n43\n46\n68\n77\n116\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42716\n43998\n44697\n46181\n47756\n49021\n50359\n51460\n52363\n52982\n54033\n54479\n55510\n56175\n57915\n58862\n60405\n62578\n63937\n64913\n65817\n67041\n68335\n69859\n71389\n74248\n76196\n78437\n80042\n81997\n85754\n89889\n93349\n98365\n101097\n104224\n107785\n111756\n118339\n125480\n132016\n141054\n154849\n169249\n197300\n",
"0\n2\n10\n20\n25\n33\n47\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1078\n1093\n1103\n1143\n1176\n1195\n1280\n1372\n1463\n1529\n1612\n1651\n1751\n1824\n1844\n1943\n1954\n2035\n2061\n2102\n2138\n2189\n2210\n2282\n2310\n2410\n2444\n2447\n2475\n2623\n2659\n2770\n2869\n2902\n2916\n3001\n3124\n3242\n3369\n3603\n3720\n3857\n3998\n4086\n4362\n4681\n4947\n5206\n5392\n5626\n5786\n6127\n6653\n7242\n7731\n8392\n9369\n10525\n12409\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1470\n1536\n1619\n1658\n1658\n1741\n1761\n1860\n1875\n1995\n2021\n2062\n2112\n2163\n2184\n2256\n2284\n2384\n2418\n2421\n2454\n2602\n2638\n2742\n2867\n2900\n2916\n3000\n3123\n3241\n3368\n3545\n3662\n3799\n3940\n4028\n4209\n4538\n4844\n5106\n5330\n5700\n5862\n6174\n6619\n7210\n7739\n8346\n9280\n10574\n12457\n",
"10\n23\n31\n43\n46\n62\n72\n105\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42511\n43793\n44492\n45976\n47551\n48816\n50154\n51255\n52158\n52777\n53828\n54274\n55305\n55970\n57710\n58657\n60200\n62373\n63732\n64708\n65612\n66836\n68130\n69654\n71184\n74043\n75991\n78232\n79837\n81792\n85549\n89684\n92939\n97955\n100687\n103814\n107375\n111346\n117929\n125070\n131401\n140439\n154234\n168634\n196480\n",
"0\n2\n6\n16\n21\n29\n39\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1078\n1093\n1111\n1151\n1184\n1203\n1288\n1380\n1471\n1537\n1620\n1659\n1759\n1832\n1852\n1951\n1962\n2043\n2069\n2110\n2146\n2197\n2218\n2290\n2318\n2418\n2452\n2455\n2483\n2631\n2667\n2778\n2877\n2910\n2932\n3017\n3140\n3258\n3385\n3619\n3736\n3873\n4014\n4102\n4378\n4697\n4963\n5222\n5408\n5642\n5810\n6151\n6677\n7266\n7755\n8416\n9393\n10549\n12441\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n988\n1013\n1032\n1084\n1099\n1111\n1150\n1183\n1202\n1287\n1379\n1494\n1560\n1643\n1682\n1682\n1765\n1785\n1884\n1899\n2019\n2045\n2086\n2136\n2187\n2208\n2280\n2308\n2408\n2442\n2445\n2478\n2626\n2662\n2766\n2891\n2924\n2940\n3024\n3147\n3265\n3392\n3569\n3710\n3847\n3988\n4076\n4257\n4586\n4892\n5154\n5378\n5748\n5910\n6222\n6667\n7258\n7787\n8394\n9352\n10646\n12553\n",
"10\n23\n31\n51\n54\n70\n80\n121\n",
"242\n766\n1186\n2159\n2975\n3407\n3617\n4283\n4417\n5266\n5411\n5777\n6385\n7315\n7928\n8243\n9106\n9734\n9831\n9940\n10005\n10197\n10938\n11252\n11988\n12005\n12877\n13848\n14407\n15055\n15388\n16159\n16330\n16657\n17439\n18276\n18579\n18972\n19264\n19551\n20281\n21115\n21909\n22777\n23317\n23568\n24357\n25250\n25273\n25578\n25694\n25914\n26613\n27476\n28056\n29048\n29909\n30302\n30400\n30653\n31197\n31368\n31704\n31911\n32501\n33521\n34257\n35515\n36617\n37776\n38599\n39881\n40319\n41979\n42511\n43793\n44492\n45976\n47551\n48816\n50154\n51255\n52158\n52777\n53828\n54274\n55305\n55970\n57710\n58657\n60200\n62373\n63732\n64708\n65612\n66836\n68130\n69654\n71184\n74043\n75991\n78232\n79837\n81792\n85549\n89684\n92939\n97955\n100687\n103814\n107375\n111346\n117929\n125070\n131401\n140439\n154234\n168737\n196583\n",
"1\n3\n7\n17\n23\n31\n42\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1678\n1778\n1851\n1871\n1970\n1981\n2062\n2088\n2129\n2165\n2216\n2237\n2309\n2337\n2437\n2471\n2474\n2502\n2650\n2686\n2797\n2915\n2948\n2970\n3055\n3178\n3296\n3423\n3657\n3774\n3911\n4052\n4140\n4416\n4735\n5001\n5260\n5465\n5699\n5867\n6208\n6734\n7323\n7812\n8473\n9469\n10625\n12536\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n703\n787\n816\n889\n898\n915\n940\n959\n1011\n1026\n1038\n1077\n1110\n1129\n1214\n1306\n1421\n1487\n1570\n1609\n1609\n1692\n1712\n1811\n1826\n1946\n1972\n2013\n2063\n2114\n2135\n2207\n2235\n2335\n2369\n2372\n2405\n2480\n2516\n2620\n2745\n2778\n2794\n2878\n3001\n3119\n3246\n3423\n3564\n3701\n3842\n3930\n4111\n4367\n4673\n4935\n5159\n5529\n5691\n6003\n6448\n6966\n7495\n8102\n9060\n10281\n12188\n",
"10\n20\n28\n48\n51\n64\n74\n112\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26455\n27318\n27898\n28890\n29751\n30144\n30242\n30495\n31039\n31210\n31546\n31753\n32343\n33363\n33941\n35199\n36301\n37460\n38283\n39565\n40003\n41663\n42195\n43477\n44176\n45660\n47235\n48500\n49838\n50939\n51842\n52461\n53512\n53958\n54989\n55654\n57394\n58341\n59884\n62057\n63416\n64392\n65296\n66520\n67814\n69338\n70710\n73569\n75517\n77758\n79363\n81318\n85075\n89210\n92465\n97481\n100213\n103340\n106901\n110872\n117455\n124596\n130769\n139807\n153602\n168105\n195793\n",
"1\n3\n10\n20\n26\n34\n48\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1675\n1775\n1848\n1868\n1967\n1978\n2059\n2085\n2126\n2162\n2213\n2234\n2306\n2334\n2434\n2468\n2471\n2499\n2647\n2683\n2794\n2912\n2945\n2967\n3052\n3175\n3293\n3420\n3654\n3771\n3908\n4049\n4134\n4410\n4729\n4995\n5254\n5459\n5693\n5861\n6202\n6728\n7317\n7806\n8467\n9463\n10619\n12530\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2228\n2328\n2362\n2365\n2398\n2473\n2509\n2613\n2738\n2771\n2787\n2871\n2994\n3112\n3239\n3416\n3557\n3694\n3835\n3923\n4104\n4360\n4666\n4928\n5152\n5522\n5684\n5996\n6441\n6959\n7488\n8095\n9046\n10267\n12167\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26841\n27704\n28284\n29276\n30137\n30530\n30628\n30881\n31425\n31596\n31932\n32139\n32729\n33749\n34327\n35585\n36687\n37846\n38669\n39951\n40389\n42049\n42581\n43863\n44562\n46046\n47621\n48886\n50224\n51325\n52228\n52847\n53898\n54344\n55375\n56040\n57780\n58727\n60270\n62443\n63802\n64778\n65682\n66906\n68200\n69724\n71096\n73955\n75903\n78144\n79749\n81704\n85461\n89596\n92851\n97867\n100599\n103726\n107287\n111258\n117841\n124982\n131155\n140193\n154374\n168877\n196951\n",
"1\n5\n12\n22\n28\n38\n52\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n805\n834\n907\n911\n1001\n1026\n1052\n1097\n1112\n1130\n1170\n1203\n1222\n1307\n1399\n1490\n1556\n1639\n1675\n1775\n1848\n1868\n1967\n1978\n2059\n2085\n2126\n2162\n2213\n2234\n2306\n2334\n2434\n2468\n2471\n2499\n2647\n2683\n2794\n2912\n2945\n2967\n3052\n3188\n3306\n3433\n3667\n3784\n3921\n4062\n4147\n4423\n4742\n5008\n5267\n5472\n5706\n5874\n6215\n6754\n7343\n7832\n8493\n9502\n10658\n12582\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2228\n2328\n2362\n2365\n2398\n2473\n2509\n2613\n2738\n2771\n2787\n2871\n2994\n3112\n3239\n3416\n3557\n3694\n3835\n3923\n4104\n4360\n4666\n4928\n5152\n5522\n5684\n5996\n6441\n6959\n7488\n8095\n9046\n10258\n12158\n",
"10\n20\n28\n48\n51\n64\n74\n109\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n14249\n14897\n15230\n16001\n16172\n16499\n17281\n18118\n18421\n18814\n19106\n19393\n20123\n20957\n21751\n22619\n23159\n23410\n24199\n25092\n25115\n25420\n25536\n25756\n26841\n27704\n28284\n29276\n30137\n30916\n31014\n31267\n31811\n31982\n32318\n32525\n33115\n34135\n34713\n35971\n37073\n38232\n39055\n40337\n40775\n42435\n42967\n44249\n44948\n46432\n48007\n49272\n50610\n51711\n52614\n53233\n54284\n54730\n55761\n56426\n58166\n59499\n61042\n63215\n64574\n65550\n66454\n67678\n68972\n70496\n71868\n74727\n76675\n78916\n80521\n82476\n86233\n90754\n94009\n99025\n101757\n104884\n108445\n112416\n118999\n126526\n132699\n141737\n155918\n170807\n198881\n",
"1\n5\n12\n22\n28\n38\n53\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n867\n896\n969\n973\n1063\n1088\n1114\n1159\n1174\n1192\n1232\n1265\n1284\n1369\n1461\n1552\n1618\n1701\n1737\n1837\n1910\n1930\n2029\n2040\n2121\n2147\n2188\n2224\n2275\n2296\n2368\n2396\n2496\n2530\n2533\n2561\n2709\n2745\n2856\n2974\n3007\n3029\n3114\n3250\n3368\n3495\n3729\n3846\n3983\n4124\n4209\n4485\n4804\n5070\n5329\n5534\n5768\n5936\n6277\n6816\n7405\n7894\n8555\n9564\n10782\n12706\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n908\n933\n952\n1004\n1019\n1031\n1070\n1103\n1122\n1207\n1299\n1414\n1480\n1563\n1602\n1602\n1685\n1705\n1804\n1819\n1939\n1965\n2006\n2056\n2107\n2128\n2200\n2219\n2319\n2353\n2356\n2389\n2464\n2500\n2604\n2729\n2762\n2778\n2862\n2985\n3103\n3230\n3407\n3548\n3685\n3826\n3914\n4095\n4351\n4657\n4919\n5143\n5513\n5675\n5987\n6432\n6950\n7479\n8086\n9028\n10240\n12131\n",
"10\n27\n35\n55\n58\n78\n88\n130\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n13796\n14444\n14777\n15548\n15719\n16046\n16828\n17665\n17968\n18361\n18653\n18940\n19670\n20504\n21298\n22166\n22706\n22957\n23746\n24639\n24662\n24967\n25083\n25303\n26388\n27251\n27831\n28823\n29684\n30463\n30561\n30814\n31358\n31529\n31865\n32072\n32662\n33682\n34260\n35518\n36620\n37779\n38602\n39884\n40322\n41982\n42514\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75769\n78010\n79615\n81570\n85327\n89848\n93103\n98119\n100398\n103525\n107086\n111057\n117640\n125167\n131340\n140378\n154106\n168995\n196616\n",
"72\n138\n220\n256\n300\n322\n385\n505\n576\n641\n646\n676\n721\n867\n896\n969\n973\n1063\n1088\n1114\n1159\n1174\n1192\n1232\n1265\n1284\n1369\n1461\n1552\n1618\n1701\n1737\n1837\n1910\n1930\n2029\n2040\n2121\n2147\n2188\n2224\n2275\n2296\n2368\n2396\n2496\n2530\n2533\n2561\n2709\n2745\n2856\n2974\n3007\n3029\n3114\n3250\n3368\n3495\n3729\n3846\n3983\n4124\n4209\n4485\n4804\n5070\n5339\n5544\n5778\n5946\n6287\n6826\n7415\n7904\n8575\n9584\n10802\n12726\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1944\n1970\n2011\n2061\n2112\n2133\n2205\n2224\n2324\n2358\n2361\n2394\n2474\n2510\n2614\n2739\n2772\n2788\n2872\n2995\n3113\n3240\n3417\n3558\n3695\n3836\n3924\n4105\n4366\n4672\n4934\n5158\n5528\n5690\n6002\n6447\n6970\n7499\n8106\n9048\n10265\n12156\n",
"10\n27\n35\n55\n58\n78\n87\n129\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5619\n6227\n7157\n7770\n8085\n8948\n9576\n9673\n9782\n9847\n10039\n10780\n11094\n11830\n11847\n12719\n13690\n13796\n14444\n14777\n15548\n15719\n16046\n16828\n17665\n17968\n18361\n18653\n18940\n19670\n20504\n21298\n22166\n22706\n22957\n23746\n24639\n24676\n24981\n25097\n25317\n26402\n27265\n27845\n28837\n29698\n30477\n30575\n30828\n31372\n31543\n31879\n32086\n32676\n33696\n34274\n35532\n36634\n37793\n38616\n39898\n40336\n41996\n42528\n43810\n44509\n45993\n47568\n48833\n50171\n51272\n52175\n52794\n53845\n54291\n55322\n55987\n57727\n59060\n60603\n62776\n63682\n64658\n65562\n66786\n68080\n69604\n70976\n73835\n75783\n78024\n79629\n81584\n85341\n89862\n93117\n98133\n100412\n103539\n107100\n111071\n117668\n125195\n131368\n140406\n154148\n169037\n196672\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n896\n925\n998\n1002\n1092\n1117\n1143\n1188\n1203\n1221\n1261\n1294\n1313\n1398\n1490\n1581\n1647\n1730\n1766\n1866\n1939\n1959\n2058\n2069\n2150\n2176\n2217\n2253\n2304\n2325\n2397\n2425\n2525\n2559\n2562\n2590\n2738\n2774\n2885\n3003\n3036\n3058\n3143\n3279\n3397\n3524\n3758\n3875\n4012\n4153\n4238\n4514\n4833\n5099\n5368\n5602\n5836\n6004\n6345\n6884\n7473\n7962\n8633\n9671\n10889\n12842\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1888\n1914\n1955\n2005\n2056\n2077\n2149\n2168\n2268\n2302\n2305\n2338\n2418\n2454\n2558\n2683\n2716\n2732\n2816\n2939\n3057\n3184\n3361\n3502\n3639\n3780\n3868\n4049\n4310\n4616\n4878\n5102\n5416\n5578\n5890\n6335\n6858\n7387\n7994\n8936\n10097\n11988\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5612\n6220\n7150\n7763\n8078\n8941\n9569\n9666\n9775\n9840\n10032\n10773\n11087\n11823\n11840\n12712\n13683\n13789\n14437\n14770\n15541\n15712\n16039\n16821\n17658\n17961\n18354\n18646\n18933\n19663\n20497\n21291\n22159\n22699\n22950\n23739\n24632\n24669\n24974\n25090\n25310\n26395\n27258\n27838\n28830\n29691\n30470\n30568\n30821\n31365\n31536\n31872\n32079\n32669\n33689\n34267\n35525\n36627\n37786\n38609\n39891\n40329\n41989\n42521\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75769\n78010\n79615\n81570\n85327\n89848\n93103\n98112\n100391\n103518\n107079\n111050\n117647\n125174\n131347\n140378\n154120\n169009\n196644\n",
"1\n5\n12\n22\n28\n41\n56\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n896\n925\n998\n1002\n1092\n1117\n1143\n1188\n1203\n1221\n1261\n1294\n1313\n1398\n1490\n1581\n1647\n1730\n1766\n1866\n1939\n1959\n2058\n2069\n2150\n2176\n2217\n2253\n2304\n2325\n2397\n2425\n2525\n2559\n2562\n2590\n2738\n2774\n2885\n3003\n3036\n3058\n3143\n3279\n3397\n3524\n3758\n3875\n4012\n4153\n4238\n4514\n4833\n5099\n5368\n5596\n5830\n5998\n6339\n6878\n7467\n7956\n8627\n9659\n10877\n12824\n",
"242\n766\n1028\n2001\n2817\n3249\n3459\n4125\n4259\n5108\n5253\n5612\n6220\n7150\n7763\n8078\n8941\n9569\n9666\n9775\n9840\n10032\n10773\n11087\n11823\n11840\n12712\n13683\n13789\n14437\n14770\n15541\n15712\n16039\n16821\n17658\n17961\n18354\n18646\n18933\n19663\n20497\n21291\n22159\n22699\n22950\n23739\n24632\n24669\n24974\n25090\n25310\n26395\n27258\n27838\n28830\n29691\n30470\n30568\n30821\n31365\n31536\n31872\n32079\n32669\n33689\n34267\n35525\n36627\n37786\n38609\n39891\n40329\n41989\n42521\n43796\n44495\n45979\n47554\n48819\n50157\n51258\n52161\n52780\n53831\n54277\n55308\n55973\n57713\n59046\n60589\n62762\n63668\n64644\n65548\n66772\n68066\n69590\n70962\n73821\n75560\n77801\n79406\n81361\n85118\n89639\n92894\n97903\n100182\n103309\n106870\n110841\n117438\n124965\n131138\n140169\n153702\n168591\n196017\n",
"72\n138\n220\n256\n329\n351\n414\n534\n605\n670\n675\n705\n750\n769\n798\n871\n875\n965\n990\n1016\n1061\n1076\n1094\n1134\n1167\n1186\n1271\n1363\n1454\n1520\n1603\n1639\n1739\n1812\n1832\n1931\n1942\n2023\n2049\n2090\n2126\n2177\n2198\n2270\n2298\n2398\n2432\n2435\n2463\n2611\n2647\n2758\n2876\n2909\n2931\n3016\n3152\n3270\n3397\n3631\n3748\n3885\n4026\n4111\n4387\n4706\n4972\n5241\n5469\n5703\n5871\n6212\n6751\n7340\n7829\n8500\n9532\n10623\n12570\n",
"4\n5\n6\n14\n",
"1\n3\n8\n12\n18\n26\n44\n",
"242\n766\n1186\n2159\n2975\n3407\n3654\n4320\n4454\n5303\n5448\n5814\n6422\n7352\n7965\n8280\n9143\n9771\n9868\n9977\n10042\n10746\n11487\n11801\n12537\n12554\n13426\n14397\n14956\n15604\n15937\n16708\n16879\n17206\n17988\n18825\n19128\n19521\n19813\n20152\n20882\n21716\n22510\n23378\n23918\n24169\n24958\n25851\n25874\n26179\n26295\n26515\n27214\n28077\n28657\n29649\n30510\n30903\n31001\n31254\n31798\n31969\n32305\n32512\n33102\n34122\n34858\n36116\n37218\n38377\n39237\n40519\n40957\n42617\n43354\n44636\n45335\n46819\n48394\n49659\n50997\n52098\n53001\n53620\n54671\n55629\n56660\n57325\n59065\n60012\n61555\n63728\n65087\n66122\n67026\n68250\n69544\n71068\n72598\n75457\n77405\n79646\n81288\n83295\n87052\n91187\n94647\n99663\n102395\n105581\n109142\n113113\n119696\n126837\n133373\n142411\n156206\n171256\n199344\n",
"13\n26\n34\n45\n48\n70\n80\n118\n",
"10\n20\n28\n48\n51\n64\n74\n112\n",
"1\n5\n12\n22\n28\n38\n53\n",
"1\n5\n12\n22\n28\n38\n53\n",
"10\n27\n35\n55\n58\n78\n87\n129\n",
"72\n138\n220\n266\n310\n332\n395\n487\n558\n623\n628\n658\n696\n780\n809\n882\n891\n913\n938\n957\n1009\n1024\n1036\n1075\n1108\n1127\n1212\n1304\n1419\n1485\n1568\n1607\n1607\n1690\n1710\n1809\n1824\n1888\n1914\n1955\n2005\n2056\n2077\n2149\n2168\n2268\n2302\n2305\n2338\n2418\n2454\n2558\n2683\n2716\n2732\n2816\n2939\n3057\n3184\n3361\n3502\n3639\n3780\n3868\n4049\n4310\n4616\n4878\n5102\n5416\n5578\n5890\n6335\n6858\n7387\n7994\n8936\n10097\n11988\n",
"10\n27\n35\n55\n58\n78\n87\n129\n"
]
} | 2CODEFORCES
|
19_B. Checkout Assistant_1258 | Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. To steal one item Bob needs exactly 1 second. What is the minimum amount of money that Bob will have to pay to the checkout assistant? Remember, please, that it is Bob, who determines the order of items for the checkout assistant.
Input
The first input line contains number n (1 β€ n β€ 2000). In each of the following n lines each item is described by a pair of numbers ti, ci (0 β€ ti β€ 2000, 1 β€ ci β€ 109). If ti is 0, Bob won't be able to steal anything, while the checkout assistant is occupied with item i.
Output
Output one number β answer to the problem: what is the minimum amount of money that Bob will have to pay.
Examples
Input
4
2 10
0 20
1 5
1 3
Output
8
Input
3
0 1
0 10
0 100
Output
111 | n=input()
t=[0]
a=[0]
for i in range(n):
v1,v2=map(int,raw_input().split(" "))
v1+=1
t.append(v1)
a.append(v2)
ans=[10**15 for j in range(n+1)]
#print ans
ans[0]=0
for i in range(1,n+1):
for j in range(n,0,-1):
ans[j]=min(ans[j],ans[max(0,j-t[i])]+a[i])
print ans[n]
| 1Python2
| {
"input": [
"4\n2 10\n0 20\n1 5\n1 3\n",
"3\n0 1\n0 10\n0 100\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n",
"2\n2 87623264\n0 864627704\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 883486551\n1 114469023\n2 184038037\n",
"5\n4 33400980\n2 410698581\n4 794747123\n0 301889198\n3 219919361\n",
"2\n0 861438648\n1 469893784\n",
"2\n0 635254032\n0 75159864\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 103950505\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 799933987\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 33558766\n",
"2\n2 123040534\n0 864627704\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 114469023\n2 184038037\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 219919361\n",
"2\n0 861438648\n1 631594951\n",
"2\n0 635254032\n0 134646445\n",
"4\n2 10\n0 0\n1 5\n1 3\n",
"5\n0 968804136\n0 736567537\n2 116381581\n0 259899572\n1 103950505\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 1372806192\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"2\n0 158610850\n0 134646445\n",
"4\n2 1\n0 0\n1 5\n1 3\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"2\n1 1522651002\n1 612262323\n",
"5\n5 491957578\n1 1041170864\n3 446810728\n4 896625835\n4 2177645\n",
"2\n1 1522651002\n1 1002823702\n",
"2\n1 551083777\n1 1002823702\n",
"4\n2 0\n0 0\n1 5\n2 3\n",
"5\n5 491957578\n2 1041170864\n3 360748231\n4 896625835\n1 2177645\n",
"2\n1 946947494\n1 1002823702\n",
"5\n5 491957578\n2 1041170864\n4 360748231\n4 896625835\n1 2177645\n",
"5\n5 222326297\n2 1041170864\n4 360748231\n4 896625835\n1 2177645\n",
"5\n5 491957578\n4 1036171349\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 318920043\n",
"2\n0 1522651002\n1 631594951\n",
"5\n5 491957578\n1 1036171349\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 160154711\n",
"2\n1 1522651002\n1 631594951\n",
"4\n2 1\n0 0\n1 5\n2 3\n",
"5\n5 491957578\n1 1041170864\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 336918934\n3 160154711\n",
"4\n2 1\n0 0\n1 5\n4 3\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"5\n4 15419518\n2 182823038\n4 794747123\n0 336918934\n3 160154711\n",
"2\n0 1522651002\n1 612262323\n",
"4\n2 1\n1 0\n1 5\n4 3\n",
"5\n5 491957578\n2 1041170864\n3 446810728\n4 896625835\n4 2177645\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 184038037\n",
"5\n4 15419518\n2 182823038\n8 794747123\n0 336918934\n3 160154711\n",
"4\n2 1\n1 0\n1 5\n2 3\n",
"5\n5 491957578\n2 1041170864\n3 360748231\n4 896625835\n4 2177645\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 291657563\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 336918934\n3 160154711\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 127971438\n3 160154711\n",
"4\n2 0\n1 0\n1 5\n2 3\n",
"10\n3 512981548\n0 163778639\n2 603901234\n2 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 127971438\n4 160154711\n",
"2\n1 946947494\n0 1002823702\n",
"4\n2 0\n1 0\n1 8\n2 3\n",
"10\n3 512981548\n0 163778639\n3 603901234\n2 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 407482685\n0 127971438\n4 160154711\n",
"2\n1 946947494\n0 149372550\n",
"4\n2 0\n1 0\n0 8\n2 3\n",
"5\n5 222326297\n2 1041170864\n4 360748231\n0 896625835\n1 2177645\n",
"10\n3 512981548\n0 163778639\n3 603901234\n2 772872647\n1 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 407482685\n0 127971438\n4 34895028\n",
"2\n1 946947494\n0 211360858\n",
"4\n2 0\n1 0\n0 8\n0 3\n"
],
"output": [
"8",
"111",
"768880682",
"855132260",
"190748656",
"87623264",
"860384990",
"33400980",
"469893784",
"710413896",
"447086769\n",
"1023496771\n",
"33558766\n",
"123040534\n",
"860384990\n",
"15419518\n",
"631594951\n",
"769900477\n",
"8\n",
"220332086\n",
"1596368976\n",
"785972176\n",
"293257295\n",
"1\n",
"768205935\n",
"584167898\n",
"612262323\n",
"2177645\n",
"1002823702\n",
"551083777\n",
"0\n",
"362925876\n",
"946947494\n",
"360748231\n",
"222326297\n",
"33558766\n",
"15419518\n",
"631594951\n",
"33558766\n",
"15419518\n",
"631594951\n",
"1\n",
"33558766\n",
"15419518\n",
"1\n",
"584167898\n",
"15419518\n",
"612262323\n",
"1\n",
"2177645\n",
"584167898\n",
"15419518\n",
"1\n",
"2177645\n",
"584167898\n",
"15419518\n",
"584167898\n",
"15419518\n",
"0\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n",
"222326297\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n"
]
} | 2CODEFORCES
|
19_B. Checkout Assistant_1259 | Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. To steal one item Bob needs exactly 1 second. What is the minimum amount of money that Bob will have to pay to the checkout assistant? Remember, please, that it is Bob, who determines the order of items for the checkout assistant.
Input
The first input line contains number n (1 β€ n β€ 2000). In each of the following n lines each item is described by a pair of numbers ti, ci (0 β€ ti β€ 2000, 1 β€ ci β€ 109). If ti is 0, Bob won't be able to steal anything, while the checkout assistant is occupied with item i.
Output
Output one number β answer to the problem: what is the minimum amount of money that Bob will have to pay.
Examples
Input
4
2 10
0 20
1 5
1 3
Output
8
Input
3
0 1
0 10
0 100
Output
111 | #include <bits/stdc++.h>
using namespace std;
const long long INFL = 1152921504606846976ll;
int n;
int t[(1 << 11)], c[(1 << 11)];
long long dp[(1 << 11)];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
dp[i] = INFL;
}
dp[0] = 0ll;
for (int i = 0; i < n; i++) {
scanf("%d%d", &t[i], &c[i]);
for (int j = n - 1; j >= 0; j--) {
int tmp;
if (j + t[i] + 1 > n) {
tmp = n;
} else {
tmp = j + t[i] + 1;
}
dp[tmp] = (long long)min((long long)dp[tmp],
(long long)dp[j] + (long long)c[i]);
}
}
printf("%I64d\n", dp[n]);
return 0;
}
| 2C++
| {
"input": [
"4\n2 10\n0 20\n1 5\n1 3\n",
"3\n0 1\n0 10\n0 100\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n",
"2\n2 87623264\n0 864627704\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 883486551\n1 114469023\n2 184038037\n",
"5\n4 33400980\n2 410698581\n4 794747123\n0 301889198\n3 219919361\n",
"2\n0 861438648\n1 469893784\n",
"2\n0 635254032\n0 75159864\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 103950505\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 799933987\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 33558766\n",
"2\n2 123040534\n0 864627704\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 114469023\n2 184038037\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 219919361\n",
"2\n0 861438648\n1 631594951\n",
"2\n0 635254032\n0 134646445\n",
"4\n2 10\n0 0\n1 5\n1 3\n",
"5\n0 968804136\n0 736567537\n2 116381581\n0 259899572\n1 103950505\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 1372806192\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"2\n0 158610850\n0 134646445\n",
"4\n2 1\n0 0\n1 5\n1 3\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"2\n1 1522651002\n1 612262323\n",
"5\n5 491957578\n1 1041170864\n3 446810728\n4 896625835\n4 2177645\n",
"2\n1 1522651002\n1 1002823702\n",
"2\n1 551083777\n1 1002823702\n",
"4\n2 0\n0 0\n1 5\n2 3\n",
"5\n5 491957578\n2 1041170864\n3 360748231\n4 896625835\n1 2177645\n",
"2\n1 946947494\n1 1002823702\n",
"5\n5 491957578\n2 1041170864\n4 360748231\n4 896625835\n1 2177645\n",
"5\n5 222326297\n2 1041170864\n4 360748231\n4 896625835\n1 2177645\n",
"5\n5 491957578\n4 1036171349\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 318920043\n",
"2\n0 1522651002\n1 631594951\n",
"5\n5 491957578\n1 1036171349\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 160154711\n",
"2\n1 1522651002\n1 631594951\n",
"4\n2 1\n0 0\n1 5\n2 3\n",
"5\n5 491957578\n1 1041170864\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 336918934\n3 160154711\n",
"4\n2 1\n0 0\n1 5\n4 3\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"5\n4 15419518\n2 182823038\n4 794747123\n0 336918934\n3 160154711\n",
"2\n0 1522651002\n1 612262323\n",
"4\n2 1\n1 0\n1 5\n4 3\n",
"5\n5 491957578\n2 1041170864\n3 446810728\n4 896625835\n4 2177645\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 184038037\n",
"5\n4 15419518\n2 182823038\n8 794747123\n0 336918934\n3 160154711\n",
"4\n2 1\n1 0\n1 5\n2 3\n",
"5\n5 491957578\n2 1041170864\n3 360748231\n4 896625835\n4 2177645\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 291657563\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 336918934\n3 160154711\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 127971438\n3 160154711\n",
"4\n2 0\n1 0\n1 5\n2 3\n",
"10\n3 512981548\n0 163778639\n2 603901234\n2 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 127971438\n4 160154711\n",
"2\n1 946947494\n0 1002823702\n",
"4\n2 0\n1 0\n1 8\n2 3\n",
"10\n3 512981548\n0 163778639\n3 603901234\n2 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 407482685\n0 127971438\n4 160154711\n",
"2\n1 946947494\n0 149372550\n",
"4\n2 0\n1 0\n0 8\n2 3\n",
"5\n5 222326297\n2 1041170864\n4 360748231\n0 896625835\n1 2177645\n",
"10\n3 512981548\n0 163778639\n3 603901234\n2 772872647\n1 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 407482685\n0 127971438\n4 34895028\n",
"2\n1 946947494\n0 211360858\n",
"4\n2 0\n1 0\n0 8\n0 3\n"
],
"output": [
"8",
"111",
"768880682",
"855132260",
"190748656",
"87623264",
"860384990",
"33400980",
"469893784",
"710413896",
"447086769\n",
"1023496771\n",
"33558766\n",
"123040534\n",
"860384990\n",
"15419518\n",
"631594951\n",
"769900477\n",
"8\n",
"220332086\n",
"1596368976\n",
"785972176\n",
"293257295\n",
"1\n",
"768205935\n",
"584167898\n",
"612262323\n",
"2177645\n",
"1002823702\n",
"551083777\n",
"0\n",
"362925876\n",
"946947494\n",
"360748231\n",
"222326297\n",
"33558766\n",
"15419518\n",
"631594951\n",
"33558766\n",
"15419518\n",
"631594951\n",
"1\n",
"33558766\n",
"15419518\n",
"1\n",
"584167898\n",
"15419518\n",
"612262323\n",
"1\n",
"2177645\n",
"584167898\n",
"15419518\n",
"1\n",
"2177645\n",
"584167898\n",
"15419518\n",
"584167898\n",
"15419518\n",
"0\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n",
"222326297\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n"
]
} | 2CODEFORCES
|
19_B. Checkout Assistant_1260 | Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. To steal one item Bob needs exactly 1 second. What is the minimum amount of money that Bob will have to pay to the checkout assistant? Remember, please, that it is Bob, who determines the order of items for the checkout assistant.
Input
The first input line contains number n (1 β€ n β€ 2000). In each of the following n lines each item is described by a pair of numbers ti, ci (0 β€ ti β€ 2000, 1 β€ ci β€ 109). If ti is 0, Bob won't be able to steal anything, while the checkout assistant is occupied with item i.
Output
Output one number β answer to the problem: what is the minimum amount of money that Bob will have to pay.
Examples
Input
4
2 10
0 20
1 5
1 3
Output
8
Input
3
0 1
0 10
0 100
Output
111 | n=int(input())
ar=[float('inf')]*(n+1)
ar[0]=0
for i in range(n):
t,c=map(int,input().split())
for j in range(n-1,-1,-1):
w=min(j+t+1,n)
ar[w]=min(ar[w],ar[j]+c)
print(ar[n])
| 3Python3
| {
"input": [
"4\n2 10\n0 20\n1 5\n1 3\n",
"3\n0 1\n0 10\n0 100\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n",
"2\n2 87623264\n0 864627704\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 883486551\n1 114469023\n2 184038037\n",
"5\n4 33400980\n2 410698581\n4 794747123\n0 301889198\n3 219919361\n",
"2\n0 861438648\n1 469893784\n",
"2\n0 635254032\n0 75159864\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 103950505\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 799933987\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 33558766\n",
"2\n2 123040534\n0 864627704\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 114469023\n2 184038037\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 219919361\n",
"2\n0 861438648\n1 631594951\n",
"2\n0 635254032\n0 134646445\n",
"4\n2 10\n0 0\n1 5\n1 3\n",
"5\n0 968804136\n0 736567537\n2 116381581\n0 259899572\n1 103950505\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 1372806192\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"2\n0 158610850\n0 134646445\n",
"4\n2 1\n0 0\n1 5\n1 3\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"2\n1 1522651002\n1 612262323\n",
"5\n5 491957578\n1 1041170864\n3 446810728\n4 896625835\n4 2177645\n",
"2\n1 1522651002\n1 1002823702\n",
"2\n1 551083777\n1 1002823702\n",
"4\n2 0\n0 0\n1 5\n2 3\n",
"5\n5 491957578\n2 1041170864\n3 360748231\n4 896625835\n1 2177645\n",
"2\n1 946947494\n1 1002823702\n",
"5\n5 491957578\n2 1041170864\n4 360748231\n4 896625835\n1 2177645\n",
"5\n5 222326297\n2 1041170864\n4 360748231\n4 896625835\n1 2177645\n",
"5\n5 491957578\n4 1036171349\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 318920043\n",
"2\n0 1522651002\n1 631594951\n",
"5\n5 491957578\n1 1036171349\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 160154711\n",
"2\n1 1522651002\n1 631594951\n",
"4\n2 1\n0 0\n1 5\n2 3\n",
"5\n5 491957578\n1 1041170864\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 336918934\n3 160154711\n",
"4\n2 1\n0 0\n1 5\n4 3\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"5\n4 15419518\n2 182823038\n4 794747123\n0 336918934\n3 160154711\n",
"2\n0 1522651002\n1 612262323\n",
"4\n2 1\n1 0\n1 5\n4 3\n",
"5\n5 491957578\n2 1041170864\n3 446810728\n4 896625835\n4 2177645\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 184038037\n",
"5\n4 15419518\n2 182823038\n8 794747123\n0 336918934\n3 160154711\n",
"4\n2 1\n1 0\n1 5\n2 3\n",
"5\n5 491957578\n2 1041170864\n3 360748231\n4 896625835\n4 2177645\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 291657563\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 336918934\n3 160154711\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 127971438\n3 160154711\n",
"4\n2 0\n1 0\n1 5\n2 3\n",
"10\n3 512981548\n0 163778639\n2 603901234\n2 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 127971438\n4 160154711\n",
"2\n1 946947494\n0 1002823702\n",
"4\n2 0\n1 0\n1 8\n2 3\n",
"10\n3 512981548\n0 163778639\n3 603901234\n2 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 407482685\n0 127971438\n4 160154711\n",
"2\n1 946947494\n0 149372550\n",
"4\n2 0\n1 0\n0 8\n2 3\n",
"5\n5 222326297\n2 1041170864\n4 360748231\n0 896625835\n1 2177645\n",
"10\n3 512981548\n0 163778639\n3 603901234\n2 772872647\n1 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 407482685\n0 127971438\n4 34895028\n",
"2\n1 946947494\n0 211360858\n",
"4\n2 0\n1 0\n0 8\n0 3\n"
],
"output": [
"8",
"111",
"768880682",
"855132260",
"190748656",
"87623264",
"860384990",
"33400980",
"469893784",
"710413896",
"447086769\n",
"1023496771\n",
"33558766\n",
"123040534\n",
"860384990\n",
"15419518\n",
"631594951\n",
"769900477\n",
"8\n",
"220332086\n",
"1596368976\n",
"785972176\n",
"293257295\n",
"1\n",
"768205935\n",
"584167898\n",
"612262323\n",
"2177645\n",
"1002823702\n",
"551083777\n",
"0\n",
"362925876\n",
"946947494\n",
"360748231\n",
"222326297\n",
"33558766\n",
"15419518\n",
"631594951\n",
"33558766\n",
"15419518\n",
"631594951\n",
"1\n",
"33558766\n",
"15419518\n",
"1\n",
"584167898\n",
"15419518\n",
"612262323\n",
"1\n",
"2177645\n",
"584167898\n",
"15419518\n",
"1\n",
"2177645\n",
"584167898\n",
"15419518\n",
"584167898\n",
"15419518\n",
"0\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n",
"222326297\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n"
]
} | 2CODEFORCES
|
19_B. Checkout Assistant_1261 | Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. To steal one item Bob needs exactly 1 second. What is the minimum amount of money that Bob will have to pay to the checkout assistant? Remember, please, that it is Bob, who determines the order of items for the checkout assistant.
Input
The first input line contains number n (1 β€ n β€ 2000). In each of the following n lines each item is described by a pair of numbers ti, ci (0 β€ ti β€ 2000, 1 β€ ci β€ 109). If ti is 0, Bob won't be able to steal anything, while the checkout assistant is occupied with item i.
Output
Output one number β answer to the problem: what is the minimum amount of money that Bob will have to pay.
Examples
Input
4
2 10
0 20
1 5
1 3
Output
8
Input
3
0 1
0 10
0 100
Output
111 | import java.io.*;
import java.util.*;
public class Answer19B{
public static void main(String[] args){
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
new Kai(reader).solve();
}
}
class Kai{
BufferedReader reader;
public Kai(BufferedReader reader){
this.reader=reader;
}
public void solve(){
//TODO
int n=to_i(read());
int[] t=new int[n];
long[] c=new long[n];
long sum=0;
for(int i=0;i<n;i++){
String[] tmp=read().split(" ");
t[i]=to_i(tmp[0]);
c[i]=to_i(tmp[1]);
sum+=c[i];
}
long[][] dp =new long[n+1][n+1+n];
for(int i=0;i<n+1;i++)Arrays.fill(dp[i],-1);
dp[0][n]=0;
for(int i=0;i<n;i++){
for(int j=0;j<2*n+1;j++){
if(dp[i][j]!=-1){
//get
dp[i+1][j-1]=Math.max(dp[i][j]+c[i],dp[i+1][j-1]);
//remove
int num=j+t[i];
if(num>=2*n)num=2*n;
dp[i+1][num]=Math.max(dp[i][j],dp[i+1][num]);
}
}
}
long max=0;
for(int i=n;i<2*n;i++){
max=Math.max(dp[n][i],max);
}
println(sum-max);
}
public String read(){
String s=null;
try{
s=reader.readLine();
}catch(IOException e){
e.printStackTrace();
}
return s;
}
public int to_i(String s){
return Integer.parseInt(s);
}
public long to_l(String s){
return Long.parseLong(s);
}
public void print(Object s){
System.out.print(s);
}
public void println(Object s){
System.out.println(s);
}
public void debug(Object s){
System.err.print(s);
}
public void debugln(Object s){
System.err.println(s);
}
public void debug(Object[] s){
System.err.print(Arrays.deepToString(s));
}
public void debugln(Object[] s){
System.err.print(Arrays.deepToString(s));
}
} | 4JAVA
| {
"input": [
"4\n2 10\n0 20\n1 5\n1 3\n",
"3\n0 1\n0 10\n0 100\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n",
"2\n2 87623264\n0 864627704\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 883486551\n1 114469023\n2 184038037\n",
"5\n4 33400980\n2 410698581\n4 794747123\n0 301889198\n3 219919361\n",
"2\n0 861438648\n1 469893784\n",
"2\n0 635254032\n0 75159864\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 103950505\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 799933987\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 33558766\n",
"2\n2 123040534\n0 864627704\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 114469023\n2 184038037\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 219919361\n",
"2\n0 861438648\n1 631594951\n",
"2\n0 635254032\n0 134646445\n",
"4\n2 10\n0 0\n1 5\n1 3\n",
"5\n0 968804136\n0 736567537\n2 116381581\n0 259899572\n1 103950505\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 1372806192\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 561877930\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"2\n0 158610850\n0 134646445\n",
"4\n2 1\n0 0\n1 5\n1 3\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n4 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"10\n3 512981548\n0 214269975\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"2\n1 1522651002\n1 612262323\n",
"5\n5 491957578\n1 1041170864\n3 446810728\n4 896625835\n4 2177645\n",
"2\n1 1522651002\n1 1002823702\n",
"2\n1 551083777\n1 1002823702\n",
"4\n2 0\n0 0\n1 5\n2 3\n",
"5\n5 491957578\n2 1041170864\n3 360748231\n4 896625835\n1 2177645\n",
"2\n1 946947494\n1 1002823702\n",
"5\n5 491957578\n2 1041170864\n4 360748231\n4 896625835\n1 2177645\n",
"5\n5 222326297\n2 1041170864\n4 360748231\n4 896625835\n1 2177645\n",
"5\n5 491957578\n4 1036171349\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 318920043\n",
"2\n0 1522651002\n1 631594951\n",
"5\n5 491957578\n1 1036171349\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 301889198\n3 160154711\n",
"2\n1 1522651002\n1 631594951\n",
"4\n2 1\n0 0\n1 5\n2 3\n",
"5\n5 491957578\n1 1041170864\n3 446810728\n4 896625835\n4 33558766\n",
"5\n4 15419518\n2 410698581\n4 794747123\n0 336918934\n3 160154711\n",
"4\n2 1\n0 0\n1 5\n4 3\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1128067436\n1 40056209\n2 184038037\n",
"5\n4 15419518\n2 182823038\n4 794747123\n0 336918934\n3 160154711\n",
"2\n0 1522651002\n1 612262323\n",
"4\n2 1\n1 0\n1 5\n4 3\n",
"5\n5 491957578\n2 1041170864\n3 446810728\n4 896625835\n4 2177645\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 184038037\n",
"5\n4 15419518\n2 182823038\n8 794747123\n0 336918934\n3 160154711\n",
"4\n2 1\n1 0\n1 5\n2 3\n",
"5\n5 491957578\n2 1041170864\n3 360748231\n4 896625835\n4 2177645\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 291657563\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 336918934\n3 160154711\n",
"10\n3 512981548\n0 163778639\n2 603901234\n3 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 127971438\n3 160154711\n",
"4\n2 0\n1 0\n1 5\n2 3\n",
"10\n3 512981548\n0 163778639\n2 603901234\n2 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 841611853\n0 127971438\n4 160154711\n",
"2\n1 946947494\n0 1002823702\n",
"4\n2 0\n1 0\n1 8\n2 3\n",
"10\n3 512981548\n0 163778639\n3 603901234\n2 772872647\n0 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 407482685\n0 127971438\n4 160154711\n",
"2\n1 946947494\n0 149372550\n",
"4\n2 0\n1 0\n0 8\n2 3\n",
"5\n5 222326297\n2 1041170864\n4 360748231\n0 896625835\n1 2177645\n",
"10\n3 512981548\n0 163778639\n3 603901234\n2 772872647\n1 224281389\n8 544111689\n1 809519308\n4 1651150053\n1 40056209\n2 483276873\n",
"5\n4 15419518\n2 182823038\n8 407482685\n0 127971438\n4 34895028\n",
"2\n1 946947494\n0 211360858\n",
"4\n2 0\n1 0\n0 8\n0 3\n"
],
"output": [
"8",
"111",
"768880682",
"855132260",
"190748656",
"87623264",
"860384990",
"33400980",
"469893784",
"710413896",
"447086769\n",
"1023496771\n",
"33558766\n",
"123040534\n",
"860384990\n",
"15419518\n",
"631594951\n",
"769900477\n",
"8\n",
"220332086\n",
"1596368976\n",
"785972176\n",
"293257295\n",
"1\n",
"768205935\n",
"584167898\n",
"612262323\n",
"2177645\n",
"1002823702\n",
"551083777\n",
"0\n",
"362925876\n",
"946947494\n",
"360748231\n",
"222326297\n",
"33558766\n",
"15419518\n",
"631594951\n",
"33558766\n",
"15419518\n",
"631594951\n",
"1\n",
"33558766\n",
"15419518\n",
"1\n",
"584167898\n",
"15419518\n",
"612262323\n",
"1\n",
"2177645\n",
"584167898\n",
"15419518\n",
"1\n",
"2177645\n",
"584167898\n",
"15419518\n",
"584167898\n",
"15419518\n",
"0\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n",
"222326297\n",
"584167898\n",
"15419518\n",
"946947494\n",
"0\n"
]
} | 2CODEFORCES
|
223_C. Partial Sums_1262 | You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:
1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 β€ i β€ n) of array s equals <image>. The operation x mod y means that we take the remainder of the division of number x by number y.
2. Then we write the contents of the array s to the array a. Element number i (1 β€ i β€ n) of the array s becomes the i-th element of the array a (ai = si).
You task is to find array a after exactly k described operations are applied.
Input
The first line contains two space-separated integers n and k (1 β€ n β€ 2000, 0 β€ k β€ 109). The next line contains n space-separated integers a1, a2, ..., an β elements of the array a (0 β€ ai β€ 109).
Output
Print n integers β elements of the array a after the operations are applied to it. Print the elements in the order of increasing of their indexes in the array a. Separate the printed numbers by spaces.
Examples
Input
3 1
1 2 3
Output
1 3 6
Input
5 0
3 14 15 92 6
Output
3 14 15 92 6 | M=10**9+7
I=lambda:map(int,raw_input().split())
n,k=I()
a=I()
l=[1]
for i in range(n):print sum(i*j for i,j in zip(l[::-1],a))%M,;l.append(l[-1]*(i+k)*pow(i+1,M-2,M)%M);
| 1Python2
| {
"input": [
"5 0\n3 14 15 92 6\n",
"3 1\n1 2 3\n",
"10 1000000\n1 2 3 4 84 5 6 7 8 9\n",
"1 1\n3\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n",
"1 0\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"4 1\n3 20 3 4\n",
"1 0\n123\n",
"17 239\n663 360 509 307 311 501 523 370 302 601 541 42 328 200 196 110 573\n",
"1 1\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 5 6 8 11\n",
"10 1000000\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 334\n",
"1 2\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 1\n5 20 3 4\n",
"1 0\n201\n",
"17 239\n663 360 509 307 311 501 523 370 302 601 1047 42 328 200 196 110 573\n",
"1 1\n1\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 5 6 4 11\n",
"5 0\n2 14 15 92 6\n",
"3 1\n2 2 3\n",
"10 1000010\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 53 128 233 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 1\n5 20 3 7\n",
"17 239\n663 360 509 307 311 501 523 370 302 48 1047 42 328 200 196 110 573\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 0 6 4 11\n",
"5 0\n0 14 15 92 6\n",
"3 0\n2 2 3\n",
"10 0000010\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 42 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 0\n5 20 3 7\n",
"17 239\n663 360 509 391 311 501 523 370 302 48 1047 42 328 200 196 110 573\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 34\n11 0 6 4 11\n",
"5 0\n0 14 15 11 6\n",
"3 0\n3 2 3\n",
"10 0000010\n1 2 3 1 8 5 6 7 8 9\n",
"13 666\n84 26 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"17 239\n663 360 509 391 311 501 523 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 27 11 6\n",
"10 0000010\n1 2 3 1 8 5 6 7 15 9\n",
"13 666\n46 26 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 391 311 501 202 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 27 16 6\n",
"10 0000010\n1 2 3 1 14 5 6 7 15 9\n",
"13 666\n46 26 37 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 35 16 6\n",
"10 0000010\n1 2 3 1 27 5 6 7 15 9\n",
"13 666\n46 45 37 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 77 42 42 7 42 42 42 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 481 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 23 42 42 42 42 42 42\n",
"5 0\n0 14 35 16 1\n",
"10 0000010\n1 2 3 1 27 3 6 7 15 9\n",
"13 666\n46 45 37 53 128 56 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 77 42 42 7 42 42 64 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 481 48 1051 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 52 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 23 42 42 42 42 42 42\n",
"5 0\n0 14 35 5 1\n",
"1 1\n201\n"
],
"output": [
"3 14 15 92 6 ",
"1 3 6 ",
"1 1000002 2496503 504322849 591771075 387496712 683276420 249833545 23968189 474356595 ",
"3 ",
"84 56033 18716627 174151412 225555860 164145872 451267967 434721493 224270207 253181081 361500071 991507723 152400567 ",
"0 ",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644609 ",
"3 23 26 30 ",
"123 ",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776716020 52125061 263719534 192023697 446278138 592149678 33061993 189288187 ",
"0 ",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644609 ",
"11 225 2416 18118 106536 ",
"1 1000002 2496503 504322849 591770999 311496712 645542420 224765591 516711096 649261079\n",
"84 56033 18716627 174151412 225555860 164145872 451267967 434721493 224270207 253181081 361500071 991507723 152400701\n",
"0\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644597\n",
"5 25 28 32\n",
"201\n",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776716020 52125567 263840468 206535777 612081891 123276661 845833532 908663880\n",
"1\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648646 51599271 850158256 437097940 807189706 279730463 711982601 807712523 805073106 298038600 475158588 660787710 599391012 366184931 166868326\n",
"11 225 2416 18114 106456\n",
"2 14 15 92 6\n",
"2 4 7\n",
"1 1000012 12496578 584288209 992308274 231197244 45948862 595982554 504118493 649422819\n",
"84 56033 18716627 174151362 225522560 153040322 978432188 852936841 265126447 488937224 994089645 958105263 95372047\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773015 214937477 654149104 446762870 489314408 203428123 937115419 852762596 444821029 227163797 262469593 342879352 8605512 196744246 600566934 99913950 642203391 531108945 271868595 957236889 95201146 763234207 745747255 344503962 868607390 469425161 195769547 454291698\n",
"5 25 28 35\n",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776715467 51993400 247980428 932445911 529644690 916828726 116950611 397761820\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648621 51598221 850135681 436766840 803464831 245461613 443543276 966985737 530621533 662196541 32364071 567577280 21044945 963824366 443308949\n",
"11 220 2316 17064 98756\n",
"0 14 15 92 6\n",
"2 2 3\n",
"1 12 78 364 1368 4397 12530 32418 77441 172965\n",
"84 56033 18716627 174151362 225522560 153040410 978490796 872482609 617317427 392878216 122182657 783174453 302014406\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142882 828904127 463105338 571970234 660082364 275220438 289170630 12918872 469630160 633302993 874335553 980317482 321310139 350455586 55045347 839800837 86995722 159051063 661056932 794253564 390910553 126137310 880557763 264467905 260382873 608805018 702481803 896124293 980697244 986950684 638120645 689705818\n",
"5 20 3 7\n",
"663 158817 19101389 537972315 259408369 747390200 200179538 943396061 444549919 900090088 370105107 279915350 475548761 198595447 604895912 951683704 899146814\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648621 51598221 850135649 436765496 803435935 245037805 438775436 923121609 187019197 306066251 601066064 393699440 134267968 44515010 383025988\n",
"11 374 6551 78748 730212\n",
"0 14 15 11 6\n",
"3 2 3\n",
"1 12 78 361 1338 4232 11870 30273 71435 157950\n",
"84 55970 18674669 160158369 109749473 39991744 829969657 429535344 94380281 150791115 770326558 32887459 648014009\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867539 227244048 913355582 435901373 685397962 943124109 654423232 849822880 911625655 187150788 842062222 111330478 54320086 165216541 459043775 366843596 287310159 915507583 368299889 491228615 457859793 730144084 630547855 233475828 454884963 821196910 645836716 352788303\n",
"663 158817 19101389 537972315 259408369 747390200 200179538 943396061 444549919 900090088 370105107 279915350 475548761 198595447 604895912 951683704 899147324\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022013 897433804 552030507 603795062 450223325 608667033 680962300 604848602 544610522 554913866 295112069 153019471 269680942 881824024 277993574 40500219 117418281 808995986 791880318 934197567 352611267\n",
"0 14 27 11 6\n",
"1 12 78 361 1338 4232 11870 30273 71442 158020\n",
"46 30662 10234451 280803175 787593140 871042492 769144324 590303418 868994417 827449343 444756626 479680872 937942218\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867539 227244048 913355582 435901373 685397962 943124109 654423232 849822880 911625655 187150788 842062222 111330478 54320086 165216541 459043775 366843596 287310159 915507583 368299889 491228615 457859793 730144084 630547855 233475828 454884963 821196910 645836716 352788274\n",
"663 158817 19101389 537972315 259408369 747390200 200179217 943319342 435343639 160518928 626050242 718848827 325510033 947240009 125716029 911969229 914228351\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884579 378168486 101695352 784630959 265279778 355695456 916059284 142810010 463449237 416828871\n",
"0 14 27 16 6\n",
"1 12 78 361 1344 4292 12200 31593 75732 170032\n",
"46 30662 10234459 280808503 789370028 266696213 942229870 783766421 671273433 846235012 650101021 968805460 953851677\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867579 227245728 913391702 436431133 691357762 997954269 83926145 794985739 950748169 404498088 950533445 260467166 379673789 208993452 416738781 342238286 324653743 337032747 27743493 836840006 861974531 970863780 501699706 831463594 657768486 396809404 13761223 538672230\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654174 308480736 804713487 962743574 352399154 214090200 438961380 937913996 876700387\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884594 378169116 101708897 784829619 267514703 376256766 77122872 247246083 228120178 998334112\n",
"0 14 35 16 6\n",
"1 12 78 361 1357 4422 12915 34453 85027 196058\n",
"46 30681 10247113 285028612 729047625 427774383 526704496 314179084 590889396 458927944 311771907 131590419 230454967\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592382 592768744 120751745 797606387 834117482 511050123 947321749 231885078 11477926 603570586 656343454 821852364 407638753 247230943 7968864 679218521 437173724 944367967 462480323 807083757 312593846 627368515 854496160 97893033 139555827 906404434 908773954 524622989 496676054 667453480 823747523 994686001 9152477 841439641 423256962\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654353 308523517 809847207 375152407 303133799 819793968 70914437 56271075 16180750\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884594 378169116 101708897 784829600 267513905 376239609 76871236 244415178 202075852 794320225\n",
"0 14 35 16 1\n",
"1 12 78 361 1357 4420 12895 34343 84587 194628\n",
"46 30681 10247113 285028612 729047625 427774118 526528006 255319669 484859747 475469273 528309979 681097972 983179691\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592382 592768744 120751745 797606387 834117482 511050123 947321771 231886002 11497792 603861954 659621344 852008952 643865359 867070520 929486253 798759536 546832897 826393144 691424860 681161057 389326100 113835591 275035127 179731876 352249812 946490698 431037055 257018819 275809571 96346745 985333461 661272872 111510959 543675814 582338966\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654353 308523517 809847211 375153363 303248519 829009808 628472757 153605238 974436691\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954875 738091524 190272893 461004327 122916287 385267821 211626814 663856509 21802679 951772351 329185334 641622238 287670544 425812173 610626541 117489202 44046991 133076136 96155972 542287440 979197804 161888821 502617561 917010850 176960488 470774363 836396310 248546841 230266586\n",
"0 14 35 5 1\n",
"201\n"
]
} | 2CODEFORCES
|
223_C. Partial Sums_1263 | You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:
1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 β€ i β€ n) of array s equals <image>. The operation x mod y means that we take the remainder of the division of number x by number y.
2. Then we write the contents of the array s to the array a. Element number i (1 β€ i β€ n) of the array s becomes the i-th element of the array a (ai = si).
You task is to find array a after exactly k described operations are applied.
Input
The first line contains two space-separated integers n and k (1 β€ n β€ 2000, 0 β€ k β€ 109). The next line contains n space-separated integers a1, a2, ..., an β elements of the array a (0 β€ ai β€ 109).
Output
Print n integers β elements of the array a after the operations are applied to it. Print the elements in the order of increasing of their indexes in the array a. Separate the printed numbers by spaces.
Examples
Input
3 1
1 2 3
Output
1 3 6
Input
5 0
3 14 15 92 6
Output
3 14 15 92 6 | #include <bits/stdc++.h>
using namespace std;
int const mod = 1e9 + 7;
int const maxn = 2005;
inline void safe_mul(int& a, int b) { a = (a * 1LL * b) % mod; }
inline int mypow(int a, int b) {
int ans = 1;
int tmp = a;
while (b) {
if (b & 1) safe_mul(ans, tmp);
safe_mul(tmp, tmp);
b >>= 1;
}
return ans;
}
inline int inv(int x) { return mypow(x, mod - 2); }
int koef[maxn];
int a[maxn];
int main() {
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
koef[0] = 1;
for (int i = 1; i < n; ++i) {
koef[i] = koef[i - 1];
safe_mul(koef[i], (k + i - 1) * 1LL * inv(i) % mod);
}
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < n; ++i) {
int ans = 0;
for (int j = 0; j <= i; ++j) ans = (ans + koef[j] * 1LL * a[i - j]) % mod;
cout << ans << " \n"[i == n - 1];
}
return 0;
}
| 2C++
| {
"input": [
"5 0\n3 14 15 92 6\n",
"3 1\n1 2 3\n",
"10 1000000\n1 2 3 4 84 5 6 7 8 9\n",
"1 1\n3\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n",
"1 0\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"4 1\n3 20 3 4\n",
"1 0\n123\n",
"17 239\n663 360 509 307 311 501 523 370 302 601 541 42 328 200 196 110 573\n",
"1 1\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 5 6 8 11\n",
"10 1000000\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 334\n",
"1 2\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 1\n5 20 3 4\n",
"1 0\n201\n",
"17 239\n663 360 509 307 311 501 523 370 302 601 1047 42 328 200 196 110 573\n",
"1 1\n1\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 5 6 4 11\n",
"5 0\n2 14 15 92 6\n",
"3 1\n2 2 3\n",
"10 1000010\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 53 128 233 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 1\n5 20 3 7\n",
"17 239\n663 360 509 307 311 501 523 370 302 48 1047 42 328 200 196 110 573\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 0 6 4 11\n",
"5 0\n0 14 15 92 6\n",
"3 0\n2 2 3\n",
"10 0000010\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 42 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 0\n5 20 3 7\n",
"17 239\n663 360 509 391 311 501 523 370 302 48 1047 42 328 200 196 110 573\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 34\n11 0 6 4 11\n",
"5 0\n0 14 15 11 6\n",
"3 0\n3 2 3\n",
"10 0000010\n1 2 3 1 8 5 6 7 8 9\n",
"13 666\n84 26 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"17 239\n663 360 509 391 311 501 523 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 27 11 6\n",
"10 0000010\n1 2 3 1 8 5 6 7 15 9\n",
"13 666\n46 26 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 391 311 501 202 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 27 16 6\n",
"10 0000010\n1 2 3 1 14 5 6 7 15 9\n",
"13 666\n46 26 37 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 35 16 6\n",
"10 0000010\n1 2 3 1 27 5 6 7 15 9\n",
"13 666\n46 45 37 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 77 42 42 7 42 42 42 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 481 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 23 42 42 42 42 42 42\n",
"5 0\n0 14 35 16 1\n",
"10 0000010\n1 2 3 1 27 3 6 7 15 9\n",
"13 666\n46 45 37 53 128 56 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 77 42 42 7 42 42 64 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 481 48 1051 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 52 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 23 42 42 42 42 42 42\n",
"5 0\n0 14 35 5 1\n",
"1 1\n201\n"
],
"output": [
"3 14 15 92 6 ",
"1 3 6 ",
"1 1000002 2496503 504322849 591771075 387496712 683276420 249833545 23968189 474356595 ",
"3 ",
"84 56033 18716627 174151412 225555860 164145872 451267967 434721493 224270207 253181081 361500071 991507723 152400567 ",
"0 ",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644609 ",
"3 23 26 30 ",
"123 ",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776716020 52125061 263719534 192023697 446278138 592149678 33061993 189288187 ",
"0 ",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644609 ",
"11 225 2416 18118 106536 ",
"1 1000002 2496503 504322849 591770999 311496712 645542420 224765591 516711096 649261079\n",
"84 56033 18716627 174151412 225555860 164145872 451267967 434721493 224270207 253181081 361500071 991507723 152400701\n",
"0\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644597\n",
"5 25 28 32\n",
"201\n",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776716020 52125567 263840468 206535777 612081891 123276661 845833532 908663880\n",
"1\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648646 51599271 850158256 437097940 807189706 279730463 711982601 807712523 805073106 298038600 475158588 660787710 599391012 366184931 166868326\n",
"11 225 2416 18114 106456\n",
"2 14 15 92 6\n",
"2 4 7\n",
"1 1000012 12496578 584288209 992308274 231197244 45948862 595982554 504118493 649422819\n",
"84 56033 18716627 174151362 225522560 153040322 978432188 852936841 265126447 488937224 994089645 958105263 95372047\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773015 214937477 654149104 446762870 489314408 203428123 937115419 852762596 444821029 227163797 262469593 342879352 8605512 196744246 600566934 99913950 642203391 531108945 271868595 957236889 95201146 763234207 745747255 344503962 868607390 469425161 195769547 454291698\n",
"5 25 28 35\n",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776715467 51993400 247980428 932445911 529644690 916828726 116950611 397761820\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648621 51598221 850135681 436766840 803464831 245461613 443543276 966985737 530621533 662196541 32364071 567577280 21044945 963824366 443308949\n",
"11 220 2316 17064 98756\n",
"0 14 15 92 6\n",
"2 2 3\n",
"1 12 78 364 1368 4397 12530 32418 77441 172965\n",
"84 56033 18716627 174151362 225522560 153040410 978490796 872482609 617317427 392878216 122182657 783174453 302014406\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142882 828904127 463105338 571970234 660082364 275220438 289170630 12918872 469630160 633302993 874335553 980317482 321310139 350455586 55045347 839800837 86995722 159051063 661056932 794253564 390910553 126137310 880557763 264467905 260382873 608805018 702481803 896124293 980697244 986950684 638120645 689705818\n",
"5 20 3 7\n",
"663 158817 19101389 537972315 259408369 747390200 200179538 943396061 444549919 900090088 370105107 279915350 475548761 198595447 604895912 951683704 899146814\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648621 51598221 850135649 436765496 803435935 245037805 438775436 923121609 187019197 306066251 601066064 393699440 134267968 44515010 383025988\n",
"11 374 6551 78748 730212\n",
"0 14 15 11 6\n",
"3 2 3\n",
"1 12 78 361 1338 4232 11870 30273 71435 157950\n",
"84 55970 18674669 160158369 109749473 39991744 829969657 429535344 94380281 150791115 770326558 32887459 648014009\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867539 227244048 913355582 435901373 685397962 943124109 654423232 849822880 911625655 187150788 842062222 111330478 54320086 165216541 459043775 366843596 287310159 915507583 368299889 491228615 457859793 730144084 630547855 233475828 454884963 821196910 645836716 352788303\n",
"663 158817 19101389 537972315 259408369 747390200 200179538 943396061 444549919 900090088 370105107 279915350 475548761 198595447 604895912 951683704 899147324\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022013 897433804 552030507 603795062 450223325 608667033 680962300 604848602 544610522 554913866 295112069 153019471 269680942 881824024 277993574 40500219 117418281 808995986 791880318 934197567 352611267\n",
"0 14 27 11 6\n",
"1 12 78 361 1338 4232 11870 30273 71442 158020\n",
"46 30662 10234451 280803175 787593140 871042492 769144324 590303418 868994417 827449343 444756626 479680872 937942218\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867539 227244048 913355582 435901373 685397962 943124109 654423232 849822880 911625655 187150788 842062222 111330478 54320086 165216541 459043775 366843596 287310159 915507583 368299889 491228615 457859793 730144084 630547855 233475828 454884963 821196910 645836716 352788274\n",
"663 158817 19101389 537972315 259408369 747390200 200179217 943319342 435343639 160518928 626050242 718848827 325510033 947240009 125716029 911969229 914228351\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884579 378168486 101695352 784630959 265279778 355695456 916059284 142810010 463449237 416828871\n",
"0 14 27 16 6\n",
"1 12 78 361 1344 4292 12200 31593 75732 170032\n",
"46 30662 10234459 280808503 789370028 266696213 942229870 783766421 671273433 846235012 650101021 968805460 953851677\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867579 227245728 913391702 436431133 691357762 997954269 83926145 794985739 950748169 404498088 950533445 260467166 379673789 208993452 416738781 342238286 324653743 337032747 27743493 836840006 861974531 970863780 501699706 831463594 657768486 396809404 13761223 538672230\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654174 308480736 804713487 962743574 352399154 214090200 438961380 937913996 876700387\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884594 378169116 101708897 784829619 267514703 376256766 77122872 247246083 228120178 998334112\n",
"0 14 35 16 6\n",
"1 12 78 361 1357 4422 12915 34453 85027 196058\n",
"46 30681 10247113 285028612 729047625 427774383 526704496 314179084 590889396 458927944 311771907 131590419 230454967\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592382 592768744 120751745 797606387 834117482 511050123 947321749 231885078 11477926 603570586 656343454 821852364 407638753 247230943 7968864 679218521 437173724 944367967 462480323 807083757 312593846 627368515 854496160 97893033 139555827 906404434 908773954 524622989 496676054 667453480 823747523 994686001 9152477 841439641 423256962\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654353 308523517 809847207 375152407 303133799 819793968 70914437 56271075 16180750\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884594 378169116 101708897 784829600 267513905 376239609 76871236 244415178 202075852 794320225\n",
"0 14 35 16 1\n",
"1 12 78 361 1357 4420 12895 34343 84587 194628\n",
"46 30681 10247113 285028612 729047625 427774118 526528006 255319669 484859747 475469273 528309979 681097972 983179691\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592382 592768744 120751745 797606387 834117482 511050123 947321771 231886002 11497792 603861954 659621344 852008952 643865359 867070520 929486253 798759536 546832897 826393144 691424860 681161057 389326100 113835591 275035127 179731876 352249812 946490698 431037055 257018819 275809571 96346745 985333461 661272872 111510959 543675814 582338966\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654353 308523517 809847211 375153363 303248519 829009808 628472757 153605238 974436691\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954875 738091524 190272893 461004327 122916287 385267821 211626814 663856509 21802679 951772351 329185334 641622238 287670544 425812173 610626541 117489202 44046991 133076136 96155972 542287440 979197804 161888821 502617561 917010850 176960488 470774363 836396310 248546841 230266586\n",
"0 14 35 5 1\n",
"201\n"
]
} | 2CODEFORCES
|
223_C. Partial Sums_1264 | You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:
1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 β€ i β€ n) of array s equals <image>. The operation x mod y means that we take the remainder of the division of number x by number y.
2. Then we write the contents of the array s to the array a. Element number i (1 β€ i β€ n) of the array s becomes the i-th element of the array a (ai = si).
You task is to find array a after exactly k described operations are applied.
Input
The first line contains two space-separated integers n and k (1 β€ n β€ 2000, 0 β€ k β€ 109). The next line contains n space-separated integers a1, a2, ..., an β elements of the array a (0 β€ ai β€ 109).
Output
Print n integers β elements of the array a after the operations are applied to it. Print the elements in the order of increasing of their indexes in the array a. Separate the printed numbers by spaces.
Examples
Input
3 1
1 2 3
Output
1 3 6
Input
5 0
3 14 15 92 6
Output
3 14 15 92 6 | n, k = map(int, input().split())
num = list(map(int, input().split()))
MOD = 10 ** 9 + 7
cf = [1]
for i in range(1, 2020):
cf.append((cf[-1] * (k + i - 1) * pow(i, MOD - 2, MOD)) % MOD)
ans = [0 for i in range(n)]
for i in range(n):
for j in range(i + 1):
ans[i] = (ans[i] + cf[i - j] * num[j]) % MOD
print(' '.join(map(str, ans)))
# Made By Mostafa_Khaled | 3Python3
| {
"input": [
"5 0\n3 14 15 92 6\n",
"3 1\n1 2 3\n",
"10 1000000\n1 2 3 4 84 5 6 7 8 9\n",
"1 1\n3\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n",
"1 0\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"4 1\n3 20 3 4\n",
"1 0\n123\n",
"17 239\n663 360 509 307 311 501 523 370 302 601 541 42 328 200 196 110 573\n",
"1 1\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 5 6 8 11\n",
"10 1000000\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 334\n",
"1 2\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 1\n5 20 3 4\n",
"1 0\n201\n",
"17 239\n663 360 509 307 311 501 523 370 302 601 1047 42 328 200 196 110 573\n",
"1 1\n1\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 5 6 4 11\n",
"5 0\n2 14 15 92 6\n",
"3 1\n2 2 3\n",
"10 1000010\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 53 128 233 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 1\n5 20 3 7\n",
"17 239\n663 360 509 307 311 501 523 370 302 48 1047 42 328 200 196 110 573\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 0 6 4 11\n",
"5 0\n0 14 15 92 6\n",
"3 0\n2 2 3\n",
"10 0000010\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 42 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 0\n5 20 3 7\n",
"17 239\n663 360 509 391 311 501 523 370 302 48 1047 42 328 200 196 110 573\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 34\n11 0 6 4 11\n",
"5 0\n0 14 15 11 6\n",
"3 0\n3 2 3\n",
"10 0000010\n1 2 3 1 8 5 6 7 8 9\n",
"13 666\n84 26 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"17 239\n663 360 509 391 311 501 523 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 27 11 6\n",
"10 0000010\n1 2 3 1 8 5 6 7 15 9\n",
"13 666\n46 26 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 391 311 501 202 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 27 16 6\n",
"10 0000010\n1 2 3 1 14 5 6 7 15 9\n",
"13 666\n46 26 37 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 35 16 6\n",
"10 0000010\n1 2 3 1 27 5 6 7 15 9\n",
"13 666\n46 45 37 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 77 42 42 7 42 42 42 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 481 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 23 42 42 42 42 42 42\n",
"5 0\n0 14 35 16 1\n",
"10 0000010\n1 2 3 1 27 3 6 7 15 9\n",
"13 666\n46 45 37 53 128 56 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 77 42 42 7 42 42 64 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 481 48 1051 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 52 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 23 42 42 42 42 42 42\n",
"5 0\n0 14 35 5 1\n",
"1 1\n201\n"
],
"output": [
"3 14 15 92 6 ",
"1 3 6 ",
"1 1000002 2496503 504322849 591771075 387496712 683276420 249833545 23968189 474356595 ",
"3 ",
"84 56033 18716627 174151412 225555860 164145872 451267967 434721493 224270207 253181081 361500071 991507723 152400567 ",
"0 ",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644609 ",
"3 23 26 30 ",
"123 ",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776716020 52125061 263719534 192023697 446278138 592149678 33061993 189288187 ",
"0 ",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644609 ",
"11 225 2416 18118 106536 ",
"1 1000002 2496503 504322849 591770999 311496712 645542420 224765591 516711096 649261079\n",
"84 56033 18716627 174151412 225555860 164145872 451267967 434721493 224270207 253181081 361500071 991507723 152400701\n",
"0\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644597\n",
"5 25 28 32\n",
"201\n",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776716020 52125567 263840468 206535777 612081891 123276661 845833532 908663880\n",
"1\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648646 51599271 850158256 437097940 807189706 279730463 711982601 807712523 805073106 298038600 475158588 660787710 599391012 366184931 166868326\n",
"11 225 2416 18114 106456\n",
"2 14 15 92 6\n",
"2 4 7\n",
"1 1000012 12496578 584288209 992308274 231197244 45948862 595982554 504118493 649422819\n",
"84 56033 18716627 174151362 225522560 153040322 978432188 852936841 265126447 488937224 994089645 958105263 95372047\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773015 214937477 654149104 446762870 489314408 203428123 937115419 852762596 444821029 227163797 262469593 342879352 8605512 196744246 600566934 99913950 642203391 531108945 271868595 957236889 95201146 763234207 745747255 344503962 868607390 469425161 195769547 454291698\n",
"5 25 28 35\n",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776715467 51993400 247980428 932445911 529644690 916828726 116950611 397761820\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648621 51598221 850135681 436766840 803464831 245461613 443543276 966985737 530621533 662196541 32364071 567577280 21044945 963824366 443308949\n",
"11 220 2316 17064 98756\n",
"0 14 15 92 6\n",
"2 2 3\n",
"1 12 78 364 1368 4397 12530 32418 77441 172965\n",
"84 56033 18716627 174151362 225522560 153040410 978490796 872482609 617317427 392878216 122182657 783174453 302014406\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142882 828904127 463105338 571970234 660082364 275220438 289170630 12918872 469630160 633302993 874335553 980317482 321310139 350455586 55045347 839800837 86995722 159051063 661056932 794253564 390910553 126137310 880557763 264467905 260382873 608805018 702481803 896124293 980697244 986950684 638120645 689705818\n",
"5 20 3 7\n",
"663 158817 19101389 537972315 259408369 747390200 200179538 943396061 444549919 900090088 370105107 279915350 475548761 198595447 604895912 951683704 899146814\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648621 51598221 850135649 436765496 803435935 245037805 438775436 923121609 187019197 306066251 601066064 393699440 134267968 44515010 383025988\n",
"11 374 6551 78748 730212\n",
"0 14 15 11 6\n",
"3 2 3\n",
"1 12 78 361 1338 4232 11870 30273 71435 157950\n",
"84 55970 18674669 160158369 109749473 39991744 829969657 429535344 94380281 150791115 770326558 32887459 648014009\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867539 227244048 913355582 435901373 685397962 943124109 654423232 849822880 911625655 187150788 842062222 111330478 54320086 165216541 459043775 366843596 287310159 915507583 368299889 491228615 457859793 730144084 630547855 233475828 454884963 821196910 645836716 352788303\n",
"663 158817 19101389 537972315 259408369 747390200 200179538 943396061 444549919 900090088 370105107 279915350 475548761 198595447 604895912 951683704 899147324\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022013 897433804 552030507 603795062 450223325 608667033 680962300 604848602 544610522 554913866 295112069 153019471 269680942 881824024 277993574 40500219 117418281 808995986 791880318 934197567 352611267\n",
"0 14 27 11 6\n",
"1 12 78 361 1338 4232 11870 30273 71442 158020\n",
"46 30662 10234451 280803175 787593140 871042492 769144324 590303418 868994417 827449343 444756626 479680872 937942218\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867539 227244048 913355582 435901373 685397962 943124109 654423232 849822880 911625655 187150788 842062222 111330478 54320086 165216541 459043775 366843596 287310159 915507583 368299889 491228615 457859793 730144084 630547855 233475828 454884963 821196910 645836716 352788274\n",
"663 158817 19101389 537972315 259408369 747390200 200179217 943319342 435343639 160518928 626050242 718848827 325510033 947240009 125716029 911969229 914228351\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884579 378168486 101695352 784630959 265279778 355695456 916059284 142810010 463449237 416828871\n",
"0 14 27 16 6\n",
"1 12 78 361 1344 4292 12200 31593 75732 170032\n",
"46 30662 10234459 280808503 789370028 266696213 942229870 783766421 671273433 846235012 650101021 968805460 953851677\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867579 227245728 913391702 436431133 691357762 997954269 83926145 794985739 950748169 404498088 950533445 260467166 379673789 208993452 416738781 342238286 324653743 337032747 27743493 836840006 861974531 970863780 501699706 831463594 657768486 396809404 13761223 538672230\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654174 308480736 804713487 962743574 352399154 214090200 438961380 937913996 876700387\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884594 378169116 101708897 784829619 267514703 376256766 77122872 247246083 228120178 998334112\n",
"0 14 35 16 6\n",
"1 12 78 361 1357 4422 12915 34453 85027 196058\n",
"46 30681 10247113 285028612 729047625 427774383 526704496 314179084 590889396 458927944 311771907 131590419 230454967\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592382 592768744 120751745 797606387 834117482 511050123 947321749 231885078 11477926 603570586 656343454 821852364 407638753 247230943 7968864 679218521 437173724 944367967 462480323 807083757 312593846 627368515 854496160 97893033 139555827 906404434 908773954 524622989 496676054 667453480 823747523 994686001 9152477 841439641 423256962\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654353 308523517 809847207 375152407 303133799 819793968 70914437 56271075 16180750\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884594 378169116 101708897 784829600 267513905 376239609 76871236 244415178 202075852 794320225\n",
"0 14 35 16 1\n",
"1 12 78 361 1357 4420 12895 34343 84587 194628\n",
"46 30681 10247113 285028612 729047625 427774118 526528006 255319669 484859747 475469273 528309979 681097972 983179691\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592382 592768744 120751745 797606387 834117482 511050123 947321771 231886002 11497792 603861954 659621344 852008952 643865359 867070520 929486253 798759536 546832897 826393144 691424860 681161057 389326100 113835591 275035127 179731876 352249812 946490698 431037055 257018819 275809571 96346745 985333461 661272872 111510959 543675814 582338966\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654353 308523517 809847211 375153363 303248519 829009808 628472757 153605238 974436691\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954875 738091524 190272893 461004327 122916287 385267821 211626814 663856509 21802679 951772351 329185334 641622238 287670544 425812173 610626541 117489202 44046991 133076136 96155972 542287440 979197804 161888821 502617561 917010850 176960488 470774363 836396310 248546841 230266586\n",
"0 14 35 5 1\n",
"201\n"
]
} | 2CODEFORCES
|
223_C. Partial Sums_1265 | You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:
1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 β€ i β€ n) of array s equals <image>. The operation x mod y means that we take the remainder of the division of number x by number y.
2. Then we write the contents of the array s to the array a. Element number i (1 β€ i β€ n) of the array s becomes the i-th element of the array a (ai = si).
You task is to find array a after exactly k described operations are applied.
Input
The first line contains two space-separated integers n and k (1 β€ n β€ 2000, 0 β€ k β€ 109). The next line contains n space-separated integers a1, a2, ..., an β elements of the array a (0 β€ ai β€ 109).
Output
Print n integers β elements of the array a after the operations are applied to it. Print the elements in the order of increasing of their indexes in the array a. Separate the printed numbers by spaces.
Examples
Input
3 1
1 2 3
Output
1 3 6
Input
5 0
3 14 15 92 6
Output
3 14 15 92 6 | //package round138;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
public class C {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni(), K = ni();
int mod = 1000000007;
int[] v = new int[n];
for(int i = 0;i < n;i++)v[n-1-i] = ni();
int[] a = new int[n];
Arrays.fill(a, 1);
int[] ret = pow(a, v, K, mod);
for(int i = 0;i < n;i++){
out.println(ret[n-1-i]);
}
}
// intθ‘ε*γγ―γγ«
public static int[] mul(int[] A, int[] v, int mod)
{
int m = A.length;
int n = v.length;
int[] w = new int[m];
for(int i = 0;i < m;i++){
long sum = 0;
for(int k = i;k < n;k++){
sum += (long)A[k-i] * v[k];
sum %= mod;
}
w[i] = (int)sum;
}
return w;
}
// A^e*v
public static int[] pow(int[] A, int[] v, long e, int mod)
{
int[] MUL = A;
for(int i = 0;i < v.length;i++)v[i] %= mod;
for(;e > 0;e>>>=1) {
if((e&1)==1)v = mul(MUL, v, mod);
MUL = p2tu(MUL, mod);
}
return v;
}
static int[] p2tu(int[] A, int mod)
{
int n = A.length;
int[] C = new int[n];
for(int i = 0;i < n;i++){
long sum = 0;
for(int j = 0;j <= i;j++){
sum += (long)A[j] * A[i-j];
sum %= mod;
}
C[i] = (int)sum;
}
return C;
}
public static int[][] p2tu(int[][] A, int mod)
{
int n = A.length;
int[][] C = new int[n][n];
for(int i = 0;i < n;i++){
long sum = 0;
for(int j = 0;j <= i;j++){
sum += (long)A[0][j] * A[0][i-j];
sum %= mod;
}
for(int j = i;j < n;j++){
C[j-i][j] = (int)sum;
}
}
return C;
}
void run() throws Exception
{
is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
long s = System.currentTimeMillis();
solve();
out.flush();
tr(System.currentTimeMillis()-s+"ms");
}
public static void main(String[] args) throws Exception
{
new C().run();
}
public int ni()
{
try {
int num = 0;
boolean minus = false;
while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
if(num == '-'){
num = 0;
minus = true;
}else{
num -= '0';
}
while(true){
int b = is.read();
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
}
} catch (IOException e) {
}
return -1;
}
public long nl()
{
try {
long num = 0;
boolean minus = false;
while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
if(num == '-'){
num = 0;
minus = true;
}else{
num -= '0';
}
while(true){
int b = is.read();
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
}
} catch (IOException e) {
}
return -1;
}
public String ns()
{
try{
int b = 0;
StringBuilder sb = new StringBuilder();
while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
if(b == -1)return "";
sb.append((char)b);
while(true){
b = is.read();
if(b == -1)return sb.toString();
if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
sb.append((char)b);
}
} catch (IOException e) {
}
return "";
}
public char[] ns(int n)
{
char[] buf = new char[n];
try{
int b = 0, p = 0;
while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
if(b == -1)return null;
buf[p++] = (char)b;
while(p < n){
b = is.read();
if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
buf[p++] = (char)b;
}
return Arrays.copyOf(buf, p);
} catch (IOException e) {
}
return null;
}
double nd() { return Double.parseDouble(ns()); }
boolean oj = System.getProperty("ONLINE_JUDGE") != null;
void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}
| 4JAVA
| {
"input": [
"5 0\n3 14 15 92 6\n",
"3 1\n1 2 3\n",
"10 1000000\n1 2 3 4 84 5 6 7 8 9\n",
"1 1\n3\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n",
"1 0\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"4 1\n3 20 3 4\n",
"1 0\n123\n",
"17 239\n663 360 509 307 311 501 523 370 302 601 541 42 328 200 196 110 573\n",
"1 1\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 5 6 8 11\n",
"10 1000000\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 334\n",
"1 2\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 1\n5 20 3 4\n",
"1 0\n201\n",
"17 239\n663 360 509 307 311 501 523 370 302 601 1047 42 328 200 196 110 573\n",
"1 1\n1\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 5 6 4 11\n",
"5 0\n2 14 15 92 6\n",
"3 1\n2 2 3\n",
"10 1000010\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 53 128 233 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 1\n5 20 3 7\n",
"17 239\n663 360 509 307 311 501 523 370 302 48 1047 42 328 200 196 110 573\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 20\n11 0 6 4 11\n",
"5 0\n0 14 15 92 6\n",
"3 0\n2 2 3\n",
"10 0000010\n1 2 3 4 8 5 6 7 8 9\n",
"13 666\n84 89 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 42 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"4 0\n5 20 3 7\n",
"17 239\n663 360 509 391 311 501 523 370 302 48 1047 42 328 200 196 110 573\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 34\n11 0 6 4 11\n",
"5 0\n0 14 15 11 6\n",
"3 0\n3 2 3\n",
"10 0000010\n1 2 3 1 8 5 6 7 8 9\n",
"13 666\n84 26 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 30\n",
"17 239\n663 360 509 391 311 501 523 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 27 11 6\n",
"10 0000010\n1 2 3 1 8 5 6 7 15 9\n",
"13 666\n46 26 29 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 43 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 391 311 501 202 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 42 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 27 16 6\n",
"10 0000010\n1 2 3 1 14 5 6 7 15 9\n",
"13 666\n46 26 37 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 42 42 42 7 42 42 42 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 302 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 42 42 42 42 42 42 42\n",
"5 0\n0 14 35 16 6\n",
"10 0000010\n1 2 3 1 27 5 6 7 15 9\n",
"13 666\n46 45 37 53 128 321 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 77 42 42 7 42 42 42 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 481 48 1047 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 42 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 23 42 42 42 42 42 42\n",
"5 0\n0 14 35 16 1\n",
"10 0000010\n1 2 3 1 27 3 6 7 15 9\n",
"13 666\n46 45 37 53 128 56 190 122 117 208 119 97 334\n",
"42 42\n42 42 42 74 42 42 42 77 42 42 7 42 42 64 83 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 1\n",
"17 239\n663 360 509 281 311 501 202 370 481 48 1051 42 328 200 196 110 1083\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 24 42 42 52 42 42 42 42 42 42 42 83 42 42 42 42 14 17 42 10 42 42 57 42 42 23 42 42 42 42 42 42\n",
"5 0\n0 14 35 5 1\n",
"1 1\n201\n"
],
"output": [
"3 14 15 92 6 ",
"1 3 6 ",
"1 1000002 2496503 504322849 591771075 387496712 683276420 249833545 23968189 474356595 ",
"3 ",
"84 56033 18716627 174151412 225555860 164145872 451267967 434721493 224270207 253181081 361500071 991507723 152400567 ",
"0 ",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644609 ",
"3 23 26 30 ",
"123 ",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776716020 52125061 263719534 192023697 446278138 592149678 33061993 189288187 ",
"0 ",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644609 ",
"11 225 2416 18118 106536 ",
"1 1000002 2496503 504322849 591770999 311496712 645542420 224765591 516711096 649261079\n",
"84 56033 18716627 174151412 225555860 164145872 451267967 434721493 224270207 253181081 361500071 991507723 152400701\n",
"0\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471671 20649822 51624555 850529088 441269800 845570818 580382507 773596603 435098280 957216216 73968454 779554271 588535300 530034849 736571438 149644597\n",
"5 25 28 32\n",
"201\n",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776716020 52125567 263840468 206535777 612081891 123276661 845833532 908663880\n",
"1\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648646 51599271 850158256 437097940 807189706 279730463 711982601 807712523 805073106 298038600 475158588 660787710 599391012 366184931 166868326\n",
"11 225 2416 18114 106456\n",
"2 14 15 92 6\n",
"2 4 7\n",
"1 1000012 12496578 584288209 992308274 231197244 45948862 595982554 504118493 649422819\n",
"84 56033 18716627 174151362 225522560 153040322 978432188 852936841 265126447 488937224 994089645 958105263 95372047\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773015 214937477 654149104 446762870 489314408 203428123 937115419 852762596 444821029 227163797 262469593 342879352 8605512 196744246 600566934 99913950 642203391 531108945 271868595 957236889 95201146 763234207 745747255 344503962 868607390 469425161 195769547 454291698\n",
"5 25 28 35\n",
"663 158817 19101389 537972231 259388293 744981080 6646898 234671418 400532510 776715467 51993400 247980428 932445911 529644690 916828726 116950611 397761820\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648621 51598221 850135681 436766840 803464831 245461613 443543276 966985737 530621533 662196541 32364071 567577280 21044945 963824366 443308949\n",
"11 220 2316 17064 98756\n",
"0 14 15 92 6\n",
"2 2 3\n",
"1 12 78 364 1368 4397 12530 32418 77441 172965\n",
"84 56033 18716627 174151362 225522560 153040410 978490796 872482609 617317427 392878216 122182657 783174453 302014406\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142882 828904127 463105338 571970234 660082364 275220438 289170630 12918872 469630160 633302993 874335553 980317482 321310139 350455586 55045347 839800837 86995722 159051063 661056932 794253564 390910553 126137310 880557763 264467905 260382873 608805018 702481803 896124293 980697244 986950684 638120645 689705818\n",
"5 20 3 7\n",
"663 158817 19101389 537972315 259408369 747390200 200179538 943396061 444549919 900090088 370105107 279915350 475548761 198595447 604895912 951683704 899146814\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012592 397606113 289227498 685193257 740773014 214937435 654148201 446749626 489165413 202057369 926377846 779133524 993842970 721730118 484757814 939150939 225471643 20648621 51598221 850135649 436765496 803435935 245037805 438775436 923121609 187019197 306066251 601066064 393699440 134267968 44515010 383025988\n",
"11 374 6551 78748 730212\n",
"0 14 15 11 6\n",
"3 2 3\n",
"1 12 78 361 1338 4232 11870 30273 71435 157950\n",
"84 55970 18674669 160158369 109749473 39991744 829969657 429535344 94380281 150791115 770326558 32887459 648014009\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867539 227244048 913355582 435901373 685397962 943124109 654423232 849822880 911625655 187150788 842062222 111330478 54320086 165216541 459043775 366843596 287310159 915507583 368299889 491228615 457859793 730144084 630547855 233475828 454884963 821196910 645836716 352788303\n",
"663 158817 19101389 537972315 259408369 747390200 200179538 943396061 444549919 900090088 370105107 279915350 475548761 198595447 604895912 951683704 899147324\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022013 897433804 552030507 603795062 450223325 608667033 680962300 604848602 544610522 554913866 295112069 153019471 269680942 881824024 277993574 40500219 117418281 808995986 791880318 934197567 352611267\n",
"0 14 27 11 6\n",
"1 12 78 361 1338 4232 11870 30273 71442 158020\n",
"46 30662 10234451 280803175 787593140 871042492 769144324 590303418 868994417 827449343 444756626 479680872 937942218\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867539 227244048 913355582 435901373 685397962 943124109 654423232 849822880 911625655 187150788 842062222 111330478 54320086 165216541 459043775 366843596 287310159 915507583 368299889 491228615 457859793 730144084 630547855 233475828 454884963 821196910 645836716 352788274\n",
"663 158817 19101389 537972315 259408369 747390200 200179217 943319342 435343639 160518928 626050242 718848827 325510033 947240009 125716029 911969229 914228351\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884579 378168486 101695352 784630959 265279778 355695456 916059284 142810010 463449237 416828871\n",
"0 14 27 16 6\n",
"1 12 78 361 1344 4292 12200 31593 75732 170032\n",
"46 30662 10234459 280808503 789370028 266696213 942229870 783766421 671273433 846235012 650101021 968805460 953851677\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592347 592767274 120720140 797142847 828902657 463073733 571506694 654867579 227245728 913391702 436431133 691357762 997954269 83926145 794985739 950748169 404498088 950533445 260467166 379673789 208993452 416738781 342238286 324653743 337032747 27743493 836840006 861974531 970863780 501699706 831463594 657768486 396809404 13761223 538672230\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654174 308480736 804713487 962743574 352399154 214090200 438961380 937913996 876700387\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884594 378169116 101708897 784829619 267514703 376256766 77122872 247246083 228120178 998334112\n",
"0 14 35 16 6\n",
"1 12 78 361 1357 4422 12915 34453 85027 196058\n",
"46 30681 10247113 285028612 729047625 427774383 526704496 314179084 590889396 458927944 311771907 131590419 230454967\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592382 592768744 120751745 797606387 834117482 511050123 947321749 231885078 11477926 603570586 656343454 821852364 407638753 247230943 7968864 679218521 437173724 944367967 462480323 807083757 312593846 627368515 854496160 97893033 139555827 906404434 908773954 524622989 496676054 667453480 823747523 994686001 9152477 841439641 423256962\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654353 308523517 809847207 375152407 303133799 819793968 70914437 56271075 16180750\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954865 738091104 190263863 460871887 121426337 371560281 104251084 927565796 512022054 897435526 552067530 604338066 456332120 664867947 121202786 623640533 34711095 277694845 181295071 705884594 378169116 101708897 784829600 267513905 376239609 76871236 244415178 202075852 794320225\n",
"0 14 35 16 1\n",
"1 12 78 361 1357 4420 12895 34343 84587 194628\n",
"46 30681 10247113 285028612 729047625 427774118 526528006 255319669 484859747 475469273 528309979 681097972 983179691\n",
"42 1806 39732 596012 6855114 64454334 515827312 612592382 592768744 120751745 797606387 834117482 511050123 947321771 231886002 11497792 603861954 659621344 852008952 643865359 867070520 929486253 798759536 546832897 826393144 691424860 681161057 389326100 113835591 275035127 179731876 352249812 946490698 431037055 257018819 275809571 96346745 985333461 661272872 111510959 543675814 582338966\n",
"663 158817 19101389 537972205 259382079 744235400 946743624 610465647 258654353 308523517 809847211 375153363 303248519 829009808 628472757 153605238 974436691\n",
"42 1806 39732 595980 6853770 64425438 515403504 607824507 548903146 777117811 441012574 397605357 289211244 684954875 738091524 190272893 461004327 122916287 385267821 211626814 663856509 21802679 951772351 329185334 641622238 287670544 425812173 610626541 117489202 44046991 133076136 96155972 542287440 979197804 161888821 502617561 917010850 176960488 470774363 836396310 248546841 230266586\n",
"0 14 35 5 1\n",
"201\n"
]
} | 2CODEFORCES
|
248_A. Cupboards_1266 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on n wooden cupboards, standing in the kitchen. He immediately realized that these cupboards have hidden jam stocks. Karlsson began to fly greedily around the kitchen, opening and closing the cupboards' doors, grab and empty all the jars of jam that he could find.
And now all jars of jam are empty, Karlsson has had enough and does not want to leave traces of his stay, so as not to let down his friend. Each of the cupboards has two doors: the left one and the right one. Karlsson remembers that when he rushed to the kitchen, all the cupboards' left doors were in the same position (open or closed), similarly, all the cupboards' right doors were in the same position (open or closed). Karlsson wants the doors to meet this condition as well by the time the family returns. Karlsson does not remember the position of all the left doors, also, he cannot remember the position of all the right doors. Therefore, it does not matter to him in what position will be all left or right doors. It is important to leave all the left doors in the same position, and all the right doors in the same position. For example, all the left doors may be closed, and all the right ones may be open.
Karlsson needs one second to open or close a door of a cupboard. He understands that he has very little time before the family returns, so he wants to know the minimum number of seconds t, in which he is able to bring all the cupboard doors in the required position.
Your task is to write a program that will determine the required number of seconds t.
Input
The first input line contains a single integer n β the number of cupboards in the kitchen (2 β€ n β€ 104). Then follow n lines, each containing two integers li and ri (0 β€ li, ri β€ 1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, if the right door of the i-th cupboard is opened, otherwise number ri equals zero.
The numbers in the lines are separated by single spaces.
Output
In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs.
Examples
Input
5
0 1
1 0
0 1
1 1
0 1
Output
3 | n=input()
A=0
B=0
for i in range(n):
a,b = map(int, raw_input().split())
if(a==1):
A+=1
if(b==1):
B+=1
ans = 0
ans = A + (n-B)
ans = min(ans, (n-A) + B)
ans = min(ans, A + B)
ans = min(ans, (n-A) + (n-B))
print ans
| 1Python2
| {
"input": [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n",
"2\n0 0\n0 0\n",
"3\n0 1\n1 1\n1 1\n",
"5\n1 0\n1 0\n1 0\n0 1\n0 1\n",
"15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 0\n1 0\n0 1\n1 0\n",
"3\n0 1\n1 1\n1 0\n",
"8\n0 1\n1 1\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
"5\n",
"2\n",
"4\n",
"3\n",
"2\n",
"2\n",
"4\n",
"4\n",
"3\n",
"4\n",
"4\n",
"2\n",
"1\n",
"6\n",
"4\n",
"7\n",
"6\n",
"7\n",
"6\n",
"3\n",
"2\n",
"4\n",
"4\n",
"2\n",
"1\n",
"6\n",
"3\n",
"6\n",
"7\n",
"8\n",
"7\n",
"1\n",
"3\n",
"1\n",
"7\n",
"6\n",
"7\n",
"2\n",
"6\n",
"8\n",
"7\n",
"6\n",
"3\n",
"2\n",
"2\n",
"4\n",
"0\n",
"6\n",
"4\n",
"2\n",
"7\n",
"6\n",
"6\n",
"2\n",
"2\n",
"4\n",
"0\n",
"4\n",
"8\n",
"7\n",
"6\n",
"7\n",
"7\n",
"5\n",
"6\n",
"3\n",
"1\n",
"7\n",
"3\n",
"1\n",
"7\n",
"7\n",
"3\n",
"7\n",
"8\n",
"6\n",
"2\n",
"6\n"
]
} | 2CODEFORCES
|
248_A. Cupboards_1267 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on n wooden cupboards, standing in the kitchen. He immediately realized that these cupboards have hidden jam stocks. Karlsson began to fly greedily around the kitchen, opening and closing the cupboards' doors, grab and empty all the jars of jam that he could find.
And now all jars of jam are empty, Karlsson has had enough and does not want to leave traces of his stay, so as not to let down his friend. Each of the cupboards has two doors: the left one and the right one. Karlsson remembers that when he rushed to the kitchen, all the cupboards' left doors were in the same position (open or closed), similarly, all the cupboards' right doors were in the same position (open or closed). Karlsson wants the doors to meet this condition as well by the time the family returns. Karlsson does not remember the position of all the left doors, also, he cannot remember the position of all the right doors. Therefore, it does not matter to him in what position will be all left or right doors. It is important to leave all the left doors in the same position, and all the right doors in the same position. For example, all the left doors may be closed, and all the right ones may be open.
Karlsson needs one second to open or close a door of a cupboard. He understands that he has very little time before the family returns, so he wants to know the minimum number of seconds t, in which he is able to bring all the cupboard doors in the required position.
Your task is to write a program that will determine the required number of seconds t.
Input
The first input line contains a single integer n β the number of cupboards in the kitchen (2 β€ n β€ 104). Then follow n lines, each containing two integers li and ri (0 β€ li, ri β€ 1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, if the right door of the i-th cupboard is opened, otherwise number ri equals zero.
The numbers in the lines are separated by single spaces.
Output
In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs.
Examples
Input
5
0 1
1 0
0 1
1 1
0 1
Output
3 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, j, a, b, k, p;
pair<int, int> cell[1001];
cin >> n;
k = 0;
p = 0;
for ((i) = (0); (i) < (int)(n); (i)++) {
cin >> a >> b;
if (a == 0) k++;
if (b == 0) p++;
}
int sum;
sum = 0;
sum += min(k, n - k);
sum += min(p, n - p);
cout << sum << endl;
return 0;
}
| 2C++
| {
"input": [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n",
"2\n0 0\n0 0\n",
"3\n0 1\n1 1\n1 1\n",
"5\n1 0\n1 0\n1 0\n0 1\n0 1\n",
"15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 0\n1 0\n0 1\n1 0\n",
"3\n0 1\n1 1\n1 0\n",
"8\n0 1\n1 1\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"5\n0 1\n1 0\n0 1\n1 1\n0 0\n",
"5\n0 1\n0 0\n0 1\n1 1\n0 0\n",
"2\n0 0\n0 1\n",
"3\n1 1\n1 1\n1 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 0\n1 0\n0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",
"7\n",
"8\n",
"7\n",
"1\n",
"3\n",
"1\n",
"7\n",
"6\n",
"7\n",
"2\n",
"6\n",
"8\n",
"7\n",
"6\n",
"3\n",
"2\n",
"2\n",
"4\n",
"0\n",
"6\n",
"4\n",
"2\n",
"7\n",
"6\n",
"6\n",
"2\n",
"2\n",
"4\n",
"0\n",
"4\n",
"8\n",
"7\n",
"6\n",
"7\n",
"7\n",
"5\n",
"6\n",
"3\n",
"1\n",
"7\n",
"3\n",
"1\n",
"7\n",
"7\n",
"3\n",
"7\n",
"8\n",
"6\n",
"2\n",
"6\n"
]
} | 2CODEFORCES
|
248_A. Cupboards_1268 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on n wooden cupboards, standing in the kitchen. He immediately realized that these cupboards have hidden jam stocks. Karlsson began to fly greedily around the kitchen, opening and closing the cupboards' doors, grab and empty all the jars of jam that he could find.
And now all jars of jam are empty, Karlsson has had enough and does not want to leave traces of his stay, so as not to let down his friend. Each of the cupboards has two doors: the left one and the right one. Karlsson remembers that when he rushed to the kitchen, all the cupboards' left doors were in the same position (open or closed), similarly, all the cupboards' right doors were in the same position (open or closed). Karlsson wants the doors to meet this condition as well by the time the family returns. Karlsson does not remember the position of all the left doors, also, he cannot remember the position of all the right doors. Therefore, it does not matter to him in what position will be all left or right doors. It is important to leave all the left doors in the same position, and all the right doors in the same position. For example, all the left doors may be closed, and all the right ones may be open.
Karlsson needs one second to open or close a door of a cupboard. He understands that he has very little time before the family returns, so he wants to know the minimum number of seconds t, in which he is able to bring all the cupboard doors in the required position.
Your task is to write a program that will determine the required number of seconds t.
Input
The first input line contains a single integer n β the number of cupboards in the kitchen (2 β€ n β€ 104). Then follow n lines, each containing two integers li and ri (0 β€ li, ri β€ 1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, if the right door of the i-th cupboard is opened, otherwise number ri equals zero.
The numbers in the lines are separated by single spaces.
Output
In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs.
Examples
Input
5
0 1
1 0
0 1
1 1
0 1
Output
3 | k = int(input())
lo=ro=rc=lc=0
for _ in range(k):
n , m = map(int,input().split())
if(n==0):
lo+=1
else:
lc=lc+1
if(m==0):
ro+=1
else :
rc=rc+1
print(min(lo,lc)+min(ro,rc))
| 3Python3
| {
"input": [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n",
"2\n0 0\n0 0\n",
"3\n0 1\n1 1\n1 1\n",
"5\n1 0\n1 0\n1 0\n0 1\n0 1\n",
"15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 0\n1 0\n0 1\n1 0\n",
"3\n0 1\n1 1\n1 0\n",
"8\n0 1\n1 1\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"5\n0 1\n1 0\n0 1\n1 1\n0 0\n",
"5\n0 1\n0 0\n0 1\n1 1\n0 0\n",
"2\n0 0\n0 1\n",
"3\n1 1\n1 1\n1 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 0\n1 0\n0 1\n1 1\n",
"8\n0 1\n0 1\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"3\n0 0\n1 1\n1 0\n",
"5\n0 1\n0 0\n1 1\n1 1\n0 0\n",
"5\n0 1\n0 0\n1 1\n1 1\n0 1\n",
"5\n0 1\n0 0\n0 1\n1 1\n0 1\n",
"3\n0 1\n1 0\n1 0\n",
"5\n1 1\n0 0\n0 1\n1 1\n0 0\n",
"5\n0 1\n0 0\n1 1\n1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\n",
"8\n0 1\n0 1\n0 1\n1 1\n0 1\n1 0\n1 1\n1 0\n",
"5\n0 1\n0 0\n0 1\n1 1\n1 1\n",
"2\n0 1\n1 1\n",
"8\n1 0\n1 0\n0 1\n1 1\n0 0\n1 0\n0 1\n1 1\n",
"5\n0 0\n1 0\n1 1\n1 0\n1 1\n",
"3\n1 1\n1 1\n1 0\n",
"8\n0 1\n0 1\n1 1\n1 0\n0 0\n0 0\n0 0\n1 1\n",
"8\n0 1\n0 0\n1 0\n1 1\n0 0\n0 0\n0 1\n1 1\n",
"5\n0 1\n0 1\n0 0\n1 1\n0 0\n",
"8\n0 1\n1 1\n1 0\n1 1\n0 0\n1 0\n0 0\n1 1\n",
"8\n1 1\n0 1\n1 0\n0 1\n0 0\n1 1\n0 0\n1 0\n",
"8\n0 1\n0 0\n0 0\n0 1\n0 1\n1 0\n0 1\n1 0\n",
"2\n0 0\n1 1\n",
"8\n1 0\n1 0\n0 0\n1 1\n0 0\n1 0\n0 1\n1 1\n"
],
"output": [
"3\n",
"7\n",
"6\n",
"0\n",
"1\n",
"4\n",
"0\n",
"8\n",
"2\n",
"6\n",
"4\n",
"3\n",
"1\n",
"0\n",
"7\n",
"5\n",
"2\n",
"4\n",
"3\n",
"2\n",
"2\n",
"4\n",
"4\n",
"3\n",
"4\n",
"4\n",
"2\n",
"1\n",
"6\n",
"4\n",
"7\n",
"6\n",
"7\n",
"6\n",
"3\n",
"2\n",
"4\n",
"4\n",
"2\n",
"1\n",
"6\n",
"3\n",
"6\n",
"7\n",
"8\n",
"7\n",
"1\n",
"3\n",
"1\n",
"7\n",
"6\n",
"7\n",
"2\n",
"6\n",
"8\n",
"7\n",
"6\n",
"3\n",
"2\n",
"2\n",
"4\n",
"0\n",
"6\n",
"4\n",
"2\n",
"7\n",
"6\n",
"6\n",
"2\n",
"2\n",
"4\n",
"0\n",
"4\n",
"8\n",
"7\n",
"6\n",
"7\n",
"7\n",
"5\n",
"6\n",
"3\n",
"1\n",
"7\n",
"3\n",
"1\n",
"7\n",
"7\n",
"3\n",
"7\n",
"8\n",
"6\n",
"2\n",
"6\n"
]
} | 2CODEFORCES
|
248_A. Cupboards_1269 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on n wooden cupboards, standing in the kitchen. He immediately realized that these cupboards have hidden jam stocks. Karlsson began to fly greedily around the kitchen, opening and closing the cupboards' doors, grab and empty all the jars of jam that he could find.
And now all jars of jam are empty, Karlsson has had enough and does not want to leave traces of his stay, so as not to let down his friend. Each of the cupboards has two doors: the left one and the right one. Karlsson remembers that when he rushed to the kitchen, all the cupboards' left doors were in the same position (open or closed), similarly, all the cupboards' right doors were in the same position (open or closed). Karlsson wants the doors to meet this condition as well by the time the family returns. Karlsson does not remember the position of all the left doors, also, he cannot remember the position of all the right doors. Therefore, it does not matter to him in what position will be all left or right doors. It is important to leave all the left doors in the same position, and all the right doors in the same position. For example, all the left doors may be closed, and all the right ones may be open.
Karlsson needs one second to open or close a door of a cupboard. He understands that he has very little time before the family returns, so he wants to know the minimum number of seconds t, in which he is able to bring all the cupboard doors in the required position.
Your task is to write a program that will determine the required number of seconds t.
Input
The first input line contains a single integer n β the number of cupboards in the kitchen (2 β€ n β€ 104). Then follow n lines, each containing two integers li and ri (0 β€ li, ri β€ 1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, if the right door of the i-th cupboard is opened, otherwise number ri equals zero.
The numbers in the lines are separated by single spaces.
Output
In the only output line print a single integer t β the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs.
Examples
Input
5
0 1
1 0
0 1
1 1
0 1
Output
3 | import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Timer;
public class Main {
static int d[][];
static int N;
static boolean used[];
static class point
{
int x = 0;
int y = 0;
}
static point dats[];
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int l = 0;
int r = 0;
for(int i = 0;i<n;i++)
{
l+= scan.nextInt();
r+= scan.nextInt();
}
int ans = Math.min(l, n-l)+Math.min(r, n-r);
System.out.println(ans);
}
}
// private static int deln(int N[])
// {
// int beg = 0;
// int end = N.length-1;
//
// int mid = (beg+end)/2;
// while(beg<=end)
// {
// if(N[mid]==mid)
// return 1;
// else
// if(N[mid]>mid)
// end = mid-1;
// else
// beg = mid+1;
// }
// return 0;
//
// }
// private static void qs(int N[])
// {
// int n = N.length;
// int i = 0;
// int j = n-1;
//
// do
// {
// while(N[i]<0)i++;
// while(N[j]>=0)j--;
//
// if(i<=j)
// {
// int t = N[i];
// N[i] = N[j];
// N[j] = t;
// i++;
// j--;
// }
// }while(i<j);
//
// j = 0;
// for(i = 0;i<n;i++)
// {
// if(N[i]>0)
// {
// j = Math.max(i+1,j);
// while(j<n&&N[j]>0) j++;
// if(j<n)
// {
// N[j] = N[i];
// N[i] = 0;
// }
// else
// break;
// }
// }
// }
// //2 3 0 -1 0 1 0 -4 5 6
// //-4 3 0 -1 0 1 0 2 5 6
// //
// private static void qsort (int N[],int i,int j)
// {
// int beg = i;
// int end = j;
// int mid =N[(i+j)>>1];
// do
// {
// while(N[i]<mid) i++;
// while(N[j]>mid) j--;
//
// if(i<=j)
// {
// int t = N[i];
// N[i] = N[j];
// N[j] = t;
// i++;
// j--;
// }
// }while(i<j);
//
// if(beg<j) qsort(N,beg,j);
// if(i<end) qsort(N,i,end);
// }
// private static void matrixSort(int N[][],int n,int m)
// {
// int T[] = new int[n];
// for(int i = 0;i<n;i++)
// T[i] = i;
// int B[] = new int[n];
// for(int i = 0;i<n;i++)
// B[i] = i;
// indSort(N,T,B,0,n-1);
// int i = 0;
// while(n>=0)
// {
// int temp[] = N[T[i]].clone();
// // N[i] =
// // i = B[i]
// }
//
// }
// private static void indSort (int N[][],int T[],int B[],int i,int j)
// {
// int mid[] = N[T[(i+j)>>1]];
// int beg = 0;
// int end = j;
// while(i<j)
// {
// while(comp(N[T[i]],mid))i++;
// while(comp(mid,N[T[j]]))j--;
//
// if(i<=j)
// {
// int t = T[i];
// T[i] = T[j];
// T[j] = t;
// B[i] = j;
// B[j] = i;
// i++;
// j--;
// }
// }
// if(beg<j)indSort(N,T,B,beg,j);
// if(i<end)indSort(N,T,B,i,end);
// }
// private static boolean comp(int N1[],int N2[])
// {
// int l = N1.length;
// for(int j = 0;j<l;j++)
// if(N1[j]<N2[j])
// return true;
// else
// if(N1[j]>N2[j])
// return false;
// return false;
//
// }
//
//
//}
| 4JAVA
| {
"input": [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n",
"2\n0 0\n0 0\n",
"3\n0 1\n1 1\n1 1\n",
"5\n1 0\n1 0\n1 0\n0 1\n0 1\n",
"15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 0\n1 0\n0 1\n1 0\n",
"3\n0 1\n1 1\n1 0\n",
"8\n0 1\n1 1\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"5\n0 1\n1 0\n0 1\n1 1\n0 0\n",
"5\n0 1\n0 0\n0 1\n1 1\n0 0\n",
"2\n0 0\n0 1\n",
"3\n1 1\n1 1\n1 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 0\n1 0\n0 1\n1 1\n",
"8\n0 1\n0 1\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"3\n0 0\n1 1\n1 0\n",
"5\n0 1\n0 0\n1 1\n1 1\n0 0\n",
"5\n0 1\n0 0\n1 1\n1 1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n",
"7\n",
"6\n",
"6\n",
"2\n",
"2\n",
"4\n",
"0\n",
"4\n",
"8\n",
"7\n",
"6\n",
"7\n",
"7\n",
"5\n",
"6\n",
"3\n",
"1\n",
"7\n",
"3\n",
"1\n",
"7\n",
"7\n",
"3\n",
"7\n",
"8\n",
"6\n",
"2\n",
"6\n"
]
} | 2CODEFORCES
|
272_B. Dima and Sequence_1270 | Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
* f(0) = 0;
* f(2Β·x) = f(x);
* f(2Β·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 β€ i < j β€ n) are there, such that f(ai) = f(aj). Help him, count the number of such pairs.
Input
The first line contains integer n (1 β€ n β€ 105). The second line contains n positive integers a1, a2, ..., an (1 β€ ai β€ 109).
The numbers in the lines are separated by single spaces.
Output
In a single line print the answer to the problem.
Please, don't use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
1 2 4
Output
3
Input
3
5 3 1
Output
1
Note
In the first sample any pair (i, j) will do, so the answer is 3.
In the second sample only pair (1, 2) will do. | import collections
raw_input()
d = [int(x) for x in raw_input().split()]
def bitcount(x):
if x == 0:
return 0
r = 0
while x:
r += x & 1
x //= 2
return r
assert bitcount(5) == bitcount(3)
assert bitcount(15) == 4
h = collections.defaultdict(lambda:0)
for x in d:
h[bitcount(x)] += 1
s = 0
for v in h.itervalues():
s += v*(v-1)/2
print s
| 1Python2
| {
"input": [
"3\n1 2 4\n",
"3\n5 3 1\n",
"6\n396640239 62005863 473635171 329666981 510631133 207643327\n",
"4\n363034183 741262741 657823174 453546052\n",
"2\n7 1\n",
"1\n1\n",
"2\n1 1\n",
"8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n",
"8\n7 1 2 7 6 8 6 5\n",
"2\n469264357 996569493\n",
"7\n481003311 553247971 728349004 258700257 916143165 398096105 412826266\n",
"6\n773209925 62005863 473635171 329666981 510631133 207643327\n",
"1\n2\n",
"7\n481003311 553247971 728349004 258700257 916143165 138445907 412826266\n",
"3\n1 1 4\n",
"7\n481003311 180197148 728349004 258700257 916143165 34179068 568037265\n",
"7\n481003311 180197148 728349004 258700257 916143165 24029675 568037265\n",
"7\n481003311 180197148 728349004 258700257 916143165 26705756 568037265\n",
"4\n363034183 761466960 657823174 453546052\n",
"2\n2 1\n",
"8\n851991424 32517099 310793856 771296843 342626527 58796623 49544509 517126753\n",
"2\n425800479 996569493\n",
"6\n773209925 35419457 473635171 329666981 510631133 207643327\n",
"4\n363034183 761466960 657823174 171535199\n",
"1\n3\n",
"2\n4 1\n",
"8\n851991424 32517099 310793856 440880219 342626527 58796623 49544509 517126753\n",
"2\n60780481 996569493\n",
"7\n481003311 553247971 728349004 258700257 916143165 34179068 412826266\n",
"6\n965185156 35419457 473635171 329666981 510631133 207643327\n",
"4\n363034183 761466960 657823174 333097968\n",
"1\n5\n",
"8\n851991424 58687854 310793856 440880219 342626527 58796623 49544509 517126753\n",
"2\n60780481 1016459657\n",
"7\n481003311 435730861 728349004 258700257 916143165 34179068 412826266\n",
"6\n965185156 35419457 473635171 457870383 510631133 207643327\n",
"4\n52674711 761466960 657823174 333097968\n",
"1\n6\n",
"8\n851991424 58687854 310793856 288710434 342626527 58796623 49544509 517126753\n",
"2\n60780481 804147783\n",
"7\n481003311 180197148 728349004 258700257 916143165 34179068 412826266\n",
"6\n626899147 35419457 473635171 457870383 510631133 207643327\n",
"4\n1028202 761466960 657823174 333097968\n",
"1\n7\n",
"8\n851991424 58687854 310793856 288710434 342626527 58796623 14549368 517126753\n",
"2\n60780481 651466505\n",
"6\n626899147 35419457 473635171 457870383 506174386 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 49507379 14549368 517126753\n",
"2\n51960337 651466505\n",
"6\n626899147 35419457 473635171 457870383 663418062 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 41578389 14549368 517126753\n",
"2\n51960337 991606139\n",
"6\n626899147 35419457 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 77874462 14549368 517126753\n",
"7\n481003311 180197148 728349004 258700257 916143165 39334435 568037265\n",
"6\n626899147 62272727 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 39236011 342626527 77874462 14549368 517126753\n",
"7\n481003311 180197148 728349004 258700257 916143165 39334435 256135693\n",
"6\n658119008 62272727 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 39236011 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 53788156 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 457870383 518510874 381582072\n",
"8\n851991424 58687854 310793856 17294012 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 156818938 518510874 381582072\n",
"8\n851991424 58687854 310793856 8547996 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 68031847 518510874 381582072\n",
"8\n851991424 58687854 310793856 8547996 106976552 77874462 23614760 517126753\n",
"6\n658119008 62272727 762372629 68031847 752002831 381582072\n",
"8\n851991424 58687854 473591941 8547996 106976552 77874462 23614760 517126753\n",
"6\n291668267 62272727 762372629 68031847 752002831 381582072\n",
"8\n851991424 58687854 473591941 8547996 106976552 77874462 24687213 517126753\n",
"6\n291668267 62272727 762372629 75566839 752002831 381582072\n",
"8\n851991424 57723474 473591941 8547996 106976552 77874462 24687213 517126753\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 517126753\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 167352897\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 39654128 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 31167807 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 45100236 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 28009783 24687213 300045002\n",
"8\n851991424 57723474 630146460 8547996 183940637 28009783 24687213 300045002\n",
"8\n851991424 49770965 630146460 8547996 183940637 28009783 24687213 300045002\n"
],
"output": [
"3",
"1",
"2",
"1",
"0",
"0",
"1",
"2",
"7",
"0",
"2",
"1\n",
"0\n",
"2\n",
"3\n",
"4\n",
"7\n",
"5\n",
"1\n",
"1\n",
"1\n",
"0\n",
"1\n",
"1\n",
"0\n",
"1\n",
"2\n",
"1\n",
"2\n",
"3\n",
"1\n",
"0\n",
"2\n",
"0\n",
"3\n",
"2\n",
"0\n",
"0\n",
"3\n",
"0\n",
"2\n",
"1\n",
"1\n",
"0\n",
"3\n",
"0\n",
"2\n",
"2\n",
"0\n",
"2\n",
"4\n",
"0\n",
"1\n",
"3\n",
"4\n",
"1\n",
"3\n",
"2\n",
"1\n",
"3\n",
"1\n",
"3\n",
"0\n",
"3\n",
"0\n",
"5\n",
"0\n",
"5\n",
"1\n",
"3\n",
"1\n",
"2\n",
"1\n",
"2\n",
"2\n",
"3\n",
"3\n",
"4\n",
"3\n",
"3\n",
"2\n",
"2\n",
"2\n"
]
} | 2CODEFORCES
|
272_B. Dima and Sequence_1271 | Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
* f(0) = 0;
* f(2Β·x) = f(x);
* f(2Β·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 β€ i < j β€ n) are there, such that f(ai) = f(aj). Help him, count the number of such pairs.
Input
The first line contains integer n (1 β€ n β€ 105). The second line contains n positive integers a1, a2, ..., an (1 β€ ai β€ 109).
The numbers in the lines are separated by single spaces.
Output
In a single line print the answer to the problem.
Please, don't use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
1 2 4
Output
3
Input
3
5 3 1
Output
1
Note
In the first sample any pair (i, j) will do, so the answer is 3.
In the second sample only pair (1, 2) will do. | #include <bits/stdc++.h>
using namespace std;
vector<int> f(100001);
int comp(int i) {
int b = 0, d = 0;
while (i > 0) {
if (i & 1 == 1) b++;
i = i >> 1;
}
return b;
}
int main() {
int m, i, n;
int h[65];
long long j, s;
for (i = 0; i < 65; i += 2) {
h[i] = 0;
h[i + 1] = 0;
}
cin >> n;
for (i = 0; i < n; i++) {
cin >> f[i];
}
for (i = 0; i < n; i++) {
h[comp(f[i])]++;
}
s = 0;
for (i = 0; i < 65; i++) {
j = h[i];
j = j * (j - 1);
j = j / 2;
s += j;
}
cout << s;
return 0;
}
| 2C++
| {
"input": [
"3\n1 2 4\n",
"3\n5 3 1\n",
"6\n396640239 62005863 473635171 329666981 510631133 207643327\n",
"4\n363034183 741262741 657823174 453546052\n",
"2\n7 1\n",
"1\n1\n",
"2\n1 1\n",
"8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n",
"8\n7 1 2 7 6 8 6 5\n",
"2\n469264357 996569493\n",
"7\n481003311 553247971 728349004 258700257 916143165 398096105 412826266\n",
"6\n773209925 62005863 473635171 329666981 510631133 207643327\n",
"1\n2\n",
"7\n481003311 553247971 728349004 258700257 916143165 138445907 412826266\n",
"3\n1 1 4\n",
"7\n481003311 180197148 728349004 258700257 916143165 34179068 568037265\n",
"7\n481003311 180197148 728349004 258700257 916143165 24029675 568037265\n",
"7\n481003311 180197148 728349004 258700257 916143165 26705756 568037265\n",
"4\n363034183 761466960 657823174 453546052\n",
"2\n2 1\n",
"8\n851991424 32517099 310793856 771296843 342626527 58796623 49544509 517126753\n",
"2\n425800479 996569493\n",
"6\n773209925 35419457 473635171 329666981 510631133 207643327\n",
"4\n363034183 761466960 657823174 171535199\n",
"1\n3\n",
"2\n4 1\n",
"8\n851991424 32517099 310793856 440880219 342626527 58796623 49544509 517126753\n",
"2\n60780481 996569493\n",
"7\n481003311 553247971 728349004 258700257 916143165 34179068 412826266\n",
"6\n965185156 35419457 473635171 329666981 510631133 207643327\n",
"4\n363034183 761466960 657823174 333097968\n",
"1\n5\n",
"8\n851991424 58687854 310793856 440880219 342626527 58796623 49544509 517126753\n",
"2\n60780481 1016459657\n",
"7\n481003311 435730861 728349004 258700257 916143165 34179068 412826266\n",
"6\n965185156 35419457 473635171 457870383 510631133 207643327\n",
"4\n52674711 761466960 657823174 333097968\n",
"1\n6\n",
"8\n851991424 58687854 310793856 288710434 342626527 58796623 49544509 517126753\n",
"2\n60780481 804147783\n",
"7\n481003311 180197148 728349004 258700257 916143165 34179068 412826266\n",
"6\n626899147 35419457 473635171 457870383 510631133 207643327\n",
"4\n1028202 761466960 657823174 333097968\n",
"1\n7\n",
"8\n851991424 58687854 310793856 288710434 342626527 58796623 14549368 517126753\n",
"2\n60780481 651466505\n",
"6\n626899147 35419457 473635171 457870383 506174386 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 49507379 14549368 517126753\n",
"2\n51960337 651466505\n",
"6\n626899147 35419457 473635171 457870383 663418062 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 41578389 14549368 517126753\n",
"2\n51960337 991606139\n",
"6\n626899147 35419457 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 77874462 14549368 517126753\n",
"7\n481003311 180197148 728349004 258700257 916143165 39334435 568037265\n",
"6\n626899147 62272727 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 39236011 342626527 77874462 14549368 517126753\n",
"7\n481003311 180197148 728349004 258700257 916143165 39334435 256135693\n",
"6\n658119008 62272727 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 39236011 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 53788156 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 457870383 518510874 381582072\n",
"8\n851991424 58687854 310793856 17294012 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 156818938 518510874 381582072\n",
"8\n851991424 58687854 310793856 8547996 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 68031847 518510874 381582072\n",
"8\n851991424 58687854 310793856 8547996 106976552 77874462 23614760 517126753\n",
"6\n658119008 62272727 762372629 68031847 752002831 381582072\n",
"8\n851991424 58687854 473591941 8547996 106976552 77874462 23614760 517126753\n",
"6\n291668267 62272727 762372629 68031847 752002831 381582072\n",
"8\n851991424 58687854 473591941 8547996 106976552 77874462 24687213 517126753\n",
"6\n291668267 62272727 762372629 75566839 752002831 381582072\n",
"8\n851991424 57723474 473591941 8547996 106976552 77874462 24687213 517126753\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 517126753\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 167352897\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 39654128 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 31167807 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 45100236 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 28009783 24687213 300045002\n",
"8\n851991424 57723474 630146460 8547996 183940637 28009783 24687213 300045002\n",
"8\n851991424 49770965 630146460 8547996 183940637 28009783 24687213 300045002\n"
],
"output": [
"3",
"1",
"2",
"1",
"0",
"0",
"1",
"2",
"7",
"0",
"2",
"1\n",
"0\n",
"2\n",
"3\n",
"4\n",
"7\n",
"5\n",
"1\n",
"1\n",
"1\n",
"0\n",
"1\n",
"1\n",
"0\n",
"1\n",
"2\n",
"1\n",
"2\n",
"3\n",
"1\n",
"0\n",
"2\n",
"0\n",
"3\n",
"2\n",
"0\n",
"0\n",
"3\n",
"0\n",
"2\n",
"1\n",
"1\n",
"0\n",
"3\n",
"0\n",
"2\n",
"2\n",
"0\n",
"2\n",
"4\n",
"0\n",
"1\n",
"3\n",
"4\n",
"1\n",
"3\n",
"2\n",
"1\n",
"3\n",
"1\n",
"3\n",
"0\n",
"3\n",
"0\n",
"5\n",
"0\n",
"5\n",
"1\n",
"3\n",
"1\n",
"2\n",
"1\n",
"2\n",
"2\n",
"3\n",
"3\n",
"4\n",
"3\n",
"3\n",
"2\n",
"2\n",
"2\n"
]
} | 2CODEFORCES
|
272_B. Dima and Sequence_1272 | Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
* f(0) = 0;
* f(2Β·x) = f(x);
* f(2Β·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 β€ i < j β€ n) are there, such that f(ai) = f(aj). Help him, count the number of such pairs.
Input
The first line contains integer n (1 β€ n β€ 105). The second line contains n positive integers a1, a2, ..., an (1 β€ ai β€ 109).
The numbers in the lines are separated by single spaces.
Output
In a single line print the answer to the problem.
Please, don't use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
1 2 4
Output
3
Input
3
5 3 1
Output
1
Note
In the first sample any pair (i, j) will do, so the answer is 3.
In the second sample only pair (1, 2) will do. | def f(x):
return str(bin(x)).count('1')
n = int(input())
a = list(map(int, input().split()))
ans = [f(x) for x in a]
s = set(ans)
counts = {x:ans.count(x) for x in s}
ans = 0
for i in counts:
ans += (counts[i]*(counts[i]-1))//2
print(ans) | 3Python3
| {
"input": [
"3\n1 2 4\n",
"3\n5 3 1\n",
"6\n396640239 62005863 473635171 329666981 510631133 207643327\n",
"4\n363034183 741262741 657823174 453546052\n",
"2\n7 1\n",
"1\n1\n",
"2\n1 1\n",
"8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n",
"8\n7 1 2 7 6 8 6 5\n",
"2\n469264357 996569493\n",
"7\n481003311 553247971 728349004 258700257 916143165 398096105 412826266\n",
"6\n773209925 62005863 473635171 329666981 510631133 207643327\n",
"1\n2\n",
"7\n481003311 553247971 728349004 258700257 916143165 138445907 412826266\n",
"3\n1 1 4\n",
"7\n481003311 180197148 728349004 258700257 916143165 34179068 568037265\n",
"7\n481003311 180197148 728349004 258700257 916143165 24029675 568037265\n",
"7\n481003311 180197148 728349004 258700257 916143165 26705756 568037265\n",
"4\n363034183 761466960 657823174 453546052\n",
"2\n2 1\n",
"8\n851991424 32517099 310793856 771296843 342626527 58796623 49544509 517126753\n",
"2\n425800479 996569493\n",
"6\n773209925 35419457 473635171 329666981 510631133 207643327\n",
"4\n363034183 761466960 657823174 171535199\n",
"1\n3\n",
"2\n4 1\n",
"8\n851991424 32517099 310793856 440880219 342626527 58796623 49544509 517126753\n",
"2\n60780481 996569493\n",
"7\n481003311 553247971 728349004 258700257 916143165 34179068 412826266\n",
"6\n965185156 35419457 473635171 329666981 510631133 207643327\n",
"4\n363034183 761466960 657823174 333097968\n",
"1\n5\n",
"8\n851991424 58687854 310793856 440880219 342626527 58796623 49544509 517126753\n",
"2\n60780481 1016459657\n",
"7\n481003311 435730861 728349004 258700257 916143165 34179068 412826266\n",
"6\n965185156 35419457 473635171 457870383 510631133 207643327\n",
"4\n52674711 761466960 657823174 333097968\n",
"1\n6\n",
"8\n851991424 58687854 310793856 288710434 342626527 58796623 49544509 517126753\n",
"2\n60780481 804147783\n",
"7\n481003311 180197148 728349004 258700257 916143165 34179068 412826266\n",
"6\n626899147 35419457 473635171 457870383 510631133 207643327\n",
"4\n1028202 761466960 657823174 333097968\n",
"1\n7\n",
"8\n851991424 58687854 310793856 288710434 342626527 58796623 14549368 517126753\n",
"2\n60780481 651466505\n",
"6\n626899147 35419457 473635171 457870383 506174386 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 49507379 14549368 517126753\n",
"2\n51960337 651466505\n",
"6\n626899147 35419457 473635171 457870383 663418062 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 41578389 14549368 517126753\n",
"2\n51960337 991606139\n",
"6\n626899147 35419457 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 77874462 14549368 517126753\n",
"7\n481003311 180197148 728349004 258700257 916143165 39334435 568037265\n",
"6\n626899147 62272727 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 39236011 342626527 77874462 14549368 517126753\n",
"7\n481003311 180197148 728349004 258700257 916143165 39334435 256135693\n",
"6\n658119008 62272727 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 39236011 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 53788156 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 457870383 518510874 381582072\n",
"8\n851991424 58687854 310793856 17294012 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 156818938 518510874 381582072\n",
"8\n851991424 58687854 310793856 8547996 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 68031847 518510874 381582072\n",
"8\n851991424 58687854 310793856 8547996 106976552 77874462 23614760 517126753\n",
"6\n658119008 62272727 762372629 68031847 752002831 381582072\n",
"8\n851991424 58687854 473591941 8547996 106976552 77874462 23614760 517126753\n",
"6\n291668267 62272727 762372629 68031847 752002831 381582072\n",
"8\n851991424 58687854 473591941 8547996 106976552 77874462 24687213 517126753\n",
"6\n291668267 62272727 762372629 75566839 752002831 381582072\n",
"8\n851991424 57723474 473591941 8547996 106976552 77874462 24687213 517126753\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 517126753\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 167352897\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 39654128 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 31167807 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 45100236 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 28009783 24687213 300045002\n",
"8\n851991424 57723474 630146460 8547996 183940637 28009783 24687213 300045002\n",
"8\n851991424 49770965 630146460 8547996 183940637 28009783 24687213 300045002\n"
],
"output": [
"3",
"1",
"2",
"1",
"0",
"0",
"1",
"2",
"7",
"0",
"2",
"1\n",
"0\n",
"2\n",
"3\n",
"4\n",
"7\n",
"5\n",
"1\n",
"1\n",
"1\n",
"0\n",
"1\n",
"1\n",
"0\n",
"1\n",
"2\n",
"1\n",
"2\n",
"3\n",
"1\n",
"0\n",
"2\n",
"0\n",
"3\n",
"2\n",
"0\n",
"0\n",
"3\n",
"0\n",
"2\n",
"1\n",
"1\n",
"0\n",
"3\n",
"0\n",
"2\n",
"2\n",
"0\n",
"2\n",
"4\n",
"0\n",
"1\n",
"3\n",
"4\n",
"1\n",
"3\n",
"2\n",
"1\n",
"3\n",
"1\n",
"3\n",
"0\n",
"3\n",
"0\n",
"5\n",
"0\n",
"5\n",
"1\n",
"3\n",
"1\n",
"2\n",
"1\n",
"2\n",
"2\n",
"3\n",
"3\n",
"4\n",
"3\n",
"3\n",
"2\n",
"2\n",
"2\n"
]
} | 2CODEFORCES
|
272_B. Dima and Sequence_1273 | Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
* f(0) = 0;
* f(2Β·x) = f(x);
* f(2Β·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 β€ i < j β€ n) are there, such that f(ai) = f(aj). Help him, count the number of such pairs.
Input
The first line contains integer n (1 β€ n β€ 105). The second line contains n positive integers a1, a2, ..., an (1 β€ ai β€ 109).
The numbers in the lines are separated by single spaces.
Output
In a single line print the answer to the problem.
Please, don't use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
Examples
Input
3
1 2 4
Output
3
Input
3
5 3 1
Output
1
Note
In the first sample any pair (i, j) will do, so the answer is 3.
In the second sample only pair (1, 2) will do. | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Sequence {
public static void main(String[] args) throws NumberFormatException, IOException {
int[] dp = new int[100];
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
int cur, cnt;
for(int i = 0; i < n; i++) {
cnt = 0;
cur = Integer.parseInt(st.nextToken());
while(cur != 0) {
while( cur % 2 == 0 ) cur /= 2;
cur--;
cnt++;
}
dp[cnt]++;
}
BigInteger ans = new BigInteger("0");
for(int i = 0; i < 100; i++) {
if(dp[i] == 0) continue;
BigInteger aux = new BigInteger(dp[i]+"");
ans = ans.add(aux.multiply(aux.subtract(BigInteger.ONE)).divide(BigInteger.ONE.add(BigInteger.ONE)));
}
System.out.println(ans);
}
}
| 4JAVA
| {
"input": [
"3\n1 2 4\n",
"3\n5 3 1\n",
"6\n396640239 62005863 473635171 329666981 510631133 207643327\n",
"4\n363034183 741262741 657823174 453546052\n",
"2\n7 1\n",
"1\n1\n",
"2\n1 1\n",
"8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n",
"8\n7 1 2 7 6 8 6 5\n",
"2\n469264357 996569493\n",
"7\n481003311 553247971 728349004 258700257 916143165 398096105 412826266\n",
"6\n773209925 62005863 473635171 329666981 510631133 207643327\n",
"1\n2\n",
"7\n481003311 553247971 728349004 258700257 916143165 138445907 412826266\n",
"3\n1 1 4\n",
"7\n481003311 180197148 728349004 258700257 916143165 34179068 568037265\n",
"7\n481003311 180197148 728349004 258700257 916143165 24029675 568037265\n",
"7\n481003311 180197148 728349004 258700257 916143165 26705756 568037265\n",
"4\n363034183 761466960 657823174 453546052\n",
"2\n2 1\n",
"8\n851991424 32517099 310793856 771296843 342626527 58796623 49544509 517126753\n",
"2\n425800479 996569493\n",
"6\n773209925 35419457 473635171 329666981 510631133 207643327\n",
"4\n363034183 761466960 657823174 171535199\n",
"1\n3\n",
"2\n4 1\n",
"8\n851991424 32517099 310793856 440880219 342626527 58796623 49544509 517126753\n",
"2\n60780481 996569493\n",
"7\n481003311 553247971 728349004 258700257 916143165 34179068 412826266\n",
"6\n965185156 35419457 473635171 329666981 510631133 207643327\n",
"4\n363034183 761466960 657823174 333097968\n",
"1\n5\n",
"8\n851991424 58687854 310793856 440880219 342626527 58796623 49544509 517126753\n",
"2\n60780481 1016459657\n",
"7\n481003311 435730861 728349004 258700257 916143165 34179068 412826266\n",
"6\n965185156 35419457 473635171 457870383 510631133 207643327\n",
"4\n52674711 761466960 657823174 333097968\n",
"1\n6\n",
"8\n851991424 58687854 310793856 288710434 342626527 58796623 49544509 517126753\n",
"2\n60780481 804147783\n",
"7\n481003311 180197148 728349004 258700257 916143165 34179068 412826266\n",
"6\n626899147 35419457 473635171 457870383 510631133 207643327\n",
"4\n1028202 761466960 657823174 333097968\n",
"1\n7\n",
"8\n851991424 58687854 310793856 288710434 342626527 58796623 14549368 517126753\n",
"2\n60780481 651466505\n",
"6\n626899147 35419457 473635171 457870383 506174386 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 49507379 14549368 517126753\n",
"2\n51960337 651466505\n",
"6\n626899147 35419457 473635171 457870383 663418062 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 41578389 14549368 517126753\n",
"2\n51960337 991606139\n",
"6\n626899147 35419457 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 288710434 342626527 77874462 14549368 517126753\n",
"7\n481003311 180197148 728349004 258700257 916143165 39334435 568037265\n",
"6\n626899147 62272727 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 39236011 342626527 77874462 14549368 517126753\n",
"7\n481003311 180197148 728349004 258700257 916143165 39334435 256135693\n",
"6\n658119008 62272727 473635171 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 39236011 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 457870383 518510874 207643327\n",
"8\n851991424 58687854 310793856 53788156 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 457870383 518510874 381582072\n",
"8\n851991424 58687854 310793856 17294012 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 156818938 518510874 381582072\n",
"8\n851991424 58687854 310793856 8547996 106976552 77874462 14549368 517126753\n",
"6\n658119008 62272727 762372629 68031847 518510874 381582072\n",
"8\n851991424 58687854 310793856 8547996 106976552 77874462 23614760 517126753\n",
"6\n658119008 62272727 762372629 68031847 752002831 381582072\n",
"8\n851991424 58687854 473591941 8547996 106976552 77874462 23614760 517126753\n",
"6\n291668267 62272727 762372629 68031847 752002831 381582072\n",
"8\n851991424 58687854 473591941 8547996 106976552 77874462 24687213 517126753\n",
"6\n291668267 62272727 762372629 75566839 752002831 381582072\n",
"8\n851991424 57723474 473591941 8547996 106976552 77874462 24687213 517126753\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 517126753\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 167352897\n",
"8\n851991424 57723474 473591941 8547996 183940637 77874462 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 39654128 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 31167807 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 45100236 24687213 300045002\n",
"8\n851991424 57723474 473591941 8547996 183940637 28009783 24687213 300045002\n",
"8\n851991424 57723474 630146460 8547996 183940637 28009783 24687213 300045002\n",
"8\n851991424 49770965 630146460 8547996 183940637 28009783 24687213 300045002\n"
],
"output": [
"3",
"1",
"2",
"1",
"0",
"0",
"1",
"2",
"7",
"0",
"2",
"1\n",
"0\n",
"2\n",
"3\n",
"4\n",
"7\n",
"5\n",
"1\n",
"1\n",
"1\n",
"0\n",
"1\n",
"1\n",
"0\n",
"1\n",
"2\n",
"1\n",
"2\n",
"3\n",
"1\n",
"0\n",
"2\n",
"0\n",
"3\n",
"2\n",
"0\n",
"0\n",
"3\n",
"0\n",
"2\n",
"1\n",
"1\n",
"0\n",
"3\n",
"0\n",
"2\n",
"2\n",
"0\n",
"2\n",
"4\n",
"0\n",
"1\n",
"3\n",
"4\n",
"1\n",
"3\n",
"2\n",
"1\n",
"3\n",
"1\n",
"3\n",
"0\n",
"3\n",
"0\n",
"5\n",
"0\n",
"5\n",
"1\n",
"3\n",
"1\n",
"2\n",
"1\n",
"2\n",
"2\n",
"3\n",
"3\n",
"4\n",
"3\n",
"3\n",
"2\n",
"2\n",
"2\n"
]
} | 2CODEFORCES
|
295_D. Greg and Caves_1274 | Greg has a pad. The pad's screen is an n Γ m rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to n from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to m from left to right.
Greg thinks that the pad's screen displays a cave if the following conditions hold:
* There is a segment [l, r] (1 β€ l β€ r β€ n), such that each of the rows l, l + 1, ..., r has exactly two black cells and all other rows have only white cells.
* There is a row number t (l β€ t β€ r), such that for all pairs of rows with numbers i and j (l β€ i β€ j β€ t) the set of columns between the black cells in row i (with the columns where is these black cells) is the subset of the set of columns between the black cells in row j (with the columns where is these black cells). Similarly, for all pairs of rows with numbers i and j (t β€ i β€ j β€ r) the set of columns between the black cells in row j (with the columns where is these black cells) is the subset of the set of columns between the black cells in row i (with the columns where is these black cells).
Greg wondered, how many ways there are to paint a cave on his pad. Two ways can be considered distinct if there is a cell that has distinct colors on the two pictures.
Help Greg.
Input
The first line contains two integers n, m β the pad's screen size (1 β€ n, m β€ 2000).
Output
In the single line print the remainder after dividing the answer to the problem by 1000000007 (109 + 7).
Examples
Input
1 1
Output
0
Input
4 4
Output
485
Input
3 5
Output
451 | #include <bits/stdc++.h>
using namespace std;
int n, m;
long long res, c[2005][2005];
int main() {
cin >> n >> m;
long long p, q, s;
for (int i = 1; i <= n; i++) {
p = 1, q = 0;
for (int j = 2; j <= m; j++) {
q = (q + c[i - 1][j]) % 1000000007;
p = (p + q) % 1000000007;
c[i][j] = p;
}
}
res = 0;
for (int i = 1; i < n; i++) {
p = 1;
q = 0;
for (int j = 2; j <= m; j++) {
s = m - j + 1;
p = (p + q) % 1000000007;
q = (q + c[n - i][j]) % 1000000007;
res = (res + s * (c[i][j] * p % 1000000007)) % 1000000007;
p = (p + c[n - i][j]) % 1000000007;
}
}
for (int j = 2; j <= m; j++) {
s = m - j + 1;
res = (res + s * c[n][j]) % 1000000007;
}
cout << res;
}
| 2C++
| {
"input": [
"3 5\n",
"1 1\n",
"4 4\n",
"5 3\n",
"1500 2000\n",
"500 1000\n",
"1000 1000\n",
"5 5\n",
"2000 2\n",
"1000 500\n",
"3 1000\n",
"2000 1\n",
"1 2\n",
"3 1999\n",
"100 100\n",
"1 1000\n",
"1000 3\n",
"7 8\n",
"9 8\n",
"10 10\n",
"2000 1777\n",
"1000 1\n",
"100 200\n",
"10 500\n",
"1998 4\n",
"2 2000\n",
"10 1000\n",
"250 250\n",
"1 2000\n",
"2000 2000\n",
"100 110\n",
"1994 1995\n",
"1999 1994\n",
"9 3\n",
"56 1000\n",
"1000 1100\n",
"5 10\n",
"1100 500\n",
"3 1001\n",
"900 1\n",
"1 3\n",
"3 1618\n",
"100 010\n",
"1 1010\n",
"1000 2\n",
"6 8\n",
"3 8\n",
"1 10\n",
"1299 1777\n",
"110 200\n",
"10 596\n",
"55 4\n",
"2 856\n",
"4 1000\n",
"250 458\n",
"511 1995\n",
"1313 1994\n",
"3 6\n",
"9 6\n",
"56 1001\n",
"1001 1100\n",
"5 8\n",
"0100 500\n",
"6 1001\n",
"2 3\n",
"101 010\n",
"2 1010\n",
"1100 2\n",
"8 8\n",
"1 11\n",
"1299 1550\n",
"110 119\n",
"5 596\n",
"55 5\n",
"1 856\n",
"250 184\n",
"511 650\n",
"1313 1988\n",
"4 6\n",
"3 2\n",
"10 6\n",
"1000 0\n",
"0 2000\n",
"000 110\n",
"2 2\n",
"0 4\n",
"900 0\n",
"3 0\n",
"0000 0\n",
"4 0000\n",
"000 010\n",
"0 8\n"
],
"output": [
"451\n",
"0\n",
"485\n",
"185\n",
"294292096\n",
"169229174\n",
"950299696\n",
"6751\n",
"2001000\n",
"900561408\n",
"977762109\n",
"0\n",
"1\n",
"583178527\n",
"631601096\n",
"499500\n",
"1333331\n",
"5898445\n",
"72459477\n",
"33937168\n",
"20685302\n",
"0\n",
"852627600\n",
"659024105\n",
"542192517\n",
"668322662\n",
"298998986\n",
"331145635\n",
"1999000\n",
"627008355\n",
"257801865\n",
"854486105\n",
"785234759\n",
"1455\n",
"231174516\n",
"192789979\n",
"1782595\n",
"456126951\n",
"646044614\n",
"0\n",
"3\n",
"551798129\n",
"924912985\n",
"509545\n",
"500500\n",
"1386164\n",
"5278\n",
"45\n",
"869374173\n",
"993394062\n",
"413363491\n",
"687854706\n",
"846678572\n",
"723521131\n",
"868295641\n",
"677371639\n",
"383191152\n",
"1149\n",
"2149739\n",
"104312590\n",
"630330749\n",
"274690\n",
"128505894\n",
"411517499\n",
"13\n",
"675800723\n",
"889141433\n",
"605550\n",
"21877005\n",
"55\n",
"59892424\n",
"621111890\n",
"798883570\n",
"847201531\n",
"365940\n",
"702018136\n",
"612412110\n",
"914103149\n",
"6309\n",
"6\n",
"5027715\n",
"0\n",
"0\n",
"0\n",
"3\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
295_D. Greg and Caves_1275 | Greg has a pad. The pad's screen is an n Γ m rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to n from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to m from left to right.
Greg thinks that the pad's screen displays a cave if the following conditions hold:
* There is a segment [l, r] (1 β€ l β€ r β€ n), such that each of the rows l, l + 1, ..., r has exactly two black cells and all other rows have only white cells.
* There is a row number t (l β€ t β€ r), such that for all pairs of rows with numbers i and j (l β€ i β€ j β€ t) the set of columns between the black cells in row i (with the columns where is these black cells) is the subset of the set of columns between the black cells in row j (with the columns where is these black cells). Similarly, for all pairs of rows with numbers i and j (t β€ i β€ j β€ r) the set of columns between the black cells in row j (with the columns where is these black cells) is the subset of the set of columns between the black cells in row i (with the columns where is these black cells).
Greg wondered, how many ways there are to paint a cave on his pad. Two ways can be considered distinct if there is a cell that has distinct colors on the two pictures.
Help Greg.
Input
The first line contains two integers n, m β the pad's screen size (1 β€ n, m β€ 2000).
Output
In the single line print the remainder after dividing the answer to the problem by 1000000007 (109 + 7).
Examples
Input
1 1
Output
0
Input
4 4
Output
485
Input
3 5
Output
451 | import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Niyaz Nigmatullin
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
FastScanner in = new FastScanner(inputStream);
FastPrinter out = new FastPrinter(outputStream);
TaskD solver = new TaskD();
solver.solve(1, in, out);
out.close();
}
}
class TaskD {
public void solve(int testNumber, FastScanner in, FastPrinter out) {
// test();
int n = in.nextInt();
int m = in.nextInt();
out.println(solve(n, m));
// if (solve(n, m) != solveStupid(n, m)) {
// throw new AssertionError();
// }
}
static final int MOD = 1000000007;
static int solve(int n, int m) {
int[][] dp = new int[m][n + 1];
int[][] dp2 = new int[m][n + 1];
dp[0][0] = 1;
for (int i = 1; i <= n; i++) {
int s = 0;
int ss = 0;
dp[0][i] = 1;
for (int j = 1; j < m; j++) {
dp2[j][i] = (ss + s + 1) % MOD;
s += dp[j][i - 1];
if (s >= MOD) {
s -= MOD;
}
ss += s;
if (ss >= MOD) {
ss -= MOD;
}
dp[j][i] = (ss + 1) % MOD;
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
int cur = 0;
for (int j = 1; j < m; j++) {
cur = (int) ((cur + (long) dp[j][i + 1] * dp2[j][n - i] % MOD * (m - j)) % MOD);
}
ans += cur;
if (ans >= MOD) {
ans -= MOD;
}
}
return ans;
}
}
class FastScanner extends BufferedReader {
boolean isEOF;
public FastScanner(InputStream is) {
super(new InputStreamReader(is));
}
public int read() {
try {
int ret = super.read();
if (isEOF && ret < 0) {
throw new InputMismatchException();
}
isEOF = ret == -1;
return ret;
} catch (IOException e) {
throw new InputMismatchException();
}
}
static boolean isWhiteSpace(int c) {
return c >= 0 && c <= 32;
}
public int nextInt() {
int c = read();
while (isWhiteSpace(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int ret = 0;
while (c >= 0 && !isWhiteSpace(c)) {
if (c < '0' || c > '9') {
throw new NumberFormatException("digit expected " + (char) c
+ " found");
}
ret = ret * 10 + c - '0';
c = read();
}
return ret * sgn;
}
}
class FastPrinter extends PrintWriter {
public FastPrinter(OutputStream out) {
super(out);
}
public FastPrinter(Writer out) {
super(out);
}
}
| 4JAVA
| {
"input": [
"3 5\n",
"1 1\n",
"4 4\n",
"5 3\n",
"1500 2000\n",
"500 1000\n",
"1000 1000\n",
"5 5\n",
"2000 2\n",
"1000 500\n",
"3 1000\n",
"2000 1\n",
"1 2\n",
"3 1999\n",
"100 100\n",
"1 1000\n",
"1000 3\n",
"7 8\n",
"9 8\n",
"10 10\n",
"2000 1777\n",
"1000 1\n",
"100 200\n",
"10 500\n",
"1998 4\n",
"2 2000\n",
"10 1000\n",
"250 250\n",
"1 2000\n",
"2000 2000\n",
"100 110\n",
"1994 1995\n",
"1999 1994\n",
"9 3\n",
"56 1000\n",
"1000 1100\n",
"5 10\n",
"1100 500\n",
"3 1001\n",
"900 1\n",
"1 3\n",
"3 1618\n",
"100 010\n",
"1 1010\n",
"1000 2\n",
"6 8\n",
"3 8\n",
"1 10\n",
"1299 1777\n",
"110 200\n",
"10 596\n",
"55 4\n",
"2 856\n",
"4 1000\n",
"250 458\n",
"511 1995\n",
"1313 1994\n",
"3 6\n",
"9 6\n",
"56 1001\n",
"1001 1100\n",
"5 8\n",
"0100 500\n",
"6 1001\n",
"2 3\n",
"101 010\n",
"2 1010\n",
"1100 2\n",
"8 8\n",
"1 11\n",
"1299 1550\n",
"110 119\n",
"5 596\n",
"55 5\n",
"1 856\n",
"250 184\n",
"511 650\n",
"1313 1988\n",
"4 6\n",
"3 2\n",
"10 6\n",
"1000 0\n",
"0 2000\n",
"000 110\n",
"2 2\n",
"0 4\n",
"900 0\n",
"3 0\n",
"0000 0\n",
"4 0000\n",
"000 010\n",
"0 8\n"
],
"output": [
"451\n",
"0\n",
"485\n",
"185\n",
"294292096\n",
"169229174\n",
"950299696\n",
"6751\n",
"2001000\n",
"900561408\n",
"977762109\n",
"0\n",
"1\n",
"583178527\n",
"631601096\n",
"499500\n",
"1333331\n",
"5898445\n",
"72459477\n",
"33937168\n",
"20685302\n",
"0\n",
"852627600\n",
"659024105\n",
"542192517\n",
"668322662\n",
"298998986\n",
"331145635\n",
"1999000\n",
"627008355\n",
"257801865\n",
"854486105\n",
"785234759\n",
"1455\n",
"231174516\n",
"192789979\n",
"1782595\n",
"456126951\n",
"646044614\n",
"0\n",
"3\n",
"551798129\n",
"924912985\n",
"509545\n",
"500500\n",
"1386164\n",
"5278\n",
"45\n",
"869374173\n",
"993394062\n",
"413363491\n",
"687854706\n",
"846678572\n",
"723521131\n",
"868295641\n",
"677371639\n",
"383191152\n",
"1149\n",
"2149739\n",
"104312590\n",
"630330749\n",
"274690\n",
"128505894\n",
"411517499\n",
"13\n",
"675800723\n",
"889141433\n",
"605550\n",
"21877005\n",
"55\n",
"59892424\n",
"621111890\n",
"798883570\n",
"847201531\n",
"365940\n",
"702018136\n",
"612412110\n",
"914103149\n",
"6309\n",
"6\n",
"5027715\n",
"0\n",
"0\n",
"0\n",
"3\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
319_B. Psychos in a Line_1276 | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangement of the psychos in the line. Calculate how many steps are needed to the moment of time such, that nobody kills his neighbor after that moment. Look notes to understand the statement more precise.
Input
The first line of input contains integer n denoting the number of psychos, (1 β€ n β€ 105). In the second line there will be a list of n space separated distinct integers each in range 1 to n, inclusive β ids of the psychos in the line from left to right.
Output
Print the number of steps, so that the line remains the same afterward.
Examples
Input
10
10 9 7 8 6 5 3 4 2 1
Output
2
Input
6
1 2 3 4 5 6
Output
0
Note
In the first sample line of the psychos transforms as follows: [10 9 7 8 6 5 3 4 2 1] β [10 8 4] β [10]. So, there are two steps. | n, t = int(raw_input()), map(int, raw_input().split())
p, s, r = [0] * n, [0] * n, t[0]
for i in range(n - 1):
j = i + 1
x = t[j]
if x > r: r = x
else:
d = 0
while t[i] < x: d, i = max(d, s[i]), p[i]
p[j], s[j] = i, d + 1
print max(s) | 1Python2
| {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 43 37 35 69 55 32 26 40 29 65 19 24 34 33 15 45 36 7\n",
"1\n1\n",
"6\n6 5 4 3 2 1\n",
"15\n15 9 5 10 7 11 14 6 2 3 12 1 8 13 4\n",
"2\n2 1\n",
"10\n10 7 4 2 5 8 9 6 3 1\n"
],
"output": [
"0\n",
"2\n",
"0\n",
"8\n",
"0\n",
"1\n",
"4\n",
"1\n",
"4\n"
]
} | 2CODEFORCES
|
319_B. Psychos in a Line_1277 | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangement of the psychos in the line. Calculate how many steps are needed to the moment of time such, that nobody kills his neighbor after that moment. Look notes to understand the statement more precise.
Input
The first line of input contains integer n denoting the number of psychos, (1 β€ n β€ 105). In the second line there will be a list of n space separated distinct integers each in range 1 to n, inclusive β ids of the psychos in the line from left to right.
Output
Print the number of steps, so that the line remains the same afterward.
Examples
Input
10
10 9 7 8 6 5 3 4 2 1
Output
2
Input
6
1 2 3 4 5 6
Output
0
Note
In the first sample line of the psychos transforms as follows: [10 9 7 8 6 5 3 4 2 1] β [10 8 4] β [10]. So, there are two steps. | #include <bits/stdc++.h>
using namespace std;
int n, m[100005], x, k[100005], res, last;
stack<int> s;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
if (s.empty() || x > s.top()) {
s.push(x);
} else {
if (last > x) {
m[x] = 1;
k[x] = last;
} else {
int lastVic = last;
while (k[lastVic] < x || m[k[lastVic]] == m[lastVic]) {
lastVic = k[lastVic];
}
m[x] = m[lastVic] + 1;
k[x] = k[lastVic];
}
}
res = max(res, m[x]);
last = x;
}
cout << res << endl;
return 0;
}
| 2C++
| {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 43 37 35 69 55 32 26 40 29 65 19 24 34 33 15 45 36 7\n",
"1\n1\n",
"6\n6 5 4 3 2 1\n",
"15\n15 9 5 10 7 11 14 6 2 3 12 1 8 13 4\n",
"2\n2 1\n",
"10\n10 7 4 2 5 8 9 6 3 1\n"
],
"output": [
"0\n",
"2\n",
"0\n",
"8\n",
"0\n",
"1\n",
"4\n",
"1\n",
"4\n"
]
} | 2CODEFORCES
|
319_B. Psychos in a Line_1278 | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangement of the psychos in the line. Calculate how many steps are needed to the moment of time such, that nobody kills his neighbor after that moment. Look notes to understand the statement more precise.
Input
The first line of input contains integer n denoting the number of psychos, (1 β€ n β€ 105). In the second line there will be a list of n space separated distinct integers each in range 1 to n, inclusive β ids of the psychos in the line from left to right.
Output
Print the number of steps, so that the line remains the same afterward.
Examples
Input
10
10 9 7 8 6 5 3 4 2 1
Output
2
Input
6
1 2 3 4 5 6
Output
0
Note
In the first sample line of the psychos transforms as follows: [10 9 7 8 6 5 3 4 2 1] β [10 8 4] β [10]. So, there are two steps. | n, t = int(input()), list(map(int, input().split()))
p, s, r = [0] * n, [0] * n, t[0]
for i in range(n - 1):
j = i + 1
x = t[j]
if x > r: r = x
else:
while t[i] < x: s[j], i = max(s[j], s[i]), p[i]
p[j] = i
s[j] += 1
print(max(s))
# Made By Mostafa_Khaled | 3Python3
| {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 43 37 35 69 55 32 26 40 29 65 19 24 34 33 15 45 36 7\n",
"1\n1\n",
"6\n6 5 4 3 2 1\n",
"15\n15 9 5 10 7 11 14 6 2 3 12 1 8 13 4\n",
"2\n2 1\n",
"10\n10 7 4 2 5 8 9 6 3 1\n"
],
"output": [
"0\n",
"2\n",
"0\n",
"8\n",
"0\n",
"1\n",
"4\n",
"1\n",
"4\n"
]
} | 2CODEFORCES
|
319_B. Psychos in a Line_1279 | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangement of the psychos in the line. Calculate how many steps are needed to the moment of time such, that nobody kills his neighbor after that moment. Look notes to understand the statement more precise.
Input
The first line of input contains integer n denoting the number of psychos, (1 β€ n β€ 105). In the second line there will be a list of n space separated distinct integers each in range 1 to n, inclusive β ids of the psychos in the line from left to right.
Output
Print the number of steps, so that the line remains the same afterward.
Examples
Input
10
10 9 7 8 6 5 3 4 2 1
Output
2
Input
6
1 2 3 4 5 6
Output
0
Note
In the first sample line of the psychos transforms as follows: [10 9 7 8 6 5 3 4 2 1] β [10 8 4] β [10]. So, there are two steps. | import java.util.*;
import java.io.*;
import java.math.*;
public class D {
public static Scanner scan = new Scanner(System.in);
public static boolean bg = true;
public static void main(String[] args) throws Exception {
int n1 = Integer.parseInt(scan.next());
int[] data = new int[n1];
TreeSet<Integer> t1 = new TreeSet();
for (int i=0;i<n1;i++){
int k1 = Integer.parseInt(scan.next());
data[i]=k1;
t1.add(i);
}
ArrayList<Integer> inv = new ArrayList<>();
for (int i=0;i<data.length-1;i++){
if (data[i]>data[i+1]) inv.add(i);
}
int count = 0;
for (;;){
ArrayList<Integer> nextinv = new ArrayList<>();
HashSet<Integer> del2 = new HashSet<>();
for (int e: inv){
if (del2.contains(e)) continue;
int ptr = e;
for (;;){
if (t1.higher(ptr)==null) break;
int next = t1.higher(ptr);
if (data[ptr]>data[next]){
del2.add(ptr);
}
else {
if (data[e]>data[next]){
nextinv.add(e);
}
break;
}
ptr= next;
}
}
inv = nextinv;
if (del2.size()==0) break;
for (int e: del2){
t1.remove(t1.higher(e));
}
count++;
}
System.out.println(count);
}
}
| 4JAVA
| {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 43 37 35 69 55 32 26 40 29 65 19 24 34 33 15 45 36 7\n",
"1\n1\n",
"6\n6 5 4 3 2 1\n",
"15\n15 9 5 10 7 11 14 6 2 3 12 1 8 13 4\n",
"2\n2 1\n",
"10\n10 7 4 2 5 8 9 6 3 1\n"
],
"output": [
"0\n",
"2\n",
"0\n",
"8\n",
"0\n",
"1\n",
"4\n",
"1\n",
"4\n"
]
} | 2CODEFORCES
|
343_B. Alternating Current_1280 | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended up entangled and now have to be untangled again.
The device is powered by two wires "plus" and "minus". The wires run along the floor from the wall (on the left) to the device (on the right). Both the wall and the device have two contacts in them on the same level, into which the wires are plugged in some order. The wires are considered entangled if there are one or more places where one wire runs above the other one. For example, the picture below has four such places (top view):
<image>
Mike knows the sequence in which the wires run above each other. Mike also noticed that on the left side, the "plus" wire is always plugged into the top contact (as seen on the picture). He would like to untangle the wires without unplugging them and without moving the device. Determine if it is possible to do that. A wire can be freely moved and stretched on the floor, but cannot be cut.
To understand the problem better please read the notes to the test samples.
Input
The single line of the input contains a sequence of characters "+" and "-" of length n (1 β€ n β€ 100000). The i-th (1 β€ i β€ n) position of the sequence contains the character "+", if on the i-th step from the wall the "plus" wire runs above the "minus" wire, and the character "-" otherwise.
Output
Print either "Yes" (without the quotes) if the wires can be untangled or "No" (without the quotes) if the wires cannot be untangled.
Examples
Input
-++-
Output
Yes
Input
+-
Output
No
Input
++
Output
Yes
Input
-
Output
No
Note
The first testcase corresponds to the picture in the statement. To untangle the wires, one can first move the "plus" wire lower, thus eliminating the two crosses in the middle, and then draw it under the "minus" wire, eliminating also the remaining two crosses.
In the second testcase the "plus" wire makes one full revolution around the "minus" wire. Thus the wires cannot be untangled:
<image>
In the third testcase the "plus" wire simply runs above the "minus" wire twice in sequence. The wires can be untangled by lifting "plus" and moving it higher:
<image>
In the fourth testcase the "minus" wire runs above the "plus" wire once. The wires cannot be untangled without moving the device itself:
<image> |
inp = raw_input()
stack = []
for i in inp:
if len(stack) == 0:
stack.append(i)
continue
cur = stack.pop()
if cur == i:
continue
stack.append(cur)
stack.append(i)
if len(stack) == 0:
print 'Yes'
else:
print 'No'
| 1Python2
| {
"input": [
"-++-\n",
"++\n",
"+-\n",
"-\n",
"+-+--+-+\n",
"+-+--+\n",
"+-+++-\n",
"+++-\n",
"-++-+--++--+-++-\n",
"-+++--\n",
"-+--+-\n",
"+-++-+\n",
"+++---+++---\n",
"+-+-\n",
"-+-+-+\n",
"+++---\n",
"++--++\n",
"+---+\n",
"--++-+\n",
"-+\n",
"-+-\n",
"--\n",
"-+++++\n",
"+-+-++\n",
"+++\n",
"-+-+-+-+-+-+-++-+-+-+-+-+-+-\n",
"-++\n",
"+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-+++-++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+-+----++++-+-+\n",
"++-+\n",
"-+-+-++-+-+-\n",
"-+-++-+-+-\n",
"-+-++--+++-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+-----++++--++-+-++\n",
"+\n",
"+-----+-++---+------+++-++++\n",
"+---++--++\n",
"-++-+--+\n",
"-+-+--\n",
"+-+-+-+-+--+-+-+-+-++--++--+\n",
"++-+-+-+-+--+\n",
"--+\n",
"+---+-+-\n",
"-+-++-+-\n",
"-++--+--+++-+-+-+-+-\n",
"--+++\n",
"+--+-+\n",
"+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-++++++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+------++++-+-+\n",
"-+++-+\n",
"+-++\n",
"---+++---+++\n",
"-+-+\n",
"+-+-+-\n",
"+---,\n",
",-+\n",
"++-+-+\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+--+-++\n",
"++-+-+-+-+-,+\n",
"-+-+---+\n",
"-++-+\n",
"+---++\n",
",---+\n",
"+-,\n",
"+-+-++++------+---+++----++++-+++--+++-++--+--+++-++++++-++-++++++++++-+++--++++++-+-++--+++-+--+++-----++---+--+-------++--+-+-++++--+--+++---+-+-+-+++-+-++-++---+++--++-+++-----+---+-+++++---+++--+--++++-+-+-+---+++---++++-+-+-----++-+--+----++--+-+++++-+-++-+-+++-----+++-+++-+----+++----+----+++++++-+-+--++++-+-+++++-------+++-+++--+---+-+--+---++--+++-+-+++++++------+--+--+\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+,++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+---+++\n",
"++-+,+-+-+-,+\n",
"+-++-\n",
"*---+\n",
"*-,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"+++---+-\n",
"++-+,+-+-+-,,\n",
"+-++,\n",
"-*,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
"+++-+---\n",
",,-+-+-+,+-++\n",
"+-,+,\n",
",*-\n",
"-++-++--++++-+++----*+---+++---++-+--+-----++--+-+--++--+-+++++--++---++++++-+-+-++++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--++-+-\n",
"++-+,+-+-+.,,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
"++-+,+-+-+,.,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+*+-++++--++-++-\n",
"++++,--+-+,.,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-,--++-----+--+-++---+++---+*----+*+-++++--++-++-\n",
",++++--+-+,.,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-,--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
",.,+-+--++++,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--+,--+++++-+--++--+-,--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
",++++,-+-+,.,\n",
"-++-++--++++-+++----*+---+++---++-+--+-----++--,-+--++--+-+++++--,+--,++++++-+-+-++++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--*+-+-\n",
",.,+-+-,++++,\n",
"-++-++--++++-+++----*+---+++---++-+--+--+--++--,-+--++--+-+++++--,+--,++++++-+-+--+++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--*+-+-\n",
",.++-,-,++++,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+++--+-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,+++*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+--+--+-+++--+-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,*++*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+--+--+-+++--,-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,*,+*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+-,+--+-+++--,-+-++++++---+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-+-,*,+*,\n",
"++-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+-,+--+-+++--,-+-++++++---+,--+++++-+--++--+-,---+--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",*+,*,-+-++.,\n"
],
"output": [
"YES\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n"
]
} | 2CODEFORCES
|
343_B. Alternating Current_1281 | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended up entangled and now have to be untangled again.
The device is powered by two wires "plus" and "minus". The wires run along the floor from the wall (on the left) to the device (on the right). Both the wall and the device have two contacts in them on the same level, into which the wires are plugged in some order. The wires are considered entangled if there are one or more places where one wire runs above the other one. For example, the picture below has four such places (top view):
<image>
Mike knows the sequence in which the wires run above each other. Mike also noticed that on the left side, the "plus" wire is always plugged into the top contact (as seen on the picture). He would like to untangle the wires without unplugging them and without moving the device. Determine if it is possible to do that. A wire can be freely moved and stretched on the floor, but cannot be cut.
To understand the problem better please read the notes to the test samples.
Input
The single line of the input contains a sequence of characters "+" and "-" of length n (1 β€ n β€ 100000). The i-th (1 β€ i β€ n) position of the sequence contains the character "+", if on the i-th step from the wall the "plus" wire runs above the "minus" wire, and the character "-" otherwise.
Output
Print either "Yes" (without the quotes) if the wires can be untangled or "No" (without the quotes) if the wires cannot be untangled.
Examples
Input
-++-
Output
Yes
Input
+-
Output
No
Input
++
Output
Yes
Input
-
Output
No
Note
The first testcase corresponds to the picture in the statement. To untangle the wires, one can first move the "plus" wire lower, thus eliminating the two crosses in the middle, and then draw it under the "minus" wire, eliminating also the remaining two crosses.
In the second testcase the "plus" wire makes one full revolution around the "minus" wire. Thus the wires cannot be untangled:
<image>
In the third testcase the "plus" wire simply runs above the "minus" wire twice in sequence. The wires can be untangled by lifting "plus" and moving it higher:
<image>
In the fourth testcase the "minus" wire runs above the "plus" wire once. The wires cannot be untangled without moving the device itself:
<image> | #include <bits/stdc++.h>
using namespace std;
const int INF = ~(1 << 31);
const double eps = 1e-6;
const long double PI = 3.1415926535;
const int MOD = 1e9 + 7;
int n, m;
int main() {
string s;
cin >> s;
stack<int> st;
for (int(i) = 0; (i) < (s.size()); ++(i)) {
int g = s[i] == '+';
if (st.size() && st.top() == g)
st.pop();
else
st.push(g);
}
if (st.size() == 0)
puts("Yes");
else
puts("No");
return 0;
}
| 2C++
| {
"input": [
"-++-\n",
"++\n",
"+-\n",
"-\n",
"+-+--+-+\n",
"+-+--+\n",
"+-+++-\n",
"+++-\n",
"-++-+--++--+-++-\n",
"-+++--\n",
"-+--+-\n",
"+-++-+\n",
"+++---+++---\n",
"+-+-\n",
"-+-+-+\n",
"+++---\n",
"++--++\n",
"+---+\n",
"--++-+\n",
"-+\n",
"-+-\n",
"--\n",
"-+++++\n",
"+-+-++\n",
"+++\n",
"-+-+-+-+-+-+-++-+-+-+-+-+-+-\n",
"-++\n",
"+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-+++-++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+-+----++++-+-+\n",
"++-+\n",
"-+-+-++-+-+-\n",
"-+-++-+-+-\n",
"-+-++--+++-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+-----++++--++-+-++\n",
"+\n",
"+-----+-++---+------+++-++++\n",
"+---++--++\n",
"-++-+--+\n",
"-+-+--\n",
"+-+-+-+-+--+-+-+-+-++--++--+\n",
"++-+-+-+-+--+\n",
"--+\n",
"+---+-+-\n",
"-+-++-+-\n",
"-++--+--+++-+-+-+-+-\n",
"--+++\n",
"+--+-+\n",
"+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-++++++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+------++++-+-+\n",
"-+++-+\n",
"+-++\n",
"---+++---+++\n",
"-+-+\n",
"+-+-+-\n",
"+---,\n",
",-+\n",
"++-+-+\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+--+-++\n",
"++-+-+-+-+-,+\n",
"-+-+---+\n",
"-++-+\n",
"+---++\n",
",---+\n",
"+-,\n",
"+-+-++++------+---+++----++++-+++--+++-++--+--+++-++++++-++-++++++++++-+++--++++++-+-++--+++-+--+++-----++---+--+-------++--+-+-++++--+--+++---+-+-+-+++-+-++-++---+++--++-+++-----+---+-+++++---+++--+--++++-+-+-+---+++---++++-+-+-----++-+--+----++--+-+++++-+-++-+-+++-----+++-+++-+----+++----+----+++++++-+-+--++++-+-+++++-------+++-+++--+---+-+--+---++--+++-+-+++++++------+--+--+\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+,++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+---+++\n",
"++-+,+-+-+-,+\n",
"+-++-\n",
"*---+\n",
"*-,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"+++---+-\n",
"++-+,+-+-+-,,\n",
"+-++,\n",
"-*,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
"+++-+---\n",
",,-+-+-+,+-++\n",
"+-,+,\n",
",*-\n",
"-++-++--++++-+++----*+---+++---++-+--+-----++--+-+--++--+-+++++--++---++++++-+-+-++++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--++-+-\n",
"++-+,+-+-+.,,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
"++-+,+-+-+,.,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+*+-++++--++-++-\n",
"++++,--+-+,.,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-,--++-----+--+-++---+++---+*----+*+-++++--++-++-\n",
",++++--+-+,.,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-,--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
",.,+-+--++++,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--+,--+++++-+--++--+-,--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
",++++,-+-+,.,\n",
"-++-++--++++-+++----*+---+++---++-+--+-----++--,-+--++--+-+++++--,+--,++++++-+-+-++++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--*+-+-\n",
",.,+-+-,++++,\n",
"-++-++--++++-+++----*+---+++---++-+--+--+--++--,-+--++--+-+++++--,+--,++++++-+-+--+++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--*+-+-\n",
",.++-,-,++++,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+++--+-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,+++*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+--+--+-+++--+-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,*++*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+--+--+-+++--,-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,*,+*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+-,+--+-+++--,-+-++++++---+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-+-,*,+*,\n",
"++-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+-,+--+-+++--,-+-++++++---+,--+++++-+--++--+-,---+--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",*+,*,-+-++.,\n"
],
"output": [
"YES\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n"
]
} | 2CODEFORCES
|
343_B. Alternating Current_1282 | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended up entangled and now have to be untangled again.
The device is powered by two wires "plus" and "minus". The wires run along the floor from the wall (on the left) to the device (on the right). Both the wall and the device have two contacts in them on the same level, into which the wires are plugged in some order. The wires are considered entangled if there are one or more places where one wire runs above the other one. For example, the picture below has four such places (top view):
<image>
Mike knows the sequence in which the wires run above each other. Mike also noticed that on the left side, the "plus" wire is always plugged into the top contact (as seen on the picture). He would like to untangle the wires without unplugging them and without moving the device. Determine if it is possible to do that. A wire can be freely moved and stretched on the floor, but cannot be cut.
To understand the problem better please read the notes to the test samples.
Input
The single line of the input contains a sequence of characters "+" and "-" of length n (1 β€ n β€ 100000). The i-th (1 β€ i β€ n) position of the sequence contains the character "+", if on the i-th step from the wall the "plus" wire runs above the "minus" wire, and the character "-" otherwise.
Output
Print either "Yes" (without the quotes) if the wires can be untangled or "No" (without the quotes) if the wires cannot be untangled.
Examples
Input
-++-
Output
Yes
Input
+-
Output
No
Input
++
Output
Yes
Input
-
Output
No
Note
The first testcase corresponds to the picture in the statement. To untangle the wires, one can first move the "plus" wire lower, thus eliminating the two crosses in the middle, and then draw it under the "minus" wire, eliminating also the remaining two crosses.
In the second testcase the "plus" wire makes one full revolution around the "minus" wire. Thus the wires cannot be untangled:
<image>
In the third testcase the "plus" wire simply runs above the "minus" wire twice in sequence. The wires can be untangled by lifting "plus" and moving it higher:
<image>
In the fourth testcase the "minus" wire runs above the "plus" wire once. The wires cannot be untangled without moving the device itself:
<image> | list_inp=input()
stack_jud=[]
for i in list_inp:
if len(stack_jud)>0:
if stack_jud[-1]==i:stack_jud.pop()
else: stack_jud.append(i)
else: stack_jud.append(i)
if stack_jud==[]:print ('Yes')
else:print ('No')
| 3Python3
| {
"input": [
"-++-\n",
"++\n",
"+-\n",
"-\n",
"+-+--+-+\n",
"+-+--+\n",
"+-+++-\n",
"+++-\n",
"-++-+--++--+-++-\n",
"-+++--\n",
"-+--+-\n",
"+-++-+\n",
"+++---+++---\n",
"+-+-\n",
"-+-+-+\n",
"+++---\n",
"++--++\n",
"+---+\n",
"--++-+\n",
"-+\n",
"-+-\n",
"--\n",
"-+++++\n",
"+-+-++\n",
"+++\n",
"-+-+-+-+-+-+-++-+-+-+-+-+-+-\n",
"-++\n",
"+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-+++-++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+-+----++++-+-+\n",
"++-+\n",
"-+-+-++-+-+-\n",
"-+-++-+-+-\n",
"-+-++--+++-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+-----++++--++-+-++\n",
"+\n",
"+-----+-++---+------+++-++++\n",
"+---++--++\n",
"-++-+--+\n",
"-+-+--\n",
"+-+-+-+-+--+-+-+-+-++--++--+\n",
"++-+-+-+-+--+\n",
"--+\n",
"+---+-+-\n",
"-+-++-+-\n",
"-++--+--+++-+-+-+-+-\n",
"--+++\n",
"+--+-+\n",
"+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-++++++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+------++++-+-+\n",
"-+++-+\n",
"+-++\n",
"---+++---+++\n",
"-+-+\n",
"+-+-+-\n",
"+---,\n",
",-+\n",
"++-+-+\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+--+-++\n",
"++-+-+-+-+-,+\n",
"-+-+---+\n",
"-++-+\n",
"+---++\n",
",---+\n",
"+-,\n",
"+-+-++++------+---+++----++++-+++--+++-++--+--+++-++++++-++-++++++++++-+++--++++++-+-++--+++-+--+++-----++---+--+-------++--+-+-++++--+--+++---+-+-+-+++-+-++-++---+++--++-+++-----+---+-+++++---+++--+--++++-+-+-+---+++---++++-+-+-----++-+--+----++--+-+++++-+-++-+-+++-----+++-+++-+----+++----+----+++++++-+-+--++++-+-+++++-------+++-+++--+---+-+--+---++--+++-+-+++++++------+--+--+\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+,++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+---+++\n",
"++-+,+-+-+-,+\n",
"+-++-\n",
"*---+\n",
"*-,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"+++---+-\n",
"++-+,+-+-+-,,\n",
"+-++,\n",
"-*,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
"+++-+---\n",
",,-+-+-+,+-++\n",
"+-,+,\n",
",*-\n",
"-++-++--++++-+++----*+---+++---++-+--+-----++--+-+--++--+-+++++--++---++++++-+-+-++++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--++-+-\n",
"++-+,+-+-+.,,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
"++-+,+-+-+,.,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+*+-++++--++-++-\n",
"++++,--+-+,.,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-,--++-----+--+-++---+++---+*----+*+-++++--++-++-\n",
",++++--+-+,.,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-,--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
",.,+-+--++++,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--+,--+++++-+--++--+-,--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
",++++,-+-+,.,\n",
"-++-++--++++-+++----*+---+++---++-+--+-----++--,-+--++--+-+++++--,+--,++++++-+-+-++++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--*+-+-\n",
",.,+-+-,++++,\n",
"-++-++--++++-+++----*+---+++---++-+--+--+--++--,-+--++--+-+++++--,+--,++++++-+-+--+++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--*+-+-\n",
",.++-,-,++++,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+++--+-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,+++*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+--+--+-+++--+-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,*++*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+--+--+-+++--,-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,*,+*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+-,+--+-+++--,-+-++++++---+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-+-,*,+*,\n",
"++-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+-,+--+-+++--,-+-++++++---+,--+++++-+--++--+-,---+--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",*+,*,-+-++.,\n"
],
"output": [
"YES\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n"
]
} | 2CODEFORCES
|
343_B. Alternating Current_1283 | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended up entangled and now have to be untangled again.
The device is powered by two wires "plus" and "minus". The wires run along the floor from the wall (on the left) to the device (on the right). Both the wall and the device have two contacts in them on the same level, into which the wires are plugged in some order. The wires are considered entangled if there are one or more places where one wire runs above the other one. For example, the picture below has four such places (top view):
<image>
Mike knows the sequence in which the wires run above each other. Mike also noticed that on the left side, the "plus" wire is always plugged into the top contact (as seen on the picture). He would like to untangle the wires without unplugging them and without moving the device. Determine if it is possible to do that. A wire can be freely moved and stretched on the floor, but cannot be cut.
To understand the problem better please read the notes to the test samples.
Input
The single line of the input contains a sequence of characters "+" and "-" of length n (1 β€ n β€ 100000). The i-th (1 β€ i β€ n) position of the sequence contains the character "+", if on the i-th step from the wall the "plus" wire runs above the "minus" wire, and the character "-" otherwise.
Output
Print either "Yes" (without the quotes) if the wires can be untangled or "No" (without the quotes) if the wires cannot be untangled.
Examples
Input
-++-
Output
Yes
Input
+-
Output
No
Input
++
Output
Yes
Input
-
Output
No
Note
The first testcase corresponds to the picture in the statement. To untangle the wires, one can first move the "plus" wire lower, thus eliminating the two crosses in the middle, and then draw it under the "minus" wire, eliminating also the remaining two crosses.
In the second testcase the "plus" wire makes one full revolution around the "minus" wire. Thus the wires cannot be untangled:
<image>
In the third testcase the "plus" wire simply runs above the "minus" wire twice in sequence. The wires can be untangled by lifting "plus" and moving it higher:
<image>
In the fourth testcase the "minus" wire runs above the "plus" wire once. The wires cannot be untangled without moving the device itself:
<image> | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;
public class alternating {
public static void main(String[] args) throws Throwable {
BufferedReader bf = new BufferedReader(new InputStreamReader (System.in));
PrintWriter pw = new PrintWriter(System.out, true);
String inp=bf.readLine();
Stack<Character> st = new Stack<Character>();
for(int i=0;i!=inp.length();i++)
{
if(st.size()!=0&&st.peek()==inp.charAt(i))
st.pop();
else
st.push(inp.charAt(i));
}
if(st.size()==0)
System.out.print("YES");
else
pw.print("NO");
pw.close();
}
}
| 4JAVA
| {
"input": [
"-++-\n",
"++\n",
"+-\n",
"-\n",
"+-+--+-+\n",
"+-+--+\n",
"+-+++-\n",
"+++-\n",
"-++-+--++--+-++-\n",
"-+++--\n",
"-+--+-\n",
"+-++-+\n",
"+++---+++---\n",
"+-+-\n",
"-+-+-+\n",
"+++---\n",
"++--++\n",
"+---+\n",
"--++-+\n",
"-+\n",
"-+-\n",
"--\n",
"-+++++\n",
"+-+-++\n",
"+++\n",
"-+-+-+-+-+-+-++-+-+-+-+-+-+-\n",
"-++\n",
"+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-+++-++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+-+----++++-+-+\n",
"++-+\n",
"-+-+-++-+-+-\n",
"-+-++-+-+-\n",
"-+-++--+++-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+-----++++--++-+-++\n",
"+\n",
"+-----+-++---+------+++-++++\n",
"+---++--++\n",
"-++-+--+\n",
"-+-+--\n",
"+-+-+-+-+--+-+-+-+-++--++--+\n",
"++-+-+-+-+--+\n",
"--+\n",
"+---+-+-\n",
"-+-++-+-\n",
"-++--+--+++-+-+-+-+-\n",
"--+++\n",
"+--+-+\n",
"+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-++++++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+------++++-+-+\n",
"-+++-+\n",
"+-++\n",
"---+++---+++\n",
"-+-+\n",
"+-+-+-\n",
"+---,\n",
",-+\n",
"++-+-+\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+--+-++\n",
"++-+-+-+-+-,+\n",
"-+-+---+\n",
"-++-+\n",
"+---++\n",
",---+\n",
"+-,\n",
"+-+-++++------+---+++----++++-+++--+++-++--+--+++-++++++-++-++++++++++-+++--++++++-+-++--+++-+--+++-----++---+--+-------++--+-+-++++--+--+++---+-+-+-+++-+-++-++---+++--++-+++-----+---+-+++++---+++--+--++++-+-+-+---+++---++++-+-+-----++-+--+----++--+-+++++-+-++-+-+++-----+++-+++-+----+++----+----+++++++-+-+--++++-+-+++++-------+++-+++--+---+-+--+---++--+++-+-+++++++------+--+--+\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+,++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"-+---+++\n",
"++-+,+-+-+-,+\n",
"+-++-\n",
"*---+\n",
"*-,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
"+++---+-\n",
"++-+,+-+-+-,,\n",
"+-++,\n",
"-*,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
"+++-+---\n",
",,-+-+-+,+-++\n",
"+-,+,\n",
",*-\n",
"-++-++--++++-+++----*+---+++---++-+--+-----++--+-+--++--+-+++++--++---++++++-+-+-++++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--++-+-\n",
"++-+,+-+-+.,,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
"++-+,+-+-+,.,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-+--++-----+--+-++---+++---+*----+*+-++++--++-++-\n",
"++++,--+-+,.,\n",
"-+-++--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-,--++-----+--+-++---+++---+*----+*+-++++--++-++-\n",
",++++--+-+,.,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--++--+++++-+--++--+-,--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
",.,+-+--++++,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-++++-+-+-++++++,--+,--+++++-+--++--+-,--++-----+--+-++---+++---+*----+++-++++--++-++-\n",
",++++,-+-+,.,\n",
"-++-++--++++-+++----*+---+++---++-+--+-----++--,-+--++--+-+++++--,+--,++++++-+-+-++++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--*+-+-\n",
",.,+-+-,++++,\n",
"-++-++--++++-+++----*+---+++---++-+--+--+--++--,-+--++--+-+++++--,+--,++++++-+-+--+++-+--+--+--+-++++-++---+-+++-+++-+-+--+----+--+---++++-*++--*+-+-\n",
",.++-,-,++++,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+++--+-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,+++*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+--+--+-+++--+-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,*++*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+--+--+-+++--,-+-++++++,--+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-,-,*,+*,\n",
"-+-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+-,+--+-+++--,-+-++++++---+,--+++++-+--++--+-,--++--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",.++-+-,*,+*,\n",
"++-+*--++*-++++---+--+----+--+-+-+++-+++-+---+,-++++-+--+-,+--+-+++--,-+-++++++---+,--+++++-+--++--+-,---+--+--+--+-++---+++---+*----+++-++++--++-++-\n",
",*+,*,-+-++.,\n"
],
"output": [
"YES\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n"
]
} | 2CODEFORCES
|
366_D. Dima and Trap Graph_1284 | Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get criminal...
Dima constructed a trap graph. He shouted: "Hey Seryozha, have a look at my cool graph!" to get his roommate interested and kicked him into the first node.
A trap graph is an undirected graph consisting of n nodes and m edges. For edge number k, Dima denoted a range of integers from lk to rk (lk β€ rk). In order to get out of the trap graph, Seryozha initially (before starting his movements) should pick some integer (let's call it x), then Seryozha must go some way from the starting node with number 1 to the final node with number n. At that, Seryozha can go along edge k only if lk β€ x β€ rk.
Seryozha is a mathematician. He defined the loyalty of some path from the 1-st node to the n-th one as the number of integers x, such that if he initially chooses one of them, he passes the whole path. Help Seryozha find the path of maximum loyalty and return to his room as quickly as possible!
Input
The first line of the input contains two integers n and m (2 β€ n β€ 103, 0 β€ m β€ 3Β·103). Then follow m lines describing the edges. Each line contains four integers ak, bk, lk and rk (1 β€ ak, bk β€ n, 1 β€ lk β€ rk β€ 106). The numbers mean that in the trap graph the k-th edge connects nodes ak and bk, this edge corresponds to the range of integers from lk to rk.
Note that the given graph can have loops and multiple edges.
Output
In a single line of the output print an integer β the maximum loyalty among all paths from the first node to the n-th one. If such paths do not exist or the maximum loyalty equals 0, print in a single line "Nice work, Dima!" without the quotes.
Examples
Input
4 4
1 2 1 10
2 4 3 5
1 3 1 5
2 4 2 7
Output
6
Input
5 6
1 2 1 10
2 5 11 20
1 4 2 5
1 3 10 11
3 4 12 10000
4 5 6 6
Output
Nice work, Dima!
Note
Explanation of the first example.
Overall, we have 2 ways to get from node 1 to node 4: first you must go along the edge 1-2 with range [1-10], then along one of the two edges 2-4.
One of them contains range [3-5], that is, we can pass through with numbers 3, 4, 5. So the loyalty of such path is 3.
If we go along edge 2-4 with range [2-7], then we can pass through with numbers 2, 3, 4, 5, 6, 7. The loyalty is 6. That is the answer.
The edge 1-2 have no influence on the answer because its range includes both ranges of the following edges. |
import sys
sys.setrecursionlimit(100000)
def dfs(v, l, r, mark):
if v == n - 1:
return True
mark[v] = True
for u, e in graph[v]:
if not mark[u] and edges[e][0] <= l <= r <= edges[e][1]:
if dfs(u, l, r, mark):
return True
return False
n, m = map(int, raw_input().split())
graph = [[] for _ in range(n)]
edges = []
events = []
for i in range(m):
ak, bk, lk, rk = map(int, raw_input().split())
edges.append((lk, rk))
graph[ak - 1].append((bk - 1, i))
graph[bk - 1].append((ak - 1, i))
events.append(lk)
events.append(rk)
events = list(set(events))
events.sort()
l = 0
r = 0
resp = 0
while r < len(events):
if r < l:
r = l
while r < len(events) and dfs(0, events[l], events[r], [False] * n):
resp = max(resp, events[r] - events[l] + 1)
r += 1
l += 1
if resp > 0:
print(resp)
else:
print('Nice work, Dima!')
| 1Python2
| {
"input": [
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"2 1\n1 2 1 1\n",
"1000 0\n",
"10 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 1 4\n4 5 1 3\n5 6 1 3\n",
"1100 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 1 6\n4 5 1 3\n5 6 1 3\n",
"4 4\n1 2 1 10\n2 2 3 5\n1 3 1 5\n2 4 2 7\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 2 10\n",
"9 0\n",
"1101 0\n",
"5 0\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 1 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 6\n1 1 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 2 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 27681\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"1010 0\n",
"6 6\n1 2 1 10\n2 3 1 8\n3 6 1 1\n1 4 1 4\n4 5 1 3\n5 6 1 3\n",
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 4\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 10\n",
"1001 0\n",
"4 0\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2748 18096\n5 3 10717 32306\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 7\n",
"5 5\n1 5 9403 40347\n1 3 13851 27681\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"6 6\n1 2 1 10\n3 3 1 10\n3 6 1 1\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 5\n1 5 9403 40347\n1 3 13851 21342\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"6 6\n1 2 1 10\n3 3 1 10\n3 6 1 2\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 559824\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 5\n1 5 9403 40347\n1 3 25167 21342\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"5 6\n1 2 1 10\n2 5 11 10\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"6 6\n1 2 1 10\n3 3 1 6\n3 6 1 2\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 2 19888 29314\n4 5 1315 559824\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 6\n1 2 1 10\n2 5 11 6\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 29314\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 5\n2 4 3 10\n",
"5 6\n1 2 1 9\n2 5 11 6\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 8\n2 4 3 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 38403\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 4\n2 4 3 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 1 2876 18096\n5 3 10717 38403\n",
"7 4\n2 2 1 3\n2 5 3 5\n1 5 1 4\n2 4 3 10\n"
],
"output": [
"6\n",
"Nice work, Dima!\n",
"30945\n",
"1\n",
"Nice work, Dima!\n",
"Nice work, Dima!\n",
"3\n",
"Nice work, Dima!",
"3",
"6",
"30945",
"2",
"4",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"3",
"3",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"30945",
"2",
"30945",
"Nice work, Dima!",
"30945",
"4",
"2",
"30945",
"Nice work, Dima!",
"30945",
"4",
"2",
"30945",
"Nice work, Dima!",
"4",
"30945",
"Nice work, Dima!",
"4",
"30945",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"30945",
"Nice work, Dima!"
]
} | 2CODEFORCES
|
366_D. Dima and Trap Graph_1285 | Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get criminal...
Dima constructed a trap graph. He shouted: "Hey Seryozha, have a look at my cool graph!" to get his roommate interested and kicked him into the first node.
A trap graph is an undirected graph consisting of n nodes and m edges. For edge number k, Dima denoted a range of integers from lk to rk (lk β€ rk). In order to get out of the trap graph, Seryozha initially (before starting his movements) should pick some integer (let's call it x), then Seryozha must go some way from the starting node with number 1 to the final node with number n. At that, Seryozha can go along edge k only if lk β€ x β€ rk.
Seryozha is a mathematician. He defined the loyalty of some path from the 1-st node to the n-th one as the number of integers x, such that if he initially chooses one of them, he passes the whole path. Help Seryozha find the path of maximum loyalty and return to his room as quickly as possible!
Input
The first line of the input contains two integers n and m (2 β€ n β€ 103, 0 β€ m β€ 3Β·103). Then follow m lines describing the edges. Each line contains four integers ak, bk, lk and rk (1 β€ ak, bk β€ n, 1 β€ lk β€ rk β€ 106). The numbers mean that in the trap graph the k-th edge connects nodes ak and bk, this edge corresponds to the range of integers from lk to rk.
Note that the given graph can have loops and multiple edges.
Output
In a single line of the output print an integer β the maximum loyalty among all paths from the first node to the n-th one. If such paths do not exist or the maximum loyalty equals 0, print in a single line "Nice work, Dima!" without the quotes.
Examples
Input
4 4
1 2 1 10
2 4 3 5
1 3 1 5
2 4 2 7
Output
6
Input
5 6
1 2 1 10
2 5 11 20
1 4 2 5
1 3 10 11
3 4 12 10000
4 5 6 6
Output
Nice work, Dima!
Note
Explanation of the first example.
Overall, we have 2 ways to get from node 1 to node 4: first you must go along the edge 1-2 with range [1-10], then along one of the two edges 2-4.
One of them contains range [3-5], that is, we can pass through with numbers 3, 4, 5. So the loyalty of such path is 3.
If we go along edge 2-4 with range [2-7], then we can pass through with numbers 2, 3, 4, 5, 6, 7. The loyalty is 6. That is the answer.
The edge 1-2 have no influence on the answer because its range includes both ranges of the following edges. | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int maxm = 3000 + 10;
struct Edge {
int v, l, r, next;
Edge(int v = 0, int l = 0, int r = 0, int next = 0)
: v(v), l(l), r(r), next(next) {}
} edges[maxm << 1];
int head[maxn], nEdge, n, m;
int a[maxm], b[maxm];
int vis[maxn], cnt;
void AddEdges(int u, int v, int l, int r) {
edges[++nEdge] = Edge(v, l, r, head[u]);
head[u] = nEdge;
edges[++nEdge] = Edge(u, l, r, head[v]);
head[v] = nEdge;
}
bool dfs(int u, int L, int R) {
if (u == n) return true;
vis[u] = cnt;
for (int k = head[u]; k != -1; k = edges[k].next) {
int v = edges[k].v;
if (vis[v] == cnt) continue;
if (L < edges[k].l || R > edges[k].r) continue;
if (dfs(v, L, R)) return true;
}
return false;
}
int solve() {
int ans = 0;
cnt = 0;
memset(vis, 0, sizeof(vis));
sort(a, a + m);
sort(b, b + m);
int L, R, mid;
for (int i = 0; i < m; ++i) {
L = a[i];
R = b[m - 1];
while (L <= R) {
mid = (L + R) >> 1;
++cnt;
if (dfs(1, a[i], mid)) {
ans = max(ans, mid - a[i] + 1);
L = mid + 1;
} else
R = mid - 1;
}
}
return ans;
}
int main() {
scanf("%d%d", &n, &m);
memset(head, 0xff, sizeof(head));
nEdge = -1;
int u, v, l, r;
for (int i = 0; i < m; ++i) {
scanf("%d%d%d%d", &u, &v, &l, &r);
AddEdges(u, v, l, r);
a[i] = l;
b[i] = r;
}
int ans = solve();
if (ans == 0)
printf("Nice work, Dima!\n");
else
printf("%d\n", ans);
return 0;
}
| 2C++
| {
"input": [
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"2 1\n1 2 1 1\n",
"1000 0\n",
"10 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 1 4\n4 5 1 3\n5 6 1 3\n",
"1100 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 1 6\n4 5 1 3\n5 6 1 3\n",
"4 4\n1 2 1 10\n2 2 3 5\n1 3 1 5\n2 4 2 7\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 2 10\n",
"9 0\n",
"1101 0\n",
"5 0\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 1 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 6\n1 1 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 2 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 27681\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"1010 0\n",
"6 6\n1 2 1 10\n2 3 1 8\n3 6 1 1\n1 4 1 4\n4 5 1 3\n5 6 1 3\n",
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 4\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 10\n",
"1001 0\n",
"4 0\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2748 18096\n5 3 10717 32306\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 7\n",
"5 5\n1 5 9403 40347\n1 3 13851 27681\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"6 6\n1 2 1 10\n3 3 1 10\n3 6 1 1\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 5\n1 5 9403 40347\n1 3 13851 21342\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"6 6\n1 2 1 10\n3 3 1 10\n3 6 1 2\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 559824\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 5\n1 5 9403 40347\n1 3 25167 21342\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"5 6\n1 2 1 10\n2 5 11 10\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"6 6\n1 2 1 10\n3 3 1 6\n3 6 1 2\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 2 19888 29314\n4 5 1315 559824\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 6\n1 2 1 10\n2 5 11 6\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 29314\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 5\n2 4 3 10\n",
"5 6\n1 2 1 9\n2 5 11 6\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 8\n2 4 3 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 38403\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 4\n2 4 3 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 1 2876 18096\n5 3 10717 38403\n",
"7 4\n2 2 1 3\n2 5 3 5\n1 5 1 4\n2 4 3 10\n"
],
"output": [
"6\n",
"Nice work, Dima!\n",
"30945\n",
"1\n",
"Nice work, Dima!\n",
"Nice work, Dima!\n",
"3\n",
"Nice work, Dima!",
"3",
"6",
"30945",
"2",
"4",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"3",
"3",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"30945",
"2",
"30945",
"Nice work, Dima!",
"30945",
"4",
"2",
"30945",
"Nice work, Dima!",
"30945",
"4",
"2",
"30945",
"Nice work, Dima!",
"4",
"30945",
"Nice work, Dima!",
"4",
"30945",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"30945",
"Nice work, Dima!"
]
} | 2CODEFORCES
|
366_D. Dima and Trap Graph_1286 | Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get criminal...
Dima constructed a trap graph. He shouted: "Hey Seryozha, have a look at my cool graph!" to get his roommate interested and kicked him into the first node.
A trap graph is an undirected graph consisting of n nodes and m edges. For edge number k, Dima denoted a range of integers from lk to rk (lk β€ rk). In order to get out of the trap graph, Seryozha initially (before starting his movements) should pick some integer (let's call it x), then Seryozha must go some way from the starting node with number 1 to the final node with number n. At that, Seryozha can go along edge k only if lk β€ x β€ rk.
Seryozha is a mathematician. He defined the loyalty of some path from the 1-st node to the n-th one as the number of integers x, such that if he initially chooses one of them, he passes the whole path. Help Seryozha find the path of maximum loyalty and return to his room as quickly as possible!
Input
The first line of the input contains two integers n and m (2 β€ n β€ 103, 0 β€ m β€ 3Β·103). Then follow m lines describing the edges. Each line contains four integers ak, bk, lk and rk (1 β€ ak, bk β€ n, 1 β€ lk β€ rk β€ 106). The numbers mean that in the trap graph the k-th edge connects nodes ak and bk, this edge corresponds to the range of integers from lk to rk.
Note that the given graph can have loops and multiple edges.
Output
In a single line of the output print an integer β the maximum loyalty among all paths from the first node to the n-th one. If such paths do not exist or the maximum loyalty equals 0, print in a single line "Nice work, Dima!" without the quotes.
Examples
Input
4 4
1 2 1 10
2 4 3 5
1 3 1 5
2 4 2 7
Output
6
Input
5 6
1 2 1 10
2 5 11 20
1 4 2 5
1 3 10 11
3 4 12 10000
4 5 6 6
Output
Nice work, Dima!
Note
Explanation of the first example.
Overall, we have 2 ways to get from node 1 to node 4: first you must go along the edge 1-2 with range [1-10], then along one of the two edges 2-4.
One of them contains range [3-5], that is, we can pass through with numbers 3, 4, 5. So the loyalty of such path is 3.
If we go along edge 2-4 with range [2-7], then we can pass through with numbers 2, 3, 4, 5, 6, 7. The loyalty is 6. That is the answer.
The edge 1-2 have no influence on the answer because its range includes both ranges of the following edges. |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
public class DimaAndTrapGraphFaster {
static List<Edge>[] edges;
static int N;
static int M;
static long[] lefts;
static long[] rights;
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
StringTokenizer tk = tk(in.readLine());
N = Integer.parseInt(tk.nextToken());
M = Integer.parseInt(tk.nextToken());
edges = new List[N];
for(int i=0;i<N;i++)edges[i] = new ArrayList();
lefts = new long[M];
rights = new long[M];
for(int i=0;i<M;i++) {
tk=tk(in.readLine());
int a = Integer.parseInt(tk.nextToken())-1;
int b = Integer.parseInt(tk.nextToken())-1;
int l = Integer.parseInt(tk.nextToken());
int r = Integer.parseInt(tk.nextToken());
lefts[i] = l;
rights[i] = r;
edges[a].add(new Edge(a,b,l,r));
edges[b].add(new Edge(b,a,l,r));
}
int maxLength = -1;
int li = 0;
int ri = 0;
visit = new int[N];
Arrays.sort(lefts);
Arrays.sort(rights);
while(true) {
if(li>=M || ri>=M)break;
int l = (int)lefts[li];
int r = (int)rights[ri];
if(check(l,r)) {
maxLength = Math.max(maxLength, r-l+1);
ri++;
} else {
li++;
}
}
if(maxLength <= 0) {
out.println("Nice work, Dima!");
} else {
out.println(maxLength);
}
out.close();
}
static int id = 0;
static int[] visit;
static int sl;
static int sr;
static boolean check(int l, int r) {
if(r<l)return true;
sl = l;
sr = r;
id++;
return dfs(0);
}
static boolean dfs(int cur) {
if(cur == N-1) return true;
visit[cur] = id;
for(Edge e : edges[cur]) {
if(visit[e.to] != id && sl >= e.l && sr <= e.r) {
if(dfs(e.to)){
return true;
}
}
}
return false;
}
static class Edge {
public int from;
public int to;
public int l;
public int r;
public Edge(int from, int to, int l, int r) {
this.from = from;
this.to = to;
this.l = l;
this.r = r;
}
}
static StringTokenizer tk(String s){return new StringTokenizer(s);}
}
| 4JAVA
| {
"input": [
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"2 1\n1 2 1 1\n",
"1000 0\n",
"10 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 1 4\n4 5 1 3\n5 6 1 3\n",
"1100 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 1 6\n4 5 1 3\n5 6 1 3\n",
"4 4\n1 2 1 10\n2 2 3 5\n1 3 1 5\n2 4 2 7\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 2 10\n",
"9 0\n",
"1101 0\n",
"5 0\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 1 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 6\n1 1 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 2 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 27681\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"1010 0\n",
"6 6\n1 2 1 10\n2 3 1 8\n3 6 1 1\n1 4 1 4\n4 5 1 3\n5 6 1 3\n",
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 4\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 10\n",
"1001 0\n",
"4 0\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2748 18096\n5 3 10717 32306\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 7\n",
"5 5\n1 5 9403 40347\n1 3 13851 27681\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"6 6\n1 2 1 10\n3 3 1 10\n3 6 1 1\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n1 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 5\n1 5 9403 40347\n1 3 13851 21342\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"6 6\n1 2 1 10\n3 3 1 10\n3 6 1 2\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 559824\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 10\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 5\n1 5 9403 40347\n1 3 25167 21342\n4 5 295 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"5 6\n1 2 1 10\n2 5 11 10\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"6 6\n1 2 1 10\n3 3 1 6\n3 6 1 2\n1 4 2 6\n4 5 1 3\n5 6 1 3\n",
"5 5\n1 5 9403 40347\n1 2 19888 29314\n4 5 1315 559824\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 5\n2 4 2 10\n",
"5 6\n1 2 1 10\n2 5 11 6\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 29314\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 5\n2 4 3 10\n",
"5 6\n1 2 1 9\n2 5 11 6\n1 4 2 5\n1 3 17 11\n3 4 12 10000\n4 5 2 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 32306\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 8\n2 4 3 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 5 2876 18096\n5 3 10717 38403\n",
"7 4\n2 2 1 3\n2 4 3 5\n1 5 1 4\n2 4 3 10\n",
"5 5\n1 5 9403 40347\n1 2 19888 10304\n4 5 1315 168654\n3 1 2876 18096\n5 3 10717 38403\n",
"7 4\n2 2 1 3\n2 5 3 5\n1 5 1 4\n2 4 3 10\n"
],
"output": [
"6\n",
"Nice work, Dima!\n",
"30945\n",
"1\n",
"Nice work, Dima!\n",
"Nice work, Dima!\n",
"3\n",
"Nice work, Dima!",
"3",
"6",
"30945",
"2",
"4",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"3",
"3",
"Nice work, Dima!",
"Nice work, Dima!",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"30945",
"2",
"30945",
"Nice work, Dima!",
"30945",
"4",
"2",
"30945",
"Nice work, Dima!",
"30945",
"4",
"2",
"30945",
"Nice work, Dima!",
"4",
"30945",
"Nice work, Dima!",
"4",
"30945",
"Nice work, Dima!",
"30945",
"Nice work, Dima!",
"30945",
"Nice work, Dima!"
]
} | 2CODEFORCES
|
38_C. Blinds_1287 | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they may not have the same length (it is even possible for them to have different lengths)
Every stripe can be cut into two or more parts. The cuttings are made perpendicularly to the side along which the length is measured. Thus the cuttings do not change the width of a stripe but each of the resulting pieces has a lesser length (the sum of which is equal to the length of the initial stripe)
After all the cuttings the blinds are constructed through consecutive joining of several parts, similar in length, along sides, along which length is measured. Also, apart from the resulting pieces an initial stripe can be used as a blind if it hasn't been cut. It is forbidden to construct blinds in any other way.
Thus, if the blinds consist of k pieces each d in length, then they are of form of a rectangle of k Γ d bourlemeters.
Your task is to find for what window possessing the largest possible area the blinds can be made from the given stripes if on technical grounds it is forbidden to use pieces shorter than l bourlemeter. The window is of form of a rectangle with side lengths as positive integers.
Input
The first output line contains two space-separated integers n and l (1 β€ n, l β€ 100). They are the number of stripes in the warehouse and the minimal acceptable length of a blind stripe in bourlemeters. The second line contains space-separated n integers ai. They are the lengths of initial stripes in bourlemeters (1 β€ ai β€ 100).
Output
Print the single number β the maximal area of the window in square bourlemeters that can be completely covered. If no window with a positive area that can be covered completely without breaking any of the given rules exist, then print the single number 0.
Examples
Input
4 2
1 2 3 4
Output
8
Input
5 3
5 5 7 3 1
Output
15
Input
2 3
1 2
Output
0
Note
In the first sample test the required window is 2 Γ 4 in size and the blinds for it consist of 4 parts, each 2 bourlemeters long. One of the parts is the initial stripe with the length of 2, the other one is a part of a cut stripe with the length of 3 and the two remaining stripes are parts of a stripe with the length of 4 cut in halves. | #!/usr/bin/env python
from sys import stdin
N, L = map(int, stdin.readline().split())
A = map(int, stdin.readline().split())
mx = max(A)
res = 0
for l in xrange(L, mx+1):
n = 0
for x in A:
n += int(x / l)
res = max(res, n * l)
print res
| 1Python2
| {
"input": [
"5 3\n5 5 7 3 1\n",
"4 2\n1 2 3 4\n",
"2 3\n1 2\n",
"93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 84 59 68 87 26 91 10 54 41 74 71 74 62 24\n",
"15 6\n1 6 6 5 2 10 4 4 7 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 11 7 9 11 6 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 2 3 4 3 3 3 3 2 1 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 36 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 28 58 83 12 3 77 34 33 73 15 35 29 8 3 21 63 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 9 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 7 7 5 1 10 9 10\n",
"2 2\n3 3\n",
"10 2\n6 3 1 1 6 4 6 1 6 3\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 18 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 4 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 2 6 6 1 2 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 80 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 55 62 76 81 27 52 55 67 28 65 71\n",
"35 3\n13 12 38 45 71 61 42 75 58 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n42 89 35 19 51 41 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 48 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 25 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 3\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 29 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 76 10 69 49 25 9 77 30\n",
"25 20\n10 8 4 6 12 14 19 18 19 9 21 16 16 15 10 15 12 12 18 18 9 22 12 14 14\n",
"98 14\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 31 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 10 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 30 33\n",
"7 4\n3 2 1 1 1 3 2\n",
"50 70\n60 21 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 61 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 32 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 76 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 1 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 1 2 1 2 1 1 2 2 2\n",
"70 12\n6 8 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 8 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 1 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"55 12\n15 5 11 16 17 3 5 28 19 15 1 9 5 26 25 3 14 14 33 12 3 21 16 30 22 18 7 16 24 28 2 17 24 25 16 16 31 9 11 9 6 13 25 23 32 18 4 21 10 32 11 5 4 32 14\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 1 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 7 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 14 33 23 25 23 11 19 19 27 27 3 20 17 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 71 68 89 47 59 5 74 92 43 100 15 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n13 3 6 11 6 11 9 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 17 25 17 38 39 37 23 37 11 6 15 43 4 15 44 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 46 48 40 69 95 10 61 47\n",
"15 6\n1 6 6 5 2 10 4 4 14 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 11 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 2 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 28 58 83 12 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 7 7 5 1 10 9 10\n",
"2 2\n3 2\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 18 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 2 6 6 1 4 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 92 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 55 62 76 81 27 52 55 67 28 65 71\n",
"35 3\n13 12 38 45 71 65 42 75 58 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n82 89 35 19 51 41 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 35 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 25 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 1\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 0 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 76 10 69 49 25 9 77 30\n",
"98 23\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 31 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 3 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 30 33\n",
"50 70\n60 21 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 64 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 61 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 76 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 0 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 1 2 1 2 1 1 2 2 2\n",
"70 12\n6 8 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 7 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 0 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 1 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 2 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 13 33 23 25 23 11 19 19 27 27 3 20 17 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 54 68 89 47 59 5 74 92 43 100 15 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n13 3 6 11 6 11 0 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 17 25 17 38 39 37 23 37 11 6 15 43 4 15 84 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 5 48 40 69 95 10 61 47\n",
"5 3\n5 5 7 5 1\n",
"15 6\n1 6 6 5 2 1 4 4 14 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 21 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 16 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"35 3\n13 12 38 45 71 65 42 75 93 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n82 89 35 19 51 28 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 35 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 7 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 2\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 0 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 43 10 69 49 25 9 77 30\n",
"25 20\n10 8 4 6 12 14 37 18 19 9 21 16 11 15 10 15 12 12 18 18 9 22 12 14 14\n",
"98 23\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 53 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 61 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 39 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 0 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 0 2 1 2 1 1 2 2 2\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 13 33 23 25 23 11 19 19 27 27 3 20 30 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 54 68 89 47 59 5 74 92 43 100 6 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n10 3 6 11 6 11 0 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 16 25 17 38 39 37 23 37 11 6 15 43 4 15 84 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"5 3\n5 5 3 5 1\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 8 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 14 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 16 9 33 10 37 20 8 7 42 8 17 0 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 1 10 6 1 4 5 5 6\n",
"25 20\n10 8 4 6 12 14 19 18 19 9 21 16 11 15 10 15 12 12 18 18 9 22 12 14 14\n",
"4 2\n1 1 3 4\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 3 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 8 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 13 58 83 12 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 0 7 5 1 10 9 10\n",
"10 1\n1 2 2 10 6 1 4 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 92 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 22 62 76 81 27 52 55 67 28 65 71\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 3 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 27 33\n",
"50 70\n60 13 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 64 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"70 12\n6 5 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 7 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 0 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 0 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 2 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 2 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 5 48 42 69 95 10 61 47\n",
"15 6\n1 6 6 5 2 1 4 4 14 15 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 21 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 9 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 3 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 3 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 13 58 83 5 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 4 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 0 7 5 1 10 9 10\n"
],
"output": [
"15\n",
"8\n",
"0\n",
"4110\n",
"36\n",
"245\n",
"66\n",
"3961\n",
"1089\n",
"225\n",
"6\n",
"33\n",
"1810\n",
"36\n",
"2030\n",
"1236\n",
"2240\n",
"2796\n",
"8\n",
"4173\n",
"42\n",
"1876\n",
"817\n",
"0\n",
"280\n",
"3492\n",
"84\n",
"756\n",
"92\n",
"588\n",
"306\n",
"672\n",
"4978\n",
"136\n",
"1360",
"1455",
"42\n",
"245\n",
"66\n",
"3961\n",
"1089\n",
"216\n",
"4\n",
"1808\n",
"38\n",
"2030\n",
"1239\n",
"2280\n",
"2782\n",
"6\n",
"4147\n",
"1472\n",
"817\n",
"280\n",
"3522\n",
"83\n",
"756\n",
"92\n",
"306\n",
"672\n",
"4962\n",
"128\n",
"1394\n",
"1410\n",
"20\n",
"36\n",
"259\n",
"1806\n",
"1275\n",
"2260\n",
"2764\n",
"8\n",
"4121\n",
"63\n",
"1495\n",
"3486\n",
"82\n",
"700\n",
"4954\n",
"126\n",
"1377\n",
"15\n",
"3944\n",
"1805\n",
"41\n",
"42\n",
"6\n",
"66\n",
"3961\n",
"1089\n",
"216\n",
"42\n",
"2030\n",
"817\n",
"280\n",
"756\n",
"92\n",
"306\n",
"1410\n",
"42\n",
"259\n",
"66\n",
"1089\n",
"216\n"
]
} | 2CODEFORCES
|
38_C. Blinds_1288 | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they may not have the same length (it is even possible for them to have different lengths)
Every stripe can be cut into two or more parts. The cuttings are made perpendicularly to the side along which the length is measured. Thus the cuttings do not change the width of a stripe but each of the resulting pieces has a lesser length (the sum of which is equal to the length of the initial stripe)
After all the cuttings the blinds are constructed through consecutive joining of several parts, similar in length, along sides, along which length is measured. Also, apart from the resulting pieces an initial stripe can be used as a blind if it hasn't been cut. It is forbidden to construct blinds in any other way.
Thus, if the blinds consist of k pieces each d in length, then they are of form of a rectangle of k Γ d bourlemeters.
Your task is to find for what window possessing the largest possible area the blinds can be made from the given stripes if on technical grounds it is forbidden to use pieces shorter than l bourlemeter. The window is of form of a rectangle with side lengths as positive integers.
Input
The first output line contains two space-separated integers n and l (1 β€ n, l β€ 100). They are the number of stripes in the warehouse and the minimal acceptable length of a blind stripe in bourlemeters. The second line contains space-separated n integers ai. They are the lengths of initial stripes in bourlemeters (1 β€ ai β€ 100).
Output
Print the single number β the maximal area of the window in square bourlemeters that can be completely covered. If no window with a positive area that can be covered completely without breaking any of the given rules exist, then print the single number 0.
Examples
Input
4 2
1 2 3 4
Output
8
Input
5 3
5 5 7 3 1
Output
15
Input
2 3
1 2
Output
0
Note
In the first sample test the required window is 2 Γ 4 in size and the blinds for it consist of 4 parts, each 2 bourlemeters long. One of the parts is the initial stripe with the length of 2, the other one is a part of a cut stripe with the length of 3 and the two remaining stripes are parts of a stripe with the length of 4 cut in halves. | #include <bits/stdc++.h>
using namespace std;
int n, l;
vector<int> v;
int main() {
scanf("%d %d", &n, &l);
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
if (x >= l) v.push_back(x);
}
sort(v.begin(), v.end());
int ms = 0;
for (int i = 0; i < v.size(); i++) {
int count = 0;
for (int j = i; j < v.size(); j++) count += v[j] / v[i];
ms = max(ms, v[i] * count);
}
int count = 0;
for (int j = 0; j < v.size(); j++) count += v[j] / l;
ms = max(ms, l * count);
printf("%d", ms);
return 0;
}
| 2C++
| {
"input": [
"5 3\n5 5 7 3 1\n",
"4 2\n1 2 3 4\n",
"2 3\n1 2\n",
"93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 84 59 68 87 26 91 10 54 41 74 71 74 62 24\n",
"15 6\n1 6 6 5 2 10 4 4 7 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 11 7 9 11 6 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 2 3 4 3 3 3 3 2 1 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 36 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 28 58 83 12 3 77 34 33 73 15 35 29 8 3 21 63 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 9 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 7 7 5 1 10 9 10\n",
"2 2\n3 3\n",
"10 2\n6 3 1 1 6 4 6 1 6 3\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 18 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 4 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 2 6 6 1 2 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 80 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 55 62 76 81 27 52 55 67 28 65 71\n",
"35 3\n13 12 38 45 71 61 42 75 58 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n42 89 35 19 51 41 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 48 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 25 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 3\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 29 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 76 10 69 49 25 9 77 30\n",
"25 20\n10 8 4 6 12 14 19 18 19 9 21 16 16 15 10 15 12 12 18 18 9 22 12 14 14\n",
"98 14\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 31 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 10 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 30 33\n",
"7 4\n3 2 1 1 1 3 2\n",
"50 70\n60 21 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 61 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 32 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 76 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 1 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 1 2 1 2 1 1 2 2 2\n",
"70 12\n6 8 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 8 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 1 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"55 12\n15 5 11 16 17 3 5 28 19 15 1 9 5 26 25 3 14 14 33 12 3 21 16 30 22 18 7 16 24 28 2 17 24 25 16 16 31 9 11 9 6 13 25 23 32 18 4 21 10 32 11 5 4 32 14\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 1 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 7 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 14 33 23 25 23 11 19 19 27 27 3 20 17 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 71 68 89 47 59 5 74 92 43 100 15 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n13 3 6 11 6 11 9 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 17 25 17 38 39 37 23 37 11 6 15 43 4 15 44 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 46 48 40 69 95 10 61 47\n",
"15 6\n1 6 6 5 2 10 4 4 14 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 11 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 2 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 28 58 83 12 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 7 7 5 1 10 9 10\n",
"2 2\n3 2\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 18 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 2 6 6 1 4 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 92 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 55 62 76 81 27 52 55 67 28 65 71\n",
"35 3\n13 12 38 45 71 65 42 75 58 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n82 89 35 19 51 41 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 35 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 25 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 1\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 0 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 76 10 69 49 25 9 77 30\n",
"98 23\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 31 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 3 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 30 33\n",
"50 70\n60 21 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 64 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 61 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 76 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 0 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 1 2 1 2 1 1 2 2 2\n",
"70 12\n6 8 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 7 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 0 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 1 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 2 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 13 33 23 25 23 11 19 19 27 27 3 20 17 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 54 68 89 47 59 5 74 92 43 100 15 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n13 3 6 11 6 11 0 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 17 25 17 38 39 37 23 37 11 6 15 43 4 15 84 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 5 48 40 69 95 10 61 47\n",
"5 3\n5 5 7 5 1\n",
"15 6\n1 6 6 5 2 1 4 4 14 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 21 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 16 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"35 3\n13 12 38 45 71 65 42 75 93 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n82 89 35 19 51 28 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 35 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 7 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 2\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 0 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 43 10 69 49 25 9 77 30\n",
"25 20\n10 8 4 6 12 14 37 18 19 9 21 16 11 15 10 15 12 12 18 18 9 22 12 14 14\n",
"98 23\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 53 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 61 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 39 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 0 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 0 2 1 2 1 1 2 2 2\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 13 33 23 25 23 11 19 19 27 27 3 20 30 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 54 68 89 47 59 5 74 92 43 100 6 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n10 3 6 11 6 11 0 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 16 25 17 38 39 37 23 37 11 6 15 43 4 15 84 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"5 3\n5 5 3 5 1\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 8 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 14 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 16 9 33 10 37 20 8 7 42 8 17 0 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 1 10 6 1 4 5 5 6\n",
"25 20\n10 8 4 6 12 14 19 18 19 9 21 16 11 15 10 15 12 12 18 18 9 22 12 14 14\n",
"4 2\n1 1 3 4\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 3 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 8 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 13 58 83 12 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 0 7 5 1 10 9 10\n",
"10 1\n1 2 2 10 6 1 4 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 92 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 22 62 76 81 27 52 55 67 28 65 71\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 3 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 27 33\n",
"50 70\n60 13 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 64 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"70 12\n6 5 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 7 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 0 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 0 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 2 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 2 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 5 48 42 69 95 10 61 47\n",
"15 6\n1 6 6 5 2 1 4 4 14 15 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 21 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 9 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 3 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 3 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 13 58 83 5 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 4 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 0 7 5 1 10 9 10\n"
],
"output": [
"15\n",
"8\n",
"0\n",
"4110\n",
"36\n",
"245\n",
"66\n",
"3961\n",
"1089\n",
"225\n",
"6\n",
"33\n",
"1810\n",
"36\n",
"2030\n",
"1236\n",
"2240\n",
"2796\n",
"8\n",
"4173\n",
"42\n",
"1876\n",
"817\n",
"0\n",
"280\n",
"3492\n",
"84\n",
"756\n",
"92\n",
"588\n",
"306\n",
"672\n",
"4978\n",
"136\n",
"1360",
"1455",
"42\n",
"245\n",
"66\n",
"3961\n",
"1089\n",
"216\n",
"4\n",
"1808\n",
"38\n",
"2030\n",
"1239\n",
"2280\n",
"2782\n",
"6\n",
"4147\n",
"1472\n",
"817\n",
"280\n",
"3522\n",
"83\n",
"756\n",
"92\n",
"306\n",
"672\n",
"4962\n",
"128\n",
"1394\n",
"1410\n",
"20\n",
"36\n",
"259\n",
"1806\n",
"1275\n",
"2260\n",
"2764\n",
"8\n",
"4121\n",
"63\n",
"1495\n",
"3486\n",
"82\n",
"700\n",
"4954\n",
"126\n",
"1377\n",
"15\n",
"3944\n",
"1805\n",
"41\n",
"42\n",
"6\n",
"66\n",
"3961\n",
"1089\n",
"216\n",
"42\n",
"2030\n",
"817\n",
"280\n",
"756\n",
"92\n",
"306\n",
"1410\n",
"42\n",
"259\n",
"66\n",
"1089\n",
"216\n"
]
} | 2CODEFORCES
|
38_C. Blinds_1289 | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they may not have the same length (it is even possible for them to have different lengths)
Every stripe can be cut into two or more parts. The cuttings are made perpendicularly to the side along which the length is measured. Thus the cuttings do not change the width of a stripe but each of the resulting pieces has a lesser length (the sum of which is equal to the length of the initial stripe)
After all the cuttings the blinds are constructed through consecutive joining of several parts, similar in length, along sides, along which length is measured. Also, apart from the resulting pieces an initial stripe can be used as a blind if it hasn't been cut. It is forbidden to construct blinds in any other way.
Thus, if the blinds consist of k pieces each d in length, then they are of form of a rectangle of k Γ d bourlemeters.
Your task is to find for what window possessing the largest possible area the blinds can be made from the given stripes if on technical grounds it is forbidden to use pieces shorter than l bourlemeter. The window is of form of a rectangle with side lengths as positive integers.
Input
The first output line contains two space-separated integers n and l (1 β€ n, l β€ 100). They are the number of stripes in the warehouse and the minimal acceptable length of a blind stripe in bourlemeters. The second line contains space-separated n integers ai. They are the lengths of initial stripes in bourlemeters (1 β€ ai β€ 100).
Output
Print the single number β the maximal area of the window in square bourlemeters that can be completely covered. If no window with a positive area that can be covered completely without breaking any of the given rules exist, then print the single number 0.
Examples
Input
4 2
1 2 3 4
Output
8
Input
5 3
5 5 7 3 1
Output
15
Input
2 3
1 2
Output
0
Note
In the first sample test the required window is 2 Γ 4 in size and the blinds for it consist of 4 parts, each 2 bourlemeters long. One of the parts is the initial stripe with the length of 2, the other one is a part of a cut stripe with the length of 3 and the two remaining stripes are parts of a stripe with the length of 4 cut in halves. | m, l = map(int, input().split())
a = list(map(int, input().split()))
print(max(i * sum(ai // i for ai in a) for i in range(l, 101))) | 3Python3
| {
"input": [
"5 3\n5 5 7 3 1\n",
"4 2\n1 2 3 4\n",
"2 3\n1 2\n",
"93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 84 59 68 87 26 91 10 54 41 74 71 74 62 24\n",
"15 6\n1 6 6 5 2 10 4 4 7 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 11 7 9 11 6 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 2 3 4 3 3 3 3 2 1 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 36 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 28 58 83 12 3 77 34 33 73 15 35 29 8 3 21 63 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 9 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 7 7 5 1 10 9 10\n",
"2 2\n3 3\n",
"10 2\n6 3 1 1 6 4 6 1 6 3\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 18 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 4 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 2 6 6 1 2 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 80 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 55 62 76 81 27 52 55 67 28 65 71\n",
"35 3\n13 12 38 45 71 61 42 75 58 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n42 89 35 19 51 41 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 48 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 25 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 3\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 29 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 76 10 69 49 25 9 77 30\n",
"25 20\n10 8 4 6 12 14 19 18 19 9 21 16 16 15 10 15 12 12 18 18 9 22 12 14 14\n",
"98 14\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 31 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 10 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 30 33\n",
"7 4\n3 2 1 1 1 3 2\n",
"50 70\n60 21 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 61 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 32 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 76 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 1 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 1 2 1 2 1 1 2 2 2\n",
"70 12\n6 8 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 8 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 1 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"55 12\n15 5 11 16 17 3 5 28 19 15 1 9 5 26 25 3 14 14 33 12 3 21 16 30 22 18 7 16 24 28 2 17 24 25 16 16 31 9 11 9 6 13 25 23 32 18 4 21 10 32 11 5 4 32 14\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 1 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 7 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 14 33 23 25 23 11 19 19 27 27 3 20 17 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 71 68 89 47 59 5 74 92 43 100 15 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n13 3 6 11 6 11 9 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 17 25 17 38 39 37 23 37 11 6 15 43 4 15 44 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 46 48 40 69 95 10 61 47\n",
"15 6\n1 6 6 5 2 10 4 4 14 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 11 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 2 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 28 58 83 12 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 7 7 5 1 10 9 10\n",
"2 2\n3 2\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 18 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 2 6 6 1 4 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 92 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 55 62 76 81 27 52 55 67 28 65 71\n",
"35 3\n13 12 38 45 71 65 42 75 58 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n82 89 35 19 51 41 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 35 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 25 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 1\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 0 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 76 10 69 49 25 9 77 30\n",
"98 23\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 31 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 3 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 30 33\n",
"50 70\n60 21 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 64 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 61 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 76 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 0 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 1 2 1 2 1 1 2 2 2\n",
"70 12\n6 8 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 7 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 0 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 1 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 2 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 13 33 23 25 23 11 19 19 27 27 3 20 17 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 54 68 89 47 59 5 74 92 43 100 15 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n13 3 6 11 6 11 0 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 17 25 17 38 39 37 23 37 11 6 15 43 4 15 84 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 5 48 40 69 95 10 61 47\n",
"5 3\n5 5 7 5 1\n",
"15 6\n1 6 6 5 2 1 4 4 14 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 21 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 16 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"35 3\n13 12 38 45 71 65 42 75 93 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n82 89 35 19 51 28 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 35 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 7 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 2\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 0 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 43 10 69 49 25 9 77 30\n",
"25 20\n10 8 4 6 12 14 37 18 19 9 21 16 11 15 10 15 12 12 18 18 9 22 12 14 14\n",
"98 23\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 53 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 61 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 39 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 0 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 0 2 1 2 1 1 2 2 2\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 13 33 23 25 23 11 19 19 27 27 3 20 30 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 54 68 89 47 59 5 74 92 43 100 6 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n10 3 6 11 6 11 0 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 16 25 17 38 39 37 23 37 11 6 15 43 4 15 84 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"5 3\n5 5 3 5 1\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 8 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 14 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 16 9 33 10 37 20 8 7 42 8 17 0 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 1 10 6 1 4 5 5 6\n",
"25 20\n10 8 4 6 12 14 19 18 19 9 21 16 11 15 10 15 12 12 18 18 9 22 12 14 14\n",
"4 2\n1 1 3 4\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 3 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 8 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 13 58 83 12 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 0 7 5 1 10 9 10\n",
"10 1\n1 2 2 10 6 1 4 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 92 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 22 62 76 81 27 52 55 67 28 65 71\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 3 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 27 33\n",
"50 70\n60 13 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 64 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"70 12\n6 5 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 7 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 0 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 0 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 2 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 2 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 5 48 42 69 95 10 61 47\n",
"15 6\n1 6 6 5 2 1 4 4 14 15 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 21 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 9 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 3 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 3 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 13 58 83 5 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 4 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 0 7 5 1 10 9 10\n"
],
"output": [
"15\n",
"8\n",
"0\n",
"4110\n",
"36\n",
"245\n",
"66\n",
"3961\n",
"1089\n",
"225\n",
"6\n",
"33\n",
"1810\n",
"36\n",
"2030\n",
"1236\n",
"2240\n",
"2796\n",
"8\n",
"4173\n",
"42\n",
"1876\n",
"817\n",
"0\n",
"280\n",
"3492\n",
"84\n",
"756\n",
"92\n",
"588\n",
"306\n",
"672\n",
"4978\n",
"136\n",
"1360",
"1455",
"42\n",
"245\n",
"66\n",
"3961\n",
"1089\n",
"216\n",
"4\n",
"1808\n",
"38\n",
"2030\n",
"1239\n",
"2280\n",
"2782\n",
"6\n",
"4147\n",
"1472\n",
"817\n",
"280\n",
"3522\n",
"83\n",
"756\n",
"92\n",
"306\n",
"672\n",
"4962\n",
"128\n",
"1394\n",
"1410\n",
"20\n",
"36\n",
"259\n",
"1806\n",
"1275\n",
"2260\n",
"2764\n",
"8\n",
"4121\n",
"63\n",
"1495\n",
"3486\n",
"82\n",
"700\n",
"4954\n",
"126\n",
"1377\n",
"15\n",
"3944\n",
"1805\n",
"41\n",
"42\n",
"6\n",
"66\n",
"3961\n",
"1089\n",
"216\n",
"42\n",
"2030\n",
"817\n",
"280\n",
"756\n",
"92\n",
"306\n",
"1410\n",
"42\n",
"259\n",
"66\n",
"1089\n",
"216\n"
]
} | 2CODEFORCES
|
38_C. Blinds_1290 | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they may not have the same length (it is even possible for them to have different lengths)
Every stripe can be cut into two or more parts. The cuttings are made perpendicularly to the side along which the length is measured. Thus the cuttings do not change the width of a stripe but each of the resulting pieces has a lesser length (the sum of which is equal to the length of the initial stripe)
After all the cuttings the blinds are constructed through consecutive joining of several parts, similar in length, along sides, along which length is measured. Also, apart from the resulting pieces an initial stripe can be used as a blind if it hasn't been cut. It is forbidden to construct blinds in any other way.
Thus, if the blinds consist of k pieces each d in length, then they are of form of a rectangle of k Γ d bourlemeters.
Your task is to find for what window possessing the largest possible area the blinds can be made from the given stripes if on technical grounds it is forbidden to use pieces shorter than l bourlemeter. The window is of form of a rectangle with side lengths as positive integers.
Input
The first output line contains two space-separated integers n and l (1 β€ n, l β€ 100). They are the number of stripes in the warehouse and the minimal acceptable length of a blind stripe in bourlemeters. The second line contains space-separated n integers ai. They are the lengths of initial stripes in bourlemeters (1 β€ ai β€ 100).
Output
Print the single number β the maximal area of the window in square bourlemeters that can be completely covered. If no window with a positive area that can be covered completely without breaking any of the given rules exist, then print the single number 0.
Examples
Input
4 2
1 2 3 4
Output
8
Input
5 3
5 5 7 3 1
Output
15
Input
2 3
1 2
Output
0
Note
In the first sample test the required window is 2 Γ 4 in size and the blinds for it consist of 4 parts, each 2 bourlemeters long. One of the parts is the initial stripe with the length of 2, the other one is a part of a cut stripe with the length of 3 and the two remaining stripes are parts of a stripe with the length of 4 cut in halves. | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Blinds {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String temp[] = br.readLine().split(" ");
int n = Integer.parseInt(temp[0]);
int l = Integer.parseInt(temp[1]);
int number=0;
int lengths[] = new int[n];
temp = br.readLine().split(" ");
for (int i=0;i<lengths.length;i++)
lengths[i] = Integer.parseInt(temp[i]);
int ans=0;
Arrays.sort(lengths);
for (int k=l;k<=lengths[lengths.length-1];k++) {
number=0;
for (int i=0;i<lengths.length;i++) {
number+= (lengths[i]/k);
}
ans = Math.max(ans, number*k);
}
System.out.println(ans);
}
}
| 4JAVA
| {
"input": [
"5 3\n5 5 7 3 1\n",
"4 2\n1 2 3 4\n",
"2 3\n1 2\n",
"93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 84 59 68 87 26 91 10 54 41 74 71 74 62 24\n",
"15 6\n1 6 6 5 2 10 4 4 7 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 11 7 9 11 6 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 2 3 4 3 3 3 3 2 1 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 36 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 28 58 83 12 3 77 34 33 73 15 35 29 8 3 21 63 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 9 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 7 7 5 1 10 9 10\n",
"2 2\n3 3\n",
"10 2\n6 3 1 1 6 4 6 1 6 3\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 18 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 4 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 2 6 6 1 2 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 80 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 55 62 76 81 27 52 55 67 28 65 71\n",
"35 3\n13 12 38 45 71 61 42 75 58 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n42 89 35 19 51 41 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 48 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 25 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 3\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 29 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 76 10 69 49 25 9 77 30\n",
"25 20\n10 8 4 6 12 14 19 18 19 9 21 16 16 15 10 15 12 12 18 18 9 22 12 14 14\n",
"98 14\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 31 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 10 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 30 33\n",
"7 4\n3 2 1 1 1 3 2\n",
"50 70\n60 21 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 61 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 32 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 76 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 1 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 1 2 1 2 1 1 2 2 2\n",
"70 12\n6 8 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 8 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 1 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"55 12\n15 5 11 16 17 3 5 28 19 15 1 9 5 26 25 3 14 14 33 12 3 21 16 30 22 18 7 16 24 28 2 17 24 25 16 16 31 9 11 9 6 13 25 23 32 18 4 21 10 32 11 5 4 32 14\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 1 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 7 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 14 33 23 25 23 11 19 19 27 27 3 20 17 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 71 68 89 47 59 5 74 92 43 100 15 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n13 3 6 11 6 11 9 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 17 25 17 38 39 37 23 37 11 6 15 43 4 15 44 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 46 48 40 69 95 10 61 47\n",
"15 6\n1 6 6 5 2 10 4 4 14 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 11 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 2 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 28 58 83 12 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 7 7 5 1 10 9 10\n",
"2 2\n3 2\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 18 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 2 6 6 1 4 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 92 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 55 62 76 81 27 52 55 67 28 65 71\n",
"35 3\n13 12 38 45 71 65 42 75 58 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n82 89 35 19 51 41 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 35 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 25 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 1\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 0 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 76 10 69 49 25 9 77 30\n",
"98 23\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 31 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 3 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 30 33\n",
"50 70\n60 21 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 64 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 61 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 76 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 0 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 1 2 1 2 1 1 2 2 2\n",
"70 12\n6 8 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 7 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 0 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 1 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 2 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 13 33 23 25 23 11 19 19 27 27 3 20 17 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 54 68 89 47 59 5 74 92 43 100 15 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n13 3 6 11 6 11 0 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 17 25 17 38 39 37 23 37 11 6 15 43 4 15 84 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 5 48 40 69 95 10 61 47\n",
"5 3\n5 5 7 5 1\n",
"15 6\n1 6 6 5 2 1 4 4 14 8 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 21 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 10 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 16 9 33 10 37 20 8 7 42 8 17 1 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"35 3\n13 12 38 45 71 65 42 75 93 40 50 70 27 38 16 37 21 12 36 7 39 4 65 12 32 26 1 21 66 63 29 56 32 29 26\n",
"60 10\n82 89 35 19 51 28 31 77 10 8 73 27 47 26 66 91 43 33 74 62 77 23 5 44 18 23 74 6 51 21 30 17 31 39 74 4 55 39 3 34 21 3 18 41 61 37 31 91 69 55 75 67 77 30 11 16 35 68 62 19\n",
"85 2\n26 5 35 55 22 22 43 29 55 29 6 53 48 35 58 22 44 7 14 26 48 17 66 44 2 10 50 4 19 35 29 61 55 57 7 5 54 64 18 17 43 16 14 63 46 22 55 23 8 52 65 30 10 13 24 18 7 44 65 7 42 63 29 54 32 23 55 17 3 11 67 14 45 31 33 22 36 28 27 54 46 45 15 40 55\n",
"5 2\n2 4 1 1 2\n",
"94 12\n40 66 66 35 43 23 77 6 55 44 68 90 20 59 11 95 78 13 75 98 30 22 40 0 2 23 82 26 53 48 16 100 97 100 74 96 73 30 35 72 23 38 25 86 7 45 53 20 18 77 68 95 41 45 1 94 42 94 54 9 33 84 53 71 6 68 98 94 35 78 58 34 84 78 28 65 58 11 2 78 96 5 8 36 34 26 43 10 69 49 25 9 77 30\n",
"25 20\n10 8 4 6 12 14 37 18 19 9 21 16 11 15 10 15 12 12 18 18 9 22 12 14 14\n",
"98 23\n23 3 39 39 6 35 2 35 38 9 11 24 42 35 35 46 23 46 20 36 25 46 23 9 21 24 21 38 43 9 9 38 38 46 3 28 17 53 30 14 29 12 37 15 5 45 46 32 35 39 39 27 25 15 42 40 19 19 11 6 32 16 25 29 46 2 45 44 5 36 21 11 14 18 39 1 39 26 18 14 1 23 38 24 10 38 14 42 15 3 8 8 23 46 40 19 14 29\n",
"90 3\n44 16 62 40 33 17 53 32 66 18 68 33 18 76 14 66 41 8 18 57 39 63 9 41 30 39 30 35 46 12 27 33 6 4 21 26 32 24 18 25 35 39 14 49 65 61 54 38 55 64 75 2 53 21 72 11 46 47 63 60 33 62 13 35 40 21 26 15 66 74 55 48 24 26 39 69 65 68 62 12 74 58 21 13 53 5 40 56 66 67\n",
"45 1\n1 1 2 3 1 2 3 0 1 1 1 2 2 2 2 3 1 1 2 2 3 3 2 3 3 1 3 3 3 1 2 3 2 1 2 1 0 2 1 2 1 1 2 2 2\n",
"97 28\n13 12 30 2 17 29 28 28 26 10 27 27 20 14 8 28 10 5 33 19 17 31 15 4 8 13 21 23 32 3 20 9 33 17 11 13 11 9 19 30 19 25 1 18 1 13 1 20 19 9 17 31 32 26 1 34 7 34 6 22 7 13 29 6 29 3 13 28 3 6 7 29 17 34 28 32 13 33 23 25 23 11 19 19 27 27 3 20 30 13 24 2 8 25 10 31 34\n",
"100 2\n79 84 2 24 18 95 57 79 67 60 78 85 75 23 68 68 76 30 39 31 32 81 42 90 50 33 49 9 63 18 74 46 34 55 48 41 7 75 74 90 14 90 2 49 20 29 33 65 43 7 11 12 58 45 17 100 1 28 3 12 26 94 45 5 45 19 3 28 95 11 54 68 89 47 59 5 74 92 43 100 6 63 78 85 70 38 62 100 78 76 29 69 64 2 32 68 48 61 82 100\n",
"20 2\n10 3 6 11 6 11 0 1 1 2 5 2 9 15 14 10 3 12 3 13\n",
"95 17\n1 24 17 9 41 5 39 30 6 32 17 30 27 11 13 25 22 23 12 31 19 31 35 43 8 23 39 23 39 41 10 16 25 17 38 39 37 23 37 11 6 15 43 4 15 84 44 42 29 2 14 6 1 6 31 45 26 21 14 18 15 17 23 11 39 12 16 6 11 19 15 31 18 10 33 10 2 8 21 4 26 3 42 45 16 1 11 28 43 24 18 45 25 39 9\n",
"5 3\n5 5 3 5 1\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 8 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 14 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"80 1\n7 13 38 24 17 20 11 3 25 23 36 16 41 36 16 9 33 10 37 20 8 7 42 8 17 0 39 30 39 24 36 17 8 11 3 33 23 42 36 16 36 3 30 20 29 35 43 17 32 26 33 2 41 34 9 37 14 26 6 40 16 24 8 26 16 31 11 12 18 24 42 34 24 37 5 23 32 13 8 14\n",
"10 1\n1 2 1 10 6 1 4 5 5 6\n",
"25 20\n10 8 4 6 12 14 19 18 19 9 21 16 11 15 10 15 12 12 18 18 9 22 12 14 14\n",
"4 2\n1 1 3 4\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 3 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 5 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"100 17\n20 61 7 74 87 84 87 35 64 7 42 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 8 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 13 42 26 25 53 95\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 13 58 83 12 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 6 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 0 7 5 1 10 9 10\n",
"10 1\n1 2 2 10 6 1 4 5 5 6\n",
"99 57\n69 27 70 70 16 66 64 35 44 1 51 38 69 17 19 35 83 7 47 4 10 22 60 64 64 56 80 54 83 34 51 42 46 51 41 75 54 10 13 44 66 46 27 79 55 13 13 40 18 12 2 33 20 13 75 45 70 75 51 39 92 25 22 27 77 52 41 83 40 33 23 76 81 21 23 59 27 74 45 68 42 20 83 50 66 58 5 8 22 62 76 81 27 52 55 67 28 65 71\n",
"75 19\n3 35 38 25 5 17 12 37 26 34 20 3 30 33 16 26 16 31 17 5 13 40 4 40 16 4 24 31 39 13 12 3 25 40 21 2 27 26 21 2 18 24 24 25 18 3 15 20 5 6 23 3 16 37 20 13 39 4 6 28 9 25 14 7 6 15 34 9 4 16 36 19 17 27 33\n",
"50 70\n60 13 1 35 20 10 35 59 27 12 57 67 76 49 27 72 39 47 56 36 36 13 62 16 6 16 39 46 35 9 67 59 64 52 1 44 70 40 60 3 5 2 14 29 56 32 4 28 35 73\n",
"70 12\n6 5 11 13 11 30 4 26 16 24 8 12 14 25 7 26 1 24 1 9 7 19 25 11 18 23 27 26 27 19 8 10 9 20 23 2 14 27 24 24 14 21 31 5 1 14 24 20 2 1 11 17 12 7 17 20 7 21 16 17 31 25 9 25 5 18 6 19 22 27\n",
"100 2\n2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 1 0 1 1 1 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 2 0 2 2 2 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1\n",
"92 8\n3 4 6 9 7 9 12 12 7 4 9 2 3 9 2 12 4 5 12 2 6 5 9 9 5 2 7 5 12 2 1 7 2 11 11 1 4 10 11 7 5 6 3 5 12 2 9 1 11 1 9 11 1 9 7 9 7 8 1 5 8 8 1 8 6 6 4 5 6 10 7 9 7 1 6 2 12 11 7 6 12 11 5 11 6 10 1 9 3 9 11 9\n",
"30 15\n93 99 77 69 43 86 56 15 9 9 75 84 56 1 42 45 10 23 83 87 86 99 5 48 42 69 95 10 61 47\n",
"15 6\n1 6 6 5 2 1 4 4 14 15 7 3 5 1 2\n",
"65 7\n1 5 4 1 4 11 9 1 11 7 6 11 9 4 2 6 10 11 10 12 4 6 1 12 12 5 1 21 7 9 11 4 10 10 7 8 4 1 3 5 2 3 2 9 11 10 5 8 7 10 12 5 11 6 8 6 2 9 9 7 2 4 12 7 7\n",
"91 6\n4 2 4 2 6 2 4 1 2 6 5 3 3 3 3 2 5 4 2 5 3 2 1 3 5 2 4 5 1 3 3 3 6 6 5 3 4 1 5 6 2 5 2 2 5 4 1 5 4 1 2 6 1 3 3 4 3 3 3 3 2 2 4 5 1 6 5 1 6 3 3 5 6 3 3 5 4 4 5 4 5 2 5 2 3 1 5 6 6 4 2\n",
"40 33\n33 52 83 32 59 90 25 90 38 31 60 30 76 77 9 13 48 1 55 39 84 13 58 83 5 3 77 34 33 73 15 35 29 8 3 21 43 4 21 75\n",
"96 9\n4 5 1 10 2 6 1 9 2 6 3 2 9 4 1 1 3 10 10 4 4 8 6 4 4 6 4 6 2 9 1 9 3 6 2 10 4 3 7 2 7 4 4 4 6 4 1 7 9 4 9 2 1 7 7 3 4 10 10 5 1 3 10 5 1 9 8 4 10 4 7 2 9 6 9 4 2 3 6 9 8 1 1 2 9 4 10 4 9 0 7 5 1 10 9 10\n"
],
"output": [
"15\n",
"8\n",
"0\n",
"4110\n",
"36\n",
"245\n",
"66\n",
"3961\n",
"1089\n",
"225\n",
"6\n",
"33\n",
"1810\n",
"36\n",
"2030\n",
"1236\n",
"2240\n",
"2796\n",
"8\n",
"4173\n",
"42\n",
"1876\n",
"817\n",
"0\n",
"280\n",
"3492\n",
"84\n",
"756\n",
"92\n",
"588\n",
"306\n",
"672\n",
"4978\n",
"136\n",
"1360",
"1455",
"42\n",
"245\n",
"66\n",
"3961\n",
"1089\n",
"216\n",
"4\n",
"1808\n",
"38\n",
"2030\n",
"1239\n",
"2280\n",
"2782\n",
"6\n",
"4147\n",
"1472\n",
"817\n",
"280\n",
"3522\n",
"83\n",
"756\n",
"92\n",
"306\n",
"672\n",
"4962\n",
"128\n",
"1394\n",
"1410\n",
"20\n",
"36\n",
"259\n",
"1806\n",
"1275\n",
"2260\n",
"2764\n",
"8\n",
"4121\n",
"63\n",
"1495\n",
"3486\n",
"82\n",
"700\n",
"4954\n",
"126\n",
"1377\n",
"15\n",
"3944\n",
"1805\n",
"41\n",
"42\n",
"6\n",
"66\n",
"3961\n",
"1089\n",
"216\n",
"42\n",
"2030\n",
"817\n",
"280\n",
"756\n",
"92\n",
"306\n",
"1410\n",
"42\n",
"259\n",
"66\n",
"1089\n",
"216\n"
]
} | 2CODEFORCES
|
40_B. Repaintings_1291 | A chessboard n Γ m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly x times.
The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.
Input
The first line contains integers n and m (1 β€ n, m β€ 5000). The second line contains integer x (1 β€ x β€ 109).
Output
Print how many squares will be painted exactly x times.
Examples
Input
3 3
1
Output
4
Input
3 3
2
Output
1
Input
1 1
1
Output
1 | n, m = map(int, raw_input().split())
x = input()
def black(x1, y1, x2, y2):
if x1 > x2 or y1 > y2:
return 0
h, w = x2 - x1 + 1, y2 - y1 + 1
return ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2)
if min(n, m) >= x + x - 1:
print black(x - 1, x - 1, n - x, m - x) - black(x, x, n - x - 1, m - x - 1)
else:
print 0 | 1Python2
| {
"input": [
"1 1\n1\n",
"3 3\n2\n",
"3 3\n1\n",
"2016 4549\n433\n",
"5000 1\n3\n",
"4035 369\n26\n",
"1595 2881\n710\n",
"3762 3914\n1073\n",
"4583 2774\n1206\n",
"10 10\n1\n",
"1812 240\n9\n",
"991 2301\n291\n",
"3154 527\n112\n",
"1353 2988\n589\n",
"4999 1\n7\n",
"3432 4788\n1203\n",
"3990 1800\n171\n",
"5000 5000\n1000000000\n",
"182 2314\n54\n",
"3042 1798\n93\n",
"4892 712\n340\n",
"2089 955\n476\n",
"419 4046\n174\n",
"2714 607\n189\n",
"4847 2143\n827\n",
"3287 2915\n538\n",
"3458 2220\n526\n",
"873 744\n42\n",
"4643 3755\n1381\n",
"3552 3036\n199\n",
"1 4999\n2309\n",
"1662 926\n452\n",
"1444 2646\n660\n",
"9 10\n1\n",
"188 3759\n53\n",
"2470 4895\n421\n",
"7 7\n777\n",
"4339 2062\n462\n",
"1043 49\n10\n",
"2813 3911\n560\n",
"293 2183\n60\n",
"10 10\n3\n",
"3663 2904\n1149\n",
"10 10\n2\n",
"4202 3834\n1478\n",
"126 4125\n52\n",
"2504 973\n201\n",
"10 10\n5\n",
"3122 1850\n201\n",
"3595 448\n110\n",
"1 1\n200\n",
"10 10\n4\n",
"3899 2141\n428\n",
"4273 4835\n159\n",
"3385 4978\n192\n",
"1922 109\n41\n",
"10 9\n4\n",
"1755 2051\n1\n",
"2793 4840\n901\n",
"3250 2992\n127\n",
"2828 4208\n912\n",
"1 5000\n3\n",
"8 8\n8\n",
"1 4999\n1000000\n",
"892 3996\n288\n",
"837 4874\n208\n",
"9 9\n3\n",
"2738 718\n308\n",
"4275 240\n16\n",
"4694 685\n208\n",
"3703 4549\n433\n",
"2931 2881\n710\n",
"3762 947\n1073\n",
"4583 2774\n986\n",
"7 10\n1\n",
"1833 240\n9\n",
"991 2301\n173\n",
"3154 787\n112\n",
"3990 1351\n171\n",
"3042 1798\n72\n",
"4892 712\n206\n",
"4847 2120\n827\n",
"2790 2915\n538\n",
"3458 2269\n526\n",
"873 744\n27\n",
"3552 3036\n358\n",
"2979 926\n452\n",
"6 10\n1\n",
"267 3759\n53\n",
"4339 4078\n462\n",
"31 49\n10\n",
"2813 3911\n909\n",
"10 18\n3\n",
"4293 2904\n1149\n",
"10 12\n2\n",
"4202 3834\n122\n",
"2504 1592\n201\n",
"3192 1850\n201\n",
"3595 318\n110\n",
"3899 3408\n428\n",
"4273 3181\n159\n",
"3385 4978\n58\n",
"1922 130\n41\n",
"10 9\n2\n",
"1755 2051\n2\n",
"2793 2312\n901\n",
"1353 2988\n1150\n",
"4999 1\n3\n",
"2085 5000\n1000000000\n",
"32 2314\n54\n",
"2089 494\n476\n",
"91 4046\n174\n",
"2714 607\n370\n",
"4643 2738\n1381\n",
"1 6336\n2309\n",
"1444 742\n660\n",
"2470 788\n421\n",
"7 7\n459\n",
"68 2183\n60\n",
"32 4125\n52\n",
"10 1\n5\n",
"1 0\n200\n",
"3 10\n5\n",
"3250 195\n127\n"
],
"output": [
"1\n",
"1\n",
"4\n",
"4835\n",
"0\n",
"4302\n",
"1638\n",
"3386\n",
"2535\n",
"18\n",
"2018\n",
"2130\n",
"3235\n",
"1987\n",
"0\n",
"3410\n",
"5108\n",
"0\n",
"2282\n",
"4470\n",
"4246\n",
"1142\n",
"3771\n",
"2567\n",
"3684\n",
"4052\n",
"3576\n",
"1451\n",
"2876\n",
"5794\n",
"0\n",
"782\n",
"1452\n",
"17\n",
"3737\n",
"5683\n",
"0\n",
"4555\n",
"1054\n",
"4486\n",
"2238\n",
"10\n",
"1973\n",
"14\n",
"2126\n",
"4045\n",
"2675\n",
"2\n",
"4170\n",
"3605\n",
"0\n",
"6\n",
"4330\n",
"8474\n",
"7597\n",
"1869\n",
"5\n",
"3804\n",
"4031\n",
"5736\n",
"3390\n",
"0\n",
"0\n",
"0\n",
"3738\n",
"4881\n",
"8\n",
"2226\n",
"4453\n",
"4549\n",
"6522\n",
"2974\n",
"0\n",
"3415\n",
"15\n",
"2039\n",
"2602\n",
"3495\n",
"4659\n",
"4554\n",
"4782\n",
"3661\n",
"3555\n",
"3625\n",
"1511\n",
"5158\n",
"2099\n",
"14\n",
"3816\n",
"6571\n",
"42\n",
"3090\n",
"18\n",
"2603\n",
"16\n",
"7550\n",
"3294\n",
"4240\n",
"3475\n",
"5597\n",
"6820\n",
"8133\n",
"1890\n",
"13\n",
"3800\n",
"1503\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
40_B. Repaintings_1292 | A chessboard n Γ m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly x times.
The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.
Input
The first line contains integers n and m (1 β€ n, m β€ 5000). The second line contains integer x (1 β€ x β€ 109).
Output
Print how many squares will be painted exactly x times.
Examples
Input
3 3
1
Output
4
Input
3 3
2
Output
1
Input
1 1
1
Output
1 | #include <bits/stdc++.h>
using namespace std;
int perimeter(int w, int h) {
if (w == 1) return h;
if (h == 1) return w;
return 2 * w + 2 * (h - 2);
}
int main() {
int n, m, x;
cin >> n >> m >> x;
int res = 0;
while (true) {
int border = (perimeter(n, m) + 1) / 2;
--x;
if (!x) {
res = border;
break;
}
n -= 2;
m -= 2;
if (n <= 0 || m <= 0) {
break;
}
}
cout << res << endl;
fclose(stdin);
fclose(stdout);
return 0;
}
| 2C++
| {
"input": [
"1 1\n1\n",
"3 3\n2\n",
"3 3\n1\n",
"2016 4549\n433\n",
"5000 1\n3\n",
"4035 369\n26\n",
"1595 2881\n710\n",
"3762 3914\n1073\n",
"4583 2774\n1206\n",
"10 10\n1\n",
"1812 240\n9\n",
"991 2301\n291\n",
"3154 527\n112\n",
"1353 2988\n589\n",
"4999 1\n7\n",
"3432 4788\n1203\n",
"3990 1800\n171\n",
"5000 5000\n1000000000\n",
"182 2314\n54\n",
"3042 1798\n93\n",
"4892 712\n340\n",
"2089 955\n476\n",
"419 4046\n174\n",
"2714 607\n189\n",
"4847 2143\n827\n",
"3287 2915\n538\n",
"3458 2220\n526\n",
"873 744\n42\n",
"4643 3755\n1381\n",
"3552 3036\n199\n",
"1 4999\n2309\n",
"1662 926\n452\n",
"1444 2646\n660\n",
"9 10\n1\n",
"188 3759\n53\n",
"2470 4895\n421\n",
"7 7\n777\n",
"4339 2062\n462\n",
"1043 49\n10\n",
"2813 3911\n560\n",
"293 2183\n60\n",
"10 10\n3\n",
"3663 2904\n1149\n",
"10 10\n2\n",
"4202 3834\n1478\n",
"126 4125\n52\n",
"2504 973\n201\n",
"10 10\n5\n",
"3122 1850\n201\n",
"3595 448\n110\n",
"1 1\n200\n",
"10 10\n4\n",
"3899 2141\n428\n",
"4273 4835\n159\n",
"3385 4978\n192\n",
"1922 109\n41\n",
"10 9\n4\n",
"1755 2051\n1\n",
"2793 4840\n901\n",
"3250 2992\n127\n",
"2828 4208\n912\n",
"1 5000\n3\n",
"8 8\n8\n",
"1 4999\n1000000\n",
"892 3996\n288\n",
"837 4874\n208\n",
"9 9\n3\n",
"2738 718\n308\n",
"4275 240\n16\n",
"4694 685\n208\n",
"3703 4549\n433\n",
"2931 2881\n710\n",
"3762 947\n1073\n",
"4583 2774\n986\n",
"7 10\n1\n",
"1833 240\n9\n",
"991 2301\n173\n",
"3154 787\n112\n",
"3990 1351\n171\n",
"3042 1798\n72\n",
"4892 712\n206\n",
"4847 2120\n827\n",
"2790 2915\n538\n",
"3458 2269\n526\n",
"873 744\n27\n",
"3552 3036\n358\n",
"2979 926\n452\n",
"6 10\n1\n",
"267 3759\n53\n",
"4339 4078\n462\n",
"31 49\n10\n",
"2813 3911\n909\n",
"10 18\n3\n",
"4293 2904\n1149\n",
"10 12\n2\n",
"4202 3834\n122\n",
"2504 1592\n201\n",
"3192 1850\n201\n",
"3595 318\n110\n",
"3899 3408\n428\n",
"4273 3181\n159\n",
"3385 4978\n58\n",
"1922 130\n41\n",
"10 9\n2\n",
"1755 2051\n2\n",
"2793 2312\n901\n",
"1353 2988\n1150\n",
"4999 1\n3\n",
"2085 5000\n1000000000\n",
"32 2314\n54\n",
"2089 494\n476\n",
"91 4046\n174\n",
"2714 607\n370\n",
"4643 2738\n1381\n",
"1 6336\n2309\n",
"1444 742\n660\n",
"2470 788\n421\n",
"7 7\n459\n",
"68 2183\n60\n",
"32 4125\n52\n",
"10 1\n5\n",
"1 0\n200\n",
"3 10\n5\n",
"3250 195\n127\n"
],
"output": [
"1\n",
"1\n",
"4\n",
"4835\n",
"0\n",
"4302\n",
"1638\n",
"3386\n",
"2535\n",
"18\n",
"2018\n",
"2130\n",
"3235\n",
"1987\n",
"0\n",
"3410\n",
"5108\n",
"0\n",
"2282\n",
"4470\n",
"4246\n",
"1142\n",
"3771\n",
"2567\n",
"3684\n",
"4052\n",
"3576\n",
"1451\n",
"2876\n",
"5794\n",
"0\n",
"782\n",
"1452\n",
"17\n",
"3737\n",
"5683\n",
"0\n",
"4555\n",
"1054\n",
"4486\n",
"2238\n",
"10\n",
"1973\n",
"14\n",
"2126\n",
"4045\n",
"2675\n",
"2\n",
"4170\n",
"3605\n",
"0\n",
"6\n",
"4330\n",
"8474\n",
"7597\n",
"1869\n",
"5\n",
"3804\n",
"4031\n",
"5736\n",
"3390\n",
"0\n",
"0\n",
"0\n",
"3738\n",
"4881\n",
"8\n",
"2226\n",
"4453\n",
"4549\n",
"6522\n",
"2974\n",
"0\n",
"3415\n",
"15\n",
"2039\n",
"2602\n",
"3495\n",
"4659\n",
"4554\n",
"4782\n",
"3661\n",
"3555\n",
"3625\n",
"1511\n",
"5158\n",
"2099\n",
"14\n",
"3816\n",
"6571\n",
"42\n",
"3090\n",
"18\n",
"2603\n",
"16\n",
"7550\n",
"3294\n",
"4240\n",
"3475\n",
"5597\n",
"6820\n",
"8133\n",
"1890\n",
"13\n",
"3800\n",
"1503\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
40_B. Repaintings_1293 | A chessboard n Γ m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly x times.
The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.
Input
The first line contains integers n and m (1 β€ n, m β€ 5000). The second line contains integer x (1 β€ x β€ 109).
Output
Print how many squares will be painted exactly x times.
Examples
Input
3 3
1
Output
4
Input
3 3
2
Output
1
Input
1 1
1
Output
1 | import itertools
import math
n, m = [int(k) for k in input().split()]
x = int(input())
if n-2*(x-1) < 1 or m-2*(x-1) < 1:
print(0)
elif n-2*(x-1) == 1 or m-2*(x-1) == 1:
print((n+m-4*(x-1))//2)
else: print(n+m-2 - 4*(x-1))
| 3Python3
| {
"input": [
"1 1\n1\n",
"3 3\n2\n",
"3 3\n1\n",
"2016 4549\n433\n",
"5000 1\n3\n",
"4035 369\n26\n",
"1595 2881\n710\n",
"3762 3914\n1073\n",
"4583 2774\n1206\n",
"10 10\n1\n",
"1812 240\n9\n",
"991 2301\n291\n",
"3154 527\n112\n",
"1353 2988\n589\n",
"4999 1\n7\n",
"3432 4788\n1203\n",
"3990 1800\n171\n",
"5000 5000\n1000000000\n",
"182 2314\n54\n",
"3042 1798\n93\n",
"4892 712\n340\n",
"2089 955\n476\n",
"419 4046\n174\n",
"2714 607\n189\n",
"4847 2143\n827\n",
"3287 2915\n538\n",
"3458 2220\n526\n",
"873 744\n42\n",
"4643 3755\n1381\n",
"3552 3036\n199\n",
"1 4999\n2309\n",
"1662 926\n452\n",
"1444 2646\n660\n",
"9 10\n1\n",
"188 3759\n53\n",
"2470 4895\n421\n",
"7 7\n777\n",
"4339 2062\n462\n",
"1043 49\n10\n",
"2813 3911\n560\n",
"293 2183\n60\n",
"10 10\n3\n",
"3663 2904\n1149\n",
"10 10\n2\n",
"4202 3834\n1478\n",
"126 4125\n52\n",
"2504 973\n201\n",
"10 10\n5\n",
"3122 1850\n201\n",
"3595 448\n110\n",
"1 1\n200\n",
"10 10\n4\n",
"3899 2141\n428\n",
"4273 4835\n159\n",
"3385 4978\n192\n",
"1922 109\n41\n",
"10 9\n4\n",
"1755 2051\n1\n",
"2793 4840\n901\n",
"3250 2992\n127\n",
"2828 4208\n912\n",
"1 5000\n3\n",
"8 8\n8\n",
"1 4999\n1000000\n",
"892 3996\n288\n",
"837 4874\n208\n",
"9 9\n3\n",
"2738 718\n308\n",
"4275 240\n16\n",
"4694 685\n208\n",
"3703 4549\n433\n",
"2931 2881\n710\n",
"3762 947\n1073\n",
"4583 2774\n986\n",
"7 10\n1\n",
"1833 240\n9\n",
"991 2301\n173\n",
"3154 787\n112\n",
"3990 1351\n171\n",
"3042 1798\n72\n",
"4892 712\n206\n",
"4847 2120\n827\n",
"2790 2915\n538\n",
"3458 2269\n526\n",
"873 744\n27\n",
"3552 3036\n358\n",
"2979 926\n452\n",
"6 10\n1\n",
"267 3759\n53\n",
"4339 4078\n462\n",
"31 49\n10\n",
"2813 3911\n909\n",
"10 18\n3\n",
"4293 2904\n1149\n",
"10 12\n2\n",
"4202 3834\n122\n",
"2504 1592\n201\n",
"3192 1850\n201\n",
"3595 318\n110\n",
"3899 3408\n428\n",
"4273 3181\n159\n",
"3385 4978\n58\n",
"1922 130\n41\n",
"10 9\n2\n",
"1755 2051\n2\n",
"2793 2312\n901\n",
"1353 2988\n1150\n",
"4999 1\n3\n",
"2085 5000\n1000000000\n",
"32 2314\n54\n",
"2089 494\n476\n",
"91 4046\n174\n",
"2714 607\n370\n",
"4643 2738\n1381\n",
"1 6336\n2309\n",
"1444 742\n660\n",
"2470 788\n421\n",
"7 7\n459\n",
"68 2183\n60\n",
"32 4125\n52\n",
"10 1\n5\n",
"1 0\n200\n",
"3 10\n5\n",
"3250 195\n127\n"
],
"output": [
"1\n",
"1\n",
"4\n",
"4835\n",
"0\n",
"4302\n",
"1638\n",
"3386\n",
"2535\n",
"18\n",
"2018\n",
"2130\n",
"3235\n",
"1987\n",
"0\n",
"3410\n",
"5108\n",
"0\n",
"2282\n",
"4470\n",
"4246\n",
"1142\n",
"3771\n",
"2567\n",
"3684\n",
"4052\n",
"3576\n",
"1451\n",
"2876\n",
"5794\n",
"0\n",
"782\n",
"1452\n",
"17\n",
"3737\n",
"5683\n",
"0\n",
"4555\n",
"1054\n",
"4486\n",
"2238\n",
"10\n",
"1973\n",
"14\n",
"2126\n",
"4045\n",
"2675\n",
"2\n",
"4170\n",
"3605\n",
"0\n",
"6\n",
"4330\n",
"8474\n",
"7597\n",
"1869\n",
"5\n",
"3804\n",
"4031\n",
"5736\n",
"3390\n",
"0\n",
"0\n",
"0\n",
"3738\n",
"4881\n",
"8\n",
"2226\n",
"4453\n",
"4549\n",
"6522\n",
"2974\n",
"0\n",
"3415\n",
"15\n",
"2039\n",
"2602\n",
"3495\n",
"4659\n",
"4554\n",
"4782\n",
"3661\n",
"3555\n",
"3625\n",
"1511\n",
"5158\n",
"2099\n",
"14\n",
"3816\n",
"6571\n",
"42\n",
"3090\n",
"18\n",
"2603\n",
"16\n",
"7550\n",
"3294\n",
"4240\n",
"3475\n",
"5597\n",
"6820\n",
"8133\n",
"1890\n",
"13\n",
"3800\n",
"1503\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
40_B. Repaintings_1294 | A chessboard n Γ m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly x times.
The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.
Input
The first line contains integers n and m (1 β€ n, m β€ 5000). The second line contains integer x (1 β€ x β€ 109).
Output
Print how many squares will be painted exactly x times.
Examples
Input
3 3
1
Output
4
Input
3 3
2
Output
1
Input
1 1
1
Output
1 |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
/**
* #
* @author pttrung
*/
public class B_Round_39 {
public static long MOD = 1000000007;
static int[] X = {0, 1, 0, -1, 1, -1, -1, 1};
static int[] Y = {1, 0, -1, 0, 1, -1, 1, -1};
public static void main(String[] args) throws FileNotFoundException {
// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
// "output.txt")));
PrintWriter out = new PrintWriter(System.out);
Scanner in = new Scanner();
int n = in.nextInt();
int m = in.nextInt();
int k = in.nextInt();
int result = 0;
int cur = 1;
while (n > 0 && m > 0) {
if (cur == k) {
break;
}
n -= 2;
m -= 2;
cur++;
}
if (cur < k || n <= 0 || m <= 0) {
out.println(0);
} else {
out.println(cal(n, m));
}
out.close();
}
static int cal(int n, int m) {
int result = (n * m + 1) / 2;
if (n > 2 && m > 2) {
result -= ((n - 2) * (m - 2) + 1) / 2;
}
return result;
}
public static int[] KMP(String val) {
int i = 0;
int j = -1;
int[] result = new int[val.length() + 1];
result[0] = -1;
while (i < val.length()) {
while (j >= 0 && val.charAt(j) != val.charAt(i)) {
j = result[j];
}
j++;
i++;
result[i] = j;
}
return result;
}
public static boolean nextPer(int[] data) {
int i = data.length - 1;
while (i > 0 && data[i] < data[i - 1]) {
i--;
}
if (i == 0) {
return false;
}
int j = data.length - 1;
while (data[j] < data[i - 1]) {
j--;
}
int temp = data[i - 1];
data[i - 1] = data[j];
data[j] = temp;
Arrays.sort(data, i, data.length);
return true;
}
public static int digit(long n) {
int result = 0;
while (n > 0) {
n /= 10;
result++;
}
return result;
}
public static double dist(long a, long b, long x, long y) {
double val = (b - a) * (b - a) + (x - y) * (x - y);
val = Math.sqrt(val);
double other = x * x + a * a;
other = Math.sqrt(other);
return val + other;
}
public static class Point implements Comparable<Point> {
int x, y;
public Point(int start, int end) {
this.x = start;
this.y = end;
}
@Override
public int hashCode() {
int hash = 5;
hash = 47 * hash + this.x;
hash = 47 * hash + this.y;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Point other = (Point) obj;
if (this.x != other.x) {
return false;
}
if (this.y != other.y) {
return false;
}
return true;
}
@Override
public String toString() {
return "Point{" + "x=" + x + ", y=" + y + '}';
}
@Override
public int compareTo(Point o) {
return x - o.x;
}
}
public static class FT {
long[] data;
FT(int n) {
data = new long[n];
}
public void update(int index, long value) {
while (index < data.length) {
data[index] += value;
index += (index & (-index));
}
}
public long get(int index) {
long result = 0;
while (index > 0) {
result += data[index];
index -= (index & (-index));
}
return result;
}
}
public static long gcd(long a, long b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
public static long pow(long a, long b, long MOD) {
if (b == 0) {
return 1;
}
if (b == 1) {
return a;
}
long val = pow(a, b / 2, MOD);
if (b % 2 == 0) {
return val * val % MOD;
} else {
return val * (val * a % MOD) % MOD;
}
}
static class Scanner {
BufferedReader br;
StringTokenizer st;
public Scanner() throws FileNotFoundException {
// System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
br = new BufferedReader(new InputStreamReader(System.in));
// br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
}
public String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (Exception e) {
throw new RuntimeException();
}
}
return st.nextToken();
}
public long nextLong() {
return Long.parseLong(next());
}
public int nextInt() {
return Integer.parseInt(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public String nextLine() {
st = null;
try {
return br.readLine();
} catch (Exception e) {
throw new RuntimeException();
}
}
public boolean endLine() {
try {
String next = br.readLine();
while (next != null && next.trim().isEmpty()) {
next = br.readLine();
}
if (next == null) {
return true;
}
st = new StringTokenizer(next);
return st.hasMoreTokens();
} catch (Exception e) {
throw new RuntimeException();
}
}
}
}
| 4JAVA
| {
"input": [
"1 1\n1\n",
"3 3\n2\n",
"3 3\n1\n",
"2016 4549\n433\n",
"5000 1\n3\n",
"4035 369\n26\n",
"1595 2881\n710\n",
"3762 3914\n1073\n",
"4583 2774\n1206\n",
"10 10\n1\n",
"1812 240\n9\n",
"991 2301\n291\n",
"3154 527\n112\n",
"1353 2988\n589\n",
"4999 1\n7\n",
"3432 4788\n1203\n",
"3990 1800\n171\n",
"5000 5000\n1000000000\n",
"182 2314\n54\n",
"3042 1798\n93\n",
"4892 712\n340\n",
"2089 955\n476\n",
"419 4046\n174\n",
"2714 607\n189\n",
"4847 2143\n827\n",
"3287 2915\n538\n",
"3458 2220\n526\n",
"873 744\n42\n",
"4643 3755\n1381\n",
"3552 3036\n199\n",
"1 4999\n2309\n",
"1662 926\n452\n",
"1444 2646\n660\n",
"9 10\n1\n",
"188 3759\n53\n",
"2470 4895\n421\n",
"7 7\n777\n",
"4339 2062\n462\n",
"1043 49\n10\n",
"2813 3911\n560\n",
"293 2183\n60\n",
"10 10\n3\n",
"3663 2904\n1149\n",
"10 10\n2\n",
"4202 3834\n1478\n",
"126 4125\n52\n",
"2504 973\n201\n",
"10 10\n5\n",
"3122 1850\n201\n",
"3595 448\n110\n",
"1 1\n200\n",
"10 10\n4\n",
"3899 2141\n428\n",
"4273 4835\n159\n",
"3385 4978\n192\n",
"1922 109\n41\n",
"10 9\n4\n",
"1755 2051\n1\n",
"2793 4840\n901\n",
"3250 2992\n127\n",
"2828 4208\n912\n",
"1 5000\n3\n",
"8 8\n8\n",
"1 4999\n1000000\n",
"892 3996\n288\n",
"837 4874\n208\n",
"9 9\n3\n",
"2738 718\n308\n",
"4275 240\n16\n",
"4694 685\n208\n",
"3703 4549\n433\n",
"2931 2881\n710\n",
"3762 947\n1073\n",
"4583 2774\n986\n",
"7 10\n1\n",
"1833 240\n9\n",
"991 2301\n173\n",
"3154 787\n112\n",
"3990 1351\n171\n",
"3042 1798\n72\n",
"4892 712\n206\n",
"4847 2120\n827\n",
"2790 2915\n538\n",
"3458 2269\n526\n",
"873 744\n27\n",
"3552 3036\n358\n",
"2979 926\n452\n",
"6 10\n1\n",
"267 3759\n53\n",
"4339 4078\n462\n",
"31 49\n10\n",
"2813 3911\n909\n",
"10 18\n3\n",
"4293 2904\n1149\n",
"10 12\n2\n",
"4202 3834\n122\n",
"2504 1592\n201\n",
"3192 1850\n201\n",
"3595 318\n110\n",
"3899 3408\n428\n",
"4273 3181\n159\n",
"3385 4978\n58\n",
"1922 130\n41\n",
"10 9\n2\n",
"1755 2051\n2\n",
"2793 2312\n901\n",
"1353 2988\n1150\n",
"4999 1\n3\n",
"2085 5000\n1000000000\n",
"32 2314\n54\n",
"2089 494\n476\n",
"91 4046\n174\n",
"2714 607\n370\n",
"4643 2738\n1381\n",
"1 6336\n2309\n",
"1444 742\n660\n",
"2470 788\n421\n",
"7 7\n459\n",
"68 2183\n60\n",
"32 4125\n52\n",
"10 1\n5\n",
"1 0\n200\n",
"3 10\n5\n",
"3250 195\n127\n"
],
"output": [
"1\n",
"1\n",
"4\n",
"4835\n",
"0\n",
"4302\n",
"1638\n",
"3386\n",
"2535\n",
"18\n",
"2018\n",
"2130\n",
"3235\n",
"1987\n",
"0\n",
"3410\n",
"5108\n",
"0\n",
"2282\n",
"4470\n",
"4246\n",
"1142\n",
"3771\n",
"2567\n",
"3684\n",
"4052\n",
"3576\n",
"1451\n",
"2876\n",
"5794\n",
"0\n",
"782\n",
"1452\n",
"17\n",
"3737\n",
"5683\n",
"0\n",
"4555\n",
"1054\n",
"4486\n",
"2238\n",
"10\n",
"1973\n",
"14\n",
"2126\n",
"4045\n",
"2675\n",
"2\n",
"4170\n",
"3605\n",
"0\n",
"6\n",
"4330\n",
"8474\n",
"7597\n",
"1869\n",
"5\n",
"3804\n",
"4031\n",
"5736\n",
"3390\n",
"0\n",
"0\n",
"0\n",
"3738\n",
"4881\n",
"8\n",
"2226\n",
"4453\n",
"4549\n",
"6522\n",
"2974\n",
"0\n",
"3415\n",
"15\n",
"2039\n",
"2602\n",
"3495\n",
"4659\n",
"4554\n",
"4782\n",
"3661\n",
"3555\n",
"3625\n",
"1511\n",
"5158\n",
"2099\n",
"14\n",
"3816\n",
"6571\n",
"42\n",
"3090\n",
"18\n",
"2603\n",
"16\n",
"7550\n",
"3294\n",
"4240\n",
"3475\n",
"5597\n",
"6820\n",
"8133\n",
"1890\n",
"13\n",
"3800\n",
"1503\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
438_A. The Child and Toy_1295 | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part i as vi. The child spend vf1 + vf2 + ... + vfk energy for removing part i where f1, f2, ..., fk are the parts that are directly connected to the i-th and haven't been removed.
Help the child to find out, what is the minimum total energy he should spend to remove all n parts.
Input
The first line contains two integers n and m (1 β€ n β€ 1000; 0 β€ m β€ 2000). The second line contains n integers: v1, v2, ..., vn (0 β€ vi β€ 105). Then followed m lines, each line contains two integers xi and yi, representing a rope from part xi to part yi (1 β€ xi, yi β€ n; xi β yi).
Consider all the parts are numbered from 1 to n.
Output
Output the minimum total energy the child should spend to remove all n parts of the toy.
Examples
Input
4 3
10 20 30 40
1 4
1 2
2 3
Output
40
Input
4 4
100 100 100 100
1 2
2 3
2 4
3 4
Output
400
Input
7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4
Output
160
Note
One of the optimal sequence of actions in the first sample is:
* First, remove part 3, cost of the action is 20.
* Then, remove part 2, cost of the action is 10.
* Next, remove part 4, cost of the action is 10.
* At last, remove part 1, cost of the action is 0.
So the total energy the child paid is 20 + 10 + 10 + 0 = 40, which is the minimum.
In the second sample, the child will spend 400 no matter in what order he will remove the parts. | n, m = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = 0
for i in xrange(m):
x, y = map(int, raw_input().split())
ans += min(a[x-1], a[y-1])
print ans
| 1Python2
| {
"input": [
"4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 30 40\n1 4\n1 2\n2 3\n",
"7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"1 0\n23333\n",
"3 3\n1 1 1\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"1 0\n40654\n",
"3 3\n1 1 0\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n",
"4 4\n100 000 100 100\n1 2\n2 3\n2 4\n3 4\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"4 4\n110 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 5 40\n1 4\n1 2\n2 3\n",
"5 4\n1 4 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 2\n1 3\n4 3\n1 4\n",
"7 10\n2 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"10 30\n3 12 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n1 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 16 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n2 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 16 1 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 10 20 10 20 20 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"5 4\n2 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n",
"7 10\n40 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 2\n4 3\n1 4\n",
"4 4\n110 100 100 000\n1 2\n2 3\n2 4\n1 4\n",
"4 3\n10 20 4 40\n1 4\n1 2\n4 3\n",
"1 0\n62008\n",
"1 0\n4702\n",
"1 0\n5105\n",
"1 0\n46084\n",
"1 0\n1302\n",
"1 0\n545\n",
"1 0\n57321\n",
"1 0\n4505\n",
"1 0\n493\n",
"1 0\n7900\n",
"4 4\n110 100 100 100\n1 2\n2 3\n2 4\n1 4\n",
"4 3\n10 20 5 40\n1 4\n1 2\n4 3\n",
"1 0\n358\n",
"7 10\n2 13 16 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"4 3\n10 20 5 32\n1 4\n1 2\n4 3\n",
"1 0\n420\n",
"4 4\n100 100 100 100\n1 2\n1 3\n2 4\n3 4\n",
"1 0\n83281\n",
"4 4\n100 000 000 100\n1 2\n2 3\n2 4\n3 4\n",
"1 0\n1589\n",
"1 0\n149\n",
"4 3\n10 12 5 40\n1 4\n1 2\n2 3\n",
"1 0\n104470\n",
"1 0\n249\n",
"1 0\n654\n",
"7 10\n2 13 16 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n7 3\n1 4\n",
"4 3\n10 20 5 32\n1 4\n1 2\n1 3\n",
"1 0\n164715\n",
"1 0\n1088\n",
"1 0\n294\n",
"1 0\n100846\n",
"1 0\n1079\n",
"7 10\n2 13 16 16 20 70 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n7 3\n1 4\n",
"4 3\n10 39 5 32\n1 4\n1 2\n1 3\n",
"1 0\n744\n",
"1 0\n28653\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 5\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"4 4\n100 101 100 100\n1 2\n2 3\n2 4\n3 4\n",
"1 0\n828\n",
"1 0\n54499\n",
"1 0\n764\n",
"1 0\n70991\n",
"1 0\n1667\n",
"1 0\n804\n",
"7 10\n40 10 20 16 20 80 59\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 2\n1 3\n4 3\n1 4\n",
"1 0\n1765\n",
"1 0\n662\n"
],
"output": [
"400\n",
"40\n",
"160\n",
"0\n",
"3\n",
"4\n",
"188\n",
"0\n",
"1\n",
"5\n",
"100\n",
"190\n",
"193\n",
"400\n",
"25\n",
"4\n",
"160\n",
"105\n",
"188\n",
"184\n",
"237\n",
"209\n",
"208\n",
"225\n",
"178\n",
"159\n",
"140\n",
"8\n",
"186\n",
"200\n",
"24\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"400\n",
"25\n",
"0\n",
"105\n",
"25\n",
"0\n",
"400\n",
"0\n",
"0\n",
"0\n",
"0\n",
"25\n",
"0\n",
"0\n",
"0\n",
"105\n",
"25\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"105\n",
"25\n",
"0\n",
"0\n",
"193\n",
"400\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"160\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
438_A. The Child and Toy_1296 | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part i as vi. The child spend vf1 + vf2 + ... + vfk energy for removing part i where f1, f2, ..., fk are the parts that are directly connected to the i-th and haven't been removed.
Help the child to find out, what is the minimum total energy he should spend to remove all n parts.
Input
The first line contains two integers n and m (1 β€ n β€ 1000; 0 β€ m β€ 2000). The second line contains n integers: v1, v2, ..., vn (0 β€ vi β€ 105). Then followed m lines, each line contains two integers xi and yi, representing a rope from part xi to part yi (1 β€ xi, yi β€ n; xi β yi).
Consider all the parts are numbered from 1 to n.
Output
Output the minimum total energy the child should spend to remove all n parts of the toy.
Examples
Input
4 3
10 20 30 40
1 4
1 2
2 3
Output
40
Input
4 4
100 100 100 100
1 2
2 3
2 4
3 4
Output
400
Input
7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4
Output
160
Note
One of the optimal sequence of actions in the first sample is:
* First, remove part 3, cost of the action is 20.
* Then, remove part 2, cost of the action is 10.
* Next, remove part 4, cost of the action is 10.
* At last, remove part 1, cost of the action is 0.
So the total energy the child paid is 20 + 10 + 10 + 0 = 40, which is the minimum.
In the second sample, the child will spend 400 no matter in what order he will remove the parts. | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int cost[MAXN];
char used[MAXN];
vector<int> g[MAXN];
int main() {
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> cost[i];
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
x--;
y--;
g[x].push_back(y);
g[y].push_back(x);
}
int ans = 0;
for (int i = 0; i < n; i++) {
int maxv = -1;
for (int j = 0; j < n; j++)
if (!used[j] && (maxv == -1 || cost[j] > cost[maxv])) maxv = j;
for (size_t j = 0; j < g[maxv].size(); j++) ans += cost[g[maxv][j]];
used[maxv] = true;
for (int j = 0; j < n; j++)
for (int k = 0; k < (int)g[j].size(); k++)
if (g[j][k] == maxv) {
swap(g[j][k], g[j].back());
g[j].pop_back();
k--;
}
}
cout << ans << '\n';
return 0;
}
| 2C++
| {
"input": [
"4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 30 40\n1 4\n1 2\n2 3\n",
"7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"1 0\n23333\n",
"3 3\n1 1 1\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"1 0\n40654\n",
"3 3\n1 1 0\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n",
"4 4\n100 000 100 100\n1 2\n2 3\n2 4\n3 4\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"4 4\n110 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 5 40\n1 4\n1 2\n2 3\n",
"5 4\n1 4 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 2\n1 3\n4 3\n1 4\n",
"7 10\n2 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"10 30\n3 12 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n1 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 16 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n2 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 16 1 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 10 20 10 20 20 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"5 4\n2 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n",
"7 10\n40 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 2\n4 3\n1 4\n",
"4 4\n110 100 100 000\n1 2\n2 3\n2 4\n1 4\n",
"4 3\n10 20 4 40\n1 4\n1 2\n4 3\n",
"1 0\n62008\n",
"1 0\n4702\n",
"1 0\n5105\n",
"1 0\n46084\n",
"1 0\n1302\n",
"1 0\n545\n",
"1 0\n57321\n",
"1 0\n4505\n",
"1 0\n493\n",
"1 0\n7900\n",
"4 4\n110 100 100 100\n1 2\n2 3\n2 4\n1 4\n",
"4 3\n10 20 5 40\n1 4\n1 2\n4 3\n",
"1 0\n358\n",
"7 10\n2 13 16 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"4 3\n10 20 5 32\n1 4\n1 2\n4 3\n",
"1 0\n420\n",
"4 4\n100 100 100 100\n1 2\n1 3\n2 4\n3 4\n",
"1 0\n83281\n",
"4 4\n100 000 000 100\n1 2\n2 3\n2 4\n3 4\n",
"1 0\n1589\n",
"1 0\n149\n",
"4 3\n10 12 5 40\n1 4\n1 2\n2 3\n",
"1 0\n104470\n",
"1 0\n249\n",
"1 0\n654\n",
"7 10\n2 13 16 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n7 3\n1 4\n",
"4 3\n10 20 5 32\n1 4\n1 2\n1 3\n",
"1 0\n164715\n",
"1 0\n1088\n",
"1 0\n294\n",
"1 0\n100846\n",
"1 0\n1079\n",
"7 10\n2 13 16 16 20 70 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n7 3\n1 4\n",
"4 3\n10 39 5 32\n1 4\n1 2\n1 3\n",
"1 0\n744\n",
"1 0\n28653\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 5\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"4 4\n100 101 100 100\n1 2\n2 3\n2 4\n3 4\n",
"1 0\n828\n",
"1 0\n54499\n",
"1 0\n764\n",
"1 0\n70991\n",
"1 0\n1667\n",
"1 0\n804\n",
"7 10\n40 10 20 16 20 80 59\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 2\n1 3\n4 3\n1 4\n",
"1 0\n1765\n",
"1 0\n662\n"
],
"output": [
"400\n",
"40\n",
"160\n",
"0\n",
"3\n",
"4\n",
"188\n",
"0\n",
"1\n",
"5\n",
"100\n",
"190\n",
"193\n",
"400\n",
"25\n",
"4\n",
"160\n",
"105\n",
"188\n",
"184\n",
"237\n",
"209\n",
"208\n",
"225\n",
"178\n",
"159\n",
"140\n",
"8\n",
"186\n",
"200\n",
"24\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"400\n",
"25\n",
"0\n",
"105\n",
"25\n",
"0\n",
"400\n",
"0\n",
"0\n",
"0\n",
"0\n",
"25\n",
"0\n",
"0\n",
"0\n",
"105\n",
"25\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"105\n",
"25\n",
"0\n",
"0\n",
"193\n",
"400\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"160\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
438_A. The Child and Toy_1297 | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part i as vi. The child spend vf1 + vf2 + ... + vfk energy for removing part i where f1, f2, ..., fk are the parts that are directly connected to the i-th and haven't been removed.
Help the child to find out, what is the minimum total energy he should spend to remove all n parts.
Input
The first line contains two integers n and m (1 β€ n β€ 1000; 0 β€ m β€ 2000). The second line contains n integers: v1, v2, ..., vn (0 β€ vi β€ 105). Then followed m lines, each line contains two integers xi and yi, representing a rope from part xi to part yi (1 β€ xi, yi β€ n; xi β yi).
Consider all the parts are numbered from 1 to n.
Output
Output the minimum total energy the child should spend to remove all n parts of the toy.
Examples
Input
4 3
10 20 30 40
1 4
1 2
2 3
Output
40
Input
4 4
100 100 100 100
1 2
2 3
2 4
3 4
Output
400
Input
7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4
Output
160
Note
One of the optimal sequence of actions in the first sample is:
* First, remove part 3, cost of the action is 20.
* Then, remove part 2, cost of the action is 10.
* Next, remove part 4, cost of the action is 10.
* At last, remove part 1, cost of the action is 0.
So the total energy the child paid is 20 + 10 + 10 + 0 = 40, which is the minimum.
In the second sample, the child will spend 400 no matter in what order he will remove the parts. | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def main():
n,m = LI()
a = LI()
aa = [LI_() for _ in range(m)]
r = 0
for b,c in aa:
r += min(a[b], a[c])
return r
print(main())
| 3Python3
| {
"input": [
"4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 30 40\n1 4\n1 2\n2 3\n",
"7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"1 0\n23333\n",
"3 3\n1 1 1\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"1 0\n40654\n",
"3 3\n1 1 0\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n",
"4 4\n100 000 100 100\n1 2\n2 3\n2 4\n3 4\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"4 4\n110 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 5 40\n1 4\n1 2\n2 3\n",
"5 4\n1 4 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 2\n1 3\n4 3\n1 4\n",
"7 10\n2 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"10 30\n3 12 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n1 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 16 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n2 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 16 1 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 10 20 10 20 20 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"5 4\n2 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n",
"7 10\n40 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 2\n4 3\n1 4\n",
"4 4\n110 100 100 000\n1 2\n2 3\n2 4\n1 4\n",
"4 3\n10 20 4 40\n1 4\n1 2\n4 3\n",
"1 0\n62008\n",
"1 0\n4702\n",
"1 0\n5105\n",
"1 0\n46084\n",
"1 0\n1302\n",
"1 0\n545\n",
"1 0\n57321\n",
"1 0\n4505\n",
"1 0\n493\n",
"1 0\n7900\n",
"4 4\n110 100 100 100\n1 2\n2 3\n2 4\n1 4\n",
"4 3\n10 20 5 40\n1 4\n1 2\n4 3\n",
"1 0\n358\n",
"7 10\n2 13 16 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"4 3\n10 20 5 32\n1 4\n1 2\n4 3\n",
"1 0\n420\n",
"4 4\n100 100 100 100\n1 2\n1 3\n2 4\n3 4\n",
"1 0\n83281\n",
"4 4\n100 000 000 100\n1 2\n2 3\n2 4\n3 4\n",
"1 0\n1589\n",
"1 0\n149\n",
"4 3\n10 12 5 40\n1 4\n1 2\n2 3\n",
"1 0\n104470\n",
"1 0\n249\n",
"1 0\n654\n",
"7 10\n2 13 16 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n7 3\n1 4\n",
"4 3\n10 20 5 32\n1 4\n1 2\n1 3\n",
"1 0\n164715\n",
"1 0\n1088\n",
"1 0\n294\n",
"1 0\n100846\n",
"1 0\n1079\n",
"7 10\n2 13 16 16 20 70 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n7 3\n1 4\n",
"4 3\n10 39 5 32\n1 4\n1 2\n1 3\n",
"1 0\n744\n",
"1 0\n28653\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 5\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"4 4\n100 101 100 100\n1 2\n2 3\n2 4\n3 4\n",
"1 0\n828\n",
"1 0\n54499\n",
"1 0\n764\n",
"1 0\n70991\n",
"1 0\n1667\n",
"1 0\n804\n",
"7 10\n40 10 20 16 20 80 59\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 2\n1 3\n4 3\n1 4\n",
"1 0\n1765\n",
"1 0\n662\n"
],
"output": [
"400\n",
"40\n",
"160\n",
"0\n",
"3\n",
"4\n",
"188\n",
"0\n",
"1\n",
"5\n",
"100\n",
"190\n",
"193\n",
"400\n",
"25\n",
"4\n",
"160\n",
"105\n",
"188\n",
"184\n",
"237\n",
"209\n",
"208\n",
"225\n",
"178\n",
"159\n",
"140\n",
"8\n",
"186\n",
"200\n",
"24\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"400\n",
"25\n",
"0\n",
"105\n",
"25\n",
"0\n",
"400\n",
"0\n",
"0\n",
"0\n",
"0\n",
"25\n",
"0\n",
"0\n",
"0\n",
"105\n",
"25\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"105\n",
"25\n",
"0\n",
"0\n",
"193\n",
"400\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"160\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
438_A. The Child and Toy_1298 | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The child can remove a single part at a time, and each remove consume an energy. Let's define an energy value of part i as vi. The child spend vf1 + vf2 + ... + vfk energy for removing part i where f1, f2, ..., fk are the parts that are directly connected to the i-th and haven't been removed.
Help the child to find out, what is the minimum total energy he should spend to remove all n parts.
Input
The first line contains two integers n and m (1 β€ n β€ 1000; 0 β€ m β€ 2000). The second line contains n integers: v1, v2, ..., vn (0 β€ vi β€ 105). Then followed m lines, each line contains two integers xi and yi, representing a rope from part xi to part yi (1 β€ xi, yi β€ n; xi β yi).
Consider all the parts are numbered from 1 to n.
Output
Output the minimum total energy the child should spend to remove all n parts of the toy.
Examples
Input
4 3
10 20 30 40
1 4
1 2
2 3
Output
40
Input
4 4
100 100 100 100
1 2
2 3
2 4
3 4
Output
400
Input
7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4
Output
160
Note
One of the optimal sequence of actions in the first sample is:
* First, remove part 3, cost of the action is 20.
* Then, remove part 2, cost of the action is 10.
* Next, remove part 4, cost of the action is 10.
* At last, remove part 1, cost of the action is 0.
So the total energy the child paid is 20 + 10 + 10 + 0 = 40, which is the minimum.
In the second sample, the child will spend 400 no matter in what order he will remove the parts. | import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Vadim Semenov
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
TaskA solver = new TaskA();
solver.solve(1, in, out);
out.close();
}
}
class TaskA {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int vertices = in.nextInt();
int edges = in.nextInt();
final int[] cost = new int[vertices];
for (int i = 0; i < vertices; i++) cost[i] = in.nextInt();
Integer[] indices = new Integer[vertices];
for (int i = 0; i < vertices; i++) indices[i] = i;
Arrays.sort(indices, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return -Integer.compare(cost[o1], cost[o2]);
}
});
boolean[][] graph = new boolean[vertices][vertices];
for (int i = 0; i < edges; i++) {
int v = in.nextInt() - 1;
int u = in.nextInt() - 1;
graph[v][u] = graph[u][v] = true;
}
boolean[] used = new boolean[vertices];
int answer = 0;
for (int i = 0; i < vertices; i++) {
int v = indices[i];
used[v] = true;
for (int j = 0; j < vertices; j++) if (graph[v][j] && !used[j]) {
answer += cost[j];
}
}
out.println(answer);
}
}
class InputReader {
private final BufferedReader reader;
private StringTokenizer tokenizer;
public InputReader(InputStream in) {
reader = new BufferedReader(new InputStreamReader(in));
}
public int nextInt() {
return Integer.parseInt(next());
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(readLine());
}
return tokenizer.nextToken();
}
public String readLine() {
String line = null;
try {
line = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return line;
}
}
| 4JAVA
| {
"input": [
"4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 30 40\n1 4\n1 2\n2 3\n",
"7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"1 0\n23333\n",
"3 3\n1 1 1\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"1 0\n40654\n",
"3 3\n1 1 0\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n",
"4 4\n100 000 100 100\n1 2\n2 3\n2 4\n3 4\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"4 4\n110 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 5 40\n1 4\n1 2\n2 3\n",
"5 4\n1 4 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 2\n1 3\n4 3\n1 4\n",
"7 10\n2 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"10 30\n3 12 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 10\n5 8\n9 5\n6 1\n2 1\n5 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n1 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 16 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 10 20 16 20 80 40\n1 5\n2 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 2\n",
"7 10\n40 13 20 28 16 1 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"7 10\n40 10 20 10 20 20 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"5 4\n2 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n",
"7 10\n40 13 20 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 2\n4 3\n1 4\n",
"4 4\n110 100 100 000\n1 2\n2 3\n2 4\n1 4\n",
"4 3\n10 20 4 40\n1 4\n1 2\n4 3\n",
"1 0\n62008\n",
"1 0\n4702\n",
"1 0\n5105\n",
"1 0\n46084\n",
"1 0\n1302\n",
"1 0\n545\n",
"1 0\n57321\n",
"1 0\n4505\n",
"1 0\n493\n",
"1 0\n7900\n",
"4 4\n110 100 100 100\n1 2\n2 3\n2 4\n1 4\n",
"4 3\n10 20 5 40\n1 4\n1 2\n4 3\n",
"1 0\n358\n",
"7 10\n2 13 16 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"4 3\n10 20 5 32\n1 4\n1 2\n4 3\n",
"1 0\n420\n",
"4 4\n100 100 100 100\n1 2\n1 3\n2 4\n3 4\n",
"1 0\n83281\n",
"4 4\n100 000 000 100\n1 2\n2 3\n2 4\n3 4\n",
"1 0\n1589\n",
"1 0\n149\n",
"4 3\n10 12 5 40\n1 4\n1 2\n2 3\n",
"1 0\n104470\n",
"1 0\n249\n",
"1 0\n654\n",
"7 10\n2 13 16 16 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n7 3\n1 4\n",
"4 3\n10 20 5 32\n1 4\n1 2\n1 3\n",
"1 0\n164715\n",
"1 0\n1088\n",
"1 0\n294\n",
"1 0\n100846\n",
"1 0\n1079\n",
"7 10\n2 13 16 16 20 70 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n7 3\n1 4\n",
"4 3\n10 39 5 32\n1 4\n1 2\n1 3\n",
"1 0\n744\n",
"1 0\n28653\n",
"10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3 7\n2 9\n8 10\n3 1\n3 4\n8 6\n10 3\n3 9\n2 3\n10 4\n2 5\n5 8\n9 5\n6 1\n2 1\n7 2\n7 6\n7 10\n4 8\n5 6\n3 6\n4 1\n8 9\n7 9\n4 2\n5 10\n",
"4 4\n100 101 100 100\n1 2\n2 3\n2 4\n3 4\n",
"1 0\n828\n",
"1 0\n54499\n",
"1 0\n764\n",
"1 0\n70991\n",
"1 0\n1667\n",
"1 0\n804\n",
"7 10\n40 10 20 16 20 80 59\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 2\n1 3\n4 3\n1 4\n",
"1 0\n1765\n",
"1 0\n662\n"
],
"output": [
"400\n",
"40\n",
"160\n",
"0\n",
"3\n",
"4\n",
"188\n",
"0\n",
"1\n",
"5\n",
"100\n",
"190\n",
"193\n",
"400\n",
"25\n",
"4\n",
"160\n",
"105\n",
"188\n",
"184\n",
"237\n",
"209\n",
"208\n",
"225\n",
"178\n",
"159\n",
"140\n",
"8\n",
"186\n",
"200\n",
"24\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"400\n",
"25\n",
"0\n",
"105\n",
"25\n",
"0\n",
"400\n",
"0\n",
"0\n",
"0\n",
"0\n",
"25\n",
"0\n",
"0\n",
"0\n",
"105\n",
"25\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"105\n",
"25\n",
"0\n",
"0\n",
"193\n",
"400\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"160\n",
"0\n",
"0\n"
]
} | 2CODEFORCES
|
45_H. Road Problem_1299 | The Berland capital (as you very well know) contains n junctions, some pairs of which are connected by two-way roads. Unfortunately, the number of traffic jams in the capital has increased dramatically, that's why it was decided to build several new roads. Every road should connect two junctions.
The city administration noticed that in the cities of all the developed countries between any two roads one can drive along at least two paths so that the paths don't share any roads (but they may share the same junction). The administration decided to add the minimal number of roads so that this rules was fulfilled in the Berland capital as well. In the city road network should exist no more than one road between every pair of junctions before or after the reform.
Input
The first input line contains a pair of integers n, m (2 β€ n β€ 900, 1 β€ m β€ 100000), where n is the number of junctions and m is the number of roads. Each of the following m lines contains a description of a road that is given by the numbers of the connected junctions ai, bi (1 β€ ai, bi β€ n, ai β bi). The junctions are numbered from 1 to n. It is possible to reach any junction of the city from any other one moving along roads.
Output
On the first line print t β the number of added roads. Then on t lines print the descriptions of the added roads in the format of the input data. You can use any order of printing the roads themselves as well as the junctions linked by every road. If there are several solutions to that problem, print any of them.
If the capital doesn't need the reform, print the single number 0.
If there's no solution, print the single number -1.
Examples
Input
4 3
1 2
2 3
3 4
Output
1
1 4
Input
4 4
1 2
2 3
2 4
3 4
Output
1
1 3 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG = 20;
struct DSU {
int par[901];
vector<int> vec[901];
DSU() {
for (int i = 1; i <= 900; i++) par[i] = i, vec[i].push_back(i);
}
int get(int x) {
if (par[x] == x) return x;
return par[x] = get(par[x]);
}
void join(int x, int y) {
x = get(x);
y = get(y);
if (x == y) return;
if (vec[x].size() < vec[y].size()) swap(x, y);
for (int v : vec[y]) vec[x].push_back(v);
par[y] = x;
vec[y].clear();
}
} dsu;
int n, m, k, u, v, x, y, t, a, b, ans;
int h[901];
bool connected[901][901];
pair<int, int> E[MAXN];
vector<int> G1[MAXN];
vector<int> G2[MAXN];
vector<pair<int, int> > cutedge;
vector<int> leaf;
int bridge(int node, int par) {
int res = h[node] = h[node] = h[par] + 1;
for (int v : G1[node])
if (v != par) {
if (h[v])
res = min(res, h[v]);
else
res = min(res, bridge(v, node));
}
if (node != 1 && res >= h[node])
cutedge.push_back({par, node});
else
dsu.join(par, node);
return res;
}
void dfs(int node, int par) {
if (G2[node].size() == 1) {
leaf.push_back(node);
return;
}
for (int v : G2[node])
if (v != par) dfs(v, node);
}
void connect(int u, int v) {
for (int x : dsu.vec[u])
for (int y : dsu.vec[v])
if (!connected[x][y]) {
cout << x << ' ' << y << '\n';
connected[x][y] = 1;
return;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
if (n == 2) return cout << -1 << '\n', 0;
for (int i = 1; i <= m; i++) {
cin >> u >> v;
G1[u].push_back(v);
G1[v].push_back(u);
E[i] = {u, v};
connected[u][v] = 1;
}
bridge(1, 1);
for (pair<int, int> p : cutedge) {
int u = dsu.get(p.first), v = dsu.get(p.second);
G2[v].push_back(u);
G2[u].push_back(v);
}
int root = 0;
for (int i = 1; i <= n; i++)
if (G2[i].size()) {
if (G2[i].size() == 1)
leaf.push_back(i);
else
root = i;
}
if (!leaf.size()) return cout << 0 << '\n', 0;
cout << (leaf.size() + 1) / 2 << '\n';
if (!root) {
connect(leaf[0], leaf[1]);
return 0;
}
leaf.clear();
dfs(root, root);
if (leaf.size() & 1) {
int v = leaf.back();
leaf.pop_back();
connect(v, leaf.back());
}
for (int i = 0; 2 * i < leaf.size(); i++)
connect(leaf[i], leaf[i + leaf.size() / 2]);
for (int i = 1; i <= n; i++) {
cerr << "(dsu.vec[i])"
<< " : ";
for (auto SHIT : (dsu.vec[i])) cerr << SHIT << ' ';
cerr << endl;
;
}
return 0;
}
| 2C++
| {
"input": [
"4 4\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n1 2\n2 3\n3 4\n",
"10 9\n7 9\n8 9\n8 2\n10 6\n8 3\n9 4\n2 6\n8 5\n9 1\n",
"2 1\n1 2\n",
"20 20\n1 9\n11 9\n3 5\n15 13\n1 20\n11 18\n10 6\n10 8\n10 19\n12 16\n10 3\n9 18\n8 4\n15 1\n13 16\n11 2\n7 20\n10 15\n3 17\n17 14\n",
"20 20\n2 17\n5 17\n14 4\n4 11\n5 1\n4 9\n18 16\n1 18\n13 6\n9 19\n2 7\n20 6\n11 12\n18 8\n13 3\n14 17\n18 13\n2 15\n10 8\n5 2\n",
"20 20\n1 7\n9 4\n11 16\n19 1\n8 3\n13 14\n10 1\n15 6\n10 18\n12 16\n15 11\n20 5\n17 11\n6 8\n20 16\n2 4\n5 12\n10 15\n17 14\n9 18\n",
"10 19\n3 7\n3 6\n8 1\n9 10\n1 4\n1 3\n4 3\n5 4\n7 10\n9 1\n4 2\n8 2\n9 4\n9 8\n7 6\n9 3\n8 6\n2 10\n6 2\n",
"10 13\n2 9\n9 5\n5 10\n4 8\n5 7\n6 1\n5 8\n9 7\n10 3\n7 1\n7 10\n2 1\n3 1\n",
"20 21\n19 7\n6 15\n17 3\n6 20\n10 11\n18 8\n1 9\n13 19\n4 16\n3 4\n3 16\n10 13\n2 3\n13 18\n1 17\n10 1\n18 6\n13 5\n9 12\n14 12\n2 16\n",
"10 9\n5 4\n3 10\n8 2\n10 1\n8 3\n7 9\n5 7\n8 5\n4 6\n",
"10 16\n1 3\n4 3\n6 4\n5 3\n5 4\n1 2\n9 8\n10 5\n2 6\n7 9\n7 8\n1 4\n2 3\n10 7\n1 6\n6 10\n",
"6 6\n4 2\n6 2\n5 6\n4 3\n5 1\n3 5\n",
"20 20\n19 11\n17 9\n1 12\n19 3\n19 2\n13 7\n10 6\n10 1\n10 19\n20 5\n10 18\n14 2\n1 17\n19 8\n14 4\n13 20\n2 4\n10 15\n1 13\n8 16\n",
"70 71\n56 50\n52 51\n6 5\n56 67\n29 17\n13 41\n39 10\n61 13\n3 22\n49 11\n2 20\n44 59\n30 4\n8 39\n37 26\n8 58\n21 57\n29 63\n69 24\n66 21\n44 55\n29 40\n44 37\n62 8\n53 64\n44 2\n15 28\n11 42\n67 53\n6 1\n52 14\n23 33\n59 16\n22 48\n2 34\n36 61\n61 32\n26 65\n56 49\n52 68\n6 25\n29 31\n15 12\n36 28\n37 9\n56 29\n47 43\n51 24\n68 35\n27 21\n22 52\n29 70\n43 23\n65 19\n7 36\n44 3\n17 45\n59 7\n36 6\n6 38\n14 62\n54 55\n69 51\n37 56\n52 30\n12 28\n25 60\n4 18\n37 47\n16 66\n46 57\n",
"9 8\n4 3\n6 4\n7 5\n3 8\n7 6\n4 1\n6 2\n9 1\n",
"3 2\n2 1\n3 1\n",
"50 50\n37 15\n19 9\n42 43\n5 23\n17 2\n14 37\n27 20\n37 46\n48 6\n41 10\n26 40\n45 12\n47 29\n14 5\n24 25\n50 44\n3 49\n47 38\n18 48\n50 24\n13 45\n39 50\n18 26\n11 39\n26 27\n50 4\n12 31\n40 1\n32 19\n23 2\n26 42\n39 47\n48 35\n28 21\n50 16\n40 3\n11 32\n32 34\n14 36\n8 11\n43 7\n46 21\n22 29\n16 30\n39 13\n17 5\n41 33\n26 8\n3 14\n4 41\n",
"20 20\n19 1\n11 9\n17 11\n15 12\n19 8\n11 5\n10 3\n10 16\n10 9\n7 20\n15 6\n14 2\n8 13\n15 19\n2 4\n9 18\n4 20\n10 15\n8 14\n17 18\n",
"60 66\n27 43\n37 11\n30 31\n50 53\n30 51\n13 8\n1 38\n22 57\n51 48\n10 5\n3 33\n5 60\n6 29\n58 39\n28 2\n33 36\n33 46\n41 33\n53 9\n47 40\n5 59\n20 3\n4 25\n17 57\n1 12\n55 6\n21 57\n41 28\n52 38\n23 42\n3 30\n22 21\n59 32\n49 35\n14 55\n4 32\n33 15\n59 40\n24 40\n36 16\n32 25\n37 52\n55 29\n58 45\n31 17\n20 15\n51 18\n24 47\n59 23\n34 49\n5 27\n33 39\n46 19\n1 56\n51 35\n30 50\n51 54\n5 41\n34 35\n13 26\n36 37\n10 14\n7 11\n45 39\n12 44\n59 13\n",
"20 21\n6 20\n12 19\n17 14\n12 6\n10 11\n9 16\n1 9\n13 15\n3 4\n15 19\n7 2\n10 13\n20 15\n13 5\n1 18\n10 1\n18 8\n13 17\n9 2\n17 4\n20 19\n",
"4 4\n1 2\n2 3\n2 4\n3 4\n",
"5 5\n4 2\n1 4\n3 2\n5 1\n3 5\n",
"8 14\n8 4\n3 5\n3 4\n6 3\n5 1\n1 4\n8 7\n2 4\n2 3\n2 1\n3 1\n2 6\n6 1\n2 5\n",
"60 61\n19 31\n1 56\n35 37\n1 47\n56 60\n15 31\n38 33\n26 57\n43 29\n28 22\n6 5\n56 38\n3 30\n49 17\n12 13\n20 49\n13 35\n31 16\n49 3\n15 14\n35 21\n54 4\n37 52\n12 32\n32 8\n23 2\n38 20\n50 5\n53 41\n12 45\n41 19\n40 39\n50 9\n58 27\n22 44\n10 46\n56 58\n20 12\n37 36\n15 28\n25 40\n58 11\n49 2\n22 55\n49 42\n11 43\n33 34\n34 48\n49 26\n53 4\n52 59\n49 51\n25 18\n58 24\n1 25\n16 54\n5 9\n21 7\n8 10\n56 6\n49 15\n",
"7 7\n4 6\n2 3\n2 4\n3 1\n5 2\n6 7\n4 7\n",
"20 20\n6 5\n3 17\n8 9\n6 1\n19 8\n11 18\n15 6\n15 11\n15 19\n12 16\n15 13\n7 20\n19 3\n15 14\n5 12\n14 4\n5 16\n10 15\n1 2\n8 7\n",
"70 69\n32 67\n1 57\n40 34\n44 38\n50 24\n69 5\n68 7\n19 61\n36 29\n60 6\n8 12\n32 10\n63 69\n62 39\n14 16\n40 63\n6 70\n39 58\n57 27\n9 55\n43 21\n25 15\n69 22\n30 3\n60 37\n22 50\n29 41\n37 56\n41 28\n11 19\n60 25\n50 46\n11 49\n14 2\n11 9\n40 60\n63 11\n62 1\n60 32\n15 64\n61 4\n10 66\n46 68\n32 18\n32 65\n50 62\n19 35\n40 36\n62 33\n56 31\n13 51\n17 44\n55 14\n14 47\n67 53\n46 17\n10 23\n69 45\n27 54\n60 8\n14 26\n43 52\n66 48\n26 59\n69 30\n36 43\n53 20\n56 51\n19 42\n",
"6 6\n4 6\n2 1\n3 2\n4 3\n5 6\n3 5\n",
"10 18\n6 4\n3 7\n4 9\n8 4\n3 4\n3 6\n7 5\n3 9\n10 9\n10 5\n1 2\n1 8\n8 2\n5 6\n6 9\n5 9\n3 10\n7 10\n",
"20 21\n12 6\n14 12\n5 7\n17 6\n10 11\n8 5\n13 1\n11 2\n4 16\n2 16\n3 4\n10 19\n20 15\n11 9\n13 6\n11 13\n5 15\n11 8\n9 18\n17 14\n2 3\n",
"10 16\n2 6\n3 7\n6 5\n5 9\n5 4\n1 2\n9 8\n6 4\n2 10\n3 8\n7 9\n1 4\n2 4\n10 5\n1 6\n6 10\n",
"4 3\n2 1\n3 4\n2 4\n",
"20 45\n3 9\n5 20\n2 16\n20 12\n18 11\n12 8\n15 8\n5 18\n8 7\n11 1\n5 10\n4 18\n10 17\n13 16\n10 11\n14 18\n9 4\n3 18\n12 1\n12 18\n5 1\n8 16\n8 19\n12 3\n8 6\n5 17\n19 7\n20 1\n6 19\n15 13\n10 20\n15 7\n4 1\n4 11\n2 7\n19 13\n14 20\n15 2\n17 14\n3 4\n6 13\n15 19\n13 2\n5 11\n16 7\n",
"30 29\n12 20\n18 8\n1 18\n1 27\n17 6\n28 23\n26 16\n2 9\n15 5\n24 19\n2 21\n13 11\n16 13\n27 17\n24 26\n26 7\n18 28\n24 25\n2 15\n4 29\n24 3\n8 10\n20 30\n26 4\n15 24\n2 22\n16 14\n5 1\n21 12\n",
"40 40\n4 7\n37 10\n26 14\n26 24\n39 28\n29 40\n37 39\n19 5\n3 16\n33 1\n15 20\n38 8\n7 19\n29 38\n29 37\n8 13\n33 4\n29 33\n9 18\n39 26\n8 22\n23 27\n34 15\n37 2\n27 12\n28 36\n21 32\n36 21\n30 31\n23 6\n40 11\n31 23\n30 40\n26 35\n4 17\n4 34\n11 31\n17 9\n24 3\n18 25\n",
"20 20\n1 9\n11 9\n3 5\n15 13\n1 20\n11 18\n10 6\n10 8\n10 19\n12 16\n10 3\n9 18\n8 7\n15 1\n13 16\n11 2\n7 20\n10 15\n3 17\n17 14\n",
"20 20\n2 17\n5 17\n14 4\n4 11\n5 1\n4 9\n18 13\n1 18\n13 6\n9 19\n2 7\n20 6\n11 12\n18 8\n13 3\n14 17\n18 13\n2 15\n10 8\n5 2\n",
"10 9\n9 4\n3 10\n8 2\n10 1\n8 3\n7 9\n5 7\n8 5\n4 6\n",
"10 16\n1 3\n4 3\n6 4\n5 3\n5 4\n1 2\n9 8\n10 5\n2 5\n7 9\n7 8\n1 4\n2 3\n10 7\n1 6\n6 10\n",
"6 6\n4 2\n6 2\n5 2\n4 3\n5 1\n3 5\n",
"20 20\n19 11\n17 9\n1 12\n19 3\n19 2\n13 3\n10 6\n10 1\n10 19\n20 5\n10 18\n14 2\n1 17\n19 8\n14 4\n13 20\n2 4\n10 15\n1 13\n8 16\n",
"70 71\n56 50\n52 51\n6 5\n56 67\n29 17\n13 41\n39 10\n61 13\n3 22\n49 11\n2 20\n44 59\n30 4\n8 39\n37 26\n8 58\n21 57\n29 63\n69 24\n66 21\n44 55\n29 40\n44 37\n62 8\n53 64\n44 2\n15 28\n11 42\n67 53\n6 1\n52 14\n23 33\n59 16\n22 48\n2 34\n36 61\n61 32\n26 65\n56 49\n52 68\n6 25\n29 31\n15 12\n36 28\n37 9\n56 29\n47 43\n51 24\n68 35\n27 21\n22 52\n29 70\n43 23\n65 19\n7 36\n44 3\n17 45\n59 7\n24 6\n6 38\n14 62\n54 55\n69 51\n37 56\n52 30\n12 28\n25 60\n4 18\n37 47\n16 66\n46 57\n",
"50 50\n37 15\n19 9\n42 43\n5 23\n17 2\n14 37\n27 20\n37 46\n48 6\n41 10\n26 40\n45 12\n47 29\n14 5\n24 25\n50 44\n3 49\n47 38\n18 48\n50 24\n13 45\n39 50\n18 26\n11 39\n26 27\n50 4\n12 31\n40 1\n32 19\n23 2\n26 42\n39 47\n48 35\n22 21\n50 16\n40 3\n11 32\n32 34\n14 36\n8 11\n43 7\n46 21\n22 29\n16 30\n39 13\n17 5\n41 33\n26 8\n3 14\n4 41\n",
"20 20\n19 1\n11 9\n17 11\n15 12\n19 8\n11 5\n10 5\n10 16\n10 9\n7 20\n15 6\n14 2\n8 13\n15 19\n2 4\n9 18\n4 20\n10 15\n8 14\n17 18\n",
"20 21\n6 20\n12 19\n17 14\n12 6\n10 11\n9 16\n1 9\n13 15\n3 4\n15 19\n7 2\n10 13\n20 15\n13 5\n1 18\n10 1\n18 8\n13 17\n15 2\n17 4\n20 19\n",
"4 4\n1 2\n2 3\n2 4\n4 4\n",
"60 61\n19 31\n1 56\n35 37\n1 47\n56 60\n18 31\n38 33\n26 57\n43 29\n28 22\n6 5\n56 38\n3 30\n49 17\n12 13\n20 49\n13 35\n31 16\n49 3\n15 14\n35 21\n54 4\n37 52\n12 32\n32 8\n23 2\n38 20\n50 5\n53 41\n12 45\n41 19\n40 39\n50 9\n58 27\n22 44\n10 46\n56 58\n20 12\n37 36\n15 28\n25 40\n58 11\n49 2\n22 55\n49 42\n11 43\n33 34\n34 48\n49 26\n53 4\n52 59\n49 51\n25 18\n58 24\n1 25\n16 54\n5 9\n21 7\n8 10\n56 6\n49 15\n",
"7 7\n4 6\n2 3\n2 4\n3 1\n3 2\n6 7\n4 7\n",
"20 20\n11 5\n3 17\n8 9\n6 1\n19 8\n11 18\n15 6\n15 11\n15 19\n12 16\n15 13\n7 20\n19 3\n15 14\n5 12\n14 4\n5 16\n10 15\n1 2\n8 7\n",
"70 69\n32 67\n1 57\n40 34\n44 38\n50 24\n69 5\n68 7\n19 61\n36 29\n60 6\n8 12\n32 10\n63 69\n62 39\n14 16\n40 63\n6 70\n39 58\n57 27\n9 55\n43 21\n25 15\n69 22\n30 3\n60 37\n22 50\n29 41\n37 56\n41 28\n11 19\n60 25\n50 46\n11 49\n14 2\n11 9\n40 60\n63 11\n62 1\n60 32\n15 64\n61 4\n10 66\n46 68\n32 18\n32 65\n50 62\n19 35\n40 36\n62 33\n56 31\n13 51\n17 44\n55 14\n14 47\n67 53\n46 17\n10 23\n69 45\n27 54\n60 8\n14 26\n43 52\n66 48\n26 59\n69 30\n2 43\n53 20\n56 51\n19 42\n",
"5 6\n4 6\n2 1\n3 2\n4 3\n5 6\n3 5\n",
"10 18\n6 4\n3 7\n4 9\n8 4\n3 4\n3 6\n7 5\n3 9\n10 9\n10 5\n1 2\n1 8\n8 2\n3 6\n6 9\n5 9\n3 10\n7 10\n",
"20 21\n12 6\n14 12\n5 7\n17 6\n10 11\n8 5\n13 1\n11 1\n4 16\n2 16\n3 4\n10 19\n20 15\n11 9\n13 6\n11 13\n5 15\n11 8\n9 18\n17 14\n2 3\n",
"4 3\n2 1\n4 4\n2 4\n",
"20 45\n3 9\n5 20\n2 16\n20 12\n18 11\n12 8\n15 8\n5 18\n8 7\n11 1\n5 10\n4 18\n10 17\n13 16\n10 11\n14 18\n9 4\n3 18\n12 1\n12 18\n5 1\n8 16\n8 19\n12 3\n8 6\n5 17\n19 7\n20 1\n6 19\n15 13\n10 20\n15 7\n4 1\n4 11\n2 7\n7 13\n14 20\n15 2\n17 14\n3 4\n6 13\n15 19\n13 2\n5 11\n16 7\n",
"40 40\n4 7\n37 10\n26 14\n26 24\n39 28\n29 40\n37 39\n19 5\n3 16\n33 1\n15 20\n38 8\n7 19\n29 38\n29 37\n8 13\n33 4\n29 33\n9 18\n39 26\n8 22\n23 27\n34 15\n37 2\n27 12\n28 36\n21 32\n36 21\n30 31\n23 6\n40 11\n31 23\n8 40\n26 35\n4 17\n4 34\n11 31\n17 9\n24 3\n18 25\n",
"4 3\n1 3\n2 3\n3 4\n",
"20 20\n1 9\n19 9\n3 5\n15 13\n1 20\n11 18\n10 6\n10 8\n10 19\n12 16\n10 3\n9 18\n8 7\n15 1\n13 16\n11 2\n7 20\n10 15\n3 17\n17 14\n",
"20 20\n19 11\n17 9\n1 12\n19 3\n19 2\n13 3\n10 6\n10 1\n10 19\n20 5\n10 18\n14 2\n1 17\n11 8\n14 4\n13 20\n2 4\n10 15\n1 13\n8 16\n",
"50 50\n37 15\n19 9\n42 43\n5 23\n17 2\n14 37\n27 20\n37 46\n48 6\n41 10\n26 40\n45 12\n47 29\n14 5\n24 25\n50 44\n3 49\n47 38\n18 48\n50 24\n13 45\n39 50\n18 26\n11 39\n26 27\n50 4\n12 31\n40 1\n32 19\n23 2\n26 42\n39 47\n48 35\n22 21\n50 16\n40 3\n11 32\n32 34\n14 36\n8 11\n18 7\n46 21\n22 29\n16 30\n39 13\n17 5\n41 33\n26 8\n3 14\n4 41\n",
"20 21\n6 20\n12 19\n17 14\n3 6\n10 11\n9 16\n1 9\n13 15\n3 4\n15 19\n7 2\n10 13\n20 15\n13 5\n1 18\n10 1\n18 8\n13 17\n15 2\n17 4\n20 19\n",
"4 4\n1 2\n2 3\n2 4\n4 2\n",
"60 61\n19 31\n1 56\n35 37\n1 47\n56 60\n18 31\n38 33\n26 57\n43 29\n28 22\n6 5\n56 38\n3 30\n49 17\n12 13\n20 49\n13 35\n31 16\n49 3\n15 14\n35 21\n54 4\n37 52\n12 32\n32 8\n23 2\n38 20\n50 5\n53 41\n12 45\n41 19\n40 39\n50 9\n58 27\n22 44\n10 46\n56 58\n20 12\n37 36\n15 28\n25 40\n58 11\n49 2\n32 55\n49 42\n11 43\n33 34\n34 48\n49 26\n53 4\n52 59\n49 51\n25 18\n58 24\n1 25\n16 54\n5 9\n21 7\n8 10\n56 6\n49 15\n",
"20 20\n11 5\n3 17\n8 9\n6 1\n19 8\n11 18\n15 6\n15 11\n15 19\n12 16\n16 13\n7 20\n19 3\n15 14\n5 12\n14 4\n5 16\n10 15\n1 2\n8 7\n",
"70 69\n32 67\n1 57\n40 34\n44 38\n50 24\n69 5\n68 7\n19 61\n36 29\n60 6\n8 12\n32 10\n63 69\n62 39\n14 16\n40 63\n6 70\n39 58\n57 27\n9 55\n43 21\n25 15\n69 22\n30 3\n60 37\n22 50\n29 41\n37 56\n41 28\n11 19\n60 25\n50 46\n11 49\n14 2\n11 9\n40 60\n63 11\n62 1\n60 32\n15 64\n61 4\n10 66\n46 68\n32 18\n32 65\n50 62\n32 35\n40 36\n62 33\n56 31\n13 51\n17 44\n55 14\n14 47\n67 53\n46 17\n10 23\n69 45\n27 54\n60 8\n14 26\n43 52\n66 48\n26 59\n69 30\n2 43\n53 20\n56 51\n19 42\n",
"20 21\n12 9\n14 12\n5 7\n17 6\n10 11\n8 5\n13 1\n11 1\n4 16\n2 16\n3 4\n10 19\n20 15\n11 9\n13 6\n11 13\n5 15\n11 8\n9 18\n17 14\n2 3\n",
"4 3\n4 1\n4 4\n2 4\n",
"40 40\n4 7\n37 10\n26 14\n26 24\n39 28\n29 40\n37 39\n19 5\n3 16\n33 1\n15 20\n38 8\n7 19\n29 38\n29 37\n8 13\n33 4\n29 33\n9 18\n39 26\n8 22\n23 27\n34 15\n37 2\n27 12\n28 36\n21 32\n36 21\n30 31\n23 6\n40 11\n31 23\n8 40\n26 35\n1 17\n4 34\n11 31\n17 9\n24 3\n18 25\n",
"4 0\n1 3\n2 3\n3 4\n",
"20 20\n2 9\n19 9\n3 5\n15 13\n1 20\n11 18\n10 6\n10 8\n10 19\n12 16\n10 3\n9 18\n8 7\n15 1\n13 16\n11 2\n7 20\n10 15\n3 17\n17 14\n",
"20 20\n19 11\n17 9\n1 12\n19 3\n19 2\n13 3\n10 6\n10 1\n10 19\n20 5\n10 18\n14 2\n1 17\n11 8\n14 4\n13 20\n2 4\n16 15\n1 13\n8 16\n",
"50 50\n37 15\n19 9\n42 43\n5 23\n17 2\n14 37\n27 20\n37 46\n48 6\n41 10\n26 40\n45 12\n47 29\n14 5\n24 25\n50 44\n3 49\n47 38\n18 48\n50 24\n13 45\n39 50\n18 26\n11 39\n26 27\n50 4\n12 31\n40 1\n32 19\n23 2\n26 42\n39 47\n48 35\n22 21\n50 16\n40 3\n11 32\n32 34\n14 36\n8 11\n18 7\n46 21\n22 14\n16 30\n39 13\n17 5\n41 33\n26 8\n3 14\n4 41\n",
"20 21\n6 20\n12 19\n17 14\n3 6\n10 11\n9 16\n1 9\n13 15\n3 3\n15 19\n7 2\n10 13\n20 15\n13 5\n1 18\n10 1\n18 8\n13 17\n15 2\n17 4\n20 19\n",
"60 61\n24 31\n1 56\n35 37\n1 47\n56 60\n18 31\n38 33\n26 57\n43 29\n28 22\n6 5\n56 38\n3 30\n49 17\n12 13\n20 49\n13 35\n31 16\n49 3\n15 14\n35 21\n54 4\n37 52\n12 32\n32 8\n23 2\n38 20\n50 5\n53 41\n12 45\n41 19\n40 39\n50 9\n58 27\n22 44\n10 46\n56 58\n20 12\n37 36\n15 28\n25 40\n58 11\n49 2\n32 55\n49 42\n11 43\n33 34\n34 48\n49 26\n53 4\n52 59\n49 51\n25 18\n58 24\n1 25\n16 54\n5 9\n21 7\n8 10\n56 6\n49 15\n",
"20 20\n11 5\n3 17\n11 9\n6 1\n19 8\n11 18\n15 6\n15 11\n15 19\n12 16\n16 13\n7 20\n19 3\n15 14\n5 12\n14 4\n5 16\n10 15\n1 2\n8 7\n",
"70 69\n32 67\n1 57\n40 34\n44 38\n50 24\n69 5\n68 7\n19 61\n36 29\n60 6\n8 12\n32 10\n63 69\n62 39\n14 16\n40 63\n6 70\n39 58\n57 27\n9 55\n43 21\n25 15\n69 22\n30 3\n60 37\n22 50\n29 41\n37 56\n41 28\n11 19\n60 25\n50 46\n11 49\n14 2\n11 9\n40 60\n63 11\n62 1\n60 32\n15 64\n61 4\n10 66\n46 68\n32 18\n32 65\n50 62\n32 35\n40 36\n62 33\n56 31\n13 51\n4 44\n55 14\n14 47\n67 53\n46 17\n10 23\n69 45\n27 54\n60 8\n14 26\n43 52\n66 48\n26 59\n69 30\n2 43\n53 20\n56 51\n19 42\n",
"10 18\n5 4\n3 7\n3 9\n8 4\n3 4\n3 6\n7 5\n3 9\n10 9\n10 5\n1 2\n1 8\n8 2\n3 6\n6 9\n5 9\n3 10\n7 10\n",
"4 4\n1 2\n2 3\n2 4\n1 3\n",
"20 20\n2 9\n19 9\n3 5\n15 13\n1 20\n11 18\n10 6\n10 8\n10 19\n12 16\n10 3\n9 18\n8 4\n15 1\n13 16\n11 2\n7 20\n10 15\n3 17\n17 14\n",
"20 20\n19 11\n17 9\n1 12\n19 3\n19 2\n13 3\n10 6\n16 1\n10 19\n20 5\n10 18\n14 2\n1 17\n11 8\n14 4\n13 20\n2 4\n16 15\n1 13\n8 16\n",
"50 50\n37 15\n19 9\n42 43\n5 23\n17 2\n14 37\n27 20\n37 46\n48 6\n41 10\n26 40\n45 12\n47 29\n14 5\n24 25\n50 44\n3 49\n47 38\n2 48\n50 24\n13 45\n39 50\n18 26\n11 39\n26 27\n50 4\n12 31\n40 1\n32 19\n23 2\n26 42\n39 47\n48 35\n22 21\n50 16\n40 3\n11 32\n32 34\n14 36\n8 11\n18 7\n46 21\n22 14\n16 30\n39 13\n17 5\n41 33\n26 8\n3 14\n4 41\n",
"60 61\n24 31\n1 56\n35 37\n1 47\n56 60\n18 31\n38 33\n26 57\n43 29\n28 22\n6 5\n56 38\n3 30\n49 17\n12 13\n20 49\n13 35\n31 16\n49 3\n15 14\n35 21\n54 4\n37 52\n12 32\n32 8\n23 2\n38 20\n50 5\n53 41\n12 45\n41 19\n40 39\n50 9\n58 27\n22 44\n10 46\n56 58\n20 12\n37 36\n15 28\n25 40\n58 11\n49 2\n32 55\n49 42\n11 43\n33 34\n22 48\n49 26\n53 4\n52 59\n49 51\n25 18\n58 24\n1 25\n16 54\n5 9\n21 7\n8 10\n56 6\n49 15\n",
"4 4\n1 2\n2 3\n2 4\n3 3\n",
"10 18\n6 4\n3 7\n3 9\n8 4\n3 4\n3 6\n7 5\n3 9\n10 9\n10 5\n1 2\n1 8\n8 2\n3 6\n6 9\n5 9\n3 10\n7 10\n",
"4 6\n1 2\n2 3\n2 4\n3 3\n",
"20 21\n12 9\n14 12\n5 7\n17 6\n10 11\n8 5\n13 1\n11 1\n4 16\n2 16\n3 4\n10 19\n20 15\n11 9\n8 6\n11 13\n5 15\n11 8\n9 18\n17 14\n2 3\n",
"4 3\n4 1\n4 4\n3 4\n",
"3 0\n1 3\n2 3\n3 4\n",
"20 20\n11 5\n3 17\n11 9\n6 1\n19 8\n11 18\n15 6\n15 11\n15 19\n12 16\n16 13\n7 20\n19 3\n15 14\n5 12\n14 4\n1 16\n10 15\n1 2\n8 7\n"
],
"output": [
"1\n1 3\n",
"1\n1 4\n",
"3\n7 5\n10 4\n3 1\n",
"-1\n",
"4\n2 4\n7 19\n12 5\n6 14\n",
"4\n7 16\n15 10\n12 20\n19 3\n",
"3\n7 3\n19 20\n2 13\n",
"1\n1 5\n",
"1\n4 6\n",
"4\n14 8\n2 15\n11 20\n7 5\n",
"2\n2 9\n6 1\n",
"1\n1 7\n",
"1\n1 2\n",
"6\n12 16\n6 18\n11 15\n3 9\n4 7\n16 5\n",
"15\n31 5\n70 60\n33 41\n20 32\n34 12\n48 54\n69 19\n10 9\n58 50\n35 64\n18 42\n46 45\n27 63\n38 40\n1 31\n",
"2\n8 2\n5 9\n",
"1\n2 3\n",
"10\n38 6\n31 35\n9 20\n34 7\n49 44\n15 25\n28 10\n17 33\n36 30\n1 22\n",
"4\n1 6\n13 3\n7 16\n12 5\n",
"11\n7 60\n21 25\n48 24\n18 42\n34 8\n54 26\n9 43\n19 45\n2 16\n29 44\n60 56\n",
"4\n16 20\n7 5\n8 14\n11 3\n",
"1\n1 3\n",
"0\n",
"1\n7 1\n",
"12\n60 59\n48 36\n17 7\n30 46\n23 45\n42 27\n57 29\n51 24\n16 9\n14 47\n44 39\n55 18\n",
"2\n7 5\n5 1\n",
"5\n16 17\n18 13\n9 4\n20 10\n17 2\n",
"16\n54 28\n58 21\n24 52\n5 4\n34 35\n70 42\n31 49\n13 16\n64 2\n20 47\n48 59\n23 45\n18 3\n65 7\n12 38\n28 33\n",
"1\n1 3\n",
"1\n1 3\n",
"4\n18 17\n7 19\n20 3\n1 18\n",
"1\n1 9\n",
"1\n1 3\n",
"1\n1 2\n",
"7\n10 19\n23 11\n6 14\n9 7\n30 29\n22 25\n19 3\n",
"7\n1 22\n5 10\n25 32\n20 14\n12 16\n6 35\n13 2\n",
"3\n5 2\n14 6\n12 19\n",
"4\n19 7\n20 15\n3 12\n10 19\n",
"2\n6 2\n1 6\n",
"1\n2 8\n",
"1\n1 6\n",
"5\n4 12\n16 6\n18 11\n15 5\n9 4\n",
"14\n64 5\n42 60\n45 10\n63 58\n40 35\n31 46\n70 27\n33 41\n20 32\n34 12\n48 54\n18 19\n38 9\n1 50\n",
"9\n15 6\n17 35\n36 20\n49 7\n38 44\n31 25\n9 10\n34 33\n1 30\n",
"3\n6 13\n16 7\n1 12\n",
"4\n7 16\n5 8\n14 11\n3 7\n",
"2\n4 3\n1 4\n",
"12\n59 60\n36 48\n7 17\n46 30\n45 23\n27 42\n29 57\n24 51\n9 14\n47 44\n39 55\n16 59\n",
"1\n1 7\n",
"5\n17 16\n13 18\n4 9\n10 20\n2 17\n",
"15\n28 54\n4 58\n35 24\n42 5\n49 34\n16 70\n21 31\n52 13\n47 64\n59 20\n45 48\n3 23\n7 18\n38 65\n33 12\n",
"1\n1 5\n",
"1\n8 9\n",
"3\n18 17\n7 19\n20 18\n",
"1\n1 4\n",
"1\n14 6\n",
"8\n22 5\n10 25\n32 20\n14 30\n16 12\n35 6\n2 13\n1 22\n",
"2\n4 2\n1 4\n",
"3\n14 6\n12 5\n2 14\n",
"4\n4 12\n18 6\n15 16\n9 5\n",
"10\n30 6\n15 35\n17 7\n36 20\n49 43\n38 44\n31 25\n9 10\n34 33\n1 30\n",
"4\n12 16\n14 8\n7 11\n5 12\n",
"1\n1 3\n",
"12\n36 60\n7 48\n46 17\n55 30\n45 23\n27 42\n29 57\n24 51\n9 14\n47 44\n39 59\n16 36\n",
"4\n17 13\n4 18\n10 9\n2 20\n",
"15\n12 54\n28 58\n4 24\n42 5\n49 34\n16 70\n21 31\n52 13\n47 64\n59 20\n45 48\n3 23\n7 18\n38 65\n33 35\n",
"2\n20 19\n18 7\n",
"1\n1 2\n",
"7\n10 5\n32 20\n14 30\n16 12\n35 6\n2 13\n25 22\n",
"0\n",
"3\n5 6\n14 18\n12 5\n",
"4\n5 12\n4 6\n18 15\n9 5\n",
"10\n29 6\n38 35\n31 7\n9 20\n34 43\n49 44\n15 25\n17 10\n36 33\n1 30\n",
"5\n3 16\n7 8\n5 11\n14 12\n4 3\n",
"11\n36 60\n7 48\n46 17\n55 30\n45 23\n27 42\n29 57\n39 51\n19 14\n9 44\n47 59\n",
"4\n17 13\n4 9\n10 18\n2 20\n",
"15\n12 54\n28 58\n38 24\n42 5\n49 34\n16 70\n21 31\n52 13\n47 64\n59 20\n45 48\n3 23\n7 18\n17 65\n33 35\n",
"1\n8 6\n",
"1\n3 4\n",
"4\n4 7\n18 12\n5 6\n14 4\n",
"4\n4 12\n6 15\n18 5\n9 4\n",
"10\n38 7\n31 20\n9 43\n34 44\n49 25\n15 10\n6 33\n35 30\n36 29\n1 38\n",
"12\n59 60\n36 34\n7 17\n46 30\n55 23\n45 42\n27 57\n29 51\n39 14\n19 44\n9 48\n47 59\n",
"2\n4 3\n1 4\n",
"1\n8 9\n",
"2\n4 3\n1 4\n",
"2\n20 19\n18 7\n",
"1\n1 3\n",
"0\n",
"4\n17 13\n4 9\n10 18\n2 20\n"
]
} | 2CODEFORCES
|
Subsets and Splits