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

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++)
        {if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    ll n;cin>>n;
    map<ll,ll> mp;
    bool t=true;
    fori(n){
        ll a;
        cin>>a;
        if(mp[a]!=0){t=false;break;}
        mp[a]++;
    }
    cout<<((t)?"YES":"NO");
    
//code ends
    return 0;
}


Measured memory_bytes: 12800
e = input()
a = int(e[0:1])
b = int(e[1:2])
c = int(e[2:3])
d = int(e[3:4])

f, g = a+b, a-b
h, i, j, k = f+c, f-c, g+c, g-c
l, m, n, o, p, q, r, s = h + d, h - d, i + d, i - d, j + d, j - d, k + d, k - d
if(l == 7):
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif(m == 7):
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif(n == 7):
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif(o == 7):
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif(p == 7):
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif(q == 7):
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif(r == 7):
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif(s == 7):
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve() {
  int n;
  cin >> n;
  vi32 w(n), s(n), v(n);
  rep(i, n) {
    cin >> w[i] >> s[i] >> v[i];
  }
  vi32 o(n);
  iota(all(o), 0);
  sort(all(o), [&](int i, int j) {
    return s[i] + w[i] < s[j] + w[j];
  });
  vector<vi64> dp(n + 1, vi64(10002, -1));
  dp[0][0] = 0;
  rep(i, n) repc(j, 10001) {
    if (dp[i][j] == -1) continue;
    int x = o[i];
    amax(dp[i + 1][j], dp[i][j]);
    if (j <= s[x]) {
      int weight = j + w[x];
      if (weight > 10000) weight = 10001;
      amax(dp[i + 1][weight], dp[i][j] + v[x]);
    }
  }
  i64 ans = 0;
  repc(j, 10001) amax(ans, dp[n][j]);
  cout << ans << endl;
}


Measured memory_bytes: 78720
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 
#include <numeric>

using namespace std; 

const long long mod=1e9+7;

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

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

    int cur=0;
    for(int i=0;i<n;i++){
        if(a[i]==cur+1) cur++;
    }

    if(cur == 0){
        cout<<-1<<endl;
    }else{
        cout<<n-cur<<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define int long long 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define ff first
#define ss second
#define vp vector <pair<int,int>>
#define vpp vector <pair<int,pair<int,int>>>
#define seti set<int>
#define setbit(x) __builtin_popcountll(x)
#define sov(v) accumulate(all(v),0)
#define fs(it,a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pqmax priority_queue <int,vector <int>> 
#define pqmin priority_queue <int,vector <int>,greater<int>> 
#define dq deque <int>
#define umi unordered_map<int,int>
#define ums unordered_map<string,int>
#define ps(x,y) fixed << setprecision(y) << x
#define all(x) x.begin(),x.end()
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define ps(x,y) fixed << setprecision(y) << x
#define countdigit(x) floor( log10(x) +1)
#define M 1000000007  
#define PI 3.1415926535
//Use (k%M+m)%m always where k is any no
#define ee "\n"
#define re return 



//Author Rahul Sannigrahi


vector<int> take(int n)
{
    int i,j;
    vi v;
    f(i,0,n)
    {
        cin>>j;
        v.pb(j);
    }
    return v;
}

void show(vector<int>v)
{
    int i;
    for(i=0;i<v.si;i++)
    {
     cout<<v[i]<<" ";   
    }
    cout<<ee;
}

int decode()
{
    int i,t,s,d;
    cin>>d>>t>>s;
    if(s*t>=d)
    cout<<"Yes"<<ee;
    else
    cout<<"No"<<ee;
    re 0;
}
 
int32_t main()
{
    IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif 
    int t=1;
    //cin>>t;
    while(t--)
    decode();
    return 0;
}
 













Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n;
int a[100010];
int pre[100010],suf[100010];
int gcd(int x,int y)
{
    if(y==0)  return x;
    return gcd(y,x%y);
}
int ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)  scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)  pre[i]=gcd(pre[i-1],a[i]);
    for(int i=n;i>=1;i--)  suf[i]=gcd(suf[i+1],a[i]);
    for(int i=1;i<=n;i++)  ans=max(ans,gcd(pre[i-1],suf[i+1]));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
  int b1, b2, b3;
  scanf("%d%d%d",&b1, &b2, &b3);
 
  if(b1 == 1 && b2 == 0 && b3 == 0){
    printf("Close\n");
  }
  else if(b1 == 0 && b2 == 1 && b3 == 0){
    printf("Close\n");
  }
  else if(b1 == 1 && b2 == 1 && b3 == 0){
    printf("Open\n");
  }
  else if(b1 == 0 && b2 == 0 && b3 == 1){
    printf("Open\n");
  }
  else if(b1 == 0 && b2 == 0 && b3 == 0){
    printf("Close\n");
  } 
  return 0;    
      
}
  

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

string s;
int len;

enum Ord {
    Le, Eq, Gt,
};

int dp[20][2][2][10000];

bool is_gochiusa(int x) {
    if (x / 1000 % 10 != 5) return false;
    if (x / 100 % 10 != 1) return false;
    if (x / 1 % 10 != 3) return false;
    return true;
}

int rec(int k, Ord ord, bool done, int tail) {
    int &ans = dp[k][ord][done][tail];
    if (ans != -1) return ans;

    ans = 0;
    if (k == len) {
        ans = done ? 1 : 0;
    } else {
        int d = s[k] - '0';
        rep(nd, 10) {
            Ord nord;
            if (ord == Le || ord == Gt) {
                nord = ord;
            } else {
                nord = nd < d ? Le : nd == d ? Eq : Gt;
            }
            if (nord == Gt) continue;
            int ntail = (tail * 10 + nd) % 10000;
            bool ndone = done || is_gochiusa(ntail);
            ans += rec(k + 1, nord, ndone, ntail);
        }
    }
    return ans;
}

signed main() {
    cin >> s;
    len = s.size();
    memset(dp, -1, sizeof dp);
    cout << rec(0, Eq, false, 0) << endl;
}



Measured memory_bytes: 9460
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
first = 0
last = sum([abs(A[i + 2] - A[i + 3]) for i in range(len(A) - 3)])
for i in range(1, len(A) - 1):
    if i != 1:
        first += abs(A[i - 2] - A[i - 1])
        last -= abs(A[i] - A[i + 1])
    print(first + abs(A[i - 1] - A[i + 1]) + last)

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

int main(){
	
	int n;
	cin >> n;
	
	vector<ll> a,b;
	rep(i,n+1){
		ll aa;
		cin >> aa;
		a.push_back(aa);
	}
	rep(i,n){
		ll bb;
		cin >> bb;
		b.push_back(bb);	
	}

	ll ans = 0;
	rep(i,n){
		//i番目が倒せる数だけansに加算
		
		if(b[i] >= a[i]){
			//i地点を倒す
			ans += a[i];
			//i+1地点も出来るだけ倒す
			
			if(a[i+1]<b[i]-a[i]){
				ans += a[i+1];
				a[i+1] = 0;
			}
			else{
				a[i+1] -= b[i]-a[i];
				ans += b[i]-a[i];
			}
		}
		else{
			//i地点を出来るだけ倒す
			ans += b[i];
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 2548
//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set> 
#include<algorithm>
#include <set> 
#include<algorithm>
#define ll long long int
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define out(n) printf("%lld\n",n)
#define inf 100000000000000
#define endl "\n"
#define precise(x) fixed << setprecision(x) 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
const int MOD =1000000007;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
 
using namespace std;

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[1] < v2[1]; 
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}
 //ll power(ll x, ll y) 
//{ 
  //  ll temp; 
    //if( y == 0) 
     //   return 1; 
    //temp = power(x, y/2); 
    //temp=temp%MOD;
    //if (y%2 == 0) 
     //   return (temp%MOD)*(temp%MOD); 
    //else
      //  return (x%MOD)*(temp%MOD)*(temp%MOD); 
//} 
 
 
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
 //diamond[2000005],ans[1000006];
 const int maxn=5e5+1000;
 ll vis[300000];
 
 
 
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
     ll t;
    // cin>>t;
   
     t=1;	
     for(ll testcase=0;testcase<t;testcase++)
    {
        ll i1,i2,k,j,j1,a1,i31,i3,j2,i5,i4,i6,i7,i,m,n;
        ll x,y,z;
        ll total=0,cnt=0;
        ll flag=0;
        y=0;
        ll res,res1,ans,res2,q,sum;
        ans=0,cnt=0;
        res1=0,res=0,sum=0;
        ll flag1=0;
        ll k1,k2,k3;
        k1=1,k2=0;
        k3=0;
        ll required,days,h,w;
        //cin>>n;
        
        //for(it=mp.begin();it!=mp.end(),it++)
        //{
        //	for(int i=0;i<it->second.size();i++) cout<<it->second[i]<<" ";
		//}
		cin>>n;
		ll a[n];
	    const int max_n = 1e6;
	    ll max_a=0;
	    f(i,0,n)
	    {
	    	cin>>a[i];
	    	max_a=max(max_a,a[i]);
		}
		vector<int> d(max_a + 1, 0);
		d[0]=1,d[1]=1;
		for(i=2;i<=max_a;i++)
		{
			j=i;
			while(j<=max_a)
			{
				if(d[j]==0) d[j]=i;
				
				j=j+i;
			}
		}
		 vector<int> count(max_a + 1, 0);
		 ll prime;
		 for(i=0;i<n;i++)
		 {
		 	ll tmp=a[i];
		 	while(tmp>1)
		 	{
		 		prime=d[tmp];
		 		count[prime]++;
		 		while(tmp%prime==0) tmp/=prime;
		 		if(count[prime]>1) flag=1;
		 		if(count[prime]==n) flag1=1;
			 }
		 }
		 string answer="not coprime";
		 if(flag1==0) answer="setwise coprime";
		 if(flag==0)  answer="pairwise coprime";
		 
		 cout<<answer<<endl;
		
    }
}
	

Measured memory_bytes: 18696
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, a[112345];

    cin >> n;
    REP(i, n)
    cin >> a[i];

    ll res = 0;
    REP(i, n)
    {
        res += a[i] / 2;
        a[i] %= 2;

        if (i < n - 1 && a[i + 1] > 0 && a[i])
        {
            a[i]--;
            a[i + 1]--;
            res++;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>                                        
#include<cstdio>
using namespace std;
static const int MAX=26;
static const int NIL=-1;
typedef struct Node{
    int p,l,r;
}Node;

Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL) return;
    cout<<" "<<u;    
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if(u==NIL) return;
    inParse(T[u].l);
    cout<<" "<<u;    
    inParse(T[u].r);
}

void postParse(int u){
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    cout<<" "<<u;    
}
    
int main(){
    int v,l,r,root;
    cin>>n;
    for(int i=0;i<n;i++)T[i].p=NIL;
    for(int i=0;i<n;i++){
        cin>>v>>l>>r;
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL)T[l].p=v;
        if(r!=NIL)T[r].p=v;
    }

    for(int i=0;i<n;i++){
        if(T[i].p==NIL)root=i;
    }

    printf("Preorder\n");
    preParse(root);
    printf("\nInorder\n");
    inParse(root);
    printf("\nPostorder\n");
    postParse(root);
    putchar('\n');
    return 0;
}    



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    vector<int> b(n-1);
    rep(i,n-1){
        cin>>b[i];
    }
    vector<int> a(n);
    a[n-1]=b[n-2];
    a[0]=b[0];
    for(int i=n-2;i>=1;i--){
        a[i]=min(b[i],b[i-1]);
    }
    ll ans=0;
    rep(i,n){
        ans+=a[i];
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
n,m = map(int,input().split())
acc = 0
ab = []
for i in range(n):
    a,b = map(int,input().split())
    ab.append((a,b))
for a,b in sorted(ab):
    c = min(b,m)
    m -= c
    acc += a * c    
    if m == 0:
        break
print(acc)

Measured memory_bytes: 17788
import copy
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

def linearSearch(A,key,n):
    i=0
    B=copy.copy(A)
    B.append(key)
    while B[i] != key:
        i=i+1
    if i==n:
        return 0
    return 1

ans=0
for i in range(q):
    if linearSearch(S,T[i],n):
        ans=ans+1

print(ans)


Measured memory_bytes: 7100
n,m=map(int,input().split())
b = [list(map(int,input().split())) for _ in range(m)]
c=set([1])
k=[0]+[1]*(n)
for i in range(m):
  k[b[i][0]]-=1
  if b[i][0] in c:
    c.add(b[i][1])
    if k[b[i][0]]==0:
      c.remove(b[i][0])
  k[b[i][1]]+=1
  
print(len(c))

Measured memory_bytes: 34964
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N = 3;
    vvi C(N, vi(N));
    REP(i, N)
        REP(j, N) cin >> C[i][j];

    vi a(N), b(N);
    a[0] = 0;
    REP(i, N) b[i] = C[0][i] - a[0];
    REP(i, N) a[i] = C[i][0] - b[0];

    bool ok = true;
    REP(i,N) {
        REP(j,N) {
            if (a[i] + b[j] != C[i][j]) {
                ok = false;
                break;
            }   
        }
        if (!ok) break;
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;


    return 0;
}

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

const ll mod = 1000000007;
const int INF = 1001001001;

ll dp[3002][3002][4];

ll max(ll a, ll b, ll c){
	return max(max(a, b), c);
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int R, C, K; cin >> R >> C >> K;
	vector<vector<ll>> mp(R, vector<ll> (C));
	for(int i = 0; i < K; i++){
		int r, c; cin >> r >> c;
		--r; --c;
		cin >> mp[r][c];

	}
	//dp[i][j][k] : you are at (i, j) and you've picked up k items on the i-th row until the coordinate(i, j).
	for(int i = 0; i < R; i++){
		for(int j = 0; j < C; j++){
			// picking an item
			for(int k = 2; k >= 0; k--){
				dp[i][j][k+1] = max(dp[i][j][k] + mp[i][j], dp[i][j][k+1]);
			}
			// moving to the next square
			for(int k = 0; k < 4; k++){
				dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
				dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
			}
		}
	}
	ll ans = 0;
	rep(k, 4) ans = max(ans, dp[R-1][C-1][k]);
	cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	bool ans = false;
	rep(i, n) {
		if (a[i] % 2 == 1) ans = true;
	}
	if (ans) cout << "first" << endl;
	else cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
int N;
string S = "ACGT";
bool contain(string s) {
	int n = s.length();
	if (n <= 2) return false;
	
	rep(i, 0, n - 2) {
		string t = s.substr(i, 3);
		if (t == "AGC") return true;
	}

	return false;
}
string add(string s, char c) {
	string res = s + c;

	int n = res.length();
	if (n <= 2) return res;

	if (contain(res)) return "";

	rep(i, 0, n - 1) {
		string tes = res;
		swap(tes[i], tes[i + 1]);
		if (contain(tes)) return "";
	}

	if (4 <= n) res = res.substr(n - 3);

	return res;
}
void _main() {
	cin >> N;

	map<string, mint> dp;
	dp[""] = 1;

	rep(i, 0, N) {
		map<string, mint> pd;
		fore(p, dp) {
			fore(c, S) {
				string nxt = add(p.first, c);
				if (nxt != "") pd[nxt] += p.second;
			}
		}
		swap(dp, pd);
	}

	mint ans = 0;
	fore(p, dp) ans += p.second;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline long long read(){
	register long long x=0;
	register bool f=0;
	register char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return f?-x:x;
}
char cr[200];int tt;
inline void print(register long long x,register char k='\n') {
    if(!x) putchar('0');
    if(x < 0) putchar('-'),x=-x;
    while(x) cr[++tt]=x%10+'0',x/=10;
    while(tt) putchar(cr[tt--]);
    putchar(k);
}
long long n;
int cnt=1,sqr1;
int main(){
	n=read();
	for(int i=1;1ll*i*i<=n;i++){
		if(1ll*i*i<(n-1)&&(n-1)%i==0) cnt++;
		if(i==1) continue;
		long long tmp=n;
		while(tmp%i==0){
			tmp/=i;
		}
		cnt+=(tmp%i==1);
	}
	print(cnt);
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

def dfs(i):
    ret = 0
    if all(han):
        return 1
    for j in range(1, n + 1):
        if han[j] == False and j in graph[i]:
            han[j] = True
            ret += dfs(j)
            han[j] = False
    return ret

han = [False] * (n + 1)
han[0] = True
han[1] = True
ans = dfs(1)
    
print(ans)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int>> s(n);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    s.at(a - 1).insert(b - 1);
    s.at(b - 1).insert(a - 1);
  }
  vector<int> v;
  for(int i = 1; i < n; i++){
    v.push_back(i);
  }
  
  sort(v.begin(), v.end());
  int count = 0;
  do {
    if (!s.at(0).count(v.at(0))) continue;
    bool flag = true;
    for (int i = 0; i < n - 2; i++) {
      if(!s.at(v.at(i)).count(v.at(i + 1))) {
        flag = false;
        break;
      }
    }
    if(flag) {
/*      cout << "1 ";
      for (int x : v) {
        cout << x + 1 << " ";
      }
      cout << endl;*/
      count++;
    }
  } while (next_permutation(v.begin(), v.end()));
  cout << count << endl;
}

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

int main() {
  long long top,under,x;cin >> under >> top >> x;
  under += (x-(under%x))%x;
  top -= top%x;
  //cout << under << top << endl;
  long long temp=top-under;
  long long ans;
  if(temp<-1) {
    ans =0;
  }
  else {
    ans = temp/x+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	N, K := read(), read()
	Max, i := K, 1

	for {
		if N <= Max-1 {
			fmt.Println(i)
			return
		}
		Max = Max * K
		i++
	}
}

func read() int {
	var v int
	fmt.Scan(&v)
	return v
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define pb push_back
typedef long long ll;

const ll mod=1000000007;
map<pii,int> mp;
ll quickpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int main(){
    int n;
    scanf("%d",&n);
    ll zero=0,ans=1;
    rep(i,0,n){
        ll a,b;
        scanf("%lld%lld",&a,&b);
        ll d=__gcd(a,b);
        if(d==0){
            zero++;
            continue;
        }
        a/=d,b/=d;
        if(b<0) a=-a,b=-b;
        mp[{a,b}]++;
    }
    for(auto tmp:mp){
        if(tmp.se==0) continue;
        ll a=tmp.fi.fi,b=tmp.fi.se;
        ll d=quickpow(2,tmp.se);
        a=-a;
        if(mp.count({b,a})){
            d=(d+quickpow(2,mp[{b,a}])-1)%mod;
            mp[{b,a}]=0;
        }
        ans=ans*d%mod;
    }
    ans=(ans+zero-1+mod)%mod;
    printf("%lld",ans);
}


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

const int MAX = 210000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];
void init() {
    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;
    }
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll calc(ll n, ll k) {
    ll res = 1;
    for (int i = 0; i < k; i++) {
        res *= n - i;
        res %= MOD;
    }
    return (res * finv[k]) % MOD;
}

int main() {
    init();
    ll n, a, b;
    cin >> n >> a >> b;
    ll res = modpow(2, n, MOD);
    ll A = calc(n, a), B = calc(n, b);
    cout << (res - A - B - 1 + 2 * MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 5120
N, L = map(int, input().split(' '))

tsum = 0
if L >= 0:
    # L+1, ..., L+N-1
    tsum = (L + N - 1) * (L + N) / 2 - L * (L + 1) / 2
elif L + N - 1 >= 0:
    # L, ..., L+N-1
    tsum = (L + N - 1) * (L + N) / 2 - (-L) * (-L + 1) / 2
else:
    # L, ..., L+N-1
    tsum = - ((-L) * (-L + 1) / 2 - (-(L+N-1)) * (-(L+N-1) + 1) / 2)

print(int(tsum))


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(x) x.begin(),x.end()
#define REPR(i,n) for(ll i=(n)-1;i>=0;i--)
#define int long long
struct edge{
    int src,to,cost;
};
vector<edge>G[808];

int N;

ll dp_r[808];
ll dp_go[808];
int par[808];
bool done[808];
set<int>leaves;
int deg[808];
ll dfs_ret(int n){
    if(dp_r[n]<1e18)return dp_r[n];
    ll ret = 0;
    for(auto e:G[n]){
        if(e.to==par[n])continue;
        par[e.to]=n;
        if(deg[e.to]==1){
            ret+=e.cost; 
        }
        else{
            ret+=dfs_ret(e.to)+3*e.cost;
        }
    }
    return dp_r[n]=ret;
}
ll dfs_go(int n){
    if(dp_go[n]<1e18)return dp_go[n];
    ll ret = 0;
    ll mn = 1e18;
    ll sum = 0;
    for(auto e:G[n]){
        if(e.to==par[n])continue;
        par[e.to]=n;
        if(deg[e.to]==1)sum+=e.cost;
        else {
            sum+=3*e.cost+dfs_ret(e.to);
        }
    }
    for(auto e:G[n]){
        if(e.to==par[n])continue;
        ll res = sum;
        if(deg[e.to]==1){
        }
        else {
            res -= (3*e.cost + dfs_ret(e.to));
            res += 2*e.cost+dfs_go(e.to);
        }
        mn = min(mn,res);
    }
    return dp_go[n]=mn;
}
ll calc(int root){
    REP(i,N){
        dp_go[i]=1e18;
        dp_r[i]=1e18;
        par[i]=-1;
        done[i]=false;
    }
    par[root]=root;
    dfs_ret(root);
    return dfs_go(root);
}

void solve() {
    cin>>N;
    if(N==0)exit(0);
    REP(i,N){
        G[i].clear();
        deg[i]=0;
    }
    vector<edge>es(N-1);
    REP(i,N-1){
        int v;cin>>v;v--;
        es[i]={i+1,v,0};
    }
    REP(i,N-1){
        int d;cin>>d;
        es[i].cost=d;
    }
    REP(i,N-1){
        int u = es[i].src,v=es[i].to;
        int c = es[i].cost;
        deg[u]++;
        deg[v]++;
        G[u].push_back({u,v,c});
        G[v].push_back({v,u,c});
    }
    
    ll ans = 1e18;
    REP(root,N){
        ans = min(ans,calc(root));
    }
    cout<<ans<<endl;
}

signed main() {
	while (true)solve();
}


Measured memory_bytes: 3400
#include <stdio.h>
int main(void)
{
	long long int n,k,x,a;
	scanf("%lld%lld",&n,&k);
	x=n/k;
	a=x*x*x;
	if(k%2==0){
		x=(n+k/2)/k;
		a+=x*x*x;
	}
	printf("%lld\n",a);
	return 0;
}

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

using namespace std;

int main(){
  int x, y;
  int a, b;
  
  cin >> x >> y;
  
  if(y%2!=0){
    cout << "No" << endl;
    return 0;
  }
  
  a = 2*x - y/2;
  b = y/2 - x;
  
  if(a<0 || b<0){
    cout << "No" << endl;
    return 0;
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define re          return
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define fill(c,val) memset(c,val,sizeof(c))
#define LB lower_bound
#define UB upper_bound
#define inf 1e16
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
	   int n; cin>>n;
	   int a[n];
	  for(int i=0;i<n;i++) cin>>a[i];
	bool vis[n+1];
	fill(vis,false);
	int dp[n+1];
  for(int i=1;i<=n;i++){
  	dp[i]=1;
  }	  
 for(int i=0;i<n;i++){
 	 if(vis[a[i]-1]==false){
 	 	 vis[a[i]]=true;
	  }
else if(vis[a[i]-1]==true){
	dp[a[i]]=dp[a[i]-1]+1;
	vis[a[i]]=true;
  }
 }
 vector<int> v;  
 int maxm=0,pos;
 for(int i=1;i<=n;i++){
    if(dp[i]>maxm){
    	maxm=dp[i];
    	pos=i;
	}
 } 
 cout<<n-maxm<<endl;
 }
    return 0;
}

Measured memory_bytes: 2048
import numpy as np
N, M, X = map(int,input().split())
A = [a for a in map(int,input().split())]

squares = np.zeros(N+1)
squares[A] = 1

cost0 = squares[:X].sum()
costN = squares[X+1:].sum()

if cost0 >= costN:
    print(int(costN))
else:
    print(int(cost0))

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

const int MAX = 10000000;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/

/****** define variable start ******/
/*
ll n;
vl a;
*/
ll d, t, s;
/******* define variable end *******/
int solve() {
	cin >> d >> t >> s;
	if(t * s >= d){
		cout << "Yes" << endl;
	}else{
		cout << "No"<< endl;
	}
	/*
	cin >> n;
	a.resize(n);
	vl sumvec(n+1);
	sumvec[0] = 0;
	REP(i, n){
		cin >> a[i];
		sumvec[i+1] = sumvec[i] + a[i];
		sumvec[i+1] %= MOD;
	}
	ll ans = 0;
	REP(i, n){
		ans += (sumvec[n]  - sumvec[i+1]) * a[i];
		ans %= MOD;
	}
	ans %= MOD;
	cout << ans << endl;
	*/
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3636
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = 0;
        int m = 0;
        int s = 0;
        
        int a = sc.nextInt();
        
        while(a>=3600){
            a -= 3600;
            h++;
        }
        
        while(a>=60){
            a -= 60;
            m++;
        }
        
        s = a;
        
        
        System.out.println(h+":"+m+":"+s);
    }
}



Measured memory_bytes: 26248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int isEvenStr(string s){
	int ret = 1;
	int L = s.size();
	if((L % 2) != 0){
		return 0;
	}


	for(int i=0; i<L/2; i++){
		if(s[i] != s[(L/2)+i]){
			ret = 0;
			break;
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	while(true){
		S.pop_back();
		int r =isEvenStr(S);
		if(r == 1){
			break;
		}
	}
	printf("%d\n", (int)S.size());
	return 0;
}

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

struct UnionFind{
    vector<int> par;
    UnionFind(int n) : par(n){
       REP(i, n) par[i] = i;
    }
    int root(int x){
        if(x == par[x]) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(x < y) swap(x, y);
        par[x] = y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

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

    int n, k, l;
    cin >> n >> k >> l;

    UnionFind D(n), R(n);
    
    REP(i, k){
        int p, q;
        cin >> p >> q;
        p--; q--;
        D.unite(p, q);
    }

    REP(i, l){
        int r, s;
        cin >> r >> s;
        r--; s--;
        R.unite(r, s);
    }

    map<pair<int, int>, int> mp;

    REP(i, n){
        mp[make_pair(D.root(i), R.root(i))]++;
    }
    
    REP(i, n){
        if(i)cout << " ";
        cout << mp[make_pair(D.root(i), R.root(i))];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<double> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a.begin(),a.end());
double sum = a[0];
for(int i=1;i<n;i++){
    sum=(sum+a[i])/2;
}
cout<<setprecision(10)<<sum<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X);
  vector<long long> B(Y);
  vector<long long> C(Z);
  for (int i = 0; i < X; ++i) cin >> A[i];
  for (int i = 0; i < Y; ++i) cin >> B[i];
  for (int i = 0; i < Z; ++i) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());
  reverse(C.begin(), C.end());
  cout << A[0] + B[0] + C[0] << endl;
  --K;
  map<long long, bool> visited;
  visited[0] = true;
  priority_queue<vector<long long> > pq;
  if (1 < X)
    pq.push({A[1] + B[0] + C[0], 1, 0, 0});
  if (1 < Y)
    pq.push({A[0] + B[1] + C[0], 0, 1, 0});
  if (1 < Z)
    pq.push({A[0] + B[0] + C[1], 0, 0, 1});
  while (K > 0) {
    vector<long long> v;
    v = pq.top();
    pq.pop();
    long long code = v[1] * 1000000 + v[2] * 1000 + v[3];
    if (visited[code]) continue;
    visited[code] = true;
    cout << v[0] << endl;
    if (v[1] + 1 < X)
      pq.push({A[v[1] + 1] + B[v[2]] + C[v[3]], v[1] + 1, v[2], v[3]});
    if (v[2] + 1 < Y)
      pq.push({A[v[1]] + B[v[2] + 1] + C[v[3]], v[1], v[2] + 1, v[3]});
    if (v[3] + 1 < Z)
      pq.push({A[v[1]] + B[v[2]] + C[v[3] + 1], v[1], v[2], v[3] + 1});
    --K;
  }
  return 0;
}


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

//read_kaisetsu
int main() {
    string s;cin>>s;
    int n=s.size();
    int c_g=0;
    int c_p=0;
    int ans=0;
    rep(i,n){
        if(s[i]=='g')++c_g;
        else ++c_p;
    }
//    int ma = c_g - c_p;
//    reverse(s.begin(), s.end());
//    rep(i,ma)if(s[i]=='g')++ans;
    cout<<n/2 - c_p<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int A, B;
    string S;
    cin >> A >> B >> S;

    bool is_post = true;
    for(int i = 0; i < A; i++){
        if(!(S[i] - '0' >= 0 && S[i] - '0' < 10)){
            is_post = false;
        }
    }

    if(S[A] != '-'){
        is_post = false;
    }

    for(int i = A+1; i < A+B+1; i++){
        if(!(S[i] - '0' >= 0 && S[i] - '0' < 10)){
            is_post = false;
        }
    }

    if(is_post){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i = 0; i < 2; i++){
    s.erase(find(s.begin(), s.end(), ','));
  }
  s.insert(s.begin()+5, ' ');
  s.insert(s.begin()+13, ' ');
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3005;
ll dp[N][N];

// dp[n][m] = # of valid permutations first n characters ending in number m
// dp[n][m] = if > then add up dp[n-1][k >= m] if < add up dp[n-1][k < m]
string s;

int main(){
	fast_io();
	int n;
	cin >> n >> s;
	dp[0][1] = 1;
	cu(i,1,n){
		if(s[i-1] == '<'){
			ll rsum = 0;
			fu(nd,1,i + 1){
				dp[i][nd] = rsum;	
				rsum = (rsum + dp[i-1][nd]) % MOD;
			}
		}
		else{
			ll rsum = 0;
			fd(nd,i + 1,1){
				rsum = (rsum + dp[i-1][nd]) % MOD;
				dp[i][nd] = rsum;	
			}
		}
	}
	ll ans = 0;
	fu(i,1,n)ans = (ans + dp[n-1][i]) % MOD;
	cout << ans << '\n';
}


Measured memory_bytes: 68992
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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 (b < a) { a = b; return true; } return false; }

const int sqrt_n = 512;
struct SqrtDecomposition {
	int n, bucket_size;
	vector<int> data;
	vector<int> bucket;
	SqrtDecomposition(int n, int val = 0) :n(n) {
		assert(n);
		bucket_size = 1 + (n - 1) / sqrt_n;
		data.assign(bucket_size * sqrt_n, val);
		bucket.assign(bucket_size, val);
	}
	void update(int x, int y) {
		int k = x / sqrt_n;
		data[x] = y;
		int mini = y;
		for (int i = k * sqrt_n; i < (k + 1) * sqrt_n; i++) {
			chmin(mini, data[i]);
		}
		bucket[k] = mini;
	}
	int get_min(int l, int r) {
		int ret = data[l];
		for (int k = 0; k < bucket_size; k++) {
			int bl = k * sqrt_n, br = (k + 1) * sqrt_n;
			if (r <= bl || br <= l)
				continue;
			if (l <= bl && br <= r) {
				chmin(ret, bucket[k]);
			}
			else {
				for (int i = max(l, bl); i < min(r, br); i++) {
					chmin(ret, data[i]);
				}
			}
		}
		return ret;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SqrtDecomposition sd(n, INT_MAX);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com == 0) {
			sd.update(x, y);
		}
		else {
			cout << sd.get_min(x, y + 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3364
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<17, mod = 1e9 + 7;
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
oset sdi[maxn], sadi[maxn];
map<pair<ll, ll>, int> h;
map<pair<ll, ll>, int> id;
ll n, a, b, k, x[maxn], y[maxn], di[maxn], adi[maxn], rdi[maxn], radi[maxn], c[maxn];
void ins(int i) {
	id[{x[i], y[i]}] = i;
	sdi[di[i]].insert(x[i]);
	sadi[adi[i]].insert(x[i]);
	h[{x[i], y[i]}] = 1;
}
void del(int i) {
	id.erase({x[i], y[i]});
	sdi[di[i]].erase(x[i]);
	sadi[adi[i]].erase(x[i]);
	h[{x[i], y[i]}] = 0;
}
int range(oset &x, ll l, ll r) {
	return max(0, (int)x.order_of_key(r+1) - (int)x.order_of_key(l));
}
ll X[] = {0, 0, 0, 0}, Y[] = {0, 0, 0, 0};
int cnt(int i) {
	int C = 0;
	for(int t = 0; t < 4; t++) {
		ll *a = t<2?rdi:radi;
		int p = lower_bound(a, a+n, x[i] + (t<2?-y[i]:y[i]) + ((t&1)?-k:k))-a;
		if(a[p] == x[i] + (t<2?-y[i]:y[i]) + ((t&1)?-k:k)) {
			//cout << "HYPE\n";
			//cout << a[p] << " " << ((t&1)?x[i]-k:x[i]) << " ; " << ((t&1)?x[i]:(x[i]+k)) << " " << range((t<2?sdi[p]:sadi[p]), (t&1)?x[i]-k:x[i], (t&1)?x[i]:(x[i]+k)) << '\n';
			//for(auto i : (t<2?sdi[p]:sadi[p])) cout << i << ", "; cout << ":\n";
			//cout << x[i] + ((t&1) ? -k : k) << " " << y[i] + ((t&2) ? -k : k) << '\n';
			C += range((t<2?sdi[p]:sadi[p]), (t&1)?x[i]-k:x[i], (t&1)?x[i]:(x[i]+k));
		}
		C -= h[{x[i] + X[t], y[i] + Y[t]}];
	}
	return C;
} 
int get(int i) {
	for(int t = 0; t < 4; t++) {
		ll *a = t<2?rdi:radi;
		int p = lower_bound(a, a+n, x[i] + (t<2?-y[i]:y[i]) + ((t&1)?-k:k))-a;
		if(a[p] == x[i] + (t<2?-y[i]:y[i]) + ((t&1)?-k:k)) {
			oset &s = (t<2?sdi[p]:sadi[p]);
			auto it = s.lower_bound((t&1)?x[i]-k:x[i]);
			if(it != s.end() && *it <= ((t&1)?x[i]:(x[i]+k))) {
				return id[{*it, (x[i] + (t<2?-y[i]:y[i]) + ((t&1)?-k:k) - *it)*(t<2?-1:1)}];
			}
		}
	}
	return -1;
}
void dfs(int v) {
	del(v);
	while(cnt(v)) dfs(get(v));
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> a >> b; --b, --a;
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i], rdi[i] = x[i] - y[i], radi[i] = x[i] + y[i];
	k = abs(x[a]-x[b])+abs(y[a]-y[b]);
	X[0] = k, X[1] = -k, Y[2] = k, Y[3] = -k;
	for(ll *i : {radi, rdi}) sort(i, i+n);
	for(int i = 0; i < n; i++) di[i] = lower_bound(rdi, rdi+n, x[i]-y[i])-rdi;
	for(int i = 0; i < n; i++) adi[i] = lower_bound(radi, radi+n, x[i]+y[i])-radi;
	for(int i = 0; i < n; i++) ins(i);
	for(int i = 0; i < n; i++) c[i] = cnt(i);
	dfs(a);
	ll ans = 0;
	for(int i = 0; i < n; i++) if(!h[{x[i], y[i]}]) ans += c[i];
	cout << ans/2;
	return 0;
}


Measured memory_bytes: 82944
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    double d = INF;
    int ans;
    rep(i, n)
    {
        double tmp = t - h[i] * 0.006;
        double dd = abs(a - tmp);
        if (d > dd)
        {
            d = dd;
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256