akhauriyash/Code-Regression huggingface dataset:
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

/* SegTreeLazy<X,M>(n,fx,fa,fm,ex,em): モノイド(集合X, 二項演算fx,fa,fm, 単位元ex,em)についてサイズnで構築
    
  using X = int;
  using M = int;
  auto fx = [](X x1, X x2) { return min(x1, x2); };
  auto fa = [](X x, M m) { return m; };
  auto fm = [](M m1, M m2) { return m2; };
  int ex = numeric_limits<int>::max();
  int em = numeric_limits<int>::max();
  SegTreeLazy<X, M> seg(n, fx, fa, fm, ex, em);
  set(int i, X x), build(): 初期化
  update(int a, int b, X x) 更新
*/
template <typename X, typename M>
struct SegTreeLazy {
    using FX = function<X(X, X)>;
    using FA = function<X(X, M)>;
    using FM = function<M(M, M)>;
    int n;
    FX fx;
    FA fa;
    FM fm;
    const X ex;
    const M em;
    vector<X> dat;
    vector<M> lazy;
    SegTreeLazy(int n_, FX fx_, FA fa_, FM fm_, X ex_, M em_)
        : n(), fx(fx_), fa(fa_), fm(fm_), ex(ex_), em(em_), dat(n_ * 4, ex), lazy(n_ * 4, em) {
        int x = 1;
        while (n_ > x) x *= 2;
        n = x;
    }
    void set(int i, X x) { dat[i + n - 1] = x; }
    void build() {
        for (int k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
    }
    /* lazy eval */
    void eval(int k) {
        if (lazy[k] == em) return;  // 更新するものが無ければ終了
        if (k < n - 1) {            // 葉でなければ子に伝搬
            lazy[k * 2 + 1] = fm(lazy[k * 2 + 1], lazy[k]);
            lazy[k * 2 + 2] = fm(lazy[k * 2 + 2], lazy[k]);
        }
        // 自身を更新
        dat[k] = fa(dat[k], lazy[k]);
        lazy[k] = em;
    }
    void update(int a, int b, M x, int k, int l, int r) {
        eval(k);
        if (a <= l && r <= b) {  // 完全に内側の時
            lazy[k] = fm(lazy[k], x);
            eval(k);
        } else if (a < r && l < b) {                     // 一部区間が被る時
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);  // 左の子
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);  // 右の子
            dat[k] = fx(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(int a, int b, M x) { update(a, b, x, 0, 0, n); }
    X query_sub(int a, int b, int k, int l, int r) {
        eval(k);
        if (r <= a || b <= l) {  // 完全に外側の時
            return ex;
        } else if (a <= l && r <= b) {  // 完全に内側の時
            return dat[k];
        } else {  // 一部区間が被る時
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
    X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
};


int main() {
  int n, q; cin >> n >> q;
  using X = int;
  using M = int;
  auto fx = [](X x1, X x2) { return x1 + x2; };
  auto fa = [](X x, M m) { return x + m; };
  auto fm = [](M m1, M m2) { return m2; };
  int ex = 0;
  int em = 0;
  SegTreeLazy<X, M> seg(n+1, fx, fa, fm, ex, em);
  loop(i,0,n+1) seg.set(i, 0);
  seg.build();
  loop(i,0,q) {
    int com, x, y; cin >> com >> x >> y;
    if (com == 0)  seg.update(x, x+1, y);
    else cout << seg.query(x, y+1) << endl;
  }
  return 0;
}



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

using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
template<class T> void writerLn(T x) { writer(x, '\n'); }
#define rep(i,n)for(int i=0;i<n;i++)
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000]{ 1 };
deque<int>que;

void bfs(int u, int t) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.emplace_back(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)writerLn(ans[i]);
}

Measured memory_bytes: 13472
#include <iostream>

using namespace std;

int main(void)
{
	int input[10];

	for(int i = 0; i < 10; i++){
		cin >> input[i];
	}

	for(int i = 0; i < 3; i++){
		for(int j = i; j < 10; j++){
			if(input[j] > input[i]){
				swap(input[j], input[i]);
			}
		}
	}


	for(int i = 0; i < 3; i++){
		cout << input[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  ll ans = 0;
  for (ll m: b) {
    ll l = lower_bound(ALL(a), m) - a.begin();
    ll r = n - (upper_bound(ALL(c), m) - c.begin());
    if (!(0 <= l && l <= n) || !(0 <= r && r <= n)) continue;
    ans += l * r; 
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 5632
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

#define N 200005

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a, b;
int n, k, l;

bool vis[N];

int szA[N], szB[N];
int prA[N], prB[N];

map <pii, int> M;

//vector <int> E[N], Rail[N], Road[N], T;

int PA(int x)
{
	if (prA[x] == x)
		return x;
	return prA[x] = PA(prA[x]);
}

int PB(int x)
{
	if (prB[x] == x)
		return x;
	return prB[x] = PB(prB[x]);
}

void uniA(int a, int b)
{
	int x = PA(a);
	int y = PA(b);
	
	if (szA[x] < szA[y])
		swap(x, y);
	
	prA[y] = x;
	szA[x]+=szA[y];
}

void uniB(int a, int b)
{
	int x = PB(a);
	int y = PB(b);
	
	if (szB[x] < szB[y])
		swap(x, y);
	
	prB[y] = x;
	szB[x]+=szB[y];
}

int main()
{
	scanf("%d%d%d", &n, &k, &l);
	
	for (int i = 1; i <= n; i++)
		szA[i] = szB[i] = 1, prA[i] = prB[i] = i;
	
	FOR (i, 1, k) {
		scanf("%d%d", &a, &b);
		uniA(a, b);
		/*E[a].pb(b);
		E[b].pb(a);
		Road[a].pb(b);
		Road[b].pb(a);*/
	}
	
	FOR (i, 1, l) {
		scanf("%d%d", &a, &b);
		/*E[a].pb(b);
		E[b].pb(a);
		Rail[a].pb(b);
		Rail[b].pb(a);*/
		uniB(a, b);
	}
	
	FOR (i, 1, n)
		M[{PA(i), PB(i)}]++;
	
	FOR (i, 1, n)
		printf("%d ", M[{PA(i), PB(i)}]);	
}


Measured memory_bytes: 15104
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define Rep(i,a) for(int i = 0; i < (a); i++)
#define rep(i,a,b) for(int i = (a); i <= (b); i++)//(a)!
#define dep(i,a,b) for(int i = (a); i >= (b); i--)
#define ab(a) ((a) > 0 ? (a) : -(a))
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int N = 100010;
int p[N], q[N];
typedef pair<int, int> node;
node s[N << 1];
int main() {
	int W, H; scanf("%d%d",&W,&H);
	rep(i,1,W) scanf("%d",&p[i]), s[i] = mp(p[i], 0);
	rep(i,1,H) scanf("%d",&q[i]), s[W + i] = mp(q[i], 1);
	sort(s + 1, s + W + H + 1);
	s[0] = mp(0,0);
	int cnt[2] = {0,0};
	LL ans = (1LL * (W + 1) * (H + 1) - 1) * s[1].first;
	rep(i,1,W + H) {
		cnt[s[i].second]++;
		LL c;
		if (cnt[0] && cnt[1]) c = 1LL * (W - cnt[0]) * (H - cnt[1]) + (H - cnt[1]) + (W - cnt[0]) + 1;
		else c = 1LL * (W - cnt[0] + 1) * (H - cnt[1] + 1);
		ans += (c - 1) * (s[i + 1].first - s[i].first);
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 2688
import sys
input=sys.stdin.readline  #危険！基本オフにしろ！

def BELLMANFORD(point,n,d,p):
    cost       = [1e18]*(n+1)  #infじゃないと閉路検出がうまくいかない
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for nownode,nextnode,c in d:
            if cost[nextnode]>cost[nownode]+c+p:
                cost[nextnode]=cost[nownode]+c+p

    negative=[0]*(n+1)                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定 negativeの1は閉路に入っている部分を表す
        for nownode,nextnode,c in d:
            if negative[nownode]:
                negative[nextnode]=1
            if cost[nextnode]>cost[nownode]+c+p and cost[nextnode]<1e17 and cost[nownode]+c+p<1e17:
                cost[nextnode]=cost[nownode]+c+p
                #print(cost[nextnode],cost[nownode]+c+p)
                negative[nownode]=1
    #print(cost)
    #print(negative)
    return cost,negative

def main():    
    n,m,p=map(int,input().split())
    
    d=[]
    for i in [0]*m:
        a,b,c=map(int,input().split())
        d.append((a,b,-c))
    
    x,y=(BELLMANFORD(1,n,d,p))
    
    if y[n]==1:
        print(-1)
    else:
        print(max(-x[n],0))

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 44764
#include <bits/stdc++.h>
#define cincout
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
#define abs(x) ((x) < 0 ? -(x) : (x))
using namespace std;


int cov[3005];
vector <int> adjlist[3005];
int n,m,k,ans;
int inp_a,inp_b;
int get_deg(int u) {
	int ret=0;
	for (int i=0;i<adjlist[u].size();++i) {
		if (!cov[adjlist[u][i]]) ++ret;
	}
	return ret;
}

void rek(int tmp_ans) {
	if (tmp_ans > k) return;
	int deg_u;
	for (int i=1;i<=n;++i) {
		if (cov[i] || (deg_u=get_deg(i))==0) continue;
		else if (deg_u==1) {
			int neigh;
			for (int j=0;j<adjlist[i].size();++j) {
				if (!cov[adjlist[i][j]] && get_deg(adjlist[i][j]) > 0) {
					neigh=adjlist[i][j];
					break;
				}
			}
			cov[neigh]=true;
			rek(tmp_ans+1);
			cov[neigh]=false;
			return;
		}
	}
	for (int i=1;i<=n;++i) {
		if (cov[i] || (deg_u=get_deg(i))==0) continue;
		else {
			cov[i]=true;
			rek(tmp_ans+1);
			cov[i]=false;
			vector <int> dat;
			int cnt=0;
			for (int j=0;j<adjlist[i].size();++j) {
				if (!cov[adjlist[i][j]] && get_deg(adjlist[i][j]) > 0) {
					dat.push_back(adjlist[i][j]);
					++cnt;
				}
			}
			for (int j=0;j<cnt;++j) cov[dat[j]]=true;
			rek(tmp_ans+cnt);
			for (int j=0;j<cnt;++j) cov[dat[j]]=false;
			return;
		}
	}
	ans=min(ans,tmp_ans);
}


int main() {
	#ifdef cincout
		cin.sync_with_stdio(0);
		cin.tie(0);
	#endif
	memset(cov,false,sizeof(cov));
	cin >> n >> m >> k;
	for (int i=0;i<m;++i) {
		cin >> inp_a >> inp_b;
		adjlist[inp_a].push_back(inp_b);
		adjlist[inp_b].push_back(inp_a);
	}
	ans=1000000;
	rek(0);
	if (ans>k) cout << "Impossible\n";
	else cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1688
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	string s;int ans1=0,ans2=0;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='C') ans1++;
		if(s[i]=='F'&&ans1!=0) ans2++; 
	}
	if(ans1!=0&&ans2!=0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

typedef struct{
	char order[10];
	char word[15];
	int tag;
} input;

int conv(char *word){
    int n = strlen(word);
    int temp=0;
    int k=0, m = 1;
    int i;
    for(i=0; i<n; i++){
        switch (word[i]){
            case 'A':
                temp=1;
                break;
            case 'C':
                temp=2;
                break;
            case 'G':
                temp=3;
                break;
            case 'T':
                temp=4;
                break;
        }
        k += temp*m;
        m = m * 5;
    }
    return k;
}

int main(void){
    int n;
    int i;
    int k;
    int j=0;
    input *in;
    int *dict;
    scanf("%d", &n);
    in =(input*)malloc(n*sizeof(input));
    dict = (int*)malloc(245000000*sizeof(int));
	memset(dict, '0', sizeof(dict));
    for(i=0; i<n; i++){
        scanf("%s", &in[i].order);
        scanf("%s", &in[i].word);
    	in[i].tag = conv(in[i].word);
    }
    for(i=0; i<n; i++){
        if(strcmp(in[i].order, "insert")==0){
            dict[in[i].tag]=1;
            j++;
        }else{
            if(dict[in[i].tag]==1){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    free(in);
    free(dict);
    return 0;
}


Measured memory_bytes: 49548
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N;
	cin >> N;
	int A;
	for(int i = 0; i < N; i++){
		cin >> A;
		if(A%2 != 0)continue;
		if(A%3 != 0 && A%5 != 0){
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;

	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}

void solve()
{
	ll n,m,flag=0,x,y;
	cin>>n>>m;
	vll h(n+1);
	for(ll i=1;i<=n;i++)
		cin>>h[i];
	vector<pair<ll,ll>> a(m);
	for(ll i=0;i<m;i++)
		cin>>a[i].ff>>a[i].ss;
	vll b(n+1,0);
	for(ll i=0;i<m;i++)
	{
		// cout<<a[i].ff<<a[i].ss;
		if(h[a[i].ff]<=h[a[i].ss])
			b[a[i].ff]=1;
		if(h[a[i].ss]<=h[a[i].ff])
			b[a[i].ss]=1;
		// cout<<b[a[i].ff]<<b[a[i].ss]<<endl;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		if(b[i]==0)
			ans++;
	}
	cout<<ans;
		return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 6372
x, k, d = map(int, input().split())
x = abs(x)
if k*d < x:
    print(abs(x-k*d))
    exit(0)

i = x//d
def calc(t):
    return abs(x - t * d)
if k%2 ==0:
    if i%2==0:
        print(min(calc(i), calc(i+2)))
        exit(0)
    else:
        print(min(calc(i-1), calc(i + 1)))
        exit(0)
else:
    if i%2==0:
        print(min(calc(i-1), calc(i+1)))
        exit(0)
    else:
        print(min(calc(i), calc(i + 2)))
        exit(0)

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

using namespace std;

template<class T>
using V = vector<T>;
template<class T>
using VV = V<V<T>>;

using ld = long double;
#define ll long long
using ull = unsigned ll;
using PLL = pair<ll, ll>;
using VLL = V<ll>;
using VB = V<bool>;
using VVB = VV<bool>;
using VVLL = VV<ll>;
using Gr = VVLL;
using MLL = map<ll, ll>;
#define UMLL unordered_map<ll, ll, custom_hash>
//typedef __int128 int128;
//typedef __float128 double128;

#define fast ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);

#define INF LLONG_MAX
#define MINF LLONG_MIN

#define R &
#define CR const R

#define FORI(i, a, b) for(ll i = a, max##i = b; i < max##i; ++i)
#define FOR(i, n) FORI(i, 0, n)
#define RFORI(i, a, b) for(ll i = a, min##i = b; i >= min##i; --i)
#define RFOR(i, n) RFORI(i, n, 0)
#define FORA(i, a) for(auto i : a)
#define FORAR(i, a) for(auto R i : a)
#define FORACR(i, a) for(auto CR i : a)
#define ALL(obj) begin(obj), end(obj)
#define Count(q) while(q--)
#define OK cerr << "OK\n";

#define mp make_pair
#define pb push_back

//#define DEBUG

template<class T>
T sqr(T x)
{
    return x * x;
}

void YES(bool g, ostream R os, bool upper = false)
{
    if(g)
        if(upper)
            os << "YES";
        else
            os << "Yes";
    else
        if(upper)
            os << "NO";
        else
            os << "No";

    os << "\n";
}

template<class T>
ll cast(T CR t)
{
    return static_cast<ll>(t);
}

template<class T>
void show(T CR t, ostream R os = cerr)
{
    FORACR(i, t)
        os << i << " ";
    os << "\n";
}

constexpr ll MOD = 1e9 + 7;
//constexpr ll len = 2 * ('z' - 'a' + 1);
//constexpr ld eps = 1e-9;

//constexpr ld unreal = -1e9;

constexpr ld PI = atanl(1.0L) * 4;

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator() (uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve(istream R is, ostream R os)
{
    ld d, t, s;
    is >> d >> t >> s;
    YES(d / s <= t, os, 0);
}

int main()
{
    fast
    ll q = 1;
    //cin >> q;
    cout << setprecision(999);
    Count(q)
        solve(cin, cout);
}


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

typedef long long ll;

ll N, M;
vector<vector<ll>> Adj;
vector<ll> Res;
queue<pair<ll, ll>> Q;

int main() {
  cin >> N >> M;
  Adj.resize(N);
  for (ll i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    Adj[a].push_back(b);
    Adj[b].push_back(a);
  }
  cout << "Yes" << endl;
  Res.resize(N, -1);
  Res[0] = 0;
  Q.push({0, 0});
  while (!Q.empty()) {
    ll from, now;
    tie(from, now) = Q.front();
    Q.pop();
    for (ll to : Adj[now]) {
      if (Res[to] == -1) {
        Res[to] = now;
        Q.push({now, to});
      }
    }
  }
  for (ll v = 1; v < N; ++v) {
    cout << Res[v] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 13536
import sys
from collections import deque
sys.setrecursionlimit(10**7)
inf=float("inf")

def BFS(x,y):
    color=[["white" for _ in range(w+2)] for _ in range(h+2)]
    D=[[inf for _ in range(w+2)] for _ in range(h+2)]

    color[x][y]="gray"
    D[x][y]=1
    queue=deque([[x,y]])
    while len(queue)!=0:
        a,b=queue.popleft()
        for c,d in ((1,0),(0,1),(-1,0),(0,-1)):
            X,Y=a+c,b+d
            if S[X][Y]=="." and color[X][Y]=="white":
                color[X][Y]="gray"
                D[X][Y]=D[a][b]+1
                queue.append([X,Y])
        color[a][b]="black"

    return D


h,w=map(int,input().split())
S=[["#"]+list(input())+["#"] for _ in range(h)]
S.insert(0,["#"]*(w+2))
S.append(["#"]*(w+2))
D=BFS(1,1)

black=0
for i in range(1,h+1):
    black +=S[i][1:w+1].count("#")
print(h*w-black-D[h][w] if D[h][w]!=inf else -1)

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int a,b;
    cin >> a >> b;
    
    
    for(int i=1;i<=10000;i++){
        int x = i*0.08;
        int y = i*0.1;
        if(x==a&&y==b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 100010 };

int best[MAX];

ll solve(int N, int K, const vector<ii>& xs)
{
    map<int, vector<ll>> ts;

    for (int i = 1; i <= N; ++i)
    {
        auto t = xs[i].first;
        auto d = xs[i].second;

        ts[t].push_back(d);
    } 

    for (const auto& p : ts)
    {
        auto t = p.first;

        sort(ts[t].begin(), ts[t].end(), greater<ll>());
    }

    // pb = melhores de cada tipo
    // pa = demais de cada tipo
    priority_queue<ll> pa, pb;

    for (const auto& p : ts)
    {
        auto ys = p.second;

        pb.push(ys.front());

        for (size_t i = 1; i < ys.size(); ++i)
            pa.push(ys[i]);
    }

    ll ans = 0, x = 0;
    priority_queue<ll, vector<ll>, greater<ll>> ps;     // Min heap dos escolhidos

    // Escolhe os melhores com tipos distintos
    while (not pb.empty() and x < K)
    {
        ++x;
        ans += pb.top();
        ps.push(pb.top());
        pb.pop();
    }

    ll n = x;           // Total já escolhido

    while (not pa.empty())
    {
        auto d = pa.top();
        pa.pop();

        if (n < K)      // Ainda não escolheu todos os K elementos: pega sem adicionar em x
        {
            ++n;
            ans += d;
            continue;
        }

        auto m = ps.top();

        if (ans + x*x < (ans - m) + d + (x - 1)*(x - 1))
        {
//cout << "Troca " << m << " por " << d << " diminuindo x para " << x - 1 << '\n';
            ans -= m;
            ans += d;
            x--;
            ps.pop();
            ps.push(d);
        }
    }
        
    return ans + x * x;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    vector<ii> xs(N + 1);

    for (int i = 1; i <= N; ++i)
        cin >> xs[i].first >> xs[i].second;

    cout << solve(N, K, xs) << '\n';

    return 0;
}


Measured memory_bytes: 13684
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int solve(vector<int>& a, const int k) {
  int size = a.size();
  int cnt{};
  while (size > k + (k - 1) * (cnt - 1)) {
    ++cnt;
  }
  return cnt;
}

int main() {
  int n, k;
  vector<int> a;
  cin >> n >> k;
  REP(i, n) {
    int ai;
    cin >> ai;
    a.push_back(ai);
  }
  cout << solve(a, k) << endl;
}


Measured memory_bytes: 892
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	repi(i,1, n) {
		ans += (n - 1) / i;
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


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

using namespace std;

#define rep0(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repU(i,bottom,ceiling) for(int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(int (i)=(ceiling);(i)>=(bottom);(i)--)
#define V vector
#define Vi vector<int>
#define VVi vector<vector<int>>
#define Vdb vector<double>
#define VVdb vector<vector<double>>
#define pub push_back
#define pob pop_back
#define pf printf
#define sf scanf
#define ci(a) cin>>a
#define lco(a) cout<<a<<endl
#define co(a) cout<<a
#define Vci(v) for(int i=0;i<v.size();i++) cin>>v[i]
#define Vco(v) for(int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define P pair
#define Pii pair<int,int>
#define mP make_pair
#define fir first
#define sec second
#define Re return 

typedef long long ll;
typedef double db;

const string alphabet("abcdefghijklmnopqrstuvwxyz");
const vector<pair<int,int>> dir={{0,0},{1,0},{1,1},{0,1},{-1,1},{0,-1},{-1,-1},{0,-1},{1,-1}};
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const int Inf=(int)2e9+1e8;
const int Mod=(int)1e9+7;

template <typename T,typename U>                                                   
pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template <typename T,typename U> 
pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template <typename T,typename U>                                                   
pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template <typename T,typename U>                                                   
pair<T,U> operator/(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir/r.fir,l.sec/r.sec};                                    
}

template <typename T> void Swap(T *x,T *y){ T tem=*x; *x=*y; *y=tem; }

long long int rem(long long int n,long long int m){
	if(!m) return 0;
	return (n<0?(n%m)+m:(n%m));
}
             
/*The main code follows below*/

int main(){
	ll a,b;
	//s[300005];
	ci(a>>b);
	lco(max(max(a*b,a+b),a-b));
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int X, N;
  cin>>X>>N;
  int ans = inf;
  map<int, int> amap;
  int p;
  for(int i=0;i<N;++i){
    cin>>p;
    amap[p]++;
  }
  for(int i=1000;i>=-1000;--i){
    if(amap[i]>0) continue;
    if(abs(ans-X) >= abs(i-X)) ans = i;
  }
  cout<<ans<<endl;
}



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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#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 each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n, m, d; cin >> n >> m >> d;
	vector<string>v(n);
	rep(i, 0, n)cin >> v[i];
	int ans(0);
	rep(i, 0, n) {
		for (int j = 0; j + d <= m; j++) {
			if (count(v[i].begin() + j, v[i].begin() + j + d, '.') == d)ans++;
		}
	}
	vector<string>w;
	rrep(i, 0, m) {
		string s;
		rep(j, 0, n)s.push_back(v[j][i]);
		w.push_back(s);
	}

	rep(i, 0, m) {
		for (int j = 0; j + d <= n; j++) {
			if (count(w[i].begin() + j, w[i].begin() + j + d, '.') == d)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(H);CIN(W);
    CIN(N);
    I vec;
    REP(a,N){
        CIN(b);
        vec.pb(b);
    }
    int w = 0;
    REP(a,H){
        vector<int> v;
        REP(b,W){
        if(vec.at(w)==0)w++;
        v.pb(w+1);
        vec.at(w)--;
        }
        if(a%2==1){
           reverse(ALL(v));
        }
        REP(a,W-1){
            cout<<v.at(a)<<" ";
        }
        cout<<v.at(W-1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
  int N,minj,i,j,flag=1,count=0,regard,sign=0,n;
  scanf("%d",&N);
  int insert[N];
  for(j=0;j<N;j++)
    {
      scanf("%d",&insert[j]);
    }
  for(i=0;i<N;i++)
    {
      minj=i;
      for(j=i;j<N;j++)
	{
	  if(insert[j]<insert[minj])
	    {
	      count=1;
	      minj=j;
	    }
	  if(count==1&&j==N-1)
	    {
	  sign++;
	  count=0;
	    }
	}
     regard=insert[minj];
	      insert[minj]=insert[i];
	      insert[i]=regard;
    }
  for(j=0;j<N-1;j++)
    {
       printf("%d ",insert[j]);
    }
  printf("%d\n",insert[N-1]);
  printf("%d\n",sign);
  return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>

void call(int);

int main(){
	
	int n;
	
	scanf("%d",&n);
	
	call(n);
	
	return 0;
}

void call(int n){
	int x,i;
	
	for(i=1 ;i<=n ;i++){
		x = i;
		if( x%3 == 0){
			printf(" %d",i);
		}else if( x%10 == 3 ){
			printf(" %d",i);
		}else{
			for(; x>0;){
				x /= 10;
				if( x%10 ==3){
					printf(" %d",i);
					break;
				}
			}
		}
	}
	printf("\n");
}


Measured memory_bytes: 2092
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<ll> h(n);
    cins(all(h));
    vector<vector<int>> g(n);
    ll a,b;
    rep(i,m){
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ll ans = 0;
    rep(i,n){
        bool ok = 1;
        for (ll v:g[i]){
            if (h[v] >= h[i]) ok = 0;
        }
        if (ok) ans++;
    }
    PRINT(ans);
}


Measured memory_bytes: 9240
#include<stdio.h>

int main(void)
{
  int n,m,i;
  int sum = 0;
  int a[10000];
  
  scanf("%d",&n);
  scanf("%d",&m);
  
  for(i = 0;i < m;i++){
    scanf("%d",&a[i]);
    sum = sum + a[i];
  }
  
  if(n - sum >= 0)
    printf("%d\n",n - sum);
  
  else
    printf("-1\n");
  
  return 0;
}

Measured memory_bytes: 1692
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 1e5 + 100, OO = 1e9, T = 4500 + 100, M = 924844033, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
bool is[N];
int cnt[N];

int32_t main() {
	use_fast;
	int n, m, ans = 0;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cnt[i] = 1;
	is[1] = true;
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		cnt[x]--;
		cnt[y]++;
		if(is[x])
			is[y] = true;
		if(cnt[x] == 0)
			is[x] = false;
	}
	for(int i = 1; i <= n; i++)
		if(is[i])
			ans++;
	cout << ans << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 4460
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<vector<ll>> v(n);
    rep(i, n - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        ll c = min(a, b);
        ll d = max(a, b);
        v[c].push_back(d);
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        ans += (n - i) * (1 + n - i) / 2;
    }
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < v[i].size(); j++)
        {
            ll temp = (i + 1) * (n - v[i][j]);
            ans -= temp;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 14296
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type rec struct {
	a, b int
}
type recs []rec

func (r recs) Len() int {
	return len(r)
}
func (r recs) Less(i, j int) bool {
	return r[i].a < r[j].a
}
func (r recs) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	rs := make([]rec, n)
	for i := 0; i < n; i++ {
		rs[i].a = nextInt(sc)
		rs[i].b = nextInt(sc)
	}
	sort.Sort(recs(rs))
	for i := 0; i < n; i++ {
		if k-rs[i].b > 0 {
			k -= rs[i].b
		} else {
			fmt.Println(rs[i].a)
			return
		}
	}
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll, ll> P;

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

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

#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind() {}

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};

int main() {
	ll n;
	cin >> n;
	map<int, int> ms;
	rep(i, n) {
		int a;
		cin >> a;
		ms[a]++;
	}
	if (ms.size() % 2 == 1) {
		cout << ms.size() << endl;
	}
	else {
		cout << ms.size() - 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 8188
n=int(input())

a=[int(input())-1 for i in range(n)]
c=[-1 for i in range(n)]
cu=0
c[cu]=0
for i in range(n):
  cu=a[cu]
  if c[cu]>0:
    break
  c[cu]=i+1
  
print(c[1])

Measured memory_bytes: 11052
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b;cin>>a>>b;
  int f=1;
  if(a>0){
    f=1;
  }
  else if(b<0){
    if((b-a)%2)f=1;
    else f=0;
  }
  else {
    cout<<"Zero"<<endl;
    return 0;
  }

  if(f)cout<<"Positive"<<endl;
  else cout<<"Negative"<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t1, t2;
  ll a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (a1*t1 < b1*t1 && a1*t1+a2*t2 < b1*t1+b2*t2) { //追い越しが発生しない
    cout << 0 << endl;
    return 0;
  }
  if (a1*t1 > b1*t1 && a1*t1+a2*t2 > b1*t1+b2*t2) {
    cout << 0 << endl;
    return 0;
  }
  ll d1 = a1*t1+a2*t2, d2 = b1*t1+b2*t2;
  ll dist = abs(d1-d2);
  if (!dist) {
    cout << "infinity" << endl;
    return 0;
  }
  ll n = abs(a1-b1)*t1/dist; //このnはまだ追い越し発生条件を満たしているので、あと1ターン残っている
  ll ans = n*2-1; //最初のターンは並んでスタートするので1回しか追い越しが発生しない
  if (dist*n+min(a1, b1)*t1 < max(a1, b1)*t1) //この後1回完全に追い越す場合、追い越されも発生するので+2
    ans += 2;
  else //追い越すのではなく並ぶパターンは+1
    ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"YES":"NO")<<endl;}
int main(){
	
	int n,y;
	int Y=0;
	int ans[3]={-1,-1,-1};
	cin >>n >>y;
	for(int a=0;a<=n;a++){
		for(int b=0;b<=(n-a);b++){
			if(a*1000 + b*5000 + (n-a-b)*10000 == y){
				ans[0]=n-a-b;
				ans[1] = b;
				ans[2] = a;
			}
		}
	}
	printf("%d %d %d\n",ans[0],ans[1],ans[2]);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int n;
    cin >> n;
    ll a[n];
    REP(i, n) cin >> a[i];
    deque<ll> dq;
    REP(i, n){
        if(i%2==0){
            dq.push_back(a[i]);
        }else{
            dq.push_front(a[i]);
        }
    }
    if(n%2==1){
        REP(i, n){
            cout << dq[n-1-i] << " ";
        }
    }else{
        REP(i, n){
            cout << dq[i] << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5376
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

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

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< long long int, long long int > prime_factor(long long int n) {//素因数分解
    map< long long int, long long int > ret;
    for(long long int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {

    int A,B;
    cin >> A >> B;

    if((A+B)%2==0){
        cout << (A+B)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}








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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, FiniteField x) { s << x.Value(); return s; }

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  cin >> n;
  int64 d_1, d_2;
  cin >> d_1 >> d_2;

  vector<int64> vs(n + 1);
  vs[0] = -2E18;
  for (int i = 1; i <= n; i++) {
    cin >> vs[i];
  }

  vector<FiniteField> dp_1(n);
  vector<FiniteField> dp_2(n);
  vector<FiniteField> cs_1(n + 1);
  vector<FiniteField> cs_2(n + 1);
  int z_1 = 0;
  int z_2 = 0;
  dp_1[0] = 1;
  dp_2[0] = 1;
  cs_1[1] = 1;
  cs_2[1] = 1;

  for (int k = 2; k <= n; k++) {
    int i_1 = distance(vs.begin(), upper_bound(vs.begin(), vs.end(), vs[k] - d_1));
    i_1 = min(i_1, k - 1);
    if (i_1 > z_2) {
      dp_1[k - 1] = cs_2[i_1] - cs_2[z_2];
    }
    cs_1[k] += cs_1[k - 1] + dp_1[k - 1];

    int i_2 = distance(vs.begin(), upper_bound(vs.begin(), vs.end(), vs[k] - d_2));
    i_2 = min(i_2, k - 1);
    if (i_2 > z_1) {
      dp_2[k - 1] = cs_1[i_2] - cs_1[z_1];
    }
    cs_2[k] += cs_2[k - 1] + dp_2[k - 1];

    if (vs[k] - vs[k - 1] < d_1) {
      z_1 = k - 1;
    }
    if (vs[k] - vs[k - 1] < d_2) {
      z_2 = k - 1;
    }
  }

  FiniteField ans = 0;
  ans += cs_1[n] - cs_1[z_1];
  ans += cs_2[n] - cs_2[z_2];
  cout << ans << endl;
}

Measured memory_bytes: 7116
#include<string>
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans=0;
    int i;
    int len=s.length()-2;
    for(i=0;i<=len;i++)
    {
        if(s[i]!=s[i+1]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512