int main(){
int l = 1, r = 1000000000;
int m = (l + r) /2;
int x = 50000000000;
int k;
int sum = 100;
int pred;
cout << "run " << x;
cin >> k;
while(l != r) {
if (floor(x / m) > k) {
cout << "run " << x += x/2;
fflush(stdout);
l = m;
m = (l + r) / 2;
sum += x;
pred = k;
cin >> k
} else if (floor(x / m) < k) {
cout << "run " << x -= x/2;
fflush(stdout);
pred = k;
r = m;
m = (l + r) / 2;
sum += x;
cin >> k;
} else if (floor(x / m) == k) {
cout << "run " << m - x % m;
fflush(stdout);
cin >> k;
if (k - pred == 1) {
r = m;
m = (l + r) /2;
x += x/2
}
else{
l = m + 1;
m = (l + r) /2;
x -= x/2
}
}
}
}
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <sstream>
using namespace std;
struct vv{
int c, num;
};
void printBigNumber(const std::vector<int>& number) {
std::stringstream ss;
for(int i = 0; i < number.size(); ++i)
{
if(i != 0)
ss << "";
ss << number[i];
}
std::string s = ss.str();
vector<int>num;
//cout << 's' << endl;
for(auto k : s)
num.push_back(int(k) - 48);
s.clear();
s.shrink_to_fit();
int cnt = 0;
std::vector<vv> kk;
for (int k = 0; k < num.size(); ++k) {
if (k + 1 < num.size()) {
if (num[k] == num[k + 1]) {
cnt++;
} else {
kk.push_back({cnt + 1, num[k]});
cnt = 0;
}
} else {
kk.push_back({cnt + 1, num[k]});
}
}
std::cout << kk.size() << std::endl;
for (auto j: kk) {
std::cout << j.c << ' ' << j.num << '\n';
}
}
int main() {
vector<int> a;
vector<int> b;
const int base = 1000 * 1000 * 1000;
int n;
string stra;
string strb;
cin >> n;
while (n--) {
int c;
char num;
cin >> c >> num;
while (c--) {
stra.push_back(num);
}
}
cin >> n;
while (n--) {
int c;
char num;
cin >> c >> num;
while (c--) {
strb.push_back(num);
}
}
for (int i = (int) stra.length(); i > 0; i -= 9) {
if (i < 9)
a.push_back(atoi(stra.substr(0, i).c_str()));
else
a.push_back(atoi(stra.substr(i - 9, 9).c_str()));
}
for (int i = (int) strb.length(); i > 0; i -= 9){
if (i < 9)
b.push_back(atoi(strb.substr(0, i).c_str()));
else
b.push_back(atoi(strb.substr(i - 9, 9).c_str()));
}
while (a.size() > 1 && a.back() == 0)
a.pop_back();
while (b.size() > 1 && b.back() == 0)
b.pop_back();
int carry = 0;
for (size_t i=0; i<max(a.size(),b.size()) || carry; ++i) {
if (i == a.size())
a.push_back (0);
a[i] += carry + (i < b.size() ? b[i] : 0);
carry = a[i] >= base;
if (carry) a[i] -= base;
}
b.clear();
b.shrink_to_fit();
std::vector<int>res;
res.push_back(a.empty() ? 0 : a.back());
for (int i=a.size()-2;i>=0;i--) {
int len2=9;
if (!a[i])
while(--len2) res.push_back(0);
else
while (a[i]<pow(10.0,--len2)) res.push_back(0);
res.push_back(a[i]);
}
a.clear();
a.shrink_to_fit();
printBigNumber(res);
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct vv{
int c, num;
};
void printBigNumber(const std::vector<int>& number, int len) {
int cnt = 0;
std::vector<vv> kk;
for (int k = 0; k < len; ++k) {
if (k + 1 < len) {
if (number[k] == number[k + 1]) {
cnt++;
} else {
kk.push_back({cnt + 1, number[k]});
cnt = 0;
}
} else {
kk.push_back({cnt + 1, number[k]});
}
}
std::cout << kk.size() << std::endl;
for (auto j: kk) {
std::cout << j.c << ' ' << j.num << '\n';
}
// for(auto k : number){
// std::cout << k << ' ';
// }
}
int main() {
vector<int> a;
vector<int> b;
const int base = 1000 * 1000 * 1000;
int n;
cin >> n;
while (n--) {
int c;
int num;
cin >> c >> num;
while (c--) {
a.push_back(num);
}
}
cin >> n;
while (n--) {
int c;
int num;
cin >> c >> num;
while (c--) {
b.push_back(num);
}
}
// for(auto k : a){
// std::cout << k;
// }
// cout << '+';
// for(auto k : b){
// std::cout << k;
// }
// cout << endl;
int size_a = a.size();
int size_b = b.size();
int length;
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
if (size_a > size_b) {
length = size_a + 1;
b.resize(length);
}
else
length = size_b + 1;
a.resize(length);
for (int ix = 0; ix < length; ix++)
{
b[ix] += a[ix];
b[ix + 1] += (b[ix] / 10);
b[ix] %= 10;
}
if (b[length - 1] == 0){
length--;
b.erase(b.end() - 1);
}
reverse(b.begin(), b.end());
printBigNumber(b, length);
}