Language: C++

  string res = input;
  reverse(all(res));
  return res;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}

int H = 20, W = 30;

bool ng(int y, int x) {
  return y < 0 || H <= y || x < 0 || W <= x;
}

void solve();

class A {
public:
  int water = 0;
  int sugar = 0;

  A() {};

  A(int water, int sugar) : water(water), sugar(sugar) {};

  double v() {
    if (water == 0 && sugar == 0) return -1;
    return (double)sugar / (water + sugar);
  }

  void print() {
    cout << water + sugar << " " << sugar << endl;
  }
};

class Solver {
public:
  int waters[2];
  int sugars[2];
  int E, F;	

  A ans() {    
    A ans, cur;
    // sugar / (water + sugar) を大きく
    
    // sugar > water * E / 100はだめ
    // sugar * 100 > water * E
    
    while (true) {
      A next;
      
      rep(i, 2) {
	A try_a(cur.water + waters[i] * 100, cur.sugar);
	try_a.print();
	if (try_a.sugar * 100 > try_a.water * E) continue;
	if (try_a.water + try_a.sugar > F) continue;
	if (try_a.v() > next.v()) {
	  next = try_a;
	}
      }   
      
      rep(i, 2) {
	A try_a(cur.water, cur.sugar + sugars[i]);
	try_a.print();
	if (try_a.sugar * 100 > try_a.water * E) continue;
	if (try_a.water + try_a.sugar > F) continue;
	if (try_a.v() > next.v()) {
	  next = try_a;
	}
      }
      
      next.print();
      if (next.v() == -1) return ans;
      cur = next;
      dump_l(cur.v());
      dump_l(ans.v());
      if (cur.v() > ans.v()) {
	ans = cur;
	cout << "ans : ";
	ans.print();
      }
    }
  }

  void solve() {
    rep(i, 2) cin >> waters[i];
    rep(i, 2) cin >> sugars[i];    
    cin >> E >> F;
    A ans_v = ans();
    ans_v.print();
  }
};
 
signed main()
{
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {
  //   auto ptr = new Solver();
  //   ptr->solve();
  //   delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'
 


Compiler output:
a.cc:1:3: error: 'string' does not name a type
    1 |   string res = input;
      |   ^~~~~~
a.cc:2:10: error: expected constructor, destructor, or type conversion before '(' token
    2 |   reverse(all(res));
      |          ^
a.cc:3:3: error: expected unqualified-id before 'return'
    3 |   return res;
      |   ^~~~~~
a.cc:4:1: error: expected declaration before '}' token
    4 | }
      | ^
a.cc: In member function 'void A::print()':
a.cc:35:5: error: 'cout' was not declared in this scope
   35 |     cout << water + sugar << " " << sugar << endl;
      |     ^~~~
a.cc:35:46: error: 'endl' was not declared in this scope
   35 |     cout << water + sugar << " " << sugar << endl;
      |                                              ^~~~
a.cc: In member function 'A Solver::ans()':
a.cc:55:11: error: 'i' was not declared in this scope
   55 |       rep(i, 2) {
      |           ^
a.cc:55:7: error: 'rep' was not declared in this scope
   55 |       rep(i, 2) {
      |       ^~~
a.cc:78:7: error: 'dump_l' was not declared in this scope
   78 |       dump_l(cur.v());
      |       ^~~~~~
a.cc:82:9: error: 'cout' was not declared in this scope
   82 |         cout << "ans : ";
      |         ^~~~
a.cc: In member function 'void Solver::solve()':
a.cc:89:9: error: 'i' was not declared in this scope
   89 |     rep(i, 2) cin >> waters[i];
      |         ^
a.cc:89:5: error: 'rep' was not declared in this scope
   89 |     rep(i, 2) cin >> waters[i];
      |     ^~~
a.cc:91:5: error: 'cin' was not declared in this scope
   91 |     cin >> E >> F;
      |     ^~~
a.cc: In function 'int main()':
a.cc:99:3: error: 'cout' was not declared in this scope
   99 |   cout << fixed << setprecision(20);
      |   ^~~~
a.cc:99:11: error: 'fixed' was not declared in this scope
   99 |   cout << fixed << setprecision(20);
      |           ^~~~~
a.cc:99:20: error: 'setprecision' was not declared in this scope
   99 |   cout << fixed << setprecision(20);
      |                    ^~~~~~~~~~~~