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

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

using P = pair<ll, ll>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
/****** define constant end ********/
/****** define variable start ******/
ll N, M, R;
vl r;
vl A, B, C;
/******* define variable end *******/

void dijkstra(const Graph &G, ll s, vector<ll> &dis) {
    ll N = G.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P> > pq;
    fill(dis.begin(), dis.end(), INF);
    dis[s] = 0;
    pq.push(P(0, s));
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        ll v = p.second;
        if (dis[v] < p.first) {
            continue;
        }
        for (ll i = 0; i < G[v].size(); i++) {
        	Edge e = G[v][i];
            if (dis[e.to] > dis[v] + e.cost) {
                dis[e.to] = dis[v] + e.cost;
                pq.push(P(dis[e.to], e.to));
            }
        }
    }
}



int solve() {
	cin >> N >> M >> R;
	r.resize(R);
	REP(i, R){
		cin >> r[i];
	}
	sort(r.begin(), r.end());
	A.resize(M);
	B.resize(M);
	C.resize(M);
	Graph G(N);
	REP(i, M){
		cin >> A[i] >> B[i] >> C[i];
		Edge e = {B[i]-1, C[i]};
		Edge e2 = {A[i]-1, C[i]};
		G[A[i]-1].push_back(e);
		G[B[i]-1].push_back(e2);
	}
	vector<vector<ll>> ans(N, vector<ll>(N));
	REP(i, N){
		dijkstra(G, i, ans[i]);
	}
	ll l_ans = INF;
	do {
	    ll l_ans_tmp = 0;
	    for(ll i = 0; i < R-1; i++) {
	    	l_ans_tmp += min(ans[r[i]-1][r[i+1]-1], ans[r[i+1]-1][r[i]-1]);
	    }
	    l_ans = min(l_ans, l_ans_tmp);
  	} while (next_permutation(r.begin(), r.end()));
  	cout << l_ans << endl;
	return 0;
}

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

	return end_solve;
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

llint cnt = 0;
llint a[100001];
llint b[100001];
int n;
llint asum = 0, bsum = 0;
llint fusoku = 0;

int main()
{
    ci >> n;
    rep(i, n) {
	ci >> a[i];
	asum += a[i];
    }
    rep(i, n) {
	ci >> b[i];
	bsum += b[i];
    }

    if(asum < bsum) {
	co << -1 << en;
	return 0;
    }

    vi v;
    rep(i, n) {
	if(a[i] >= b[i]) {
	    cnt++;
	    v.pb(a[i] - b[i]);
	} else {
	    fusoku += b[i] - a[i];
	}
    }

    sort(v.begin(), v.end(), greater<int>());

    if(fusoku > 0) {
	for(int i = 0; i < v.size(); i++) {
	    fusoku -= v[i];
	    cnt--;
	    if(fusoku <= 0) break;
	}
    }
	
    co << n - cnt << en;
  
    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int x,t; cin >> x >> t;
    cout << max(0, x-t) << '\n';
    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll h,w;cin>>h>>w;
	if (h != 1 && w != 1){
		cout << ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) << endl;
	}
	else{
		cout << 1 << endl;
	}
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;


int main(){
	
	int n;cin >> n;
	vector<pair<ll,ll>> v;
	
	REP(i,n){
		ll a,b;cin >> a >> b;
		v.PB(MP(min(a,b),max(a,b)));
	}
	
	sort(ALL(v));
	
	ll rmin = INF;
	ll rmax = 0;
	ll bmin = INF;
	ll bmax = 0;
	REP(i,n){
		rmin = min(rmin,v[i].FI);
		bmin = min(bmin,v[i].SE);
		rmax = max(rmax,v[i].FI);
		bmax = max(bmax,v[i].SE);
	}
	
	ll ans = (rmax - rmin) * (bmax - bmin);
	ll tmp = max(rmax,bmax) - min(rmin,bmin);
	
	rmin = v[0].FI;
	rmax = v[n-1].FI;
	bmin = v[0].SE;
	bmax = v[0].SE;
	
	REP(i,n-1){
		rmin = v[i+1].FI;
		bmin = min(bmin,v[i].SE);
		bmax = max(bmax,v[i].SE);
		ll seica = max(rmax,bmax) - min(rmin,bmin);
		ans = min(ans,tmp * seica);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

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

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


struct edge{
    int x, y, cost;
};

int V, E;
int dist[1000];
vector<edge> es;

bool bellmanford(int s){
    REP(i, V) dist[i] = INT32_MAX;
    dist[s] = 0;
    bool update = false;
    REP(i, V){
        update = false;
        for(auto e : es){
            if(dist[e.x] + e.cost < dist[e.y] && dist[e.x] < INT32_MAX){
                dist[e.y] = dist[e.x] + e.cost;
                update = true;
            }
        }
        if(i == V - 1 && update) return false;
    }
    return true;
}

signed main(){
    int r, s, t, d;
    cin >> V >> E >> r;
    REP(i, E){
        cin >> s >> t >> d;
        es.push_back({s, t, d});
    }
    if(!bellmanford(r)){
        PRINT("NEGATIVE CYCLE");
    }else{
        REP(i, V){
            if(dist[i] < INT32_MAX) PRINT(dist[i]);
            else PRINT("INF");
        }
    }
    return 0;
}


Measured memory_bytes: 3196
def resolve():
    INF = 10 ** 18
    N, M = map(int, input().split())

    Cost = [0] * M
    Box_key = [0] * M
    for i in range(M):
        a, b = map(int, input().split())
        Cost[i] = a
        C = list(map(int, input().split()))
        Box_key[i] = sum(1 << (c - 1) for c in C)

    # dp[ i ][ S ] := 最初の i 個の鍵からいくつか選んで、
    # 開いた宝箱の集合が S で表されるような場合についての、最小コスト
    dp = [[INF] * (1 << N) for _ in range(M + 1)]
    dp[0][0] = 0

    for i in range(M):
        for j in range(1 << N):
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
            dp[i + 1][j | Box_key[i]] = min(dp[i + 1][j | Box_key[i]], dp[i][j] + Cost[i])

    if dp[M][(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[M][(1 << N) - 1])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 106740
#include <iostream>
#include <algorithm>
#include <cstring>
const int maxn = 205;
using namespace std;

struct node
{
    int x;
    int y;
}a[maxn],b[maxn];
bool cmp(node a,node b)
{
    if(a.x==b.x)
        return a.y<b.y;
    return a.x<b.x;
}
int main()
{
    int n;
    int ans=0;
    int vis[maxn];
    memset(vis,0,sizeof(vis));
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i].x>>a[i].y;
    for(int i=1;i<=n;i++)
        cin>>b[i].x>>b[i].y;
    sort(a+1,a+1+n,cmp);
    sort(b+1,b+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int p=0;
        int f=0;
        for(int j=1;j<=n;j++)
        {
            if(a[j].x<b[i].x&&a[j].y<b[i].y&&!vis[j])
            {
                f++;
                if(f==1)
                {
                    p=j;
                }
                else if(a[j].y>a[p].y)
                {
                    p=j;
                }
            }
        }
        if(p>0)
        {
            vis[p]=1;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int a[N],n,k,b[N],d[N],l;
struct Tree{
	int l,r,num1,num2;
}T[N*4];
void build(int x,int l,int r){
	T[x].l=l;T[x].r=r;
	if (l==r){
		T[x].num1=T[x].num2=a[l];
		return;
	}
	int mid=(l+r)/2;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
	T[x].num1=min(T[x*2].num1,T[x*2+1].num1);
	T[x].num2=max(T[x*2].num2,T[x*2+1].num2);
}
int find1(int x,int l,int r){
	if (T[x].l>r||l>T[x].r)return 1e9;
	if (T[x].l>=l&&T[x].r<=r)return T[x].num1;
	return min(find1(x*2,l,r),find1(x*2+1,l,r));
} 
int find2(int x,int l,int r){
	if (T[x].l>r||l>T[x].r)return 0;
	if (T[x].l>=l&&T[x].r<=r)return T[x].num2;
	return max(find2(x*2,l,r),find2(x*2+1,l,r));
} 
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	build(1,1,n);
	int ans=1,l=1,r=0;
	for (int i=1;i<=k;i++){
		while (l<=r&&a[d[r]]>a[i])r--;
		d[++r]=i;
	}
	int flag=0;
	if (r-l+1==k)flag=1;
	for (int i=2;i+k-1<=n;i++){
		if (d[l]<i)l++;
		while (l<=r&&a[d[r]]>a[i+k-1])r--;
		d[++r]=i+k-1;
		if (r-l+1==k){
			ans+=!flag;
			flag=1;
			continue;
		} 
		if (find1(1,i-1,i+k-2)!=a[i-1]||find2(1,i,i+k-1)!=a[i+k-1])ans++;
	}
	printf("%d\n",ans);	
}

Measured memory_bytes: 13184
/**
   _           _
  / /         \ \
 / /  _   _  _ \ \
< < (_) (_) (_) > >
 \ \           / /
  \_\         /_/

Nerede Gitsen Çukur Orda
**/

#include<bits/stdc++.h>
#include<fstream>
///#include "windows.h"
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define Zohiri_dzd cout.tie(NULL);
#define Belafz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front
#define quluq return 0;
using namespace std ;

    const ll N = 1e4 + 0.000001 ;

int main ()
{
    Zohiri_dzd
    Belafz
    CODER
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Author of the greatest code :: Murtazoev Alijon
    ///4294967295
    char a ;
    cin >> a ;
    cout << char ( a + 1 ) ;
}
///Mavl studios
///Eco students


Measured memory_bytes: 3460
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


s, t = input().split()
a, b = inpl()
u = input()[:-1]
if u == s:
    print(a - 1, b)
else:
    print(a, b - 1)


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

using namespace std;

using ll =  long long int;

#define int  long long int
#define mod  1000000007

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
            res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

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

    ll s;
    
    cin >> s;
    
    if(s < 3) {
    	cout << 0 << endl;
    	return 0;
    }
    
    int dp[s+5];
    
    for(int i = 0; i <= s; ++i) {
    	dp[i] = 1;
    }
    
    for(int i = 3; i <= s; ++i) {
    	for(int j = i - 3; j >= 3; --j) {
    		dp[i] += dp[j];
    		dp[i] %= mod;
    	}
    }
    
    cout << dp[s] << endl;
    
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e6;
int n, k;
int A[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> k >> n;
  int ma=0;
  FOR(i, 0, n) cin >> A[i];
  FOR(i, 0, n) maxs(ma, (A[(i+1)%n]-A[i]+k)%k);
  cout << k-ma << endl;
}

Measured memory_bytes: 4392
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll K, N;
	cin >> K >> N;
	vll A(N + 1);
	repn(i, N)cin >> A[i];

	ll d = K - A[N] + A[1];
	repn(i, N-1) {
		d = max(A[i + 1] - A[i], d);
	}

	cout << K - d << endl;

}


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

using namespace std;

#define int long long

signed main(){
	int n, k; cin>>n>>k;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	
	for(int i = k; i < n; i++){
		if(a[i] > a[i-k]){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	
}

Measured memory_bytes: 4840
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, M; cin >> N >> M;
    vl a(M); REP(i, M) cin >> a[i];
    sort(a.begin(), a.end());
    vs dp(N+10, "");
    vl cost = {0,2,5,5,4,5,6,3,7,6};
    REP(i, M){
        ll v = a[i];
        if(dp[cost[v]] != "") dp[cost[v]] = max(dp[cost[v]], to_string(v));
        else dp[cost[v]] = to_string(v);
    }
    FOR(i,1,N+1){
        REP(j, M){
            ll v = a[j];
            if(i - cost[v] < 0) continue;
            if(dp[i-cost[v]] == "") continue;
            string ans = max(to_string(v) + dp[i-cost[v]], dp[i-cost[v]] + to_string(v));

            if(dp[i] == "") dp[i] = ans;
            else if(dp[i].size() < ans.size()) dp[i] = ans;
            else if (dp[i].size() == ans.size() && dp[i] < ans) dp[i] = ans;
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 31872
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	int N;
	cin >> N;
	vector<int> L(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> L[i];
	}
	sort(L.begin(), L.end());

	auto result = 0ll;
	for (auto i = 0; i < N - 1; ++i)
	{
		for (auto j = i + 1; j < N; ++j)
		{
			auto a = L[i];
			auto b = L[j];

			if (a + b <= L[0])
			{
				continue;
			}
			auto it1 = lower_bound(L.begin(), L.end(), a + b);
			auto index1 = it1 - L.begin();

			if (b - a >= L[N - 1])
			{
				continue;
			}
			auto index2 = j + 1;

			if (index2 < index1)
			{
				result += index1 - index2;
			}
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n; string s, t; cin >> n >> s >> t;
    int sub = 0;
    for (int i = 0; i < n; i++)
    {
        if(s[i] == t[sub]) sub++;
    }
    cout << 2 * n - sub << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(min(a + b, b + c),a + c) << endl;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {
    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long n;
        n = sc.nextLong();
        long a;
        a = sc.nextLong();
        long b;
        b = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(n, a, b);
    }
}

class Solver {
    static final long MOD = 1000000007;

    public void solve(long n, long a, long b) {
        long all = iterativePow(2, n, MOD) % MOD;

        long allButA = calcSub(n, a, MOD);
        long allButB = calcSub(n, b, MOD);

        long ans = (all + MOD - 1) % MOD; // Ignore the case where no flower selected
        ans = (ans + MOD - allButA) % MOD;
        ans = (ans + MOD - allButB) % MOD;

        System.out.println(ans);
    }

    private long calcSub(long n, long k, long mod) {
        long x = permutation(n, k, mod);
        long y = permutation(k, k, mod);
        long invY = iterativePow(y, mod - 2, mod);

        return x * invY % mod;
    }

    private long permutation(long n, long k, long mod) {
        long ans = 1;
        for (long i = n - k + 1; i <= n; i++) {
            ans *= i;
            ans %= mod;
        }
        return ans;
    }

    private long invMod(long n, long mod) {
        return iterativePow(n, mod - 2, mod);
    }

    private long iterativePow(long n, long p, long mod) {
        if (p == 0) {
            return 1;
        }
        if (p % 2 == 0) {
            long pow = iterativePow(n, p / 2, mod);
            return pow * pow % mod;
        }
        return n * iterativePow(n, p - 1, mod) % mod;
    }
}



Measured memory_bytes: 23764
<?php
fscanf(STDIN, "%d%d%d%d", $A, $B, $H, $M);
$argH = ($H/12+$M/12/60)*2*pi();
$argM = $M/60*2*pi();
$dx = $A*cos($argH) - $B*cos($argM);
$dy = $A*sin($argH) - $B*sin($argM);
echo ($dx**2+$dy**2)**0.5;

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N;
	cin >> N;
	int a, b, c = -1, da = 0, db, dc;
	cin >> a >> b;
	db = abs(a - b);
	for(int i = 2; i < N; i++) {
		cin >> c;
		dc = min(da + abs(a - c), db + abs(b - c));
		a = b; b = c;
		da = db; db = dc;
	}
	if(c == -1)
		dc = db;
	cout << dc << endl;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  int ans=0;
  for(int i=0; i<S.size(); i++){
    S.push_back(S.at(0));
    S.erase(S.begin());
    int flag=0;
    for(int j=0; j<S.size(); j++){
      if(S.at(j)==T.at(j)) flag++;
    }
    if(flag==S.size()) ans++;
  }
  if(ans>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int M,D; cin >> M >> D;
    int ans = 0;
    for(int i = 1; i <= M; ++i){
        for(int j = 10; j <= D; ++j){
            if( (j/10) >= 2 && (j%10) >= 2 && (j/10)*(j%10)==i) ans++;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main(void) {
    int n,i,j,flag;
    while (scanf("%d",&n)!=EOF) {
        for(i=n-1;;i--) {
            flag = 1;
            for (j=2; j*1.0<=sqrt(i); j+=2) {
                if (i%j==0) {
                    flag=0;
                    break;
                }
                if (j==2) j--;
            }
            if (flag==1) {
                printf("%d ",i);
                break;
            }
        }
        for(i=n+1;;i++) {
            flag = 1;
            for (j=2; j*1.0<=sqrt(i); j+=2) {
                if (i%j==0) {
                    flag=0;
                    break;
                }
                if (j==2) j--;
            }
            if (flag==1) {
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

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

int N, C, M;

ll dp[2][10001];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 1;
	while (kkt--) {
		for (int i = 0; i < 2; i++) for (int j = 0; j <= 10000; j++) dp[i][j] = -1;
		int now = 0;
		int next = 1;
		dp[now][0] = 0;
		scanf("%d %d %d", &C, &N, &M);
		vector<int> s(N), p(N); for (int i = 0; i < N; i++) scanf("%d %d", &s[i], &p[i]);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j <= 10000; j++) dp[next][j] = -1;
			for (int j = 0; j <= 10000; j++) {
				if (dp[now][j] == -1) continue;
				chmax(dp[next][j], dp[now][j]);
				if (j + s[i] <= 10000) chmax(dp[next][j + s[i]], dp[now][j] + p[i]);
			}
			swap(now, next);
		}
		for (int i = 0; i < 10000; i++) chmax(dp[now][i + 1], dp[now][i]);
		for (int i = 1; i <= M; i++) {
			printf("%lld\n", dp[now][C / i] * i);
		}
	}
	return 0;
}


Measured memory_bytes: 3468
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;	
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = (int)1e5+5;
LL a[5];
int main(void){
	rep(i, 3) scanf("%lld", a + i);
	sort(a, a + 3);
	DRI(k);
	rep(i, k) a[2] *= 2; 
	LL sum = a[0] + a[1] + a[2];
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input.split('\n')
  input[0] = input[0].split(' ').map(v => ~~v)
  const n = input[0][0]
  const m = input[0][1]
  if (n >= m) {
    console.log(0)
    return
  }

  const x = input[1]
    .split(' ')
    .map(v => ~~v)
    .sort((a, b) => a - b)

  const map = [0]
  for (let i = 1; i < m; i++) {
    map.push(x[i] - x[i - 1])
  }
  map.sort((a, b) => a - b)
  let sum = map.slice(0, m - n + 1).reduce((a, c) => a + c)

  console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll n;

int count_numbers ( int num) {
   int count =0;
   while (num !=0) {
      count++;
      num/=10;
   }
   return count;
}
int main(){

  cin >> n;
  ll x=0;
  for(int i=1;i<=n;++i){
   x+=count_numbers(i)%2;
  }
  cout << x;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)  throws IOException,NumberFormatException{
		try {
		FastScanner sc=new FastScanner();
		int a=sc.nextInt(),b=sc.nextInt();
		System.out.println((a+b)>=10?"error":a+b);
		}
		catch(Exception e) {
			return ;
		}
		
	}
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;
		for(int i=0;i<n;i++) {
			int oi=random.nextInt(n),temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try { 
                                      st=new StringTokenizer(br.readLine());				               
                              } catch (IOException e) {}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for(int i=0; i<n ; i++) a[i]=nextLong();
			return a;
		}
		
		String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
	}

}


Measured memory_bytes: 32708
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  ll a,b;
  cin >> a >> b;
  ll fa = 0,fb = 0;
  ll as = a,bs = b;
  as = as/4*4;
  bs = bs/4*4;
  FOR(i,as,a) fa^=i;
  FOR(i,bs,b+1) fb ^= i;
  cout << (fa^fb) << endl;
}


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

int main() {
	int n, x;
	int count;

	while(1){
		count = 0;
		cin >> n >> x;
		if (n == 0 && x ==0) break;

		for(int i = 1; i <= n - 2; i++){
			for(int j = i + 1; j <= n - 1; j++){
				for (int k = j + 1; k <= n; k++){
					if (i + j + k == x) { 
						count++;
					}
				}
			}
		}
		cout << count << endl;
	}

	return 0;
}


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

int main(){

  int n, len_str, len_vc, pos;
  string str;
  vector<char> vc;

  cin >> n;
  
  for(int i=0; i<n; i++){
    cin >> str;
    len_str = str.length();
    vc.clear();
    vc.push_back(str[0]);
    len_vc = 1;
    pos = 0;
  
    for(int j=1; j<len_str; j+=3){
      if(str[j] == '<'){
        if(pos != 0) pos--;
        else{
          vc.insert(vc.begin(), str[j+2]);
          len_vc++;
        }
      }
      else{
        if(pos != len_vc - 1) pos++;
        else{
          vc.push_back(str[j+2]);
          len_vc++;
          pos++;
        }
      }
    }
  
    for(int j=0; j<len_vc; j++){
      cout << vc[j];
    }
    cout << endl;
 
  }

  return 0;

}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
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; }
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
const ll max_n=110;
const ll max_v=100010;
// ll dp[max_n][max_v];

// Generated by {{ atcodertools.version }} {{ atcodertools.url }}  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int n;cin>>n;
    ll w;cin>>w;
    ll w_ary[n];
    ll v_ary[n];

    rep(i,n) cin >> w_ary[i] >> v_ary[i];

    ll dp[2][100010];
    rep(i,2) rep(j,max_v) dp[i][j]=MOD;
    dp[0][0] = 0;

    REP(i,1,n+1) rep(j,max_v)
    {
        if (j-v_ary[i-1]>=0) dp[i%2][j] = min(dp[(i-1)%2][j], dp[(i-1)%2][j-v_ary[i-1]]+w_ary[i-1]);
        else dp[i%2][j] = dp[(i-1)%2][j];
    }
    ll ans = 0;
    rep(i,100010)
    {
        if (dp[n%2][i] <= w) ans = i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#define f(n)for(int i=0;i<n;i++)
#define s(w)scanf("%d",&w);
int a,n,m,d[99][99],u[16]={-1,-1,-1,0,0,1,1,1,-1,0,1,-1,1,-1,0,1};void k(int x,int y){if(d[x][y]){d[x][y]=0;f(8)k(x+u[i],y+u[i+8]);}}int main(){a=0;s(n)s(m)if(n==0)return 0;f(9801)d[0][i]=0;f(n*m)s(d[i/n+1][i%n+1])f(n*m)if(d[i/n+1][i%n+1])a++,k(i/n+1,i%n+1);printf("%d\n",a);main();}

Measured memory_bytes: 1132
function Main(input) {
  var n = parseInt(input[0].trim(), 10);
  var s = input[1].trim();

  var mae = s.substring(0, Math.floor(n / 2));
  var ato = s.substring(Math.floor(n / 2), n);

  var result;
  if ((mae == ato)) {
    result = "Yes";
  } else {
    result = "No";
  }

//   console.log("%s", mae);
//   console.log("%s", ato);
  console.log("%s", result);
}

Main(
  require("fs")
    .readFileSync("/dev/stdin", "utf8")
    .split("\n")
);


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int N;
double x[1231];
double y[1231];

int main() {

    Scd(N);
    int a,b;
    Rep(i,N){
        Scd2(a,b);
        x[i] = a; y[i] = b;
    }

    double ans = 0;
    Rep(i,N) Rep(j,N){
        ans += sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
    }

    printf ("%.9lf\n", ans/N );

    return 0;
}





Measured memory_bytes: 256
N, A, B = map(int,input().split())
S = input()

Fore_rank = 1
passed = 0

for i in range(N):
    if S[i] == 'a' and A+B > passed:
        print("Yes")
        passed += 1
    elif S[i] == 'b' and A+B > passed and B >= Fore_rank:
        print("Yes")
        Fore_rank += 1
        passed += 1
    else: print("No")

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

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

int main(){
    int n,h;
    cin>>h>>n;
    
    vector<int> a(n),b(n),dp(h+1,1e9);
    rep(i,n) cin>>a[i]>>b[i];
    
    dp[0]=0;
    rep(i,n)rep(j,h+1)dp[min(j+a[i],h)]=min(dp[min(j+a[i],h)],dp[j]+b[i]);
    cout<<dp[h];
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


//combinationの最大値
#define MAX 200010
//mod
#define MOD 1000000007

//fac: 階乗、finv: 階乗の逆元(invの積)、inv: ある数の逆元(フェルマーの小定理より)
ll fac[MAX], finv[MAX], inv[MAX];

//テーブルを作る前処理
void combModInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算s
ll comb(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll pmod(ll n, ll m){
    if(m == 1) return n % MOD;
    if(m % 2 == 0){
        return pmod(n * n % MOD, m / 2) % MOD;
    }
    return n * pmod(n * n % MOD, (m - 1) / 2) % MOD;
}

// 二項係数計算(直接)
ll combDirect(ll n, ll k){
    ll frac = n; //分子
    ll deno = k; //分母
    for(ll i = n - 1; i > n - k; i--){
        frac = frac * i % MOD;
    }
    for(ll i = k - 1; i > 0; i--){
        deno = deno * i % MOD;
    }
    deno = pmod(deno, MOD - 2);
    return frac * deno % MOD;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans;
    ans = pmod(2, n) - 1;
    if(ans < 0){
        ans += MOD;
    }
    ans = ans - combDirect(n, a);
    if(ans < 0){
        ans += MOD;
    }
    ans = ans - combDirect(n, b);
    if(ans < 0){
        ans += MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

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

int bfs(vector<vector<char> > &board, int h, int w) {
    queue<pair<int, int> > qu;
    qu.push(make_pair(0, 0));
    vector<vector<int> > dist(h, vector<int>(w, -1));
    dist[0][0] = true;
    while (not qu.empty()) {
        auto yx = qu.front();
        qu.pop();
        int y = yx.first;
        int x = yx.second;
        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny >= 0 and ny < h and nx >= 0 and nx < w
                and board[ny][nx] == '.' and dist[ny][nx] == -1) {
                qu.push(make_pair(ny, nx));
                dist[ny][nx] = dist[y][x] + 1;

            }
        }
    }
    return dist[h - 1][w - 1];

}

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char> > board(h, vector<char>(w));
    int num_white = 0;
    rep(i, h) {
        rep(j, w) {
            cin >> board[i][j];
            if (board[i][j] == '.') num_white++;
        }
    }
    int ans = bfs(board, h, w);
    if (ans == -1) {
        cout << -1 << endl;
    } else {
        cout << num_white - ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

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

  int sum=0;
  for(int i=N-1;i>0;i--){
    sum += (N-1)/i;
  }

  cout<<sum<<endl;

  return 0;

}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,i,j,k,s=0;
cin>>n;
for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
        for(k=1;k<=n;k++){
          s=s+__gcd(i,__gcd(j,k));
        }
    }
}cout<<s;
    return 0;
  
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef pair<int,int> pr;
typedef vector<pr > vpr;
const int INF=1<<30;
int DP[302][302];
int sumS[302];
int sum(int a,int b){
	bool flag=false;
	int times=0;
	REP(i,20){
		times+=(a%10)*(b%10)+flag;
		flag=(a%10+b%10+flag>=10);
		a/=10;
		b/=10;
	}
	return times;
}
int connect(int s,int e){
	if(s==e)
	return 0;
	if(DP[s][e])
	return DP[s][e];
	int minium=INF;
	FOR(i,s,e)
		minium=min(minium,connect(s,i)+connect(i+1,e)+sum(sumS[i]-sumS[s-1],sumS[e]-sumS[i]));
	return DP[s][e]=minium;
}
int main() {
	int n;
	cin >> n;
	FOR(i,1,n+1){
	cin >> DP[i][i];
	sumS[i]=sumS[i-1]+DP[i][i];
	DP[i][i]=0;
	}
	cout << connect(1,n)  << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1544
from itertools import product, permutations


def warshall_floyd(d):
    # d        : nxn adjacent matrix
    for k, i, j in product(range(n), repeat=3):
        if d[i][j] > d[i][k] + d[k][j]:
            d[i][j] = d[i][k] + d[k][j]


INF = float("inf")
n, m, r = map(int, input().split())
r_list = list(map(lambda x: int(x) - 1, input().split()))
d = [[INF] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    d[a][b] = d[b][a] = c
warshall_floyd(d)

ans = float("inf")
for np in permutations(r_list):
    cand = sum([d[np[i]][np[i + 1]] for i in range(r - 1)])
    ans = min(ans, cand)

print(ans)


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

int main(){
    int s; cin >> s;
    int cnt=1;
    bool flag = true;
    while(flag){
        if(s%2==0){
            if(s==4){
                cout << cnt+3 << endl;
                flag = false;
            }else if(s==2){
                cout << cnt+3 << endl;
                flag = false;
            }else{
                s /= 2;
            }
        }else if(s==1){
            cout << cnt+3 << endl;
            flag = false;
        }else{
            s = 3*s+1;
        }
        cnt++;
    }
}

Measured memory_bytes: 256