#line 1 "main.cpp"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int> xs(n), ys(n), ps(n);
    for (auto& x : xs) cin >> x;
    for (auto& y : ys) cin >> y;
    for (auto& p : ps) {
        cin >> p;
        --p;
    }

    vector<int> prev(n);
    for (int i = 0; i < n; ++i) prev[ps[i]] = i;

    vector<int> is(n);
    iota(is.begin(), is.end(), 0);
    sort(is.begin(), is.end(),
         [&](auto i, auto j) { return xs[i] < xs[j]; });

    vector<pair<int, int>> ans;
    for (auto i : is) {
        if (ps[i] == i) continue;
        if (ys[ps[i]] >= xs[i]) {
            cout << "-1\n";
            return;
        }

        int j = prev[i];
        ans.emplace_back(i, j);

        swap(prev[ps[i]], prev[ps[j]]);
        swap(ps[i], ps[j]);
    }

    cout << ans.size() << "\n";
    for (auto [i, j] : ans) {
        cout << i + 1 << " " << j + 1 << "\n";
    }
}

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

    solve();

    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;

const int maxn = 1e6 + 5;

struct bit {
    vector<ll> a;
    int n;
    void init(int _n) {
	n = _n;
	a.resize(n+10);
    }

    void upd(int i, ll dx) {
	for (; i<=n; i+=i&-i) {
	    a[i] += dx;
	}
    }

    ll qry(int i) {
	ll res = 0;
	for (; i; i-=i&-i) {
	    res += a[i];
	}
	return res;
    }
};

ll invs(vector<int> a) {
    int n = a.size();
    ll res = 0;
    bit bit;
    bit.init(n);
    for (int i=n-1; i>=0; i--) {
	res += bit.qry(a[i]);
	bit.upd(a[i],+1);
    }
    return res;
}

vector<int> rand_perm(int n, int index=1) {
    assert(n>=1);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    vector<int> a(n);
    iota(a.begin(), a.end(), index);
    shuffle(a.begin(), a.end(), rng);
    return a;
}

// needs to be 1 cycle, with n-1 inversions
bool check(vector<int> a) {
    int n = a.size();
    if (invs(a) != n-1) return false;

    for (int i=0; i<n; i++) {
	a[i] --;
    }
    vector<int> viz(n,0);
    int len = 0;
    int at = 0;
    while (!viz[at]) {
	len++;
	viz[at]=1;
	at=a[at];
    }
    return len==n;
}

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

    /*auto p = rand_perm(10);
    while (!check(p)) {
	p = rand_perm(10);
    }
    for (int x: p) cout<<x<<" ";
    cout<<endl;*/

    int n;
    cin>>n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    if (!check(a)) out(-1);

    for (int i=0; i<n; i++) {
	a[i] --;
    }
    vector<int> ans;

    for (int i=0; i<n; i++) {
	if (i>a[i]) {
	    for (int j=i-1; j>=a[i]; j--) {
		ans.push_back(j);
	    }
	}
    }

    assert(int(ans.size()) == n-1);

    for (int i: ans) {
	cout<<i+1<<"\n";
	swap(a[i],a[i+1]);
    }

    assert(is_sorted(a.begin(),a.end()));
    return 0;
}


// Hail god Yato

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

#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n;
    cin>>n;
    vector<ll> fst(n), snd(n);
    for(int i = 0; i < n; i++)
        cin>>fst[i];
    for(int j = 0; j < n; j++)
        cin>>snd[j];
    ll last = 0, mx = 0;;
    for(int i = 0; i < n; i++){
        ll ans = 0;
        mx = max(mx, fst[i]);
        ans = mx*snd[i];
        if(last < ans)
            last = ans;
        cout<<last<<"\n";
    }
}
signed main(){
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0;
}

#include <bits/stdc++.h>

using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vb=vector<bool>;using vvb=vector<vb>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;

#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()

// cin and cout of a vector
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}

// for loop
#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 repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revv(i, a, b) for (int i = (int)(b-1); i >= (int)(a); i--)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
// #define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
// #define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
// #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
// #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)

// Yes/no
#define cho(n,a,b) cout<< ((n)?a:b)<<endl;
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}

#define pb push_back
#define rsortv(v) sort((v).rbegin(), (v).rend())
#define sortv(v) sort((v).begin(), (v).end())

// max/min
template<class T, class U>bool chmax(T&a,const U&b){bool x=a<b;x?a=b:b;return x;}template<class T, class U>bool chmin(T&a,const U&b){bool x=a>b;x?a=b:b;return x;}
template<class T, class U>auto max(const T&a,const U&b){return a<b?b:a;}template<class T, class U>auto min(const T&a,const U&b){return a<b?a:b;}

//========================================
//========================================
//========================================

template<class T>auto minv(const T&a){return *min_element(all(a));}
template<class T>auto smod(T a, T b){a %= b; if (a < 0); a+= b; return a;}
template<class T>auto maxv(const T&a){return *max_element(all(a));}
template<class T>auto sumv(const T&a){ll sum = 0; for(auto x: a) sum+= x; return sum;}

template<class T>void pr(const T&a){cout << a << endl;}
template<class T>void pr_precise(const T&a){cout.precision(10); cout << fixed << a << endl;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
// ll M = 1000000007;
ll M = 998244353;

unordered_map <ll, ll> m;

int main() {
    int cases = 1;
    // cin >> cases;

    rep(CASE, cases){
        ll n;
        cin >> n;
        vl A(n);
        cin >> A;
        vl B(n);
        cin >> B;
        vl C(n);
        ll mp = 0;
        ll ma = 0;
        rep(i, n){
            chmax(ma, A[i]);
            chmax(mp, ma*B[i]);
            pr(mp);
        }

        // pr(A);
        // pr(B);
        // pr(C);

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    cin>>n>>k;

    int town[n][n];
    vector<int> v(n-1);
    for(int i=0;i<n-1;i++) v[i] = i+1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
           cin>>town[i][j];
        }
    }
    int p = 0;
    int ans = 0;
    int cnt = 0;
    do{
       for(int n:v){
          ans += town[p][n];
          p = n;
       }
       ans += town[p][0];
       if(ans == k) cnt++;
       ans = 0;
       p = 0;
    }while(next_permutation(v.begin(), v.end()));

    cout<<cnt<<endl;
}

#include <bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 3e5 + 10;
const int MOD = 0;

int a[N];

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i =1; i <= n;i ++){
		int x;
		scanf("%d", &x);
		a[x] ++;
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++){
		k = min(k, a[i]);
		ans += k;
	}
	printf("%lld", ans);

}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c, neg = 0; while(isspace(c = getchar_unlocked()));
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar_unlocked())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class Ty, class... Args> inline void rd(Ty& x, Args&... args) { rd(x); rd(args...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

ll get(ll n) {
	return n * (n + 1) / 2;
}

int main() {
	int n; rd(n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll l, r; rd(l, r);
		ans += get(r) - get(l-1);
	}
	printf("%lld\n", ans);

}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <stack>
#include <cstring>
#include <set>
#include <utility>
#include <iostream>
#include <iomanip>
#include <list>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cctype>
//#include <boost/multiprecision/cpp_int.hpp>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <numeric>
#include <complex>
#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SUM(v) accumulate(ALL(v),0ll)
using ll = long long;
const ll INF=1e24;
const ll eps=1;
const double pi=3.14159265359;
const ll mod=1e9+7;
using I32 = int32_t;
using I64 = int64_t;
using namespace std;
//Union Find テンプレ
struct UnionFind {
  vector<int> par , siz;
  UnionFind(int n) : par(n,-1) , siz(n,1) { }
  int root(int x) {
    if(par[x] == -1) return x;
    else return par[x] = root(par[x]);
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = root(x) ; y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) swap(x,y);
    par[y] = x;
    siz[x] += siz[y];
    return true;
  }
  int size(int x) {
    return siz[root(x)];
  }
};
typedef pair<int,int> P;
int func(int a,int b)
{
  if(b==0)return a;
  return func(b,a%b);
}
int main()
{
  ll n;
  cin>>n;
  ll ans=0;
  ll a,b;
  REP(i,n)
  {
    cin>>a>>b;
    ans+=(a+b)*(b-a+1)/2;
  }
  cout<<ans<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define rep1(i,n) for(int i = 1 ; i <= (n) ; i++)
#define rrep(i,n) for(int i = (n) - 1 ; i >= 0 ; i--)
#define rrep1(i,n) for(int i = (n) ; i > 0 ; i--)
#define MOD 1000000007
using ll = int64_t;
using P = pair<int, int>;
using PL = pair<ll,ll>;
using PD = pair<double,double>;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vP = vector<P>;
using p_q = priority_queue<int, vi, greater<int>>;
const int INF = 1001001001;
const ll LINF = (1ll<<62) + ((1ll<<62)-1);
#define v(n) vector<n>
#define vv(n) vector<vector<n>>
#define vvv(n) vector<vector<vector<n>>>
#define p_q(n) priority_queue<(n), v(n), greater<n>>
#define line cout << "================================" << endl;
#define Yn(x) ((x) ? "Yes" : "No")
#define yn(x) ((x) ? "yes" : "no")
#define mmax(a,b) a = max(a,b)
#define mmin(a,b) a = min(a,b)
#define debug(x) cout << #x" : " << (x) << endl;
#define output(x) cout << (x) << endl;
#define outs(x) cout << #x << endl;
#define mod(n) %(n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
template <typename T> void chmin(T& a, T b){if(a>b)a=b;}
template <typename T> void chmax(T& a, T b){if(a<b)a=b;}

class alucrex{
    public:
    void vin(vi& a){rep(i,a.size())cin>>a[i];}
    void vin1(vi& a){rep1(i,a.size())cin>>a[i];}
    void vvin(vvi& a){rep(i,a.size())rep(j,a[i].size())cin>>a[i][j];}
    void vvdes(vvi& a){rep(i,a.size()){rep(j,a[i].size()){
        cout << a[i][j] << " ";}cout<<endl;
    }}
    void vinl(vl& a){rep(i,a.size())cin>>a[i];}
    void vvinl(vvl& a){rep(i,a.size())rep(j,a[i].size())cin>>a[i][j];}
    void vvdesl(vvl& a){rep(i,a.size()){rep(j,a[i].size()){
        cout << a[i][j] << " ";}cout<<endl;
    }}
    void vpin(vP& a){for(auto& x:a)cin>>x.first>>x.second;}
    template<typename T>
    void vvd(vv(T)& a){rep(i,a.size()){rep(j,a[i].size()){
        cout << a[i][j] << " ";}cout<<endl;
    }}
};
#include <chrono>
using namespace chrono;

int main(){
    alucrex al;
    steady_clock::time_point start = steady_clock::now();
    map<int, vi> mp;
    int n, m; cin >> n >> m;
    rep(i,m) {
        int x, y; cin >> x >> y;
        mp[x].push_back(y);
    }
    set<int> table;
    table.insert(n);

    for(auto i : mp) {
        vi erase, add;
        for(int j : i.second) {
            int flag = 0;
            if(table.count(j - 1) || table.count(j + 1)) add.push_back(j);
            else if(table.count(j)) erase.push_back(j);
        }
        for(int j : add) table.insert(j);
        for(int j : erase) table.erase(j);
    }
    cout << table.size() << endl;
    steady_clock::time_point end = steady_clock::now();
    auto res = end - start;
    //cout << "実行時間：" << duration_cast<milliseconds>(res).count() << "ms" << endl;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    set<int> s;
    s.emplace(n);
    int m;
    cin >> m;
    map<int, vector<int>> mp;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        mp[x].push_back(y);
    }
    for(auto [x, v] : mp) {
        sort(v.begin(), v.end());
        vector<int> add;
        vector<int> er;
        for(auto e : v) {
            if(s.count(e)) {
                if(!s.count(e - 1) and !s.count(e + 1)) er.push_back(e);
            } else {
                if(s.count(e - 1) or s.count(e + 1)) add.push_back(e);
            }
        }
        for(auto e : add) s.emplace(e);
        for(auto e : er) s.erase(e);
    }
    cout << s.size() << endl;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <unordered_set>
#include <fstream>

using namespace std;

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

	long long int n;
	long long int res = 0;

	cin >> n;

	stringstream ss;
	ss << n;
	long long int val = 1;
	int len = ss.str().length();

	for (int i = 1; i < len; i++)
	{
		long long int x = ((i - 1) / 3);
		res += ((x * (10 * val - val)));
		val *= 10;
	}
	long long int x = ((len - 1) / 3);
	res += ((x * (n - val + 1)));

	cout << res << '\n';

	return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure
using namespace __gnu_pbds;              //Policy Based Data Structure
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //Policy Based Data Structure
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int> >
#define mk(arr,n,type)  type *arr = new type[n]
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int             long long
#define ld              long double
#define nn              '\n'
#define w(t)            cin>>tc; while(tc--)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x,y)       cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define lb(v,x)         lower_bound(v.begin(),v.end(),x)  //returns address of number equal to or just greater than x ,else it is v.end() (i.e. not found)
#define ub(v,x)         upper_bound(v.begin(),v.end(),x)
#define all(x)          x.begin(), x.end()
#define fill(a, b)      memset(a, b, sizeof(a))
#define sortall(x)      sort(all(x))
#define tr(it,a)        for(auto it = a.begin(); it != a.end(); it++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define PI              3.1415926535897932384626
#define inf             1e18
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());  //Random Shuffler
typedef pair<int, int>   pii;
typedef vector<int>      vi;
typedef vector<pii>      vpii;
typedef vector<vi>       vvi;
typedef map<int, int>    mii;
typedef map<char, int>   mci;
typedef map<string, int> msi;
int mpow(int base, int exp);
int lcm(int a, int b);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
vi g[N];
// no of prime numbers in range : (70,19) , (1000,168) , (100000,1229) , (sqrt(10^9),3409)
//=======================

void sol()
{
	int i, j, k, n, x, y, z, m, tc = 1;
	string s;
	// cin >> tc;
	while (tc--)
	{
		cin >> n;
		x = 1e9;
		y = 1e6;
		x *= y;
		y = 1e3;
		int ans = 0;
		fo(i, 5)
		{
			z = n - x;
			if (z >= 0)
			{
				int cnt = n - x + 1;
				ans += (5ll - i) * cnt;
				n -= cnt;
			}
			x /= y;
		}

		cout << ans << nn;
	}
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	sol();

	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}

int lcm(int a, int b)
{
	int g = __gcd(a, b);
	return a / g * b;
}

void ipgraph(int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}


#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,m,q;
vector<pair<LL,LL>> arr;
int main(){
	IO();
	cin>>n>>m>>q;
	arr.resize(n);
	LL w,v;
	rep(i,0,n){
		cin>>w>>v;
		arr[i].F = v;
		arr[i].S = w;
	}
	VL brr(m);
	rep(i,0,m){
		cin>>brr[i];
	}
	sort(ALL(arr), greater<pair<LL, LL>>());
	LL l, r;
	rep(i,0,q){
		cin>>l>>r;
		l--;r--;
		VL temp;
		for(LL j=0;j<l;j++){
			temp.PB(brr[j]);
		}
		for(LL j=r+1;j<m;j++){
			temp.PB(brr[j]);
		}
		if(SZ(temp) == 0){
			dout(0);
		}
		else{
			LL ans = 0;
			LL ss = SZ(temp);
			sort(ALL(temp));
			VL visited(ss, 0);
			rep(j,0,n){
				rep(k,0,ss){
					if(!visited[k]){
						if(temp[k] >= arr[j].S){
							visited[k] = 1;
							ans += arr[j].F;
							break;
						}
					}
				}
			}
			dout(ans);
		}
	}
	return 0;
}

#include<bits/stdc++.h>
#define M 1005
typedef long long ll;
using namespace std;
int stp[M][M][27];
int n,m;
int to[2*M],nxt[2*M],hd[M][26],cnte;
void adde(int u,int v,int c){
	to[++cnte]=v;
	nxt[cnte]=hd[u][c];
	hd[u][c]=cnte;
}
struct node{int x,y,c;};
queue<node> Q;
int BFS(){
	int x,y,c;
	while(!Q.empty()){
		x=Q.front().x;
		y=Q.front().y;
		c=Q.front().c;
		if((c==26)&&((x==1&&y==n)||(x==n&&y==1)))return stp[x][y][26];
		Q.pop();
		if(c==26){
			for(int i=0;i<26;++i)
				for(int j=hd[x][i],z;j;j=nxt[j]){
					if(~stp[z=to[j]][y][i])continue;
					stp[z][y][i]=stp[x][y][c]+1;
					Q.push((node){z,y,i});
				}
		}else{
			for(int j=hd[y][c],z;j;j=nxt[j]){
				if(~stp[x][z=to[j]][26])continue;
				stp[x][z][26]=stp[x][y][c]+1;
				Q.push((node){x,z,26});
			}
		}
	}
	return -1;
}
int main(){
	cin>>n>>m;
	memset(stp,-1,sizeof(stp));
	for(int i=1;i<=n;++i){
		stp[i][i][26]=0;
		Q.push((node){i,i,26});
	}
	int u,v;char c[5];
	for(int i=1;i<=m;++i){
		scanf("%d%d%s",&u,&v,c);
		if(u>v)swap(u,v);
		adde(u,v,c[0]-'a');
		adde(v,u,c[0]-'a');
		if(u==v)continue;
		stp[u][v][26]=1;
		stp[v][u][26]=1;
		Q.push((node){u,v,26});
		Q.push((node){v,u,26});
	}
	cout<<BFS();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
// clang-format off
using ll = int64_t;
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& a : v) cin >> a;
    return is;
}
template <class T>
istream& operator>>(istream& is, vector<pair<T, T>>& v) {
    for (auto& a : v) cin >> a.first >> a.second;
    return is;
}
template <class T>
istream& operator>>(istream& is, vector<tuple<T, T, T>>& v) {
    for (auto& a : v) {
        T a1, a2, a3;
        cin >> a1 >> a2 >> a3;
        a = {a1, a2, a3};
    }
    return is;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
    for (auto& a : v) os << a << " ";
    os << endl;
    return os;
}
#define all(v) begin(v), end(v)
#define TRC1(a) cout << #a ":" << a
#define TRC2(a, b) TRC1(a); cout << " "; TRC1(b)
#define TRC3(a, b, c) TRC2(a, b); cout << " "; TRC1(c)
#define TRC4(a, b, c, d) TRC3(a, b, c); cout << " "; TRC1(d)
using veci = vector<int>;
using vecll = vector<ll>;
using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define fore(x, v) for (auto x : v)
const int IINF = INT32_MAX;
const ll LINF = INT64_MAX;
// cout << fixed << setprecision(15);
void solve();
int main() { cout << fixed << setprecision(15); solve(); return 0; }
// clang-format on

double dp[100][100][100];

double f(int x, int y, int z) {
    if (x == 100 || y == 100 || z == 100) return 0;

    if (dp[x][y][z] != 0) return dp[x][y][z];

    int sum = x + y + z;
    double res = (double)x / sum * (f(x + 1, y, z) + 1) +
                 (double)y / sum * (f(x, y + 1, z) + 1) +
                 (double)z / sum * (f(x, y, z + 1) + 1);
    dp[x][y][z] = res;
    return res;
}

void solve() {
    double A, B, C;
    cin >> A >> B >> C;

    double ans = f(A, B, C);
    cout << ans << endl;
}

#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int A,B,C;
double f[105][105][105];
int main()
{
	scanf("%d%d%d",&A,&B,&C);
	f[A][B][C]=1;
	for(int len=A+B+C;len<=300;len++)
	{
		for(int i=A;i<=99;i++)
		for(int j=B;j<=99;j++)
		{
			int k=len-A-B;
			if(k>=C&&k<=99)
			{
				if(i) f[i+1][j][k]+=f[i][j][k]*((double)i/(i+j+k));
				if(j) f[i][j+1][k]+=f[i][j][k]*((double)j/(i+j+k));
				if(k) f[i][j][k+1]+=f[i][j][k]*((double)k/(i+j+k));
			}
		}
	}
	double ans=0;
	for(int i=0;i<=100;i++)
	for(int j=0;j<=100;j++)
	{
		ans+=(100+i+j-A-B-C)*f[100][i][j];
		ans+=(100+i+j-A-B-C)*f[i][100][j];
		ans+=(100+i+j-A-B-C)*f[i][j][100];
	}
	printf("%0.8lf",ans);
}


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

int main(){
  int n, m;
  cin >> n >> m;
  ll w[n], l[m], v[m], a[n];
  rep(i,n) a[i] = i;
  rep(i,n) cin >> w[i];
  rep(i,m) cin >> l[i] >> v[i];
  rep(i,n) {
    rep(j,m) {
      if(w[i] > v[j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  vector<ll> d(1<<n);
  rep(i,1<<n) {
    ll weight = 0, dist = 0;
    rep(j,n) if(i & (1<<j)) weight += w[j];
    rep(j,m) if(weight > v[j]) dist = max(dist,l[j]);
    d[i] = dist;
  }
  ll ans = INF;
  do {
    vector<ll> dp(n);
    for(int i = 1; i < n; i++) {
      rep(j,i) {
        int id = 0;
        for(int k = j; k <= i; k++) id |= (1<<a[k]);
        dp[i] = max(dp[i],dp[j]+d[id]);
      }
    }
    ans = min(ans,dp[n-1]);
  } while(next_permutation(a,a+n));
  cout << ans << endl;
  return 0;
}

/**
 *   @FileName	c.cpp
 *   @Author	kanpurin
 *   @Created	2020.10.11 23:04:57
**/

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

template<typename T>
struct Bellman_Ford {
private:
    struct edge { int to; T cost; };
    int V;
    vector<vector<edge>> G;
    vector<T> d;
public:
    const T inf = numeric_limits<T>::max();
    Bellman_Ford(int V) : V(V){
        G.resize(V);
        d.resize(V);
    }

    void add_edge(int from, int to, T cost) {
        G[from].push_back({to,cost});
    }

    bool build(int s) {
        d.assign(V,inf);
        d[s] = 0;
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                for (edge &e : G[j]) {
                    if (d[j] != inf && d[j] + e.cost < d[e.to]) {
                        d[e.to] = d[j] + e.cost;
                        if (i == V - 1) {
                            return false;
                        }
                    }
                }
            }
        }
        /*
        REP(i, V) {
            cout << s << " -> " << i << " = " << d[i] << endl;
        }
        */
        return true;
    }

    T dist(int v) {
        return d[v];
    }
};
int main() {
    int n,m;cin >> n >> m;
    vector<int> w(n);
    int max_w = 0;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        max_w = max(max_w,w[i]);
    }
    sort(w.begin(), w.end());
    vector<pair<int,int>> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i].second >> p[i].first;
        if (p[i].first < max_w) {
            cout << -1 << endl;
            return 0;
        }
    }
    sort(p.begin(), p.end());
    for (int i = 1; i < m; i++) {
        p[i].second = max(p[i].second,p[i-1].second);
    }
    constexpr long long LLINF = 1e18 + 1;
    ll ans = LLINF;
    do {
        Bellman_Ford<ll> g(n);
        for (int i = 0; i < n-1; i++) {
            int sum = w[i];
            for (int j = i+1; j < n; j++) {
                sum += w[j];
                auto t = lower_bound(p.begin(), p.end(), make_pair(sum,-1));
                if (t == p.begin()) {
                    g.add_edge(i,j,0);
                }
                else {
                    t--;
                    g.add_edge(i,j,-(*t).second);
                }
            }
        }
        g.build(0);
        ans = min(ans,-g.dist(n-1));
    } while(next_permutation(w.begin(), w.end()));
    cout << ans << endl;
    return 0;
}


#include <iostream>

int getNum(int x) {
    return 7 - x;
}

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;

    int result = getNum(a) + getNum(b) + getNum(c);
    std::cout << result << std::endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,j,n) for(int i=j;i<n;i++)
#define readvec(v,n) for(int i=0;i<n;i++){cin>>v[i];}
#define MOD 1000000007
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  cout<<21-(a+b+c)<<"\n";
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A>
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

const int N = 2e5 + 10;

int n, a[N];
ll s[N], ss[N], ms[N];

// a1  a1 + a2  a1 + a2 + a3

// a1 2*a1 + a2  3*a1 + 2*a2 + a3
// 2   3          2

// -2  -3  -1  0  0

int main()
{
	fastIO;
	cin >> n;
	rep (i,1,n + 1) {
		cin >> a[i];
		s[i] = s[i - 1] + a[i];
		ss[i] = ss[i - 1] + s[i];
		ms[i] = max(ms[i - 1], s[i]);
	}

	ll ans = 0;

	rep (i,0,n) {
		ans = max(ans, ss[i] + ms[i + 1]);
	}

	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;

ull gcd (ull a, ull b) {
  if(b == 0) return a;

  return gcd(b, a % b);
}

ull lcm (ull a, ull b){
  // バッファ溢れを抑えるために順番大事！！！
  return a / gcd(a, b) * b;
}

ull calcDigitLength(ull n, int count) {
  if(n < 10) return count + 1;

  return calcDigitLength(n/10, count+1);
}

bool isPrime (ull a) {
  if(a == 0 || a == 1) return false;
  if(a == 2) return true;
  if(a == 3) return true;

  for(int i = 2; i * i <= a; i++) {
    if(a % i == 0) {
      return false;
    }
  }

  return true;
}

int main () {

  ll n;

  cin >> n;

  ll a;

  // 距離
  vector<ll> vec;

  // 前回進んだ距離
  vector<ll> susuda;
  ll sum = 0;

  ll currentMax = 0;
  ll currentPoint = 0;
  ll currentSumMax = 0;

  for(ll i = 0; i < n; i++) {
    cin >> a;
    sum += a;

    vec.push_back(a);
    susuda.push_back(sum);

    currentSumMax = max(sum, currentSumMax);

    currentMax = max(max(currentMax, currentPoint + sum), currentPoint +currentSumMax);
    currentPoint += sum;
  }

  cout << currentMax << endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ub upper_bound
#define lb lower_bound
const int M=1e9L+7;
const ll k=1e12L+7;
const ll MM=1e18L;
unordered_set<ll>s;
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll n;
   cin>>n;
   ll ans=0,a=0;
   for(ll i=0;i<n;++i){
   	ll k;
   	cin>>k;
   	ans+=k*k;
   	a+=k;
   }
   cout<<n*ans-a*a<<"\n";
   return 0;
}

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <complex>
#define ll long long
#define inf 1e9 + 8
#define sinf 1e17 + 500
#define ld long double
#define ull unsigned long long
#define poll complex<double>
#define line pair<poll, poll>
#define pi acos(-1)
#define lp(a, b, c, d) for (ll a = b; a < c; a += d)
#define endl '\n'
//#define EPS 1e-12
#define IO                          \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);                   \
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
using namespace std;
const ll N = 1e4  +6, SEG = (1 << 14);
ll gcd(ll a, ll b)
{
  if(b==0)return a;
  return gcd(b,a%b);
}
int  main()
{
  IO
 ll n;
 cin>>n;
 ll arr[n];
 map<ll,ll>cnt;
 set<ll>st;
 for(ll i=0;i<n;i++)
 {
   cin>>arr[i];
   cnt[arr[i]]++;
   st.insert(arr[i]);
 }
 vector<ll>v;
 for(auto d:st)
 {
   v.push_back(d);
  // cout<<d<<endl;
 }
 ll res=0;
 for(ll i=0;i<v.size();i++)
 {
   ll tmp=0;
   for(ll j=i+1;j<v.size();j++)
   {
     tmp+=(v[j]-v[i])*(v[j]-v[i])*cnt[v[j]];
   }
   res+=tmp*cnt[v[i]];
 }
 cout<<res<<endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)1e18+7

signed main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    int a[3];
    for (int i = 0; i < 3; i ++) {
        cin >> a[i];
    }
    sort(a, a + 3);

    if (a[0] == a[1]) cout << a[2] << endl;
    else if (a[1] == a[2]) cout << a[0] << endl;
    else cout << 0 << endl;
    return 0;
}

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c & 1) {
		if (a < 0 && b < 0) {
			if (a < b) {
				cout << ">\n";
			} else if (a > b) {
				cout << "<\n";
			} else {
				cout << "=\n";
			}
		}
		else if (a < b) {
			cout << "<\n";
		} else if (a > b) {
			cout << ">\n";
		} else {
			cout << "=\n";
		}
	} else {
		a = abs(a);
		b = abs(b);
		if (a < b) {
			cout << "<\n";
		} else if (a > b) {
			cout << ">\n";
		} else {
			cout << "=\n";
		}
	}
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int _ = 1;
	//cin >> _;
	while (_--) {
		solve();
	}
}


#define IOS ios::sync_with_stdio(false);
#define rep(i, a, n) for(ll i=a;i<=n;i++)

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define endl "\n"
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
ll n, m, t, k, ans, cnt, sum, flag;
ll arr[N], vis[N];
char s[N], c;

int main() {
    IOS;
    cin >> n >> m;
    rep(i, 1, n) cin >> arr[i];
    rep(i, 1, n) if (arr[i] != m) cout << arr[i] << " ";
    cout<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

signed main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	//string s[n];
	set <string> s;
	map <string,bool> m1,m2;
	string ans = "satisfiable";
	string a;
	for(int i=0; i<n; i++){
		cin >> a;
		if(a[0]=='!'){
			a = a.substr(1);
			m2[a]=1;
		}
		else{
			m1[a]=1;
		}
		s.insert(a);
	}

	auto it = s.begin();
	while(it!=s.end()){
		if(m1[*it] && m2[*it]){
			ans = *it;
			break;
		}
		it++;
	}

	cout << ans;

	return 0;
}


#pragma GCC target ("avx2")
//#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll uset<ll>
#define sll set<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define umll umap<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define pb push_back
#define pf push_front
#define ld long double
#define random(l,r,T)    uniform_int_distribution<T>(l,r)(rng)
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template<class T, class H>using umap=unordered_map<T,H,custom_hash>;
template<class T>using uset=unordered_set<T,custom_hash>;
const ll mod = 1000000007;
ll ans=0;
void dfs(vll adj[],ll vis[],ll v){
    vis[v]=1;
    for(auto i:adj[v]){
        if(vis[i])
            continue;
        ans++;
        dfs(adj,vis,i);
    }
}
int main()
{
    clock_t clk = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll test=1;
    //cin>>test;
    for(ll tc=1;tc<=test;tc++)
    {
        ll n,m;
        cin>>n>>m;
        vll adj[n+1];
        for(ll i=1;i<=m;i++){
            ll x,y;
            cin>>x>>y;
            adj[x].pb(y);
        }
        ans+=n;
        for(ll i=1;i<=n;i++){
            ll vis[n+1]={0};
            dfs(adj,vis,i);
        }
        cout<<ans;
        //cout<< "Case #"<<tc<< ": "<<ans<< "\n";
    }
    // cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';
    return 0;
}

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

using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define reps(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define uniq(a) (a).erase(unique(all(a)), (a).end())
#define bit(n) (1LL << (n))
#define dump(a) cerr << #a " = " << (a) << endl
using vll = vector<ll>;
using pll = pair<ll, ll>;
template <typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr ll DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr ll DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
ll sign(ll a) { return (a > 0) - (a < 0); }
ll cdiv(ll a, ll b) { return (a - 1 + b) / b; }
template <typename T> T sq(T a) { return a * a; }
template <typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &a) {
    os << "(" << a.first << ", " << a.second << ")";
    return os;
}
template <typename T, typename U, typename V> ostream &operator<<(ostream &os, const tuple<T, U, V> &a) {
    auto [t, u, v] = a;
    os << "(" << t << ", " << u << ", " << v << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &a) {
    os << "(";
    for (auto itr = a.begin(); itr != a.end(); itr++) { os << *itr << (next(itr) != a.end() ? ", " : ""); }
    os << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const deque<T> &a) {
    os << "(";
    for (auto itr = a.begin(); itr != a.end(); itr++) { os << *itr << (next(itr) != a.end() ? ", " : ""); }
    os << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) { os << *itr << (next(itr) != a.end() ? ", " : ""); }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) { os << *itr << (next(itr) != a.end() ? ", " : ""); }
    os << "}";
    return os;
}
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) { os << *itr << (next(itr) != a.end() ? ", " : ""); }
    os << "}";
    return os;
}
struct setup {
    static constexpr ll PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int main() {
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) { cin >> a[i]; }
    map<ll, ll> mp;
    rep(i, n) mp[a[i]]++;
    ll ans = n * (n - 1) / 2;
    for (auto [_, k] : mp) { ans -= k * (k - 1) / 2; }
    cout << ans << endl;
}


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

const int N=2e3+100,mod=1e9+7;
int n,m,a[N];

inline int read(){
    int sum=0,sign=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
       if(ch=='-') sign=-1;
       ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        sum=(sum<<1)+(sum<<3)+(ch^48);
        ch=getchar();
    }
    return sum*sign;
}

inline int Qpower(long long base, long long power) {
    int result = 1;
    base%=mod;
    while (power > 0) {
        if (power & 1) {
            result = result * base%mod;
        }
        power >>= 1;
        base = (base * base)%mod;
    }
    return result;
}

signed main(){
	scanf("%lld%lld",&n,&m);
	int sum=0;
	for(rei i=1;i<=n;++i) sum+=read();
	if(m<sum){
		printf("0\n");
		return 0;
	}
	//ans=(∑Ai+N)
	//    (M+N   )
	m+=n,sum+=n;
	int ans=1;
	for(rei i=1;i<=sum;++i){
		ans=ans*Qpower(i,mod-2)%mod *(m-i+1) %mod;
	}
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long pow_log(long long x,int y)
{
	if (!y)
	return 1;
	long long ret=pow_log(x,y/2);
	ret=(ret*ret)%mod;
	if (y%2)
	ret=(ret*x)%mod;
	return ret;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	m+=n;
	int sum=n;
	for (int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		sum+=a;
	}
	long long ans=1;
	for (int i=m-sum+1;i<=m;i++)
	ans=(ans*i)%mod;
	for (int i=1;i<=sum;i++)
	ans=(ans*pow_log(i,mod-2))%mod;
	printf("%lld",ans);
}


#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll fact[200005];

ll mod_pow(ll x,ll n){
	ll res=1;
	while(n>0LL){
		if(n&1LL){
			res=res*x%MOD;
		}
		x=x*x%MOD;
		n>>=1LL;
	}
	return res;
}

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-fact[n%p])%p;
	}
	return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p=MOD){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}

int n;
string s;
int K;
int val[200005];
ll dp[200005][20];
int cnt[17];
ll ans;

int main(void){
	fact[0]=1;
	for(ll i=1;i<=200000;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	cin >> s >> K;
	n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]>='0' && s[i]<='9'){
			val[i]=(s[i]-'0');
		}else{
			val[i]=(s[i]-'A')+10;
		}
	}
	int ct=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=15;j++){
			if(i==0 && j==0)continue;
			if(j<val[i]){
				if(cnt[j]!=0)dp[i+1][ct]++;
				else{
					dp[i+1][ct+1]++;
				}
			}
		}
		cnt[val[i]]++;
		if(cnt[val[i]]==1){
			ct++;
		}
	}
	if(ct==K){
		ans++;
	}
	for(int i=1;i<n;i++){
		dp[i][0]++;
		for(int j=0;j<=K;j++){
			if(dp[i][j]==0)continue;
			if(j==0){
				dp[i+1][1]+=dp[i][j]*15%MOD;
				dp[i+1][1]%=MOD;
			}else{
				dp[i+1][j]+=dp[i][j]*j%MOD;
				dp[i+1][j]%=MOD;
				dp[i+1][j+1]+=dp[i][j]*(16-j)%MOD;
				dp[i+1][j+1]%=MOD;
			}
		}
	}
	ans+=dp[n][K];
	ans%=MOD;
	printf("%lld\n",ans);
	return 0;
}

#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
//#define int long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define mod 1000000007
struct modint{
    int x;
    modint(int o=0){x=o;}
    modint &operator = (int o){return x=o,*this;}
    modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
    modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
    modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
    modint &operator ^=(int b){
        modint a=*this,c=1;
        for(;b;b>>=1,a*=a)if(b&1)c*=a;
        return x=c.x,*this;
    }
    modint &operator /=(modint o){return *this *=o^=mod-2;}
    modint &operator +=(int o){return x=x+o>=mod?x+o-mod:x+o,*this;}
    modint &operator -=(int o){return x=x-o<0?x-o+mod:x-o,*this;}
    modint &operator *=(int o){return x=1ll*x*o%mod,*this;}
    modint &operator /=(int o){return *this *= ((modint(o))^=mod-2);}
    template<class I>friend modint operator +(modint a,I b){return a+=b;}
    template<class I>friend modint operator -(modint a,I b){return a-=b;}
    template<class I>friend modint operator *(modint a,I b){return a*=b;}
    template<class I>friend modint operator /(modint a,I b){return a/=b;}
    friend modint operator ^(modint a,int b){return a^=b;}
    friend bool operator ==(modint a,int b){return a.x==b;}
    friend bool operator !=(modint a,int b){return a.x!=b;}
    bool operator ! () {return !x;}
    modint operator - () {return x?mod-x:0;}
};
inline modint qpow(modint a,int b){
	return  a^b;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 200005
#define inf 0x3f3f3f3f
char str[maxn];
int n,d[maxn],k;
modint cnt[maxn][23];
modint fac[44],ifac[44];
inline void prework(int n){
	fac[0]=ifac[0]=1;
	For(i,1,n)fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]/i;
}
inline modint C(int n,int m){
	if(n<m||n<0||m<0)return 0;
	return fac[n]*ifac[m]*ifac[n-m];
}
int c[1<<17];
modint dfs(int now,int st,bool lim,bool zero){
	if(now==n+1) return
	//cout<<"val "<<(c[st]==k)<<endl,
	c[st]==k;
	if(!lim && !zero) return
	//cout<<n-now+1<<" "<<c[st]<<endl,
	cnt[n-now+1][c[st]];
	int r=lim?d[now]:15;
	modint res=0;
	For(i,0,r){
		if(i||!zero)res+=dfs(now+1,st|(1<<i),lim&&(i==r),0);
		else res+=dfs(now+1,st,lim&&(i==r),1);
	}
	return res;
}
modint pw[23][maxn];

signed main()
{
	scanf("%s",str+1);
	n=strlen(str+1);
	prework(30);
	For(i,1,n){
		if(isdigit(str[i]))d[i]=str[i]-'0';
		else d[i]=str[i]-'A'+10;
	}
	For(i,1,((1<<16)-1))
		c[i]=c[i>>1]+(i&1);
	// pw[i][j] = (i^j);
	For(i,1,16){
		pw[i][0]=1;
		For(j,1,n)pw[i][j]=pw[i][j-1]*i;
	}
	k=read();
	For(i,0,n)For(j,0,k) {
		// 已有j个不同数，还要填i个
		if(i<k-j)continue;
		Rep(x,k-j,0){
			if((x-(k-j))%2) cnt[i][j]-=C(k-j,x)*pw[x+j][i];
			else cnt[i][j]+=C(k-j,x)*pw[x+j][i];
		}
		cnt[i][j]*=C(16-j,k-j);
	}
	//cout<<cnt[2][0].x<<endl;
	//cnt[1][1]=15;
	modint res=dfs(1,0,1,1);
	cout<<res.x;
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
#include <climits>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n;
string s, t;
queue<int> que;
ll ans;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++)if (s[i] == '1')que.push(i);
	for (int i = 0; i < n; i++) {
		if (!que.empty() && que.front() == i)que.pop();
		if (s[i] == t[i])continue;
		if (que.empty()) {
			cout << -1 << endl;
			return 0;
		}
		int p = que.front();
		ans += p - i;
		que.pop();
		if (s[i] == '0')s[i] = '1', s[i + 1] = '0', s[p] = '0';
		else s[i] = '0', s[i + 1] = '0', s[p] = '0';
	}
	cout << ans << endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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

int N;
ll ans=0;
string S, T;
vi cnt1(2, 0);

int solve(){
    queue<int> que1, que2;
    for(int i=0; i<N; i++){
        if(S[i] == '1') que1.push(i);
        if(T[i] == '1') que2.push(i);
    }
    while(!que1.empty() || !que2.empty()){
        if(que1.empty()) return 0;
        int a=que1.front(); que1.pop();
        if(!que2.empty()){
            int b=que2.front();
            if(a >= b){
                ans=ans+a-b;
                que2.pop();
            }
            else{
                if(que1.empty()) return 0;
                int c=que1.front(); que1.pop();
                ans=ans+c-a;
            }
        }
        else{
            if(que1.empty()) return 0;
                int c=que1.front(); que1.pop();
                ans=ans+c-a;
        }
    }
    return 1;
}

int main(){
    cin >> N;
    cin >> S >> T;

    if(solve()){
        cout << ans << endl;
    }
    else cout << "-1" << endl;
    return 0;
}


#include <stdint.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

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

	for(auto i = 0; i < s.size() && s[i] != '.'; ++i) {
		cout << s[i];
	}

	cout << endl;

	return 0;
}

// Jai Shree Ram

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

int solve(){
 		string s;cin>>s;
 		string t;
 		for(auto i:s){
 			if(i=='.')break;
 			t.push_back(i);
 		}
 		if(t.empty())t="0";
 		cout<<t<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main () {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  string t;
  cin >> t;
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  set<int> pre, cur;
  cur.emplace(0);
  int p = 1;
  for (int i = 0; i < n; i++) {
    pre = cur;
    cur.clear();
    if (t[i] == 'T') {
      for (int x = 0; x < 7; x++) {
        int v1 = x;
        int v2 = x + (s[i] - '0') * p;
        v2 %= 7;
        if (pre.count(v1) || pre.count(v2)) cur.emplace(x);
      }
    } else {
      for (int x = 0; x < 7; x++) {
        int v1 = x;
        int v2 = x + (s[i] - '0') * p;
        v2 %= 7;
        if (pre.count(v1) && pre.count(v2)) cur.emplace(x);
      }
    }
    p *= 10;
    p %= 7;
  }
  cout << (cur.count(0) ? "Takahashi" : "Aoki") << endl;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first

typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;

typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

const int inf = 1e9, maxn = 2e5 + 48, mod = 1e9 + 7, N = 2e5 + 12;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;

int n, pw[N], dp[N][7];
string s, t;

int rec (int i, int j) {
	int &res = dp[i][j];
	if (res != -1)
		return res;

	if (i == n) {
		if (!j)
			return res = 1;
		return res = 0;
	}

	int g1 = rec(i + 1, (j + pw[n - 1 - i] * (s[i] - '0')) % 7);
	int g2 = rec(i + 1, j);
//	cerr << i << ' ' << j << ' ' << pw[n -  1 - i] << ' ' << (s[i] - '0') << ' ' << g1 << ' ' << g2 << endl;

	if ((t[i] == 'T' && (g1 || g2)) || (t[i] == 'A' && g1 && g2))
		return res = 1;
	return res = 0;
}

main () {
	pw[0] = 1;
	for (int i = 1; i < N; ++i)
		pw[i] = pw[i - 1] * 10 % 7;

	memset(dp, -1, sizeof(dp));

	fastio
	cin >> n >> s >> t;
	puts(rec(0, 0) ? "Takahashi" : "Aoki");
}


#include <iostream>
using namespace std;
int main()
{
  int n;
  double x;
  cin >> n >> x;
  x *= 100;
  for (int i = 0; i < n; i++)
  {
      int v, p;
      cin >> v >> p;
      x -= v * p;
      if (x < 0)
      {
          cout << i+1; return 0;
      }
      else {if (i == n-1)
      {
          cout <<  -1; return 0;
      }}
  }
}

#include <cstdio>
#include <vector>
using namespace std;

int main(int argc, char** argv)
{
	char c, s[200005];
	int len = 0;
	while((c = getchar()) != '\n');
	while((c = getchar()) != '\n')
	{
		s[len++] = c;
		if(len >= 3 && s[len - 3] == 'f'
					&& s[len - 2] == 'o'
					&& s[len - 1] == 'x')
			len -= 3;
	}
	printf("%d\n", len);
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_set>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using i64 = long long;
template<class T, class U>
bool chmin(T& a, const U& b) { return (b < a) ? (a = b, true) : false; }
template<class T, class U>
bool chmax(T& a, const U& b) { return (b > a) ? (a = b, true) : false; }

template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}

int main(){
    int n, q;
    cin >> n >> q;
    vector<i64> a(n);
    cin >> a;
    sort(all(a));
    set<i64> s;
    for (auto i: a) s.insert(i);
    vector<i64> ans;
    while (q--){
        i64 k;
        cin >> k;
        i64 ok = 2e18, ng = 0;
        while (ok - ng > 1){
            i64 mid = (ok + ng) / 2;
            auto x = upper_bound(all(a), mid) - a.begin();
            if (mid - x >= k) ok = mid;
            else ng = mid;
        }
        while (s.count(ok)) ok++;
        ans.emplace_back(ok);
    }
    for (auto i: ans) cout << i << "\n";
}

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

int main()
{
  	int a,b;
  	cin>>a>>b;
	int y=(a-b)/2;
	cout<<b+y<<" "<<y;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using Pii = pair<int, int>;
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) rep2(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

#define INF (ll)1e9

const int mod = 1e9 + 7;
const int di[4] = {0, 1, 0, -1};
const int dj[4] = {1, 0, -1, 0};

const int di2[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj2[8] = {1, 0, -1, 0, 1, -1, 1, -1};

bool get(int m, int h) {
  if(h % m == 0) return true;
  else return false;
}

int main() {
  int m, h;
  cin >> m >> h;
  if(get(m, h)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int v,t,s,d,a,s1,flag=0;
    cin>>v>>t>>s>>d;
    a=v*t;
    for(int i=t; i<=s; i++)
    {

        if((d>=(v*i)&&(d<=(v*s))))
        {
            flag=1;
            break;
        }

    }
    if(flag==1)

    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}


#include<iostream>

using namespace std;

int main()
{

	int a,b;
	cin>>a>>b;
	int x=(a+b)/2;
	cout<<x<<" "<<a-x<<endl;

	return 0;
 }

#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
   a = a / b;
   cout << a << endl;
}


#include<bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
template<class T>void read(T&x) {
	T f=1;x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	x*=f;
}
template<class T>void print(T x,char c) {
	if(x<0)putchar('-'),x=-x;int s[20],top=0;
	while(s[++top]=x%10,x/=10);
	while(top)putchar(s[top--]+'0');putchar(c);
}
int n;
int main() {
	read(n);
	for(int i=1; i<=n; ++i)if((i+1)*i/2 >= n)print(i,'\n'),exit(0);
}

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

int main(){
  int n;
  cin >> n ;
  int sum = 0;
  for(int i=0;;i++){
    sum += i;
    if(sum >= n){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

//vector <long long> v[1000001];

//stack <long long> s, s2;
//bbbbaaaa
//queue <long long> s, s2;

long long int  z[1], x[1][3], y[1][2], m, szu, wy[100][100];
char s[10000000];

long long nwd(long long a, long long b)
{
    while(a*b)
    {
        if(a>b)swap(a, b);
        b%=a;
    }
    return(a+b);
}

int main()
{
    long long int chu, d, e, f, i, j, q, t, k, a, n, b, c, w, p, aa, bb, cc, dd, nn, kk;

    t=1;
    //scanf("%lld", &t);
    for(q=1; q<=t; q++)
    {
        scanf("%lld%lld", &n, &a);

        for(i=1; i<n; i++)
        {
            scanf("%lld", &b);
            a=nwd(a, b);
        }
        printf("%lld\n", a);
    }

    return(0);
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair

typedef vector<int> vi;
typedef pair<int,int> pi;
#define REP(i,a,b) for (int i = a; i <= b; i++)

void solve(){

int a,b,c;
cin>>a>>b;

if(a == b){cout<<a;return;}

if(a==0){
    if(b == 1){
        cout<<2;return;
    }
    cout<<1;return;
}
else if(a == 1){
    if(b == 2){
        cout<<0;return;
    }
    cout<<2;return;
}
else{
        if(b == 1){
        cout<<0;return;
    }
    cout<<1;return;
}

}

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n =1;
// cin>>n;
while(n--){
    // cout<<n;
    solve();
}
}


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

using namespace std;
constexpr int INF = 168430090;
int x[17], y[17], z[17], dist[17][17], dp[17][131072];

int main()
{
    memset(dp, 10, sizeof(dp));
	dp[0][1] = 0;
	int N; scanf("%d", &N);
	for(int i = 0; i < N; i++)scanf("%d%d%d", &x[i], &y[i], &z[i]);
	int NUM = (1<<N);

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			dist[i][j] = abs(x[i] - x[j]) + abs(y[i] - y[j]) + max(0, z[j] - z[i]);
		}
	}

	for(int bit = 1; bit < NUM; bit++) {
		for(int i = 0; i < N; i++) {
			if(!((1<<i) & bit) || dp[i][bit] == INF)continue;
			for(int j = 0; j < N; j++) {
				if((1<<j) & bit)continue;
				dp[j][bit | (1<<j)] = min(dp[j][bit | (1<<j)], dp[i][bit] + dist[i][j]);
			}
		}
	}

	int ans = INF;
	while(--N) {
		ans = min(ans, dp[N][NUM - 1] + dist[N][0]);
	}
	printf("%d\n", ans);
}

#include<bits/stdc++.h>
using namespace std;
long int min=-1;
void find_min(long int m)
{
  if(::min==-1)
  {
    ::min=m;
    return;
  }
  if(m<(::min))
    ::min=m;
}
int main()
{
  long int n,**a,i;
  cin>>n;
  a=new long int*[n];
  for(i=0;i<n;i++)
  {
    a[i]=new long int[3];
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    if(a[i][2]-a[i][0]>0)
      find_min(a[i][1]);
  }
  cout<<::min<<endl;
  return 0;
}


// #pragma GCC optimize("O3") // (code on steroids)
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define int ll
# define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
# define len(x) (ll((x).size()))

# define print(x) cout<<(x)<<"\n"
# define P0(x) cout<<(x)<<' '
# define P1(x) cout<<(x)<<"\n"
# define P2(x,y) cout<<(x)<<' '<<(y)<<"\n"
# define P3(x,y,z) cout<<(x)<<' '<<(y)<<' '<<(z)<<"\n"
# define P4(x,y,z,w) cout<<(x)<<' '<<(y)<<' '<<(z)<<' '<<(w)<<"\n"

// using auto in for
# define printv(v) {auto kjhg = v;for(auto idnphq : kjhg) cout<< idnphq << ' ';cout << "\n";}
# define printvv(v) {auto kjhg = v;for(auto idnphq : kjhg) {for(auto plinrw : idnphq) cout<< plinrw << ' ';cout << "\n";}}
# define prints(s) {auto kjhg = s;for(auto idnphq : kjhg) cout<< idnphq << ' ';cout << "\n";}
# define printm(m) {auto kjhg = m;for(auto idnphq : kjhg) cout<< idnphq.first << ':' << idnphq.second << ' ';cout << "\n";}

// for runtime errors (assertions and segmentation faults)
# define debug(x) {\
    cout<<"all good "<<x<<"\n";\
    exit(0);\
}

int isl(vector<int> a){
	return(a[0]<=2);
}
int isr(vector<int> a){
	return(a[0]%2);
}

int f(vector<int> a, vector<int> b){
	// case 1 if left corrdinates are equal
	if(b[1]==a[1]){
		return(1);
	}
	// case two unequal
	if(b[1]<a[1]) swap(a,b);// a is now the one with lesser left coordinate
	if(a[2]>b[1]){
		return(1);
	}else if(a[2]==b[1]){
		int fl = isr(a) && isl(b);
		return(fl);
	}else{
		return(0);
	}
}

int32_t main(){
fastio;

int n; cin>>n;

vector<vector<int>> a = {};
for(int i = 0; i<n ; i++){
	vector<int> dat(3);
	cin>>dat[0]>>dat[1]>>dat[2];
	a.push_back(dat);
}
// printvv(a);
int cnt = 0;
for(int i = 0; i<n ; i++){
	for( int j = i+1; j<n ; j++){
		cnt+=f(a[i],a[j]);
		// print(f(a[i],a[j]));
	}
}

print(cnt);

return(0);
}

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

typedef long long ll;
#define ephsilon 1e-9
#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod = 1e9+7;
const long long mod1 = 998244353;
const int maxN = 2e5+1;
const int mx = 1e5+1;

int32_t main()
{
    fastio;
    int n;
    double a,b;
    cin>>n;
    vector<pair<double,double>>v;
    int t;
    for(int i=0;i<n;i++)
    {
        cin>>t>>a>>b;
        if(t==2)b-=.1;
        else if(t==3)a+=.1;
        else if(t==4)a+=.1,b-=.1;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            double l1=v[i].first,r1=v[i].second;
            double l2=v[j].first,r2=v[j].second;

            if(l1>r2 || r1<l2)continue;
            else ans++;
        }
    }
    cout<<ans<<"\n";

return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <string>
#include <algorithm>
#include <tuple>
#include <array>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

int main()
{
    ll L;
    cin >> L;

    ll dp[L][12];

    for (int i = 0; i < L; ++i) {
        for (int j = 0; j < 12; ++j) {
            if (i == 0 || j > i) {
                dp[i][j] = 0;
            } else if (j == 0 || i==j) {
                dp[i][j] = 1;
            } else {
                dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
            }
        }
    }

    cout << dp[L-1][11];
    return 0;
}

#include<iostream>
#include<cmath>

using namespace std;
int  main()
{
   long long int n;
   cin>>n;
   long long int c=0,x=0;

   long long int h=1e10,l=0;
long long int m=0;

   while(h-l>1)
    {
        m=l+(h-l)/2;

       if(m*(m+1)/2<=n+1)
       {
           l=m;
       }
       else

       {
           h=m;
       }

   }
   //cout<<l<<" ";
   cout<<n-l+1;
}


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

int main()
{
    ll k, n, m;
    cin >> k >> n >> m;

    vector<ll> a(k);
    for (int i = 0; i < k; i++)
    {
        cin >> a[i];
    }

    vector<ll> b(k);
    vector<pair<ll, ll>> d(k);
    ll sum = 0;
    for (int i = 0; i < k; i++)
    {
        b[i] = a[i] * m / n;
        d[i].first = a[i] * m % n;
        d[i].second = i;

        sum += b[i];
    }

    // a[i] * m % n が大きい順に1足す
    sort(d.begin(), d.end(), [](pair<ll, ll> a, pair<ll, ll> b) {
        return a.first > b.first;
    });
    const ll addNum = m - sum;

    for (ll i = 0; i < addNum; i++)
    {
        b[d[i].second]++;
    }

    for (auto const v : b)
    {
        cout << v << " ";
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

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

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

signed main(){
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int k,n,m;
  cin>>k>>n>>m;
  int a[k];
  rep(i,k){
    cin>>a[i];
    a[i]*=m;
  }
  int ans[k]={};
  int sum=0;
  priority_queue<PII> p;
  rep(i,k){
    ans[i]=((a[i]*2)+n)/(n*2);
    //cout<<ans[i]<<" "<<a[i]<<endl;
    sum+=ans[i];
    //cout<<sum<<endl;

  }
  //cout<<sum<<endl;
  if(sum<m){
    rep(i,k){
      p.push({((n+a[i]+((n)/2)))%n,i});
      //cout<<-((n+a[i]-((n+1)/2)))%n<<endl;
    }
    while(sum<m){
      PII now=p.top();
      p.pop();
      sum++;
      ans[now.S]++;
      now.F-=n;
      p.push(now);
    }
  }
  if(sum>m){
    rep(i,k){
      p.push({-(n+a[i]+((n)/2))%n,i});
      //cout<<(a[i]+(n/2))%n<<endl;
    }

    while(sum>m){
      PII now=p.top();
      p.pop();
      sum--;
      ans[now.S]--;
      now.F-=n;
      p.push(now);
    }
  }
  rep(i,k){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;

  return 0;
}


#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }

//---------- 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); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	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; }

mint m_comb(mint n, mint r)
{
	int i;
	mint p = 1;
	for (i = 1; i <= r.x; i++)
	{
		p *= n - i + 1;
		p /= i;
	}
	return p;
}
mint m_comb_with_rep(mint n, mint r)
{
	return m_comb(n + r - 1, r);
}
mint m_perm(mint n, mint r)
{
	mint a = 1;
	for (int i = n.x; i > n.x - r.x; i--)
	{
		a *= i;
	}
	return a;
}

int N;
int A[200001];

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	ARY_SORT(A, N);

	mint ans = 0;
	mint sum = 0;
	mint b = 1;

	for (int i = 1; i < N; i++)
	{
		mint a = A[0] * A[i];
		sum += a * b;
		b *= 2;
	}

	ans = sum;

	for (int i = 0; i < N - 1; i++)
	{
		sum -= (A[i] * A[i + 1]);
		sum /= 2;
		sum /= A[i];
		sum *= A[i + 1];
		ans += sum;
	}

	for (int i = 0; i < N; i++)
	{
		mint a = A[i] * A[i];
		ans += a;
	}

	cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 1, inf = 1e9, mod = 998244353;
ll modpow(ll x, ll p){
    ll ans = 1;
    for (ll i = p; i; i >>= 1, x = x * x % mod) if (i & 1) ans = ans * x % mod;
    return ans;
}
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    ll a[n], pre[n], ans = 0;
    for (ll &i : a) cin >> i;
    sort(a, a + n);
    for (int i = 0; i < n; i++) pre[i] = ((i ? pre[i - 1] : 0) + a[i] * modpow(2, i)) % mod;
    for (int i = 0; i < n; i++){
        ll tmp = a[i] * (pre[n - 1] - pre[i]) % mod;
        tmp = tmp * modpow(modpow(2, i + 1), mod - 2) % mod;
        ans = (ans + tmp + a[i] * a[i]) % mod;
    }
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
#define F(index,start,end) for(ll index=start;index<end;++index)
#define IA(array,size) F(index,0,size) cin >> array[index]
#define IA2(array,height,width) F(i,0,height) F(j,0,width) cin >> array[i][j]
#define PA(array,size) F(index,0,size)  { cout << array[index]; if(index!=size-1) cout << " ";} cout << endl
#define PA2(array,height,width) F(i,0,height) {F(j,0,width) cout << array[i][j]; cout << endl;}
#define P(str) cout << str << endl
constexpr int32_t MOD=1000000007;

int main(){
    ll n,m;
    cin>>n>>m;
    if(m==0){
        cout << 1 << endl;
        return 0;
    }
    ll a[m];
    IA(a,m);
    if(n==m){
        cout << 0 << endl;
        return 0;
    }
    sort(a,a+m);

    vll d;
    if(a[0]-1!=0) d.push_back(a[0]-1);
    F(i,1,m){
        if(a[i]-a[i-1]-1!=0) d.push_back(a[i]-a[i-1]-1);
    }
    if(n-a[m-1]!=0) d.push_back(n-a[m-1]);

    sort(d.begin(),d.end());
    ll sum=0;
    for(auto dd:d){
        sum+=ll(ceil(double(dd)/d[0]));
    }
    cout << sum << endl;
    return 0;
}

#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {

  ll N, W;
  cin >> N >> W;
  vector<ll> S(N), T(N), P(N);
  rep(i,N) cin >> S[i] >> T[i] >> P[i];

  priority_queue<pair<ll, LLP>, vector<pair<ll, LLP>>, greater<pair<ll, LLP>>> wait;
  priority_queue<LLP, vector<LLP>, greater<LLP>> now;

  rep(i,N) {
    pair<ll, LLP> k = make_pair(S[i], make_pair(T[i], P[i]));
    wait.push(k);
  }

  ll demand = 0;
  rep(i,200000) {
    while (!wait.empty() && wait.top().first <= i) {
      LLP next = wait.top().second; wait.pop();
      now.push(next);
      demand += next.second;
    }
    while (!now.empty() && now.top().first <= i) {
      demand -= now.top().second;
      now.pop();
    }
    if (demand > W) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<int,P>;
using PP = pair<P, P>;
constexpr int INF32 = 1 << 29;
constexpr ll INF64 = 1LL << 61;
constexpr ll MOD = 1000000007;
// constexpr ll MOD = 998244353;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-10;
const double PI = acos(-1);

#define ALL(v) (v).begin(),(v).end()
#define REP(i,n) for(int i=0,i_len=n; i<i_len; ++i)

template<typename T1,typename T2> bool chmax(T1 &a, T2 b) { if (a<b) { a=b; return 1; } return 0; }
template<typename T1,typename T2> bool chmin(T1 &a, T2 b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<10000;i++){
        string t = to_string(i);
        while(t.size() < 4) t.insert(t.begin(),'0');
        bool valid = true;
        for(int j=0;j<10;j++){
            if(s[j]=='o'){
                valid &= t.find('0'+j) != t.npos;
            }
            if(s[j]=='x'){
                valid &= t.find('0'+j) == t.npos;
            }
        }
        if(valid) ans++;
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;

ll cnt[3];

// ll solve(ll a, ll b, ll c){
//     if (a>4) return 0;
//     if (a==4) return 24;
//     if (a==3){
//         if (c==0) return 81-solve(1,b,1)-solve(1,b,2);
//         else return solve(a,b,0)+24*c;
//     }
//     if (a==2){
//         if (c==0) return 16-2;
//         if (c==1) return solve(3,7,0)+solve(a,b,0);
//         if (c==2) return solve(4,6,0)+solve(a,b,1);
//         if (c==3) return 3*solve(4,6,0)
//     }

// }

ll combi(ll a, ll b){
    if (a==b) return 1;
    if (2 * b > a) return combi(a, a-b);
    ll ret = 1;
    for(ll i=0; i<b; i++){
        ret *= (a-i);
    }
    for(ll i=1; i<=b; i++){
        ret /= i;
    }
    return ret;
}

// 4桁の数字をa個の文字を使って作る方法
ll make_four_digits(ll a){
    if (a==4) return 24;
    if (a==3) return 81-combi(3,2)*make_four_digits(2)-combi(3,1)*make_four_digits(1);
    if (a==2) return 16-combi(2,1)*make_four_digits(1);
    if (a==1) return 1;
    else return 0;
}

ll solve(ll a, ll b, ll c){
    if (a>4) return 0;
    if (a==4) return make_four_digits(4);
    if (a==3){
        if (c==0) return make_four_digits(3);
        if (c==1) return make_four_digits(3) + make_four_digits(4);
        else return make_four_digits(3) + c*make_four_digits(4);
    }else if (a==2){
        if (c==0) return make_four_digits(2);
        if (c==1) return make_four_digits(2) + make_four_digits(3);
        else return make_four_digits(2) + combi(c,1)*make_four_digits(3) + combi(c,2)*make_four_digits(4);
    }else if (a==1){
        if (c==0) return 1;
        if (c==1) return make_four_digits(1)+make_four_digits(2);
        if (c==2) return make_four_digits(1) + combi(2,1)*make_four_digits(2) + combi(2,2)*make_four_digits(3);
        else return make_four_digits(1) + combi(c,1)*make_four_digits(2) + combi(c,2)*make_four_digits(3) + combi(c,3)*make_four_digits(4);
    }else{ // (a==0)
        if (c==0) return 0;
        if (c==1) return 1;
        if (c==2) return combi(2,1)*make_four_digits(1) + combi(2,2)*make_four_digits(2);
        if (c==3) return combi(3,1)*make_four_digits(1) + combi(3,2)*make_four_digits(2) + combi(3,3)*make_four_digits(3);
        else return combi(c,1)*make_four_digits(1) + combi(c,2)*make_four_digits(2) + combi(c,3)*make_four_digits(3) + combi(c,4)*make_four_digits(4);
    }
}

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

    for(ll i=0; i<S.size(); i++){
        if (S[i]=='o') cnt[0]++;
        else if (S[i]=='x') cnt[1]++;
        else cnt[2]++;
    }

    cout << solve(cnt[0], cnt[1], cnt[2]) << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

long long calc_score(string s)
{
  long long score = 0;
  for (char c = '1'; c <= '9'; c++)
  {
    int cnt = 0;
    rep(i, s.size())
    {
      if (c == s[i])
        cnt++;
    }

    int tmp = (c - '0');
    rep(j, cnt)
    {
      tmp *= 10;
    }

    score += tmp;
  }

  return score;
}

long long calc_cases(string s, string t, int K)
{
  vector<int> rest(10, K);
  rep(i, 4)
  {
    rest[s[i] - '0']--;
  }
  rep(i, 4)
  {
    rest[t[i] - '0']--;
  }

  long long cases = rest[s[4] - '0'];
  rest[s[4] - '0']--;
  cases *= rest[t[4] - '0'];

  return cases;
}

int main()
{
  int K;
  cin >> K;

  string S, T;

  cin >> S >> T;

  vector<int> rest(10, K);
  rep(i, S.size())
  {
    rest[S[i] - '0']--;
  }
  rep(i, T.size())
  {
    rest[T[i] - '0']--;
  }

  double cases = 0;
  for (char c = '1'; c <= '9'; c++)
  {
    if (rest[c - '0'] == 0)
      continue;

    string s = S;
    s[4] = c;
    for (char c2 = '1'; c2 <= '9'; c2++)
    {
      if (rest[c2 - '0'] == 0 || (c == c2 && rest[c2 - '0'] == 1))
        continue;

      string t = T;
      t[4] = c2;

      if (calc_score(s) > calc_score(t))
      {
        cases += calc_cases(s, t, K);
      }
    }
  }

  cout << std::fixed << std::setprecision(10) << cases / (K * 9 - 8) / (K * 9 - 8 - 1) << endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp1  make_pair
#define     REP(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        ll a,b,w,mn,mx;
        cin>>a>>b>>w;
        w=w*1000;
      mx=w/a; mn=ceil(w/(b*1.00));
      if(mn>mx) cout<<"UNSATISFIABLE"<<endl;
      else cout<<mn<<" "<<mx<<endl;

    }
}


#include <bits/stdc++.h>
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
typedef double DB;
typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
// head
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    LL n;int k;cin>>n>>k;
    for(int i=1;i<=k;i++) {
        if(n%200==0) n/=200;
        else n=n*1000+200;
    }
    cout<<n<<'\n';
    return 0;
}

/*Name-Dipesh
Location-Somewhere in interstellar
W/A is inevitable*/
#include <algorithm>
#include <array>
#include <cassert>
#include<bits/stdc++.h>
#include <chrono>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include<unordered_map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
#define Super_schnell ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test() long long t; cin>>t; while(t--)
#define comp(v) v.begin(),v.end()
#define sortv(v) sort(comp(v))
#define vecfind(v,key) (find(all(v),key)!=v.end())
#define vecdelp(v,pos) v.erase(v.begin()+pos)
#define setfind(v,key) (v.find(key) != v.end())
#define mapfind(m,key) (mp.find(key) != mp.end())
#define print(i) cout<<i<<"\n"
#define veccount(v,key) (count(all(v),key))
#define setcount(s,key) (s.count(key))
#define bitcount(i) __builtin_popcount(i)
#define int long long
#define ull unsigned long long
#define db double
#define inf 1000000007
#define mod 1000000007
#define veci vector<long long>
#define vecs vector<string>
#define mp make_pair
#define pqueue priority_queue< long long >
#define pdqueue priority_queue< long long,vi ,greater< long long > >
#define pi 3.14159265358979323846
#define mem(x , v) memset((x) , (v) , sizeof(x))
using namespace std;

int gcd(int a,int b){
    while(b){
        a%=b;
        swap(a,b);
    }
    return a;}
    int square(int num)
{

    if (num < 0) num = -num;

    int result = 0, times = num;

    while (times > 0)
    {
        int possibleShifts = 0, currTimes = 1;

        while ((currTimes << 1) <= times)
        {
            currTimes = currTimes << 1;
            ++possibleShifts;
        }

        result = result + (num << possibleShifts);
        times = times - currTimes;
    }

    return result;
}

char reVal(int num)
{
    if (num >= 0 && num <= 9)
        return (char)(num + '0');
    else
        return (char)(num - 10 + 'A');
}

int32_t main()
{

int n,k;
cin>>n>>k;
while(k--)
{
if(n%200==0)
{
n=n/200;
}
else
{
  n=(n*1000)+200;

}
}
cout<<n;
}


//The moment you giveup , is the moment you let someone else win!!!
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define PI (3.141592653589)
#define seal(x,y) ((x+y-1)/y)
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define all(x) x.begin(),x.end()

int digit_sum(int n){
int sum=0;
while(n)
sum+=(n%10),n/=10;
return sum;
}

//int digicnt_fact(int n)
//{
//if(n<0) return 0;  //factorial doesn't exist
//if(n<=1) return 1; //base case
//double x=((n * log10(n / M_E) +log10(2 * M_PI * n) /2.0));  //Kamenetsky's formula
//return floor(x)+1;
//}
void solve(){
 int n;cin>>n;
 int a[n];
 rep(i,n)
 cin>>a[i];
 int ans=0;
 unordered_map<int,int> m;
 for(int i=n-1;i>=0;i--)
 {
     ans+=(n-1-i-m[a[i]]);
     m[a[i]]++;
 }
 cout<<ans;
}

int32_t main()
{
fast
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <map>
#include<stack>
#include <cmath>

using namespace std;

char judge(string Input){
  if(Input=="RP" || Input=="PR"||Input =="PP")return 'P';
  if(Input=="RS" || Input=="SR"||Input =="RR")return 'R';
  if(Input=="PS" || Input=="SP"||Input =="SS")return 'S';
}

void solve(){
  int n,k;
  scanf("%d %d",&n,&k);
  string Input,Output="",temp="";
  cin>>Input;
  while(k>0){
    Input = Input + Input;
    Output="";
    for(int i=0;i<Input.length();i+=2){
      temp= "";
      temp+=Input[i];
      temp+=Input[i+1];
      Output += judge(temp);
    }
    Input=Output;
    k--;
  }
  cout<<Input[0]<<endl;

}

int main()
{
  int t=1,i=1;
  //scanf("%d",&t);
  while(t--){
    //cout<<"Case #"<<i<<":";
    solve();
    i++;
  }
  return 0;
}


#include<iostream>
using namespace std;

int main(){
    int n;cin>>n;
    int xy[110][2]={0};
    bool f=false;
    for(int i=0;i<n;++i)cin>>xy[i][0]>>xy[i][1];
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n-1;++j){
            for(int k=j+1;k<n;++k){
                int x1=xy[i][0]-xy[k][0];
                int y1=xy[i][1]-xy[k][1];
                int x2=xy[j][0]-xy[k][0];
                int y2=xy[j][1]-xy[k][1];
                if(x1*y2==x2*y1)f=true;
            }
        }
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define pb           push_back
#define mp           make_pair
#define pf printf
#define ff first
#define ss second
#define sef second.first
#define ses second.second
#define PI 3.14159265 /// tan inverse = atan(value)*(180/PI)

#define ms(a,b)            memset(a, b, sizeof(a))
#define lp(i,a,b) for (int i = a; i <= b; i++)
#define pii                pair <int,int>

#define SL(a)              scanf("%I64d",&a)
#define SLL(a,b)           scanf("%I64d %I64d",&a,&b)
#define PL(x) printf("%I64d\n",(x))
#define PLL(x,y) printf("%I64d %I64d\n",x,y)

#define S(a)              scanf("%d",&a)
#define SS(a,b)           scanf("%d %d",&a,&b)
#define P(x) printf("%d\n",(x))
#define PP(x,y) printf("%d %d\n",x,y)
using namespace std ;
typedef long long ll ;
const int imin = 1e9+100;
const ll maxx = 1e5+10,mod=1e9+7,imax=1e18+10;
int main()
{
   ll n,a=0,b=mod ;
   cin >> n ;
   for(int i=1;i<=n;i++)
   {
       ll x ;
       cin >> x ;
       a = max(x,a);
   }
    for(int i=1;i<=n;i++)
   {
       ll x ;
       cin >> x ;
       b = min(x,b);
   }
   ll ans = max(0LL,b-a+1);
   cout << ans << endl;
   return 0 ;
}


#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <array>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template < typename T >
ostream& operator<<(ostream& os, vector< T >& v) {
    os << "{";
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i < v.size() - 1 ? ", " : "");
    }
    os << "}";
    return os;
}
// pair出力
template < typename T, typename U >
ostream& operator<<(ostream& os, const pair< T, U >& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template < typename T, typename U >
ostream& operator<<(ostream& os, const map< T, U >& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template < typename T >
ostream& operator<<(ostream& os, const set< T >& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#pragma endregion

/////////////////////////////////////////

int main() {
    int n;cin >> n;
    vector<int> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vector<int> x,y;
    for (int i = 0; i < n; i++) {
        int b;cin >> b;
        if (i & 1) {
            y.push_back(b-a[i]);
        }
        else {
            x.push_back(b-a[i]);
        }
    }
    sort(x.rbegin(), x.rend());
    sort(y.rbegin(), y.rend());
    for (int i = 0; i < x.size(); i++) {
        if (x[i] + y[i] > 0) {
            sum += x[i] + y[i];
        }
    }
    cout << sum << endl;
    return 0;
}

/////////////////////////////////////////

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
//template<class T>T ABS(T x) {return x<0?-x:x;}
//int ksm(int x,int y) {int r=1;while(y) y&1?r=1ll*r*x%mod:0,x=1ll*x*x%mod,y>>=1;return r;}
//char __buf[1<<20],*__p1,*__p2;
//#define getchar() (__p1==__p2?(__p2=__buf+fread(__p1=__buf,1,1<<20,stdin),__p1==__p2?EOF:*__p1++):*__p1++)
int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
const int maxn = 2e5+10;
//const int mod = ;
//struct Edge{int to,next;}a[maxn];int h[maxn],cnt;
//void add(int x,int y) {a[++cnt]=(Edge){y,h[x]},h[x]=cnt,a[++cnt]=(Edge){x,h[y]},h[y]=cnt;}
//vector<int>G[maxn];
//void add(int x,int y) {G[x].push_back(y),G[y].push_back(x);}
struct node{int x,y;
}a[maxn<<1];int n,k;
bool cmp(node x,node y) {return x.x<y.x;}
signed main() {
	n=read(),k=read();
	for(int i=1;i<=n;i++) a[i]=(node){read(),read()};
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
		if(k>=a[i].x) {
			k+=a[i].y;
		}
		else break;
	cout<<k<<'\n';
	return 0;
}


//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
//using mint = modint998244353;
//using mint = modint1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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

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

  string G="atcoder";
  ll T; cin>>T;
  rep(_,T){
    string S; cin>>S;
    ll N=S.size();
    auto MS=S;
    sort(MS.rbegin(),MS.rend());
    if(G>=MS) {cout<<-1<<'\n'; continue;}
    ll ans=INF;
    vector<ll> vec(7,-1);
    rep(i,N){
      rep(j,7){
        if(S[i]==G[j]&&vec[j]==-1) vec[j]=i;
      }
    }
    //for(auto v:vec) cout<<v<<'\n';
    rep(i,8){
      ll sans=0;
      rep(j,i){
        if(vec[j]==-1) goto OUT;
        sans+=abs(vec[j]-j);
      }
      int piyo=0;
      rep(j,N){
        int hoge=0;
        rep(k,i){
          if(j==vec[k]) hoge=1;
        }
        if(hoge) continue;
        if(S[j]>(i==7?'a'-1:G[i])){
          sans+=abs(j-i);
          piyo=1;
          //cout<<i<<' '<<j<<'\n';
          break;
        }
      }
      //cout<<i<<' '<<sans<<'\n';
      if(piyo) chmin(ans,sans);
    }
    OUT:;

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

/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}

int main(){
    int w, x, y, z;
    cin >> w >> x >> y >> z;
    cout << w * z - x * y;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
using ll = long long;
using pii = pair<int, int>;

ll f(ll n){
    if (n % 200 == 0) n /= 200;
    else n = n * 1000 + 200;
    return n;
}

int main(){
    ll n,k;
    cin >> n >> k;
    rep(i,k) n = f(n);
    cout << n << endl;
}

#include <iostream>
#include <string>
#include <iomanip>
#include <sstream>
#include <istream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int max(int, int);
int min(int, int);
int positiveNum(int);
unsigned long long factorial(int);
unsigned long long combination(int, int);
long long power(int, int);
bool between(int, int, int);
vector<string> split(string, char);
int digit_sum(int);
vector<long long> divisors(long long);
//cout << fixed << setprecision(15) << y << endl;
long long count_comb(long long, long long);

int main()
{
  long long n, k;
  cin >> n >> k;

  long long count = 0;

  for(long long i = 2; i <= 2 * n; i++)
  {
    if(count_comb(i, n) > 0 && count_comb(i + k, n) > 0)
    {
      count += count_comb(i, n) * count_comb(i + k, n);
    }
  }

  cout << count << endl;

  return 0;
}

long long count_comb(long long num, long long n)
{
  if(num <= n + 1)
  {
    return num - 1;
  }
  else
  {
    long long ans = n - (num - (n + 1));
    if(ans >= 0)
    {
      return ans;
    }
    else
    {
      return 0;
    }
  }
}

//2つの整数のうち大きい方を返す
int max(int a, int b)
{
  if(a > b)
  {
    return a;
  }
  else
  {
    return b;
  }
}

//2つの整数のうち小さい方を返す
int min(int a, int b)
{
  if(a < b)
  {
    return a;
  }
  else
  {
    return b;
  }
}

//入力が正ならその値，負なら0を返す
int positiveNum(int x)
{
  if(x >= 0)
  {
    return x;
  }
  else
  {
    return 0;
  }
}

//階乗
unsigned long long factorial(int n)
{
  unsigned long long ans = 1;

  for(int i = 1; i <= n; i++)
  {
    ans *= i;
  }

  return ans;
}

//mの中からn取る組み合わせの数
unsigned long long combination(int m, int n)
{
  return factorial(m) / (factorial(m-n)*factorial(n));
}

//cがaとbの間にあるか
bool between(int a, int b, int c)
{
  if(a > b)
  {
    int swap;
    swap = a;
    a = b;
    b = swap;
  }
  if(a <= c && c <= b)
  {
    return true;
  }
  else
  {
    return false;
  }
}

//累乗(long long版)
long long power(int x, int y)
{
  long long num = 1;

  for(int i = 0; i < y; i++)
  {
    num *= x;
  }

  return num;
}

//カンマ等で区切られた文字列を要素で分ける
vector<string> split(string s, char c)
{
  vector<string> v;

  stringstream ss{s};
  string buf;

  while(getline(ss, buf, c))
  {
    v.push_back(buf);
  }

  return v;

}

//各桁の和を求める
int digit_sum(int x)
{
  int sum = 0;

  while(x > 0)
  {
    sum += x % 10;
    x /= 10;
  }

  return sum;
}

//Nの約数を求める
vector<long long> divisors(long long N)
{
  vector<long long> a;

  for (long long i = 1; i * i <= N; i++)
  {
    if (N % i == 0)
    {
      a.push_back(i);
      if (N/i != i)
      {
        a.push_back(N/i);
      }
    }
  }

  sort(a.begin(), a.end());

  return a;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

using namespace std;
using ll = long long int;
using P = pair<int, int>;

const ll INF_L = 1LL << 60;
const int INF_I = 1 << 30;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

int main()
{
    int n;
    cin >> n;
    complex<double> a, b;
    rep(i, 2)
    {
        double x, y;
        cin >> x >> y;
        if (!i)
            a = {x, y};
        else
            b = {x, y};
    }

    auto m = (a + b) / 2.0;
    auto res = m + (a - m) * polar(1.0, 2.0 * PI / n);

    printf("%.10f\n%.10f\n", res.real(), res.imag());
    return 0;
}