QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745094#6435. Paimon Segment TreemaspyAC ✓365ms15364kbC++2325.0kb2024-11-14 04:09:162024-11-14 04:09:16

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 04:09:16]
  • 评测
  • 测评结果:AC
  • 用时:365ms
  • 内存:15364kb
  • [2024-11-14 04:09:16]
  • 提交

answer

#line 1 "library/my_template.hpp"
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;

template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define vv(type, name, h, ...) \
  vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)   \
  vector<vector<vector<type>>> name( \
      h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)       \
  vector<vector<vector<vector<type>>>> name( \
      a, vector<vector<vector<type>>>(       \
             b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define FOR4_R(i, a, b, c) for (ll i = (b)-1; i >= ll(a); i -= (c))
#define overload4(a, b, c, d, e, ...) e
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) \
  overload4(__VA_ARGS__, FOR4_R, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) for (ll t = s; t >= 0; t = (t == 0 ? -1 : (t - 1) & s))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

template <typename T>
T SUM(vector<T> &A) {
  T sum = T(0);
  for (auto &&a: A) sum += a;
  return sum;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T, typename U>
T ceil(T x, U y) {
  return (x > 0 ? (x + y - 1) / y : x / y);
}

template <typename T, typename U>
T floor(T x, U y) {
  return (x > 0 ? x / y : (x - y + 1) / y);
}

template <typename T, typename U>
pair<T, T> divmod(T x, U y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

ll binary_search(function<bool(ll)> check, ll ok, ll ng) {
  assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    if (check(x))
      ok = x;
    else
      ng = x;
  }
  return ok;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

vi s_to_vi(const string &S, char first_char) {
  vi A(S.size());
  FOR(i, S.size()) { A[i] = S[i] - first_char; }
  return A;
}

template <typename T>
vector<T> cumsum(vector<T> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

template <typename CNT, typename T>
vc<CNT> bincount(const vc<T> &A, int size) {
  vc<CNT> C(size);
  for (auto &&x: A) { ++C[x]; }
  return C;
}

template <typename T>
vector<int> argsort(const vector<T> &A) {
  // stable
  vector<int> ids(A.size());
  iota(all(ids), 0);
  sort(all(ids),
       [&](int i, int j) { return A[i] < A[j] || (A[i] == A[j] && i < j); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  int n = len(A);
  assert(len(I) == n);
  vc<T> B(n);
  FOR(i, n) B[i] = A[I[i]];
  return B;
}
#line 1 "library/other/io.hpp"
// based on yosupo's fastio
#include <unistd.h>

namespace detail {
template <typename T, decltype(&T::is_modint) = &T::is_modint>
std::true_type check_value(int);
template <typename T>
std::false_type check_value(long);
} // namespace detail

template <typename T>
struct is_modint : decltype(detail::check_value<T>(0)) {};
template <typename T>
using is_modint_t = enable_if_t<is_modint<T>::value>;
template <typename T>
using is_not_modint_t = enable_if_t<!is_modint<T>::value>;

struct Scanner {
  FILE *fp;
  char line[(1 << 15) + 1];
  size_t st = 0, ed = 0;
  void reread() {
    memmove(line, line + st, ed - st);
    ed -= st;
    st = 0;
    ed += fread(line + ed, 1, (1 << 15) - ed, fp);
    line[ed] = '\0';
  }
  bool succ() {
    while (true) {
      if (st == ed) {
        reread();
        if (st == ed) return false;
      }
      while (st != ed && isspace(line[st])) st++;
      if (st != ed) break;
    }
    if (ed - st <= 50) {
      bool sep = false;
      for (size_t i = st; i < ed; i++) {
        if (isspace(line[i])) {
          sep = true;
          break;
        }
      }
      if (!sep) reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    while (true) {
      size_t sz = 0;
      while (st + sz < ed && !isspace(line[st + sz])) sz++;
      ref.append(line + st, sz);
      st += sz;
      if (!sz || st != ed) break;
      reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    bool neg = false;
    if (line[st] == '-') {
      neg = true;
      st++;
    }
    ref = T(0);
    while (isdigit(line[st])) { ref = 10 * ref + (line[st++] & 0xf); }
    if (neg) ref = -ref;
    return true;
  }
  template <class T, is_modint_t<T> * = nullptr>
  bool read_single(T &ref) {
    long long val = 0;
    bool f = read_single(val);
    ref = T(val);
    return f;
  }
  bool read_single(double &ref) {
    string s;
    if (!read_single(s)) return false;
    ref = std::stod(s);
    return true;
  }
  bool read_single(char &ref) {
    string s;
    if (!read_single(s) || s.size() != 1) return false;
    ref = s[0];
    return true;
  }
  template <class T>
  bool read_single(vector<T> &ref) {
    for (auto &d: ref) {
      if (!read_single(d)) return false;
    }
    return true;
  }
  template <class T, class U>
  bool read_single(pair<T, U> &p) {
    return (read_single(p.first) && read_single(p.second));
  }
  template <class A, class B, class C>
  bool read_single(tuple<A, B, C> &p) {
    return (read_single(get<0>(p)) && read_single(get<1>(p))
            && read_single(get<2>(p)));
  }
  template <class A, class B, class C, class D>
  bool read_single(tuple<A, B, C, D> &p) {
    return (read_single(get<0>(p)) && read_single(get<1>(p))
            && read_single(get<2>(p)) && read_single(get<3>(p)));
  }
  void read() {}
  template <class H, class... T>
  void read(H &h, T &... t) {
    bool f = read_single(h);
    assert(f);
    read(t...);
  }
  Scanner(FILE *fp) : fp(fp) {}
};

struct Printer {
  Printer(FILE *_fp) : fp(_fp) {}
  ~Printer() { flush(); }

  static constexpr size_t SIZE = 1 << 15;
  FILE *fp;
  char line[SIZE], small[50];
  size_t pos = 0;
  void flush() {
    fwrite(line, 1, pos, fp);
    pos = 0;
  }
  void write(const char &val) {
    if (pos == SIZE) flush();
    line[pos++] = val;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  void write(T val) {
    if (pos > (1 << 15) - 50) flush();
    if (val == 0) {
      write('0');
      return;
    }
    if (val < 0) {
      write('-');
      val = -val; // todo min
    }
    size_t len = 0;
    while (val) {
      small[len++] = char(0x30 | (val % 10));
      val /= 10;
    }
    for (size_t i = 0; i < len; i++) { line[pos + i] = small[len - 1 - i]; }
    pos += len;
  }
  void write(const string &s) {
    for (char c: s) write(c);
  }
  void write(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++) write(s[i]);
  }
  void write(const double &x) {
    ostringstream oss;
    oss << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  void write(const long double &x) {
    ostringstream oss;
    oss << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  template <class T, is_modint_t<T> * = nullptr>
  void write(T &ref) {
    write(ref.val);
  }
  template <class T>
  void write(const vector<T> &val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  template <class T, class U>
  void write(const pair<T, U> &val) {
    write(val.first);
    write(' ');
    write(val.second);
  }
  template <class A, class B, class C>
  void write(const tuple<A, B, C> &val) {
    auto &[a, b, c] = val;
    write(a), write(' '), write(b), write(' '), write(c);
  }
  template <class A, class B, class C, class D>
  void write(const tuple<A, B, C, D> &val) {
    auto &[a, b, c, d] = val;
    write(a), write(' '), write(b), write(' '), write(c), write(' '), write(d);
  }
  template <class A, class B, class C, class D, class E>
  void write(const tuple<A, B, C, D, E> &val) {
    auto &[a, b, c, d, e] = val;
    write(a), write(' '), write(b), write(' '), write(c), write(' '), write(d), write(' '), write(e);
  }
  template <class A, class B, class C, class D, class E, class F>
  void write(const tuple<A, B, C, D, E, F> &val) {
    auto &[a, b, c, d, e, f] = val;
    write(a), write(' '), write(b), write(' '), write(c), write(' '), write(d), write(' '), write(e), write(' '), write(f);
  }
  template <class T, size_t S>
  void write(const array<T, S> &val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  void write(i128 val) {
    string s;
    bool negative = 0;
    if(val < 0){
      negative = 1;
      val = -val;
    }
    while (val) {
      s += '0' + int(val % 10);
      val /= 10;
    }
    if(negative) s += "-";
    reverse(all(s));
    if (len(s) == 0) s = "0";
    write(s);
  }
};

Scanner scanner = Scanner(stdin);
Printer printer = Printer(stdout);

void flush() { printer.flush(); }
void print() { printer.write('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  printer.write(head);
  if (sizeof...(Tail)) printer.write(' ');
  print(forward<Tail>(tail)...);
}

void read() {}
template <class Head, class... Tail>
void read(Head &head, Tail &... tail) {
  scanner.read(head);
  read(tail...);
}

#define INT(...)   \
  int __VA_ARGS__; \
  read(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  read(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  read(__VA_ARGS__)
#define CHAR(...)      \
  char __VA_ARGS__; \
  read(__VA_ARGS__)
#define DBL(...)      \
  double __VA_ARGS__; \
  read(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 2 "library/mod/modint.hpp"
template <u32 mod>
struct modint {
  static constexpr bool is_modint = true;
  u32 val;
  constexpr modint(const ll val = 0) noexcept
      : val(val >= 0 ? val % mod : (mod - (-val) % mod) % mod) {}
  bool operator<(const modint &other) const {
    return val < other.val;
  } // To use std::map
  modint &operator+=(const modint &p) {
    if ((val += p.val) >= mod) val -= mod;
    return *this;
  }
  modint &operator-=(const modint &p) {
    if ((val += mod - p.val) >= mod) val -= mod;
    return *this;
  }
  modint &operator*=(const modint &p) {
    val = (u32)(1LL * val * p.val % mod);
    return *this;
  }
  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }
  modint operator-() const { return modint(get_mod() - val); }
  modint operator+(const modint &p) const { return modint(*this) += p; }
  modint operator-(const modint &p) const { return modint(*this) -= p; }
  modint operator*(const modint &p) const { return modint(*this) *= p; }
  modint operator/(const modint &p) const { return modint(*this) /= p; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  modint inverse() const {
    int a = val, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b), swap(u -= t * v, v);
    }
    return modint(u);
  }
  modint pow(int64_t n) const {
    modint ret(1), mul(val);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  static constexpr u32 get_mod() { return mod; }
};

struct ArbitraryModInt {
  static constexpr bool is_modint = true;
  u32 val;
  ArbitraryModInt() : val(0) {}
  ArbitraryModInt(int64_t y)
      : val(y >= 0 ? y % get_mod()
                   : (get_mod() - (-y) % get_mod()) % get_mod()) {}
  bool operator<(const ArbitraryModInt &other) const {
    return val < other.val;
  } // To use std::map<ArbitraryModInt, T>
  static u32 &get_mod() {
    static u32 mod = 0;
    return mod;
  }
  static void set_mod(int md) { get_mod() = md; }
  ArbitraryModInt &operator+=(const ArbitraryModInt &p) {
    if ((val += p.val) >= get_mod()) val -= get_mod();
    return *this;
  }
  ArbitraryModInt &operator-=(const ArbitraryModInt &p) {
    if ((val += get_mod() - p.val) >= get_mod()) val -= get_mod();
    return *this;
  }
  ArbitraryModInt &operator*=(const ArbitraryModInt &p) {
    unsigned long long a = (unsigned long long)val * p.val;
    unsigned xh = (unsigned)(a >> 32), xl = (unsigned)a, d, m;
    asm("divl %4; \n\t" : "=a"(d), "=d"(m) : "d"(xh), "a"(xl), "r"(get_mod()));
    val = m;
    return *this;
  }
  ArbitraryModInt &operator/=(const ArbitraryModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ArbitraryModInt operator-() const { return ArbitraryModInt(get_mod() - val); }
  ArbitraryModInt operator+(const ArbitraryModInt &p) const {
    return ArbitraryModInt(*this) += p;
  }
  ArbitraryModInt operator-(const ArbitraryModInt &p) const {
    return ArbitraryModInt(*this) -= p;
  }
  ArbitraryModInt operator*(const ArbitraryModInt &p) const {
    return ArbitraryModInt(*this) *= p;
  }
  ArbitraryModInt operator/(const ArbitraryModInt &p) const {
    return ArbitraryModInt(*this) /= p;
  }
  bool operator==(const ArbitraryModInt &p) const { return val == p.val; }
  bool operator!=(const ArbitraryModInt &p) const { return val != p.val; }
  ArbitraryModInt inverse() const {
    int a = val, b = get_mod(), u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b), swap(u -= t * v, v);
    }
    return ArbitraryModInt(u);
  }
  ArbitraryModInt pow(int64_t n) const {
    ArbitraryModInt ret(1), mul(val);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
};

template <typename mint>
tuple<mint, mint, mint> get_factorial_data(int n) {
  static const int mod = mint::get_mod();
  assert(0 <= n && n < mod);
  static vector<mint> fact = {1, 1};
  static vector<mint> fact_inv = {1, 1};
  static vector<mint> inv = {0, 1};
  while (len(fact) <= n) {
    int k = len(fact);
    fact.eb(fact[k - 1] * mint(k));
    auto q = ceil(mod, k);
    int r = k * q - mod;
    inv.eb(inv[r] * mint(q));
    fact_inv.eb(fact_inv[k - 1] * inv[k]);
  }
  return {fact[n], fact_inv[n], inv[n]};
}

template <typename mint>
mint fact(int n) {
  static const int mod = mint::get_mod();
  assert(0 <= n);
  if (n >= mod) return 0;
  return get<0>(get_factorial_data<mint>(n));
}

template <typename mint>
mint fact_inv(int n) {
  static const int mod = mint::get_mod();
  assert(0 <= n && n < mod);
  return get<1>(get_factorial_data<mint>(n));
}

template <typename mint>
mint inv(int n) {
  static const int mod = mint::get_mod();
  assert(0 <= n && n < mod);
  return get<2>(get_factorial_data<mint>(n));
}

template <typename mint, bool large = false>
mint C(ll n, ll k) {
  assert(n >= 0);
  if (k < 0 || n < k) return 0;
  if (!large) return fact<mint>(n) * fact_inv<mint>(k) * fact_inv<mint>(n - k);
  k = min(k, n - k);
  mint x(1);
  FOR(i, k) { x *= mint(n - i); }
  x *= fact_inv<mint>(k);
  return x;
}

template <typename mint, bool large = false>
mint C_inv(ll n, ll k) {
  assert(n >= 0);
  assert(0 <= k && k <= n);
  if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k);
  return mint(1) / C<mint, 1>(n, k);
}

using modint107 = modint<1000000007>;
using modint998 = modint<998244353>;
using amint = ArbitraryModInt;
#line 2 "library/ds/lazysegtree.hpp"

template <typename Lazy>
struct LazySegTree {
  using Monoid_X = typename Lazy::X_structure;
  using Monoid_A = typename Lazy::A_structure;
  using X = typename Monoid_X::value_type;
  using A = typename Monoid_A::value_type;
  int n, log, size;
  vc<X> dat;
  vc<A> laz;

  LazySegTree() : LazySegTree(0) {}
  LazySegTree(int n) : LazySegTree(vc<X>(n, Monoid_X::unit())) {}
  LazySegTree(vc<X> v) : n(len(v)) {
    log = 1;
    while ((1 << log) < n) ++log;
    size = 1 << log;
    dat.assign(size << 1, Monoid_X::unit());
    laz.assign(size, Monoid_A::unit());
    FOR(i, n) dat[size + i] = v[i];
    FOR3_R(i, 1, size) update(i);
  }

  void reset() {
    fill(all(dat), Monoid_X::unit());
    fill(all(laz), Monoid_A::unit());
  }

  void reset(const vc<X>& v) {
    assert(len(v) == n);
    reset();
    FOR(i, n) dat[size + i] = v[i];
    FOR3_R(i, 1, size) update(i);
  }

  void update(int k) { dat[k] = Monoid_X::op(dat[2 * k], dat[2 * k + 1]); }

  void all_apply(int k, A a) {
    dat[k] = Lazy::act(dat[k], a);
    if (k < size) laz[k] = Monoid_A::op(laz[k], a);
  }

  void push(int k) {
    all_apply(2 * k, laz[k]);
    all_apply(2 * k + 1, laz[k]);
    laz[k] = Monoid_A::unit();
  }

  void set(int p, X x) {
    assert(0 <= p && p < n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    dat[p] = x;
    for (int i = 1; i <= log; i++) update(p >> i);
  }

  X get(int p) {
    assert(0 <= p && p < n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    return dat[p];
  }

  vc<X> get_all() {
    FOR(i, size) push(i);
    return {dat.begin() + size, dat.begin() + size + n};
  }

  X prod(int l, int r) {
    assert(0 <= l && l <= r && r <= n);
    if (l == r) return Monoid_X::unit();

    l += size;
    r += size;

    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push((r - 1) >> i);
    }

    X xl = Monoid_X::unit(), xr = Monoid_X::unit();
    while (l < r) {
      if (l & 1) xl = Monoid_X::op(xl, dat[l++]);
      if (r & 1) xr = Monoid_X::op(dat[--r], xr);
      l >>= 1;
      r >>= 1;
    }

    return Monoid_X::op(xl, xr);
  }

  X prod_all() { return dat[1]; }

  void apply(int p, A a) {
    assert(0 <= p && p < n);
    p += size;
    dat[p] = Lazy::act(dat[p], a);
    for (int i = 1; i <= log; i++) update(p >> i);
  }

  void apply(int l, int r, A a) {
    assert(0 <= l && l <= r && r <= n);
    if (l == r) return;

    l += size;
    r += size;

    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push((r - 1) >> i);
    }

    {
      int l2 = l, r2 = r;
      while (l < r) {
        if (l & 1) all_apply(l++, a);
        if (r & 1) all_apply(--r, a);
        l >>= 1;
        r >>= 1;
      }
      l = l2;
      r = r2;
    }

    for (int i = 1; i <= log; i++) {
      if (((l >> i) << i) != l) update(l >> i);
      if (((r >> i) << i) != r) update((r - 1) >> i);
    }
  }

  template <typename C>
  int max_right(C& check, int l) {
    assert(0 <= l && l <= n);
    assert(check(Monoid_X::unit()));
    if (l == n) return n;
    l += size;
    for (int i = log; i >= 1; i--) push(l >> i);
    X sm = Monoid_X::unit();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!check(Monoid_X::op(sm, dat[l]))) {
        while (l < size) {
          push(l);
          l = (2 * l);
          if (check(Monoid_X::op(sm, dat[l]))) {
            sm = Monoid_X::op(sm, dat[l]);
            l++;
          }
        }
        return l - size;
      }
      sm = Monoid_X::op(sm, dat[l]);
      l++;
    } while ((l & -l) != l);
    return n;
  }

  template <typename C>
  int min_left(C& check, int r) {
    assert(0 <= r && r <= n);
    assert(check(Monoid_X::unit()));
    if (r == 0) return 0;
    r += size;
    for (int i = log; i >= 1; i--) push((r - 1) >> i);
    X sm = Monoid_X::unit();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!check(Monoid_X::op(dat[r], sm))) {
        while (r < size) {
          push(r);
          r = (2 * r + 1);
          if (check(Monoid_X::op(dat[r], sm))) {
            sm = Monoid_X::op(dat[r], sm);
            r--;
          }
        }
        return r + 1 - size;
      }
      sm = Monoid_X::op(dat[r], sm);
    } while ((r & -r) != r);
    return 0;
  }

  void debug() { print("lazysegtree getall:", get_all()); }
};
#line 5 "main.cpp"

using mint = modint107;

struct MonoX {
  using value_type = tuple<mint, mint, mint, mint>;
  using X = value_type;
  static X op(X& x, X& y) {
    auto& [x0, x1, x2, x3] = x;
    auto& [y0, y1, y2, y3] = y;
    return {x0 + y0, x1 + y1, x2 + y2, x3 + y3};
  }
  static constexpr X unit() { return {0, 0, 0, 0}; }
  static constexpr bool commute = 1;
};

struct MonoA {
  // (4,4) 行列なのだが、1~3行目を圧縮して、4個組にする
  using value_type = tuple<mint, mint, mint, mint>;
  using X = value_type;
  static X op(X& x, X& y) {
    auto& [xa, xb, xc, xd] = x;
    auto& [ya, yb, yc, yd] = y;
    return {xa + ya, yb + yc * xa + yd * xa * xa + xb, yc + yd * (xa + xa) + xc,
            yd + xd};
  }
  static constexpr X unit() { return {0, 0, 0, 0}; }
  static X from_x(mint k) { return {k, k * k, k + k, mint(1)}; }
  static constexpr bool commute = 0;
};

struct Lazy {
  using MX = MonoX;
  using MA = MonoA;
  using X_structure = MX;
  using A_structure = MA;
  using X = typename MX::value_type;
  using A = typename MA::value_type;
  static X act(const X& x, const A& aa) {
    auto [x0, x1, x2, x3] = x;
    auto [a, b, c, d] = aa;
    return {x0, a * x0 + x1, a * a * x0 + (a + a) * x1 + x2,
            b * x0 + c * x1 + d * x2 + x3};
  }
};

void solve() {
  LL(N, M, Q);
  VEC(mint, A, N);

  using T = tuple<ll, ll, ll, ll>;
  vc<T> CHANGE(M + 1);
  vvc<T> CALC(M + 1);
  FOR(i, M) {
    LL(l, r, x);
    CHANGE[i] = {--l, r, x, 0};
  }
  FOR(q, Q) {
    LL(x, y, l, r);
    --l, --x;
    CALC[r].eb(x, y, 1, q);
    if (l != -1) CALC[l].eb(x, y, -1, q);
  }

  vc<mint> ANS(Q);

  vc<typename MonoX::value_type> seg_raw(N);
  FOR(i, N) {
    mint a = A[i];
    seg_raw[i] = {mint(1), a, a * a, a * a};
  }
  LazySegTree<Lazy> seg(seg_raw);

  FOR(m, M + 1) {
    for (auto&& [x, y, cf, q]: CALC[m]) {
      auto s = seg.prod(x, y);
      ANS[q] += mint(cf) * get<3>(s);
    }
    if (m == M) break;
    auto [l, r, x, _] = CHANGE[m];
    seg.apply(0, l, MonoA::from_x(0));
    seg.apply(l, r, MonoA::from_x(x));
    seg.apply(r, N, MonoA::from_x(0));
  }
  for (auto&& x: ANS) print(x);
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(15);

  // LL(T);
  ll T = 1;
  FOR(T) solve();

  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3512kb

input:

3 1 1
8 1 6
2 3 2
2 2 0 0

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

4 3 3
2 3 2 2
1 1 6
1 3 3
1 3 6
2 2 2 3
1 4 1 3
4 4 2 3

output:

180
825
8

result:

ok 3 number(s): "180 825 8"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

100 107 180
-280960553 266308104 -997644864 856103777 592874377 674379235 -946339772 641750362 642418716 -360811715 -555543246 206614021 358239245 349842656 983198973 807518446 -66612455 -980932737 109826132 -109676067 51226145 452115561 -42729559 -950621304 -87009773 714026474 375317493 693260053 -...

output:

400489222
480617351
531108525
254983761
446689548
764223236
142229431
307405789
39817281
66225912
247029353
46506707
529135498
578008236
201809860
674078444
746060191
171471121
722471473
657196163
861551838
606551808
360903956
401221326
767571915
669762004
163759234
141144218
579174939
276557168
518...

result:

ok 180 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

295 269 129
-210918287 343352194 936488821 -682920910 944685019 677819690 -913857474 643356008 215752838 -582778677 735744580 307969642 807954422 388654459 761031712 -978166251 65058102 236039317 -205619898 -79984863 977152006 79198370 -999053192 -933631858 -776338105 -988909566 -427172257 -83477275...

output:

618251287
899907228
531858556
882858895
725455126
938410366
816431580
6908535
24554323
39964258
545169468
118739750
324108277
57969570
909045869
771733081
78663884
765348479
855417630
840946863
849560917
792963883
68199493
607258525
976267825
554521243
921526613
189188489
544501166
169313970
7657692...

result:

ok 129 numbers

Test #5:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

290 130 153
467014672 -187494410 -834410250 -221945583 -113569812 976227414 823657567 644961655 -718120549 900287103 634923088 999259803 -742330414 114542837 -69026244 941181808 998903438 650836591 381792036 -50293659 -391889416 -588686091 44623189 -916642412 -368524388 505979642 770338007 734336505...

output:

205306195
913174634
627098553
583511289
53628555
776119748
741459303
361721232
792181766
998349032
63183274
449140540
772865125
869222155
83821401
342565107
772194112
208578315
473166159
924882996
534863573
359442652
252396430
259427632
357792582
605715971
225467777
31224502
410770535
77000480
73685...

result:

ok 153 numbers

Test #6:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

184 292 178
-560085111 986691728 196865471 -958795491 238240831 979667868 -848892877 351600031 -849819158 973287410 -73789099 492724730 509559542 743289180 3773764 -844502889 -869426018 770666596 66346005 -20602454 534036445 135538767 -911700444 -604685696 942147293 -607021858 -32151743 -793696299 -...

output:

858202984
433975321
69198683
98775914
749936095
716134874
281147731
186709890
903234421
920600352
323335030
69435264
896305275
257633690
55255202
182091822
935500760
726305425
381037995
804018605
478673738
484297808
286861521
10149069
594778768
547188580
540808257
427373166
853802061
768386487
90138...

result:

ok 178 numbers

Test #7:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

179 152 127
117847849 -936264195 130999142 -202852895 885018743 -721924420 -816410579 353205678 -686550496 751320448 -174610592 889047621 959274719 469177558 -826284192 779877900 64419317 -814536143 -249100025 -793086029 262137073 -237378424 739866630 -587696250 -42148309 887867350 -834641493 -26761...

output:

505009166
348176298
768846383
639656852
767297876
334028836
672141959
865320262
32468111
824990615
935878450
39788029
776229057
745398975
622480518
927354339
667485118
767183633
797234162
637335006
725843572
397083849
891541202
474690368
807830014
546532554
370859947
512952106
797356109
977040750
56...

result:

ok 127 numbers

Test #8:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

173 215 251
482857384 237921943 65132814 -644735533 -173236088 -423516696 921104462 -742330725 886783639 -862755834 -883322779 677479818 -591010117 -902076112 951548559 994193216 -706768090 697403181 338311909 -763394825 -811937079 799769858 -216457003 -570706804 660632678 -520101420 657836040 -4576...

output:

532409264
425334301
297106918
497679015
766180735
997240773
876619970
775627119
369095265
141725042
860632646
806561262
693330436
844811627
533129631
666137230
797776768
349015941
304013406
366877046
285656333
796617951
263787451
188404775
795402622
368862072
922591321
853125733
448636483
903008737
...

result:

ok 251 numbers

Test #9:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

168 151 100
-544242399 314966033 -903591478 -478727476 178574554 -420076241 -751445982 -740725078 -47089749 915277216 112997778 778835439 -141294940 -863264310 121490604 -791491481 834967940 -887799557 22865879 971329122 -475945758 426852667 827219378 -553717358 -28695654 71929823 758204255 14314631...

output:

352187626
704247599
53684196
147547097
652201927
257200097
626135496
49775525
672820311
189599120
469216129
487715787
155787875
856115710
757497826
561926086
567295451
568260936
378849834
906105482
480823862
527730971
133376678
862463926
443893047
318620602
549415798
799707998
458453406
462381509
43...

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

163 213 224
133690560 -215880572 -674490536 -625642844 825352466 -121668517 -718963684 -739119431 -178788357 693310253 307143555 567267636 308420237 862624082 -100676658 -872143435 63780533 -767969553 -587547422 -96121722 155012833 53935476 773753709 560414138 987008757 -433180982 -44285495 48628183...

output:

747432440
517227949
996821749
805271519
840593989
22089777
153536567
999462554
483313583
174809962
671096506
911407220
301225235
350791783
414302958
610922065
348064356
221620487
622546838
251737080
930284090
787053181
512448105
483900137
418446165
774811006
614925836
789232720
98746705
671256184
88...

result:

ok 224 numbers

Test #11:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

258 174 173
-893409223 958305567 -740356864 -459634788 -527869635 176739208 -981448656 967518958 -15519695 176376021 -991503172 668623257 758135414 -508629589 -930734614 -657828118 -707406874 743969771 -902993452 -66430518 -919061319 -613948985 -772504464 577403584 -310210269 158850261 -846775245 55...

output:

763779848
971203287
417629333
128055735
17327247
15630176
25359233
62738585
361956876
281789376
957004306
7982723
694276684
450550861
225480663
650754963
57977660
889194726
638963520
880818703
608956290
276560765
718925350
342938575
243384787
865317875
569251525
302758871
232054208
811410731
1124094...

result:

ok 173 numbers

Test #12:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

224 261 183
321076468 14144917 -964309122 -998152041 -233777241 498830290 -124389333 152924562 100565362 -951633735 -51153541 -539047258 -158691246 266759044 -656520429 -577382886 -383476274 -274905450 -161914533 -572427748 644517420 376447356 -227879896 -972623510 702539156 -675224598 698346506 -17...

output:

322262446
309629779
753522996
746794296
331484522
808430979
727359918
533145896
642265099
611737090
791371384
936246806
480013565
761553227
859970290
114739196
147749092
992690312
222043170
425264912
61368448
532877858
131993381
347759625
310385807
693085135
594668938
342481048
673051834
663459641
1...

result:

ok 183 numbers

Test #13:

score: 0
Accepted
time: 2ms
memory: 3940kb

input:

500 500 500
702413239 -895672661 513406482 -706023315 -811668957 -735208181 -537176715 118033401 207303475 203060235 -140437061 -31133246 -878633428 945167015 -142724367 291023931 895505386 218454358 -658034840 845336331 139891825 -182393293 -837703814 -429556732 -291437105 -281345565 -660666794 132...

output:

799094138
146472194
58171908
40775791
547185279
571631473
320570241
279864315
784754669
36384176
647854975
369168115
86332530
547176983
240323948
240924775
72654152
69035557
647102037
39065205
809733534
122261401
419058965
996509642
840422954
505500073
254560823
567513427
197957750
174710109
8980857...

result:

ok 500 numbers

Test #14:

score: 0
Accepted
time: 2ms
memory: 3776kb

input:

500 500 500
-124873923 -862644826 -949273940 266876915 -439657598 -801074509 -979059352 -940221430 505711199 -59424737 -138831414 -965006634 899399622 -860687221 -649259440 740739108 621393765 291254366 -443719524 -220818346 -348168865 -497839324 -513045340 201401859 -959321566 762330816 -643677348 ...

output:

726058600
157394298
6026295
626157799
473455503
836929915
65432281
223447620
258103506
201786082
245837249
839381477
776736180
495914531
234139152
826978202
609481390
609186653
448424325
37801505
772356936
176131960
94645367
507234205
491293083
51500902
336742281
8572500
581656090
337181638
19093229...

result:

ok 500 numbers

Test #15:

score: 0
Accepted
time: 2ms
memory: 3800kb

input:

500 500 500
-952161085 875415752 980154970 336919180 734528541 525168482 -813051296 -293443518 804118924 -26942438 157741502 608327501 382465389 135633335 -252936549 -809545728 660205567 -538803590 -229404208 -89147789 -228338860 89572610 419503829 224469756 -235096708 -488960087 -626687902 -2683037...

output:

948178708
63043518
412562474
979471847
632004126
197149770
44765001
333070147
209208490
245340835
327984181
86381120
108549140
206693435
696566524
692690063
761978712
63394241
115659288
133306357
949561112
412838504
951662013
614320278
450808891
653747562
528431330
653894325
459172133
26721646
92240...

result:

ok 500 numbers

Test #16:

score: 0
Accepted
time: 2ms
memory: 3908kb

input:

500 500 500
220551766 318509048 -482525453 -985147873 -91285334 164334884 -959966664 58367124 807559378 300507130 -135620121 771596163 160498427 34811843 -759471622 -64863281 -711048103 -466003581 -310056161 844697547 186458414 -225873420 449195033 855428348 -608013899 -837393026 -609698455 13950992...

output:

862364241
846328796
782119369
279661198
954588064
332802857
198320732
828750538
842000005
545677700
631170861
739609232
88580357
709394833
410740136
881387963
388869353
282008286
748754853
160380786
98885674
125774059
463282867
88796885
879824305
396598644
823020688
334851683
682882712
847429599
888...

result:

ok 500 numbers

Test #17:

score: 0
Accepted
time: 2ms
memory: 3764kb

input:

500 500 500
-901702666 351536883 -553096556 -12247644 -14241244 98468556 -793958607 -999887707 -894032910 38022158 -134014475 639897554 -61468536 -968867614 -363148731 -518006068 -985159725 -688170843 -390708115 73510139 601255689 -836286721 478886237 -218645804 724101653 206283354 -592709009 -54981...

output:

879478176
44895837
222778896
299056760
459849951
413838727
271861909
135172325
369876017
772291349
288915506
40518418
120722520
489004058
795467085
440669676
679489168
686147119
484183055
276961468
387433763
227355653
842643573
798414401
667476501
635395856
510642724
792257092
437757870
921878747
36...

result:

ok 500 numbers

Test #18:

score: 0
Accepted
time: 2ms
memory: 3628kb

input:

500 500 500
-23957085 89597448 279190305 665685316 -840055119 -575288467 -332983281 -648077065 -595625186 70504456 -427376098 803166216 324455195 -774721837 -574716534 -363258160 -356413382 186803944 -176392799 -89786574 113194999 -248874787 508577442 412312787 351184462 -750040278 -575719563 465886...

output:

796480339
557837848
754107862
815827346
414562979
472887526
461802193
704671280
150724230
889392203
410794501
355361325
755045478
230684672
469082755
160421817
613888058
880851910
81781514
275777155
469039160
274812243
382134369
90336156
83487675
755510237
502221402
519154393
272454262
984290073
699...

result:

ok 500 numbers

Test #19:

score: 0
Accepted
time: 2ms
memory: 3668kb

input:

500 500 500
-556276977 -974516765 816509895 735727582 629098290 -641154795 -774865919 -1299153 -297217461 397954025 -425770451 -425674441 102488232 221598719 -178393643 86457017 -630525004 259603952 -257044753 844058762 233025004 -564320817 -263906133 -661761365 -21732729 -1331168 -263762847 8736997...

output:

430703521
264296600
450750921
819273205
764437218
898752834
45110599
31736921
270581198
820706868
583121122
706134979
774622614
982742936
341484311
656982673
880764494
460796214
464341544
193506837
403410316
168844313
654226247
921525043
207675841
601386662
604116713
804815031
780918170
556319636
85...

result:

ok 500 numbers

Test #20:

score: 0
Accepted
time: 2ms
memory: 3772kb

input:

500 500 500
321468604 763543813 745938792 -586339472 706142380 -412053853 -313890593 645478759 -293777007 135469053 478693159 -557373050 -119478730 415744497 217929248 536172194 -591713202 -865421273 -42729437 -222095915 647822278 -879766847 -234214929 -933660738 -689617190 -54796837 -246773401 4793...

output:

99643867
797790680
117520301
52202392
750645517
708216290
41516009
835813051
977083646
977651719
730889761
289737413
425913664
845931313
563046428
367920130
455303169
324460957
330372383
916507678
470615106
571780062
981697429
286596333
568468983
29449857
156959753
537748583
968861047
328057384
2612...

result:

ok 500 numbers

Test #21:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

500 500 500
-505818558 206637109 -421774360 681528028 -414638765 619221868 -755773230 -707743342 4630718 167951351 185331536 -689071658 -341445693 -587934960 -288605825 985887371 -865824823 -792621265 -123381391 -90425359 159761589 2612356 -499490994 -302702146 642498362 988879543 -229783955 -504956...

output:

516027113
339960641
489756734
355729464
725784885
222560920
681515130
426514409
475293251
502597154
50178091
756157988
28579538
564199781
754874794
514003796
749624739
289019012
672003817
901814808
7682411
338820429
686389969
644898154
678031469
103954649
681979482
17471041
4440262
543919815
3165571...

result:

ok 500 numbers

Test #22:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

500 500 500
-347877860 527039679 48889269 423854846 -285585489 -909443324 83088136 -755862860 -342498224 -356043217 170471024 325807447 -511588712 -818997308 -358183 -669803979 -595710417 513262231 -929467517 164182054 -462596490 -79245066 345522978 -223646976 595580352 -657224741 -923381515 -895054...

output:

969965606
18264751
629305960
27286696
162768537
126384997
545402051
188094206
407060997
206670050
716310712
535000164
143845354
998379114
177833472
618210301
982753253
633108530
647352469
861145917
616175682
65506261
856210146
100547662
645637137
6039651
576222559
808554231
307695396
592645172
14327...

result:

ok 500 numbers

Test #23:

score: 0
Accepted
time: 237ms
memory: 11256kb

input:

30976 35179 40169
493897111 888600649 -975309652 -653761772 -109084948 -339057770 -323560919 172076671 194108839 -733555675 177323248 -801860526 -220088802 -261931344 291094970 -715152201 295852610 -950657180 -394691096 375214182 -495546348 222663161 -710690410 -906392069 415617168 457144628 -484651...

output:

46341209
997384397
950488515
880577381
375257170
314721120
156703815
783764888
585385783
218371806
505978258
290823773
97757571
88511309
68018513
533033979
269812217
775847487
591945012
740085563
597329525
10424245
181307192
753319789
394603730
546533807
503735790
628994999
34437448
68508764
9516834...

result:

ok 40169 numbers

Test #24:

score: 0
Accepted
time: 233ms
memory: 12180kb

input:

33559 33197 32218
-533202672 62786775 -746208710 102180824 537692964 -40650045 -586045890 -121284952 357377501 -347631944 76501755 -110570365 229626375 -536042966 -243995716 -795804155 -770302067 -535859905 192720838 404905386 135412243 -445221300 332985970 -594435353 -273711164 -47966178 712859087 ...

output:

661408620
883039430
655607633
320305584
608991919
708269037
724364884
648497371
466222603
902610255
682226559
935071350
906857400
102381762
789417646
519996983
269881403
293864597
319515564
124414314
253285433
768530221
25242000
722517507
70496856
933049360
835531898
536069595
902460658
502132452
25...

result:

ok 32218 numbers

Test #25:

score: 0
Accepted
time: 276ms
memory: 11784kb

input:

31025 41512 42008
439697558 434798135 285067011 -634669083 -815529137 257757679 -553563592 783178658 -871463157 -569598907 -632210431 -912072708 384374282 92703376 -466162978 -581488838 -638631510 -121062631 -122725193 -662545458 -938661909 -818138491 786727811 -577445907 134102553 544065066 8132273...

output:

104154550
636719266
672445873
521784998
388849013
403232035
103746236
510001288
922372536
983032201
316241735
486520512
23675597
220393145
956990774
398774286
717153424
157368210
37588637
645574476
532850485
512500425
211278932
8524610
155292579
304469258
183693392
612597955
979616360
783454755
9837...

result:

ok 42008 numbers

Test #26:

score: 0
Accepted
time: 265ms
memory: 13344kb

input:

41050 32087 44355
-882369496 -391015740 219200683 -173693757 -463718495 261198134 -226114024 784784305 996838248 -791565869 -733031924 -220782547 834089459 -476375515 703779079 729968527 295213826 -1232626 -438171223 -337886984 -307703318 808944331 -169595822 -560456461 -555225779 333921530 10737551...

output:

699230737
631303224
680676353
746898772
921147020
508953443
682548856
210051385
134195677
263295351
358416302
102499310
812639565
634746682
598909309
179011382
639567328
228291778
273934347
629893397
161741784
900081127
65142039
108896554
932568448
982588840
694316110
280088865
717518571
761170947
2...

result:

ok 44355 numbers

Test #27:

score: 0
Accepted
time: 227ms
memory: 12628kb

input:

38516 30105 36405
-812327230 -608938920 448301624 287281569 478026687 559605858 -488598996 786389951 865139640 691499911 558255902 -727317620 380946672 152370827 481611818 354349303 -770940852 -489293316 -145726559 -308195780 618222544 436027140 -223061491 -248499745 460478632 630985503 -496784928 -...

output:

132961294
348386401
594429344
364192801
275872392
887837116
492084187
478850839
227154931
362355328
710380954
471717720
215642858
424650813
798378640
752095758
498803711
112670643
881853754
70560672
170211753
123450414
590338715
81179425
730958764
500872481
638525088
27880574
851626964
451862153
700...

result:

ok 36405 numbers

Test #28:

score: 0
Accepted
time: 338ms
memory: 14724kb

input:

48541 48123 46195
160572999 565247218 -520422668 -154601068 829837329 858013583 -456116697 787995598 -971591712 469532948 457434409 -330994728 830661849 -416708064 259444556 568664619 -639270295 -74496041 -461172589 -278504575 346323171 -526824591 820614889 865631750 -836740394 420841968 700725335 -...

output:

378481395
351044147
787515091
732223322
8696638
325218000
258700177
179011676
819069760
903381184
459107749
59531701
6255066
644726995
580640172
153135117
573170083
595056741
668245274
607887910
239626636
750137596
253375172
890538316
159766606
815292452
781106359
332339306
33507190
863901941
912045...

result:

ok 46195 numbers

Test #29:

score: 0
Accepted
time: 303ms
memory: 13436kb

input:

38565 46141 38244
838505959 -260566656 -291321726 11406988 -523384772 861454037 -128667129 494633975 896709693 247565985 -251277777 65328163 -719622987 212038278 -570613400 782979935 294575041 340301234 -481651350 359077323 977281762 -899741782 -430676013 882621197 178964017 -987126802 193202855 -45...

output:

753850336
502252689
802403482
978398393
117851985
798841877
43995632
516285864
579060912
361345165
740413781
441373174
226139974
882322891
827957052
64198003
820220944
442452875
774697027
440917528
63578196
217485523
685698879
159151553
460641308
189366603
841900015
613978928
298106290
566344472
763...

result:

ok 38244 numbers

Test #30:

score: 0
Accepted
time: 312ms
memory: 13364kb

input:

36031 44158 40592
-188593824 111444703 -357188054 -135508380 418360410 -840138252 -391152101 496239621 -332130964 928456987 -352099270 -441206910 -269907810 840784621 -792780662 702327981 -476612366 -442726726 -797097380 388768527 -96792390 727341040 -484141682 -805422100 -510364315 -395095558 -6092...

output:

218099207
441534512
348953852
307702032
199585323
886817307
952366094
373272821
414910543
167557341
794363613
416150824
770487173
167472124
572336401
815720303
364468162
394790493
10323415
127001500
843766306
96603026
480184090
721593917
235716073
894024128
794648367
172306236
816345189
439706791
24...

result:

ok 40592 numbers

Test #31:

score: 0
Accepted
time: 307ms
memory: 13900kb

input:

46056 45031 40084
489339135 -714369171 379120397 325466947 -132686912 -541730527 -358669803 202877998 -463829573 706490024 644221286 -44884019 -115159903 271705729 377161395 916643297 -639909080 -27929451 -504652716 713427002 534166201 59456579 559534698 -788432654 -102550599 -900206364 588223369 -1...

output:

664819303
799746579
923774208
594766628
579158619
983662223
55387977
160414858
808857608
740952408
499027547
434237500
698323449
582287616
36543143
958333643
694916160
319725402
467047755
632374377
8167929
455183029
325233930
586113339
376850009
994136907
626970498
9979936
395110261
982706983
165704...

result:

ok 40084 numbers

Test #32:

score: 0
Accepted
time: 271ms
memory: 13052kb

input:

42419 34754 40219
-81257471 -880283165 -854577525 261470348 -180806430 -888859469 20193593 -909124563 256082263 241379735 413158938 -954461611 524116030 246852865 585902843 110557171 -90334398 -60352991 -291542868 -441559039 -289636592 12538570 913430427 517969798 410209796 -497406597 -357636629 -53...

output:

928070962
853950805
542939619
982613561
794645945
212795670
871529435
17236586
139226933
817619804
326557170
567618911
739659580
508266934
978468129
547378009
120827330
237229657
556423452
742001152
221768690
298561715
226249912
497497385
25493016
761671683
250057079
779706492
323074294
119412064
72...

result:

ok 40219 numbers

Test #33:

score: 0
Accepted
time: 319ms
memory: 14028kb

input:

39885 45330 42567
596675489 293902973 -625476583 427478405 465971482 -885419014 52675892 -907518916 419350924 19412772 -590520519 -263171450 973831207 -27258756 -539122383 29905218 -548598381 -843380950 -606988899 -411867835 636289269 -360378621 -42893206 534959244 -279118537 -707550133 839873634 -3...

output:

502476096
506934774
952833153
393266087
322134977
776938966
690976245
794548023
559849553
779414963
662675454
256414850
802855538
162511556
455260051
71778548
652326757
707432184
389742096
808591613
604729355
542666837
505957394
493947674
836707756
143276576
934371764
627099456
352932726
949779805
6...

result:

ok 42567 numbers

Test #34:

score: 0
Accepted
time: 303ms
memory: 13956kb

input:

42468 43347 42058
-430424295 -531910901 -691342911 -14404233 -887250619 -587011290 85158190 799119474 287652316 -202554191 -396374742 935326220 -576453629 601487586 -171355105 244220534 680214225 -428583676 -19576965 -382176631 -732752152 971736931 -96358875 551948690 128695180 -410486159 940241848 ...

output:

23667705
172505419
471332034
487482354
51081815
576449668
330671133
107850233
208744607
84722510
849204755
577806670
923783607
716939389
632072588
29738872
763433944
700208199
30561046
101952420
558620702
696997621
652421567
444898639
273125245
320007945
358506981
238545632
693696287
815389780
37015...

result:

ok 42058 numbers

Test #35:

score: 0
Accepted
time: 309ms
memory: 13820kb

input:

39934 41365 44406
-655349299 -454866812 339932809 446571093 -240472707 -583570836 117640488 800725120 450920978 -719488424 599945815 -373383632 -126738451 935266659 703619683 163568580 -385940452 -13786401 -335022995 -352485426 -709684255 303852470 652350235 863905407 -855600422 -915596965 137752098...

output:

556693908
99643681
869465
651413204
907743016
509005791
758173775
81832327
739278689
437746268
510885966
991574019
982417149
723595894
937420340
245214387
870380711
883921055
536231784
521178561
276335686
851435784
357468610
13300817
385244297
777375139
274728175
808208796
924077879
865949191
897231...

result:

ok 44406 numbers

Test #36:

score: 0
Accepted
time: 294ms
memory: 13328kb

input:

49959 42238 36456
612518201 -985713416 569033751 907546420 111337935 -285163111 150122786 802330767 -777919680 -38597422 794091592 -879918705 322976726 661155037 481452421 377883896 -254269895 -796814360 -945436296 580063742 -78725664 -69064721 -598940667 880894853 750038529 -28598451 -664737651 452...

output:

252413152
532119424
406448928
269144049
249582589
519220730
354313721
582284613
953291124
555035962
230819422
302946127
374805829
417162715
571155180
590462404
940453267
261109987
143599243
16721068
389744778
472500517
589256476
537870601
115108721
997191074
477282477
296730974
148082717
928587673
7...

result:

ok 36456 numbers

Test #37:

score: 0
Accepted
time: 323ms
memory: 13696kb

input:

39983 47698 38803
-709548853 188472722 208200153 170696512 -946916896 13244613 182605085 508969143 -909618288 -260564385 85379405 -483595814 -130166061 994934110 -348605535 592199212 974542710 -382017086 -63057092 314787676 552232927 -441981912 -652406336 602917029 -842147767 -533709257 827739882 92...

output:

515602599
840773175
782418
248297677
872540642
793118823
593048288
531378318
401541593
891383103
133384969
371454219
772475679
214356385
473486068
630247370
437364081
180882921
544208093
214356385
292831564
691233913
994048553
279691874
405323791
127202068
479845414
88521425
559627127
60697117
39923...

result:

ok 38803 numbers

Test #38:

score: 0
Accepted
time: 254ms
memory: 11224kb

input:

30007 38273 38295
263351377 265516812 -465556869 926639108 -595106254 16685068 -79879887 805542060 -746349626 -777498618 -310409358 -695163617 24581846 720822488 -570772797 216579988 811245997 -262187081 -378503122 639446151 -521841225 -814899103 391270044 914873745 173556644 58321986 25250132 49396...

output:

312959125
751651242
523591358
382940310
923615456
443417811
723517833
384124779
257474267
614631633
163902128
476695623
363962378
357357459
834983087
855201376
623046498
438620716
937051905
426662914
435639371
224782583
693786506
742154114
341448090
768997127
903736270
664732051
680247267
270893938
...

result:

ok 38295 numbers

Test #39:

score: 0
Accepted
time: 304ms
memory: 14124kb

input:

47475 36290 48085
941284336 -560297062 -531423197 189789201 51671658 315092792 247569681 -584961612 -878048235 -704498311 980878469 -593807996 474297023 -650431183 -497972788 430895304 40058590 -750247771 -693949152 669137355 109117367 517216449 -565053589 931863191 -515771688 650353230 -777239617 -...

output:

736331601
461303388
621211408
206999831
686128835
72823391
396257059
205006948
180309060
671228864
124902281
943884441
596713243
373136061
829767275
463515905
626442460
228494758
280595114
12216258
97538493
201821746
706963996
131531125
813319379
895770026
517084977
90941182
929570558
266860229
1403...

result:

ok 48085 numbers

Test #40:

score: 0
Accepted
time: 242ms
memory: 12380kb

input:

44941 34308 30431
-988673411 -483252973 -597289526 650764527 993416840 613500517 280051979 -583355966 -714779573 -926465273 -22800988 97482165 924012200 780489939 377001999 350243350 973903926 -335450496 -106537219 -398313490 132185264 144299258 -913486527 948852637 187009299 145242424 420270646 -26...

output:

678203604
191590724
727913144
355103440
233633207
639152924
334921232
319823541
765601151
83534178
386820815
800846205
373628171
886661101
224685715
337761600
463174138
260928709
696364993
245691459
254403765
946396169
839196141
302832330
45693002
282324168
671736586
905441918
85229817
870643346
559...

result:

ok 30431 numbers

Test #41:

score: 0
Accepted
time: 338ms
memory: 14756kb

input:

47524 44884 49924
-15773181 985900436 728953465 208881889 -654772531 616940971 17567008 -581750319 -238587487 556600507 171344789 -704020178 -626272636 -590763732 744769277 564558666 -894425531 79346778 -716950519 -368622286 763143855 573556846 130189853 -739190660 -797286303 737273667 -87251834 -99...

output:

814581235
718931323
297723760
833028295
709557033
764991341
44533879
803178657
881187924
796394089
783408721
528684423
60019194
739624667
862850936
70957920
430251722
387029870
734617070
97963166
835904907
119127654
627625478
758270100
45651438
406012443
647099169
148891812
43808501
858322934
374566...

result:

ok 49924 numbers

Test #42:

score: 0
Accepted
time: 287ms
memory: 12052kb

input:

31328 44904 42617
21520906 525019171 -504744456 -952256758 -702892048 564779299 -506427560 -891578101 481324348 -710684561 -962575523 -415772535 -281963973 -320649325 -244314509 -241527459 -934785389 849098018 -503840671 -426466277 -60658938 -570503213 484085581 -335646171 -284525909 42931386 671920...

output:

185780195
274329194
243407060
313613843
308238682
399989560
433786743
252918088
42774324
239780808
286808755
27549098
230579907
900861122
160145833
595559598
278428902
619336579
31088691
432947341
884445910
726849634
334525048
801265998
18613500
813771576
208617668
963623393
652253376
317808904
6152...

result:

ok 42617 numbers

Test #43:

score: 0
Accepted
time: 360ms
memory: 15220kb

input:

50000 50000 50000
674028042 392361958 123922920 91563172 -5827433 -865578055 605860618 -56114136 568219754 -473945262 -889972454 644593010 -932651524 936602997 -922307608 167751204 815304526 -171514501 -27212143 -803114832 -736104720 83571263 506082891 865266923 761612339 -472238051 -318656725 12328...

output:

737969576
10553619
620023180
716422679
219924644
737617398
912695130
306514688
157060903
899492976
27194127
535399030
649491971
560447882
113292414
648548885
533005301
988697279
510038820
373986172
894649465
338936132
388611497
738715407
978774054
506798175
910184557
144751598
303344241
964091520
96...

result:

ok 50000 numbers

Test #44:

score: 0
Accepted
time: 360ms
memory: 15364kb

input:

50000 50000 50000
-153259120 130422523 956209781 769496132 -831641307 165697666 -933164069 590663776 571660208 -441462964 14491157 512894401 550414256 -67076459 -525984717 617466381 -555949145 703460286 -107864097 130730504 -321307446 -231874768 830741365 -503774499 388695148 -525703720 -301667279 -...

output:

871870025
156055780
845980859
738375577
269009227
802638169
721686197
226735856
771120264
522084796
170449908
601160588
456841642
178945926
734158618
658611836
757099522
935334817
762961787
999872735
612803656
317246670
123300527
526486215
715132612
228948906
264677560
994254466
979480855
10335758
2...

result:

ok 50000 numbers

Test #45:

score: 0
Accepted
time: 360ms
memory: 15264kb

input:

50000 50000 50000
724486461 -131516911 885638677 -257603652 -754597218 394798608 329986036 -762558325 870067933 -408980666 -278870467 676163063 328447293 -167897952 967480223 772214288 -830060766 776260294 106451219 -640456903 895664608 -547320798 860432570 127184093 15777957 223005390 -284677833 74...

output:

989576751
271469626
331854599
885693011
770199090
100141589
59080796
651397273
883620703
220848590
743214542
390302738
507783814
793600877
996327406
884142280
497140694
61803127
704786135
232816789
61263940
66431045
291822982
343336669
572349138
811447518
234314935
945876011
580612086
533893125
1041...

result:

ok 50000 numbers

Test #46:

score: 0
Accepted
time: 362ms
memory: 15328kb

input:

50000 50000 50000
-102800701 -393456346 -282074475 420329308 419588921 328932280 -914071381 -410747683 -831524356 -376498367 -277264820 544464455 106480331 -876610139 -636196899 -778070548 -201314424 -348764931 25799265 -803753617 -689538131 -862766828 -501985545 -946890059 445035545 971714501 27278...

output:

688727722
60948626
127327346
15296134
11061227
704966245
109650180
428739874
681485346
633091939
533527374
415453189
736650885
969209089
321893860
329695403
334271407
887485406
778485047
792913742
918682447
743512129
515398461
551424150
430826855
598223639
991117123
562419342
352200613
292717799
219...

result:

ok 50000 numbers

Test #47:

score: 0
Accepted
time: 360ms
memory: 15256kb

input:

50000 50000 50000
-930087863 247462183 255245116 -606770475 -406224954 -344824742 -748063324 530997499 -828083901 -344016069 -570626444 -684376203 -410453902 -977431632 -847764702 768786678 -475426045 -275964923 240114581 425058989 -274740856 -275354894 -472294341 781210581 72118354 15390868 4426832...

output:

945997819
908835721
159596094
927662929
106638943
981434142
273177766
803020351
878999966
61296144
435780293
885677777
315502911
434418211
894373516
644936363
795295559
984902994
524374814
367208839
686259457
826916721
363609672
868635919
602232760
153531821
165491555
684300021
849649412
97430237
26...

result:

ok 50000 numbers

Test #48:

score: 0
Accepted
time: 355ms
memory: 15144kb

input:

50000 50000 50000
242624988 280490019 -110293258 -536728210 -34213594 -410691071 810054051 -822224602 -529676177 -311533771 -569020797 -816074811 565404369 313856195 -746409081 -781498158 -436614243 599009864 159462627 -346128418 -762801546 -590800925 -442603137 -292863571 -595766107 -38074801 61257...

output:

192767965
260136054
290992294
480760301
268229025
215333968
593247471
655071089
39008428
625146457
75162763
434944886
433380927
923630761
251366026
840525965
773189585
261055764
643147097
282868274
96026209
790598352
706360479
632326476
542298673
881488673
190073670
566401763
35915367
790724910
4031...

result:

ok 50000 numbers

Test #49:

score: 0
Accepted
time: 358ms
memory: 15180kb

input:

50000 50000 50000
-879629444 18550584 721993603 436172020 -860027469 -476557399 -728970636 -470413960 -231268452 -279051472 -272447880 -652806149 343437406 213034702 -55118920 -331782980 192132100 671809872 78810673 -509425131 -642971541 -906246955 -117944662 43127750 -968683298 -994398434 373214492...

output:

395336063
588825091
214068731
271315962
788937616
563944155
983790315
148936928
98980418
643311933
198372057
634855134
530230270
346931320
107160709
219653547
24119335
779408199
407694935
218344002
745941931
323989590
712629760
473679839
469727905
30905339
352133400
324025068
237260281
693812105
180...

result:

ok 50000 numbers

Test #50:

score: 0
Accepted
time: 346ms
memory: 15160kb

input:

50000 50000 50000
-1883863 -243388851 651422500 -885895034 -782983379 -247456457 829146740 471331222 -227827998 -246569174 -565809504 -784504758 -173496826 -495677485 -856621263 117932197 -81979522 744609880 293125989 424420205 -228174267 -613802291 814604506 969053612 363432254 -245689323 390203938...

output:

428105572
275939771
437675993
874797861
340550920
275468988
483724528
412730750
533117990
213505312
884073079
755167150
780997605
426933096
717241618
688669890
210583537
743860192
777614486
749651177
758442258
313246374
405302645
683387432
224185432
695430706
599934870
455730309
18094650
749266251
2...

result:

ok 50000 numbers

Test #51:

score: 0
Accepted
time: 361ms
memory: 15348kb

input:

50000 50000 50000
-534203755 -505328285 -811257923 87005196 391202759 783819264 995154796 823141864 70579727 -214086876 -564203857 -621236096 -395463789 -596498978 -165331102 272680104 546766821 -85448075 212474035 261123491 186623008 -929248321 844295710 -399987810 -9484937 -299154992 407193384 507...

output:

595887661
422933791
281766814
113964065
110544176
891999647
621601416
650944521
273426135
905737378
486108697
767512389
916075180
650018768
864820311
353016514
664254150
386719559
929165407
236365734
897843170
549014848
364661856
106860297
536269964
985853102
553295984
720396467
190662315
17368715
9...

result:

ok 50000 numbers

Test #52:

score: 0
Accepted
time: 365ms
memory: 15176kb

input:

50000 50000 50000
720878993 422964979 -340594293 -778558680 -677569199 -744845928 931158198 775022346 -884439909 966951299 28826325 98675739 -860574078 -25386547 925091319 -793076706 -380944007 123293372 798497229 515730903 661406978 -716138474 786451719 776209410 -56402946 349708006 -286404177 -177...

output:

424370819
898014889
118543047
736912097
458772746
58178103
150731182
913387569
624441542
541632503
27906000
788862205
955371708
611885018
447457643
786472080
805379759
325346392
221958339
653692449
692401708
188028282
594467166
602105088
427659005
451554369
494806247
79212830
308358303
265529658
496...

result:

ok 50000 numbers

Test #53:

score: 0
Accepted
time: 361ms
memory: 15144kb

input:

50000 50000 50000
-401375439 161025545 491692567 194341550 -600525109 -810712256 -607866489 -578199755 824033288 999433597 -264535298 869835095 917458972 168759230 -383618533 -638328799 247802335 998268160 717845275 647401460 -923795761 166240730 -280999126 -297864742 -429320137 -901582896 -26941473...

output:

795027632
930172317
609216241
200109886
623598479
443083390
310050599
800740326
398288998
233052387
73893431
775815853
677703782
435802979
267185187
776479650
866505928
122571242
416142913
656191219
353303877
271238861
457466825
117896627
737723286
237396726
733369100
80846583
191141531
398084026
29...

result:

ok 50000 numbers

Test #54:

score: 0
Accepted
time: 362ms
memory: 15060kb

input:

50000 50000 50000
771337412 -100913890 -676020585 872274509 868628299 515530735 -754781856 68578157 25298964 -968084118 32037619 738136486 -401650040 -834920226 814879137 -188613622 581581408 776100898 932160591 -123785947 588143563 -149205300 -546275192 -569764115 607828145 -152873786 42541985 7392...

output:

389059872
543219376
669715865
314960171
353866496
576849433
297852105
688174263
660853317
112291099
646155507
101297410
831223766
917886852
273879085
331369652
245618934
360361278
976984872
82022109
358621448
455306335
638522813
190616247
70142931
840832524
127493693
610335093
13695277
275289430
339...

result:

ok 50000 numbers

Test #55:

score: 0
Accepted
time: 357ms
memory: 15144kb

input:

50000 50000 50000
-350917020 -67886055 -746591688 -154825274 945672389 449664407 -588773800 -187501895 323706688 -935601819 -261324005 901405148 -918584273 -640774449 -493830715 261101555 307469786 -53957058 851508637 810059389 -997059176 -759618601 -516583988 61194476 234910954 -206339455 59531432 ...

output:

951887062
103788627
63546856
227947039
318774282
965301751
736905688
912070602
448613246
438248431
194536974
107753476
121349232
831494932
873609436
251925847
808048653
90328724
885436074
730764402
925772410
472664644
29554110
562640200
467484409
266080551
858075036
167638652
569165451
213951186
276...

result:

ok 50000 numbers

Test #56:

score: 0
Accepted
time: 349ms
memory: 15172kb

input:

50000 50000 50000
-883236912 -329825489 -209272098 -84783009 119858514 678765349 -127798474 164308747 327147143 -903119521 -259718358 769706540 859448778 355546107 999634225 710816732 641248859 -276124320 -934176060 941729945 -877229171 -172206667 -191925513 987120337 -138006237 837336925 76520878 1...

output:

805337669
529161281
847436089
526927147
703366960
703126174
225382246
314689078
815119398
235755261
274474664
551806450
331270950
126307097
977507014
612167659
659117489
385299407
478888698
593346316
310643079
232761071
674908122
742062038
253023722
777785567
277055586
139964128
259711789
633838270
...

result:

ok 50000 numbers

Test #57:

score: 0
Accepted
time: 351ms
memory: 15144kb

input:

50000 50000 50000
-5491331 -591764924 -574810471 593149951 999077383 -289958944 -569681112 -893946084 625554867 -870637223 644745252 932975201 932449085 549691884 -604042897 257673945 367137237 893817737 985171999 -419392002 -462431897 -487652697 740623655 -381921084 -805890698 -413953977 388477594 ...

output:

311391793
661021829
690797548
717883970
435809372
128133467
988112940
695729110
194332160
481958913
809452536
630749954
917636177
285997810
995222227
575792537
140977416
71000404
305926148
491291270
267407706
893473989
773390932
756610864
60338881
845209795
741198421
184072709
692861511
582267087
20...

result:

ok 50000 numbers

Test #58:

score: 0
Accepted
time: 355ms
memory: 15212kb

input:

50000 50000 50000
-832778493 49153605 257476389 -433949832 -923878540 -355825272 -108705785 -247168172 923962592 -543187654 351383629 -590832726 415514852 -453987572 -207720005 707389122 995883580 671650476 904520045 809420604 -950492586 -803098727 770314859 544004777 821192124 -467419646 405467040 ...

output:

644270050
458024629
873867630
333425143
662579180
206390717
140580782
875283987
474707878
1652365
868560326
614453966
259797959
239235096
92504673
84476394
852577013
458740995
486230271
25997410
813354862
125835334
969225614
415291755
330275079
963447034
953344685
105994246
692000742
57486262
366177...

result:

ok 50000 numbers

Test #59:

score: 0
Accepted
time: 359ms
memory: 15352kb

input:

50000 50000 50000
44967088 -212785829 186905286 538950397 545274868 -421691600 -845555693 104642470 927403046 -805672626 352989276 -427564064 193547889 -554809065 -714255078 862137029 721771958 -960582259 -881164652 646123891 -535695312 -510654064 800006064 272105404 448274933 576256734 -775368748 -...

output:

794158355
45852409
200780375
497735628
167392938
273712642
425962026
783983075
713002875
369788525
202932638
162005872
560115519
411129768
252241884
878543837
155508483
591915335
690311019
360432007
339538796
840607568
325589718
417548078
41923625
350824018
587153794
680421682
481745446
696970706
66...

result:

ok 50000 numbers

Test #60:

score: 0
Accepted
time: 353ms
memory: 15292kb

input:

50000 50000 50000
-782320074 -179757994 724224877 608992663 -280539006 609584121 -89613097 -953612361 -774189242 -773190328 59627652 -559262673 -28419073 441511491 -317932187 -688147807 -944448983 -85607472 -961816606 -125063517 -415865307 -531132824 829697268 -801968748 75357742 -380066899 -4634120...

output:

218018094
516251893
764539666
915656938
500395532
285576965
910671667
164766208
440013813
372299757
253797827
389867423
889982996
62594543
146724877
642031695
10177845
251607618
14326601
89403198
936752922
685584945
703208900
561510222
165665846
319391388
997857402
131440140
189052349
428072560
2142...

result:

ok 50000 numbers

Test #61:

score: 0
Accepted
time: 358ms
memory: 15176kb

input:

50000 50000 50000
390392777 -441697428 -443488276 -713074391 -203494917 838685063 -826463004 -601801719 -475781518 -445740760 356200569 -395994011 357504658 635657268 -824467260 -238432630 486472139 -12807464 -747501289 -896250924 -903925997 -846578854 57213693 -171010156 -887493989 -728499837 -4464...

output:

744755394
368192840
408469045
740362685
98137139
172330033
690626518
954389264
830618524
772013015
344976383
332559661
588695624
261071062
753268398
426666297
619488888
914851253
339502883
613250917
227006493
291900791
791805582
615574734
673747197
804978616
380813202
799668685
505530491
897195714
2...

result:

ok 50000 numbers

Test #62:

score: 0
Accepted
time: 356ms
memory: 15324kb

input:

50000 50000 50000
548333476 -416262128 27175354 -380813033 727733138 -689980129 -282568908 -649921237 274231589 -361844634 949230752 323917824 187361639 -498263044 -536219618 105876033 756586545 998108763 741379868 261214452 768683207 -633469006 -295597569 -994812950 -934411999 -79636839 859979867 -...

output:

896232114
339768819
1188782
248681677
202258708
607836632
791614211
624388898
684036744
275925920
794136474
338647050
227294606
510736936
878707585
131233367
958626729
168649908
196919680
449314296
549848214
600294826
340995304
861591565
857009429
211397609
644540989
499953317
861582122
846444921
61...

result:

ok 50000 numbers