akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define int long long
using namespace std;
//const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
int N;
int a[200010], b[200010];

vector<int> G[200010];

P find(int x)
{
    int e[200010] = {};
    e[x] = 1;
    int m = 0;
    int E = 0;
    queue<int> que;
    que.push(x);
    while (!que.empty()) {
        int q = que.front();
        que.pop();
        for (int i = 0; i < (int)G[q].size(); i++) {
            int I = G[q][i];
            if (!e[I]) {
                e[I] = e[q] + 1;
                que.push(I);
                if (m < e[I]) {
                    m = e[I];
                    E = I;
                }
            }
        }
    }
    return P(E, m);
}

void solve()
{
    for (int i = 0; i < N; i++) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    P p = find(1);
    P q = find(p.first);
    int n = q.second;

    if ((n % 3) == 2) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
}

signed main()
{
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 15092
import math

N = int(input())
rate = 1.08
# print((N / rate))
# print((N + 1) / rate)
a = math.ceil(N / rate)
b = math.ceil((N + 1) / rate)
# print(a)
# print(b)
if a >= b:
    print(":(")
else:
    # assert math.floor(a * rate) == N
    print(a)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int cost[100005],h[100005];

int  fun(int n,int k)
{
	if(n==0)
	{
		cost[0]=0;
		return 0;
	}
	if(n==1)
	{
		cost[1]=abs(h[1]-h[0]);
		return cost[1];
	}
	if(cost[n]!=-1)
		return cost[n];
	int min=0;
	for(int i=1;i<=k;i++)
	{
		if(n-i < 0)
			break;
		int value=fun(n-i,k);
		if(i==1 ||( min > (value+abs(h[n]-h[n-i]))))
			min=value+abs(h[n]-h[n-i]);
	}
   cost[n]=min;

   return cost[n];

}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>h[i];
for(int i=0;i<n;i++)
cost[i]=-1;
fun(n-1,k);
cout<<cost[n-1]<<endl;

return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
	while(b<=a)
	{
		ans++;
		b*=2;
	}
	while(c<=b)
	{
		ans++;
		c*=2;
	}
	if(ans<=k)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
template<typename weight_t> using graph = vector<vector<pair<int,weight_t>>>;
template<typename weight_t> vector<weight_t> dijkstra(const graph<weight_t> &g,const int e,const int goal=-1){
    using node=pair<int,weight_t>; auto cmp=[](node &a,node &b)->bool {return (a.second>b.second);};
    priority_queue<node,vector<node>,decltype(cmp)> pq(cmp);
    vector<weight_t> w(g.size(),numeric_limits<weight_t>::max());
    vector<bool> done(g.size(),false);
    pq.push({e,0}); w[e]=0;
    while(!pq.empty()){ auto u=pq.top(); pq.pop(); 
        if(done[u.first])continue;
        for(auto &v:g[u.first]){
        if(w[u.first]+v.second<w[v.first]){
            w[v.first]=w[u.first]+v.second; pq.push({v.first,w[v.first]});
        }}
        done[u.first]=true;
        if(goal>=0&&done[goal])break;
    }
    return w;
}
int main(){
    double xs,ys,xt,yt;
    int n;
    cin >> xs >> ys >> xt >> yt >> n;
    vector<double> x(n+2),y(n+2),r(n+2);
    x[0]=xs;
    y[0]=ys;
    x[1]=xt;
    y[1]=yt;
    rep(i,2,n+2){
        cin >> x[i] >> y[i] >> r[i];
    }
    graph<double> g(n+2);
    auto dist = [&](double xi,double yi,double xj,double yj)->double{
        return sqrt((xi-xj)*(xi-xj)+(yi-yj)*(yi-yj));};
    loop(i,n+1)rep(j,i+1,n+2){
        double d=max(0.0,dist(x[i],y[i],x[j],y[j])-r[i]-r[j]);
        g[i].push_back({j,d});
        g[j].push_back({i,d});
    }
    auto ans=dijkstra(g,0,1);
    cout << setprecision(10) << ans[1] << endl;
    return 0;
}

Measured memory_bytes: 22768
//
//  honestorunkind2.cpp
//  my_programs
//
//  Created by Jiatuo Zou on 7/27/20.
//  Copyright © 2020 Jiatuo Zou. All rights reserved.
//

#include <iostream>
using namespace std;

int f = 0;

int combination(int n, int xy[][2], int A[], int b[], int d, int MAX){
    if(d == n){
        f = 0;
        for(int i = 1; i <= n; i++){
            for(int j = A[i - 1]; j < A[i]; j++){
                if(b[i - 1] == 1 && b[xy[j][0] - 1] != xy[j][1]){
                    f = 1;
                    break;
                }
            }
            if(f == 1){
                break;
            }
        }
        if(f == 0){
            for(int i = 0; i < n; i++){
                if(b[i] == 1){
                    f++;
                }
            }
            MAX = max(MAX, f);
        }
    }
    if(d < n){
        for(int i = 0; i <= 1; i++){
            b[d] = i;
            MAX = combination(n, xy, A, b, d + 1, MAX);
        }
    }
    return MAX;
}

int main()
{
    int n, xy[210][2] = {{0}}, A[16] = {0}, b[15];
    cin >> n;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        A[i] += (a + A[i - 1]);
        for(int j = A[i - 1]; j < A[i]; j++){
            cin >> xy[j][0] >> xy[j][1];
        }
    }
    cout << combination(n, xy, A, b, 0, 0) << endl;
    return 0;
}


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

int main(){
	vector<int>x(5);
	rep(i,5)cin>>x[i];
	rep(i,5){
		if(x[i]==0)cout<<i+1<<endl;
	}
	return 0;
}

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

 
int main() {
    
    
    ll x,k,d; cin>>x>>k>>d;
    x=abs(x);
    ll n=x/d;
    if(n>=k)cout<<x-k*d<<endl;
    else
    {
        ll a=x-n*d;
        ll b=abs(a-d);
        k-=n;
        if(k%2==1)cout<<b<<endl;
        else cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 3540
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s[n];
  int m[n][26] = {};
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; s[i][j] != '\0'; j++) {
      m[i][s[i][j] - 'a']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    int cn = 50;
    for (int j = 0; j < n; j++) {
      cn = min(cn, m[j][i]);
    }
    cout << string(cn, i + 'a');
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    string s1,s2;
    cin>>s1;

    cin>>s2;
    int count = 0;
    for ( int i = 0 ; i < s1.length() ; i++ )
    {
        if ( s1[i] == s2[i] )
        {
            count++;
        }
    }

    cout<<count<<endl;
    return 0;
}

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

typedef long long ll;

using namespace std;

ll MAX = 1e9+1;
const int MOD = 1e9 + 7;

pair<int, int> dfs(int node, vector< vector<int> >& g, vector<bool>& seen) {
    // ways.first = number of ways if node is painted black
    // ways.second = # ways if node is painted white
    // if leaf node, there is 1 way to do both

    ll ways_b = 1, ways_w = 1;

    seen[node] = true;

    //cout << "processing " << node << endl;

    for (int child : g[node]) {
        if (!seen[child]) {
            //cout << child << " is a child" << endl;
            pair<int, int> child_ways = dfs(child, g, seen);
            ways_b *= child_ways.second;
            ways_w *= (child_ways.second + child_ways.first);
            ways_b %= MOD;
            ways_w %= MOD;
        }
    }

    //cout << node << ": (" << ways_b << ", " << ways_w << ")" << endl;
    return make_pair(ways_b, ways_w);
}

void solve() {
    int n;
    cin >> n;

    vector< vector<int> > g(n, vector<int>());
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }

    vector<bool> seen(n, false);
    
    pair<int, int> ways = dfs(0, g, seen);

    int ans = (ways.first + ways.second) % MOD;

    cout.precision(20);
    cout << ans << endl;
}


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



Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

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

  vector<int> a(n), b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  int ans = 0;
  for(int i=28; i>=0; --i){
    int t = 1 << i, k = t*2-1;

    REP(j, n) b[j] %= (t*2);
    sort(b.begin(), b.end());

    int sum = 0;
    REP(j, n){
      a[j] %= (t*2);
      sum += lower_bound(b.begin(), b.end(), 2*t-a[j]) - lower_bound(b.begin(), b.end(), t-a[j]) +
	lower_bound(b.begin(), b.end(), 4*t-a[j]) - lower_bound(b.begin(), b.end(), 3*t-a[j]);
    }
    if(sum % 2) ans += t;
  }

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 100100

vi V[MAXN];
typedef pair<ll,pi> pii;
vector<pii> edgeList;
ll N,a,b,w;
ll d[MAXN], p[MAXN];
ll centw;
pi cent;
ll blk[MAXN];

void dfs(ll x, ll pa){
	d[x]=1;p[x]=pa;
	for (auto v:V[x])if (v!=pa){
		dfs(v,x);
		d[x] += d[v];
	}
}

ll find(ll a, ll b){
	if (p[a] == b)return d[a];
	else{
		return N-d[b];
	}
}

ll lll;
int dfs2(int x, int p){
	for (auto v:V[x])if (v!=p){
		if (d[v] > N/2)return dfs2(v,x);
	}
	return x;
}

int main(){
	cin>>N;
	for (ll i=1;i<N;++i){
		cin>>a>>b>>w;
		edgeList.pb(mp(w, mp(a,b)));
		V[a].pb(b);
		V[b].pb(a);
	}
	sort(ALL(edgeList));
	dfs(1,-1);
	ll ans = 0;
	ll comb = 0;
	for (auto i : edgeList){
		ll a = i.s.f;
		ll b = i.s.s;
		ll w = i.f;
		
		ll l = find(a, b);
		ll r = find(b, a);
		if (l == r)comb = w;
		if (min(l,r) > centw){
			centw = min(l,r);
			cent = mp(a,b);
		}
		// if (min(l,r) > 10000)cout<<w<<' '<<' '<<l<<' '<<r<<' '<<2*min(l,r)<<'\n';
		ans += w*2*min(l,r);
	}
	if (comb)ans -= comb;
	else {
		int c = dfs2(1,-1);
		ll minsub = 1e18;
		for (auto i:edgeList)if(i.s.f==c || i.s.s == c)minsub = min(minsub,i.f);
		ans -= minsub;
	}
	cout<<ans;
}

Measured memory_bytes: 13616
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
/********************************************************************************/
int n,m,k;
int a[100010];
string s;
vi v;
int main()
{
	cin>>n>>m;
	if(n<=m)
	{
		cout<<"unsafe";
	}
	else
	{
		cout<<"safe";
	}
    return 0;
}

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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string
#define sz(x) x.size()
#define INF LONG_LONG_MAX
#define PI (2.0*acos(0.0))
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

/*LL gcd(LL a,LL b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}*/



int main()
{
    int n;
    cin>>n;
    int arr[n];
    D dum = 0;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        dum += arr[i];
    }
    sort(arr,arr+n);

    int mini = arr[0];
    int maxi = arr[n-1];
    int sum = 0;
    D mid = dum/n;
    int mid1 = ceil((mid));
    int mid2 = floor((mid));
    for(int i=0; i<n; i++)
    {
            sum = sum + (abs(arr[i]-mid1)*abs(arr[i]-mid1));
    }
    int kum = 0;
    for(int i=0; i<n; i++)
    {
            kum = kum + (abs(arr[i]-mid2)*abs(arr[i]-mid2));
    }

    if(sum<kum) cout<<sum;
    else cout<<kum;
}


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

int main(void) {
	int N, i;
	int pf = -1, pa = -1, pt = -1, px = -1, py = -1;
	int f, a, t, x, y;
	int ansd[2] = {-1, -1}, anst[2] = {-1, -1};
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d%d%d%d", &f, &a, &t, &x, &y) != 5) return 0;
		if (t == pt && a != pa) {
			int curd = (x - px) * (x - px) + (y - py) * (y - py);
			int curt = f - pf;
			if (curd > ansd[t] || (curd == ansd[t] && curt < anst[t])) {
				ansd[t] = curd;
				anst[t] = curt;
			}
		}
		pf = f;
		pa = a;
		pt = t;
		px = x;
		py = y;
	}
	for (i = 0; i < 2; i++) {
		if (ansd[i] < 0) {
			puts("-1 -1");
		} else {
			printf("%.15f %.15f\n", sqrt(ansd[i]), anst[i] / 60.0);
		}
	}
	return 0;
}

Measured memory_bytes: 648
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==1)
				return;
			boolean  a[]=new boolean[300001];
			Arrays.fill(a, true);
			for(int i=2;i*i<=300000;i++)
			{
				if(!a[i])
					continue;
				if(i%7==1||i%7==6)
					for(int j=i+i;j<=300000;j+=i)
						a[j]=false;
			}
			for(int i=0;i<=300000;i++)
			{
				if(i%7!=1&&i%7!=6)
					a[i]=false;
			}
			System.out.print(n+":");
			for(int i=2;i<=n;i++)
			{
				if(a[i])
					if(n%i==0)
						System.out.print(" "+i);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        sc.close();
        double distance = Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2));
        System.out.println(distance);
    }
}


Measured memory_bytes: 27992
//Keep pluggin',this is your only outlet.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cctype>
#include<cassert>
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define fi first
#define mp make_pair
#define se second
using namespace std;
//#define int long long

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int quickmul(int x,int y,int mod){return (x*y-(int)((long double)x/mod*y)*mod+mod)%mod;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x * f;
}

const int MAXN = 2e5 + 100;

char s[MAXN];
int n,k,a[MAXN<<2],l,r,p = 0;

///------------------head------------------
signed main(signed argc, char *argv[]){
    // freopen("in2.txt","r",stdin);
    // freopen("in2.out","w",stdout);
    n = read(),k = read();
    scanf("%s",s+1);
    rep(i,1,n) a[i] = s[i] == 'A';
    l = 1,r = n;
    for (int i = 1; i <= (n << 1); ++i) {
        if ((a[l]^p)) a[l] ^= 1;
        else ++l,++r,p^=1,a[r] = p^1;
        if (i == k) {
            //cerr << l << ' ' << r << endl;
            for (int j = l; j <= r; ++j)
            printf("%c",(a[j]^p^1) + 'A');
            return 0;
        }
    }
    if ((n&1)&&(k&1)) a[l] ^= 1;
    for (int j = l; j <= r; ++j)
    printf("%c",(a[j]^p^1) + 'A');
    return 0;
}

/* Examples: */
/*

*/

/*

*/


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,c;
  string str;
  cin>>n;
  cin>>str;
  c=1;
  for(i=0;i<n-1;i++)
  {
      if(str[i]!=str[i+1])
      {
          c++;
      }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 3772
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

ans = -1

for i in range(1000):
    s_i = str(i)
    if len(s_i) == n and all(int(s_i[s-1])==c for s,c in sc):
        ans = i
        break

print(ans)

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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

string s;

int main(int argc, char const *argv[])
{

  cin >> s;

  if(s.size() < 4)
  	cout << "No";
  else{
  	if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
  		cout << "Yes";
  	else
  		cout << "No";
  }

  return 0;
}  

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;

class Node
{
public:
	vector<int> to,rev,rn;
};

class Trl
{
public:
	int p,c,a;
	
	Trl(int p, int c, int a)
	:p(p),c(c),a(a)
	{}
	
	bool operator<(const Trl& t) const
	{
		if(c!=t.c) return c>t.c;
		return a>t.a;
	}
};

bool v[1001][10001];

int main()
{
	int N,M,S,T;
	while(scanf("%d", &N), N)
	{
		Node node[1001];
		scanf("%d%d", &S,&T);
		scanf("%d", &M);
		for(int i=1; i<=M; i++)
		{
			int s,d;
			scanf("%d%d", &s, &d);
			
			node[s].to.push_back(d);
			node[d].rev.push_back(s);
			node[d].rn.push_back(i);
		}
		
		memset(v,0,sizeof(v));

		
		priority_queue<Trl> q;
		q.push(Trl(S,0,0));
		
		while(!q.empty())
		{
			Trl t=q.top(); q.pop();
			if(t.p==T)
			{
				printf("%d %d\n", t.c, t.a);
				break;
			}
			
			for(int i=0; i<node[t.p].to.size(); i++)
			{
				int next=node[t.p].to[i];
				if(v[next][t.a]) continue;
				
				v[next][t.a]=1;
				
				q.push(Trl(next, t.c+1, t.a));
			}
			
			if(t.a==0)
			{
				for(int i=0; i<node[t.p].rev.size(); i++)
				{
					int next=node[t.p].rev[i], na=node[t.p].rn[i];
					if(v[next][na]) continue;
					
					v[next][na]=1;
					
					q.push(Trl(next, t.c+1, na));
				}
			}
		}
	}
}

Measured memory_bytes: 10000
/*
 author : nit1n
 created : 13/09/2020 17:30:32
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;


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

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



Measured memory_bytes: 3636
N=int(input())

A=[]

for i in range(N):
    d=[]
    p = int(input())
    d.append(p)
    d.append(i)

    A.append(d)

A.sort(key=lambda x:x[0])

#print(A)

for j in range(N):
    if  j == A[N-1][1]:
         print(A[N-2][0])
    else:
        print(A[N-1][0])

Measured memory_bytes: 42500
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100005
#define X first
#define Y second
#define mod 1000000007
#define inf 1e10
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

int main()
{
    fastio;
    string s,t;
    cin>>s>>t;
    t=t+s;
    cout<<t<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int k,t;
int a[125];

int main(){
  scanf("%d%d",&k,&t);
  REP(i,t)scanf("%d",a+i);
  int mx = *max_element(a,a+t);
  printf("%d\n",max(0,mx-(k-mx+1)));
  return 0;
}


Measured memory_bytes: 384
//***No one wants to die...yet death is the destiation we all share***
//***Because people who are crazy enough to think that they can change the world are the ones who do it***
//Think different
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[2*100002];
int main(){
  ll n,ans=0;
  cin>>n;
  forn(i,n) cin>>a[i];
  sort(a,a+n,greater<ll>());
  ans+=a[0];
  ll j=1;
  n--;
  n--;
  while(n>0){
    ans+=a[j];
    n--;
    if(n==0) break;
    ans+=a[j];
    n--;
    j++;
  }
  cout<<ans;
}

Measured memory_bytes: 5152
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
int a[300][300];
int op[300];
int join[300];
int ans = 114514;

signed main() {
	int n, m; cin >> n >> m;
	rep(i, n)rep(j, m)cin >> a[i][j];
	rep(i, m) {
	fill(join, join + m, 0);
	rep(j, n) {
		rep(k, m) {
			if (op[a[j][k] - 1] == 0) {
				join[a[j][k] - 1]++;
				break;
			}
		}
	}
	int mx = 0;
	rep(j, m)mx = max(mx, join[j]);
	ans = min(ans, mx);
	rep(j, m) {
		if (join[j] == mx) {
			op[j]++;
			break;
		}
	}
}
	cout << ans << endl;
}

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

long long gcd(long long a,long long b)
{
    return (b ? gcd(b, a % b) : a);
}
int main()
{
	long long x = 0,n = 0,a;
	cin >> n;
	cin >> x;
	n = n - 1;
	while(n--)
	{
		cin >> a;
		x = a * (x / gcd(a,x));
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;

    int r0 = x;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        r0 = max(r0, t);
    }

    int r1 = y;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        r1 = min(r1, t);
    }

    cout << (r0 < r1 ? "No War" : "War") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////


void solve()
{
 int a, b, c; cin>>a>>b>>c; 
 cout<<c<<" "<<a<<" "<<b; 
}
int main()
{ ios; 

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    ll n;
    cin >> n;
    vector<vector<int>> c(10,vector<int>(10,0));
    for (int i = 1; i <= n; ++i) {
        vector<int> dig;
        int tmp = i;
        while(tmp > 0){
            dig.push_back(tmp%10);
            tmp /= 10;
        }
        c[dig[dig.size()-1]][dig[0]]++;
    }
    ll ans = 0;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            ans += c[i][j]*c[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = input() + "_"

a = 0
r = 0
i = 0

while i < len(s):
    if s[i] == "A":
        a += 1
        i += 1
    elif s[i] == "B":
        if s[i + 1] == "C":
            r += a
            i += 2
        else:
            a = 0
            i += 1
    else:
        a = 0
        i += 1

print(r)

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
int main()
{
       long long int n,i,a[1000],k;
       cin>>n;
       for(i=0;i<n;i++)
       {
           cin>>a[i];
       }
       for(i=0;i<n;i++)
       {
           k=1;
           if((a[i]%2==0)){
              if((a[i]%3==0)||(a[i]%5==0)){
                    k=1;}
                else{k=0;
          break;}}
                    }
          if(k==1){
               cout<<"APPROVED"<<endl;}
               else
                cout<<"DENIED"<<endl;
          return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	public void run()
	{
		Scanner file = new Scanner(System.in);
		int A = file.nextInt();
		int B = file.nextInt();
		int T = file.nextInt();
		System.out.println(T/A*B);
	}
	
}


Measured memory_bytes: 23892
#include<stdio.h>
const int N = 15;
int main()
{
	int n, s[N]={0}, h[N]={0}, c[N]={0}, d[N]={0};
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		char k;
		int p;
		scanf(" %c %d", &k, &p);
		if(k == 'S')
		{
			s[p]++;
		}
		else if(k == 'H')
		{
			h[p]++;
		}
		else if(k == 'C')
		{
			c[p]++;
		}
		else
		{
			d[p]++;
		}
	}
		for(int i = 1; i<=13; i++)
		{
			if(s[i] == 0)
			{
				printf("S %d\n", i);
			}
		}
		for(int i = 1; i<=13; i++)
		{
			if(h[i] == 0)
			{
				printf("H %d\n", i);
			}
		}
		for(int i = 1; i<=13; i++)
		{
			if(c[i] == 0)
			{
				printf("C %d\n", i);
			}
		}
		for(int i = 1; i<=13; i++)
		{
			if(d[i] == 0)
			{
				printf("D %d\n", i);
			}
		}
	
	return 0;
} 



Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a; cin>>a;
    if(a<=111){
        cout<<111<<endl;
    }else if(a<=222){
        cout<<222<<endl;
    }else if(a<=333){
        cout<<333<<endl;
    }else if(a<=444){
        cout<<444<<endl;
    }else if(a<=555){
        cout<<555<<endl;
    }else if(a<=666){
        cout<<666<<endl;
    }else if(a<=777){
        cout<<777<<endl;
    }else if(a<=888){
        cout<<888<<endl;
    }else{
        cout<<999<<endl;
    }

}



Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  map<long long, long long> m;
  vector<long long> v(N);
  for (int i = 0; i < N; ++i) {
    long long a;
    cin >> a;
    v[i] = a;
    if (m.find(a) == m.end())
      m[a] = 0;
    ++m[a];
  }

  long long total = 0;
  for (map<long long, long long>::iterator i = m.begin(); i != m.end(); ++i) {
    long long n = i->second;
    long long c = n * (n - 1) / 2;
    if (c > 0)
      total += c;
  }

  for (int i = 0; i < N; ++i) {
    long long a = v[i];
    long long n = m[a];
    long long old_c = n * (n - 1) / 2;
    long long new_c = (n - 1) * (n - 2) / 2;
    long long ret = 0;
    if (old_c < 1)
      ret = total;
    else if (new_c < 1)
      ret = total - old_c;
    else
      ret = total - old_c + new_c;
    cout << ret << endl;
  }


  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans = 3;
    else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) ans = 2;
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') ans = 1;

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

Measured memory_bytes: 3564
s = input()
if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
else:
  print(1)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,M;
P A[100005];

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

	cin >> N >> M;

	for (int i = 0;i < N;i++){
		cin >> A[i].first >> A[i].second;
	}

	sort(A, A+N);

	ll sum = 0;
	ll ans = 0;

	for (int i = 0;i < N;i++){
		if(sum+A[i].second >= M ){
			ans += A[i].first*(M-sum);
			cout << ans << endl;
			return 0;
		}
		ans += A[i].first*A[i].second;
		sum += A[i].second;
	}

	cout << ans << endl;

	return 0;

}


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

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

    vector<pair<int64_t, int>> edge[1<<12];
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        int mask = 0;
        for(int j=0;j<b;++j){
            int c;
            cin >> c;
            --c;
            mask |= (1<<c);
        }
        for(int from=0;from<(1<<n);++from){
            edge[from].emplace_back(a, from | mask);
        }
    }

    priority_queue<pair<int64_t, int>> q;
    q.emplace(0, 0);
    bool checked[1<<12];
    for(int i=1;i<(1<<n);++i) checked[i] = false;

    int goal = (1<<n)-1;
    while(!q.empty()){
        auto t = q.top();
        q.pop();
        if(t.second == goal){
            cout << -t.first << endl;
            return 0;
        }
        if(checked[t.second]) continue;
        checked[t.second] = true;
        for(auto to: edge[t.second]){
            if(checked[to.second]) continue;
            q.emplace(t.first - to.first, to.second);
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 71536
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
    fast;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("op.txt","w",stdout);
    // #endif

    ll r;
    cin>>r;
    cout<<2*3.14159*r;
    
}//Goodbye...

Measured memory_bytes: 3800
#define _[301][301]
N,M,i,j,t,r,C _,D _;char S _;main(v){for(scanf("%d%d ",&N,&M);i=j=++t<M;r+=v)for(;j>N?j=i++<N:1;v=D[i][j]=fmin(D[i-1][j],D[i][j-1])+(C[i][j]=C[i-1][j-1]+(S[i][t-1]==S[j++][t])))i-1||gets(S+j);printf("%d",r);}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll a, b; cin >> a >> b;
	a--, b--;
	char m[100][100] = {};
	rep(i, 0, 100) {
		rep(j, 0, 100) {
			if (i < 50) m[i][j] = '#';
			else m[i][j] = '.';
		}
	}

	rep(i, 1, 50) {
		rep(j, 1, 99) {
			if (a > 0 && i % 2) {
				if (i % 2 == j % 2) {
					m[i][j] = '.';
					a--;
				}
			}
		}
	}
	rep(i, 51, 100) {
		rep(j, 1, 99) {
			if (b > 0 && i % 2) {
				if (i % 2 == j % 2) {
					m[i][j] = '#';
					b--;
				}
			}
		}
	}
	cout << 100 << " " << 100 << endl;

	rep(i, 0, 100) {
		rep(j, 0, 100) {
			cout << m[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N=int(input())

robot=[]
for _ in range(N):
    x,l=map(int,input().split())
    robot.append((x+l,x-l))
robot.sort()

tmp=-10**10
ans=0
for i in range(N):
    end,start=robot[i]
    if tmp<=start:
        tmp=end
        ans+=1
print(ans)




Measured memory_bytes: 22768
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int n, r;
 int tmp[64];
 int p, c;
    while(scanf("%d %d", &n, &r), n || r)
    {
        int card[64];
        int i;
 
        for (i = 0; i < n; i++){
            card[i] = n-i; //?±±????????????(?±±???????????????card[n-1]??§card[0]??????n?????\??£?????????)
        }
 
        while (r-- > 0){
            //int p, c;
            //int tmp[64];
 
            scanf("%d %d", &p, &c);
            for (i = p - 1; i < p + c - 1; i++){ //p~p-1+c???????????????tmp[0]~tmp[c]?????\??????              
                tmp[i - p + 1] = card[i];
            }
            for (i = p - 1 + c - 1; i-c+1 > 0 ; i--){ //p~p-1+c????????????????????£?????´??????p+c~n?????§???????????\??????
                card[i] = card[i - c];
            }
            int j = 0;
            for (i = 0; i < c; i++){
                card[i] = tmp[j];
                j++;
            }
        }
 
        printf("%d\n", card[0]);
    
    }
    return 0;
}

Measured memory_bytes: 600
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"
#include "random"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<int>v(K);
	for (int i = 0; i < K; i++) {
		cin >> L >> R;
		v[i] = L;
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 1; i < K; i++) {
		ans += max((int)N - v[i], 0);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  lol a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  a = a * 60 + b;
  c = c * 60 + d;
  cout << (c - a) - e << '\n'; 
  return 0;
}


Measured memory_bytes: 3664
# include <bits/stdc++.h>
# define int        long long
# define all(vc)   vc.begin(),vc.end()
# define all2(vc)  vc.rbegin(),vc.rend()
# define pb        push_back
# define fi        first
# define se        second
# define speed     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time      cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;

void solve(){
    int n, k = 1, i;
    cin >> n >> k >> i;
    cout << i << ' ' << n << ' '<<k;
}

int32_t main(){
    speed;
    cout<<fixed<<setprecision(0);
    int t = 1;
    //cin >> t;
    while( t-- ){
         solve();
         cout<<'\n';
    }

    time;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define maxn 100000
    #define INF 1LL<<60
    using namespace std;
    long long h[maxn+3], dp[maxn+3];
    int n;

    long long solve(int cur){
        if(cur >= n) return INF;
        if(cur == n-1) return 0;
        if(dp[cur]!= INF) return dp[cur];
        //long long res1 = INF, res2 = INF;
        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);
        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);
        return dp[cur] = min(res1, res2); 
    }

    int main() {
    	// your code goes here
        //freopen("in.txt", "r", stdin);
    	while(scanf("%d",&n)==1){
            
            for (int i = 0; i < n; ++i){
                scanf("%lld",&h[i]);
                dp[i] = INF;
            }

            long long ans = solve(0);
            printf("%lld\n", ans);
        }
    }
     

Measured memory_bytes: 4864
/*
__   __                                       _ 
\ \ / /                                      | |
 \ V /___  _   _ _ __   __ _ _ __   ___  __ _| |
  \ // _ \| | | | '_ \ / _` | '_ \ / _ \/ _` | |
  | | (_) | |_| | | | | (_| | | | |  __/ (_| | |
  \_/\___/ \__,_|_| |_|\__, |_| |_|\___|\__,_|_|
                        __/ |                   
                       |___/                     
*/

// #pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
// #pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef double db;
typedef long long ll;
const int N=2e5+5;
const int mod=1e9+7;

int n,c[N],f[N],pre[N];

void Mul(int &x,int y){x=1ll*x*y%mod;}
int mul(int x,int y){return 1ll*x*y%mod;}
void Dec(int &x,int y){x=x-y<0?x+mod-y:x-y;}
int dec(int x,int y){return x-y<0?x+mod-y:x-y;}
void Inc(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}
int inc(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int ksm(int a,int b=mod-2,int ans=1){for(;b;a=mul(a,a),b>>=1) if(b&1) ans=mul(ans,a);return ans;}

signed main(){
	scanf("%d",&n); f[1]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		if(i==1){pre[c[i]]=i;continue;}
		f[i]=f[i-1];
		if(i-1!=pre[c[i]]) Inc(f[i],f[pre[c[i]]]);
		pre[c[i]]=i;
	} printf("%d\n",f[n]);
	return 0;
}


Measured memory_bytes: 2560
N,B,R = input().split()
N = int(N)
B = int(B)
R = int(R)
X = B + R
Z = N // X
Y = N % X
if B == 0:
    print(0)
elif  X == N:
    print(B)
elif X < N:
    if Y < B:
        print(B*Z + Y)
    elif Y >= B:
        print(B*Z + B)
elif X > N:
    if B > N:
        print(N)
    else:
        print(B)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vector<vi> g(n, vi(n, -1));
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            g[i][x-1] = y;
        }
    }
    int ans = 0;
    rep(i, 1<<n) {
        vi d(n);
        rep(j, n) if (i&(1<<j)) d[j] = 1;
        bool ok = true;
        rep(j, n) {
            if (d[j]) {
                rep(k, n) {
                    if (g[j][k] == -1) continue;
                    if (g[j][k] != d[k]) ok = false;
                }
            }
        }
        if (ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//UnionFind
//全て添字で扱うこと
struct union_find {
  vll parent;
  vll sizes;

  void init(ll n) {
    for (ll i = 0; i < n; i++) parent.push_back(i);
    for (ll i = 0; i < n; i++) sizes.push_back(1);
    return;
  }

  ll root(ll n) {
    if (parent[n] == n) return n;
    return parent[n] = root(parent[n]);
  }

  ll size(ll n) {
    return sizes[root(n)];
  }

  bool is_united(ll a, ll b) {
    return (root(a) == root(b));
  }

  void unite(ll a, ll b) {
    if (is_united(a, b)) return;
    sizes[root(a)] += sizes[root(b)];
    parent[root(b)] = root(a);
    return;
  }
};

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

  vll a(m), b(m);
  for (ll i = 0; i < m; i++) cin >> a[i] >> b[i];

  struct union_find uf;
  uf.init(n);

  ll unconv = n * (n - 1) / 2;
  vll ans(1, unconv);

  for (ll i = m - 1; i > 0; i--) {
    if (!uf.is_united(a[i] - 1, b[i] - 1)) {
      unconv -= uf.size(a[i] - 1) * uf.size(b[i] - 1);
    }
    uf.unite(a[i] - 1, b[i] - 1);
    ans.push_back(unconv);
  }

  for (ll i = 0; i < m; i++) cout << ans[m - 1 - i] << endl;
}

Measured memory_bytes: 5364
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  string S,T;
  cin>>S;
  cin>>T;
  int res = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if(S[i] != T[i])res++;
  }
  cout<<res<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main() {
  int a, b;
  string ans;
  cin >> a >> b;
  if (a==b){
    for(int i=0; i<b; i++){
      ans += to_string(a);
    }
    cout << ans << endl;
  }
  else if (a<b){
    for(int i=0; i<b; i++){
      ans += to_string(a);
    }
    cout << ans << endl;
  }
  else{
    for(int i=0; i<a; i++){
      ans += to_string(b);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256