[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 long k
declare vector of long longs v
in the function d with long long argument n
    declare long long variable c = 0
    for i = 1 while i * i <= n
        if n % i = 0
            push i to the end of v
            if n / i != i push n / i to the end of v
        end of the block
    end of the block
    sort v
    if length of v is less than k
        print "-1"
    else
        print v[k - 1]
end of the block
define the main function
    create long long n
    read n and k
    invoke function d with argument n
    return to indicate successful execution
end of the block

[CODE]:

long long k;
vector<long long> v;
void d(long long n) {
    long long c = 0;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (n / i != i) v.push_back(n / i);
        }
    }
    sort(v.begin(), v.end());
    if (v.size() < k)
        cout << "-1" << endl;
    else
        cout << v[k - 1] << endl;
}
int main() {
    long long n;
    cin >> n >> k;
    d(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 iamax (get pointer to int arr, int N, return int)
    ma=arr[0]
    for i=1 to N exclusive ma=max(arr[i], ma)
    return ma
end of the block
function readarr (get pointer to int arr and N, return nothing)
    read into N
    for i=0 to number pointed by N exclusive read arr[i]
end of the block
arr=array of 1005 char
k,n=int
function pal (get int a and b, return bool)
    while a<b
        if arr[a] is not arr[b-1] return false
        increment a
        decrement b
    end of the block
    return true
end of the block
function run (no args, return bool)
    mul=n/k
    for i=0 to n exclusive by mul
        if not pal(i,i+mul) return false
    end of the block
    return true
end of the block
define the main function
    read arr,k
    n=length of arr
    if n modulo k
        print "NO"
    else
        if run()
            print "YES"
        else
            print "NO"
    end of the block
end of the block

[CODE]:

int iamax(int *arr, int N) {
    int ma = arr[0];
    for (int i = 1; i < N; i++) ma = max(arr[i], ma);
    return ma;
}
void readarr(int *arr, int *N) {
    cin >> *N;
    for (int i = 0; i < *N; i++) cin >> arr[i];
}
char arr[1005];
int k, n;
bool pal(int a, int b) {
    while (a < b) {
        if (arr[a] != arr[b - 1]) return false;
        a++;
        b--;
    }
    return true;
}
bool run() {
    int mul = n / k;
    for (int i = 0; i < n; i += mul) {
        if (!pal(i, i + mul)) return false;
    }
    return true;
}
int main() {
    cin >> arr >> k;
    n = strlen(arr);
    if (n % k)
        cout << "NO\n";
    else {
        if (run())
            cout << "YES\n";
        else
            cout << "NO\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
    declare long ints n and ans where ans = 0
    read n
    create integers vector v
    for i = 0 to n exclusive
        create integer x
        read x
        push x to v
    end of the block
    sort v
    for i from 0 to n - 1 exclusive, increase ans by v[n - 1] - v[i]
    print ans
end of the block

[CODE]:

int main() {
    long int n, ans = 0;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n - 1; i++) { ans += v[n - 1] - v[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]:
create constant long long MAX = 1000
define the main function
    declare long long variable n
    read input to n
    if n is odd
        print 1
    else
        print 2 to the output
end of the block

[CODE]:

const long long MAX = 1000;
int main() {
    long long n;
    cin >> n;
    if (n % 2 == 1)
        cout << 1 << endl;
    else
        cout << 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]:
define the main function
    a, b, c = long long
    read a, b, c
    ada = boolean = 0
    for i = 0, i is multiplied by a to 100000 inclusive
        for i = 0, i is multiplied by b to 100000 inclusive
            if j * b + i * a > c, exit the for loop
            if j * b + i * a is c, ada = 1
            if ada is nonzero, exit the loop
        end of the block
        if ada is nonzero, exit the loop
    end of the block
    if ada is nonzero
        print Yes
    else
        print No
end of the block

[CODE]:

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    bool ada = 0;
    for (long long i = 0; i * a <= 100000; i++) {
        for (long long j = 0; j * b <= 100000; j++) {
            if (j * b + i * a > c) break;
            if (j * b + i * a == c) ada = 1;
            if (ada) break;
        }
        if (ada) break;
    }
    if (ada)
        cout << "Yes" << endl;
    else
        cout << "No" << 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]:
a = integer array of size 105
in function summ with parameters integers l, r and return long long
    ans = long long set to 0
    for i = l to r inclusive, add a[i] to ans
    return ans
end of the block
define the main function
    declare an integer n
    input n
    sum = long long set to 0
    ans = integer set to 0
    for i = 1 to n inclusive
        read a[i]
        add a[i] to sum
        if a[i] is 0, increment ans
    end of the block
    if sum is 0
        if ans is n
            print NO
        else
            for i = 1 to n exclusive
                if call summ with 1, i isn't 0 and call summ with i + 1, n isn't 0
                    print YES, newline, 2
                    print 1, " ", i
                    print i + 1, " ", n
                    break
                end of the block
            end of the block
        end of the block
    else
        print YES
        print 1
        print 1, " ", n
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int a[105];
long long summ(int l, int r) {
    long long ans = 0;
    for (int i = l; i <= r; i++) { ans += a[i]; }
    return ans;
}
int main() {
    int n;
    cin >> n;
    long long sum = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
        if (a[i] == 0) ans++;
    }
    if (sum == 0) {
        if (ans == n) {
            cout << "NO" << endl;
        } else {
            for (int i = 1; i < n; i++) {
                if (summ(1, i) != 0 && summ(i + 1, n) != 0) {
                    cout << "YES" << endl << 2 << endl;
                    cout << 1 << " " << i << endl;
                    cout << i + 1 << " " << n << endl;
                    break;
                }
            }
        }
    } else {
        cout << "YES" << endl;
        cout << 1 << endl;
        cout << 1 << " " << n << 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, m = integers
    read n and m
    i, x, y, t, up, down, ans, u_d, d_u, count, sum = integers with up set to 0, down set to 0, count set to 0, sum set to 0
    for 1 to n inclusive
        read x, y and t
        set up to 0
        set down to 0
        set count to 0
        set sum to 0
        set u_d to 2 * (m - x)
        set d_u to 2 * (x - 1)
        if x is equal to y
            print t
        else
            if t is less than or equal to x - 1
                if y is greater than x
                    print x - 1 + y - x
                else
                    print x - 1 + x - y + u_d
                end of the block
            else
                decrement t by x - 1
                set up to 1
                increment sum by x - 1
                while t is greater than 0
                    if count % 2 is 0
                        decrement t by u_d
                        set down to 1
                        set up to 1
                        increment sum by u_d
                    else
                        decrement t by d_u
                        set down to 0
                        set up to 1
                        increment sum by d_u
                    end of the block
                    increment count
                end of the block
                if y is greater than x
                    if up is equal to 1
                        print sum + y - x
                    else
                        print sum + d_u + y - x
                    end of the block
                else
                    if up is equal to 1
                        print sum + x - y + u_d
                    else
                        print sum + x - y
                    end of the block
                end of the block
            end of the block
        end of the block
    end of the block
end of the block

[CODE]:

int main() {
    int n, m;
    cin >> n >> m;
    int i, x, y, t, up = 0, down = 0, ans, u_d, d_u, count = 0, sum = 0;
    for (i = 1; i <= n; i++) {
        cin >> x >> y >> t;
        up = 0;
        down = 0;
        count = 0;
        sum = 0;
        u_d = 2 * (m - x);
        d_u = 2 * (x - 1);
        if (x == y)
            cout << t << endl;
        else {
            if (t <= x - 1) {
                if (y > x) {
                    cout << x - 1 + y - x << endl;
                } else {
                    cout << x - 1 + x - y + u_d << endl;
                }
            } else {
                t -= (x - 1);
                up = 1;
                sum += (x - 1);
                while (t > 0) {
                    if (count % 2 == 0) {
                        t -= u_d;
                        down = 1;
                        up = 0;
                        sum += u_d;
                    } else {
                        t -= d_u;
                        down = 0;
                        up = 1;
                        sum += d_u;
                    }
                    count++;
                }
                if (y > x) {
                    if (up == 1) {
                        cout << sum + y - x << endl;
                    } else {
                        cout << sum + d_u + y - x << endl;
                    }
                } else {
                    if (up == 1) {
                        cout << sum + x - y + u_d << endl;
                    } else {
                        cout << sum + x - y << 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
    x = integer with x = 0
    s2 = string
    read s2
    for i = s2.length() - 2 down to 0
        if s2[i] is s2[i + 1], erase(i, 2) from s2
    end of the block
    print s2
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int x = 0;
    string s2;
    cin >> s2;
    for (int i = s2.length() - 2; i >= 0; i--) {
        if (s2[i] == s2[i + 1]) s2.erase(i, 2);
    }
    cout << s2 << 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]:
declare constant integer maxn = 1e5 + 10
declare integer arrays a size maxn, b size maxn
declare integer arrays c size maxn, d size maxn
define the main function
    declare integer n
    read n
    for i = 0 to n exclusive
        read a[i]
        increment c[a[i]]
    end of the block
    for i = 0 to n exclusive
        read b[i]
        increment d[b[i]]
    end of the block
    declare integer k = 0
    for i = 1 to 5 inclusive
        if (d[i] + c[i] bitwise and 1 )
            print "-1" and newline
            return to indicate successful execution
        end of the block
        increment k by absolute value of ( c[i] - d[i] ) / 2
    end of the block
    print k / 2 and newline
    return to indicate successful execution
end of the block

[CODE]:

const int maxn = 1e5 + 10;
int a[maxn], b[maxn];
int c[maxn], d[maxn];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[a[i]]++;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        d[b[i]]++;
    }
    int k = 0;
    for (int i = 1; i <= 5; i++) {
        if ((d[i] + c[i] & 1)) {
            cout << "-1" << endl;
            return 0;
        }
        k += abs(c[i] - d[i]) / 2;
    }
    cout << k / 2 << 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 = integer
    read a
    if a & 1 or a = 2
        print "NO" and a new line
    else
        print "YES" and a new line
end of the block

[CODE]:

int main() {
    int a;
    cin >> a;
    if (a & 1 || a == 2)
        cout << "NO" << endl;
    else
        cout << "YES" << 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
    a, b, c, d are strings
    read a, b
    display a, ' ', b
    n is an integer
    read n
    iterate n times
        read c, d
        if c equals a
            assign d to a
        else
            assign d to b
        display a, ' ', b
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string a, b, c, d;
    cin >> a >> b;
    cout << a + ' ' + b << '\n';
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c >> d;
        if (c == a)
            a = d;
        else
            b = d;
        cout << a + ' ' + b << '\n';
    }
    return 0;
}

ross rachel
4
ross joey
rachel phoebe
phoebe monica
monica chandler

ross rachel
joey rachel
joey phoebe
joey monica
joey chandler

ze udggmyop
4
ze szhrbmft
udggmyop mjorab
szhrbmft ojdtfnzxj
ojdtfnzxj yjlkg

ze udggmyop
szhrbmft udggmyop
szhrbmft mjorab
ojdtfnzxj mjorab
yjlkg mjorab

q s
10
q b
b j
s g
j f
f m
g c
c a
m d
d z
z o

q s
b s
j s
j g
f g
m g
m c
m a
d a
z a
o a

iii iiiiii
7
iii iiiiiiiiii
iiiiiiiiii iiii
iiii i
iiiiii iiiiiiii
iiiiiiii iiiiiiiii
i iiiii
iiiii ii

iii iiiiii
iiiiiiiiii iiiiii
iiii iiiiii
i iiiiii
i iiiiiiii
i iiiiiiiii
iiiii iiiiiiiii
ii iiiiiiiii

bwyplnjn zkms
26
zkms nzmcsytxh
nzmcsytxh yujsb
bwyplnjn gtbzhudpb
gtbzhudpb hpk
yujsb xvy
hpk wrwnfokml
wrwnfokml ndouuikw
ndouuikw ucgrja
ucgrja tgfmpldz
xvy nycrfphn
nycrfphn quvs
quvs htdy
htdy k
tgfmpldz xtdpkxm
xtdpkxm suwqxs
k fv
suwqxs qckllwy
qckllwy diun
fv lefa
lefa gdoqjysx
diun dhpz
gdoqjysx bdmqdyt
dhpz dgz
dgz v
bdmqdyt aswy
aswy ydkayhlrnm

bwyplnjn zkms
bwyplnjn nzmcsytxh
bwyplnjn yujsb
gtbzhudpb yujsb
hpk yujsb
hpk xvy
wrwnfokml xvy
ndouuikw xvy
ucgrja xvy
tgfmpldz xvy
tgfmpldz nycrfphn
tgfmpldz quvs
tgfmpldz htdy
tgfmpldz k
xtdpkxm k
suwqxs k
suwqxs fv
qckllwy fv
diun fv
diun lefa
diun gdoqjysx
dhpz gdoqjysx
dhpz bdmqdyt
dgz bdmqdyt
v bdmqdyt
v aswy
v ydkayhlrnm

wxz hbeqwqp
7
hbeqwqp cpieghnszh
cpieghnszh tlqrpd
tlqrpd ttwrtio
ttwrtio xapvds
xapvds zk
wxz yryk
zk b

wxz hbeqwqp
wxz cpieghnszh
wxz tlqrpd
wxz ttwrtio
wxz xapvds
wxz zk
yryk zk
yryk b

wced gnsgv
23
gnsgv japawpaf
japawpaf nnvpeu
nnvpeu a
a ddupputljq
ddupputljq qyhnvbh
qyhnvbh pqwijl
wced khuvs
khuvs bjkh
pqwijl ysacmboc
bjkh srf
srf jknoz
jknoz hodf
ysacmboc xqtkoyh
hodf rfp
xqtkoyh bivgnwqvoe
bivgnwqvoe nknf
nknf wuig
rfp e
e bqqknq
wuig sznhhhu
bqqknq dhrtdld
dhrtdld n
sznhhhu bguylf

wced gnsgv
wced japawpaf
wced nnvpeu
wced a
wced ddupputljq
wced qyhnvbh
wced pqwijl
khuvs pqwijl
bjkh pqwijl
bjkh ysacmboc
srf ysacmboc
jknoz ysacmboc
hodf ysacmboc
hodf xqtkoyh
rfp xqtkoyh
rfp bivgnwqvoe
rfp nknf
rfp wuig
e wuig
bqqknq wuig
bqqknq sznhhhu
dhrtdld sznhhhu
n sznhhhu
n bguylf

qqqqqqqqqq qqqqqqqq
3
qqqqqqqq qqqqqqqqq
qqqqqqqqq qqqqq
qqqqq q

qqqqqqqqqq qqqqqqqq
qqqqqqqqqq qqqqqqqqq
qqqqqqqqqq qqqqq
qqqqqqqqqq q

wwwww w
8
wwwww wwwwwwww
wwwwwwww wwwwwwwww
wwwwwwwww wwwwwwwwww
w www
wwwwwwwwww wwww
wwww ww
www wwwwww
wwwwww wwwwwww

wwwww w
wwwwwwww w
wwwwwwwww w
wwwwwwwwww w
wwwwwwwwww www
wwww www
ww www
ww wwwwww
ww wwwwwww

k d
17
k l
d v
v z
l r
z i
r s
s p
p w
w j
j h
i c
h m
m q
c o
o g
q x
x n

k d
l d
l v
l z
r z
r i
s i
p i
w i
j i
h i
h c
m c
q c
q o
q g
x g
n g


[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 integer n
    read n
    if n equal 0
        print 0
    else if n equal 2
        print 2
    else
        print 1
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    if (n == 0)
        cout << 0 << endl;
    else if (n == 2)
        cout << 2 << endl;
    else
        cout << 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]:
define the main function
    n, one, two and trone are integers where one, two and trone = 0
    declare vector of ints called x
    read n
    for integer i = 0 to n exclusive
        declare integer variable tmp
        read tmp
        if tmp = 1
            increment one by 1
        else
            increment two by 1
        push tmp into x
    end of the block
    assign one to trone
    create int ans = min of one and two
    subtract ans from trone
    divide trone by 3
    print ans + trone
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, one = 0, two = 0, trone = 0;
    vector<int> x;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (tmp == 1)
            one++;
        else
            two++;
        x.push_back(tmp);
    }
    trone = one;
    int ans = min(one, two);
    trone -= ans;
    trone /= 3;
    cout << ans + trone << 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]:
in the function binaria that takes integer x, reference n and returns integer
    l, r = integers with l = 1, r = sqrt(n) + 1
    while l <= r
        mid = integer with mid = (l + r) / 2
        if mid * (mid + 1) is x
            return 1
        else if mid * (mid + 1) < x
            l = mid + 1
        else
            r = mid - 1
    end of the block
    return to indicate successful execution
end of the block
define the main function
    n = integer
    read n
    flag = bool with flag = false
    for i = 1 to sqrt(n * 2)
        if binaria(2 * n - i * (i + 1), n)
            flag = true
            break loop
        end of the block
    if not flag
        print NO
    else
        print YES
end of the block

[CODE]:

int binaria(int x, int &n) {
    int l = 1, r = sqrt(n) + 1;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (mid * (mid + 1) == x)
            return 1;
        else if (mid * (mid + 1) < x)
            l = mid + 1;
        else
            r = mid - 1;
    }
    return 0;
}
int main() {
    int n;
    cin >> n;
    bool flag = false;
    for (int i = 1; i <= sqrt(n * 2); i++)
        if (binaria(2 * n - i * (i + 1), n)) {
            flag = true;
            break;
        }
    if (!flag)
        cout << "NO" << endl;
    else
        cout << "YES" << 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
    create integers n, m
    create characters a, b
    read n read m
    for i = 0 to n exclusive
        for j = 0 to m exclusive
            if j is 0
                read a
                if i is not 0 and a is b
                    print "NO\n"
                    return to indicate successful execution
                end of the block
                set b to a
            else
                read a
            if a is not b
                print "NO\n"
                return to indicate successful execution
            end of the block
        end of the block
    end of the block
    print "YES\n"
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, m;
    char a, b;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (j == 0) {
                cin >> a;
                if (i != 0 && a == b) {
                    cout << "NO\n";
                    return 0;
                }
                b = a;
            } else
                cin >> a;
            if (a != b) {
                cout << "NO\n";
                return 0;
            }
        }
    }
    cout << "YES\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 const int MAXN = 1005
create character c
declare integer array s with size MAXN
create integers n and p
function work2 with int argument x
    if x is greater than n
        for i from 1 to n inclusive, print s[i] + 'a' - 1 as char
        print a new line
        call exit with argument 0
    end of the block
    for i from 1 to p inclusive incrementing i
        declare boolean ch1 = (x - 1 <= 0 || i != s[x - 1])
        declare boolean ch2 = (x - 2 <= 0 || i != s[x - 2])
        if ch1 is true and ch2 is true
            assign i to s[x]
            call function work2 with arguments x + 1
        end of the block
    end of the block
end of the block
function work with int argument x
    while s[x] < p
        increment s[x] by one
        declare bool ch1 = (x - 1 <= 0 || s[x - 1] != s[x])
        create boolean ch2 = (x - 2 <= 0 || s[x - 2] != s[x])
        if ch1 && ch2 are both true, call work2(x + 1)
    end of the block
end of the block
define the main function
    read from the input to n and p
    for i = 1 to n inclusive, read c and set s[i] to c - 'a' + 1
    for integer i = n to 1 inclusive, decrementing i, call work(i)
    print "NO"
    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 longs n, k
    create 2d integer array a with size 3 by 10 with a = {{0, 1, 2, 2, 1, 0}, {1, 0, 0, 1, 2, 2}, {2, 2, 1, 0, 0, 1}}
    read n read k
    set n to n % 6
    for i = 0 to 3 exclusive
        if a[i][n] is k, print i 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 t be a character
    read t
    let a, b be strings
    read a, b
    let s0 , s1 be characters with s0 is equal to a[1], s1 is equal to b[1]
    if a[0] is equal to A, a[0] is equal to Z
    if b[0] is equal to A, b[0] is equal to Z
    if a[0] is equal to T, a[0] is equal to B
    if b[0] is equal to T, b[0] is equal to B
    if a[0] is equal to K, a[0] is equal to X
    if b[0] is equal to K, b[0] is equal to X
    if s0 is equal to t and s1 is not equal to t
        print YES and newline
        return to indicate successful execution
    end of the block
    if s0 is equal to s1 and a[0] is greater than b[0]
        print YES and newline
        return to indicate successful execution
    end of the block
    print NO and 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
    i, j, k, even, odd, n, x and y are ints with even and odd = 0, j = 1 and k = 2; a is an array of ints with size 56
    read input to n
    for i = 0 to n / 2 exclusive, read input to a[i]
    sort a from index 0 to n / 2
    for i = 0 to n / 2 exclusive
        assign j - a[i] to x
        if x is less than 0, invert the sign of x
        add x to odd
        assign k - a[i] to y
        if y is less than 0, invert the sign of y
        increase even by y
        add 2 to j
        add 2 to k
    end of the block
    if odd is greater than even
        print even
    else
        print odd
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int i, j = 1, k = 2, even = 0, odd = 0, n, x, y, a[56];
    cin >> n;
    for (i = 0; i < n / 2; i++) { cin >> a[i]; }
    sort(a, a + n / 2);
    for (i = 0; i < n / 2; i++) {
        x = j - a[i];
        if (x < 0) x = -x;
        odd += x;
        y = k - a[i];
        if (y < 0) y = -y;
        even += y;
        j += 2;
        k += 2;
    }
    if (odd > even)
        cout << even << endl;
    else
        cout << odd << 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 constant integer maxn = 110
create integer array a of size maxn
define the main function
    create integers i, j, n, and k
    read n and k
    for i = 0 to n exclusive, read a[i]
    create integers e, s, and maxx = -1
    for i = 0 to k exclusive
        set e to 0
        set s to 0
        for j = 0 to n exclusive
            if (j - i) modulo k is 0
                continue to next loop iteration
            else
                if a[j] is equal to 1
                    increment e
                else if a[j] is equal to -1
                    increment s
            end of the block
        end of the block
        set maxx to the max of maxx and the absolute value of e - s
    end of the block
    print maxx
    return to indicate successful execution
end of the block

[CODE]:

const int maxn = 110;
int a[maxn];
int main() {
    int i, j, n, k;
    cin >> n >> k;
    for (i = 0; i < n; i++) { cin >> a[i]; }
    int e, s, maxx = -1;
    for (i = 0; i < k; i++) {
        e = 0;
        s = 0;
        for (j = 0; j < n; j++) {
            if ((j - i) % k == 0) {
                continue;
            } else {
                if (a[j] == 1)
                    e++;
                else if (a[j] == -1)
                    s++;
            }
        }
        maxx = max(maxx, abs(e - s));
    }
    cout << maxx << 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]:
INF = const long with INF = 2000000
a = long array of size 10000
i, j = long
n, m = long
define the main function
    read n, m
    for i = 0 to m exclusive
        read j
        increment a[j]
    end of the block
    j = INF
    for i = 1 to n
        if (j > a[i]), j = a[i]
    print j
    return to indicate successful execution
end of the block

[CODE]:

const long INF = 2000000;
long a[10000];
long i, j;
long n, m;
int main() {
    cin >> n >> m;
    for (i = 0; i < m; i++) {
        cin >> j;
        a[j]++;
    }
    j = INF;
    for (i = 1; i <= n; i++)
        if (j > a[i]) j = a[i];
    cout << j << 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]:
declare tp with integer a as argument, returning boolean
    if a is less than 2, return false from function
    for i = 2 to i * i is less than or equal to a, incrementing i
        if a % i is 0, return false from function
    end of the block
    return true from function
end of the block
declare cm with integer a as argument
    create integer lt with lt = 2
    for i = 3 to a inclusive
        if result of run tp with i as argument is true
            if lt + i is a, return true from function
            if lt + i is greater than a, return false from function
            set lt to i
        end of the block
    end of the block
    return false from function
end of the block
create integers n, k, cnt
define the main function
    read n read k
    for i = 2 to n inclusive
        if result of run tp with i as argument is true
            create integer p with p = i - 1
            if result of run cm with p as argument is true, increment cnt
        end of the block
    end of the block
    if cnt is greater than or equal to k
        print "YES" print newline
    else
        print "NO" print newline
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

bool tp(int a) {
    if (a < 2) { return false; }
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0) { return false; }
    }
    return true;
}
bool cm(int a) {
    int lt = 2;
    for (int i = 3; i <= a; i++) {
        if (tp(i)) {
            if (lt + i == a) { return true; }
            if (lt + i > a) { return false; }
            lt = i;
        }
    }
    return false;
}
int n, k, cnt;
int main() {
    cin >> n >> k;
    for (int i = 2; i <= n; i++) {
        if (tp(i)) {
            int p = i - 1;
            if (cm(p)) { cnt++; }
        }
    }
    if (cnt >= k) {
        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
    a is a new array of ints with 6 elements; i, j, k, sum, flg and b are integers with sum, flg and b = 0 and j = 1
    for i = 0 to 6 exclusive
        read b from the user input
        assign b to a[i] if 0 <= b and b <= 1000
    end of the block
    start for loop from i = 0 to 6 exclusive, increasing sum by a[i] on each loop iteration
    if sum is even
        in a for loop, change i from 0 to 4 exclusive incrementing i
            for j = i + 1 to 5 exclusive
                change k from j + 1 to 6 exclusive incrementing k in a for loop
                    if a[i] + a[j] + a[k] is equal to sum / 2
                        change flg to 1
                        stop the loop
                    end of the block
                end of the block
                if flg is equal to 1, break
            end of the block
            if flg is equal to 1, break
        end of the block
        if flg is equal to 1
            print "YES"
        else
            print "NO" to the standard output
        end of the block
    else
        print "NO"
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, max, idx = integers with max = -1
    let x = float
    read n, m
    for integer i=0 to n exclusive do the following
        read x
        set x = round up of x / m
        if x is greater than or equal to max do the following
            set max = x
            set idx = i
        end of the block
    end of the block
    print idx + 1
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, m, max = -1, idx;
    float x;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> x;
        x = ceil(x / m);
        if (x >= max) {
            max = x;
            idx = i;
        }
    }
    cout << (idx + 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]:
define the main function
    let a be an array of characters of length 10
    read 9 characters into a
    for i = 0 to 5 exclusive
        if a[i] != a[8 - i]
            print "NO" and a new line
            return to indicate successful execution
        end of the block
    end of the block
    print "YES" and a new line
end of the block

[CODE]:

int main() {
    char a[10];
    for (int i = 0; i < 9; i++) { cin >> a[i]; }
    for (int i = 0; i < 5; i++) {
        if (a[i] != a[8 - i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << 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
    s = string
    loop while reading s
        len = int with len = length of s
        print (len + 1) * 26 - len
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string s;
    while (cin >> s) {
        int len = s.length();
        cout << (len + 1) * 26 - len << 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 ans, s
    read s
    create integer i with size of s / 2 - 1
    if size of s % 2 is 1, increment i
    create integer p with p = i + 1
    for i is less than or equal to 0, decrementing i, incrementing p
        add element s[i] to end of ans
        if p is less than size of s, add element s[p] to end of ans
    end of the block
    print ans print newline
end of the block

[CODE]:

int main() {
    string ans, s;
    cin >> s;
    int i = s.size() / 2 - 1;
    if (s.size() % 2 == 1) i++;
    int p = i + 1;
    for (; i >= 0; i--, p++) {
        ans.push_back(s[i]);
        if (p < s.size()) ans.push_back(s[p]);
    }
    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
    create int a, b, c, d, k, set k to 0
    read a, b and c
    create int n
    read n
    for i=0 to n exclusive
        read d
        if d greater than b and d less than c, increment k
    end of the block
    print k
end of the block

[CODE]:

int main() {
    int a, b, c, d, k = 0;
    cin >> a >> b >> c;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d;
        if (d > b && d < c) k++;
    }
    cout << 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]:
define the main function
    n,s,a,b,c,d=int, pos=1
    read n,a,b,c,d
    s=a+b+c+d
    decrement n
    while decremented value of n is not zero
        read a,b,c,d
        if a+b+c+d > s increment pos
    end of the block
    print pos
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, s, a, b, c, d, pos = 1;
    cin >> n >> a >> b >> c >> d;
    s = a + b + c + d;
    n--;
    while (n--) {
        cin >> a >> b >> c >> d;
        if (a + b + c + d > s) { pos++; }
    }
    cout << pos << '\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
    declare character arrays m1 = "1", m2 = "14", m3 ="144"
    declare character array a size 1000
    declare integers i, j, k, l
    read a
    for i = 0 to a[i]
        if a[i] is m3[0] and a[i+1] is m3[1] and a[i+2] is m3[2]
            increment i by 3
        else if a[i] is m2[0] and a[i+1] is m2[1]
            increment i by 2
        else if a[i] is m1[0]
            increment i by 1
        else
            print "NO\n"
            exit program with code 0
        end of the block
    end of the block
    print "YES\n"
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]:
n, d = integers with vis, lvl = arrays of 200 integers
st = string
in function bfs
    Q = queue of integers
    set all contents of vis to -1
    push 0 in Q
    lvl[0] = 0
    u = integer
    while not Q is empty
        set u to the front of Q
        pop Q
        if u is n - 1 then return lvl[u]
        for i = u + 1 to u + d inclusive
            if vis[i] is -1 and st[i] is character 1
                vis[i] = 1
                set lvl[i] to lvl[u] + 1
                push i in Q
            end of the block
        end of the block
    end of the block
    return -1
end of the block
define the main function
    read n and d
    read st
    print the result of fuction bfs
end of the block

[CODE]:

int n, d, vis[200], lvl[200];
string st;
int bfs() {
    queue<int> Q;
    memset(vis, -1, sizeof(vis));
    Q.push(0);
    lvl[0] = 0;
    int u;
    while (!Q.empty()) {
        u = Q.front();
        Q.pop();
        if (u == n - 1) return lvl[u];
        for (int i = u + 1; i <= u + d; i++) {
            if (vis[i] == -1 && st[i] == '1') {
                vis[i] = 1;
                lvl[i] = lvl[u] + 1;
                Q.push(i);
            }
        }
    }
    return -1;
}
int main() {
    cin >> n >> d;
    cin >> st;
    cout << bfs() << "\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
    n, b =integers
    Read n
    set b to n / 2 + 1
    print b and a new line
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, b;
    cin >> n;
    b = n / 2 + 1;
    cout << 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]:
k, a, b, v, tot = int
define the main function
    read k then a then b then v
    iterate i
        increment to by (min of b + 1, k) * v
        decrement b by min of (b, k - 1)
        if tot >= a
            print i
            return to indicate successful execution
        end of the block
    end of the block
end of the block

[CODE]:

int k, a, b, v, tot;
int main() {
    cin >> k >> a >> b >> v;
    for (int i = 1;; i++) {
        tot += (min(b + 1, k)) * v;
        b -= (min(b, k - 1));
        if (tot >= a) {
            cout << i << 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 new array of characters str with size 1007
vis is a new array of booleans with 1007 elements
define the main function
    read str from the input
    change vis['a'], vis['e'], vis['i'], vis['o'] and vis['u'] to true
    for i from 0 to exclusive incrementing i
        if vis[str[i]] is false and str[i] != 'n'
            if vis[str[i + 1]] is false, return 0 * puts("NO")
    print "YES" to stdout
    return to indicate successful execution
end of the block

[CODE]:

char str[1007];
bool vis[1007];
int main() {
    cin >> str;
    vis['a'] = vis['e'] = vis['i'] = vis['o'] = vis['u'] = true;
    for (int i = 0; str[i]; i++)
        if (!vis[str[i]] && str[i] != 'n')
            if (!vis[str[i + 1]]) return 0 * puts("NO");
    puts("YES");
    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 integer n and an array of integers a with size 100010
    read n and keep looping
        declare long long variable sum = 0
        create integer minn = 1e9
        for integer i = 1 to n inclusive
            read a[i]
            if a[i] is odd
                if a[i] is less than minn, change minn to a[i]
            end of the block
            increase sum by a[i]
        end of the block
        if sum is even
            print sum
        else
            print sum - minn
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, a[100010];
    while (cin >> n) {
        long long sum = 0;
        int minn = 1e9;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
            if (a[i] % 2 != 0) {
                if (a[i] < minn) minn = a[i];
            }
            sum += a[i];
        }
        if (sum % 2 == 0)
            cout << sum << endl;
        else
            cout << sum - minn << 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 n be a integer
    read n
    the integer value of x = 0
    the integer value of k = -1
    the integer value of m = 0
    for i = 1 to n inclusive
        for j = 1 to n + 1 inclusive
            m is equal to 0
            if j is equal to n + 1
                print newline
                stop
            end of the block
            for integer k = n / 2 - x + 1 to n / 2 + x + 1 inclusive
                if j is equal to k , increment m by 1
            end of the block
            if m is equal to 0
                print *
            else do the following
                print D
            end of the block
        end of the block
        if i <= n / 2
            increment x by 1
        else do the following
            decrement x by 1
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

***D*** **DDD** *DDDDD* DDDDDDD *DDDDD* **DDD** ***D***

*****D***** ****DDD**** ***DDDDD*** **DDDDDDD** *DDDDDDDDD* DDDDDDDDDDD *DDDDDDDDD* **DDDDDDD** ***DDDDD*** ****DDD**** *****D*****

*******D******* ******DDD****** *****DDDDD***** ****DDDDDDD**** ***DDDDDDDDD*** **DDDDDDDDDDD** *DDDDDDDDDDDDD* DDDDDDDDDDDDDDD *DDDDDDDDDDDDD* **DDDDDDDDDDD** ***DDDDDDDDD*** ****DDDDDDD**** *****DDDDD***** ******DDD****** *******D*******

**********D********** *********DDD********* ********DDDDD******** *******DDDDDDD******* ******DDDDDDDDD****** *****DDDDDDDDDDD***** ****DDDDDDDDDDDDD**** ***DDDDDDDDDDDDDDD*** **DDDDDDDDDDDDDDDDD** *DDDDDDDDDDDDDDDDDDD* DDDDDDDDDDDDDDDDDDDDD *DDDDDDDDDDDDDDDDDDD* **DDDDDDDDDDDDDDDDD** ***DDDDDDDDDDDDDDD*** ****DDDDDDDDDDDDD**** *****DDDDDDDDDDD***** ******DDDDDDDDD****** *******DDDDDDD******* ********DDDDD******** *********DDD********* **********D**********

*************D************* ************DDD************ ***********DDDDD*********** **********DDDDDDD********** *********DDDDDDDDD********* ********DDDDDDDDDDD******** *******DDDDDDDDDDDDD******* ******DDDDDDDDDDDDDDD****** *****DDDDDDDDDDDDDDDDD***** ****DDDDDDDDDDDDDDDDDDD**** ***DDDDDDDDDDDDDDDDDDDDD*** **DDDDDDDDDDDDDDDDDDDDDDD** *DDDDDDDDDDDDDDDDDDDDDDDDD* DDDDDDDDDDDDDDDDDDDDDDDDDDD *DDDDDDDDDDDDDDDDDDDDDDDDD* **DDDDDDDDDDDDDDDDDDDDDDD** ***DDDDDDDDDDDDDDDDDDDDD*** ****DDDDDDDDDDDDDDDDDDD**** *****DDDDDDDDDDDDDDDDD***** ******DDDDDDDDDDDDDDD****** *******DDDDDDDDDDDDD******* ********DDDDDDDDDDD******** *********DDDDDDDDD********* **********DDDDDDD********** ***********DDDDD*********** ************DDD************ *************D*************

*****************D***************** ****************DDD**************** ***************DDDDD*************** **************DDDDDDD************** *************DDDDDDDDD************* ************DDDDDDDDDDD************ ***********DDDDDDDDDDDDD*********** **********DDDDDDDDDDDDDDD********** *********DDDDDDDDDDDDDDDDD********* ********DDDDDDDDDDDDDDDDDDD******** *******DDDDDDDDDDDDDDDDDDDDD******* ******DDDDDDDDDDDDDDDDDDDDDDD****** *****DDDDDDDDDDDDDDDDDDDDDDDDD***** ****DDDDDDDDDDDDDDDDDDDDDDDDDDD**** ***DDDDDDDDDDDDDDDDDDDDDDDDDDDDD*** **DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD** *DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD* DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD *DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD* **DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD** ***DDDDDDDDDDDDDDDDDDDDDDDDDDDDD*** ****DDDDDDDDDDDDDDDDDDDDDDDDDDD**** *****DDDDDDDDDDDDDDDDDDDDDDDDD***** ******DDDDDDDDDDDDDDDDDDDDDDD****** *******DDDDDDDDDDDDDDDDDDDDD******* ********DDDDDDDDDDDDDDDDDDD******** *********DDDDDDDDDDDDDDDDD********* **********DDDDDDDDDDDDDDD********** ***********DDDDDDDDDDDDD*********** ************DDDDDDDDDDD************ *************DDDDDDDDD************* **************DDDDDDD************** ***************DDDDD*************** ****************DDD**************** *****************D*****************


[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
    read n
    create int j = n + 1
    create int ans = max of 1 and (n * sqrt(2)) * 4 cast to int
    print ans
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    int j = n + 1;
    int ans = max(1, (int)(n * sqrt(2)) * 4);
    cout << ans << 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, s = int
    read n, s
    a = int array of length 110
    hh, mm = int
    tt = 0 = int
    for i = 0 to n exclusive, read hh and mm, a[i] = hh * 60 + mm
    flag = int = 1
    if s + 1 <= a[0] and flag then set both tt and flag to 0
    for i = 1 to n exclusive
        if s + 1 <= (a[i] - a[i - 1] - s - 1) and flag then set tt to a[i-1] + s + 1, set flag to 0
    end of the block
    if flag then set tt to a[n-1] + s + 1
    h = tt/60 = int
    m = tt - tt/60 * 60
    print h and space and m
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, s;
    cin >> n >> s;
    int a[110];
    int hh, mm;
    int tt = 0;
    for (int i = 0; i < n; i++) cin >> hh >> mm, a[i] = hh * 60 + mm;
    int flag = 1;
    if (s + 1 <= a[0] && flag) tt = 0, flag = 0;
    for (int i = 1; i < n; i++) {
        if (s + 1 <= (a[i] - a[i - 1] - s - 1) && flag) tt = a[i - 1] + s + 1, flag = 0;
    }
    if (flag) tt = a[n - 1] + s + 1;
    int h = tt / 60;
    int m = tt - tt / 60 * 60;
    cout << h << " " << m << 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 integers n, s, create integer array a with size 50
define the main function
    read n
    for i = 1 to n inclusive
        read s
        increment a[s]
    end of the block
    if a[1] is greater than a[2]
        print a[2] + ( a[1] - a[2] ) / 3 print newline
    else
        print a[1] 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]:
in the function gcd that takes integer a, b and returns integer
    return if b, gcd(b, a % b) else a
end of the block
in the function lcm that takes integer a, b and returns integer
    return a / gcd(a, b) * b
end of the block
in the function lcm that takes integer pointer arr and integer n and returns integer
    r = integer with r = arr[0]
    for i = 1 to n exclusive, r = lcm of r and arr[i]
    return r
end of the block
in = bool array of size 101 with in= {}
cycle = integer array of size 101
target = integer array of size 101
n = integer
define the main function
    read n
    for i = 1 to n
        read target[i]
        if in[target[i]]
            print -1
            return to indicate successful execution
        end of the block
        in[target[i]] = true
    end of the block
    for i = 1 to n
        current = integer with current = i
        cycle[i] = 0
        do
            current = target[current]
            cycle[i] = cycle[i] + cycle[i] 1
        while current is not i
        if ((cycle[i] bitwise and 1) is 0), cycle[i] = right shift cycle[i] 1 place
    end of the block
    print lcm(cycle + 1, n)
end of the block

[CODE]:

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int lcm(int *arr, int n) {
    int r = arr[0];
    for (int i = 1; i < n; ++i) { r = lcm(r, arr[i]); }
    return r;
}
bool in[101] = {};
int cycle[101];
int target[101];
int n;
int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> target[i];
        if (in[target[i]]) {
            cout << -1 << endl;
            return 0;
        }
        in[target[i]] = true;
    }
    for (int i = 1; i <= n; ++i) {
        int current = i;
        cycle[i] = 0;
        do {
            current = target[current];
            cycle[i] += 1;
        } while (current != i);
        if ((cycle[i] & 1) == 0) { cycle[i] >>= 1; }
    }
    cout << lcm(cycle + 1, n) << 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
    x is a new array of integers with 31 element
    create new array of integers y with 31 element
    z is a new 2d array of integers with size 31 by 31
    declare integer variables n, m, i, j and k
    read n and loop further
        change first sizeof(x) bytes at the pointer x to 0
        set the values of sizeof(y) bytes at the pointer y to 0
        for i from 0 to n exclusive
            for j = 0 to n exclusive, read from the input to z[i][j]
        end of the block
        start for loop from i = 0 to n exclusive incrementing i
            in a for loop, change j from 0 to n exclusive
                increase x[i] by z[i][j]
                change y[i] to the sum of y[i] and z[j][i]
            end of the block
        end of the block
        assign 0 to k
        in a for loop, change i from 0 to n exclusive incrementing i
            start for loop from j = 0 to n exclusive incrementing j
                if y[j] is greater than x[i], increment k
            end of the block
        end of the block
        print k
    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, c be ints
    read n and c
    y = int
    read y
    cur = y = int
    ans = 1 = int
    x = int
    for i = 0 to n-1 exclusive
        read x
        if the abs of cur-x to int is <= c
            increment ans
        else
            reset ans to 1
        end of the block
        set cur to x
    end of the block
    print ans and new line
end of the block

[CODE]:

int main() {
    int n, c;
    cin >> n >> c;
    int y;
    cin >> y;
    int cur = y;
    int ans = 1;
    int x;
    for (int i = 0; i < n - 1; i++) {
        cin >> x;
        if ((int)abs(cur - x) <= c) {
            ans++;
        } else {
            ans = 1;
        }
        cur = x;
    }
    cout << ans << '\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
    declare integer n
    create long longs a and Ans and long long array ara with size 101
    read n
    read a
    assign value of a to Ans
    for integer i = 1 to n exclusive
        read ara[i]
        increase Ans by (ara[i] - 1) * (i + 1) + 1
    end of the block
    print Ans
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    long long a, ara[101], Ans;
    cin >> n;
    cin >> a;
    Ans = a;
    for (int i = 1; i < n; i++) {
        cin >> ara[i];
        Ans += (ara[i] - 1) * (i + 1) + 1;
    }
    cout << Ans << 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, i, j, count = integers with count = 0
    sii = stack of integer
    s = string
    read n, s
    for i = s.size() - 1 down to 0, push s[i] - 0 in sii
    while (not sii.empty())
        j = top of sii
        pop sii
        if (j + 1 is 2)
            increment count
        else if (j + 1 is 1)
            increment count
            break loop
        end of the block
    end of the block
    print count
end of the block

[CODE]:

int main() {
    int n, i, j, count = 0;
    stack<int> sii;
    string s;
    cin >> n >> s;
    for (i = s.size() - 1; i >= 0; i--) { sii.push(s[i] - '0'); }
    while (!sii.empty()) {
        j = sii.top();
        sii.pop();
        if (j + 1 == 2) {
            count++;
        } else if (j + 1 == 1) {
            count++;
            break;
        }
    }
    cout << count << 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,x,y=long long
    ny=long long
    wasOut=bool
    borderPoints=0
    nx=0
    read n
    if n is 0
        print 1
        return to indicate successful execution
    else if n<0
        return to indicate successful execution
    end of the block
    subtract n from x
    while x<=0
        wasOut=true
        ny=sqrt(n*n-x*x)+1
        for y=-ny to 0 inclusive
            if x*x+y*y <= n*n
                if wasOut is true
                    wasOut=false
                    increment borderPoints
                    if x is 0 increment nx
                else
                    if x<0
                        if (x-1)^2+y^2 > n^2
                            increment borderPoints
                            if x is 0 increment nx
                        else
                            y=n+1
                        end of the block
                    else if x>0
                        if (x+1)^2+y^2 > n^2
                            increment borderPoints
                            if x is 0 increment nx
                        else
                            y=n+1
                        end of the block
                    end of the block
                end of the block
            end of the block
        end of the block
        increment x
    end of the block
    print 2*(borderPoints*2-nx)-2
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long n, x, y;
    long long ny;
    bool wasOut;
    long long borderPoints = 0;
    long long nx = 0;
    cin >> n;
    if (n == 0) {
        cout << 1 << endl;
        return 0;
    } else if (n < 0) {
        return 0;
    }
    x = -n;
    while (x <= 0) {
        wasOut = true;
        ny = sqrt(n * n - x * x) + 1;
        for (y = -ny; y <= 0; y++) {
            if (x * x + y * y <= n * n) {
                if (wasOut == true) {
                    wasOut = false;
                    borderPoints++;
                    if (x == 0) { nx++; }
                } else {
                    if (x < 0) {
                        if ((x - 1) * (x - 1) + y * y > n * n) {
                            borderPoints++;
                            if (x == 0) { nx++; }
                        } else {
                            y = n + 1;
                        }
                    } else if (x > 0) {
                        if ((x + 1) * (x + 1) + y * y > n * n) {
                            borderPoints++;
                            if (x == 0) { nx++; }
                        } else {
                            y = n + 1;
                        }
                    }
                }
            }
        }
        x++;
    }
    cout << 2 * (borderPoints * 2 - nx) - 2 << 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, k = int
    read n then k
    s = string
    read s
    pos, post = int
    for i = 0 to n
        if s[i] is 'G' set pos to i
        if s[i] is 'T' set post to i
    end of the block
    if abs of (pos - post) mod k is not 0
        print "NO"
    else
        f = bool with f = 1
        if pos < post
            for i = pos to post inclusive incrementing i by k
                if s8i] is '#' set f to 0
        else
            for i = pos to post inclusive decrementing i by k
                if s[i] is '#' set f to 0
        end of the block
        print "YES" if f else print "NO"
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int pos, post;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'G') pos = i;
        if (s[i] == 'T') post = i;
    }
    if (abs(pos - post) % k != 0)
        cout << "NO\n";
    else {
        bool f = 1;
        if (pos < post) {
            for (int i = pos; i <= post; i += k)
                if (s[i] == '#') f = 0;
        } else {
            for (int i = pos; i >= post; i -= k)
                if (s[i] == '#') f = 0;
        }
        cout << (f ? "YES" : "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
    x=int
    read x
    for y=x/2 down to 0 exclusive
        for z=0 to y exclusive print *
        for z=0 to x-2*y exclusive print D
        for z=0 to y exclusive print *
        print newline
    end of the block
    for y=0 to x exclusive print D
    print newline
    for y=1 to x/2 inclusive
        for z=0 to y exclusive print *
        for z=0 to x-2*y exclusive print D
        for z=0 to y exclusive print *
        print newline
    end of the block
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]:
create function f with parameters int a, int b
    x1 = integer, x1 = a / 10
    x2 = integer, x2 = remainder of a / 10
    x3 = integer, x3 = b / 10
    x2 = integer, x4 = remainder of b / 10
    if x1 equals x4 and x2 = x3, return 1
    return to indicate successful execution
end of the block
define the main function
    let a, b be integers
    let s be char
    read a, s, b
    if f(a, b) == 1
        print 0
    if last statement was false
        for int i = 1
            if b + 1 equals 60 and a is smaller than 23
                let b = 0
                add 1 to a
            else if a equals 23
                if b is greater than 32
                    print 60 - b
                    exit for loop
                if last statement was false
                    add one to b
            else
                add one to b
            end of the block
            if f(a, b) equals 1
                print i
                exit for loop
            end of the block
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int f(int a, int b) {
    int x1 = a / 10;
    int x2 = a % 10;
    int x3 = b / 10;
    int x4 = b % 10;
    if (x1 == x4 && x2 == x3) return 1;
    return 0;
}
int main() {
    int a, b;
    char s;
    cin >> a >> s >> b;
    if (f(a, b) == 1)
        cout << "0" << endl;
    else {
        for (int i = 1;; i++) {
            if (b + 1 == 60 && a < 23) {
                b = 0;
                a += 1;
            } else if (a == 23) {
                if (b > 32) {
                    cout << 60 - b << endl;
                    break;
                } else
                    b++;
            } else {
                b++;
            }
            if (f(a, b) == 1) {
                cout << i << endl;
                break;
            }
        }
    }
    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
    integer as n,x
    read n,x
    integer as pre = 0
    integer as i,val
    for = 0 to less than n do the following
        read val
        pre equals pre plus val
    end of the block
    integer as ans = 0
    if pre is greater than 0 then do the following
        set ans to (pre / x)
        if pre modulo x is greater than 0 then add one to ans
    end of the block
    if pre is less than 0 then do the following
        set ans to absolute value of pre / absolute value of x
        if absolute value of pre modulo absolute value of x is greater than 0 then add one to ans
    end of the block
    output ans
end of the block

[CODE]:

int main() {
    int n, x;
    cin >> n >> x;
    int pre = 0;
    int i, val;
    for (i = 0; i < n; i++) {
        cin >> val;
        pre += val;
    }
    int ans = 0;
    if (pre > 0) {
        ans = (pre / x);
        if (pre % x > 0) ans++;
    }
    if (pre < 0) {
        ans = (abs(pre) / abs(x));
        if (abs(pre) % abs(x) > 0) ans++;
    }
    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
    declare integers n, y, y2, y3, y4
    read n
    for i = 1 + n to 9020 inclusive
        let y be i % 10
        let y2 be (i / 10) % 10
        let y3 be (i / 100) % 10
        let y4 be (i / 1000) % 10
        if y is not y2 and y is not y3 and y is not y4 and y2 is not y3 and y2 is not y4 and y3 is not y4
            print i and newline
            end loop
        end of the block
    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 int array ara of size 100 with array of size 100
    create integers i, n, r, z, j, temp, and m
    for i = 0 to 5 exclusive
        for j = 0 to 5 exclusive, read ara[i][j]
    end of the block
    for i = 0 to 5 exclusive
        for j = 0 to 5 exclusive
            if ara[i][j] is equal to 1
                set m to 2 - i
                set n to 2 - j
            end of the block
        end of the block
    end of the block
    if n is less than 0, set n to n * (-1)
    if m is less than 0, set m to m * (-1)
    print m + n
    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
    s = string
    read s
    n = int = size of s
    print ((26 * (n + 1)) - n)
end of the block

[CODE]:

int main() {
    string s;
    cin >> s;
    int n = s.size();
    cout << ((26 * (n + 1)) - n) << endl;
}