akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,x[10],y[10],a[10];
long double ans,ans1;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>x[i]>>y[i];
	for(int i=1;i<=n;i++)
	a[i-1]=i-1;
	do{
		ans1=0;
		for(int i=0;i<n-1;i++){
			long double res=10; 
			res*=(long double)(sqrt(((x[a[i]])-(x[a[i+1]]))*((x[a[i]])-(x[a[i+1]]))+((y[a[i]])-(y[a[i+1]]))*((y[a[i]])-(y[a[i+1]]))));
			ans1+=res;
		}
		ans+=ans1;
	}while(next_permutation(a,a+n));
	
		
	int res=n;
	for(int i=n-1;i>1;i--)
	res*=i;
	ans/=(long double)(res);
	cout<<setprecision(10)<<ans/10;
	re 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  double N;
  cin>>N;
  vector <double> a(N);
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  double ans = 0;
  sort(a.begin(),a.end());
  for(int i = 1;i<N;i++){
    ans += a[i]/pow(2.0,(N-i));
  }
  cout << ans+(a[0]/pow(2.0,(N-1))) << endl;
  return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int k;
  string s;
  cin >> k >> s;
  cout << ( (s.length() <= k) ? s : s.substr(0,k) + "...") <<"\n";
return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int l = -1, r = -1;
	rep(i,s.size()){
		if(l == -1 && s.at(i) == 'A') l = i;
		if(s.at(i) == 'Z') r = i;
	}
	cout << r - l + 1 << endl;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, a, b;
  cin >> n >> a >> b;
  ll m = n / (a+b);
  ll ans = a*m;
  if((a+b)*m + a <= n) ans += a;
  else ans += n-(a+b)*m;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
k = 0
cur = 0
while k < K:
    if cur == 0:
        if A % 2 == 0:
            B += A // 2
            A -= A // 2
        else:
            A -= 1
            B += A // 2
            A -= A // 2

        cur ^= 1
    else:
        if B % 2 == 0:
            A += B // 2
            B -= B // 2
        else:
            B -= 1
            A += B // 2
            B -= B // 2
        cur ^= 1
    k += 1

print(A, B)

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

int main() {
    vector<int> abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];
    sort(abc.begin(), abc.end(), greater<int>());

    cout << abc[0]*10+abc[1]+abc[2] << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main() {
    ll N, K, L, p, q;
    cin >> N >> K >> L;
    vector<ll> res(N, 1);
    UnionFind Road(N), Rail(N);
    FOR(i,0,K-1) {
        cin >> p >> q; --p; --q;
        Road.merge(p, q);
    }

    FOR(i,0,L-1) {
        cin >> p >> q; --p; --q;
        Rail.merge(p, q);
    }

    // 道路でも電車でも連結してる
    // 根が同じ
    map<pair<ll,ll>, ll> mp;
    FOR(i,0,N-1) mp[{Road.root(i), Rail.root(i)}]++;
    FOR(i,0,N-1) cout << mp[{Road.root(i), Rail.root(i)}] << " ";
    cout << endl;

    return 0;
}



Measured memory_bytes: 19584
i = int(input())

l = [i]
count = 0
f = True
while f:
  if l[-1] % 2 == 0:
    x = l[-1] / 2
  else:
    x = 3 * l[-1] + 1
  
  for y in l:
    if y == x:
      f = False
  l.append(x)

print len(l)
      

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define NMAX (int)(1e5+4)
#define pb push_back
#define ft first
#define sd second
using namespace std;
typedef pair <int, int> pairINT;
typedef long long ll;

int n,m;
bool used[NMAX],odd[NMAX];
vector <int> g[NMAX];
vector <pairINT> sol;

void dfs(int);

int main(){
    int x,y;
    cin>>n>>m;
    for(int i=0;i<m;++i){
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    if(m&1){
        cout<<-1;
        return 0;
    }
    dfs(1);
    for(auto it:sol)
        cout<<it.ft<<' '<<it.sd<<'\n';
    return 0;
}
void dfs(int node){
    vector <int> adj;
    used[node]=1;
    for(auto it:g[node])
        if(used[it])
            adj.push_back(it);
    for(auto it:g[node])
        if(!used[it])
            dfs(it);

    if(odd[node]){
        sol.pb({node, adj.back()});
        adj.pop_back();
    }
    for(auto it:adj)
        odd[it]^=1,
        sol.pb({it, node});
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  std::cin >> a;

  std::vector<bool> flag(n, false);
  int64_t num = 0;

  for (int64_t i = n - 1; 0 <= i; i--) {
    const auto j = i + 1;
    int64_t k = 2;
    int64_t t = 0;
    while (j * k <= n) {
      if (flag[j * k - 1]) {
        t++;
      }
      k++;
    }
    t %= 2;
    if (t != a[i]) {
      flag[i] = true;
      num++;
    }
  }

  std::cout << num << std::endl;
  if (num != 0) {
    int64_t p = 0;
    for (int64_t i = 0; i < n; i++) {
      if (flag[i]) {
        std::cout << i + 1;
        p++;
        if (num != p) {
          std::cout << " ";
        }
      }
    }
    std::cout << std::endl;
  }
}


Measured memory_bytes: 2560
/* When Talent doesn't work, Hard work beats Talent*/

#include"bits/stdc++.h"

using namespace std;

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define FIX_IT cout<<fixed<<setprecision(20);
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;

void solve()
{
	FIX_IT;
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double ang=m*6;
	double s=(h+m/60.0)*30;
	ang=abs(s-ang);
	ang=ang*PI/180;
	double len= a*a + b*b - 2*a*b*cos(ang);
	len=sqrt(len);
	cout<<len<<nl;
	return ;
}

int32_t main()
{
	FastIO;
	solve();
	return 0;
}


Measured memory_bytes: 4124
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc=new Scanner(System.in);
        while(true){
           int H=sc.nextInt();
           int W=sc.nextInt();
           if(H==0){
               if(W==0)break;
           }else{
                for(int i=1;i<=H;i++){
                    for(int j=1;j<=W;j++){
                        System.out.print("#");
                    }
                    System.out.println();
                }
           }
          System.out.println();
        }
           
    }
}


Measured memory_bytes: 34868
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,l;
    cin>>n>>l;
    vi a(n);
    rep(i,n)cin>>a[i];
    bool ng=true;
    int last;
    rep(i,n-1){
        if(a[i]+a[i+1]>=l){
            ng=false;
            last=i;
            break;
        }
    }
    if(ng){
        cout<<"Impossible"<<endl;
        return;
    }
    cout<<"Possible"<<endl;
    vi ans;
    ans.pb(last+1);
    rev(i,last)ans.pb(i+1);
    Rep(i,last+1,n-1)ans.pb(i+1);
    reverse(all(ans));
    rep(i,n-1)cout<<ans[i]<<endl;
}

Measured memory_bytes: 2548
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(int i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  int n;
  cin >> n;

  vector<int> a(n);
  fillInt(a, n);

  int cnt = 0;

  int cl = -1;
  int clc = 0;

  rep(i, n) {
    if (cl == a[i]) clc++;
    else {
      cnt += clc/2;
      clc = 0;
      cl = a[i];
      clc++;
    }
  }

  cnt += clc/2;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,x;
	cin>>a>>b>>x;
	ll g = b/x-a/x;
	if(a%x==0)
		g++;
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();

    int count = 0;
    int max = 0;
    for (int i = 0; i < s.length(); i++) {
      char c = s.charAt(i);
      if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
        count++;
        max = Math.max(count, max);
      } else {
        count = 0;
      }
    }

    os.println(max);
  }
}

Measured memory_bytes: 23252
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            Console.WriteLine(Ans(JudgeMM(S.Substring(0, 2)), JudgeMM(S.Substring(2, 2))));
        }

        static bool JudgeMM(string str)
        {
            var n = int.Parse(str);
            return 1 <= n && n <= 12;
        }

        static string Ans(bool b1, bool b2)
        {
            if (b1)
            {
                if (b2) return "AMBIGUOUS";
                else return "MMYY";
            }
            else
            {
                if (b2) return "YYMM";
                else return "NA";
            }
        }
    }
}


Measured memory_bytes: 27344
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,x;
    cin>>n>>x;
    int mi,m_min;
    m_min=1e+6;
    for (int i=0;i<n;i++){
        cin>>mi;
        x-=mi;
        m_min = min(m_min,mi);
    }
    int ans = n+(x/m_min);
    cout<<ans;
    
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		if (c >= a && b >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	defer flush()

	H := readInt()
	W := readInt()
	Ch := readInt() - 1
	Cw := readInt() - 1
	Dh := readInt() - 1
	Dw := readInt() - 1
	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	t := make([][]int, H)
	for i := 0; i < H; i++ {
		t[i] = make([]int, W)
		for j := 0; j < W; j++ {
			if S[i][j] == '#' {
				t[i][j] = -1
			} else {
				t[i][j] = math.MaxInt64
			}
		}
	}

	a := 0
	t[Ch][Cw] = a
	q := make([][2]int, 0, 1024)
	q = append(q, [2]int{Ch, Cw})

	for len(q) != 0 {
		warpq := make([][2]int, 0, 1024)
		for len(q) != 0 {
			h, w := q[0][0], q[0][1]
			warpq = append(warpq, [2]int{h, w})
			q = q[1:]
			if h-1 >= 0 && t[h-1][w] > a {
				q = append(q, [2]int{h - 1, w})
				t[h-1][w] = t[h][w]
			}
			if h+1 < H && t[h+1][w] > a {
				q = append(q, [2]int{h + 1, w})
				t[h+1][w] = t[h][w]
			}
			if w-1 >= 0 && t[h][w-1] > a {
				q = append(q, [2]int{h, w - 1})
				t[h][w-1] = t[h][w]
			}
			if w+1 < W && t[h][w+1] > a {
				q = append(q, [2]int{h, w + 1})
				t[h][w+1] = t[h][w]
			}
		}

		if t[Dh][Dw] != math.MaxInt64 {
			break
		}

		a++
		for i := 0; i < len(warpq); i++ {
			h, w := warpq[i][0], warpq[i][1]
			for i := max(0, h-2); i <= min(H-1, h+2); i++ {
				for j := max(0, w-2); j <= min(W-1, w+2); j++ {
					if t[i][j] <= a {
						continue
					}
					t[i][j] = a
					q = append(q, [2]int{i, j})
				}
			}
		}
	}

	if t[Dh][Dw] == math.MaxInt64 {
		println(-1)
	} else {
		println(t[Dh][Dw])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 21316
#include <bits/stdc++.h>
using namespace std;
typedef struct node
{
	long long x,y;
	bool operator < (const struct node & n)const
	{
		return (y==n.y?x>n.x:y<n.y);
	}
}NODE,*PNODE;
NODE a[200001];
int main()
{
	int n,i;
	long long s=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].x,&a[i].y);
		s+=a[i].x;
	}
	sort(a+1,a+n+1);
	if(s>a[n].y)
	{
		printf("No");
		return 0;
	}
	s=0;
	for(i=1;i<=n;i++)
	{
		s+=a[i].x;
		if(s>a[i].y)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
    return 0;
}

Measured memory_bytes: 3328
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  9/23 20:08:29 2017
 * Ended  Time*  : 六  9/23 20:14:07 2017
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 1000;
int n, m, k;

int main()
{
	while(~scanf("%d %d %d", &n, &m, &k)){
		bool flag = false;
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= m; j++){
				int tot = i * m - (j * i) + (j * (n - i));
				if(tot == k) flag = true;
			}
		}
		for(int i = 0; i <= m; i++){
			for(int j = 0; j <= n; j++){
				int tot = i * n - (j * i) + (j * (m - i));
				if(tot == k) flag = true;
			}
		}
		if(flag) printf("Yes\n");
		else printf("No\n");
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    int pc = 0;
    rep(i, n) pc += (s[i] == '1');
    
    vector<int> v(n+1), u(n+1);
    ll a = 1, b = 1;
    rep(i, n){
        v[i] = a;
        a *= 2;
        a %= (pc+1);

        u[i] = b;
        b *= 2;
        b %= max(pc-1, 1);
    }

    ll x = 0, y = 0;
    rep(i, n){
        if(s[i] == '1') x += v[n-i-1], y += u[n-i-1];
    }

    rep(i, n){
        int ans = 1;
        int nex;
        if(s[i] == '0') nex = (x + v[n-i-1])%(pc+1);
        else if(pc-1 == 0) ans = 0, nex = 0;
        else nex = (y - u[n-i-1])%(pc-1);

        while(nex > 0){
            ans++;
            nex %= __builtin_popcount(nex);
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    array<array<int64_t, 10>, 10> a{};
    int64_t d = 1;
    for (auto i : irange(1L, n + 1)) {
        if (i >= d * 10) {
            d *= 10;
        }

        auto s = i / d;
        auto e = i % 10;
        ++a[s][e];
    }

    int64_t ans = 0;
    for (auto i : irange(1L, 10L)) {
        for (auto j : irange(1L, 10L)) {
            ans += a[i][j] * a[j][i];
        }
    }

    cout << ans << endl;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

struct token{
  char c;
  int num;
  token(char c,int num):c(c),num(num){}
};

const char TOKEN_NUM = 'N';

vector<token> tokenize(string s){
  vector<token> tokenlist;
  int idx = 0;
  while (idx<s.size())
  {
    if('0'<=s[idx]&&s[idx]<='9'){
      int val = 0;
      while('0'<=s[idx]&&s[idx]<='9'){
        val *= 10;
        val += s[idx] - '0';
        idx++;
      }
      tokenlist.push_back(token(TOKEN_NUM, val));
    }
    else
    {
      tokenlist.push_back(token(s[idx], 0));
      idx++;
    }
  }
  return tokenlist;
}

void simplify(vector<token>& tokenlist,int idx){
  if(0==idx||idx==tokenlist.size()-1){
    return;
  }
  if(tokenlist[idx].c!=TOKEN_NUM){
    return;
  }
  while(tokenlist[idx-1].c=='('&&tokenlist[idx+1].c==')'){
    tokenlist.erase(tokenlist.begin() + idx + 1);
    tokenlist.erase(tokenlist.begin() + idx - 1);
    idx--;
  }
}

bool is_op(char c){
  return c == '+' || c == '-' || c == '*' || c == '/';
}

vector<token> f(vector<token> tokenlist,int num){
  int cnt = -1;
  int idx = 0;
  for (; idx < tokenlist.size();++idx)
  {
    if(is_op(tokenlist[idx].c)){
      cnt++;
    }
    if(cnt==num){
      break;
    }
  }

  if(cnt!=num){
    return {};
  }

  if(tokenlist[idx-1].c==TOKEN_NUM&&tokenlist[idx+1].c==TOKEN_NUM){
    int l = tokenlist[idx - 1].num;
    int r = tokenlist[idx + 1].num;
    int val;
    if (tokenlist[idx].c == '+')
    {
      val = l + r;
    }
    else if (tokenlist[idx].c == '-')
    {
      val = l - r;
    }
    else if (tokenlist[idx].c == '*')
    {
      val = l * r;
    }
    else if (tokenlist[idx].c == '/')
    {
      if(r==0){
        return {};
      }
      val = l / r;
    }
    tokenlist.erase(tokenlist.begin() + idx + 1);
    tokenlist.erase(tokenlist.begin() + idx);
    tokenlist[idx - 1].num = val;
    simplify(tokenlist, idx - 1);
    return tokenlist;
  }
  else
  {
    return {};
  }
}

set<int> st;

void calc(vector<token> tokenlist,int bound){
  REP(i,bound){
    auto list = f(tokenlist, i);
    if(list.size()==0){
      continue;
    }
    if(list.size()==3){
      st.insert(list[1].num);
      continue;
    }
    calc(list, bound - 1);
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while(true){
    string s;
    cin >> s;
    if(s[0]=='#'){
      break;
    }

    s = "$"+s+"#";

    vector<token> tokenlist = tokenize(s);
    
    REP(i, tokenlist.size())
    {
      simplify(tokenlist,i);
    }
    
    st = {};

    int bound = 0;
    
    

    REP(i,tokenlist.size()){
      if (is_op(tokenlist[i].c))
      {
        bound++;
      }
    }

    calc(tokenlist, bound);
    cout << st.size() << endl;
  }
}



Measured memory_bytes: 3268
N,*A = map(int, open(0).read().split())
p = 1
ans = 0
for c in A:
  if c%p!=0:
    ans += c//p
  else:
    if c==p:
      p += 1
      continue
    ans += c//p-1
    if p==1:
      p += 1
print(ans)

Measured memory_bytes: 14332
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int[] a = new int[N];
 
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
 
        int alice = 0;
        int bob = 0;
 
        Arrays.sort(a);
        int index = 0;
        for (int i = N - 1; i >= 0; i--) {
            if (index % 2 == 0)
                alice += a[i];
            else
                bob += a[i];
 
            index++;
        }
 
        System.out.println(alice - bob);
        sc.close();
    }
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

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

    int H,W,h,w;
    cin >> H >> W >> h >> w;

    cout << (H-h)*(W-w) << endl;

    return 0;
}


Measured memory_bytes: 256
#!ruby -ropenssl
eval"N,A,B,K="+`tr ' ' ,`;
M=998244353.to_bn;
*f=s=1;N.times{|i|f<<s=s*-~i%M};
p (0..N).map{|a|
b=(K-A*a)/B;0>b||b>N||A*a+B*b!=K ? 0:f[N]**2*(f[a]*f[b]*f[N-a]*f[N-b]%M).to_bn.mod_inverse(M).to_i
}.reduce(:+)%M


Measured memory_bytes: 32644
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);
	cinai(x, n);

	ll ans = 1e9;
	for (int i = 1; i <= 100; i++) {
		ll lans = 0;
		for (int j : x) {
			int diff = abs(i - j);
			lans += diff * diff;
		}
		ans = min(ans, lans);
	}
	cout << ans << endl;
}

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



Measured memory_bytes: 256
#include <stdio.h>

int mysqrt(int n) {
	int left,right;
	long long mid;
	if(n==0)return 0;
	if(n<0)return -1;
	left=1;right=n;
	while(left<=right) {
		mid=(left+right)/2;
		if(mid*mid==n)return mid;
		else if(mid*mid<n)left=mid+1;
		else right=mid-1;
	}
	return left-1;
}

int main(void) {
	int query;
	int max;
	int sum;
	int i;
	while(1) {
		scanf("%d",&query);
		if(query==0)break;
		sum=1;
		max=mysqrt(query);
		for(i=2;i<=max;i++) {
			if(query%i==0) {
				sum+=i+query/i;
			}
		}
		if(max*max==query)sum-=max;
		if(sum==query)puts("perfect number");
		else if(sum<query)puts("deficient number");
		else puts("abundant number");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <string.h>
#include <algorithm>

using namespace std;


int main(){
  int n,y,Y,x;
  cin >> n >> Y;
  int judge=0;
  for(x=0; x<n+1;x++){
    for(y=0; y<n+1;y++){
      if(10000*x + 5000*y + 1000*(n-x-y) == Y && n-x-y>=0){
        judge=1;
        break;
      }
      else if(n-x-y<0) break;
    }
    if(judge==1) break;
  }
  if(judge == 1){
    cout << x <<" "<<y <<" "<<n-x-y <<" "<< endl;
  }else{
    cout << "-1 -1 -1" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {
	
	int n, h[100001];
	bool ispossible = true;
	scanf("%d", &n);
	rep(i, n)scanf("%d", &h[i]);
	repr(i, n - 1) {
		if (h[i] == h[i + 1] + 1)--h[i];
		else if (h[i] > h[i + 1])ispossible = false;
	}
	printyn(ispossible);
	return 0;
}


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

int main(){
  char S[4], T[4];
  cin >> S >> T;
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(S[i] == T[i]){
      count++;
    }
  }
  cout << count << endl;
}

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

map<ll,ll> a;
set <ll> s;

void calc(ll b, ll c){
	if(b == 0) return;
	ll x = *s.lower_bound(1), sum = 0;
	if(x >= c) return;
	if(b <= a[x]) sum = b;
	else sum = a[x];
//	cerr << x << " " << a[x] << " " << c << " " << a[c] << " " << b << endl;
	a[x] -= b;
	a[c] += sum;
	s.insert(c);
	if(a[x] < 0) {
		a[x] = 0;
	}
	if(a[x] == 0) s.erase(x);
	b -= sum;
//	cerr << " " << x << " " << a[x] << " " << c << " " << a[c] << " " << b << endl;
	calc(b, c);
}

int main() {
	ll n,m;
	cin >> n >> m;
	vector<ll> b(m), c(m);
	for(int i = 0; i < n; i++){
		ll x;
		cin >> x;
		a[x]++;
		s.insert(x);
	}
	for(int i = 0; i < m; i++) cin >> b[i] >> c[i];
	for(int i = 0; i < m; i++){

		calc(b[i], c[i]);
	}
	ll sum = 0;
	for(pair<ll,ll> i : a){
//		cerr << i.first << " " << i.second << endl;
//		cerr << sum << endl;
		sum += i.first * i.second;
	}
	cout << sum << "\n";
	return 0;
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
#define int long long
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r, g, b;
    cin >> r;
    int arr[r];
    int a[10] = {0};
    int max1 = 0, min1 = 10001;
    for (int i = 0; i < r; i++)
    {
        cin >> arr[i];
        if (arr[i] < 400)
        {
            a[0]++;
        }
        if (arr[i] > 399 && arr[i] < 800)
        {
            a[1]++;
        }
        if (arr[i] > 799 && arr[i] < 1200)
        {
            a[2]++;
        }
        if (arr[i] > 1199 && arr[i] < 1600)
        {
            a[3]++;
        }
        if (arr[i] > 1599 && arr[i] < 2000)
        {
            a[4]++;
        }
        if (arr[i] > 1999 && arr[i] < 2400)
        {
            a[5]++;
        }
        if (arr[i] > 2399 && arr[i] < 2800)
        {
            a[6]++;
        }
        if (arr[i] > 2799 && arr[i] < 3200)
        {
            a[7]++;
        }
        if (arr[i] > 3199)
        {
            a[8]++;
        }
    }
    int count = 0;

    for (int i = 0; i < 8; i++)
    {
        if (a[i] != 0)
            count++;
    }
    if (count)
        cout << count << " ";
    else
    {
        if (a[8] == 0)
            cout << 0 << "\n";
        else
        {

            cout << 1 << " ";
        }
    }

    cout << count + a[8] << " ";

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
long long mod_pow(long long x,long long y){//x^yを返す//計算量は0(log(y))
  long long tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
    string L;
    cin>>L;
    long long ans=0,a=L.size(),count=0;
    for(int i=0;i<a;i++){
        if(i==0){
            ans=mod_pow(3,a-i-1);
            count++;
        }
        else if(L.at(i)=='1'){
            ans+=mod_pow(2,count)*mod_pow(3,a-i-1);
            ans%=MOD;
            count++;
        }
    }
    ans+=mod_pow(2,count);
    cout<<ans%MOD<<endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    int n, m; 
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i]; 
    }
    int ans = INT_MAX;
    for (int i = 0; i + m - 1 < n; ++i) {
        ans = min(ans, a[i + m - 1] - a[i] + min(abs(a[i]), abs(a[i + m - 1]))); 
    }
    cout << ans << endl; 
    return 0; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

ll c[50];
ll tmp[60];

int main()
{
  ll n, k;
  scanf("%ld", &n);
  scanf("%ld", &k);
  vector<ll> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%ld", &a[i]);
  sort(a.begin(), a.end());
  ll sum = 0;
  int p = 0;
  tmp[0] = 1;
  for (ll i = 1; i < 60; ++i)
  {
    tmp[i] = 2 * tmp[i - 1];
  }
  while (true)
  {
    if (k / tmp[p])
    {
      p++;
    }
    else
      break;
  }
  p--;

  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j <= p; ++j)
    {
      if (a[i] & tmp[j])
      {
        c[j]++;
      }
    }
  }
  ll key = 0;
  for (int i = p; i >= 0; --i)
  {
    if (key > k)
    {
      key -= tmp[i + 1];
    }
    if (2 * c[i] < n)
    {
      key += tmp[i];
    }
  }
  if (key > k)
    key -= tmp[0];
  ll ans = 0;
  for (int i = 0; i < n; ++i)
  {
    ans += a[i] ^ key;
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 1024
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;
const int maxn=2e6+5;

struct edges{
	int to,nxt;
}ed[maxn<<1];
int head[maxn],ecnt=0;
int n,k,a[maxn],de[maxn];
int ans[maxn];

void add(int x,int y){
	ed[++ecnt].to=y;ed[ecnt].nxt=head[x];head[x]=ecnt;
}

struct segm{
	int mn;
}se[maxn<<2];

void build(int x,int y,int num){
	if(x==y){
		se[num].mn=inf;return ;
	}
	int mid=x+y>>1;
	build(x,mid,num<<1);build(mid+1,y,num<<1|1);
	se[num].mn=min(se[num<<1].mn,se[num<<1|1].mn);
}

void update(int l,int to,int x,int y,int num){
	if(x==y){
		se[num].mn=to;return ;
	}
	int mid=x+y>>1;
	if(l<=mid)update(l,to,x,mid,num<<1);
	else update(l,to,mid+1,y,num<<1|1);
	se[num].mn=min(se[num<<1].mn,se[num<<1|1].mn);
}

int query(int l,int r,int x,int y,int num){
	if(l>r)return 0;
	if(l<=x && y<=r)return se[num].mn;
	int mid=x+y>>1;
	if(r<=mid)return query(l,r,x,mid,num<<1);
	else if(l>mid)return query(l,r,mid+1,y,num<<1|1);
	else return min(query(l,r,x,mid,num<<1),query(l,r,mid+1,y,num<<1|1));
}

void topo(){
	priority_queue<int,vector<int>,greater<int> >Q;
	for(int i=1;i<=n;i++){
		if(de[i]==0)Q.push(i);
	}
	int idx=0;
	while(!Q.empty()){
		int tp=Q.top();Q.pop();ans[tp]=++idx;
		for(int i=head[tp];i!=-1;i=ed[i].nxt){
			int u=ed[i].to;
			-- de[u];
			if(!de[u])Q.push(u);
		}
	}
}

int main(){
	memset(head,-1,sizeof head);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		a[x]=i;
	}
	build(1,n,1);
	
	for(int i=n;i>=1;i--){
		int u=query(a[i]+1,min(a[i]+k,n),1,n,1);
		int v=query(max(1,a[i]-k+1),a[i]-1,1,n,1);
		if(u>=1&&u<=n)add(a[i],a[u]), ++ de[a[u]];
		if(v>=1&&v<=n)add(a[i],a[v]), ++ de[a[v]];
		update(a[i],i,1,n,1);
	}
	topo();
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);

	return 0;
}


Measured memory_bytes: 40500
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    char ch = s[0];
    int num = 0;
    for(int i = 1; i < s.length(); ++i)
    {
        if(s[i] != ch)
        {
            ++num;
            ch = s[i];
        }
    }
    cout << num << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n, a, b, ans = 0;
	std::cin >> n >> a >> b;

	vll x(n);
	std::cin >> x[0];
	rep(i, 1, n) {
		std::cin >> x[i];
		ll tmp = x[i] - x[i - 1];
		if (tmp * a > b) {
			ans += b;
		}
		else {
			ans += tmp * a;
		}
	}

	outn(ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int A[100010];
int dp[100010];
int main(){
   // freopen("input.txt","r",stdin);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }
    dp[0]=0;
    dp[1]=abs(A[0]-A[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i]));
    }
    cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1024
solve :: Int -> Int -> Int -> Bool
solve n 9 9
    | n == 81 = True
    | otherwise = False
solve n a b 
    | a * b == n = True
    | b == 9 = solve n (a+1) 1
    | otherwise  = solve n a (b+1)

main = do
    n <- readLn
    putStrLn $ if solve n 1 1 then "Yes" else "No"

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <limits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define lowbit(x) ( x&( -x) )
#define pi 3.141592653589793
#define e 2.718281828459045
#define INF 0x3f3f3f3f
#define efs 1e-7
#define HalF (l + r)>>1
#define lsn rt<<1
#define rsn rt<<1|1
#define Lson lsn, l, mid
#define Rson rsn, mid+1, r
#define QL Lson, ql, qr
#define QR Rson, ql, qr
#define myself rt, l, r
#define MP(a, b) make_pair(a, b)
using namespace std;
typedef unsigned long long ull;
typedef unsigned int uit;
typedef long long ll;
const int maxN = 205;
int N, ans;
char mp[maxN][maxN];
vector<int> E[maxN];
struct node
{
    int id, val;
    node(int a=0, int b=0):id(a), val(b) {}
};
int main()
{
    scanf("%d", &N);
    for(int i=1; i<=N; i++)
    {
        scanf("%s", mp[i] + 1);
        for(int j=1; j<=N; j++) if(mp[i][j] == '1') E[i].push_back(j);
    }
    ans = -1;
    for(int s=1; s<=N; s++)
    {
        queue<node> Q;
        int dis[maxN] = {0};
        Q.push(node(s, 1)); dis[s] = 1;
        bool flag = true;
        while(!Q.empty())
        {
            node now = Q.front(); Q.pop();
            int u = now.id;
            int len = (int)E[u].size();
            for(int i=0, v; i<len; i++)
            {
                v = E[u][i];
                if(dis[v] == dis[u]) { flag = false; break; }
                if(!dis[v])
                {
                    dis[v] = dis[u] + 1;
                    Q.push(node(v, dis[v]));
                }
            }
        }
        if(flag) for(int j=1; j<=N; j++) ans = max(ans, dis[j]);
    }
    printf("%d\n", ans);
    return 0;
}
/*
7
0100000
1010100
0101000
0010001
0100010
0000101
0001010
ans:5
6
010000
101010
010100
001001
010001
000110
ans:-1
 */

Measured memory_bytes: 512
while True:
    N = int(input())
    if N == 0: break
    for _ in range(N):
        m, e, j = map(int, input().split())
        me, mej = (m+e)//2, (m+e+j)//3
        if 100 in (m, e, j) or me >= 90 or mej >= 80:
            print('A')
        elif mej >= 70 or (mej >= 50 and m >= 80 or e >= 80):
            print('B')
        else:
            print('C')



Measured memory_bytes: 5616
n,k = io.read("*n","*n", "*l")
t = {}
for i = 1, n do
    t[i] = io.read("*n")
end
table.sort( t )
a = 0
i = 1
while i <= n-k do
    a = a + t[i]
    i = i + 1
end
io.write(string.format("%d\n", a))


Measured memory_bytes: 2304
m , n = map(int,input().split(" "))


if n == 2 or m == 2:
  print("0")
  exit()
elif n  == 1 and m == 1:
  print(1)
  exit()
elif n == 1 and m != 1:
  print (m - 2)
  exit()
elif m == 1 and n != 1:
    print (n - 2)
    exit()
else:
  print(((n-2)*(m-2)))
  exit()



Measured memory_bytes: 3060
#include <stdio.h>
int main(void) {                                                                    double x1, y1, x2, y2, x3, y3, x4, y4;                                      
    int n;                                                                      
                                                                                    scanf("%d", &n);                                                                while (n-- > 0) {                                                           
scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);      
        if (x2 - x1 == 0)                                                       
            if (x4 - x3 == 0)                                                   
                printf("YES\n");                                                            else                                                                                printf("NO\n");                                                 
        else if (((y2 - y1) / (x2 - x1)) == ((y4 - y3) / (x4 - x3)))            
            printf("YES\n");                                                            else                                                                                printf("NO\n");                                                     
    }                                                                                                                                                           
    return 0;                                                                   
}

Measured memory_bytes: 620
#include<stdio.h>
int main(){
        int n,s;
        int i;
        int sum,max,min,result;
while(1){
        sum=0;
        result=0;
        max=0;
        min=1000;
        scanf("%d",&n);
        if(n==0){
                break;
        }
        for(i=0;i<n;i++){
                scanf("%d",&s);
                sum+=s;
                if(s>max){
                        max=s;
                }
                if(min>s){
                        min=s;
                }
        }
        result=(sum-(max+min))/(n-2);
        printf("%d\n",result);
}
        return 0;
}

Measured memory_bytes: 596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int W, H;
  while((cin >> W >> H) && W && H){
	VS code(H+2, string(W+2, 'A'));
	REP(y,H) REP(x,W)
	  cin >> code[y+1][x+1];
	pair<int, string> dp[100][100];
	for(int y=0;y<H+2;++y)
	  for(int x=0;x<W+2;++x)
		dp[y][x] = MP(0, "");

	int pdx[] = {-1, 0};
	int pdy[] = {0, -1};
	for(int y=1;y<=H;++y){
	  for(int x=1;x<=W;++x){
		if(!isdigit(code[y][x])) dp[y][x] = MP(0, "");
		else
		  for(int i=0;i<2;++i){
			//cout<<x<<","<<y<<endl;
			int px = x + pdx[i], py = y + pdy[i];
			if(dp[py][px].first > 0){
			  dp[y][x] = max(dp[y][x],
							 MP(dp[py][px].first+1,
								dp[py][px].second + code[y][x]));
			}
			else if(code[y][x] != '0'){
			  string s(1, code[y][x]);
			  dp[y][x] = max(dp[y][x], MP(1, s));
			}
			else
			  dp[y][x] = max(dp[y][x], MP(0, string("")));
		  }
	  }
	}
	pair<int,string> ans(0, "");
	for(int y=1;y<=H;++y)
	  for(int x=1;x<=W;++x)
		ans = max(ans, dp[y][x]);
	cout << ans.second << endl;
  }
  
  return 0;
}

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

int main(){
  string ans = "No";
  string s;
  cin >> s;
  int n=s.length();
  string s_re = s;
  reverse(s_re.begin(), s_re.end());
  string s_a = s.substr(0,(n-1)/2);
  string s_are = s_a;
  reverse(s_are.begin(), s_are.end());
  string s_b = s.substr(((n-1)/2)+1,(n-1)/2);
  string s_bre = s_b;
  reverse(s_bre.begin(), s_bre.end());
  if((s==s_re&&s_a==s_are)&&s_b==s_bre){
    ans = "Yes";
  }
  cout << ans;
}


Measured memory_bytes: 256