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 integer k and an array x with size 3
    read x[0], x[1] and x[2] from the input
    sort x
    assign x[2] - x[0] to k
    print k
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int x[3], k;
    cin >> x[0] >> x[1] >> x[2];
    sort(x, x + 3);
    k = x[2] - x[0];
    cout << k << 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 string s
    read s
    make char cur = 'a'
    make int mn
    let integer ans = 0
    for i = 0 to s.length() exclusive
        set mn to min(abs(s[i] - cur), abs(26 - abs((s[i] - cur))))
        set ans to ans + mn
        set cur to s[i]
    end of the block
    display ans
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string s;
    cin >> s;
    char cur = 'a';
    int mn;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        mn = min(abs(s[i] - cur), abs(26 - abs((s[i] - cur))));
        ans += mn;
        cur = s[i];
    }
    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]:
declare tostr with integer n as argument, returning string
    declare stringstream rr
    read n with rr
    return string from rr
end of the block
declare check_lucky with long long n as argument, returning integer
    while n is greater than 0
        if n % 10 is 8, return 1 from function
        let n be n / 10
    end of the block
    return to indicate successful execution
end of the block
define the main function
    declare long long a
    read a
    declare integer res = 0
    while result of run check_lucky( absolute value of a ) is false or res is 0
        increment res by 1
        increment a by 1
    end of the block
    print res and newline
    return to indicate successful execution
end of the block

[CODE]:

string tostr(int n) {
    stringstream rr;
    rr << n;
    return rr.str();
}
int check_lucky(long long n) {
    while (n > 0) {
        if (n % 10 == 8) { return 1; }
        n /= 10;
    }
    return 0;
}
int main() {
    long long a;
    cin >> a;
    int res = 0;
    while (!check_lucky(abs(a)) || (res == 0)) {
        res += 1;
        a += 1;
    }
    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]:
define the main function
    x, y, z = long long
    read x, y
    let z = (y - 1) / x
    add one to z
    print z
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long x, y, z;
    cin >> x >> y;
    z = (y - 1) / x;
    z++;
    cout << z << 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 integer variables x1, x2, y1 and y2
    declare integers diff1 and diff2
    read x1 and y1
    read x2 and y2
    set value of diff1 to absolute value of x2 - x1
    set diff2 to absolute value of y2 - y1
    if diff1 is greater than diff2
        print diff1
    else if diff2 is greater than diff1
        print diff2
    else if diff1 = diff2
        print diff1
    end of the block
end of the block

[CODE]:

int main() {
    int x1, x2, y1, y2;
    int diff1, diff2;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    diff1 = abs(x2 - x1);
    diff2 = abs(y2 - y1);
    if (diff1 > diff2) {
        cout << diff1 << endl;
    } else if (diff2 > diff1) {
        cout << diff2 << endl;
    } else if (diff1 == diff2) {
        cout << diff1 << 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
    declare new int n and int array a with 1010 elements
    read n from the input
    read n sequential elements of a from the input
    sort a
    if a[0] - 1 <= 0
        print -1
    else
        print 1
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n, a[1010];
    cin >> n;
    for (int i = 0; i < n; i++) { cin >> a[i]; }
    sort(a, a + n);
    if (a[0] - 1 <= 0) {
        cout << -1 << endl;
    } else {
        cout << 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 long long integers a, b, and c and long long array of size 100001
define the main function
    read a and b
    for i = 0 to a exclusive, read x[i] and set c to c + (x[i] + b - 1) / b
    print (c + 1) / 2
    return to indicate successful execution
end of the block

[CODE]:

long long a, b, c, x[100001];
int main() {
    cin >> a >> b;
    for (int i = 0; i < a; i++) cin >> x[i], c += (x[i] + b - 1) / b;
    cout << (c + 1) / 2 << 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
    count = 0 = int
    k = int array of length n
    read the first n elements of k
    mini, maxi = int
    for i = 0 to n exclusive
        if i = 0
            set mini to k[i]
            set maxi to k[i]
        end of the block
        if k[i] < mini
            increment count
            set mini to k[i]
        end of the block
        if k[i] > maxi
            increment count
            set maxi to k[i]
        end of the block
    end of the block
    print count
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    int count = 0;
    int k[n];
    for (int i = 0; i < n; i++) { cin >> k[i]; }
    int mini, maxi;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            mini = k[i];
            maxi = k[i];
        }
        if (k[i] < mini) {
            count++;
            mini = k[i];
        }
        if (k[i] > maxi) {
            count++;
            maxi = k[i];
        }
    }
    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
    a,b = strings
    read a and b
    create integer x=0
    for i=0 to size of a exclusive
        if a[i] is equal to b[i] then continue
        if a[i] is equal to 8
            if b[i] is equal to (
                decrement x
            else do the following
                increment x
            end of the block
        else if a[i] is equal to (
            if b[i] is equal to [
                subtract 1 from x
            else do the following
                add 1 to x
            end of the block
        else do the following
            if b[i] is equal to (
                add 1 to x
            else do the following
                decrement x
        end of the block
    end of the block
    if x is 0 then print TIE else if x>0 print TEAM 1 WINS else print TEAM 2 WINS and new line
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string a, b;
    cin >> a >> b;
    int x = 0;
    for (int i = 0; i < a.size(); i += 2) {
        if (a[i] == b[i]) continue;
        if (a[i] == '8') {
            if (b[i] == '(') {
                x--;
            } else {
                x++;
            }
        } else if (a[i] == '(') {
            if (b[i] == '[') {
                x--;
            } else {
                x++;
            }
        } else {
            if (b[i] == '(')
                x++;
            else
                x--;
        }
    }
    cout << (!x ? "TIE\n" : (x > 0 ? "TEAM 1 WINS\n" : "TEAM 2 WINS\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 strings n1 and n2
    read n1 and n2
    for i from 0 to length of n1 exclusive
        if n1[i] is equal to n2[i]
            change n1[i] to '0'
        else
            set n1[i] to '1'
        end of the block
    end of the block
    print n1
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string n1, n2;
    cin >> n1 >> n2;
    for (size_t i = 0; i < n1.length(); ++i) {
        if (n1[i] == n2[i]) {
            n1[i] = '0';
        } else {
            n1[i] = '1';
        }
    }
    cout << n1 << 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 integer sum
declare gcd with integers a, b as arguments, returning integer
    if a % b is 0, return b from function
    return result of run gcd with arguments b, a %b from function
end of the block
declare add with integers n, x as arguments, returning void
    while n is not 0
        increment sum by n % x
        set n to n / x
    end of the block
end of the block
define the main function
    create integer n
    read n
    for i = 2 to n exclusive, run add with n, i as arguments
    create integer div with div = result of run gcd with sum, n - 2 as arguments
    print sum / div print '/' print (n - 2)/div print newline
    return to indicate successful execution
end of the block

[CODE]:

int sum;
int gcd(int a, int b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}
void add(int n, int x) {
    while (n != 0) {
        sum += n % x;
        n /= x;
    }
}
int main() {
    int n;
    cin >> n;
    for (int i = 2; i < n; i++) add(n, i);
    int div = gcd(sum, n - 2);
    cout << sum / div << '/' << (n - 2) / div << 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 multidimensional char array wb of size 10x10
    for i = 1 to 8 inclusive
        for j = 1 to 8 inclusive, read wb[i][j]
    end of the block
    create int judge = 1
    for i = 1 to 8 inclusive
        for j = 1 to 7 inclusive
            if wb[i][j] equals wb[i][j + 1], set judge to 0
        end of the block
    end of the block
    if judge equals 1
        print "YES"
    else
        print "NO"
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    char wb[10][10];
    for (int i = 1; i <= 8; i++) {
        for (int j = 1; j <= 8; j++) cin >> wb[i][j];
    }
    int judge = 1;
    for (int i = 1; i <= 8; i++) {
        for (int j = 1; j <= 7; j++) {
            if (wb[i][j] == wb[i][j + 1]) { judge = 0; }
        }
    }
    if (judge == 1) {
        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
    integer as n
    read n
    for i = 0 to less than n do the following
        integer as k = 0
        if i is less than (n / 2 then do the following + 1
            set k to i
        else
            set k to n - 1 - i
        for j = 1 to less than or equal to n do the following
            if abs is less than or equal to k then do the following
                output D
            else
                output *
        end of the block
        output endl
    end of the block
end of the block

[CODE]:

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int k = 0;
        if (i < (n / 2) + 1)
            k = i;
        else
            k = n - 1 - i;
        for (int j = 1; j <= n; j++) {
            if (abs(j - (n / 2) - 1) <= k)
                cout << "D";
            else
                cout << "*";
        }
        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 count with count = 0, create integer array arr with size 4
    for i = 0 to 4 exclusive, read arr[i]
    for i = 0 to 3 exclusive
        if arr[i] is not 0
            for j = i + 1 to 4 exclusive
                if arr[i] is arr[j] and arr[j] is not 0
                    increment count
                    set arr[j] to 0
                end of the block
            end of the block
    end of the block
    print count print newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int count = 0, arr[4];
    for (int i = 0; i < 4; i++) cin >> arr[i];
    for (int i = 0; i < 3; i++) {
        if (arr[i] != 0)
            for (int j = i + 1; j < 4; j++) {
                if (arr[i] == arr[j] && arr[j] != 0) {
                    count++;
                    arr[j] = 0;
                }
            }
    }
    cout << count << endl;
    return 0;
}