akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

int main()
{
	string in;
	bool runner[3];
	int point,out,n;
	int i,j;

	scanf("%d",&n);

	for(i = 0; i < n; i++){
		out = 0;
		point = 0;
		for(j = 0; j < 3; j++){
			runner[j] = false;
		}

		while(out < 3){
			cin >> in;
			if(in == "HIT"){
				if(runner[2]){
					point++;
				}
				else if(runner[1]){
					runner[2] = true;
				}
				else if(runner[0]){
					runner[1] = true;
				}
				else{
					runner[0] = true;
				}
			}
			else if(in == "OUT"){
				out++;
			}
			else if(in == "HOMERUN"){
				for(j = 0; j < 3; j++){
					if(runner[j]){
						runner[j] = false;
						point++;
					}
				}
				point++;
			}
		}
		printf("%d\n",point);
	}

	return 0;
}

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

int main()
{
    int64_t n;
    cin>>n;
    vector<pair<int64_t,int64_t> >v1(100010,pair<int64_t,int64_t>(0,0));
    vector<pair<int64_t,int64_t> >v2(100010,pair<int64_t,int64_t>(0,0));
    for(int64_t i=1;i<100010;i++)
    {
        v1.at(i).second=i;
        v2.at(i).second=i;
    }

    for(int64_t i=1;i<=n;i++)
    {
        int64_t v;
        cin>>v;
        if(v<=0)continue;
        if(i%2==1)v1.at(v).first++;
        if(i%2==0)v2.at(v).first++;
    }
    
    sort(v1.begin(),v1.end());
    reverse(v1.begin(), v1.end());
    sort(v2.begin(),v2.end());
    reverse(v2.begin(), v2.end());

    int64_t sum=v1.at(0).first+v2.at(0).first;
    sum=n-sum;
    if(v1.at(0).second==v2.at(0).second)sum=n-max(v1.at(0).first+v2.at(1).first,v1.at(1).first+v2.at(0).first);
    cout<<sum<<endl;
}



Measured memory_bytes: 3328
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define inf (1LL<<60);
long long dp[3001][3001];
long long sum[3001][3001];
long long solve(vector<int> &v,int i,int j)
{
    if(i == j)
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    long long minCost = inf;
    for(int k = i;k < j;k++)
    {
        minCost = min(minCost,sum[i][j] + solve(v,i,k) + solve(v,k+1,j));
    }
    return dp[i][j] = minCost;
}

void preprocess(vector<int> &v,int n)
{
    for(int i = 1;i <= n;i++)
    {
        for(int j = i;j <= n;j++)
        {
            sum[i][j] = v[j] + ((j == i) ? 0:sum[i][j-1]);
        }
    }
}
int main() {
    int n;
    cin>>n;
    memset(dp,-1,sizeof dp);
    //memset(sum,0,sizeof sum);
    vector<int> v(n+1);
    for(int i = 1;i <= n;i++)
        cin>>v[i];
    //for(int i = 1;i <= n;i++)
        //cout<<v[i]<<" ";
    preprocess(v,n);
    cout<<solve(v,1,n);
    return 0;
}

Measured memory_bytes: 76168
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	int n;
  	cin>>n;
  	char a[n+5];
  	for(int i=0;i<n;i++)
      cin>>a[i];
  if(n%2==1)
    cout<<"No";
  else
  {
    int flag=0;
    for(int i=0;i<n/2;i++)
      if(a[i]!=a[i+n/2])
      {
        flag=1;
      }
    if(flag)
      cout<<"No";
    else
      cout<<"Yes";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define db              double
#define ll              long long
#define loop(i,e,n)      for(int i=e;i<=n;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
ll PowFun(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}
double phi = acos(-1);
using namespace std;



    int main()
    {
        string a,b;
         cin>>a>>b;
         int counter = 0;
         for(int i = 0; i < a.size(); i++)
         {
             if(a[i] != b[i]) counter++;
         }
         cout<<counter<<endl;
    }



Measured memory_bytes: 3916
fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: usize = rd.get();
    let k: usize = rd.get();
    let a: Vec<usize> = (0..n).map(|_| rd.get()).collect();

    let m = a.iter().max().unwrap() + 1;
    let mut seg = SegmentTree::new(m, 0, |a, b| std::cmp::max(a, b));
    for x in a {
        let l = if x >= k { x - k } else { 0 };
        let r = std::cmp::min(m, x + k + 1);
        let len = seg.fold(l..r) + 1;
        seg.update(x, std::cmp::max(seg.get(x), len));
    }
    println!("{}", seg.fold(0..m));
    // println!(
    // "{:?}",
    // (0..m).map(|i| seg.fold(i..(i + 1))).collect::<Vec<_>>()
    // );
}

struct SegmentTree<T, F> {
    n: usize,
    dat: Vec<T>,
    e: T,
    multiply: F,
}

impl<T, F> SegmentTree<T, F>
where
    T: Copy,
    F: Fn(T, T) -> T,
{
    fn new(n: usize, e: T, multiply: F) -> Self {
        let n = n.next_power_of_two();
        Self {
            n,
            dat: vec![e; n * 2 - 1],
            e,
            multiply,
        }
    }
    fn get(&self, i: usize) -> T {
        self.dat[i + self.n - 1]
    }
    fn update(&mut self, i: usize, x: T) {
        let mut k = i + self.n - 1;
        self.dat[k] = x;
        while k > 0 {
            k = (k - 1) / 2;
            self.dat[k] = (self.multiply)(self.dat[k * 2 + 1], self.dat[k * 2 + 2]);
        }
    }
    fn fold(&self, range: std::ops::Range<usize>) -> T {
        self._fold(&range, 0, 0..self.n)
    }
    fn _fold(
        &self,
        range: &std::ops::Range<usize>,
        i: usize,
        i_range: std::ops::Range<usize>,
    ) -> T {
        if range.end <= i_range.start || i_range.end <= range.start {
            return self.e;
        }
        if range.start <= i_range.start && i_range.end <= range.end {
            return self.dat[i];
        }
        let m = (i_range.start + i_range.end) / 2;
        (self.multiply)(
            self._fold(range, i * 2 + 1, i_range.start..m),
            self._fold(range, i * 2 + 2, m..i_range.end),
        )
    }
}

pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

Measured memory_bytes: 6824
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int N, K,cnt=0,j;
	scanf("%d %d", &N, &K);

	for (int f = 0; f < N-1; f++) {
		scanf("%d ", &j);
	}

	while (N > 0) {
		N = N - K;
		cnt++;
		if (N != 0) {
			N++;
		}
	}
	printf("%d\n", cnt);
}  
   

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

int main () {
  int N , H , W;
  cin >> N >> H >> W;
  int answer = 0;
  rep(i, N){
    int A , B;
    cin >> A >> B;
    if(A >= H && B >= W){
      answer++;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, k = li()
a = list(li())
MOD = 10**9 + 7

ans = 0
for i, ai in enumerate(a):
    for j, aj in enumerate(a):
        if ai > aj:
            if j < i:
                ans += ((k-1)*k // 2)
            else:
                ans += ((k+1)*k // 2)

            ans %= MOD


print(ans % MOD)

Measured memory_bytes: 3188
#include<iostream>

int main(){
	while(1){
		int n;
		std::cin >> n;
		if(n == 0)break;
		int a = 0, b = 0;
		for(int i = 0; i < n; ++i){
			int a1,b1;
			std::cin >> a1 >> b1;
			if(a1 > b1) a += a1 + b1;
			else if(a1 < b1) b += a1 + b1;
			else a += a1, b += b1;
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

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

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			int num, i = 1;
			do {
				num = Integer.parseInt(br.readLine());
				if (num == 0) {
					break;
				} else {
					System.out.println("Case " + i + ": " + num);
					i++;
				}
			} while (true);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 27084
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int n; cin>>n;
    ll ans =0;
    vector<int>l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int a=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
            ans+=a-(j+1);
        }
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static int N = 0;
    public static String output = "";

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        int length = String.valueOf( N ).length();
        if (length == 6) {
            output = Integer.toString(9 + 900 + 90000);
        }
        else if (length == 5) {
            output = Integer.toString(9 + 900 + (N - 9999));
        }
        else if (length == 4) {
            output = Integer.toString(9 + 900);
        }
        else if (length == 3) {
            output = Integer.toString(9 + (N - 99));
        }
        else if (length == 2) {
            output = Integer.toString(9);
        }
        else if (length == 1) {
            output = Integer.toString(N);
        }

        System.out.println(output);
    }
}

Measured memory_bytes: 23508
n,k = map(int, input().split())
al = list(map(int, input().split()))   

cnt = 0
cl = [-1]*(n+1)
cll = [1]
curr = 1
for i in range(min(n,k)):
    # print(curr)
    next_c = al[curr-1]
    if cl[next_c] != -1:
        # loop_start = (i+1)
        loop_start = cl[next_c]
        rem = k - (i+1)
        break
    else:
        cl[next_c] = i + 1
        cll.append(next_c)
    curr = next_c

else:
    print(curr)
    exit()

# print(rem)
loop_c = cll[loop_start:]
# print(loop_c)
last_ind = rem%len(loop_c)
ans = loop_c[last_ind]
print(ans)

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

int main(){
	int n;
	cin >> n;
	int counts = 0;
	int countsA = 0;
	for(int i = 1; i <= n; i++){
		counts = 0;
		if(i%2 == 0) continue;
		else{
			for(int j = 1; j <=n; j++){
			if(i%j == 0) counts++;
		}
		if(counts == 8) countsA++;
	}
	}
	cout << countsA << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define oo 1000000010
using namespace std;

int main()
{
    ll x;
    cin >> x;

    for(ll i=-1000; i<=1000; i++){
		for(ll j=-1000; j<=1000; j++){
			if(round(pow(i, 5)) - round(pow(j, 5)) == x){
				cout << i << ' ' << j;
				return 0;
			}
		}
    }

    return 0;
}


Measured memory_bytes: 4100
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()

print(3.141592653589793*2*N)

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

using namespace std;

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

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

    bool flags[n] = { false };

    for (int i = 0; i < n; i ++) {
        if (!flags[i] && !flags[arr[i] - 1] && arr[i] != i + 1) {
            int num = arr[i];
            int tmp = arr[num - 1];
            arr[num - 1] = num;
            arr[i] = tmp;
            flags[num - 1] = true;
            flags[i] = true;
            break;
        }
    }

    if (is_sorted(arr, arr + n) || n == 1 || n == 2)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int s,d,f,g,h,i,j;
	char a[10000];
	scanf("%s",a);
	s=strlen(a);
	for(i=0;i<s;i++){
		if(a[i]=='C'||a[i]=='B'||a[i]=='A')
			a[i]+=26;
		a[i]-=3;
	}
	printf("%s",a);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2664
#include<iostream>
#include<algorithm>
using namespace std;
long long a[1005],b[1005],c[1005],d[1000005],ans[3000005];
bool cmp(long long x,long long y){
	return x>y;
}
int main()
{
	int x,y,z,k,i,j,s;
	cin>>x>>y>>z>>k;
	for(i=1;i<=x;i++) cin>>a[i];
	for(i=1;i<=y;i++) cin>>b[i];
	for(i=1;i<=z;i++) cin>>c[i];
	
	int t=0;
	for(i=1;i<=x;i++)
		for(j=1;j<=y;j++){
			d[++t]=a[i]+b[j];
		}
	
	sort(d+1,d+t+1,cmp);
	
	s=0;
	for(i=1;i<=z;i++)
		for(j=1;j<=k;j++)
			ans[++s]=c[i]+d[j];
	
	sort(ans+1,ans+s+1,cmp);
	
	for(i=1;i<=k;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

int n;
string s;
set<string>st;

int main()
{
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 19160
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 5;
void solve(){
    int n, m;  cin>>n>>m;
    vi v(n+1,-1), dp(n+2,0);
    dp[0]=1;
    for(int i = 0; i < m; i++) cin>>v[i];
    int cur=0;
    for(int i = 0; i< n; i++){
        if(i==v[cur]){
            cur++;
            continue;
        }
        dp[i+1] = (dp[i+1]+dp[i])%1000000007;
        dp[i+2]=(dp[i+2] + dp[i])%1000000007;
    }
    //for(int it:dp) cout<<it<<" ";
    cout<<dp[n];

}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

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

using namespace std;

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

    for (int i = 0; i < static_cast<int>(s.size()); i++) {
        s[i] = ((s[i] - 'A' + n) % 26) + 'A';
    }

    cout << s << endl;
}


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

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

int main(){
    int A[3][3];
    int B[3][3];
    for(int i=0;i<3;i++){
     for(int j=0;j<3;j++){
         cin >> A[i][j];
         B[i][j] = 0;
     }
    }

    int N;
    cin >> N;
    for(int n=0;n<N;n++){
        int ni;
        cin >> ni;
            for(int i=0;i<3;i++){
             for(int j=0;j<3;j++){
                 if(A[i][j] == ni){
                    B[i][j] = 1;
                 }
             }
            }
    }

    int f_0x = 1;
    int f_1x = 1;
    int f_2x = 1;
    int f_x0 = 1;
    int f_x1 = 1;
    int f_x2 = 1;
    int f_z1 = 1;
    int f_z2 = 1;
    int i;


    for(i=0;i<3;i++){
        f_0x *= B[0][i];
        f_1x *= B[1][i];
        f_2x *= B[2][i];
        f_x0 *= B[i][0];
        f_x1 *= B[i][1];
        f_x2 *= B[i][2];
        f_z1 *= B[i][i];
        f_z2 *= B[2-i][i];
    }
    if(f_0x + f_1x + f_2x + f_x0 + f_x1 + f_x2 + f_z1 + f_z2 == 0){cout << "No" << endl;}
    else{cout << "Yes" << endl;}


    return 0;
}


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

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

  int n, h, w;
  cin >> n >> h >> w;

  cout << (n-h+1) * (n-w+1) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<string ,int> mp;
    for(int i = 0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }

    cout<<"AC"<<" "<<"x"<<" "<<mp["AC"]<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<mp["WA"]<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<mp["TLE"]<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<mp["RE"]<<endl;;
    return 0;
    

}

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

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  int x=0,y=0;
  for(int i=0;i<h;i++){
    cin>>s[i];
  }
  while(x<w&&y<h){
    if(x==w-1&&y==h-1) break;
    if(x==w-1){
      if(s[y+1].at(x)=='#'){
        if(s[y+1].at(x-1)=='#'){
          cout<<"Impossible"<<endl;
          return 0;
        }
        y++;
      }else{
        cout<<"Impossible"<<endl;
        return 0;
      }
    }else if(y==h-1){
      if(s[y].at(x+1)=='#'){
        if(s[y-1].at(x+1)=='#'){
          cout<<"Impossible"<<endl;
          return 0;
        }
        x++;
      }else{
        cout<<"Impossible"<<endl;
        return 0;
      }
    }
    else if(s[y].at(x+1)=='#'){
      if(y!=0){
        if(s[y-1].at(x+1)=='#'){
          cout<<"Impossible"<<endl;
          return 0;
        }
      }
      if(s[y+1].at(x)=='#'){
        cout<<"Impossible"<<endl;
        return 0;
      }else x++;
    }else if(s[y+1].at(x)=='#'){
      if(s[y].at(x+1)=='#'){
        cout<<"Impossible"<<endl;
        return 0;
      }else y++;
    }else{
      cout<<"Impossible"<<endl;
      return 0;
    }
  }
  if(s[h-1].at(w-1)=='#'){
    cout<<"Possible"<<endl;
  }else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


ll n;
vector<ll> g[2000005];
ll vis[2000005];
ll done[2000005];
ll in[2000005];
ll out[2000005];
void dfs(ll s)
{
        if(vis[s]) assert(false);
        vis[s]=1;
        for(auto &i : g[s]) {
                if(vis[i] == 0) dfs(i);
                else if(vis[i] == 1) {
                        cout << "-1\n"; exit(0);
                }
        }
        vis[s]=2;
}
ll maxm;
int main()
{
        cin >> n;
        for(ll i=1;i<=n;i++) {
                ll prv = -1;
                for(ll j=1;j<n;j++) {
                        ll x;
                        cin >> x;
                        ll yo = min(i,x);
                        ll mm = max(i,x);
                        yo = yo*(n+1) + mm;
                        maxm=max(maxm, yo);
                        if(prv != -1) {
                                g[prv].pb(yo);
                                in[yo]++;
                                out[prv]++;
                        }
                        prv = yo;
                }
        }
        for(ll i=1;i<= (n+1)*(n+1)+2;i++) {
                if(vis[i] == 0) {
                        dfs(i);
                }
        }
        priority_queue<ll> pq;
        for(ll i=1;i<=maxm;i++) {
                if(in[i] == 0 && out[i] == 0) continue;
                if(in[i] == 0) pq.push(i);
        }
        ll ans = 0;
        while(pq.empty()==false) {
                priority_queue<ll> nw;
                ans++;
                while(pq.empty() == false) {
                        ll xx = pq.top(); pq.pop();
                        done[xx]=1;
                        for(auto &i : g[xx]) {
                                in[i]--;
                                if(done[i] == 0 && in[i] == 0) nw.push(i);
                        }
                }
                pq=nw;
        }
        cout << ans << endl;
        return 0;
}


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

int getMax(int a,int b,int c){
  if(a>b){
    if(a>c)
      return 0;
    else
      return 2;
  }else{
    if(b>c)
      return 1;
    else
      return 2;
  }
}

int main(void){
  int x[3];
  cin >> x[0] >> x[1] >> x[2];
  int k;
  cin >> k;
  int sum = 0;
  for(int i=0;i<k;i++){
    x[getMax(x[0],x[1],x[2])] *= 2;
  }
  sum = x[0] + x[1] + x[2];
  cout << sum << endl;
  return 0;
}

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

int main(){
    int number;
    int boss[200010]={0},count[200010]={0};

    std::cin >> number;

    for(int i = 2; i <= number; i++){
        std::cin >> boss[i];
    }

    for(int i = 2; i <= number; i++){
        count[boss[i]]++;
    }
    
    for(int i = 1; i <= number; i++){
        std::cout << count[i] << endl;
    }
}

Measured memory_bytes: 5180
N = int(input())
X = list(map(int, input().split()))

p_max = max(X)
p_min = min(X)
ans = 0
ans_tmp = 0

for i in range(p_min, p_max):
    for j in range(len(X)):
        ans_tmp += (X[j] - i)**2
    if i == p_min:
        ans = ans_tmp
    elif ans_tmp < ans:
        ans = ans_tmp
    ans_tmp = 0

print(ans)

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

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

	//minimum cost to reach n th stone
	int dp[n+1];
	dp[0]=0;        //trivial case
  	dp[1]=0;        //base case

	//TIP:  last jump made is either 1 or 2.
	for(int i=2;i<=n;i++)
	{		
		dp[i] = min(dp[i-2]+abs(a[i-1]-a[(i-1)-2]), dp[i-1]+abs(a[i-1]-a[(i-1)-1]) );
	}
	cout << dp[n];
	
	return 0;
	
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    string str;
    cin>>str;

    int l=0,r=str.size()-1;
    int counter = 0;
    while(l<=r)
    {
        if(str[l]!=str[r])counter++;
        r--;
        l++;
    }
    cout<<counter<<endl;

    return 0;
}


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

int main() {
    ll N, K; cin >> N >> K;
    map<ll, ll> mp;
    for (int i = 0; i<N; i++) {
        ll a, b; cin >> a >> b;
        mp[a] += b;
    }
    
    for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
        K -= it->second;
        if (K <= 0) {
            cout << it->first << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4224
import numpy as np

a = np.reshape(np.array(list(map(int, input().split()))), (2, 2))


def rotation(x, t, deg = False):
    if deg == True:
        t = np.deg2rad(t)
    a = np.array([[np.cos(t), -np.sin(t)],
                  [np.sin(t),  np.cos(t)]])
    ax = np.dot(a, x)
    return ax


b = a[1] + rotation(a[1] - a[0], 90, deg=True)
c = b + rotation(b - a[1], 90, deg=True)
ans_list = np.hstack((b, c)).tolist()
ans = [round(i) for i in ans_list]

print(' '.join(map(str, ans)))

Measured memory_bytes: 12624
dict = Hash.new(0)

N = gets.to_i
N.times do
  input = gets.chomp
  dict[input] += 1
end

M = gets.to_i
M.times do
  input = gets.chomp
  dict[input] -= 1
end

ans = dict.to_a.sort_by {|i| i[1]}.last[1]
puts [ans, 0].max


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

public class Main {
	public static void main(String[] args)throws IOException{
		int h;
		int m;
		int s;
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		int inputValue = Integer.parseInt(br.readLine());

		if(inputValue >= 3600){
			h = inputValue/3600;
			inputValue = inputValue - (h * 3600);
		}else{
			h = 0;
		}

		if(inputValue >= 60){
			m = inputValue/60;
			s = inputValue - (m * 60);
		}else{
			m = 0;
			s = inputValue;
		}

		System.out.println(h + ":" + m + ":" + s);
	}

}

Measured memory_bytes: 24336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll x=1000,h=0;
    ll ans=1000;
    if(a[0]<a[1]){
        ll pl=x/a[0];
        h+=pl;
        x-=pl*a[0];
    }
    rep(i,n-1){
        if(i==0)continue;
        chmax(ans,x);
        if(a[i-1]>=a[i]&&a[i]<=a[i+1]){
            ll pl=x/a[i];
            h+=pl;
            x-=pl*a[i];
        }else if(a[i-1]<=a[i]&&a[i]>=a[i+1]){
            x+=h*a[i];
            h=0;
        }
    }
    x+=h*a[n-1];
    chmax(ans,x);
    cout<<ans<<endl;
}



Measured memory_bytes: 3652
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		int i;
		Dictionary<Int64, Int64> dict = new Dictionary<Int64, Int64>();

		int n = int.Parse(Console.ReadLine());
		string[] strInput = Console.ReadLine().Split(' ');

		Int64[] a = new Int64[n];
		for(i = 0; i < n; i++)
        {
			a[i] = Int64.Parse(strInput[i]);
			if(dict.ContainsKey(a[i]) == true)
            {
				dict[a[i]]++;
            }
			else
            {
				dict.Add(a[i], 1);
            }
		}
		int q = int.Parse(Console.ReadLine());
		Int64[] b = new Int64[q];
		Int64[] c = new Int64[q];
		for (i = 0; i < q; i++)
        {
			strInput = Console.ReadLine().Split(' ');
			b[i] = Int64.Parse(strInput[0]);
			c[i] = Int64.Parse(strInput[1]);
		}

		Int64 result = 0;
		Int64 tmpVal;

		//要素の和を最初に集計
		foreach (KeyValuePair<Int64, Int64> kvp in dict)
		{
			Int64 key = kvp.Key;
			Int64 val = kvp.Value;
			result += key * val;
		}

		for (i = 0; i < q; i++)
		{
			//操作
			if(dict.ContainsKey(b[i]) == true)
            {
				tmpVal = dict[b[i]];
				result -= tmpVal * b[i];
				result += tmpVal * c[i];
				if(dict.ContainsKey(c[i]) == true)
                {
					dict[c[i]] += tmpVal;
                }
                else
                {
					dict.Add(c[i], tmpVal);
                }
				dict.Remove(b[i]);
            }



			Console.WriteLine(result);
		}

		return;
	}
}

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

typedef long long LL;
typedef unsigned long long LONG;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MAXINT = 2147483647;
const int mod = 1000000007;
const long long MAXLONG = 9223372036854775807;
using namespace std;
typedef pair<int, int> PII;
#define ft fisrt
#define sd second
#define eb emplace_back
#define END '\n'

template <class T>
inline bool Read(T &ret)
{
	char c;
	int sgn;
	if (static_cast<void>(c = getchar()), c == EOF)
		return 0;
	while (c != '-' && (c < '0' || c > '9'))
		c = getchar();
	sgn = (c == '-') ? -1 : 1;
	ret = (c == '-') ? 0 : (c - '0');
	while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
		ret = ret * 10 + (c - '0');
	ret *= sgn;
	return 1;
}

template <class T>
inline void Write(T x)
{
	if (x < 0)
		putchar('-'), Write(x);
	if (x > 9)
		Write(x / 10);
	putchar(x % 10 + '0');
}

int a[10][10];

int check1(int cur){
	int vis[10]={false};
	for(int i=1;i<=9;++i){
		if(!vis[a[cur][i]]){
			vis[a[cur][i]]=true;
		}
	}
	for(int i=1;i<=9;++i)
	  if(vis[i]){
	  	return i;
	  }
}
void solve(int question_num)
{
	while (question_num--)
	{
		int k;
		LL sum=0;
		cin>>k;
		for(int i=1;i<=k;++i){
			for(int j=1;j<=k;++j){
				for(int w=1;w<=k;++w){
					sum+=(__gcd(__gcd(i,j),w));
				}
			}
		}
		cout<<sum;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t = 1;
	// cin >> t;
	solve(t);
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(){
	int l[100000],r[100000];
	int n,m;
	scanf("%d %d",&n,&m);
	for(int a=0;a<100000;a++){
		r[a]=n;
		scanf("%d %d",&l[a],&r[a]);
		if(l[a]==0&&r[a]==0)break;
	}
	int min=n,max=0;
	for(int b=0;b<100000;b++){
		if(r[b]<min)min=r[b];
		if(l[b]>max)max=l[b];
	}
	int ans;
	for(ans=0;max<=min;max++)ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctype.h>

const int INF =100000000;

using namespace std;

int ans = 0;

int main(){

  int a ;
  cin >> a;

  ans += a*100;

  cin >> a;

  ans += a*10;

  cin >> a;

  ans += a;

  if(ans == 110 || ans == 1){
    cout << "Open" << endl;
  }else{
    cout << "Close" << endl;
  }
}


Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf 
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
int to_num(string str){
	int t=0;
	int n=str.length();
	for(int i=0;i<n;i++)t=t*10+str[i]-'0';
	return t;
}
ll n,a,b,c,d;
char s[N];
int bf(){
	   if(s[b]=='#'||s[d]=='#')return o("No");
                for(int i=b;i<=d;i++){
                        if(s[i]=='#'&&s[i+1]=='#')return o("No");
                }
                if(s[a]=='#'||s[c]=='#')return o("No");
                for(int i=a;i<=c;i++){
                        if(s[i]=='#'&&s[i+1]=='#')return o("No");
                }
                return o("Yes");

}
int main(){
	cin>>n>>a>>b>>c>>d;
	cin>>(s+1);
	if(c<d){
		return bf();
	}
	for(int i=a;i<=c;i++){
		if(s[i]=='#'&&s[i+1]=='#')return o("No");
	}
	for(int i=b;i<=d;i++)if(s[i]=='#'&&s[i+1]=='#')return o("No");
	while((s[b+1]!='.'||s[b-1]!='.'||s[b]=='#')&&b<=n)b++;
	if(b>d)return o("No");
	puts("Yes");
}


Measured memory_bytes: 384
fun main(args : Array<String>) {
    val(N,M,C) = readLine()!!.split(" ").map(String::toInt)
    val Bs =  readLine()!!.split(" ").map(String::toInt).toIntArray()
    var count = 0
    println(Array(N){readLine()!!.split(" ").map(String::toInt).toIntArray()}.map{it.foldIndexed(C){index,sum,value -> sum + value*Bs[index]}}.count{it>0})
}


Measured memory_bytes: 37864
// 2150、p番目の素数の和

import java.util.*;
public class Main{
    public  static void main(String[] args){
	new Main().run();
    }
    Scanner kbd = new Scanner(System.in);
    int n, p;

    void run(){
	boolean[] prime = new boolean[1000000];
	setP(prime);

	while(kbd.hasNext()){
	    n = kbd.nextInt();
	    p = kbd.nextInt();
	    if(n!=-1 && p!=-1){
		solve(prime);
	    }
	}
    }

    void solve(boolean[] prime){
	int[] sum = new int[100000];
	Arrays.fill(sum, Integer.MAX_VALUE);
	setSum(sum, prime); 
	Arrays.sort(sum);
	/*
	int i=0;
	while(i<(a+p-1)){
	    System.out.println(i+" "+sum[i]);
	    i++;
	}
	*/
	System.out.println(sum[p-1]);
    }

    void setP(boolean[] prime){
	int i, j, k=0;
	Arrays.fill(prime, true);
	prime[0] = false;
	prime[1] = false;
	for(i=2; i<prime.length; i++){
	    for(j=i+i; j<prime.length; j+=i){
		if(prime[i]) prime[j] = false;
	    }
	}
    }

    void setSum(int[]sum, boolean[] prime){
	int i=0, j=0, a=0, b;
	for(a=n+1; a<n+300 && i<sum.length; a++){
	    b = a;
	    for(; b<n+300 && i<sum.length; b++){
		if(prime[a] && prime[b]){
		    sum[i] = a+b;
		    //System.out.println("* "+pp[a]+" "+pp[b]+" "+sum[i]);
		    i++;
		}
	    }
	}
    }
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define all(v) v.begin(),v.end()
# define pl(s)  std::cout << s << endl;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1e9+7;

void addM(ll & a, ll b){
    a = (a+b) % MOD;
}

// numを二進数化した時に2^nのビットがonであるかを判定する
bool is_nth_bit_on(int num, int n){
    return (num >> n) & 1;
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;

    // dp[i][j]:1:1からi：j（i行目のj列目）に移動する場合の数
    auto dp = make_vec<ll>(101,8);

    // i本目から次行のj本目に移動する場合の数
    auto num = make_vec<ll>(8,8);

    // あみだクジの場合の数を事前準備
    REP(b,1<<(W-1)){
        // 隣合うビットが立っていないかの確認
        bool ok = true;
        REP(i,W-2){
            if(is_nth_bit_on(b, i) && is_nth_bit_on(b, i+1)){
                ok = false;
                break;
            }
        }
        if(!ok) continue;

        vector<int> P(W);iota(all(P),0);

        // i番目のフラグがONである＝その橋を渡って、i番目とi+1番目が次行で入れ替わる
        // i番目のフラグがOFFである＝i番目はそのまま次行に行く
        REP(i,W-1) if(is_nth_bit_on(b, i)) swap(P[i], P[i+1]);

        // 算出結果を数え上げていく
        REP(i,W) addM(num[i][P[i]],1);
    }

    // DP実行
    dp[0][0] = 1;
    REP(i,H) REP(j,W) {
        // そのまま次行に遷移
        addM(dp[i+1][j], dp[i][j] % MOD * num[j][j] % MOD);
        // 右のくじに移動して、次行に遷移
        if(j+1<W)  addM(dp[i+1][j+1], dp[i][j] % MOD * num[j][j+1] % MOD);
        // 左のくじに移動して、次行に遷移
        if(j-1>=0) addM(dp[i+1][j-1], dp[i][j] % MOD * num[j][j-1] % MOD);
    }

    pl(dp[H][K-1]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    char pre = s.at(0);
    int cnt = 1;
    for (int i = 1; i < s.length(); i++)
    {
        if(pre != s.at(i)) {
            pre = s.at(i);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
n,m,x = map(int,input().split())
c = []
a = []
for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0]) 
    a.append(tmp[1:])

ans = 100000000
l = 0
for i in range(2**n):
    ab = [0]*m
    kari = 0
    for j in range(n):
        if (i >> j) & 1:
            ab = [x + y for (x, y) in zip(ab, a[j])]
            kari += c[j]
    if all([z >= x for z in ab]):
        ans = min(ans,kari)
        l += 1

if l == 0:
    ans = -1

print(ans)

Measured memory_bytes: 9236
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    static readonly string OK = "Possible", NG = "Impossible";

    public void Solve()
    {
        int N = Reader.Int(), L = Reader.Int();
        var A = Reader.IntArray(N);
        int x = Enu.Range(1, N - 1).FirstOrDefault(i => A[i - 1] + A[i] >= L) - 1;
        if (x == -1) { Console.WriteLine(NG); return; }
        Console.WriteLine(OK);
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        for (int i = 0; i < x; i++) Console.WriteLine(i + 1);
        for (int i = N - 2; i > x; i--) Console.WriteLine(i + 1);
        Console.WriteLine(x + 1);
        Console.Out.Flush();
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 18000
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};

int main() {
    str s;
    int ans=0;
    cin >> s;
    rep(i,4){
        if (s[i]=='+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll long long int
#define N 200100
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	deque<char> fro,la;
	int rev=0;
	int q;
	cin>>q;
	while(q--){
		int t;
		cin>>t;
		if(t==1)
			rev=1-rev;
		else{
			int f;
			char c;
			cin>>f>>c;
			if(rev==0){
				if(f==1){
					fro.push_front(c);
				} else{
					la.push_back(c);
				}
			} else{
				if(f==1){
					la.push_back(c);
				} else{
					fro.push_front(c);
				}
			}
		}
	}
	if(rev==0){
		// fro s la
		while(!fro.empty()){
			char c=fro.front();
			fro.pop_front();
			cout<<c;
		}
		cout<<s;
		while(!la.empty()){
			char c=la.front();
			la.pop_front();
			cout<<c;
		}
		cout<<endl;
	} else{
		// la s fro
		while(!la.empty()){
			char c=la.back();
			la.pop_back();
			cout<<c;
		}
		reverse(s.begin(),s.end());
		cout<<s;
		while(!fro.empty()){
			char c=fro.back();
			fro.pop_back();
			cout<<c;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 848
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    print(max(a * b, c * d))
    return

#B
def B():
    _ = II()
    s = S()
    d = {}
    d["I"] = 1
    d["D"] = -1
    ans = 0
    now = 0
    for i in s:
        now += d[i]
        ans = max(ans, now)
    print(ans)
    return

#C
def C():
    def primes2(n):
        """https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n/3035188#3035188"""
        """ Returns  a list of primes < n """
        sieve = [True] * (n//2)
        for i in range(3,int(n**0.5)+1,2):
            if sieve[i//2]:
                sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)
        return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]]
    n = II()
    prime = primes2(n+1)
    d = []
    for i in prime:
        b = n
        f = 0
        while b:
            b = b // i
            f += b
        d.append(f%mod)
    ans = 1
    for i in d:
        ans *= (i + 1)
        ans %= mod
    print(ans)
    return

#D
def D():
    n, a, b = LI()
    x = LI()
    ans = 0
    for i in range(n - 1):
        ans += min((x[i + 1] - x[i]) * a, b)
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 59248
n = int(input())
s = list(map(int,input()))

def nc(n,s,i,j,k):
    c1 = -1
    for l in range(n):
        if s[l] == i:
            c1 = l
            break
    if c1 == -1:
        return 0
    c2 = -1
    for l in range(c1+1,n):
        if s[l] == j:
            c2 = l
            break
    if c2 == -1:
        return 0
    c3 = -1
    for l in range(c2+1,n):
        if s[l] == k:
            c3 = l
            break
    if c3 == -1:
        return 0
    return 1

c = 0
for i in range(10):
        for j in range(10):
            for k in range(10):
                c += nc(n,s,i,j,k)



print(c)


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

const int N = 200000;
int a[N+5];
map<int, int> mp;


int main(){
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a+i);
    long long ans = 0;
    for (int i = n; i >= 1; --i){
        ans += mp[a[i] + i];
        ++mp[i - a[i]];
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    for (int i=0;i<b;i++) cout << string(a,'1') + string(w-a,'0') << endl;
    for (int j=b;j<h;j++) cout << string(a,'0') + string(w-a,'1') << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a;
int main() {
  cin >> n; read_n(a, n);
  lli sum = 0;
  for (lli x : a) sum += x;
  lli k = n*(n+1)/2;
  if (sum % k != 0) { cout << "NO" << endl; return 0; }
  lli d = sum / k;
  bool ok = true;
  for (lli i=0; i<n; ++i) {
    lli x = a[i], y = a[(i+1)%n];
    if (y - x > d) ok = false; 
    if (y - x < d) {
      if ((y - x - d) % n != 0) ok = false;
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 1024
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}

//}}}

// -------------------- Spliters ------------------------
const int maxn = 22222;

ll a[maxn];
ll oa[maxn], ob[maxn];
int main() {
	ios::sync_with_stdio(0);
	int N;
	cin>>N;
	rep(i, 0, N) cin>>a[i];
	rep(i, 1, N + 1) oa[i] = ll(i) * (N + 1);
	rep(i, 1, N + 1) ob[i] = ll(N - i + 1)*(N+1);
	rep(i, 1, N + 1) {
		oa[a[i]] += i;
		ob[a[i]] += i;
	}
	rep(i, 1, N + 1) cout<<oa[i]<<" "; cout<<endl;
	rep(i, 1, N + 1) cout<<ob[i]<<" "; cout<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


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

#define pi 3.14159265358979323846264338

int main() {
    double a, b, h, m, x;
    cin >> a >> b >> h >> m;
    double c = 11.0/360.0*(60*h+m)*pi;
    x = pow((a * a + b * b - 2 * a * b * cos(c)),0.5);
    cout << fixed << setprecision(20) << x << endl;
    return 0;
}

Measured memory_bytes: 4340
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    List<Character> list = new ArrayList<>();
    list.add(c[0]);
    for (int i = 1; i < n; i++) {
      if (c[i - 1] != c[i]) {
        list.add(c[i]);
      }
    }
    System.out.println(list.size());
  }
}


Measured memory_bytes: 26320