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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define loop(i, n) for(int i = 0 ; i < n ; ++i)
#define LOOP(i, a, b) for(int i = a ; i < b ; ++i)
#define max3(a, b, c) max(a, max(b,c))
#define max4(a, b, c, d) max3(a, b, max(c, d))
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18
#define inf 1e9
#define MOD 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const ll M = 1e9+7;
ll add(ll a, ll b){return (a % M + b % M) % M;}
ll mul(ll a, ll b){return (a % M * b % M) % M;}

int n, d[100005];
vvi e;
ll dp[100005][2];

ll color(int i, int p, int l)
{
	ll &ans = dp[i][l];
	if(ans != -1LL) return ans;
	ans = 1;
	for(auto it : e[i])
	{
		if(it == p) continue;
		if(l)
		{
			ans *= color(it, i, 0), ans %= M;
		}
		else
		{
			ans *= color(it, i, 0) + color(it, i, 1), ans %= M;
		}
	}
	return ans;
}
int main() {
	_69e27;
	memset(dp, -1LL, sizeof(dp));
	cin >> n;
	e.resize(n+5);
	loop(i, n-1)
	{
		int in1, in2;
		cin >> in1 >> in2;
		e[in1].pb(in2);
		e[in2].pb(in1);
	}
	ll ans = (color(1, 0, 0) + color(1, 0, 1))%M;
	cout << ans;
	return 0;
}

Measured memory_bytes: 17024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N;
    cin >> N;
    N = -N;
    while (N < 0) N += 1000;
    cout << N << endl;

    return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void solve() {
  int l, r;
  cin >> l >> r;
  if(r - l <= 5000) {
    ll ret = 5050;
    for(int x = l; x <= r; x++) {
      for(ll y = x+1; y <= r; y++) {
        ret = min(ret, (x*y)%2019);
      }
    }
    cout << ret << "\n";
  }
  else {
    cout << "0\n";
  }
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define LL long long
using namespace std;

LL n,a,b,ans;

int main()
{
    scanf("%lld %lld %lld",&n,&a,&b);
    ans=(b-a)*(n-2)+1;
    if(ans<0)puts("0");
    else printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
MOD = 998244353
fact = [1] * 300001
ifact = [1] * 300001

for i in range(1, 300001):
    fact[i] = (fact[i-1] * i) % MOD
    ifact[i] = pow(fact[i], MOD-2, MOD)

def nCk(n, k):
    if k < 0 or k > n: return 0
    return (fact[n] * ifact[n-k] * ifact[k]) % MOD

N, A, B, K = map(int, raw_input().split())
ab = []
max_a = K // A
max_a = min(max_a, N)
for i in range(max_a+1):
  if ((K-A*i) % B) == 0:
    j = (K-A*i) / B
    if j > N:
      continue
    ab.append([i, j])

total = 0
for a, b in ab:
  total += nCk(N, a) * nCk(N, b)
print(total % MOD)


Measured memory_bytes: 61916
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next().toUpperCase();
        String b = sc.next().toUpperCase();
        String c = sc.next().toUpperCase();

        System.out.println(a.charAt(0)+""+b.charAt(0)+""+c.charAt(0));


    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<utility>
#define ll long long
/*#define fr first
#define sd second*/

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x) {
        data =x;
        left=NULL;
        right=NULL;
    }
};

#define Node struct Node

int dp[100005][3];
int pro(int a[][3], int i, int s)
{
    if(i==-1)
        return 0;
    if(dp[i][s]!=-1)
        return dp[i][s];
    if(s==0)
    {
        return dp[i][s]=max(a[i][1]+pro(a,i-1,1),a[i][2]+pro(a,i-1,2));
    }
    if(s==1)
    {
        return dp[i][s]=max(a[i][0]+pro(a,i-1,0),a[i][2]+pro(a,i-1,2));
    }
    if(s==2)
    {
        return dp[i][s]=max(a[i][1]+pro(a,i-1,1),a[i][0]+pro(a,i-1,0));
    }
}

int main()
{
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n][3];
        for(int i=0;i<n;i++)
        {
            cin>>a[i][0];
            cin>>a[i][1];
            cin>>a[i][2];
        }
        memset(dp,-1,sizeof(dp));
        cout<<max(a[n-1][0]+pro(a,n-2,0),max(a[n-1][1]+pro(a,n-2,1),a[n-1][2]+pro(a,n-2,2)))<<endl;
    }
}











Measured memory_bytes: 12188
#include<iostream>

using namespace std;

struct classP{
	string name;
	int gozen;
	int gogo;
	int sp;
	int price;
};

int main(){
	 
	classP A[9] = {};
	
	for(int i=0;i<9;i++) {
		
		cin >> A[i].name >> A[i].gozen >> A[i].gogo;
		
		A[i].sp = A[i].gozen + A[i].gogo;
		A[i].price = A[i].gozen * 200 + A[i].gogo * 300;
			
	} 
	for(int i=0;i<9;i++)
	cout << A[i].name << " " << A[i].sp << " "
		 << A[i].price << "\n";
	
		
  	return 0;
}


Measured memory_bytes: 3020
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const ll MOD = 1000000000007;
const int MAX = 60;

ll C[MAX][MAX];

void com(){
    C[0][0]=1;
    for(int i=1;i<51;i++){
        for(int j=0;j<i+1;j++){
            if(j==0||j==i) C[i][j]=1;
            else{
                C[i][j]=C[i-1][j-1]+C[i-1][j];
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,cnt,x;
    cin>>n>>a>>b;
    vector<ll> v(n);
    double ans;
    ll res=0;
    rep(i,n) cin>>v[i];
    sort(all(v));
    for(int i=n-1;i>=n-a;i--){
        ans+=(double)v[i];
    }
    ans/=a;
    cnt=(int)(upper_bound(all(v),v[n-a])-lower_bound(all(v),v[n-a]));
    x=(int)(upper_bound(all(v),v[n-a])-v.begin()-(n-a));
    // cout<<cnt<<" "<<x<<endl;
    com();
    // cout<<C[2][1]<<" "<<C[3][1]<<endl;
    if(upper_bound(all(v),v[n-a])==v.end()){
        for(int i=a;i<b+1;i++){
            res+=C[cnt][i];
        }
    }
    else if(cnt>x){
        res=C[cnt][x];
    }
    else res=1;
    cout<<fixed<<setprecision(6)<<ans<<endl;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
/*+lmake
 * STD = c++14
 * DEFINE += MDEBUG
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#ifdef DEBUG
#define debug(args...)            {dbg,args; cerr<<endl;}
#else
#define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
	template<typename T> debugger& operator , (const T& v)
	{
		cerr<<v<<" ";
		return *this;
	}
} dbg;
#define MAXM 100
int p[MAXM+10];
void solve(long long N, long long M, vector<long long> A){
	if (M==1) {
		if (N==1) {
			cout<<"1\n1\n1\n";
			return;
		}
		printf("%lld\n2\n%lld 1\n",A[0],A[0]-1);
		return;
	}
	int cnt=0;
	for(int i=0; i<M; ++i) {
		if (A[i]%2!=0) {
			p[++cnt]=i;
		}
	}
	if (cnt>2) {
		puts("Impossible");
		return;
	}
	if (cnt==1) {
		swap(A[0],A[p[1]]);
	} else if (cnt==2) {
		if (p[1]!=0) {
			swap(A[p[1]],A[M-1]);
			swap(A[p[2]],A[0]);
		} else if (p[2]!=0) {
			swap(A[p[2]],A[M-1]);
			swap(A[p[1]],A[0]);
		}
	}
	for(int i=0; i<M; ++i) {
		cout<<A[i]<<' ';
	}
	cout<<endl;
	if (A[0]>1) {
		cout<<M<<'\n'<<A[0]-1<<' ';
	} else {
		cout<<M-1<<'\n';
	}
	for(int i=1; i<M-1; ++i) {
		cout<<A[i]<<' ';
	}
	cout<<A[M-1]+1;
	cout<<endl;
}

int main(){
	long long N;
	long long M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> A(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, M, A);
	return 0;
}



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

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s=="SUN")
    {
        cout << "7\n";
    }
    else if(s=="MON")
    {
        cout << "6\n";
    }
    else if(s=="TUE")
    {
        cout << "5\n";
    }
    else if(s=="WED")
    {
        cout << "4\n";
    }
    else if(s=="THU")
    {
        cout << "3\n";
    }
    else if(s=="FRI")
    {
        cout << "2\n";
    }
    else if(s=="SAT")
    {
        cout << "1\n";
    }

    return 0;
}


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

using namespace std;

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

  int N; cin >> N;

  vector<char> ans(2*N, 0);

  bool fin = false;
  auto request_range = [&](int f) {
    cout << "? ";
    for (int i = f; i < f+N; i++)
      cout << i+1 << " ";
    cout << endl;

    string s; cin>>s;
    if (s == "-1")
      fin = true;
    return s == "Red";
  };
  int l = 0, r = N;
  auto lr = request_range(l);
  if (fin)
    return 0;
  while (r - l > 1) {
    auto c = (l+r)/2;
    auto cr = request_range(c);
    if (fin)
      return 0;
    if (cr == lr)
      l = c;
    else
      r = c;
  }

  auto t1 = l, t2 = r+N-1;
  ans[t1] = lr ? 'R' : 'B';
  ans[t2] = lr ? 'B' : 'R';

  for (size_t i = 0; i < 2*N; i++) {
    if (i == t1 or i == t2)
      continue;
    cout << "? ";
    if (i > t1 and i < t2) {
      for (int j = 0; j < t1; j++)
        cout << j+1 << " ";
      cout << i+1 << " ";
      for (int j = t2+1; j < 2*N; j++)
        cout << j+1 << " ";
    } else {
      if (i < t1)
        cout << i+1 << " ";
      for (int j = t1+1; j < t2; j++)
        cout << j+1 << " ";
      if (i > t2)
        cout << i+1 << " ";
    }
    cout << endl;

    string s; cin>>s;
    if (s == "-1")
      return 0;
    ans[i] = s == "Red" ? 'R' : 'B';
  }

  cout << "! ";
  for (auto c : ans)
    cout << c;
  cout << endl;

  return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    sort(p,p+N);
    int ans = 0;
    for (int i = 0; i < K; i++)
    {
        ans += p[i];
    }
    cout << ans << endl;
}	


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll solve() {
	ll n; cin >> n;
	vl a(n+1);
	FOR(i,0,n+1) cin >> a[i];

	vl b(n+1), c(n+1);
	b[0] = 1;
	FOR(i,0,n) {
		if (b[i] < a[i]) return -1;
		b[i+1] = min(ll(1e15), 2*(b[i]-a[i]));
		if (b[i+1] <= 0) return -1;
	}
	if (b[n] < a[n]) return -1;

	c[n] = a[n];
	FORD(i,0,n) {
		c[i] = c[i+1]+a[i];
	}

	ll res = 0;
	FOR(i,0,n+1) {
		cerr << b[i] << " " << c[i] << endl;
		res += min(b[i],c[i]);
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << solve() << endl;
}



Measured memory_bytes: 5772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const unordered_map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define dbg(x) cout<<#x<<" = "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________________
int main()
{
       int n;
       cin>>n;
       ld a[n];
       arrin(a,n);
       ld lim = 1;
       ld pro = 1;
       fri(i,0,n){
              if(a[i]==0){
                     ex(0);
              }
       }
       fri(i,0,n){
              if(a[i]>((ld)1e18/pro)){
                     ex(-1);
              }
              pro *= a[i];
       }
       cout<<(ll)pro<<endl;


}


Measured memory_bytes: 5296
unittest
{
	assert( [ "5", "1 1 2 2" ].parse.expand.solve == "2\n2\n0\n0\n0" );
	assert( [ "10", "1 1 1 1 1 1 1 1 1" ].parse.expand.solve == "9\n0\n0\n0\n0\n0\n0\n0\n0\n0" );
	assert( [ "7", "1 2 3 4 5 6" ].parse.expand.solve == "1\n1\n1\n1\n1\n1\n0" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	as[] -= 1;
	return tuple( as );
}

auto solve( long[] as )
{
	auto anss = new long[ 1 + as.length ];
	foreach( a; as )
	{
		anss[ a ]++;
	}
	return anss.to!( string[] ).join( "\n" );
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
}


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

signed main() {
	int N,a;
	cin>>N;
	int tmp=0;
	for(int i=0;i<N;i++){
		cin>>a;
		if(a==tmp+1){
			tmp++;
		}
	}
	
	if(tmp!=0)cout<<N-tmp<<endl;
	else cout<<-1<<endl;
}

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

int main() {

  int a, b, c; cin >> a >> b >> c;
  if (a == b) {
    if (b == c) {
      cout << 1 << endl;
    }
    else {
      cout << 2 << endl;
    }
  }
  else if (a == c || b == c) {
    cout << 2 << endl;
  }
  else {
    cout << 3 << endl;
  }
}


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

int main()
{
    int n;
    int num[105];
    cin>>n;
    for(int i=0;i<n;i++) cin>>num[i];
    int ans=0;
    while(1){
        int i=0;
        int flag=0;
        while(i<n){
            if(num[i]>=1){
                num[i]--;
                if(!flag) ans++,flag=1;
            }
            else flag=0;
            i++;
        }
        int sum=0;
        for(int i=0;i<n;i++) if(!num[i]) sum++;
        if(sum==n) break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int n;
    cin >> n;
    int x[n][2];
    rep(i,n){
        cin >> x[i][0] >> x[i][1];
    }

    if(n==1){
        cout << '1' << endl;
        return 0;
    }

    vector<P> v;

    rep(i,n){
        rep(j,n){
            if(i!=j){
                v.push_back(P(x[i][0]-x[j][0],x[i][1]-x[j][1]));
            }
        }
    }
    sort(v.begin(),v.end());
    int count = 0;
    int a,b;



    a = v[0].first;
    b = v[0].second;
    int tmp = 1;
    srep(i,1,v.size()){
        if(v[i].first==a&&v[i].second==b){
            tmp++;
        }else{
            count = max(count,tmp);
            a = v[i].first;
            b = v[i].second;
            tmp = 1;
        }
    }
    count = max(count,tmp);

    int ans = n-count;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define out(x) #x << " = " << x
#define yn(x) ((x) ? "YES" : "NO")
#define el "\n"
using namespace std;
typedef pair <int, int> ii;

const ll siz = 2e5 + 10;
const ll SIZ = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll maxx = 2e9;
const ll MAXX = 1e18;

int a[siz];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_4.INP", "r", stdin);
//    freopen ("OUT_4.OUT", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n - 1; i++)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; i++)
        cout << a[i] << el;
    return 0;
}


Measured memory_bytes: 5088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    int t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

int main(){
  int h,n;cin >> h >> n;
  vector<int> a(n),b(n);
  rep(i,n)cin >> a[i] >> b[i];
  //dp[i]:=相手の体力をちょうどi削った時の消耗量のmin
  vector<ll> dp(200001,-1);
  dp[0]=0;
  rep(i,h+1){
    if(dp[i]==-1)continue;
    rep(j,n){//i+a[j]に送るdpをする
      if(i+a[j]>200000)continue;
      if(dp[i+a[j]]==-1)dp[i+a[j]]=dp[i]+b[j];
      else dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j]);
    }
  }
  ll ans=1000000000000000;
  rep2(i,h,200001){
    if(dp[i]!=-1)ans=min(ans,dp[i]);
  }
  printf("%lld\n",ans);
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"

void solve(string n) {
    int cnt = 0;
    while(stoi(n) > 9) {
        int m = n.size();
        int ma = -1;
        for(int i=1; i<m; i++) {
            string s1 = n.substr(0,i);
            string s2 = n.substr(i,m-i);
            if(stoi(s1) * stoi(s2) > ma) {
                ma = stoi(s1) * stoi(s2);
            }
        }
        n = to_string(ma);
        cnt++;
    }
    cout << cnt << "\n";
}

int main() {
    int q; cin>>q;
    rep(i,q) {
        string n; cin>>n;
        solve(n);
    }
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

pair<vl,vvl> comps(vvl adj) {
	ll n = sz(adj);
	vb mark(n);
	vvl comps;
	vl c(n,-1);
	ll C = 0;
	FOR(i,0,n) if (!mark[i]) {
		queue<ll> q;
		q.push(i);
		mark[i] = true;
		vl comp = {i};
		c[i] = C;
		while (sz(q)) {
			ll j = q.front(); q.pop();
			for (ll k: adj[j]) if (c[k] == -1)
					c[k] = C, q.push(k), comp.pb(k), mark[k] = true;
		}
		comps.pb(comp);
		C++;
	}
	return {c,comps};
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m1, m2;
	cin >> n >> m1 >> m2;

	vvl adj1(n);
	FOR(i,0,m1) {
		ll a, b; cin >> a >> b;
		a--, b--;
		adj1[a].pb(b), adj1[b].pb(a);
	}
	vl comp1 = comps(adj1).xx;
	
	vvl adj2(n);
	FOR(i,0,m2) {
		ll a, b; cin >> a >> b;
		a--, b--;
		adj2[a].pb(b), adj2[b].pb(a);
	}
	vl comp2 = comps(adj2).xx;
	
	vl comp3(n,-1);
	map<pll,ll> comp3id;
	ll C = 0;
	FOR(i,0,n) {
		pll p(comp1[i],comp2[i]);
		if (!has(comp3id,p)) comp3id[p] = C++;
		comp3[i] = comp3id[p];
	}
	
	vl comp3sz(C);
	FOR(i,0,n) comp3sz[comp3[i]]++;

	FOR(i,0,n) cout << comp3sz[comp3[i]] << " \n"[i+1 == n];


}



Measured memory_bytes: 44892
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define ll long long
using namespace std;

int main(){
	int N;
	cin >>N;
	struct P{
		int x;
		int y;
		ll h;
	};
	P p[N];
	P sample;
	for(int i=0;i<N;i++){
		cin>>p[i].x>>p[i].y>>p[i].h;
		if(p[i].h>=1LL){
			sample=p[i];
		}
	}

	vector<P> ansPoss;
	for(int x=0;x<=100;x++){
		for(int y=0;y<=100;y++){
			bool flag=true;
			ll V=sample.h+abs(sample.x-x)+abs(sample.y-y);
			V=max(V,0LL);
			for(int i=0;i<N;i++){
				if(p[i].h!=max(V-abs(p[i].x-x)-abs(p[i].y-y),0LL)){
					flag=false;
				}
			}
			if(flag==true){
				ansPoss.push_back(P{x,y,V});
			}
		}
	}
	P ans=ansPoss[0];
	cout<<ans.x <<" "<<ans.y <<" "<<ans.h <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

using namespace std;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int tot = (n - 1) * n / 2 + n * m;
  int ans = (n - 1) * n / 2 + (n - 1) * m;
  for (int i = 0; i < n; ++i) {
    int cur = (n - 1) * n / 2 - i + (n - 1) * m;
    if (abs(tot - cur) < abs(tot - ans)) {
      ans = cur;
    }
  }
  printf("%d\n", ans);
}


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

using namespace std;
typedef long long ll;


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

    int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
    for (int i = 0; i < 4; ++i) {
        if (N[i] == 1) cnt1++;
        else if (N[i] == 9) cnt2++;
        else if (N[i] == 7) cnt3++;
        else if (N[i] == 4) cnt4++;
        else continue;
    }

    if (cnt1 * cnt2 * cnt3 * cnt4 == 1) cout << "YES" << endl;
    else cout << "NO" << endl;


}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  dsu d(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    d.merge(a-1, b-1);
  }
  cout << d.groups().size()-1 << endl;
}


Measured memory_bytes: 8908
#include<iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int n, debt = 100000;
  cin >> n;
  REP(i,n) {
    debt *= 1.05;
    if (debt % 1000 != 0) debt = (debt / 1000 + 1) * 1000;
  }
  cout << debt << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>

#define MIM 1100000
#define NCI (-1)
#define LOLLOL 14
#define max 50000000

char H[MIM][LOLLOL];


int gC(char );
long long gk(char *);
int h1(int );
int h2(int ); 
int fd(char *);
int ins(char *);







int main(){
  int i,n,j;
  char str[LOLLOL],com[9],comcomcom[50000000];
  for(i=0;i<MIM;i++)H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<max;i++){
    comcomcom[i]=i;
  }
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      ins(str);
    }
    else {
      if(fd(str)){
	printf("yes\n");
      }
      else{
	printf("no\n");
	       }
      }
  }return 0;
}

int gC(char chocolate){
  if(chocolate=='A'){
    return 2;
  }
  else if(chocolate=='C'){
    return 2;
  }
  else if(chocolate=='G'){
    return 3;
  }
  else if(chocolate=='T'){
    return 4;
  }
  
  else return 0;
}

long long gk(char strong[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(strong);i++){
    sum+=p*(gC(strong[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){
  return key%MIM;
}
int h2(int key){
  return 1+(key%(MIM-1));
}


int fd(char strong[]){
  long long key,i,hai;
  key=gk(strong);
  for(i=0;;i++){
    hai=(h1(key)+i*h2(key))%MIM;
    if(strcmp(H[hai],strong)==0)return 1;
    else if(strlen(H[hai])==0)return 0;
  }
  return 0;
}

int ins (char str[]){
  long long key,i,j;
  key=gk(str);
  for(i=0;;i++){
    j=(h1(key)+i*h2(key))%MIM;
    if(strcmp(H[j],str)==0)return 1;
    else if(strlen(H[j])==0){
      strcpy(H[j],str);
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 16780
d = [0, 0, 0, 0]

for i in range(0, 3):
  a, b = map(int, input().split(" "))
  d[a - 1] += 1
  d[b - 1] += 1
  
c = 0
for i in range(0, 4):
  if d[i] % 2 == 1:
    c += 1

if c == 2:
  print("YES")
else:
  print("NO")

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

int main(void){
  int N,M;
  cin >> N >> M ;
  int L[M+1];int R[M+1];
  for(int i = 0;i<M;++i){
    cin >> L[i] >> R[i];
  }
  int count = 0;
  int max_L = 0,min_R = N;
  for(int i = 0;i<M;++i){
    if(max_L < L[i]){
      max_L = L[i];
    }
  }
  for(int i = 0;i<M;++i){
    if(min_R > R[i]){
      min_R = R[i];
    }
  }
  for(int j = 1;j<N+1;++j){
    if(j <= min_R && max_L <= j){
      count++;
    }
  }
  cout << count << endl;    
}

Measured memory_bytes: 1024
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
priority_queue<ll> p;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, m, a, s = 0;
    cin >> n >> m;
    for (ll i = 0; i < n; i++)
        cin >> a, p.push(a);
    while (m--)
    {
        ll x = p.top();
        x /= 2;
        p.pop();
        p.push(x);
    }
    while (p.size())
        s += p.top(), p.pop();
    cout << s;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  char s;
  cin >> s;
  if (s=='a' || s == 'i' || s == 'u' || s == 'e' || s == 'o' ) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

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

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

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

  int n;
  cin >> n;

  vector<string> a(n);
  trav(i, a) cin >> i;

  using state = tuple<int, int, int, int>; // left close, right open, total diff, len
  vector<state> b(n);
  rep(i, 0, n) {
    int cnt = 0, lc = 0, ro = 0;
    trav(c, a[i])
      lc = max(lc, cnt += (c == ')') ? 1 : -1);
    reverse(all(a[i])); cnt = 0;
    trav(c, a[i])
      ro = max(ro, cnt += (c == ')') ? -1 : 1);
    b[i] = {lc, ro, ro - lc, sz(a[i])};
  }
  sort(all(b), [&](state s1, state s2) {
                 auto [lc1, ro1, delta1, len1] = s1;
                 auto [lc2, ro2, delta2, len2] = s2;
                 if (delta1 > 0 and delta2 <= 0) {
                   return true;
                 } else if (delta1 <= 0 and delta2 > 0) {
                   return false;
                 } else if (delta1 <= 0 and delta2 <= 0){
                   return tie(ro2, delta1) < tie(ro1, delta2);
                 } else if (delta1 > 0 and delta2 > 0) {
                   return tie(lc1, delta2) < tie(lc2, delta1);
                 } else assert(false);
               });
  bool good = true;
  int have = 0;
  for (const auto& [lc, ro, diff, len]: b) {
    good &= lc <= have;
    have += diff;
  }
  good &= have == 0;
  cout << (good ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 50184
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>

typedef signed char        int8;
typedef short              int16;
typedef int                int32;
typedef long long          int64;
typedef unsigned char      uint8;
typedef unsigned short     uint16;
typedef unsigned int       uint32;
typedef unsigned long long uint64;

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

int main(void) {
  int k;
  std::cin >> k;
  int sum = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        sum += gcd(gcd(a, b), c);
      }
    }
  }
  std::cout << sum << std::endl;
  return 0;
}


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

using namespace std;

using ll = long long;

const int maxN = 2e5 + 5;

vector<int> fr(maxN);

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> fr[i];
	sort(fr.begin(), fr.begin() + n, [](int a, int b) { return a > b; });
	ll ans = fr[0], count = 2, in = 1;
	int times = 0;
	while(count != n) {
	    if(times == 2) {
	        in++;
	        times = 0;
	    }
	    ans += fr[in];
	    times++;
	    count++;
	}
	cout << ans;
	return 0;
}

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

int main() {
	string s;
	getline(cin, s);
	rep(i,0,s.length()-4) {
		if(s.substr(i,5) == "peach") {
			s.replace(i,5,"apple");
		}
		else if(s.substr(i,5) == "apple") {
			s.replace(i,5,"peach");
		}
	}
	cout << s << endl;
	return 0;
}

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

int main()
{
  int a, b, c, d;
  std::cin
    >> a
    >> b
    >> c
    >> d;
  auto r0 = std::abs(a - c);
  auto r1 = std::abs(a - b);
  auto r2 = std::abs(b - c);

  auto ans = r0 <= d || (r1 <= d && r2 <=d);
  std::cout
    << (ans ? "Yes" : "No")
    << std::endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

e = [0] * 1001
e[1] = 1.0
for i in range(2, 1001):
    e[i] = e[i-1] + 0.5

ans = [0] * (n-k+1)
for i in range(k):
    ans[0] += e[p[i]]
for i, v in enumerate(range(k, n), start=1):
    ans[i] = ans[i-1] + e[p[v]] - e[p[v-k]]
print(max(ans))

Measured memory_bytes: 25604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N),B(N),C(N-1);
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
        ans+=B[i];
    }
    for(int i=0;i<N-1;i++){
        cin>>C[i];
    }
    for(int i=1;i<N;i++){
        if(A[i-1]+1==A[i]) ans+=C[A[i-1]-1];
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
using namespace std;

int main()
{
	int nn;
	cin >> nn;
	nn %= 10;
	if(nn == 3)
	{
		cout << "bon" << endl;
	}
	else if(nn == 0 || nn == 1 || nn == 6 || nn == 8)
	{
		cout << "pon" << endl;
	}
	else
	{
		cout << "hon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class DAnOrdinaryGame {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            out.println(s.charAt(0) == s.charAt(s.length() - 1) ^ s.length() % 2 == 1 ? "First" : "Second");
        }

    }
}



Measured memory_bytes: 26912
n = int(input())
h = list(map(int,input().split()))[::-1]
ans = 'Yes'
for i in range(n-1):
    if h[i+1] - h[i] >= 2:
        ans = 'No'
    elif h[i+1] - h[i] == 1:
        h[i+1] -= 1
print(ans)

Measured memory_bytes: 20528
main :: IO ()
main = do
  [n, m, x] <- (map read . words) <$> getLine :: IO [Int]
  as <- (map read . words) <$> getLine :: IO [Int]
  let c1 = length $ filter (\a -> a <= x) as
  let c2 = length $ filter (\a -> a >= x) as
  print $ min c1 c2


Measured memory_bytes: 892
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final long MOD = 1000000007;
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.parallelSort(a);
		boolean f = true;
		int c=0;
		if(n%2==0) {
			c = 1;
			for (i = 0; i < n; i+=2) {
				if(a[i]!=c||a[i+1]!=c) {
					f=false;
					break;
				}
				c+=2;
			}
		} else {
			c = 0;
			if(a[0]!=c) {
				f=false;
			}
			if(f) {
				c+=2;
				for (i = 1; i < n; i+=2) {
					if(a[i]!=c||a[i+1]!=c) {
						f=false;
						break;
					}
					c+=2;
				}
			}
		}
		long ans = 0;
		if(f) {
			ans = 1;
			for (i = 0; i < n/2; i++) {
				ans*=2;
				if(ans>=MOD) {
					ans-=MOD;
				}
			}
		}
		out.println(ans);
	}
}


Measured memory_bytes: 49276
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int maxn = 100000 + 5;

int a, b, c;

int main() {
    cin >> a >> b >> c;
    if (a * c <= b) cout << c << endl;
    else cout << b / a << endl;
    return 0;
}

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

int main() {
	int a, b, c, d,x,y;
	cin >> a >> b >> c >> d;
	y = (a + b + c + d) % 60;
	x = (a + b + c + d) / 60;
	cout << x << endl << y << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int
main ()
{
  int W, H, x, y, r, a, b, c, d;
  cin >> W >> H >> x >> y >> r;
 a = x + r;
  b = y + r;
c= x-r;
d=y-r;
  if (c < 0 ||a > W|| d < 0 || b > H)
    {
      cout << "No" << endl;
    }
  else
    {
      cout << "Yes" << endl;
    }

 

  return 0;
}


Measured memory_bytes: 3092
// 2020-08-03 14:46:03
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct FenwickTree {
  int N;
  vll bit;
  void init(int n) {
    N = n;
    bit.assign(n+2, 0);
  }
  void add(int i, ll a) {
    while(i <= N) {
      bit[i] += a;
      // chmax(bit[i], a);
      i += (i & -i);
    }
  }
  ll sum(int i) {
    ll res = 0;
    while(i > 0) {
      res += bit[i];
      // chmax(res, bit[i]);
      i -= (i & -i);
    }
    return res;
  }
  int lower_bound(ll w) {
    int k = 1;
    while(k <= N) k *= 2;
    k /= 2;
    int x = 0;
    while(k > 0) {
      if(x+k <= N && bit[x+k] < w) {
        w -= bit[x+k];
        x += k;
      }
      k /= 2;
    }
    return x+1;
  }
};

const int inf = 1e9+5;
void answer() {
  int q;
  cin >> q;
  vector<int> a(q), b(q), c(q);
  map<int, int> mpx;
  mpx[-inf] = 0;
  mpx[inf] = 0;
  rep(i, q) {
    cin >> c[i];
    if(c[i] == 1) {
      cin >> a[i] >> b[i];
      mpx[a[i]] = 0;
      mpx[b[i]] = 0;
    }
  }
  vector<int> xs;
  for(auto& p : mpx) {
    p.second = xs.size();
    xs.push_back(p.first);
  }
  FenwickTree bit;
  bit.init(xs.size() * 2);
  ll x = 0, y = 0;
  auto update = [&](int qi) {
    bit.add(1, -1);
    bit.add(mpx[a[qi]] * 2 + 1, 1);
    bit.add(mpx[a[qi]] * 2 + 2, 1);
    int bitx = bit.lower_bound(0);
    ll past = x;
    x = xs[(bitx-1)/2];
    y += b[qi];
    int cnt = -bit.sum(1);
    if(cnt % 2) {
      y += abs(x - ll(a[qi]));
    } else {
      y += abs(past - ll(a[qi]));
    }
  };
  rep(qi, q) {
    if(c[qi] == 1) {
      update(qi);
    } else {
      cout << x << ' ' << y << '\n';
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 18848
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char a[110];
int main()
{
    long long k,ans=0;
    std::cin>>a;
    cin>>k;
    for(int i=0;i<strlen(a);i++)
    if(a[i]=='1')
    ans++;
    else
    break;
    if(k<=ans)
    printf("1");
    else
    printf("%d",a[ans]-48);
}

Measured memory_bytes: 256
def main():
  n, k = map(int, input().split(" "))

  arr = [0] * n

  for _ in range(k):
    input()
    for a in map(int, input().split(" ")):
      arr[a - 1] += 1

  print(len(tuple(filter(lambda count: count == 0, arr))))


main()


Measured memory_bytes: 9172
n=str(input())
if len(n)%2==0:
    if len(n)==2:
        print(9)
    elif len(n)==4:
        print(909)
    else:
        print(90909)
else:
    if len(n)==1:
        print(int(n))
    elif len(n)==3:
        print(int(n)-90)
    else:
        print(int(n)-9090)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

vector<ll> fact,inv;

ll f(ll a,ll b, ll p)  // a^b mod pを求める
{
    if (b == 0)
    {
        return 1;
    }else if (b % 2 == 0)
    {
        ll d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
        return d * d % mod;
    }else
    {
        return a * f(a,b-1,p) % mod;
    }
}

void init(ll n)
{
    fact.resize(n+1,1);
    inv.resize(n+1,1);

    for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
    {
        fact[i] = fact[i-1] * i % mod;
    }
    for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
    {
        inv[i] = f(fact[i],mod-2,mod) % mod;
    }
}

ll comb(ll n,ll k)  //n_C_k
{
    if (n < k)
    {
        return 0;
    }
    return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll max = 0;
    int p = -1;
    for(int i = 0; i < n; i++)
    {
        if(a[i]>max) max = a[i] , p = i;
    }
    // init(max);

    // ll cnb = 0,num = -1;
    // for(int i = 0; i < n; i++)
    // {
    //     if(a[i]!=max && comb(max,a[i]) > cnb)
    //     {
    //         cnb = comb(max,a[i]);
    //         num = i;
    //     }
    // }
    cout << max << " ";
    if(max%2!=0) max++;
    ll sol = INF;
    ll min = INF;
    //cout << max/2 << endl;
    for(int i = 0; i < n; i++)
    {
        if(abs(max/2 - a[i])<min && i!=p) min = abs(max/2 - a[i]),sol = a[i];
    }

    cout << sol << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

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

    int ans = 0;
    for(int i = 1;i < n+1;i ++){
        if(i % 2 == 1 && a.at(i) % 2 == 1) ans ++;
    }

    cout << ans << endl;
}

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

int main()
{
  string S;
  cin >> S;
  int count = 0;
  for (int i=0; i<S.size(); i++) {
    if (S[i] == 'o') count++;
  }
  count = count + (15 - S.size()); 
  if (count >= 8) cout << "YES"<< endl;
  else cout << "NO"<< endl;
  return 0;
}


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

int main() {
	int W,a,b;
    cin >> W >> a >> b;
    if(b<a){
      int c = b;
      b = a;
      a = c;
    }
    if(a <= b && b <= a+W){
      cout << 0 << endl;
    }else{
       int s = b-(a+W);
       int t = b-a;
       if(s<0){
          s = (-1)*s;
       }
       if(t<0){
          t = (-1)*t;
       }
       if(s<t){
          cout << s << endl;
       }else{
          cout << t << endl;
       }
    }
}


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<cstring>
#include<stdio.h>
using namespace std;
typedef long long LL;
#define maxn (100000*2)
long long sett[maxn+1];
int n,cnt;
set<long long> ss;
map<long long ,long long > mp;
bool binary(int x,int y,long long v)
{
    while(x<y)
    {
        int mid=(x+y)/2;
        if(sett[mid]==v) return true;
        else if(sett[mid]>v) y=mid;
        else  x=mid+1;
    }
    return false;
}
int main()
{
    cnt=0;
    mp.clear();
    scanf("%d",&n);
    long long sum=0;
    for(int i=0;i<n;i++)
    {
        int x;scanf("%d",&x);
        sum+=x;
        mp[sum]++;
       // if(binary(0,cnt,sum)) continue;
       ss.insert(sum);
      // if(j<cnt) continue;
        //  sett[cnt++]=sum;
    }
     set<long long >::iterator iter;
    long long ans=0,tmp;
    for(iter=ss.begin();iter!=ss.end();iter++)
    {
        tmp=mp[*iter];
        //cout<<tmp<<" "<<*iter<<endl;
        ans+=(tmp*(tmp-1)/2);
    }
    cout<<ans+mp[0]<<endl;
    return 0;
}

Measured memory_bytes: 22144
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int search(const int* const len, const int n, const int dest, const int i0)
{
    int lowest = abs(dest);
    if (dest > 0) {
        for (int i = i0; i < n; ++i) {
            int tmp = 10 + search(len, n, dest - len[i], i + 1);
            lowest = min(lowest, tmp);
        }
    }
    return lowest;
}

int cost(const int* const len, const int n, const int dest)
{
    assert(n > 0);
    int lowest = 1e9;
    for (int i = 0; i < n; ++i) {
        int tmp = search(len, n, dest - len[i], i + 1);
        lowest = min(lowest, tmp);
    }
    return lowest;
}

int solve(const std::vector<int>& len, const int a, const int b, const int c)
{
    int mp = 1e9;

    const int n = len.size();

    for (int i = 1; i + 2 <= n; ++i) {
        int mp_a = cost(len.data() + 0, i - 0, a);
        if (mp_a >= mp) continue;

        for (int j = i + 1; j + 1 <= n; ++j) {
            int mp_b = cost(len.data() + i, j - i, b);
            if (mp_a + mp_b >= mp) continue;

            const int k = n;
            int mp_c = cost(len.data() + j, k - j, c);
            if (mp_a + mp_b + mp_c >= mp) continue;

            int tmp = mp_a + mp_b + mp_c;
            mp = min(mp, tmp);
            // cerr << (i - 0) << ", " << (j - i) << ", " << (k - j) << " -- ";
            // cerr << mp_a << ", " << mp_b << ", " << mp_c << " -- " << tmp << "\n";
        }
    }

    return mp;
}

int main()
{
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    auto len = std::vector<int>(n);
    for (auto& l : len) {
        cin >> l;
    }

    sort(len.begin(), len.end());
    int best = 1e9;
    do {
        best = min(best, solve(len, a, b, c));
    } while (next_permutation(len.begin(), len.end()));
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,x=0,y;
    cin>>a;
    int b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
        y=1;
        for(int j=0;j<i;j++){
            if(b[i]==b[j]) y=0;
        }
        if(y) x++;
    }
    cout<<x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pvar(x) clog << "[" << #x << ":" << x << "]\n"
using namespace std;
using ll = long long int;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // b>g>r
  int r, g, b, k;
  cin >> r >> g >> b >> k;
  if (b > g && g > r) {
    cout << "Yes";
    return 0;
  }
  while (g <= r && k > 0) {
    g *= 2;
    --k;
  }
  while (b <= g && k > 0) {
    b *= 2;
    --k;
  }
  if (b > g && g > r) {
    cout << "Yes";
  } else
    cout << "No";
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

const int MOD = 1000000007;

int main()
{
	int m, d;
	cin >> m >> d;

	int ans = 0;
	int a = d / 10;
	int b = d % 10;

	for(int x=1; x<=m; x++){
		for(int i=2;i<a;i++){
			for(int j=2;j<=9;j++){
				if(x == i*j)
					ans++;
			}
		}

		for(int j=2;j<=b;j++){
			if(a >= 2 && x == a*j)
				ans++;
		}
	}

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

Measured memory_bytes: 256