akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
#define N 3
#define N2 9
#define ANS "123456780"

using namespace std;

// 上、左、右、下
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
struct Puzzle {
  string f;
  int space;
  int step;
};

void bfs (Puzzle p) {
  Puzzle cur;
  queue<Puzzle> Q;
  map<string, bool> M;

  Q.push(p);

  while (Q.size()) {
    cur = Q.front(); Q.pop();
    if (cur.f == ANS) {
      cout << cur.step << endl;
      break;
    }
    int sx = cur.space / N;
    int sy = cur.space % N;
    for (int r = 0; r < 4; r++) {
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      Puzzle next;
      next.f = cur.f;
      swap(next.f[cur.space], next.f[tx * N + ty]);
      next.space = tx * N + ty;
      if (!M[next.f]) {
        M[next.f] = true;
        next.step = cur.step + 1;
        Q.push(next);
      }
    }
  }
}

int main () {
  Puzzle p;
  char c;
  
  p.step = 0;
  
  for (int i = 0; i < N2; i++) {
    cin >> c;
    p.f += c;
    if (c == '0') {
      p.space = i;
    }
  }

  bfs(p);

  return 0;
}


Measured memory_bytes: 23400
a = eval(input())
b = eval(input())
c = eval(input())
x = eval(input())
count = 0
le = x // 50
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x and i * 10 + j * 2 + k <= le :
                count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int maxi = max(a, b);
	maxi = max(maxi, c);
	if(maxi == c)
		cout << a * b / 2;
	else if(maxi == b)
		cout << a * c / 2;
	else
		cout << b * c / 2;
}

Measured memory_bytes: 256
a = list(map(int,[input() for i in range(5)]))
k = int(input())

ans = True
for i in range(5):
    for j in range(i+1,5):
        if (a[j]-a[i]) > k:
            ans = False

if ans:
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 2940
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        for(int i = 100; i > 0; i--) {
            if(a % i == 0 && b % i == 0) count++;
            if(count == k) {
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 22608
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <queue>
using namespace std;

priority_queue < pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > > q;
long long n, d, a;
long long now, ans;

int main() {
	cin >> n >> d >> a;

	while (n--) {
		long long x, h;
		cin >> x >> h;
		q.push(make_pair(x, h));
	}

	while (!q.empty()) {
		pair<long long, long long> p = q.top(); q.pop();
		long long x = p.first;
		long long h = p.second;

		if (h < 0)
			now += h;

		if (h - now > 0) {
			long long aTmp = (h - now - 1) / a + 1;
			ans += aTmp;
			now += aTmp * a;
			q.push(make_pair(x + d * 2 + 1, -aTmp * a));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int a[101] = { 0 };
	int k;
	int mex = 0;
	while (cin >> k) {
		a[k]++;
		if (mex < a[k]) {
			mex = a[k];
			//cout << "mex??´??°" << k << endl;
		}
	}
	for (int i = 1; i <= 100; i++) {
		if (a[i] == mex) {
			cout << i << endl;
		}
	}
    return 0;
}

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

#define ll long long
#define endl "\n"

int main ()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll
	int ans;
	for (int i=1; i<=5; i++){
		int a;
		cin >> a;
		if (a == 0) ans = i;
	}

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

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

using namespace std;
#define ll long long
int main()
{
    ll r=0;
    ll x;
    cin>>x;
    ll i=100;
    while(i<x)
    {
        i=i+i/100;
        r++;
    }
    cout<<r;
    return 0;
}


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

int main()
{
	int n, k;
	int ans = 0;
	scanf("%d %d", &n, &k);
	for (;n != 0;ans++)
	{
		n -= k;
		if (n == 0)
		{
			ans++;
			break;
		}
		else n += (k - 1);
		
	}
	printf("%d\n",ans);
	return 0;
}

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

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

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

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<unordered_map<int, int>>num(n);
  vector<ed>es(m);
  if(m==0){cout<<-1<<endl;return 0;}

  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    num[a][c]++;
    num[b][c]++;
  }
  int cnt=0;
  rep(i,n)
  {
    int tn=cnt++;
    for(auto &p:num[i])
    {
      p.second=cnt++;
    }
    num[i][-1]=tn;
  }
  vector<int>dist(cnt+2,-1);
  vector<vector<P>>edge(cnt+2);
  rep(i,n)for(auto p:num[i])
  {
    if(p.first==-1)continue;
    int t=num[i][-1];
    int tn=p.second;
    edge[t].push_back({1,tn});
    edge[tn].push_back({0,t});
  }
  rep(i,m)
  {
    int to=num[es[i].a][es[i].c],from=num[es[i].b][es[i].c];
    edge[to].push_back({0,from});
    edge[from].push_back({0,to});
  }
  int start=num[0][-1],end=num[n-1][-1];
  priority_queue<P,vector<P>,greater<P>>q;
  q.push({0,start});
  while(!q.empty())
  {
    P tp=q.top();q.pop();
    if(dist[tp.second]!=-1)continue;
    if(tp.second==end){cout<<tp.first<<endl;return 0;}
    dist[tp.second]=tp.first;
    for(P nn:edge[tp.second])
    {
      if(dist[nn.second]!=-1)continue;
      q.push({nn.first+tp.first,nn.second});
    }
  }
  cout<<-1<<endl;



  return 0;

}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;
  vector<pair<ll,ll>> b;
  rep(i,n){
    b.emplace_back(a[i],i+1);
  }
  sort(b.begin(),b.end());
  rep(i,n){
    cout<<b[i].second<<" ";
  }cout<<endl;


}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll path[705][705];
ll used[705],dp[750][2000];
int main(){
	ll n,m;
	vector<ll> p[705];
	vector< pair<ll,ll> > alt;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		path[a][b] = 1;
		path[b][a] = 1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if( (i!=j) && path[i][j]==0){
				p[i].pb(j);
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(used[i] == 0){
			used[i] = 1;
			if( p[i].size() == 0){
				alt.pb( mp(1,0) );
			}
			else{
				queue< pair<ll,ll> > que;
				ll cnt[3]={0,0,0};
				que.push( mp(i,1) );
				cnt[1]++;
				while(!que.empty()){
					ll cpos = que.front().first;
					ll ctp = que.front().second;
					que.pop();
					for(int j = 0;j<p[cpos].size();j++){
						ll dest = p[cpos][j];
						if(used [ dest ] == 0){
							used[ dest ] = 3-ctp;
							que.push( mp( dest, 3-ctp) );
							cnt[3-ctp]++;
						}
						else if(used[ dest ] == ctp){
							cout<<-1<<endl;
							return 0;
						}
					}
				}
				alt.pb( mp(cnt[1],cnt[2]) );
			}
		}
	}
	ll aa = alt.size();
	dp[0][0]=1;
	for(int i=0;i<aa;i++){
		//cout<<alt[i].first<<" "<<alt[i].second<<endl;
		for(int j=0;j<=n;j++){
			dp[i+1][j+alt[i].first]=max(dp[i+1][j+alt[i].first],dp[i][j]);
			dp[i+1][j+alt[i].second]=max(dp[i+1][j+alt[i].second],dp[i][j]);
		}
	}
	/* for(int i=0;i<=aa;i++){
		for(int j=0;j<n;j++){
			printf("dp[%d][%d]:%d\n",i,j,dp[i][j]);
		}
	} */
	for(int i=n/2;i>=0;i--){
		if(dp[aa][i]==1){
			ll s1 = i;
			ll s2 = n-i;
			ll ans = 0;
			ans += s1 * (s1-1) / 2;
			ans += s2 * (s2-1) / 2;
			cout<<ans<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 

   string s,t;
   cin>>s>>t;

   ll n=s.size(),m=t.size();

   ll dp[n+1][m+1];

   for(ll i=0;i<n+1;i++)
   {
   	for(ll j=0;j<m+1;j++)
   	{
   		if(i==0 or j==0)
   			dp[i][j]=0;
   		else
   		{
   			if(s[i-1]==t[j-1])
   				dp[i][j]=dp[i-1][j-1]+1;
   			else
   				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
   		}
   	}
   }

   vector<char>ans;

   for(ll i=n,j=m;i>0 and j>0;)
   {
   	
   		if(s[i-1]==t[j-1])
   			{
   				ans.pb(s[i-1]);
   				i--;
   				j--;
   			}
   			else
   			{
   				if(dp[i-1][j]>=dp[i][j-1])
   					i--;
   				else j--;
   			}
  
   }
   reverse(ans.begin(),ans.end());
   for(auto i:ans)
   	cout<<i;
}


Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, x);
    Cins(int, n, a);
    Sort(a);
    Cusum(ll, a, sa);
    if(x == sa[n]){
        Cout(n); return 0;
    }
    Cout(min(n-1, (int)distance(sa.begin(), upper_bound(Range(sa), x)) - 1));
}


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

int main(void){
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i = 0 ; i < N ; i++){
        cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    int sum = 0;
    for(int i = 0 ; i < K ; i++){
        sum += p.at(i);
    }
    cout << sum << endl;
}

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dp[2001][2001];

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

  int A, B;
  cin >> A >> B;
  string s1, s2;
  cin >> s1 >> s2;

  dp[A-1][B] = (s1.back() == 'I');
  dp[A][B-1] = (s2.back() == 'I');

  for(int i=A;i>=0;--i){
	for(int j=B;j>=0;--j){
	  int& tmp = dp[i][j];
	  if(i < A && s1[i] == 'I')
		maxi(tmp, 1);
	  if(j < B && s2[j] == 'I')
		maxi(tmp, 1);
	  
	  if(i < A && j < B){
		if(s1[i] == s2[j] && s1[i] == 'I'){
		  maxi(tmp, 1);
		}
		else if(s1[i] != s2[j]){
		  if(dp[i+1][j+1])
			maxi(tmp, dp[i+1][j+1] + 2);
		}
	  }

	  if(i+2 <= A && s1[i] == 'I' && s1[i+1] == 'O')
		if(dp[i+2][j])
		  maxi(tmp, dp[i+2][j] + 2);
	  if(j+2 <= B && s2[j] == 'I' && s2[j+1] == 'O')
		if(dp[i][j+2])
		  maxi(tmp, dp[i][j+2] + 2);
	}
  }

  int ans = 0;
  REP(i,A+1) REP(j,B+1)
	maxi(ans, dp[i][j]);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 18880
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        double r = Double.parseDouble(br.readLine());
        double L = 2.0 * r * Math.PI;
        double S = r * r * Math.PI;
        
        System.out.printf("%.6f " , S);
        System.out.printf("%.6f\n" , L);
    }
}



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

using namespace std;
using ll = long long;

int main(){
  ll x, y;
  cin >> x >> y;
  
  ll i = x;
  ll cnt = 1;
  while(true){
    i += i;
    if(i>y) break;
    cnt++;
  }
  
  cout << cnt << endl;


  return 0;
}

Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        w: [i64; n],
    }
    let mut ans = 100000000000;
    for i in 1..n {
        let s1 = w[0..i].iter().sum::<i64>();
        let s2 = w[i..].iter().sum::<i64>();
        ans = std::cmp::min(ans, (s1 - s2).abs());
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

long long int a[100001];

int main()
{
    int n, ct = 0;
    long long int m = 1000000001, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] < 0)
        {
            ct++;
            sum -= a[i];
            m = min(m, -1 * a[i]);
        }
        else
        {
            sum += a[i];
            m = min(m, a[i]);
        }
    }

    if (ct % 2 == 0)
    {
        cout << sum;
    }
    else
    {
        cout << sum - 2 * m;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int main() {
    int A,B,H;
    cin >> A >> B >> H;
    cout << (A+B)*H/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a[4];
    rep(i,4) cin>>a[i];
    ll ans=-1000000000000000000;
    rep(i,2){
        repi(j,2,4) ans=max(ans,a[i]*a[j]);
    }
    cout<<ans;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
  long int A, B;
  scanf("%ld %ld", &A, &B);

  if (0 == (A+B)%2) {
    printf("%ld\n", (A+B)/2);
  } else {
    printf("IMPOSSIBLE\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int x;
    cin >> x;
    vector<bool> flg(x+1, false);
    flg[1] = true;
    for ( int i = 2; i * i <= x; ++i ) {
        int num = i;
        while(1) {
            if ( num > x ) break;
            flg[num] = true;
            num *= i;
        }
    }
    int ans = 0;
    rep(i, x+1) {
        if ( flg[i] ) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<long long> n(4);
	n[0] = a * c;
	n[1] = a * d;
	n[2] = b * c;
	n[3] = b * d;
	int i = 0;
	for (int j = 1; j < 4; j++)
	{
		if (n[i] < n[j]) {
			i = j;
		}
	}
	cout << n[i] << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define mod 1000000007
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} //log(a+b) complexity
int Max(int a,int b){
	return a>b?a:b;
}
void testcase(){
int n;
cin>>n;
int *a=new int[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
int  mx=a[0],ans=0;
for(int i=1;i<n;i++){
	if(a[i]<mx){
		ans+=mx-a[i];
	}
	mx=Max(mx,a[i]);
}
cout<<ans<<endl;
return;
}
int32_t main(){
ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
 cout.tie(NULL); 
int t=1,k=1;
//cin>>t;
do{
//cout<<"Case #"<<k<<":"<<" ";
testcase();
k++;
t--;
}while(t>0);

return 0;
}


Measured memory_bytes: 5212
from itertools import accumulate


def GCD(x, y):
    if y == 0:
        return x
    return GCD(y, x % y)


N, X = map(int, input().split())
A = [abs(X - a) for a in map(int, input().split())]
ans = list(accumulate(A, func=GCD))[-1]
print(ans)

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

int main(){
	int n;
  	cin >> n;
  	string temp;
  	map<string, int> m;
  	for(int i = 0; i < n; ++i){
    	cin >> temp;
      	m[temp]++;
    }
  	cout << "AC x " << m["AC"] << endl;
  	cout << "WA x " << m["WA"] << endl;
  	cout << "TLE x " << m["TLE"] << endl;
  	cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

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 long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int a[100][2];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i][0];
        cin >> a[i][1];
    }
    for (int i = 0; i < n-2; ++i) {
        if(a[i][0] == a[i][1] && a[i+1][0] == a[i+1][1] && a[i+2][0] == a[i+2][1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	string s;
	
	cin >> s;

	bool f1 = false;
	bool f2 = false;

	for(int i=0; i<s.size(); i++){
		if(s[i] == 'C'){
			f1 = true;
		}
		if(f1 && s[i] == 'F'){
			f2 = true;
		}
	}
	
	if(f2) puts("Yes");
	else puts("No");

	return 0;
}


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

static class RomanFigure
{
    static void Main()
    {
        var dig = new Dictionary<char, int>()
        {
            { 'I', 1 },
            { 'V', 5 },
            { 'X', 10 },
            { 'L', 50 },
            { 'C', 100 },
            { 'D', 500 },
            { 'M', 1000 },
        };

        var indata = Console.In.ReadToEnd()
            .Split( 
                new[] { '\r', '\n' },
                StringSplitOptions.RemoveEmptyEntries );
        var q =
            from roman in indata
            select roman
                .Reverse()
                .Aggregate( 
                    new { acc = 0, post = 'I' }, 
                    (x, y) => dig[y] < dig[x.post]
                        ? new { acc = x.acc - dig[y], post = y }
                        : new { acc = x.acc + dig[y], post = y },
                    x => x.acc );
        foreach ( var num in q )
            Console.WriteLine( num );
    }
}

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

using namespace std;

typedef long long ll;

const int N = 310;

int dp[N][N][N];
string s;

int f(int i, int j, int k) {
    if (dp[i][j][k] != -1) {
        return dp[i][j][k];
    }
    if (i > j) {
        return dp[i][j][k] = 0;
    }
    if (i == j) {
        return dp[i][j][k] = 1;
    }
    if (s[i] == s[j]) {
        return dp[i][j][k] = f(i + 1, j - 1, k) + 2;
    }
    dp[i][j][k] = 0;
    if (k) {
        dp[i][j][k] = f(i + 1, j - 1, k - 1) + 2;
    }
    dp[i][j][k] = max(dp[i][j][k], f(i + 1, j, k));
    dp[i][j][k] = max(dp[i][j][k], f(i, j - 1, k));
    return dp[i][j][k];
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> s >> k;
    int n = s.length();
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
                dp[i][j][k] = -1;
            }
        }
    }
    cout << f(0, n - 1, k);
    return 0;
}

Measured memory_bytes: 116736
hash = Hash.new
array = gets.chomp.split("")
array.each do |str|
  	hash.key?(str) ? hash[str] += 1 : hash.store(str,1)
end
isBeautifulString = "Yes"
hash.each do |key, val|
	if val.odd?
      isBeautifulString = "No"
      break
    end
end
puts isBeautifulString

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

int main() {

vector<int> vec(5);
for(int i=0;i<5;i++){
    cin >> vec.at(i);
}
for(int i=0;i<5;i++){
    if(vec.at(i)==0){
        cout << i+1 << endl;
    }
}

}

Measured memory_bytes: 3540
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

int main()
{
	int h,n;
	ll sum=0;
	cin>>h>>n;
	rep(i,1,n) sum+=read();
	puts((sum>=h)?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    flag = False
    t, x, y = map(int, input().split())
    for a in range(t - pre_t + 1):
        b = pre_x - x + a
        if b >= 0:
            for c in range(t - pre_t + 1  - a - b):
                d = t - pre_t - a - b - c
                if pre_y + c - d == y:
                    count += 1
                    flag = True
                    break
        if flag:
            break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")

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

const LL MOD = pow(10,9) + 7;

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

    for(int i = 0; i < n; ++i){
        if(s[i] == s[k - 1]){
            cout << s[i];
        }else{
            cout << '*';
        }
    }

    cout << endl;

    return 0;
}

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

int main(){
    int H,W;
    cin >> H >> W;
    char temp;
    int c[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> temp;
            if(temp == '.') c[i][j] = 0;
            if(temp == '#') c[i][j] = -1;
        }
    }

    queue<int> x,y;
    //スタート設定
    x.push(0);
    y.push(0);
    //ゴール設定
    c[H - 1][W - 1] = -2;
    int g = 0;

    //経路記録用変数
    int rec[1000];
    for(int i = 0; i < 1000; i++){
        rec[i] = -1;
    }

    while(!y.empty()){
        int nx = x.front();
        int ny = y.front();
        x.pop();
        y.pop(); 
        if(nx + 1 < W and c[ny][nx + 1] == -2){
            c[ny][nx + 1] = c[ny][nx] + 1;
            g = c[ny][nx + 1];
            break;
        }
        else if(nx + 1 < W and c[ny][nx + 1] == 0){
            c[ny][nx + 1] = c[ny][nx] + 1;
            x.push(nx + 1);
            y.push(ny);
        }

        if(nx - 1 >= 0 and c[ny][nx - 1] == -2){
            c[ny][nx - 1] = c[ny][nx] + 1;
            g = c[ny][nx - 1];
            break;
        }
        else if(nx - 1 >= 0 and c[ny][nx - 1] == 0){
            c[ny][nx - 1] = c[ny][nx] + 1;
            x.push(nx - 1);
            y.push(ny);
        }

        if(ny + 1 < H and c[ny + 1][nx] == -2){
            c[ny + 1][nx] = c[ny][nx] + 1;
            g = c[ny + 1][nx];
            break;
        }
        else if(ny + 1 < H and c[ny + 1][nx] == 0){
            c[ny + 1][nx] = c[ny][nx] + 1;
            x.push(nx);
            y.push(ny + 1);
        }

        if(ny - 1 >= 0 and c[ny - 1][nx] == -2){
            c[ny - 1][nx] = c[ny][nx] + 1;
            g = c[ny - 1][nx];
            break;
        }
        if(ny - 1 >= 0 and c[ny - 1][nx] == 0){
            c[ny - 1][nx] = c[ny][nx] + 1;
            x.push(nx);
            y.push(ny - 1);
        }
    }
    
    c[0][0] = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(c[i][j] > g){
                c[i][j] = 0;
            }
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            for(int k = 0; k < 1000; k++){
                if(c[i][j] == k){
                    rec[k] += 1;
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < 1000; i++){
        if(rec[i] != -1) ans += rec[i];
    }
    if(c[H - 1][W - 1]== -2){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int dp[100000]; // i????????§??????????????????



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

	int a[n];

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



	for (int i = 0; i < n; i++) {
		int* p = upper_bound(dp,dp + i,a[i] - 1);
		*(p) = a[i];
	}

	int * b = upper_bound(dp,dp + n, INT_MAX - 1);

	cout << b - dp  << endl;



	return 0;
}

Measured memory_bytes: 1940
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Node {
  int x;
  int y;
  int cost;
  Node(int x, int y, int cost) : x(x), y(y), cost(cost) {;}
};

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int h, w;
int field[100][100][4];
int memo[2000][32][32];
int dist[32][32][4];
bool visit[32][32];

int d(int sx, int sy , int dir) {
  if (dist[sy][sx][dir] != -1) { return dist[sy][sx][dir]; }
  MEMSET(visit, false);
  int ret = 20000;
  field[sy][sx][dir] = 1;
  queue<Node> que;
  que.push(Node(sx, sy, 0));
  while (!que.empty()) {
    Node p = que.front();
    que.pop();
    if (visit[p.y][p.x]) { continue; }
    visit[p.y][p.x] = true;
    if (p.x == w - 1 && p.y == h - 1) {
      ret = p.cost;
      break;
    }
    REP(dir, 4) {
      if (field[p.y][p.x][dir] != 0) { continue; }
      int nx = p.x + dx[dir];
      int ny = p.y + dy[dir];
      int ncost = p.cost + 1;
      que.push(Node(nx, ny, ncost));
    }
  }
  field[sy][sx][dir] = 0;
  return dist[sy][sx][dir] = ret;
}

int calc(int depth, int x, int y) {
  if (memo[depth][y][x] != -1) { return memo[depth][y][x]; }
  if (depth == 1999) { return 20000; }
  if (x == w - 1 && y == h - 1) { return 0; }
  int ret = 20000;
  REP(dir, 4) {
    if (field[y][x][dir] != 0) { continue; }
    int nx = x + dx[dir];
    int ny = y + dy[dir];
    int cost = max(d(x, y, dir), 1 + calc(depth + 1, nx, ny));
    ret = min(ret, cost);
  }
  return memo[depth][y][x] = ret;
}

int main() {
  while (scanf("%d %d", &h, &w), h|w) {
    MEMSET(memo, -1);
    MEMSET(dist, -1);
    REP(y, 100) REP(x, 100) REP(dir, 4) { field[y][x][dir] = 1; }
    REP(i, h * 2 - 1) {
      if (i % 2 == 0) {
        int y = i / 2;
        REP(j, w - 1) {
          int v;
          int fx = j;
          int tx = fx + 1;
          scanf("%d", &v);
          field[y][fx][0] = v;
          field[y][tx][2] = v;
        }
      } else {
        int fy = i / 2;;
        int ty = fy + 1;
        REP(x, w) {
          int v;
          scanf("%d", &v);
          field[fy][x][1] = v;
          field[ty][x][3] = v;
        }
      }
    }
    int ans = calc(0, 0, 0);
    printf("%d\n", ans < 2000 ? ans : -1);
  }
}

Measured memory_bytes: 9192
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

const int MAX = 100005;
const int NIL = -1;

struct Node
{
    int parent, left, right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void Preorder(int u)
{
    cout << " " << u;
    if (T[u].left != NIL)
        Preorder(T[u].left);

    if (T[u].right != NIL)
        Preorder(T[u].right);
}

void Inorder(int u)
{

    if (T[u].left != NIL)
        Inorder(T[u].left);
    cout << " " << u;
    if (T[u].right != NIL)
        Inorder(T[u].right);
}

void Postorder(int u)
{

    if (T[u].left != NIL)
        Postorder(T[u].left);

    if (T[u].right != NIL)
        Postorder(T[u].right);
    cout << " " << u;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    cin >> n;
    for (int i = 0; i < n; ++i)
        T[i].parent = NIL;

    for (int i = 0; i < n; ++i)
    {
        int v, l, r; //vは節点の番号
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if (l != NIL)
            T[l].parent = v;
        if (r != NIL)
            T[r].parent = v;
    }

    int root = 0;
    for (int i = 0; i < n; ++i)
        if (T[i].parent == NIL)
            root = i;

    cout << "Preorder" << endl;
    Preorder(root);
    cout << endl;
    cout << "Inorder" << endl;
    Inorder(root);
    cout << endl;
    cout << "Postorder" << endl;
    Postorder(root);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    long double a,b,c;
    cin >> a >> b >> c;
    long double tmp = sqrt(a);
    long double tmp2 = sqrt(b);
    long double ans = a + b + 2 * tmp * tmp2;
    if(ans < (long double)c) print("Yes");
    else print("No");
   
    
}


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

int main()
{
    char s[101];
    cin>>s;
    char *p=strchr(s,'C');
    if(!p){
        cout<<"No";
        return 0;
    }
    p=strchr(p,'F');
    if(p){
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

ll A, B, a[100010];
int n;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> A >> B;
    FOR(i,1,n) cin >> a[i];
    ll now = a[1];
    ll res = 0;
    FOR(i,2,n) {
        if ((a[i]-now)*A < B) {
            res += (a[i]-now)*A;
        }
        else {
            res += B;
        }
        now = a[i];
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using v  = vector<ll>;
#define rep(i,n) for(ll i=0;i<(n);i++)
int main(){
    ll n; cin >> n;
    auto a = v(n,0);
    auto b = v(n,0);
    auto c = v(n+1,0);
    rep(i,n) cin >> a[i] >> b[i];
    for(ll i=n-1;i>=0;i--){
        ll cc = (a[i]+c[i+1])%b[i];
        c[i] = c[i+1]+(cc==0?0:b[i]-cc);
    }
    cout << c[0];
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;

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

	int maxv = -2000000000;
	int minv =  R[0];

	for (int j = 1; j < n; j++) {
		if (maxv < R[j] - minv) {
			maxv = R[j] - minv;
		}
		if (minv > R[j]) {
			minv = R[j];
		}

	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 3888
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int k,x;
  cin >> k >> x;
  for(int i=1; i< k*2-1; ++i){
    printf("%d ", x-k+i);
  }
  printf("%d\n", x+k-1);
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

p = 10 ^ 9 + 7

f :: Int -> Int
f i = foldr (\x a -> (x * a) `mod` p) 1 (replicate i 2)

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- sort . fmap read . words <$> getLine :: IO [Int]

    let es = concat [replicate 2 x | x <- [1, 3 ..]]
    let os = 0 : concat [replicate 2 x | x <- [2, 4 ..]]
    let bs = if even n then take n es else take n os

    if as == bs
        then do
            case () of
                _ | length as == 1 -> print 1
                  | odd  n -> print $ f ((last as) `div` 2)
                  | even n -> print $ f ((last as + 1) `div` 2)
        else print 0

Measured memory_bytes: 36476
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main(){
    int h,w;cin>>h>>w;
    char s[h][w];
    rep(i,h)rep(j,w)cin>>s[i][j];

    int l[h][w],r[h][w],f[h][w],b[h][w];
    rep(i,h){
        rep(j,w){    
         
        if(s[i][j]=='.'){
            if(j==0) l[i][j] = 1;
            else l[i][j] = l[i][j-1] + 1;
        }
        
        else{
            l[i][j] = 0;
        }
    }
    }
    rep(i,h){
        rep(j,w){     
            if(s[i][j]=='.'){
                if(i==0)f[i][j] = 1;
                else f[i][j] = f[i-1][j]+1;
            }
            else{
                f[i][j] = 0;
            }
        }
    }
    rep(i,h){
            for(int j=w-1;j>=0;j--){     
                if(s[i][j]=='.'){
                    if(j==w-1) r[i][j] = 1;
                    else r[i][j] = r[i][j+1]+1;
                }
                else{
                    r[i][j] = 0;
                }
            }
        }
    for (
        int i = h-1; i >= 0; i--)
    {
        rep(j,w){     
            if(s[i][j]=='.'){
                if(i==h-1) b[i][j] = 1;
                else b[i][j] = b[i+1][j] + 1;
            }
            else{
                b[i][j] = 0;
            }
        }
    }
    int mx=0;
    rep(i,h)rep(j,w){
        int sum;
        sum = r[i][j] + b[i][j] + l[i][j] + f[i][j] -3;
        mx = max(mx,sum);
    }

    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 66688
/*

RFL <3
The Feeling of Happiness

"In dreams begin responsibility"

*/


#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)


/*
#define nMX 5000000
#define pMX 500000
int pr[pMX+1],prnum[nMX+1];

int sieve()
{
    int i,j;
    for(i=1;i<=nMX;i++)
        prnum[i]=i+1;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            for(j=2*prnum[i]-1;j<=nMX;j+=prnum[i])
                    prnum[j]=-1;
    j=0;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            pr[++j]=prnum[i];
    re j;
}*/

/*ll m_ncr[10001][10001];
ll ncr(ll i,ll j)
{
    if(j==1) re i;
    if(i==j) re 1;
    if(m_ncr[i][j]!=-1) re m_ncr[i][j];
    re m_ncr[i][j]=ncr(i-1,j) + ncr(i-1,j-1);
}*/

/*ll m_fact[21];
ll fact(ll i)
{
    if(i==1 || i==0) re 1;
    if(m_fact[i]!=-1) re m_fact[i];
    re m_fact[i]=i*fact(i-1);
}*/


/*#define MX 200005
ll int arr[MX];
ll int tree[MX * 3];
void init(ll int node, ll int b, ll int e)
{
    if (b == e) {
        tree[node] = arr[b];
        return;
    }
    ll int Left = node * 2;
    ll int Right = node * 2 + 1;
    ll int mid = (b + e) / 2;
    init(Left, b, mid);
    init(Right, mid + 1, e);
    tree[node] = max(tree[Left], tree[Right]);
}
ll int query(ll int node, ll int b, ll int e, ll int i, ll int j)
{
    if (i > e || j < b)
        return -1e6;
    if (b >= i && e <= j)
        return tree[node];
    ll int Left = node * 2;
    ll int Right = node * 2 + 1;
    ll int mid = (b + e) / 2;
    ll int p1 = query(Left, b, mid, i, j);
    ll int p2 = query(Right, mid + 1, e, i, j);
    return max(p1, p2);
}
void updateRange(ll int node, ll int start, ll int endd, ll int l, ll int r, ll int val)
{
    // out of range
    if (start > endd or start > r or endd < l)
        return;

    // Current node is a leaf node
    if (start == endd)
    {
        // Add the difference to current node
        tree[node] += val;
        return;
    }

    // If not a leaf node, recur for children.
    ll int mid = (start + endd) / 2;
    updateRange(node*2, start, mid, l, r, val);
    updateRange(node*2 + 1, mid + 1, endd, l, r, val);

    // Use the result of children calls to update this node
    tree[node] = tree[node*2] + tree[node*2+1];
}*/


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll int i,j,x,y,n,m,cnt=0,k,g,flg,t;
    cin>>n;
    double prb;
    x=n/2;
    if(n%2) x++;
    prb=x*1.0/(n*1.0);
    cout<<prb;
}


Measured memory_bytes: 384