akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

class unionfind {
  vector<int> v;

  int size(int n) {
    return -v[root(n)];
  }

  int parent(int n) {
    return v[n] < 0 ? n : v[n];
  }

  int root(int n) {
    return parent(n) == n ? n : v[n] = root(parent(n));
  }

public:
  int component_count;

  unionfind(int n) {
    v.resize(n, -1);
    component_count = n;
  }

  int unite(int a, int b) {
    int ra = root(a);
    int rb = root(b);
    if (ra == rb) return -1;
    component_count--;
    if (size(ra) < size(rb)) swap(ra, rb);
    v[ra] += v[rb];
    v[rb] = ra;
    return size(ra);
  }
};

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

  unionfind uf(n);

  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    uf.unite(x, y);
  }
  cout << uf.component_count << endl;
}


Measured memory_bytes: 640
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
double dist(int x, int y){
	double ans = 0;

	ans = pow(x*x+y*y, 0.5);
	return ans;
}

void solve(){

	int n;
	cin >> n;

	int x[n+1],y[n+1];
	for(int i = 0;i<n;i++){
		cin >> x[i] >> y[i];
	}

	double ans=0.0;

	for(int i = 0;i<n;i++ )
		for(int j = i+1;j<n;j++){
		ans+=2*dist(x[i]-x[j], y[i]-y[j])/n;
	}

	cout << fixed << setprecision(10)<< ans << endl;
	
}
	
	

signed main() 
{   
	IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

struct RollingHash{
	ll M;
	vector<ll> H,B;
	RollingHash(string s,ll b=1009LL,ll m=1000000007LL){
		//ll b= 9973LL,ll m = 999999937LL
		M = m;
		ll n = s.size();
		B.resize(n+1);
		H.resize(n+1,0);
		B[0] = 1;
		for(ll i=0;i<n;i++){
			B[i+1] = (B[i]*b)%M;
			H[i+1] = (H[i]*b%M+s[i])%M;
		}
	}
	ll GetHash(ll l,ll r){ // [l,r)
		return (H[r]+(M-B[r-l]*H[l]%M))%M;
	}
};


int main(){
	
	int N;
	string S;
	cin >> N >> S;
	RollingHash rh1(S),rh2(S,9973LL,999999937LL);

	int ok=0 ,ng=N;
	while(ng-ok>1){
		int mid = (ng+ok)/2;
		map<ll,ll> ma1,ma2,ma1b,ma2b;
		bool did = false;
		vector<ll> H1,H2;
		FOR(i,0,N-mid+1){
			ll h1 = rh1.GetHash(i,i+mid);
			ll h2 = rh2.GetHash(i,i+mid);
			H1.push_back(h1);
			H2.push_back(h2);
			ma1[h1]++;
			ma2[h2]++;
			if(i>=mid){
				ma1b[H1[i-mid]]--;
				ma2b[H2[i-mid]]--;
			}
			if((ma1[h1]-ma1b[h1])>1 && (ma2[h2]-ma2b[h2])>1){
				ok = mid;
				did = true;
				break;
			}
			ma1b[h1]++;
			ma2b[h2]++;
		}
		if(!did){
			ng = mid;
		}
	}
	cout << ok << endl;

}


Measured memory_bytes: 1884
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    ll k,a,b;
    cin >> k >> a >> b;
    ll ans = k+1;
    ll cnt = 0;

    if(b - a <= 2){
        ans = k+1;
    }else{
        //a<b
        ll tmp = 0;
        if(a+1 <= k){//a枚にたどり着ける
            tmp = b;//1回目
            cnt += a+1;
            ll tm = (k-cnt)/2;
            ll md = (k-cnt)%2;
            tmp += (b-a)*tm;
            tmp += md;
        }
        ans = max(ans,tmp);
    }

    cout << ans << endl;







    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            double goukei = 0;
            for (int i = 0; i < n; i++)
            {
                var x = Console.ReadLine().Split(' ');
                if(x[1]=="JPY")
                {
                    goukei += double.Parse(x[0]);
                }
                else
                {
                    goukei += double.Parse(x[0]) * 380000;
                }
            }
            Console.WriteLine(goukei);
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    map <string,bool> mp;
    ll N;
    cin >> N;
    ll i,ans=0;
    string S;
    for(i=0;i<N;i++){
        cin >> S;
        if(mp.count(S)!=1){
            ans++;
            mp[S]=1;
        }
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i,H)cin >> S[i];
    vector<vector<int>> wid(H,vector<int>(W));
    vector<vector<int>> hei(H,vector<int>(W));
    REP(i,H){
        int now = 0;
        REP(l,W){
            if(S[i][l] == '#'){
                now = 0;
                wid[i][l] = now;
            }else{
                now++;
                wid[i][l] = now;
            }
        }
    }
    REP(i,W){
        int now = 0;
        REP(l,H){
            if(S[l][i] == '#'){
                now = 0;
                hei[l][i] = now;
            }else{
                now++;
                hei[l][i] = now;
            }
        }
    }
    RREP(i,H){
        int now = 0;
        RREP(l,W){
            if(S[i][l] == '#'){
                now = 0;
                wid[i][l] = now;
            }else{
                chmax(now,wid[i][l]);
                wid[i][l] = now;
            }
        }
    }
    RREP(i,W){
        int now = 0;
        RREP(l,H){
            if(S[l][i] == '#'){
                now = 0;
                hei[l][i] = now;
            }else{
                chmax(now,hei[l][i]);
                hei[l][i] = now;
            }
        }
    }
    // REP(i,H){
    //     REP(l,W){
    //         cout << wid[i][l];
    //     }
    //     cout << "\n";
    // }
    // REP(i,H){
    //     REP(l,W){
    //         cout << hei[i][l];
    //     }
    //     cout << "\n";
    // }
    int best = 0;
    REP(i,H){
        REP(l,W){
            chmax(best,hei[i][l] + wid[i][l]-1);
        }
    }
    cout << best << "\n";
}

Measured memory_bytes: 35968
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;


void solve()
{   
    string s, t;
    cin >> s >> t;

    int sz = (int) t.size();

    int ans = sz + 1;

    for(int i = 0; i + sz <= (int) s.size(); i ++) {
        int here = 0;

        for(int j = i; j < i + sz; j ++) {
            here += s[j] != t[j - i];
        }

        ans = min(ans, here);
    }

    prin(ans);
} 

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3684
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = True

for i in range(h):
    for k in range(w):
        if s[i][k] == "#":
            count = True
            d = [[0, 1], [1, 0], [0, -1], [-1, 0]]
            for l in d:
                if 0 <= i + l[0] < h and 0 <= k + l[1] < w:
                    if s[i + l[0]][k + l[1]] == "#":
                        count = False
                        break

            if count:
                ans = False

print("Yes") if ans else print("No")


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=202,mod=1e9+7;
int n,m,k,ans=1,cnt,top,dfn[N],low[N],q[N],fac[N],inv[N];
vector<int>G[N];
set<int>S;
set<int>::iterator it;
int C(int a,int b){return 1ll*fac[a]*inv[b]%mod*inv[a-b]%mod;}
int qpow(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}
int polya(int n)
{
	int ret=0;
	for(int i=1;i<=n;i++)ret=(ret+qpow(k,__gcd(n,i)))%mod;
	ret=1ll*ret*qpow(n,mod-2)%mod;
	return ret;
}
void tarjan(int u,int fa)
{
	dfn[u]=low[u]=++cnt,q[++top]=u;
	for(int i=0;i<G[u].size();i++)
	if(G[u][i]!=fa)
	{
		int v=G[u][i];
		if(!dfn[v])
		{
			tarjan(v,u),low[u]=min(low[u],low[v]);
			if(low[v]>=dfn[u])
			{
				S.clear();
				int n=0,m=0,now;
				do{
					S.insert(q[top]),now=q[top],q[top--]=0,n++;
				}while(now!=v);
				S.insert(u),n++;
				for(it=S.begin();it!=S.end();it++)
				{
					int x=*it;
					for(int j=0;j<G[x].size();j++)if(S.count(G[x][j]))m++;
				}
				m>>=1;
				if(m<n)ans=1ll*ans*k%mod;
				else if(m==n)ans=1ll*ans*polya(n)%mod;
				else ans=1ll*ans*C(m+k-1,m)%mod;
			}
		}
		else low[u]=min(low[u],dfn[v]);
	}
	if(!fa)q[top--]=0;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	fac[0]=1;for(int i=1;i<=m+k;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[m+k]=qpow(fac[m+k],mod-2);for(int i=m+k;i;i--)inv[i-1]=1ll*inv[i]*i%mod;
	for(int i=1,x,y;i<=m;i++)scanf("%d%d",&x,&y),G[x].push_back(y),G[y].push_back(x);
	for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i,0);
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int h, w, n;
vector<vector<int> > board;
vector<vector<int> > dp;

int main(int argc, char const* argv[])
{
  while(true){
    cin >> h >> w >> n;
    if(h == 0)break;
    board.clear();
    board.resize(h);
    dp.clear();
    dp.resize(h + 1);
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        int a;
        cin >> a;
        board[i].pb(a);
        dp[i].pb(0);
      }
      dp[i].pb(0);
    }
    for(int i = 0; i <= w; i++){
      dp[h].pb(0);
    }
    dp[0][0] = n - 1;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(board[i][j] == 0){
          dp[i + 1][j] += (dp[i][j] + 1) / 2;
          dp[i][j + 1] += (dp[i][j]) / 2;
        }else{
          dp[i + 1][j] += (dp[i][j]) / 2;
          dp[i][j + 1] += (dp[i][j] + 1) / 2;
        }
      }
    }
    int currx = 0;
    int curry = 0;
    while(true){
      if(currx == h || curry == w)break;
      if(board[currx][curry] == 0){
        if(dp[currx][curry] % 2 == 0){
          currx++;
        }else{
          curry++;
        }
      }else{
        if(dp[currx][curry] % 2 == 0){
          curry++;
        }else{
          currx++;
        }
      }
    }
    cout << currx + 1 << " " << curry + 1 << endl;
  }
	return 0;
}



Measured memory_bytes: 11076
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    string N;
    cin >> N;
    cout << "ABC" << N << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <set>
 
using namespace std;
 
const int MAX_V = 200005;
 
typedef pair<int, int> edge;
 
edge make_edge (int u, int v) {
  return make_pair(min(u, v), max(u, v));
}
 
vector<vector<int> > ans;
vector<int> adj [MAX_V];
int ord [MAX_V];
int cur;
set<edge> used;
 
void dfs (int vertex, int parent) {
  cur++;
  ord[vertex] = cur;
 
  for (int child : adj[vertex]) {
    if (ord[child] == 0) {
      dfs(child, vertex);
    }
  }
 
  vector<int> priority;
 
  /* back-edges */
  for (int child : adj[vertex]) {
    if (ord[child] < ord[vertex] &&
        child != parent &&
        used.count(make_edge(vertex, child)) == 0) {
      priority.push_back(child);
    }
  }
 
  /* child-edges */
  for (int child : adj[vertex]) {
    if (ord[child] > ord[vertex] &&
        used.count(make_edge(vertex, child)) == 0) {
      priority.push_back(child);
    }
  }
 
  /* parent-edge */
  if (used.count(make_edge(vertex, parent)) == 0 &&
      parent != 0) {
    priority.push_back(parent);
  }
 
  /* form the edge-pairs */
  for (int i = 0; i + 1 < (int) priority.size(); i += 2) {
    cout << vertex << " " << priority[i] << '\n';
    cout << vertex << " " << priority[i + 1] << '\n';
 
    used.insert(make_edge(priority[i], vertex));
    used.insert(make_edge(priority[i + 1], vertex));
  }
}
 
int main () {
  ios::sync_with_stdio(false);
 
  int vertexc, edgec;
  cin >> vertexc >> edgec;
 
  for (int i = 0; i < edgec; i++) {
    int u, v;
    cin >> u >> v;
 
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  if (edgec % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  
  dfs(1, 0);
}


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

using namespace std;


int h1[1000010];
int h[1000010];

int n;

int f[1000010];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
		h1[i] = h[i];
	}
	h1[n]--;
	bool tf = true;
	for (int i = n; i >= 1; i-- ) {
		if (h[i] < h[i - 1]) {
			if (h[i] < h[i - 1] - 1) {
				tf = false;
			}
			h[i - 1]--;
		}
	}
	if (tf) {
		cout << "Yes" << endl;
		return 0;
	}
	for (int i = n; i >= 1; i-- ) {
		if (h1[i] < h1[i - 1]) {
			if (h1[i] < h1[i - 1] - 1) {
				tf = false;
			}
			h1[i - 1]--;
		}
	}
	if (tf){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 8448
#define g(I)(p[x=P[I-1]]-p[P[I]])*1./(h[y=P[I]]-h[x])-h[x]-h[y]
long C,h[2<<17],p[2<<17],a;P[2<<17];s,t,x,y;
main(i){
	for(scanf("%*d%ld%d",&C,h);~scanf("%d",&a);){
		for(h[i]=a;s<t&&g(s+1)>-2*a;s++);
		p[i]=p[P[s]]+(a-=h[P[s]])*a+C;
		P[++t]=i;
		for(;s+1<t&&g(t)>g(t-1);P[--t]=i);
		i++;
	}
	printf("%ld",p[i-1]);
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int A[1005],B[1005],T[10005],V[1005];
int solve(int mini,int n)
{
	int ans=0;
	for(int i=0;i<n;i++){
		if(V[i]) continue;
		int cur=i,ssum=0,mmini=1e5,cnt=0;
		do{
			V[cur] = 1;
			int v = A[cur];
			ssum += v;
			mmini = min(mmini,v);
			cur = T[v];
			cnt++;
		} while (!V[cur]);
		ans += min(ssum+(cnt-2)*mmini,mmini+ssum+(cnt+1)*mini);
	}
	return ans;
}
int main()
{
	int n,mini=1e5; 
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
		B[i] = A[i];
		mini = min(A[i],mini);
	}

	sort(B,B+n);
	for(int i=0;i<n;i++) T[B[i]] = i;
	memset(V,0,sizeof(V));

	int ans = solve(mini,n);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
int n,a[2][111];
int main(){
	scanf("%d",&n);
	for(int i=0; i<2; i++){
		for(int j=0; j<n; j++){
			scanf("%d",&a[i][j]);
			a[i][j] += max(i>0?a[i-1][j]:0, j>0?a[i][j-1]:0);
		}
	}
	printf("%d\n",a[1][n-1]);
	return 0;
}


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

#define N_MAX 100000

using namespace std;



int main() {
  int N;
  int A[N_MAX], B[N_MAX], C[N_MAX];
  int ia, ib, ic;
  long long ans = 0;

  scanf("%d", &N);
  for(int i=0; i<N; i++) scanf("%d", A + i);
  for(int i=0; i<N; i++) scanf("%d", B + i);
  for(int i=0; i<N; i++) scanf("%d", C + i);

  sort(A, A + N);
  sort(B, B + N);
  sort(C, C + N);

  ia = ib = ic = 0;
  for(; ib < N; ib++) {
    for(; ia < N; ia++){
      if(A[ia] >= B[ib]) break;
    }
    for(; ic < N; ic++){
      if(C[ic] > B[ib]) break;
    }
    ans += (long long)ia * (N - ic);
  }

  printf("%llu\n", ans);

  return 0;
}


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

#define MAX 100000
#define min(a, b) a < b ? a : b

int main(void)
{
	long long N, a, b;
	long long x[MAX];
	int i;
	long long sum = 0;

	scanf("%lld %lld %lld", &N, &a, &b);
	for (i = 0; i < N; i++) {
		scanf("%lld", &x[i]);
	}
	/*printf("%d %d %d\n", N, a, b);
	for (i = 0; i < N; i++) {
		printf("%lld\n", x[i]);
	}*/
	for (i = 1; i < N; i++) {
		sum += min((x[i] - x[i - 1]) * a, b);
	}

	printf("%lld\n", sum);

	return (0);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main (){
  string S;
  cin >> S;
  int T = S.size();
  bool jud = true;
  
  for(int i=0; i<T; i++){
    if(i %2 == 0){
      if(S.at(i) == 'L'){
        jud = false;
      }
    }
    
    if(i %2 == 1){
      if(S.at(i) == 'R'){
        jud = false;
      }
    }
  }
  
  if(jud){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}
      

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

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

  sort(s.begin(), s.end());

  if (s[0] == 'a' && s[1] == 'b' && s[2] == 'c')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	s := next()
	out := ""
	for i := 0; i < len(s); i++ {
		out += "x"
	}

	fmt.Println(out)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

vector<int> cnt;
vector<bool> seen;

int dfs(const Graph &G, int v, int p){
    seen[v] = true;

    cnt[v] += p;

    for(int nv: G[v]){
        if(seen[nv]) continue;
        dfs(G, nv, cnt[v]);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    Graph G(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cnt.resize(n); seen.resize(n);
    rep(i,q){
        int p, x;
        cin >> p >> x; 
        p--;
        cnt[p] += x;
    }
    dfs(G,0,0);
    
    rep(i,n){
        cout << cnt[i] << " ";
    }
    
}

Measured memory_bytes: 23552
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            var m = int.Parse(Console.ReadLine().Trim());
            if (n == 0 && m == 0) break;
            var d = new Dictionary<int, List<int>>();
            for (int i = 1; i <= n; i++) d[i] = new List<int>();
            for (int i = 0; i < m; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var a = int.Parse(line[0]);
                var b = int.Parse(line[1]);
                d[a].Add(b);
                d[b].Add(a);
            }
            var hs = new HashSet<int>();
            foreach (var x in d[1])
            {
                hs.Add(x);
                foreach (var y in d[x])
                    hs.Add(y);
            }
            Console.WriteLine(hs.Count() - 1);
        }
    }
}





Measured memory_bytes: 10660
package main

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

var sc *bufio.Scanner

func nextString() string {
	sc.Scan()
	i := sc.Text()
	return i
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

type Dice struct {
	nums []int
}

//  /1
// 4/2/3/5
//  /6
func (d *Dice) rotate(direction string) {
	if direction == "W" {
		d.nums[0], d.nums[2], d.nums[5], d.nums[3] = d.nums[2], d.nums[5], d.nums[3], d.nums[0]
	}
	if direction == "E" {
		d.nums[0], d.nums[2], d.nums[5], d.nums[3] = d.nums[3], d.nums[0], d.nums[2], d.nums[5]
	}
	if direction == "N" {
		d.nums[0], d.nums[4], d.nums[5], d.nums[1] = d.nums[1], d.nums[0], d.nums[4], d.nums[5]
	}
	if direction == "S" {
		d.nums[0], d.nums[1], d.nums[5], d.nums[4] = d.nums[4], d.nums[0], d.nums[1], d.nums[5]
	}

}

func (d *Dice) lr(direction string) {
	if direction == "L" {
		d.nums[3], d.nums[1], d.nums[2], d.nums[4] = d.nums[1], d.nums[2], d.nums[4], d.nums[3]
	}
	if direction == "R" {
		d.nums[3], d.nums[1], d.nums[2], d.nums[4] = d.nums[4], d.nums[3], d.nums[1], d.nums[2]
	}
}

func (d *Dice) getindex(value int) (index int) {
	for i, v := range d.nums {
		if v == value {
			index = i
			break
		}
	}
	return index
}

func check(a, b []int) bool {
	flag := true
	for i, v := range a {
		if v != b[i] {
			flag = false
			break
		}
	}
	return flag
}

func compare(dice1, dice2 Dice) bool {
	iniDice2 := Dice{
		make([]int, 6),
	}
	for i := 0; i < 6; i++ {
		iniDice2.nums[i] = dice2.nums[i]
	}
	flag := true
	index := 0
	for i := 0; i < 6; i++ {
		for j := 0; j < 6; j++ {
			dice2.nums[j] = iniDice2.nums[j]
		}
		index = i
		if index == 1 {
			dice2.rotate("N")
		}
		if index == 2 {
			dice2.rotate("W")
		}
		if index == 3 {
			dice2.rotate("E")
		}
		if index == 4 {
			dice2.rotate("S")
		}
		if index == 5 {
			dice2.rotate("N")
			dice2.rotate("N")
		}
		for j := 0; j < 4; j++ {
			dice2.lr("L")
			flag = check(dice1.nums, dice2.nums)
			if flag {
				break
			}
		}
		if flag {
			break
		}
	}
	return flag
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	dices := make([]Dice, n)
	for i := 0; i < n; i++ {
		dices[i] = Dice{
			make([]int, 6),
		}
		for j := 0; j < 6; j++ {
			dices[i].nums[j] = nextInt()
		}
	}
	flag := true
	for i := 1; i < n; i++ {
		for j := 0; j < i; j++ {
			flag = compare(dices[i], dices[j])
			if flag {
				fmt.Println("No")
				break
			}
		}
		if flag {
			break
		}
	}
	if !(flag) {
		fmt.Println("Yes")
	}
}



Measured memory_bytes: 1100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
//const int MOD = 1000000007;
const int MOD = 998244353;
const ll INF = 1001001001001;

int main(){
    int n;
    ll d;
    cin>>n>>d;
    
    int ans = 0;
    
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        
        ll dist = x*x + y*y;
        if(dist<=d*d)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    static int bubbleSort(int[] data) {
        int ret = 0, n = data.length;
        for (int i = 0; i < n - 1; ++i) {
            for (int j = 0; j < n - 1; ++j) {
                if (data[j] > data[j + 1]) {
                    ++ret;
                    int tmp = data[j];
                    data[j] = data[j + 1];
                    data[j + 1] = tmp;
                }
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] data = new int[n];

        for (int i = 0; i < n; ++i) {
            data[i] = scanner.nextInt();
        }

        int cnt = bubbleSort(data);
        for (int i = 0; i < n; ++i) {
            System.out.print(data[i]);
            if (i != n - 1) System.out.print(" ");
        }
        System.out.println();
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26308
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); 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

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  char x, y;
  cin >> x >> y;
  if (x > y) P(">");
  else if (x == y) P("=");
  else P("<");

  return 0;
}

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

typedef long long unsigned llu;
typedef long long lld;
typedef long ld;
typedef unsigned int ui;

#define ff 			first
#define ss 			second
#define pb 			push_back
#define pob 		pop_back
#define mp 			make_pair
#define gcd(a,b)    __gcd(a,b)
#define IOS 		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define SET(a,val)  memset(a,val,sizeof(a))
#define PI          3.1415926535897932384626433832795

#define count1(n)   __builtin_popcount(n)   //count number of ones
#define trail0(n)   __builtin_ctz(n)        //count number of trailing zeros

#define imax 	INT_MAX
#define imin 	INT_MIN
#define ldmax	LONG_MAX
#define ldmin	LONG_MIN
#define lldmax  LLONG_MAX
#define lldmin  LLONG_MIN
#define llumax  ULLONG_MAX

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

//constants
const lld MOD=1000000007;
#define INF 	1<<57
#define MAX 	100000
#define gc 		getchar

int main()
{
    //freopen("input.txt", "r", stdin)
    //freopen("output.txt", "w", stdout)
    int n,k,s=1;
    scanf("%d",&n);
    scanf("%d",&k);
    while(n--)
    {
        if(s<k)
            s*=2;
        else
            s+=k;
    }
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

ll oddsolve(ll a) { return (a+1)/2 % 2; }
ll solve(ll a) {
    if (a % 2 == 1) return oddsolve(a);
    else return oddsolve(a+1) ^ (a+1);
}
int main() {
    ll A, B; cin >> A >> B;
    cout << (solve(B) ^ solve(A-1)) << endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if(a+b==c+d)
    cout << "Balanced" << endl;
  else if(a+b>c+d)
    cout << "Left" << endl;
  else
    cout << "Right" << endl;

}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 2e3 + 10;
int a[maxn];
int n, x;

int read() {
  if (scanf("%d%d", &n, &x) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  return 1;
}

int vals[maxn];

void solve() {
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    vals[i] = a[i];
    sum += vals[i];
  }

  long long res = sum;
  for (int iter = 0; iter < n; ++iter) {
    sum += x;
    for (int i = 0; i < n; ++i) {
      sum -= vals[i];
      vals[i] = min(vals[i], a[(n + i - iter - 1) % n]);
      sum += vals[i];
    }
    res = min(res, sum);
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
N,X=map(int,input().split())
Thick=[]
P=[]
a=1
b=1
for i in range(N+1):
  Thick.append(a)
  P.append(b)
  a=a*2+3
  b=b*2+1
def dfs(l,x):
  if l==0:
    return 1
  
  if x==1:
    return 0
  elif x==Thick[l]//2:
    return P[l-1]
  elif x==Thick[l]//2+1:
    return P[l-1]+1
  elif x==Thick[l]:
    return P[l-1]*2+1
  else:
    if x<Thick[l]//2:
      return dfs(l-1,x-1)
    else:
      return P[l-1]+1+dfs(l-1,x-(Thick[l]//2+1))

print(dfs(N,X))
  

Measured memory_bytes: 38384
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	vector<int> x(n+1,0),ans(n*(n+1),0),th(n+1,0);
	priority_queue<pair<int,int>> pq;
	priority_queue<pair<int,int>> pq2;
	FORQ(i,1,n){
		cin>>x[i];
		pq.push(MP(-x[i],i));
		pq2.push(MP(x[i],i));
		th[i]=x[i];
	}
	int l=1,r=n*n;
	while(pq.size()){
		pair<int,int> pr=pq.top();
		pq.pop();
		int tm=-pr.ST,num=pr.ND;
		FORQ(i,1,num){
			while(ans[l]!=0){
				l++;
			}
			if(i==num){
				if(ans[tm]!=0){
					cout<<"No"<<endl;
					return 0;
				}
				ans[tm]=num;
				if(l==tm)l++;
				break;
			}
			ans[l]=num;
			l++;
		}
	}
	while(pq2.size()){
		pair<int,int> pr=pq2.top();
		pq2.pop();
		int tm=pr.ST,num=pr.ND;
		FORQ(i,1,n-num){
			while(ans[r]!=0){
				r--;
			}
			ans[r]=num;
			r--;
			if(i==n-num){
				if(tm>r){
					cout<<"No"<<endl;
					return 0;
				}
				break;
			}
		}
	}

	cout<<"Yes"<<endl;
	FOR(i,1,n*n){
		cout<<ans[i]<<" ";
	}
	cout<<ans[n*n]<<endl;
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2)
{
	return ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
	return (a * (a + 1LL)) / 2;
}
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };


const int N = 3010;
const lli mod = 1e9 + 7;
const ld pi = acos(-1);
const int T = 238;
const ld e = 74e-9;

lli bp(lli a, lli b = -2LL)
{
	lli ret = 1;
	while (b)
	{
		if (b & 1) ret *= a, ret %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return ret;
}

int n, x, y;
int pat[N];
int main()
{
	fastio;
	cin >> n >> x >> y;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j < i; j++)
		{
			int sm = i - j;
			sm = min(sm, abs(i - y) + abs(j - x) + 1);
			pat[sm]++;
		}
	}
	for (int i = 1; i < n; i++)
	{
		cout << pat[i] << " ";
	}
	
	return 0;
}


/*
  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/


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

int main(void){
    
   string s;
   cin >> s;
   int len = s.size();
   
   for(int i=0;i<len;i++){
       if(s.at(i) == '7'){
           cout << "Yes" <<endl;
           break;
       }
       
       if(i == len-1) cout <<"No" <<endl; 
   }
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k; llong T[MAX];
int check(llong P){
    int i = 0;
    for(int j = 0; j < k; j++){
        llong s = 0;
        while(s + T[i] <= P){
            s += T[i];
            i++;
            if(i == n) return n;
        }
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;
    while(right - left > 1){
        mid = (left + right) / 2;
        int v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    return right;
}

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

ll n;
vll ans;

bool check(ll x){
	map<ll,ll> m;
	bool b=true;
	while(x){
		if(x%10!=3 && x%10!=5 && x%10!=7) b=false;
		m[x%10]++;
		x/=10;
	}
	return (m[3] && m[5] && m[7] && b);
}

void dfs(ll x){
	if(x>n) return;
	if(check(x)) ans.pb(x);
	dfs(x*10+3);
	dfs(x*10+5);
	dfs(x*10+7);
}

int main()
{
	cin >> n;
	dfs(0);
	cout << (ll)ans.size() << endl;
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int N;
char S[1100];
int main(){
  N = rd(S);
  if(S[N-1]=='s'){
    S[N++] = 'e';
  }
  S[N++] = 's';
  S[N] = '\0';
  wt_L(S);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200916-1

// --- original code ---
// int N;
// char S[1100];
// {
//   rd(S@N);
//   if(S[N-1]=='s') S[N++] = 'e';
//   S[N++] = 's';
//   S[N] = '\0';
//   wt(S);
// }


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define lld long long 
#define pb push_back
#define mk make_pair
using namespace std;

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

	int flag=0;

	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='7')
		{
			flag=1;
			break;
		}	

	}

	if(flag)
		cout<<"Yes"<<endl;

	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <cstring>
const int N = 200050;
typedef long long LL;
char s[N];
int oc[26];
int main() {
  scanf("%s", s);
  int n;
  LL ans = 0;
  for (n = 0; s[n]; ++n)
    ans += (++oc[s[n] - 'a']);
  printf("%lld\n", (LL)n * (n + 1) / 2 - ans + 1);
  return 0;
}


Measured memory_bytes: 384
import itertools
import numpy as np

H, W, K =map(int, input().split())

b = np.array([['.' for i in range(W)] for j in range(H)])

for h in range(H):
    b[h] = list(input())
    
h_conb = []
w_conb = []
for i in range(1,H+1):
    h_conb += list(itertools.combinations(range(H), i))
for i in range(1,W+1):
    w_conb += list(itertools.combinations(range(W), i))

count = 0

if K == 0:
    count += 1

for h in h_conb:
    for w in w_conb:
        #print(h, w)
        #print(b[list(h)][:,list(w)])
        if np.count_nonzero(b[list(h)][:,list(w)] == '#') == K:
            count += 1

print(count)

Measured memory_bytes: 27200
#include <stdio.h>

int main(){
    int n,count=0;
    scanf("%d",&n);
    int p[n];
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(int i=1;i<n-1;i++){
        if((p[i]>p[i-1])&&(p[i+1]>p[i])){
            count++;
        }else if((p[i]<p[i-1])&&(p[i]>p[i+1])){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;
int g;

int calc(int x){
    int ret = 0;
    while(x){
        x /= 2;
        ret += x;
    }
    return ret;
}
int solve(){
    int ret = 0;
    for(int i = 0 ; i < n ; i++){
        if(calc(n - 1) != calc(i) + calc(n - i - 1)) continue;
        ret = (ret + a[i]) % 2;
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        char c;
        cin >> c;
        a.push_back(c - '0' - 1);
    }
    int ans = solve();
    if(ans == 1) finish(1);
    for(auto &i : a) if(i == 1) finish(0);
    for(auto &i : a) i /= 2;
    cout << solve() * 2 << endl;
}


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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> w(N); rep(i, 0, N) { cin >> w[i]; }
	vector<int>v(w);
	sort(all(v));
	vector<int>T(10101);
	rep(i, 0, N)T[v[i]] = i;
	vector<bool>f(N, false);
	int min_w = *min_element(all(w));
	int ans(0);
	rep(i, 0, N) {
		if (f[i])continue;
		int sum(0),n(0),small(INF);
		int j = i;
		while (!f[j]) {
			dump(j);
			chmin(small, w[j]);
			n++;
			f[j] = true;
			sum += w[j];
			j = T[w[j]];
		}
		ans += min(sum + (n - 2)*small, 2 * (min_w + small) + sum - small + min_w + (n - 2)*min_w);
		dump(ans);
	}
	cout << ans << endl;
	return 0;
}

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;


int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.precision(20);
    int n, k;
    cin >> n >> k;
    vector<int> pos, neg;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x > 0) {
            pos.push_back(x);
        } else {
            neg.push_back(-x);
        }
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    int ans = 1e9 + 7;
    for (int i = 0; i <= k; i++) {
        int j = k - i;
        if (i > pos.size() || j > neg.size()) {
            continue;
        }
        int x = 0;
        if (i) {
            x = pos[i - 1];
        }
        int y = 0;
        if (j) {
            y = neg[j - 1];
        }
        ans = min(ans, x + x + y);
        ans = min(ans, x + y + y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1020
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, x, y;
	cin>>n>>x>>y;
	int ans[2020]={};
	x--; y--;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ans[min(j-i, abs(i-x)+abs(j-y)+1)]++;
		}
	}
	for(int i=1; i<n; i++) cout<<ans[i]<<endl;
	return 0;
}


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

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

inline int Sieve_of_Eratothenes(const int n) {

	std::vector<bool> flg(n + 1, true);
	for (int i = 2; i < n; i++) {
		if (flg[i]) {
			for (int j = i + i; j <= n; j += i) {
				flg[j] = false;
			}
		}
	}

	return(std::count(flg.begin(), flg.end(), true) - 2);

}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int a = 0;
	std::vector<int> A;
	while (std::cin >> a) {
		A.push_back(a);
	}

	std::for_each(A.begin(), A.end(),
		[](int i) {std::cout << Sieve_of_Eratothenes(i) << std::endl; });
}

Measured memory_bytes: 3080
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

vector<vector<int>> G;
vector<int> dp(100100);
int search(int v) {
    if (dp[v] != -1)
        return dp[v];

    int res = 0;
    for (auto nv : G[v]) {
        res = max(res, search(nv) + 1);
    }
    return dp[v] = res;
}

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

    G.assign(N, vector<int>());

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
    }

    rep(v, N){
      dp[v] = -1;
    }
    
    int res = 0;
    rep(v, N) { res = max(res, search(v)); }
    cout << res << endl;
}

Measured memory_bytes: 8192