akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class C100To105 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll x;
	    in >> x;
	    vector<ll> dp(x+1, 0);
	    dp[0] = 1;
	    for(int i=0; i<=x; i++){
	        if(i >= 100 && dp[i-100]) dp[i] = 1;
	        if(i >= 101 && dp[i-101]) dp[i] = 1;
	        if(i >= 102 && dp[i-102]) dp[i] = 1;
	        if(i >= 103 && dp[i-103]) dp[i] = 1;
	        if(i >= 104 && dp[i-104]) dp[i] = 1;
	        if(i >= 105 && dp[i-105]) dp[i] = 1;
	    }

	    out << dp[x] << endl;
	}
};


int main() {
	C100To105 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#define pb push_back
using namespace std;
typedef long long li;

const int Mod = 1e9 + 7;
inline int Add(int x, int y) { x += y; return x >= Mod ? x - Mod : x; }
inline int Sub(int x, int y) { x -= y; return x < 0 ? x + Mod : x; }
inline int Mul(int x, int y) { return 1LL * x * y % Mod; }
int Pow(int x, int y = Mod - 2) {
  if (y < 0) return 0;
  int res = 1;
  while (y) {
    if (y & 1) res = Mul(res, x);
    x = Mul(x, x);
    y >>= 1;
  }
  return res;
}

const int maxn = 2010;
int n, m;
li X;

struct edge {
  int u, v, intree;
  li dis;
  inline bool operator < (const edge &p) const {
    return dis < p.dis;
  }
};
vector<edge> E;

namespace Tree {
  int par[maxn], dep[maxn];
  li path[maxn];
  vector< pair<int, li> > g[maxn];

  li Query(int x, int y) {
    li res = 0;
    if (dep[x] < dep[y]) swap(x, y);
    while (dep[x] > dep[y]) {
      res = max(res, path[x]);
      x = par[x];
    }
    while (x != y) {
      res = max(res, path[x]);
      res = max(res, path[y]);
      x = par[x];
      y = par[y];
    }
    return res;
  }
  
  void Dfs(int x, int pre) {
    for (auto p : g[x]) {
      int y = p.first;
      if (y == pre) continue;
      par[y] = x;
      dep[y] = dep[x] + 1;
      path[y] = p.second;
      Dfs(y, x);
    }
  }
  void Build(void) {
    for (int i = 1; i <= n; ++i) g[i].clear();
    for (int i = 0; i < m; ++i) {
      edge e = E[i];
      if (e.intree) {
        g[e.u].pb({e.v, e.dis});
        g[e.v].pb({e.u, e.dis});
      }
    }
    path[1] = par[1] = dep[1] = 0;
    Dfs(1, 0);
  }
}

namespace GetMST {
  int fa[maxn];

  int Find(int x) {
    return fa[x] == x ? x : fa[x] = Find(fa[x]);
  }
  
  li Solve(void) {
    li sum = 0;
    for (int i = 1; i <= n; ++i) fa[i] = i;
    sort(E.begin(), E.end());
    
    for (int i = 0; i < m; ++i) {
      edge e = E[i];
      int x = Find(e.u), y = Find(e.v);
      if (x == y) continue;
      
      sum += e.dis;
      E[i].intree = 1;
      fa[x] = y;
    }

    return sum;
  }
}

int main(void) {
  scanf("%d%d%lld", &n, &m, &X);
  for (int i = 0; i < m; ++i) {
    edge tmp;
    scanf("%d%d%lld", &tmp.u, &tmp.v, &tmp.dis);
    tmp.intree = 0;
    E.pb(tmp);
  }

  li lim = X - GetMST::Solve();
  if (lim < 0) {
    puts("0");
    return 0;
  }
  
  Tree::Build();

  int eq = 0, upper = 0;
  for (int i = 0; i < m; ++i) {
    edge e = E[i];
    if (e.intree) continue;
    li diff = e.dis - Tree::Query(e.u, e.v);
    if (diff == lim) ++eq;
    else if (diff > lim) ++upper;
  }

  int ans = 0;
  if (lim == 0) ans = Mul(Sub(Pow(2, n - 1), 2), Pow(2, m - n + 1));
  ans = Add(ans, Mul(2, Mul(Sub(Pow(2, eq), 1), Pow(2, upper))));
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 512
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

namespace mine
{
	const int INF=0x3f3f3f3f;
	typedef long long ll;

	const ll MOD=1e9+7;
	ll qpower(ll x,ll e)
	{
		ll ans=1;
		while(e>0)
		{
			if(e&1) ans=ans*x%MOD;
			x=x*x%MOD;e>>=1;
		}
		return ans;
	}
	ll inv(ll x) {return qpower(x,MOD-2);}

	const int MAX_N=25100;
	ll fac[410];//<=k
	ll P(int n,int m) {return fac[n]*inv(fac[n-m])%MOD;}

	int a[MAX_N];
	bool b[410];
	ll f[MAX_N][410],g[MAX_N][410];
	void main()
	{
		fac[0]=1;for(int i=1;i<410;i++) fac[i]=fac[i-1]*i%MOD;

		int n,k,m;scanf("%d%d%d",&n,&k,&m);
		for(int i=1;i<=m;i++) scanf("%d",&a[i]);

		int mxlen=1;
		for(int l=1,r=0;l<=m;b[a[l++]]=0)
		{
			if(l>r) b[a[++r]]=1;
			while(r+1<=m and !b[a[r+1]]) b[a[++r]]=1;
			mxlen=max(mxlen,r-l+1);
		}

		ll ans=ll(n-m+1)*qpower(k,n-m)%MOD;
		if(mxlen==k) ;
		else if(mxlen<m)
		{
			memset(b,0,sizeof b);int ls=0;while(ls+1<=m and !b[a[ls+1]]) b[a[++ls]]=1;
			f[0][ls]=1;
			memset(b,0,sizeof b);int rs=m+1;while(rs-1>=1 and !b[a[rs-1]]) b[a[--rs]]=1;
			g[0][m-rs+1]=1;//debug 要的是长度

			for(int i=1;i<=n-m;i++)
			{
				ll fsum=0,gsum=0;
				for(int ln=k-1;ln>=1;ln--)
				{
					(fsum+=f[i-1][ln])%=MOD;(gsum+=g[i-1][ln])%=MOD;
					f[i][ln]=(f[i-1][ln-1]*(k-(ln-1))%MOD+fsum)%MOD;
					g[i][ln]=(g[i-1][ln-1]*(k-(ln-1))%MOD+gsum)%MOD;
				}
			}
			for(int left=0;left<=n-m;left++)
			{
				ll fsum=0,gsum=0;
				for(int ln=k-1;ln>=1;ln--)
					(fsum+=f[left][ln])%=MOD,(gsum+=g[n-m-left][ln])%=MOD;
				(ans-=fsum*gsum%MOD)%=MOD;
			}
		}
		else
		{
			f[0][0]=1;
			for(int i=1;i<=n;i++)
			{
				ll fsum=0,gsum=0;
				for(int ln=k-1;ln>=1;ln--)
				{
					(fsum+=f[i-1][ln])%=MOD;(gsum+=g[i-1][ln])%=MOD;
					f[i][ln]=(f[i-1][ln-1]*(k-(ln-1))%MOD+fsum)%MOD;
					g[i][ln]=(g[i-1][ln-1]*(k-(ln-1))%MOD+gsum)%MOD;
					if(ln>=m) (g[i][ln]+=f[i][ln])%=MOD;
				}
			}
			ll tot=0;
			for(int i=1;i<=k-1;i++) (tot+=g[n][i])%=MOD;
			(ans-=tot*inv(P(k,m))%MOD)%=MOD;
		}
		printf("%lld",(ans+MOD)%MOD);
	}
}
int main()
{
	mine::main();
}


Measured memory_bytes: 160768
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;

using ll = long long int;



long long int N, M;

int main() {

	cin >> N >> M;
	vector<vector<int>>v(N, vector<int>(M));
	for (auto &i : v) {
		for (auto &j : i)cin >> j;
	}
	vector<vector<int>>dis(N, vector<int>(M, 10000));
	vector<vector<vector<vector<int>>>>dp(M, vector<vector<vector<int>>>(N, vector<vector<int>>(M)));
	for (int i = M - 1; i >= 0; i--) {
		int mi = 100000;
		for (int j = 0; j < N; j++) {
			mi = min(mi, v[j][i]);
		}
		for (int j = 0; j < N; j++) {
			if (mi != v[j][i])continue;
			if (i == M - 1) {
				dp[i][j][0] = { j };
			}
			else {
				for (int k = 0; k < M; k++) {
					for (int l = 0; l < N; l++) {
						if (l != j) {
							if (k - 1 <0 || dp[i + 1][l][k - 1].empty())continue;
							if (dp[i][j][k].empty()) {
								dp[i][j][k] = { j };
								for (auto m : dp[i + 1][l][k - 1])dp[i][j][k].push_back(m);
							}
							else {
								vector<int>comp({ j });
								for (auto m : dp[i + 1][l][k - 1])comp.push_back(m);
								dp[i][j][k] = min(dp[i][j][k], comp);
							}
						}
						else {
							if (dp[i + 1][l][k].empty())continue;
							if (dp[i][j][k].empty()) {
								dp[i][j][k] = { j };
								for (auto m : dp[i + 1][l][k])dp[i][j][k].push_back(m);
							}
							else {
								vector<int>comp({ j });
								for (auto m : dp[i + 1][l][k])comp.push_back(m);
								dp[i][j][k] = min(dp[i][j][k], comp);
							}
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < M; k++) {
				if (dp[i][j][k].empty())continue;
//				cout << i << " " << j << " " << k << endl;
//				for (auto l : dp[i][j][k])cout << l << " ";
//				cout << endl;
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < M; i++) {
		int add = 100000;
		for (int j = 0; j < N; j++) {
			add = min(add, v[j][i]);
		}
		sum += add;
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			if (dp[0][j][i].empty())continue;
			cout << sum << " " << i << endl;
			for (auto k : dp[0][j][i])cout << k+1 << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 18992
#include <iostream>
#include <deque>
#include <sstream>
#include <cstdio>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,t;
	string c;
	vector< vector<int> > dp;
	while(cin >> c){
		dp.resize(dp.size()+1);
		rep(i,c.length())if(c[i] == ',')c[i] = ' ';
		stringstream ss(c);
		while(ss >> t)dp.back().push_back(t);
	}
	for(int i=1;i<dp.size()/2+1;i++){
		rep(j,dp[i].size()){
			int ins = 0;
			if(j)ins = max(ins,dp[i-1][j-1]);
			if(j != dp[i].size()-1)ins = max(ins,dp[i-1][j]);
			dp[i][j] += ins;
		}
	}

	for(int i=dp.size()/2+1;i<dp.size();i++){
		rep(j,dp[i].size()){
			dp[i][j] += max(dp[i-1][j+1],dp[i-1][j]);
		}
	}
	cout << dp.back()[0] << endl;
		
	
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> sta(N-1,vector<int>(3));
  for (int i = 0; i < N-1; i++) {
    for (int j = 0; j < 3; j++) cin >> sta[i][j];
  }
  
  for (int i = 0; i < N-1; i++) {
    int T = sta[i][1];
    for (int j = i; j < N-1; j++) {
      if (T < sta[j][1]) T = sta[j][1];
      else if (T%sta[j][2] != 0) T = T-(T%sta[j][2])+sta[j][2];
      T += sta[j][0];
    }
    cout << T << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
   int a, b, keta;

   while(scanf("%d %d", &a, &b)!=EOF){
      a+=b;
      keta=1;
      while((a/=10)!=0) keta++;
      printf("%d\n", keta);
   }
   return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

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

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7

int main() {
    string S;
    cin >> S;
    rep(i, S.size()) {
        cout << 'x';
    }
    cout << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n;
  cin >> n;
  vi a(n);
  int cnt = 0;
  for (int &i : a)
    cin >> i;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 32; j++) {
      if ( !(a[i] & 1 << j) )
        cnt++;
      else
        break;
    }
  }
  cout << cnt << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S;

    cin >> S;

    if(S=="KIHBR") cout << "YES" << endl;
    else if(S=="AKIHBR") cout << "YES" << endl;
    else if(S=="KIHABR") cout << "YES" << endl;
    else if(S=="KIHBAR") cout << "YES" << endl;
    else if(S=="KIHBRA") cout << "YES" << endl;
    else if(S=="AKIHABR") cout << "YES" << endl;
    else if(S=="AKIHBAR") cout << "YES" << endl;
    else if(S=="AKIHBRA") cout << "YES" << endl;
    else if(S=="KIHABAR") cout << "YES" << endl;
    else if(S=="KIHABRA") cout << "YES" << endl;
    else if(S=="KIHBARA") cout << "YES" << endl;
    else if(S=="AKIHABAR") cout << "YES" << endl;
    else if(S=="AKIHABRA") cout << "YES" << endl;
    else if(S=="AKIHBARA") cout << "YES" << endl;
    else if(S=="KIHABARA") cout << "YES" << endl;
    else if(S=="AKIHABARA") cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
struct graph
{
    struct edge
    {
        int v; double w;
        edge(int v, double w):v(v),w(w){}
        bool operator>(const edge& other)const
        {
            return this->w > other.w;
        }
    };
    int n; 
    vector<vector<edge>> adj;
    graph(int n):n(n){ adj.resize(n); }
    void add_edge(int u, int v, double w)
    {
        adj[u].push_back(edge(v,w));
        adj[v].push_back(edge(u,w));
    }
    double SSSP(int s, int t)
    {
        vector<double> d(n,INF);
        vector<bool> vis(n,false);

        priority_queue<edge,vector<edge>,greater<edge>> frontier;
        frontier.push({s,0});
        d[s] = 0;

        while(!frontier.empty())
        {
            int u = frontier.top().v;
            frontier.pop();

            if(!vis[u])
            {
                vis[u] = true;
                for(const edge& e : adj[u])
                    if(d[u]+e.w < d[e.v])
                    {
                        d[e.v] = d[u]+e.w;
                        frontier.push({e.v,d[e.v]});
                    }
            }
        }
        return d[t];
    }
};
struct circle
{
    struct point
    {
        LL x, y; 
        point(){}
        point(LL x, LL y):x(x),y(y){}
        const point operator-(point& other)const
        {
            return point(this->x-other.x, this->y-other.y);
        }
        LL dist2() const
        {
            return x*x + y*y;
        }
        double dist() const
        {
            return sqrt(dist2());
        }
    };
    point c; LL r;
    circle():r(0){}
    circle(LL x, LL y, LL r):r(r){ c.x = x, c.y = y; }
};
double dist(circle& c1, circle& c2)
{
    // if r1 + r1 >= dist(c1,c2)
    if((c1.r+c2.r)*(c1.r+c2.r) >= (c1.c-c2.c).dist2())
        return 0;
    else
        return (c1.c-c2.c).dist() - (c1.r+c2.r);
}
int main()
{
    circle s, t;
    cin >> s.c.x >> s.c.y >> t.c.x >> t.c.y;

    int n; cin >> n;
    graph g(n+2);

    vector<circle> pt = {s}; pt.reserve(n+2);
    for(int u = 1; u <= n; u++)
    {
        LL x, y, r; cin >> x >> y >> r;
        pt.push_back(circle(x,y,r));
    }
    pt.push_back(t);

    for(int u = 0; u < n+2; u++)
        for(int v = u+1; v < n+2; v++)
            g.add_edge(u,v,dist(pt[u],pt[v]));  

    cout<<fixed<<setprecision(20)<<g.SSSP(0,n+1)<<endl;

    return 0;
}

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

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

ll f(ll x, ll y) {
	ll res = oo;
	if (x <= y) res = min(res,y-x);
	if (-x <= y) res = min(res,1+y+x);
	if (x <= -y) res = min(res,1-y-x);
	if (-x <= -y) res = min(res,2-y+x);
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll x, y; cin >> x >> y;
	cout << f(x,y) << endl;

}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int n,i,j;
int a=0;
scanf("%d",&n);
for(i=1;i<10;i++)
  {
   for(j=1;j<10;j++)
      if(i*j==n)
      {
      	a=1;
      break;
      }
     }
if(a==0)
printf("No");
	else
	printf("Yes");     
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF (1<<31)-1

int main(){
    int ans=0,sum=0;
    int n,k;
    
    cin >>n>>k;
    int h[n];
    int cost[n];


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

    cost[0]=0;

    for (int i = 1; i < n; i++){
        int c=INF;

        for (int j = 1; j <= min(k,i); j++){
            c=min(c,cost[i-j]+abs(h[i]-h[i-j]));
        }
        cost[i] = c;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << cost[n-1] << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int powMod(int n, int p, int mod) {
  int res = 1;
  while (p) {
    if (p & 1) (res *= n) %= mod;
    (n *= n) %= mod;
    p >>= 1;
  }
  return res;
}

signed main() {
  int N;
  cin >> N;
  
  string s;
  cin >> s;

  vector<int> one;
  REP(i, N) if(s[i] == '1') one.emplace_back(i);

  int a = 0, b = 0;
  REP(i, N){
    a *= 2; b *= 2;
    if(s[i] == '1'){
      a++, b++;
    }
    a %= one.size()+1;
    if((int)one.size()-1 >= 1){
      b %= one.size()-1;
    }
  }

  vector<int> dp(N+1, 1);
  FOR(i, 1, N+1){
    int cnt = __builtin_popcountll(i);
    dp[i] = dp[i%cnt]+1;
  }

  REP(i, N){
    if(s[i] == '1'){
      if(one.size() == 1) cout << 0 << "\n";
      else{
        int t = (b-powMod(2, N-1-i, one.size()-1))%((int)one.size()-1);
        if(t < 0) t += one.size()-1;
        cout << dp[t] << "\n";
      }
    }else{
      int t = (a+powMod(2, N-1-i, one.size()+1))%((int)one.size()+1);
      if(t < 0) t += one.size()+1;
      cout << dp[t] << "\n";
    }
  }

  return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

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

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s;

    cin >> s;
    cout << s[0];
    cin >> s;
    cout << s[1];
    cin >> s;
    cout << s[2] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

struct Circle {
    int x;
    int y;
    int r;
    int c;
};

bool overwrap(const Circle& c1, const Circle& c2)
{
    const int d = c1.r + c2.r;
    const int R = (c1.x - c2.x) * (c1.x - c2.x) + (c1.y - c2.y) * (c1.y - c2.y);
    return d * d > R;
}

int n;
int dp(map<int, int>& table, const vector<vector<bool>>& wrap, const int state, const vector<Circle>& circle)
{
    if (table.find(state) != table.end()) {
        return table[state];
    } else {
        vector<int> sub(4, 0);
        vector<vector<int>> top(4, vector<int>(0));
        for (int j = 0; j < n; j++) {
            if (state & (1 << j)) {
                bool ok = true;
                for (int i = 0; i < j; i++) {
                    if (state & (1 << i)) {
                        if (wrap[i][j]) {
                            ok = false;
                            break;
                        }
                    }
                }
                if (ok) {
                    sub[circle[j].c] += (1 << j);
                    top[circle[j].c].push_back(j);
                }
            }
        }
        int maxi = 0;
        for (int i = 0; i < 4; i++) {
            const int size = top[i].size();
            if (size <= 1) {
                continue;
            }

            for (int j = 0; j < size; j++) {
                for (int k = j + 1; k < size; k++) {
                    const int val = dp(table, wrap, state - (1 << top[i][j]) - (1 << top[i][k]), circle);
                    maxi = max(maxi, val + 2);
                }
            }

            // if (size % 2 == 0) {
            //     const int val = dp(table, wrap, state - sub[i], circle);
            //     maxi = max(maxi, val + size);
            // } else {
            //     int maxi = 0;
            //     for (int j = 0; j < size; j++) {
            //         const int val = dp(table, wrap, state - sub[i] + (1 << top[i][j]), circle);
            //         maxi = max(maxi, val + (size / 2 * 2));
            //     }
            // }
        }
        table[state] = maxi;
        return maxi;
    }
}

int main()
{
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<Circle> circle(n);
        for (int i = 0; i < n; i++) {
            int x, y, r;
            int c;
            cin >> x >> y >> r >> c;
            c--;
            circle[i] = Circle{x, y, r, c};
        }

        vector<vector<bool>> wrap(n, vector<bool>(n, false));  // j?????????i?????????
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                wrap[i][j] = overwrap(circle[i], circle[j]);
            }
        }

        const int maximum = 1 << n;
        map<int, int> table;
        table[0] = 0;
        cout << dp(table, wrap, maximum - 1, circle) << endl;
    }
    return 0;
}

Measured memory_bytes: 52332
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

bool check(ll n){
	int work[3]={3,5,7};
	bool flag[3]={false,false,false};
	while(n>0){
		rep(i,3){
			if(n%10==work[i])flag[i]=true;
		}
		n/=10;
	}
	return flag[0]&&flag[1]&&flag[2];
}
int main(void){
	ll n;
	cin>>n;
	queue<ll> que;
	que.push(3);
	que.push(5);
	que.push(7);

	ll ans=0;
	while(!que.empty()){
		ll tmp=que.front();
		que.pop();
		if(tmp<=n){
			if(check(tmp))ans++;
			que.push(tmp*10+3);
			que.push(tmp*10+5);
			que.push(tmp*10+7);
		}
	}
	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 768
#include <stdio.h>
#include <limits.h>

int main(void){
    int n, i, tmp, tmp2;
    int profit = INT_MIN;
    int min = INT_MAX;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        tmp2 = tmp-min;
        if(tmp2>profit){
            profit=tmp2;
        }
        if(tmp<min)min=tmp;
    }
    printf("%d\n",profit);
    return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;

int log22(int x,int y){
  int k=x;
  while(k<y)k*=2;
  return k/x;
  //x*2^?>=y となる2^?
}

int main(){
  int n,k;
  cin >> n >> k;
  long double ans=0.0;
  if(n>=k)ans+=(n-k+1.1-0.1)/n;
  rep(i,min(n,k-1)){ 
    //2^t>=k&&2^(t-1)<k->ans+=1/2^t
    ans+=(1.1-0.1)/(n*log22(i+1,k));
  }
  cout << fixed << setprecision(15);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int L,M,N,i,a=0;
    while(1){
        a=0;
        scanf("%d",&L);
        if(L==0)break;
        for(i=0;i<12;i++){
            scanf("%d %d",&M,&N);
            L-=(M-N);
            if(L<=0&&a==0){
                printf("%d\n",i+1);
                a++;
            }
        }
        if(L>0)printf("NA\n");
    }
    return 0;
}

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

const int N = 310;
int n , a[N][N] , m , freq[N];
set < int > st;

void calc()
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(st.count(a[i][j]) == 0)
			{
				freq[a[i][j]]++;
				break;
			}
		}
	}
}

int main()
{
	cin >> n >> m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int best = n;
	int k = m;
	while(k--)
	{
		for(int i=0;i<N;i++) freq[i] = 0;
		calc();
	//	for(int i=0;i<=m + 1;i++) cout << freq[i] << " ";
	//	cout << endl;
		int mx = 0 , idx = 0;
		for(int i=0;i<N;i++)
		{
			if(freq[i] > mx)
			{
				mx = freq[i];
				idx = i;
			}
		}
		best = min(best , mx);
		st.insert(idx);
	}
	cout << best;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    vector<int>v(3); for(auto && e:v)cin >> e;
    sort(all(v));
    int ans = INF;
    do{
        cmin(ans,abs(v[1]-v[0])+abs(v[2]-v[1]));
    }while(next_permutation(all(v)));
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<ll,ll>
#define endl "\n"
#define MAXN 100005
using namespace std;

ll x;

void solve()
{
	cin>>x;
	for(ll i=-200;i<=200;i++)
	{
		for(ll j=-200;j<=200;j++)
		{
			ll t=pow(i,5)-pow(j,5);
			if(t==x)
			{
				cout<<i<<" "<<j<<endl;
				return;
			}
		}
	}
}

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


Measured memory_bytes: 4080
#include <iostream>
#include <string>

using namespace std;

int main(){

    int n, a, b;
    cin >> n >> a >> b;
    int total = 0;

    for (int i = 1; i <= n; i++) {

        int sum = 0;
        int temp = i;
        while (temp > 0) {
            sum += temp % 10;
            temp /= 10;
        }
        


        if(sum >= a && sum <= b) {
            total = total + i;
        } 

    }

    cout << total << endl;
  

    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
S=set(A)
c=Counter(A)
L=c.most_common(len(S))
 
x=len(S)-1
for _ in range(len(S)-K):
    count=count+int(L[x][1])
    x=x-1
 
print(count)

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

#define FASTIO1 ios_base::sync_with_stdio(false)
#define FASTIO2 cin.tie(NULL),cout.tie(NULL)
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll power(ll x,ll y,ll p);
const ll inf=999999999;
const ll mod=1e9+7;
bool tc=false;

void solve()
{
	ll n; cin>>n;
	if(n==1)
		cout<<0;
	else
		cout<<(power(10,n,mod)-power(9,n,mod)*2+power(8,n,mod)+mod*2)%mod;
}

int main() 
{
    FASTIO1;
    FASTIO2;
    clock_t start=clock();
    ll t=1; 
    if(tc) cin>>t;
    while(t--)
        solve();
    cerr<<fixed<<setprecision(6);
    cerr<<(double)(clock()-start)/CLOCKS_PER_SEC<<endl;
    return 0;
}

ll power(ll x,ll y,ll p)  
{  
    ll res=1; x=x%p;
    if(x==0) return 0;
    while(y>0)  
    {
        if(y&1) res=(res*x)%p;
        y=y>>1; x=(x*x)%p;  
    }
    return res;  
}  


Measured memory_bytes: 3756
n = int(input())
s = n // 3

def cmb2(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


total = 0
for i in range(s):
  y = n - 3*(i+1)
  x = cmb2(y+i,i,p)
  total = (total + x) % (10**9+7)
  
print(total)  
  

Measured memory_bytes: 128044
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

class SquareDivision{
    private:
        const int bucketSize = 256;
        ll N, B;
        vector<ll> data;
        vector<ll> bucketAdd;

    public:
        void prepare(int n){
            B = (n + bucketSize - 1)/ bucketSize;
            N = B * bucketSize;
            data.assign(N, 0);
            bucketAdd.assign(B, 0);
        }

        void add(int s, int t, int x){
            for(int k=0; k<B; k++){
                int l = k * bucketSize;
                int r = (k + 1) * bucketSize;

                if(r <= s || t <= l) continue;

                if(s <= l && r <= t){
                    bucketAdd[k] += x;
                }
                else{
                    for(int i=max(s, l); i<min(t, r); i++){
                        data[i] += x;
                    }
                }
            }
        }

        int get(int i){
            int k = i / bucketSize;
            return data[i] + bucketAdd[k];
        }
};

int main(){
    int n, q; cin>>n>>q;
    SquareDivision ans;
    ans.prepare(n);

    while(q--){
        int c; cin>>c;
        if(c == 0){
            int s, t, x; cin>>s>>t>>x;
            ans.add(s, t+1, x);
        }
        else{
            int i; cin>>i;
            cout << ans.get(i) << endl;
        }
    }
}


Measured memory_bytes: 3620
use strict;
use warnings;

my $str = <STDIN>;
chomp $str;

my $length      = length($str) ;
my @str_array   = split(q{}, $str);

my $count = 0;

for my $i ( 0..$length-1 ) {
    $count += 1 if $str_array[$i] ne $str_array[-($i+1)];
}

print $count/2;

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;

//マクロ
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<long long, long long> 
#define vin(v,N) for(int i=0;i<N;i++) cin>>v.at(i)
#define pb push_back

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(ll x,ll N){
  ll ret=1;
  for(int i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//素因数分解(mapで返す)
map<ll,ll> factor(ll p){
  ll p1=p;
  map<ll,ll>ret;
  for(ll i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}

int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  ll N;cin>>N;
  vector<map<ll,ll>>fac(N-1);
  for(ll i=0;i<N-1;i++){
    fac[i]=factor(i+2);
  }
  map<ll,ll>Fac;
  rep(i,N-1){
    //cout<<i<<": ";
    for(auto p:fac[i]){
      Fac[p.first]+=p.second;
      //cout<<"("<<p.first<<","<<p.second<<") ";
    }
    //cout<<endl;
  }
  
  ll res=1;
  
  for(auto p:Fac){
    res=res*(p.second+1)%mod;
  }
  
  cout<<res;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
//cout<<setprecision(1)<<fixed<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;
#define eps 1e-7
//#define Kongxiangzhouye
int n;
int a[123][123];
int st[123];
int ed[123];
int now;
void dfs(int local){
	st[local]=now++;
	for(int i=1;i<=n;i++){
		if(a[local][i]){
			if(st[i]==0){
				dfs(i);
			}
		}
	}
	ed[local]=now++;
}
int main(){
	ios::sync_with_stdio(false);
	while(cin>>n){
		memset(a,0,sizeof(a));
		memset(st,0,sizeof(st));
		memset(ed,0,sizeof(ed));
		for(int i=0;i<n;i++){
			int t,m;
			cin>>t>>m;
			for(int i=0;i<m;i++){
				int te;
				cin>>te;
				a[t][te]=1;
			}
			now=1;
		}
		for(int i=1;i<=n;i++){
			if(!st[i])
				dfs(i);
		}
		for(int i=1;i<=n;i++){
			cout<<i<<" "<<st[i]<<" "<<ed[i]<<endl;
		}
	}
	return 0;
}


//


Measured memory_bytes: 3220
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	a := sc.NextInt()
	b := sc.NextInt()

	base := a
	another := b
	if a < b {
		base = b
		another = a
	}
	for i := 1; i < 1000000; i++ {
		ans := base * i
		if ans%another == 0 {
			fmt.Printf("%+v\n", ans) // output for debug
			return
		}
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

using namespace std;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, a[300000], dp[300000];
	cin >> n;
	for (int i=0; i<n; ++i)
		cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	for (int i=2; i<n; ++i)
		dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
	cout << dp[n-1] << endl;
	return 0;
}


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

int main(){
  char S[6];
  int i;
  for(i = 0; i < 6; i++){
    cin >> S[i];
  }
  if(S[2] == S[3] && S[4] == S[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	VI h(n);
	REP(i, n)
		cin >> h[i];
	int ans = 0, p = 0;
	REP(i, n - 1) {
		if (h[i] >= h[i + 1])
			p++;
		else {
			ans = max(ans, p);
			p = 0;
		}
	}
	ans = max(ans, p);
	cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define per(i,l,r) for (int i=l;i>=r;i--)
using namespace std;
typedef unsigned long long ull;
const ull mm=419;
const ull mm2=31;
const ull mm3=998244353;
int n;
char s[60];
ull ans;
map<ull,int> mp;
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	int all=1<<n;
	rep(i,0,all-1){
		ull h1=0,h2=0;
		rep(j,0,n-1) {
			if (i&(1<<j)) h1=h1*mm+s[j]-'a'+1;
		}
		per(j,n-1,0) {
			if (~i&(1<<j)) h2=h2*mm2+s[j]-'a'+1;
		}
		h1=h1*mm3+h2;
		mp[h1]++;
	}
	rep(i,0,all-1){
		ull h1=0,h2=0;
		rep(j,0,n-1) {
			if (i&(1<<j)) h1=h1*mm2+s[n+j]-'a'+1;
		}
		per(j,n-1,0) {
			if (~i&(1<<j)) h2=h2*mm+s[n+j]-'a'+1;
		}
		h2=h2*mm3+h1;
		ans+=mp[h2];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 33024
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;


// 0 : left, 1 : right
int dx[2][9] = {
    {1,1,1,1,1,2,2,2,3}, 
    {-1,-1,-1,-1,-1,-2,-2,-2,-3}
};
int dy[2][9] = {
    {2,1,0,-1,-2,1,0,-1,0},
    {2,1,0,-1,-2,1,0,-1,0}
};

char mp[100][100];
int cost[2][100][100];
void init(){
    for(int y = 0; y < 100; y++){
        for(int x = 0; x < 100; x++){
            mp[y][x] = 'X';
            cost[0][y][x] = 11451419;
            cost[1][y][x] = 11451419;
        }
    }
}

int main(){

    for(int w, h; cin >> w >> h, w; ){
        init();
        priority_queue<PP, vector<PP>, greater<PP> >Q;
        for(int y = 1 + 10; y <= h + 10; y++){
            for(int x = 1 + 10; x <= w + 10; x++){
                cin >> mp[y][x];
                if(mp[y][x] == 'S'){
                    Q.push(PP(P(0, 0), P(x, y)));
                    Q.push(PP(P(0, 1), P(x, y)));
                }
            }
        }
        int ans = 11451419;
        while(!Q.empty()){
            int cst = Q.top().first.first;
            int lr = Q.top().first.second;
            int x = Q.top().second.first;
            int y = Q.top().second.second;
            Q.pop();
            if(cost[lr][y][x] < 11451419)continue;
            cost[lr][y][x] = cst;
            if(mp[y][x] == 'T'){
                ans = cst;
                break;
            }
            for(int i = 0; i < 9; i++){
                int nx = x + dx[lr][i];
                int ny = y + dy[lr][i];
                if(mp[ny][nx] == 'X')continue;
                if(cost[lr ^ 1][ny][nx] < 11451419)continue;
                int ncst = cst;
                if('0' <= mp[ny][nx] && mp[ny][nx] <= '9'){
                    ncst += mp[ny][nx] - '0';
                }
                Q.push(PP(P(ncst, lr ^ 1), P(nx, ny)));
            }
        }
        if(ans == 11451419)cout << -1 << endl;
        else cout << ans << endl;
    }

    return 0;
}


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

vector<LL> fact;
vector<LL> inver(200001);

LL combination(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}

LL fpow(LL a, LL n,LL m){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%m;
        }
        a=a*a%m;
        n >>= 1;
    }
    return x;
}

LL dp[3001][3001];
LL ways[3001];

//iをjに分割する個数
LL rec(int i,int j){
    if(dp[i][j]) return dp[i][j];
    if(i<j) return 0;
    else if(i==j||j==0) return 1;
    else return dp[i][j]=(rec(i-1,j-1)+(j+1)*rec(i-1,j))%mod;
}

int main(){
    int N;
    cin >> N >> mod;
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=200000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[200000]=fpow(fact[200000],mod-2,mod);
    for(int i=199999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            ways[i]=(ways[i]+rec(i,j)*fpow(2,(N-i)*j,mod))%mod;
        }
        ways[i]*=fpow(2,fpow(2,N-i,mod-1),mod);
        ways[i]%=mod;
    }
    LL ans=0;
    for(int i=0;i<=N;i++){
        if(i%2) ans=(ans+mod-(combination(N,i)*ways[i])%mod)%mod;
        else ans=(ans+combination(N,i)*ways[i])%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 72176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	ld d;
	cin >> d;
	ld ans = d / sqrt(2) * 2;
	FOR(i, 1, 11)
	{
		ld h = sqrt(d*d - i*i);
		if (h >= 0 && h <= 1) chmax(ans, (ld)i + 1);
	}
	cout << D10 << ans << endl;
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct PrimeList
{
    PrimeList(ll n)
    {
        vector<bool> isPrime(n, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i <= n; ++i)
        {
            if (!isPrime[i])
                continue;
            mPrimeList.push_back(i);
            for (int j = i * 2; j <= n; j += i)
                isPrime[j] = false;
        }
    }

    //! i番目の素数を取得
    int get(int i)
    {
        return mPrimeList[i];
    }

    vector<int> mPrimeList;
};

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

int main()
{
    ll A, B;
    cin >> A >> B;

    ll m = gcd(A, B);
    PrimeList pl(1000005);

    vector<pll> v;
    REP(i, pl.mPrimeList.size())
    {
        if (m <= 1)
            break;
        ll pr = pl.get(i);
        pll p(pr, 0);
        ll n = 0;
        while (m % pr == 0)
        {
            m /= pr;
            p.second++;
        }
        if (p.second > 0)
        {
            v.push_back(p);
        }
    }
    if (m > 1)
    {
        pll p(m, 1);
        v.push_back(p);
    }

    ll ans = 1 + v.size();

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1020