Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

const int64_t MOD = std::pow(10, 9) + 7;

int64_t ModInv(int64_t a, int64_t m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    std::swap(a, b);
    u -= t * v;
    std::swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

int64_t Result(int64_t a, int64_t b) {
  a %= MOD;
  return a * ModInv(b, MOD) % MOD;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t b, w;
  cin >> b >> w;
  int64_t result_x, result_y;
  int64_t y_1 = 1, y_2 = 1;
  for (int64_t i = 1; i <= b + w; i++) {
    if (i <= w) {
      cout << 500000004 << endl;
    } else if (i == w + 1) {
      result_x = 1;
      for (int64_t j = 0; j < i; j++) {
        result_x *= 2;
        result_x %= MOD;
      }
      for (int64_t j = 1; j <= w; j++) {
        result_x *= j;
        result_x %= MOD;
        y_2 *= j;
        y_2 %= MOD;
      }
      for (int64_t j = 1; j <= i - 1 - w; j++) {
        result_x *= j;
        result_x %= MOD;
        y_2 *= j;
        y_2 %= MOD;
      }
      for (int64_t j = 1; j <= i - 1; j++) {
        y_2 *= 2;
        y_2 %= MOD;
      }
      for (int64_t j = 1; j <= i - 1; j++) {
        y_1 *= j;
        y_1 %= MOD;
      }
      result_y = y_1 + y_2;
      result_y %= MOD;
      // cerr << "\033[93m" << result_y << "\033[m" << endl;
      // cerr << "\033[93m" << result_x << "\033[m" << endl;
      cout << Result(result_y, result_x) << endl;
    } else {
      result_x *= 2;
      result_x %= MOD;
      result_x *= (i - 1 - w);
      result_x %= MOD;
      y_1 *= (i - 1);
      y_1 %= MOD;
      y_2 *= 2;
      y_2 %= MOD;
      y_2 *= (i - 1 - w);
      y_2 %= MOD;
      result_y = y_1 + y_2;
      result_y %= MOD;
      // cerr << "\033[93m" << result_y << "\033[m" << endl;
      // cerr << "\033[93m" << result_x << "\033[m" << endl;
      cout << Result(result_y, result_x) << endl;
    }
    // cerr << "===" << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int64_t ModInv(int64_t, int64_t)':
a.cc:27:14: error: no matching function for call to 'swap(int64_t&, long long int&)'
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/stdexcept:38,
                 from /usr/include/c++/14/system_error:43,
                 from /usr/include/c++/14/bits/ios_base.h:46,
                 from /usr/include/c++/14/iomanip:42,
                 from a.cc:5:
/usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
/usr/include/c++/14/bits/exception_ptr.h:229:25: note:   no known conversion for argument 1 from 'int64_t' {aka 'long int'} to 'std::__exception_ptr::exception_ptr&'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |          ~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   deduced conflicting types for parameter '_Tp' ('long int' and 'long long int')
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
  250 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~
/usr/include/c++/14/bits/move.h:250:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types '_Tp [_Nm]' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
 1089 |     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::pair<_T1, _T2>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
 1106 |     swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::pair<_T1, _T2>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/deque:66,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_deque.h:2370:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(deque<_Tp, _Alloc>&, deque<_Tp, _Alloc>&)'
 2370 |     swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_deque.h:2370:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::deque<_Tp, _Alloc>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/deque:81:
/usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)'
 2805 |     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
      |     ^~~~
/usr/include/c++/14/tuple:2805:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
/usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted)
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
/usr/include/c++/14/tuple:2823:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41:
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 4039 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/map:62,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_tree.h:1675:5: note: candidate: 'template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> void std::swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)'
 1675 |     swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_tree.h:1675:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/map:63:
/usr/include/c++/14/bits/stl_map.h:1586:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(map<_Key, _Tp, _Compare, _Allocator>&, map<_Key, _Tp, _Compare, _Allocator>&)'
 1586 |     swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_map.h:1586:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::map<_Key, _Tp, _Compare, _Allocator>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/map:64:
/usr/include/c++/14/bits/stl_multimap.h:1208:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(multimap<_Key, _Tp, _Compare, _Allocator>&, multimap<_Key, _Tp, _Compare, _Allocator>&)'
 1208 |     swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_multimap.h:1208:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::multimap<_Key, _Tp, _Compare, _Allocator>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/queue:63,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(vector<_Tp, _Alloc>&, vector<_Tp, _Alloc>&)'
 2122 |     swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_vector.h:2122:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::vector<_Tp, _Alloc>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/queue:66:
/usr/include/c++/14/bits/stl_queue.h:445:5: note: candidate: 'template<class _Tp, class _Seq> typename std::enable_if<std::__is_swappable<_T2>::value>::type std::swap(queue<_Tp, _Seq>&, queue<_Tp, _Seq>&)'
  445 |     swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_queue.h:445:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::queue<_Tp, _Seq>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_queue.h:834:5: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> typename std::enable_if<std::__and_<std::__is_swappable<_T2>, std::__is_swappable<_Compare> >::value>::type std::swap(priority_queue<_Tp, _Sequence, _Compare>&, priority_queue<_Tp, _Sequence, _Compare>&)'
  834 |     swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_queue.h:834:5: note:   template argument deduction/substitution failed:
a.cc:27:14: note:   mismatched types 'std::priority_queue<_Tp, _Sequence, _Compare>' and 'int64_t' {aka 'long int'}
   27 |     std::swap(a, b);
      |     ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/set:63,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_set.h:1061:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> void std::swap(set<_Key, _Compare, _Allocator>&, set<_Key, _Compare, _Allocator>&)'
 1061 |     swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits