akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

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

int n,m;
vector<int> G[501];
bool path[21][501][501];
bool now[505];
bool tmp[505];

bool C(int v){
	memset(now,false,sizeof(now));
	now[0]=true;
	for(int i=0;i<20;i++){
		if((v>>i) & 1){
			memset(tmp,false,sizeof(tmp));
			for(int j=0;j<n;j++){
				if(now[j]){
					for(int k=0;k<n;k++){
						if(path[i][j][k]){
							tmp[k]=true;
						}
					}
				}
			}
			for(int j=0;j<n;j++){
				now[j]=tmp[j];
			}
		}
	}
	for(int i=0;i<n;i++){
		if(!now[i])return false;
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&m);
	memset(path,false,sizeof(path));
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;
		v--;
		path[0][u][v]=true;
	}
	for(int i=0;i<20;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(path[i][j][k]){
					for(int l=0;l<n;l++){
						if(path[i][k][l]){
							path[i+1][j][l]=true;
						}
					}
				}
			}
		}
	}
	int l=0,r=1000000;
	while(l+1<r){
		int mid=(l+r)/2;
		if(C(mid))r=mid;
		else l=mid;
	}
	if(r==1000000){
		printf("-1\n");
	}else{
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 8368
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(ll i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(ll i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

ll n, k, a[55], f[55][55][2510], res;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    f[0][0][0] = 1;
    FOR(i,1,n) {
        FOR(j,0,i-1)
            FOR(p,1,i)
                FOR(r,1,2500)
                    if (r - a[i] >= 0) f[i][p][r] += f[j][p-1][r-a[i]];
    }
    FOR(j,1,n)
        FOR(i,1,n) res += f[i][j][j*k];
    cout << res;
    return 0;
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}
const int maxn = 100000+5;

bool have357(const string& s){
    int f1 = 1, f2 = 2, f3 = 4;
    int f = 0;
    for(int i = 0; i <(int)s.size(); ++i){
        if(s[i] == '3') f |= f1;
        if(s[i] == '5') f |= f2;
        if(s[i] == '7') f |= f3;
    }
    if(f == (f1|f2|f3)) return true;
    return false;
}

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    int n;
    int ans = 0;
    cin>>n;
    queue<string> q;
    q.push("");
    while(!q.empty()){
        string s = q.front();
        if(s != ""){
            if(have357(s)){
                ll t = stoll(s);
                if(t <= n) ans++;
                else break;
            }
        }
        q.pop();
        q.push(s+"3");
        q.push(s+"5");
        q.push(s+"7");
    }

    cout<<ans<<endl;

    return 0;
}


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

int main(){
  char b; cin>>b;
  if(b=='A') cout << 'T' << endl;
  else if(b=='T') cout << 'A' << endl;
  else if(b=='C') cout << 'G' << endl;
  else cout << 'C' << endl;
}

Measured memory_bytes: 256
a=[]
n=int(input())
for i in range(n):a.append(int(input()))
a.sort()
if len(a)%2==0:
    b=[a.pop(len(a)//2-1)]
    while len(a)!=1:
        b.append(a.pop(-1))
        b.append(a.pop(0))
    b.append(a.pop(-1))
else:
    b=[a.pop(len(a)//2)]
    if abs(b[0]-a[len(a)//2])>abs(b[0]-a[len(a)//2-1]):
        while len(a)!=0:
            b.append(a.pop(-1))
            b.append(a.pop(0))
    else:
        while len(a)!=0:
            b.append(a.pop(0))
            b.append(a.pop(-1))
ans=0
for i in range(n-1):ans+=abs(b[i]-b[i+1])
print(ans)

Measured memory_bytes: 7788
#include <bits/stdc++.h>
  using namespace std;
  #define int long long int 
  #define vi vector<int>
  #define pii pair<long long ,long long>
  #define pll pair<int,int>
  #define mod 1000000007
  #define hell 998244353
  #define all(x) x.begin(),x.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb push_back
  #define ff first
  #define ss second
  #define rep(n) for(int i=0;i<n;i++)
  #define lb lower_bound
  #define up upper_bound
  
  void solve()
  { 
    int n;
    cin>>n;
    vector<pair<int,int> > v(n);
    rep(n)
    {
       int x;
       cin>>x;
       v[i].ff=x;
       v[i].ss=i+1;
    }
    sort(all(v));
    for(int i=0;i<n;i++)
      cout<<v[i].ss<<" ";
    
    

  }



  signed main()
  {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    
    
     
    
    int T;
    T=1;
    
    while(T--)
    {
      solve();
    }
    return 0;
  }

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;



int main(){
    string s;cin >> s;
    int m = stoi(s.substr(5,2));
    int d =  stoi(s.substr(8,2));
  //  cout<<m<<" "<<d<<endl;
    if(m >= 5){
        cout<<"TBD"<<endl;;
        return 0;
    }
    if(m <= 4){
        cout<<"Heisei"<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

int a,b;

int main(){
    cin >> a >> b;

    if (a<=0 && 0<=b) cout << "Zero";
    else if (a>0) cout << "Positive";
    else{
        if ((b-a)%2==0) cout << "Negative";
        else cout << "Positive";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let boalls: Vec<(i64,i64)> = (0..n).map(|_| (read(),read())).collect();
    let mut map = HashMap::new();

    if n == 1 {
        println!("1");
        return;
    }
    for i in 0..n{
        for j in 0..n{
            if i == j{
                continue;
            }
            let x = boalls[i].0 - boalls[j].0;
            let y = boalls[i].1 - boalls[j].1;
            let count = map.entry((x,y)).or_insert(0);
            *count += 1;
            //println!("x{} y{}",x,y);
        }
    }
    println!("{}",n - map.iter().max_by(|x,y|x.1.cmp(y.1)).unwrap().1);
}


Measured memory_bytes: 2188
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f and k*c <= L*e:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f and M <= L*e:
            if (M*100)/(M+L*100) > ans:
                ans = (M*100)/(M+L*100)
                ansL = L*100
                ansM = M
if ansL == 0:
    print('{} {}'.format(a*100,0))
else:
    print('{} {}'.format(ansL+ansM,ansM))

Measured memory_bytes: 3064
a,b,c = map(int,input().split())
if a == 5 and b == 5 and c == 7:
    print('YES')
elif a == 5 and b == 7 and c == 5:
    print('YES')
elif a == 7 and b == 5 and c == 5:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
n=int(input())
H=list(map(int,input().split()))
start,end,ans=0,H[0],0

for i in range(1,n):
  if end <= H[i]:
    end=H[i]
  else:
    ans += (end-start)
    start,end=H[i],H[i]
    
ans += (end-start)
print(ans)

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

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    int a = x, b = y, c = z;

    int tmp = a;
    a = b;
    b = tmp;

    tmp = a;
    a = c;
    c = tmp;

    cout << a << " " << b << " " << c << endl;

}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k) = (v[0] as usize, v[1]);
    let mut numbers = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        if v[0] > k {
            continue;
        }
        numbers.push((v[0], v[1]));
    }
    let mut one_poses = vec![];
    for i in 0..30 {
        if (k >> i) & 1 == 1 {
            one_poses.push(i);
        }
    }
    let mut ans = 0;
    'outer1: for &(a, b) in numbers.iter() {
        for i in 0..30 {
            if (k >> i) & 1 == 0 && (a >> i) & 1 == 1 {
                continue 'outer1;
            }
        }
        ans += b;
    }
    for pos in one_poses {
        let mut temp = 0;
        'outer2: for &(a, b) in numbers.iter() {
            if (a >> pos) & 1 == 1 {
                continue 'outer2;
            }
            for i in pos + 1..30 {
                if (k >> i) & 1 == 0 && (a >> i) & 1 == 1 {
                    continue 'outer2;
                }
            }
            // for i in pos + 1..30 {}
            temp += b;
        }
        ans = max(ans, temp);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,i,kaisuu,wa,ansk;
  cin>>n;
  ansk=0;
  vector<int> vec(n);
  vector<int> hako(n);
  for (i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for(i=n-1; -1<i; i=i-1){
    wa=0;
    kaisuu=n/(i+1);
    for(int j=1; j<kaisuu+1; j++){
      wa=wa+hako.at(j*(i+1)-1);
    }
    if(wa%2==vec.at(i)){
    }
    else{
      hako.at(i)=1;
      ansk=ansk+1;
    }
  }
  cout<<ansk<<endl;
  for(i=0; i<n; i++){
    if(hako.at(i)==1){
      cout<<i+1<<endl;
    }
  }
}

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

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

  cin>>n>>m;

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

  
  float val=(float)sum/(float)(4*m);
  
  for(int i=0;i<n;i++){
    if((float)a[i]>=val)
      m--; 
  }
  if(m>0){
    cout<<"No"<<endl;
  }
  else cout<<"Yes"<<endl;
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    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;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

int main() {
    int h,w;
    string s;
    cin >> h >> w;
    vector<vector<char>> C(h+2,vector<char>(w+2, '.'));
    vector<vector<char>> CC(h+2,vector<char>(w+2,'0'));
    for(int i=1; i<=h; ++i) {
        for(int j=1; j<=w; ++j) {
            cin >> C[i][j];
        }
    }
    for(int i=1; i<=h; ++i) {
        for(int j=1; j<=w; ++j) {
            if (C[i][j] == '#') {
                CC[i][j] = '9';
                CC[i][j-1]++;
                CC[i-1][j-1]++;
                CC[i-1][j]++;
                CC[i-1][j+1]++;
                CC[i][j+1]++;
                CC[i+1][j]++;
                CC[i+1][j-1]++;
                CC[i+1][j+1]++;
            }
        }
    }
    for(int i=1; i<=h; ++i) {
        for(int j=1; j<=w; ++j) {
            if (CC[i][j] > '8') {
                cout << '#';
            } else {
                cout << CC[i][j];
            }
        }
        cout << "\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		 int F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
	long long G()
	{
		 long long F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
}
int R(int l,int r)
{
	return (rand()<<15|rand())%(r-l+1)+l;
}
const int M=1000000007;
int a[111111];
int inv[111111];
int main()
{
	int n=io::F();
	inv[1]=1;
	for(register int i=2;i<=n;++i)inv[i]=((long long)(-M/i)*inv[M%i]%M+M)%M;
	for(register int i=1;i<=n;++i)a[i]=io::F();
	for(register int i=1;i<=n;++i)inv[i]=(inv[i]+inv[i-1])%M;
	int ans=0;
	for(register int i=1;i<=n;++i)ans=(ans+(long long)a[i]*(inv[i]+inv[n+1-i]-1))%M;
	for(register int i=1;i<=n;++i)ans=(long long)ans*i%M;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m;
int p;
char s[22];
int cnt[100100][2];
int ac;
int pm;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d%s",&p,s);
		if(s[0]=='A')
		{
			cnt[p][1]++;
			if(cnt[p][1]==1)ac++,pm+=cnt[p][0];
		}
		else
			cnt[p][0]++;
	}
	printf("%d %d\n",ac,pm);
	return 0;
}


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

using namespace std;

int N, M;
int num[14], arr[14][14];
int val[14], cnt[14];
int ans = 0;

void sol(int x){
    if(x > N){
        int f = 1;
        for(int i = 1; i <= M; ++i){
            if(cnt[i] % 2 != val[i]){
                f = 0; break;
            }
        }
        ans += f; return;
    }
    sol(x + 1);
    for(int i = 1; i <= M; ++i){
        for(int j = 1; j <= num[i]; ++j){
            if(arr[i][j] == x) ++cnt[i];
        }
    }
    sol(x + 1);
    for(int i = 1; i <= M; ++i){
        for(int j = 1; j <= num[i]; ++j){
            if(arr[i][j] == x) --cnt[i];
        }
    }
}

int main(){
    scanf("%d %d", &N, &M);
    for(int i = 1; i <= M; ++i){
        scanf("%d", num + i);
        for(int j = 1; j <= num[i]; ++j){
            scanf("%d", arr[i] + j);
        }
    }
    for(int i = 1; i <= M; ++i) scanf("%d", val + i);
    sol(1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int solve(int n){
    int copy = n;
    int prime=0;
    for(int i=2;i*i<=copy;i++){
        bool pri = false;
        while(n%i==0){
            n/=i;
            pri=true;
        }
        if(pri){
            prime++;
        }
    }
    if(n!=1) prime++;
    return prime+1; //素因数の数 + 1
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,G;
    cin >> A>>B;
    G=gcd(A,B);
    
    int ans=solve(G);



    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,x,c[50],a[50][50],b[50],d[50],l,sum=INT_MAX,cost;
void dfs(int s){
	int i,j,k;
	if(s==l+1){
		for(k=1;k<=m;k++)d[k]=0;
		for(j=1;j<=l;j++)
			for(k=1;k<=m;k++)d[k]+=a[b[j]][k];
		for(k=1;k<=m;k++)
			if(d[k]<x)return;
		cost=0;
		for(j=1;j<=l;j++)cost+=c[b[j]];
		sum=min(sum,cost);
		return ;
	}
	for(i=b[s-1]+1;i<=n;i++){
		b[s]=i;
		dfs(s+1);
	}
}
int main(){
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++)cin>>a[i][j];
	}
	for(l=1;l<=n;l++)b[0]=0,dfs(1);
	if(sum==INT_MAX)cout<<-1<<endl;
	else cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
long long n, a[110000], ans1, ans2, sum1, sum2;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        sum1 += a[i];
        if (i % 2 == 0) {
            if (sum1 <= 0) {
                ans1 += 1 - sum1;
                sum1 = 1;
            }
        } else {
            if (sum1 >= 0) {
                ans1 += sum1 + 1;
                sum1 = -1;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        sum2 += a[i];
        if (i % 2 == 0) {
            if (sum2 >= 0) {
                ans2 += sum2 + 1;
                sum2 = -1;
            }
        } else {
            if (sum2 <= 0) {
                ans2 += 1 - sum2;
                sum2 = 1;
            }
        }
    }
    cout << min(ans1, ans2) << endl;
}
//符号固定　その場その場での判断　コスト不変でリスク無し

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

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

    vector<vector<pair<int, int>>> x(N + 1);
    int P[M];
    int Y[M];
    for (int i = 0; i < M; i++)
    {
        cin >> P[i] >> Y[i];
        x[P[i]].push_back(make_pair(Y[i], x[P[i]].size()));
    }

    for (int i = 0; i <= N; i++)
    {
        sort(x[i].begin(), x[i].end());
    }

    vector<vector<int>> y(N + 1);
    for (int i = 0; i <= N; i++)
    {
        vector<int> tmp(x[i].size());
        y[i] = tmp;
        for (int j = 0; j < x[i].size(); j++)
        {
            y[i][x[i][j].second] = j;
        }
    }

    for (int i = 0; i < M; i++)
    {
        cout << setfill('0') << setw(6) << P[i];
        cout << setfill('0') << setw(6) << y[P[i]][0] + 1;
        cout << endl;
        y[P[i]].erase(y[P[i]].begin());
    }
}


Measured memory_bytes: 13184
#include <stdio.h>

int main(){

  int a,b,c;  
  scanf("%d %d %d",&a,&b,&c);
  // && ||
  if(a <= b && b <= c){
    printf("%d %d %d\n",a,b,c);
  }

  else if(a <= c && c <= b){
    printf("%d %d %d\n",a,c,b);
  }

  else if(b <= a && a <= c){
    printf("%d %d %d\n",b,a,c);
  }
  else if(b <= c && c <= a){
    printf("%d %d %d\n",b,c,a);
  }
  else if(c <= a && a <= b){
    printf("%d %d %d\n",c,a,b);
  }
  else if(c <= b && b <= a){
    printf("%d %d %d\n",c,b,a);
  }
 


  
 

  return 0; 
}

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

int main(){
  
  int e, cnt[110]={};

  for(int i=0;i<12;i++){
    cin>>e;
    cnt[e]++;
  }

  for(int i=1;i<=100;i++){
    if(cnt[i]%4){
      cout<<"no"<<endl;
      return 0;
    }
  }

  cout<<"yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 3088
n = int(input())
B = list(map(int,input().split()))

def a():
    A = []
    while len(B) > 0:
        lb = len(B)
        for i in range(len(B)-1, -1, -1):
            if i == B[i]-1:
                A.append(B[i])
                t = B.pop(i)
                break
        if len(B) == lb:
            return -1
    return A

aa = a()
if aa != -1:
    for i in aa[::-1]:
        print(i)
else:
    print(-1)

# def b():
#     while True:
#         if True:
#             break
#         return 1
#     return 0

# print(b())


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n,d;cin>>n>>d;d=d*d;
    ll ans=0;
    rep(i,n){
        ll x,y;cin>>x>>y;
        if(x*x+y*y<=d)ans++;
    }
    out(ans);
}

Measured memory_bytes: 3612
//??????????????\???
#include <iostream>
#define int long long
using namespace std;

int n;
char s[100002];
int OI[100001];	//OI[i] = OI[i, n-1]
int J[100001];	//J[i] = J[0, i-1]
int I[100001];	//I[i] = I[i, n-1]
int JO[100001];	//JO[i] = JO[0, i-1]

signed main() {
	int i;
	cin >> n >> s;
	
	for (i = n - 1; i >= 0; i--) I[i] = I[i+1] + (s[i] == 'I');
	for (i = n - 1; i >= 0; i--) OI[i] = OI[i+1] + (s[i] == 'O') * I[i];
	for (i = 0; i < n; i++) J[i+1] = J[i] + (s[i] == 'J');
	for (i = 0; i < n; i++) JO[i+1] = JO[i] + (s[i] == 'O') * J[i];

	int ini = 0;
	for (i = 0; i < n; i++) ini += (s[i] == 'J') * OI[i];
	
	int ans = 0;
	for (i = 0; i <= n; i++) {
		ans = max(ans, OI[i]);
		ans = max(ans, J[i] * I[i]);
		ans = max(ans, JO[i]);
	}
	ans += ini;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
 int main(){
   string AC,WA,TLE,RE;
  int N;
  int a=0,b=0,c=0,d = 0;
  cin >> N;
   string str;
  for (int i = 0; i < N; i++){
   cin >> str;
    if(str == "AC")
      a++;
     else if(str == "WA")
      b++;
     else if(str == "TLE")
      c++;
    else  
      d++;
  }
  cout << "AC x "<< a  << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}


Measured memory_bytes: 3604
from collections import deque


def main():
    item = deque([i for i in input()])
    n = int(input())
    flag = 0
    append = item.append
    for i in range(n):
        tmp = input()
        if tmp[0] == '1':
            flag += 1
            continue

        _, q, s = tmp.split()
        if q == '1' and flag % 2 == 0:
            item.appendleft(s)
            continue
        elif q == '2' and flag % 2 == 1:
            item.appendleft(s)
            continue
        append(s)

    if flag % 2 == 1:
        item.reverse()
    print(''.join(item))

if __name__ == '__main__':
    main()

Measured memory_bytes: 76192
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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() {
    ll K;
    cin >> K;
    if(K % 2 == 0) {
        cout << "-1" << endl;
        return 0;
    }
    ll sevens = 7LL;
    REP(i, K) {
        if(sevens % K == 0LL) {
            cout << i + 1 << endl;
            return 0;
        }
        sevens = sevens * 10LL + 7LL;
        sevens %= K;
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  
  rep(i,n){
    cin>>c[i];
    rep(j,m) cin>>a[i][j];
  }
  
  int res=12000000;
  rep(bit,1<<n){
    bool flag=true;
    int cost=0;
    vector<int> u(m);
    rep(i,n){
      if(bit&1<<i){
        cost+=c[i];
        rep(j,m) u[j]+=a[i][j];
      }
    }
    rep(i,m) if(u[i]<x) flag=false;
    if(flag) res=min(res,cost);
  }
  if(res==12000000) cout<<-1;
  else cout<<res<<endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long A,B;
 
    cin >> A >> B;
 
    vector<long long> A_yakusu;
 
    long long now = 0; 
    long long a = 2;
    while(A >= a*a){
        if(A%a == 0){
            //cout << a << endl;
            if (a != now){
                A_yakusu.push_back(a);
                now = a;
            }
            A /= a;
            //cout << A << endl;
        }else{
            a++;
            //cout << a << endl;
        }
    }
 
    if(A != now & A != 1) A_yakusu.push_back(A);
 
    vector<long long> B_yakusu;
 
    now = 0; 
    a = 2;
    while(B >= a*a){
        if(B%a == 0){
            if(a != now){
                B_yakusu.push_back(a);
                now = a;
            }
            B /= a;
            
        }else{
            a++;
        }
    }
 
    //cout << B << endl;
 
    if(B != now & B != 1) B_yakusu.push_back(B);
 
    long long ans = 0;
    if(A_yakusu.size() >= B_yakusu.size()){
        for(long long i=0;i<B_yakusu.size();i++){
            if(std::count(A_yakusu.begin(), A_yakusu.end(), B_yakusu.at(i)) == 1) ans++;
        }
    }else{
        for(long long i=0;i<A_yakusu.size();i++){
            if(std::count(B_yakusu.begin(), B_yakusu.end(), A_yakusu.at(i)) == 1) ans++;
        }
    }
 
 
    /*
    for(long long i=0;i<A_yakusu.size();i++){
        cout << A_yakusu.at(i) << endl;
    }
 
    cout << endl;
 
    for(long long i=0;i<B_yakusu.size();i++){
        cout << B_yakusu.at(i) << endl;
    }
    */
    
    
 
    ans++;
 
    cout << ans << endl;
    return 0;
 
 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static int n = 0;
    static int r = 0;
    static int c = 0;
    static int x = 0;
    static int y = 0;
    static string s = "";
    static string[] ss;
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static int[] arr;
    static char[,] map;
    static int[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static int Int(string s)
    {
        return int.Parse(s);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setarray(int num = -1)
    {
        if (n == 0)
        {
            n = Int(rl());
        }
        arr = new int[n];
        if (num == -1) ss = rls();
        for (int i = 0; i < n; i++)
        {
            if (num == -1)
                arr[i] = Int(ss[i]);
            else
                arr[i] = num;
        }
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(int def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new int[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        n = Int(rl());
        s = rl();
        if (s.Length % 2 == 0)
        {
            if (s.Substring(0, s.Length / 2) == s.Substring(s.Length / 2))
            {
                wl("Yes");
                return;
            }
        }
        wl("No");
    }
}



Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10;
int n,a[maxn],idx[maxn],idx_cnt;
struct szsz{
	int c[maxn];
	inline int lowbit(int x){
		return x&(-x);
	}
	int sum(int x){
		int res=0;
		while(x){
			res+=c[x];
			x-=lowbit(x);
		}
		return res;
	}
	void add(int x){
		while(x<=maxn-10){
			c[x]++;
			x+=lowbit(x);
		}
	}
	void clear(){
		REP(i,1,maxn-10) c[i]=0;
	}
}bit;
bool check(int x){
	ll res=0;
	int cur=1e5;
	bit.clear();
	bit.add(cur);
	REP(i,1,n){
		if(a[i]>=x) ++cur;else --cur;
		res+=bit.sum(cur);
		bit.add(cur);
	}
	return 2*res>=(ll)n*(n+1)/2;
}
int main(){
	n=read();
	REP(i,1,n) a[i]=read(),idx[++idx_cnt]=a[i];
	sort(idx+1,idx+idx_cnt+1);
	idx_cnt=unique(idx+1,idx+idx_cnt+1)-idx-1;
	REP(i,1,n) a[i]=lower_bound(idx+1,idx+idx_cnt+1,a[i])-idx;
	int L=1,R=idx_cnt;
	while(L<=R){
		int Mid=(L+R)>>1;
		if(check(Mid)) L=Mid+1;
		else R=Mid-1;
	}
	printf("%d\n",idx[L-1]);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    array<int, 2> beauty{-1, 1};
    array<int, 2> delicious{-1, 1};
    array<int, 2> popular{-1, 1};
    ll N, M;
    cin >> N >> M;
    vector<ll> bs(N), ds(N), ps(N);
    for (size_t i = 0; i < N; i++){
        cin >> bs.at(i) >> ds.at(i) >> ps.at(i);
    }
    vector<ll> values{};
    for (int b_sign: beauty){
        for (int d_sign: delicious){
            for (int p_sign: popular){
                vector<ll> eval(N);
                for (size_t i = 0; i < N; i++){
                    eval.at(i) = b_sign * bs.at(i) + d_sign * ds.at(i) + p_sign * ps.at(i);
                }
                sort(eval.begin(), eval.end(), greater<>());
                ll value{0};
                for (size_t i = 0; i < M; i++){
                    value += eval.at(i);
                }
                values.emplace_back(value);
            }
        }
    }
    sort(values.begin(), values.end(), greater<>());
    cout << *(values.begin()) << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  //cout << M << endl;*/

  //int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  unsigned long long int ans = 0;

  for (int i = 1; i < N; i++) {
    if(vec.at(i) < vec.at(i-1)){
      int tmp = vec.at(i-1) - vec.at(i);
      ans = ans+tmp;
      vec.at(i) = vec.at(i)+tmp;
    }
    /*for (int i = 0; i < vec.size()-1; i ++){
      cout << vec.at(i) << " ";
    }
    cout << vec.at(vec.size() - 1) << endl;*/
  }

  cout << ans << endl;

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 4024
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn prim(graph: &[Vec<(usize, i64)>]) -> i64 {
    let mut visited = vec![false; graph.len()];
    let mut ret = 0;
    let mut heap = BinaryHeap::new();

    heap.push((0, 0));
    while let Some((d, v)) = heap.pop() {
        if visited[v] {
            continue;
        }
        ret += -d;
        visited[v] = true;
        for &(i, dist) in graph[v].iter() {
            if !visited[i] {
                heap.push((-dist, i))
            }
        }
    }
    ret
}
fn main() {
    let n = scan!(usize);
    let mut points: Vec<(usize, (i64, i64))> = (0..n)
        .map(|i| {
            let (x, y) = scan!(i64, i64);
            (i, (x, y))
        })
        .collect();

    let mut graph: Vec<Vec<(usize, i64)>> = (0..n).map(|_| vec![]).collect();
    points.sort_by(|&(_, (x0, _)), &(_, (x1, _))| x0.cmp(&x1));
    for (&(i, (ix, _)), &(j, (jx, _))) in points.iter().zip(points[1..].iter()) {
        graph[i].push((j, jx - ix));
        graph[j].push((i, jx - ix));
    }

    points.sort_by(|&(_, (_, y0)), &(_, (_, y1))| y0.cmp(&y1));
    for (&(i, (_, iy)), &(j, (_, jy))) in points.iter().zip(points[1..].iter()) {
        graph[i].push((j, jy - iy));
        graph[j].push((i, jy - iy));
    }
    println!("{}", prim(&graph))
}


Measured memory_bytes: 20732
N = int(input())
Red = [[int(T) for T in input().split()] for TN in range(0,N)]
Red.sort(key=lambda X:X[1],reverse=True)
Blue = [[int(T) for T in input().split()] for TN in range(0,N)]
Blue.sort(key=lambda X:X[0])
Count = 0

for TB in range(0,N):
    DelInd = -1
    for TR in range(0,len(Red)):
        if Blue[TB][0]>Red[TR][0] and Blue[TB][1]>Red[TR][1]:
            DelInd = TR
            break
    if DelInd!=-1:
        del Red[DelInd]
        Count += 1
print(Count)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const LL MOD = 1e9+7;
const LL INF = 1LL<<60;
int MAXN = 1e7+2;
const double eps = 1e-13;

int p[309][309];
int last[309];
vector<int> match[309];
bool ban[309];

int main(){
	DRII(n,m);
	REP(i,n){
		REP(j,m){
			DRI(x);
			p[i][j]=x-1;
		}
	}
	int st=1,en=n;
	while(st<en){
		int mi=(st+en)/2;
		MS0(last);
		MS0(ban);
		REP(i,m)match[i].clear();
		bool legit=1;
		queue<int> q;
		REP(i,n)q.push(i);
		while(SZ(q)){
			int x=q.front();q.pop();
			while(last[x]<m&&ban[p[x][last[x]]])last[x]++;
			if(last[x]==m){legit=0;break;}
			match[p[x][last[x]]].PB(x);
			int cur=p[x][last[x]];
			if(SZ(match[cur])>mi){
				for(int i:match[cur]){
					q.push(i);
					last[i]++;
				}
				ban[cur]=1;
				match[cur].clear();
			}
		}
		/*printf("MI %d\n",mi);
		REP(i,m){
			for(int j:match[i])printf("%d ",j);puts("");
		}*/
		if(legit)en=mi;
		else st=mi+1;
	}
	printf("%d",st);
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<long> a(n + 1);
  for (int i=0; i<n+1; i++) {
    cin >> a.at(i);
  }
  vector<long> b(n);
  for (int i=0; i<n; i++) {
    cin >> b.at(i);
  }

  long ans = 0;
  for (int i=0; i<n; i++) {
    long first = min(a.at(i), b.at(i));
    ans += first;
    b.at(i) -= first;
    long second = min(a.at(i + 1), b.at(i));
    ans += second;
    a.at(i + 1) -= second; 
  }
  cout << ans << endl;
}

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

#define endl '\n'
using namespace std;
using ll = long long;

const ll MOD = 1e9+7;
string str;
ll mul;
ll dp[100005][101][2]; // dp[digit][rem][s] = # of ways, s=1 on edge, s=0 small already

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> str >> mul;
}

void add_self(ll &lhs, ll rhs)
{
    lhs += rhs;
    if(lhs >= MOD) lhs -= MOD;
}

ll pos(ll x) { return (x%mul+mul)%mul; }

void process()
{
    for(int d = 0; d < str[0]-'0'; d++) dp[0][d%mul][0] += 1;
    dp[0][(str[0]-'0')%mul][1] += 1;
    for(int i = 1; i < str.size(); i++)
    {
        // s = 0
        for(int rem = 0; rem < mul; rem++)
            for(int d = 0; d < 10; d++)
                add_self(dp[i][rem][0], dp[i-1][pos(rem-d)][0]);
        // s = 1
        for(int rem = 0; rem < mul; rem++)
            add_self(dp[i][rem][1], dp[i-1][pos(rem-(str[i]-'0'))][1]);
        // s = 1 -> s = 0
        for(int rem = 0; rem < mul; rem++)
            for(int d = 0; d < str[i]-'0'; d++)
                add_self(dp[i][rem][0], dp[i-1][pos(rem-d)][1]);
    }
    cout << (dp[str.size()-1][0][0] + dp[str.size()-1][0][1] - 1 + MOD)%MOD << endl;
}



Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a),i##_end_ = (b);i<=i##_end_;i++)
#define ROF(i,a,b) for(int i = (a),i##_end_ = (b);i>=i##_end_;i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 100005
#define INF 1000000000000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-8
#define DEBUG_
#ifdef DEBUG_
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
#else
#define DEBUG(...)
#endif // DEBUG
using namespace std;

ll x[N];
int main()
{
    ll n,a,b;
    while(cin>>n>>a>>b)
    {
        FOR(i,1,n)cin>>x[i];
        if(b<=a)cout<<b*(n-1)<<endl;
        else
        {
            ll ans = 0;
            FOR(i,1,n-1)
            {
                if(a*(x[i+1]-x[i])>b)ans+=b;
                else ans+=a*(x[i+1]-x[i]);
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
s = input()

sum = 0
for bit in range(1 << (len(s) - 1)):
    expr = s[0]
    for i in range(len(s) - 1):
        if bit & 1 << i:
            expr += '+'
        expr += s[i + 1]
    sum += eval(expr)

print(sum)


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

int main(){
	string S;
	cin >> S;
	int now = 0;
	int ans = 0;
	while (now < S.size()-1 && S.size()>0) {
		if (S[now] != S[now+1]) {
			S.erase(now,2);
			now = max(0,now-1);
			ans += 2;
		}
		else now++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    int A, B, K;
    
    cin >> A >> B >> K;
    
    int answer = 101;
    int cnt = 0;

    while(cnt < K){
        answer --;
        if(A % answer == 0 && B % answer == 0){
            cnt ++;
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;


int main(){
	int r,d,x; cin>>r>>d>>x;
	ll op = x*1ll;
	for(int i=0; i<10; i++){
		op = r*op-d; 
		cout<<op<<endl;
	}
	return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define M 1000000007
using namespace std;

int main(){
	string S;
	long long int tmp;
	cin>>S;
	vector<vector<int> >dp(13);
	for(int j=0;j<13;j++)dp[j]=vector<int>(S.size());
	for(int j=0;j<13;j++)for(int i=0;i<S.size();i++)dp[j][i]=0;
	if(S[0]=='?'){
			for(int j=0;j<10;j++){
					dp[j][0]=1;
			}
	}else{
			dp[S[0]-'0'][0]=1;
	}
	for(int i=1;i<S.size();i++){
		if(S[i]=='?'){
			for(int j=0;j<13;j++){
				for(int k=0;k<10;k++){
					tmp=dp[(j*10+k)%13][i]+dp[j][i-1];
					dp[(j*10+k)%13][i]=tmp%M;
				}
			}
		}else{
			for(int j=0;j<13;j++){
				tmp=dp[(j*10+(S[i]-'0'))%13][i]+dp[j][i-1];
				dp[(j*10+(S[i]-'0'))%13][i]=tmp%M;
			}
		}
	}
	cout<<dp[5][S.size()-1]<<endl;

	return 0;
}



Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main(){
	fast_io;
	int n,k;cin>>n>>k;
	vi h(n);

	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	vi dp(n,1e9+7);
	dp[0] = 0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=k && i-j>=0; j++){
			dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
		}
		// trace2(i,dp[i])
	} 
	cout<<dp[n-1];
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 1024