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
    declare integers a and b
    read a and b
    create integer sum = a + b
    create integer tempa = a
    declare integer variable tempb = b
    create integer i = 1
    create integer val = tempa
    create integer rem = 0
    declare integer rem1 = 0
    while val is greater than 0
        rem = val modulo 10
        divide val by 10
        if rem > 0
            increase rem1 by rem * i
            multiply i by 10
        end of the block
    end of the block
    declare integer newa = rem1
    set val to tempb
    set rem and rem1 to 0
    i = 1
    while val is greater than 0
        rem = val % 10
        divide val by 10
        if rem
            increase rem1 by rem * i
            multiply i by 10
        end of the block
    end of the block
    declare integer variable newb = rem1
    create integer newsum = newa + newb
    set val to sum
    rem and rem1 = 0
    set value of i to 1
    while val is greater than 0
        rem = val % 10
        divide val by 10
        if rem > 0
            increase rem1 by rem * i
            multiply i by 10
        end of the block
    end of the block
    if newsum = rem1
        print "YES"
    else
        print "NO"
    invoke function putchar with arguments '\n'
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int a, b;
    cin >> a >> b;
    int sum = a + b;
    int tempa = a;
    int tempb = b;
    int i = 1;
    int val = tempa;
    int rem = 0;
    int rem1 = 0;
    while (val > 0) {
        rem = val % 10;
        val = val / 10;
        if (rem) {
            rem1 = rem1 + rem * i;
            i = i * 10;
        }
    }
    int newa = rem1;
    val = tempb;
    rem1 = rem = 0;
    i = 1;
    while (val > 0) {
        rem = val % 10;
        val = val / 10;
        if (rem) {
            rem1 = rem1 + rem * i;
            i = i * 10;
        }
    }
    int newb = rem1;
    int newsum = newa + newb;
    val = sum;
    rem1 = rem = 0;
    i = 1;
    while (val > 0) {
        rem = val % 10;
        val = val / 10;
        if (rem) {
            rem1 = rem1 + rem * i;
            i = i * 10;
        }
    }
    if (newsum == rem1)
        cout << "YES";
    else
        cout << "NO";
    putchar('\n');
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
define the main function
    create integer n
    read n
    create integer ans with ans = 0
    increment ans by n / 100
    set n to n % 100
    increment ans by n / 20
    set n to n % 20
    increment ans by n / 10
    set n to n % 10
    increment ans by n / 5
    set n to n % 5
    increment ans by n / 1
    set n to n % 100
    print ans print newline
end of the block

[CODE]:

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

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

[PSEUDOCODE]:
define the main function
    Let N an int
    read N
    let ans an array of long longs of length 1000
    for i from 0 to N exclusive
        let a, b, and k long longs
        read a, b, and k
        if k is even
            set ans[i] to (a - b) * (k / 2)
        otherwise
            set ans[i] to (a - b) * (k / 2)
            add a to ans[i]
        end of the block
    end of the block
    print the first N values of ans
end of the block

[CODE]:

int main() {
    int N;
    cin >> N;
    long long ans[1000];
    for (int i = 0; i < N; i++) {
        long long a, b, k;
        cin >> a >> b >> k;
        if (k % 2 == 0) {
            ans[i] = (a - b) * (k / 2);
        } else {
            ans[i] = (a - b) * (k / 2);
            ans[i] += a;
        }
    }
    for (int i = 0; i < N; i++) cout << ans[i] << 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]:
void function READ with string arguments INPUT (default value "NO") and OUTPUT (default value "NO")
    if INPUT != "NO" open file INPUT.c_str() for reading
    if OUTPUT != "NO" open file OUTPUT.c_str() for writing
end of the block
let A be integer array with size 200001
declare string variables a and b
function ok with integer argument k that returns boolean
    mp = map from integer to boolean
    for i = 0 to k exclusive, mp[A[i]] = 1
    create integer id = 0
    for i = 0 while id < length of b and i < length of a
        if mp[i] is not 0, continue the loop
        if a[i] = b[id], increment id
    end of the block
    return true if id >= length of b, else return false
end of the block
define the main function
    read a and b
    for i = 0 to length of a exclusive
        read A[i]
        decrement A[i]
    end of the block
    declare integers l, r, m and ans where l = 0 and r = length of a
    while l <= r
        m = (l + r) >> 1
        if ok(m)
            set ans to m
            set l to m + 1
        else
            assign value of m - 1 to r
    end of the block
    print ans and "\n"
    return to indicate successful execution
end of the block

[CODE]:

void READ(string INPUT = "NO", string OUTPUT = "NO") {
    if (INPUT != "NO") freopen(INPUT.c_str(), "r", stdin);
    if (OUTPUT != "NO") freopen(OUTPUT.c_str(), "w", stdout);
}
int A[200001];
string a, b;
bool ok(int k) {
    map<int, bool> mp;
    for (int i = 0; i < k; i++) mp[A[i]] = 1;
    int id = 0;
    for (int i = 0; id < (int)b.size() && i < (int)a.size(); i++) {
        if (mp[i]) continue;
        if (a[i] == b[id]) id++;
    }
    return id >= (int)b.size();
}
int main() {
    cin >> a >> b;
    for (int i = 0; i < (int)a.size(); i++) {
        cin >> A[i];
        A[i]--;
    }
    int l = 0, r = (int)a.size(), m, ans;
    while (l <= r) {
        m = (l + r) >> 1;
        if (ok(m)) {
            ans = m;
            l = m + 1;
        } else
            r = m - 1;
    }
    cout << ans << "\n";
    return 0;
}
[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

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

[PSEUDOCODE]:
create ints p, q, A, B, R, and i = 1 and int array C of size 2000000 containing {1, 1}
define the main function
    read p and q
    for loop i to 2e6 exclusive
        if C[i] is falsy
            set A to A + q
            for j = i to 2e6 exclusive by incrementing by i, set C[j] to 1
        end of the block
        make ints r = 0 and t = i
        for loop while t is truthy and increment by r = 10 * r + t % 10 and t /= 10
            end statement
        set B to B + p * (r == i )
        set R to A <= B ? i : R
    end of the block
    display R
end of the block

[CODE]:

int p, q, A, B, R, C[2000000] = {1, 1}, i = 1;
int main() {
    cin >> p >> q;
    for (; i < 2e6; i++) {
        if (!C[i]) {
            A += q;
            for (int j = i; j < 2e6; j += i) C[j] = 1;
        }
        int r = 0, t = i;
        for (; t; r = 10 * r + t % 10, t /= 10)
            ;
        B += p * (r == i);
        R = A <= B ? i : R;
    }
    cout << R << 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 integers n, m, k, i, a, sum with sum = 0
    read n read m read k
    set a to m * 2
    for i = 1, incrementing i
        increment sum by a
        if k is less than sum
            print i print ' '
            break loop
        else if k is sum
            print i print m print ' ' print "R" print newline
            return to indicate successful execution
        end of the block
    end of the block
    decrement sum by a
    set a to k - sum
    if a % 2 is 1
        set a to a /2
        print a + 1 print ' ' print "L" print newline
    else if a % 2 is 0
        set a to a / 2
        print a print ' ' print "R" print newline
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, m, k, i, a, sum = 0;
    cin >> n >> m >> k;
    a = m * 2;
    for (i = 1;; i++) {
        sum += a;
        if (k < sum) {
            cout << i << ' ';
            break;
        } else if (k == sum) {
            cout << i << ' ' << m << ' ' << "R" << endl;
            return 0;
        }
    }
    sum -= a;
    a = k - sum;
    if (a % 2 == 1) {
        a /= 2;
        cout << a + 1 << ' ' << "L" << endl;
    } else if (a % 2 == 0) {
        a /= 2;
        cout << a << ' ' << "R" << 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
    print n
    for ( i= 1 to n-1 inclusive ), print space and i
    print newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    cout << n;
    for (int i = 1; i <= n - 1; i++) cout << " " << i;
    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]:
in int function countSubseq taking a, b = string
    m = length of a = int
    n = length of b = int
    let dp be a matrix of sizes m+1, n+1, and set dp[0][0] = 0
    for i = 0 to n inclusive, increment i first, set dp[0][i] = 0
    for i = 0 to m inclusive, increment i first, set dp[i][0] = 1
    for i = 1 to m inclusive
        for j = 1 to n inclusive
            if a[i-1] = b[i-1]
                set dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]
            else
                set dp[i][j] = dp[i - 1][j]
        end of the block
    end of the block
    return dp[m][n]
end of the block
define the main function
    n = string
    read n
    print countSubseq with args n, "QAQ"
    return to indicate successful execution
end of the block

[CODE]:

int countSubseq(string a, string b) {
    int m = a.length();
    int n = b.length();
    int dp[m + 1][n + 1] = {{0}};
    for (int i = 0; i <= n; ++i) dp[0][i] = 0;
    for (int i = 0; i <= m; ++i) dp[i][0] = 1;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (a[i - 1] == b[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    return dp[m][n];
}
int main() {
    string n;
    cin >> n;
    cout << countSubseq(n, "QAQ") << 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
    s = string
    read s
    l, u = int with l = 0 and u = 0
    for i = 0 to size of s
        if s[i] is a lower case letter
            increment l
        else
            increment u
    end of the block
    if l < u
        for i = 0 to size of s print toupper of s[i]
        print newline
    else
        for i = 0 to size of s print tolower of s[i]
        print newline
    end of the block
end of the block

[CODE]:

int main() {
    string s;
    cin >> s;
    int l = 0, u = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] >= 'a' && s[i] <= 'z')
            l++;
        else
            u++;
    }
    if (l < u) {
        for (int i = 0; i < s.size(); i++) cout << char(toupper(s[i]));
        cout << endl;
    } else {
        for (int i = 0; i < s.size(); i++) cout << char(tolower(s[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 integers n1, n2, k1, k2
    read n1 read n2 read k1 read k2
    print "First" if n1 is greater than n2, else "Second", print '\n'
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n1, n2, k1, k2;
    cin >> n1 >> n2 >> k1 >> k2;
    cout << (n1 > n2 ? "First" : "Second") << '\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]:
let a be an int array of length 1010
define the main function
    let N, K be ints
    read N, K
    for i = 1 to N*2+1 inclusive the read a[i]
    let int k = 0
    for i = 2 to N*2 inclusive
        if a[i] > a[i - 1] + 1 and a[i] > a[i + 1] + 1
            decrement a at i
            increment k
            if k is same as K, exit loop
        end of the block
    end of the block
    for i = 1 to N * 2, print a at i and space
    print a[N * 2 + 1]
    return to indicate successful execution
end of the block

[CODE]:

int a[1010];
int main() {
    int N, K;
    cin >> N >> K;
    for (int i = 1; i <= N * 2 + 1; i++) { cin >> a[i]; }
    int k = 0;
    for (int i = 2; i <= N * 2; i++) {
        if (a[i] > a[i - 1] + 1 && a[i] > a[i + 1] + 1) {
            a[i]--;
            k++;
            if (k == K) break;
        }
    }
    for (int i = 1; i <= N * 2; i++) { cout << a[i] << " "; }
    cout << a[N * 2 + 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]:
create int n and d
create int a[105]
define the main function
    while read n and d
        for i=0 to n exclusive, read a[i]
        sort elements between a and a + n
        maxlen=0
        for i=0 to n exclusive
            thislen = 1
            for j=i+1 to n exclusive
                if a[j] - a[i] > d, break
                increment thislen
            end of the block
            set maxlen to max(thislen, maxlen)
        end of the block
        print n - maxlen
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int n, d;
int a[105];
int main() {
    while (cin >> n >> d) {
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a, a + n);
        int maxlen = 0;
        for (int i = 0; i < n; ++i) {
            int thislen = 1;
            for (int j = i + 1; j < n; ++j) {
                if (a[j] - a[i] > d) break;
                thislen++;
            }
            maxlen = max(thislen, maxlen);
        }
        cout << n - maxlen << 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 long integer
    read n
    if n modulo 2 is equal to 0
        print 2 and newline
    else do the following
        print 1 and newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long n;
    cin >> n;
    if (n % 2 == 0)
        cout << 2 << endl;
    else
        cout << 1 << endl;
    return 0;
}