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

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

[PSEUDOCODE]:
declare integer array father size 1005
declare n, m, k as integers
declare find with integer x as argument, returning integer
    return x if father[x] is x, else let father[x] be run find with father[x] as argument
end of the block
declare integer array node size 1005
declare integer array fathercnt size 1005
declare integer cnt
declare integer array isgro size 1005
define the main function
    set bytes from isgro to size of isgro to value 0
    read n, m, k
    declare integer gro
    for j = 1 to n inclusive, let father[j] be j
    for i = 0 to k exclusive
        declare integer g
        read g
        let isgro[g] be 1
        let gro be g
    end of the block
    for j = 1 to n inclusive, let fathercnt[j] be 1
    for i = 0 to m exclusive
        declare p, q as integers
        read p and q
        if isgro[p] is true
            declare integer x
            let x be result of run find(q)
            if father[ run find(q) ] is not father[ run find(p) ]
                let father[ run find(q) ] be father [ run find(p) ]
                increment fathercnt[ run find(p) ] by fathercnt[x]
                let fathercnt[x] be 0
            end of the block
        else if isgro[q] is true
            declare integer x
            let x be result of run find(p)
            if father[ run find(p) ] is not father[ run find(q) ]
                let father[ run find(p) ] be father [ run find(q) ]
                increment fathercnt[ run find(q) ] by fathercnt[x]
                let fathercnt[x] be 0
            end of the block
        else
            declare integer x
            if isgro[father[result of run find(p)]] is true
                let x be result of run find(q)
                if father[ run find(q) ] is not father[ run find(p) ]
                    let father[ run find(q) ] be father [ run find(p) ]
                    increment fathercnt[ run find(p) ] by fathercnt[x]
                    let fathercnt[x] be 0
                end of the block
            else
                let x be result of run find(p)
                if father[ run find(p) ] is not father[ run find(q) ]
                    let father[ run find(p) ] be father [ run find(q) ]
                    increment fathercnt[ run find(q) ] by fathercnt[x]
                    let fathercnt[x] be 0
                end of the block
            end of the block
        end of the block
    end of the block
    declare integer maxfather = 0
    declare integer strunity
    for i = 1 to n inclusive
        if fathercnt[i] is greater than maxfather
            let maxfather be fathercnt[i]
            let strunity be i
        end of the block
    end of the block
    declare integer maxgro = 0
    declare integer strgro = gro
    for i = 1 to n inclusive
        if isgro[i] and fathercnt[i] is greater than maxgro
            let maxgro be fathercnt[i]
            let strgro be i
        end of the block
    end of the block
    for i = 1 to n inclusive
        if fathercnt[i] is not 0
            if isgro[run find(i)] is not 1
                increment fathercnt[strgro] by fathercnt[i]
                let fathercnt[i] be 0
            end of the block
        end of the block
    end of the block
    let cnt be 0
    for i = 1 to n inclusive
        if isgro[i] is true, increment cnt by fathercnt[i] * (fathercnt[i] - 1)) / 2
    end of the block
    print cnt - m, newline
    return to indicate successful execution
end of the block

[CODE]:

int father[1005];
int n, m, k;
int find(int x) {
    return father[x] == x ? x : father[x] = find(father[x]);
}
int node[1005];
int fathercnt[1005];
int cnt;
int isgro[1005];
int main() {
    memset(isgro, 0, sizeof(isgro));
    cin >> n >> m >> k;
    int gro;
    for (int j = 1; j <= n; j++) { father[j] = j; }
    for (int i = 0; i < k; i++) {
        int g;
        cin >> g;
        isgro[g] = 1;
        gro = g;
    }
    for (int j = 1; j <= n; j++) { fathercnt[j] = 1; }
    for (int i = 0; i < m; i++) {
        int p, q;
        cin >> p >> q;
        if (isgro[p]) {
            int x;
            x = find(q);
            if (father[find(q)] != father[find(p)]) {
                father[find(q)] = father[find(p)];
                fathercnt[find(p)] += fathercnt[x];
                fathercnt[x] = 0;
            }
        } else if (isgro[q]) {
            int x;
            x = find(p);
            if (father[find(p)] != father[find(q)]) {
                father[find(p)] = father[find(q)];
                fathercnt[find(q)] += fathercnt[x];
                fathercnt[x] = 0;
            }
        } else {
            int x;
            if (isgro[father[find(p)]]) {
                x = find(q);
                if (father[find(q)] != father[find(p)]) {
                    father[find(q)] = father[find(p)];
                    fathercnt[find(p)] += fathercnt[x];
                    fathercnt[x] = 0;
                }
            } else {
                x = find(p);
                if (father[find(p)] != father[find(q)]) {
                    father[find(p)] = father[find(q)];
                    fathercnt[find(q)] += fathercnt[x];
                    fathercnt[x] = 0;
                }
            }
        }
    }
    int maxfather = 0;
    int strunity;
    for (int i = 1; i <= n; i++) {
        if (fathercnt[i] > maxfather) {
            maxfather = fathercnt[i];
            strunity = i;
        }
    }
    int maxgro = 0;
    int strgro = gro;
    for (int i = 1; i <= n; i++) {
        if (isgro[i] && fathercnt[i] > maxgro) {
            maxgro = fathercnt[i];
            strgro = i;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (fathercnt[i] != 0) {
            if (isgro[find(i)] != 1) {
                fathercnt[strgro] += fathercnt[i];
                fathercnt[i] = 0;
            }
        }
    }
    cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (isgro[i]) { cnt += (fathercnt[i] * (fathercnt[i] - 1)) / 2; }
    }
    cout << cnt - 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 constant integer N = 100 + 5
create constant integer mod = 1000000000 + 7
bool function ok with char argument a
    if a is a letter character return 1
    if a is a capital letter character return 1
    if a is a digit return 1
    if a is '_' return 1
    return to indicate successful execution
end of the block
define the main function
    declare array of characters of size N
    read a + 1
    create integer len with value = length of (a + 1)
    set integer op to 1
    set boolean flag to 1
    integers cnt1 = 0, cnt2 = 0, ccnt = 0 and cnt3 = 0
    for integer i = 1 to len and flag inclusive
        if op is equal to 1
            increase cnt1
            if a[i] is '@'
                decrement cnt1
                set value of op to 2
                go to the start of the loop
            end of the block
            if ok(a[i]) is false, set flag to 0
            if cnt1 is greater than 16, set flag to 0
        else if op is equal to 2
            increment ccnt
            if cnt1 = 0 or cnt1 > 16, set flag to 0
            if a[i] is '.'
                if cnt2 = 0 or cnt2 > 16, set flag to 0
                set cnt2 to 0
                go to the start of the loop
            end of the block
            if a[i] is '/'
                decrement ccnt
                op = 3
                continue the loop
            end of the block
            if ok(a[i]) is false, set flag to 0
            increase cnt2
            if cnt2 is greater than 16, set flag to 0
        else
            if cnt2 = 0 or cnt2 is greater than 16, set flag to 0
            if ccnt = 0 or ccnt is greater than 32, set flag to 0
            if ok(a[i]) is false, set flag to 0
            increase cnt3
            if cnt3 is greater than 16, set flag to 0
        end of the block
    end of the block
    if op is equal to 1, set flag to 0
    if op = 2 and (cnt2 = 0 or cnt2 is greater than 16), set flag to 0
    if op = 3 and (cnt3 = 0 or cnt3 is greater than 16), set flag to 0
    if flag is true
        print "YES" and a new line
    else
        print "NO" and a new line
    return to indicate successful execution
end of the block

[CODE]:

const int N = 100 + 5;
const int mod = 1000000000 + 7;
bool ok(char a) {
    if (a >= 'a' && a <= 'z') return 1;
    if (a >= 'A' && a <= 'Z') return 1;
    if (a >= '0' && a <= '9') return 1;
    if (a == '_') return 1;
    return 0;
}
int main() {
    char a[N];
    cin >> a + 1;
    int len = strlen(a + 1);
    int op = 1;
    bool flag = 1;
    int cnt1 = 0, cnt2 = 0, ccnt = 0, cnt3 = 0;
    for (int i = 1; i <= len && flag; i++) {
        if (op == 1) {
            cnt1++;
            if (a[i] == '@') {
                cnt1--;
                op = 2;
                continue;
            }
            if (!ok(a[i])) { flag = 0; }
            if (cnt1 > 16) flag = 0;
        } else if (op == 2) {
            ccnt++;
            if (cnt1 == 0 || cnt1 > 16) flag = 0;
            if (a[i] == '.') {
                if (cnt2 == 0 || cnt2 > 16) flag = 0;
                cnt2 = 0;
                continue;
            }
            if (a[i] == '/') {
                ccnt--;
                op = 3;
                continue;
            }
            if (!ok(a[i])) { flag = 0; }
            cnt2++;
            if (cnt2 > 16) flag = 0;
        } else {
            if (cnt2 == 0 || cnt2 > 16) flag = 0;
            if (ccnt == 0 || ccnt > 32) flag = 0;
            if (!ok(a[i])) flag = 0;
            cnt3++;
            if (cnt3 > 16) flag = 0;
        }
    }
    if (op == 1) flag = 0;
    if (op == 2 && (cnt2 == 0 || cnt2 > 16)) flag = 0;
    if (op == 3 && (cnt3 == 0 || cnt3 > 16)) flag = 0;
    if (flag)
        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]:
boolean function l that takes character c as argument
    return true if c is a letter
    return true if c is a capital letter
    return true if c is a digit
    return true if c is an underscore
    return false
end of the block
function un with string argument s
    set value of int n to length s
    if n is 0 or n > 16 return false
    for i = 0 to n exclusive
        if l(s at index i) is false return false
    end of the block
    return true
end of the block
function hn with string argument s
    declare integers n = size of s, i, nw = 0
    if n is 0 or n > 32 return false
    appen character '.' to s
    for i = 0 to n + 1 exclusive
        if s[i] is character "."
            if nw is equal to 0 or nw is greater than 16 return false
            nw = 0
        else
            if l(s at index i) is false return false
            increase nw
        end of the block
    end of the block
    return true
end of the block
boolean function r with string argument s
    return un(s)
end of the block
boolean function f with string argument s
    int n = length of s, i, j
    for i = 0 to n exclusive
        if s at index i is "@" break the loop
    end of the block
    if i is equal to n return false
    if un(substring of s from 0 to i) is false return false
    for j = from i + 1 to n exclusive
        if s[j] is "/" break the loop
    end of the block
    if hn(substring of s from i + 1 to j - i - 1) is false return false
    if j is not equal to n and r(substring of s from 0 to j +1) is false return false
    return true
end of the block
let s be string
define the main function
    read s
    if f(s)
        print "YES" and a new line
    else
        print "NO" and a new line
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

bool l(char c) {
    if (c >= 'a' && c <= 'z') { return true; }
    if (c >= 'A' && c <= 'Z') { return true; }
    if (c >= '0' && c <= '9') { return true; }
    if (c == '_') { return true; }
    return false;
}
bool un(string s) {
    int n = s.size();
    if (n == 0 || n > 16) { return false; }
    for (int i = 0; i < n; i++) {
        if (!l(s[i])) { return false; }
    }
    return true;
}
bool hn(string s) {
    int n = s.size(), i, nw = 0;
    if (n == 0 || n > 32) { return false; }
    s += '.';
    for (i = 0; i < n + 1; i++) {
        if (s[i] == '.') {
            if (nw == 0 || nw > 16) { return false; }
            nw = 0;
        } else {
            if (!l(s[i])) { return false; }
            nw++;
        }
    }
    return true;
}
bool r(string s) {
    return un(s);
}
bool f(string s) {
    int n = s.size(), i, j;
    for (i = 0; i < n; i++) {
        if (s[i] == '@') { break; }
    }
    if (i == n) { return false; }
    if (!un(s.substr(0, i))) { return false; }
    for (j = i + 1; j < n; j++) {
        if (s[j] == '/') { break; }
    }
    if (!hn(s.substr(i + 1, j - i - 1))) { return false; }
    if (j != n && !r(s.substr(j + 1))) { return false; }
    return true;
}
string s;
int main() {
    cin >> s;
    if (f(s)) {
        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]:
create constant integer N with N = 100 + 5
create contant integer mod with mod = 1000000000 + 7
declare boolean ok with character a as argument, returning boolean
    if a is greater than or equal to 'a' and a is less than or equal to 'z', return 1 from function
    if a is greater than or equal to 'A' and a is less than or equal to 'Z', return 1 from function
    if a is greater than or equal to '0' and a is less than or equal to '9', return 1 from function
    if a is '_', return 1 from function
    return to indicate successful execution
end of the block
define the main function
    create character array a with size N
    read a + 1
    create integer len with len = string length of (a + 1)
    create integer op with op = 1
    create boolean flag with flag = 1
    create integers cnt1, cnt2, ccnt, cnt3, with cnt1 = 0, cnt2 = 0, ccnt = 0, cnt3 = 0
    for i = 1 to len and flag inclusive
        if op is 1
            increment cnt1
            if a[i] is '@'
                decrement cnt1
                set op to 2
                break current loop iteration
            end of the block
            if result of run ok with a[i] as argument is false, set flag to 0
            if cnt1 is greater than 16, set flag to 0
        else if op is 2
            increment ccnt
            if cnt is 0 or cnt1 is greater than 16, set flag to 0
            if a[i] is '.'
                if cnt2 is 0 or cnt2 is greater than 16, set flag to 0
                set cnt2 to 0
                break current loop iteration
            end of the block
            if a[i] is '/'
                decrement ccnt
                set op to 3
                break current loop iteration
            end of the block
            if result of run ok with a[i] as argument is false, set flag to 0
            increment cnt2
            if cnt2 is greater than 16, set flag to 0
        else
            if cnt2 is 0 or cnt2 is greater than 16, set flag to 0
            if ccnt is 0 or ccnt is greater than 32, set flag to 0
            if result of run ok with a[i] as argument is false, set flag to 0
            increment cnt3
            if cnt3 is greater than 16, set flag to 0
        end of the block
    end of the block
    if op is 1, set flag to 0
    if op is 2 and ( cnt2 is 0 or cnt2 is greater than 16 ), set flag to 0
    if op is 3 and ( cnt3 is 0 or cnt3 is greater than 16 ), set flag to 0
    if flag is true
        print "YES" print newline
    else
        print "NO" print newline
    return to indicate successful execution
end of the block

[CODE]:


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

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

[PSEUDOCODE]:
define the main function
    create ints i, j, flag = 1, and dot = 0
    let string ch
    read ch
    for i = 0 to length of ch exclusive
        if ch[i] is equal to '@'
            if i is greater than 16 or i is less than 1
                set flag to 0
                move to print
            end of the block
            break loop
        else if ch[i] is greater than or equal to 'a' and ch[i] is less than or equal to 'z' or if ch[i] is greater than or equal to 'A' and ch[i] is less than or equal to 'Z'
            continue to next loop
        else if ch[i] is greater than or equal to '0' and ch[i] is less than or equal to '9' and if ch[i] is equal to '_'
            continue to next loop iteration
        else
            set flag to 0
            go to print
        end of the block
    end of the block
identify dot
    for j = i + 1 to length of ch exclusive
        if ch[j] is equal to '.'
            if j - 1 is greater than 17 or j - i is less than 2
                set flag to 0
                go to print
            end of the block
            set i to j
        else if ch[j] is greater than or equal to 'a' and ch[j] is less than or equal to 'z' or if ch[j] is greater than or equal to 'A' and ch[j] is less than or equal to 'Z'
            continue to next loop
        else if ch[j] is greater than or equal to '0' and ch[j] is less than or equal to '9' or if ch[j] is equal to '_'
            continue to next loop
        else if ch[j] is equal to '/'
            if j - 1 is greater than 17 or j - i is less than 2
                set flag to 0
                go to print
            end of the block
            set i to j
        otherwise
            set flag to 0
            move to print
        end of the block
    end of the block
    if j - i is greater than 17 or j - i is less than 2, set flag to 0
identify print
    print "YES\n" if flag is truthy or "NO\n" if not
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int i, j, flag = 1, dot = 0;
    string ch;
    cin >> ch;
    for (i = 0; i < ch.length(); i++) {
        if (ch[i] == '@') {
            if (i > 16 || i < 1) {
                flag = 0;
                goto print;
            }
            break;
        } else if ((ch[i] >= 'a' && ch[i] <= 'z') || (ch[i] >= 'A' && ch[i] <= 'Z'))
            continue;
        else if ((ch[i] >= '0' && ch[i] <= '9') || (ch[i] == '_'))
            continue;
        else {
            flag = 0;
            goto print;
        }
    }
dot:
    for (j = i + 1; j < ch.length(); j++) {
        if (ch[j] == '.') {
            if (j - i > 17 || j - i < 2) {
                flag = 0;
                goto print;
            }
            i = j;
        } else if ((ch[j] >= 'a' && ch[j] <= 'z') || (ch[j] >= 'A' && ch[j] <= 'Z'))
            continue;
        else if ((ch[j] >= '0' && ch[j] <= '9') || (ch[j] == '_'))
            continue;
        else if (ch[j] == '/') {
            if (j - i > 17 || j - i < 2) {
                flag = 0;
                goto print;
            }
            i = j;
        } else {
            flag = 0;
            goto print;
        }
    }
    if (j - i > 17 || j - i < 2) flag = 0;
print:
    (flag) ? (cout << "YES\n") : (cout << "NO\n");
    return 0;
}


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

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

[PSEUDOCODE]:
declare myCompare with constant pair address's i, j, from string to integer
    return second element of i is less than second element of j
end of the block
create string s
declare check with no arguments, returning integer
    create integers x, y, 0, with x = 0, y = 0, flag = 0
    for i = 0 to size of s
        if flag is 0
            if s[i] is '@'
                if i - x is greater than 16 or i - x is less than 1 or i + 1 is size of s, return 0 from function
                set x to i + 1
                set y to i + 1
                set flag to 1
            else if s[i] is alphanumeric or s[i] is digit or s[i] is '_'
                break current loop iteration
            else if s[i] is not alphanumeric or s[i] is not digit or s[i] is not '_'
                return to indicate successful execution
            end of the block
        else if flag is 1
            if s[i] is '/'
                if i - x is greater than 32 or i - x is less than 1 or i + 1 is size of s or s[i-1] is '.', return 0 from function
                set x to i + 1
                set flag to 2
            else if s[i] is '.'
                if i - y is greater than 16 or i - y is less than 1 or i + 1 is size of s, return 0 from function
                set y to i + 1
            else if s[i] is alphanumeric or s[i] is digit or s[i] is '.' or s[i] is '_'
                if i + 1 is size of s
                    if i - x + 1 is greater than 32 or i - x + 1 is less than 1, return 0 from function
                    if i - y + 1 is greater than 16 or i - y + 1 is less than 1, return 0 from function
                end of the block
                break current loop iteration
            else if s[i] is not alphanumeric or s[i] is not digit or s[i] is not '.' or s[i] is not '_'
                return to indicate successful execution
            end of the block
        else
            if s[i] is '_' and i + 1 is size of s, return 0 from function
            if s[i] is alphanumeric or s[i] is digit or s[i] is '_'
                if i + 1 is size of s
                    if i - x + 1 is greater than 16 or i - x + 1 is less than 1, return 0 from function
                end of the block
                break current loop iteration
            end of the block
            if s[i] is not alphanumeric or s[i] is not digit or s[i] is not '_', return 0 from function
        end of the block
    end of the block
    if flag is greater than 0
        return 1 from function
    else
        return to indicate successful execution
end of the block
define the main function
    read s
    print "YES" if result of run check is true, else "NO" print newline
    return to indicate successful execution
end of the block

[CODE]:

bool myCompare(const pair<string, int> &i, const pair<string, int> &j) {
    return i.second < j.second;
}
string s;
int check() {
    int x = 0, y = 0, flag = 0;
    for (int i = 0; i < s.size(); i++) {
        if (flag == 0) {
            if (s[i] == '@') {
                if ((i - x) > 16 || (i - x) < 1 || (i + 1 == s.size())) return 0;
                x = i + 1;
                y = i + 1;
                flag = 1;
            } else if (isalpha(s[i]) || isdigit(s[i]) || s[i] == '_') {
                continue;
            } else if (!isalpha(s[i]) || !isdigit(s[i]) || s[i] != '_') {
                return 0;
            }
        } else if (flag == 1) {
            if (s[i] == '/') {
                if ((i - x) > 32 || (i - x) < 1 || (i + 1 == s.size()) || s[i - 1] == '.') return 0;
                x = i + 1;
                flag = 2;
            } else if (s[i] == '.') {
                if ((i - y) > 16 || (i - y) < 1 || (i + 1 == s.size())) return 0;
                y = i + 1;
            } else if (isalpha(s[i]) || isdigit(s[i]) || s[i] == '.' || s[i] == '_') {
                if (i + 1 == s.size()) {
                    if ((i - x + 1) > 32 || (i - x + 1) < 1) return 0;
                    if ((i - y + 1) > 16 || (i - y + 1) < 1) return 0;
                }
                continue;
            } else if (!isalpha(s[i]) || !isdigit(s[i]) || s[i] != '.' || s[i] != '_') {
                return 0;
            }
        } else {
            if (s[i] == '_' && i + 1 == s.size()) return 0;
            if (isalpha(s[i]) || isdigit(s[i]) || s[i] == '_') {
                if (i + 1 == s.size()) {
                    if ((i - x + 1) > 16 || (i - x + 1) < 1) return 0;
                }
                continue;
            }
            if (!isalpha(s[i]) || !isdigit(s[i]) || s[i] != '_') { return 0; }
        }
    }
    if (flag > 0)
        return 1;
    else
        return 0;
}
int main() {
    cin >> s;
    cout << (check() ? "YES" : "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]:
n=int
computer and vis=array of 201 int, check=array of 3 by 201 int
vv=array of 201 vector of int
function bfs (get int k and now, return int)
    q=queue of int
    ans=n
    for i=1 to n inclusive
        if check[k][i] is 0 push i into q
    end of the block
    while q is not empty
        fill vis with 0
        while q is not empty
            head = first item in q
            pop q
            if vis[head] is n
                push head into q
                break
            end of the block
            increment vis[head]
            if computer[head] is not now
                push head into q
                continue
            end of the block
            for i=0 to size of vv[head] exclusive
                decrement check[k][vv[head][i]]
                if check[k][vv[head][i]] is 0 push vv[head][i] into q
            end of the block
        end of the block
        now = 1 if now is 3 else now+1
        if q is not empty increment ans
    end of the block
    return ans
end of the block
define the main function
    while read n
        fill check with 0
        for i=1 to n inclusive clear vv[i]
        for i=1 to n inclusive read compute[i]
        for i=1 to n inclusive
            ki=int
            read ki
            for j=1 to ki inclusive
                aj=int
                read aj
                add i to end of vv[aj]
                increment check[0][i],check[1][i],check[2][i]
            end of the block
        end of the block
        ans=3f3f3f3f in exadecimal
        for i=1 to 3 exclusive ans=min(ans, bfs(i-1,i))
        print ans
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int n;
int computer[201], check[3][201], vis[201];
vector<int> vv[201];
int bfs(int k, int now) {
    queue<int> q;
    int ans = n;
    for (int i = 1; i <= n; i++) {
        if (check[k][i] == 0) q.push(i);
    }
    while (!q.empty()) {
        memset(vis, 0, sizeof(vis));
        while (!q.empty()) {
            int head = q.front();
            q.pop();
            if (vis[head] == n) {
                q.push(head);
                break;
            }
            vis[head]++;
            if (computer[head] != now) {
                q.push(head);
                continue;
            }
            for (int i = 0; i < vv[head].size(); i++) {
                check[k][vv[head][i]]--;
                if (check[k][vv[head][i]] == 0) q.push(vv[head][i]);
            }
        }
        now = (now == 3 ? 1 : now + 1);
        if (!q.empty()) ans++;
    }
    return ans;
}
int main() {
    while (cin >> n) {
        memset(check, 0, sizeof(check));
        for (int i = 1; i <= n; i++) vv[i].clear();
        for (int i = 1; i <= n; i++) cin >> computer[i];
        for (int i = 1; i <= n; i++) {
            int ki;
            cin >> ki;
            for (int j = 1; j <= ki; j++) {
                int aj;
                cin >> aj;
                vv[aj].push_back(i);
                check[0][i]++, check[1][i]++, check[2][i]++;
            }
        }
        int ans = 0x3f3f3f3f;
        for (int i = 1; i <= 3; i++) ans = min(ans, bfs(i - 1, i));
        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]:
let n be an int
let computer be an integer array of length 201, check an integer matrix of size 3x201, vis an integer array of length 201
let vv be an integer vector of size 201
in int function bsf that takes int num, int st
    let q be a queue of int
    let ans = n be an int
    for i = 1 to n inclusive
        if che[num][i] is 0, push i in q
    end of the block
    while q is not empty
        reset vis to all 0
        while q is not empty
            let head = int = result of calling front on q
            pop q
            if vis at head is n
                push head in q
                exit loop
            end of the block
            increment vis[head]
            if computer at head is not st
                push head in q
                next iteration
            end of the block
            for i = 0 to size of vv[head] exclusive
                let v = vv[head][i] be an int
                decrement check[num][v]
                if check[num][v] is 0 then push v in q
            end of the block
        end of the block
        set st to 1 if st is 3 else set st to st + 1
        if q is not empty then increment ans
    end of the block
    return ans
end of the block
define the main function
    while reading n
        reset check to all 0
        clear n elements of vv[i]
        read n elements of computer
        for i = 1 to n inclusive
            let ki = integer
            read ki
            for j = 1 to ki inclusive
                let aj be an integer
                read aj
                add i to the end of vv[aj]
                increment check[0][i]++, check[1][i]++, check[2][i]++
            end of the block
        end of the block
        let ans be an int = 0x3f3f3f3f
        for i = 1 to 3 inclusive, set ans to the minimum between ans and bfs of i - 1 and i
        print ans
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int n;
int computer[201], check[3][201], vis[201];
vector<int> vv[201];
int bfs(int num, int st) {
    queue<int> q;
    int ans = n;
    for (int i = 1; i <= n; i++) {
        if (check[num][i] == 0) q.push(i);
    }
    while (!q.empty()) {
        memset(vis, 0, sizeof(vis));
        while (!q.empty()) {
            int head = q.front();
            q.pop();
            if (vis[head] == n) {
                q.push(head);
                break;
            }
            vis[head]++;
            if (computer[head] != st) {
                q.push(head);
                continue;
            }
            for (int i = 0; i < vv[head].size(); i++) {
                int v = vv[head][i];
                check[num][v]--;
                if (check[num][v] == 0) q.push(v);
            }
        }
        st = (st == 3 ? 1 : st + 1);
        if (!q.empty()) ans++;
    }
    return ans;
}
int main() {
    while (cin >> n) {
        memset(check, 0, sizeof(check));
        for (int i = 1; i <= n; i++) vv[i].clear();
        for (int i = 1; i <= n; i++) cin >> computer[i];
        for (int i = 1; i <= n; i++) {
            int ki;
            cin >> ki;
            for (int j = 1; j <= ki; j++) {
                int aj;
                cin >> aj;
                vv[aj].push_back(i);
                check[0][i]++, check[1][i]++, check[2][i]++;
            }
        }
        int ans = 0x3f3f3f3f;
        for (int i = 1; i <= 3; i++) ans = min(ans, bfs(i - 1, i));
        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]:
declare int N and an arrays of ints a and c with 200 elements
declare an array of int vectors called edges with 200 elements
int function simulate with int argument s
    set first sizeof(c) bytes at the pointer c to 0
    for i = 0 to N exclusive
        for j = 0 to length of edges[i] exclusive, increment c[edges[i][j]]
    end of the block
    q is a new array of int queues with 3 elements
    for integer i = 0 to N exclusive
        if c[i] is false, push i into q[a[i]]
    create integer poped = 0
    declare int variable ret = -1
    while poped < N
        while q[s] is not empty
            declare int variable f = front element of q[s]
            remove front element from q[s]
            increment poped by one
            for i = 0 to length of edges[f] exclusive
                create int next = edges[f][i]
                decrement c[next], if c[next] != 0, push next into q[a[next]]
            end of the block
        end of the block
        assign (s + 1) % 3 to s
        increment ret by one
    end of the block
    return ret
end of the block
define the main function
    read N and loop further
        for i = 0 to N exclusive
        for integer i = int to N exclusive
            read input to a[i]
            a[i] = a[i] modulo 3
        end of the block
        for integer i = 0 to N exclusive
            declare ints k and t
            read k
            for j = 0 to k exclusive
                read input to t
                push i into edges[t - 1]
            end of the block
        end of the block
        create integer ans = 1000000000
        for integer i = 0 to 3 exclusive, set ans to min(ans, simulate(i))
        print ans + N
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int N, a[200], c[200];
vector<int> edges[200];
int simulate(int s) {
    memset(c, 0, sizeof(c));
    for (int i = int(0); i < int(N); i++) {
        for (int j = int(0); j < int(edges[i].size()); j++) c[edges[i][j]]++;
    }
    queue<int> q[3];
    for (int i = int(0); i < int(N); i++)
        if (!c[i]) q[a[i]].push(i);
    int poped = 0;
    int ret = -1;
    while (poped < N) {
        while (!q[s].empty()) {
            int f = q[s].front();
            q[s].pop();
            poped++;
            for (int i = int(0); i < int(edges[f].size()); i++) {
                int next = edges[f][i];
                if (!--c[next]) { q[a[next]].push(next); }
            }
        }
        s = (s + 1) % 3;
        ret++;
    }
    return ret;
}
int main() {
    while (cin >> N) {
        for (int i = int(0); i < int(N); i++) edges[i].clear();
        for (int i = int(0); i < int(N); i++) {
            cin >> a[i];
            a[i] %= 3;
        }
        for (int i = int(0); i < int(N); i++) {
            int k, t;
            cin >> k;
            for (int j = int(0); j < int(k); j++) {
                cin >> t;
                edges[t - 1].push_back(i);
            }
        }
        int ans = 1000000000;
        for (int i = int(0); i < int(3); i++) ans = min(ans, simulate(i));
        cout << ans + 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]:
create const int N = 205
declare integer variable n and arrays of integers in, tin and a with size N
declare vector of integers e
bfs is an int function with int argument k
    Q is a queue of integers with 5 elements
    for integer i = 1 to n inclusive
        if in[i] is false, push i into Q[a[i]]
    for i = 1 to n inclusive, change tin[i] to in[i]
    declare int step = -1
    while any of Q[1], Q[2] or Q[3] is not empty
        increment step by one
        while Q[k] is not empty
            declare integer variable u = front element of Q[k]
            remove front element from Q[k]
            increment step
            for i from 0 to length of e[u] exclusive
                declare int v = e[u][i]
                decrement tin[v] by one
                if tin[v] is false, push v into Q[a[v]]
            end of the block
        end of the block
        if k = 1
            assign 2 to k
        else if k = 2
            assign 3 to k
        else if k = 3
            assign 1 to k
    end of the block
    if step != -1, return step
    return to indicate successful execution
end of the block
define the main function
    read n
    for i = 1 to n inclusive, read a[i]
    for integers i = 1, m and x, while i <= n, incrementing i
        read input to m
        change in[i] to m
        decrement m and loop further, while m is not 0
            read x
            push i into e[x]
        end of the block
    end of the block
    declare integer variable ans = 0x3f3f3f3f
    for i = 1 to 3 inclusive, set ans to min of ans and bfs(i)
    print ans
    return to indicate successful execution
end of the block

[CODE]:

const int N = 205;
int in[N], tin[N], n, a[N];
vector<int> e[N];
int bfs(int k) {
    queue<int> Q[5];
    for (int i = 1; i <= n; i++)
        if (!in[i]) Q[a[i]].push(i);
    for (int i = 1; i <= n; i++) tin[i] = in[i];
    int step = -1;
    while (!Q[1].empty() || !Q[2].empty() || !Q[3].empty()) {
        step++;
        while (!Q[k].empty()) {
            int u = Q[k].front();
            Q[k].pop();
            step++;
            for (int i = 0; i < e[u].size(); i++) {
                int v = e[u][i];
                tin[v]--;
                if (!tin[v]) Q[a[v]].push(v);
            }
        }
        if (k == 1)
            k = 2;
        else if (k == 2)
            k = 3;
        else if (k == 3)
            k = 1;
    }
    if (step != -1) return step;
    return 0;
}
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1, m, x; i <= n; i++) {
        cin >> m;
        in[i] = m;
        while (m--) {
            cin >> x;
            e[x].push_back(i);
        }
    }
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= 3; i++) ans = min(ans, bfs(i));
    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]:
let n be an int
let vv be an int vector of size 210
let computer, in, bk, temp be integer vectors of size 210 each
in int function bfs which takes int st
    let q be an int queue
    let ans = n = integer
    for i = 1 to n inclusive
        if in at i is 0 then push i into q
    end of the block
    while q isn't empty
        reset all bk to 0
        while q isn't empty
            head = front of q = integer
            pop q
            if bk at head is 5
                push head in q
                exit loop
            end of the block
            increment bk at head
            if computer at head is not st
                push head into q
                next iteration
            end of the block
            let up be an integer = the size of vv at head
            for i = 0 to up exclusive
                let the integer v be vv[head][i]
                decrement in at v
                if in at v is 0 then push v into q
            end of the block
        end of the block
        set st = 1 if st is 3 else increment st
        if q isn't empty then increment ans
    end of the block
    return ans
end of the block
define the main function
    while reading n
        reset all in to 0
        clear vv form 1 to n inclusive
        read computer from 1 to n inclusive
        for i = 1 to n inclusive
            let ki be an int
            read ki
            for j = 1 to ki inclusive
                declare int aj
                read aj
                add i to the end of vv[aj]
                increment in at i
            end of the block
        end of the block
        let ans be an integer = 0x3f3f3f3f
        for i = 1 to n inclusive, set temp at i to in at i
        for i = 1 to 3 inclusive
            for j = 1 to n inclusive
            set ans to the minimum between ans and bfs of i
        end of the block
        print ans
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int n;
vector<int> vv[210];
int computer[210], in[210], bk[210], temp[210];
int bfs(int st) {
    queue<int> q;
    int ans = n;
    for (int i = 1; i <= n; i++) {
        if (in[i] == 0) q.push(i);
    }
    while (!q.empty()) {
        memset(bk, 0, sizeof(bk));
        while (!q.empty()) {
            int head = q.front();
            q.pop();
            if (bk[head] == 5) {
                q.push(head);
                break;
            }
            bk[head]++;
            if (computer[head] != st) {
                q.push(head);
                continue;
            }
            int up = vv[head].size();
            for (int i = 0; i < up; i++) {
                int v = vv[head][i];
                in[v]--;
                if (in[v] == 0) q.push(v);
            }
        }
        st = (st == 3 ? 1 : st + 1);
        if (!q.empty()) ans++;
    }
    return ans;
}
int main() {
    while (cin >> n) {
        memset(in, 0, sizeof(in));
        for (int i = 1; i <= n; i++) vv[i].clear();
        for (int i = 1; i <= n; i++) cin >> computer[i];
        for (int i = 1; i <= n; i++) {
            int ki;
            cin >> ki;
            for (int j = 1; j <= ki; j++) {
                int aj;
                cin >> aj;
                vv[aj].push_back(i);
                in[i]++;
            }
        }
        int ans = 0x3f3f3f3f;
        for (int i = 1; i <= n; i++) temp[i] = in[i];
        for (int i = 1; i <= 3; i++) {
            for (int j = 1; j <= n; j++) in[j] = temp[j];
            ans = min(ans, bfs(i));
        }
        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]:
mod = 10^9+7
function fast_pow (get int a and b, return int)
    res=a, ret=1
    while b>0
        if b modulo 2 ret=(ret*res) modulo mod
        res=(res*res) modulo mod
        divide b by 2
    end of the block
    return ret
end of the block
n=int
m=int
c=array of 200 int
g=array of 200 by 200 int
define the main function
    read n
    for i=0 to n exclusive
        read c[i]
        decrement c[i]
    end of the block
    for i=0 to n exclusive
        k=int
        read k
        for j=0 to k exclusive
            u=int
            read u
            decrement u
            g[u][i]=1
        end of the block
    end of the block
    ans=100*n
    for start=0 to 3 exclusive
        m=0
        ok=array of 200 bool
        fill ok with 0
        cur=start
        res=n
        while m not equal n
            while true
                kpyto=false
                for i=0 to n exclusive
                    if ok[i] or c[i] != cur continue
                    win=true
                    for j=0 to n exclusive
                        if g[j][j] and not ok[j]
                            win=false
                            break
                        end of the block
                    end of the block
                    if win
                        kpyto=true
                        increment m
                        ok[i]=true
                    end of the block
                end of the block
                if not kpyto break
            end of the block
            if m is n break
            cur=(cur+1) modulo 3
            increment res
        end of the block
        ans=min(res, ans)
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:

const int mod = 1e9 + 7;
int fast_pow(int a, int b) {
    int res = a, ret = 1;
    while (b > 0) {
        if (b % 2) ret = (ret * res) % mod;
        res = (res * res) % mod;
        b /= 2;
    }
    return ret;
}
int n;
int m;
int c[200];
int g[200][200];
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        c[i]--;
    }
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int u;
            cin >> u;
            u--;
            g[u][i] = 1;
        }
    }
    int ans = 100 * n;
    for (int start = 0; start < 3; ++start) {
        m = 0;
        bool ok[200];
        memset(ok, 0, sizeof(ok));
        int cur = start;
        int res = n;
        while (m != n) {
            while (1) {
                bool kpyto = false;
                for (int i = 0; i < n; ++i) {
                    if (ok[i] || c[i] != cur) continue;
                    bool win = true;
                    for (int j = 0; j < n; ++j) {
                        if (g[j][i] && (!ok[j])) {
                            win = false;
                            break;
                        }
                    }
                    if (win) {
                        kpyto = true;
                        m++;
                        ok[i] = true;
                    }
                }
                if (!kpyto) break;
            }
            if (m == n) break;
            cur = (cur + 1) % 3;
            res++;
        }
        ans = min(res, ans);
    }
    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]:
tu = int vector array of size 1005
a, cnt, checks = int array of size 1005 each and n = int
in function check taking an int x and returning an in
    i, k = int
    sum = int with sum = -1
    qua = int queue array of size 5
    for i = 1 to n inclusive
        if cnt[i] is 0 then push i to qua[a[i]]
    end of the block
    loop infinitely
        if size of qua[1] or size of qua[2] or size of qua[3] is 0 break
        loop while qua[x] is not empty
            increment sum
            set k to front of qua[x]
            pop qua[x]
            for i = 0 to size of tu[k]
                xx = int with xx = tu[k][i]
                decrement cnt[xx]
                if cnt[xx] is 0 push xx to qua[a[xx]]
            end of the block
        end of the block
        if x is 1
            set x to 2
        else if x is 2
            set x to 3
        else if x is 3
            set x to 1
        increment sum
    end of the block
    if sum is -1
        return to indicate successful execution
    else
        return sum
end of the block
define the main function
    i = int
    ans, T, x = int
    read n
    set all values of a to 0
    set all values of tu to 0
    set all values of cnt to 0
    for i = 1 to n inclusive read a[i]
    for i = 1 to n inclusive
        read T
        loop T times
            read x
            append i to tu[x]
            increment checks[i]
        end of the block
    end of the block
    set ans to 1 bitshift right by 30
    j = int
    for i = 1 to 3 inclusive
        for j = 1 to n inclusive set cnt[j] to checks[j]
        set ans to min of ans and check of i
    end of the block
    set ans
end of the block

[CODE]:

vector<int> tu[1005];
int a[1005], cnt[1005], n, checks[1005];
int check(int x) {
    int i, k;
    int sum = -1;
    queue<int> qua[5];
    for (i = 1; i <= n; i++) {
        if (cnt[i] == 0) { qua[a[i]].push(i); }
    }
    for (;;) {
        if (qua[1].size() == 0 && qua[2].size() == 0 && qua[3].size() == 0) break;
        while (!qua[x].empty()) {
            sum++;
            k = qua[x].front();
            qua[x].pop();
            for (i = 0; i < tu[k].size(); i++) {
                int xx = tu[k][i];
                cnt[xx]--;
                if (cnt[xx] == 0) qua[a[xx]].push(xx);
            }
        }
        if (x == 1)
            x = 2;
        else if (x == 2)
            x = 3;
        else if (x == 3)
            x = 1;
        sum++;
    }
    if (sum == -1)
        return 0;
    else
        return sum;
}
int main() {
    int i;
    int ans, T, x;
    cin >> n;
    memset(a, 0, sizeof(a));
    memset(tu, 0, sizeof(tu));
    memset(cnt, 0, sizeof(cnt));
    for (i = 1; i <= n; i++) { cin >> a[i]; }
    for (i = 1; i <= n; i++) {
        cin >> T;
        while (T--) {
            cin >> x;
            tu[x].push_back(i);
            checks[i]++;
        }
    }
    ans = 1 << 30;
    int j;
    for (i = 1; i <= 3; i++) {
        for (j = 1; j <= n; j++) { cnt[j] = checks[j]; }
        ans = min(ans, check(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]:
N = const integer with N = 2e2 + 5
n, c, vis = integers with c, vis = array of size N
ned, a = vector of integers array of size N
in the function solve that takes integer x and returns integer
    set all contents of vis to 0
    res, cnt, flag = integers with res = 0, cnt = 0, flag = 0
    while cnt < n
        mk = bool with mk = true
        while mk
            mk = false
            for i = 0 to a[x].size() exclusive
                id = integer with id = a[x][i], tot = 0
                if vis[id], continue next iteration
                for j = 0 to ned[id].size() exclusive
                    if vis[ned[id][j]], increment tot
                if tot is ned[id].size()
                    increment res and cnt
                    vis[id] = 1
                    flag = 0
                    mk = true
                end of the block
            end of the block
        end of the block
        if cnt is n, return res
        increment x
        if x > 3, x = 1
        increment res, flag
        if flag < -4, return 2e9
    end of the block
end of the block
define the main function
    read n
    for i = 1 to n, read c[i], a[c[i]].push_back(i)
    for i = 1 to n
        k = integer
        read k
        for j = 0 to k exclusive
            x = integer
            read x
            append x in ned[i]
        end of the block
    end of the block
    res = integer with res = 2e9
    for i = 1 to 3, res = min(res, solve(i))
    print res
    return to indicate successful execution
end of the block

[CODE]:

const int N = 2e2 + 5;
int n, c[N], vis[N];
vector<int> ned[N], a[N];
int solve(int x) {
    memset(vis, 0, sizeof(vis));
    int res = 0, cnt = 0, flag = 0;
    while (cnt < n) {
        bool mk = true;
        while (mk) {
            mk = false;
            for (int i = 0; i < a[x].size(); i++) {
                int id = a[x][i], tot = 0;
                if (vis[id]) continue;
                for (int j = 0; j < ned[id].size(); j++)
                    if (vis[ned[id][j]]) tot++;
                if (tot == ned[id].size()) {
                    res++, cnt++;
                    vis[id] = 1;
                    flag = 0;
                    mk = true;
                }
            }
        }
        if (cnt == n) return res;
        x++;
        if (x > 3) x = 1;
        res++, flag--;
        if (flag < -4) return 2e9;
    }
}
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> c[i], a[c[i]].push_back(i);
    for (int i = 1; i <= n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int x;
            cin >> x;
            ned[i].push_back(x);
        }
    }
    int res = 2e9;
    for (int i = 1; i <= 3; i++) res = min(res, solve(i));
    cout << res << '\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 desperate_optimization (get precision as int)
    use normal notation
    show decimal point
    set precision digits
end of the block
vec=vector of 250 int
q=array of 3 queue of int
qq=array of 3 queue of int
type=array of 250 int
outt = array of 250 int
toutt = array of 250 int
define the main function
    desperate_optimization(20)
    n=int
    read n
    for i=1 to n inclusive read type[i]
    for i=1 to n inclusive
        decrement type[i]
        x=int
        read x
        outt[i] = x
        while decremented x > 0
            u=int
            read u
            add i to end of vec[u]
        end of the block
    end of the block
    for i=1 to n inclusive
        if outt[i] is 0 push i into q[type[i]]
    start=0
    for i=0 to 3 exclusive qq[i]=q[i]
    for i=1 to n inclusive toutt[i]=outt[i]
    ans=1000000000
    for i=0 to 3 exclusive
        if qq[i] is empty continue
        for j=0 to 3 exclusive q[j]=qq[j]
        for j=1 to n inclusive outt[j]=toutt[j]
        start=i
        total=0
        while q[0], q[1] and q[2] are not empty
            while q[start] is not empty
                pos=first item of q[start]
                pop q[start]
                for i=0 to size of vec[pos] exclusive
                    nx=vec[pos][i]
                    decrement outt[nx]
                    if outt[nx] is 0 push nx into q[type[nx]]
                end of the block
                increment total
            end of the block
            start=(start+1) modulo 3
            increment total
        end of the block
        ans=min(ans, total-1)
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:

void desperate_optimization(int precision) {
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(precision);
}
vector<int> vec[250];
queue<int> q[3];
queue<int> qq[3];
int type[250];
int outt[250];
int toutt[250];
int main() {
    desperate_optimization(20);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> type[i];
    for (int i = 1; i <= n; i++) {
        type[i]--;
        int x;
        cin >> x;
        outt[i] = x;
        while (x--) {
            int u;
            cin >> u;
            vec[u].push_back(i);
        }
    }
    for (int i = 1; i <= n; i++)
        if (outt[i] == 0) q[type[i]].push(i);
    int start = 0;
    for (int i = 0; i < 3; i++) qq[i] = q[i];
    for (int i = 1; i <= n; i++) toutt[i] = outt[i];
    int ans = 1e9;
    for (int i = 0; i < 3; i++) {
        if (qq[i].empty() == true) continue;
        for (int j = 0; j < 3; j++) q[j] = qq[j];
        for (int j = 1; j <= n; j++) outt[j] = toutt[j];
        start = i;
        int total = 0;
        while (!q[0].empty() || !q[1].empty() || !q[2].empty()) {
            while (!q[start].empty()) {
                int pos = q[start].front();
                q[start].pop();
                for (int i = 0; i < vec[pos].size(); i++) {
                    int nx = vec[pos][i];
                    outt[nx]--;
                    if (outt[nx] == 0) q[type[nx]].push(nx);
                }
                total++;
            }
            start = (start + 1) % 3;
            total++;
        }
        ans = min(ans, total - 1);
    }
    cout << ans << '\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
    n,m,a=int
    read n
    c and n = array of n+1 int, filled with 0
    g=array of n+2 vector of int
    cc=array of 5 vector of int
    for i=0 to n exclusive
        read c[i]
        decrement c[i]
        add i to end of cc[c[i]]
    end of the block
    for i=0 to n exclusive
        read m
        while decremented value of m is not 0
            read a
            add i to end of g[a-1]
            increment d[i]
        end of the block
    end of the block
    mx=INT_MAX
    for k=0 to n exclusive
        if d[k] is 0
            dp=array of n+1 int
            for i=0 to n exclusive dp[i]=d[i]
            p=c[k], ok=0, an=n
            while true
                if ok is n break
                for i=0 to size of cc[p] exclusive
                    if d[cc[p][i]] is 0
                        decrement d[cc[p][i]]
                        increment ok
                        for j=0 to size of g[cc[p][i]] exclusive
                            u=g[cc[p][i]][j]
                            decrement d[u]
                        end of the block
                        i=-1
                    end of the block
                end of the block
                if ok and ok<n increment an
                p=(p+1) modulo 3
            end of the block
            for i=0 to n exclusive d[i]=dp[i]
            mx=min(mx,an)
        end of the block
    print mx
end of the block

[CODE]:

int main() {
    int n, m, a;
    cin >> n;
    int c[n + 1], d[n + 1] = {0};
    vector<int> g[n + 2];
    vector<int> cc[5];
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
        cc[c[i]].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> m;
        while (m--) {
            cin >> a;
            g[a - 1].push_back(i);
            d[i]++;
        }
    }
    int mx = INT_MAX;
    for (int k = 0; k < n; k++)
        if (d[k] == 0) {
            int dp[n + 1];
            for (int i = 0; i < n; i++) dp[i] = d[i];
            int p = c[k], ok = 0, an = n;
            while (1) {
                if (ok == n) break;
                for (int i = 0; i < cc[p].size(); i++) {
                    if (d[cc[p][i]] == 0) {
                        d[cc[p][i]]--;
                        ok++;
                        for (int j = 0; j < g[cc[p][i]].size(); j++) {
                            int u = g[cc[p][i]][j];
                            d[u]--;
                        }
                        i = -1;
                    }
                }
                if (ok && ok < n) an++;
                p = (p + 1) % 3;
            }
            for (int i = 0; i < n; i++) d[i] = dp[i];
            mx = min(mx, an);
        }
    cout << mx << 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 length 110
b = integer array of length 110
define the main function
    s = string
    read one line into s
    num, ten = integers with num value of 0 and ten value of 1
    for i = size of s-1 to 0 inclusive descending
        if s[i] equals = then break
        if s[i] is less than '9' and greater than '0'
            x = integer with value of s[i] - '0'
            increase num by x*ten
            set ten to ten * 10
        end of the block
    end of the block
    cnt = integer with value of 0
    set a[0] to 1
    for i = 0 to size of s exclusive
        if s[i] equals '+'
            increase cnt by 1 and set a[cnt] to 1
        else if s[i] equals '-'
            increase cnt by 1 and set a[cnt] to 0
        end of the block
    end of the block
    x = integer with value of 0
    for i =0 to cnt inclusive
        set b[i] to 1
        if a[i]
            increase x by b[i]
        else
            decrease x by b[i]
    end of the block
    set x to num - x
    for i = 0 to cnt inclusive
        if x is less than 0
            if a[i] equals 0 and b[i] is less than num
                k = integer with value of the minimum of num-b[i] and negative x
                increase b[i] by k
                increase x by k
            end of the block
        else if x is greater than 0
            if a[i] equals 1 and b[i] is less than num
                k = integer with value of the minimum of num-b[i] and x
                increase b[i] by k
                decrease x by b[i]
            end of the block
        else
            break
    end of the block
    set x to 0
    for i = 0 to count inclusive
        if a[i]
            increase x by b[i]
        else
            decrease x by b[i]
    end of the block
    if x does not equal num
        print Impossible
        return to indicate successful execution
    end of the block
    print Possible
    set cnt to 0
    for i = 0 to size of s exclusive
        if s[i] equals '+' or '-' or '=' print b[cnt] space s[i] space then increase cnt by 1
    end of the block
    print num
    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]:
let c be a character array of size 1000
let res be an integer array of size 1000
let l, mn, pl, n be integers with pl = 1
define the main function
    ch = character
    input ch
    while input ch
        if ch is the character =, break
        set c[l] to ch
        if c[l] is the character +
            increment pl
        else
            increment mn
        increment l
        input ch
    end of the block
    input n
    if n * pl - nm is less than n or pl - n * mn is greater than n
        print Impossible
    else
        print Possible
        for i = 0 to 1 inclusive, set res[i] to 1
        d is an integer with d = n - (pl - mn)
        for i = 0 to 1 inclusive
            if (i equals 0 or c[i - 1] equals the character +) and d is greater than 0
                if d is less than n - res[i]
                    add d to res[i]
                    set d to 0
                else
                    subtract n - res[i] from d
                    res[i] is assigned n
                end of the block
            else if i isn't 0 and c[i - 1] equals the character - and d is less than 0
                if -d is less than n - res[i]
                    add -d to res[i]
                    set d to 0
                else
                    add n - res[i] to d
                    set res[i] to n
                end of the block
            end of the block
        end of the block
        output res[0]
        for i = 0 to 1 exclusive, output the character space, c[i] the character space, and res[i + 1]
        output the string " = " and n
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

char c[1000];
int res[1000];
int l, mn, pl = 1, n;
int main() {
    char ch;
    cin >> ch;
    while (cin >> ch) {
        if (ch == '=') break;
        c[l] = ch;
        if (c[l] == '+')
            pl++;
        else
            mn++;
        l++;
        cin >> ch;
    }
    cin >> n;
    if (n * pl - mn < n || pl - n * mn > n)
        cout << "Impossible" << endl;
    else {
        cout << "Possible" << endl;
        for (int i = 0; i <= l; i++) res[i] = 1;
        int d = n - (pl - mn);
        for (int i = 0; i <= l; i++) {
            if ((i == 0 || c[i - 1] == '+') && d > 0) {
                if (d < n - res[i]) {
                    res[i] += d;
                    d = 0;
                } else {
                    d -= n - res[i];
                    res[i] = n;
                }
            } else if (i != 0 && c[i - 1] == '-' && d < 0) {
                if (-d < n - res[i]) {
                    res[i] += -d;
                    d = 0;
                } else {
                    d += n - res[i];
                    res[i] = n;
                }
            }
        }
        cout << res[0];
        for (int i = 0; i < l; i++) cout << " " << c[i] << " " << res[i + 1];
        cout << " = " << 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]:
p, n, k, s = integer with p = 1, s = array of size 105
c = character
define the main function
    s[increment k] = 1
    while (read c and c is not =
        if c is +, increment p, s[increment k] = 1
        if c is -, decrement p, s[increment k] = -1
    end of the block
    read n
    for i = 0 to k exclusive
        if s[i] > 0
            while p < n and s[i] < n, increment s[i], increment p
        else
            while p > n and s[i] > -n, decrement s[i], decrement p
    end of the block
    if p is not n
        print Impossible
        return to indicate successful execution
    end of the block
    print Possible
    for i = 0 to k exclusive, (if i, (if s[i] < 0, print - else print +) else ), and print absolute of s[i]
    print = and 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]:
declare character array a with size 1204000
define the main function
    loop when read input to a
        create int array A with 1204 elements
        declare integer ans = 0
        declare integer r = 0
        declare integer flag = 0
        declare integer p = 0
        for i from 0 to exclusive incrementing i
            if a[i] is '?'
                if flag is false
                    change A[r] to 1
                    increment r
                    increment p
                end of the block
                if flag is true
                    assign - 1 to A[r]
                    increment r
                    decrement p
                end of the block
            end of the block
            if a[i] is '-', change flag to 1
            if a[i] is '+', change flag to 0
            if a[i] >= '0' and a[i] <= '9', change n to n * 10 + a[i] - '0'
        end of the block
        loop i from 0 to r exclusive incrementing i
            if A[i] is less than 0
                if p is greater than n
                    looping infinitely
                        if absolute value pf A[i] >= n or p = n, stop the loop
                        decrement A[i]
                        decrement p
                    end of the block
                end of the block
            else if A[i] is greater than 0
                if p is less than n
                    in the infinite loop
                        if A[i] >= n or p = n, stop the loop
                        increment A[i]
                        increment p by one
                    end of the block
                end of the block
            end of the block
        end of the block
        if p != n
            print "Impossible"
        else
            print "Possible"
            if A[0] is greater than 0
                print A[0]
            else
                print A[0]
            end of the block
            for i = 1 to r exclusive
                print " "
                if A[i] is greater than 0
                    print "+"
                else
                    print "-"
                end of the block
                print " " and absolute value of A[i]
            end of the block
            print " = " and n
        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
    set int n, sum to 0
    create an integer vector v
    set character mark to value of +
    if mark is not equal to = then do the following
        if mark is + then do
            set the push_back value of v to 1
            add one to sum
        end of the block
        if mark is - then do
            set the push_back value of v to -1
            minus 1 from sum
        end of the block
        take input mark
    end of the block
    read n
    for i = 0 to less than or equal to v.size() - 1 do the following
        if sum is greater than n then do
            if v[i] is less than 0 then do
                if sum - n is less than or equal to n - 1 then do
                    subtract sum - n from v[i]
                    set sum to n
                    break
                else
                    subtract n - 1 from v[i]
                    subtract n - 1 from sum
                end of the block
            end of the block
        else if the sum is less than n
            if v[i] is greater than 0 then do
                if n - sum is less than or equal to n - 1 then do
                    v[i] equals v[i] plus n - sum
                    set sum to n
                    break
                else
                    v[i] equals v[i] plus n - 1
                    sum equals sum plus n - 1
                end of the block
            end of the block
        else
            break
    end of the block
    if sum is n then do
        output Possible
        output v[0]
        for i = 1 to less than or equal to v.size() - 1 do the following
            if v[i] is greater than 0 then do
                output +
            else
                output -
            output the absolute value of v[i]
        end of the block
        output = n
    else
        output Impossible
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, sum = 0;
    vector<int> v;
    char mark = '+';
    while (mark != '=') {
        if (mark == '+') {
            v.push_back(1);
            sum++;
        }
        if (mark == '-') {
            v.push_back(-1);
            sum--;
        }
        cin >> mark;
    }
    cin >> n;
    for (int i = 0; i <= v.size() - 1; i++) {
        if (sum > n) {
            if (v[i] < 0) {
                if (sum - n <= n - 1) {
                    v[i] -= sum - n;
                    sum = n;
                    break;
                } else {
                    v[i] -= n - 1;
                    sum -= n - 1;
                }
            }
        } else if (sum < n) {
            if (v[i] > 0) {
                if (n - sum <= n - 1) {
                    v[i] += n - sum;
                    sum = n;
                    break;
                } else {
                    v[i] += n - 1;
                    sum += n - 1;
                }
            }
        } else
            break;
    }
    if (sum == n) {
        cout << "Possible" << endl;
        cout << v[0] << " ";
        for (int i = 1; i <= v.size() - 1; i++) {
            if (v[i] > 0)
                cout << "+ ";
            else
                cout << "- ";
            cout << abs(v[i]) << " ";
        }
        cout << "= " << n << endl;
    } else
        cout << "Impossible" << endl;
    return 0;
}


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

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

[PSEUDOCODE]:
maxn = const int with maxn = 105
num = integer array of size maxn
define the main function
    s = string
    read s
    n = integer
    l = integer with l = s.size()
    set all contents of num to 0
    zheng, fu = integer with zheng = 0, fu = 0
    zuida = int with zuida = 1
    pos = integer
    num[1] = 1
    increment zheng
    increment zuida
    for i = 1 to l
        if s[i] is +
            num[increment zuida] = 1
            increment zheng
        else if s[i] is -
            num[increment zuida] = -1
            increment fu
        else if s[i] is =
            pos = i
            break loop
        end of the block
    end of the block
    a = string with a = s.substr(pos + 2)
    ss = stringstream, call ss on a
    right shift ss n times
    flag = bool with flag = false
    for i = 1 to zuida exclusive
        if n is zheng - fu)
            flag = true
            break loop
        end of the block
        while n > zheng - fu and num[i] > 0 and num[i] < n
            increment zheng
            increment num[i]
        end of the block
        while (n < zheng - fu and num[i] < 0 and abs(num[i]) < n)
            increment fu
            decrement num[i]
        end of the block
    end of the block
    if n is zheng - fu, flag = true
    if flag
        print Possible
        print num[1]
        for i = 2 to zuida exclusive
            if num[i] < 0
                print - and -num[i]
            else
                print + and num[i]
        end of the block
        print =
        print n
    else
        print Impossible
    return to indicate successful execution
end of the block

[CODE]:

const int maxn = 105;
int num[maxn];
int main() {
    string s;
    getline(cin, s);
    int n;
    int l = s.size();
    memset(num, 0, sizeof(num));
    int zheng = 0, fu = 0;
    int zuida = 1;
    int pos;
    num[1] = 1;
    ++zheng;
    ++zuida;
    for (int i = 1; i < l; i++) {
        if (s[i] == '+') {
            num[zuida++] = 1;
            ++zheng;
        } else if (s[i] == '-') {
            num[zuida++] = -1;
            ++fu;
        } else if (s[i] == '=') {
            pos = i;
            break;
        }
    }
    string a = s.substr(pos + 2);
    stringstream ss(a);
    ss >> n;
    bool flag = false;
    for (int i = 1; i < zuida; i++) {
        if (n == zheng - fu) {
            flag = true;
            break;
        }
        while (n > zheng - fu && num[i] > 0 && num[i] < n) {
            ++zheng;
            ++num[i];
        }
        while (n < zheng - fu && num[i] < 0 && abs(num[i]) < n) {
            ++fu;
            --num[i];
        }
    }
    if (n == zheng - fu) flag = true;
    if (flag) {
        cout << "Possible" << endl;
        cout << num[1];
        for (int i = 2; i < zuida; i++) {
            if (num[i] < 0)
                cout << " - " << -num[i];
            else
                cout << " + " << num[i];
        }
        cout << " = ";
        cout << n << endl;
    } else
        cout << "Impossible" << endl;
    return 0;
}


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

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

[PSEUDOCODE]:
define the main function
    declare long longs a and b
    read a and b and keep looping
        declare new string variable s
        declare long long variables x and y = 0
        read standard input to s
        create new long long called i
        for i = 0 to length of s exclusive
            if x = a and y = b, stop the loop
            if s[i] is equal to 'L', change x to x - 1
            if s[i] = 'R', change x to the sum of x and 1
            if s[i] = 'U', change y to the sum of y and 1
            if s[i] = 'D', decrease y by 1
        end of the block
        declare new long long variable j
        if i = length of s
            for j from 0 to length of s exclusive
                if s[j] is equal to 'L', increase a by 1
                if s[j] is equal to 'R', subtract 1 from a
                if s[j] is equal to 'U', subtract 1 from b
                if s[j] is equal to 'D', add 1 to b
                if a = 0 and b is equal to 0, stop the loop
                create long long variable da with value = absolute value of a
                declare new long long db with value abs(b)
                dx is a new long long variable = abs(x)
                declare long long variable dy = absolute value of y
                if a * y = b * x && a * x >= 0 && b * y >= 0
                    if a != 0 and b != 0
                        if dx != 0 and dy != 0
                            if da % dx = 0 and db % dy = 0, break the loop
                        end of the block
                    else if a != 0 and b = 0
                        if dx != 0
                            if dy is equal to 0 and da%dx = 0, stop the loop
                        end of the block
                    else if a = 0 and b != 0
                        if dy != 0
                            if dx = 0 and db % dy is equal to 0, break
                        end of the block
                    end of the block
                end of the block
            end of the block
            if j != length of s
                print "Yes"
            else
                print "No" to the standard output
            end of the block
        else
            print "Yes"
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long a, b;
    while (cin >> a >> b) {
        string s;
        long long x = 0, y = 0;
        cin >> s;
        long long i;
        for (i = 0; i < s.size(); i++) {
            if (x == a && y == b) break;
            if (s[i] == 'L') x -= 1;
            if (s[i] == 'R') x += 1;
            if (s[i] == 'U') y += 1;
            if (s[i] == 'D') y -= 1;
        }
        long long j;
        if (i == s.size()) {
            for (j = 0; j < s.size(); j++) {
                if (s[j] == 'L') a += 1;
                if (s[j] == 'R') a -= 1;
                if (s[j] == 'U') b -= 1;
                if (s[j] == 'D') b += 1;
                if (a == 0 && b == 0) break;
                long long da = abs(a);
                long long db = abs(b);
                long long dx = abs(x);
                long long dy = abs(y);
                if ((long long)a * y == (long long)b * x && (long long)a * x >= 0 && (long long)b * y >= 0) {
                    if (a != 0 && b != 0) {
                        if (dx != 0 && dy != 0) {
                            if (da % dx == 0 && db % dy == 0) break;
                        }
                    } else if (a != 0 && b == 0) {
                        if (dx != 0) {
                            if (dy == 0 && da % dx == 0) break;
                        }
                    } else if (a == 0 && b != 0) {
                        if (dy != 0) {
                            if (dx == 0 && db % dy == 0) break;
                        }
                    }
                }
            }
            if (j != s.size()) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "Yes" << 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
    x, y = integers
    read x, y
    a = string
    read a
    len = integer with len = a.length()
    rx, ry = integer with rx = 0, ry = 0
    for i = 0 to len exclusive
        if a[i] is U, ry = ry + 1
        if a[i] is D, ry = ry - 1
        if a[i] is R, rx = rx + 1
        if a[i] is L, rx = rx - 1
    end of the block
    tx, ty, nx, ny = integers with tx = 0, ty = 0, nx = 0, ny = 0
    for i = 0 to len exclusive
        if rx and ry
            tx = (x - nx) modulo rx
            ty = (y - ny) modulo ry
            if not tx and not ty and (x - nx) / rx is (y - ny) / ry and (x - nx) / rx >= 0
                print Yes
                return to indicate successful execution
            end of the block
        else if rx and not ry
            tx = (x - nx) modulo rx
            if not tx and (x - nx) / rx >= 0 and ny is y
                print Yes
                return to indicate successful execution
            end of the block
        else if not rx and ry
            ty = (y - ny) modulo ry;
            if not ty and (y - ny) / ry >= 0 and nx == x)
                print Yes
                return to indicate successful execution
            end of the block
        else
            if nx is x and ny is y
                print Yes
                return to indicate successful execution
            end of the block
        end of the block
        if a[i] is U, ny = ny + 1
        if a[i] is D, ny = ny - 1
        if a[i] is R, nx = nx + 1
        if a[i] is L, nx = nx - 1
    end of the block
    print No
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int x, y;
    cin >> x >> y;
    string a;
    cin >> a;
    int len = a.length();
    int rx = 0, ry = 0;
    for (int i = 0; i < len; i++) {
        if (a[i] == 'U') ry += 1;
        if (a[i] == 'D') ry -= 1;
        if (a[i] == 'R') rx += 1;
        if (a[i] == 'L') rx -= 1;
    }
    int tx = 0, ty = 0, nx = 0, ny = 0;
    for (int i = 0; i < len; i++) {
        if (rx && ry) {
            tx = (x - nx) % rx;
            ty = (y - ny) % ry;
            if (!tx && !ty && (x - nx) / rx == (y - ny) / ry && (x - nx) / rx >= 0) {
                cout << "Yes" << endl;
                return 0;
            }
        } else if (rx && !ry) {
            tx = (x - nx) % rx;
            if (!tx && (x - nx) / rx >= 0 && ny == y) {
                cout << "Yes" << endl;
                return 0;
            }
        } else if (!rx && ry) {
            ty = (y - ny) % ry;
            if (!ty && (y - ny) / ry >= 0 && nx == x) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            if (nx == x && ny == y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        if (a[i] == 'U') ny += 1;
        if (a[i] == 'D') ny -= 1;
        if (a[i] == 'R') nx += 1;
        if (a[i] == 'L') nx -= 1;
    }
    cout << "No" << endl;
    return 0;
}