akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong();
			long m = scanner.nextLong();
			if (1L == n) {
				if (1L == m) {
					System.out.println("1");
				} else {
					System.out.println(m - 2);
				}
			} else {
				if (1L == m) {
					System.out.println(n - 2);
				} else {
					System.out.println((n - 2) * (m - 2));
				}
			}
		}
	}
}


Measured memory_bytes: 23892
#include<iostream>
#include<string>

using namespace std;

int main(){
    //string s;
    //cin >> s;
    //int num = stoi(s);
    int num;
    cin >> num;
    
    int f = num/100;
    int b = num%100;

    //cout << "num " << num << "f " << f << "b " << b << endl;   

    if(0<f && f<13){
        if(0<b && b<13)  cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
       
    }
    else{
        if(0<b && b<13) cout << "YYMM" << endl;
        else  cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const  int maxn = 10005;
int a[maxn];
int s(int k)
{
	int ans=0;
	if(k%2==1) return 0;
	while(k%2==0)
	{
		ans++;k/=2;
	}
	return ans;
	
	
}
int main()
{
	int n,j;
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>j;
		ans+=s(j);
	}
	cout<<ans;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, H;
    cin >> N >> H;
    vector<P> v(N);
    int mx = 0;
    for(int i = 0; i < N; ++i) {
        cin >> v[i].S >> v[i].F;
        mx = max(mx, v[i].S);

    }
    sort(all(v), greater<P>());

    vector<P> use;
    LL res = 0;
    for(int i = 0; i < N; ++i) {
        if(v[i].F < mx) continue;
        H -= v[i].F;
        ++res;
        if(H <= 0) {
            cout << res << endl;
            return 0;

        }
    }

    res += H / mx;
    if(H % mx != 0) ++res;
    cout << res << endl;

    return 0;
}



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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> sum(n + 1);
    map<ll, ll> cnt;
    cnt[0] += 1;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
        cnt[sum[i + 1]] += 1;
    }
    ll ans = 0;
    for(auto& p : cnt) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15104
#include <cstdio>

using namespace std;

const int Nmax = 505;

char a[Nmax][Nmax], b[Nmax][Nmax];
int n, m, i, j;

int main()
{
   
    scanf("%d %d\n", &n, &m);
    for(i=1; i<=n; ++i) scanf("%s\n", a[i]+1);

    for(i=1; i<=n; ++i)
    for(j=1; j<=m; ++j)
    if(a[i][j]=='#') b[i][j] = '#';
    else b[i][j] = '.';

    for(i=1; i<=m; ++i)
    {
        a[1][i] = b[n][i] = '#';

        if(i&1) for(j=2; j<n; ++j) a[j][i] = '#';
        else for(j=2; j<n; ++j) b[j][i] = '#';
    }

    for(i=1; i<=n; ++i) printf("%s\n", a[i]+1);
    printf("\n");
    for(i=1; i<=n; ++i) printf("%s\n", b[i]+1);

    return 0;
}


Measured memory_bytes: 1152
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //CASH MONEY --> Collections.sort()>>>>>Arrays.sort()
 
	public static void main(String[] args) { //Ball out dawg
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			a[i] = I.nextInt();
			sum+=a[i];	
		}
		if (sum%10==0) {
			Arrays.sort(a);
			for (int i = 0; i < N; i++) {
				if (a[i]%10!=0) {
					sum-=a[i];
					break;
				}
			}
			if (sum%10==0) sum=0;
		}
		O.pln(sum);
	}
	public static int MEX(int N,int[] cnts) {
		for (int test = 0; test <=N; test++) if (cnts[test]==0) return test;
		return -1;
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25720
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
double hh(vector<double> x,vector<double> y,vector<int> ff,int i){
  double dx=x[ff[i]-1]-x[ff[i+1]-1];
  double dy=y[ff[i]-1]-y[ff[i+1]-1];
  return sqrt(dx*dx+dy*dy);
}

int main(){
  int n;
  cin>>n;
  vector<double> x(n);
  vector<double> y(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  vector<int> ff(n);
  for(int i=1;i<=n;i++){
    ff[i-1]=i;
  }
  double ans=0;
  do{
        for(int i=0;i<n-1;i++){
        ans+=hh(x,y,ff,i);
        }
    }while(next_permutation(ff.begin(),ff.end()));
  cout<<fixed << setprecision(10);
  double t=1;
  for(int i=1;i<=n;i++){
    t*=i;
  }
  cout<<ans/t<<endl;
}
    
  


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

#define PI 3.141592653589793238462

int main()
{
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double digA = 30*(H + M/60.0) , digB = 6*M;
  double interdig = abs(digA - digB);
  interdig = min(interdig, 360 - interdig);
  double ans = A*A + B*B - 2*A*B*cos(PI*interdig/180.0);
  ans = sqrt(ans);
  cout << fixed;
  cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 4188
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INARR(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

	struct BellmanFord // compute shortest paths from 1 source to every vertices, negative weight - tolerant
	{
		// NOTE:
		//		vertices are ZERO-indexed
		//		DIRECTIONAL graph
		int n, m;
		ll *dist;
		int starter;
		pair< pair<int, int>, int> *edges;
		int cnt_edge;
		ll INF;
		bool computed;
		
		void init(int n_, int m_, int starter_) {
			n = n_;
			m = m_;
			starter = starter_;
			computed = 0;
			
			INF = 1; INF = INF * oo * oo;
			
			dist = new ll [n+1];
					
			for (int i = 0; i <= n; ++i) {
					
				if (i == starter)
					dist[i] = 0;
				else
					dist[i] = INF;
			}
			
			edges = new pair< pair<int, int>, int> [m];
			cnt_edge = 0;
		}
		
		void addEdge(int u, int v, int w) {
			edges[cnt_edge++] = make_pair(make_pair(u, v), w);
		}
		
		void computeShortestPaths() {
			int u, v, w;
			
			// compute shortest paths
			for (int i = 1; i < n; ++i) {
				for (int j = 0; j < cnt_edge; ++j) {
					u = edges[j].first.first;
					v = edges[j].first.second;
					w = edges[j].second;
					if (dist[u] != INF && dist[v] > dist[u] + w)
						dist[v] = dist[u] + w;
				}
			}
			
			// detect negative cycle
			for (int i = 1; i < n; ++i) {
				for (int j = 0; j < cnt_edge; ++j) {
					u = edges[j].first.first;
					v = edges[j].first.second;
					w = edges[j].second;
					
					if (dist[u] != INF && dist[v] != -INF && dist[v] > dist[u] + w)
						dist[v] = -INF;
				}
			}
		}
		
		ll distanceTo(int v) {
			if (!computed) {
				computeShortestPaths();
				computed = 1;
			}
			
			return dist[v];
		}
		
	};

int n, m, p;
BellmanFord bell;

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n >> m >> p;
	bell.init(n, m, 1);
	
	FOR(i, 1, m) {
		cin >> x >> y >> w;
		w -= p;
		
		bell.addEdge(x, y, -w);
	}
	
}


void preprocess() {
	
	bell.computeShortestPaths();
	
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	ll res = bell.distanceTo(n);
	
	if (res < -oo) {
		cout << -1 << endl;
	}
	else {
		cout << max(0ll, -res) << endl;
	}
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 384
function main()
	N=parse(Int,readline())
	As=map(x->parse(Int,x),split(readline()))
	A=As[1]
	B=As[2]
	S=0
	for i=3:N
		S=xor(S,As[i])
	end
	if A+B<S||(A+B-S)%2==1
		println(-1)
		exit()
	end
	D=div(A+B-S,2)
	if D>A||(D&S)!=0
		println(-1)
		exit()
	end
	a=D
	for i=40:-1:0
		if (S>>i)%2==1&&(a+(1<<i))<=A
			a+=1<<i
		end
	end
	println(a==0 ? -1 : A-a)
end
main()


Measured memory_bytes: 167820
n,k=map(int,input().split())
pl=list(map(int,input().split()))

cuml=[]
cum=0
for i in range(n):
    cum+=(pl[i]+1)/2
    cuml.append(cum)
mx=0
#cumsum
for i in range(n-(k-1)):
    if i==0:
        mx=max(cuml[i+k-1],mx)
    else:
        mx=max(cuml[i+k-1]-cuml[i-1],mx)
print('{:.9f}'.format(mx))



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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var S = Console.ReadLine().ToCharArray();
        var Q = int.Parse(Console.ReadLine());
        var count = 0;
        var ll = new LinkedList<char>();
        foreach (var c in S)
            ll.AddLast(c);

        for (var i = 0; i < Q; i++)
        {
            var l = Console.ReadLine().Split().ToArray();

            if (int.Parse(l[0]) == 1)
            {
                count ^= 1;
            }
            else
            {
                if (count == 0)
                {
                    if (int.Parse(l[1]) == 1)
                    {
                        ll.AddFirst(l[2][0]);
                    }
                    else
                    {
                        ll.AddLast(l[2][0]);
                    }
                }
                else
                {
                    if (int.Parse(l[1]) == 1)
                    {
                        ll.AddLast(l[2][0]);
                    }
                    else
                    {
                        ll.AddFirst(l[2][0]);
                    }
                }
            }
        }

        Console.WriteLine(count == 0 ? new string(ll.ToArray()) : string.Join("", (new string(ll.ToArray()).Reverse())));
    }
}


Measured memory_bytes: 36572
#include<iostream>
#include<algorithm>

using namespace std;

void Solution()
{
    int W, H, x, y , r;
    
    while(cin>>W>>H>>x>>y>>r)
    {
        if((y + r <= H && y + r >= 2 * r) && (x + r >= 2 * r && x + r <= W ))
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
}

int main()
{
    Solution();
}

Measured memory_bytes: 1156
#!/usr/bin/env python3

n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]


for x in range(0, 101):
    for y in range(0, 101):
        H_less = 10**10
        H = -1
        flag = 0
        for x_, y_, h_ in xyh:
            if h_ == 0:
                H_less = min(abs(x_-x)+abs(y_-y), H_less)
            else:
                h_tmp = h_ + abs(x_-x) + abs(y_-y)
                if H != -1:
                    if H != h_tmp:
                        flag = 1
                        break
                H = h_tmp
        if flag == 1:
            continue
        # print(H, H_less)
        if H > H_less:
            continue
        print(x, y, H)
        exit()


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


Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int a[200003];
int dp[(1 << 26) + 3];

int main() {
	string s; cin >> s;
	a[0] = 0;
	for (int i = 1; i <= (int)s.length(); i++) {
		a[i] = 1 << (s[i - 1] - 'a');
		a[i] ^= a[i - 1];
	}
	for (int i = 0; i < (1 << 26); i++) dp[i] = 1e9;
	dp[0] = 0;
	int ans;
	for (int i = 1; i <= (int)s.length(); i++) {
		int t = dp[a[i]] + 1;
		for (int j = 0; j < 26; j++) {
			t = min(t, dp[a[i] ^ (1 << j)] + 1);
		}
		dp[a[i]] = min(dp[a[i]], t);
		ans = t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 263556
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(b-1);i>=(a);i--)
#define all(V) V.begin(),V.end()
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a
typedef long long ll;
typedef pair<int ,int > pii;
typedef vector<int> vi;
//----

const int N=20;
const int mod=1e9+7;
pair<pii,pii> Max[1<<N];
int cmp(pii a,pii b)
{
	return a>b;
}
int main()
{
	int n;
	scanf("%d",&n);
	rep(i,0,1<<n)scanf("%d",&Max[i].fi.fi),Max[i].fi.se=i;
	int Ans=0;
	rep(i,1,1<<n)
	{
		rep(j,0,n)if((i>>j)&1)
		{
			vector<pii> V;
			V.pb(Max[i].fi);
			V.pb(Max[i].se);
			V.pb(Max[i^(1<<j)].fi);
			V.pb(Max[i^(1<<j)].se);
			sort(all(V),cmp);
			V.erase(unique(all(V)),V.end());
			Max[i].fi=V[0],Max[i].se=V[1];
		}
		Ans=max(Ans,Max[i].fi.fi+Max[i].se.fi);
		cout<<Ans<<endl;
	}	
	return 0;	
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 100;

int a[MAX_N];

int main(void){
	for(int i = 0; i <= MAX_N; i++){
		a[i] = 0;
	}

	int input;
	while(scanf("%d", &input) != EOF){
		a[input]++;
	}

	int max_a = 0;
	for(int i = 0; i < MAX_N; i++){
		if(a[i] > max_a) max_a = a[i];
	}
	for(int i = 0; i < MAX_N; i++){
		if(a[i] == max_a) printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 3192
H, W = list(map(int, input().split(' ')))

if H ==1 or W ==1:
    print(1)
elif H%2 == 0 and W%2 ==0:
    print(int(H * W / 2))
elif H%2 == 1 and W%2 == 1:
    print(int(H*W //2 + 1))
else:
    print(int(H*W/2))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    private static int[] fact;

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

        int N = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(solve(N, a, b));
    }

    private static long solve(int N, int a, int b) {
        long sum = power(2, N, MOD) - 1;

        sum = mod(sum - combination(N, a, MOD), MOD);
        sum = mod(sum - combination(N, b, MOD), MOD);

        return mod(sum, MOD);
    }

    public static long power(long base, long t, long p) {
        long ans = 1;

        while (t > 0) {
            if (t % 2 == 1) {
                ans = ans * base % p;
            }

            t /= 2;
            base = base * base % p;
        }

        return ans;
    }

    public static long combination(int n, int r, int p) {
        if (n == 0 && r == 0) return 1;
        if (n < r || n < 0)   return 0;

        long sum = 1;
        for (int i=1; i<=r; i++) {
            sum = mod(sum * (n-i+1), p);
            sum *= modInv(i, p);
            sum = mod(sum, p);

        }

        return sum%MOD;
    }

    public static int modInv(long a, int p) {
        long b = p;
        long u = 1;
        long v = 0;
        while (b > 0) {
            long t = a/b;
            a -= t*b;
            u -= t*v;

            long tmp;
            tmp = a;
            a = b;
            b = tmp;

            tmp = u;
            u = v;
            v = tmp;
        }

        u %= p;
        if (u < 0) u+= p;

        return (int)u;
    }

    public static long mod(long a, long p) {
        return (a%p + p) % p;
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;
inline int read()
{
	char x = getchar();
	int lin = 0, f = 1;
	while(x < '0' || x > '9')
	{
		if(x == '-') f = -1;
		x = getchar();
	}
    while(x >= '0' && x <= '9')
	{
		lin = lin * 10 + x - '0';
		x = getchar();
	}
	return lin * f;
}
#define PII pair<int,int>
#define fir first
#define sec second
#define ma(a,b) make_pair(a,b)
#define inf 123123123
int n,t,ans = inf,a,b;
signed main(){
	n = read(); t = read();
	for(int i = 1; i <= n; i++)
	{
		a = read(); b = read();
		if(b <= t)
			ans = min(ans,a);
	}
	if(ans == inf) cout << "TLE";
	else cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>num1,num2;
ll num0=0,k;
ll check(ll x){
	if(x>0){
		ll res=0;
		for (int i=0;i<num1.size();i++){
			res+=upper_bound(num1.begin(),num1.end(),x/num1[i])-num1.begin();
			if (num1[i]*num1[i]<=x) res--; 
		}
		for (int i=0;i<num2.size();i++){
			res+=upper_bound(num2.begin(),num2.end(),x/num2[i])-num2.begin();
			if (num2[i]*num2[i]<=x) res--; 
		}
		return res/2;
	}
	if (x<0){
		x*=-1;
		ll res=0;
		for (int i=0;i<num1.size();i++){
			res+=num2.size()-(lower_bound(num2.begin(),num2.end(),(x+num1[i]-1)/num1[i])-num2.begin());
		}
		return res;
	}
}
int main(){
	ll n;cin>>n>>k;
	for (ll i=0;i<n;i++){
		ll x;cin>>x;
		if (x<0) num1.push_back(-x);
		if (x>0) num2.push_back(x);
		if (x==0) num0++; 
	}
	sort (num1.begin(),num1.end());
	sort (num2.begin(),num2.end());
	ll l=-1e18-1,r=1e18+1,n1=num1.size(),n2=num2.size();
	ll nn0=num0*(n1+n2)+num0*(num0-1)/2,nn1=n2*n1,nn2=n2*(n2-1)/2+n1*(n1-1)/2;
	if (nn1>=k){
		r=0;
		while (r>l+1){
			ll mid=(l+r)/2;
			if (check(mid)<k) l=mid;
			else r=mid;
		}
		cout<<r<<"\n";
	}
	else if (nn1+nn0>=k){
		puts("0");return 0;
	}else{
		k-=nn1+nn0;
		l=0;
		while (r>l+1){
			ll mid=(l+r)/2;
			if (check(mid)<k) l=mid;
			else r=mid;
		}
		cout<<r<<"\n";
	}
}

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

using namespace std;

int a[200001];
int sum[400001];
int n;
int mx;
const int N = 400000;
int main( ) {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
		sum[a[i]] ++;
		sum[a[i] + 3] --;
	}
	for (int i = 1; i <= N; i ++) {
		sum[i] += sum[i - 1];
		if (sum[i] > mx) mx = sum[i];
	}
	printf("%d\n", mx);
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
#define PI 3.1415926535

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;}

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 1000000000000000000;

//input
ll A,B;

//processing


//dpTable
int dp[100050];

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string s;
  cin >> s;
  string month = s.substr(5, 2);
  if (stoi(month) <= 4) P("Heisei");
  else P("TBD");

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a,b; cin >> a >> b;
  if(a < b){
    REP(i,b)
      cout << a;
  }
  else{
    REP(i,a)
      cout << b;
  }
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;
int main(){
    string s;
    cin >> s;
    if(s.size() %2 != 0){
        cout << "No" << endl;
        return 0;
    }
    string an = ""; 
    for(int i = 0; i < s.size(); i++){
        if(i%2 == 0) an += "h";
        else an += "i";
    }
    if(s == an) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3576
n,m = map(int,input().split())
l = []
i = 2
if m == 1 or n == 1:
    print(1)
    exit()
while m != 1:
    if m%i == 0:
        l.append(0)
        while m%i == 0:
            l[-1] += 1
            m //= i
    i += 1

mod = 10**9+7 
fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+max(l)+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

ans = 1

for i in l:
    ans *= nCr(n+i-1,n-1,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 57968
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int result = 0;
    for (int i = 0; i < N; i++) {
      int l = sc.nextInt();
      int r = sc.nextInt();
      result += (r - l + 1);
    }
    System.out.println(result);
  }
}

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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    string S;
    cin >> S;

    int price = 700;

    if(S[0] == 'o') price += 100;
    if(S[1] == 'o') price += 100;
    if(S[2] == 'o') price += 100;

    cout << price << endl;
    
    return 0;
}

/*****************************************************************************/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n+1);
    for(int i=1;i<=n;i++)
        cin>>v[i];
    int test=0;
    int i=1;
    while(i<=n)
    {
        if(i==v[i])
        {
            test++;
            if(i+1<=n)
                swap(v[i],v[i+1]);
        }
        i++;
    }
    cout<<test<<endl;
    
    
    
    return 0;   
}




 
 


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

Minkowski's distance (ミンコフスキー距離)は以下のように表される
D_{xy} = { \sum_{i-1}^{n} |x_i - y_i|^{p} }^{1/p}

*/

/*
p=1のときマンハッタン距離
p=2のときユークリッド距離
p=∞のときチェビチェフ距離
を表す
*/

//問題http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_D&lang=jp

using namespace std;
int n;
double x[100],y[100];
double distance(double p){
    double ans = 0;
    for(int i = 0; i < n; i++){
        double w = abs(x[i]-y[i]);
        ans += pow(w,p);
    }
    return pow(ans, 1.0/p);
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < n; i++){
        cin >> y[i];
    }
    cout << fixed << setprecision(10);
    cout << distance(1) << endl;
    cout << distance(2) << endl;
    cout << distance(3) << endl;

    double mx = 0;
    for(int i = 0; i < n; i++){
        mx = max(abs(x[i]-y[i]), mx);
    }
    cout << mx << endl;
}


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

int main(){
    int A;
    int B;
    cin >> A;
    cin >> B;

    int result;

    if (A > 12){
        result = B;
    }else if(6 <= A && A <= 12){
        result = B/2;
    }else{
        result = 0;
    }

    cout << result << "\n";

}

Measured memory_bytes: 256
def next_num prev_num
  if prev_num.empty?
    @love_num[0]
  else
    next_digit = @love_num.next prev_num[-1]
    if next_digit
      prev_num[-1] = next_digit
      prev_num
    else
      move_up prev_num, 1
    end
  end
end

def move_up num, digit
  # digitが何桁目とaryのindexとは逆なため
  num.reverse!
  num[digit - 1] = @love_num[0]
  next_digit = @love_num.next num[digit]
  if next_digit
    num[digit] = next_digit
    num.reverse!
  elsif digit == num.size
    if @love_num[0] == "0"
      @love_num[1] + @love_num[0] * num.size
    else
      @love_num[0] * (num.size + 1)
    end
  else
    move_up num.reverse!, digit + 1
  end
end

class Array
  def next factor
    # [前提]
    # selfの配列内の要素がすべて互いにuniqである
    # sort済
    return unless factor
    self.find{|i| i > factor}
  end
end

ALL_NUM = ("0".."9").to_a
n, _k = gets.chomp.split
hate_num = gets.chomp.split
@love_num = (ALL_NUM - hate_num).sort

if (n.chars.uniq - @love_num).empty?
  puts n
else
  until (n.chars.uniq - @love_num).empty? do
    num = next_num(n)
  end
  puts num
end



Measured memory_bytes: 14248
slct='D'

# C
if slct=='C':
    N,M=map(int,input().split())
    cnd=[tuple(int(i) for i in input().split()) for j in range(M)]
    ans=-1
    for n in range(10**N):
        # print(n)
        flag=True
        n_str=str(n)
        if len(n_str)!= N:
            continue
        for s,c in cnd:
            if n_str[s-1]!=str(c):
                # print(n_str[s-1],c)
                flag=False
                break
        if flag:
            ans=n
            break
    print(ans)

# D
elif slct=='D':
    N,M,K=map(int,input().split())
    
    par=[-1 for _ in range(N)]
    # 負なら根でabsがその根の属する木のサイズ
    # 正ならその値が親

    def root(n):
        if par[n]<0:
            return n
        else:
            par[n]=root(par[n]) # 親の根に繋ぎなおす
            return par[n]
    
    def unite(m,n):
        x=root(m)
        y=root(n)
        if x==y: # 同じ木にいる
            return
        if par[x]>par[y]: # yのサイズの方が大きい:swap
            x,y=y,x 
        par[x]+=par[y] # サイズの大きいxにくっつける: サイズを記録
        par[y]=x 

    def issame(m,n):
        return root(m)==root(n)
    
    def size(n): # nの属する木のsizeを取得
        return -par[root(n)]
    
    # iの求めたい値 = size(i) -直接の友達関係の数 -iの木上でブロック関係にある数 -1
    # 直接の友達関係ならお互いに同じ木にいる
    ans=[-1 for _ in range(N)] # 自分の分: -1
    
    for _ in range(M): #木達の構築
        A,B=map(int,input().split())
        unite(A-1,B-1)
        # 直接の友達関係を引く
        ans[A-1]-=1
        ans[B-1]-=1
    for _ in range(K): # ブロック関係にあるかどうか
        C,D=map(int,input().split())
        #同じ木でなければ答えに関係ない,同じ木にいるなら引く
        if issame(C-1,D-1):
            ans[C-1]-=1
            ans[D-1]-=1
    for i in range(N): 
        print(ans[i]+size(i))

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void){
  string s;
  cin >> s;
  int len = s.length();
  if(s[len-1] == 's'){
    s += "es";
  }
  else{
    s += "s";
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3528
n=int(input())
rem=10**10
S=0
allissame=0
for i in range(n):
  a,b=map(int,input().split())
  S+=a
  if a<b:
    allissame|=1
    continue
  elif a>b:
    if rem > b:
      rem=b
    allissame|=1
  else:pass
if not allissame:
  print(0)
else:
  print(S-rem)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 100005;

int c1, c2, c3;
string s;

void no(bool p){
	if(p){
		puts("NO");
		exit(0);
	}
}
int main(){
	cin >> s;
	for(auto &i : s){
		if(i == 'a') c1++;
		if(i == 'b') c2++;
		if(i == 'c') c3++;
	}
	if(s.size() % 3 == 0){
		no(c1 != c2 || c2 != c3 || c3 != c1);
	}
	if(s.size() % 3 == 1){
		no(max({c1, c2, c3}) - min({c1, c2, c3}) > 1);
	}
	if(s.size() % 3 == 2){
		no(max({c1, c2, c3}) - min({c1, c2, c3}) > 1);
	}
	cout << "YES" << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(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;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];
ll d[101];


//long longしか使わない
//素数は1より大きい
int main() {
	rep(i, 5) {
		cin >> d[i];
		if (d[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] Az = new int[N];
        for (int i = 0; i < N; i++){
            Az[i] = sc.nextInt() - 1;
        }
        int[] order = new int[N];
        for (int i = 0; i < N; i++){
            order[Az[i]] = i;
        }

        for (int i = 0; i < N; i++){
            System.out.print((order[i]+1)+" ");
        }
        System.out.println();


    }
}

Measured memory_bytes: 62008
#include <bits/stdc++.h>
#define ll long long
#define PI 2 * acos(0)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 200000
#define MOD 1e7
#define print(a, b) printf("Case %d: %.0f\n", a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
/*................OMI.................*/

bool isPrime(ll n)
{
   if (n <= 1)
      return false;
   if (n <= 3)
      return true;

   if (n % 2 == 0 || n % 3 == 0)
      return false;

   for (ll i = 5; i * i <= n; i = i + 2)
      if (n % i == 0)
         return false;

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

ll lcm(ll a, ll b)
{
   ll g = gcd(a, b);
   ll ans = (a * b) / g;
   return ans;
}

///palindrome check!
bool palindrome(string s)
{
   for (ll i = 0; i < s.length() / 2; i++)
   {
      if (s[i] != s[s.length() - i - 1])
         return 0;
   }
   return 1;
}
/// divisors->>
void printDivisors(int n)
{
   for (int i = 1; i <= sqrt(n); i++)
   {
      if (n % i == 0)
      {
         if (n / i == i)
            printf("%d ", i);

         else
            printf("%d %d ", i, n / i);
      }
   }
}

///prime storage>>>

vector<ll> prime;

void primes(ll m)
{

   bool isprime[m];
   for (int i = 0; i <= m; i++)
      isprime[i] = true;

   for (int i = 3; i * i <= m; i++)
   {
      if (isprime[i])
      {

         for (int j = i * i; j <= m; j += i)
            isprime[j] = false;
      }
   }
   prime.push_back(2);
   for (int i = 3; i <= m; i += 2)
      if (isprime[i])
         prime.push_back(i);
}

/************MAIN_FUNCTION***********/

int main(int argc, char *argv[])
{
   FAST;

   ll a, b, c, d;
   cin >> a >> b >> c >> d;
   int res = (a - 1) / d;
   int res2 = (c - 1) / b;

   if (res >= res2)
      cout << "Yes" << endl;
   else 
      cout << "No" << endl;
   return 0;
}

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

char ma[105][105];
int vis[105][105];
int ans;int w,h;

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

void dfs(int x,int y,char ch)
{
    if(vis[x][y]) return ;
    vis[x][y]=1;
    for(int i=0;i<4;i++)
    {
        int xx=x+dx[i];
        int yy=y+dy[i];
        if(xx>=0&&xx<w&&yy>=0&&yy<h&&ma[xx][yy]==ch)
        dfs(xx,yy,ma[xx][yy]);
    }
}


int main()
{

    while(scanf("%d%d",&w,&h)&&w!=0)
    {
        memset(vis,0,sizeof(vis));
        ans=0;
        for(int i=0;i<w;i++)
            scanf("%s",&ma[i]);

        for(int i=0;i<w;i++)
        {
            for(int j=0;j<h;j++)
            {
                if(vis[i][j])continue;
                dfs(i,j,ma[i][j]);ans++;
            }


        }
        printf("%d\n",ans);

    }
}

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

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back



using namespace std;
using namespace std::chrono;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };



void solve() {

    string s;
    cin>>s;
    int n=s.length();
    if(s[s.length()-1]=='s') cout<<s<<"es"<<endl;
    else cout<<s<<'s'<<endl;
    
}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

        
        solve();


    return 0;
}

Measured memory_bytes: 3624
using System.Linq;
using static System.Console;

namespace ConsoleApp30
{
    class FootPrint
    {
        public bool Visit { get; set; }
        public long Time { get; set; }

        public FootPrint(long t)
        {
            Visit = true;
            Time = t;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var buff = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long N = buff[0];
            long K = buff[1];

            var teleport = ReadLine().Split(' ').Select(long.Parse).ToArray();

            long position = 1;
            long count = 0;
            var footprints = new FootPrint[N];
            footprints[0] = new FootPrint(0);

            for(long i = K - 1; i >= 0; i--)
            {
                position = teleport[position - 1];
                count++;
                if (footprints[position - 1] != null)
                {
                    i %= (count - footprints[position - 1].Time);
                }
                else
                {
                    footprints[position - 1] = new FootPrint(count);
                }
            }

            WriteLine(position);
        }
    }
}


Measured memory_bytes: 50136
#include <cassert>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<LL, LL> PII;

#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); puts("");}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v;}
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) {cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}

#define all(x)  (x).begin(),(x).end()
#define tr(c, it)   for(auto it=c.begin(); it!=c.end(); it++)
#define clr(a, b)   memset(a, b, sizeof(a))
#define forn(i, n)   for(int i=0; i<n; i++)

const double eps = 1e-5;
const int INF = 0x3f3f3f3f;

const int N = 100010;
int n, a, b;
int x[N];


int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif

    while(~scanf("%d%d%d",&n,&a,&b))
    {
        for(int i=1; i<=n; i++)
            scanf("%d",&x[i]);

        LL ans = 0;
        int pos = x[1];
        for(int i=2; i<=n; i++)
        {
            LL v1 = 1ll * (x[i] - pos) * a;
            LL v2 = b;
            ans += min(v1, v2);
            pos = x[i];
        }
        cout << ans << endl;

    }
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println(H*W-(h*W+w*H-h*w));
    }   
}


Measured memory_bytes: 35676
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
vector<int> adj[100005];
bool vis1[100005],vis2[100005];
int l1[100005],l2[100005];
void dfs(int s,int d){
	vis1[s]=true;
	l1[s]=d;
	for(int i=0;i<(int)adj[s].size();++i){
		if(!vis1[adj[s][i]])
		dfs(adj[s][i],d+1);
	}
}
void dfs1(int s,int d){
	vis2[s]=true;
	l2[s]=d;
	for(int i=0;i<(int)adj[s].size();++i){
		if(!vis2[adj[s][i]])
		dfs1(adj[s][i],d+1);
	}
}
void q5(){
	int n;
	cin>>n;
	if(n<10 || n&1){
		cout<<"0\n";
		return ;
	}
	int ans=0;
	int num=10;
	int xp=num;
	while(num<=n){
		ans+=n/num;
		num*=5;
	}
	cout<<ans<<endl;
}
void q3(){
	int a,b;
	cin>>a>>b;
	int g=__gcd(a,b);
	a*=b;a/=g;
	cout<<a;
}
void q1(){
	int a,b;
	cin>>a>>b;
	cout<<6-a-b;
}
void q2(){
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;++i)
	cout<<s[i]<<t[i];
}
void q4(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;++i)
	cin>>arr[i];
	int idx=-1;
	int ans=0;
	for(int i=0;i<n;++i){
		if(arr[i]==1){
			idx=i;
			break;
		}
	}
	if(idx==-1){
		cout<<idx;
		return ;
	}
	ans+=idx-0;
	int num=2;
	int pre=idx;
	for(int i=idx;i<n;++i){
		if(arr[i]==num){
			num++;
			ans+=i-pre-1;
			pre=i;
		}
	}
	ans+=n-1-pre;
	cout<<ans;
}
void print(int arr[],int n){
	for(int i=0;i<n;++i)
	cout<<arr[i]<<" ";
	cout<<endl;
}
void solve(){
	int n,u,v;
	cin>>n>>u>>v;
	u--;v--;
	for(int i=1;i<n;++i){
		int a,b;
		cin>>a>>b;
		a--;b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(u,0);dfs1(v,0);
	int ans=-1;
	for(int i=0;i<n;++i)
	if(l2[i]>l1[i])
	ans=max(ans,l2[i]);
	cout<<ans-1;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;//cin>>t;
	t=1;
	while(t--)//
	solve();
	return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

int main()
{
    int a;
    cin >> a;
    bool yes = false;

    for (int i = 1; i < 10; i++) {
        if (a%i == 0 && a/i < 10) {
            yes = true;
            break;
        }
    }
    if (yes) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

bool is_prime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;    
    }    
    return n != 1;
} 

int main() {
    int x; cin >> x;
    while(1) {
        if (is_prime(x)) {
            cout << x << "\n";
            break;
        } else x++;
    }
}

Measured memory_bytes: 256
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vector<set<int>> tree(N);
	vi C;
	rp(i, 0, N-1){
		int p,c; cin>>p>>c; p--,c--;
		tree[p].insert(c); tree[c].insert(0);
		C.push_back(c);
	}

	int K = 0;
	vi p_color(N), visited(N);
	queue<int> q;
	q.push(0);
	visited[0] = true;
	while(!q.empty()){
		int p = q.front(); q.pop();
		K = max(K, (int)tree[p].size());
		int color = 1;
		for(auto c:tree[p]){
			if(visited[c]) continue;
			if(color == p_color[p]) color++;
			p_color[c] = color++;
			q.push(c);
			visited[c] = true;
		}
	}

	cout<< K <<endl;
	for(auto c:C) cout<< p_color[c] <<endl;
}

Measured memory_bytes: 15736
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

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

int cur,N;
string s;

int dig(){
	return s[cur++]-'0';
}

int num(){
	int n=dig();
	while(cur<s.size()&&isdigit(s[cur]))n=n*10+dig();
	return n;
}

char cha(){
	return s[cur++];
}

string str(){
	string st="";
	st+=cha();
	while(cur<s.size()&&isalpha(s[cur]))st+=cha();
	return st;
}

string gen(){
	string st="";
	while(cur<s.size()&&s[cur]!=')'&&st.size()<=N){
		if(isdigit(s[cur])){
			int n=num();
			if(s[cur]=='('){
				cur++;
				string st2=gen();
				cur++;
				rep(i,n){
					st+=st2;
					if(st.size()>N)break;
				}
			}
			else{
				char c=cha();
				rep(i,n){
					st+=c;
					if(st.size()>N)break;
				}
			}
		}
		else st+=str();
	}
	return st;
}

int main(){
	while(cin>>s>>N&&(s!="0"||N)){
		cur=0;
		string st=gen();
		if(st.size()<=N)cout<<0<<endl;
		else cout<<st[N]<<endl;
	}
}

Measured memory_bytes: 3684