PrincetonPLI/LongProc huggingface dataset:
[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 const long long INF = 1e9
define the main function
    declare long long variables n and m
    read n and m
    create long longs cnt1 and cnt2 = 1
    for i = 7 to n exclusive multiplying i by 7, increment cnt1 by one
    for i from 7 to m exclusive multiplying i by 7, increment cnt2
    declare long long variable res = 0
    if cnt1 + cnt2 <= 7
        for i = o while i !=n
            for j = o while j !=m
                create vector of long long called used with 7 elements filled with 0
                for a = i, k = 0, while k != cnt1, increment k and divide a by 7, incrementing used[a % 7] on each iteration
                for a = j, k = 0, while k != cnt2, increment k and divide a by 7, incrementing used[a % 7] on each iteration
                if max_element of used <= 1, increment res
            end of the block
        end of the block
    end of the block
    print res
    return to indicate successful execution
end of the block

[CODE]:

const long long INF = 1e9;
int main() {
    long long n, m;
    cin >> n >> m;
    long long cnt1 = 1, cnt2 = 1;
    for (long long i = 7; i < n; i *= 7) cnt1++;
    for (long long i = 7; i < m; i *= 7) cnt2++;
    long long res = 0;
    if (cnt1 + cnt2 <= 7) {
        for (long long i = 0; i != n; ++i) {
            for (long long j = 0; j != m; ++j) {
                vector<long long> used(7, 0);
                for (long long a = i, k = 0; k != cnt1; ++k, a /= 7) used[a % 7]++;
                for (long long a = j, k = 0; k != cnt2; ++k, a /= 7) used[a % 7]++;
                if (*max_element((used).begin(), (used).end()) <= 1) res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
find_len is a long long function with long long argument num
    create long long l = 1
    for a = 7 to num exclusive multiplying a by 7, add 1 to l
    return l
end of the block
define the main function
    declare long longs n, m, x, y, res, i and j
    read n and m
    change x to find_len(n)
    change y to find_len(m)
    change res to 0
    if x + y <= 7
        for i from 0 to n exclusive
            for j from 0 to m exclusive
                create vector of long long f with 7 elements, filled with 0
                for k = 0 and a = i while k != x, incrementing k and dividing a by 7, increment f[a % 7]
                for k = 0 and b = j while k != y, incrementing k and dividing b by 7, increment f[b % 7]
                if *max_element(f.begin(), f.end()) <= 1, increment res
            end of the block
        end of the block
    end of the block
    print res
    return to indicate successful execution
end of the block

[CODE]:

long long find_len(long long num) {
    long long l = 1;
    for (long long a = 7; a < num; a *= 7) l += 1;
    return l;
}
int main() {
    long long n, m, x, y, res, i, j;
    cin >> n >> m;
    x = find_len(n);
    y = find_len(m);
    res = 0;
    if (x + y <= 7) {
        for (i = 0; i != n; i++) {
            for (j = 0; j != m; j++) {
                vector<long long> f(7, 0);
                for (long long k = 0, a = i; k != x; k++, a /= 7) f[a % 7]++;
                for (long long k = 0, b = j; k != y; k++, b /= 7) f[b % 7]++;
                if (*max_element(f.begin(), f.end()) <= 1) res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    create integer N
    read N
    declare character array mat with size N + 1 by N + 1
    let rows and columns be arrays of integer vectors with size N + 1
    for integer i = 1 to N inclusive
        for integer j = 1 to N inclusive
            read mat[i][j]
            if mat[i][j] != 'E'
                push j to the end of rows[i]
                push i to the end of columns[j]
            end of the block
        end of the block
    end of the block
    create booleans rowFull and columnFull = false
    for i = 1 to N inclusive
        if size of rows[i] is 0, set rowFull to true
        if size of columns[i] is 0, set columnFull to true
    end of the block
    if rowFull && columnFull
        print "-1"
    else if rowFull
        for i = 1 to N inclusive print columns[i][0], " " and i
    else
        for integer i = 1 to N inclusive print i, " " and rows[i][0]
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int N;
    cin >> N;
    char mat[N + 1][N + 1];
    vector<int> rows[N + 1], columns[N + 1];
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            cin >> mat[i][j];
            if (mat[i][j] != 'E') {
                rows[i].push_back(j);
                columns[j].push_back(i);
            }
        }
    }
    bool rowFull = false, columnFull = false;
    for (int i = 1; i <= N; i++) {
        if (!rows[i].size()) rowFull = true;
        if (!columns[i].size()) columnFull = true;
    }
    if (rowFull && columnFull) {
        cout << "-1" << endl;
    } else if (rowFull) {
        for (int i = 1; i <= N; i++) { cout << columns[i][0] << " " << i << endl; }
    } else {
        for (int i = 1; i <= N; i++) { cout << i << " " << rows[i][0] << 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]:
assign value 11000 to constant integer maxn
create integer INF = 1 << 30
let m and n be integers
da is an 2d array of integers with size 110 by maxn
joo is an 2d array of integers with size 110 by maxn
define the main function
    read m and n
    create string s
    for i = 0 to m exclusive
        read s
        for integer j = 0 to n exclusive set da[i][j] to 1 if s[j] = '1', 0 if it is not
    end of the block
    declare integers t and jj
    for i = 0 to m exclusive
        t = INF
        for j = 0 while j < n * 2
            jj = j % n
            if da[i][jj] = 1, set t to 0
            set joo[i][jj] = t and increment t
        end of the block
        t = INF
        for integer j = n * 2 to 0 inclusive counting down
            jj = j % n
            if da[i][jj] = 1, set t to 0
            joo[i][jj] = min of joo[i][jj] and t
        end of the block
    end of the block
    declare long longs mi = INF and sum
    for integer j = 0 to n exclusive
        assign value of 0 to sum
        for integer i = 0 to m exclusive add joo[i][j] to sum
        set mi to min of sum and mi
    end of the block
    if mi >= INF
        print -1 and a new line
    else
        print mi and a new line
    return to indicate successful execution
end of the block

[CODE]:

const int maxn = 11000;
int INF = 1 << 30;
int m, n;
int da[110][maxn];
int joo[110][maxn];
int main() {
    cin >> m >> n;
    string s;
    for (int i = 0; i < m; i++) {
        cin >> s;
        for (int j = 0; j < n; j++) da[i][j] = (s[j] == '1' ? 1 : 0);
    }
    int t, jj;
    for (int i = 0; i < m; i++) {
        t = INF;
        for (int j = 0; j < n * 2; j++) {
            jj = j % n;
            if (da[i][jj] == 1) t = 0;
            joo[i][jj] = t++;
        }
        t = INF;
        for (int j = n * 2; j >= 0; j--) {
            jj = j % n;
            if (da[i][jj] == 1) t = 0;
            joo[i][jj] = min(joo[i][jj], t++);
        }
    }
    long long mi = INF, sum;
    for (int j = 0; j < n; j++) {
        sum = 0;
        for (int i = 0; i < m; i++) { sum += joo[i][j]; }
        mi = min(sum, mi);
    }
    if (mi >= INF)
        cout << -1 << endl;
    else
        cout << mi << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
create constant integer MAXN with value 1001
declare integer called n
let s be an array of characters of length MAXN
c is an array of integers with size 256 filled with 0
f is an array of booleans with size MAXN
define the main function
    read input to s
    assign length of s to n
    memset with arguments c, sizeof(c) and 0
    for i = 0 to n exclusive incremen c[s[i]]
    k is integer = 0
    for i = 0 to 256 exclusive
        if c[i] is greater than c[k] set k to i
    memset with arguments f, true and sizeof(f)
    for integer i = 2 to i * i <= n
        if f[i] is true
            for integer j = i * i to n inclusive with step of i, set f[j] to false
    set value of f[1] to true
    for integer i = 2 to i + i <= n, set f[j] to false
    for i = 1 to n inclusive
        if f[i] is false
            if c[k] = 0
                print "NO" and a new line
                return to indicate successful execution
            end of the block
            decrease c[s[i - 1] = k] by one
        end of the block
    assign value of 0 to k
    for integer i = 1 to n inclusive
        if f[i] is true
            increment k while c[k] = 0
            decrease c[s[i - 1] = k] by one
        end of the block
    print "YES" and a new line
    print s and a new line
    return to indicate successful execution
end of the block

[CODE]:

const int MAXN = 1001;
int n;
char s[MAXN];
int c[256] = {0};
bool f[MAXN];
int main() {
    gets(s);
    n = strlen(s);
    memset(c, sizeof(c), 0);
    for (int i = 0; i < n; i++) c[s[i]]++;
    int k = 0;
    for (int i = 0; i < 256; i++)
        if (c[i] > c[k]) k = i;
    memset(f, true, sizeof(f));
    for (int i = 2; i * i <= n; i++)
        if (f[i])
            for (int j = i * i; j <= n; j += i) f[j] = false;
    f[1] = true;
    for (int i = 2; i + i <= n; i++) f[i] = false;
    for (int i = 1; i <= n; i++)
        if (!f[i]) {
            if (c[k] == 0) {
                cout << "NO" << endl;
                return 0;
            }
            c[s[i - 1] = k]--;
        }
    k = 0;
    for (int i = 1; i <= n; i++)
        if (f[i]) {
            while (c[k] == 0) k++;
            c[s[i - 1] = k]--;
        }
    cout << "YES" << endl;
    cout << s << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
create constant integer MAXN with MAXN = 1001
create integer n
create character array s with size MAXN
create integer array c with size 256
declare boolean array f with size MAXN
define the main function
    read string into s
    set n to string length of s
    for i = 0 to n exclusive, increment c[s[i]]
    create integer k with k = 0
    for i = 0 to 256 exclusive
        if c[i] is greater than c[k], set k to i
    set bytes from f to size of f to true
    for i = 2 to i * i is less than or equal to n, incrementing i
        if f[i] is true
            for j = i * i to n inclusive, incrementing j by i, set f[j] to false
    set f[1] to true
    for i = 2 to i + i is less than or equal to n, incrementing i, set f[i] to false
    for i = 1 to n inclusive
        if not f[i]
            if c[k] is 0
                print "NO"
                return to indicate successful execution
            end of the block
            decrement c[set s[i-1] to k]
        end of the block
    set k to 0
    for i = 1 to n inclusive
        if f[i] is true
            while c[k] is 0, increment k
            decrement c[set s[i-1] to k]
        end of the block
    print "YES"
    print s
    return to indicate successful execution
end of the block

[CODE]:

const int MAXN = 1001;
int n;
char s[MAXN];
int c[256];
bool f[MAXN];
int main() {
    gets(s);
    n = strlen(s);
    for (int i = 0; i < n; ++i) c[s[i]]++;
    int k = 0;
    for (int i = 0; i < 256; ++i)
        if (c[i] > c[k]) k = i;
    memset(f, true, sizeof(f));
    for (int i = 2; i * i <= n; i++)
        if (f[i])
            for (int j = i * i; j <= n; j += i) f[j] = false;
    f[1] = true;
    for (int i = 2; i + i <= n; i++) f[i] = false;
    for (int i = (1); i <= (n); ++i)
        if (!f[i]) {
            if (c[k] == 0) {
                puts("NO");
                return 0;
            }
            c[s[i - 1] = k]--;
        }
    k = 0;
    for (int i = (1); i <= (n); ++i)
        if (f[i]) {
            while (c[k] == 0) k++;
            c[s[i - 1] = k]--;
        }
    puts("YES");
    puts(s);
    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 st be a string
let temp, bst be strings
create a set of strings by name v
let rl be a function that accepts string st and returns a string value
    the character value of c is equal to st[0]
    st[0] is equal to st[1]
    st[1] is equal to st[2]
    st[2] is equal to st[3]
    st[3] is equal to c
    return the value of st
end of the block
let ru be a function that accepts string st and returns a string value
    the character value of temp is equal to st[4]
    st[4] is equal to st[0]
    st[0] is equal to st[5]
    st[5] is equal to st[2]
    st[2] is equal to temp
    return the value of st
end of the block
define the main function
    read st
    sort the values of st from beginning to end
    do
        temp is equal to st
        bst is equal to temp
        for integer iter = 1 to 2000 inclusive
            if rand() modulo 2
                temp is equal to rl(temp)
            else do the following
                temp is equal to ru(temp)
            if bst is greater than temp , bst is equal to temp
        end of the block
        insert bst into v
    while next_permutation of st from beginning to end
    print length of v and newline
    read a character
    read a character
    return to indicate successful execution
end of the block

[CODE]:

string st;
string temp, bst;
set<string> v;
string rl(string st) {
    char c = st[0];
    st[0] = st[1];
    st[1] = st[2];
    st[2] = st[3];
    st[3] = c;
    return st;
}
string ru(string st) {
    char temp = st[4];
    st[4] = st[0];
    st[0] = st[5];
    st[5] = st[2];
    st[2] = temp;
    return st;
}
int main() {
    cin >> st;
    sort(st.begin(), st.end());
    do {
        temp = st;
        bst = temp;
        for (int iter = 1; iter <= 2000; iter++) {
            if (rand() % 2)
                temp = rl(temp);
            else
                temp = ru(temp);
            if (bst > temp) bst = temp;
        }
        v.insert(bst);
    } while (next_permutation(st.begin(), st.end()));
    cout << v.size() << endl;
    cin.get();
    cin.get();
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
create const int MAXN = 5005
declare izq taking in string c and returning string
    create string temp = c
    set temp[0] to c[3]
    set temp[1] to c[5]
    set temp[3] to c[1]
    set temp[5] to c[0]
    return temp
end of the block
declare abajo taking in string c and returning string
    make string temp = c
    for i = 2 to 5 exclusive, swap values of temp[i] and temp[i + 1]
    return temp
end of the block
declare last taking in string c and returning string
    make string ans = c
    for i = 0 to 4 exclusive
        for j = 0 to 4 exclusive
            for k = 0 to 4 exclusive
                set ans to max of ans and c
                set c to izq(c)
            end of the block
            set c to abajo(c)
        end of the block
        set c to izq(c)
    end of the block
    return ans
end of the block
define the main function
    make string color
    read color
    sort color
    make string set ans
    do insert last(color) into ans while next_permutation(color.begin(), color.end()) returns true
    show ans.size()
    return to indicate successful execution
end of the block

[CODE]:

int const MAXN = 5005;
string izq(string c) {
    string temp = c;
    temp[0] = c[3];
    temp[1] = c[5];
    temp[3] = c[1];
    temp[5] = c[0];
    return temp;
}
string abajo(string c) {
    string temp = c;
    for (int i = 2; i < 5; ++i) swap(temp[i], temp[i + 1]);
    return temp;
}
string last(string c) {
    string ans = c;
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                ans = max(ans, c);
                c = izq(c);
            }
            c = abajo(c);
        }
        c = izq(c);
    }
    return ans;
}
int main() {
    string color;
    cin >> color;
    sort(color.begin(), color.end());
    set<string> ans;
    do { ans.insert(last(color)); } while (next_permutation(color.begin(), color.end()));
    cout << ans.size() << '\n';
    return 0;
}