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
    a, b, c, d =integers
    Read a, b, c, d
    set a = maximum value of 3 * a / 10 and a - a * c / 250
    set b = maximum value of 3 * b / 10 and b - b * d / 250
    if a is greater than b
        print Misha and a new line
    else if b is greater than a
        print Vasya and a new line
    else do the following
        print Tie and a new line
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a = max(3 * a / 10, a - a * c / 250);
    b = max(3 * b / 10, b - b * d / 250);
    if (a > b)
        cout << "Misha" << endl;
    else if (b > a)
        cout << "Vasya" << endl;
    else
        cout << "Tie" << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

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

[CODE]:

int main() {
    int n;
    cin >> n;
    char ch;
    int counter_A = 0;
    int counter_D = 0;
    while (n > 0) {
        cin >> ch;
        if (ch == 'A')
            counter_A++;
        else
            counter_D++;
        n--;
    }
    if (counter_A > counter_D)
        cout << "Anton\n";
    else if (counter_D > counter_A)
        cout << "Danik\n";
    else
        cout << "Friendship\n";
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

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

[CODE]:

int n, m, startx = 55, starty = 55, finishx, finishy;
char st[55][55];
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            cin >> st[i][j];
            if (st[i][j] == '*') {
                startx = min(startx, i);
                starty = min(starty, j);
                finishx = max(finishx, i);
                finishy = max(finishy, j);
            }
        }
    for (int i = startx; i <= finishx; i++) {
        for (int j = starty; j <= finishy; j++) { cout << st[i][j]; }
        cout << endl;
    }
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

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

[CODE]:

int n, a[1001];
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) { cin >> a[i]; }
    int ans = 0;
    for (int i = 2; i < n; i++) {
        if (a[i] > a[i + 1] && a[i] > a[i - 1]) {
            ans++;
            continue;
        }
        if (a[i] < a[i + 1] && a[i] < a[i - 1]) { 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]:
define the main function
    create long long n and a
    read n
    if n is even
        a= n/2
    else
        set ((n + 1) / 2) * (-1)
    print a
    return to indicate successful execution
end of the block

[CODE]:

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

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

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

[CODE]:

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

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

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

[CODE]:

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

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

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

[CODE]:

long long a[3], b[3], k;
int main() {
    cin >> a[0] >> a[1] >> a[2] >> k;
    k = min(k, a[0] + a[1] + a[2] - 3);
    sort(a, a + 3);
    for (long long i = 0; i < 3; i++) b[i] = k / 3;
    for (long long i = 0; i < k % 3; i++) b[2 - i]++;
    for (long long i = 0; i < 2; i++) {
        if (b[i] >= a[i]) {
            b[2] += b[i] - (a[i] - 1);
            b[i] = a[i] - 1;
        }
    }
    while (b[2] - 1 >= b[1] + 1 && b[1] + 1 < a[1]) b[1]++, b[2]--;
    cout << (b[0] + 1) * (b[1] + 1) * (b[2] + 1) << '\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]:
declare integer array arr size 10000
declare integer veector v
declare integer array brr size 10000
define the main function
    declare integer n
    read n
    for i = 1 to n inclusive
        declare integer m
        read m
        let arr[i] be m
        add m to end of v
    end of the block
    sort from beginning of v to end of v
    declare integers idx = 1, cur
    for i = n - 1 to 0 inclusive, decrementing i
        if i is n - 1
            let cur be v[i]
            let brr[idx] be v[i]
        else
            if cur is not v[i]
                let brr[idx] be v[i]
                let cur be v[i]
            end of the block
        end of the block
        increment idx
    end of the block
    for i = 1 to n inclusive
        for j = 1 to n inclusive
            if arr[i] is brr[j] and arr[i] is not 0 and brr[j] is not 0
                if i is n
                    print j and newline
                else
                    print j and " "
                end of the block
            end of the block
        end of the block
    end of the block
end of the block

[CODE]:

int arr[10000];
vector<int> v;
int brr[10000];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int m;
        cin >> m;
        arr[i] = m;
        v.push_back(m);
    }
    sort(v.begin(), v.end());
    int idx = 1, cur;
    for (int i = n - 1; i >= 0; i--) {
        if (i == n - 1) {
            cur = v[i];
            brr[idx] = v[i];
        } else {
            if (cur != v[i]) {
                brr[idx] = v[i];
                cur = v[i];
            }
        }
        idx++;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (arr[i] == brr[j] && arr[i] != 0 && brr[j] != 0) {
                if (i == n) {
                    cout << j << endl;
                } else {
                    cout << j << " ";
                }
            }
        }
    }
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

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

[CODE]:

int main() {
    int n, x, y, z, xsum(0), ysum(0), zsum(0);
    cin >> n;
    while (n--) {
        cin >> x >> y >> z;
        xsum += x;
        ysum += y;
        zsum += z;
    }
    if (xsum == 0 && ysum == 0 && zsum == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

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

[CODE]:

int main() {
    int n, res = 0, cur, x, y;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) { cin >> a[i]; }
    for (int i = 0; i < n; i++) { cin >> b[i]; }
    for (int i = 0; i < n; i++) {
        x = 0;
        y = 0;
        for (int j = i; j < n; j++) {
            x |= a[j];
            y |= b[j];
            cur = x + y;
            res = max(res, cur);
        }
    }
    cout << res << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

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

[CODE]:

const double PI = acos(-1.0);
const int inf = int(1e9);
const int mod = inf + 7;
long long n, m, k, l, w, h, sum, mx, mn;
int main() {
    mn = (1e9);
    string a, b;
    cin >> a >> b;
    if (a == b)
        cout << a;
    else
        cout << 1;
    cout << endl;
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

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

[CODE]:

int main() {
    string str1, str2, str3, str4;
    cin >> str1 >> str2 >> str3;
    str4 = str2;
    int flag = 0, flag1 = 0;
    if ((str1[0] == str3[2]) && (str1[1] == str3[1]) && (str1[2] == str3[0])) { flag = 1; }
    if ((str2[0] == str2[2]) && (str2[1] == str2[1]) && (str2[2] == str2[0])) { flag1 = 1; }
    if (flag && flag1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}