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

using namespace std;
#define BUF (1000)
#define ll long long 


int a[BUF];
int d[BUF];
int n;


int main(void){
	int cnt=0;
	cin >> n;
	for(int i=1;i<=n;i++) cin >> a[i];

	sort(a+1,a+n+1);

	for(int i=1;i<=n;i++){
		if(d[a[i]]==0){
			cnt++;
			d[a[i]]++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ary = gets.chomp.split.map(&:to_i)

dp = Array.new(n, Float::INFINITY)
dp[0] = 0

n.times do |i|
    if i+1 >= n
        next
    end    
    dp[i+1] = [dp[i]+(ary[i+1]-ary[i]).abs, dp[i+1]].min
    if i+2 >= n
        next
    end
    dp[i+2] = [dp[i]+(ary[i+2]-ary[i]).abs, dp[i+2]].min
end

puts dp[n-1]



Measured memory_bytes: 11788
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける


//   a/b mod c
ll moddiv(ll a,ll b){
	ll x0=MOD,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%MOD;
      if (x2==1){
        ans=(n2+MOD)%MOD;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%MOD)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1) ans=ans*aa%MOD;
    aa=aa*aa%MOD;
    beki/=2;
    if (beki==0)break;
  }
  return ans;
}


const ll HASH_P=2013265921;
const ll HASH_Wn=52278;
void makehash(vector<ll> &array,vector<ll> &outarray,ll leng)
{
  ll asz=outarray.size();
  ll alast=0;
  ll wi=1;
  for(ll i=0;i<leng;i++){
    alast=(alast+array[asz+i-1]%HASH_P*wi)%HASH_P;
    if (i==leng-1)break;
    wi*=HASH_Wn;
    wi%=HASH_P;
  }
  outarray[asz-1]=alast;

  for(ll i=asz-2;i>=0;i--){
    outarray[i]=(((outarray[i+1]-array[i+leng]*wi)%HASH_P)*HASH_Wn%HASH_P+array[i]+HASH_P)%HASH_P;
  }
}



ll n;

int main(){
  ll ans=0;
  cin >> n;
  vi a(n),b(n);
  vi sa(n*2-1),sb(n*2-1);
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n){
    cin>>b[i];
  }
  
  REP(i,n){
    sa[i]=a[i]^a[(i+1)%n];
  }
  REP(i,n){
    sb[i]=b[i]^b[(i+1)%n];
  }

  REP(i,n-1){
    sa[i+n]=sa[i];
    sb[i+n]=sb[i];
  }

  vi hsa(n),hsb(n);
  makehash(sa,hsa,n);
  makehash(sb,hsb,n);

  REP(i,n){
    if (hsb[0]==hsa[i]){
      cout<<i<<" "<<(b[0]^a[i])<<endl;
    }
  }



  return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100000;


int main(){
  int N = in(), count = 0, ans = 1000, x;

  rep(i, N){
    x = in();
    count = 0;
    while(x % 2 == 0){
      x /= 2;
      count++;
    }
    ans = min(ans, count);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

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

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////
int f(LL A) {
	int cnt = 0;
	while (A % 100 == 0) {
		A /= 100;
		cnt++;
	}
	return cnt;
}
void solve() {
	LL D, N;
	cin >> D >> N;
	
	int cnt = 0;
	for (int i = 1;; ++i) {
		int ter = i;
		if (f(ter) == D) {
			cnt++;
		}
		if (cnt == N) {
			cout << i << endl;
			return;
		}
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> data;
const int mod=1e9+7;
vector<data> a[205];
ll F[205];
const ll inf=1e18+10;
int Q;
int main(){
	F[0]=F[1]=1;
	for(int i=2;i<=200;i++) F[i]=F[i-1]+F[i-2];
	a[1].push_back(mp(1,2));
	a[1].push_back(mp(1,3));
	for(int i=1;i<=200;i++){
		for(int p=0,S=a[i].size();p<S;p++){
			ll x=a[i][p].first,y=a[i][p].second;
			x+=y;
			while(x<=F[i+3]+F[i]){
				a[i+1].push_back(mp(y,x));
				x+=y;
			}
		}
	}
	scanf("%d",&Q);
	ll n,m;
	while(Q--){
		scanf("%lld%lld",&n,&m);
		if(n>m) swap(n,m);
		int ans=1;
		while(F[ans+1]<=n&&F[ans+2]<=m) ans++;
		if(ans<=1){
			printf("%d %lld\n",ans,n*m%mod);
			continue;
		}
		ll num=0;
		for(int i=0,S=a[ans-1].size();i<S;i++){
			ll x=a[ans-1][i].first,y=a[ans-1][i].second;
			if(y<=n) num=(num+(m-x)/y)%mod;
			if(y<=m) num=(num+(n-x)/y)%mod;
		}
		printf("%d %lld\n",ans,num);
	}
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if((n%10==7)||((n/10)%10==7)||((n/100)%10==7))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const int N_MAX = 100;
const int S_MAX = 100;
const int NS_MAX = N_MAX * S_MAX;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> s(N);
    int smax = INT_MIN;
    rep(i, N) {
        cin >> s[i];
        smax = max(smax, s[i]);
    }
    bool dp[N_MAX][NS_MAX];
    dp[0][0] = 1;
    int ans = 0;
    
    rep(i, N) {
        rep(ii, N * smax + 1) {
            if (i == 0) {
                dp[i][ii] = (ii == s[i]);
            }
            else {
                dp[i][ii] = dp[i - 1][ii] || ((ii > s[i]) ? dp[i - 1][ii - s[i]] : false) || (ii == s[i]);
            }
            
            if ((dp[i][ii]) && (ii % 10 != 0)) {
                ans = max(ii, ans);
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int N = 3e2 + 1;
const int M = 22;
const ll mod = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
int a[N];
int b[N];
double ans[N][N][N];

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

    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> a[i];
        b[a[i]] += 1;
    }
    for( int i = 0; i <= n; i++ ){
        for( int j = 0; j <= n; j++ ){
            for( int h = 0; h <= n; h++ ){
                if( (i | j | h) == 0 )continue;
                int f = n - i - j - h;
                if( f < 0 )continue;
                double x1 = i * 1.0 / n;
                double x2 = j * 1.0 / n;
                double x3 = h * 1.0 / n;
                if( i ){
                    x1 *= ans[i - 1][j + 1][h];
                }
                if( j ){
                    x2 *= ans[i][j - 1][h + 1];
                }
                if( h ){
                    x3 *= ans[i][j][h - 1];
                }
                ans[i][j][h] = (x1 + x2 + x3 + 1) / (1.0 - f * 1.0 / n);
            }
        }
    }
    cout.precision(9);
    cout << fixed << ans[b[3]][b[2]][b[1]];
}


Measured memory_bytes: 111180
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define all(x) x.begin(), x.end()
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

bool prime[1000001];

int main() {
    Int x;
    cin >> x;
    for (Int i = 0; i <= 1000000; i++) {
        prime[i] = true;
    }
    prime[0] = prime[1] = false;
    for (Int i = 2; i * i <= 1000000 - 1; i++) {
        if (prime[i]) {
            for (Int j = 2; i * j <= 1000000 - 1; j++) {
                prime[i * j] = false;
            }
        }
    }
    while (not prime[x]) {
        x++;
    }
    dump(x);
    return 0;
}

Measured memory_bytes: 1280
def gcd2(a,b):
    x, y = max(a, b), min(a, b)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            x, y = y, x % y
        return y


K = int(input())
s = [gcd2(a, b) for a in range(1, K+1) for b in range(a+1, K+1)]
t = [2 * gcd2(a, b) for a in range(1, K+1) for b in s]
n = [gcd2(a, b) for a in range(1, K+1) for b in range(1, K+1)]
print(sum(t)+sum(n))


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

template<typename T, int mod = MOD>
int CommomSubsequencesCount(const vector<T>& s, const vector<T>& t) {
	int n1 = s.size();
	int n2 = t.size();
	VVL dp(n1 + 1, VL(n2 + 1, 0));

	for (int i = 1; i <= n1; i++) {
		for (int j = 1; j <= n2; j++) {
			if (s[i - 1] == t[j - 1])
				dp[i][j] = 1 + dp[i][j - 1] + dp[i - 1][j];
			else
				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] + mod -
					dp[i - 1][j - 1]) % mod;
			dp[i][j] %= mod;
		}
	}
	dp[n1][n2] += 1;
	dp[n1][n2] %= mod;
	return dp[n1][n2];
}

void solve_abc130_E() {
	int N, M; cin >> N >> M;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	vector<int> b(M);
	for (int i = 0; i < M; ++i) {
		cin >> b[i];
	}
	cout << CommomSubsequencesCount(a, b) << endl;
}

int main() {
	solve_abc130_E();
}


Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll n;
void go(int i){
  string s = "? ";
  for(int j=0;j<n;j++) {
    s += to_string(i+j);
    if(j!=n-1) s += " ";
  }
  std::cout << s << "\n" << std::flush;
}

string make(int i){
  string s = "? ";
  for(int j=0;j<n-1;j++) s += to_string(i+j) + (j!=n-1?" ":"");
  return s;
}

int main(int argc, char const *argv[]) {
  std::cin >> n;
  string t;
  ll L = 1, R = n+1;
  go(1);
  string FIRST;
  std::cin >> FIRST;

  while(R-L>1){
    ll mid = (L+R)/2;
    go(mid);
    string s = "? ";
    std::cin >> t;
    if(t==FIRST) L = mid;
    else R = mid;
  }
  string x = make(R);

  vll ans(2*n+1, 0);
  vll r, b;

  for(int i=1;i<R;i++){
    string y = x + to_string(i);
    std::cout << y << "\n" << std::flush;
    std::cin >> t;
    if(t=="Red") r.push_back(i), ans[i] = 1;
    else b.push_back(i), ans[i] = 0;
  }
  for(int i=R+n-1;i<=2*n;i++){
    string y = x + to_string(i);
    std::cout << y << "\n" << std::flush;
    std::cin >> t;
    if(t=="Red") r.push_back(i), ans[i] = 1;
    else b.push_back(i), ans[i] = 0;
  }

  string z = "? ";
  for(int i=0;i<n/2;i++) z += to_string(r[i]) + " ";
  for(int i=0;i<n/2;i++) z += to_string(b[i]) + " ";

  // mid
  for(int i=R;i<R+n-1;i++){
    string tmp = z + to_string(i);
    std::cout << tmp << "\n" << std::flush;
    std::cin >> t;
    if(t=="Red") ans[i] = 1;
  }
  string ret = "! ";
  for(int i=1;i<=2*n;i++) ret += (ans[i]?"R":"B");
  std::cout << ret << "\n" << std::flush;
  return 0;
}


Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
    // fastio
    int n,k,c;cin>>n>>k>>c;
    string s;   cin>>s;
    s='$'+s+'#';
    int prefix[n+2]={0},suffix[n+2]={0},lastIndex[n+2]={0};
    lastIndex[0]=-3e5;
    for(int i=1;i<=n;i++){
        prefix[i]=prefix[i-1];lastIndex[i]=lastIndex[i-1];
        if(s[i]=='o'){
            if(i-c>=1){
                if(prefix[i-c-1]+1>prefix[i]){
                   prefix[i]=max(prefix[i],prefix[i-c-1]+1);
                   lastIndex[i]=i; 
                }
            }else{
                if(1>prefix[i]){
                    lastIndex[i]=i; 
                    prefix[i]=max(prefix[i],1);
                }
            }      
        }
    }
    for(int i=n;i>=1;i--){
        suffix[i]=suffix[i+1];
        if(s[i]=='o'){
            if(i+c+1<=n)    suffix[i]=max(suffix[i],suffix[i+c+1]+1);
            else            suffix[i]=max(suffix[i],1);
        }
    }
    // for(int i=1;i<=n;i++)   cout<<suffix[i]<<" ";cout<<"\n";
    // for(int i=1;i<=n;i++)   cout<<prefix[i]<<" ";cout<<"\n";
    int flag[n+2]={0};
    for(int i=1;i<=n;i++){
        if(s[i]=='o'){
            flag[i]=1;i+=c;
        }
    }
    for(int i=1;i<=n;i++){
        int index=min(n+1,max(lastIndex[i-1]+c+1,i+1));
        // cout<<i<<" "<<lastIndex[i]<<" "<<index<<"\n";
        // cout<<prefix[i-1]<<" "<<suffix[index]<<"\n";
        if(flag[i] && (prefix[i-1]+suffix[index]<k)){
            // cout<<i<<" "<<lastIndex[i]<<" "<<index<<"\n";
            cout<<i<<"\n";
        }
    }
    return 0;
}



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

int main() {
  int n;

  cin >> n;

  vector<long> h(n);

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

  for (int i = n - 1; i > 0; i--) {
    if (h[i - 1] > h[i]) h[i - 1]--;
  }

  for (int i = 0; i < n - 1; i++) {
    if (h[i] > h[i + 1]) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";

  return 0;
}

Measured memory_bytes: 1024
import sys

class Node:
    def __init__(self):
        self.id = -1
        self.parent = -1
        self.type = "leaf"

    def printInfo(self):
        print "node {0.id}: parent = {0.parent}, depth = {0.depth}, {0.type}, {0.children}".format(self)

def setTree(id, tree, depth):
    tree[id].depth = depth
    if not tree[id].children:
        return

    for child in tree[id].children:
        tree[child].parent = id
        setTree(child, tree, depth + 1)
    tree[id].type = "internal node"

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    N = int(lines[0])
    del lines[0]

    tree = []
    for i in range(N):
        tree.append(Node())

    root = N * (N - 1) / 2
    for line in lines:
        info = map(int, line.split())
        tree[info[0]].children = info[2:]
        tree[info[0]].id = info[0]
        for i in tree[info[0]].children:
            root -= i

    setTree(root, tree, 0)
    tree[root].type = "root"

    for node in tree:
        node.printInfo()

Measured memory_bytes: 67740
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for(int i = (s); i < (e); i++)
#define FOE(i, s, e) for(int i = (s); i <= (e); i++)
#define FOD(i, s, e) for(int i = (s); i >= (e); i--)
#define ll long long

char s[1000010];
int n, del[1000010];

/* FUCK, I think dreamer as dreamr */

int check(int x, int y)
{
	if (s[x] == 'e' && s[x + 1] == 'r' && s[x + 2] == 'a' && s[x + 3] == 's' && s[x + 4] == 'e' && s[x + 5] == 'r')
	{
		if (y == 1) return 1;
	}
	if (s[x] == 'e' && s[x + 1] == 'r' && s[x + 2] == 'a' && s[x + 3] == 's' && s[x + 4] == 'e')
	{
		if (y == 0) return 1;
	}
	if (s[x] == 'd' && s[x + 1] == 'r' && s[x + 2] == 'e' && s[x + 3] == 'a' && s[x + 4] == 'm' && s[x + 5] == 'e' && s[x + 6] == 'r')
	{
		if (y == 3)	return 1;
	}
	if (s[x] == 'd' && s[x + 1] == 'r' && s[x + 2] == 'e' && s[x + 3] == 'a' && s[x + 4] == 'm')
	{
		if (y == 2) return 1;
	}
	return 0;
}

int dp[100005];

int main ()
{
	scanf("%s", s);
	n = strlen(s);
	
	dp[0] = 1;
	FOE(i, 1, n)
	{
		if (i >= 5 && check(i - 5, 0)) dp[i] = dp[i - 5];
		if (i >= 5 && check(i - 5, 2)) dp[i] = dp[i - 5];
		if (i >= 6 && check(i - 6, 1)) dp[i] = max(dp[i], dp[i - 6]);
		if (i >= 7 && check(i - 7, 3)) dp[i] = max(dp[i], dp[i - 7]);
	}
	
	int ok = dp[n];
	if (ok == 1) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}

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

using namespace std;
#define N 2005

int main()
{
    ios::sync_with_stdio(0);
    int a,b,c,d;
    string str;
    cin>>str;
    a=str[0]-'0';
    b=str[1]-'0';
    c=str[2]-'0';
    d=str[3]-'0';
    int flag=-1;
    for(int i=0;i<2;++i){
        int b1=b;
        if(i) b1*=-1;
        for(int j=0;j<2;++j){
            int c1=c;
            if(j)
                c1*=-1;
            for(int k=0;k<2;++k){
                int d1=d;
                if(k)d1*=-1;
                if(a+b1+c1+d1==7){
                    printf("%d",a);
                    printf("%c",i==1?'-':'+');
                    printf("%d",b);
                    printf("%c",j==1?'-':'+');
                    printf("%d",c);
                    printf("%c",k==1?'-':'+');
                    printf("%d=7",d);
                    return 0;
                }
            }
        }
    }
    return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a;
  cout << a+a*a+a*a*a;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#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(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    double H, W, N;
    cin >> H >> W >> N;
    double D = max(H, W);
    cout << ceil(N / D) << endl;
}

Measured memory_bytes: 256
x, y = map(int, input().split())

if x <= y:
    if x >= 0 or y <= 0:
        print(abs(abs(x)-abs(y)))
    else:
        print(abs(abs(x)-abs(y)) + 1)
elif x > y:
    if x < 0 or y > 0:
        print(abs(abs(x)-abs(y)) + 2)
    else:
        print(abs(abs(x)-abs(y)) + 1)

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

int main() {
    int K;
    string S;
    cin>>K>>S;
    if(S.size()<=K){
        cout<<S<<endl;
    }
    else{
        rep(i,K){
            cout<<S.at(i);
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3628
/*
以下の解説ブログがすごく納得できる.
https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2020-05-03abc-166
*/
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll A, B, C;
    cin >> N >> A >> B >> C;
    vector<string> S(N);
    for (auto& s : S) {
        cin >> s;
    }
    vector<ll> cnt = {A, B, C};
    string abc = "ABC";
    vector<char> ans;
    rep(i, 0, N) {
        vector<int> idx(2);
        rep(j, 0, 2) {
            idx[j] = find(all(abc), S[i][j]) - abc.begin();
        }
        if (!cnt[idx[0]] && !cnt[idx[1]]) {
            cout << "No" << endl;
            return 0;
        }
        if (A + B + C == 2 && cnt[idx[0]] == cnt[idx[1]] && i < N - 1 && S[i] != S[i + 1]) {
            vector<int> next_idx(2);
            rep(j, 0, 2) {
                next_idx[j] = find(all(abc), S[i + 1][j]) - abc.begin();
            }
            rep(j, 0, 2) {
                if (find(all(next_idx), idx[j]) != next_idx.end()) {
                    ans.push_back(abc[idx[j]]);
                    ++cnt[idx[j]];
                    --cnt[idx[j ^ 1]];
                    break;
                }
            }
        } else {
            int selected = 0;
            if (cnt[idx[0]] > cnt[idx[1]]) {
                selected = 1;
            }
            ans.push_back(abc[idx[selected]]);
            ++cnt[idx[selected]];
            --cnt[idx[selected ^ 1]];
        }
    }
    cout << "Yes" << endl;
    for (auto& c : ans) {
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 6660
// Gear4        
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
using ld = long double;
using ll = long long;
#define endl '\n'
const int inf = 1e9, mod = 1e9 + 7;
const ll INF = 9e18;
const ld EPS = 1e-9, PI = acosl(-1.0);
int a[3], b[3], ans=inf;
int solve(int x) {
    int poss = 0;
    FOR0(i, 3) if((a[i]%2) == (x%2)) poss++;
    return (poss%2==1) ? (3*x - a[0] - a[1] - a[2]) / 2: inf;
}
int main() {
    SYNC
    
    FOR0(i, 3) cin >> a[i];
    sort(a, a + 3);
    for(int x = a[2]; x <= a[2] + 5; x++) {
        ans = min(ans, solve(x));
    }
    cout << ans;
}

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

using namespace std;

int n, arr[50], a;
long long memo[50][2501][51];

long long solve(int i, int sum, int taken) {
    if (i == n)
        return (taken && sum / taken == a && sum % taken == 0);

    long long &r = memo[i][sum][taken];

    if (r == -1)
        r = solve(i + 1, sum + arr[i], taken + 1) + solve(i + 1, sum, taken);

    return r;
}

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

    memset(memo, -1, sizeof memo);

    cin >> n >> a;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    cout << solve(0, 0, 0) << '\n';

    return 0;
}

Measured memory_bytes: 50048
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

// char al(char zz,int n){
//
// }

int main(){
  int n; cin>>n;
  string s; cin>>s;
  rep(i,s.size()){
    // cout<<s[i]+n-'0'<<endl;
    if(s[i]+n-'0'>42){
      s[i]=s[i]+n-26;
      // cout<<"iku"<<endl;
    }else{
      s[i]=s[i]+n;
    }
  }
  cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define numOfOnes(n) __builtin_popcount(n)
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//</DEFINE>
int h, w;
vector<vector<char>>v;
//<FUNCTIONS>
bool valid(int i, int j) {
	return i >= 0 && i < h && j >= 0 && j < w;
}
int res[1000][1000];
ll solve(int i=0,int j=0) {
	if (!valid(i, j) || v[i][j]=='#')return 0;
	if (i == h - 1 && j == w - 1)return 1;
	if (~res[i][j])return res[i][j];
	return res[i][j] = ((solve(i + 1, j) % mod) + (solve(i, j + 1) % mod)) % mod;
}
//</FUNCTIONS>		
int main() {
	Fast();
	cin >> h >> w;
	v.resize(h, vector<char>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)cin >> v[i][j];
	}
	memset(res, -1, sizeof(res));
	cout << solve() << endl;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
bool prime[(int)1e6 + 7];
vector<int> primes;

int main() {
	int x;
	cin >> x;
	if (x < 2) {
		cout << 2;
		return 0;
	}
	for (ll i = 2; i <= 1e6; i++) {
		if (prime[i])
			continue;

		primes.push_back(i);
		for (ll j = i * i; j <= 1e6; j += i) {
			prime[j] = 1;
		}
	}

	cout << *lower_bound(primes.begin(), primes.end(), x);

}

Measured memory_bytes: 1916
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e9;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
vector<pairs> p;


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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}
// ------------------------------------

int main(){
    ll n, h, w;
    cin>>n>>h>>w;
    ll ans = 0;
    ll a[n], b[n];
    for(ll i=0;i<n;++i){
        cin>>a[i]>>b[i];
        if(b[i] >= w and a[i] >= h){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 2e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 9;
const ll inf = 1e18;

ll dp[N], weight[109];
int val[109];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i)
    cin >> weight[i] >> val[i];
  memset(dp, '?', sizeof dp);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    dp[0] = 0;
//    dp[i][val[i]] = min(dp[i][val[i]], weight[i]);
    if(dp[val[i]] <= k)
      ans = max(ans, val[i]);
    for (int j = N; j >= 0; --j) {
      if(j + val[i] >= N) continue;
      dp[j + val[i]] = min(dp[j + val[i]], dp[j] + weight[i]);
      if(dp[j + val[i]] <= k)
        ans = max(ans, j + val[i]);
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1792
while True:
	try:
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
	except: break
	
	hit = blow = 0
	for i in range(4):
		if a[i] == b[i]:
			hit += 1
			b[i] = -1
	for i in range(4):
		if b[i] >= 0:
			if b[i] in a:
			    blow += 1
	print(hit, blow)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX=200005;
ll par[MAX],val[MAX],num[MAX],n;
struct seq{
    ll c0,c,idx;
    ll m;
    bool operator<(const seq &a)const{
        return c*a.c0<c0*a.c;
    }
};
priority_queue<seq> temp;
deque<seq> block[MAX];
vector<ll> conn[MAX];
void reviser(ll x);
void builder(ll x){
    for(ll i=0;i<conn[x].size();i++) builder(conn[x][i]);
    for(ll i=0;i<conn[x].size();i++){
        seq t=block[conn[x][i]].front();
        block[conn[x][i]].pop_front();
        temp.push(t);
    }
    while(!temp.empty()){
        seq t=temp.top();
        temp.pop();
        if(!block[conn[x][num[t.idx]]].empty()){
            seq tt=block[conn[x][num[t.idx]]].front();
            block[conn[x][num[t.idx]]].pop_front();
            temp.push(tt);
        }
        t.idx=x;
        block[x].push_back(t);
    }
    reviser(x);
}
void reviser(ll x){
    deque<seq> tmp;
    seq t={val[x],1,x,0};
    while(!block[x].empty()){
        seq t1=block[x].front();
        block[x].pop_front();
        if(!(t1<t)) t={t.c0+t1.c0,t.c+t1.c,x,t.c0*(t1.c-t1.c0)+t.m+t1.m};
        else tmp.push_back(t),t=t1;
    }
    tmp.push_back(t);
    while(!tmp.empty()){
        seq t1=tmp.front();
        tmp.pop_front();
        block[x].push_back(t1);
        //printf("%d %d %d %d\n",t1.c0,t1.c,t1.idx,t1.m);
    }
}
ll counter(ll x){
    seq t=block[x].front();
    block[x].pop_front();
    while(!block[x].empty()){
        seq t1=block[x].front();
        block[x].pop_front();
        t={t.c0+t1.c0,t.c+t1.c,x,t.c0*(t1.c-t1.c0)+t.m+t1.m};
    }
    return t.m;
}
int main(){
    scanf("%lld",&n);
    for(ll i=2;i<=n;i++) scanf("%lld",&par[i]),num[i]=conn[par[i]].size(),conn[par[i]].push_back(i);
    for(ll i=1;i<=n;i++) scanf("%lld",&val[i]);
    builder(1);
    printf("%lld\n",counter(1));
}


Measured memory_bytes: 178432
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+7;
const int N=1E5+7;
int l[N],r[N];
int arr[N];
struct stu{
	int a,b;
	bool friend operator <(const stu &x,const stu &y){
		return x.a>y.a;
	}
}s[N];
int main()
{
	int n;
	cin>>n;
	int lmax=0,rmin=INF,width=0;
	for(int i=1;i<=n;i++){
		cin>>l[i]>>r[i];
		if(l[i]>=lmax)	lmax=l[i];
		if(r[i]<=rmin)	rmin=r[i];
		width=max(width,r[i]-l[i]+1);
	}
	int sum=max(rmin-lmax+1,0)+width;
	for(int i=1;i<=n;i++){
		s[i].a=max(0,rmin-l[i]+1);
		s[i].b=max(0,r[i]-lmax+1);
	}
	sort(s+1,s+1+n);
	arr[n]=s[n].b;
	for(int i=n-1;i>=1;i--){
		arr[i]=min(arr[i+1],s[i].b);
	}
	int ans=0;
	for(int i=1;i<=n-1;i++){
		ans=max(ans,s[i].a+arr[i+1]);	
	}
	cout<<max(ans,sum)<<endl;
	return 0;
 } 

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int> A(n);
	for(int i = 0; i < n ;i++)
		cin >> A[i];
	int mini = A[0];
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(mini >= A[i])
			ans++;
		mini = min(mini, A[i]);
	}
	cout << ans << '\n';

}

Measured memory_bytes: 1024
def main():
    with open(0) as f:
        N = int(f.readline())
        train = [tuple(map(int, line.split())) for line in f.readlines()]
    
    ans = []
    for start in range(N-1):
        arrive = 0
        for station in range(start, N-1):
            c, s, f = train[station]
            #出発時間:区間[arrive,)の下限     
            departure = lambda arrive:(arrive+f-1)//f*f if arrive >= s else s
            arrive = departure(arrive) + c
        ans.append(arrive)
    ans.append(0)
    for x in ans: print(x)

main()


Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    ll T1, T2; cin >> T1 >> T2;
    vector<ll> A(3, 0), B(3, 0);
    rep(i, 2) cin >> A[i+1];
    rep(i, 2) cin >> B[i+1];

    if(A[1]>B[1] && A[2]>B[2]) { cout << 0 << endl; return 0; }
    if(A[1]<B[1] && A[2]<B[2]) { cout << 0 << endl; return 0; }
    if(A[1]>B[1] && A[2]<B[2]) {
        ll O = (A[1]-B[1])*T1;
        ll E = (A[2]-B[2])*T2;
        if(O+E == 0) { cout << "infinity\n"; return 0; }
        if(O+E > 0)  { cout << 0 << endl; return 0; }

        ll K = O / (-(O+E)) + 1;
        if(O % (-(O+E)) == 0) cout << 2*K - 2 << endl;
        else cout << 2*K-1 << endl;

        return 0;
    }
    if(A[1]<B[1] && A[2]>B[2]) {
        ll O = (A[1]-B[1])*T1; // < 0
        ll E = (A[2]-B[2])*T2; // > 0
        if(O+E == 0) { cout << "infinity\n"; return 0; }
        if(O+E < 0)  { cout << 0 << endl; return 0; }

        ll K = (-O) / (O+E) + 1;
        if((-O) % (O+E) == 0) cout << 2*K - 2 << endl;
        else cout << 2*K - 1 << endl;
        
        return 0;
    }

    
    return 0;
}

Measured memory_bytes: 256
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); i++)
#define rep1(i,n) for(int (i) = 1; (i) <= (int)(n); i++)
#define INF 1000000
#define MOD 998244353



int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    int sum=0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    sort(all(A),greater<>());
    if (A[M-1] * 4 * M >= sum) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    
    return 0;
}



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

public class S
{

    private const long DP_INIT_MINUS1 = -1;
    private const double DP_INIT_DOUBLE_MINUS1 = -1.0;
	private const long MOD = 1000000007;


    //s
    private const int FIRST_WIN = 1;
    private const int SECOND_WIN = 0;

    private static long[,] dp;
    private static long[] cSum;


    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        */

        var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var M = input[0];
        var D = input[1];

        solver(M,D);
    }

    public static void solver(int M, int D){

        var count = 0;

        for(int i = 1; i <= M; i++){
            for(int k = 2; k <= (D/10); k++){
                for(int j = 2; j <= 9; j++){
                    if(k * 10 + j > D) break;
                    if(k * j == i){
                        count++;
                    }
                }
            }
        }

        Console.WriteLine(count);



    }

}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> A(N), B(N), C(M), D(M), Distant(M);
  
  for(int i=0; i<N; i++) {
    cin >> A[i] >> B[i];
  }
  for(int i=0; i<M; i++) {
    cin >> C[i] >> D[i];
  }
  for(int i=0; i<N; i++) {
    int x=1;
    int MD=abs(A[i]-C[0])+abs(B[i]-D[0]);
    for(int j=1; j<M; j++) {
      Distant[j] = abs(A[i]-C[j])+abs(B[i]-D[j]);
      if(Distant[j]<MD) {
      x=j+1;
      MD=Distant[j];
      }
    }
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sc(x) scanf("%d", &x)
#define pr(x) printf("%d\n", x)
#define lowbit(x) (x & -x)
#define ll long long
#define N 100010
#define memset(x) memset(x, 0, sizeof(x))
using namespace std;
int n;
char s[N];
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	sc(n);
	cin >> s + 1;
	int j = 1, ans = 0;
	while (j <= n)
	{
		ans++;
		while (s[j] == s[j + 1])
		{
			j++;
		}
		j++;
	}
	printf("%d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, A, B;
  cin >> N >> A >> B;
  
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  
  vector<ll> b(N-1);
  rep(i,N-1) b[i] = a[i+1] - a[i];
  
  ll p = 0;
  
  rep(i,N-1){
    p += min(A * b[i], B);
  }

  cout << p << endl;
  
  
}

Measured memory_bytes: 1792
#C
N = int(input())
A = list(map(int,input().split()))

SUM = 0
ans = 0
flag = 0 #0+,1-
for i in range(N):
    if i == 0:
        SUM = A[i]
        if SUM <= 0:
            ans+=1-SUM
            SUM = 1
    else:
        SUM += A[i]
        if flag == 0:
            if SUM >= 0:
                ans += SUM+1
                SUM = -1
            flag = 1
        else:
            if SUM <= 0:
                ans += 1-SUM
                SUM = 1
            flag = 0
    #print(ans,SUM)

MIN = ans
ans = 0
flag = 1 #0+,1-
for i in range(N):
    if i == 0:
        SUM = A[i]
        if SUM >= 0:
            ans+=1+SUM
            SUM = -1
    else:
        SUM += A[i]
        if flag == 0:
            if SUM >= 0:
                ans += SUM+1
                SUM = -1
            flag = 1
        else:
            if SUM <= 0:
                ans += 1-SUM
                SUM = 1
            flag = 0
    #print(ans,SUM)
                
ans = min(MIN,ans)
print(ans)

Measured memory_bytes: 14464
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  cin >> A >> B;
  if (B % A == 0) {
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }
  return 0;
}

Measured memory_bytes: 3532
import java.util.*;

public class Main{
  public static void main(String args[]){
    int[] suuti = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
    System.out.println(suuti[x-1]);
  }
}


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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    vector<LL> C(100100, 0);
    int N;
    cin >> N;
    LL sum = 0;
    while(N--) {
        int x;
        cin >> x;
        C[x]++;
        sum += x;
    }
    int Q;
    cin >> Q;
    while(Q--) {
        LL x, y;
        cin >> x >> y;
        sum += (y - x) * C[x];
        C[y] += C[x];
        C[x] = 0;
        cout << sum << "\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <iomanip>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

typedef double D;
typedef complex<D> P;
typedef pair<D,int> pdi;

D pi;
D smax, smin, tmax, tmin;
vector<P> ps;

D dot(const P &a, const P &b){
	return real(a) * real(b) + imag(a) * imag(b);
}

P check(D t){
	while(t < 0.0){ t += pi; }
	while(t >= pi){ t -= pi; }
	t += 0.0;
	
	int n = ps.size();
	P a = polar(D(1.0), 0.5 * pi - t);
	vector<pdi> v(2 * n);
	for(int i = 0; i < n; ++i){
		D z = dot(ps[i], a);
		v[2 * i] = pdi(z - 1.0, i);
		v[2 * i + 1] = pdi(z + 1.0, ~i);
	}
	sort(v.begin(), v.end());
	int cnt = 0;
	D sum = 0.0;
	P ret;
	for(int i = 0; i < 2 * n; ++i){
		if(cnt){ sum += v[i].first - v[i - 1].first; }
		if(v[i].second >= 0){
			if(!cnt++){ ret -= ps[v[i].second]; }
		}
		else{
			if(!--cnt){ ret += ps[~v[i].second]; }
		}
	}
	
	if(sum > smax){
		smax = sum;
		tmax = t;
	}
	if(sum < smin){
		smin = sum;
		tmin = t;
	}

	return ret;
}

int main(){
	pi = acos(D(-1.0));
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	while(cin >> n, n){
		smax = -1e300;
		smin = 1e300;
	
		ps.resize(n);
		for(int i = 0; i < n; ++i){
			int x, y;
			cin >> x >> y;
			ps[i] = P(x, y);
		}

		check(0);

		vector<D> cand;
		for(int i = 0; i < n; ++i)
		for(int j = 0; j < i; ++j){
			D a = -arg(ps[j] - ps[i]);
			D b = asin(2.0 / abs(ps[j] - ps[i]));
			cand.push_back(a);
			cand.push_back(a - b);
			cand.push_back(a + b);
		}
		for(size_t i = 0; i < cand.size(); ++i){
			while(cand[i] < 0.0){ cand[i] += pi; }
			while(cand[i] > pi){ cand[i] -= pi; }
			check(cand[i]);
		}
		sort(cand.begin(), cand.end());
		for(size_t i = 1; i < cand.size(); ++i){
			P ret = check(0.5 * (cand[i - 1] + cand[i]));
			if(abs(ret) > 1e-12){
				check(0.5 * pi - arg(ret));
			}
		}
		cout << tmin << '\n' << tmax << '\n';
	}
}

Measured memory_bytes: 1548
//
//  main.cpp
//  SUBCRIBER
//
//  Created by Jay Scott on 1/27/19.
//  Copyright © 2019 hoangtheanh. All rights reserved.
//

#include <iostream>
using namespace std;
int n, a, b;
int main()
{
    cin >> n >> a >> b;
    cout << min(a, b) << " " << ((a + b - n > 0) ? a+b-n : 0);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int cost[101][101];
int d[101];
bool used[101];
int n, m;
bool usedp[101][101];
int prv[101];

void get_path(int t){
  if(prv[t] == -1){
    usedp[t][prv[t]] = true;
  }
  while(prv[t] != -1){
    usedp[t][prv[t]] = true;
    t = prv[t];
  }
}

void dijkstra(int s){
  fill(d, d+n, INF);
  fill(used , used + n, false);
  fill(prv, prv + n, -1);
  d[s] = 0;

  while(true){
    int v = -1;
    rep(u, n) if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    if(v == -1) break;
    used[v] = true;
    rep(u, n){
      if(d[u] > d[v] + cost[v][u]){
        d[u] = d[v] + cost[v][u];
        prv[u] = v;
      }
    }
  }
  rep(i, n) get_path(i);
}

int main(){
  cin >> n >> m;
  int inp1, inp2, inp3;
  rep(i, n)rep(j,n) cost[i][j] = INF;
  rep(i, m){
    cin >> inp1 >> inp2 >> inp3;
    cost[inp1-1][inp2-1] = inp3;
    cost[inp2-1][inp1-1] = inp3;
  }
  rep(i,n)rep(j,n) usedp[i][j] = false;
  rep(i, n) dijkstra(i);

  int ans = 0;
  rep(i,n)rep(j,n) if(usedp[i][j] == false && cost[i][j] != INF) ans++;
  cout << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
int gcd(int a,int b){
  if(b>a) swap(a,b);
  if(b == 0) return a;
  return gcd(b,a%b);
}

int N;
int A[200000];

int main(){
  cin >> N;
  REP(i,N) cin >> A[i];
  int k;
  k = gcd(A[0],A[1]);
  REP(i,N){
    k = gcd(k,A[i]);
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>

constexpr int MAX_N = 200000;
int a[MAX_N + 1];
int b[MAX_N + 1];

int main() {
  int N;
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i + 1];
  }
  int total_balls = 0;
  for (int i = N; i >= 1; --i) {
    int num_balls = 0;
    for (int j = i + i; j <= N; j += i) {
      num_balls += b[j];
    }
    if (num_balls % 2 == a[i]) {
      b[i] = 0;
    } else {
      b[i] = 1;
      ++total_balls;
    }
  }
  std::cout << total_balls << std::endl;
  if (total_balls > 0) {
    for (int i = 1; i <= N; ++i) {
      if (b[i] == 1) {
        std::cout << i;
        --total_balls;
        if (total_balls > 0) {
          std::cout << ' ';
        }
      }
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  int i, j, N;
  j = 0;
  scanf("%d", &N);
    int count = N;
  int t[N], x[N], y[N];
  t[0]=x[0]=y[0]=0;
  for(i = 1; i <= N; i++){
    scanf("%d", &t[i]);
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
  }
  for(i = 1; i <= N; i++){
    int T = abs(t[i] - t[i - 1]);
    int xt = abs(x[i] - x[i - 1]);
    int yt = abs(y[i] - y[i - 1]);
    if((T >= (xt + yt)) && ((T - xt - yt) % 2 == 0))
      j++;
  }
  dump(j); dump(count);
  if(count == j)
    printf("Yes");
  else
    printf("No");

    return 0;
}


Measured memory_bytes: 1408
exp_list = []
for i in range(2,32):
	j = i
	while True:
		j = j * i
		if j > 1000:
			break
		exp_list.append(j)
exp_list = sorted(set(exp_list+[1]))

n = int(input())
for i in range(n,0,-1):
	if i in exp_list:
		print(i)
		break

Measured memory_bytes: 38256