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
    create long long integers x1, y1, x2, y2, x, y
    read x1 read y1 read x2 read y2
    read x ready
    if absolute value of ( x2 - x1 ) % x is not 0 or absolute value of ( y2 - y1 ) % y is not 0
        print "NO\n"
        return to indicate successful execution
    end of the block
    if ((x2-x1) / x - (y2-y1) / y)%2 is 0
        print "YES\n"
    else
        print "NO\n"
end of the block

[CODE]:

int main() {
    long long int x1, y1, x2, y2, x, y;
    cin >> x1 >> y1 >> x2 >> y2;
    cin >> x >> y;
    if (abs(x2 - x1) % x != 0 || abs(y2 - y1) % y != 0) {
        cout << "NO\n";
        return 0;
    }
    if (((x2 - x1) / x - (y2 - y1) / y) % 2 == 0)
        cout << "YES\n";
    else
        cout << "NO\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
    let n, m, x, y be integers
    read n, m, x, and y
    let a be a vector of ints
    set the size of a to n
    let b be a vector of ints
    set the size of b to m
    for i = 0 to n exclusive, read a[i]
    for i = 0 to m exclusive, read b[i]
    let count be an int with value 0
    let result be a vector of ints
    set the size of result to n
    let index be an int with value 0
    for i and j starting at 0, i < n and j < m
        if b[j] < a[i] - x
            increment j
        else if b > a[i] + y
            increment i
        else
            set result[i] to j + 1
            increment i
            increment j
            increment count
        end of the block
    end of the block
    print count
    for i = 1 to result.size() exclusive
        if result[i] is not 0
            print i + 1, then print a space, then print result[i]
            decrement count
        end of the block
        if count is 0 then break
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> a;
    a.resize(n);
    vector<int> b;
    b.resize(m);
    for (int i = 0; i < n; i++) { cin >> a[i]; }
    for (int i = 0; i < m; i++) { cin >> b[i]; }
    int count = 0;
    vector<int> result;
    result.resize(n);
    int index = 0;
    for (int i = 0, j = 0; i < n && j < m;) {
        if (b[j] < a[i] - x) {
            ++j;
        } else if (b[j] > a[i] + y) {
            ++i;
        } else {
            result[i] = j + 1;
            i++;
            j++;
            ++count;
        }
    }
    cout << count << "\n";
    for (int i = 0; i < result.size(); i++) {
        if (result[i] != 0) {
            cout << i + 1 << " " << result[i] << "\n";
            count--;
        }
        if (count == 0) break;
    }
    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 constant integer inf with inf = integer casted 1e9
create constant integer mod with mod = inf + 7
create constant double eps with eps = 1e-9
create constant double pi with pi = acosign of -1.0
create integers r, g, b
define the main function
    read r read g read b
    create integer ans with ans = 30
    for i = 1 to 100000 exclusive
        if i % 3 is 1
            increment ans
            decrement r by 2
        end of the block
        if i % 3 is 2
            increment ans
            decrement g by 2
        end of the block
        if i % 3 is 0
            increment ans
            decrement b by 2
        end of the block
        if r is less than or equal to 0 and g is less than or equal to 0 and b is less than or equal to 0, return print ans -1 print newline, 0 from function
    end of the block
end of the block

[CODE]:

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int r, g, b;
int main() {
    cin >> r >> g >> b;
    int ans = 30;
    for (int i = 1; i < 100000; ++i) {
        if (i % 3 == 1) {
            ans++;
            r -= 2;
        }
        if (i % 3 == 2) {
            ans++;
            g -= 2;
        }
        if (i % 3 == 0) {
            ans++;
            b -= 2;
        }
        if (r <= 0 && g <= 0 && b <= 0) return cout << ans - 1 << endl, 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 const int INF = 0x3f3f3f3f
create const long long INFLL = 0x3f3f3f3f3f3f3f3fLL
inlined long long function read
    create long longs x = 0 and f = 1
    read char from the input to the new char variable ch
    while ch is not a digit character
        if ch = '-', assign -1 to f
        read char from the input to ch
    end of the block
    while ch is a digit character
        assign x * 10 + ch - '0' to x
        read char from the input to ch
    end of the block
    return x * f
end of the block
declare const int maxn = 1e5 + 10
create integers m and k
declare integer arrays d, mx and s with size maxn
define the main function
    read m and k
    loop i from 1 to m inclusive read d[i]
    for i = 1 to m inclusive
        read s[i]
        change mx[i] to max(mx[i - 1], s[i])
    end of the block
    declare ints ans = 0 and now = s[1]
    for i = 1 to m inclusive
        while d[i] > now, increment now by mx[i] and ans by k
        subtract d[i] from now
        increase now by s[i + 1]
        increase ans by d[i]
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:

const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline long long read() {
    long long x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
const int maxn = 1e5 + 10;
int m, k;
int d[maxn], mx[maxn], s[maxn];
int main() {
    cin >> m >> k;
    for (int i = 1; i <= m; i++) cin >> d[i];
    for (int i = 1; i <= m; i++) {
        cin >> s[i];
        mx[i] = max(mx[i - 1], s[i]);
    }
    int ans = 0, now = s[1];
    for (int i = 1; i <= m; i++) {
        while (d[i] > now) now += mx[i], ans += k;
        now -= d[i];
        now += s[i + 1];
        ans += d[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
    declare string variable str
    read input to str
    change str[0] to uppercase
    print str
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string str;
    cin >> str;
    str[0] = (char)toupper(str[0]);
    cout << str << 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 long long variables n, k and count
let bisa be a vector of long longs
define the main function
    read n and k
    for long long i = 1 to square root of n inclusive
        if n % i = 0 && i * i != n
            push i into bisa
            push n / i into bisa
        end of the block
        if i * i = n, push i into bisa
    end of the block
    sort bisa
    if n = 1 && k is greater than 1
        print "-1"
    else if length of bisa >= k
        print bisa[k - 1]
    else
        print "-1"
    end of the block
end of the block

[CODE]:

long long n, k, count;
vector<long long> bisa;
int main() {
    cin >> n >> k;
    for (long long i = 1; i <= sqrt(n); i++) {
        if (n % i == 0 && i * i != n) {
            bisa.push_back(i);
            bisa.push_back(n / i);
        }
        if (i * i == n) { bisa.push_back(i); }
    }
    sort(bisa.begin(), bisa.end());
    if (n == 1 && k > 1) {
        cout << "-1" << endl;
    } else if (bisa.size() >= k) {
        cout << bisa[k - 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]:
let a = array of integers of size 1000010
let inf = integer constant with value hexadecimal 3f3f3f3f
define the main function
    let n = integer
    while (read n) is true do the following
        let a, b = arrays of integers of size 310
        read a[0]
        let m = integer of value 0
        for integer i=1 to n exclusive do the following
            read a[i]
            set b[i] = a[i] - a[i-1]
            if b[i] is greater than m set m = b[i]
        end of the block
        let mi = integer with mi = inf
        for integer i=1 to n exclusive do the following
            set b[i] = b[i] + b[i+1]
            if b[i] is less than mi set mi = b[i]
        end of the block
        if mi is greater than m
            print mi
        else
            print m
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

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

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

[PSEUDOCODE]:
define the main function
    let n, t, k, d be integers
    read n, t, k, d
    let k1, t1, i be integers with k1 = 0, t1 = t, i = -1
    increment d by t
    if k >= n
        print NO and newline
        return to indicate successful execution
    end of the block
    let counter be a integer with counter = ceiling ((float)n / k) * t
    while k1 is less than n
        if i is equal to t1
            increment k1 by k
            increment t1 by t
        end of the block
        if i is equal to d
            increment k1 by k
            increment d by t
        end of the block
        if k1 is less than n, increment i by 1
    end of the block
    if i is less than counter
        print YES and newline
    else do the following
        print NO and newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, t, k, d;
    cin >> n >> t >> k >> d;
    int k1 = 0, t1 = t, i = -1;
    d += t;
    if (k >= n) {
        cout << "NO" << endl;
        return 0;
    }
    int counter = ceil((float)n / k) * t;
    while (k1 < n) {
        if (i == t1) {
            k1 += k;
            t1 += t;
        }
        if (i == d) {
            k1 += k;
            d += t;
        }
        if (k1 < n) ++i;
    }
    if (i < counter)
        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 long longs a, b
    input a and b
    if a is positive
        if b is positive
            display 0, ' ', a + b, ' '. a + b, ' ', 0
        else
            display 0, ' ', b - a, ' ', a - b, ' ', 0
    else
        if b is positive
            display a - b, ' ', 0, ' ', 0, ' ', b - a
        else
            display a + b, ' ', 0, ' ', 0, ' ', a + b
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long a, b;
    cin >> a >> b;
    if (a > 0) {
        if (b > 0)
            cout << 0 << ' ' << a + b << ' ' << a + b << ' ' << 0 << '\n';
        else
            cout << 0 << ' ' << b - a << ' ' << a - b << ' ' << 0 << '\n';
    } else {
        if (b > 0)
            cout << a - b << ' ' << 0 << ' ' << 0 << ' ' << b - a << '\n';
        else
            cout << a + b << ' ' << 0 << ' ' << 0 << ' ' << a + b << '\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]:
declare my_gcd taking in ints x and y and returning integer
    if x is 0, return y
    return the return value of my_gcd(y % x, x)
end of the block
define the main function
    create ints n, m, and z
    read n, m, and z
    create integer lcm = n * m / my_gcd(n, m)
    print z / lcm
    return to indicate successful execution
end of the block

[CODE]:

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

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

[PSEUDOCODE]:
create integers k, n, x, a, ans
define the main function
    read k read n read x
    for i = 0 to k exclusive
        read a
        if k - n is less than or equal to i and a is greater than x
            increment ans by x
        else
            increment ans by a
    end of the block
    print ans print '\n'
end of the block

[CODE]:

int k, n, x, a, ans;
int main() {
    cin >> k >> n >> x;
    for (int i = 0; i < k; i++) {
        cin >> a;
        if (k - n <= i && a > x)
            ans += x;
        else
            ans += a;
    }
    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]:
declare long long variables n, t, e, f, g and y
create new 2d array of long longs Ta 5001 by 4, filled with 0
define the main function
    read from the input to n
    for x from 1 to n inclusive, incrementing x
        read t from the user input
        if t is equal to 1
            set the value of Ta[x - f - g][1] to x
            increment e by one
        else if t is equal to 2
            change the value of Ta[x - e - g][2] to x
            increment f
        else if t is equal to 3
            change Ta[x - e - f][3] to x
            increment g
        end of the block
    end of the block
    for x = 1 to n inclusive incrementing x
        if none of Ta[x][1, Ta[x][2] and Ta[x][3] is equal to 0, increment y
    end of the block
    if y = 0
        print "0" to the standard output
    else
        print y to the standard output
        for x = 1 to y inclusive, print Ta[x][1], " ", Ta[x][2], " " and Ta[x][3]
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

long long n, t, e, f, g, y;
long long Ta[5001][4] = {0, 0};
int main() {
    cin >> n;
    for (int x = 1; x <= n; x++) {
        cin >> t;
        if (t == 1) {
            Ta[x - f - g][1] = x;
            e++;
        } else if (t == 2) {
            Ta[x - e - g][2] = x;
            f++;
        } else if (t == 3) {
            Ta[x - e - f][3] = x;
            g++;
        }
    }
    for (int x = 1; x <= n; x++) {
        if (Ta[x][1] != 0 && Ta[x][2] != 0 && Ta[x][3] != 0) { y++; }
    }
    if (y == 0) {
        cout << "0" << endl;
    } else {
        cout << y << endl;
        for (int x = 1; x <= y; x++) { cout << Ta[x][1] << " " << Ta[x][2] << " " << Ta[x][3] << endl; }
    }
    return 0;
}