akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
string s;
char a[100005];
int k;
int main()
{
 //freopen(".in","r",stdin);
 //freopen(".out","w",stdout);
 cin>>s;
 for(int i=0;i<s.size();i++)
 {
 	if(s[i]!='B') a[++k]=s[i];
 	else 
	 {
	 	k--;
	 	if(k<0) k=0;
	 }
 }
 for(int i=1;i<=k;i++)
 	cout<<a[i];
 cout<<endl;
 
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma warning( disable : 4996 )
#define ll long long
#define pb push_back
#define endl '\n'
#define fastIO cin.tie( 0 );ios_base::sync_with_stdio( false )
#define pii pair<int, int>
#define eps 1e-13
#define M 2000
#define N 1005

using namespace std;

int n, m;
int ans[N][N];


struct item {
  int dis, x, y;
  bool operator<( const item& a ) const
  {
      return dis > a.dis;
  }
};
priority_queue<item> q;
inline void bfs()
{
    item tmp, temp;
    while ( !q.empty() ) {
        tmp = q.top();
        temp = tmp;
        ++temp.dis;
        q.pop();
        if ( tmp.x != n - 1 && ans[tmp.x + 1][tmp.y] > tmp.dis + 1 ) {
            temp.x = tmp.x + 1;
            q.push( temp );
            ans[tmp.x + 1][tmp.y] = tmp.dis + 1;
        }
        if ( tmp.x != 0 && ans[tmp.x - 1][tmp.y] > tmp.dis + 1 ) {
            temp.x = tmp.x - 1;
            q.push( temp );
            ans[tmp.x - 1][tmp.y] = tmp.dis + 1;
        }
        temp.x = tmp.x;
        if ( tmp.y != m - 1 && ans[tmp.x][tmp.y + 1] > tmp.dis + 1 ) {
            temp.y = tmp.y + 1;
            q.push( temp );
            ans[tmp.x][tmp.y + 1] = tmp.dis + 1;
        }
        if ( tmp.y != 0 && ans[tmp.x][tmp.y - 1] > tmp.dis + 1 ) {
            temp.y = tmp.y - 1;
            q.push( temp );
            ans[tmp.x][tmp.y - 1] = tmp.dis + 1;
        }
    }
}


inline void init()
{
    char type;
    item tmp;
    cin >> n >> m;
    memset( ans, 0x7f, sizeof( ans ) );
    for ( int i = 0; i < n; ++i ) {
        for ( int j = 0; j < m; ++j ) {
            cin >> type;
            switch ( type ) {
                case '#':tmp.x = i, tmp.y = j, tmp.dis = 0;
                    ans[i][j] = 0;
                    q.emplace( tmp );
                    break;
            }
        }
    }
}

inline void solve()
{
    bfs();
    int max0 = 0;
    for ( int i = 0; i < n; ++i ) {
        for ( int j = 0; j < m; ++j )
            max0 = max( max0, ans[i][j] );
    }
    cout << max0 << endl;
}

int main()
{
    fastIO;
    init();
    solve();

    return 0;
}


Measured memory_bytes: 18668
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin(), x.end()
typedef long long int unsigned lliu;
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

int main(){
	fastIO
	int n, m;
	cin>>n>>m;
	vi alturas(n+1);
	forn(i, n)
		cin>>alturas[i+1];
	vvi v(n+1);
	int a, b;
	forn(i, m){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int contador=0;
	bool paso;
	forna(i,1, n+1){
		paso = true;
		forn(j, v[i].size()){
			if(alturas[i]<=alturas[v[i][j]]){
				paso = false;
				break;
			}
		}
		if(paso)
			contador++;
	}

	cout<<contador<<endl;

	return 0;
}

Measured memory_bytes: 8676
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

  int x, y, z;
  x = y = z = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] <= a)
      x++;
    else if (p[i] <= b)
      y++;
    else
      z++;
  }
  cout << min({x, y, z}) << endl;
  return 0;
}

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

int main()
{
  int a,b;
  int ans=0;
  int sum=1;
  cin>>a>>b;
  while(sum<b)
  {
    sum = sum+a-1;
    ans++;
  }
  
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=0;
    ll cc=max(c,d),dd=min(c,d),r=cc%dd;
    while(r>0){
        cc=dd;
        dd=r;
        r=cc%dd;
    }
    ans+=b/c+b/d-b/(c*d/dd);
    ans-=(a-1)/c+(a-1)/d-(a-1)/(c*d/dd);
    cout<<b-a+1-ans;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cost[] = new int[3];
		for(int i = 0; i < 3; i ++) {
			cost[i] = sc.nextInt();
		}
		Arrays.sort(cost);
		System.out.println(Math.abs(cost[0] - cost[2]));
	}
}

Measured memory_bytes: 22996
#include <stdio.h>
int main(void){
    int a,b,c,ans=0;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=0;i<b;i++){
        if(a*i%b==c){ans++;break;}
    }
    if(ans==0)printf("NO\n");
    else printf("YES\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({10 * a + b + c, a + 10 * b + c, a + b + 10 * c}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long 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 n,m;
vector<int>a;
vector<int>b;
vector<vector<bool>>g;
vector<bool>visited;

void dfs(int v) {
    if(visited[v]) return;
    visited[v] = true;
    rep(nv,n) {
        if(g[v][nv]) {
            dfs(nv);
        }
    }
}
int main() {
    cin >> n >> m;
    a.resize(m);
    b.resize(m);
    g.assign(n,vector<bool>(n,false));
    visited.resize(n);
    int ans = 0;
    rep(i,m) {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
    }
    rep(i,m) {
        rep(j,n) visited[j] = false;
        g[a[i]][b[i]] = false;
        g[b[i]][a[i]] = false;
        dfs(0);
        bool connected = true;
        rep(j,n) if(!(visited[j])) connected = false;
        if(!connected) ans++;
        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
    }
    cout << ans << endl;
}






Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define mat(name,fnum,snum,init); vector<vector<ll>> name((fnum),vector<ll>((snum),(init)));
#define debugP int debug_point; cin>>debug_point;
#define Pow(a,b) rep(i,b)a*=b;

int main(){
    ll n;
    cin>>n;
    vec(a,4,0);
    rep(i,4){
        a[3-i]=n%10;
        n/=10;
    }
    int b=0;
    int tmp=0;
    for(;(b>>3)==0;b++){
        tmp=a[0];
        repf(i,0,3){
            if(b>>i&1){
               tmp+=a[i+1];
            }else {
                tmp-=a[i+1];
            }
            //op((b>>i&1));
        }
        //cout<<endl;
        if(tmp==7){
            cout<<a[0]<<((b>>0&1)?"+" : "-")<<a[1]<<((b>>1&1)?"+" :"-")<<a[2]<<((b>>2&1)?"+" :"-")<<a[3]<<"=7"<<endl;
            return 0;
        }tmp=0;
    }
    opN;
    return 0;
}

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

class UnionFind {
private:
	vector<int> data;
	int root(int a) {
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}
public:

	UnionFind(int n) : data(n, -1) {}
	bool Find(int a, int b) {
		return root(a) == root(b);
	}
	void Union(int a, int b) {
		int ra = root(a), rb = root(b);
		if (ra == rb)
			return;
		if (data[ra] < data[rb]) {
			data[ra] += data[rb];
			data[rb] = a;
		}
		else {
			data[rb] += data[ra];
			data[ra] = b;
		}
	}
	int size(int a) {
		return -data[root(a)];
	}
};

int main()
{
	int n, q;
	cin >> n >> q;
	UnionFind uf(n);
	for (int i = 0, com, x, y;i < q;i++) {
		cin >> com >> x >> y;
		if (com)
			cout << uf.Find(x,y) << endl;
		else
			uf.Union(x,y);
	}
	return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    int sum = 0;

    for(int i = 0; i < N; i++){
        int h;
        cin >> h;

        if(h >= K){
            sum++;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int total=0;
	int t=0;
	int i=0;
	int N=0;
	int V[50];
	int C[50];
	
	for(i=0;i<50;i++)
	{
		V[i]=0;
		C[i]=0;
	}
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++)
	{
		scanf("%d",&V[i]);
	}
	
	for(i=0;i<N;i++)
	{
		scanf("%d",&C[i]);
	}
	
	for(i=0;i<N;i++)
	{
		t=V[i]-C[i];
		if(t>0)
		{
			total+=t;
		}
	}
	printf("%d\n",total);
	return 0;
}

Measured memory_bytes: 128
#pragma gcc optimize (o3)
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define ll long long
#define ld long double
#define U unsigned
#define pi acos(-1)

using namespace std;

const ll N = 2e5+5;

ll dp, arr[N], n, c;
set <pair<ll, ll> > s;

ll solveI()
{
    s.insert({arr[n], arr[n]*arr[n]});
    for(int i = n-1 ; i > 0 ; i--)
    {
        auto ff = s.end();
        ff--;
        while(s.size()>1)
        {
            auto ss = ff--;
            if(-2*ff->F*arr[i] + ff->S  <= -2*ss->F*arr[i] + ss->S) s.erase(ss);
            else break;
        }
        ff = s.end();
        ff--;
        dp = arr[i]*arr[i] - 2*ff->F*arr[i] + ff->S + c;
        while(s.size()>1)
        {
            auto ss = s.begin();
            ff = ss++;
            if((ff->S-ss->S)/(ss->F-ff->F)>=((dp + arr[i]*arr[i])-ff->S)/(ff->F-arr[i])) s.erase(ff);
            else break;
        }
        s.insert({arr[i], arr[i]*arr[i] + dp});
    }
    return dp;
}

int main()
{
    scanf("%lld%lld", &n, &c);
    for(int i = 1 ; i <= n ; i++) scanf("%lld", arr+i);
    printf("%lld\n", solveI());
    return 0;
}


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

typedef long long ll;
typedef pair<int,ll> P;
typedef pair<P,P> P2;
const ll INF=100000000000000001;
int main() {
	int n;
	cin>>n;

	bitset<4000001> bs1(0);
	int t=0;
	int a1;
	for(int i=0;i<n;++i){
		cin>>a1;
		t+=a1;
		bitset<4000001> bs2(1);
		bs1=bs1|(bs1<<a1);
		bs2=bs2<<a1;
		bs1=bs1|bs2;
	}
	int k=t/2+t%2;
	for(;k<=t&&(!bs1[k]);++k);
	cout<<k<<endl;
	return 0;
}


Measured memory_bytes: 3712
k, n = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
z = []
sum = 0
max = 0
maxInde = 0
(n - 1).times do |i|
  sum += a[i+1] - a[i]
end
(n-1).times do |i|
  tem = a[i+1] - a[i]
  if (max < tem)
    max = tem
    maxInde = i
  end
end
e = a[maxInde] + (k- a[maxInde+1])
if e > sum
  puts "#{sum}"
else
  puts "#{e}"
end


Measured memory_bytes: 18700
n=int(input())
s=[]
for i in range(n):
    s.append(int(input()))
s=sorted(s)
if sum(s)%10!=0:
    print(sum(s))
else:
    for i in range(n):
        if s[i]%10!=0:
            print(sum(s)-s[i])
            exit()
    print(0)


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
	int d;
	scanf("%d", &d);
	int c[30];
	int i;
	for (i = 0; i < 26; i++)
		scanf("%d", &c[i]);
	int j;
	int s[400][30];
	for (i = 0; i < d; i++)
		for (j = 0; j < 26; j++)
			scanf("%d", &s[i][j]);
	int ans;
	for (i = 0; i < d; i++)
	{
      printf("%d\n",(26*400-i)%26+1);
	}
	return 0;
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int n,m,k;
	cin>>n>>m>>k;
	int cn=0;
	int cnt=0;
	for(int i=2;i<=n;i++)cnt+=i-1;
	cn+=cnt;
	for(int i=2;i<=n;i++){
		cnt-=n-i+1;
		cnt+=i-1;
		cn+=cnt;
	}
	cn/=2;
	int ans=0;
	ans+=(((m*m)%MOD*cn)%MOD*COM(n*m-2,k-2))%MOD;
	int cm=0;
	cnt=0;
	for(int i=2;i<=m;i++)cnt+=i-1;
	cm+=cnt;
	for(int i=2;i<=m;i++){
		cnt-=m-i+1;
		cnt+=i-1;
		cm+=cnt;
	}
	cm/=2;
	ans+=(((n*n)%MOD*cm)%MOD*COM(n*m-2,k-2))%MOD;
	cout<<ans%MOD<<endl;
}

Measured memory_bytes: 12160
#include "bits/stdc++.h"
using namespace std;

int main(){
  
  int n,ans = 0;
  cin >> n;
  
  ans = n%10 + (n%100-n%10)/10 + (n%1000-n%100)/100 + (n%10000-n%1000)/1000 + (n%100000-n%10000)/10000 + (n%1000000-n%100000)/100000 + (n%10000000-n%1000000)/1000000 + (n%100000000-n%10000000)/10000000;
  
  string l;
  if(n%ans == 0)l = "Yes";
  else l = "No";
  
  cout << l << endl;
  
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	long long int a[n];
	for(int i=0;i<n;i++)
		cin >> a[i];
	int i,max = a[0];
	for(i=1;i<n;i++){
		if(a[i] < max){
			if(max - 1 > a[i])
				break;
		}
		else max = a[i];
	}
	if(i==n)	cout << "Yes" << endl;
	else cout << "No" << endl;	
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::max;
use std::io;

/*
6
3 10
2 6
10 30
1 3
10 20
8 100
*/
/*
5
3 10
2 6
1 3
10 20
8 100
*/

fn main() {
    let input = input_number();
    let n = input[0] as usize;
    let mut input = (0..n).map(|_| input_number()).collect::<Vec<Vec<i64>>>();

    let median_a: i64;
    input.sort_by(|a, b| a[0].cmp(&b[0]));
    if n % 2 == 0 {
        median_a = input[n / 2][0] + input[n / 2 - 1][0];
    } else {
        median_a = input[n / 2][0];
    }

    let median_b: i64;
    input.sort_by(|a, b| a[1].cmp(&b[1]));
    if n % 2 == 0 {
        median_b = input[n / 2][1] + input[n / 2 - 1][1];
    } else {
        median_b = input[n / 2][1];
    }

    if n % 2 == 0 {
        println!("{}", median_b - median_a + 1);
    } else {
        println!("{}", median_b - median_a + 1);
    }
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}


Measured memory_bytes: 14980
#include <bits/stdc++.h>
using namespace std;
#define pow2(x) ((x)*(x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define f(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef set <ll> se;
typedef queue<ll> Q;
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
// unordered_map<ii, hash_pair> umap;
bool sort1(const pair<pair<int,int>, int> &a, 
              const pair<pair<int,int>, int> &b) 
{ 
    return (a.fi.second < b.fi.second); 
}
bool sort2(const pair<pair<int,int>, int> &a, 
              const pair<pair<int,int>, int> &b) 
{ 
    return (a.fi.first > b.fi.first); 
}
ll lcm(ll a, ll b)
{
    ll gcd = __gcd(a,b);
    ll l = (a*b)/gcd;
    return l;
}
// unordered_map<int, int> umap;
int mod =1000000007 ;


// Returns n^(-1) mod p 
// long long modInverse(ll n, ll p) 
// { 
//     return power(n, p - 2, p); 
// } 


int main()
{
    fast;
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s = "";
        string w = "ACL";
        while(n--) s+=w;
        cout<<s;
    }
}

Measured memory_bytes: 3652
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
int []t=new int[4];
int []t2=new int[2];
for(int i=0;i<4;i++)t[i]=sc.nextInt();
t2[0]=sc.nextInt();
t2[1]=sc.nextInt();
Arrays.sort(t);
System.out.println(t[3]+t[2]+t[1]+Math.max(t2[0],t2[1] ));
    }
}

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

//#define DEBUG
using namespace std;


long double f(int ,int,int,int);

bool v[306][306][306];
long double ans[306][306][306];
int dish[4];

int main()
{
    //int a=0,b=0,c=0;
    int n;
    memset(v,false,sizeof(v));
    memset(ans,0,sizeof(ans));
    memset(dish,0,sizeof(dish));
    #ifndef DEBUG
    cin>>n;
    for (int i=1;i<=n;i++)
     {
         int temp;
         cin>>temp;
         dish[temp]++;
     }
    cout<<setprecision(16)<<f(dish[1],dish[2],dish[3],n)<<endl;;
    #endif // DEBUG
    #ifdef DEBUG
    cout<<setprecision(20)<<f(0,0,100,100)<<endl;;
    #endif // DEBUG
    return 0;
}

long double f(int a,int b,int c,int n)
{
    long double aa=0,bb=0,cc=0;

    //cout<<a<<' '<<b<<' '<<c<<endl;
    if (v[a][b][c])return ans[a][b][c];
    if (!a&&!b&&!c) return 0;

    if (a!=0)
     {
         aa=f(a-1,b,c,n);
         //aa=aa+(n+0.0)/(a+0.0);
         aa=aa*((long double)a)/((long double)(a+b+c));
     }
     if (b!=0)
     {
         bb=f(a+1,b-1,c,n);
        // bb=bb+(n+0.0)/(b+0.0);
         bb=bb*((long double)b)/((long double)(a+b+c));
     }
     if (c!=0)
     {
         cc=f(a,b+1,c-1,n);
       //  cc=cc+(n+0.0)/(c+0.0);
         cc=cc*((long double)c)/((long double)(a+b+c));;
     }
     ans[a][b][c]=aa+bb+cc+((long double)n)/((long double)(a+b+c));
     v[a][b][c]=true;
     return ans[a][b][c];
}



Measured memory_bytes: 476032
N, T = map(int, raw_input().split())

list=[]
P_COST = 0
P_TIME = 1

for i in range(N):
    route = map(int, raw_input().split())
    if route[P_TIME] <= T :
        list.append(route)

#print list

if len(list) == 0:
    print 'TLE'
else:

    opt_route = list.pop()
    
    for route in list:
        if route[P_COST] < opt_route[P_COST]:
            opt_route = route
            
    print opt_route[P_COST]


Measured memory_bytes: 2568
H,W=map(int,input().split())
a=[input() for _ in range(H)]
MOD=10**9+7
dp=[[0 for _ in range(W)] for _ in range(H)]
dp[0][0]=1
for i in range(H):
    for j in range(W):
        if i+1<H and a[i+1][j]=='.':
            dp[i+1][j]+=dp[i][j]
        if j+1<W and a[i][j+1]=='.':
            dp[i][j+1]+=dp[i][j]
        dp[i][j]%=MOD
print(dp[-1][-1])

Measured memory_bytes: 50524
from sys import stdin, setrecursionlimit
from heapq import heapify, heappop, heappush


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = [-ai for ai in a]
    heapify(a)

    for _ in range(m):
        tmp = -heappop(a)
        heappush(a, -(tmp // 2))

    print(-sum(a))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	sort( A.begin(), A.end() );
	int sz = 1000000 + 1;
	vector<bool> e( sz, true );
	int last = -1;
	for( int i = 0; i < N; i++ ) {
		if( A[i] == last ) {
			e[ A[i] ] = false;
			continue;
		}
		last = A[i];
		if( e[ A[i] ] ) {
			int a = A[i];
			for( int j = 2; a * j < sz; j++  ) {
				e[a * j] = false;
			}
		}
	}
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( e[ A[i] ] ) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 4320
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner inp = new Scanner(System.in);
int a = inp.nextInt();
int b = inp.nextInt();
int c = inp.nextInt();
if (a<b && b<c) 
System.out.println("Yes");
else
System.out.println("No");
}
}


Measured memory_bytes: 26440
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 1000 + 5;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, m;
int cnt[30];
char st[maxn][maxn];

int main() {
#ifdef Wearry
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    cin >> n >> m;
    for(int i = 0; i < n; ++i) {
        scanf("%s", st[i]);
        for(int j = 0; j < m; ++j) { cnt[st[i][j] - 'a'] ++; }
    }

    int t = 0, t1 = 0, x = 0;
    if(n & 1) t += m / 2;
    if(m & 1) t += n / 2;

    x = (n&1) && (m&1);

    t1 = (n * m - t * 2 - x) / 4;

    for(int i = 0; i < 26; ++i) {
        if(cnt[i] & 1) -- x, -- cnt[i];
        while(t1 && cnt[i] >= 4) cnt[i] -= 4, -- t1;
        while(t && cnt[i] >= 2) cnt[i] -= 2, -- t;
    }

    puts(x >= 0 && t1 == 0 && t == 0 ? "Yes":"No");

    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;


int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  if(m==0) {
    if(n==1){cout << 0; return 0;}
    else if(n==2){cout << 10;return 0;}
    else {cout << 100;return 0;}
  }
  int s[m],c[m];
  map <int,int> score;
  int ans=0;

  rep(i,m) {

    cin >> s[i] >> c[i];
    if(s[i]>n && c[i]>0){
      cout << -1;
      return 0;
    }
    if(score.count(s[i])){

      if(score.at(s[i])!=c[i]){
      cout << -1;
      return 0;
    }
   }
    score[s[i]] = c[i];
  }  
  
  if(n>1 && !score.count(1))score[1]=1;
  else if(n>1 && score[1]==0){
      cout << -1;
      return 0;
    }
  rep(i,n){
    ans = ans *10 + score[i+1];
  }

  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define endl '\n'
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << "\n"
#define watch3(x, y, z) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << " and " << (#z) << " is " << (z) << "\n"
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define rep(i, a, b) for (ll i = a; i < (b); ++i)
#define reb(i, a, b) for (ll i = a; i >= (b); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
ll dp[101][101][101],price[101][101];
ll n,m,k,c[101],mm=100000000000000;
ll fun(ll index,ll prev,ll dist)
{	
	if(dist>k)
	return mm;
	if(index==n)
	{
		if(dist==k)
		return 0;
		else
		{
			return mm;
		}
	}
	ll &res=dp[index][prev][dist];
	if(res!=-1)
	return res;
	if(c[index]!=0)
	{
		if(c[index]==prev)
		res=(fun(index+1,prev,dist));
		else
		{
			res=fun(index+1,c[index],dist+1);
		}
		return res;	
	}
	res=mm;
	rep(i,0,m)
	{
		if(prev==i+1)
		{
			res=min(fun(index+1,i+1,dist)+price[index][i],res);
		}
		else
		{
			res=min(fun(index+1,i+1,dist+1)+price[index][i],res);
		}
		//cout<<res<<endl;
	}
	return res;
}
int main()
{
//     #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		ll n;
		cin>>n;
		ll a[n];
		rep(i,0,n)
		{
			cin>>a[i];
		}
		ll maxx=a[0],ans=0;
		rep(i,1,n){
			if(a[i]<maxx)
			ans+=maxx-a[i];
			maxx=max(maxx,a[i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 5148
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  string s; cin >> s;
  int n=s.length();
if(n%2==1){
  for(int i=0;i<n/2+1;i++){
    cout<<s[2*i];
}}
else{
  for(int i=0;i<n/2;i++){
    cout<<s[2*i];
}}
  cout<<endl;
  return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
sc = []
for _ in range(m):
    s, c = map(int, input().split())
    sc.append((s - 1, c))
for i in range(1000):
    now = str(i)
    l = len(now)
    if l != n:
        continue
    flag = True
    for s, c in sc:
        if s > l - 1:
            flag = False
            break
        if now[s] != str(c):
            flag = False
            break
    if flag:
        print(int(now))
        exit()
print(-1)

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

int main() {
    vector<int> input(3);
    int a, b, c, k;
    cin >> input[0] >> input[1] >> input[2] >> k;

    sort(input.begin(), input.end());
    int max_input = input.back();

    while (k > 0) {
        max_input *= 2;
        k--;
    }

    cout << input[0] + input[1] + max_input << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static char[] s;
	public static int[] table;
	public static int n;
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			s = in.next().toCharArray();
			if(s[0] == '#') break;
			int alps = 0;
			for(int i=0; i<s.length; i++){
				if(s[i] < 'a' || 'z' < s[i]) continue;
				alps |= 1<<s[i]-'a';
			}
			n = Integer.bitCount(alps);
			table = new int[n];
			int idx = 0;
			for(int i=0; i<15; i++){
				if((alps&1<<i)==0) continue;
				table[idx++] = i;
			}
			System.out.println(dfs(0, 0) ? "YES" : "NO");
		}
	}
	
	public static boolean dfs(int idx, int state){
		if(idx == n){
			if(!check(state))
				return false;
			return true;
		}
		if(!dfs(idx+1, state|1<<table[idx]) || !dfs(idx+1, state))
			return false;
		return true;
	}
	public static int idx;
	public static boolean check(int state){
		idx = 0;
		st = state;
		boolean val = formula();
		idx++;
		return val==formula();
	}
	public static int st;
	public static boolean[][] arr = {
		{true, true},
		{false,true}
	};
	public static boolean formula(){
		if(s[idx] == '-'){
			idx++;
			return !formula();
		}else if(s[idx] == '('){
			idx++;
			boolean val = formula();
			if(s[idx] == '*'){
				idx++;
				val = val&formula();
			}else if(s[idx] == '+'){
				idx++;
				val = val|formula();
			}else{
				idx+=2;
				val = arr[val?1:0][formula()?1:0];
			}
			idx++;
			return val;
		}else if(s[idx] == 'T'){
			idx++;
			return true;
		}
		else if(s[idx] == 'F'){
			idx++;
			return false;
		}
		return (st&1<<s[idx++]-'a')>0;
	}
	
}

Measured memory_bytes: 26732
N = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0

for i in range(N):
    S = input()
    if S[0] == 'M':
        m += 1
    elif S[0] == 'A':
        a += 1
    elif S[0] == 'R':
        r += 1
    elif S[0] == 'C':
        c += 1
    elif S[0] == 'H':
        h += 1

ans = m * a * (r+c+h) + m * r * (c+h) + m * c * h + a * r * (c + h) + a * c * h + r * c * h
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int n;
vvi ans;
vector<bool> used;

void solve(int i,vi s){
  if(i==n){
    ans.push_back(s);
    return;
  }
  rep(j,n){
    if(!used[j]){
      used[j]=true;
      s.push_back(j+1);
      solve(i+1,s);
      s.pop_back();
      used[j]=false;
    }
  }
}

int main(){
  cin>>n;
  vi p,q;
  p.resize(n);
  q.resize(n);
  used.resize(n,false);
  rep(i,n){
    cin>>p[i];
  }
  rep(i,n){
    cin>>q[i];
  }
  solve(0,{});
  int a=0,b=0;
  int N=ans.size();
  rep(i,N){
    if(ans[i]==p){
      a=i;
    }
    if(ans[i]==q){
      b=i;
    }
  }
  cout<<abs(a-b)<<endl;
  return 0;
}


Measured memory_bytes: 3256
#include<stdio.h>
int main()
{
char a[3];
  int i;
  for(i=0;i<3;++i)
  {scanf("%c",&a[i]);}
if(a[0]=='A' && a[1]=='A' && a[2]=='A') printf("No");
else if(a[0]=='B' && a[1]=='B' && a[2]=='B') printf("No");
else printf("Yes");
 
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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 n;
    cin >> n;
    vector<int> P(n);
    vector<int> Q(n);
    vector<int> R(n);
    for(int i = 0; i < n; i++){
        cin >> P[i];
    }
    for(int i = 0; i < n; i++){
        cin >> Q[i];
    }
    for(int i = 0; i < n; i++){
        R[i] = i + 1;
    }
    int a, b, cnt;
    cnt = 0;
    do{
        cnt++;
        if(P == R) a = cnt;
        if(Q == R) b = cnt;
    } while(next_permutation(R.begin(), R.end()));

    cout << abs(a-b) << endl;
    return 0;
}

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

int main(void) {
	int h, w; cin >> h >> w;
	char s[h + 2][w + 2];
	int i, j, sum = 0;

	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			cin >> s[i][j];
		}
	}

	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			if(s[i][j]=='#'){}
			else if (s[i][j] == '.') {
				if (s[i - 1][j - 1] == '#') { sum += 1; }
				if (s[i - 1][j] == '#') { sum += 1; }
				if (s[i - 1][j + 1] == '#') { sum += 1; }
				if (s[i][j + 1] == '#') { sum += 1; }
				if (s[i][j - 1] == '#') { sum += 1; }
				if (s[i + 1][j - 1] == '#') { sum += 1; }
				if (s[i + 1][j + 1] == '#') { sum += 1; }
				if (s[i + 1][j] == '#') { sum += 1; }
				s[i][j] = '0'+sum;
			}
          sum=0;
		}
	}

	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			cout << s[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;
    int MAX_M = 100000;
    int MAX_N = 100000;
    int H, W;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        String[] A = new String[H];
        char[][] a = new char[H][];
        dp = new long[H][W];
        for (int i = 0; i < H; i++) {
            A[i] = sc.next();
        }
        for (int i = 0; i < H; i++) {
            a[i] = A[i].toCharArray();
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i - 1 >= 0 && i - 1 < H && j + 0 >= 0 && j + 0 < W && a[i - 1][j] == '.') {
                    dp[i][j] += dp[i - 1][j];
                }
                if (i >= 0 && i < H && j - 1 >= 0 && j - 1 < W && a[i][j - 1] == '.') {
                    dp[i][j] += dp[i][j - 1];
                }
                dp[i][j] %= 1000000007;
            }
        }
        System.out.println(dp[H - 1][W - 1]);
    }
}

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



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i,j;
    cin>>n;
    int arr[n];
    map<int,int>mp;
    for(i=0;i<n;i++){
        cin>>arr[i];
        mp[arr[i]]++;
    }
    vector<int> vt((mp.rbegin()->first)+2,1);
    int ans=0;
    for(auto it=mp.begin();it!=mp.end();it++){
        if(vt[it->first]==1 && it->second==1){
            ans++;
        }
        for(i=it->first;i<=mp.rbegin()->first;i+=it->first){
            vt[i]=0;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 17152
#include <iostream>
using namespace std;
class Dice
{
    int top;
    int front;
    int right;
    int left;
    int back;
    int bottom;

public:
    Dice(int top, int front, int right, int left, int back, int bottom);
    void print_answer(Dice d2);
    bool is_same(Dice d2);
    void turn_front(Dice *d2);
    void roll_char(Dice *d2, char command);
    void find_top(Dice *d2);
    bool is_same_four(Dice *d2);
};
Dice::Dice(int top, int front, int right, int left, int back, int bottom)
{
    this->top = top;
    this->front = front;
    this->right = right;
    this->left = left;
    this->back = back;
    this->bottom = bottom;
}
void Dice::roll_char(Dice *d2, char command)
{
    int tmp;
    switch (command)
    {
    case 'S':
        tmp = d2->top;
        d2->top = d2->back;
        d2->back = d2->bottom;
        d2->bottom = d2->front;
        d2->front = tmp;
        break;
    case 'N':
        tmp = d2->top;
        d2->top = d2->front;
        d2->front = d2->bottom;
        d2->bottom = d2->back;
        d2->back = tmp;
        break;
    case 'W':
        tmp = d2->top;
        d2->top = d2->right;
        d2->right = d2->bottom;
        d2->bottom = d2->left;
        d2->left = tmp;
        break;
    case 'E':
        tmp = d2->top;
        d2->top = d2->left;
        d2->left = d2->bottom;
        d2->bottom = d2->right;
        d2->right = tmp;
        break;
    }
}
void Dice ::turn_front(Dice *d2)
{
    char command[] = "NENEN";
    int i = 0;
    while (d2->top != front || i < 5)
    {
        roll_char(d2, *(command + i));
        i++;
    }
    //d2->top == front になればループ抜ける
    roll_char(d2, 'S');
    //同じにならなかったらこの時点で違う
}
void Dice ::find_top(Dice *d2)
{
    char command[] = "EEE";
    int i = 0;
    while (d2->top != this->top)
    {
        roll_char(d2, *(command + i));
        i++;
    }
}
bool Dice ::is_same_four(Dice *d2)
{
    //ただのrightではだめなのか?
    if (this->right == d2->right && this->left == d2->left && this->bottom == d2->bottom && this->back == d2->back)
    {
        return true;
    }
    return false;
}
bool Dice ::is_same(Dice d2)
{
    //まずfrontを同じにする
    //d1のfrontと同じになるようにd2を回す
    Dice::turn_front(&d2);
    //topが一致するまで回す（一致しなければfalse）
    Dice::find_top(&d2);
    if (this->top != d2.top)
    {
        return false;
    }
    //残る４面が同じか判定する
    return Dice ::is_same_four(&d2);
}
void Dice ::print_answer(Dice d2)
{
    if (is_same(d2))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}
int main()
{
    int top, front, right, left, back, bottom;
    cin >> top >> front >> right >> left >> back >> bottom;
    Dice d1(top, front, right, left, back, bottom);
    cin >> top >> front >> right >> left >> back >> bottom;
    Dice d2(top, front, right, left, back, bottom);

    d1.print_answer(d2); //別に値を変える訳ではない
}



Measured memory_bytes: 3112
def run(N, M, A):
    A = sorted(A, reverse=True)
    right = A[0] * 2
    left = 0
    while left <= right:
        X = (left + right) // 2
        # 左手の相手がaで、満足度がX以上となる組合せの数
        cnt = 0
        for a in A:
            cnt += search(A, X - a)
        if cnt >= M:
            res = X
            left = X + 1
        else:
            right = X - 1
    X = res
    # Xが決まったので、累積和で組合せの数分の値を求める
    sum_A = [0]
    for a in sorted(A):
        sum_A.append(sum_A[-1] + a)
    sum_cnt = 0
    ans = 0
    for a in A:
        cnt = search(A, X - a)
        sum_cnt += cnt
        if cnt > 0:
            ans += cnt * a + sum_A[-1] - sum_A[-cnt-1]
    if sum_cnt > M:
        ans -= X * (sum_cnt - M)
    return ans


def search(A, X):
    '''
    AのリストからX以上となる数値がいくつか探す
    Aはソート済み(降順)
    二分探索で実装O(logN)
    leftとrightはチェック未
    middleはループ終了後チェック済み
    '''
    left = 0
    right = len(A) - 1
    res = 0
    while left <= right:
        middle = (left + right) // 2
        if A[middle] >= X:
            res = middle + 1
            left = middle + 1
        else:
            right = middle - 1
    return res


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    print(run(N, M, A))


if __name__ == '__main__':
    main()


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

long long N,arr[200010],prefix[200010]; const long long MOD=1e9+7;

long long Sub(long long a, long long b){
	if(a>b)return a-b;
	return a+1000000007-b;
}

long long Add(long long a, long long b, long long c){
	long long currAdd=(b*c)%MOD;
	return (a+currAdd)%MOD;
}

void Input(){
	cin>>N;
	for(long long i=0; i<N; i++){
		cin>>arr[i];
		if(i==0){
			prefix[i]=arr[i];
		}else{
			prefix[i]=(prefix[i-1]+arr[i])%MOD;
		}
	}
}

void Solve(){
	long long total=0;
	for(long long i=0; i<N; i++){
		total=Add(total,arr[i],Sub(prefix[N-1],prefix[i]));
	}
	cout<<total<<'\n';
}

int main(){
	Input();
	Solve();
}

Measured memory_bytes: 6744
s = input().strip()
t = input().strip()

scount = []
tcount = []

for x in [chr(i) for i in range(97,97+26)]:
    scount.append(s.count(x))
    tcount.append(t.count(x))

if sorted(scount) == sorted(tcount):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	double n,m,d;
	cin>>n>>m>>d;
  	if(d){
		double ans=2*(m-1)*(n-d)/(n*n);
		cout<<fixed;
		cout<<setprecision(12)<<ans;
    }
	else{
		double ans=(m-1)*(n-d)/(n*n);
		cout<<fixed;
		cout<<setprecision(12)<<ans;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#pragma warning(disable : 4996)

#define MAX_N 100000
#define INF 1000000000

template <typename T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template <typename T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int Abs(int a) {
	if (a < 0) return a *= -1;
	return a;
}

int min(int a, int b) {
	if (a < b) return a;
	return b;
}
int max(int a, int b) {
	if (a > b) return a;
	return b;
}
int N;
int DP[3][MAX_N + 1];
int main(void) {
	scanf("%d", &N);
	DP[0][0] = DP[1][0] = DP[2][0] = 0;
	for (int i = 0; i < N; ++i) {
		int h[3];
		scanf("%d %d %d", &h[0], &h[1], &h[2]);
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (j == k) continue;
				chmax(DP[k][i + 1], DP[j][i] + h[k]);
			}
		}

	}
	int ans = max(max(DP[0][N], DP[1][N]), DP[2][N]);
	printf("%d", ans);

	return 0;
}


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

namespace _1_7_b
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] s = Console.ReadLine().Split(' ');
                int n = int.Parse(s[0]);
                int x = int.Parse(s[1]);
                int q = 0;

                if (n == 0 && x == 0)
                {
                    break;
                }

                for (int a = 1; a <= n; a++)
                {
                    for (int b = a + 1; b <= n; b++)
                    {
                        for (int c = b + 1; c <= n; c++)
                        {
                            if (x == a + b + c)
                            {
                                q += 1;
                            }
                            else
                            {

                            }
                        }
                    }
                }

                Console.WriteLine(q);
                Console.ReadKey();
            }
        }
    }
}



Measured memory_bytes: 15944
//Half and Half

#include<iostream>
#include<algorithm>

#define NDEBUG
#include<cassert>

using namespace std;

using cost = int_fast32_t;
using numPizza = int_fast32_t;

cost Half_and_Half(cost a, cost b, cost c, numPizza x, numPizza y){
        if (2*c >= a+b){
                return a*x+b*y;
        }
        if (x > y){
                return 2*c*y+min(a,2*c)*(x-y);
        }
        return 2*c*x+min(b,2*c)*(y-x);
}

int main(){
        cost A, B, C;
        numPizza X, Y;

        cin >> A >> B >> C >> X >> Y;
        assert(1<=A && A<=5000);
        assert(1<=B && B<=5000);
        assert(1<=C && C<=5000);
        assert(1<=X && X<=100000);
        assert(1<=Y && Y<=100000);

        cout << Half_and_Half(A, B, C, X, Y) << endl;;

        return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define inf 1e18+9
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define umap unordered_map<ll,ll>
#define lpq priority_queue<ll,vector<ll>,greater<ll>>
ll globe=0;
ll powe(ll n,ll r){if(!r)return 1;else if(r%2==0)return powe(n*n,r/2);else return n*powe(n*n,(r-1)/2);}
 
int32_t main(){
 	
	if(fopen("input.txt", "r")){
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	}
 
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
 
	ll t=1;
	//cin>>t;
	while(t--){
	    ll n,m;
	    cin>>n>>m;
	    cout<<(n*(n-1)+m*(m-1))/2<<endl;;
	    
	}
 
	return 0;
 
}
//BitMasking->setBit: n|(1<<i); unsetBit: n&!(1<<i); checkBit: n&(1<<i);
//ll idx=upper_bound(v.begin(),v.end(),val)-v.begin();
//v.erase(unique(v.begin(),v.end()),v.end());
//ll cnt=count(v.begin(),v.end(),val);
//bool f=find(v.begin(),v.end(),val);

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>

namespace
{
	auto is_right = [](std::vector<unsigned int> length)
	{
		std::sort(length.begin(), length.end());
		std::transform(length.begin(), length.end(), length.begin(),
			[](unsigned int element) { return std::pow(element, 2); });
		return length[0] + length[1] == length[2];
	};
}

namespace
{
	unsigned int N; std::vector<unsigned int> length(3);
}

int main()
{
	std::scanf("%u", &N);
	for (unsigned int i = 0; i < N; i++)
	{
		std::scanf("%u%u%u", &length[0], &length[1], &length[2]);
		std::printf((is_right(length) ? "YES\n" : "NO\n"));
	}
	return 0;
}


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

int main() {
    // #ifndef _DEBUG
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    string s;
    cin >> s;

    size_t count {};
    for (size_t i {}, j {s.size()-1}; i < j; ++i, --j) {
    	if (s.at(i) != s.at(j)) ++count;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

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

	return true;
}








int main()
{
	
	int h, a;

	cin >> h >> a;

	int ans = (h + a - 1) / a;
	cout << ans << endl;



	





	return 0;

}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!

#検索される文字列
S = input()
#検索する文字列
T = input()
min = len(T)


for Snum in range(len(S)- len(T) + 1):
    count = 0
    for i in range(len(T)):
        if S[Snum + i] != T[i]:
            count += 1
    if count < min:
        min = count
print(min)

Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
using namespace std;

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

  vector<int> h(N);
  rep( i, 0, N ) cin >> h.at(i);

  int Ans = 0;
  rep( i, 0, N ) {
    if ( K<=h.at(i) ) {Ans++;
    }
  }
  cout << Ans << endl;
}


Measured memory_bytes: 640