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
    let t be a integer
    read t
    while t is true
        let n be a integer
        read n
        the double value of k = 3.0
        the double value of ans = 0.0
        while the condition is true
            ans is equal to ((k - 2.0) * 180.0) / k
            if n equals ans
                print YES and newline
                stop
            else if ans is greater than n
                print NO and newline
                stop
            end of the block
            increment k by 1
        end of the block
        decrement t by 1
    end of the block
end of the block

[CODE]:

int main() {
    int t;
    cin >> t;
    while (t) {
        int n;
        cin >> n;
        double k = 3.0;
        double ans = 0.0;
        while (1) {
            ans = ((k - 2.0) * 180.0) / k;
            if (n == ans) {
                cout << "YES" << endl;
                break;
            } else if (ans > n) {
                cout << "NO" << endl;
                break;
            }
            k++;
        }
        t--;
    }
}
[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 function fastpow with arguments of long long base and long long exp that returns a long long
    res = long long = 1
    while exp > 0
        if exp is odd, then res = (res * base) modulo 1000000009
        base = (base * base) % 1000000009
        exp = exp / 2
    end of the block
    return res modulo 1000000009
end of the block
in function ask with argument of long long a that returns a long long
    print 1 a
    x = long long
    read x
    return x
end of the block
define the main function
    testcases = long long
    read testcases
    while looping decrease testcases by 1
        a, b, k = long long
        read a, b, k
        if k is even
            print (k / 2) * (a - b)
        else
            print ((k - 1) / 2) * (a - b) + a
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

long long fastpow(long long base, long long exp) {
    long long res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % 1000000009;
        base = (base * base) % 1000000009;
        exp /= 2;
    }
    return res % 1000000009;
}
long long ask(long long a) {
    cout << 1 << " " << a << endl;
    long long x;
    cin >> x;
    return x;
}
int main() {
    long long testcases;
    cin >> testcases;
    while (testcases--) {
        long long a, b, k;
        cin >> a >> b >> k;
        if (k % 2 == 0) {
            cout << (k / 2) * (a - b) << endl;
        } else {
            cout << ((k - 1) / 2) * (a - b) + 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
    l, r = long long
    read l, r
    if r - l + 1 < 3
        print -1
        return to indicate successful execution
    end of the block
    if l modulo 2 is 0
        print l,' ',l + 1,' ',l + 2
        return to indicate successful execution
    end of the block
    if r - l + 1 > 3
        print l + 1,' ',l + 2,' ',l + 3
        return to indicate successful execution
    end of the block
    print -1
end of the block

[CODE]:

int main() {
    long long l, r;
    cin >> l >> r;
    if (r - l + 1 < 3) {
        cout << -1 << endl;
        return 0;
    }
    if (l % 2 == 0) {
        cout << l << ' ' << l + 1 << ' ' << l + 2 << endl;
        return 0;
    }
    if (r - l + 1 > 3) {
        cout << l + 1 << ' ' << l + 2 << ' ' << l + 3 << endl;
        return 0;
    }
    cout << -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
    let s, s1 be strings
    let n,k be integers
    read n,k
    if (k is greater than n or (k is equal to 1 and n is greater than 1)) , and print -1 and endline , return 0
    if (k is equal to 1) print a and endline, return 0
    for( i=1 to k - 2 inclusive), s is equal to s + b + i
    for( i=1 to n- k +2 inclusive), s1 = s1 + (if i modulus 2 ) ? a else b
    print s1 and s and newline
end of the block

[CODE]:

int main() {
    string s, s1;
    int n, k;
    cin >> n >> k;
    if (k > n || (k == 1 && n > 1)) return cout << "-1" << endl, 0;
    if (k == 1) return cout << "a" << endl, 0;
    for (int i = 1; i <= k - 2; i++) s += 'b' + i;
    for (int i = 1; i <= n - k + 2; i++) s1 += i % 2 ? 'a' : 'b';
    cout << s1 << s << 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 int n, i and arrays p and s of length 100100
    read n
    for i=2 to n inclusive, read p[i]
    for i=1 to n inclusive, read s[i]
    for i=2 to n inclusive
        if s[i] = -1, continue the loop
        s[p[i]] = -1
            set s[p[i]] = s[i]
        else
            s[p[i]] = min of s[p[i]] and s[i]
    end of the block
    for i=2 to n inclusive
        if s[i] equal to -1, continue the loop
        if s[p[i]] greater than s[i]
            print -1
            return to indicate successful execution
        end of the block
    end of the block
    set ans to s[1]
    for i=2 to n inclusive
        if s[i] equal to -1, continue the loop
        assign ans + s[i] - s[p[i]] to ans
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, p[100100], s[100100], i;
    cin >> n;
    for (i = 2; i <= n; i++) cin >> p[i];
    for (i = 1; i <= n; i++) cin >> s[i];
    for (i = 2; i <= n; i++) {
        if (s[i] == -1) continue;
        if (s[p[i]] == -1)
            s[p[i]] = s[i];
        else
            s[p[i]] = min(s[p[i]], s[i]);
    }
    for (i = 2; i <= n; i++) {
        if (s[i] == -1) continue;
        if (s[p[i]] > s[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    long long ans = s[1];
    for (i = 2; i <= n; i++) {
        if (s[i] == -1) continue;
        ans += (s[i] - s[p[i]]);
    }
    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
    a = array of integers of length 110
    let n be a integer
    read n
    let A , B be integers with A = 0, B = 0
    for i = 0 to n exclusive
        read a[i]
        if a[i] is greater than 0
            increment A by a[i]
        else do the following
            increment B by a[i]
    end of the block
    print A - B and newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int a[110];
    int n;
    cin >> n;
    int A = 0, B = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > 0)
            A += a[i];
        else
            B += a[i];
    }
    cout << A - 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]:
maxn = const integer with maxn = 1e5 + 5
define the main function
    n = integer
    s = string array of size 105
    read n
    for i = 0 to n exclusive
        s[i] = " "
        read s[i]
    end of the block
    ans = integer with ans = 0
    for i = 0 to 25
        for j = 0 to 25
            x = character with x = a + i
            y = character with y = a + j
            temp = integer with temp = 0
            for k = 0 to n exclusive
                temp1 = integer with temp1 = 0
                flag = integer with flag = 1
                for l = 0 to s[k].size() exclusive
                    if (s[k][l] is x or s[k][l] is y)
                        increment temp1
                    else
                        flag = 0
                        break loop
                    end of the block
                end of the block
                if (flag), temp = temp + temp1
            end of the block
            ans = max of ans and temp
        end of the block
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:

const int maxn = 1e5 + 5;
int main() {
    int n;
    string s[105];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        s[i] = " ";
        cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i <= 26; ++i) {
        for (int j = 0; j <= 26; ++j) {
            char x = 'a' + i;
            char y = 'a' + j;
            int temp = 0;
            for (int k = 0; k < n; ++k) {
                int temp1 = 0;
                int flag = 1;
                for (int l = 0; l < s[k].size(); ++l) {
                    if (s[k][l] == x || s[k][l] == y)
                        temp1++;
                    else {
                        flag = 0;
                        break;
                    }
                }
                if (flag) temp += temp1;
            }
            ans = max(ans, temp);
        }
    }
    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 = int
    read n
    a = int array of size n
    cnt = int with cnt = 0
    for i = 1 to n inclusive read a[i]
    call sort on a + 1 and a + 1 + n
    if n equals 1 or 2
        print 0
    else if n is greater than 2
        minn = int with minn = a[1]
        mixx = int with mixx = a[n]
        for i = 2 to n - 1 inclusive
            if a[i] is between minn and mixx then increment cnt
        end of the block
        print cnt
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;
    for (int i = 1; i <= n; i++) { cin >> a[i]; }
    sort(a + 1, a + 1 + n);
    if (n == 1 || n == 2)
        cout << 0 << endl;
    else if (n >= 3) {
        int minn = a[1];
        int mixx = a[n];
        for (int i = 2; i <= n - 1; i++) {
            if (a[i] > minn && a[i] < mixx) cnt++;
        }
        cout << cnt << 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]:
let n, m, p, a and b be integers
void function solve
    read a, b and n
    let tmp be integer = a * 10
    for i = 0 to 10 exclusive
        if tmp % b = 0
            print tmp
            print "0" n - 1 times
            print new line
            return
        end of the block
        increase tmp
    end of the block
    print -1 and a new line
end of the block
define the main function
    ;
    declare integer variable T = 1
    call solve() T times
    return to indicate successful execution
end of the block

[CODE]:

int n, m, p, a, b;
void solve() {
    cin >> a >> b >> n;
    int tmp = a * 10;
    for (int i = 0; i < 10; i++) {
        if (tmp % b == 0) {
            cout << tmp;
            for (int i = 0; i < n - 1; ++i) cout << "0";
            cout << endl;
            return;
        }
        tmp++;
    }
    cout << -1 << endl;
}
int main() {
    ;
    int T = 1;
    for (int i = 0; i < T; i++) { solve(); }
    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 ints n, na = 0, nb = 0, and ab = 0 and int arrays aa of size 110 and bb of size 110
    read n
    for a = 0 to n exclusive
        read aa[a]
        read bb[a]
        set na to na + aa[a]
        add bb[a] to nb
        if (aa[a] + bb[a]) modulo 2 is 1, set ab to 1
    end of the block
    if na modulo 2 is equal to 0 and nb modulo 2 is equal to 0
        print 0
    else if na % 2 is equal to 1, nb % 2 is equal to 1, and ab is 1
        print 1
    otherwise
        display -1
end of the block

[CODE]:

int main() {
    int n, aa[110], bb[110], na = 0, nb = 0, ab = 0;
    cin >> n;
    for (int a = 0; a < n; a++) {
        cin >> aa[a];
        cin >> bb[a];
        na += aa[a];
        nb += bb[a];
        if ((aa[a] + bb[a]) % 2 == 1) ab = 1;
    }
    if (na % 2 == 0 && nb % 2 == 0) {
        cout << 0 << endl;
    } else if (na % 2 == 1 && nb % 2 == 1 && ab == 1) {
        cout << 1 << endl;
    } else
        cout << -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
    let n = integer
    read n
    if n is odd
        print 1
    else
        print 0
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    if (n % 2)
        cout << "1\n";
    else
        cout << "0\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
    create n, m as integers
    get n, m
    create str, cmd as strings
    get str
    create x, y as integers
    create c1, c2 as characters
    for integer i=0 to m-1 with increment i do
        get x, y, c1, c2
        for integer j=x to y with increment j do
            if str[j-1] is equal to c1 then assign c2 to str[j-1]
        end of the block
    end of the block
    print str
end of the block

[CODE]:

int main() {
    int n, m;
    cin >> n >> m;
    string str, cmd;
    cin >> str;
    int x, y;
    char c1, c2;
    for (int i = 0; i < m; i++) {
        cin >> x >> y >> c1 >> c2;
        for (int j = x; j <= y; j++) {
            if (str[j - 1] == c1) str[j - 1] = c2;
        }
    }
    cout << str << endl;
}