akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define MAX 2020

char buf[MAX];
string A;
string B;

vector<int> v;

vector<pair<int, int> > vv;

vector<pair<int, int> > watch;

int main() {
	scanf("%s", buf);
	A = buf;
	scanf("%s", buf);
	B = buf;
	for (int i = 0; i < B.size(); i++) {
		if (B[i] == '1') {
			v.push_back(i - (int)(B.size()));
			v.push_back(i);
			v.push_back(i + (int)(B.size()));
		}
	}
	sort(v.begin(), v.end());
	if (A == B) {
		puts("0");
		return 0;
	}
	if (B.find('1') == string::npos) {
		puts("-1");
		return 0;
	}
	for (int i = 0; i < A.size(); i++) {
			
			int id = lower_bound(v.begin(), v.end(), i) - v.begin();
			int rig = v[id] - i;
			int id2 = upper_bound(v.begin(), v.end(), i) - v.begin();
			int lef = i-v[id2 - 1];
			vv.push_back(make_pair(lef, rig));
	}
	if (vv.size() == 0) {
		puts("0");
	}
	int n = A.size();
	int ans = INT_MAX;
	for (int i = 0; i < n; i++) {//A[j]=B[j+i]
		int cnt = 0;
		watch.clear();
		for (int j = 0; j < n; j++) {
			char cur = A[j];
			char go = B[(j + i)%B.size()];
			if (cur == go)continue;
			cnt++;
			if (go == '1') {

			}
			else {
				watch.push_back(vv[j]);
			}
		}
		sort(watch.begin(), watch.end());
		watch.push_back(make_pair(INT_MAX, 0));
		for (int i = (int)watch.size() - 2; i >= 0; i--) {
			watch[i].second = max(watch[i].second, watch[i + 1].second);
		}
		int idx = 0;
		for (int j = 0; j < n; j++) {
			while (watch[idx].first <= j) {
				idx++;
			}
			int len = 0;
			for (int k = 0; k < n; k++) {
				int need = 0;
				bool ng = true;
				need = max(need, watch[idx].second - k);
				if (ng == false) {
					len = k;
					break;
				}
				len = k + need;
				break;
			}
			{
				int sc = cnt;
				sc += j * 2;
				sc += len;
				int M = n + i - len;
				M %= n;
				M = min(M, n - M);
				sc += M;
				ans = min(ans, sc);
			}
			{
				int sc = cnt;
				sc += len * 2;
				sc += j;
				int M = j + i;
				M %= n;
				M = min(M, n - M);
				sc += M;
				ans = min(ans, sc);
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int k;
    cin >> k;
    vector<ll> lun;
    for (int i = 1; i < 10; i++) lun.push_back(i);
    int cnt = 0;
    while (lun.size() <= k) {
        ll p = lun[cnt] * 10;
        int q = lun[cnt] % 10;
        if (q == 0) {lun.push_back(p);lun.push_back(p+1);}
        else if (q == 9) {lun.push_back(p+8);lun.push_back(p+9);}
        else {
            for (int i = q-1; i <= q+1; i++) lun.push_back(p+i);
        }
        cnt++;
    }
    cout << lun[k-1] << endl;
    return 0;
}

Measured memory_bytes: 4232
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<pair<int, int>> v;

    for (int i = 0; i < A; i++) {
        int pi;
        cin >> pi;
        v.push_back({0, pi}); // red
    }

    for (int i = 0; i < B; i++) {
        int qi;
        cin >> qi;
        v.push_back({1, qi}); // green
    }

    for (int i = 0; i < C; i++) {
        int ri;
        cin >> ri;
        v.push_back({2, ri});
    }

    // cout << "X: " << X << endl;
    // cout << "Y: " << Y << endl;
    // cout << "v.size(): " << v.size() << endl;

    sort(v.begin(), v.end(), [](const auto &l, const auto &r) {
        return l.second > r.second;
    });

    long long ans = 0;
    int cnt = 0;
    int lastX = X;
    int lastY = Y;
    for (int i = 0; i < v.size(); i++) {
        // cout << v[i].first << ", " << v[i].second << endl;
        if (v[i].first == 0 && lastX <= 0) {
            continue;
        }
        if (v[i].first == 1 && lastY <= 0) {
            continue;
        }

        if (v[i].first == 0) {
            lastX--;
        } else if (v[i].first == 1) {
            lastY--;
        }
        ans += v[i].second;
        cnt++;

        // cout << "*: " << v[i].second << endl;
        // cout << "cnt: " << cnt << endl;

        if (cnt >= (X + Y)) {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6384
N = int(input())
A = [int(l) for l in input().split()]

count = 0
k = 0
while True:
  for i in range(N):
    if A[i]/2**k % 2 != 0:
      break
  else:
    count += 1
    k += 1
    continue
  break
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
int a, b, c, max;
scanf("%d %d %d", &a, &b, &c);
if(c>b&&c>a)
max = c;
if(b>c&&b>a){
max = b;
b = c;
}
if(a>b&&a>c){
max = a;
a = c;
}
if(a>b)
printf("%d %d %d\n",b ,a ,max);
else{
printf("%d %d %d\n",a ,b ,max);
}
return 0;
}

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

int main() {
    int N,count;
  count =0;
    cin >> N;
  int A[N],B[N],C[N-1];
  
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    cin >> B[i];
  }
    for(int i=0;i<N-1;i++){
    cin >> C[i];
  }
  
for(int i=0;i<N;i++){

   count +=  B[A[i]-1];
  if(A[i-1] + 1 == A[i]){
   count +=C[A[i]-2];
  }
}
  cout << count ;
  
  return 0;
}


Measured memory_bytes: 256
class UnionFindTree:
    """Disjoint-Set Data Structure

    Union-Find Tree

    complexity:
        - init: O(n)
        - find, unite, same: O(alpha(n))
    """

    def __init__(self, n):
        self.par = list(range(n))  # parent
        self.rank = [0] * n  # depth of tree

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)


def main() -> None:
    N, M, K = map(int, input().split())
    uft = UnionFindTree(N)
    ans = [-1] * N
    for i in range(M):
        a, b = map(int, input().split())
        uft.unite(a-1, b-1)
        ans[a-1] -= 1
        ans[b-1] -= 1
    groups = {}
    for i in range(N):
        p = uft.find(i)
        groups[p] = groups.get(p, 0) + 1
    for i in range(N):
        ans[i] += groups[uft.find(i)]
    for i in range(K):
        c, d = map(int, input().split())
        if uft.is_same(c-1, d-1):
            ans[c-1] -= 1
            ans[d-1] -= 1
    print(*ans)





if __name__ == '__main__':
    main()


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

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

    int a,b;
    cin >> a >> b;
    int dif = b - a;
    int realb = 0;
    for(int i = 0; i <= dif; i++){
        realb += i;
    }
    cout << realb - b << endl;
    return 0;
}


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

int main()
{
    int N, x, y, count;
    x = 0;
    y = 0;
    count = 0;
    cin >> N;

    for (int i = 0;i < N; i++){
        cin >> x >> y;
        count += y - x + 1;
    }
    cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using vis=vector<string>;
using vvi=vector<vi>;
//aとbの最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//aとbの最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n%2==0&&s.substr(0,n/2)==s.substr(n/2,n/2))
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <unordered_map>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int rk[100010];

signed main() {
	int n;
	cin >> n;

	vector<int> x;
	inputVector(x, n);

	int ret = 1;
	int num = 0;
	int pt = 0;
	int pti = 0;

	rep(i, n) {
		num++;
		ret *= num;
		ret %= MOD;
		//cerr << "i:" << i << endl;
		//cerr << " num:" << num << endl;
		//cerr << " ret:" << ret << endl;
		if (x[i] % 2 == 0 && (x[i] + 1 - pt) / 2 < (i + 1 - pti)) {
			num--;
			pt = x[i];
			pti = i + 1;
		}
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
char A[N], B[N];
int L[N], R[N], back[N];
int solve(char A[N], char B[N], int n) {
	int ans = 1e9;
	int tmp = -1;
	for (int i = n - 1; i >= 0; -- i) if (B[i] == '1') {tmp = i; break;}
	for (int i = 0; i < n; ++ i) {
		L[i] = B[i] == '1' ? i : tmp;
		tmp = L[i];
		L[i] = L[i] == -1 ? 1e9 : (i + n - L[i]) % n;
	}
	tmp = -1;
	for (int i = 0; i < n; ++ i) if (B[i] == '1') {tmp = i; break;}
	for (int i = n - 1; i >= 0; -- i) {
		R[i] = B[i] == '1' ? i : tmp;
		tmp = R[i];
		R[i] = R[i] == -1 ? 1e9 : (R[i] + n - i) % n;
	}
	for (int off = 0; off < n; ++ off) {
		int res = off;
		vector<pair<int, int>> a;
		for (int i = 0; i < n; ++ i) {
			int j = (i + off) % n;
			if (B[i] != A[j]) res ++;
			if (B[i] == '0' && A[j] == '1') {
				if (L[j] > off) a.push_back({L[i], R[j]});
			}
		}
		sort(a.begin(), a.end());
		int m = a.size();
		back[m] = 0;
		for (int i = m - 1; i >= 0; -- i) {
			back[i] = max(back[i + 1], a[i].second);
		}
		int j;
		ans = min(ans, res + 2 * back[0]);
		for (int i = 0; i < m; i = j) {
			for (j = i; j < m && a[i].first == a[j].first; ++ j);
			if (a[i].first == (int) 1e9 || back[j] == (int) 1e9) continue;
			ans = min(ans, res + 2 * (a[i].first + back[j]));
		}
	}
	return ans;
}
int main () {
	scanf("%s", A);
	scanf("%s", B);
	int n = strlen(A);
	int ans = solve(A, B, n);
	reverse(A, A + n);
	reverse(B, B + n);
	ans = min(ans, solve(A, B, n));
	if (ans >= 1e9) ans = -1;
	printf("%d\n", ans);
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  ll s;
  cin >> s;

  ll a = sqrtl(s);
  while (a * a < s) { ++a; }

  const int M = 1e9;

  auto Check = [&](ll x1, ll y2) {
    ll diff = x1 * y2 - s;
    if (diff < 0) { return false; }
    if (diff > M) { return false; }

    ll x2 = diff;
    ll y1 = 1;

    cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";
    return true;
  };

  if (Check(a, a)) { return 0; }
  if (Check(a, a - 1)) { return 0; }
  assert(false);

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
using namespace std;

    const ll N = 1e3 + 7;
    const ll mod = 1e9 + 7;



void solve(){
    string a;
    cin >> a;
    if(a[0] == tolower(a[0])){
        cout << "a";
    }
    else{
        cout << "A";
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


Measured memory_bytes: 3568
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<pii> v(n);
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		v[i] = { b,a };
	}
	sort(ALL(v));
	bool ok = true;
	ll t = 0;
	REP(i, n) {
		if (t + v[i].second > v[i].first) {
			cout << "No" << endl;
			return 0;
		}
		t += v[i].second;

	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1792
n = int(input())
h = list(map(int, input().split()))

dp = [float("inf")] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                dp[i - 1] + abs(h[i] - h[i - 1]))

print(dp[-1])


Measured memory_bytes: 52208
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



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

	int ca = 0;
	int cb = 0;

	rep(i, s.size())
	{
		if (s[i] == 'A') ca++;
		else cb++;
	}

	if (ca > 0 && cb > 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
integer N
integer,allocatable,dimension(:,:)::A,B
read*,N
allocate(A(2,N),B(2,N))
read*,A(1,:)
read*,A(2,:)
B(1,1)=A(1,1)
do i=2,N
  B(1,i)=B(1,i-1)+A(1,i)
end do
B(2,1)=B(1,1)+A(2,1)
do i=2,N
  B(2,i)=max(B(1,i),B(2,i-1))+A(2,i)
end do
print"(i0)",B(2,N)
end

Measured memory_bytes: 256
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
 
    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
 
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
 
    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
        
n=int(input())
xlist=[]
ylist=[]
rlist=[]
checked=[-1]*n
for i in range(n):
  x,y=map(int,input().split())
  xlist.append([x,i])
  ylist.append([y,i])
xlist=sorted(xlist,key=lambda x:x[0])
ylist=sorted(ylist,key=lambda x:x[0])
for i in range(1,n):
  cost=xlist[i][0]-xlist[i-1][0]
  rlist.append([cost,xlist[i][1],xlist[i-1][1]])
  cost=ylist[i][0]-ylist[i-1][0]
  rlist.append([cost,ylist[i][1],ylist[i-1][1]])
rlist=sorted(rlist,key=lambda x:x[0])
cnt=0
cost=0
groupn=0
groupc=0
t=UnionFind(n)
for c,p1,p2 in rlist:
  if cnt==n and groupn-groupc==1:
    break
  if checked[p1]==-1 and checked[p2]==-1:
    checked[p1]=groupn
    checked[p2]=groupn
    cost+=c
    cnt+=2
    groupn+=1
    t.Unite(p1,p2)
  elif checked[p1]==-1:
    checked[p1]=checked[p2]
    cost+=c
    cnt+=1
    t.Unite(p1,p2)
  elif checked[p2]==-1:
    checked[p2]=checked[p1]
    cost+=c
    cnt+=1
    t.Unite(p1,p2)
  elif checked[p1]==checked[p2]:
    continue
  else:
    if t.isSameGroup(p1,p2):
      continue
    else:
      cost+=c
      groupc+=1
      t.Unite(p1,p2)
print(cost)

Measured memory_bytes: 129196
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define eps 1e-7
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<29;
typedef unsigned long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int a,b;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

    cin >> a >> b;

    if(a%2==0 || b%2==0)
        cout << "No\n";
    else
        cout << "Yes\n";

	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int r = 0, b = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0') {
      r++;
    }
    if (s[i] == '1') {
      b++;
    }
  }
  cout << min(r, b) * 2 << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()

using namespace std;

int main(){
	int n;
  	cin >> n;
  	cout << 1110-n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int t, x;
    cin >> t >> x;
    double r = (double) t/x;
    cout << setprecision(20) << r << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3788
from collections import deque

N = int(input())
S = input()

reserveL = deque()
out = deque()
q = deque()

for s in S:
    if s == "(":
        reserveL.append(s)
        out.append("(")
    else:
        # print(len(reserveL))
        if len(reserveL) == 0:
            out.appendleft("(")
            out.append(")")
        else:
            out.append(")")
            reserveL.popleft()

    # print(out)

# print(out)
while reserveL:
    out.append(")")
    reserveL.popleft()
ans = ""
while out:
    ans += out.popleft()
print(ans)


Measured memory_bytes: 9312
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M2 == M1 + 1) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


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

typedef long long ll;
vector<ll> a;
int main(){
    ll n,b;
    cin >> n;
    a.resize(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]-=i;
    }

    sort(a.begin(),a.end());
    if(n%2==0){
        ll med1 = a[n/2];
        ll med2 = a[n/2-1];
        b = (med1+med2)/2;
    }else{
        b=a[n/2];
    }

    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-b);
    }

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

Measured memory_bytes: 1920
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin >> s >> t;
	ll ans=0;
	rep(i,0,3){
		if(s[i]==t[i]) ans++;
	}
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


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

int main(){
  int maxup=0, maxdown=0, n, t;
  cin >> t;

  for(int m = 0; m<t; ++m){
    maxup = maxdown = 0;
    
    cin >> n;

    int *h = new int[n];
    
    for(int i=0; i<n; ++i){
      cin >>h[i];
      
      if( i != 0){
	if(h[i-1] - h[i] < 0){
	  if(maxup < h[i] - h[i-1]) maxup = h[i] - h[i-1];
	}
	if(h[i-1] - h[i] > 0){
	  if(maxdown < h[i-1] - h[i]) maxdown = h[i-1] - h[i];
	}
      }
    }


    cout << maxup << " "<< maxdown << endl;

    delete[] h;
  }
  return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.h>

int mas[3][3];
int cpy[3][3];





void copy(int m[3][3], int t[3][3]) {
    int i, j;
    
    for(i = 0; i < 3; i++)
        for(j = 0; j < 3; j++) m[i][j] = t[i][j];
}

int calc() {
    int i, sum = 0;
    for(i = 0; i < 9; i++) {
        int v = mas[i/3][i%3];
        if(v) {
            v--;
            sum += abs(i/3-v/3)+abs(i%3-v%3);
        }
    }
    return sum;
}

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

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

int is_in(int x, int y) {
    return 0<=x&&x<3&&0<=y&&y<3;
}

int dfs(int x, int y, int p, int dep, const int lim) {
    int i, h = calc();
    if(h == 0) return dep;
    if(dep+h > lim) return -1;
    
    for(i = 0; i < 4; i++) {
        int nx = x+dx[i], ny = y+dy[i], res;
        if(~p && i == (p+2)%4) continue;
        if(!is_in(nx, ny)) continue;
        swap(&mas[y][x], &mas[ny][nx]);
        res = dfs(nx, ny, i, dep+1, lim);
        if(~res) return res;
        swap(&mas[y][x], &mas[ny][nx]);
    }
    
    return -1;
}

void get_empty(int *x, int *y) {
    int i, j;
    for(i = 0; i < 3; i++) {
        for(j = 0; j < 3; j++) {
            if(!mas[i][j]) {
                *x = j;
                *y = i;
                return;
            }
        }
    }
}

int solve() {
    int x, y, lim, ans;
    get_empty(&x, &y);
    for(lim = 0; lim < 50; lim++) {
        copy(cpy, mas);
        if((ans = dfs(x, y, -1, 0, lim)) != -1) return ans;
        copy(mas, cpy);
    }
    return -1;
}

int main() {
    int i, j;
    for(i = 0; i < 3; i++)
        for(j = 0; j < 3; j++)
            scanf("%d", &mas[i][j]);
    printf("%d\n", solve());
    return 0;
}



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

int main(){
	int n;
	cin>>n;
	int c=0,ms=0,s=0;
	int* p=new int[n];
	for(int i=0;i<n;i++){
		cin>>p[i];
		if(p[i]>ms) ms=p[i];
	}
	for(int i=1; i<=ms;i++){
		c=0;
		for(int j=0;j<n;j++){
			if(i<=p[j]) c++;
		}
		if(c>=i) s=i;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
using namespace std;
using ll = unsigned long long;

int main() {
  int x, y, z = 0;
  cin >> x >> y;

  if (x == 1) {
    z += 300000;
  } else if (x == 2) {
    z += 200000;
  } else if (x == 3) {
    z += 100000;
  }

  if (y == 1) {
    z += 300000;
  } else if (y == 2) {
    z += 200000;
  } else if (y == 3) {
    z += 100000;
  }

  if (x == 1 && y == 1) {
    z += 400000;
  }

  cout << z << endl;
}


Measured memory_bytes: 256
#115_D
N,X=map(int,input().split())
a=[1]
p=[1]
for i in range(1,N+1):
    a.append(a[i-1]*2+3)
    p.append(p[i-1]*2+1)
def f(n,x):
    if n==0:
        return 1 if x>0 else 0
    elif x<=1+a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])
    
print(f(N,X))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    ll n;
    scanf("%lld",&n);
    int min = 999;

    rep(i,10){
        if(abs(n%1000-753)<min){
            min = abs(n%1000-753);
        }
        n /= 10;
    }

    int ans = min;
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool p[1000000]={true,true};
int main(){
  for(int i=2; i<1000; i++)
    if(!p[i])
      for(int j=i*i; j<1000000; j+=i)
	p[j] = true;
  int n;
  while(cin >>n){
    int solve = 0;
    for(int i=0; i<=n; i++)
      if(!p[i])
	solve++;
    cout <<solve<<endl;
  }
  return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint N;
	cin >> N;
	char S[N];
	cin >> S;
	
	
	//SOLVE
	llint ans = 0;
	llint buf;
	llint i,j,k,l;
	
	for(i = 0; i<=999; i++ ) {
		//100
		buf = i/100;
		for(j = 0; j<=N-3; j++ ) {
			if (buf == (llint)(S[j]-'0')) {
				break;
			}
		}
		if (j == N-2) {
			i+=99;
			continue;
		} 
		
		//10
		buf = (i % 100)/10;
		for(k = j+1 ; k<=N-2; k++) {
			if (buf == (llint)(S[k]-'0')) {
				break;
			}
		}
		if (k == N-1) {
			i+= 9;
			continue;
		}
		
		//1
		buf = i % 10;
		for(l = k+1 ; l<=N-1; l++) {
			if (buf == (llint)(S[l]-'0')) {
				ans++;
				break;
			}
		}
		
	}
	
	
	//OUTPUT
	cout << ans << endl;
	
	
	// llint ans=0;
	// 
	// set<llint> pass;
	// 
	// llint pasno;
	// 
	// for(llint i=0;i<
	// 
	// pasno = ((llint)(S[0] - '0') *100) + ((llint)(S[1] - '0') * 10) + (llint)(S[2] - '0');
	// 
	// if (pass.count(pasno) == 0) {
	// 
	// } else {
	// 	pass.emplace(pasno);
	// }
	// 
	// //OUTPUT
	// cout << pass.size() << endl;
	
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
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; }

ll n;

int main() {
    cin >> n;
    map<ll, int> Amap;
    for(int i = 0; i < n; ++i) {
        ll Ain; cin >> Ain;
        Amap[Ain]++;
    }

    ll tate = 0; ll yoko = 0;
    for(auto x : Amap) {
        if(x.second >= 4) {
            tate = x.first; yoko = x.first;
        }else if(x.second >= 2) {
            if(tate > yoko) yoko = x.first;
            else tate = x.first;
        }
    }

    cout << tate*yoko << endl;
}

Measured memory_bytes: 6528
# これ灰difじゃないか？
# 各マス偶数回なら表 奇数回なら裏 -> 角は偶数回（4回）だし縁も偶数回（6回）だけどソレ以外は9回
# n, m = 1, 1の場合を忘れていてWA -> なんかしらんけどちがうっぽい 意味不明 （そもそも1,1のテストケースないんじゃないかこれ
# マジで納得がいかねぇ
n, m = map(int, input().split())
print(abs(n * m - (n * 2 + (m - 2) * 2)))


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int dp[100100];
int main()
{
    int n,m;
    cin >> n >> m;
    vector<P> key(m);
    rep(i, m){
        int a,b;
        cin >> a >> b;
        int val = 0;
        rep(j,b){
            int c;
            cin >> c;
            val+=(1<<(c-1));
        }
        key[i] = P(a,val);
    }
    rep(i, 100100)
    {
        dp[i] = 1e9;
    }
    dp[0] = 0;
    rep(i,m){
        rep(j,10000){
            dp[j | key[i].second] = min(dp[j | key[i].second],dp[j]+key[i].first);
        }
    }
    if(dp[(1<<n)-1]==1e9){
        cout << -1 << endl;
        return 0;
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
s = readlines.map(&:to_i)[1..-1].sort
S = s.inject(&:+)

if (S % 10) != 0
  puts S
  exit
end

min_not_divisible_num = s.index { |num| (num % 10) != 0 }

if min_not_divisible_num.nil?
  puts 0
else
  s.delete_at(min_not_divisible_num)
  puts s.inject(&:+)
end

Measured memory_bytes: 1788
import java.util.*;

//update 2019/12/13

public class Main{

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int n = nextInt();  int k = nextInt();
    int r = nextInt();  int s = nextInt();  int p = nextInt();
    String t = next();

    long ans = 0;

    String[] machine = splitString(t);

    //理想の手
    String[] ideal = win(machine);

    //とりあえずk回はok
    for(int i=0;i<k;i++){
      if(ideal[i].equals("p")){
        ans += p;
      }
      else if(ideal[i].equals("r")){
        ans += r;
      }
      else if(ideal[i].equals("s")){
        ans += s;
      }
    }

    //制限の調整
    for(int i=k;i<n;i++){
      int mae = i-k;
      if(ideal[mae].equals(ideal[i])){ //k回前と同じなら
        //手を変える。今回は0点
          ideal[i] = "-"; //

          //ここで適当に手を変えると、k個先と同じになってしまう場合がある。
          //また、k回前とk回先のどちらとも同じにならない手は必ず存在する。
          //k回先も見て変えてもよよいが、記述がめんどい。
          //よって、適当な文字に変えて良い。

      }
      else{ //k回前と同じでないなら、
        //理想手で勝利。理想手に基づいてポイントを加算。
        if(ideal[i].equals("p")){
          ans += p;
        }
        else if(ideal[i].equals("r")){
          ans += r;
        }
        else if(ideal[i].equals("s")){
          ans += s;
        }
      }
    }

    System.out.println(ans);


/*
    for(int i=0;i<n;i++){
      System.out.println("machine["+i+"]="+machine[i]);
    }
    for(int i=0;i<n;i++){
      System.out.println("real["+i+"]="+ideal[i]);
    }
*/

  }

  static String[] win(String[] machine){
    int lng = machine.length;
    String[] ideal = new String[lng];
    for(int i=0;i<lng;i++){
      if(machine[i].equals("r")){
        ideal[i] = "p";
      }
      else if(machine[i].equals("s")){
        ideal[i] = "r";
      }
      else if(machine[i].equals("p")){
        ideal[i] = "s";
      }
    }
    return ideal;
  }


  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char aaa){
    return aaa - 48;
  }

  public static int maxInt(int[] a,int lng){
    int max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static int minInt(int[] a,int lng){
    int min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

  public static long maxLong(long[] a,int lng){
    long max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static long minLong(long[] a,int lng){
    long min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

}


Measured memory_bytes: 34448
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n , a, b = f()
    x = f()
    dis = [x[i+1] - x[i] for i in range(n-1)]


    ans = 0
    for i in dis:
        if i*a <= b:
            ans += i * a
        else:
            ans += b
    
    print(ans)


solve()


Measured memory_bytes: 14480
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    ans = 0
    D = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI','SAT']
    
    return 7 - D.index(S)


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


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

char a[100][100];
int main()
{
    int h, w;
    cin >> h >> w;
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }
    a[1][1] = '.';
    int flag  = 1;
    int i = 1;
    int j = 1;
    while(j <= w) {
        int ok = 0;
        if(a[i][j + 1] == '#') {  // 可向右
            a[i][j + 1] = '.';
            ok = 1;
            j++;
        } else {
            if(a[i + 1][j] == '#') {// 可以向下
                a[i + 1][j] = '.';
                i++;
                ok = 1;
            }
        }
        if(ok == 0){
            flag = 0;
            break;
        }

        if(i == h && j == w){
            break;
        }

    }
    for(i = 1; i <= h; i++) {
        for(j = 1; j <= w; j++) {
            if(a[i][j] == '#') {
                flag = 0;
                break;
            }
        }
        if(flag == 0) {
            break;
        }

    }
    if(flag) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    
    int a, b;
    vector<int> vec;
    rep(i, N) vec.push_back(i + 1);
    int cnt = 0;
    do {
        if (P == vec) a = cnt;
        if (Q == vec) b = cnt;
        ++cnt;
    } while (next_permutation(vec.begin(), vec.end()));
    
    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char S[3] = {};
    scanf("%s",S);
    if(S[0]!=S[1]&&S[0]!=S[2]&&S[1]!=S[2]){
        printf("Yes");
        return 0;
    }else{
        printf("No");
        return 0;
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

const int nax = 1e5 + 5;
map<int, bool> AC;
map<int, int> WA;

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;

    int n, sub;
    cin >> n >> sub;
    int solve, pen;
    solve = pen = 0;
    for (int i = 0; i < sub; i++){
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC"){
            if (!AC[p]){
                AC[p] = true;
                solve++;
                pen += WA[p];
            }
        }
        else{
            if (!AC[p]){
                WA[p]++;
            }
        }
    }
    cout << solve << " " << pen << endl;
    return 0;
}




Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

const ll inf = 1LL << 62;
//struct edge {int to; ll cost;};
struct edge {int to; ll cost;};
struct node {int pos; ll cost;};
bool operator < (const node &a, const node &b){
    return a.cost > b.cost;
}

const int d = 2501;
int N;
vector<ll> dijkstra(vector<vector<edge>> &G, int root, int S){
    vector<ll> ret(G.size(), inf);
    priority_queue<node> pq;
    pq.push({root + N * S, 0});
    while (!pq.empty()) {
        node t = pq.top();
        pq.pop();
        
        if (ret[t.pos] == inf) ret[t.pos] = t.cost;
        else continue;
        
        for (edge e : G[t.pos]) {
            pq.push({e.to, t.cost + e.cost});
        }
    }
    return ret;
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int M;
    ll S;
    cin >> N >> M >> S;
    vector<vector<edge>> G(N * d);
    rep(i, M) {
        int U, V;
        int A;
        ll B;
        cin >> U >> V >> A >> B;
        U--;
        V--;
        rep(i, d) {
            if(i - A >= 0) G[U + N * i].pb({V + N * (i - A), B});
            if(i - A >= 0) G[V + N * i].pb({U + N * (i - A), B});
        }
    }
    rep(i, N) {
        ll C, D;
        cin >> C >> D;
        rep(j, d - 1) {
            G[i + N * j].pb({i + N * (int)min(ll(d) - 1, C + j), D});
        }
    }
    
    vector<ll> ans = dijkstra(G, 0, (int)min((ll)d - 1, S));
    
    vector<ll> ret(N, inf);
    rep(i, N) {
        rep(j, d) {
            ret[i] = min(ret[i], ans[i + j * N]);
        }
    }
    
    rep(i, 1, N) output(ret[i]);
    
    
    
    
    return 0;
}


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



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<vector<char>>c(2,vector<char>(3));
  auto d=c;

  rep(i,2)rep(j,3)cin>>c[i][j];
  rep(i,2)rep(j,3)d[i][j]=c[1-i][2-j];
  //cout<<c[0][0]<<d[0][0]<<endl;
  int f=1;
  rep(i,2)rep(j,3)
  {
    if(c[i][j]!=d[i][j])f=0;
  }
  if(f)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;



  return 0;

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int count = 0;

    for (int i = 0; i < n - 2; i++)
    {
        if ((p[i] < p[i + 1] && p[i + 2] >= p[i + 1]) || (p[i + 2] < p[i + 1] && p[i] >= p[i + 1]))
            ++count;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256