akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

//ビット探索のやり方
/*int main(){
	int n, q;
	cin >> n;
	v1 a(n);
	rep(i, n){
		cin >> a.at(i);
	}
	cin >> q;
	v1 m(q);
	rep(i, q){
		cin >> m.at(i);
	}
	for(int bit = 0; bit < (1<<n); ++bit){
		int sum = 0;
		rep(i, n){
			if(bit & (1<<i)) sum += a.at(i);
		}
		auto itr = m.begin();
		while(itr != m.end()){
			itr = find(m.begin(), m.end(), sum);
			if(itr != m.end()){
				*itr = 0;
			}
		}
	}
	rep(i, q){
		if(m.at(i) == 0){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
}*/

int N;
v1 A(0);
bool judge = false;

void check(int i, int target, int sum){
	if(i == N) return;
	if(sum > target) return;
	rep(j, 2){
		int sum1 = sum;
		if(j == 0) sum1 += A.at(i);
		if(sum1 == target){
			judge = true;
			return;
		}
		check(i+1, target, sum1);
	}
}

int main(){
	cin >> N;
	rep(i, N){
		int b;
		scanf("%d", &b);
		A.push_back(b);
	}
	int q;
	cin >> q;
	v1 m(q);
	rep(i, q){
		int a;
		scanf("%d", &a);
		check(0, a, 0);
		if(judge){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
		judge = false;
	}
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin>>x1>>y1>>x2>>y2;
  int a,b;
  a=x2-x1;
  b=y2-y1;
  x3=x2-b;
  y3=y2+a;
  x4=x1-b;
  y4=y1+a;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    lint n;
    cin >> n;
    lint a[100000];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    lint en=a[n-1];
    cout << en << ' ';
    
    lint min=INT64_MAX,mi=0;
    for(int i=0;i<n-1;i++){
        if(abs(en-a[i]*2)<min){
            min=abs(en-a[i]*2);
            mi=i;
        }
    }
    cout << a[mi] << endl;

    return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  string s, t;
  cin >> s >> t;
  rep(i, 0, t.size()) {
    cout << t[i];
  }
  rep(i, 0, s.size()) {
    cout << s[i];
  }
  cout << endl;
};


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

using ll = long long;

void solve(std::vector<long long> T, std::vector<long long> A, std::vector<long long> B){
    A[0] *= T[0];
    A[1] *= T[1];
    B[0] *= T[0];
    B[1] *= T[1];
    if(A[0] + A[1] == B[0] + B[1]){
        cout<<"infinity"<<endl;
        return;
    }
    if(A.front() < B.front()){
        swap(A, B);
    }
    if(A[0] + A[1]  > B[0] + B[1]){
        cout<<0<<endl;
        return;
    }
    ll ans = ((A[0] - B[0]) / (B[0] + B[1] - A[0] - A[1]));

    cout<<ans * 2 + (((A[0] - B[0]) % (B[0] + B[1] - A[0] - A[1])) ? 1 : 0)<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> T(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&T[i]);
    }
    std::vector<long long> A(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&B[i]);
    }
    solve(std::move(T), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mn=1e5;

int n,m,cnt,lin;
int a[mn+3];long long S[mn+3];
inline long long qsum(int l,int r) {
	return S[r]-S[l-1];
}

bool jud(int w) {
	if(a[w]+m<a[lin]) return false;//够不到第lin名。
	
	long long midc=cnt-lin-(n-w);//每轮必须给中间安排的数。
	if(midc*m+qsum(lin,w-1) > 1ll*(a[w]+m)*(w-lin))
	    return false;//溢出了。
	else return true;
}

int main() {
	cin>>n>>m>>cnt>>lin;
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+n+1,greater<int>());
	for(int i=1;i<=n;i++) S[i]=S[i-1]+a[i];
	
	int l=lin,r=n;
	while(l<r) {
		int mid=(l+r+1)/2;
		
		if(jud(mid)) l=mid;
		else r=mid-1;
	}
	cout<<r;
	return 0;
}

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

int main() {
	int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ( a + b > c + d)
    cout << "Left" << endl;
  else if ( a + b < c + d)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

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

const MOD: usize = 1_000_000_007;

fn rec(s: usize, dp: &mut Vec<usize>) -> usize {
    if s < 3 || dp[s] != 0 {
        dp[s]
    } else {
        dp[s] = (rec(s - 1, dp) + rec(s - 3, dp)) % MOD;
        dp[s]
    }
}

#[fastout]
fn main() {
    input! {
        mut s: usize,
    }
    let mut dp = vec![0; s + 1];
    dp[0] = 1;
    println!("{}", rec(s, &mut dp));
}


Measured memory_bytes: 2188
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
string s;
cin>>s;
  int count = 0;
rep0(i,2){
 if(s[i] == '1')count++; 
}
  cout<<count<<endl;
return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll m[105][105];
ll d[105];
ll n;


void bfs(ll s){
    queue<ll> q;
    q.push(s);
    rep(i,n){
        d[i]=INF;
    }
    d[s]=0;
    while(!q.empty()){
        ll u=q.front();
        q.pop();
        rep(v,n){
            if(m[u][v]==0) continue;
            if(d[v]!=INF) continue;
            d[v]=d[u]+1;
            q.push(v);
        }
    }
    rep(u,n){
        cout << u+1 << " " << (d[u]==INF?-1:d[u]) << endl;
    }
}

int main()
{
    cin >> n;
    rep(u,n){
        rep(v,n){
            m[u][v]=0;
        }
    }
    ll u,k,v;
    rep(i,n){
        cin >> u >> k;
        u--;
        rep(j,k){
            cin >> v;
            v--;
            m[u][v]=1;
        }
    }
    bfs(0);
    return 0;
} 


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
  	int n,i,j,k;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(j=1;j<n-1;++j)
    {
        char ch[4000]={'0'};
        int cr=0,cb=0,cg=0;
        for(i=0;i<j;++i)
        {
            if(s[j]!=s[i])
            {
                if(s[i]=='R')
                    cr++;
                else if(s[i]=='B')
                    cb++;
                else
                    cg++;
                ch[j-i]=s[i];
            }
        }
        for(k=j+1;k<n;++k)
        {
            if(s[j]!=s[k])
            {
                if(s[k]=='B')
                {
                    if(ch[k-j]!='R' && ch[k-j]!='G')
                        ans+=cr+cg;
                    else
                        ans+=cr+cg-1;
                }
                else if(s[k]=='R')
                {
                    if(ch[k-j]!='B' && ch[k-j]!='G')
                        ans+=cb+cg;
                    else
                        ans+=cb+cg-1;
                }
                else if(s[k]=='G')
                {
                    if(ch[k-j]!='B' && ch[k-j]!='R')
                        ans+=cr+cb;
                    else
                        ans+=cr+cb-1;
                }
            }
        }
    }
    cout<<ans;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k;
const ll big = 1000000007;
const ll big2 = 998244353;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,e;

    cin >> n >> m >> k;
    if(m > n || k > n){
        cout << 0 << "\n";
        return 0;
    }
    cout << (n-m+1) * (n-k+1) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int N;
	int max1 = 0;
	int now = 0;
	int cnt = 0;
	cin >> N;
	vector<int> s;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		s.push_back(a);
	}
	now = s[0];
	for (int i = 0; i < N - 1; i++) {
		if (now >= s[i + 1]) {
			cnt++;
			now = s[i + 1];
		}
		else {
			max1 = max(max1, cnt);
			cnt = 0;
			now = s[i + 1];
		}
	}
	cout << max(max1, cnt);
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll int64_t
#define ull uint64_t
using namespace std;


int main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
  #endif
  int test;
  cin>>test;
  if(test<30)
  	cout<<"No";
  else
  	cout<<"Yes";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;


int main() {
	int N, p;
	cin >> N;
	map<int, int>U;
	priority_queue<long long>ans;
	long long po = 0;
	for (size_t i = 0; i < N; i++)
	{
		cin >> p;
		U[p]++;
		if (U.at(p) == 2) { ans.push(p);}
		if (U.at(p) == 4 && ans.top() == p)po = (long long)p *(long long) p;
	}
	if (ans.size() < 2) {
		cout << po;
		return 0;
	}
	long long answer = ans.top();
	ans.pop();
	answer *= ans.top();
	cout << max(answer,po);
}

Measured memory_bytes: 4992
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int a,b,c;
  cin >> a >> b >>c;

  if(a==b+c || b==a+c || c==a+b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n, m;
	int A[101][101];
	int B[101];
	int C[101];
	
	cin >> n >> m;
	
	for(int i = 1;i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> A[i][j];
		}
	}
	
	for(int i = 1; i <= m; i++){
		cin >> B[i];
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			C[i] += A[i][j] * B[j];
		}
		cout << C[i] <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <string>
using namespace std;
#define S string
S f(S s,S x,S y){
	while (true){
		S::size_type p = s.find(x);
		if (p == S::npos) break;
		s.replace(p, x.size(), y);
	}
	return s;
}
int main(void){
	S s,a="apple",b="peach",x="X";
	getline(cin,s);
	s=f(s,a,x);
	s=f(s,b,a);
	s=f(s,x,b);
	cout<<s<<endl;
} 

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll a, b, c, k; cin >> a >> b >> c >> k;

	ll x = a - b;
	ll ans = 0;

	if (k % 2 == 0) {
		ans = x;
	}
	else {
		ans = -1 * x;
	}
	if (abs(ans) > pow(10, 18)) {
		cout << "unfair" << endl;
	}
	else {
		cout << ans << endl;
	}

	/*ll test = 0;
	test = pow(10, 18);
	cout << test << endl;
	*/
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
char s[2000100];
  int i=0;
  while(1){
	 	scanf("%c",&s[i]);
    	if(s[i]=='\0')return 0;
        if(s[i]=='?')printf("D");
    	else printf("%c",s[i]);
    	i++;
  }
  return 0;
}

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

int main(){
  int r, D, x2000, tmpr;
  cin >> r >> D >> x2000;
  
  tmpr = x2000;
  for(int i = 0; i < 10; i++){
     tmpr = (r * tmpr) - D;
     cout << tmpr << endl;
  }
}

Measured memory_bytes: 256
def gcd(a,b):
	if a%b==0:return b
	else:return gcd(b,a%b)
INF=10**9
ans=INF
n,X=map(int,input().split())
x=list(map(int,input().split()))
if n==1:
	print(abs(X-x[0]))
else:
	for i in range(n-1):
		tmp=gcd(abs(X-x[i]),abs(X-x[i+1]))
		ans=min(ans,tmp)
	print(ans)


Measured memory_bytes: 14480
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a , b;
	cin>>a>>b;
	if( a > 0 && a < 10 && b > 0 && b < 10) 
		cout<<a*b<<endl;
	else
		cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void makegraph(int x,vector<vec> &v){rep(i,x-1){int a=in(),b=in();v[a].pb(b);v[b].pb(a);}}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 255050

ll n,m,k;
ll a[N];
template<typename T>
struct BIT{
    vector<T> data;

    BIT(int size){
        data.assign(++size,0);
    }
    T sum(int k){
        T ret=0;
        for(++k;k>0;k-=k&-k) ret+=data[k];
        return (ret);
    }
    void add(int k,T x){
        for(++k;k<data.size();k+=k&-k)data[k]+=x;
    }
};
int mem[N];
main(){
    string s;
    cin>>s;
    n=s.size();
    vector<vector<ll>> v(26);
    vector<ll> t;
    rep(i,n){
        v[(ll)(s[i]-'a')].pb(i);
        t.pb((ll)(s[i]-'a'));
    }
    ll res=0;
    rep(i,26){
        res+=v[i].size()%2;
    }
    if(res>1){cout<<-1;return 0;}
    vector<ll> now(26,0);
    vector<ll> pre,suf,prenum;
    rep(i,n){
        if((v[t[i]].size())/2<=now[t[i]]){
            continue;
        }
        pre.pb(v[t[i]][now[t[i]]++]);
        prenum.pb(t[i]);
    }
    if(res){
        rep(i,26){
            if(v[i].size()%2)now[i]++;
        }
    }
    rep2(i,1,pre.size()){
        ll p=prenum[pre.size()-i];
        suf.pb(v[p][now[p]++]);
    }
    BIT<ll> BIT(n+1);
    ll ans=0;
    rep(i,pre.size()){
        ans+=BIT.sum(pre[i]);
        BIT.add(pre[i],1);
    }
    if(res){
        ll q;
        rep(i,26)if(v[i].size()%2){q=i;break;}
        ll num=v[q][(v[q].size()-1)/2];
        ans+=BIT.sum(num);
        BIT.add(num,1);
    }
    rep(i,suf.size()){
        ans+=BIT.sum(suf[i]);;
        BIT.add(suf[i],1);
    }
    cout<<(n*(n-1)/2-ans);
}

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

int main() {
  int A, B;
  int i1, i2, i3;
  int s1, s12;
  int i=0;
  cin >> A >> B;
  for (i1=1; i1<10; i1++) {
    s1=i1*10001;
//    cout <<s1 <<"+9990<?" <<A <<endl;/////////
    if (s1+9990<A) continue;
//    if (s1+9990<A) { cout <<s1 <<"+9990<" <<A <<endl; continue;}
//    cout << s1 << '>?' << B << endl;////////
    if (s1>B) break;
//    if (s1>B) { cout << s1 << '>' << B << endl; break; }////////
    for (i2=0; i2<10; i2++) {
      s12=s1+i2*1010;
      if (s12+900<A) continue;
      if (s12>B) continue;
      for (i3=0; i3<1000; i3+=100) {
        if ((s12+i3>=A) && (s12+i3<=B)) i++;
//        cout << s12+i3 << ' ' << i << endl;//////////////
      }
    }
  }
  cout <<i <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#define l(s) s.length()
#define sort(v) sort(v.begin(), v.end());
#define scan(v,n) rep(i,0,n) {ll k; cin >> k; v.pb(k);}
#define print(v,n) {rep(i,0,n) cout << v[i] << " "; cout << endl;}
#define printstr(s,n) {rep(i,0,n) cout << s[i]; cout << endl;}
#define rev(a) reverse(a.begin(), a.end());
#define pb push_back
typedef long long ll;
typedef long double lld;
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
 
const ll mxN=3e3;
const ll N=1e9+7;
 
ll dp[mxN+1][mxN+1];

//deque
//assume that we start the game with the array from index l to r. 
// then, dp[l][r] is the max possible difference bw the scores of the player who goes first and the one who goes second
//obviously, for a single element array, the diff is the element itself
// we want dp[0][l-1]
// why reverse loop for variable l and forward loop for r though? BECAUSE THE DP EXPRESSION USES L+1 AND R-1
//TO DETERMINE DP[L][R],
// SO NATURALLY YOU NEED INFO ABOUT L+1 BEFORE L AND INFO ABOUT R-1 BEFORE R!!!


  int main() {
      int T=1;// cin >> T;
      while(T--){
          ll n; cin >> n;
          vi v; scan(v,n);
          rep(i,0,n) dp[i][i]=v[i];
          rrep(l,n-2,0) {
              rep(r,l+1,n) {
                  dp[l][r]=(v[l]-dp[l+1][r]>v[r]-dp[l][r-1]?v[l]-dp[l+1][r]:v[r]-dp[l][r-1]);
              }
          }
          cout << dp[0][n-1];
      } 
	 return 0;
}


Measured memory_bytes: 49796
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;


typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;

//部屋の移動
//k回後の組み合わせ
//移動は1回何人でも移動して良いただし、隣にしか移動できない


//xHy x種類のものから重複を許してy個選ぶ(重複組合せ)
//xHy = (x+y-1)C(x-1)
const int MAX = 210000;

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


int main()
{
    int n, k;
    cin >> n >> k;
    //k回で移動できるのは、
    //距離がk以下のところまで
    //0人の部屋やk個以下となる

    //m = 0,1,2,3,4,5

    //nCm ×(n−m)Hm
    //ci = 0がmとなるような数列の数
    //xHy = (x+y-1)C(x-1)

    //m = 0,1,2,...n-1

    COMinit();
    ll res = 0;
    for(int m = 0; m <= min(n-1, k); ++m)
    {
        ll tmp;
        tmp = COM(n,m) * COM(n - m + m - 1, n-m-1);
        res += tmp;
        res %= MOD;
    }

    cout << res << endl;
    return 0;
}

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

int main()
{
    cin>>st;
    if(st=="Sunny")cout<<"Cloudy"<<endl;
    else if(st=="Cloudy")cout<<"Rainy"<<endl;
    else if(st=="Rainy")cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";

const main = arg => {
	const arr = arg.trim().split(' ');
  	for (let i = 0; i < arr.length; i++) {
      if(arr[i] == 0) {
        console.log(i+1);
      }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 29524
#include <iostream>
using namespace std;
const int MAX = 500;

int main() {
	int n, m, Q;
	cin >> n >> m >> Q;
	int S[MAX+1][MAX+1] = {};
	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		S[l][r]++;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			S[i][j] += S[i][j-1];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			S[i][j] += S[i-1][j];
		}
	}
	auto sum_rect = [&](int x0, int y0, int x1, int y1) {
		return S[x1][y1] - S[x0-1][y1] - S[x1][y0-1] + S[x0-1][y0-1];
	};
	for (int query = 0; query < Q; query++) {
		int p, q;
		cin >> p >> q;
		int ans = sum_rect(p, p, q, q);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4616
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main() {
  fast();
  cin >> n >> m >> t;
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    int s = 0;
    for (auto c : to_string(i)) s += (c - '0');
    if (s >= m and s <= t) ans += i;
  }
  cout << ans;

  return 0;
}



Measured memory_bytes: 3720
#include <iostream>]
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;



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


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N,M;
	int A[25][25];
	int B[25];
	int C;
	
	cin >> N >> M >> C;
	for(int i=0;i<M;i++)
		cin >> B[i];
	for(int i=0;i<N;i++)
		for(int j=0;j<M;j++)
			cin >> A[i][j];
	
	int ans=0;
	for(int i=0;i<N;i++)
	{
		int tmp=0;
		for(int j=0;j<M;j++)
			tmp+=A[i][j]*B[j];
		tmp+=C;
		if(tmp>0)
			ans++;
	}
	
	cout << ans << endl;
	return 0;
}



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

int main() {
  int N, profit = 0;
  vector<int> V(60), C(60);
  cin >> N;

  for (int i = 0; i < N; i++){
    cin >> V.at(i);
  }
  for (int i = 0; i < N; i++){
    cin >> C.at(i);
  }

  for(int j = 0; j < N; j++){
    if(V.at(j) > C.at(j)){
      profit += V.at(j) - C.at(j);
    }
  }

  cout << profit << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAX=2e5+5;
int n;
int a[MAX];
ll he,he1,he2;
ll an=(ll)1e19;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        he+=a[i];
    }
    for (int i=1;i<n;i++)
    {
        he1+=a[i];
        an=min(an,abs(2LL*he1-he));
    }
    printf("%lld\n",an);
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll h, w;
  cin >> h >> w;
  char c[h][w];
  REP(i, h){
    REP(j, w)
      cin >> c[i][j];
  }

  REP(i, 2*h){
    REP(j, w)
      cout << c[i/2][j];
    cout << endl;
  }

}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var strs = Console.ReadLine().Split();
            var N = int.Parse(strs[0]);
            var K = int.Parse(strs[1]);

            Console.WriteLine(N % K == 0 ? "0" : "1");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int a[100010] = {0};
int dp[100010] = {0};

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    a[x] = 1;
  }
  for (int i = 1; i <= n - 1; i++) {
    if (a[i] == 1 && a[i + 1] == 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  dp[0] = 1;
  if (a[1] == 0) {
    dp[1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] == 0 && a[i - 2] == 0) {
      dp[i] = dp[i - 1] + dp[i - 2];
      dp[i] %= 1000000007;
    }
    else if (a[i - 1] == 0 && a[i - 2] == 1) {
      dp[i] = dp[i - 1];
      dp[i] %= 1000000007;
    }
    else if (a[i - 1] == 1 && a[i - 2] == 0) {
      dp[i] = dp[i - 2];
      dp[i] %= 1000000007;
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1024
//    ŦĦ€Ř€'Ş ŇØŦĦƗŇǤ ĦØŁĐƗ'Ň Μ€ βΔĆҜ ΔŁŴΔ¥Ş ΔŇĐ ₣ØŘ€V€Ř 😈🤩😇😈💪🤜👊🤛🤟😉🤩:

#include<bits/stdc++.h>

#define mod 1000003
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define B(a) a.begin()
#define E(a) a.end()
#define For(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define M_P make_pair
#define P_B push_back
#define endd "\n"

using namespace std;

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

    ll n,cnt=0;cin>>n;
    vll a(n);

    For(i,0,n)
    cin>>a[i];

    For(i,1,n)
    {
        if(a[i-1]>a[i])
            {
                cnt=cnt+abs(a[i-1]-a[i]);
                a[i]=a[i]+abs(a[i-1]-a[i]);


            }

    }

    cout<<cnt;



    return 0;
}


Measured memory_bytes: 4772
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
N=int(input())
dankai=[1]*50
for i in range(1,50):
    dankai[i]=dankai[i-1]+i+1

c = list(Counter(prime_factorize(N)).values())

ans=0
for v in c:
    i=0
    while v>=dankai[i]:
        i+=1
    ans+=i
print(ans)

Measured memory_bytes: 10424
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut ans = 0;
    let mut maxv = 0;
    for i in 0..a.len() {
        let ai = a[i];
        ans += max(0, maxv - ai);
        maxv = max(maxv, ai);
    }
    println!("{}", ans);
}


Measured memory_bytes: 5648
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a[2][3];
  bool f=0;
  while(cin>>a[0][0]>>a[0][1]>>a[0][2]>>a[1][0]>>a[1][1]>>a[1][2]){
    if(a[0][0]==0)
      for(int i=0;i<3;i++)swap(a[0][i],a[1][i]),f=1;
    for(int i=0;i<2;i++){
      for(int j=i+1;j<3;j++)
	a[i][j]/=a[i][i];
      a[i][i]=1;
      for(int j=0;j<2;j++){
	if(j==i)continue;
	double t=a[j][i];
	for(int k=i;k<3;k++)
	  a[j][k]-=t*a[i][k];
      }
    }
    printf("%.3f %.3f\n",a[0][2],a[1][2]);
  }
  return 0;
}

Measured memory_bytes: 1236
r,c = map(int,input().split())
a = []

for i in range(r):
 a.append(list(map(int,input().split())))
 a[i].append(sum(a[i]))

b = []
for j in range(c+1):
 s = 0
 for i in range(r):
   s += a[i][j]
 b.append(s)

a.append(b)

for i in range(r+1):
    print(" ".join(list(map(str, a[i]))))



Measured memory_bytes: 5704
from collections import deque, Counter
n, x, y = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(n-1):
    G[i].append(i+1)
    G[i+1].append(i)
G[x-1].append(y-1)
G[y-1].append(x-1)
c = Counter()
for i in range(n):
    q = deque([i])
    dist = [-1]*n
    dist[i] = 0
    while q:
        cur = q.popleft()
        for nx in G[cur]:
            if dist[nx] != -1:
                continue
            dist[nx] = dist[cur]+1
            q.append(nx)
    for j, d in enumerate(dist):
        if i == j:
            continue
        c[d] += 1
for i in range(1, n):
    print(c[i]//2)


Measured memory_bytes: 76540
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int len = str.length();
  int cs[4];

  memset(cs, 0, sizeof(cs));
  
  for (int i = 0; i < len; i++)
    for (int j = 0; j < 4; j++)
      if (str[i] == "KUPC"[j]) {
	cs[j]++;
	break;
      }

  int minc = 1 << 30;
  for (int j = 0; j < 4; j++)
    if (minc > cs[j]) minc = cs[j];

  cout << minc << endl;
  
  return 0;
}

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

class Program {
    static void Main (string[] args) {
        int n = int.Parse(Console.ReadLine());
        string[] nm = Console.ReadLine().Split(' ');

        long[] a = new long[n];
        
        for(int i = 0;i<n;i++){
            a[i] = long.Parse(nm[i]);
        }
        int cnt = 0;
        int ans = 0;

        for(int i = 0;i<n-1;i++){
            if(a[i] >= a[i+1]){
                cnt++;
            }else{
                ans = System.Math.Max(cnt,ans);
                cnt = 0;
            }
        }
        
        ans = System.Math.Max(cnt,ans);
        Console.WriteLine(ans);

    }
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e3) + 17;

int n;
ll a[MAXN], S[MAXN];
bool used[MAXN][MAXN];
ll dp[MAXN][MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i + 1];

    return true;
}

void dfs(int l, int r) {
    if (used[l][r])
        return ;

    used[l][r] = true;

    if (l == r) {
        dp[l][r] = 0;
        return ;
    }

    dp[l][r] = INF * INF;

    for (int m = l; m < r; ++m) {
        dfs(l, m);
        dfs(m + 1, r);
        dp[l][r] = min(dp[l][r], S[r] - S[l - 1] + dp[l][m] + dp[m + 1][r]);
    }
}

void solve() {
    for (int i = 1; i <= n; ++i)
        S[i] = S[i - 1] + a[i];

    dfs(1, n);
    cout << dp[1][n] << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



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

int main(){
  int N, K, Q; cin >> N >> K >> Q;
  
  vector<int> ans(N);
  
  for(int i=0; i<Q; i++){
    int ans_n; cin >> ans_n; ans_n--;
    ans.at(ans_n)++;  
  }
  
  int number = 0;
  for(int i=0; i<N; i++){
    if(K-Q+ans.at(i) > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
    vector<int> vec(5);
    for(int i=0;i<5;i++){
        cin>>vec[i];
        if(vec[i] == 0){
            cout<<i+1;
            break;
        }
    }
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());

  int a = d[n / 2 - 1];
  int b = d[n / 2];
  int ans = b - a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>

#define BUFSIZE 512 //my define
#define N_MAX 10 //max value of selected cards
#define PERM_MAX 5040 //10P4


void RmOverlappingCards(char buffer[BUFSIZE], int *no){
  int i;
  int flag=0;
  int figure[PERM_MAX];

  figure[*no] = atoi(buffer);

  for(i=0; i<*no; i++){
	if((figure[*no]-figure[i]) == 0){
	  flag = 1;
	  break;
	}
  }

  if(flag>0){
	flag=0;
  }else{
	(*no)++;
  }

}


int LineUp(int n, int k, int a[N_MAX+1]){
  int b1, b2, b3, b4;
  int i,j,l,m;
  char buffer[BUFSIZE];
  int figure[PERM_MAX]={0};
  int no=0;

  for(i=0; i<n; i++){ //lining up 2 cards
	b1=a[i];
	for(j=0; j<n; j++){
	  while(1){
		if(j==i){
		  j++;
		}else{
		  b2=a[j];
		  break;
		}
	  }
	  if(b1>0 && b2>0 && k==2){
		sprintf(buffer,"%d%d", b1,b2);
		RmOverlappingCards(buffer, &no);
	  }
	  if(k>=3){ //lining up 3 cards
		for(l=0; l<n; l++){
		  while(1){
			if(l==i || l==j){
			  l++;
			}else{
			  b3=a[l];
			  break;
			}
		  }
		  if(b1>0 && b2>0 && b3>0 && k==3){
			sprintf(buffer,"%d%d%d",b1,b2,b3);
			RmOverlappingCards(buffer, &no);
		  }
		  if(k>=4){ //lining up 4 cards
			for(m=0; m<n; m++){
			  while(1){
				if(m==i || m==j || m==l){
				  m++;
				}else{
				  b4=a[m];
				  break;
				}
			  }
			  if(b1>0 && b2>0 && b3>0 && b4>0){
				sprintf(buffer,"%d%d%d%d",b1,b2,b3,b4);
				RmOverlappingCards(buffer, &no);
			  }
			}
		  }//End of lining up 4 cards
		}
	  }//End of lining up 3 cards
	}
  }//End of lining up 2 cards

  return no;

}


int main(void){
  int n, k;
  int a[N_MAX+1];
  int i;

  while(1){

	for(i=0; i<N_MAX+1; i++){
	  a[i]=-1;
	}

	scanf("%d", &n);
	scanf("%d", &k);

	if(n==0 && k==0){
	  return 0;
	}
	for(i=0; i<n; i++){
	  scanf("%d", &a[i]);
	}

	printf("%d\n", LineUp(n, k, a));
  }

  return 0;

}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	ll x;
	cin>>x;
	if(x>105*1000000){
		cout << "0";
		return 0;
	}
	ll sum1=x%100;
	ll sum2=x/100;
	if(sum1<=sum2*5){
		cout <<"1";
	}
	else {
		cout << "0";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc161/tasks/abc161_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> v(N);
    for (auto &x : v) {
        cin >> x;
    }
    // 降順
    sort(ALLR(v));
    int sum = accumulate(ALL(v), 0LL);
    double avg = (double)sum / M / 4;
    bool flag = true;
    REP(i, M) {
        if (v[i] < avg) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
"""
左から 1,2,3 .. とどこまで並べられるか調べる
while で探索して行き，できなくなったら終わり
全体数(N)　- 残った数 = 砕いた数になる
N .. レンガの個数
a .. レンガに書かれている数
position .. 現在探している数
ans .. ここまでは整数揃ったよっていう値 (最終的にN- ans で答え出す)
"""

N = int(input())
a = list(map(int,input().split()))
position = 0
ans = 0
while True:
  if position >= N:#終了条件
    print(-1) if ans == 0 else print(N-ans)
    break
  for i in range(position,N):
    if a[i] == ans + 1:
      #position += 1
      position = i
      ans += 1
      break
  else: #終了    
    position = N

Measured memory_bytes: 26140
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, M;
	cin >> N;
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		int D;
		cin >> D;
		mp[D]++;
	}
	cin >> M;
	bool out = false;
	for (int i = 0; i < M; i++) {
		int T;
		cin >> T;
		if (mp[T] <= 0) out = true;
		mp[T]--;
	}
	if (!out)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cmath>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) (v).erase( unique(all(v), (v).end() );
#define SZ(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return true;}return false;}

const char newl = '\n';

ll qp(ll a,ull b){ll ans=1;do{if(b&1u)ans*=a;a*=a;}while(b>>=1u);return ans;}
ll qp(ll a,ull b,ll mod){ll ans=1;do{if(b&1u)ans=ans*a%mod;a=a*a%mod;}while(b>>=1u);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


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

    if (n >= 30) {
        cout << "Yes" << newl;
    } else {
        cout << "No" << newl;
    }

    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

void solve(){

	string s;
	cin>>s;
	ll ans1=0,ans2=0;
	for(int i=0;i<s.length();i++)
		if((s[i]-'0')%2==i%2)
			ans1++;
		else 
			ans2++;
	cout<<min(ans1,ans2)<<"\n";



}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N,M;cin>>N>>M;
  if(N>=(M/2)){
    cout<<(M/2)<<endl;
    return 0;
  }else{
    int ans=N;
    int temp=M-2*N;
    ans+=temp/4;
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string A, B, C;
	
	cin >> A >> B >> C;
	
	char ans[4];
	
	ans[0] = toupper(A[0]);
	ans[1] = toupper(B[0]);
	ans[2] = toupper(C[0]);
	ans[3] = '\0';
	
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2 5
1 WA
2 AC
1 WA
2 AC
1 WA
---+/
/+---test
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
---+/
/+---test
100000 3
7777 AC
7777 AC
7777 AC
---+/
/+---test
6 0
---+/

void main(string[] args) {
  long N, M;
  readf(" %d %d ", &N, &M);

  auto pen = new long[](N);
  auto ac  = new bool[](N);

  foreach (i; 0..M) {
    const x = readln.split.array;
    long p = x[0].to!long;
    string s = x[1].to!string;
    --p;

    if (!ac[p] && s == "WA") {
      ++pen[p];
    } else {
      ac[p] = ac[p] || (s == "AC");
    }
  }
  "%d %d".writefln(ac.count(true), zip(ac, pen).filter!(x => x[0]).map!(x => x[1]).sum);
}


Measured memory_bytes: 4092
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<numeric>
#include<functional>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg




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

	int ans = t.size();

	for (int i = 0; i <= s.size() - t.size();i++) {
		int diff=0;
		for (int j = 0; j < t.size();j++) {
			if (t[j] != s[i + j]) {
				diff++;
			}
		}
		ans = min(ans, diff);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3600