akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <functional>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  long long x, y, diff;
  cin >> x >> y;
  diff = x - y;
  if (diff == 1 || diff == 0 || diff == -1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return(0);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	s := sc.Text()

	ns := strings.Split(s, " ")

	a, _ := strconv.Atoi(ns[0])
	b, _ := strconv.Atoi(ns[1])
	c, _ := strconv.Atoi(ns[2])

	count := 0
	for i := a; i < b+1; i++ {
		if c%i == 0 {
			count++
		}
	}

	fmt.Println(count)
}



Measured memory_bytes: 1120
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break

Measured memory_bytes: 3444
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Map.Entry;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, MyScan in, PrintWriter out) {
            int d = in.nextInt();
            int g = in.nextInt();

            Map<Integer, Integer> x = new HashMap<>();

            x.put(0, 0);
            for (int s = 1; s <= d; s++) {

                Map<Integer, Integer> next = new HashMap<>();


                int xx = in.nextInt();
                int pp = in.nextInt();

                for (Map.Entry<Integer, Integer> mins : x.entrySet()) {
                    for (int i = 0; i < xx; i++) {
                        next.merge(mins.getKey() + i, mins.getValue() + i * s * 100, Math::max);
                    }
                    next.merge(mins.getKey() + xx, mins.getValue() + xx * s * 100 + pp, Math::max);
                }

                x = next;
            }

            int ans = 100000000;
            for (Map.Entry<Integer, Integer> mins : x.entrySet()) {
                if (mins.getValue() >= g) {
                    ans = Math.min(ans, mins.getKey());
                }
            }
            out.println(ans);


        }

    }

    static class MyScan {
        private final InputStream in;
        private byte[] inbuf = new byte[1024];
        public int lenbuf = 0;
        public int ptrbuf = 0;

        public MyScan(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 41364
//#pragma GCC optimize("O3", "no-stack-protector")
//#pragma GCC target("sse4", "avx", "popcnt", "lzcnt", "sse3", "sse4.1", "sse4.2", "sse2", "tune=native")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using old = long double;

const int N = 401;

int h, w;
int used[N][N];
string a[N];
int cnt[2];

int dx[4] = { -1, 1, 0, 0 };
int dy[4] = { 0, 0, -1, 1 };

void dfs(int i, int j) {
    used[i][j] = 1;
    if (a[i][j] == '#') {
        ++cnt[0];
    } else {
        ++cnt[1];
    }
    for (int t = 0; t < 4; ++t) {
        int x = i + dx[t];
        int y = j + dy[t];
        if (x >= 0 && x < h && y >= 0 && y < w && a[i][j] != a[x][y] && !used[x][y]) {
            dfs(x, y);
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (used[i][j]) {
                continue;
            }
            cnt[0] = cnt[1] = 0;
            dfs(i, j);
            ans += 1LL * cnt[0] * cnt[1];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 18560
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  vector<int>a(N);
  for ( int i = 0; i < N; i++ ) cin >> a[i];
  int cnt = 0;
  int tmp = -1;
  for ( int i = 0; i < N-1; i++ ) {
    if ( a[i] == a[i+1] ) {
      cnt++;
      a[i+1] = tmp;
      tmp--;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {

    int n;
    int k;
    int d[10];
    cin >> n >> k;
    REP(i, k) cin >> d[i];

    for(int i = n; i <= n*10; i++) {
        int num = i;
        bool is_ok = true;
        while(num > 0) {
            int idx = num % 10;
            num /= 10;
            if(d+k != find(d, d+k, idx)) {
                is_ok = false;
                break;
            }
        }
        if(is_ok) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int A,B;
	cin>>A>>B;
	cout<<max(A+A-1,max(A+B,B+B-1))<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define all(v) ((v).begin()),((v).end())
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
#define el '\n';
#define loop(i, n) for(int i = 0;i < int(n);i++)
#define PI acos(-1)
#define pb push_back
#define F first
#define S second

void LOL() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

bool comp(double a, double b) {
    return abs(a - b) < 1e-9;
}

int LCM(int a, int b) {
    return a * b / (__gcd(a, b));
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b) {
    return (a.second < b.second);
}

const int N = 1e6 + 7, E = 1e5 + 5, OO = 0x3f3f3f3f;
int main() {
    LOL();
   int k,a,b;
   cin>>k>>a>>b;
   for(int i=a;i<=b;++i){
       if(i%k==0)return cout<<"OK\n",0;
   }
   cout<<"NG\n";
    return 0;
}

// CHECK THE FOLLOWING ONE MORE TIME BEFORE SUBMIT :
// the vector,arr,etc is redefined in multi cases
// the constraint N M OO etc ,,, The size of the array,vector etc
// the data type of variables ,,, int is enough ?
// the complexity of the code ? O(n)? O(n*n)? will fit ?
// Out of bond ? access an element out of size ? i-1>0 ? i+1 <n?
// CHECK ONE MORE TIME, IT'S OK TO GET WA,BUT NOT OK TO GET TLE OR RTE

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <sstream>


#define rep(i,n) for(long long i=0;i<n;i++)
using namespace std;



int main() {

	int n;
	cin >> n;
	vector<long long> a(n);
	rep(i, n) cin >> a[i];

	sort(a.begin(), a.end());
	bool ans = true;

	rep(i, n-1)
	{
		if (a[i] == a[i + 1]) ans = false;
	}

	

	cout << (ans ? "YES" : "NO") << endl;

	return 0;
}




Measured memory_bytes: 1792
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n,m = sc.nextInt

  val mod = 1000000007

  def plus(a: Long, b: Long): Long = (a+b) % mod
  def minus(a: Long, b: Long): Long = (a-b+mod) % mod
  def times(a: Long, b: Long): Long = (a*b) % mod

  def pow(a: Long, n: Int): Long = {
    def pow(a: Long, n: Int, res: Long): Long = {
      if (n == 0) res
      else if ((n&1) == 0) pow(times(a,a),n >> 1,res)
      else pow(times(a,a),n >> 1,times(a,res))
    }
    pow(a,n,1L)
  }

  def inv(a: Long): Long = pow(a,mod-2)
  def div(a: Long, b: Long): Long = times(a,inv(b))


  def factorize(n: Int): List[Int] = {
    if (n == 1) Nil
    else {
      var i = 2
      var d = 0
      while (i*i <= n && d == 0) {
        if (n % i == 0) d = i
        i += 1
      }
      if (d == 0) List(n) else d::factorize(n/d)
    }
  }

  if (m == 1) println(1)
  else {
    val f = factorize(m)
    val bs = f.toSet.toList.map((x: Int) => f.count(_ == x))

    val l = bs.max + n - 1

    def factTable(n: Int): IndexedSeq[Long] = {
      (1 to n).scanLeft(1L)(times(_,_))
    }

    val fact = factTable(l)

    def factInvTable(n: Int): IndexedSeq[Long] = {
      (1 to n).scanRight(inv(fact(n)))(times(_,_))
    }

    val factInv = factInvTable(l)

    def comb(n: Int, k: Int): Long = {
      times(times(fact(n), factInv(k)), factInv(n-k))
    }

    println(bs.map(b => comb(b+n-1, b)).reduceLeft(times(_,_)))
  }
}


Measured memory_bytes: 41312
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int counter = 0;

void bfs(vector<vector<vector<int> > >& stamps, const vector<string>& grid, const pair<int,int>& start, const pair<int,int>& goal)
{
  const int R = grid.size(), C = grid[0].size();
  queue<pair<int,int> > q;
  q.push(start);
  vector<vector<int> > prev(R, vector<int>(C, -1));
  while (!q.empty()) {
    if (q.front() == goal) {
      break;
    }
    const int i = q.front().first;
    const int j = q.front().second;
    q.pop();

    for (int d = 0; d < 4; d++) {
      static const int di[] = {1, -1, 0, 0};
      static const int dj[] = {0, 0, 1, -1};
      const int k = i + di[d], l = j + dj[d];
      if (0 <= k && k < R && 0 <= l && l < C && grid[k][l] == '.' && prev[k][l] == -1) {
        prev[k][l] = i*C + j;
        q.push(make_pair(k, l));
      }
    }
  }
  vector<pair<int,int> > path;
  for (pair<int,int> pos = goal; pos != start;) {
    path.push_back(pos);
    const int p = prev[pos.first][pos.second];
    pos.first = p/C;
    pos.second = p%C;
  }
  for (vector<pair<int,int> >::reverse_iterator it = path.rbegin(); it != path.rend(); ++it) {
    stamps[it->first][it->second].push_back(counter++);
  }
}

int main()
{
  int R, C, M;
  cin >> R >> C >> M;
  vector<string> grid(R);
  for (int i = 0; i < R; i++) {
    cin >> grid[i];
  }
  static int keep_costs[50][50], on_costs[50][50], off_costs[50][50];
  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++) {
      cin >> keep_costs[i][j];
    }
  }
  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++) {
      cin >> on_costs[i][j];
    }
  }
  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++) {
      cin >> off_costs[i][j];
    }
  }
  static pair<int,int> rooms[1000];
  for (int i = 0; i < M; i++) {
    cin >> rooms[i].first >> rooms[i].second;
  }

  vector<vector<vector<int> > > stamps(R, vector<vector<int> >(C));
  stamps[rooms[0].first][rooms[0].second].push_back(counter++);
  for (int i = 0; i < M-1; i++) {
    bfs(stamps, grid, rooms[i], rooms[i+1]);
  }
  int ans = 0;
  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++) {
      const vector<int>& s = stamps[i][j];
      if (!s.empty()) {
        const int keep = keep_costs[i][j];
        const int on = on_costs[i][j];
        const int off = off_costs[i][j];
        ans += on;
        for (vector<int>::const_iterator it = s.begin(); it+1 != s.end(); ++it) {
          ans += min(off + on, keep*(*(it+1) - *it));
        }
        ans += off;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int Cmp(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

void Do(int N){
  int i;
  int v[N];
  double s;
  for(i = 0;i < N;i++) scanf("%d", &v[i]);
  qsort(v, N, sizeof(int), Cmp);
  s = v[0];
  for(i = 1;i < N;i++) s = (s + v[i]) / 2.;
  printf("%g\n", s);
}

int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
class A
{
    static void Main()
    {
        double[] a = Console.ReadLine().Split().Select(double.Parse).ToArray();
        Console.WriteLine(Math.Sqrt((a[2]-a[0])*(a[2]-a[0])+(a[3]-a[1])*(a[3]-a[1])));
    }
}

Measured memory_bytes: 9628
#include<stdio.h>

#define MAX 100
#define INF 100000000
#define white 0
#define gray 1
#define black 2

typedef struct{
  int data[MAX];
  int head;
  int tail;
}queue;

queue Q;

int n,d[MAX] = {INF};
int g[MAX][MAX] = {0};
int color[MAX] = {white};

void bfs(int);
void enqueue(int);
int dequeue(void);

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      g[u-1][v-1] = 1;
    }
  }
  for(i=0;i<n;i++)
    d[i] = INF;

  bfs(0);

  for(i=0;i<n;i++){
    if(d[i] == INF)printf("%d %d\n",i+1,-1);
    else printf("%d %d\n",i+1,d[i]);
  }
  return 0;
}

void bfs(s){
  int v,u;

  d[s] = 0;
  color[s] = gray;
  Q.head = Q.tail = 0;
  enqueue(s);

  while(Q.tail < n){
    u = dequeue();
    if(u == INF)break;
    for(v=0;v<n;v++){
      if(g[u][v] == 0)continue;
      if(color[v] == white){
	d[v] = d[u] + 1;
	color[v] = gray;
	enqueue(v);
      }
    }
    color[u] = black;
  }
}

void enqueue(int s){

  if(Q.tail >= n)return;
  
  Q.data[Q.tail] = s;
  Q.tail++;
}

int dequeue(){
  int s;

  if(Q.head == Q.tail)return INF;

  s = Q.data[Q.head];
  Q.head++;

  return s;
}

Measured memory_bytes: 636
#include <stdio.h>

int main(){
    int a, b, w, answer;
    scanf("%d %d %d", &w, &a, &b);
    if((a < b && b < a + w) || (a < b + w && b < a) || (a == b)){
        printf("0");
    }else if(a < b){
        answer = b - a - w;
        printf("%d", answer);
    }else{
        answer = a - b - w;
        printf("%d", answer);
    }
    return 0;
}

Measured memory_bytes: 128
import sys
#input = sys.stdin.buffer.readline

def main():
    N = int(input())
    S = input()
    Q = input()
    x = tuple(map(int,input().split()))
    for k in x:
        d,m,dm,dmc = 0,0,0,0
        for i in range(N):
            st = S[i]
            if st == "D":
                d += 1
            elif st == "M":
                m += 1
                dm += d
            elif st == "C":
                dmc += dm
            if i >= k-1:
                if S[i-k+1] == "D":
                    dm -= m
                    d -= 1
                elif S[i-k+1] == "M":
                    m -= 1
        print(dmc)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 55448
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
		int N, K;
		cin >> N >> K;
		vector<int> v(N, 0);
		for (int i = 0; i < N; i++) cin >> v[i];

		int ans = 0;
		for (int l = 0; l <= K; l++) {
				for (int r = 0; r <= K-l; r++) {
						if (l+r > N) continue;
						int d = K - l - r;
						int now = 0;
						vector<int> S;

						for (int i = 0; i < l; i++) {
								now += v[i];
								S.push_back(v[i]);
						}

						for (int i = N-r; i < N; i++) {
								now += v[i];
								S.push_back(v[i]);
						}

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

						for (int i = 0; i < d; i++) {
								if (i >= S.size()) break;
								if (S[i] > 0) break;
								now -= S[i];
						}

						ans = max(ans, now);
				}
		}

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


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

n,m,q=parseMap(split(readline()))
array=Vector{Vector{Int}}()
function dfs(now,arr::Vector{Int})
    if now==n
        push!(array,arr)
        return
    end
    if now==0
        for i in 1:m
            dfs(now+1,[i])
        end
    else
        for i in arr[end]:m
            dfs(now+1,vcat(arr,i))
        end
    end
end

function main()
    data=[parseMap(split(readline())) for i in 1:q]
    dfs(0,Vector{Int}())
    ans=0
    for i in array
        res=0
        for j in data
            if i[j[2]]-i[j[1]]==j[3]
                res+=j[4]
            end
        end
        ans=max(ans,res)
    end
    println(ans)
end
main()

Measured memory_bytes: 246672
#include <bits/stdc++.h>
using namespace std;

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

int main()
{

    long double s;
    //int s;
    cin >> s;

    lint a, b, c, d;

    lint ans, tmp=0;
    lint x = pow(10, 9);

    a = ceil(sqrt(s));
    b = a;

    while (a * b - s > x)
    {
        if(a < x){
        a++;
        b--;
        }
        else
        {
            b++;
        }
        if(b>x){
            b = x-1;
            tmp = 1;
            break;
        }
    }

    if(tmp==1){
        c = 0;
    }
    c = 1;
    d = a * b - s;

    cout << "0 0 " << a << " " << c << " " << d << " " << b;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
ll gcd(ll a,ll b)
{
    if(a<b)
        swap(a,b);
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    ll n,i,j,k,l,a,b,c,sum=0;
    cin >> n;
    for(i=1; i<=n; i++)
    {
        a=i;
        for(j=1; j<=n; j++)
        {
            b=j;
            for(k=1; k<=n; k++)
            {
                c=k;
                sum+=gcd(gcd(a,b),c);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


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

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

vector<int> a;
vector<vector<int>> edges;
vector<int> dp;
vector<int> ans;

void dfs(int v) {
  int i = distance(dp.begin(), lower_bound(dp.begin(), dp.end(), a[v]));
  int old = dp[i];
  dp[i] = a[v];
  ans[v] = distance(dp.begin(), lower_bound(dp.begin(), dp.end(), INF)) - 1;
  for (int k : edges[v]) {
    if (ans[k] < 0) dfs(k);
  }
  dp[i] = old;
}

int main() {
  
  int N;
  cin >> N;
  a = vector<int>(N);
  rep(i,N) cin >> a[i];
  edges = vector<vector<int>>(N);
  rep(i,N-1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  
  dp = vector<int>(N+1, INF);
  dp[0] = -1;
  ans = vector<int>(N, -1);

  dfs(0);

  rep(i,N) cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 25060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

const int MAXM = 11;
const int MAXN = 101;
const int INF = 1<<28;

int M, N;
int T[MAXN], U[MAXN];
int space1[MAXM];
int space2[MAXM];
queue<int> car;
vector<int> ans;

void out(int t) {
  for(int i = 0; i < M; ++i) {
    while(space1[i] != -1 && U[space1[i]] <= t) {
      ans.push_back(space1[i]);
      space1[i] = space2[i];
      space2[i] = -1;
    }
  }
}

void in(int t) {
  if(t % 10 == 0) {
    int k = t / 10;
    if(k < N) car.push(k);
  }

  if(car.empty()) return;
  int k = car.front();

  try {
    for(int i = 0; i < M; ++i) {
      if(space1[i] == -1) {
        space1[i] = k;
        throw 0;
      }
    }
    
    int id = -1;
    int mini = INF;
    for(int i = 0; i < M; ++i)
      if(space2[i] == -1) {
        int rem = U[space1[i]] - t;
        if(rem >= T[k]) {
          int diff = rem - T[k];
          if(mini > diff) {
            id = i;
            mini = diff;
          }
        }
      }
    if(id != -1) {
      space2[id] = space1[id];
      space1[id] = k;
      throw 0;
    }

    for(int i = 0; i < M; ++i)
      if(space2[i] == -1) {
        int rem = U[space1[i]] - t;
        int diff = T[k] - rem;
        if(mini > diff) {
          id = i;
          mini = diff;
        }
      }
    if(id != -1) {
      space2[id] = space1[id];
      space1[id] = k;
      throw 0;
    }

  } catch(...) {
    U[k] = t + T[k];
    car.pop();
  }
}

int main() {
  while(cin >> M >> N && (M|N)) {
    for(int i = 0; i < N; ++i) {
      cin >> T[i];
    }
    ans.clear();
    fill(space1, space1+MAXM, -1);
    fill(space2, space2+MAXM, -1);
    for(int t = 0; t <= 2000; ++t) {
      out(t);
      in(t);
    }
    for(int i = 0; i < ans.size(); ++i) {
      if(i) cout << " ";
      cout << ans[i]+1;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N; cin >> N;
  vector<long long> A(N), B(N);
  vector<pair<long long, int>> C;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
    C.push_back(make_pair(A.at(i) + B.at(i), i));
  }
  sort(C.begin(), C.end(), greater<pair<long long, int>>());
  long long a = 0;
  long long b = 0;
  for (int i = 0; i < N; i++) {
    int index = C.at(i).second;
    if (i % 2 == 0) a += A.at(index);
    else b += B.at(index);
  }
  cout << a - b << endl;
}

Measured memory_bytes: 3956
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    String s;
    char[] c;
    int res, i, l;

    res = 0;
    for(;sc.hasNext();){
      s = sc.next(); c = new char[s.length()];
      for(i = 0;i < s.length();i++)c[i] = s.charAt(i);

      for(i = 0;i < s.length();i++){
        if(c[i] >= '0' && c[i] <= '9'){
          for(l = i;i < s.length() && c[i] >= '0' && c[i] <= '9';)i++;
          res += readint(c, l, i);
        }
      }
    }
    out.println(res);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int readint(char[] ch, int l, int r){
    int i, d, res;
    d = 1; res = 0;
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res;
  }
}

Measured memory_bytes: 17152
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    string a,b;
    
    cin >> a;
    
    if(a == "Sunny"){
        b="Cloudy";
    }else if( a == "Cloudy"){
        b = "Rainy";
    }else{
        b="Sunny";
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  char c[n];
  scanf("%s", c);
  int l = 0, r = 0, m = 0;
  ;
  for (int i = 0; i < n; i++) {
    if (c[i] == '(')
      l++;
    else
      r++;
    m = max(m, r - l);
  }
  for (int i = 0; i < m; i++) printf("(");
  l += m;
  for (int i = 0; i < n; i++) printf("%c", c[i]);
  for (int i = 0; i < l - r; i++) printf(")");
  printf("\n");
  return 0;
}

Measured memory_bytes: 256
import heapq
x,y,z,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True);B.sort(reverse=True);C.sort(reverse=True)
hq=[]
heapq.heappush(hq,(-(A[0]+B[0]+C[0]),0,0,0))
searched={(0,0,0)}
a,b,c=0,0,0
D=((1,0,0),(0,1,0),(0,0,1))
for _ in range(k):
    abc,a,b,c=heapq.heappop(hq)
    print(-abc)
    for dx,dy,dz in D:
        if not (a+dx,b+dy,c+dz) in searched:
            if a+dx<x and b+dy<y and c+dz<z:
                heapq.heappush(hq,(-(A[a+dx]+B[b+dy]+C[c+dz]),a+dx,b+dy,c+dz))
                searched.add((a+dx,b+dy,c+dz))

Measured memory_bytes: 60504
import java.util.Scanner;

public class Main {
	static int N, M;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		char[][] a = new char[N][N];
		char[][] b = new char[N][N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.next().toCharArray();
		}
		for (int i = 0; i < M; i++) {
			b[i] = sc.next().toCharArray();
		}

		System.out.print(check(a, b) ? "Yes" : "No");
	}

	static boolean check(char[][] a, char[][] b) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if(i + M - 1 >= N || j + M - 1 >= N) continue;
				boolean match = true;
				for (int i2 = 0; i2 < M; i2++) {
					for (int j2 = 0; j2 < M; j2++) {
						if(a[i2 + i][j2 + j] != b[i2][j2]) match = false;
					}
				}
				if(match) return true;
			}
		}
		return false;
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

unordered_map<ll,ll> prime_factorization(ll n)
{
    unordered_map<ll, ll> prime_fact;
    for (int i = 2; i * i <= n; i++)
    {
        while( n % i == 0){
            prime_fact[i]++;
            n /= i;
        }
    }
    if(n != 1){
        prime_fact[n]++;
    }

    return prime_fact;
}

int main(void)
{
    ll n;
    ll mod = 1e9 + 7;
    cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }

    vector<unordered_map<ll, ll>> prime_factlist(n);
    REP(i,n){
        prime_factlist[i] = prime_factorization(a[i]);
    }

    unordered_map<ll,ll> lcm_fact = prime_factlist[0];
    FOR(i,1,n){
        for (auto itr = prime_factlist[i].begin(); itr != prime_factlist[i].end();itr++){
            if(lcm_fact[itr->first] < itr->second){
                lcm_fact[itr->first] = itr->second;
            }
        }
    }

    ll lcm = 1;
    for (auto itr = lcm_fact.begin(); itr != lcm_fact.end(); itr++)
    {
        REP(i,itr->second){
            lcm = (lcm * itr->first)%mod;
        }
    }

    ll sum = 0;
    REP(i, n)
    {
        sum  = (sum + lcm * modinv(a[i],mod))%mod;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    int res = N;
    for(int i = 0; i < M; i++) {
        int j;
        cin >> j;
        res -= j;
    }
    if(res < 0) cout << -1 << endl;
    else cout << res << endl;
}


Measured memory_bytes: 3632
N = int(input())
ans = 10000

for i in range(1, N):
  temp = 0
  n = str(i)
  m = str(N-i)
  for j in range(len(n)):
    temp += int(n[j])
  for j in range(len(m)):
    temp += int(m[j])
  ans = min(ans, temp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int N;

	cin >> N;

	int H[N + 1];

	for (int i = 1; i <= N; i++)
	{
		cin >> H[i];
	}

	int countbuf = 0;
	int countmax = 0;

	for (int i = 1; i < N; i++)
	{
		if (H[i] >= H[i + 1])
		{
			countbuf++;

			if (countbuf > countmax)
			{
				countmax = countbuf;
			}
		}
		else
		{
			countbuf = 0;
		}
	}

	cout << countmax << endl;

	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	char a,b,c,d;
	int A,B,C,D;
	scanf("%c%c%c%c",&a,&b,&c,&d);
	A=a-48;
	B=b-48;
	C=c-48;
	D=d-48;
//	printf("%d",A);
while(1){
	if(A+B+C+D==7){
		printf("%d%c%d%c%d%c%d%c%d\n",A,'+',B,'+',C,'+',D,'=',7);
		break;
	}
	if(A+B+C-D==7){
		printf("%d%c%d%c%d%c%d%c%d\n",A,'+',B,'+',C,'-',D,'=',7);
		break;
	}
	if(A+B-C+D==7){
		printf("%d%c%d%c%d%c%d%c%d\n",A,'+',B,'-',C,'+',D,'=',7);
		break;
	}
	if(A+B-C-D==7){
		printf("%d%c%d%c%d%c%d%c%d\n",A,'+',B,'-',C,'-',D,'=',7);
		break;
	}
	if(A-B+C+D==7){
		printf("%d%c%d%c%d%c%d%c%d\n",A,'-',B,'+',C,'+',D,'=',7);
		break;
	}
	if(A-B+C-D==7){

		printf("%d%c%d%c%d%c%d%c%d\n",A,'-',B,'+',C,'-',D,'=',7);
		break;}
	if(A-B-C+D==7){
		printf("%d%c%d%c%d%c%d%c%d\n",A,'-',B,'-',C,'+',D,'=',7);
		break;}
	if(A-B-C-D==7){
		printf("%d%c%d%c%d%c%d%c%d\n",A,'-',B,'-',C,'-',D,'=',7);
		break;}
}
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll x,y;
	cin>>x>>y;
	int co=0;
	while(x<=y){
		x*=2;
		co++;
	}
	cout<<co<<endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i++)
typedef long long ll;
const int INF = 1e9;

int n, a, b;
ll v[51];
ll comb[51][51];
void get_comb() {
	REP(i, 0, n + 1) {
		REP(j, 0, i + 1) {
			if (j == 0 || j == i) comb[i][j] = 1;
			else comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
	return;
}

int main()
{
	cin >> n >> a >> b;
	REP(i, 0, n) cin >> v[i];

	get_comb();
	sort(v, v + n);
	reverse(v, v + n);

	double avr = 0.0;
	REP(i, 0, a) avr += v[i];
	avr /= a;

	int cnt1 = 0, cnt2 = 0;
	ll ans = 0;
	REP(i, 0, n) {
		if (v[i] == v[a - 1]) {
			cnt1++;
			if (i < a) cnt2++;
		}
	}

	if (cnt2 == a) {
		REP(i, a, b + 1) {
			ans += comb[cnt1][i];
		}
	}
	else {
		ans += comb[cnt1][cnt2];
	}

	printf("%.8f\n", avr);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INFTY 1000000000
#define N 500000
void mergeSort(int *A,int left,int right);
void merge(int *A,int left,int mid,int right);
int cnt=0,n;

int main(){
  int i,A[N];

  scanf("%d",&n);
  if(n <= 0 || n > 500001)
    printf("Error\n");

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    if(i == (n-1)) printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",cnt);
  return 0;
}

void mergeSort(int *A,int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

void merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k;
  int L[N],R[N];
  
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++){
    L[i] = A[left + i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY; 
  R[n2] = INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i] <= R[j]){
      cnt++;
      A[k] = L[i];
      i++;
    }
    else{
      cnt++;
      A[k] = R[j];
      j++;
    }
  }
  
  
}



Measured memory_bytes: 5772
from collections import Counter

n = int(input())
s = input()
c = Counter(s)
a = c['R'] * c['G'] * c['B']

def search(l, r, a, t):
    while (r-l)>=0:
        mid = (l+r)//2
        if a[mid] == t:
            return True
        if a[mid] > t:
            r = mid-1
        if a[mid] < t:
            l = mid+1

    return False

ri = []
gi = []
bi = []

for i in range(n):
    if s[i] == "R":
        ri.append(i)
    elif s[i] == "G":
        gi.append(i)
    elif s[i] == "B":
        bi.append(i)
        
for i in range(len(gi)):
    for j in range(len(bi)):
        if search(0, len(ri)-1, ri, bi[j]-abs(gi[i]-bi[j])) or search(0, len(ri)-1, ri, gi[i]-abs(gi[i]-bi[j])):
            a -= 1
            
for i in range(len(bi)):
    for j in range(len(ri)):
        if search(0, len(gi)-1, gi, ri[j]-abs(bi[i]-ri[j])) or search(0, len(gi)-1, gi, bi[i]-abs(bi[i]-ri[j])):
            a -= 1
            
for i in range(len(ri)):
    for j in range(len(gi)):
        if search(0, len(bi)-1, bi, gi[j]-abs(ri[i]-gi[j])) or search(0, len(bi)-1, bi, ri[i]-abs(ri[i]-gi[j])):
            a -= 1
            
print(a)

Measured memory_bytes: 72504
from collections import Counter

H,W,*n = open(0).read().split()
H = int(H)
W = int(W)
c = Counter([])
for x in n:
    c += Counter(x)
if H % 2 == 0 and W % 2 == 0:
    for x in c.values():
        if x % 4 != 0:
            print('No')
            break
    else:
        print('Yes')
elif H % 2 == 1 and W % 2 == 1:
    center = 0
    cross = H + W - 1
    corner = (H*W) - cross
    corner_filled = 0
    cross_filled = 0
    for x in c.values():
        if x % 2 == 1:
            if center == 0:
                center = 1
                y = x - 1
            else:
                print('No')
                break
        else:
            y = x
        if y % 4 == 0:
            if corner_filled + x < corner:
                corner_filled += x
            elif corner_filled == corner:
                if cross_filled + x > cross:
                    print('No')
                    break
                else:
                    cross_filled += x
            else:
                cross_filled += corner_filled + x - corner
                corner_filled = corner
        else:
            temp = (x//4) * 4
            if corner_filled + temp < corner:
                corner_filled += temp
            elif corner_filled == corner:
                if cross_filled + temp > cross:
                    print('No')
                    break
                else:
                    cross_filled += temp
            else:
                cross_filled += corner_filled + temp - corner
                corner_filled = corner
            if cross_filled + 2 > cross:
                print('No')
                break
            else:
                cross_filled += 2
    else:
        print('Yes')
else:
    if H % 2 == 1:
        center = W
        sides = (H*W) - W
    else:
        center = H
        sides = (H*W) - H
    center_filled = 0
    sides_filled = 0
    for x in c.values():
        if x % 4 == 0:
            if sides_filled + x < sides:
                sides_filled += x
            elif sides_filled == sides:
                if center_filled + x > center:
                    print('No')
                    break
                else:
                    center_filled += x
            else:
                center_filled += sides_filled + x - sides
                sides_filled = sides
        elif x % 2 == 0:
            temp = (x//4) * 4
            if sides_filled + temp < sides:
                sides_filled += temp
            elif sides_filled == sides:
                if center_filled + temp > center:
                    print('No')
                    break
                else:
                    center_filled += temp
            else:
                center_filled += sides_filled + temp - sides
                sides_filled = sides
            if center_filled + 2 > center:
                print('No')
                break
            else:
                center_filled += 2
        else:
            print('No')
            break
    else:
        print('Yes')

Measured memory_bytes: 9456
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> cnt(K);
    rep(i, K) {
        int mul = N / K;
        cnt[i] = mul;
        if (i != 0 && N % K != 0 && N - mul * K >= i) cnt[i]++;
    }

    ll ans = 0;
    rep(i, K) {
        if ((i + i) % K == 0) {
            ll a = cnt[i];
            ll b = cnt[(K - i) % K];
            ll c = cnt[i];
            ans += a * b * c;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
sx,sy,tx,ty=map(int,input().split())
a=ty-sy 
b=tx-sx
c=ty-sy+1
d=tx-sx+1
ans=('U'*a)+('R'*b)+('D'*a)+('L'*b)+('L')+('U'*c)+('R'*d)+('D')+('R')+('D'*c)+('L'*d)+('U')
print(ans)

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

int a,b,c,d;
signed main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	printf("%lld\n",max(max(a*c,a*d),max(b*c,b*d)));
	
	
return 0;	
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<long long, long long> P;
const int MOD = 1e9 + 7;
int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    priority_queue<long long> sei, hu, hu2;
    for(int i = 0; i < N; i++) {
        long long a;
        cin >> a;
        A[i] = a;
        if(a < 0) {
            hu.push(-a);
            hu2.push(a);
        }
        else sei.push(a);
    }
    long long ans = 1;
    if(N == K){
        for(int i = 0; i < N; i++){
            ans *= A[i];
            ans %= MOD;
        }
        cout << (ans + MOD) % MOD << endl;
        return 0;
    }
    if(sei.size() == 0 && K % 2 == 1){
        for(int i = 0; i < K; i++){
            ans *= hu2.top();
            hu2.pop();
            ans %= MOD;
        }
        cout << (ans + MOD) % MOD << endl;
        return 0;
    }
    while(K > 0){
        if(K == 1){
            ans *= sei.top();
            K--;
            sei.pop();
        }
        else if(hu.size() >= 2 && sei.size() >= 2){
            long long hut1, hut2, seit1, seit2;
            hut1 = hu.top();
            hu.pop();
            hut2 = hu.top();
            seit1 = sei.top();
            sei.pop();
            seit2 = sei.top();
            if(hut1 * hut2 < seit1 * seit2){
                ans *= seit1;
                hu.push(hut1);
                K--;
            }
            else{
                ans *= hut1 * hut2 % MOD;
                sei.push(seit1);
                hu.pop();
                K -= 2;
            }
        }
        else if(hu.size() >= 2 && sei.size() < 2){
            long long t1, t2;
            t1 = hu.top();
            hu.pop();
            t2 = hu.top();
            hu.pop();
            ans *= t1 * t2 % MOD;
            K -= 2;
        }
        else if(hu.size() < 2 && sei.size() >= 2){
            ans *= sei.top();
            sei.pop();
            K--;
        }
        else{
            ans *= sei.top();
            ans %= MOD;
            sei.pop();
            K--;
        }
        ans %= MOD;
    }
    cout << (ans + MOD) % MOD << endl;
}

Measured memory_bytes: 8176
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

int Mod(int a) {
	return (a+mod)%mod;
}
int Mul(int a, int b) {
	return Mod(Mod(a) * Mod(b));
}
int Add(int a, int b) {
	return Mod(Mod(a) + Mod(b));
}
//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int n;
        cin>>n;
        int ans = 0;
        for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++) {
				if(i*j < n) ans++;
				else break;
			}
		}
		cout<<ans<<endl;
			
        
        
    }



return 0;
}


Measured memory_bytes: 3648
M=10**9+7
N,K=gets.split.map(&:to_i)
1.upto(K).each do |i|
  k=(0...(K-1)).to_a.combination(i-1).size % M
  n=(0...(N-K+1)).to_a.combination(i).size % M
  p n*k%M
end

Measured memory_bytes: 3488
#include <stdio.h>
#include <stdlib.h>

#define inf (int)(1e9 + 7)

int main(){
	int N, amax = 0, amin = inf, i;
	scanf("%d", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
		if(a[i] > amax){
			amax = a[i];
		}
		if(a[i] < amin){
			amin = a[i];
		}
	}
	if(amax - amin > 1){
		printf("No\n");
	}
	if(amax - amin == 0){
		if(amax == N - 1 || amax <= N / 2){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	if(amax - amin == 1){
		int aminnum = 0;
		for(i = 0; i < N; i++){
			if(a[i] == amin){
				aminnum++;
			}
		}
		if(1 <= amax - aminnum && amax - aminnum <= (N - aminnum) / 2){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18;  
ll n;

void solve(int data){
    if(data == 0) return;
    auto f = abs(data) %2;
    solve((data-f)/(-2));
    cout << f;
}


int main(){
  cin >> n;
  if(n==0){
  	cout << n;
  }else{
    solve(n);
  }
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

long long yen = 100, need;
int tot = 0;

int main() {
	ios::sync_with_stdio(0);
//	freopen("abc165_b.in", "r", stdin);
//	freopen("abc165_b.out", "w", stdout);

	cin >> need;
	while(yen < need) {
		yen = yen + yen / 100;
		tot++;
	}

	cout << tot << endl;

//	fclose(stdin);
//	fclose(stdout);
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=100001 ;
int main()
{
   fast ;
   ll n ;
   cin>>n ;
   ll sum =0;
   vector<ll>v(n) ;
   ll num=INT_MAX ;
   for(ll i=0;i<n;i++)
   {
       ll x ;
       cin>>x ;
       v[i]=x ;
       if(x%10!=0)
       {
           num=min(num,x) ;
       }
       sum+=x ;
   }
   if(num==INT_MAX)
    cout<<"0"<<endl ;
   else if(sum%10!=0)
    cout<<sum<<endl ;
   else
    cout<<(sum-num)<<endl ;


}


Measured memory_bytes: 256
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());

int n;

string s;

void rec(int v, int c) {
    if (v == n) {
        cout << s << endl;
        return ;
    }
    for (int i = 0; i <= c + 1; i++) {
        s[v] = char('a' + i);
        rec(v + 1, max(c, i));
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        s += ' ';
    }
    rec(0, -1);
	return 0;
}


Measured memory_bytes: 1536
(defun cb (accum cell)
    (let ((result (+ (car cell) (cadr cell))))
        (cond ((< result accum) result)
            (t accum))))

(defun solve (p q r)
    (let* ((lst `((,p ,q) (,q ,r) (,p ,r)))
              (result (reduce #'cb lst :initial-value 100000)))
        (print result)))

(solve (read) (read) (read))


Measured memory_bytes: 3432
#include<stdio.h>

int main(void){

    int a,b,t;
    scanf("%d%d%d",&a,&b,&t);
    int i=0;
    while(1){
        if(a*i>t){
            break;
        }
        i++;
    }

    printf("%d",(i-1)*b);

    return 0;
}

Measured memory_bytes: 128