#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << '\n'; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin, n, m;
    if (n == 1 &&  m==0) {
        print(1, 2);
        return 0;
    }
    if (m < 0 || m >= n - 1) {
        print(-1);
        return 0;
    }
    if (m == 0) {
        REP(i, 1, n + 1) {
            print(2 * i, 2 * i + 1);
        }
        return 0;
    }

    REP(i, 1, n) {
        int a = 2 * i, b = 2 * i + 1;
        if (i > m + 1) {
            a++;
            b++;
        }
        print(a, b);
    }
    print(1, 2 * (m + 2));
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <cmath>

using ll=long long;
using namespace std;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  //mint inv() const { return pow(mod-2);}

  //supports not prime
  mint modinv(ll a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    mint res(u);
    return res;
}
  mint& operator/=(const mint a) { return *this *= modinv(a.x);}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<mint> fact;
vector<mint> finv;

void comb_init(int n){
    fact=vector<mint>(n+1);
    finv=vector<mint>(n+1);
    fact[0]=1;
    for(int i=1;i<=n;i++){
        fact[i]=fact[i-1]*i;
    }
    finv[0]=1;
    finv[n]=mint(1)/fact[n];
    for(int i=n;i>=2;i--){
        finv[i-1]=finv[i]*i;
    }
}

mint comb(int a,int b){
    return fact[a]*finv[b]*finv[a-b];
}

int main(){
    int N,M,K;
    cin>>N>>M>>K;

    if(N > M+K){
        cout<<0<<endl;
        return 0;
    }

    comb_init(2*N+M+5);

    mint all = fact[N+M]*finv[N]*finv[M];
    mint minus = 0;
    if(N > K){
        minus = fact[N+M]*finv[M+K+1]*finv[N-(K+1)];
    }
    cout<<all-minus<<endl;

    return 0;
}


/*----- || Hare Krishna || -----*/
/*  "WHY DO WE FALL, BRUCE?"  */

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define precision(n) fixed<< showpoint << setprecision(n)
#define elif else if
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384
#define MOD 1000000007
using namespace std;

int lg2(const int &x){return 31 - __builtin_clz(x);}
long long int lg2(const long long int &x){return 63 - __builtin_clzll(x);}

char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

const int N = 300001;
int st[4*N];
int v[N];

void build(int si, int ss, int se){
	if(ss==se){
		st[si]=v[ss];
		return;
	}
	int mid = (ss+se)>>1;
	build(si<<1, ss, mid);
	build(si<<1|1, mid+1, se);
	st[si]=st[si<<1]^st[si<<1|1];
}

void upd(int si, int ss, int se, int val, int idx){
	if(ss==se){
		st[si]^=val;
		return;
	}
	int mid = (ss+se)>>1;
	if(idx<=mid){
		upd(si<<1, ss, mid, val, idx);
	}
	else{
		upd(si<<1|1, mid+1,se, val, idx);
	}
	st[si] = st[si<<1]^st[si<<1|1];
}

int query(int si, int ss, int se, int qs, int qe){

	if(qs>se || qe<ss){
		return 0;
	}

	if(qs<=ss && qe>=se){
		return st[si];
	}

	int mid = (ss+se)>>1;

	return query(si<<1, ss, mid, qs, qe)^query(si<<1|1, mid+1, se, qs, qe);

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n,q;
	cin >> n >> q;
	for(int i=1; i<=n; i++){
		cin >> v[i];
	}
	build(1,1,n);
	while(q--){
		int t,x,y;
		cin >> t >> x >> y;
		if(t==2){
			cout << query(1,1,n,x,y) << endl;
		}
		else{
			upd(1,1,n,y,x);
		}
	}

}

#include<bits/stdc++.h>
using namespace std;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU

void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	off;
}
LL n,q;
VL segtree;
VL arr;
void build(int l, int r, int node){
	if(l == r){
		segtree[node] = arr[l];
		return ;
	}
	LL mid = l + (r - l)/2;
	build(l, mid, 2*node);
	build(mid+1, r, 2*node+1);
	segtree[node] = segtree[2*node] ^ segtree[2*node+1];
}
void update(int l, int r, int node, int ind, int val){
	if(l == r){
		segtree[node] = val;
		return ;
	}
	LL mid = l + (r - l)/2;
	if(ind <= mid)
		update(l, mid, 2*node, ind, val);
	else
		update(mid+1, r, 2*node+1, ind, val);
	segtree[node] = segtree[2*node] ^ segtree[2*node+1];
}
LL query(int l, int r, int gl, int gr, int node){
	if(l > r || l > gr || r < gl)
		return 0;
	if(l >= gl && r <= gr)
		return segtree[node];
	LL mid = l + (r - l)/2;
	return query(l, mid, gl, gr, 2*node)^query(mid+1, r, gl, gr, 2*node+1);
}
int main(){
	IO();
	cin>>n>>q;
	segtree.resize(4*n + 2);
	arr.resize(n);
	rep(i,0,n){
		cin>>arr[i];
	}
	build(0, n-1, 1);
	rep(i,0,q){
		LL t,x,y;
		cin>>t>>x>>y;
		x--;
		if(t == 1){
			update(0, n-1, 1, x, arr[x]);
			arr[x] = arr[x] ^ y;
			update(0, n-1, 1, x, arr[x]);
		}
		else{
			y--;
			dout(query(0, n-1, x, y, 1));
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Rep(i,n) for(ll i=0; i<int(n); ++i)
#define read(v) for (auto &it : v) cin >> it;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(s) s.size()
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define deb(x) cout<<"For debug : "<<x<<endl;
#define min_heap priority_queue<ll,vector<ll>,greater<ll>>
typedef long long ll;
#define ld long double
#define mod 1000000007
#define endl '\n'
const int MXN=1e6+10;

void solve(){
    ld sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;

    // symmetric point (gx,gy): opposite y coordinates
    // if(gy>0) gy=-gy;
    ld ans=(gx*sy+sx*gy)/(sy+gy);

    cout.precision(10);
    cout<<fixed<<ans;
}

int main(){
    optimize();
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int tt=1;
    // scanf("%d",&tt); cin>>tt;
    for(int i=1; i<=tt; i++){
        // cout<<"Case "<<i<<": ";
        solve();
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long LL;

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

  double a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a > c) {
    swap(a, c);
    swap(b, d);
  }
  cout << fixed << setprecision(10) << abs(a - c) * b / (b + d) + a << endl;

  return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << endl;
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if (n & 1) res *= x;
  res %= mod;
  return res;
}

signed main() {
  init();
  ll N, S, D;
  cin >> N >> S >> D;

  rep(i, N) {
    ll x, y;
    cin >> x >> y;
    if (x >= S) continue;
    if (y <= D) continue;
    Yes;
    return 0;
  }
  No;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int n, vis[105], coun;
ld x[105], y[105], r;

inline ld sqr(ld t) {
	return t*t;
}

void dfs(int node) {
	vis[node] = coun;
	FOR(i, 1, n) if (sqr(x[i] - x[node]) + sqr(y[i] - y[node]) < sqr(2*r) and vis[i] == -1) dfs(i);
}

bool check(ld g) {
	memset(vis, -1, sizeof vis);
	coun = 0;
	r = g;
	FOR(i, 1, n) if (100 - y[i] < 2*r and vis[i] == -1) ++coun, dfs(i);
	FOR(i, 1, n) if (y[i] + 100 < 2*r and vis[i] != -1) return 0;
	return 1;
}

int main() {
	fastio;
	cin >> n;
	FOR(i, 1, n) cin >> x[i] >> y[i];
	ld lower = 0, upper = 100.0001;
	while (upper - lower > (ld) 0.0001) {
		ld mid = (upper + lower)/2;
		if (check(mid)) lower = mid;
		else upper = mid;
	}
	cout << fixed << setprecision(4) << lower;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>
#include<math.h>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll K,s3a,ansc=0,ansb=0,ansa=0;
    cin>>K;
    REP(i,K){
        if(i*i*i<=K) ansa++;
    }

    //全部違う場合
    for(ll i=1;i<=ansa;i++){
        for(ll j=i+1;i*j<=K;j++){
            ll k=K/(i*j);
            if(j>=k) break;
            ansc+=k-j;
        }
    }

    //1つだけ同じ
    REP(i,sqrt(K)){
        ansb+=K/(i*i);
        if(i*i*i<=K) ansb--;
    }

    cout<<ansc*6+ansb*3+ansa<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 2;

int subtree[maxn];
vector < int > adj[maxn];

int dfs(int v,int p){
  int ans = 1;
  subtree[v] = 1;
  if(adj[v].size() == 1 and p)
    return 1;
  vector < int > odd_maxcoins,even_maxcoins;

  for(auto child : adj[v]){
    if(child == p)
      continue;
    else{
      int max_coins = dfs(child, v);
      subtree[v] += subtree[child];
      if(subtree[child]%2)
        odd_maxcoins.push_back(2*max_coins-subtree[child]);
      else
        even_maxcoins.push_back(2*max_coins-subtree[child]);
    }
  }
  // take out all negative differences in even array
  // for(auto vertex : odd_maxcoins)
  //   cout<<vertex<<"  ";
  // cout<<"\n";

  sort(odd_maxcoins.begin(),odd_maxcoins.end());
  sort(even_maxcoins.begin(),even_maxcoins.end());

  int n1 = odd_maxcoins.size(),n2 = even_maxcoins.size();
  for(int i=0;i<n1;++i){
    if(i%2)
      ans -= odd_maxcoins[i];
    else
      ans += odd_maxcoins[i];
  }

  for(int i=0;i<n2;++i){
    if(even_maxcoins[i] < 0)
      ans+=even_maxcoins[i];
    else if(n1%2)
      ans-=even_maxcoins[i];
    else
      ans+=even_maxcoins[i];
  }
  // cout<<v<<"  "<<subtree[v]<<"  "<<ans<<"\n";

  return (ans + subtree[v])/2;
}

int main(){
  int n,p;
  cin>>n;
  for(int i=2;i<=n;++i){
    cin>>p;
    adj[i].push_back(p);
    adj[p].push_back(i);
  }
  cout<<dfs(1,0);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  string n;
  cin >> n;
  int size = n.size();
  int ans = INF;
  for(int bit = 1; bit < (1<<size); bit++){
    int sum = 0;
    int cnt = 0;
    for(int i = 0; i < size; i++){
      if(bit&(1<<i)){
        sum += n[i]-'0';
        cnt ++;
      }
    }
    if(sum % 3 == 0) ans = min(ans, size - cnt);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    string S; cin >> S;

    deque<char> dq; bool flipped = false;
    for (auto &c : S) {
        if (c == 'R') {
            flipped = !flipped;
        } else {
            if (flipped) {
                dq.push_front(c);
            } else {
                dq.push_back(c);
            }
        }
    }
    // for (auto c : dq) cout << c;
    // cout << endl;

    vector<char> ans;
    int N = dq.size();
    int j = 0;
    REP(i, 0, N) {
        // cout << "# i : " << i << ", c : " << dq[i] << endl;
        // cout << "# j : " << j << endl;
        if (j == 0) {
            // cout << "--> empty" << endl;
            if (ans.empty()) {
                ans.push_back(dq[i]);
            } else {
                ans[j] = dq[i];
            }
            j++;
        } else if (ans[j - 1] == dq[i]) {
            // cout << "--> same" << endl;
            j--;
        } else {
            // cout << "--> use" << endl;
            if ((int)ans.size() > j) {
                ans[j] = dq[i];
            } else {
                ans.push_back(dq[i]);
            }
            j++;
        }
    }

    if (flipped) {
        REP(i, 0, j) cout << ans[j - i - 1];
        cout << endl;
    } else {
        REP(i, 0, j) cout << ans[i];
        cout << endl;
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<bitset>
#include<cstdio>
#include<string>
#include<time.h>
#include<vector>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int N=2e5+5;
int a[2][N],t[N],x[N],y[N],l[N],c,e[2][N];
long long d[2][N];
int lsh(int x)
{
	return lower_bound(l+1,l+c+1,x)-l;
}
int lb(int x)
{
	return -x&x;
}
void add(bool w,int x,int v,int f)
{
	int y=c-x+1;
	while(x<=c)
	{
		e[w][x]+=f;
		x+=lb(x);
	}
	while(y<=c)
	{
		d[w][y]+=f*v;
		y+=lb(y);
	}
}
pair<int,long long> ask(bool w,int x)
{
	int an=0,y=c-x;
	long long as=0;
	while(x)
	{
		an+=e[w][x];
		x-=lb(x);
	}
	while(y)
	{
		as+=d[w][y];
		y-=lb(y);
	}
	return pair<int,long long>(an,as);
}
int main()
{
	int n,m,q,s,g;
	long long an=0;
	scanf("%d%d%d",&n,&m,&q);
	l[++c]=0;
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
		t[i]--;
		l[++c]=y[i];
	}
	sort(l+1,l+c+1);
	c=unique(l+1,l+c+1)-l-1;
	for(int i=1;i<=n;i++)
		add(0,1,0,1);
	for(int i=1;i<=m;i++)
		add(1,1,0,1);
	for(int i=1;i<=q;i++)
	{
		s=lsh(a[t[i]][x[i]]);
		g=lsh(y[i]);
		add(t[i],s,l[s],-1);
		add(t[i],g,y[i],1);
		pair<int,long long>p=ask(t[i]^1,s);
		pair<int,long long>r=ask(t[i]^1,g);
		a[t[i]][x[i]]=y[i];
		an+=1ll*r.first*y[i]+r.second-1ll*p.first*l[s]-p.second;
		printf("%lld\n",an);
	}
}

#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

struct SegmentTree {
    #define mid (l + r) / 2
    #define left(u) (u + 1)
    #define right(u) (u + ((mid - l + 1) << 1 ))

    struct Node{
        lli s, cnt;
        Node(lli s = 0, lli cnt = 0): s(s), cnt(cnt){}
        Node operator+(const Node &n) const {
              return Node(s + n.s, cnt + n.cnt);
        }
    };

    int n;
    Node z;
    vector<Node> st;

    SegmentTree(int n): n(n) {
        st.resize(2 * n);
    }

    void update(int u, int l, int r, int kth, lli val, lli c) {
      if(l == r) {
          st[u].s += val;
          st[u].cnt += c;
          return;
      }
      if(kth <= mid) update(left(u), l, mid, kth, val, c);
      else update(right(u), mid + 1, r, kth, val, c);
      st[u] = st[left(u)] + st[right(u)];
    }
    Node query(int u, int l, int r, int ll, int rr) {
       if(r < ll or rr < l or r < l) return z;
       if(ll <= l and r <= rr) return st[u];
       return query(left(u), l, mid, ll, rr) + query(right(u), mid + 1, r, ll, rr);
   }
};

lli n, m, q, sz, ans = 0;
vi vn;
vi vm;
vector<SegmentTree> vs;
vector<pair<bool, ii>> query;

set<lli> st;
map<lli, lli> mp;

void comp() {
  sz = 0;
  for(auto it : st) mp[it] = sz++;
}

lli get(int id, lli x) {
  lli l = (vs[id].query(0, 0, sz, 0, mp[x]).cnt) * x;
  lli r = vs[id].query(0, 0, sz, mp[x] + 1, sz).s;
  //if(id == 0) deb(vs[id].query(0, 0, sz, 1, sz).s);
  return l + r;
}

int main(){ _
  cin >> n >> m >> q;
  vn.resize(n);
  vm.resize(m);
  query.resize(q);
  lli t, x, y;
  st.insert(0);
  fore(i, 0, q) {
    cin >> t >> x >> y; --x; st.insert(y);
    query[i].f = t == 1;
    query[i].s = {x, y};
  }
  comp();
  vs = vector<SegmentTree>(2, SegmentTree(sz));
  --sz;
  fore(i, 0, n) vs[0].update(0, 0, sz, 0, 0, 1);
  fore(i, 0, m) vs[1].update(0, 0, sz, 0, 0, 1);
  for(auto it : query) {
    x = it.s.f; y = it.s.s;
    if(it.f) {
      ans -= get(1, vn[x]);
      vs[0].update(0, 0, sz, mp[vn[x]], -vn[x], -1);
      vn[x] = y;
      vs[0].update(0, 0, sz, mp[y], vn[x], 1);
      ans += get(1, vn[x]);
    }
    else {
      ans -= get(0, vm[x]);
      vs[1].update(0, 0, sz, mp[vm[x]], -vm[x], -1);
      vm[x] = y;
      vs[1].update(0, 0, sz, mp[y], vm[x], 1);
      ans += get(0, vm[x]);
    }
    cout << ans << ENDL;
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define pb push_back
#define q_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

typedef vector<ll> vll;

const long long val = 1000000007;
const long long v = 100001;

map<ll, ll> mymap;

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r", stdin);
		freopen("output.txt","w", stdout);
	#endif
	q_io;
	ll t, n, m, k, x, si, temp, a, myelement;

	cin>>n;
	for (ll i = 0; i < n; i++)
	{
		cin>>k;
		mymap[k%200]++;
	}
	ll ans=0;
	for(auto i=mymap.begin(); i!=mymap.end(); i++){
		x = i->second;
		ans += (x*(x-1))/2;
	}

	cout<<ans<<"\n";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SZ(x) (int)(x).size()
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout if (DEBUG) cerr
#define dvar(...) " \x1b[35m[" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "]\x1b[0m "
template <typename T>
true_type const_iterator_check(typename T::const_iterator*);
template <typename T>
false_type const_iterator_check(...);
template <typename T>
struct IsC : decltype(const_iterator_check<T>(nullptr)) {};
template <>
struct IsC<string> : false_type {};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0); cin.tie(0);

  set<int> s;
  F0R (i, 200002) {
    s.insert(i);
  }
  int n; cin >> n;
  while (n--) {
    int x; cin >> x; s.erase(x);
    cout << *s.begin() << endl;
  }

  return 0;
}


// ＵＴＦ−８

#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using lc = complex<double>;
template <class T>
bool complex_comparator(const complex<T> &a, const complex<T> &b) {
 return real(a) == real(b) ? imag(a) < imag(b) : real(a) < real(b);
}

/* #include<atcoder/all> */
/* using namespace atcoder; */

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

int main(void) {
    constexpr ll MOD = 0 ? 1e9+7 : 998244353;
    const double PI = acos(-1);
    constexpr double eps = 1e-5;
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    if(1) {
        ll n;
        cin >> n;
        vector<lc> s(n), t(n);

        lc gs = 0, gt = 0;
        for(ll i=0; i<n; i++) {
            double x, y;
            cin >> x >> y;
            s[i] = lc(n*x, n*y);
            gs += s[i];
        }
        for(ll i=0; i<n; i++) {
            double x, y;
            cin >> x >> y;
            t[i] = lc(n*x, n*y);
            gt += t[i];
        }
        gs /= n;
        gt /= n;
        for(auto &v: s) v -= gs;
        for(auto &v: t) v -= gt;

        {
            ll i;
            for(i=0; i<n; i++) {
                if(s[i] != 0.0) break;
            }
            if(i == n) {
                for(i=0; i<n; i++) {
                    if(t[i] != 0.0) break;
                }
                cout << (i == n ? "Yes" : "No") << endl;
                return 0;
            }

            lc x = s[i] / abs(s[i]);
            for(ll j=0; j<n; j++)
                s[j] /= x;
        }
        sort(begin(s), end(s), complex_comparator<double>);

        for(ll i=0; i<n; i++) {
            if(t[i] == 0.0) continue;

            vector<lc> tt(n);
            for(ll j=0; j<n; j++)
                tt[j] = t[j] / (t[i] / abs(t[i]));

            sort(begin(tt), end(tt), complex_comparator<double>);

            bool ok = true;
            for(ll j=0; j<n; j++) {
                ok &= norm(tt[j] - s[j]) < eps;
            }
            if(ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;

    }
    return 0;
}

#include <bits/stdc++.h>

#define fi first
#define se second
#define DB double
#define U unsigned
#define LL long long
#define LD long double
#define pb emplace_back
#define MP std::make_pair
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 100 + 5;
const DB EPS = 1e-9;

inline int sgn(DB x){
	if(std::fabs(x) <= EPS) return 0;
	return x > 0 ? 1 : -1;
}

struct P{
	DB x,y;
	P(DB x=0,DB y=0) : x(x),y(y) {}
	P operator + (const P &t) const {return P(x+t.x,y+t.y);}
	P operator - (const P &t) const {return P(x-t.x,y-t.y);}
	P operator / (const DB &t) const {return P(x/t,y/t);}
	DB dot(const P &t){return x*t.x+y*t.y;}
	DB det(const P &t){return x*t.y-y*t.x;}
	DB len2(){return x*x+y*y;}
	DB len(){return std::sqrt(len2());}

	inline bool operator < (const P &t) const {
		if(sgn(x-t.x)) return sgn(x-t.x) < 0;
		return sgn(y-t.y) < 0;
	}

	inline bool operator == (const P &t) const {
		return !sgn(x-t.x) && !sgn(y-t.y);
	}
}a[MAXN],b[MAXN],c[MAXN],t[MAXN];
int n;

inline P rotate(P v,DB sin,DB cos){
	return P(v.x*cos-v.y*sin,v.x*sin+v.y*cos);
}

int main(){
//	freopen("A.in","r",stdin);
	scanf("%d",&n);
	if(n <= 2){
		puts("Yes");
		return 0;
	}
	FOR(i,1,n) scanf("%lf%lf",&a[i].x,&a[i].y);
	FOR(i,1,n) scanf("%lf%lf",&b[i].x,&b[i].y);
	P sm2 = 0;FOR(i,1,n) sm2 = sm2+b[i];sm2 = sm2/n;
	std::sort(b+1,b+n+1);
	// a[i]*A-b[i] = a[j]*A-b[j]
	// (a[i]-a[j])*A = b[i]-b[j]
	FOR(i,1,n) FOR(j,1,n){
		if(i == j) continue;
		P u = a[1]-a[2],v = b[i]-b[j];
//		if(!sgn(u.len()) || !sgn(v.len())) continue;
		DB Cos = u.dot(v)/u.len()/v.len(),Sin = u.det(v)/u.len()/v.len();

		FOR(k,1,n) c[k] = rotate(a[k],Sin,Cos);
		P sm = 0;
		FOR(k,1,n) sm = sm+c[k];
		sm = sm/n;
		P vec = sm2-sm;

		FOR(l,1,n) t[l] = c[l]+vec;
		std::sort(t+1,t+n+1);
		bool flag = 1;
		FOR(l,1,n) flag &= t[l]==b[l];
		if(flag){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void sort2vectors(vector<__int64_t> &av, vector<__int64_t> &bv){
   int n = av.size();
   vector<__int64_t> p(n), av2(n), bv2(n);
   iota(p.begin(), p.end(), 0);
   sort(p.begin(), p.end(), [&](__int64_t a, __int64_t b) { return av[a] < av[b]; });
   for (int i = 0; i < n; i++) {
       av2[i] = av[p[i]];
       bv2[i] = bv[p[i]];
   }
   av = av2;
   bv = bv2;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<__int64_t> Avec(N), Bvec(N);
    for(int i=0; i<N; i++)
    {
        cin >> Avec.at(i) >> Bvec.at(i);
    }
    sort2vectors(Avec, Bvec);

    __int64_t Money = K;

    for(int i=0; i<N; i++)
    {
        if(Money >= Avec.at(i))
        {
            Money += Bvec.at(i);
        }
    }
    cout << Money;
}

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	vector<string> S(N);
	REP(i, N) cin >> S[i];

	ll odd = 0, even = 0;
	FOR(i, 1, N) {
		int cnt = 0;
		REP(j, M) if (S[0][j] != S[i][j]) ++cnt;
		if (cnt & 1) ++odd;
		else ++even;
	}

	ll ans = odd;
	ans += odd * even;
	cout << ans << endl;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[200010], s[200010] = {0}, ans[200010] = {0}, vis[200010] = {0}, n;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		vis[i] = max(vis[i-1], a[i]);
		s[i] = s[i-1] + a[i];
	}
	for (int i = 1; i <= n; i++) {
		ans[i] = ans[i-1]+s[i];
		printf("%lld\n", ans[i]+i*vis[i]);
	}
	return 0;
}

#include <algorithm>
#include <bitset>
//#include <cmath>
//#include <complex>
#include <cctype>
#include <cstdio>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

int64_t INF = LLONG_MAX;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> A(N);
    vector<int> maxA(N);
    int currentmax = 0;
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        currentmax = max(A.at(i), currentmax);
        maxA.at(i) = currentmax;
    }

    vector<int64_t> memo(N);
    int64_t currentsum = 0;

    memo.at(0) = A.at(0) + currentmax;
    currentsum += memo.at(0);

    vector<int64_t> ans(N);
    for(int i = 1; i < N; i++){
        memo.at(i) = memo.at(i-1) + A.at(i);
        currentsum += memo.at(i);
    }

    ans.at(N-1) = currentsum;
    int tmp = 0;
    for(int i = N-1; i > 0; i--){
        currentsum -= memo.at(i) - tmp;
        if(maxA.at(i-1) < maxA.at(i)){
            currentsum -= (maxA.at(i) - maxA.at(i-1)) * i;
            tmp += (maxA.at(i) - maxA.at(i-1));
        }

        ans.at(i-1) = currentsum;
    }

    for(auto a: ans){
        cout << a << endl;
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#define int long long
using namespace std;

const int maxm = 3e3 + 5;
const int mod = 1e9 + 7;

int ms[maxm][maxm];
int d[maxm][maxm];     //d[i][j]表示前i个数分成j段的方案数
int sum[maxm];
int a[maxm];
int n;

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    for (int i = 1; i <= n; i++) {
        d[i][1] = 1;
        for (int j = 2; j <= n; j++) {
            int t = sum[i] % j;
            d[i][j] = ms[j][t];
        }
        for (int j = 2; j <= n; j++) {
            int t = sum[i] % j;
            ms[j][t] = (ms[j][t] + d[i][j - 1]) % mod;
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) ans = (ans + d[n][i]) % mod;
    cout << ans << "\n";
}
signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    solve();
    return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;

int get() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}

const int N = 3e5 + 5;
int n, a[N], b[N], sum[N], top;
map<int, int> cnt[2];

signed main() {
	n = get();
	for(int i = 1; i <= n; i++) a[i] = get();
	sum[1] = a[1];
	for(int i = 2; i <= n; i++) sum[i] = sum[i - 2] + a[i];
	cnt[0][0]++, cnt[1][0]++;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += cnt[i & 1][sum[i] - sum[i - 1]];
		cnt[i & 1][sum[i] - sum[i - 1]]++;
	}
	cnt[0].clear(), cnt[1].clear();
	for(int i = 1; i <= n; i++) {
		ans += cnt[i & 1][sum[i] - sum[i - 1]];
		cnt[i & 1 ^ 1][sum[i - 1] - sum[i]]++;
	}
//	for(int i = 1; i <= n; i += 2) printf("%lld: %lld\n", i, sum[i] - sum[i - 1]);
//	for(int i = 2; i <= n; i += 2) printf("%lld: %lld\n", i, sum[i] - sum[i - 1]);
	printf("%lld\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int LGN = 15;
const int MAXN = 5005;
const long long int MOD = 998244353;
long long int fact[MAXN], inv_fact[MAXN], dp[LGN][MAXN];
long long int power(long long int a, int b)
{
	if (b == 0)
	{
		return 1;
	}
	long long int ans = power(a, b/2);
	ans = (ans * ans) % MOD;
	if (b % 2)
	{
		ans = (ans * a) % MOD;
	}
	return ans;
}
void precomp()
{
	fact[0] = 1;
	for (int i = 1; i < MAXN; ++i)
	{
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	inv_fact[MAXN - 1] = power(fact[MAXN - 1], MOD - 2);
	for (int i = MAXN - 2; i >= 0; --i)
	{
		inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % MOD;
	}
}
long long int comb(int n, int r)
{
	if (r > n)
	{
		return 0;
	}
	long long int ans = (fact[n] * inv_fact[r]) % MOD;
	ans = (ans * inv_fact[n - r]) % MOD;
	return ans;
}
int main(int argc, char const *argv[])
{
	precomp();
	int n, m;
	cin>>n>>m;
	for (int i = 0; i <= m; i += 2)
	{
		dp[0][i] = comb(n, i);
	}
	for (int i = 1; i < LGN; ++i)
	{
		int cpow = (1<<i);
		for (int j = 0; j <= m; ++j)
		{
			dp[i][j] = 0;
			for (int k = 0; k * cpow <= j; k += 2)
			{
				dp[i][j] = (dp[i][j] + dp[i - 1][j - (k * cpow)] * comb(n, k)) % MOD;
			}
		}
	}
	cout<<dp[LGN - 1][m]<<"\n";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0;i < (int)(n);++i)
#define MS(x) memset((x), -1, sizeof((x)))
#define ALL(x) x.begin(), x.end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool is_npos(string::size_type x) { return x == string::npos; }
using PI = pair<int, int>;

#define MOD 1000000007

ll n;
ll a[3010];
ll mat[3010][3010];

ll dp[3010][3010] = {};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> n;
	rep(i, n){
		cin >> a[i];
	}

	for(int i = 1;i <= n;i++){
		for(int j = 0;j < n;j++){
			mat[i][j+1] = (mat[i][j] + a[j]) % i;
		}
	}

	dp[1][0] = 1;

	ll ans = 0;
	for(int j = 1;j <= n;j++){
		for(int i = n;i >= 1;i--){
			if(j == n){
				ans += dp[i][mat[i][j]];
				ans %= MOD;
			}
			dp[i+1][mat[i+1][j]] += dp[i][mat[i][j]];
			dp[i+1][mat[i+1][j]] %= MOD;
		}
	}

	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

pair<int, int> divmod(int a, int b) { return make_pair(a / b, a % b); }

class Solver {
private:
    const int n = 30;
    double score = 0.0;

    pair<int, int> input_query() {
        int si, sj, ti, tj;
        cin >> si >> sj >> ti >> tj;
        return make_pair(si * n + sj, ti * n + tj);
    }

    void output(string path) { cout << path << endl; }

    void input_score() { int in; cin >> in; }

    string query(int s, int t) {
        auto[si, sj] = divmod(s, n);
        auto[ti, tj] = divmod(t, n);
        string res = "";
        int di = ti - si;
        int dj = tj - sj;
        if(di > 0) res += string(di, 'D');
        else res += string(-di, 'U');
        if(dj > 0) res += string(dj, 'R');
        else res += string(-dj, 'L');
        return res;
    }

public:
    void solve() {
        rep(k, 1000) {
            auto[s, t] = input_query();
            string path = query(s, t);
            output(path);
            input_score();
        }
    }
};

int main() {
    Solver solver;
    solver.solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int n , x [103] , y [103] , vis [103];
vector < int > gr [103];
void dfs ( int x )
{
    vis [x] = 1;
    for ( int i = 0 ; i < gr [x] . size () ; i ++ )
    {
        int u = gr [x][i];
        if ( vis [u] ) continue;
        dfs ( u );
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("milk.in","r",stdin);
    //freopen("milk.out","w",stdout);
    cin >> n;
    for ( int i = 3 ; i <= n + 2 ; i ++ ) cin >> x [i] >> y [i];
    long double l = 0 , r = 100 , mid;
    while ( abs ( r - l ) >= 1e-8 )
    {
        memset ( vis , 0 , sizeof vis );
        for ( int i = 1 ; i <= n + 2 ; i ++ ) gr [i] . clear ();
        mid = ( l + r ) / 2;
        for ( int i = 3 ; i <= n + 2 ; i ++ )
        {
            if ( 2 * mid > abs ( y [i] + 100 ) )
            {
                gr [i] . push_back ( 1 );
                gr [1] . push_back ( i );
            }
            if ( 2 * mid > abs ( 100 - y [i] ) )
            {
                gr [i] . push_back ( 2 );
                gr [2] . push_back ( i );
            }
            for ( int j = i ; j <= n + 2 ; j ++ )
            {
                long double dx = x [i] - x [j] , dy = y [i] - y [j];
                if ( 4 * mid * mid > dx * dx + dy * dy )
                {
                    gr [i] . push_back ( j );
                    gr [j] . push_back ( i );
                }
            }
        }
        dfs ( 1 );
        if ( vis [2] == 0 ) l = mid;
        else r = mid;
    }
    cout << fixed << setprecision ( 5 ) << l;
}


#include <bits/stdc++.h>
using namespace std;
int n;
const int dydis = 1e5 + 100;
vector<pair<int, int> > mas[dydis], gr[dydis];
bool vis[dydis] = {0};
int ans[dydis] = {0};
int neut[dydis] = {0};
void dfs(int v){
    vis[v] = 1;
    for(auto x : mas[v]){
        if(vis[x.first]) continue;
        gr[x.first].push_back({v, x.second});
        gr[v].push_back({x.first, x.second});
        dfs(x.first);
    }
}
void mkN(int v){
    vector<int> st;
    for(auto x : gr[v]){
        st.push_back(x.second);
    }
    sort(st.begin(), st.end());
    int db = 1;
    for(auto x : st){
        if(x > db){
            neut[v] = db;
            return;
        }
        if(x == db) db++;
    }
    neut[v] = db;
}
void fAns(int v, int came){
    if(v == 0){
        ans[v] = neut[v];
    }
    for(auto x : gr[v]){
        if(x.first == came) continue;
        if(ans[v] != x.second) ans[x.first] = x.second;
        else ans[x.first] = neut[x.first];
        fAns(x.first, v);
    }
}
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b, c; cin >> a >> b >> c; a--; b--;
        mas[a].push_back({b, c});
        mas[b].push_back({a, c});
    }
    dfs(0);
    for(int i = 0; i < n; i++) mkN(i);
    fAns(0, -1);
    for(int i = 0; i < n; i++){
        cout << ans[i] << "\n";
    }
    return 0;
}

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const int INF=1001001001;
    const int mod=1e9+7;

    int used[20],sz=0,p[20];
    int ng[3][20];
    vector<int>G[20];
    void rec(int n){
      if(used[n]){return;}
      used[n]=1;
      p[sz++]=n;
      for(int u:G[n]){
        rec(u);
      }
    }

    ll tot=0;
    void dfs(int depth){
      int now=p[depth];
      if(depth==sz){tot++;return;}
      rep(col,3){
        if(!ng[col][now]){
          for(int u:G[now]){
            ng[col][u]++;
          }
          dfs(depth+1);
          for(int u:G[now]){
            ng[col][u]--;
          }
        }
      }
    }
    void solve(){
      int n,m;
      cin>>n>>m;
      rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
      }
      ll ans=1;
      rep(i,n){
        if(used[i]){continue;}
        sz=0,tot=0;
        rec(i);
        dfs(0);
        ans*=tot;
      }
      cout<<ans<<endl;
    }
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      solve();
      return 0;
    }


#include <bits/stdc++.h>
#define LOCAL
#define mkp make_pair
#define ft first
#define sd second
using namespace std;
typedef long long ll;
typedef long double lld;
typedef pair<ll,ll> pll;
const lld pi = 3.14159265358979323846;
const ll maxn=1e5+10;
const ll mod=998244353;
void init(void);
ll pow_mod(ll a,ll k);

void solve() {
	ll n,num=0,i=1;
	cin >> n;
	n*=2;
	while(1){
		ll x=n-i*(i-1);
		if(x<=0)break;
		if(x%(2*i)==0)num++;
		i++;
	}
	cout << num*2;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//init();
	ll T=1;
	//cin >> T;
	while(T--){
		solve();
	}
	return 0;
}

void init (void)
{
	#ifdef LOCAL
		freopen ("data.txt", "r", stdin);
		freopen ("out.txt", "w", stdout);
	#endif
}

ll pow_mod(ll a,ll k)
{
    ll ans = 1;
    a %= mod;
    while(k)
    {
        if(k % 2) ans *= a;
        a = (a * a) % mod;
        k /= 2;
        ans %= mod;
    }
    return ans;
}

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define X first
#define Y second
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define pf(a) cout<<"checking-- "<<a<<endl
#define pff(a,b) cout<<"Checking-- "<<a<<' '<<b<<endl
#define pfff(a,b,c) cout<<"Checking-- "<<a<<' '<<b<<' '<<c<<endl
#define clr(ar) memset(ar,0,sizeof(ar))
#define gP(n) (prime[n>>6]&(1<<((n>>1)&31)))
#define sP(n) (prime[n>>6]=prime[n>>6]|(1<<((n>>1)&31)))
#define on(val,pos) (val|(1<<pos))
#define off(val,pos) (val&(~(1<<pos)))
#define check(val,pos) (val&(1<<pos))
#define invert(val,pos) (val^(1<<pos))
#define INF (ll) 1e18
#define pie (double)acos(-1.0)
#define vsort(v) sort(v.begin(),v.end())
#define arsort(v,n) sort(v,v+n)
#define MAX 100004
#define MOD 1000000007
vector<tuple<int,int,int>> edges;

void solve(){
    ll n; cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int num=i;
        int tr=0;
        while(num){
            if(num%10==7) {tr=1;break;}
            num/=10;
        }
        num=i;
        while(num){
            if(num%8==7) {tr=1;break;}
            num/=8;
        }
        if(tr==0) ans++;
    }
    cout<<ans<<endl;

}
int main(){
    int tst=1;
    while(tst--){
        solve();
    }

    return 0;
}


#include <iostream>
#include <vector>
#include<math.h>
#include<algorithm>
#include <float.h>
#include <iomanip>
#include<string>
using namespace std;

int main()
{

	unsigned long long N, a, c,bmax,bmin,I,Iking,a_,b_,c_;
	N = 0;
	cin >> N;

	Iking = 100000000000000;
	bmax = floor(log2(N));
	bmin = 0;
	if (N == 1) { cout << 1; return 0; }

	for (int b = bmin; b < bmax; b++) {
		a = floor(N /pow(2, b));
		c = N - a * (unsigned long long)pow(2, b);
		I = a + b + c;
		if (I < Iking) { Iking = I; a_ = a; b_ = b; c_ = c; }
	}

	cout << Iking;

}

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

int main() {
  vi a(5);
  rep(i, 4) cin >> a[i];
  a[4] = 0;
  bool ok = false;
  int wa = 0;
  rep(i, 4) wa += a[i];
  rep(i, 5) rep(j, 5) rep(k, 5){
    if (i==j||j==k||k==i) continue;
    int x = a[i] + a[j] + a[k];
    int y = wa - x;
    if (x == y) ok = true;
  }
  if (ok) cout<< "Yes\n";
  else cout << "No\n";
}


//================code===================//

//#define TLE

#ifdef TLE
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define ld double
#define fa(i,a,b) for(LL i=(a);i<(LL)(b);++i)
#define fd(i,a,b) for(LL i=(a);i>(LL)(b);--i)
#define setp tuple<LL,LL,LL>
#define setl pair<LL,LL>
#define micro 0.000001

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }

#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
#define DB(a) cerr << __LINE__ << ": " << #a << " = " << (a) << endl;
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#else
#define AT
#define AE
#define ce(t)
#endif

pair <int, int> vu[9] = { {0,1},{1,0},{0,-1} ,{-1,0},{0,0},{1,-1}, {-1,1} , {-1,-1},{-1,-1} }; //RDLU EWSN

template<typename T, typename U> void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U> void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } bool operator()(setl& a, setl& b) { return a.second < b.second; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } bool operator()(setl& a, setl& b) { return a.second > b.second; } };

const int max_v = 2e5 + 7;
const int max_k = 5e2 + 7;
const int bsz = (1ll << 10) + 7;
const int INF = 1e9 + 7;
const LL LNF = (LL)5e18 + 7ll;
LL mod = 998244353;
template<typename T, typename U> void MOD(T& a, U b) { a += b; if (a >= mod) a -= mod; };

int main()
{
#ifdef OHSOLUTION
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; ci(n);

	vector<LL> va(n);
	vector<LL> vb(n);

	fa(i, 0, n) ci(va[i]);
	fa(i, 0, n) ci(vb[i]);

	unordered_map<LL, vector<int>> xh;
	fd(i, n-1, -1) va[i] += i,xh[va[i]].push_back(i);

	LL d = 0;
	LL ans = 0;
	vector<LL> arr(n+1);

	auto upd = [&](int i)
	{
		++i;
		for (; i<=n; i += i & -i) ++arr[i];
	};

	auto qur = [&](int i)
	{
		++i;
		LL ret = 0;
		for (; i; i -= i & -i)ret += arr[i];
		return ret;
	};

	fa(i, 0, n)
	{
		if (xh[vb[i] + d].empty())
		{
			co(-1);
			return 0;
		}

		int t = xh[vb[i] + d].back();

		xh[vb[i] + d].pop_back();

		ans += t - qur(t);
		upd(t);
		++d;
	}

	co(ans);

	return 0;
}

#include "bits/stdc++.h"
#define int long long
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;
template <typename T>
struct BIT {
	int n;          // 配列の要素数(数列の要素数+1)
	vector<T> bit;  // データの格納先
	BIT(int n_) : n(n_ + 1), bit(n, 0) {}
	void add(int i, T x) {
		for (int idx = i; idx < n; idx += (idx & -idx)) {
			bit[idx] += x;
		}
	}
	T sum(int i) {
		T s(0);
		for (int idx = i; idx > 0; idx -= (idx & -idx)) {
			s += bit[idx];
		}
		return s;
	}
};
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	vector<int>A(N), B(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> B[i];
	map<int, vector<int>>mp;
	for (int i = N - 1; i >= 0; i--)mp[i + A[i]].push_back(i);
	vector<int>c(N);
	BIT<int>bit(N + 100);
	for (int i = 0; i < N; i++) {
		if (mp[i + B[i]].empty()) {
			cout << -1 << endl; return 0;
		}
		int idx = mp[i + B[i]].back();
		mp[i + B[i]].pop_back();
		c[i] = idx + 1;
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {

		ans += i - bit.sum(c[i]);
		bit.add(c[i], 1);
	}
	cout << ans << endl;
	return 0;

}


#include <bits/stdc++.h>
#define f(i,j,k) for(long long i=j;i<k;i++)
#define f2(i,j,k) for(long long i=j;i>=k;i--)
#define ll long long
using namespace std;
const long long mod=1e9+7;
void chmin(int& a, int b){ if(a > b) a = b; }
void chmax(int& a, int b){ if(a < b) a = b; }
void answer(ll a){
    if(a==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}
int main(){
    ll n,a,b,c,d;
    string s;
    cin>>n;
    cout<<n-1<<endl;
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
using ll = long long;
using namespace std;

int main(int argc, char *argv[]) {
  ll N;
  cin >> N;
  cout << N - 1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N;
	set<int> A;
	cin >> N;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		A.insert(a);
	}

	while(A.size() > 1){
		int x = *A.begin();
		int X = *A.rbegin();
		A.erase(X);
		A.insert(X-x);
	}

	cout << *A.begin() << endl;
	return(0);
}

#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> A(n), G(1001);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  int ans = -1, best = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      G[__gcd(A[i], A[j])]++;
    }
    int x = max_element(G.begin() + 2, G.end()) - G.begin();
    if (G[x] > best) best = G[x], ans = x;
    fill(G.begin(), G.end(), 0);
  }
  cout << ans << '\n';
  return 0;
}


#include <iostream>
#include <string>
#define mod 3
using namespace std;
int n;
string s;
int dp[400000] = { 0 };
int f[400000] = { 0 };
int g[400000] = { 0 };
void compute()
{
    dp[0] = 1;
    f[0] = 0;
    g[0] = 1;
    for (int i = 1; i < n; ++i) {
        f[i] += f[i - 1];
        int j = i;
        while (j % mod == 0) {
            f[i]++;
            j /= mod;
        }
        g[i] = (g[i - 1] * j) % mod;
    }
    for (int i = 1; i < n; ++i) {
        if (f[n - 1] > f[i] + f[n - 1 - i]) {
            dp[i] = 0;
        } else {
            dp[i] = g[n - 1] * g[n - 1 - i] * g[i];
            dp[i] %= mod;
        }
    }
}
int convert(char c)
{
    if (c == 'B')
        return 0;
    if (c == 'R')
        return 1;
    if (c == 'W')
        return 2;
}
char revert(int num)
{
    if (num == 0)
        return 'B';
    if (num == 1)
        return 'R';
    if (num == 2)
        return 'W';
}
int main()
{
    cin >> n >> s;
    compute();
    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += dp[i] * (convert(s[i])) % mod;
    }
    if ((n - 1) % 2) {
        res = -res;
    }
    res = ((res % mod) + mod) % mod;
    cout << revert(res) << endl;
}

#include <bits/stdc++.h>
#define LL long long

using namespace std;

LL n, k;

int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  while (k--) {
    if (n % 200) {
      n = n * 1000 + 200;
    } else {
      n /= 200;
    }
  }
  cout << n;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef int_fast32_t int32;
typedef int_fast64_t int64;
typedef uint_fast64_t uint64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

uint64 choose(uint64 n, uint64 r){
  chmin(r,n-r);
  uint64 res = 1;
  set<uint64> st;
  REP(i,r){
    res *= n-i;
    REP(j,r){
      if(st.count(j+1))continue;
      if(res % (j+1))continue;
      res /= (j+1);
      st.insert(j+1);
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  uint64 l;
  cin >> l;
  l -= 12;
  uint64 ans = choose(l+11,11);
  ANS(ans);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 a, b;
  cin >> a >> b;
  cout << (a + b) / 2 << " " << (a - b) / 2 << endl;
}


#include <bits/stdc++.h>
//#define rep(i,a,n) for (int i=a;i<n;i++)
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)

#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define rrep(i,a,n) for (int i=n-1;i>=a;i--)
#define ALL(x) x.begin(),x.end()

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pause "read -p 'Press Enter to continue...' var"

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define in(x,y)(0<=(x)&&(x)<h&&0<=(y)&&(y)<w)

/*
テスト通りますように
　　●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

const ll INF = numeric_limits<ll>::max()/4;
const ll MAX = 200005;
const int MOD = 3;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll in[MAX];
ll out[MAX];
vll rnkV[MAX];
vll children[MAX];

ll timer = 0;

void dfs(ll pos,ll rnk){
  in[pos] = timer++;
  rnkV[rnk].pb(in[pos]);
  for(ll to: children[pos]){
    dfs(to,rnk+1);
  }
  out[pos] = timer++;
}

int main() {
	ll n;
  cin >> n;
  rep(n-1){
    ll p;
    cin >> p;
    p--;
    children[p].pb(i+1);
  }
  dfs(0,0);
  ll q;
  cin >> q;
  rep(q){
    ll u,d;
    cin >> u >> d;
    u--;
    ll cnt = 0;
    cnt = lower_bound(rnkV[d].begin(),rnkV[d].end(), out[u]) - lower_bound(rnkV[d].begin(),rnkV[d].end(), in[u]);
    cout << cnt << endl;
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
void dfs(vector<vector<tuple<int, int, int>>> &E, vector<string> &ans, int v){
  for (auto e : E[v]){
    int w = get<0>(e);
    int id = get<1>(e);
    int t = get<2>(e);
    if (ans[id] == ""){
      if (t == 0){
        ans[id] = "->";
      } else {
        ans[id] = "<-";
      }
      dfs(E, ans, w);
    }
  }
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<int> c(N);
  for (int i = 0; i < N; i++){
    cin >> c[i];
  }
  vector<string> ans(M);
  for (int i = 0; i < M; i++){
    if (c[a[i]] > c[b[i]]){
      ans[i] = "->";
    }
    if (c[a[i]] < c[b[i]]){
      ans[i] = "<-";
    }
  }
  vector<vector<tuple<int, int, int>>> E(N);
  for (int i = 0; i < M; i++){
    if (ans[i] == ""){
      E[a[i]].push_back(make_tuple(b[i], i, 0));
      E[b[i]].push_back(make_tuple(a[i], i, 1));
    }
  }
  for (int i = 0; i < N; i++){
    dfs(E, ans, i);
  }
  for (int i = 0; i < M; i++){
    cout << ans[i] << endl;
  }
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    ll N; cin >> N;
    vector<ll> a(N), b(N), c(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    ll ma = a[0];
    c[0] = a[0] * b[0];
    for(int i = 1; i < N; i++){
        ma = max(ma, a[i]);
        c[i] = max(c[i - 1], ma * b[i]);
    }
    rep(i,N) cout << c[i] << endl;
}

//                  //
//     Radmanシ     //
//                 //
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>

using namespace std;

//#define int long long

typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
#define F first
#define S second

const int maxn=2e5+5,maxlog=17;
int a[maxn],b[maxn],mark[maxn];
vector<int> v,yal[maxn];
map<int,int> mp;
int ans=0;

void dfs(int now)
{
   mark[now]=1;
   if(!b[a[now]])
   {
      b[a[now]]=1;
      v.push_back(a[now]);
      ans++;
   }
   for(int i=0;i<yal[now].size();i++)
   {
      int next=yal[now][i];
      if(mark[next])
         continue;
      dfs(next);
   }
}

int32_t main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0),cout.tie(0);
   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
      cin>>a[i];
   for(int i=1;i<=n/2;i++)
   {
      yal[i].push_back(n-i+1);
      yal[n-i+1].push_back(i);
   }
   for(int i=1;i<=n;i++)
   {
      if(mp[a[i]])
      {
         yal[i].push_back(mp[a[i]]);
         yal[mp[a[i]]].push_back(i);
         mp[a[i]]=i;
      }
      mp[a[i]]=i;
   }
   for(int i=1;i<=n;i++)
   {
      if(mark[i])
         continue;
      dfs(i);
      while(v.size())
      {
         int l=v.back();
         v.pop_back();
         b[l]=0;
      }
      ans--;
   }
   cout<<ans<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
constexpr long long INF = 1000000000 + 100;
constexpr long long LINF = 1000000000000000000 + 100;
#define all(v) v.begin( ), v.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
#define rrep(i, n) for(int i=(n); i>=0; i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

/*
辞書順でK番目のものを答えよ、という問題と同様の解き方で解く（あってた）
どうやってsumごとの組み合わせ数を数えるか⇒DP+いもす法（わからなかった）
Nが変動して貪欲できないのでDPという発想が自然かもしれない
*/

ll dp[4][3010101];
int main(){
    ll N, K; cin >> N >> K;

    dp[0][0] = 1;
    rep(cnt, 3){
        rep(sum, 2010101){ //何故2*1e6なのか？ -> dp[2][sum]の最大値が200000だから
            //imos法
            dp[cnt+1][sum+1] += dp[cnt][sum];
            dp[cnt+1][sum+N+1] -= dp[cnt][sum];
        }
        rept(sum, 1, 3010101){
            dp[cnt+1][sum] += dp[cnt+1][sum-1];
        }
    }

    ll cu = 1;//今見てるのが何番目か？
    //総和を確定させる
    int sum = -1; //3つの数の総和。最大1e6*3
    for(int i=3; i<3010101; i++){
        if(cu <= K and K < cu + dp[3][i]){//グループの範囲内かどうか
            sum = i;
            break;
        }
        cu += dp[3][i];
    }

    rep(i, sum) K -= dp[3][i]; //総和未満のグループ合計値を引く

    cu = 1;
    int ans_a = -1;
    //aを全探索
    rept(a, 1, N+1){
        if(K < cu + dp[2][sum - a]){ //dp[2][sum-a]:aを固定してb,cを選んだときの総和の場合の数
            ans_a = a;
            break;
        }
        cu += dp[2][sum-a];
    }

    rept(i, 1, ans_a) K -= dp[2][sum - i];

    cu = 1;
    int ans_b = -1;
    //bを全探索
    rept(b, 1, N+1){
        if(K < cu + dp[1][sum - ans_a - b]){
            ans_b = b;
            break;
        }
        cu += dp[1][sum - ans_a - b];
    }

    int ans_c = sum - ans_a - ans_b;
    cout << ans_a << " " << ans_b << " " << ans_c << ln;
}

#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi[maxii];
vector<int>:: iterator child;
vector<int>vi2[maxii];
vector<int>vi3[maxii];
vector<lln> vl;
vector<vector<pair<int, int> > > vii;
//vector<pii> vii;
vector<pll> vll;
//vii.clear();
//vii.resize(n + 1);

lln arr[maxii];
int arr2[maxii];
bool check[maxii];
bool check2[1000][1000];
int n,m;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
  //  cout<<INT_MAX<<endl;;
    sc(n)
    sc(m)
    map<lln,lln>mp1;
   // map<lln,lln>mp2;
    lln tip=1;
    for(int i=0;i<n;i++)
    {
        scl(arr[i])
        mp1[arr[i]]++;
       //// mp2[arr[i]]=tip++;
    }
    lln x;
    lln ans=0;

    for(int i=0;i<m;i++)
    {
        scl(x)
        ans=0;
        lln l=1;
        lln r=2000000000000000000+7;
        while(l<=r){

        lln mid=(l+r)/2;
        //cout<<mid<<endl;
        if(mp1[mid]==0)
        {
            int p=upper_bound(arr,arr+n,mid)-arr;

            if(mid-p>=x)
            {
                // cout<<p<<" "<<mid<<endl;
                r=mid-1;
                ans=mid;
            }
            else
            {
                l=mid+1;
            }
        }
        else
        {
            int p=upper_bound(arr,arr+n,mid)-arr;
            if(mid-p>=x)
            {
               // cout<<p<<" "<<mid<<endl;
                r=mid-1;
            }
            else l=mid+1;
        }
    }
        pfl(ans)
    }

}


#include<bits/stdc++.h>
using namespace std;

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define int long long int
#define mod(x) x%MOD

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define debug(x)
#endif

template <class T> void pprint(vector <T> v) {for (T i : v) {cout << i << " ";} cout << endl;}

void print(int t) {cerr << t ;}
void print(string t) {cerr << t ;}
void print(char t) {cerr << t ;}
void print(double t) {cerr << t ;}

template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.ff); cerr << ","; print(p.ss); cerr << "}" << endl;}
template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]" << endl;}
template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]" << endl;}
template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]" << endl;}
template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]" << endl;}

void solve() {
	int a, b;
	cin >> a >> b;
	cout << (float)( (float)a * b / 100) << endl;
}

int32_t main() {

	fastio();
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif

	solve();

}

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define show(a) for(auto el:a)cout<<el<<" "
#define ff first
#define ss second
#define pairv vector<pair<ll,ll>>
#define vec vector <ll>
#define all(a) a.begin(),a.end()
#define fam(v,i) for(auto i=v.begin();i!=v.end();i++)
#define fai(v,i) for(auto i : v)
#define mo 1000000007
#define nn cout<<"\n";
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define cout_dec cout << fixed << setprecision(9)
#define casepr(ti)  cout<<"case #"<<ti+1<<": "
#define fill(a,b) memset(a, b, sizeof(a))
ll pow1(ll n,ll p)
{
if(p==0) return 1;
ll x=pow1(n, p/2);
x=(x*x)%mo;
if(p%2==0)
return x;
else
return (x*n)%mo;
}
bool sortbysec(const pair<ll,ll> &a,
const pair<ll,ll> &b)
{
return (a.second < b.second);
}
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
if(p1.ff < p2.ff) return true;
if(p1.ff == p2.ff) return p1.ff < p2.ss;
return false;
}
ll const maxn=200007;
ll nxt[maxn];
void seive()
{
      for (ll i = 2; i < maxn; ++i) {
        if (nxt[i] == 0) {
            nxt[i] = i;
            for (ll j = i * i; j < maxn; j += i) {
                if(j>=maxn)
                {
                    break;
                }
                if (nxt[j] == 0) nxt[j] = i;
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

        ll i,j,k,e,f,n,c=0,x=0,r,y;
       cin>>r>>x>>y;
       ll d=(x*x)+(y*y);
       ll g=sqrt(d);
       if(g*g!=d)
       {
           c=1;
       }
        e=g/r;
       if(e>1)
       {
           if(g%r==0)
           {
               if(c!=1)
             cout<<e;
             else
             {
                 cout<<e+1;
             }
           }
           else
           {
               cout<<e+1;
           }
       }
       else
       {
           if(c==1 || g%r!=0)
           {
               cout<<2;
           }
           else
           {
               cout<<e;
           }
       }

     return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll mod = 1e9 + 7;
const ll linf = 1LL << 62;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M;
int dp[1010][1010];
int A[1010], B[1010];
int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < M; i++) cin >> B[i];
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            if (A[i] == B[j]) chmin(dp[i + 1][j + 1], dp[i][j]);
            chmin(dp[i + 1][j], dp[i][j] + 1);
            chmin(dp[i][j + 1], dp[i][j] + 1);
            chmin(dp[i + 1][j + 1], dp[i][j] + 1);
        }
    }
    cout << dp[N][M] << endl;
}

#include <bits/stdc++.h>
int main (){
    int H, W, CNT=0, min=101;
    std::cin >> H >> W;
    int A[H][W];
    for (int i=0; i<H; i++) {for (int j=0; j<W; j++) std::cin >> A[i][j];}
    for (int i=0; i<H; i++) {for (int j=0; j<W; j++) if(min>A[i][j]) min=A[i][j];}
    for (int i=0; i<H; i++) {for (int j=0; j<W; j++) CNT=CNT+(A[i][j]-min);}
    std::cout << CNT << std::endl;
}


#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b >= (MOD-1)) b %= (MOD-1);
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);   t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
ll modinverse(ll a, ll m){
	ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1) return 0;
    while (a > 1){
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0) x += m0;
    return x;
}
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

void solve(){
    string s;
    cin>>s;

    ll n = s.length();

    ll i = n-2;

    unordered_map<char, int> mp;
    char prev = s[i+1];
    char cur;
    ll rt = 0;
    mp[prev]++;

    ll ans=0;

    while(i>=0){

        cur = s[i];
        mp[cur]++;
        // cout<<prev<<" "<<cur<<endl;
        if(cur==prev){
            ans += rt - (mp[cur]-2);
            mp.clear();
            mp[cur] = rt+2;
        }
        prev = cur;
        rt++;
        i--;
    }
    cout<<ans;
}

int main()
{
	fast_cin();
    ll t=1;
    // cin>>t;
    // forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    // }
    return 0;
}

#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define rep(i, begin, end) for(int i = begin; i < (int)(end); i++)
#define contains(v, x) (find(all(v), x) != v.end())
template<class T> bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> T roundup(T a, T b){ return (a + b - 1) / b; }
const double PI = 3.14159265359;
const vector<int> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
const vector<int> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};
using ll = long long;
struct Edge{ int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} };
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e9;
using P = pair<ll, int>;
using Graph = vector<vector<int>>;
/*#include <atcoder/all>
using namespace atcoder;
using mint = modint;*/

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //mint::set_mod(MOD);

    string s;
    cin >> s;

    reverse(all(s));
    int n = s.size();
    ll ans = 0;
    vector<int> cnt(26);
    rep(i, 0, n - 1){
        if(s[i] == s[i + 1]){
            ans += i - cnt[s[i] - 'a'];
            fill(all(cnt), 0);
            cnt[s[i] - 'a'] = i + 2;
            i++;
        }else cnt[s[i] - 'a']++;
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
#define PI 3.141592653589793238462
#define eps 1e-20
#define fi first
#define se second
using namespace std;
using cd = complex<double>;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll c[2000006],p1[2000005],p2[2000006],mod=1e9+7;
ll C(ll a,ll b){return (p1[a]%mod*p2[b]%mod*p2[a-b]%mod)%mod;}
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b/=2;}return res%mod;}
int main(){
    ll n,m,k;cin>>n>>m>>k;p1[0]=1;
    if(n>m+k){cout<<0<<endl;return 0;}
    for(ll i=1;i<=2000000;i++){
        p1[i]=p1[i-1]*i%mod;
    }
    p2[2000000]=qpow(p1[2000000],mod-2);
    for(ll i=2000000-1;i>=0;i--){
        p2[i]=p2[i+1]*(i+1);p2[i]%=mod;
    }
    ll ans=C(n+m,n)-C(n+m,m+k+1);
    ans=(ans%mod+mod)%mod;
    cout<<ans<<endl;
}

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dp[101][101];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N, X;
	cin >> N >> X;
	int A[100];
	rep(i, N) cin >> A[i];

	ll kotae = 2e18;
	ll b = 0;
	rep1(s, N) {
		b += 2000000000;
		ll amari = X % s;
		dp[0][0] = b;
		rep(i, N) {
			ce(i);
			for (int j = min(i, s - 1); j >= 0; j--) {
				int t0 = A[i] % s;
				int t = t0;
				rep(k, s - t0) {
					if (dp[j][k] >= b) chmax(dp[j + 1][t], dp[j][k] + A[i]);
					t++;
				}
				t -= s;
				for (int k = s - t0; k < s; k++) {
					if (dp[j][k] >= b) chmax(dp[j + 1][t], dp[j][k] + A[i]);
					t++;
				}
			}
		}
		if (dp[s][amari] >= b) {
			chmin(kotae, (X - dp[s][amari] + b) / s);
		}
	}
	co(kotae);

	Would you please return 0;
}


#include <iostream>

using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    cout<<a/b;
    return 0;
}

/*First,solve the problem then write the code:);)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test ll t;cin>>t;while(t--)
#define vll vector<ll>
#define mll map<ll,ll>
#define vvll vector<vector<ll>>
#define vpll vector<pair<ll,ll>>
#define vvpll vector<vector<pair<ll,ll>>>
#define mpll map<pair<ll,ll>,ll>
#define pll pair<ll,ll>
#define sll stack<ll>
#define qll queqe<ll>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fastio
  ll n,w;
  cin>>n>>w;
  cout<<(n/w)<<"\n";
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
string s[110];
int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> s[i];
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(s[i][k]=='1'&&s[k][j]=='1'){
                    s[i][j] = '1';
                }
            }
        }
    }
    long double res = 0;
    rep(i,n){
        long double tmp = 1.0;
        int c = 1;
        rep(j,n){
            if(s[j][i]=='1'&&i!=j){
                c++;
            }
        }
        tmp /= (long double )c;

        res += tmp;
        // cerr << c << " " << tmp << endl;
    }
    cout.precision(30);
    cout << fixed << res << endl;
    return 0;
}

#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define pb(a) push_back(a)
#define vll vector<ll>
#define loop(i, n) for(ll i=1;i<=n;i++)
#define loop0(i, n) for(ll i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) printf("%lld", i)
#define pll pair<ll, ll>
#define vpll vector<pair<ll, ll>>
#define mp(i, j) make_pair(i, j);
const ll mod = 1000000007;
const ll big = 2999999999999999999;
const ll small = -2999999999999999999;
void in2(ll& a, ll& b) { in(a); in(b); }
void in3(ll& a, ll& b, ll& c) { in(a); in(b); in(c); }
void swap(ll& a, ll& b) { a = a+b; b = a-b; a = a-b; }
void arrayIn(vll& a, ll& n) { loop0(i, n) in(a[i]); }

ll n, m, a, b, c, u, v, p, q, k;

int main()
{
  in3(a, b, c);
  ll mini = min({a, b, c}), maxi = max({a, b, c});
  ll mid = a+b+c-mini-maxi;
  if(mid-mini == maxi-mid)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  vector<int> va(a), vb(b);
  iota(begin(va), end(va), 1);
  iota(begin(vb), end(vb), -b);
  int sa = a * (a + 1) / 2;
  int sb = b * (b + 1) / 2;
  if (sa < sb) {
    va[a - 1] += sb - sa;
  } else if (sa > sb) {
    vb[0] -= sa - sb;
  }
  for (auto&& e : va) {
    cout << " " << e;
  }
  for (auto&& e : vb) {
    cout << " " << e;
  }
  cout << endl;
}

#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  ll n,l; cin >> n >> l;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  vector<ll> b(n);
  rep(i,n){
    cin >> b[i];
    b[i]--;
  }
  unordered_map<ll,set<ll>> mp;
  mp[0].insert(-1);
  mp[l-n].insert(n);
  rep(i,n){
    mp[a[i]-i].insert(i);
  }
  ll ans=0;
  rep(i,n){
    if(mp.count(b[i]-i)){
      if(a[i]!=b[i]){
        ll add=min(abs(*begin(mp[b[i]-i])-i),abs(*rbegin(mp[b[i]-i])-i));
        if(*begin(mp[b[i]-i])<=i&&i<=*rbegin(mp[b[i]-i])) add=0;
        ans+=add;
        mp[b[i]-i].insert(i);
      }
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  if(a==b) cout << 0 << endl;
  else cout << ans << endl;

}


#include<bits/stdc++.h>
using namespace std;
#define deb(x)                cout<<#x<< " = "<< x<<"\n";
//#include<ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;

#define sz(x)                 (int)(x).size()
#define all(x)                (x).begin(), (x).end()
#define tr(x, it)             for(auto (it) = (x).begin();it != (x).end();it++)
#define fo(i, k, n)           for(int i = (k);i < (n);i++)
#define Fo(i, k, n)           for(int i = (k);i >= (n);i--)
#define el                    "\n"
#define ff                    first
#define ss                    second
#define ll                    long long
#define pb                    push_back
#define mp                    make_pair
#define pii                   pair<int, int>
#define vi                    vector<int>
#define mii                   map<int, int>
//#define pqb                   priority_queue<int>
//#define pqs                   priority_queue<int, vi, greater<int>>
//#define pc(x)                 putchar(x);
//#define setbits(x)            __builtin_popcountll(x)
//#define zrobits(x)            __builtin_ctzll(x)
#define mod                   1000000007
#define inf                   1e18
//#define ps(x, y)              fixed<<setprecision(y)<<x
//#define mk(arr, n, type)      type *arr = new type[n];
//#define w(x)                  int x; cin>>x; while(x--)
vector<bool> used(20, false);
ll func(ll a, ll n){
	for(ll i = 11; i >= 2; i--){
		if(!used[i]){
			if(n % i == 0){
				n /= i;
				used[i] = true;
			}
		}
	}
	return a*n;
}
void solve(){
	ll l;
	cin>>l;
	l--;
	ll ans = 1;
	fo(i, 0, 11){
		ans = func(ans, l-i);
	}
	for(ll i = 11; i >= 2; i--){
		if(!used[i]){
			ans /= i;
		}
	}
	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
		cout<<el;
	}
	return 0;
}

#ifdef LOGX
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;

/*---------macro---------*/
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define unless(x) if(!(x))
#define until(x) while(!(x))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define mybit(i,j) (((i)>>(j))&1)

/*---------type/const---------*/
const int big=1000000007;
//const int big=998244353;
const double EPS=1e-8; //適宜変える
typedef long long ll;
typedef unsigned long long ull;
typedef std::string::const_iterator state; //構文解析
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char newl='\n';
struct{
    constexpr operator int(){return -int(1e9)-10;}
    constexpr operator ll(){return -ll(1e18)-10;}
}neginf;
struct{
    constexpr operator int(){return int(1e9)+10;}
    constexpr operator ll(){return ll(1e18)+10;}
    constexpr auto operator -(){return neginf;}
}inf;

/*---------debug---------*/
#ifdef LOGX
#include <template/debug.hpp>
#else
#define dbg(...) ;
#define dbgnewl ;
#define prt(x) ;
#define _prt(x) ;
#endif

/*---------function---------*/
template<typename T> T max(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=max(ans,elem);}return ans;}
template<typename T> T min(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=min(ans,elem);}return ans;}
template<typename T,typename U> bool chmin(T &a,const U b){if(a>b){a=b;return true;}return false;}
template<typename T,typename U> bool chmax(T &a,const U b){if(a<b){a=b;return true;}return false;}
bool valid(int i,int j,int h,int w){return (i>=0 && j>=0 && i<h && j<w);}
template<class T,class U>T expm(T x,U y,const ll mod=big){T res=1;while(y){if(y&1)(res*=x)%=mod;(x*=x)%=mod;y>>=1;}return res;}
template<class T,class U>T exp(T x,U y){T res=1;while(y){if(y&1)res*=x;x*=x;y>>=1;}return res;}

int main(){
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(nullptr);
    std::cout.precision(10);
/*------------------------------------*/

    int n;
    string s;
    cin >> n >> s;
    if(s.front()==s.back()){
        char a=s[0];
        int cnt=0;
        for(int i=0;i<n;i++){
            if(s[i]!=a){
                cnt++;
                if(cnt>=2){
                    cout << 2 << newl;
                    return 0;
                }
            }
            else cnt=0;
            dbg(cnt);
        }
        cout << -1 << newl;
        return 0;
    }
    else{
        cout << 1 << newl;
    }
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
struct mint{
using ull=unsigned long long int;
ull v;
mint(ll vv=0){s(vv%mod+mod);}
mint& s(ull vv){
v=vv<mod?vv:vv-mod;
return *this;
}
//オーバーロード
mint operator-()const{return mint()-*this;}//mint型にキャスト
mint&operator+=(const mint&val){return s(v+val.v);}
mint&operator-=(const mint&val){return s(v+mod-val.v);}
mint&operator*=(const mint&val){
v=ull(v)*val.v%mod;
return *this;
}
mint&operator/=(const mint&val){return *this*=val.inv();}
mint operator+(const mint&val){return mint(*this)+=val;}
mint operator-(const mint&val){return mint(*this)-=val;}
mint operator*(const mint&val){return mint(*this)*=val;}
mint operator/(const mint&val){return mint(*this)/=val;}
mint pow(ll n)const{
mint res(1),x(*this);
while(n){
if(n&1)res*=x;
x*=x;
n>>=1ll;
}
return res;
}
mint inv()const{return pow(mod-2);}
//拡張ユークリッドの互除法
/* mint inv()const{
int x,y;
int g=extgcd(v,mod,x,y);
assert(g==1);
if(x<0)x+=mod;
return mint(x);
}*/
friend ostream& operator<<(ostream&os,const mint&val){
return os<<val.v;
}//出力
bool operator<(const mint&val)const{return v<val.v;}
bool operator==(const mint&val)const{return v==val.v;}
bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
fac[0] = fac[1] = 1;
for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
finv[MAX-1]=fac[MAX-1].inv();
for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
if (n<k) return 0;
if (n<0 || k<0) return 0;
return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * finv[k] * finv[n - k];
}
class UF{
public:
	vector<int> par,num;
	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UF(int N):par(N),num(N,1){
		iota(all(par),0);
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return;
		if(num[u]<num[v])swap(u,v);
		num[u]+=num[v];
		par[v]=u;
	}
	bool same(int u,int v){
		return find(u)==find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};
int main(){
    init();
    int n,K;
    cin>>n>>K;
    V<V<int>> a(n,V<int>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)cin>>a[i][j];
    }
    UF l(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool ok=true;
            for(int k=0;k<n;k++){
                  if(a[i][k]+a[j][k]>K)ok=false;
            }
            if(ok)l.unite(i,j);
        }
    }
    mint ans=mint(1);
    for(int i=0;i<n;i++){
         if(l.find(i)!=i)continue;
         ans*=fac[l.size(i)];
    }
    UF r(n);
        for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool ok=true;
            for(int k=0;k<n;k++){
                  if(a[k][i]+a[k][j]>K)ok=false;
            }
            if(ok)r.unite(i,j);
        }
    }
        for(int i=0;i<n;i++){
         if(r.find(i)!=i)continue;
         ans*=fac[r.size(i)];
    }
    cout<<ans<<"\n";
}

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P = pair<ll,ll>;
    const int mod=998244353;
    const int INF=1001001001;

    struct edge{
      int to;
      ll w;
      edge(int to,ll w):to(to),w(w){}
    };
    using Graph=vector<vector<edge>>;

    int N,M;

    void dijkstra(int s,Graph G,vector<ll>& dist){
      dist.resize(N,INF);
      dist[s]=0;
      priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>q;
      q.push({dist[s],s});
      while(!q.empty()){
        int v=q.top().second;
        ll d=q.top().first;
        q.pop();
        if(d>dist[v]){continue;}
        for(auto e:G[v]){
          if(chmin(dist[e.to],dist[v]+e.w)){
            q.push({dist[e.to],e.to});
          }
        }
      }
    }

    int main() {
      cin>>N>>M;
      Graph G(N);
      rep(i,M){
        ll A,B;
        cin>>A>>B;
        A--;B--;
        G[A].push_back(edge(B,1));
        G[B].push_back(edge(A,1));
      }
      int K;
      cin>>K;
      vector<int>C(K);
      rep(i,K){cin>>C[i];C[i]--;}

      vector<vector<int>>dist(K);
      rep(i,K){
        vector<ll>d(N,INF);
        dijkstra(C[i],G,d);
        rep(j,K){dist[i].push_back(d[C[j]]);}
      }
      vector<vector<ll>>dp(1<<K,vector<ll>(K,INF));
      rep(i,K){dp[1<<i][i]=0;}
      rep(s,1<<K){
        rep(i,K){
          if((s>>i)&1){
            ll res=s^(1<<i);
            rep(j,K){
              if(res&(1<<j)){chmin(dp[s][i],dp[res][j]+dist[i][j]);}
            }
          }
        }
      }
      ll ans=*min_element(dp.back().begin(),dp.back().end());
      cout<<(ans<INF?ans+1:-1)<<endl;
      return 0;
    }


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define fill0(a) memset(a,0,sizeof(a))
#define fill1(a) memset(a,-1,sizeof(a))
#define fillbig(a) memset(a,63,sizeof(a))
#define pb push_back
#define ppb pop_back
#define mp make_pair
template<typename T1,typename T2> void chkmin(T1 &x,T2 y){if(x>y) x=y;}
template<typename T1,typename T2> void chkmax(T1 &x,T2 y){if(x<y) x=y;}
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned int u32;
typedef unsigned long long u64;
namespace fastio{
	#define FILE_SIZE 1<<23
	char rbuf[FILE_SIZE],*p1=rbuf,*p2=rbuf,wbuf[FILE_SIZE],*p3=wbuf;
	inline char getc(){return p1==p2&&(p2=(p1=rbuf)+fread(rbuf,1,FILE_SIZE,stdin),p1==p2)?-1:*p1++;}
	inline void putc(char x){(*p3++=x);}
	template<typename T> void read(T &x){
		x=0;char c=getchar();T neg=0;
		while(!isdigit(c)) neg|=!(c^'-'),c=getchar();
		while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
		if(neg) x=(~x)+1;
	}
	template<typename T> void recursive_print(T x){if(!x) return;recursive_print(x/10);putc(x%10^48);}
	template<typename T> void print(T x){if(!x) putc('0');if(x<0) putc('-'),x=~x+1;recursive_print(x);}
	void print_final(){fwrite(wbuf,1,p3-wbuf,stdout);}
}
const int MAXN=1e5;
int n;char s[MAXN+5];
int main(){
	scanf("%d%s",&n,s+1);
	if(s[1]^s[n]) return puts("1")&0;
	for(int i=1;i<n;i++) if((s[1]^s[i])&&(s[i+1]^s[n]))
		return puts("2")&0;
	puts("-1");
	return 0;
}

 #include <bits/stdc++.h>

 #define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
 #define all(v) (v).begin(), (v).end()
 using namespace  std;
 #define forn(i,n) for (int i = 0; i < (n); ++i)
 #define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
 using ll = long long;
 int mod = (ll)1e9 + 7;
 #define PI acos(-1)
 typedef pair<int, int> pairs;

 const int INF = 1e9 + 1;
 const int N = 2e5 + 100;
 const double eps = 1e-7;

 template <class T> using V = vector<T>;
 template <class T> using VV = V<V<T>>;

 template <typename XPAX>
 void ckma(XPAX &x, XPAX y) {
     x = (x < y ? y : x);
 }
 template <typename XPAX>
 void ckmi(XPAX &x, XPAX y) {
     x = (x > y ? y : x);
 }
 void __print(int x) {cerr << x;}
 void __print(long x) {cerr << x;}
 void __print(long long x) {cerr << x;}
 void __print(unsigned x) {cerr << x;}
 void __print(unsigned long x) {cerr << x;}
 void __print(unsigned long long x) {cerr << x;}
 void __print(float x) {cerr << x;}
 void __print(double x) {cerr << x;}
 void __print(long double x) {cerr << x;}
 void __print(char x) {cerr << '\'' << x << '\'';}
 void __print(const char *x) {cerr << '\"' << x << '\"';}
 void __print(const string &x) {cerr << '\"' << x << '\"';}
 void __print(bool x) {cerr << (x ? "true" : "false");}

 template<typename T, typename V>
 void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
 template<typename T>
 void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
 void _print() {cerr << "]\n";}
 template <typename T, typename... V>
 void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
 void solve() {

 	int n;cin >> n;
 	string s;
 	cin >> s;
 	VV<int> g(26);
 	forn(i, n) {
 		g[s[i] - 'a'].push_back(i);
 	}

 	V<int> cnt(26, INF);

 	V<int> dp(n + 1, INF);

 	dp[0] = 0;

 	forn(i, n) {
 		for(int j = 0;j < 26;++j) {
 			if(j == (s[i] - 'a'))continue;
 			if(!g[j].size())continue;
 			ckmi(dp[i + 1], dp[g[j][0]] + 1);
 			if(g[j].size() > 1)ckmi(dp[i + 1], dp[g[j][1]] + 1);
 		}
 	}

 	debug(dp);
 	cout << (dp[n] == INF ? -1 : dp[n]) << '\n';

 	// acbababca

 }
 void test_case() {
     int t;
     cin >> t;
     forn(p, t) {

         //cout << "Case #" << p + 1 << ": ";
         solve();
     }
 }
 int main() {

     ios::sync_with_stdio(false);
     cin.tie(0);

     solve();

 }