akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.array, std.conv;

struct Card {
    char suit, value;
}

void bubble(int n, Card[] x) {
    foreach (i; 0 .. n) {
        foreach_reverse (j; i+1 .. n) {
            if (x[j].value < x[j-1].value) {
                Card t = x[j];
                x[j] = x[j-1];
                x[j-1] = t;
            }
        }
    }
}

void selection(int n, Card[] x) {
    foreach (i; 0 .. n) {
        int minj = i;
        foreach (j; i .. n) {
            if (x[j].value < x[minj].value) {
                minj = j;
            }
        }
        Card t = x[i];
        x[i] = x[minj];
        x[minj] = t;
    }
}

bool isStable(int n, Card[] x, Card[] y) {
    foreach (i; 0 .. n) {
        if (x[i].suit != y[i].suit) return false;
    }
    return true;
}

void main() {
    int n = readln.chomp.to!int;
    string[] _a = readln.chomp.split;
    Card[] a, b;
    foreach (x; _a) {
        a ~= Card(x[0], x[1]);
        b ~= Card(x[0], x[1]);
    }
    bubble(n, a);
    selection(n, b);
    foreach (i, x; a) {
        write(x.suit, x.value);
        if (i != n - 1) " ".write;
        else writeln;
    }
    "Stable".writeln;
    foreach (j, y; b) {
        write(y.suit, y.value);
        if (j != n - 1) " ".write;
        else writeln;
    }
    writeln(isStable(n, a, b) ? "Stable" : "Not stable");
}


Measured memory_bytes: 2484
#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;

int min(int a, int b, int c)
{
    if (a <= b && a <= c)
    return a;
    else if (b <= a && b <= c)
    return b;
    else if (c <= a && c <= b)
    return c;
    else
    return a;

}

int gcd(int a, int b, int c)
{
    int mini = min(a, b, c);

    vector<int> v;
    for (int i = 1; i <= mini; i++) {
        if (mini % i == 0) {
            v.push_back(i);
        }
    }

    for (int i = v.size() - 1; 0 <= i; i--) {
        int x = v[i];
        if (a % x == 0 && b % x == 0 && c % x == 0) {
            return x;
        }
    }
}

int main (void)
{
    int k;
    cin >> k;

    long int sum = 0;

    //int arr[k+1][k+1][k+1];
    int ***arr;
    arr = (int ***)malloc(sizeof(int **) * (k + 1));
    for (int i = 0; i <= k; i++) {
        arr[i] = (int **)malloc(sizeof(int *) * (k + 1));
        for (int j = 0; j <= k; j++) {
            arr[i][j] = (int *) malloc(sizeof(int) * (k + 1));
        }
    }


    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            for (int h = 0; h <= k; h++) {
                arr[i][j][h] = 0;
            }
        }
    }

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int h = 1; h <= k; h++) {
                //cout << i << " " <<  j  << " " << h << endl;;
                if (arr[i][j][h] == 0) {
                    int x = gcd(i, j, h);
                    arr[i][j][h] = x;
                    arr[i][h][j] = x;

                    arr[j][i][h] = x;
                    arr[j][h][i] = x;

                    arr[h][i][j] = x;
                    arr[h][j][i] = x;

                    sum += x;
                }
                else {
                    sum += arr[i][j][h];
                }
                //cout << i << " " << j << " " << h << " : " << min(i, j, h) << endl;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 35576
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}




void solve()
{
	ll k;
	cin >> k;
	ll lim = k + 1;
	ll count = 0;
	ll start = 0;
	while (lim--)
	{
		count++;
		start *= 10;
		start += 7;
		start %= k;
		if (start == 0)
		{
			cout << count << "\n";
			return;
		}
	}
	cout << -1 << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] array = br.readLine().split(" ");

        for (int i = 1; i < n; i++) {
            System.out.println(String.join(" ", array));
            for (int j = i - 1; j >= 0; j--) {
                if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {
                    String tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                }
            }
        }
        System.out.println(String.join(" ", array));
    }
}

Measured memory_bytes: 27716
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;

ll comb(int n, int k) {
    ll res = 1;

    rep(i,k) res = (res * (n - i)) ;
    rep(i,k) res = (res / (k - i)) ;

    return res;
}

int main(){
    ll N; cin >> N;
    vector<string> v(N);
    ll ans = 0;
    map<string,ll> mp;
    rep(i,N){
        cin >> v[i];
        sort(v[i].begin(),v[i].end());
        mp[v[i]]++;
    }
    for(auto it : mp){
        ll k = it.second;
        ans += comb(k,2);
    }
    cout << ans << endl;
}

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

int main(void)
{
	int i,j;
	int n;
	int card[4][13];
	char symbolList[4] = {'S','H','C','D'};
	char symbol;
	int rank;
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 13; j++)
		{
			card[i][j] = 0;
		}
	}
	
	cin >> n;
	
	for(i = 0; i < n; i++)
	{
		cin >> symbol >> rank;
		for(j = 0; j < 4; j++)
		{
			if(symbol == symbolList[j])
			{
				card[j][rank - 1] = 1;
			}
		}
	}
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 13; j++)
		{
			if(card[i][j] == 0)
			{
				cout << symbolList[i] << " " << j + 1 << endl;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, l;
    cin >> n >> l;
    vstr s(n);
    rep(i, n) cin >> s[i];

    sort(all(s));
    string ans = "";
    rep(i, n) ans += s[i];
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long k=sc.nextLong();
		int[] array = new int[n];
		for(int i=0;i<n;i++) array[i]=sc.nextInt();
		int[] list = new int[n];
		list[0]=0;
		int now = 0,count=0,next;
		while(true) {
			next = array[now]-1;
			count++;
			if(list[next]!=0) {
				count = count-list[next];
				break;
			}
			list[next]=count;
			now=next;
		}
		if(k<list[next]) {
			for(int i=0;i<n;i++) {
				if(list[i]==k) {
					System.out.println(i+1);
					break;
				}
			}
		}else {
			k-=list[next];
			for(int i=0;i<n;i++) {
				if(list[i]==list[next]+(k%count)) {
					System.out.println(i+1);
					break;
				}
			}
		}
	}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

bool isPrime(int a) {
    if (a == 1) return false;
    for (int i = 2; i * i <= a; i++) {
        if(a % i == 0) return false;
    }
    return true;
}


void solve()
{
  int n;
  cin >> n;

  vector<int> ans{2};
  int num = 1;
  while(ans.size() < n)
  {
    num += 10;
    if (isPrime(num)) ans.emplace_back(num);
  }
  for(const auto& v : ans)
  {
    cout << v << " ";
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans=a[0]/2;
    a[0] = a[0] % 2;
    for(ll i=1; i<n; i++){
        if(i>0){
            if(a[i-1] % 2 == 1 && a[i] > 0){
                a[i]--;
                a[i-1] = 0;
                ans++;
            }
        }
        ans += a[i] / 2;
        a[i] = a[i] % 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}







/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,q;
  string s;
  cin>>n>>q>>s;
  vector<ll> sum(n+2,0);
  for(ll i=1;i<=n;i++){
    sum[i+1]=sum[i];
    if(s[i-1]=='A' && s[i]=='C') sum[i+1]++;
  }
  rep(i,q){
    ll a,b;cin>>a>>b;
    cout<<sum[b]-sum[a]<<endl;
  }
}

Measured memory_bytes: 1872
n, m = map(int, input().split())
A = [[0 for j in range(m)] for i in range(n)]

for i in range(n):
   A[i] = list(map(int, input().split()))

S = [0 for j in range(m)]
c = 0
for i in range(n):
   for j in range(m):
      print(A[i][j], end = "")
      print(" ", end = "")
   print(sum(A[i]))
   c += sum(A[i])

for j in range(m):
   sum = 0
   for i in range(n):
      sum += A[i][j]
   print(sum, end = "")
   print(" ", end = "")
print(c)


Measured memory_bytes: 6748
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[100005];
ll dp[100005][2];    // keta,smaller

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int len=strlen(str);

    int i,j,k;
    dp[0][0]=2; dp[0][1]=1;
    for(i=0; i<len; i++) {
        int tmp=str[i]-'0';
        if(i==0) {
            assert(tmp);
        }
        else {
            for(j=0; j<2; j++) {
                for(k=0; k<=(j? 1: tmp); k++) {
                    dp[i][j || k<tmp] += dp[i-1][j] * (k? 2: 1);
                    dp[i][j || k<tmp] %= MOD;
                }
            }
        }
    }

    printf("%lld\n", (dp[len-1][0]+dp[len-1][1])%MOD);
    return 0;
}


Measured memory_bytes: 1792
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final String line = sc.nextLine();
        Set<Character> target = new HashSet<>();
        target.add('A');
        target.add('C');
        target.add('G');
        target.add('T');
        int count = 0;
        int result = 0;
        for (char c : line.toCharArray()) {
            if (target.contains(c)) {
                count++;
            } else {
                result = Math.max(result, count);
                count = 0;
            }
        }
        result = Math.max(result, count);
        System.out.println(result);
    }
}


Measured memory_bytes: 23380
#include <iostream>

using namespace std;

int even (int); //偶数
int odd (int); //奇数

int main()
{
    int s; //初項
    int a[1000000]; //数列a
    
    cin >> s; //入力
    a[0] = s;
    //cout << s << '\n';
    for (int i = 1; i <= 1000000; i++){ //数列生成
        if (a[i-1] % 2 == 0){//a[i-1]が偶数ならa[i]にf(n) = n/2
            a[i] = even(a[i-1]);
//            cout << a[i] << '\n';
//            cout << "a[" << i - 1 << "] =" << a[i -1] << '\n';
        }
        else {//a[i-1]が奇数ならa[i]にf(n) = 3n+1
            a[i] = odd(a[i-1]);
//            cout << a[i] << '\n';
//            cout << "a[" << i - 1 << "] =" << a[i -1] << '\n';
        }
    }
    int i;
    
    for (i = 0; i < 1000000; i++){ //全検索
        for (int j = 0; j < i; j++){
            if (a[j] == a[i])
                goto LABEL; //見つけたら脱出
        }
    }
LABEL:
    cout << i + 1 << '\n';
}

int even(int n)
{
    return n / 2;
}

int odd(int n)
{
    return 3 * n + 1;
}


Measured memory_bytes: 4344
#include<iostream>

using namespace std;

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

	int debt = 100000;
	for(int i = 0; i < n; i++)
	{
		debt += debt * 0.05;
		if(debt % 1000 != 0)
		{
			debt -= debt % 1000;
			debt += 1000;
		}
	}
	cout << debt << endl; 

	return 0;
}

Measured memory_bytes: 1160
N,x = map(int,input().split())
A = list(map(int,input().split()))

ans = 0

for i in range(N-1):
  a,b = A[i],A[i+1]
  if a+b > x:
    if b-(x-a-b) >= 0:
      ans += a+b-x
      A[i+1] -= (a+b-x)
      A[i+1] = max(0,A[i+1])
    else:
      A[i+1] = 0
      A[i] -= ((x-a-b)-b)
      ans += (a-A[i])+(b-A[i+1])

print(ans)

Measured memory_bytes: 19992
a=list(input())
b=list(input())
if a==b:
  print("No")
else:
  a.sort()
  a="".join(a)
  b.sort()
  b=b[::-1]
  b="".join(b)
  list_ = [a,b]
  list_.sort()
  if list_[0]==a:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>

int main() {

  int a,b,i,j;
  int n = 1;
  int asum = 0, bsum = 0;
 

  while(1) {
    asum = 0;
    bsum = 0;

    scanf("%d",&n);

    if(n == 0) break;

  for(i = 0;i < n;i++) {

    scanf("%d %d",&a,&b);

    if(a > b) asum  += a + b;
    else if(b > a) bsum += a + b;
    else {
      asum += a;
      bsum += b;
    }

  }

  printf("%d %d\n",asum,bsum);

  }


  return 0;

}

Measured memory_bytes: 600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        int res = 0;
        for (int i = 1; i < n; i++)
        {
            var cnt = s.Substring(0, i).Intersect(s.Substring(i)).ToArray();
            res = Max(res, cnt.Length);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 28400
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    before = A
    after = []
    for _ in range(pow(10, 9)):
        x = before[0]
        if len(before) == 1:
            print(x)
            return
        after.append(x)
        for i in range(1, len(before)):
            y = before[i]%x
            if y != 0:
                after.append(y)
        after.sort()
        before = after
        after = []

if __name__ == "__main__":
    main()


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

int main() {
	
	int n; cin >> n;
	vector<int> a(n + 2, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int sum = 0;
	for (int i = 1; i <= n + 1; i++) {
		sum +=abs(a[i] - a[i - 1]);
	}
	for (int i = 1; i <= n; i++) {
		int tmp = sum;
		tmp -= abs(a[i] - a[i - 1]);
		tmp -= abs(a[i + 1] - a[i]);
		tmp += abs(a[i + 1] - a[i - 1]);
		cout << tmp << endl;
	}
    return 0;
}

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

ll k, m, ans, a, b;
ll t[1 << 17], d[1 << 17];
vector<ll> u, v;

int main()
{
    cin >> k >> a >> b;
    ans = 1;
    if (a + 1 >= b || a > k - 1)
    {
        cout << k + 1 << endl;
        return 0;
    }
    else
    {
        ans = a;
        k -= a - 1;
        k -= 2;
        ans = b;
        ans += (b - a) * (k / 2) + k % 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	string s;
	cin>>s;
	rep(i,3){
		if(s[i]==s[i+1]){cout<<"Bad"<<endl;return 0;}
	}
	cout<<"Good"<<endl;
}





Measured memory_bytes: 256
#include <stdio.h>

#define N 500000
#define SENTINEL 1000000000;

int compareCount=0;

void Merge(int* ,int, int ,int );
void MergeSort(int* ,int ,int );

int main(){

  int n, A[N];
  int i;

  scanf("%d", &n);
  for(i=0;i<n;i++)
    scanf("%d", &A[i]);

  MergeSort(A, 0, n);


  printf("%d",A[0]);
  for(i=1;i<n;i++)
    printf(" %d", A[i]);

  printf("\n%d\n", compareCount);

  return 0;
}



void Merge(int* A,int left,int mid,int right){
  int l,r;
  int i, k;

  l = mid - left;
  r = right - mid;

  int L[N/2+2], R[N/2+2];

  for(i=0; i<l; i++)   L[i] = A[left + i];
  for(i=0; i<r; i++)   R[i] = A[mid + i];

  L[l] = SENTINEL;
  R[r] = SENTINEL;

  i = 0;
  int j = 0;

  for(k=left; k<right; k++){

    compareCount++;
    
    if( L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
    
  }
}
  
void MergeSort(int *A,int left,int right){
  
  int mid;

  if(left+1 < right){
    mid = (left + right)/2;
    MergeSort(A, left, mid);
    MergeSort(A, mid, right);
    Merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4500
package main

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

var sc = bufio.NewScanner(os.Stdin)

const MOD = 1000000007

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

	a := make([]int, 3)
	for i := 0; i < 3; i++ {
		a[i] = nextInt()
	}

	sort.Ints(a)
	fmt.Println(a[2] - a[0])
}

Measured memory_bytes: 640
n = int(input())

r = [[0,0,1] for i in range(n)]
for i in range(n) :
  x,y = map(int,input().split())
  r[i][0],r[i][1] = x,y
  
b = [[0,0,1] for i in range(n)]
for i in range(n) :
  x,y = map(int,input().split())
  b[i][0],b[i][1] = x,y
  
r.sort(key=lambda x: x[0],reverse=True)
b.sort(key=lambda x: x[1])

ans = 0
for i in range(n) :
  for j in range(n) :
    if r[i][2] == 0 or b[j][2] == 0 :
      continue
    if r[i][0] < b[j][0] and r[i][1] < b[j][1] :
      r[i][2] = 0 ; b[j][2] = 0
      ans += 1
      
print(ans)

Measured memory_bytes: 3064
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();

    let n: usize = buf.trim().parse().unwrap();

    buf = String::new();

    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let mut num_vec: Vec<i64> = Vec::new();

    for _ in 0..n {
        let num: i64 = iter.next().unwrap().parse().unwrap();

        num_vec.push(num);
    }

    let mut div2_count = 0;
    for num in &num_vec {
        let mut num = *num;
        while num % 2 == 0 {
            div2_count += 1;
            num /= 2;
        }
    }

    println!("{}", div2_count);
}


Measured memory_bytes: 4352
*_, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort.reverse
b = gets.split.map(&:to_i).sort.reverse
c = gets.split.map(&:to_i).sort.reverse
puts a.product(b).map { |x, y| x + y }.sort.reverse[0, k].product(c).map{ |x, y| x + y }.sort.reverse[0, k].join("\n")

Measured memory_bytes: 287372
#include <iostream>
#include <bitset>

int main() {
    uint N, M;
    std::cin >> N >> M;

    std::bitset<32> a(N), b(M);
    std::cout << (a & b) << std::endl;
    std::cout << (a | b) << std::endl;
    std::cout << (a ^ b) << std::endl;
    return 0;
}



Measured memory_bytes: 3144
import math
a, b, c = map(int, input().split())

LL = (a * a) + (b * b) - 2 * a * b * math.cos(math.radians(c))
L = math.sqrt(LL) + a + b
h = b * math.sin(math.radians(c))
S = a * b * math.sin(math.radians(c)) / 2

print(S)
print(L)
print(h)


Measured memory_bytes: 5712
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

fn d2c(num: u32) -> char {
    std::char::from_digit(num, 10).unwrap()
}

fn main() {
    abc079_c();
}

fn abc079_c() {
    input! {
        a: chars
    }
    let nums: Vec<i32> = a.into_iter().map(|c| c as i32 - 48).collect();
    let ans: String = abc079_c_helper(&nums).into_iter().collect();
    println!("{}", ans);
}

fn abc079_c_helper(nums: &Vec<i32>) -> Vec<char> {
    for i in 0..8 {
        let mut sum = nums[0];
        let mut text: Vec<char> = Vec::new();
        text.push(d2c(nums[0] as u32));
        for j in 0..3 {
            if i & (1 << j) == 0 {
                sum += nums[j + 1];
                text.push('+');
            } else {
                sum -= nums[j + 1];
                text.push('-');
            }
            text.push(d2c(nums[j+1] as u32));
        }
        if sum == 7 {
            text.push('=');
            text.push('7');
            return text;
        }
    }

    Vec::new()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int main()
{
  int N, K; cin >> N >> K;
  ++N;
  ll ans = 0;

  repe(i, K, N){
    ans += i * N - (i * i) + 1;
    ans %= MOD;
  }

  cout << ans << endl;

}



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

typedef long long ll;
#define inf 1e9+7

int n;
ll dp[102][102];
ll p[102];

void init(){
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=inf;
        }
        dp[i][i]=0;
    }
}

void cal(int l, int r){
    if(l>=r)return;
    if(dp[l][r]<inf)return;
    for(int k=l;k<r;k++){
        cal(l,k);
        cal(k+1,r);
        dp[l][r] = min(dp[l][r], dp[l][k]+dp[k+1][r]+p[l]*p[k+1]*p[r+1]);
    }
}

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

    cin >> n;
    init();
    cin >> p[0] >> p[1];
    ll a,b;
    for(int i=1;i<n;i++){
        cin >> a >> b;
        p[i+1]=b;
    }
    cal(0,n-1);
    cout << dp[0][n-1] << endl;
    return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653

ll su(ll x, ll y){
	return ((x-y+1)*y+1)%MOD;
}
int main(){
	ll n, k; cin >> n >> k;
	ll ans = 0;
	FOR(i,k,n+1) ans = (ans+su(n,i))%MOD;
	cout << ans << endl;
}

Measured memory_bytes: 3604
/**
 * C - 白昼夢 / Daydream
 * https://atcoder.jp/contests/abc049/tasks/arc065_a
 **/
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
    string S; cin >> S;
    int ptr=S.length();
    vector<string> kouho={"dreamer", "dream", "eraser", "erase"};
    while(ptr>0) {
        bool flag = false;
        // cout << ptr << endl;
        for(auto str:kouho) {
            if(str.length()>ptr) continue;
            // cout << "kouho:" << str <<endl;
            // cout << "ptr=>" << ptr << "start:" << ptr-str.length() << endl;
            // cout << S.substr(ptr-str.length(), str.length()) << endl;
            if(S.substr(ptr-str.length(), str.length())==str) {
                ptr = ptr - str.length();
                flag = true;
                break;
            }
        }
        // cout << flag << endl;
        if(flag==false) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(h, w, k);
    vector<string> table(h);

    rep(i, h) {
        cin >> table[i];
    }

    vvi ans(h, vi(w, 0));

    int cnt = 1;
    rep(i, h) {
        bool fl = false;
        rep(j, w) {
            if (table[i][j] == '#') fl = true;
        }
        if (fl) {
            bool flg = false;
            rep(j, w) {
                if (table[i][j] == '.') {
                    ans[i][j] = cnt;
                } else if (!flg) {
                    ans[i][j] = cnt;
                    flg = true;
                } else {
                    cnt++;
                    ans[i][j] = cnt;
                }
            }
            cnt++;
        }
    }

    rep(i, h) {
        if (ans[i][0]) {
            for (int k = i-1; k >= 0; k--) {
                if (ans[k][0]) break;
                rep(j, w) {
                    ans[k][j] = ans[i][j];
                }
            }
        }
    }


    rep(i, h) {
        if (ans[i][0]) {
            for (int k = i+1; k < h; k++) {
                if (ans[k][0]) break;
                rep(j, w) {
                    ans[k][j] = ans[i][j];
                }
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }




    return 0;
}




Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int N, K;

int main() {
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
  
    vector<int> cost(N);
    for (int i = 1; i <= K; i++) {
        cost[i] = abs(h[i] - h[0]);
        if(i == N - 1) {
          cout << cost[i] << endl;
          return 0;
        }
    }
    for (int i = K + 1; i < N; i++) {
        int c = 1e9;
        for (int j = 1; j <= K; j++) {
            c = min(c, cost[i - j] + abs(h[i] - h[i - j]));
        }
        cost[i] = c;
    }
    cout << cost[N - 1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  vector<int> A(M);
  REP(i, M) cin >> A[i];
  sort(ALL(A), greater<int>());

  vector<int> num = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  vector<int> dp(N+1, -1);
  dp[0] = 0;
  REP(i, N){
    for(int j : A){
      if(dp[i] == -1) continue;
      if(i+num[j] <= N) chmax(dp[i+num[j]], dp[i]+1);
    }
  }

  int cnt = dp[N];
  REP(i, cnt){
    REP(j, M){
      int tmp = N-num[A[j]];
      if(tmp < 0) continue;
      if(dp[tmp] == dp[N]-1){
        cout << A[j];
        N -= num[A[j]];
        break;
      }
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	map<string, string>m;
	m["Sunny"] = "Cloudy";
	m["Cloudy"] = "Rainy";
	m["Rainy"] = "Sunny";
	string s;
	cin >> s;
	cout << m[s] << endl;
}

Measured memory_bytes: 256
import sys
N,K=map(int,sys.stdin.readline().split())
A=sorted([int(e) for e in sys.stdin.readline().split()] for _ in range(N))
x,y=zip(*A)
Y=sorted(y)
r=(x[-1]-x[0])*(Y[-1]-Y[0])
for i in range(N):
 for j in range(i+1,N):
  for k in range(N):
   for l in range(k+1,N):
    ly=Y[k];ry=Y[l];q=(x[j]-x[i])*(ry-ly)
    if r>q and K<=(j-i+1) and K<=sum(ly<=y[z]<=ry for z in range(i,j+1)): r=q
print(r)

Measured memory_bytes: 35176
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  // 入力
  long int X;
  cin >> X;

  long int gohyaku_yen = X/500;
  long int nokori = X%500;
  long int go_yen = nokori/5;
  long int result = gohyaku_yen*1000 + go_yen*5;

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#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 <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int A[1000][1000];
int patov[1000][1000];
vector<int> G[1000000];
int ined[1000000];
int day[1000000];
void Calc(){
	int N = rei();
	int c = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<i;j++){
			patov[i][j] = c;
			patov[j][i] = c;
			c++;
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N-1;j++){
			A[i][j] = rei()-1;
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N-2;j++){
			int f = patov[i][A[i][j]];
			int t = patov[i][A[i][j+1]];
			G[f].push_back(t);
			ined[t]++;
		}
	}
	queue<int> que;
	for(int i=0;i<c;i++){
		if(ined[i] == 0){
			que.push(i);
			day[i] = 1;
		}
	}
	while(!que.empty()){
		int v = que.front();
		que.pop();
		for(int t:G[v]){
			ined[t]--;
			if(ined[t] == 0){
				day[t] = day[v]+1;
				que.push(t);
			}
		}
	}
	int M = 0;
	for(int i=0;i<c;i++){
		if(day[i] == 0){
			cout << "-1" << endl;
			return;
		}
		M = max(M,day[i]);
	}
	cout << M << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 54912
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    long long stock = 0;
    long long money = 1000;
    for (int i = 0; i < N - 1; i++)
    {
        if (stock == 0)
        {
            if (A[i] < A[i + 1])
            {
                stock = money / A[i];
                money -= stock * A[i];
                if (i + 1 == N - 1)
                {
                    money += stock * A[i + 1];
                    stock = 0;
                }
            }
        }
        else
        {
            if (A[i] > A[i + 1])
            {
                money += stock * A[i];
                stock = 0;
            }
            else if (i + 1 == N - 1)
            {
                money += stock * A[i+1];
                stock = 0;
            }
        }
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
const int Nmax = 100000;
int N;
ll A,B,X[Nmax];

int main(){
    cin >> N >> A >> B;
    for(int i=0; i<N; i++) cin >> X[i];

    ll ans = 0;
    for(int i=0; i<N-1; i++){
        if((X[i+1]-X[i])*A > B){
            ans += B;
        }
        else{
            ans += (X[i+1]-X[i])*A;
        }
    }

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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	auto prev = 2ull;
	auto result = 1ull;
	for (auto i = 2; i <= N; ++i)
	{
		auto temp = prev;
		prev = result;
		result = result + temp;
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while (true)
    {
        c-=b;
        if(c<=0) 
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0) 
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>>data(n);
  vector<int>p(m);
  vector<int>y(m);
  rep(i,m){
    cin >> p[i] >> y[i];
    p[i]--;
  }
  rep(i,m) data[p[i]].push_back(y[i]);
  rep(i,n) sort(data[i].begin(),data[i].end());
  rep(i,m){
    printf("%06d",p[i]+1);
    int id = lower_bound(data[p[i]].begin(),data[p[i]].end(),y[i])-data[p[i]].begin();
    printf("%06d\n",id+1);
  }
}

Measured memory_bytes: 7808
import math
H,W = list(map(int,input().split(" ")))
mas = []
for _ in range(H):
    temp = input()
    if temp == "."*W :
        temp = "-" * W
    mas.append(list(temp))
for w in range(W):
    flag = True
    for h in range(H):
        if mas[h][w]  == "#":
            flag = False
            break
    if flag:
        for h in range(H):
            mas[h][w] = "-"

for h in range(H):
    flag = False
    for w in range(W):
         if mas[h][w] != "-":
            print(mas[h][w],end="")
            flag = True
    if flag:
        print()


Measured memory_bytes: 4468
#include<stdio.h>
#include<string.h>
char ns[5];
char *f(int n){
  int i,j;
  char c[5];
  for(i=0;n;i++){
    c[i]=n%10+'0';
    n/=10;
  }
  for(j=0;j<i;j++)ns[j]=c[i-j-1];
  ns[j]=0;
  return ns;
}
int main(){
  int n,c,i,j;
  char s[300000];
  while(scanf("%d",&n),n){
    scanf("%s",s);
    while(n--){
      char sn[300000]={0};
      for(i=c=0;s[i];i++){
	if(s[i]-s[i+1]){
	  strcat(sn,f(c+1));
	  strncat(sn,&s[i],1);
	  //printf("%s\n",sn);
	  c=0;
	}
	else c++;
      }
      strcpy(s,sn);
      // printf("%s\n",s);
    }
    printf("%s\n",s);
  }
  return 0;
}

Measured memory_bytes: 940
#include <stdio.h>  
int main(void) 
{
    int i, j, n, m, a[100][100], b[100], c[100] = {0};
     
    scanf("%d %d", &n, &m); 
     
    for (i=0; i<n; i++) 
    {
        for (j=0; j<m; j++)
        {     
            scanf("%d", &a[i][j]);
        }    
    }
     
    for (i=0; i<m; i++) 
    { 
        scanf("%d", &b[i]); 
    }
     
    for (i=0; i<n; i++) 
    {
        for (j=0; j<m; j++)
        {
            c[i] += a[i][j] * b[j];
        }
    }
     
    for (i=0; i<n; i++)
    {
        printf("%d\n", c[i]);   
    }
    return 0; 
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

ll D = 365;
vec c(26);
mat s(D, vec(26));
vec last(26, 0);


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

    cin >> D;
    Rep (i, 26) {
        cin >> c[i];
    }
    Rep (i, D) {
        Rep (j, 26) {
            cin >> s[i][j];
        }
    }

    ll tmp = 0;
    Rep (i, D) {
        ll ans = 0;
        ll best = -inf;
        Rep (j, 26) {
            ll score = 0;
            score += s[i][j];
            Rep (k, 26) {
                if (k != j) score -= c[k] * (i+1-last[k]);   
            }
            if (score > best) {
                ans = j;
                best = score;
            }
        }

        last[ans] = i+1;
        tmp += s[i][ans];
        Rep (j, 26) {
            tmp -= c[j] * (i+1-last[j]);
        }

        cout << ans+1 << endl;
    }
}

Measured memory_bytes: 3744
#include<iostream>
using namespace std;
int main(){

  long long X;
  long long K;
  long long D;

  cin>>X>>K>>D;
  if(X<0){
    X*=-1;
  }
  long long mindistance=X%D;
  if(mindistance<0){
  if(mindistance*-1>mindistance+D){
    mindistance+=D; 
  }
    else mindistance*=-1;
  }
  long long needmove=X/D;
  //cout<<mindistance<<endl<<needmove<<endl;
  if(needmove<=K){
  
    if((K-needmove)%2==0){
    
      cout<<mindistance;
    }
    else{
      if(mindistance+D<(mindistance-D)*-1){
        
        cout<<mindistance+D;
      }
      else{
      
        cout<<(mindistance-D)*-1;
      }
    }
  }
  else{
  
    cout<<X-D*K;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define debug2(a, b) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<endl
#define debug3(a, b, c) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<endl
#define debug4(a, b, c, d) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<" | "<<#d<<" = "<<d<<endl
#define debug5(a, b, c, d, e) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<" | "<<#d<<" = "<<d<<" | "<<#e<<" = "<<e<<endl
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll N = 100000 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
unordered_set<string> occured;
int main() {
	int n, X;
	scanf("%d %d", &n, &X);	
	int x[n+1];
	x[0] = X;
	for(int i=1; i<=n; ++i) scanf("%d", &x[i]);
	sort(x, x+n+1);
	int diff[n];
	for(int i=0; i<n; ++i)
		diff[i] = x[i+1]-x[i];
	int g = diff[0];
	for(int i=1; i<n; ++i) {
		g = __gcd(g, diff[i]);
	}
	printf("%d\n", g);
}


Measured memory_bytes: 1024