[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    integers = n
    set int files to 0
    set int f to 0
    set int sum[500] to 0
    set int index to 0
    read n
    integers = a
    if n is not equal to 0 then do the following
        read a
        if a is less than 0 then increment f by 1
        if f is 3 then do the following
            files equals files plus 1
            set f to 1
            index equals index plus 1
        end of the block
        sum[index] equals sum[index] plus 1
    end of the block
    files equals files plus 1
    output files,endl
    for i = 0 to less than files - 1 then ouput sum[i] and a space
    output sum[files - 1]
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    int files = 0;
    int f = 0;
    int sum[500] = {0};
    int index = 0;
    cin >> n;
    int a;
    while (n-- != 0) {
        cin >> a;
        if (a < 0) { f += 1; }
        if (f == 3) {
            files += 1;
            f = 1;
            index += 1;
        }
        sum[index] += 1;
    }
    files += 1;
    cout << files << endl;
    for (int i = 0; i < files - 1; i++) { cout << sum[i] << ' '; }
    cout << sum[files - 1] << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
let maxn be an int const = 1e9 + 7
let INF be an int const = 0x3f3f3f3f
let maxx be a const int = 1e5
in long long function poww that takes int a
    let k = 1, sum = 0 be both long long
    scale k by 2 for a times
    return k
end of the block
define the main function
    n, m = long long
    read n, m
    if n >= 35
        print m and new line
    else
        q = long long
        set q to poww with arg n
        print m mod q
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

const int maxn = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 1e5;
long long poww(int a) {
    long long k = 1, sum = 0;
    for (int i = 0; i < a; i++) { k = k * 2; }
    return k;
}
int main() {
    long long n, m;
    cin >> n >> m;
    if (n >= 35) {
        cout << m << endl;
    } else {
        long long q;
        q = poww(n);
        cout << m % q << endl;
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n, sum = int
    num = int array of size 10 with values 2, 7, 2, 3, 3, 4, 2, 5, 1, 2
    loop while reading n
        if n < 10
            set sum to 2 * num[n]
        else
            set sum to num[n / 10] * num[n mod 10]
        end of the block
        print sum
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create new integer variable n
    read n from the user input
    print n % 2
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    cout << n % 2 << endl;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
let INF be const integer with INF = 0x3f3f3f3f
define the main function
    let n, m be integers
    read n, m
    let ans, ar be array of size 105 by 105 with ans = ar = {0}
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            read ans[i][j]
            set ar[i][j] to ans[i][j]
        end of the block
    let mins, sum be integers with mins = INF and sum = 0
    let temp be integer array of size 6 by 200 with temp = {0}
    for i = 1 to n inclusive
        set mins to INF
        for j = 1 to m inclusive, set mins to min of mins, ans[i][j]
        set temp[1][i] to mins
        for j = 1 to m inclusive, set ans[i][j] to ans[i][j] - mins
    end of the block
    for j = 1 to m inclusive
        set mins to INF
        for i = 1 to n inclusive, set mins to min of mins, ans[i][j]
        set temp[2][j] to mins
        for i = 1 to n inclusive, decrement ans[i][j] by mins
    end of the block
    for j = 1 to m inclusive
        set mins to INF
        for i = 1 to n inclusive, set mins to min of mins, ar[i][j]
        set temp[3][j] to mins
        for i = 1 to n inclusive, set ar[i][j] to ar[i][j] - mins
    end of the block
    for i = 1 to n inclusive
        set mins to iNF
        for j = 1 to m inclusive, mins = min of mins, ar[i][j]
        temp[4][i] = mins
        for j = 1 to m inclusive, decrement ar[i][j] by mins
    end of the block
    let flag1, flag2 be integers with flag1 = flag2 = 0
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            if ans[i][j] != 0
                set flag1 to 1
                break
            end of the block
        end of the block
    end of the block
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            if ar[i][j] != 0
                set flag2 to 0
                break
            end of the block
        end of the block
    end of the block
    if flag1 == 1 and flag2 == 1
        print -1
    else if flag1 == 0 and flag2 == 0
        sum1 = sum2 = integer = 0
        for i = 1 to n inclusive
            increment sum1 by temp[1][i]
            increment sum2 by temp[4][i]
        end of the block
        for j = 1 to m inclusive
            increment sum1 by temp[2][j]
            increment sum2 by temp[3][j]
        end of the block
        if sum1 > sum2
            print sum2
            for i = 1 to n inclusive
                for j = 1 to temp[4][i], print row, i
            for j = 1 to m inclusive
                for i = 1 to temp[3][j] inclusive, print col, j
        else
            print sum1
            for i = 1 to n inclusive
                for j = 1 to temp[1][i], print "row ", i
            for j = 1 to m inclusive
                for i = 1 to temp[2][j] inclusive, print "col ", j
        end of the block
    else if flag1 == 1
        let sum2 be integer with sum2 = 0
        for i = 1 to n inclusive, increment sum2 by temp[4][i]
        for j = 1 to n inclusive, increment sum2 by temp[3][j]
        print sum2
        for i = 1 to n inclusive
            for j = 1 to temp[4][i] inclusive, print "row ", i
        for j = 1 to m inclusive
            for i = 1 to temp[3][j] inclusive, print "col ", j
    else if flag2 == 1
        sum1 = int = 0
        for i = 1 to n inclusive, increment sum1 by temp[4][i]
        for j = 1 to n inclusive, increment sum1 by temp[3][j]
        print sum1
        for i = 1 to n inclusive
            for j = 1 to temp[1][i] inclusive, print "row ", i
        for j = 1 to m inclusive
            for i = 1 to temp[2][j] inclusive, print "col ", j
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

const int INF = 0x3f3f3f3f;
int main() {
    int n, m;
    cin >> n >> m;
    int ans[105][105] = {0}, ar[105][105] = {0};
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            cin >> ans[i][j];
            ar[i][j] = ans[i][j];
        }
    int mins = INF, sum = 0;
    int temp[6][200] = {0};
    for (int i = 1; i <= n; i++) {
        mins = INF;
        for (int j = 1; j <= m; j++) mins = min(mins, ans[i][j]);
        temp[1][i] = mins;
        for (int j = 1; j <= m; j++) ans[i][j] -= mins;
    }
    for (int j = 1; j <= m; j++) {
        mins = INF;
        for (int i = 1; i <= n; i++) mins = min(mins, ans[i][j]);
        temp[2][j] = mins;
        for (int i = 1; i <= n; i++) ans[i][j] -= mins;
    }
    for (int j = 1; j <= m; j++) {
        mins = INF;
        for (int i = 1; i <= n; i++) mins = min(mins, ar[i][j]);
        temp[3][j] = mins;
        for (int i = 1; i <= n; i++) ar[i][j] -= mins;
    }
    for (int i = 1; i <= n; i++) {
        mins = INF;
        for (int j = 1; j <= m; j++) mins = min(mins, ar[i][j]);
        temp[4][i] = mins;
        for (int j = 1; j <= m; j++) ar[i][j] -= mins;
    }
    int flag1 = 0, flag2 = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (ans[i][j] != 0) {
                flag1 = 1;
                break;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (ar[i][j] != 0) {
                flag2 = 1;
                break;
            }
        }
    }
    if (flag1 == 1 && flag2 == 1)
        cout << -1 << endl;
    else if (flag1 == 0 && flag2 == 0) {
        int sum1 = 0, sum2 = 0;
        for (int i = 1; i <= n; i++) {
            sum1 += temp[1][i];
            sum2 += temp[4][i];
        }
        for (int j = 1; j <= m; j++) {
            sum1 += temp[2][j];
            sum2 += temp[3][j];
        }
        if (sum1 > sum2) {
            cout << sum2 << endl;
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= temp[4][i]; j++) cout << "row " << i << endl;
            for (int j = 1; j <= m; j++)
                for (int i = 1; i <= temp[3][j]; i++) cout << "col " << j << endl;
        } else {
            cout << sum1 << endl;
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= temp[1][i]; j++) cout << "row " << i << endl;
            for (int j = 1; j <= m; j++)
                for (int i = 1; i <= temp[2][j]; i++) cout << "col " << j << endl;
        }
    } else if (flag1 == 1) {
        int sum2 = 0;
        for (int i = 1; i <= n; i++) { sum2 += temp[4][i]; }
        for (int j = 1; j <= m; j++) { sum2 += temp[3][j]; }
        cout << sum2 << endl;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= temp[4][i]; j++) cout << "row " << i << endl;
        for (int j = 1; j <= m; j++)
            for (int i = 1; i <= temp[3][j]; i++) cout << "col " << j << endl;
    } else if (flag2 == 1) {
        int sum1 = 0;
        for (int i = 1; i <= n; i++) { sum1 += temp[4][i]; }
        for (int j = 1; j <= m; j++) { sum1 += temp[3][j]; }
        cout << sum1 << endl;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= temp[1][i]; j++) cout << "row " << i << endl;
        for (int j = 1; j <= m; j++)
            for (int i = 1; i <= temp[2][j]; i++) cout << "col " << j << endl;
    }
    return 0;
}

9
row 1
row 2
row 3
row 4
row 6
row 7
row 8
row 9
row 10

9
col 1
col 2
col 3
col 4
col 5
col 6
col 8
col 9
col 10

7
row 1
row 2
row 3
row 5
col 1
col 2
col 3

7
row 1
row 2
row 3
col 1
col 2
col 3
col 5

10
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1

9
col 1
col 1
col 1
col 2
col 2
col 2
col 3
col 3
col 3

9
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1

11
row 2
row 3
row 3
row 4
row 4
row 4
row 5
row 5
row 5
row 5
col 1

15
col 1
col 1
col 1
col 1
col 1
col 2
col 2
col 2
col 2
col 2
col 2
col 2
col 2
col 2
col 2

12
row 2
row 2
col 1
col 1
col 1
col 2
col 2
col 2
col 2
col 3
col 3
col 3

15
row 1
row 1
row 1
row 1
row 1
row 1
row 1
row 1
row 1
row 1
row 2
row 2
row 2
row 2
row 2


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
declare long longs n, m, res, long long arrays a size 1010, c size 1010
define the main function
    read n, m
    for i = 1 to n inclusive, read c[i]
    for i = 1 to m inclusive, read a[i]
    declare long long neo = 1
    for i = 1 to m inclusive
        while neo is less than n and a[i] is less than c[neo], increment neo
        if c[neo] is less than or equal to a[i]
            increment res
            increment neo
        else
            end loop
        if neo is greater than n, end loop
    end of the block
    print res and newline
    return to indicate successful execution
end of the block

[CODE]:

long long n, m, a[1010], c[1010], res;
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> c[i];
    for (int i = 1; i <= m; i++) cin >> a[i];
    long long neo = 1;
    for (int i = 1; i <= m; i++) {
        while (neo < n && a[i] < c[neo]) neo++;
        if (c[neo] <= a[i]) {
            res++;
            neo++;
        } else
            break;
        if (neo > n) break;
    }
    cout << res << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create string str
    create integer array freq with size 26
    for i = 0 to 26 exclusive, set freq[i] to 0
    read str
    for i = 0 to size of str exclusive, increment freq[str[i]-'a']
    create integer sum with sum = 0
    for i = 0 to 26 exclusive
        if freq[i] is greater than 0, increment sum
    end of the block
    if sum % 2 is 0
        print "CHAT WITH HER!" print newline
    else
        print "IGNORE HIM!" print newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string str;
    int freq[26];
    for (int i = 0; i < 26; i++) freq[i] = 0;
    cin >> str;
    for (int i = 0; i < str.size(); i++) ++freq[str[i] - 'a'];
    int sum = 0;
    for (int i = 0; i < 26; i++) {
        if (freq[i] > 0) sum++;
    }
    if (sum % 2 == 0)
        cout << "CHAT WITH HER!" << endl;
    else
        cout << "IGNORE HIM!" << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    a, b, c, d =integers
    Read a, b, c, d
    set a = maximum value of 3 * a / 10 and a - a * c / 250
    set b = maximum value of 3 * b / 10 and b - b * d / 250
    if a is greater than b
        print Misha and a new line
    else if b is greater than a
        print Vasya and a new line
    else do the following
        print Tie and a new line
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a = max(3 * a / 10, a - a * c / 250);
    b = max(3 * b / 10, b - b * d / 250);
    if (a > b)
        cout << "Misha" << endl;
    else if (b > a)
        cout << "Vasya" << endl;
    else
        cout << "Tie" << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n =integer
    Read n
    ch = character
    counter_A = integer with 0
    counter_D = integer with 0
    while n is greater than 0
        Read ch
        if ch is equal to A
            increment counter_A
        else do the following
            increment counter_D
        decrement n
    end of the block
    if counter_A is greater than counter_D
        print Anton and a new line
    lse if counter_D is greater than counter_A
        print Danik and a new line
    else do the following
        print Friendship and a new line
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    char ch;
    int counter_A = 0;
    int counter_D = 0;
    while (n > 0) {
        cin >> ch;
        if (ch == 'A')
            counter_A++;
        else
            counter_D++;
        n--;
    }
    if (counter_A > counter_D)
        cout << "Anton\n";
    else if (counter_D > counter_A)
        cout << "Danik\n";
    else
        cout << "Friendship\n";
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create integers n, m, startx, starty, finishx, finishy, with startx=55, starty=55
create 2d character array st with size 55 by 55
define the main function
    read n read m
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            read st[i][j]
            if st[i][j] is '*'
                set startx to minimum of startx and i
                set starty to minimum of starty and j
                set finishx to maximum of finishx and i
                set finishy to maximum of finishy and j
            end of the block
        end of the block
    for i = startx to finishx inclusive
        for j = starty to finishy inclusive, print st[i][j]
        print newline
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int n, m, startx = 55, starty = 55, finishx, finishy;
char st[55][55];
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            cin >> st[i][j];
            if (st[i][j] == '*') {
                startx = min(startx, i);
                starty = min(starty, j);
                finishx = max(finishx, i);
                finishy = max(finishy, j);
            }
        }
    for (int i = startx; i <= finishx; i++) {
        for (int j = starty; j <= finishy; j++) { cout << st[i][j]; }
        cout << endl;
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create int n, a[1001]
define the main function
    read n
    for i=1 to n inclusive, read a[i]
    ans=0
    for i=2 to n exclusive
        if a[i] > a[i + 1] and a[i] > a[i - 1]
            increment ans
            continue
        end of the block
        if a[i] < a[i + 1] and a[i] < a[i - 1], increment ans
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create long long n and a
    read n
    if n is even
        a= n/2
    else
        set ((n + 1) / 2) * (-1)
    print a
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long n, a;
    cin >> n;
    if (n % 2 == 0)
        a = n / 2;
    else
        a = ((n + 1) / 2) * (-1);
    cout << a << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    sum and cost are integers= 0
    let n be integer
    read n
    integer array out with size [n + 1] filled with 0
    integer array in with size [n + 1] filled with 0
    for integer i = 0 to n exclusive
        create integers a, b and c
        read a, b and c
        if out[a] or in[b]
            increase sum by c
            set out[b] to 1
            in[a] = 1
        else
            set value of out[a] to 1
            set value of in[b] to 1
        end of the block
        increase cost by c
    end of the block
    print min of cost - sum and sum and a new line
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int sum = 0, cost = 0;
    int n;
    cin >> n;
    int out[n + 1] = {0};
    int in[n + 1] = {0};
    for (int i = 0; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if (out[a] || in[b]) {
            sum += c;
            out[b] = 1;
            in[a] = 1;
        } else {
            out[a] = 1;
            in[b] = 1;
        }
        cost += c;
    }
    cout << min(cost - sum, sum) << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create integers n, k
    create string s
    read n read k
    read s
    create integer vector t initialized with k
    for i = 0 to n exclusive, increment t[s[i] - 'A']
    create integer min with min = n + 1
    create boolean b with b = 0
    for i = 0 to k exclusive
        if t[i] is 0, set b to 1
        if t[i] is less than min, set min to t[i]
    end of the block
    if b is true
        print "0" print newline
    else
        print min * k print newline
end of the block

[CODE]:

int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    vector<int> t(k);
    for (int i = 0; i < n; i++) { t[s[i] - 'A']++; }
    int min = n + 1;
    bool b = 0;
    for (int i = 0; i < k; i++) {
        if (t[i] == 0) b = 1;
        if (t[i] < min) min = t[i];
    }
    if (b)
        cout << "0" << endl;
    else
        cout << min * k << endl;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
k = long long and a, b = long long array of size 3 each
define the main function
    read a[0] then a[1] then a[2] then k
    set k to min of k and a[0] + a[1] + a[2] - 3
    sort a
    set all values of b to k / 3
    for i = 0 to k % 3 increment b[2 - i]
    for i = 0 to 2
        if b[i] is greater or equal to a[i]
            increment b[2] by b[i] - (a[i] - 1)
            set b[i] to a[i] - 1
        end of the block
    end of the block
    loop while b[2] - 1 is greater or equal to b[1] + 1 and b[1] + 1 is less than a[1] incrementing b[1] and decrementing b[2]
    print (b[0] + 1) * (b[1] + 1) * (b[2] + 1)
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
declare integer array arr size 10000
declare integer veector v
declare integer array brr size 10000
define the main function
    declare integer n
    read n
    for i = 1 to n inclusive
        declare integer m
        read m
        let arr[i] be m
        add m to end of v
    end of the block
    sort from beginning of v to end of v
    declare integers idx = 1, cur
    for i = n - 1 to 0 inclusive, decrementing i
        if i is n - 1
            let cur be v[i]
            let brr[idx] be v[i]
        else
            if cur is not v[i]
                let brr[idx] be v[i]
                let cur be v[i]
            end of the block
        end of the block
        increment idx
    end of the block
    for i = 1 to n inclusive
        for j = 1 to n inclusive
            if arr[i] is brr[j] and arr[i] is not 0 and brr[j] is not 0
                if i is n
                    print j and newline
                else
                    print j and " "
                end of the block
            end of the block
        end of the block
    end of the block
end of the block

[CODE]:

int arr[10000];
vector<int> v;
int brr[10000];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int m;
        cin >> m;
        arr[i] = m;
        v.push_back(m);
    }
    sort(v.begin(), v.end());
    int idx = 1, cur;
    for (int i = n - 1; i >= 0; i--) {
        if (i == n - 1) {
            cur = v[i];
            brr[idx] = v[i];
        } else {
            if (cur != v[i]) {
                brr[idx] = v[i];
                cur = v[i];
            }
        }
        idx++;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (arr[i] == brr[j] && arr[i] != 0 && brr[j] != 0) {
                if (i == n) {
                    cout << j << endl;
                } else {
                    cout << j << " ";
                }
            }
        }
    }
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create integers n, x, y, z, xsum(0), ysum(0), zsum(0)
    read n
    decrement n and loop while n > 0
        read x, y and z
        increase xsum by x
        increase ysum by y
        increase zsum by z
    end of the block
    if xsum = 0 && ysum = 0 && zsum = 0
        print "YES"
    else
        print "NO"
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, x, y, z, xsum(0), ysum(0), zsum(0);
    cin >> n;
    while (n--) {
        cin >> x >> y >> z;
        xsum += x;
        ysum += y;
        zsum += z;
    }
    if (xsum == 0 && ysum == 0 && zsum == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    declare integers n, res = 0, cur, x, y
    read n
    declare integer vectors a initialized with n, b initialized with n
    for i = 0 to n exclusive, read a[i]
    for i = 0 to n exclusive, read b[i]
    for i = 0 to n exclusive
        let x be 0
        let y be 0
        for j = 0 to n exclusie
            let x be x bitwise or a[j]
            let y be y bitwise or b[j]
            let cur be x + y
            let res be maximum of ( res and cur )
        end of the block
    end of the block
    print res and newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, res = 0, cur, x, y;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) { cin >> a[i]; }
    for (int i = 0; i < n; i++) { cin >> b[i]; }
    for (int i = 0; i < n; i++) {
        x = 0;
        y = 0;
        for (int j = i; j < n; j++) {
            x |= a[j];
            y |= b[j];
            cur = x + y;
            res = max(res, cur);
        }
    }
    cout << res << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
PI is a new constant double = acos of -1.0
set constant integer inf to 1e9 casted to int
declare new constant integer mod with value inf + 7
declare long longs n, m, k, l, w, h, sum, mx and mn
define the main function
    assign 1e9 to mn
    create new strings a and b
    read variables a and b from the input
    if a = b
        print a
    else
        print 1
    print new line
    return to indicate successful execution
end of the block

[CODE]:

const double PI = acos(-1.0);
const int inf = int(1e9);
const int mod = inf + 7;
long long n, m, k, l, w, h, sum, mx, mn;
int main() {
    mn = (1e9);
    string a, b;
    cin >> a >> b;
    if (a == b)
        cout << a;
    else
        cout << 1;
    cout << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create strings str1, str2, str3, str4
    read str1 read str2 read str3
    set str4 to str2
    create integers flag, flag1 with flag = 0, flag1 = 0
    if str1[0] is str3[2] and str1[1] is str3[1] and str1[2] is str3[0], set flag to 1
    if str2[0] is str2[2] and str2[1] is str2[1] and str2[2] is str2[0], set flag1 to 1
    if flag and flag1
        print "YES" print newline
    else
        print "NO" print newline
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    let n, m, min1, max1, simmin , summax , o be integers with simmin = 0, summax = 0
    create a vector of integers by name of
    read n, m, min1, max1
    for integer y = 0 to m exclusive
        read o
        push_back o into of
    end of the block
    sort the values of.begin(), of.end()
    if min1 is not equal to of[0] , increment simmin by 1
    if min1 is greater than of[0]
        print Incorrect and newline
        return to indicate successful execution
    end of the block
    if max1 is less than of[m - 1]
        print Incorrect and newline
        return to indicate successful execution
    end of the block
    if max1 is not equal to of[m - 1] , increment summax by 1
    let sum be a integer with sum = simmin + summax
    if sum + m <= n
        print Correct and newline
        return to indicate successful execution
    else do the following
        print Incorrect and newline
        return to indicate successful execution
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, m, min1, max1, simmin = 0, summax = 0, o;
    vector<int> of;
    cin >> n >> m >> min1 >> max1;
    for (int y = 0; y < m; y++) {
        cin >> o;
        of.push_back(o);
    }
    sort(of.begin(), of.end());
    if (min1 != of[0]) { simmin++; }
    if (min1 > of[0]) {
        cout << "Incorrect" << endl;
        return 0;
    }
    if (max1 < of[m - 1]) {
        cout << "Incorrect" << endl;
        return 0;
    }
    if (max1 != of[m - 1]) { summax++; }
    int sum = simmin + summax;
    if (sum + m <= n) {
        cout << "Correct" << endl;
        return 0;
    } else {
        cout << "Incorrect" << endl;
        return 0;
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
n is an integer
chair be a character array of size 10000
define the main function
    read n
    a is an integer
    read input as chair+1
    let chair[0] be 0
    let chair[n+1] be 0
    let ans be integer with ans = 0
    if n=1 and chair[1]=0,
        print No and new line
        return to indicate successful execution
    end of the block
    if n=1 and chair[1]=1
        print Yes and new line
        return to indicate successful execution
    end of the block
    for integer i = 1 to n inclusive
        if chair[i] = 1 and either chair[i - 1] = 1 or chair[i + 1] =1
            let ans be 1
            stop
        end of the block
        if chair[i]=0,
            if chair[i - 1]= 0 and chair[i + 1] = 0,
                let ans be 1
                stop
            end of the block
        end of the block
    end of the block
    if ans equals 1,
        print No and new line
    else
        print yes and newline
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n = integer
    read n
    xay = character array of size n
    z = integers with z = 0
    for i = 0 to n exclusive
        s = character
        read xay[i]
        if xay[i] and s
            increment z
            s = 0
        else
            s = 0
        end of the block
        s = xay[i]
    end of the block
    print z
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    char xay[n];
    int z = 0;
    for (int i = 0; i < n; i++) {
        char s;
        cin >> xay[i];
        if (xay[i] == s) {
            z++;
            s = '\0';
        } else {
            s = '\0';
        }
        s = xay[i];
    }
    cout << z << endl;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n, t, k, d = int
    read n then t then k then d
    limit = long long with limit = ((n + k - 1) / k - 1) * t
    if d is less than limit
        print "YES"
    else
        print "NO"
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, t, k, d;
    cin >> n >> t >> k >> d;
    long long limit = ((n + k - 1) / k - 1) * t;
    if (d < limit) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create integers a, b, x
    read a read b
    create string array die_roll with size 6, with die_roll = {"1/6", "1/3", "1/2", "2/3", "5/6", "1/1"}
    set x to maximum of a and b
    print die_roll[6-x] print newline
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create integer test with test = 1
    while decrement test is true
        create integers n, m, i, j, x, y, s, k, q, a, b, c with c = 0
        create long long integer sum with sum = 0
        read n
        for i = 0 to n exclusive
            read k
            increment sum by k
            set c to maximum of c and k
        end of the block
        set j to 1 if sum % ( n - 1 ) is greater than 0, else 0
        set sum to sum / ( n - 1 ) + j
        set sum to sum if sum is greater than c, else c
        print sum print "\n"
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int test = 1;
    while (test--) {
        int n, m, i, j, x, y, s, k, q, a, b, c = 0;
        long long int sum = 0;
        cin >> n;
        for (i = 0; i < n; i++) {
            cin >> k;
            sum += k;
            c = max(c, k);
        }
        j = sum % (n - 1) > 0 ? 1 : 0;
        sum = sum / (n - 1) + j;
        sum = sum > c ? sum : c;
        cout << sum << "\n";
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
function bigmod with long long arguments a, p and m that returns long long
    if p = 0, return 1 modulo m
    declare new long long called x = result of bigmod(a, p/2, m)
    change x to x squared % m
    if p is odd, assign (x * a) modulo m to x
    return x modulo m
end of the block
create an array of long longs m with 256 elements, q with 266 elements and 2d array v with size 10009 by 266
define the main function
    create new strings a and b
    read input to a and b
    prepend " " to a
    start for loop from i = 'a' to 'z' inclusive, setting q[i] to length of a on each loop iteration
    start for loop from i = length of a to 0 inclusive decrementing i
        assign value of 1 to m[a[i]]
        in a for loop, change j from 'a' to 'z' inclusive, assigning q[j] to v[i][j] on each iteration
        set value of q[a[i]] to i
    end of the block
    declare new long longs c = 0 and an = 1
    for i from 0 to length of b - 1 inclusive incrementing i
        if m[b[i]] is equal to 0, return 0 and print "-1"
        assign v[c][b[i]] to c
        if c = length of a
            increment an
            change c to v[0][b[i]]
        end of the block
    end of the block
    print an to the standard output
end of the block

[CODE]:

long long bigmod(long long a, long long p, long long m) {
    if (p == 0) return 1 % m;
    long long x = bigmod(a, p / 2, m);
    x = (x * x) % m;
    if (p % 2) x = (x * a) % m;
    return x % m;
}
long long v[10009][266], q[266], m[256];
int main() {
    string a, b;
    cin >> a >> b;
    a = " " + a;
    for (int i = 'a'; i <= 'z'; i++) q[i] = a.size();
    for (int i = a.size(); i >= 0; i--) {
        m[a[i]] = 1;
        for (int j = 'a'; j <= 'z'; j++) v[i][j] = q[j];
        q[a[i]] = i;
    }
    long long c = 0, an = 1;
    for (int i = 0; i <= b.size() - 1; i++) {
        if (m[b[i]] == 0) return 0 & puts("-1");
        c = v[c][b[i]];
        if (c == a.size()) {
            an++;
            c = v[0][b[i]];
        }
    }
    cout << an << endl;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    str is a new array of characters with 100 elements
    declare integers dif and ans with ans = 0
    read str
    declare new integer called len = length of str
    declare character cur = 'a'
    in a for loop, change i from 0 to len exclusive
        assign absoluve value of str[i] - cur to dif
        change ans to ans + min of dif and 26 - dif
        assign str[i] to cur
    end of the block
    print ans
end of the block

[CODE]:

int main() {
    char str[100];
    int dif, ans = 0;
    gets(str);
    int len = strlen(str);
    char cur = 'a';
    for (int i = 0; i < len; i++) {
        dif = abs(str[i] - cur);
        ans += min(dif, 26 - dif);
        cur = str[i];
    }
    cout << ans << endl;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n = integer
    read n
    C = boolean array of sizes 5, 5 with C = {}
    color = string = "RGBYW"
    value = string = "12345"
    for i = 0 to n exclusive
        declare a string c
        read c
        for i = 0 to 5 exclusive
            for j = 0 to 5 exclusive
                if c[0] equals color[i] and c[1] equals value[j], set C[i][j] to true
    end of the block
    ans = integer set to 25
    for bc = 0 as long as bc is less than 1 shifted left 5 bits with increment bc + 1
        for bv = 0 as long as bv is less than 1 shifted left 5 bits with increment bv + 1
            ok = boolean = true
            for c = 0 to 5 exclusive
                if bc shifted left c bitwise and 1 bits
                    t = integer = 0
                    for v = 0 to 5 exclusive
                        if bv shifted right v bitwise and 1 bits is false, add integer value of C[c][v] to t
                    if t is greater than 1, set ok to false
                end of the block
            for v = 0 to 5 exclusive
                if bv shifted right v bitwise and 1 bits
                    t = integer = 0
                    for c = 0 to 5 exclusive
                        if bc shifted right c bitwise and 1 bits is false, add integer value of C[c][v] to t
                    if t is greater than 1, set ok to false
                end of the block
            t = integer = 0
            for c = 0 to 5 exclusive
                for v = 0 to 5 exclusive
                    if not (bc shifted right c bitwise and 1 bits) and not (bv shifted right v bitwise and 1 bits), add integer value of C[c][v] to t
            if t is greater than 1, set ok to false
            if ok
                a = integer set to 0
                for i = 0 to 5 exclusive, add (bc shifted right i bitwise and 1 bits) + (bv shifted right i bitwise and 1 bits) to a
                set ans to call min with ans, a
            end of the block
        end of the block
    display ans
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    bool C[5][5] = {};
    string color = "RGBYW";
    string value = "12345";
    for (int i = 0; i < n; i++) {
        string c;
        cin >> c;
        for (int i = 0; i < 5; i++)
            for (int j = 0; j < 5; j++)
                if (c[0] == color[i] && c[1] == value[j]) C[i][j] = true;
    }
    int ans = 25;
    for (int bc = 0; bc < 1 << 5; bc++)
        for (int bv = 0; bv < 1 << 5; bv++) {
            bool ok = true;
            for (int c = 0; c < 5; c++)
                if (bc >> c & 1) {
                    int t = 0;
                    for (int v = 0; v < 5; v++)
                        if (!(bv >> v & 1)) t += (int)C[c][v];
                    if (t > 1) ok = false;
                }
            for (int v = 0; v < 5; v++)
                if (bv >> v & 1) {
                    int t = 0;
                    for (int c = 0; c < 5; c++)
                        if (!(bc >> c & 1)) t += (int)C[c][v];
                    if (t > 1) ok = false;
                }
            int t = 0;
            for (int c = 0; c < 5; c++)
                for (int v = 0; v < 5; v++)
                    if (!(bc >> c & 1) && !(bv >> v & 1)) t += (int)C[c][v];
            if (t > 1) ok = false;
            if (ok) {
                int a = 0;
                for (int i = 0; i < 5; i++) a += (bc >> i & 1) + (bv >> i & 1);
                ans = min(ans, a);
            }
        }
    cout << ans << endl;
}

W4 Y1 W5 R4 W3 Y1 R4 W2 G3 G1 B5 Y5 Y2 Y3 G4 B5 W1 G5 Y5 Y3 G2 Y5 Y5 G5 R2 B3 B1 W5 Y1 W5 B4 W4 R4 B1 R1 W3 R5 R4 G2 W3 W3 R2 W5 Y2 B2 R3 R3 Y1 G5 G2 Y1 R4 Y5 W5 G5 B3 W2 R1 B2 W2 W2 Y5 W3 G1 B1 G2 Y3 W3 G1 W5 W1 G5 G2 Y1 W5 B5 W4 Y5 G2 R3 B4 R5 B1 R1 B4 Y4 Y4 Y3 R5 Y3 B3 W5 R5 Y5 G2 G5 W5 B4 G4 W5

B5 G3 Y2 W3 W1 G1 Y4 G3 G4 B5 W4 B5 Y3 R5 B4 G4 G4 B1 G1 R5 G4 B4 G1 G2 W1 Y4 R5 Y3 W5 W4 Y5 W1 B4 G3 R2 R3 W1 B4 Y4 G2 G2 R1 Y5 W1 Y3 B3 G5 Y3 G3 W2 W5 Y4 B2 Y5 R4 B2 Y3 W4 G2 G3 R2 W1 B4 B2 B1 Y2 Y2 Y3 W3 Y5 W1 R1 R1 R4 R4 R4 Y1 Y3 B2 Y3 Y1 R3 G4 G4 Y5 B5 W2 G1 G5 B3 G1 Y1 R2 G5 R2 Y5 R5 Y4 R4 W2

Y3 Y3 Y5 Y2 Y4 Y1 Y2 Y3 Y1 Y5 Y3 Y1 Y4 Y5 Y5 Y3 Y1 Y5 Y2 Y3 Y1 Y4 Y4 Y1 Y2 Y2 Y4 Y2 Y4 Y5 Y5 Y2 Y3 Y1 Y3 Y5 Y3 Y1 Y5 Y3 Y3 Y2 Y5 Y1 Y5 Y5 Y4 Y2 Y2 Y1 Y2 Y4 Y3 Y2 Y5 Y3 Y4 Y3 Y1 Y4 Y2 Y4 Y4 Y3 Y3 Y1 Y1 Y4 Y2 Y5 Y3 Y4 Y4 Y4 Y3 Y2 Y2 Y2 Y3 Y4 Y4 Y2 Y1 Y2 Y2 Y4 Y3 Y5 Y4 Y2 Y5 Y3 Y1 Y5 Y2 Y5 Y4 Y1 Y2 Y1

G3 B3 G3 Y3 R3 G3 R3 G3 W3 B3 B3 B3 R3 Y3 Y3 W3 R3 B3 G3 W3 G3 W3 Y3 R3 Y3 W3 W3 G3 W3 G3 W3 Y3 G3 R3 Y3 W3 W3 Y3 Y3 Y3 R3 W3 R3 G3 W3 W3 G3 Y3 B3 W3 B3 Y3 G3 Y3 B3 Y3 W3 Y3 R3 Y3 R3 W3 W3 W3 G3 Y3 G3 R3 B3 R3 Y3 R3 Y3 R3 Y3 R3 Y3 R3 W3 Y3 R3 W3 W3 W3 G3 G3 Y3 B3 Y3 R3 G3 G3 B3 B3 Y3 R3 G3 R3 W3 G3

W5 Y5 Y3 W3 Y5 Y5 W5 W5 Y3 W5 Y5 Y3 W5 Y5 W5 W3 Y3 Y5 W3 W5 Y5 W3 Y5 Y3 W3 W3 Y3 Y5 W3 W3 Y3 Y5 W3 Y5 Y5 Y5 W5 Y5 W5 Y5 W5 W5 W3 W5 W3 Y3 W5 W3 W3 W5 Y3 Y5 W5 W5 W3 W5 W5 Y5 W5 W3 W3 W3 Y3 Y5 Y5 Y3 Y5 W5 W5 Y5 W3 W3 W5 Y5 Y5 Y3 W5 W5 W3 Y5 W3 W5 Y3 Y5 W5 Y3 Y3 W3 Y3 Y5 Y3 Y3 W5 Y5 Y3 Y5 Y3 W3 Y3 W5

Y5 Y5 Y3 Y5 Y3 Y5 Y5 Y5 Y3 Y3 Y5 Y3 Y3 Y5 Y3 Y3 Y5 Y3 Y3 Y5 Y3 Y5 Y5 Y3 Y3 Y5 Y3 Y5 Y3 Y3 Y3 Y5 Y3 Y3 Y3 Y3 Y3 Y3 Y3 Y5 Y5 Y5 Y5 Y3 Y5 Y5 Y5 Y5 Y3 Y3 Y3 Y5 Y5 Y3 Y3 Y3 Y5 Y3 Y3 Y5 Y3 Y3 Y3 Y5 Y3 Y5 Y5 Y5 Y5 Y3 Y3 Y5 Y5 Y5 Y5 Y5 Y5 Y5 Y5 Y3 Y5 Y5 Y5 Y5 Y5 Y5 Y3 Y5 Y3 Y5 Y5 Y5 Y5 Y5 Y5 Y3 Y3 Y3 Y5 Y5

Y3 Y3 Y3 W3 W3 Y3 Y3 W3 Y3 Y3 W3 Y3 Y3 Y3 W3 Y3 Y3 W3 Y3 Y3 Y3 W3 Y3 W3 W3 W3 W3 W3 Y3 Y3 W3 Y3 Y3 W3 W3 Y3 Y3 W3 Y3 Y3 W3 W3 W3 W3 W3 Y3 Y3 Y3 Y3 W3 Y3 Y3 W3 W3 W3 Y3 W3 W3 W3 Y3 Y3 Y3 Y3 W3 W3 W3 W3 W3 Y3 Y3 W3 Y3 W3 Y3 Y3 Y3 Y3 Y3 Y3 Y3 W3 W3 W3 W3 Y3 W3 Y3 Y3 Y3 Y3 Y3 Y3 Y3 Y3 W3 Y3 Y3 W3 W3 Y3

G5 G5 G3 G2 G3 Y3 W3 Y3 G5 W5 G2 G2 W5 G5 G5 W3 G3 G2 Y3 W5 W3 G5 W5 G2 Y2 Y3 W5 G3 W3 W2 G2 W3 Y2 G3 G3

G3 G2 G5 G2 W2 G3 W2 W5 Y5 G5 W2 W2 W2 G5 Y2 G5 W5 W3 W2 Y2 G5 W5 W3 W5 Y2 Y5 W2 W2 W3 Y3 G2 W3 G5 G3 W2

W2 W3 Y2 G5 G2 W3 G5 Y2 W5 Y5 W3 G2 G3 W5 W2 W3 Y2 Y5 Y2 Y5 Y2 Y2 G2 Y5 W3 Y5 G3 Y2 G3 Y2 Y5 W5 G3 W5 W5

Y2 Y3 Y2 Y3 Y5 Y5 Y3 Y5 Y5 Y2 Y2 Y5 Y2 Y2 Y5 Y3 Y2 Y5 Y5 Y3 Y3 Y2 Y2 Y2 Y3 Y5 Y2 Y5 Y5 Y3 Y5 Y2 Y3 Y3 Y2

Y5 Y5 W5 Y5 W3 Y3 W5 W3 W5 W3 W5 Y5 Y3 W3 W5 W5 W5 W3 Y5 Y3 Y5 W5 W5 Y3 Y5 Y5 Y3 W5 W3 W3 W3 W5 Y5 W3 W5

G3 G3 W3 W3 G3 G3 Y3 G3 Y3 Y3 G3 W3 Y3 G3 W3 Y3 W3 Y3 Y3 Y3 Y3 G3 G3 Y3 Y3 G3 G3 G3 G3 G3 Y3 W3 W3 W3 G3

R2 R2 R2 R2 G3 G2 Y3 G2 R3 W5 G4 Y3 Y3 G2 Y5 W5 G4 G2 W4 Y2 W3 R5 W5 G4 G4 Y2 G2 Y5 G2 Y4 W3 G5 G2 R3 G4

G2 Y1 Y1 R4 G5 B5 R2 G4 G2 G3 W4 W1 B3 W5 R2 Y5 R4 R4 B5 Y2 B4 B1 R3 G4 Y3 G2 R4 G3 B2 G2 R3 B2 R1 W2 B4

W4 Y5 Y3 Y3 R5 W3 R5 W2 R5 Y2 R2 Y2 G2 G3 Y4 Y4 R4 Y3 G2 W2 R2 R3 Y3 W5 W2 G4 R3 R3 W2 W5 Y4 R3 W2 R4 R2

Y3 Y3 Y3 Y3 Y3 Y3 W3 G3 G3 G3 W3 G3 G3 Y3 Y3 W3 G3 G3 Y3 W3 W3 Y3 Y3 G3 W3 W3 G3 Y3 Y3 W3 G3 W3 G3 W3 G3

W3 Y3 W3 W5 Y5 W3 W3 Y5 W3 W3 W3 W5 W3 Y3 Y5 Y3 Y5 Y3 W3 W3 W5 W5 W3 Y5 W3 W3 Y3 W3 W5 W3 Y3 Y3 Y5 Y5 Y3

Y3 R2 R2 Y2 Y5 Y4 B3 B3 Y4 W3 R1 W3 W5 B5 R1 Y4 B4 B5 B3 G3 B1 R2 R4 G5 Y5

W5 R1 Y3 G5 G3 G5 W2 Y1 R3 R4 B3 G5 G2 Y2 W1 G2 Y1 B4 Y2 G3 G3 Y4 W3 W5 Y2

Y1 W2 G3 W1 G1 G3 G4 W1 B2 W3 R4 B1 G2 Y4 G1 R2 R3 Y4 B2 G4 W2 Y2 R2 Y5 R4

B3 Y1 R3 Y3 R5 B4 B3 G1 R1 B4 B5 W3 R4 W1 B3 Y3 B3 Y4 B2 G5 Y1 G5 R4 B5 Y1

G4 R4 Y1 Y4 R3 B5 W2 G4 B5 B2 G1 B4 R4 G2 Y3 Y4 G5 Y3 R1 G2 Y5 G3 Y3 Y4 W3

R1 R3 G1 B5 Y5 W3 R4 R4 R1 G3 R2 W1 B1 G2 W2 G4 R2 W3 B1 W3 B5 Y5 R2 B4 B5

Y3 R4 G1 W1 R3 R2 W4 W1 R5 Y4 G3 R5 Y2 W1 Y1


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n, k, x, y, z = long long
    read n, k
    x = n / 2
    if (k + 1) > x
        print 0," ",0," ",n
    else
        y = x / (k + 1)
        z = y * k
        print y," ",z," ",(n - (z + y))
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    let q and b be long long
    let s be a char
    let num1 and num2 be long long = 0
    read q
    for long long i = 0 to q exclusive
        read n
        read s
        set num1 to s - 48
        if n is 2
            read s
            set num2 to s - 48
            is num1 >= num2
                print NO
            else
                print YES
                print 2
                print num1 and space and num2
            end of the block
        else
            print YES
            print 2
            print num1 and space
            for long long j = 1 to n excluded
                read s
                print s
            end of the block
            print new line
            set num2 to 0
            set num1 to 0
        end of the block
    end of the block
end of the block

[CODE]:

int main() {
    long long q, n;
    char s;
    long long num1, num2 = 0;
    cin >> q;
    for (long long i = 0; i < q; i++) {
        cin >> n;
        cin >> s;
        num1 = s - 48;
        if (n == 2) {
            cin >> s;
            num2 = s - 48;
            if (num1 >= num2)
                cout << "NO" << endl;
            else {
                cout << "YES" << endl;
                cout << 2 << endl;
                cout << num1 << " " << num2 << endl;
            }
        } else {
            cout << "YES" << endl;
            cout << 2 << endl;
            cout << num1 << " ";
            for (long long j = 1; j < n; j++) {
                cin >> s;
                cout << s;
            }
            cout << endl;
            num2 = 0;
            num1 = 0;
        }
    }
}

NO
YES
2
1 2
YES
2
1 3
YES
2
1 4
YES
2
1 5
YES
2
1 6
YES
2
1 7
YES
2
1 8
YES
2
1 9
NO
NO
YES
2
2 3
YES
2
2 4
YES
2
2 5
YES
2
2 6
YES
2
2 7
YES
2
2 8
YES
2
2 9
NO
NO
NO
YES
2
3 4
YES
2
3 5
YES
2
3 6
YES
2
3 7
YES
2
3 8
YES
2
3 9
NO
NO
NO
NO
YES
2
4 5
YES
2
4 6
YES
2
4 7
YES
2
4 8
YES
2
4 9
NO
NO
NO
NO
NO
YES
2
5 6
YES
2
5 7
YES
2
5 8
YES
2
5 9
NO
NO
NO
NO
NO
NO
YES
2
6 7
YES
2
6 8
YES
2
6 9
NO
NO
NO
NO
NO
NO
NO
YES
2
7 8
YES
2
7 9
NO
NO
NO
NO
NO
NO
NO
NO
YES
2
8 9


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n, c = long long with c = 0
    read n
    while decrement n
        p, q = long long with p = 0, q = 0
        read p, q
        if (q - p >= 2), increment c
    end of the block
    print c
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long n, c = 0;
    cin >> n;
    while (n--) {
        long long p = 0, q = 0;
        cin >> p >> q;
        if (q - p >= 2) c++;
    }
    cout << c << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create long longs n, m and a
    read n, m and a
    long long stones = (n / a) * (m / a)
    if n % a != 0 add m / a to stones
    if m % a != 0 add n / a to stones
    if m % a != 0 && n % a != 0 add 1 to stones
    print stones and a new line
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long n, m, a;
    cin >> n >> m >> a;
    long long stones = (n / a) * (m / a);
    if (n % a != 0) { stones += m / a; }
    if (m % a != 0) { stones += n / a; }
    if (m % a != 0 && n % a != 0) { ++stones; }
    cout << stones << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    i, j, n, max, count = ints with count = 1
    let a be a long long int array of length 100005
    read n
    set max to 1
    for i = 0 to n exclusive
        read a at i
        if a[i-1] < a at i and i isn't 0
            increment count
            if max < count the set max to count
        else
            set count to 1
    end of the block
    print max
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int i, j, n, max, count = 1;
    long long int a[100005];
    cin >> n;
    max = 1;
    for (i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i - 1] < a[i] && i != 0) {
            count++;
            if (max < count) max = count;
        } else
            count = 1;
    }
    cout << max << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    let t be a integer
    read t
    while t is true
        let n be a integer
        read n
        the double value of k = 3.0
        the double value of ans = 0.0
        while the condition is true
            ans is equal to ((k - 2.0) * 180.0) / k
            if n equals ans
                print YES and newline
                stop
            else if ans is greater than n
                print NO and newline
                stop
            end of the block
            increment k by 1
        end of the block
        decrement t by 1
    end of the block
end of the block

[CODE]:

int main() {
    int t;
    cin >> t;
    while (t) {
        int n;
        cin >> n;
        double k = 3.0;
        double ans = 0.0;
        while (1) {
            ans = ((k - 2.0) * 180.0) / k;
            if (n == ans) {
                cout << "YES" << endl;
                break;
            } else if (ans > n) {
                cout << "NO" << endl;
                break;
            }
            k++;
        }
        t--;
    }
}

YES NO NO NO NO NO NO YES NO NO NO YES YES NO NO YES NO YES NO NO

NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO

YES NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO

YES NO NO NO NO NO NO NO NO NO NO NO YES YES NO NO NO NO NO NO

NO NO YES NO NO NO YES NO NO NO NO NO YES NO NO YES NO YES NO NO

NO NO NO NO NO NO YES NO NO NO NO YES NO NO NO


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
in function fastpow with arguments of long long base and long long exp that returns a long long
    res = long long = 1
    while exp > 0
        if exp is odd, then res = (res * base) modulo 1000000009
        base = (base * base) % 1000000009
        exp = exp / 2
    end of the block
    return res modulo 1000000009
end of the block
in function ask with argument of long long a that returns a long long
    print 1 a
    x = long long
    read x
    return x
end of the block
define the main function
    testcases = long long
    read testcases
    while looping decrease testcases by 1
        a, b, k = long long
        read a, b, k
        if k is even
            print (k / 2) * (a - b)
        else
            print ((k - 1) / 2) * (a - b) + a
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

long long fastpow(long long base, long long exp) {
    long long res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % 1000000009;
        base = (base * base) % 1000000009;
        exp /= 2;
    }
    return res % 1000000009;
}
long long ask(long long a) {
    cout << 1 << " " << a << endl;
    long long x;
    cin >> x;
    return x;
}
int main() {
    long long testcases;
    cin >> testcases;
    while (testcases--) {
        long long a, b, k;
        cin >> a >> b >> k;
        if (k % 2 == 0) {
            cout << (k / 2) * (a - b) << endl;
        } else {
            cout << ((k - 1) / 2) * (a - b) + a << endl;
        }
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    l, r = long long
    read l, r
    if r - l + 1 < 3
        print -1
        return to indicate successful execution
    end of the block
    if l modulo 2 is 0
        print l,' ',l + 1,' ',l + 2
        return to indicate successful execution
    end of the block
    if r - l + 1 > 3
        print l + 1,' ',l + 2,' ',l + 3
        return to indicate successful execution
    end of the block
    print -1
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    let s, s1 be strings
    let n,k be integers
    read n,k
    if (k is greater than n or (k is equal to 1 and n is greater than 1)) , and print -1 and endline , return 0
    if (k is equal to 1) print a and endline, return 0
    for( i=1 to k - 2 inclusive), s is equal to s + b + i
    for( i=1 to n- k +2 inclusive), s1 = s1 + (if i modulus 2 ) ? a else b
    print s1 and s and newline
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create int n, i and arrays p and s of length 100100
    read n
    for i=2 to n inclusive, read p[i]
    for i=1 to n inclusive, read s[i]
    for i=2 to n inclusive
        if s[i] = -1, continue the loop
        s[p[i]] = -1
            set s[p[i]] = s[i]
        else
            s[p[i]] = min of s[p[i]] and s[i]
    end of the block
    for i=2 to n inclusive
        if s[i] equal to -1, continue the loop
        if s[p[i]] greater than s[i]
            print -1
            return to indicate successful execution
        end of the block
    end of the block
    set ans to s[1]
    for i=2 to n inclusive
        if s[i] equal to -1, continue the loop
        assign ans + s[i] - s[p[i]] to ans
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    a = array of integers of length 110
    let n be a integer
    read n
    let A , B be integers with A = 0, B = 0
    for i = 0 to n exclusive
        read a[i]
        if a[i] is greater than 0
            increment A by a[i]
        else do the following
            increment B by a[i]
    end of the block
    print A - B and newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int a[110];
    int n;
    cin >> n;
    int A = 0, B = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > 0)
            A += a[i];
        else
            B += a[i];
    }
    cout << A - B << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
maxn = const integer with maxn = 1e5 + 5
define the main function
    n = integer
    s = string array of size 105
    read n
    for i = 0 to n exclusive
        s[i] = " "
        read s[i]
    end of the block
    ans = integer with ans = 0
    for i = 0 to 25
        for j = 0 to 25
            x = character with x = a + i
            y = character with y = a + j
            temp = integer with temp = 0
            for k = 0 to n exclusive
                temp1 = integer with temp1 = 0
                flag = integer with flag = 1
                for l = 0 to s[k].size() exclusive
                    if (s[k][l] is x or s[k][l] is y)
                        increment temp1
                    else
                        flag = 0
                        break loop
                    end of the block
                end of the block
                if (flag), temp = temp + temp1
            end of the block
            ans = max of ans and temp
        end of the block
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:

const int maxn = 1e5 + 5;
int main() {
    int n;
    string s[105];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        s[i] = " ";
        cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i <= 26; ++i) {
        for (int j = 0; j <= 26; ++j) {
            char x = 'a' + i;
            char y = 'a' + j;
            int temp = 0;
            for (int k = 0; k < n; ++k) {
                int temp1 = 0;
                int flag = 1;
                for (int l = 0; l < s[k].size(); ++l) {
                    if (s[k][l] == x || s[k][l] == y)
                        temp1++;
                    else {
                        flag = 0;
                        break;
                    }
                }
                if (flag) temp += temp1;
            }
            ans = max(ans, temp);
        }
    }
    cout << ans << endl;
    return 0;
}

6 gggggg gggggg gggggg gggggg gggggg gggggg

6 aaaaaa aaaaaa bbbbbb bbbbbb aaabbb ababab

26 q w e r t y u i o p a s d f g h j k l z x c v b n m

5 zzz zzzz zz z aaaaaaaaaaaaaaaaaaaaaaaaaaaf

7 pavel erika alexxxxxxx gracio zhenya sudarev chelyaba

31 fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml fml

5 zloyfreid graciocode schooldiary kazakov evgesha


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    n = int
    read n
    a = int array of size n
    cnt = int with cnt = 0
    for i = 1 to n inclusive read a[i]
    call sort on a + 1 and a + 1 + n
    if n equals 1 or 2
        print 0
    else if n is greater than 2
        minn = int with minn = a[1]
        mixx = int with mixx = a[n]
        for i = 2 to n - 1 inclusive
            if a[i] is between minn and mixx then increment cnt
        end of the block
        print cnt
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;
    for (int i = 1; i <= n; i++) { cin >> a[i]; }
    sort(a + 1, a + 1 + n);
    if (n == 1 || n == 2)
        cout << 0 << endl;
    else if (n >= 3) {
        int minn = a[1];
        int mixx = a[n];
        for (int i = 2; i <= n - 1; i++) {
            if (a[i] > minn && a[i] < mixx) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
let n, m, p, a and b be integers
void function solve
    read a, b and n
    let tmp be integer = a * 10
    for i = 0 to 10 exclusive
        if tmp % b = 0
            print tmp
            print "0" n - 1 times
            print new line
            return
        end of the block
        increase tmp
    end of the block
    print -1 and a new line
end of the block
define the main function
    ;
    declare integer variable T = 1
    call solve() T times
    return to indicate successful execution
end of the block

[CODE]:

int n, m, p, a, b;
void solve() {
    cin >> a >> b >> n;
    int tmp = a * 10;
    for (int i = 0; i < 10; i++) {
        if (tmp % b == 0) {
            cout << tmp;
            for (int i = 0; i < n - 1; ++i) cout << "0";
            cout << endl;
            return;
        }
        tmp++;
    }
    cout << -1 << endl;
}
int main() {
    ;
    int T = 1;
    for (int i = 0; i < T; i++) { solve(); }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create ints n, na = 0, nb = 0, and ab = 0 and int arrays aa of size 110 and bb of size 110
    read n
    for a = 0 to n exclusive
        read aa[a]
        read bb[a]
        set na to na + aa[a]
        add bb[a] to nb
        if (aa[a] + bb[a]) modulo 2 is 1, set ab to 1
    end of the block
    if na modulo 2 is equal to 0 and nb modulo 2 is equal to 0
        print 0
    else if na % 2 is equal to 1, nb % 2 is equal to 1, and ab is 1
        print 1
    otherwise
        display -1
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    let n = integer
    read n
    if n is odd
        print 1
    else
        print 0
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    if (n % 2)
        cout << "1\n";
    else
        cout << "0\n";
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create n, m as integers
    get n, m
    create str, cmd as strings
    get str
    create x, y as integers
    create c1, c2 as characters
    for integer i=0 to m-1 with increment i do
        get x, y, c1, c2
        for integer j=x to y with increment j do
            if str[j-1] is equal to c1 then assign c2 to str[j-1]
        end of the block
    end of the block
    print str
end of the block

[CODE]:

int main() {
    int n, m;
    cin >> n >> m;
    string str, cmd;
    cin >> str;
    int x, y;
    char c1, c2;
    for (int i = 0; i < m; i++) {
        cin >> x >> y >> c1 >> c2;
        for (int j = x; j <= y; j++) {
            if (str[j - 1] == c1) str[j - 1] = c2;
        }
    }
    cout << str << endl;
}

9 51
bhfbdcgff
2 3 b b
2 8 e f
3 8 g f
5 7 d a
1 5 e b
3 4 g b
6 7 c d
3 6 e g
3 6 e h
5 6 a e
7 9 a c
4 9 a h
3 7 c b
6 9 b g
1 7 h b
4 5 a e
3 9 f a
1 2 c h
4 8 a c
3 5 e d
3 4 g f
2 3 d h
2 3 d e
1 7 d g
2 6 e g
2 3 d g
5 5 h h
2 8 g d
8 9 a f
5 9 c e
1 7 f d
1 6 e e
5 7 c a
8 9 b b
2 6 e b
6 6 g h
1 2 b b
1 5 a f
5 8 f h
1 5 e g
3 9 f h
6 8 g a
4 6 h g
1 5 f a
5 6 a c
4 8 e d
1 4 d g
7 8 b f
5 6 h b
3 9 c e
1 9 b a

5 16
acfbb
1 2 e f
2 5 a f
2 3 b e
4 4 f a
2 3 f a
1 2 b e
4 5 c d
2 4 e c
1 4 e a
1 3 d c
3 5 e b
3 5 e b
2 2 e d
1 3 e c
3 3 a e
1 5 a a

30 4
eaaddabedcbbcccddbabdecadcecce
2 17 c a
16 29 e e
16 21 c b
7 11 b c

7 17
bbaabab
3 5 a b
5 7 a a
5 5 a a
4 4 b a
7 7 a a
5 6 b b
1 3 b a
6 7 a b
4 6 a b
6 6 a a
2 4 b a
1 7 b a
4 6 b b
2 5 b b
2 5 a b
1 4 a a
4 4 b a


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
declare integer p and 2d array of integers dp with size 2005 by 2005
void function helper
    set first sizeof(dp) bytes at the pointer dp to 0
    for i from 0 to p exclusive, change dp[i][0] to 1
    for x from 1 to p exclusive
        for i = 1 to p exclusive, set dp[x][i] to ((dp[x][i - 1]) * x) % p
    end of the block
end of the block
isPrimeRoot is a bool function with int argument x
    declare int curr = 0
    for k from 0 to p - 2 exclusive
        add dp[x][k] to curr
        return false if curr % p = 0
    end of the block
    set curr to curr + dp[x][p - 2]
    return false if curr % p != 0
    return true
end of the block
integer function solve
    if p is equal to 2, return 1
    call helper()
    create integer ans = 0
    change x from 1 to p exclusive in a loop
        if isPrimeRoot(x) returned true, increment ans
    end of the block
    return ans
end of the block
define the main function
    read p
    declare integer ans = result of the solve()
    print ans
    return to indicate successful execution
end of the block

[CODE]:

int p, dp[2005][2005];
void helper() {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < p; i++) { dp[i][0] = 1; }
    for (int x = 1; x < p; x++) {
        for (int i = 1; i < p; i++) { dp[x][i] = ((dp[x][i - 1]) * x) % p; }
    }
}
bool isPrimeRoot(int x) {
    int curr = 0;
    for (int k = 0; k < p - 2; k++) {
        curr += dp[x][k];
        if (curr % p == 0) { return false; }
    }
    curr = curr + dp[x][p - 2];
    if (curr % p != 0) { return false; }
    return true;
}
int solve() {
    if (p == 2) return 1;
    helper();
    int ans = 0;
    for (int x = 1; x < p; x++) {
        if (isPrimeRoot(x)) { ans++; }
    }
    return ans;
}
int main() {
    cin >> p;
    int ans = solve();
    cout << ans << endl;
    return 0;
}