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]:
maxn = constant integer = 1005
a = integer array of size maxn, b = integer array of size maxn, fa = integer array of size maxn, fb = integer array of size maxn
define the main function
    n = integer
    read n
    for i = 1 to n inclusive
        read a[i]
        if i is 1
            fa[i] is a[i]
        else
            fa[i] = bitwise or of fa[i - 1] and a[i]
    end of the block
    for i = 1 to n inclusive
        read b[i]
        if i is 1
            fb[i] = b[i]
        else
            fb[i] = bitwise or of fb[i - 1] and b[i]
    end of the block
    res = long long = 0
    for i = 1 to n inclusive
        for j = 1 inclusive
            t = long long = fb[i] + fa[i] - fa[j - 1] - fb[j - 1]
            res = bigger value between res and t
        end of the block
    end of the block
    print res
    return to indicate successful execution
end of the block

[CODE]:

const int maxn = 1005;
int a[maxn], b[maxn], fa[maxn], fb[maxn];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (i == 1)
            fa[i] = a[i];
        else
            fa[i] = fa[i - 1] | a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        if (i == 1)
            fb[i] = b[i];
        else
            fb[i] = fb[i - 1] | b[i];
    }
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            long long t = fb[i] + fa[i] - fa[j - 1] - fb[j - 1];
            res = max(res, t);
        }
    }
    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]:
create vector integer v
create integer arrays num, value, with num size 51, value size 51
define the main function
    create integers n, index with index = 1
    read n
    for i = 0 to n exclusive, read num[i]
    add element num[n-1] to end of v
    for i = n - 2 to 0 inclusive, decrementing i
        create integers j, flag with j = 0, flag = 0
        while j is less than size of v
            if num[i] is v[j]
                set flag to 1
                break loop
            end of the block
            increment j
        end of the block
        if not flag, add element num[i] to end of v
    end of the block
    print size of v print newline
    print v[size of v - 1]
    for i = size of v - 2 to 0 inclusive, decrementing i, print " " print v[i]
    print newline
end of the block

[CODE]:

vector<int> v;
int num[51], value[51];
int main() {
    int n, index = 1;
    cin >> n;
    for (int i = 0; i < n; i++) { cin >> num[i]; }
    v.push_back(num[n - 1]);
    for (int i = n - 2; i >= 0; i--) {
        int j = 0, flag = 0;
        while (j < v.size()) {
            if (num[i] == v[j]) {
                flag = 1;
                break;
            }
            j++;
        }
        if (!flag) v.push_back(num[i]);
    }
    cout << v.size() << endl;
    cout << v[v.size() - 1];
    for (int i = v.size() - 2; i >= 0; i--) cout << " " << v[i];
    cout << endl;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    create integer m
    read m
    create integer x with x = 0
    for i = 1 to m inclusive
        create string s
        read s
        if s is "X++" or s is "++X"
            increment x
        else if s is "X--" or s is "--X"
            decrement x
    end of the block
    print x print newline
end of the block

[CODE]:

int main() {
    int m;
    cin >> m;
    int x = 0;
    for (int i = 1; i <= m; i++) {
        string s;
        cin >> s;
        if (s == "X++" || s == "++X")
            x++;
        else if (s == "X--" || s == "--X")
            x--;
    }
    cout << x << 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]:
declare ints n, v, sum and cnt
create int array ans with size 60 and 2d array s with 60 by 60
define the main function
    read user input to n and v
    change the value of sum to 0
    change cnt to 0
    start for loop from i1 = 0 to n exclusive
        create integer k
        read user input to k
        in a for loop, change i2 from 0 to k exclusive
            read s[i1][i2] from the user input
            increment sum if v is greater than s[i1][i2]
        end of the block
        if sum is greater than 0
            assign i1 + 1 to ans[cnt]
            increment cnt
        end of the block
        set sum to 0
    end of the block
    print cnt to the standard output
    for i2 = 0 to cnt exclusive
        if i2 != cnt - 1
            print ans[i2] and " " to the standard output
        else
            print ans[i2]
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int n, v, sum, cnt;
int s[60][60], ans[60];
int main() {
    cin >> n >> v;
    sum = 0;
    cnt = 0;
    for (int i1 = 0; i1 < n; i1++) {
        int k;
        cin >> k;
        for (int i2 = 0; i2 < k; i2++) {
            cin >> s[i1][i2];
            if (v > s[i1][i2]) { sum++; }
        }
        if (sum > 0) {
            ans[cnt] = i1 + 1;
            cnt++;
        }
        sum = 0;
    }
    cout << cnt << endl;
    for (int i2 = 0; i2 < cnt; i2++) {
        if (i2 != cnt - 1) {
            cout << ans[i2] << " ";
        } else {
            cout << ans[i2] << 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 integer n
declare integer array arr size 100001
declare maxi = 0 as integer
declare solve with integer i as argument, returning integer
    if i is n, return 0
    declare integer ret = result of run solve ( i + 1 )
    if i is n - 1, return 1 from function
    if arr[i] is less than or equal to arr[i+1], return ret + 1
    let maxi be maximum of maxi and ret
    return 1 from function
end of the block
define the main function
    read n
    for i = 0 to n exclusive, read arr[i]
    declare integer ret = result of run solve(0)
    print maximum of ret and maxi, newline
    return to indicate successful execution
end of the block

[CODE]:

int n;
int arr[100001];
int maxi = 0;
int solve(int i) {
    if (i == n) return 0;
    int ret = solve(i + 1);
    if (i == n - 1) return 1;
    if (arr[i] <= arr[i + 1]) return ret + 1;
    maxi = max(maxi, ret);
    return 1;
}
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    int ret = solve(0);
    cout << max(ret, maxi) << 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 m, a, b, c be integers
    read m
    for i = 1 to m inclusive
        read a
        if a >= 180 or a <= 0
            print NO with newline
            continue
        end of the block
        if (360 / (180 - a) - int of (360 / (180 - a))) <= 0
            print YES
        else
            print NO
        end of the block
    end of the block
end of the block

[CODE]:

int main() {
    int m, a, b, c;
    cin >> m;
    for (int i = 1; i <= m; i++) {
        cin >> a;
        if (a >= 180 || a <= 0) {
            cout << "NO" << endl;
            continue;
        }
        if ((360.0 / (180 - a) - int(360 / (180 - a)) <= 0))
            cout << "YES" << endl;
        else {
            cout << "NO" << endl;
        }
    }
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    create ints n, m, mint and maxt
    read standard input to n, m, mint and maxt
    declare integer variables cmin and cmax
    read cmin
    assign the new value = cmin to cmax
    for i from 1 to m exclusive
        define new integer called a
        read standard input to a
        set cmin to min of cmin and a
        assign max of cmax and a to cmax
    end of the block
    begin try-catch block
        if cmin < mint or maxt < cmax, throw error with code 1
        if n - m is less than cmin != mint + cmax != maxt, throw error with code 1
        print "Correct\n"
    catch erorr and put it's code into new integer a, then print "Incorrect\n"
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, m, mint, maxt;
    cin >> n >> m >> mint >> maxt;
    int cmin, cmax;
    cin >> cmin;
    cmax = cmin;
    for (int i = 1; i < m; i++) {
        int a;
        cin >> a;
        cmin = min(cmin, a);
        cmax = max(cmax, a);
    }
    try {
        if (cmin < mint || maxt < cmax) throw 1;
        if (n - m < int(cmin != mint) + (cmax != maxt)) throw 1;
        cout << "Correct\n";
    } catch (int a) { cout << "Incorrect\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]:
str=array of 105 strings
define the main function
    n,m=int
    read n,m
    read str+1
    while m is not 0, decrement m
        l,r=int
        c1,c2=char
        read l,r,c1,c2
        for i=l to r inclusive
            if str[i] is c1 str[i]=c2
        end of the block
    end of the block
    print str+1
end of the block

[CODE]:

char str[105];
int main() {
    int n, m;
    cin >> n >> m;
    cin >> str + 1;
    while (m--) {
        int l, r;
        char c1, c2;
        cin >> l >> r >> c1 >> c2;
        for (int i = l; i <= r; ++i) {
            if (str[i] == c1) str[i] = c2;
        }
    }
    cout << str + 1 << endl;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    create new integer called a
    for i from 1 to 5 inclusive
        in a for loop, change j from 1 to 5 inclusive incrementing j
            read input to a
            if a is equal to 1, print (abs(3 - i) + abs(3 - j)) to the output
        end of the block
end of the block

[CODE]:

int main() {
    int a;
    for (int i = 1; i <= 5; i++)
        for (int j = 1; j <= 5; j++) {
            cin >> a;
            if (a == 1) cout << (abs(3 - i) + abs(3 - j)) << 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
    number = integer
    sum = long
    ok is boolean = false
    read number
    if number is equal to 1 set ok to true
    for counter = 1 to number exclusive
        increase sum by counter
        if sum is equal to number set ok to true
    end of the block
    if ok 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]:

int main() {
    int number;
    long sum = 0;
    bool ok = false;
    cin >> number;
    if (number == 1) ok = true;
    for (int counter = 1; counter < number; ++counter) {
        sum += counter;
        if (sum == number) ok = true;
    }
    if (ok)
        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 long longs c, v0, v1, a, l
declare input with no arguments, returning void
    read c read v0 read v1 read a read l
end of the block
define the main function
    run input
    create long long speed with speed = v0
    create long long cur with cur = 0
    create long long ans with ans = 0
    while cur is less than c
        if cur is true, decrement cur by l
        increment cur by speed
        set speed to minimum of speed + a and v1
        increment ans
    end of the block
    print ans print "\n"
end of the block

[CODE]:

long long c, v0, v1, a, l;
void input() {
    cin >> c >> v0 >> v1 >> a >> l;
}
int main() {
    input();
    long long speed = v0;
    long long cur = 0;
    long long ans = 0;
    while (cur < c) {
        if (cur) cur -= l;
        cur += speed;
        speed = min(speed + a, v1);
        ans++;
    }
    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]:
set MAX to 100000
set INF to 1000000001
create int a[MAX]
create integers n, s ans sum, set sum to 0
define the main function
    let count and temp be int, set count to 0
    read n
    for i=0 to n exclusive
        read temp
        assign temp to a[temp]
    end of the block
    for i=1 to 601 inclusive
        if a[i] different from 0, increment count
    print count
    return to indicate successful execution
end of the block

[CODE]:

const int MAX = 100000;
const int INF = 1000000001;
int a[MAX];
int n, s, sum = 0;
int main() {
    int count = 0, temp;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        a[temp] = temp;
    }
    for (int i = 1; i <= 601; ++i)
        if (a[i]) count++;
    cout << count << 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 t
    let a, b and k be long long variables
    create long long ans
    read t
    for t iterations
        read a, b and k
        set ans to 0
        create bool even = true
        if k is even
            set ans to k / 2 * (a - b)
        else
            set ans to k / 2 * (a - b) + a
        print ans
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int t;
    long long a, b, k;
    long long ans;
    cin >> t;
    while (t--) {
        cin >> a >> b >> k;
        ans = 0;
        bool even = true;
        if (k % 2 == 0)
            ans = k / 2 * (a - b);
        else
            ans = k / 2 * (a - b) + a;
        cout << ans << endl;
    }
    return 0;
}