#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  int n;
  cin >> n;
  int ar[n], it = n - 1;
  stack<pair<ll, int>> st;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    ll ss = ar[i];
    int c = 1;
    while (st.size() && (st.top().first * c > ss * st.top().second)) {
      ss += st.top().first;
      c += st.top().second;
      st.pop();
    }
    st.push(make_pair(ss, c));
  }
  double ans[n];
  while (st.size()) {
    for (int i = it; i > it - st.top().second; i--) {
      ans[i] = (double)(st.top().first) / (double)(st.top().second);
    }
    it -= st.top().second;
    st.pop();
  }
  for (int i = 0; i < n; i++) {
    cout << setprecision(12) << ans[i] << "\n";
  }
}

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //convex hoe
         ArrayList<Integer> lsX = new ArrayList<Integer>();
         ArrayList<Long> lsY = new ArrayList<Long>();
         lsX.add(0);
         lsY.add(0L);
         long sum = 0L;
         for(int i=1; i <= N; i++)
         {
            sum += arr[i-1];
            if(lsX.size() == 1)
            {
               lsX.add(i);
               lsY.add(sum);
               continue;
            }
            int M = lsX.size();
            long prev = (lsY.get(M-1)-lsY.get(M-2))*(i-lsX.get(M-1));
            long curr = (sum-lsY.get(M-1))*(lsX.get(M-1)-lsX.get(M-2));
            while(M >= 2 && prev > curr)
            {
               lsX.remove(M-1);
               lsY.remove(M-1);
               M--;
               if(M < 2)
                  break;
               prev = (lsY.get(M-1)-lsY.get(M-2))*(i-lsX.get(M-1));
               curr = (sum-lsY.get(M-1))*(lsX.get(M-1)-lsX.get(M-2));
            }
            lsX.add(i);
            lsY.add(sum);
         }
         int M = lsX.size();
         StringBuilder sb = new StringBuilder();
         for(int i=0; i < M-1; i++)
         {
            long len = lsX.get(i+1)-lsX.get(i);
            long sum1 = lsY.get(i+1)-lsY.get(i);
            double val = 1.0*sum1/len;
            for(int a=0; a < len; a++)
               sb.append(val).append(" ");
         }
         System.out.println(sb);
      }
   }


import java.util.Arrays;
import java.util.Scanner;

public class CodeTest {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int x=sc.nextInt();
		int count=0;
		String str="";
		int pass=0;
		while(count<x-1)
		{
			if(pass%2==0)
			{
				str+="1";
				b--;
			}
			else
			{
				str+="0";
				a--;
			}
			pass++;
			count=str.length()-1;
		}
		//System.out.println(" count is "+count);
		if(str.endsWith("0"))
		{
			count++;
			if(count!=x||b==0)
			{
				str="0"+str;
				a--;
			}
			while(a-->0)
			{
				str+="0";
			}

			while(b-->0)
			{
				str+="1";
			}

		}
		else
		{
			while(b-->0)
				str+="1";
			while(a-->0)
				str+="0";
		}
		System.out.println(str);
	}
}


import java.util.*;
public class PerfectSquares {

	private static final double Ep = Math.pow(10, -9);
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> a = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			a.add(sc.nextInt());
		}
		a.sort(Collections.reverseOrder());
		for(int i = 0; i < n; i++) {
			int key=a.get(i);
//			System.out.println(Math.sqrt(16));
//			System.out.println(Math.sqrt(64));
//			System.out.println(Math.sqrt(56));
//			System.out.println(isSquare(key));
			if(!isSquare(key)) {
				System.out.println(key);
				break;
			}
		}
		sc.close();

	}

	private static boolean isSquare(int key) {

		for(int i = 0; i < (int)Math.sqrt(key)+1; i++) {
//			System.out.println(i*i-Ep);
//			System.out.println( i*i+Ep);
//			System.out.println(key);
			if(key == i*i) {
				return true;
			}
		}
		return false;
	}

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int max = -10000001;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a < 0) {
      if (a > max) {
        max = a;
      }
    } else {
      int root = sqrt(a);
      if (root * root != a) {
        if (a > max) {
          max = a;
        }
      }
    }
  }
  cout << max << "\n";
  return 0;
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];
            TaskA.Can[] cans = new TaskA.Can[n];
            long sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                sum += a[i];
            }
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            if (n <= 2) {
                out.println("YES");
                return;
            }
            ArrayUtils.sort(b);
            if (sum <= b[n - 2] + b[n - 1]) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

        static class Can implements Comparable<TaskA.Can> {
            int cap;
            int value;

            public Can(int cap, int value) {
                this.cap = cap;
                this.value = value;
            }

            public int compareTo(TaskA.Can o) {
                return Integer.compare(value, o.value);
            }

        }

    }

    static class ArrayUtils {
        public static void sort(int[] arr) {
            int n = arr.length;
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int p = r.nextInt(n + 1);
                if (p < n) {
                    int temp = arr[i];
                    arr[i] = arr[p];
                    arr[p] = temp;
                }
            }
            Arrays.sort(arr);
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

NO YES YES YES NO NO NO YES YES YES NO NO YES NO YES YES YES NO YES NO NO NO YES NO YES YES YES YES NO NO NO NO NO NO NO YES YES YES NO NO YES YES YES NO YES NO YES YES NO NO NO NO YES YES NO NO NO YES YES NO NO YES YES NO NO NO NO NO NO YES YES YES

#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, sum = 0;
  cin >> n;
  long long int b[n];
  for (long long int i = 0; i < n; i += 1) {
    long long int val;
    cin >> val;
    sum += val;
  }
  for (long long int i = 0; i < n; i += 1) {
    cin >> b[i];
  }
  sort(b, b + n);
  if (b[n - 1] + b[n - 2] >= sum)
    cout << "YES";
  else
    cout << "NO";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) solve();
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  list<char> L;
  for (int i = 0; i < s.length(); i++) L.push_back(s[i]);
  list<char>::iterator it1 = L.begin();
  list<char>::iterator it2 = L.begin();
  ++it2;
  for (; it2 != L.end();)
    if (*it1 == *it2) {
      list<char>::iterator tmp1;
      list<char>::iterator tmp2;
      if (it1 == L.begin()) {
        tmp1 = it1;
        ++tmp1;
        ++tmp1;
        tmp2 = it2;
        ++tmp2;
        ++tmp2;
      } else {
        tmp1 = it1;
        --tmp1;
        tmp2 = it2;
        ++tmp2;
      }
      L.erase(it1, ++it2);
      it1 = tmp1;
      it2 = tmp2;
    } else {
      ++it1;
      ++it2;
    }
  for (list<char>::iterator it = L.begin(); it != L.end(); it++) cout << *it;
exit:
  return (0);
}

a xy a rezy wre b babababababababababababa ab wre a

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class polikarp {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		String s = in.next();
		List<Character> L = new ArrayList<Character>();
		for(int i=0;i<s.length();i++){
			if (L.size()==0||s.charAt(i)!=L.get(L.size()-1))
			L.add(s.charAt(i));
			else L.remove(L.size()-1);
		}
		for(int i=0;i<L.size()-1;i++)
			if(L.get(i)==L.get(i+1)){
				L.remove(i); L.remove(i); i-=Math.min(i+1, 2);
			}
		for(int i=0;i<L.size();i++)
		System.out.print(L.get(i));
	}

}


x, y = input().split(" ")
a = x,y
a = list(a)
for i in range(len(a)):
    a[i]=int(a[i])
count=0
num =a[1]
for i in range(a[0]):
    z,f = input().split(" ")
    char=z
    inp=int(f)
    if char == '+':
        num = num + inp
    elif char == '-':
        num = num - inp
        if num < 0:
            count+=1
            num = num+inp

print(num,count)

import java.util.HashSet;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        long ice = input.nextLong();
        char c ;
        long l = 0;
        long distressed = 0;
        for (int i = 0; i < n; i++) {
            c = input.next().charAt(0);
            l = input.nextLong();
            if (c == '+') {
                ice += l;
            } else {
                if (l <= ice) {
                    ice -= l;
                } else {
                    distressed++;
                }
            }

        }
        System.out.print(ice + " " + distressed);

    }
}


#include <bits/stdc++.h>
using namespace std;
long n, m;
int main() {
  scanf("%ld %ld\n", &n, &m);
  if (m == 1 && n == 1)
    printf("%ld", 1);
  else if ((m < n && n / 2 >= m) || m == 1)
    printf("%ld", m + 1);
  else
    printf("%ld", m - 1);
  return 0;
}

n,m = map(int, input().split())
p = [m+int(m<n),m-int(m>1)]
print(p[n-m<=m-1])


ASGDFJH
AHGRSDXGER
3
23 h 15 r
68 h 15 y
79 h 15 y

ASFSHDSG
ADGYRTJNG
5
1 h 1 y
2 h 1 y
3 h 1 y
4 h 1 r
5 h 1 y

MASFF
SAFBDSRG
5
1 h 1 y
15 h 1 r
27 a 1 y
58 a 1 y
69 h 10 y

REAL
BARCA
3
27 h 7 y
44 a 10 y
87 h 3 r

PORTUGAL 6 45
NETHERLANDS 3 63
PORTUGAL 20 78
NETHERLANDS 5 90

home=input()
away=input()
n=int(input())
yellows=set()
reds=set()
s={'h':home,'a':away}
while n:
    x=input().split()
    time=int(x[0])
    team=x[1]
    shirt=int(x[2])
    card=x[3]
    if card=='y':
        if (shirt,team) in yellows and (shirt,team) not in reds:#2nd time
            print(s[team],shirt,time)
            yellows.remove((shirt,team))
            reds.add((shirt,team))
        else:#1st time
            yellows.add((shirt,team))
    else:
        if(shirt,team) not in reds:
            reds.add((shirt,team))
            print(s[team],shirt,time)
    n-=1


import java.io.*;
import java.util.*;

public class Main {
	private static boolean _READ_FROM_FILE = System.getProperty("ONLINE_JUDGE") == null;
	private static Scanner in;
	private static void core() {
		int nRows = in.nextInt(), nCols = in.nextInt();
		long[][] a = new long[nRows][nCols];
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				a[i][j] = in.nextInt();
			}
		}
		for (int i = 0; i < a.length; i++) {
			for (int j = 1; j < a[i].length; j++) {
				a[i][j] += a[i][j - 1];
			}
		}
		long[][] dp = new long[nRows][nCols];
		for (int j = 0; j < dp[0].length; j++) {
			dp[0][j] = a[0][j];
		}
		Long res = Long.MIN_VALUE;
		for (int row = 1; row < dp.length; row++) {
			if (row % 2 == 1) {
				TreeSet<Long> all = new TreeSet<Long>();
				all.add(dp[row - 1][dp[row].length - 1]);
				for (int col = dp[row].length - 2; col >= 0; col--) {
					dp[row][col] = a[row][col] + all.last();
					all.add(dp[row - 1][col]);
					if (row + 1 == dp.length)
						res = Math.max(res, dp[row][col]);
				}
			}
			else {
				TreeSet<Long> all = new TreeSet<Long>();
				all.add(dp[row - 1][0]);
				for (int col = 1; col < dp[row].length; col++) {
					dp[row][col] = a[row][col] + all.last();
					all.add(dp[row - 1][col]);
					if (row + 1 == dp.length)
						res = Math.max(res, dp[row][col]);
				}
			}
		}
		System.out.println(res);
	}
	static void debug(Object...os) {
		System.out.println(Arrays.deepToString(os));
	}
	public static void main(String[] args) throws FileNotFoundException {
		if (_READ_FROM_FILE)
			System.setIn(new FileInputStream("in.in"));
		in = new Scanner(System.in);
		core();
	}
	static class Scanner {
		BufferedReader reader;
		StringTokenizer tokenizer;
		public Scanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = new StringTokenizer("");
		}
		public String next() {
			try {
				while(!tokenizer.hasMoreElements())
					tokenizer = new StringTokenizer(reader.readLine());
				return tokenizer.nextToken();
			} catch (Exception e) {
				e.printStackTrace();
				throw new RuntimeException(e);
			}
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  long long p, t, a[1600], dp[1600];
  scanf("%d%d", &n, &m);
  fill(dp + 1, dp + m + 1, 0);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      scanf("%I64d", &a[j]);
    }
    partial_sum(a + 1, a + 1 + m, a + 1);
    t = -0x123456789ABCDEFLL;
    if (i & 1) {
      for (int j = 1; j <= m; ++j) {
        p = t;
        t = max(t, dp[j]);
        dp[j] = p + a[j];
      }
    } else {
      for (int j = m; j >= 1; --j) {
        p = t;
        t = max(t, dp[j]);
        dp[j] = p + a[j];
      }
    }
  }
  printf("%I64d\n", *max_element(dp + 1, dp + m + 1));
  return 0;
}


import java.io.*;
import java.util.*;

public class Main{
    FastScanner in;
    PrintWriter out;

    long check(long x, int n, int m)
    {
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            long cnt = x / i;
            if (cnt > m)
                cnt = m;
            ans += cnt;
        }

        return ans;
    }

    public void solve()
    {
        int n = in.nextInt();
        int m = in.nextInt();
        long k = in.nextLong();

        long r = n*1L*m;
        long l = 0;

        while (r-l>1) {
            long md = (l + r) >> 1;
            if (check(md, n, m) < k)
                l = md;
            else
                r = md;
        }

        out.println(l+1);
    }

    public void run()
    {
        in = new FastScanner();
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    public static void main(String[] args) {
        new Main().run();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Os")
using namespace std;
template <typename T, typename K>
inline void umax(T &a, K b) {
  a = max(a, (T)b);
}
template <typename T, typename K>
inline void umin(T &a, K b) {
  a = min(a, (T)b);
}
const int32_t N = 8e6;
const long long INF = 1e16 + 10;
const long double EPS = 1e-6;
const long long II = 1e9 + 10;
const long long MOD = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  long long ll = 0, rr = n * m + 1;
  while (ll < rr) {
    long long mm = (ll + rr) >> 1LL;
    long long cnt = 0;
    for (long long i = 1; i <= n; i++) {
      cnt += min(m, mm / i);
    }
    if (cnt < k)
      ll = mm + 1;
    else
      rr = mm;
  }
  cout << ll << endl;
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
/*
8 6

46
 */
public class b
{
	public static void main(String[] arg) throws Exception
	{
		new b();
	}
	public b() throws Exception
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		if(n == 5)
		{
			System.out.println("1 2 3");
			System.out.println("1 3 3");
			System.out.println("2 4 2");
			System.out.println("4 5 1");
			System.out.println("3 4");
			System.out.println("3 5");

		}
		else
		{
			for(int i = 1; i <= n/2; i++)
			{
				System.out.println(i + " " + (i+n/2) + " " + 1);
			}
			for(int i = n/2+1; i < n; i++)
			{
				System.out.println(i + " " + (i+1) + " " + ((2*(i-n/2)-1)));
			}
			for(int i = 1; i < n/2; i++)
			{
				System.out.println(i + " " + (i+1));
			}
			System.out.println("1 3");
		}
		in.close(); out.close();
	}
	class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
		public void close() throws IOException
		{
			br.close();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
	}
}


import java.util.Scanner;
import java.util.Arrays;

public class Main3{
   public static void main(String[] Args){

	   Scanner sc = new Scanner(System.in);

	   int n = sc.nextInt();
	   int median = sc.nextInt();

       int[] a = new int[n + 1];
       for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
       }
       a[n] = Integer.MAX_VALUE;
       Arrays.sort(a);

       int pos = 0, count = 0, cur_median = ((n + 1) / 2 - 1);
       //1. Find the position of the median in the array
       for (int i = 0; i < n; i++) {
    	   if (a[i] < median && a[i + 1] > median) {
		        count++;
		        n++;
		        pos = i + 1;
		   }
    	   else {
               if (a[i] == median) {
                   pos = i;
                   if (i >= cur_median) {
                       break;
                   }
               }
           }
		}
       //edge case to add to the beggining
		if (pos == 0 && a[0] != median) {
		    n++;
		    count++;
		}
	    // Figure out how many more we need to add to the set
		while (pos != (cur_median = ((n + 1) / 2 - 1))){
		    if (pos < cur_median) {
		        pos++;
		    }
		    count++;
		    n++;
		}
		System.out.println(count);
               // :(
   }

}

#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int main() {
  int n, x, ans = 0, t;
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  t = n;
  while (arr[(t - 1) / 2] != x) {
    arr[t++] = x;
    sort(arr, arr + t);
    ans++;
  }
  cout << ans << "\n";
  return 0;
}


import java.util.*;

public class BagOfMice
{
	static double prob[][];
	static int totalMice;

	public static void main(String args[])
	{
		Scanner in = new Scanner(System.in);
		int w = in.nextInt();
		int b = in.nextInt();
		prob = new double[w+1][b+1];
		totalMice = w + b;
		for(int i = 0; i <= w; i++){
			for(int j = 0; j <= b ; j++)
				prob[i][j] = -1;
		}
		System.out.println(probFunction(w,b));
	}

	public static double probFunction(int w, int b)
	{
		double probW = (double)w / (w + b);
		double probB = (double)b / (w + b);

		if((w == -1 || b == -1) || (w == 0 && b == 0))
		{
			return new Double(0);
		}
		else
		{
			if(prob[w][b] != -1)
				return prob[w][b];
			else{
				double princessProb;
				int turn = (totalMice - w - b) % 3;
				//turn: 0 = princess, 1 = dragon, 2 = mice escapes
				switch(turn)
				{
					case 0 : princessProb = probW + (probB * probFunction(w, b - 1)); break;
					case 1 : princessProb = probB * probFunction(w, b - 1); break;
					default : princessProb = (probW * probFunction(w - 1, b)) + (probB * probFunction(w, b - 1)); break;
				}
				prob[w][b] = princessProb;
				return princessProb;
			}
		}

	}
}


import java.util.*;
import java.io.*;
public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int gcd(int a,int b)
    {
        if(b%a==0)
        return a;
        return gcd(b%a,a);
    }
    public static void main(String args[])
    {
        FastReader fs=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int n=fs.nextInt();
        int p=fs.nextInt();
        int ans=-1;
        for(int i=0;i<=30;i++)
        {
            int rem=n-i*p;
            if(rem<0)
            break;
            int cnt=0;
            long set=0;
            for(int j=0;j<=30;j++)
            {
                if(((rem>>j)&1)==1)
                {
                    cnt++;
                    set+=(1L<<j);
                }
            }
            //pw.println(cnt+" "+set);
            if(cnt==i)
            {
                ans=i;
                break;
            }
            if(cnt<i&&set>=i)
            {
                ans=i;
                break;
            }
        }
        if(p>=n)
        ans=-1;
        pw.println(ans);
        pw.flush();
        pw.close();
    }
}

#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, p;
  cin >> n >> p;
  long long int f = 0, g = 0;
  for (long long int i = 1; i <= 10000; i++) {
    long long int a = n - (p * i);
    if (a == 1 && i != 1) continue;
    long long int x = 0;
    for (long long int j = 1; j <= i; j++) {
      if (a <= 0) break;
      long long int q = log2(a);
      x = x + pow(2, q);
      a = a - pow(2, q);
      if (a == 0) {
        if (i <= x) f = 1;
        break;
      }
    }
    if (f == 1) {
      cout << i;
      g = 1;
      break;
    }
  }
  if (g == 0) cout << -1;
  return 0;
}


10 10
PPPPPPPPPP
PPPPPPPWPP
PPPPPPPPPP
PPPPPPPPPP
PPPPPPPPPP
PPPPPPPPPP
PPPPPPPPPP
PPPPPPPPPP
PPPPPPPPPP
PPPPPPPPPP

10 9
WWP.P.WPP
..PWP.P.W
....PWP..
WW...P.WP
.P.WP..W.
PP...W.P.
P.W..WP.W
.PWPP..P.
.PPPPPWW.
PW..W..PP

4 10
..P.PW.P.P
P.WP.W..WP
W..P.P..WP
W.PWW.P.P.


from math import log2
n = int(input())
if n == 3:
    print(1,1,3)
elif n == 1:
    print(1)
else:
    num = n // 2
    num3 = 2 ** int(log2(num)) * 2
    num2 = n % 2
    print("1 " * (num2 + num),end="")
    cur_num = 2
    while num > 1:
        num2 = num % 2
        num //= 2
        print((str(cur_num)+ " ") *(num2 + num),end="")
        cur_num *= 2
    if num3 + num3 // 2 > n:
        print(cur_num)
    else:
        print(cur_num // 2 * 3)

42
```

Each of these inputs is a single integer between 1 and 42, inclusive.

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, cnt = 0;
  scanf("%d", &n);
  if (n == 3)
    printf("1 1 3");
  else {
    int x = n;
    for (i = 1; x > 3; i <<= 1) {
      int y = x - x / 2;
      x /= 2;
      for (j = 1; j <= y; ++j) printf("%d ", i), cnt++;
    }
    if (x == 3) printf("%d %d %d", i, i, i * 3);
    if (x == 2) printf("%d %d", i, i * 2);
    if (x == 1) printf("%d", i);
  }
}


/*
 *
 * @author Mukesh Singh
 *
 */

import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
@SuppressWarnings("unchecked")

public class Main {
	//solve test cases

	void solve() throws Exception {
		//int T = in.nextInt();
		//for(int tid = 1; tid <= T; ++tid)
			solveT();
    }

    	void solveT() throws Exception{

		int n = in.nextInt();
		long []A=new long[n];

		for(int i=0;i<n;i++){
			A[i]=in.nextLong();
		}
		int m = in.nextInt();
		long []B=new long[m];

		for(int i=0;i<m;i++){
			B[i]=in.nextLong();
		}

		long a=0,b=0;
		int i=0,j=0,p=1,q=1;
		int count=0;

		while(i<n && j<m){
			if(p==1)
			a+=A[i];
			if(q==1)
			b+=B[j];
			p=0;
			q=0;
			if(a==b){
				count++;
				i++;
				j++;
				a=0;
				b=0;
				p=1;
				q=1;
			}else if(a<b){
				i++;
				p=1;
			}else {
				j++;
				q=1;
			}
		}

		if(i<n|| j<m)
		System.out.println("-1");
		else
		System.out.println(count);

	}
	//@ main function
	public static void main(String[] args) throws Exception {
		new Main();
	}

	InputReader in;
	PrintStream out ;
	DecimalFormat df ;
	Main() {
		try {
			File defaultInput = new File("file.in");
			if (defaultInput.exists())
				in = new InputReader("file.in");
			else
				in = new InputReader();
			defaultInput = new File("file.out");
			if (defaultInput.exists())
				out = new PrintStream(new FileOutputStream("file.out"));
			else
				out = new PrintStream(System.out);
			df = new DecimalFormat("######0.00");
			solve();
			out.close();
		}
		catch (Exception e) {
			e.printStackTrace();
			System.exit(261);
		}
	}

	class InputReader {
		BufferedReader reader;
		StringTokenizer tokenizer;

		InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		InputReader(String fileName) throws FileNotFoundException {
			reader = new BufferedReader(new FileReader(new File(fileName)));
		}

		String readLine() throws IOException {
			return reader.readLine();
		}

		String nextToken() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens())
				tokenizer = new StringTokenizer(readLine());
			return tokenizer.nextToken();
		}

		boolean hasMoreTokens() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				String s = readLine();
				if (s == null)
					return false;
				tokenizer = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextToken());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(nextToken());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(nextToken());
		}
	}
}

#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const long long INF = 1e9 + 7;
const int N = 5e5 + 10;
long long a[N];
long long b[N];
int main() {
  int n;
  int m;
  scanf("%d", &n);
  map<long long, int> mc;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
    mc[a[i]] = 1;
  }
  scanf("%d", &m);
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    b[i] += b[i - 1];
    if (mc.count(b[i])) ans++;
  }
  if (b[m] != a[n]) ans = -1;
  printf("%d\n", ans);
  return 0;
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Radio_Station {
	public static void main(String[] args)throws Throwable {
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(bf.readLine());
		int servers=Integer.parseInt(st.nextToken());
		int commands=Integer.parseInt(st.nextToken());
		HashMap<String, String> map=new HashMap<String,String>();
		while(servers-->0)
		{
			st=new StringTokenizer(bf.readLine());
			String a=st.nextToken();
			String b=st.nextToken()+";";
			map.put(b, a);
		}
		while(commands-->0)
		{
			st=new StringTokenizer(bf.readLine());
			System.out.print(st.nextToken()+" ");
			String a=st.nextToken();
			System.out.println(a+" #"+map.get(a));
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int count = 0;
  map<string, string> mp;
  vector<vector<string>> v;
  for (int i = 0; i < (n + m); i++) {
    string str1, str2;
    vector<string> vin;
    cin >> str1;
    cin >> str2;
    if (i < n) mp[str2 + ';'] = str1;
    vin.push_back(str1);
    vin.push_back(str2);
    v.push_back(vin);
  }
  for (int i = n; i < (n + m); i++) {
    string ans = "";
    ans += v[i][0] + " " + v[i][1] + " " + '#' + mp[v[i][1]];
    cout << ans << endl;
  }
}


_,m=map(int,input().split())
a=input()
for _ in [0]*m:
  l,r,b,c=input().split();l=int(l)-1;r=int(r)
  a=a[:l]+a[l:r].replace(b,c)+a[r:]
print(a)

94 13
bcaaaaaaccacddcdaacbdaabbcbaddbccbccbbbddbadddcccbddadddaadbdababadaacdcdbcdadabdcdcbcbcbcbbcd
52 77 d d
21 92 d b
45 48 c b
20 25 d a
57 88 d b
3 91 b d
64 73 a a
5 83 b d
2 69 c c
28 89 a b
49 67 c b
41 62 a c
49 87 b c

83 10
fhbecdgadecabbbecedcgfdcefcbgechbedagecgdgfgdaahchdgchbeaedgafdefecdchceececfcdhcdh
9 77 e e
26 34 b g
34 70 b a
40 64 e g
33 78 h f
14 26 a a
17 70 d g
56 65 a c
8 41 d c
11 82 c b

30 4
eaaddabedcbbcccddbabdecadcecce
2 17 c a
16 29 e e
16 21 c b
7 11 b c

87 5
nfinedeojadjmgafnaogekfjkjfncnliagfchjfcmellgigjjcaaoeakdolchjcecljdeblmheimkibkgdkcdml
47 56 a k
51 81 o d
5 11 j h
48 62 j d
16 30 k m

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class IOtest {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer str = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(str.nextToken());
        int m = Integer.parseInt(str.nextToken());
        StringBuilder strb = new StringBuilder(in.readLine());
        int l[] = new int[m];
        int r[] = new int[m];
        char c1[] = new char[m];
        char c2[] = new char[m];
        int j = 0;
        while (j < m) {
            str = new StringTokenizer(in.readLine());
            l[j] = Integer.parseInt(str.nextToken());
            r[j] = Integer.parseInt(str.nextToken());
            c1[j] = str.nextToken().charAt(0);
            c2[j] = str.nextToken().charAt(0);
            j++;
        }
        j = 0;
        while (j < m) {
            int i = l[j] - 1;
            while (i <= r[j] - 1) {
                if (strb.charAt(i) == c1[j])
                    strb.setCharAt(i, c2[j]);
                i++;
            }
            j++;
        }
        out.println(strb.toString());
        out.flush();
    }

    public static boolean isEvenBit(int i) {
        return (i & 1) == 0;
    }
}


I = lambda: map(int, input().split())

_, k = I()
A = list(I())

print(min(A) if k<2 else max(A) if k>2 else max(A[0], A[-1]))

import java.util.*;
import java.lang.*;

public class Max {

 public static void main(String[] args)
 {
     Scanner in = new Scanner(System.in);
     int n=in.nextInt();
     int k=in.nextInt();
     int a[]=new int[n];
     for(int i=0;i<n;i++)
         a[i]=in.nextInt();
     if(k==1)
     {
         int min=a[0];
         for(int i=1;i<n;i++)
            min=Math.min(min,a[i]);
         System.out.println(min);
     }
     else if(k==2)
     {
         int suffix[]=new int[n];
         suffix[n-1]=a[n-1];
         for(int i=n-2;i>=0;i--)
             suffix[i]=Math.min(a[i],suffix[i+1]);
         int prefix=a[0];
         int ans=Math.max(prefix,suffix[1]);
         for(int i=1;i<n-1;i++)
         {
             prefix=Math.min(prefix,a[i]);
             ans=Math.max(ans,Math.max(prefix,suffix[i+1]));
         }
         System.out.println(ans);
     }
     else
     {
         int max=a[0];
         for(int i=1;i<n;i++)
             max=Math.max(a[i],max);
         System.out.println(max);
     }
 }

}


import java.util.*;
import java.io.*;
public class TestClass  {

   static InputReader sc = new InputReader();
   static ArrayList[] al;
   static boolean[] v;
   static long count=0;
   static long[] val;
   static void dfs(int src){

       v[src]=true;
       for(int i=0;i<al[src].size();i++){

           if(!v[(int)al[src].get(i)])
              {
                count+=val[(int)al[src].get(i)];
                dfs((int)al[src].get(i));
              }
       }
       return;
   }

    public static void main(String[] args) throws IOException{
         String s=s();
        int k=i();
        long l=Long.parseLong(s);
        int lol=0,ans=0;
        boolean flag=true;
          for(int i=0;i<s.length()-1;i++){
            if(s.charAt(i)!='0'){
               flag=false;
               break;
            }else{
              ans++;
            }
          }
      if(flag==true){
            System.out.println(s.length()-1);
      }else{

        if(s.length()<=k){
            System.out.println(s.length()-1);
        }else{
            for(int j=s.length()-1;j>=0;j--){
                if(lol==k){
                  System.out.println(ans);
                  return;
                }
                if(s.charAt(j)=='0'&&j!=0){
                  lol++;
                }else{
                  ans++;
                }

            }
           if(lol!=k){
               System.out.println(s.length()-1);
           }

        }
}
    }
    /////////////////////////////////////////////////////////// shortcuts //////////////////////////////
       static int i()  {

          return sc.nextInt();
        }
        static long l()  {
          return sc.nextLong();

        }
        static double d() throws IOException{
          return sc.nextDouble();
        }
        static String s() throws IOException{
          return sc.next();

        }
        static String sL() throws IOException{
          return sc.nextLine();
        }
       static void loop(int[] a) throws IOException{
          for(int j=0;j<a.length;j++){
              a[j]=i();
          }
        }
        static void eloop(int[] a) throws IOException{
          for(int i=1;i<=a.length;i++){
              a[i]=i();
          }
        }
        static void ploop(int[] a)throws IOException{
             for(int j=0;j<a.length;j++){
                System.out.println(a[j]);
             }

        }
        static void eploop(int[] a)throws IOException{
             for(int j=1;j<=a.length;j++){
                System.out.println(a[j]);
             }

        }

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

  static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                throw new RuntimeException();
            }
            return str;
        }
    }

 }

#include <bits/stdc++.h>
using namespace std;
char a[15];
int k, ans, r = 1, i, j, cnt, res;
string s;
int main() {
  cin >> s >> k;
  for (i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '0') {
      res++;
    }
  }
  if (res < k) {
    cout << s.size() - 1;
    return 0;
  }
  for (i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '0')
      ans++;
    else
      cnt++;
    if (ans == k) {
      cout << cnt;
      return 0;
    }
  }
}


n = int(input())
if n & 1:
    print(n//2)
else:
    k = 1
    while k <= n:
        k *= 2
    print((n - k//2)//2)

/*Author LAVLESH*/
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class solution{
	static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st=new StringTokenizer("");

	static public String next() {
	        while (st == null || !st.hasMoreTokens()) {
	            try {
	                st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return st.nextToken();
	    }

	public static void main(String[]args)throws IOException{
		PrintWriter op =new PrintWriter(System.out,true);
		int x=2;
		int n=Integer.parseInt(next());
		if((n&(n-1))==0)op.println(0);
		else if(n%2==1)op.print(n/2);
		else{
			while(x<n)x*=2;
		x/=2;
		op.print((n-x)/2);
		}

		 op.close();
  }
}


#include <bits/stdc++.h>
using namespace std;
long long int solve(long long int x, long long int y, long long int k) {
  if (x == y && x % k == 0) return 1;
  if (x == y && x % k != 0) return 0;
  if (y - ((x / k) * k + k) >= 0) {
    if (x % k != 0) return ((y - ((x / k) * k + k)) / k) + 1;
    return ((y - ((x / k) * k + k)) / k) + 2;
  } else {
    if (x % k == 0)
      return 1;
    else
      return 0;
  }
}
int main() {
  long long int a, b, p, res = 0;
  cin >> p >> a >> b;
  if (a >= 0 && b >= 0)
    res = solve(a, b, p);
  else if (a < 0 && b >= 0)
    res = solve(1, -a, p) + solve(0, b, p);
  else
    res = solve(-b, -a, p);
  cout << res << endl;
  return 0;
}

k, a, b = map(int, input().split())

def Do(a, b,):
    suma = 0

    if a < 0:
        if b == 0:
            print(-a // k + 1)

        if b > 0:
            suma = 1
            a = -a

            if a % k == 0:
                if b % k == 0:
                    suma += b // k + a // k
                    print(suma)

                else:
                    suma += b // k + a // k
                    print(suma)

            else:
                if b % k == 0:
                    suma += b // k + a // k
                    print(suma)

                else:
                    suma += b // k + a // k
                    print(suma)

        if b < 0:
            el = a
            a = -b
            b = -el

            if a % k == 0:
                if b % k == 0:
                    suma = 1
                    suma += b // k - a // k
                    print(suma)

                else:
                    suma = 1
                    suma += b // k - a // k
                    print(suma)

            else:
                if b % k == 0:
                    suma += b // k - a // k
                    print(suma)

                else:
                    suma += b // k - a // k
                    print(suma)

    else:
        if a % k == 0:
            if b % k == 0:
                suma = 1
                suma += b // k - a // k
                print(suma)

            else:
                suma = 1
                suma += b // k - a // k
                print(suma)

        else:
            if b % k == 0:
                suma += b // k - a // k
                print(suma)

            else:
                suma += b // k - a // k
                print(suma)

if a == b:
    if a % k == 0:
        print(1)
    else:
        print(0)

else:
    Do(a, b)


import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.HashSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author ilyakor
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskC {
    int[][][] d;
    boolean[][][] u;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        boolean[][] a = new boolean[n][2];
        for (int i = 0; i < k; ++i) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            a[x][y] = true;
        }
        d = new int[n + 1][4][4];
        u = new boolean[n + 1][4][4];
        int prev = 0;
        int res = 0;
        for (int i = 0; i < n; ) {
            int j = i;
            while (j < n && !a[j][0] && !a[j][1]) ++j;
            int cur = 0;
            if (j < n) {
                if (a[j][0]) cur |= 2;
                if (a[j][1]) cur |= 1;
            }
            int val = go(j - i, prev, cur);
            res ^= val;
            prev = cur;
            i = j + 1;
        }
        out.printLine(res == 0 ? "LOSE" : "WIN");
    }

    private int go(int n, int ml, int mr) {
        if (n <= 0) return 0;
        if (u[n][ml][mr]) return d[n][ml][mr];
        u[n][ml][mr] = true;
        if (ml == 3) {
            // Should be impossible, but anyway.
            int res = go(n - 1, 0, mr);
            d[n][ml][mr] = res;
            return res;
        }
        if (mr == 3) {
            // Should be impossible, but anyway.
            int res = go(n - 1, ml, 0);
            d[n][ml][mr] = res;
            return res;
        }
        int res = 0;
        int[][] a = new int[n][2];
        if (ml % 2 == 1) a[0][0] = 1;
        if ((ml / 2) % 2 == 1) a[0][1] = 1;
        if (mr % 2 == 1) a[n - 1][0] = 1;
        if ((mr / 2) % 2 == 1) a[n - 1][1] = 1;
        HashSet<Integer> hs = new HashSet<Integer>();
        for (int x = 0; x < n; ++x)
            for (int y = 0; y < 2; ++y)
                if (a[x][y] == 0) {
                    int cur = go(x, ml, (1 << (1 - y))) ^ go(n - x - 1, (1 << (1 - y)), mr);
                    hs.add(cur);
                }
        while (hs.contains(res)) ++res;
        d[n][ml][mr] = res;
        return res;
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buffer = new byte[10000];
    private int cur;
    private int count;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public static boolean isSpace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public int read() {
        if (count == -1) {
            throw new InputMismatchException();
        }
        try {
            if (cur >= count) {
                cur = 0;
                count = stream.read(buffer);
                if (count <= 0)
                    return -1;
            }
        } catch (IOException e) {
            throw new InputMismatchException();
        }
        return buffer[cur++];
    }

    public int readSkipSpace() {
        int c;
        do {
            c = read();
        } while (isSpace(c));
        return c;
    }

    public int nextInt() {
        int sgn = 1;
        int c = readSkipSpace();
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res = res * 10 + c - '0';
            c = read();
        } while (!isSpace(c));
        res *= sgn;
        return res;
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    }

WIN WIN WIN LOSE LOSE WIN WIN WIN LOSE LOSE LOSE WIN LOSE LOSE WIN LOSE LOSE WIN WIN WIN WIN WIN LOSE WIN LOSE WIN WIN WIN LOSE WIN WIN LOSE WIN LOSE LOSE WIN LOSE WIN WIN LOSE WIN WIN WIN LOSE LOSE WIN WIN WIN LOSE WIN LOSE LOSE WIN WIN LOSE LOSE WIN LOSE LOSE LOSE WIN WIN LOSE LOSE LOSE WIN LOSE WIN WIN WIN WIN

r,n = [int(x) for x in input().split()]
cells = [[int(x) for x in input().split()] for i in range(n)]
cells.sort()
#print(cells)
out = False

res = {True:"WIN",False:"LOSE"}

if len(cells) == 0: print(res[r%2 == 1])
else:
    out = False
    #print(cells[0][0] > 1)
    #print(cells[-1][0] < r)
    for i in range(1,n):
        out ^= ((cells[i][0]-cells[i-1][0]-1)%2) ^ (cells[i][1] != cells[i-1][1])
    dif = abs((cells[0][0]-1)-(r-cells[-1][0]))
    #print(out,dif)
    hi,lo = max(cells[0][0]-1,r-cells[-1][0]),min(cells[0][0]-1,r-cells[-1][0])
    #print(out,dif,lo,hi)
    if lo > 1:
        if dif == 0:
            print(res[out])
        elif dif == 1 and lo % 2 == 0:
            print(res[not out])
        else:
            print(res[True])
    elif lo == 0:
        if hi == 0: print(res[out])
        elif hi == 1:
            print(res[not out])
        else:
            print(res[True])
    elif lo == 1:
        if hi == 1:
            print(res[out])
        else:
            print(res[True])


#include <bits/stdc++.h>
using namespace std;
const long long M = 998244353;
int t, n, k;
long long st(long long a, long long b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    long long aa = (a * a) % M;
    return (st(aa, b / 2) % M);
  } else {
    return ((a * st(a, b - 1)) % M);
  }
}
int main() {
  vector<long long> f = vector<long long>(500005);
  f[0] = 1;
  f[1] = 1;
  for (int i = 2; i < 500005; i++) {
    f[i] = i * f[i - 1];
    f[i] %= M;
  }
  cin >> n >> k;
  k--;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int N = n / i;
    N--;
    if (N >= k) ans += (f[N] * st(((f[k] * f[N - k]) % M), M - 2));
    ans %= M;
  }
  cout << ans << "\n";
}

import sys
import string
input = sys.stdin.readline
import math
#import numpy
#letters = list(string.ascii_lowercase)
from decimal import Decimal

n = list(map(int, input().split()))
n,k = n[0], n[1]
m = 998244353

fact = []
fac = 1

for i in range(1, n+2):
    fac *= i
    fac = fac % m
    fact.append(fac)

ans = 0
fact = [1] + fact

for i in range(1, n//k + 1):
    out = n//k
    a = n//i - 1
    b = k - 1
    #print(a,b)
    #print(pow(2,6, 502))
    l = fact[b] * fact[a-b]
    ans += (fact[a] * pow(l, m-2, m)) % m
    #print(ans)
    #print(i, ans)

print(int(ans) % m)


// Main Code at the Bottom
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
	//Fast IO class
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
        	if(!env) {
        		try {
					br=new BufferedReader(new FileReader("src\\input.txt"));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				}
        	}
        	else br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    static long MOD=1000000000+7;
    //Euclidean Algorithm
    static long gcd(long A,long B){
    	return (B==0)?A:gcd(B,A%B);
    }
    //Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
    //Modular Inverse
    static long inverse(long x) {
    	return fastExpo(x,MOD-2);
    }
    //Prime Number Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i*i<=n;i+=6) if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
    //Reverse an array
    static void reverse(char arr[],int l,int r){
    	while(l<r) {
    		char tmp=arr[l];
    		arr[l++]=arr[r];
    		arr[r--]=tmp;
    	}
    }
    //Print array
    static void print1d(int arr[]) {
    	out.println(Arrays.toString(arr));
    }
    static void print2d(int arr[][]) {
    	for(int a[]: arr) out.println(Arrays.toString(a));
    }
    // Pair
    static class pair{
    	int x,y;
    	pair(int a,int b){
    		this.x=a;
    		this.y=b;
    	}
    	public boolean equals(Object obj) {
    		if(obj == null || obj.getClass()!= this.getClass()) return false;
            pair p = (pair) obj;
            return (this.x==p.x && this.y==p.y);
        }
    	public int hashCode() {
            return Objects.hash(x,y);
        }
    }
    static FastReader sc=new FastReader();
    static PrintWriter out=new PrintWriter(System.out);
    //Main function(The main code starts from here
    static int n,m,av,a[],b[],c[],N=5000+5;
    static ArrayList<Integer> arr[]=new ArrayList[N],x[]=new ArrayList[N];
    static long dp[][]=new long[N][N];
    static long solve(int i,int k) {
    	if(i==n) {
    		if(k<0) return Integer.MIN_VALUE;
    		return 0;
    	}
    	long sol=Integer.MIN_VALUE;
    	if(a[i]>k) return Integer.MIN_VALUE;
    	if(dp[i][k]!=-1) return dp[i][k];
    	Collections.sort(x[i],(i1,i2)->c[i2]-c[i1]);
    	int val=0,len=0;
    	for(Integer j: x[i]) {
    		sol=Math.max(sol, val+solve(i+1,k-len+b[i]));
    		val+=c[j];
    		len++;
    	}
    	sol=Math.max(sol, val+solve(i+1,k-len+b[i]));
    	return dp[i][k]=sol;
    }
    public static void main (String[] args) throws java.lang.Exception {
    	int test=1;
    	//test=sc.nextInt();
    	while(test-->0){
    		n=sc.nextInt();m=sc.nextInt();av=sc.nextInt();
    		a=new int[n];b=new int[n];c=new int[n];
    		for(int i=0;i<5000+5;i++) Arrays.fill(dp[i], -1);
    		for(int i=0;i<n;i++) {
    			a[i]=sc.nextInt();
    			b[i]=sc.nextInt();
    			c[i]=sc.nextInt();
    		}
    		for(int i=0;i<n;i++) {
    			arr[i]=new ArrayList<>();
    			x[i]=new ArrayList<>();
    		}
    		for(int i=0;i<m;i++) {
    			int src=sc.nextInt()-1,dest=sc.nextInt()-1;
    			arr[dest].add(src);
    		}
    		for(int i=0;i<n;i++) {
    			Collections.sort(arr[i]);
    			if(arr[i].size()>0) x[arr[i].get(arr[i].size()-1)].add(i);
    			else x[i].add(i);
    		}
    		long ans=solve(0,av);
    		out.println(Math.max(ans, -1));
    	}
        out.flush();
        out.close();
    }
}

import sys
input = sys.stdin.buffer.readline

N, M, K = map(int, input().split())
A = [0] * N
B = [0] * N
C_raw = [0] * N
for i in range(N):
    A[i], B[i], C_raw[i] = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(M):
    u, v = map(int, input().split())
    adj[v].append(u)

C = [[] for _ in range(N)]
for i in range(N):
    if adj[i+1]:
        C[max(adj[i+1])-1].append(C_raw[i])
    else:
        C[i].append(C_raw[i])
for i in range(N):
    if C[i]:
        C[i].sort(reverse=True)

dp = [[-10**5] * 5001 for _ in range(N+1)]
dp[0][K] = 0
for i in range(N):
    for k in range(5001):
        if dp[i][k] >= 0:
            if k >= A[i]:
                dp[i+1][k+B[i]] = max(dp[i+1][k+B[i]], dp[i][k])
                p = k + B[i]
                q = 0
                cnt = 0
                for ci in C[i]:
                    if p > 0:
                        p -= 1
                        q += ci
                        cnt += 1
                        dp[i+1][k+B[i] - cnt] = max(dp[i+1][k+B[i] - cnt], dp[i][k] + q)
                    else:
                        break

if max(dp[-1]) >= 0:
    print(max(dp[-1]))
else:
    print(-1)


n, k = [int(x) for x in input().strip().split()]
S = input().strip()

if n == 1 and k == 1:
    res = '0'
elif k == 0:
    res = S
else:
    S = [c for c in S]

    if S[0] != '1':
        S[0] = '1'
        k -= 1

    i = 1
    while k > 0:
        if i >= n:
            break
        if S[i] == '0':
            i += 1
            continue

        S[i] = '0'
        k -= 1
        i += 1

    res = "".join(S)

print(res)

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if (n == 1 && k > 0) {
    cout << 0 << endl;
  } else if (k == 0) {
    cout << s << endl;
  } else {
    int i = 0;
    int j = 1;
    if (s[0] != '1') {
      s[0] = '1';
      k--;
    }
    while (i < k && j < n) {
      if (s[j] == '0') {
        j++;
        continue;
      }
      s[j] = '0';
      i++;
      j++;
    }
    cout << s << endl;
  }
  return 0;
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class E {
    private void solve() throws IOException {
        int T = nextInt();
        for (int i = 0; i < T; i++) {
            int n = nextInt();

            if (n % 2 == 0)
                writer.println(1);
            else
                writer.println(0);
            writer.flush();
        }
    }

    public static void main(String[] args) {
        new E().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new FileReader("input.txt"));
            tokenizer = null;
            writer = new PrintWriter("output.txt");
            solve();
            reader.close();
            writer.close();
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, k;
  ifstream ifile("input.txt");
  if (ifile) {
    freopen("input.txt", "rt", stdin);
  }
  if (ifile) {
    freopen("output.txt", "wt", stdout);
  }
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> k;
    if (k % 2 == 1)
      cout << 0 << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}


//package Contest573;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class mainD {
    public static PrintWriter out = new PrintWriter(System.out);
    public static FastScanner enter = new FastScanner(System.in);
    public static HashMap<Long, Integer> hm=new HashMap<>();
    public static void main(String[] args) throws IOException {
        int n=enter.nextInt();
        long summ=0;
        for (int i = 0; i <n ; i++) {
            long tmp=enter.nextLong();
            if(hm.get(tmp)!=null){
                hm.put(tmp, hm.get(tmp)+1);
            }
            else{
                hm.put(tmp,1);
            }
            summ+=tmp;
        }

        int kol_vo=0;
        LinkedList<Long> ll=new LinkedList<>();
        for (long key:hm.keySet()) {
            if(hm.get(key)>1){
                kol_vo++;
                ll.addFirst(key);
            }
        }

        if(kol_vo>1){
            System.out.println("cslnb");
            return;
        }

        if(kol_vo==1){
            Long who =ll.peekFirst();
            if(hm.get(who-1)!=null || hm.get(who)>2 || who==0){
                System.out.println("cslnb");
                return;
            }
        }
        long oorAns=n*(n-1);
        oorAns/=2;
        summ-=oorAns;
        if(summ%2==0){
            System.out.println("cslnb");
        }
        else{
            System.out.println("sjfnb");
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer stok;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() throws IOException {
            while (stok == null || !stok.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return null;
                }
                stok = new StringTokenizer(s);
            }
            return stok.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        char nextChar() throws IOException {
            return (char) (br.read());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }
    }
}

sjfnb cslnb cslnb sjfnb cslnb cslnb sjfnb cslnb cslnb cslnb cslnb cslnb cslnb cslnb sjfnb cslnb cslnb cslnb cslnb cslnb cslnb cslnb cslnb sjfnb sjfnb cslnb cslnb cslnb cslnb cslnb cslnb cslnb cslnb cslnb cslnb sjfnb sjfnb cslnb sjfnb sjfnb sjfnb sjfnb cslnb cslnb cslnb cslnb cslnb cslnb cslnb sjfnb

#include <bits/stdc++.h>
using namespace std;
vector<long long> nums;
long long repetidos() {
  sort(nums.begin(), nums.end());
  long long rta = 0, ant = -1;
  for (auto x : nums) {
    if (x == ant) {
      rta++;
    }
    ant = x;
  }
  return rta;
}
bool falla(int n) {
  for (int i = 1; i < n - 1; i++) {
    if (nums[i] == nums[i - 1] + 1 && nums[i] == nums[i + 1]) {
      return true;
    }
  }
  return false;
}
int main() {
  int n;
  long long acum = 0, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    nums.push_back(x);
    acum += x;
  }
  long long rep = repetidos();
  if (rep > 1 || (n > 1 && nums[0] == nums[1] && nums[0] == 0) || falla(n)) {
    cout << "cslnb\n";
    return 0;
  }
  long long N = n;
  long long menos = (N * (N - 1)) / 2;
  if ((acum - menos) % 2 == 0) {
    cout << "cslnb\n";
  } else {
    cout << "sjfnb\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ara[32];
  for (int i = 0; i <= 30; i++) {
    ara[i] = pow(2, i) - 1;
  }
  int x = n;
  vector<int> v;
  int f = 0;
  int cnt = 0;
  for (int i = 0;; i++) {
    for (int j = 0; j <= 30; j++) {
      if (x == ara[j]) {
        f = 1;
        break;
      }
    }
    if (f == 1) {
      break;
    }
    if (i % 2 == 0) {
      int g = log(x) / log(2);
      for (int j = g; j >= 0; j--) {
        int e = pow(2, j) - 1;
        int m = x ^ e;
        if (m > x) {
          x = m;
          v.push_back(j);
          break;
        }
      }
    } else {
      x++;
    }
    cnt++;
  }
  cout << cnt << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  return 0;
}

from sys import stdin,stdout
from collections import Counter
def ai(): return list(map(int, stdin.readline().split()))
def ei(): return map(int, stdin.readline().split())
def ip(): return  int(stdin.readline().strip())
def op(ans): return stdout.write(str(ans) + '\n')

import math
n = ip()
ans = 0
li = []
for _ in range(40):
	if (n&(n+1))==0:
		break
	lofnum = len(bin(n)[2:])
	num = int(lofnum*'1',2)
	final_num = n^num
	for i in range(30):
		if (2**i) > final_num:
			break
	n ^= ((2**i) -1)
	ans += 1
	li.append(i)
	if(n&(n+1)) == 0:
		break
	n += 1
	ans += 1

if ans>0:
	print(ans)
	print(*li)
else:
	print(0)


#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int fa[N];
vector<int> ans[N];
int find(int x) { return fa[x] < 0 ? x : (fa[x] = find(fa[x])); }
void merge(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  int temp = fa[a] + fa[b];
  if (fa[a] < fa[b]) {
    for (int i = 0; i < ans[b].size(); ++i) ans[a].push_back(ans[b][i]);
    ans[b].clear();
    fa[b] = a;
    fa[a] = temp;
  } else {
    for (int i = 0; i < ans[a].size(); ++i) ans[b].push_back(ans[a][i]);
    ans[a].clear();
    fa[a] = b;
    fa[b] = temp;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  memset(fa, -1, sizeof(fa));
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) ans[i].push_back(i);
  int x, y;
  for (int i = 0; i < n - 1; ++i) {
    cin >> x >> y;
    x -= 1;
    y -= 1;
    merge(x, y);
  }
  int u = find(0);
  for (int i = 0; i < ans[u].size(); ++i) cout << ans[u][i] + 1 << " ";
  cout << endl;
  return 0;
}

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.rank = [0 for _ in range(n + 1)]
        self.size = [1] * (n + 1)
        self.group = [[i] for i in range(n + 1)]

    def find(self, x):
        # If x is root
        if self.parent[x] == x:
            return x
        # If x is not root, search again by using x's parent
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # Make an edge from the root of lower tree to the root of higher tree
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            # If the height of tree the tree is the same, increase one of the heights by 1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def merge(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if len(self.group[x]) < len(self.group[y]):
            x, y = y, x
        self.group[x].extend(self.group[y])
        self.group[y] = []
        self.parent[y] = x

    def check_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]

N = int(input())
items = []
for i in range(N - 1):
    items.append(tuple(map(int, input().split())))

union_find = UnionFind(N)

for a, b in items:
    union_find.merge(a, b)
ans = union_find.group[union_find.find(1)]
print(*ans)


#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  cin >> n;
  cout << n << endl;
  for (int i = 0; i < n; i++) {
    cout << 1 << " ";
  }
  return 0;
}

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n;
        n = sc.nextInt();
        out.println(n);
        for(int i = 0;i < n;i++)
            out.print("1 ");
        out.flush();
        out.close();
    }
}


#include <bits/stdc++.h>
const long long mod = (long long)1e9 + 7;
using namespace std;
long long n;
vector<long long> vc;
vector<vector<pair<long long, long long>>> adj;
long long ans;
long long dfs(long long s, long long p) {
  long long m1, m2;
  m1 = m2 = 0;
  for (auto i : adj[s]) {
    if (p != i.first) {
      long long m = dfs(i.first, s);
      m -= i.second;
      if (m > m1) {
        m2 = m1;
        m1 = m;
      } else if (m > m2) {
        m2 = m;
      }
    }
  }
  ans = max(ans, m1 + m2 + vc[s]);
  return m1 + vc[s];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vc.resize(n + 1);
  adj.resize(n + 1);
  for (long long i = 1; i <= n; i++) cin >> vc[i];
  long long a, b, c;
  for (long long i = 0; i < n - 1; i++) {
    cin >> a >> b >> c;
    adj[a].push_back({b, c});
    adj[b].push_back({a, c});
  }
  dfs(1, -1);
  cout << ans << "\n";
  return 0;
}

from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
from collections import deque
n=int(input())
l=list(map(int,input().split()))
visited=set()
graph={i:set() for i in range(1,n+1)}
d={}
papa=[0 for i in range(n+1)]
level=[[] for i in range(n+1)]
z=[[0] for i in range(n+1)]
for i in range(n-1):
	a,b,c=map(int,input().split())
	graph[a].add(b)
	graph[b].add(a)
	d[(a,b)]=c
stack=deque()
# print(graph)
for i in graph:
	if len(graph[i])==1:
		stack.append([i,0])
m=0
while stack:
	# print(stack)
	x,y=stack.popleft()
	if len(graph[x])>=1:
		for i in graph[x]:
			t=i
			break
		if (t,x) in d:
			q=d[(t,x)]
		else:
			q=d[(x,t)]
		z[t].append(y+l[x-1]-q)
		graph[t].remove(x)
		if len(graph[t])==1:
			stack.append([t,max(z[t])])
for i in range(1,n+1):
	z[i].sort()
	if len(z[i])>=3:
		m=max(m,l[i-1]+z[i][-2]+z[i][-1])
	m=max(m,z[i][-1]+l[i-1])
print(m)


pointer = 0
lst = [0, 0]
n, m = list(map(int, input().split()))
for i in range(n):
    a, b = list(map(int, input().split()))
    if (pointer == 0):
        lst[0], lst[1] = a, b
    pointer+=1
    if ((m*lst[0])/lst[1]) > ((m*a)/b):
        lst[0], lst[1] = a, b
print((m*lst[0])/lst[1])

import java.util.Collections;
import java.util.Scanner;

public class Super {

	public static void main(String[] args)
	{
		Scanner jk = new Scanner(System.in);
		int n = jk.nextInt();
		Long m = jk.nextLong();
		Double[] ins = new Double[n];
		for (int i=0; i<n; i++)
		{
			Double a = jk.nextDouble();
			Double b = jk.nextDouble();
			ins[i] = (a/b)*m;
		}
		Double ans = ins[0];
		for (Double i:ins)
		{
			if (ans>i)
			{
				ans = i;
			}
		}
		System.out.println(ans);

	}

}


#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int main() {
  memset(a, 0, sizeof(a));
  int num = 0;
  for (int i = 1; i <= 100005; i++) {
    a[i] = a[i - 1] + i;
    num = i;
    if (a[i] > 100005) break;
  }
  int k;
  scanf("%d", &k);
  if (k == 0) {
    printf("ab\n");
    return 0;
  }
  int vis[26] = {0}, numm = 0;
  for (int i = num; i >= 0; i--) {
    if (k >= a[i]) {
      vis[numm++] = i + 1;
      k -= a[i];
      i++;
    }
    if (k == 0) break;
  }
  for (int i = 0; i < numm; i++) {
    for (int j = 0; j < vis[i]; j++) {
      printf("%c", i + 'a');
    }
  }
  printf("\n");
  return 0;
}

from math import sqrt

def readln(): return map(int, input().rstrip().split())

def possible(n): return n * (n + 1) // 2

charset = 'abcdefghijklmnopqrstuvwxyz'
ci = 0
n = int(input())
rs = []
while n > 0:
    for i in range(int(sqrt(n) + 1), 0, -1):
        if n >= possible(i):
            n -= possible(i)
            rs.extend([charset[ci]] * (i + 1))
            ci += 1
else:
    if not rs:
        rs.append('a')
print(''.join(rs))


import javax.lang.model.element.Element;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class TestClass {
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[] ) throws Exception {

          FastReader sc=new FastReader();
          long k2=sc.nextLong();
          long k3=sc.nextLong();
          long k5=sc.nextLong();
          long k6=sc.nextLong();
           long result=0;
          long ans=new Double(Math.min(k2,Math.min(k5,k6))).longValue();
          k2=k2-ans;
          k5=k5-ans;
          k6=k6-ans;
          result+=ans*256;
          if(k2>=0){
          	ans=Math.min(k2,k3);
          	result+=ans*32;

          }
          System.out.println(result);
    }
}


n, l = int(input()), list(map(int, input().split()))
print(2 * max(l) - sum(l) + 1)

import java.util.Scanner;
public class main {
    public static void main(String args[]) throws Exception {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int i=0;
        int sum=0;
        int max=0;
        for (i=0;i<x;i++){
            int g = in.nextInt();
             sum=sum+g;
            max = Math.max(g,max);

        }
        System.out.println(2*max-sum+1);

    }
}


import java.awt.Point;
import java.awt.geom.Line2D;
import java.io.BufferedReader;
import java.io.File;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.security.GuardedObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.io.InputStream;
import java.math.BigInteger;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        long var=System.currentTimeMillis();
        solver.solve(1, in, out);
        /*if(System.getProperty("ONLINE_JUDGE")==null){
            out.println("["+(double)(System.currentTimeMillis()-var)/1000+"]");
        }*/
        out.close();
    }
}
class Pair {
    long x,y,index;
    Pair(long x,long y,int index){
        this.x=x;
        this.y=y;
        this.index=index;
    }
    public String toString(){
        return this.x+" "+this.y+" ";
    }

}
class tupple{
    long x,y,z;
    ArrayList<String> list=new ArrayList<>();
    tupple(long x,long y,long z){
        this.x=x;
        this.y=y;
        this.z=z;
    }
    tupple(tupple cl){
        this.x=cl.x;
        this.y=cl.y;
        this.z=cl.z;
        this.list=cl.list;
    }
}
class Edge{
    int u;
    int v;
    int time;
    long cost;
    public Edge(int u,int v){
        this.u=u;
        this.v=v;
        time=Integer.MAX_VALUE;
    }
    public int other(int x){
        if(u==x)return v;
        return u;
    }
}
class Ss{
    Integer a[]=new Integer[3];
    Ss(Integer a[]){
        this.a=a;

    }
    public int hashCode(){
        return a[0].hashCode()+a[1].hashCode()+a[2].hashCode();
    }
    public boolean equals(Object o){
        Ss x=(Ss)o;
        for(int i=0;i<3;i++){
            if(x.a[i]!=this.a[i]){
                return false;
            }
        }
        return true;

    }
}
class queary{
    int type;
    int l;
    int r;
    int index;
    queary(int type,int l,int r){
        this.type=type;
        this.l=l;
        this.r=r;
    }
}
class boat implements Comparable<boat>{
    int capacity;
    int index;
    boat(int capacity,int index)
    {
        this.capacity=capacity;
        this.index=index;
    }
    @Override
    public int compareTo(boat o) {
        // TODO Auto-generated method stub
        return this.capacity-o.capacity;
    }
}
class TaskC {
    static long mod=(long)(1e9+7);
/*    SegTree tree;
        int min[];
    static int prime_len=1000000;
    static int prime[]=new int[prime_len];
    static int primes[]=new int[prime_len];
    static int pn=0;
    static{
        //System.out.println("lifhgifwrek");
        for(int i=2;i<prime.length;i++){
            if(prime[i]==0){
                primes[pn++]=i;
            }
            if(1L*i*i<=Math.sqrt(prime.length)){
            for(int j=i*i;j<prime.length;j+=i){
                prime[j]=i;
            }
            }
        }
    //  System.out.println("end");

    //  prime[0]=true;
    //  prime[1]=1;
    }
    /*
     *  long pp[]=new long[10000001];
            pp[0]=0;
            pp[1]=1;
            for(int i=2;i<pp.length;i++){
                if(prime[i]!=0){
                    int gcd=(int)greatestCommonDivisor(i/prime[i], prime[i]);
                    pp[i]=(pp[i/prime[i]]*pp[prime[i]]*gcd)/pp[(int)gcd];
                }
                else
                    pp[i]=i-1;
            }

     * */
            public void solve(int testNumber, FastScanner in, PrintWriter out) throws IOException {
                String s=in.readString();
                int m=in.nextInt();
                StringBuilder sb=new StringBuilder(s);

                for(int i=0;i<m;i++){

                    int l=in.nextInt()-1;
                    int r=in.nextInt()-1;
                    int k=in.nextInt()%(r-l+1);
                    String ss=sb.substring(l,r+1);
                    StringBuilder temp=new StringBuilder();
                    int index=0;
                    for(int j=0;j<s.length();j++){
                        index++;
                        if(index>s.length()){
                            break;
                        }
                        if(j==l){

                            for(int p=k;p>0;p--){
                                temp.append(ss.charAt(ss.length()-p));
                            }
                        }
                        else if(j==l+(r-l+1-k)){
                        //  System.out.println(j+" "+(r+1)+" "+s.length());
                            j=r+1;
                        }

                        if(j<s.length()){
                            temp.append(sb.charAt(j));
                        }
                        //System.out.println(sb+" "+temp+" "+j);

                    }
                    sb=temp;
                }
                System.out.println(sb);

            }
        BigInteger BMOD=BigInteger.valueOf(mod);
        private long inv(long q) {
            return BigInteger.valueOf(q).modInverse(BMOD).longValue();
        }

            static void dfs(List<Integer>[] graph, boolean[] used, List<Integer> res, int u) {
            used[u] = true;
            for (int v : graph[u])
              if (!used[v])
                dfs(graph, used, res, v);
            res.add(u);
          }

          public static List<Integer> topologicalSort(List<Integer>[] graph) {
            int n = graph.length;
            boolean[] used = new boolean[n];
            List<Integer> res = new ArrayList<>();
            for (int i = n-1; i >0; i--)
              if (!used[i])
                dfs(graph, used, res, i);
            Collections.reverse(res);
            return res;
          }

        public static long[][] mulmatrix(long m1[][],long m2[][],long mod){
            long ans[][]=new long[m1.length][m2[0].length];
            for(int i=0;i<m1.length;i++){
                for(int j=0;j<m2[0].length;j++){
                    for(int k=0;k<m1.length;k++){
                        ans[i][j]+=(m1[i][k]*m2[k][j]);
                        ans[i][j]%=mod;
                    }
                }
            }
            return ans;
        }
        public static long[][] matrixexpo(long m[][],String n,long mod){
            if(n.equals("1")){
                return m.clone();
            }
            if(n.equals("10")){
                return mulmatrix(m, m , mod);
            }
            else{
                long temp [][]=matrixexpo(m,n.substring(0,n.length()-1),mod);
                temp=mulmatrix(temp, temp, mod);
                if(n.charAt(n.length()-1)=='0')return temp;
                else return mulmatrix(temp, m,mod);
            }
        }
        public static boolean isCompatible(long x[],long y[]){

            for(int i=0;i<x.length-1;i++){
                if(x[i]==y[i] && x[i+1]==y[i+1] && x[i]==x[i+1] && y[i]==y[i+1]){
                    return false;
                }
            }
            return true;
        }

        int phi(int n) {
            int res = n;
            for (int i = 2; i * i <= n; ++i) {
                if (n % i == 0) {
                    while (n % i == 0) {
                        n /= i;
                    }
                    res -= res / i;
                }
            }
            if (n != 1) {
                res -= res / n;
            }
            return res;
        }
        long pow(long x,long y,long mod){
            if(y<=0){
                return 1;
            }
            if(y==1){
                return x%mod;
            }
            long temp=pow(x,y/2,mod);
            if(y%2==0){
                return (temp*temp)%mod;
            }
            else{
                return (((temp*temp)%mod)*x)%mod;
            }
        }

/*      long DP(int id,int mask){
            //System.out.println("hi"+dp[id][mask]+" "+id+" "+Integer.toBinaryString(mask));
            if(id==0 && mask==0){
                dp[0][mask]=1;
                return 1;
            }
            else if(id==0){
                dp[0][mask]=0;
                return 0;
            }
            if(dp[id][mask]!=-1){

                return dp[id][mask];
            }
            long ans=0;
            for(int i=0;i<n;i++){
                if((mask & (1<<i))!=0 && c[i][id]>=1){
                        ans+=DP(id-1,mask ^ (1 << i));
                        ans%=mod;
                }
            }
            ans+=DP(id-1,mask);
            ans%=mod;
            dp[id][mask]=ans;
            return ans;
        }*/
            static long greatestCommonDivisor (long m, long n){
                    long x;
                    long y;
                    while(m%n != 0){
                        x = n;
                        y = m%n;
                        m = x;
                        n = y;
                    }
                    return n;
                }
                long no_of_primes(long m,long n,long k){
                    long count=0,i,j;
                    int primes []=new int[(int)(n-m+2)];
                       if(m==1)    primes[0] = 1;
                        for(i=2; i<=Math.sqrt(n); i++)
                        {
                            j = (m/i);    j *= i;
                            if(j<m)
                                j+=i;
                            for(; j<=n; j+=i)
                             {
                                 if(j!=i)
                                    primes[(int)(j-m)] = 1;
                             }
                        }

                for(i=0; i<=n-m; i++)
                            if(primes[(int)i]==0 && (i-1)%k==0)
                                count++;
                return count;
                }
}
class SegTree {
    int n;
    long  t[];
    long mod=(long)(1000000007);
    SegTree(int n,long  t[]){
        this.n=n;
        this.t=t;
        //build();
    }

    void build() {  // build the tree

        for (int i = n - 1; i > 0; --i)
            t[i]=(t[i<<1]+t[i<<1|1]);
    }

     void modify(int p, long value) {  // set value at position p
      for (t[p += n]=value; p > 1; p >>= 1) t[p>>1] = (t[p] + t[p^1]);
    }

     long query(int l, int r) {  // sum on interval [l, r)
      long res=0;

      for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if ((l&1)!=0) res=(res+t[l++]);
            if ((r&1)!=0) res=(res+t[--r]);
          }
      return res;
    }

    //
//
//
}
class FastScanner
{

    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar;
    private int snumChars;
    private SpaceCharFilter filter;

    public FastScanner(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }
    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }

        int res = 0;

        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));

        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }

        long res = 0;

        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));

        return res * sgn;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}
 class UF {

    private int[] parent;  // parent[i] = parent of i
    private byte[] rank;   // rank[i] = rank of subtree rooted at i (never more than 31)
    private int count;     // number of components
    public UF(int N) {
        if (N < 0) throw new IllegalArgumentException();
        count = N;
        parent = new int[N];
        rank = new byte[N];
        for (int i = 0; i < N; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }

    public int find(int p) {
        if (p < 0 || p >= parent.length) throw new IndexOutOfBoundsException();
        while (p != parent[p]) {
            parent[p] = parent[parent[p]];    // path compression by halving
            p = parent[p];
        }
        return p;
    }
    public int count() {
        return count;
    }

    public boolean connected(int p, int q) {
        return find(p) == find(q);
    }

    public boolean union(int p, int q) {
        int rootP = find(p);
        int rootQ = find(q);
        if (rootP == rootQ) return false;

        // make root of smaller rank point to root of larger rank
        if      (rank[rootP] < rank[rootQ]) parent[rootP] = rootQ;
        else if (rank[rootP] > rank[rootQ]) parent[rootQ] = rootP;
        else {
            parent[rootQ] = rootP;
            rank[rootP]++;
        }
        count--;
        return true;
    }

}

science zctycopttp deep engineering intelligence personalization meteorology electronics geology generation hacker reinforcement encryption artificial bylwlwylbb technology system neural computer lacongaithattuyet biology translation u mathematics baabcaa physics oceanography natural bababababab zozoumuhackleyan language machine abracadabra astronomy summarization ssssssssss caesar recommendation program algorithm aaaaaaaaa abacaba sentiment chemistry networks processing robotics analysis learning p

#include <bits/stdc++.h>
using namespace std;
long long n;
string s, f;
int main() {
  cin >> s >> n;
  if (s.length() == 1) {
    cout << s << endl;
    return 0;
  }
  for (int j = 1; j <= n; j++) {
    int l, r, k;
    cin >> l >> r >> k;
    k %= (r - l + 1);
    l--;
    for (int i = 0; i < l; i++) f += s[i];
    for (int i = r - k; i < r; i++) f += s[i];
    for (int i = l; i < r - k; i++) f += s[i];
    for (int i = r; i < s.length(); i++) f += s[i];
    s = f;
    f = "";
  }
  cout << s;
  return 0;
}


import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class StronglyConnectedCity {

    static FastReader in = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static final int[] dx = { 1 , 0 , -1 , 0 };
    static final int[] dy = { 0 , 1 , 0 , -1 };
    static final String D = "v>^<";
    // down // right // up // left

    public static void main(String[] args) {
        int n = in.nextInt() , m = in.nextInt();
        String[][] grid = new String[n][m];
        for(int i=0 ; i<n ; i++){
            Arrays.fill(grid[i],"");
        }
        String input = in.next();
        for(int i=0 ; i<n ; i++){
            for(int j=0 ; j<m ; j++){
                grid[i][j] += input.charAt(i);
            }
        }
        input = in.next();
        for(int i=0 ; i<m ; i++){
            for(int j=0 ; j<n ; j++){
                grid[j][i] += input.charAt(i);
            }
        }

        boolean fail = false;
        main:
        for(int i=0 ; i<n ; i++){
            for(int j=0 ; j<m ; j++){
                boolean[][] v = new boolean[n][m];
                v[i][j] = true;
                dfs(i,j,v,grid,n,m);
                for(int x=0 ; x<n ; x++){
                    for(int y=0 ; y<m ; y++){
                        if(!v[x][y]){
                            fail = true;
                            break main;
                        }
                    }
                }
            }
        }

        out.println(fail ? "NO" : "YES");

        out.flush();
    }

    public static boolean inside(int x,int y,int n,int m){
        return x >= 0 && x < n && y >= 0 && y < m ;
    }

    public static void dfs(int x, int y, boolean[][] v,String[][] grid,int n,int m) {
        v[x][y] = true;
        for(int i=0 ; i<D.length() ; i++){
            if(grid[x][y].contains(String.valueOf(D.charAt(i)))){
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(inside(nx,ny,n,m) && !v[nx][ny]){
                    dfs(nx,ny,v,grid,n,m);
                }
            }
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] nextInts(int n) {
            int[] ints = new int[n];
            for (int i = 0; i < n; i++) {
                ints[i] = in.nextInt();
            }
            return ints;
        }

        long[] nextLongs(int n) {
            long[] longs = new long[n];
            for (int i = 0; i < n; i++) {
                longs[i] = in.nextLong();
            }
            return longs;
        }
    }
}

#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d %d\n", &n, &m);
  std::string horizontal;
  getline(std::cin, horizontal);
  std::string vertical;
  getline(std::cin, vertical);
  std::string cycle = std::string("") + horizontal[0] + vertical[0] +
                      horizontal[n - 1] + vertical[m - 1];
  if (cycle == "<v>^" || cycle == ">^<v") {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, A[100001], sum = 0, index = 1;
  cin >> n >> k;
  for (int i = 1; i <= 2 * n; i++) A[i] = i;
  while (sum != 2 * k) {
    swap(A[index], A[index + 1]);
    sum += 2;
    index += 2;
  }
  for (int i = 1; i <= 2 * n; i++) cout << A[i] << " ";
  cout << endl;
  return 0;
}

n,k = list(map(int, input().split()))
A = [i for i in range(0, (2*n)+1)]
for i in range(1,k+1):
    A[2*i], A[2*i-1] = A[2*i-1], A[2*i]
print(" ".join(map(str, A[1:])))


import	java.util.*;
public	class	Main{
	public	static	void	main(String[]args){
		Scanner	cin=new	Scanner(System.in);
		int	x=cin.nextInt(),y=cin.nextInt(),s=Math.abs(x)+Math.abs(y);
		if(0>x){
			System.out.print(-s+" 0 0 ");
			if(0>y)	System.out.print(-s);
			else	System.out.print(s);
		}else{
			System.out.print("0 ");
			if(0>y)	System.out.print(-s);
			else	System.out.print(s);
			System.out.print(" "+s+" 0");
		}
	}
}

x,y=map(int,input().split())

w = abs(x)+abs(y)

if x<0:
	if y<0:
		print(-w,0,0,-w)
	else:
		print(-w,0,0,w)
else:
	if y<0:
		print(0,-w,w,0)
	else:
		print(0,w,w,0)


#include <bits/stdc++.h>
using namespace std;
unsigned long long n, sum, size[80010];
vector<unsigned long long> G[80010];
unsigned long long cal(unsigned long long x) { return x * (x - 1) / 2; }
void dfs(unsigned long long u, unsigned long long fa) {
  size[u] = 1;
  unsigned long long ans1 = 0, ans2 = 0;
  for (unsigned long long i = 0; i < G[u].size(); i++) {
    unsigned long long v = G[u][i];
    if (v == fa) {
      continue;
    }
    dfs(v, u);
    size[u] += size[v];
    ans1 -= cal(size[v]);
  }
  ans1 += cal(size[u]);
  ans2 += size[u] * (n - size[u]);
  sum += ans1 * ans1 + ans1 * ans2 * 2;
}
signed main() {
  cin >> n;
  for (unsigned long long i = 1; i < n; i++) {
    unsigned long long a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1, 0);
  cout << cal(n) * cal(n) - sum;
  return 0;
}

import java.io.*;
import java.math.*;
import java.util.*;

public class Solution {
    int n;
    ArrayList[] edges;

    long answer;

    long pairs(long n) {
        return n * (n - 1) / 2;
    }

    int solve(int p, int u) {
        int size = 1;
        ArrayList <Integer> subtrees = new ArrayList <Integer>();
        for (Object iter : edges[u]) {
            int v = (Integer)iter;
            if (v != p) {
                int ret = solve(u, v);
                size += ret;
                subtrees.add(ret);
            }
        }
        long pass = pairs(size);
        for (int subtree : subtrees) {
            pass -= pairs(subtree);
        }
        answer -= pass * pass;
        long out = (n - size) * size;
        answer -= 2 * out * pass;
        return size;
    }

    @SuppressWarnings("unchecked")
    public void run() {
        try {
            n = reader.nextInt();
            edges = new ArrayList[n];
            for (int i = 0; i < n; ++ i) {
                edges[i] = new ArrayList <Integer>();
            }
            for (int i = 0; i < n - 1; ++ i) {
                int a = reader.nextInt() - 1;
                int b = reader.nextInt() - 1;
                edges[a].add(b);
                edges[b].add(a);
            }
            answer = pairs(n) * pairs(n);
            solve(-1, 0);
            writer.println(answer);
        } catch (IOException ex) {
        }
        writer.close();
    }

    InputReader reader;
    PrintWriter writer;

    Solution() {
        reader = new InputReader();
        writer = new PrintWriter(System.out);
    }

    public static void main(String[] args) {
        new Solution().run();
    }

}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    Integer nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}