akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;

#define A 3
#define AB 9

struct pazzle{
  int f[AB];
  int space;
  string path;

  bool operator < (const pazzle &p) const{
    for(int i=0;i<AB;i++){
      if(f[i]==p.f[i])continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(pazzle p){
  for(int i=0;i<AB;i++)
    if(p.f[i]!=(i+1))return false;
  return true;
}

string bfs(pazzle s){
  queue<pazzle> Q;
  map<pazzle,bool> V;
  pazzle u,v;
   s.path = "";
  Q.push(s);
  V[s]=true;

  while(!Q.empty()){
    u=Q.front();
    Q.pop();

    if(isTarget(u))return u.path;

    int sx = u.space/A;
    int sy = u.space%A;

    for(int r=0;r<4;r++){
      int tx = sx+dx[r];
      int ty = sy+dy[r];

      if(tx<0 || ty<0 || tx>=A || ty>=A)continue;

      v=u;
      swap(v.f[u.space],v.f[tx*A+ty]);
      v.space = tx*A+ty;
      if(!V[v]){
        V[v]=true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }
  return "unsolvable";
}

int main(){
  pazzle in;

  for(int i=0;i<AB;i++){
    cin >> in.f[i];
    if(in.f[i]==0){
      in.f[i]=AB;
      in.space =i;
    }
  }
 string ans = bfs(in);
 cout << ans.size() << endl;
 return 0;
}




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

using namespace std;

typedef long long ll;

int main() {
	#ifdef FUN
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#else
		#define endl "\n"
	#endif

	ll a, b; cin >> a >> b;

	if(a <= 0 && b >= 0) cout << "Zero"  << endl;
	else {
        ll diff = abs(a) - abs(b) + 1;
        if(a >= 0)  cout << "Positive" << endl;
        else {
            if(diff % 2 == 0) cout << "Positive" << endl;
            else cout << "Negative" << endl;
        }
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long P=1000000007;
long long dp[10009][105][2];
long long dig(int i,int r,int f,string &k,int d){
	if(i==k.size()){
		if(r%d==0)
			dp[i][r][f]=1;
		else
			dp[i][r][f]=0;
	}
	if(dp[i][r][f]==-1){
		long long sum=0;
		if(f==1){
			int j=0;
			for(j=0;j<(k[i]-'0');j++)
				sum=(sum+dig(i+1,(r-j+d)%d,0,k,d))%P;
			sum=(sum+dig(i+1,(r-j+d)%d,1,k,d))%P;
		}
		else{
			int j;
			for(j=0;j<10;j++)
				sum=(sum+dig(i+1,(r-j+d)%d,0,k,d))%P;
		}
		dp[i][r][f]=sum;
	}
	return dp[i][r][f];
}
int main(){
	string k;
	int d;
	cin >> k;
	cin >> d;
	memset(dp,-1,sizeof(long long)*10009*105*2);
	cout << (dig(0,0,1,k,d)-1+P)%P << endl;
}

Measured memory_bytes: 17664
n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif height[r[0]-1] == height[r[1]-1]:
        lower_list.append(r[0])
        lower_list.append(r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

Measured memory_bytes: 20108
#include<stdio.h>
int main(void){
    char a[51][51],b[51][51];
    int i,j,k,l,n,m,flag;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++) scanf("%s",a[i]);
    for(i=0;i<m;i++) scanf("%s",b[i]);
    for(i=0;i<n-m+1;i++){
        for(j=0;j<n-m+1;j++){
            flag=1;
            for(k=0;k<m;k++){
                for(l=0;l<m;l++){
                    if(a[i+k][j+l]!=b[k][l]) flag=0;
                }
            }
            if(flag==1){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n,a,b;

  scanf("%d%d%d",&n,&a,&b);

  if(a > b){
    printf("0\n");
    return 0;
  }

  if(n==1 && a != b){
    puts("0");
    return 0;
  }
  
  ll sum1 = (ll)a*(n-1) +b;
  ll sum2 = (ll)b*(n-1) +a;

  printf("%lld\n",sum2-sum1+1);
  
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC128
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

void solve(void){
  
  int R, D, X;
  
  cin >> R >> D >> X;
    
  REP2(i,1,11){
    X = R * X - D;
    cout << X << endl;
  }
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

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

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}




Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] {
			res = a[i]
		}
	}
	return res
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

const MaxUint = ^uint(0)
const MaxInt = int(MaxUint >> 1)

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	l := nextInt()
	ans := 0
	m := MaxInt
	d := 0

	for i := 0; i < n; i++ {
		ans += l + i
		if m != min(m, abs(l+i)) {
			m = min(m, abs(l+i))
			d = l + i
		}
	}
	ans -= d

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int nmx = 1e5+5;
vector<int> g[nmx];
int visited[nmx], dist[nmx], indegree[nmx];
void dfs(int i){
   // cout<<i<<" ";
    visited[i] = 1;
    for(auto a: g[i]){
        dist[a] = max(dist[a], dist[i]+1);
        indegree[a]--;
        if(!indegree[a]){
        dfs(a);
       }
    }

}
int main()
{
	fast;
	int n,m,a,b, ans=-1;
	cin>>n>>m;
	while(m--){
        cin>>a>>b;
        g[a].push_back(b);
        indegree[b]++;
	}
	for(int i =1; i<=n; i++){
        if(!visited[i] && !indegree[i]){
                indegree[i]--;
                dfs(i);
        }
	}
	for(int i=1; i<=n; i++)ans = max(ans, dist[i]);
	cout<<ans;
    return 0;
}

Measured memory_bytes: 9984
import java.util.*;
public class Main{
	static int max;
	static int Count;
	static int len;
	static String[] ans;
	static int n;
	
	public static void main(String[]agrs){
		Scanner sc = new Scanner(System.in);
		while(true) {
			max = -1;
			Count = -1;
			len = -1;
			ans = new String[100];
			n = sc.nextInt();
			String in = sc.next();
			if(n == 0 && in.equals("0")) break;
			dfs(in,0,1,new String[in.length()+1],0,0);
			
			if(max == -1) System.out.println("error");
			else if(Count >= 2) System.out.println("rejected");
			else {
				System.out.print(max);
				for(int i = 0; i < len; i++) {
					System.out.print(" " + ans[i]);
				}
				System.out.println();
			}
		}
	}
	
	public static void dfs(String a,int l, int r, String[] b,int sum,int count) {
		if(l == a.length()) {
			if(max < sum && sum <= n) {
				max = sum;
				ans = b;
				Count = 1;
				len = count;
			}
			else if(sum == max) {
				Count++;
			}
			return ;
		}
		if(r == a.length()+1) {
			return;
		}
		
		dfs(a,l,r+1,b,sum,count);
		
		String[] cp = Arrays.copyOf(b, b.length);
		cp[count] = a.substring(l, r);
		
		
		sum += Integer.parseInt(a.substring(l, r));
		
		dfs(a,r,r+1,cp,sum,count+1);
	}
}

Measured memory_bytes: 20476
#include <bits/stdc++.h>
using namespace std;
//Copyright (c) 2020 0214sh7
//https://github.com/0214sh7/library/
vector<long long> prime_factorization(long long N){
  vector<long long> R;
  if(N<2)return R;
  for(long long i=2;i*i<=N;i++){
    while(N%i==0){
      R.push_back(i);
      N/=i;
    }
  }
  if(N!=1){
    R.push_back(N);
  }
  return R;
}

int main(){

  long long A;
  cin >> A;
  if(A==1){
    cout << 0 << endl;
    return 0;
  }
  vector<long long> R;
  R = prime_factorization(A);
  sort(R.begin() , R.end());
  int X = R.size();
  int csr=0;
  int Total = 0;
  long long pr = R.at(0);
  while(csr!=X){
    int cnt = lower_bound(R.begin(), R.end(), pr+1) - R.begin() - csr;
    csr = lower_bound(R.begin(), R.end(), pr+1) - R.begin();
    if(csr!=X) pr = R.at(csr);

    //cout << cnt << endl;

    int j=1;
    while(j<=cnt){
      cnt -= j;
      j++;
    }

    Total += j-1;
  }

  cout << Total <<endl;

}

Measured memory_bytes: 3572
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            boolean state=true;
            Deque<Integer> stack = new ArrayDeque<>();
            String s = sc.nextLine();
            if(s.equals("."))break;
            for(int i=0;i<s.length();i++){
                switch(s.charAt(i)){
                    case '(':
                        stack.addFirst(1);
                        break;
                    case '[':
                        stack.addFirst(2);
                        break;
                    case ')':
                        if(stack.isEmpty()||stack.removeFirst()!=1)state=false;
                        break;
                    case ']':
                        if(stack.isEmpty()||stack.removeFirst()!=2)state=false;
                        break;
                }
            }
            if(state&&stack.isEmpty())System.out.println("yes");
            else System.out.println("no");
        }
    }
}


Measured memory_bytes: 51540
use std::io::{self, Read};

fn main() {
  let mut buf = String::new();
  io::stdin().read_to_string(&mut buf).unwrap();
  let tokens: Vec<&str> = buf.split_whitespace().collect();
  let k: i64 = tokens[0].parse().unwrap();
  let x: i64 = tokens[1].parse().unwrap();

  if 500*k >= x {
    println!("Yes");
  } else {
    println!("No");
  }
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef int64_t ll;
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; }



int main() {
	string N;
	cin >> N;
	
	bool ok = true;
	for (int i = 1; i < N.size(); i++)
	{
		if (N.at(i)!='9')
		{
			ok = false;
		}
	}

	if (ok)
	{
		cout << N.at(0) - '0' + 9 * N.size() - 9 << endl;
	}
	else {
		cout << N.at(0) - '1' + 9 * N.size() - 9 << endl;
	}
}

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

int main()
{
    int n, q, t, c, i, x;
    cin >> n;
    vector<int> vec[n];
    cin >> c;
    while (c--)
    {
        cin >> t >> q;
        if (t == 0)
        {
            cin >> x;
            vec[q].push_back(x);
        }
        if (t == 1)
        {
            for (i = 0; i < vec[q].size(); i++)
            {
                if (i)
                    cout << " ";
                cout << vec[q][i];
            }
            cout << endl;
        }
        if (t == 2)
        {
            vec[q].clear();
        }
    }
}


Measured memory_bytes: 5840
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ll a, b, m;
  cin >> a >> b >> m;
  ll min_a = INF, min_b = INF;
  ll arr_a[a], arr_b[b];
  fi(0,a){
    cin >> arr_a[i];
    chmin(min_a, arr_a[i]);
  }
  fi(0,b){
    cin >> arr_b[i];
    chmin(min_b, arr_b[i]);
  }
  ans = min_a + min_b;
  ll x,y,c,q;
  fi(0,m){
    cin>>x>>y>>c;
    q=arr_a[x-1]+arr_b[y-1]-c;
    chmin(ans,q);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var inputArray1 = int.Parse(Console.ReadLine());
            var inputArray2 = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var inputArray3 = int.Parse(Console.ReadLine());

            var counterArray = new long[100001];

            for (var i = 0; i < inputArray2.Length; i++)
            {
                counterArray[inputArray2[i]]++;
            }
            var result = inputArray2.Sum();

            for (int i = 0; i < inputArray3; i++)
            {
                var inputArray4 = Console.ReadLine().Split().Select(long.Parse).ToArray();
                result += (inputArray4[1] - inputArray4[0]) * counterArray[inputArray4[0]];
                counterArray[inputArray4[1]] += counterArray[inputArray4[0]];
                counterArray[inputArray4[0]] = 0;
                Console.WriteLine(result);
            }

            Console.Out.Flush();
        }
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for(auto& i: A) cin >> i;

  auto ok = [&](auto x) {
    long long k = 0;
    for(auto& a: A) k += (a-1)/x;
    return k <= K;
  };

  int l=0, h=1e9;
  while(1 < h-l) {
    auto m = (l + h) / 2;
    if(ok(m)) h = m;
    else      l = m;
  }
  cout << h << endl;
}


Measured memory_bytes: 4048
//2020.1.23
//s1270188 xxxmk2
//alds1_11c

#include<stdio.h>
#define N 100

//global
int data[N+1][N], num, vi[N+1];

//prototype
void bfs(int);
void visit(int,int);

int main(){
  int i, j, a, b;

  //input
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++) scanf("%d",&data[a][j]);
    data[a][j]=0;
  }

  //bfs
  bfs(1);
  
  return 0;
}

void bfs(int x){
  int i;

  //reset
  for(i=1;i<=num;i++)  vi[i]=-1;

  visit(x,0);
  
  for(i=1;i<=num;i++) printf("%d %d\n",i,vi[i]);
}

void visit(int x,int t){
  int i;
  
  if(vi[x]==-1 || vi[x]>t) vi[x]=t;
  else return;
  for(i=0;data[x][i]!=0;i++) visit(data[x][i],t+1);
}






Measured memory_bytes: 2052
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int L,R,d,ans=0;cin>>L>>R>>d;
	for(int i=L;i<=R;i++){
		if(i%d==0){ans++;}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define pb push_back
map<ll,ll>mp;

    ll t,s,i,e,o=0,n,ans;
int main(){
    fast;
    cin>>n;
    ll b[n+5],a[n+5];
    for(i=1;i<n;i++){
        cin>>b[i];
    }
    a[1]=b[1];
    a[2]=b[1];
    for(i=2;i<n;i++){
        if(b[i]>=a[i])a[i+1]=b[i];
        else{
            a[i]=a[i+1]=b[i];
        }
    }
    for(i=1;i<=n;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
  char S[20];
  char V[20];
  scanf("%s", &S);
  scanf("%s", &V);
  
  V[strlen(S)] = '\0';
  if(strcmp(S, V) == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N, A, B, C;
ll X[3], s[100001], t[100001];

signed main(){
    cin >> N >> A >> B >> C;
    string str;
    string ABC = "ABC";
    X[0] = A; X[1] = B; X[2] = C;
    ll a, b, c;
    REP(i, N){
        cin >> str;
        s[i] = str[0] - 'A', t[i] = str[1] - 'A';
    }
    vector<int> v;
    REP(i, N){
        if(X[s[i]] == 0 && X[t[i]] == 0){
            PRINT("No");
            return 0;
        }else if(X[3 - s[i] - t[i]] == 0 && X[s[i]] == 1 && X[t[i]] == 1){
            if(i < N - 1 && (s[i] == s[i + 1] || s[i] == t[i + 1])){
                X[s[i]]++; X[t[i]]--;
                v.push_back(s[i]);
            }else if(i < N - 1 && (t[i] == s[i + 1] || t[i] == t[i + 1])){
                X[s[i]]--; X[t[i]]++;
                v.push_back(t[i]);
            }else{
                X[s[i]]--; X[t[i]]++;
                v.push_back(t[i]);
            }
        }else{
            if(X[s[i]] < X[t[i]]){
                X[s[i]]++; X[t[i]]--; v.push_back(s[i]);
            }else{
                X[s[i]]--; X[t[i]]++; v.push_back(t[i]);
            }
        }
        // cerr << X[0] << " " << X[1] << " " << X[2] << endl;
    }
    PRINT("Yes");
    for(int i : v) PRINT(ABC[i]);
    return 0;
}

Measured memory_bytes: 5432
#pragma GCC omptimize("unroll-loops")
#pragma optimize("SEX_ON_THE_BEACH")
#pragma GCC optimize("no-stack-protector")
#pragma comment(linker, "/STACK:1000000000")
#include<bits/stdc++.h>

using namespace std;

//#define need_tree

#ifdef need_tree
    #include<ext/pb_ds/assoc_container.hpp>
    using namespace __gnu_pbds;
    template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#endif // need_tree

using ll = long long int;
using ull = unsigned long long int;
using dd = long double;
using ldd = long double;
using si = short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

ll get_seed(string s)
{
    ll ans = 0;
    for (int i = 0; i < s.size(); ++i)
        ans += s[i];
    return ans;
}

int popcount(int x)
{
    return __builtin_popcount(x);
}

ll popcountll(ll x)
{
    return __builtin_popcount(x);
}

#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second

// debug defines
#ifdef HOME
    int jjj;
    #define PO cout << "Pomelo" << endl;
    #define OL cout << "Oliva" << endl;
    #define debug(x) cout << #x << " " << x << endl;
    #define debug_p(x) cout << #x << " " << x.ff << " " << x.ss << endl;
    #define debug_v(x) cout << #x << " "; for (auto iii : x) cout << iii << " "; cout << endl;
    #define debug_vp(x) cout << #x << " "; for (auto ii : x) cout << '[' << ii.ff << " " << ii.ss << ']'; cout << endl;
    #define wait() cin >> jjj;
#else
    #define PO 0;
    #define OL 0;
    #define debug(x) 0;
    #define debug_p(x) 0;
    #define debug_vp(x) 0;
    #define debug_v(x) 0;
    #define debug_vp(x) 0;
    #define wait() 0;
#endif // HOME
// end of debug definess

bool check(string& s, int cnt)
{

}

void solve(int ii)
{
    string s;
    cin >> s;
    if (s.size() == 1)
    {
        cout<< 1;
        return;
    }
    vector<pair<int, int>> dp(s.size());
    dp[0].ff = 1;
    dp[1].ss = 1;
    dp[1].ff = (s[0] == s[1] ? 0 : 2);
    for (int i = 2; i < s.size(); ++i)
    {
        dp[i].ff = dp[i - 1].ss + 1;
        if (s[i] != s[i - 1])
            dp[i].ff = max(dp[i].ff, dp[i - 1].ff + 1);
        dp[i].ss = dp[i - 2].ff + 1;
        string t = " " + s[i - 1] + s[i];
        string tt = " " + (i > 2 ? s[i - 3] + s[i - 2] : s[i - 2]);
        if (t != tt)
            dp[i].ss = max(dp[i].ss, dp[i - 2].ss + 1);
    }
    cout << max(dp.back().ff, dp.back().ss);
    return;
    int l = 1, r = s.size() + 1;
    while (r - l > 1)
    {
        int m = (r + l) >> 1;
        if (check(s, m))
            l = m;
        else
            r = m;
    }
    cout << l;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int t;
    t = 1;
    //cin >> t;
    for (int i = 0; i < t; ++i)
        solve(i);

    return 0;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    int N, M; cin >> N >> M;
    vector<int> H(N); for (auto& h : H) cin >> h;
    vector<vector<int>> G(N+1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;

    for (int v = 1; v <= N; v++) {
        bool good = true;
        for (int u : G[v]) {
            if (H[u-1] >= H[v-1]) {
                good = false;
                break;
            }
        }
        if (good) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 8800
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, x, S;
  cin >> N >> K;
  for( int i=0; i<N; i++){
    cin >> x;
    if(x < K-x) {
      S += x*2;
    }
    else{
      S += (K-x)*2;
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

struct Node {
    int id;
    int left;
    int right;

    int parent = -1;
    int depth = 0;
    int height = 0;

    Node() : id(-1), left(-1), right(-1) {}
    Node(int id, int left, int right) : id(id), left(left), right(right) {}
    string getType() {
        if (parent == -1) return "root";
        if (left == -1 && right == -1) return "leaf";
        return "internal node";
    }
    int getSible(vector<Node> nodes) {
        if (parent == -1) return -1;
        if (nodes[parent].left == id) return nodes[parent].right;
        return nodes[parent].left;
    }
    int getDegree() {
        if (left != -1 && right != -1) return 2;
        if (left == -1 && right == -1) return 0;
        return 1;
    }
};

Node constructTree(int n, vector<Node>& nodes) {
    int root;
    queue<Node> q;
    rep(i, n) {
        if (nodes[i].getType() == "root") {
            root = i;
            q.push(nodes[i]);
            break;
        }
    }
    while (!q.empty()) {
        Node v = q.front(); q.pop();
        if (v.left != -1) {
            nodes[v.left].depth = v.depth + 1;
            q.push(nodes[v.left]);
        }
        if (v.right != -1) {
            nodes[v.right].depth = v.depth + 1;
            q.push(nodes[v.right]);
        }
    }

    rep(i, n) {
        if (nodes[i].getType() == "leaf") {
            q.push(nodes[i]);
        }
    }
    while (!q.empty()) {
        Node v = q.front(); q.pop();
        if (v.parent == -1) continue;
        nodes[v.parent].height = max(nodes[v.parent].height, v.height + 1);
        q.push(nodes[v.parent]);
    }
    return nodes[root];
}

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

    int n;
    cin>>n;
    vector<Node> nodes(n);
    rep(i, n) {
        int id, left, right;
        cin>>id>>left>>right;
        nodes[id].id = id;
        nodes[id].left = left;
        nodes[id].right = right;
        nodes[left].parent = id;
        nodes[right].parent = id;
    }
    constructTree(n, nodes);
    
    rep(i, n) {
        Node v = nodes[i];
        cout<<"node "<<v.id<<": parent = "<<v.parent<<", sibling = "<<v.getSible(nodes);
        cout<<", degree = "<<v.getDegree()<<", depth = "<<v.depth<<", height = "<<v.height<<", "<<v.getType()<<endl;;
    }
}


Measured memory_bytes: 3192
N = gets.to_i
march = [0] * 5
head = 'MARCH'
N.times do
  name = gets.chomp
  5.times do |i|
    if name[0] == head[i]
      march[i] += 1
      break
    end
  end
end

puts march.combination(3).collect{|c| c.inject(:*)}.inject(:+)

Measured memory_bytes: 1788
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()
#define int long long
typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

const int mod  =1e9 + 7;

main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector <int> v[n], t(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i];
        v[t[i]].pb(i);
    }
    int cs = 1;
    for (int i = 3; i > 3 - len(v[0]); i--)
        cs *= i;
    for (int i = 0; i < n; i++) {
        if (t[i] != 0) {
            int cnt = upper_bound(all(v[t[i] - 1]), i) - v[t[i] - 1].begin();
            int flexcnt = upper_bound(all(v[t[i]]), i) - v[t[i]].begin() - 1;
            cnt -= flexcnt;
            cs *= cnt;
            cs %= mod;
        }
    }
    cout << cs;


    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
using namespace std;

int main() {
	long numA, numB, timesK;
	cin >> numA >> numB >> timesK;

	if( numA == 0 && numB == 0 ) {
		cout << numA << " " << numB << endl;
		return 0;
	}

	if ( numA - timesK >= 0 ) {
		numA -= timesK;
		cout << numA << " " << numB << endl;
		return 0;
	}

	timesK -= numA;
	numA = 0;
	if( numB - timesK >= 0 ) {
		numB -= timesK;
		cout << numA << " " << numB << endl;
		return 0;
	} else {
		numB = 0;
		cout << numA << " " << numB << endl;
	}
	
	return 0;
}

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

using namespace std;
int main(){
    int d;
    cin >> d;
    if(d==22) cout << "Christmas Eve Eve Eve" << endl;
    else if(d==23) cout << "Christmas Eve Eve"  << endl;
    else if(d==24) cout << "Christmas Eve" << endl;
    else if(d==25) cout << "Christmas" << endl;
    return 0;
}

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

#define N 100000
#define INF 1000000

typedef struct{
  int go;
  int back;
  int cost;
}Date;

int n ,d[N];
Date a[500000];

void root(int);

int main(void){
  int i;
  int j;
  int k;
  int l;
  int count = 0;

  scanf("%d", &n);

  for(i=0 ; i<n ; i++){
    scanf("%d%d", &k, &l);

    for(j=0 ; j<l ; j++){
      a[count].back = k;
      scanf("%d%d", &a[count].go, &a[count].cost);
      count++;
    }
  }

  root(count);

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

void root(int x){
  int i;
  int judge = 1;

  for(i=0 ; i<n ; i++){
    d[i] = INF;
  }
  d[0] = 0;

  while(judge != 0){
    judge = 0;
    for(i=0 ; i<x ; i++){
      if(a[i].cost + d[a[i].back] < d[a[i].go]){
        d[a[i].go] = a[i].cost + d[a[i].back];
        judge = 1;
      }
    }
  }

}



Measured memory_bytes: 7552
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    set<char> str;

    rep(i, s.length()) { str.insert(s[i]); }

    if(str.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int tuukasya = 0;
	int kaigai = 0;
	rep(i, N) {
		if (S[i] == 'a') {
			if (tuukasya < A + B) {
				cout << "Yes" << endl;
				tuukasya++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (S[i] == 'b') {
			if (tuukasya < A + B && kaigai < B) {
				cout << "Yes" << endl;
				tuukasya++;
				kaigai++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>

int main(){
    int X;
    int i, j, k;
    int ans=0, tmp;

    scanf("%d", &X);
    for(i=2; i<=100; i++){
        tmp = i*i;
        while(tmp<=X){
            if(ans < tmp){
                ans = tmp;
            }
            tmp = tmp *i;
        }
    }
    if(ans == 0){
        printf("1");
    }else{
        printf("%d", ans);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl



int main()
{
	FIN;
	
	int n;
	cin >> n;
	vector <ll> v(n);
	forn(i,n) cin >> v[i];
	sort(all(v));
	reverse(all(v));
	int cont = 0;
	ll ans = 0;
	ans += v[0]; cont=2;
	forr(i,2,n)
	{
		ans += v[(cont)/2];
		cont++;
	}
	
	cout << ans << "\n";
	
    return 0;
}


Measured memory_bytes: 4780
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      int N=int.Parse(Console.ReadLine());
      string S=Console.ReadLine();
      char[] Schar=S.ToCharArray();
     
    for(int i=0;i<Schar.Length;i++)
    {
      int Sint=(int)Schar[i];
      Sint+=N;
      if(Sint>90){
      Sint-=26; 
      }
      Console.Write((char)Sint);
    }
      Console.Write("\n");
    }
    
  }

}


Measured memory_bytes: 27580
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now()

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(d); readll(t_); readll(s);
        cout << (d<=t_*s ? "Yes" : "No") << endl;        
    }

//    auto end = chrono::steady_clock::now();
//    cerr << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int A[1000000], n;

int main() {
  cin >> n;
  for ( int i = 0; i < n; i++ )
    scanf("%d", &A[i]);

  int q, k, sum = 0;
  cin >> q;
  for ( int i = 0; i < q; i++ ) {
    scanf("%d", &k);
    // 標準ライブラリの lower_bound を使用
    if ( *lower_bound(A, A + n, k) == k ) sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3528
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
typedef long long ll;
const int MAXN = 500510;
const int MAX = 1e7 + 1 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
ll mod = 500500507;
ll powr(ll a , ll b){ if(b==0) return 1LL ; ll x = powr(a,b/2) ; x = (x*x)%mod ; if(b%2) return ((a%mod)*x)%mod ; return x ;}
ll gcd(ll a , ll b){if(a==0) return b ; return gcd(b%a,a);}


int main () {
    
    ll N , H, W ;
    cin>>N>>H>>W ;
    pair<ll,ll> a[N] ;
    int cnt= 0;
    for(int i = 0;i < N;i++){
        ll l,b ;
        cin >> l >> b ;
        if(l >=H && b >=W) cnt++ ;
    }
    cout<<cnt<<endl;
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>

#define ll long long

using namespace std;

const int NMAX = 1e5+5;

char s[NMAX];
int v[NMAX];


int main()
{
    int N,i,j;

    cin>>(s+1);
    N = strlen(s+1);

    for(i = 2 ; i <= N ; ++i)
    {
        if(s[i-1] == 'R' && s[i] == 'L')
        {
            int cntl = 0 , cntr = 0,centre = i;
            j = i-1;
            while(j > 0 && s[j] == 'R')
                j--,cntl++;;
            j++;

            while(i <= N && s[i] == 'L')
                i++,cntr++;
            i--;
            int sum = cntl + cntr;

            if((cntl&1) && !(cntr&1))
            {
                v[centre-1] = sum/2 + 1;
                v[centre] = sum/2;
            }
            else if(!(cntl&1) && (cntr&1))
            {
                v[centre] = sum/2 + 1;
                v[centre-1] = sum/2;
            }
            else
            {
                v[centre] = v[centre-1] = sum/2;
            }
        }
    }
    for(i = 1 ; i <= N ; ++i)
        cout<<v[i]<<" ";
}


Measured memory_bytes: 896
import java.util.*;
class Main
{
	public static void main(String[] args) 	
	{
		Scanner scan=new Scanner(System.in) ;
		int N=scan.nextInt();
		float prob, odd;
		
		if(N>=1 && N<=100)
		{
			if(N%2==0)
				prob=0.5f;
			else
			{
				odd=(N/2)+1;
				prob=odd/N;
			}
			System.out.println(prob);
		}
	}
}


Measured memory_bytes: 22996
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

bh = 10**12
bl = 0
m = 10**6
while True:
    t = K
    for i in range(len(A)):
        if A[i]*F[i] > m:
            t -= A[i] - int(m / F[i])
            if t < 0:
                break
    if t >= 0:
        bh = m
        m = (bh + bl) // 2
    else:
        bl = m + 1
        m = (bh + bl) // 2
    if bh == bl:
        print(bh)
        exit(0)


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;
const int mod = 1e9+7;
ll powmod(ll a, ll p){
  ll ans = 1;
  ll mul = a;
  for(; p > 0; p >>= 1, mul = (mul*mul) % mod){ //初期条件なし、pを2で割り続け、mulの値を更新
    if((p & 1) == 1) ans = ( ans * mul) % mod;//pが1なら ansの値を更新
  }
  return ans;
}

const int MAX_N = 2000001;

ll fact[MAX_N];
ll revfact[MAX_N];

void setFact(int N){
  fact[0] = 1;
  for(int i = 1; i < N; ++i){
    fact[i] = (fact[i-1]*i) % mod;
  }
  revfact[N-1] = powmod(fact[N-1],mod-2);//逆元を求める
  for(int i = N-2;i >= 0;--i){
    revfact[i] = (revfact[i+1] * (i+1)) % mod;
  }
}

ll getP(int a,int b){
  return (fact[a] * revfact[b]) % mod;
}

ll getC(int a, int b){
  return (fact[a] * revfact[b] % mod) * revfact[a-b] % mod;
}

ll mod_add(ll a, ll b) {
	return (a + b) % mod;
}
 
ll mod_sub(ll a, ll b) {
	return (a - b + mod) % mod;
}
 
ll mod_mul(ll a, ll b) {
	return a*b % mod;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,l = 0,r = 0;
  cin >> n;
  vector<ll> v(n+1);
  map<ll,ll> m;
  rep(i,n+1){
    cin >> v[i];
    m[v[i]]++;
    if(m[v[i]] == 2){
      a = v[i];
      r = i;
    }
  }
  rep(i,n+1){
    if(v[i] == a){
      l = i;
      break;
    }
  }
  setFact(MAX_N-1);
  ll N = n+1;
  REP(i,1,N+1){
    ll ans = getC(N,i);
    if(l + n - r  >= i-1){
      ans = mod_sub(ans,getC(l+n-r,i-1));
    }
    std::cout << ans << std::endl;
  }
  return 0;
}


Measured memory_bytes: 39552
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if((x-r)<0){
        cout<<"No"<<endl;
    }
    else if((y-r)<0){
        cout<<"No"<<endl;
    }
    else if((x+r)>W){
        cout<<"No"<<endl;
    }
    else if((y+r)>H){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}


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

int main(void){
    int i,j,k,v,N;
    int A[100];
    scanf("%d",&N);
	if(1>N && N>100){
		exit(0);
	}
    for(i=0; i < N; i++){
        scanf("%d",&A[i]);
    	if(0>A[i] && A[i]>1000){
    		exit(0);
    	}
    }
    for(i=0;i<N;i++){
        v = A[i];
        j = i - 1;
        while(j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(k=0; k<N; k++){
        	if( k == N-1){
        		printf("%d",A[k]);
        	}else{
            	printf("%d ",A[k]);
        	}
        }
    	printf("\n");

    }
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+18;

struct Edge {
    ll u, v, c;
    Edge(ll u, ll v, ll c): u(u), v(v), c(c) {}
};

vector<ll> to[1005];
vector<ll> rto[1005];

bool reachable1[1005];
bool reachable2[1005];
bool ok[1005];
void dfs(ll v, ll p=-1) {
    reachable1[v] = true;
    for (ll e: to[v]) {
        if (e==p) continue;
        if (!reachable1[e]) dfs(e, v);
    }
}
void dfs2(ll v, ll p=-1) {
    reachable2[v] = true;
    for (ll e: rto[v]) {
        if (e==p) continue;
        if (!reachable2[e]) dfs2(e, v);
    }
}


int main(){
    ll n, m;
    cin >> n >> m;
    vector<Edge> edge;
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        c *= -1;
        edge.emplace_back(a, b, c);
        to[a].push_back(b);
        rto[b].push_back(a);
    }
    dfs(0);
    dfs2(n-1);
    rep(i, n) {
        ok[i] = reachable1[i] && reachable2[i];
    }
    vector<ll> dist(n);
    rep(i, n) dist[i] = INF;
    dist[0] = 0;
    bool update = false;
    rep(i, n) {
        update = false;
        for (auto e: edge) {
            ll u = e.u;
            ll v = e.v;
            ll c = e.c;
            if (!ok[u]) continue;
            if (!ok[v]) continue;
            if (dist[v]>dist[u]+c) {
                update = true;
                dist[v] = dist[u] + c;
            }
        }
        if (!update) break;
    }
    if (update) {
        cout << "inf" << endl;
        return 0;
    }

    ll ans = -dist[n-1];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3832
#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 reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> s(n + 2);
    rep(i, n) cin >> s[i];
    s[n] = LONG_LONG_MIN;
    s[n + 1] = LONG_LONG_MAX;
    sort(all(s));
    ll q;
    cin >> q;
    ll ans = 0;
    rep(i, q) {
        ll t;
        cin >> t;
        ll l = 0, h = n + 1;
        while((l + 1) < h) {
           ll m = (l + h) / 2;
           if (s[m] <= t) l = m;
           else h = m;
        }
        if (s[l] == t) ans++;
    }
    cout << ans << endl;
    return 0;
}



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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int i,n;
    sf(n);
    int cnt=0;
    for(i=1;i<=n;i++)
    {
        if(int(log10(i)+1)&1)
            cnt++;
    }
    pf("%d",cnt);
}


Measured memory_bytes: 256
from math import sqrt
N, M = map(int, input().split())

cand = []

for i in range(1, int(sqrt(M))+1):
    if M % i == 0:
        cand.append(i)
        u = M // i
        if u != i:
            cand.append(u)

cand.sort()

ans = 1
for j in cand:
    if N * j <= M:
        ans = max(ans, j)

print(ans)

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

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

    vector<int>P;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin>>p;
        P.push_back(p);
    }
    
    int ans=0;
    for (int i = 1; i < n-1; i++)
    {
        auto p=minmax({P[i-1],P[i],P[i+1]});
        if(p.first!=P[i]&&p.second!=P[i])
        {
            ++ans;
        }
    }
    

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3640