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]:
define the main function
    n, b =integers
    Read n
    set b to n / 2 + 1
    print b and a new line
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, b;
    cin >> n;
    b = n / 2 + 1;
    cout << b << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
k, a, b, v, tot = int
define the main function
    read k then a then b then v
    iterate i
        increment to by (min of b + 1, k) * v
        decrement b by min of (b, k - 1)
        if tot >= a
            print i
            return to indicate successful execution
        end of the block
    end of the block
end of the block

[CODE]:

int k, a, b, v, tot;
int main() {
    cin >> k >> a >> b >> v;
    for (int i = 1;; i++) {
        tot += (min(b + 1, k)) * v;
        b -= (min(b, k - 1));
        if (tot >= a) {
            cout << i << endl;
            return 0;
        }
    }
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
create new array of characters str with size 1007
vis is a new array of booleans with 1007 elements
define the main function
    read str from the input
    change vis['a'], vis['e'], vis['i'], vis['o'] and vis['u'] to true
    for i from 0 to exclusive incrementing i
        if vis[str[i]] is false and str[i] != 'n'
            if vis[str[i + 1]] is false, return 0 * puts("NO")
    print "YES" to stdout
    return to indicate successful execution
end of the block

[CODE]:

char str[1007];
bool vis[1007];
int main() {
    cin >> str;
    vis['a'] = vis['e'] = vis['i'] = vis['o'] = vis['u'] = true;
    for (int i = 0; str[i]; i++)
        if (!vis[str[i]] && str[i] != 'n')
            if (!vis[str[i + 1]]) return 0 * puts("NO");
    puts("YES");
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    create integer n and an array of integers a with size 100010
    read n and keep looping
        declare long long variable sum = 0
        create integer minn = 1e9
        for integer i = 1 to n inclusive
            read a[i]
            if a[i] is odd
                if a[i] is less than minn, change minn to a[i]
            end of the block
            increase sum by a[i]
        end of the block
        if sum is even
            print sum
        else
            print sum - minn
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, a[100010];
    while (cin >> n) {
        long long sum = 0;
        int minn = 1e9;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
            if (a[i] % 2 != 0) {
                if (a[i] < minn) minn = a[i];
            }
            sum += a[i];
        }
        if (sum % 2 == 0)
            cout << sum << endl;
        else
            cout << sum - minn << endl;
    }
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    let n be a integer
    read n
    the integer value of x = 0
    the integer value of k = -1
    the integer value of m = 0
    for i = 1 to n inclusive
        for j = 1 to n + 1 inclusive
            m is equal to 0
            if j is equal to n + 1
                print newline
                stop
            end of the block
            for integer k = n / 2 - x + 1 to n / 2 + x + 1 inclusive
                if j is equal to k , increment m by 1
            end of the block
            if m is equal to 0
                print *
            else do the following
                print D
            end of the block
        end of the block
        if i <= n / 2
            increment x by 1
        else do the following
            decrement x by 1
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    int x = 0;
    int k = -1;
    int m = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n + 1; j++) {
            m = 0;
            if (j == n + 1) {
                cout << endl;
                break;
            }
            for (int k = n / 2 - x + 1; k <= n / 2 + x + 1; k++) {
                if (j == k) { m++; }
            }
            if (m == 0) {
                cout << '*';
            } else {
                cout << 'D';
            }
        }
        if (i <= n / 2) {
            x += 1;
        } else {
            x -= 1;
        }
    }
    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 int n
    read n
    create int j = n + 1
    create int ans = max of 1 and (n * sqrt(2)) * 4 cast to int
    print ans
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    int j = n + 1;
    int ans = max(1, (int)(n * sqrt(2)) * 4);
    cout << ans << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    n, s = int
    read n, s
    a = int array of length 110
    hh, mm = int
    tt = 0 = int
    for i = 0 to n exclusive, read hh and mm, a[i] = hh * 60 + mm
    flag = int = 1
    if s + 1 <= a[0] and flag then set both tt and flag to 0
    for i = 1 to n exclusive
        if s + 1 <= (a[i] - a[i - 1] - s - 1) and flag then set tt to a[i-1] + s + 1, set flag to 0
    end of the block
    if flag then set tt to a[n-1] + s + 1
    h = tt/60 = int
    m = tt - tt/60 * 60
    print h and space and m
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, s;
    cin >> n >> s;
    int a[110];
    int hh, mm;
    int tt = 0;
    for (int i = 0; i < n; i++) cin >> hh >> mm, a[i] = hh * 60 + mm;
    int flag = 1;
    if (s + 1 <= a[0] && flag) tt = 0, flag = 0;
    for (int i = 1; i < n; i++) {
        if (s + 1 <= (a[i] - a[i - 1] - s - 1) && flag) tt = a[i - 1] + s + 1, flag = 0;
    }
    if (flag) tt = a[n - 1] + s + 1;
    int h = tt / 60;
    int m = tt - tt / 60 * 60;
    cout << h << " " << m << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
create integers n, s, create integer array a with size 50
define the main function
    read n
    for i = 1 to n inclusive
        read s
        increment a[s]
    end of the block
    if a[1] is greater than a[2]
        print a[2] + ( a[1] - a[2] ) / 3 print newline
    else
        print a[1] print newline
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int n, a[50], s;
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        a[s]++;
    }
    if (a[1] > a[2]) {
        cout << a[2] + (a[1] - a[2]) / 3 << endl;
    } else {
        cout << a[1] << endl;
    }
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
in the function gcd that takes integer a, b and returns integer
    return if b, gcd(b, a % b) else a
end of the block
in the function lcm that takes integer a, b and returns integer
    return a / gcd(a, b) * b
end of the block
in the function lcm that takes integer pointer arr and integer n and returns integer
    r = integer with r = arr[0]
    for i = 1 to n exclusive, r = lcm of r and arr[i]
    return r
end of the block
in = bool array of size 101 with in= {}
cycle = integer array of size 101
target = integer array of size 101
n = integer
define the main function
    read n
    for i = 1 to n
        read target[i]
        if in[target[i]]
            print -1
            return to indicate successful execution
        end of the block
        in[target[i]] = true
    end of the block
    for i = 1 to n
        current = integer with current = i
        cycle[i] = 0
        do
            current = target[current]
            cycle[i] = cycle[i] + cycle[i] 1
        while current is not i
        if ((cycle[i] bitwise and 1) is 0), cycle[i] = right shift cycle[i] 1 place
    end of the block
    print lcm(cycle + 1, n)
end of the block

[CODE]:

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int lcm(int *arr, int n) {
    int r = arr[0];
    for (int i = 1; i < n; ++i) { r = lcm(r, arr[i]); }
    return r;
}
bool in[101] = {};
int cycle[101];
int target[101];
int n;
int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> target[i];
        if (in[target[i]]) {
            cout << -1 << endl;
            return 0;
        }
        in[target[i]] = true;
    }
    for (int i = 1; i <= n; ++i) {
        int current = i;
        cycle[i] = 0;
        do {
            current = target[current];
            cycle[i] += 1;
        } while (current != i);
        if ((cycle[i] & 1) == 0) { cycle[i] >>= 1; }
    }
    cout << lcm(cycle + 1, n) << endl;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    x is a new array of integers with 31 element
    create new array of integers y with 31 element
    z is a new 2d array of integers with size 31 by 31
    declare integer variables n, m, i, j and k
    read n and loop further
        change first sizeof(x) bytes at the pointer x to 0
        set the values of sizeof(y) bytes at the pointer y to 0
        for i from 0 to n exclusive
            for j = 0 to n exclusive, read from the input to z[i][j]
        end of the block
        start for loop from i = 0 to n exclusive incrementing i
            in a for loop, change j from 0 to n exclusive
                increase x[i] by z[i][j]
                change y[i] to the sum of y[i] and z[j][i]
            end of the block
        end of the block
        assign 0 to k
        in a for loop, change i from 0 to n exclusive incrementing i
            start for loop from j = 0 to n exclusive incrementing j
                if y[j] is greater than x[i], increment k
            end of the block
        end of the block
        print k
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int x[31];
    int y[31];
    int z[31][31];
    int n, m, i, j, k;
    while (cin >> n) {
        memset(x, 0, sizeof(x));
        memset(y, 0, sizeof(y));
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) { cin >> z[i][j]; }
        }
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                x[i] += z[i][j];
                y[i] += z[j][i];
            }
        }
        k = 0;
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                if (y[j] > x[i]) k++;
            }
        }
        cout << k << endl;
    }
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    let n, c be ints
    read n and c
    y = int
    read y
    cur = y = int
    ans = 1 = int
    x = int
    for i = 0 to n-1 exclusive
        read x
        if the abs of cur-x to int is <= c
            increment ans
        else
            reset ans to 1
        end of the block
        set cur to x
    end of the block
    print ans and new line
end of the block

[CODE]:

int main() {
    int n, c;
    cin >> n >> c;
    int y;
    cin >> y;
    int cur = y;
    int ans = 1;
    int x;
    for (int i = 0; i < n - 1; i++) {
        cin >> x;
        if ((int)abs(cur - x) <= c) {
            ans++;
        } else {
            ans = 1;
        }
        cur = x;
    }
    cout << ans << '\n';
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    declare integer n
    create long longs a and Ans and long long array ara with size 101
    read n
    read a
    assign value of a to Ans
    for integer i = 1 to n exclusive
        read ara[i]
        increase Ans by (ara[i] - 1) * (i + 1) + 1
    end of the block
    print Ans
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    long long a, ara[101], Ans;
    cin >> n;
    cin >> a;
    Ans = a;
    for (int i = 1; i < n; i++) {
        cin >> ara[i];
        Ans += (ara[i] - 1) * (i + 1) + 1;
    }
    cout << Ans << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    n, i, j, count = integers with count = 0
    sii = stack of integer
    s = string
    read n, s
    for i = s.size() - 1 down to 0, push s[i] - 0 in sii
    while (not sii.empty())
        j = top of sii
        pop sii
        if (j + 1 is 2)
            increment count
        else if (j + 1 is 1)
            increment count
            break loop
        end of the block
    end of the block
    print count
end of the block

[CODE]:

int main() {
    int n, i, j, count = 0;
    stack<int> sii;
    string s;
    cin >> n >> s;
    for (i = s.size() - 1; i >= 0; i--) { sii.push(s[i] - '0'); }
    while (!sii.empty()) {
        j = sii.top();
        sii.pop();
        if (j + 1 == 2) {
            count++;
        } else if (j + 1 == 1) {
            count++;
            break;
        }
    }
    cout << count << endl;
}