akhauriyash/Code-Regression huggingface dataset:
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    string s,t;
    cin>>s>>t;
    vector<ll> mx(26,E);
    vector<vector<ll>> next(s.size()+1,vector<ll>(26)),next2(t.size()+1,vector<ll>(26));
    for(ll i=s.size()-1;i>=0;i--){
        next[i+1]=mx;
        mx[s[i]-'a']=i+1;
    }
    next[0]=mx;
    for(auto &i:mx){i=E;}
    for(ll i=t.size()-1;i>=0;i--){
        next2[i+1]=mx;
        mx[t[i]-'a']=i+1;
    }
    next2[0]=mx;
    vector<vector<pair<ll,pll>>> dp(s.size()+1,vector<pair<ll,pll>>(t.size()+1,{0,{0,0}}));
    ll ans=0;
    pll W={0,0};
    for(int i=0;i<=s.size();i++){
        for(int j=0;j<=t.size();j++){
            for(int c=0;c<26;c++){
                if(next[i][c]!=E && next2[j][c]!=E && dp[next[i][c]][next2[j][c]].F<dp[i][j].F+1){
                    dp[next[i][c]][next2[j][c]]={dp[i][j].F+1,{i,j}};
                    if(ans<dp[next[i][c]][next2[j][c]].F){
                        ans=dp[next[i][c]][next2[j][c]].F;
                        W={next[i][c],next2[j][c]};
                    }
                }
            }
        }
    }
    string ret;
    pll a={0,0};
    while(W!=a){
        ret.push_back(s[W.F-1]);
        W=dp[W.F][W.S].S;
    }
    reverse(ret.begin(),ret.end());
    cout<<ret<<endl;
    
    return 0;
}


Measured memory_bytes: 212992
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        int k = Integer.parseInt(scanner.nextLine());
        int x = Integer.parseInt(scanner.nextLine());
        int y = Integer.parseInt(scanner.nextLine());

        int ans = 0;

        for (int i=1; i <= n; i++) {
            if (i <= k) {
                ans += x;
            } else {
                ans += y;
            }
        }
        System.out.print(ans);
    }
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

ll baisuu_atob(ll a, ll b, ll x){
    if(a % x > 0) a += x - (a % x);
    b -= a;
    if(b < 0) return 0;
    else return b/x + 1;
}

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    ll r = a % b;
    if(r == 0) return b;
    else return gcd(b, r);
}

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

int main(void){
    ll N, M; cin >> N >> M;
    ll upplim = M+1;
    ll A[N]; rep(i, N) {cin >> A[i]; if(A[i] % 2 == 1) return 0;}
    rep(i, N) A[i] /= 2;
    ll lcm_A = 1;
    rep(i, N){
        lcm_A = lcm(lcm_A, A[i]);
        if(lcm_A >= upplim){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, N){
        if((lcm_A / A[i]) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    //lcm_Aの奇数倍が1からMまでにいくつあるか
    ll ans = (M / lcm_A + 1) / 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Last Modified: 19/Oct/2019 05:30:55 PM


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    a, b = get_ints()
    print(max(0, a - 2 * b))


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array():
    return list(map(int, sys.stdin.readline().split()))


def get_ints():
    return map(int, sys.stdin.readline().split())


def input():
    return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.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(void) {
	string str;
	cin >> str;
	int len = str.length();
	string ans;
	if (str.at(str.length() - 1) == 's') {
		cout << str << "es" << endl;
	} else {
		cout << str << "s" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,W;
    int h,w;
    cin >> H >> W;
    cin >> h >> w;
    int ans = (H-h)*(W-w);
    if(ans >= 0) cout << ans << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int V = scan.nextInt();
			int E = scan.nextInt();
			int[]s = new int [E];
			int[]t= new int [E];
			int[]w = new int [E];
			long goukei = 0;
			
			final Comparator<Edge> comp = new COMP();
			PriorityQueue<Edge> queue = new PriorityQueue<Edge>(comp);
			UnionfindTree U = new UnionfindTree(V);
			for(int i=0;i<E;i++) {
				s[i] = scan.nextInt();
				t[i] = scan.nextInt();
				w[i] = scan.nextInt();	
				queue.add(new Edge(s[i],t[i],w[i]));	
			}
			
			while(!queue.isEmpty()) {
				Edge z = queue.poll();
				if(!U.same(z.se, z.to)) {
					U.union(z.se, z.to);
					goukei+=z.we;
				}	
			}
			
			System.out.println(goukei);

		}
	}
	
	
	static class Edge{//辺の保持
		int se;int to;int we;
		Edge(int s,int t,int w){se=s;to=t;we=w;}
	}
	
		
	static class COMP implements Comparator<Edge>{	
		public int compare(Edge x,Edge y) {
			if(x.we>y.we) return 1;
			if(x.we<y.we) return -1;
			return 0;
			}
	}
	
	//unionfind は分割できない以下重要なこと。
/*
 * 繋げていく処理だけを考えるとき，繋げたものだけを考えれば良いので，連結かどうかの判定は簡単
 * 
 * 辺を壊した後にグラフが連結がどうかは，遠くまで見ないと連結かどうかの判定が難しい．
 * 
 * 上記の「難しい」というのは，グラフ上を遠くまで探索して連結かどうかを愚直に調べることのできるのは 
 * DFS，BFS なので，制約が大きいと計算量的に判定が難しい，という意味．
 * 
 * 以上 3 つを考えると意味が分かると思います．繋がっているかどうかの判定は，
 * ここまで見てきた通り，Union-Find 木を使えば簡単にできます
 * （DFS，BFS，ワーシャルフロイド法などでも繋がっているかの判定はできるが，制約が大きくなると計算量的に使えない）．
 * このポイントは，例えば「無向グラフが与えられてその辺を壊し
 * ，連結かどうかの判定」を行うという典型的な問題に対して適用することができます．
 */



//グループを作る、そしてそのグループについてどうなのかという問題に使えるUNIONFIND木
static class UnionfindTree{
	int [] parent;//配列番号＝頂点番号、値＝その点の親の頂点
	int [] rank;//その頂点を根とするグラフの深さの値、独立した頂点をランク１とする
	
	
	public UnionfindTree(int size){//size=グループ分けしたい頂点の数の合計
		this.parent = new int[size];
		this.rank = new int[size];
		for(int i = 0;i<size;i++) {
			parent[i] = i;
			rank[i] = 0; //集合の高さ
		}
	}
	
	public void union(int x, int y) {//計算量　O(logN)パス圧縮してるのでO(1/A(n,n))と相当小さくなる
		int xRoot = find(x);
		int yRoot = find(y);
		
		//xが属する木の方が大きい場合
		if (rank[xRoot] > rank[yRoot]) { 
			parent[yRoot] = xRoot; //yの親をxに更新 
								   
		} else if(rank[xRoot] < rank[yRoot]) {
			parent[xRoot] = yRoot;
			
		} else if (xRoot != yRoot){//高さ一緒で同じ値ではない、同じ値は無視していい
			parent[yRoot] = xRoot;
			rank[xRoot]++; //同じ高さの木がルートの子として着くから大きさ++;
		}
	}
	
	//引数の属する木のルートのidを返す
	public int find(int i) {//計算の工夫パス圧縮、これによりこのメソッドの計算量は  O(logN)  になる。(非自明)
		if (i != parent[i]) {//指定された頂点が根(親)なら無視してそのまま値を返せばいい
			parent[i] = find(parent[i]);//そうでないならその頂点がもつ親の値までいきそこでその値をもらいに行く
		}//それと同時に、指定された頂点のもつ値をそこで保存しておくことで、パス圧縮が行われ計算量が短縮される。
		return parent[i];
	}
	
	//同じ木に属しているか
	public boolean same(int x, int y) {//計算量O(logN)
		return find(x) == find(y);
	}
}
		

}



Measured memory_bytes: 109824
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=1e9+7;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    int a1=-1;
    while(1){
        c-=b;
        if(c<=0){
            a1=0;
            break;
        }
        a-=d;
        if(a<=0){
            a1=1;
            break;
        }
    }
    if(a1==0)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 3652
#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 lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a) / (b) + (((a) % (b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

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 = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int 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 m, k;
    cin >> m >> k;
    if(k >= (1 << m)) {
        cout << -1 << endl;
        return 0;

    }
    if(m == 0) {
        cout << "0 0" << endl;
        return 0;

    }
    if(m == 1) {
        if(k == 0) {
            cout << "1 1 0 0" << endl;

        } else {
            cout << -1 << endl;

        }
        return 0;
    }

    for(int i = 0; i < (1 << m); ++i) {
        if(i != k) {
            cout << i << " ";

        }
    }
    cout << k << " ";
    for(int i = (1 << m) - 1; i >= 0; --i) {
        if(i != k) {
            cout << i << " ";

        }
    }
    cout << k << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

long main(void) {
	int i, j;

	int N, L;

	if(scanf("%d", &N) < 1)return 0;
	if (scanf("%d", &L) > 100)return 0;

	char moji[10000][101], tmp[101];

	for (i = 0; i < N; i++) {
		if (scanf("%s", moji[i]) ==EOF)return 0;
	}

	for (i = 1; i < N; i++) {
		for (j = 1; j < N; j++) {
			if (strcmp(moji[j - 1], moji[j])>0) {
				strcpy(tmp, moji[j - 1]);
				strcpy(moji[j - 1], moji[j]);
				strcpy(moji[j], tmp);
			}
		}
	}

	for (i = 0; i < N; i++) {
		printf("%s", moji[i]);
	}

	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;



signed main()
{
    int N;
    cin >> N;
    
    cout << "ABC" << N << endl;
}


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

int main()
{
	long long n,x,a,b,ans,sav;
	scanf("%lld %lld",&n,&x);
	ans = n;
//	if(n % 2 == 1)
//	{
//		printf("%lld",(n-1)*3ll);
//	}
//	else
	{
		a = min(n-x,x);
		b = max(n-x,x);
		while(a >= 1)
		{
			if(b % a == 0)
			{
				ans += (b/a)*2*a;
				ans -= a;
				break;
			}
			else
			{
				ans += (b/a)*2*a;
				sav = a;
				a = b%a;
				b = sav;
			}
		}
		printf("%lld",ans);
		return 0;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n, a[26];
	for(int i = 0; i < 26; i++){
		a[i] = 0;
	}
	cin >> n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		int b[26];
		for(int i = 0; i < 26; i++){
			b[i] = 0;
		}
		for(unsigned int j = 0; j < s.size(); j++){
				b[int(s[j]) - 97] += 1;
			}
		if(i == 0){
			for(int j = 0; j < 26; j++){
				a[j] = b[j];
			}
			continue;
		}
		for(int j = 0; j < 26; j++){
			a[j] = (a[j] < b[j] ? a[j] : b[j]);
		}
	}
	for(int i = 0; i < 26; i++){
		for(int j = 0; j < a[i]; j++){
			cout << char(i + 97) << flush;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcd(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

int ans = 0;
int n;
vi h(1000);

void water(int l, int r)
{
    if (l > r)
        return;
    int m = INF;
    int sp;
    rep(i, l, r + 1)
    {
        if (m > h[i])
        {
            m = h[i];
            sp = i;
        }
    }
    //cout << "m=" << m << endl;
    rep(i, l, r + 1)
    {
        h[i] -= m;
        //cout << h[i] << " ";
    }
    //cout << endl;
    ans += m;
    water(l, sp - 1);
    water(sp + 1, r);
}

int main()
{
    cin >> n;
    rep(i, 0, n) cin >> h[i];

    water(0, n - 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M, L = map(int, input().split())
INF = float('inf')
VD = [[INF] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    VD[a][b] = c
    VD[b][a] = c
for i in range(N):
    VD[i][i] = 0
 
for k in range(N):
    for i in range(N):
        for j in range(N):
            if VD[i][j] > VD[i][k] + VD[k][j]:
                VD[i][j] = VD[i][k] + VD[k][j]
 
WD = [[INF] * N for _ in range(N)]
for i in range(N):
    WD[i][i] = 0
    for j in range(i+1,N):
        d = VD[i][j]
        if d <= L:
            WD[i][j] = 1
            WD[j][i] = 1
 
for k in range(N):
    for i in range(N):
        for j in range(N):
            if WD[i][j] > WD[i][k] + WD[k][j]:
                WD[i][j] = WD[i][k] + WD[k][j]
 
Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    print(WD[s-1][t-1]-1 if WD[s-1][t-1] < INF else -1)

Measured memory_bytes: 82396
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
const int mod = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 1000000;
    for(int i = 0; i + t.size() <= s.size(); i++){
        int tmp = 0;
        rep(j, t.size()){
            if(s[i + j] != t[j]) tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;
 
//GCD and LCM
public class Main{
 
    public static long gcd(long a, long b){
        if(a < b){
            long tmp = a;
            a = b;
            b = tmp;
        }
        while(b!=0){
            long r = a%b;
            a = b;
            b = r;
        }
        return a;
    }
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            long g = gcd(a, b);
            System.out.println(g+" "+a/g*b);
        }
    }
}


Measured memory_bytes: 25896
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
#define int ll

const int MOD = 1e9 + 7;
const int INF = 1e15 + 373;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int query(int i) {
    string s;

    cout << i << endl;
    cin >> s;

    if (s == "Male") {
        return 0;
    }
    if (s == "Female") {
        return 1;
    }
    return -1;
}

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

    int s = query(0);
    int t = (s + 0) % 2;

    // [lb, ub)
    int lb = 0;
    int ub = n;
    while (ub - lb > 1) {
        int mid = lb + (ub - lb) / 2;
        if ((mid + query(mid)) % 2 == t) {
            lb = mid;
        } else {
            ub = mid;
        }
    }

    return 0;
}


Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int debu(string a)
{
	cout<<a<<endl;
}
int debu()
{
	cout<<"ok"<<endl;
}
int debu(int a)
{
	cout<<a<<endl;
}




int main()
{
	int d,c;
	cin>>d>>c;
	cout<<d*c<<endl;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 3e4 + 20;

ll fact[MAXN];

void prec(){

}

void solve() {

    string s;
    cin >> s;

    for (auto e : s){
        if (e == '?')
            cout << 'D';
        else
            cout << e;
    }

}

#else

void solve() {

}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case " << (i++) << ": ";
        solve();
        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
    //    gen();
#endif

}


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

int main() {
  int a,b,c,S;
  cin>>a>>b>>c;
  S=a*b/2;
  
  if(a*a + b*b == c*c)
    cout<< S <<endl;
  
  else
    cout<<"error"<<endl;
  
}

Measured memory_bytes: 256
n, w = map(int, input().split())

wv = [list(map(int, input().split())) for i in range(n)]
cache = [{} for x in range(n)]

def solve(i, w):
    if i >= n:
        return 0

    cache_value = cache[i].get(w)
    if cache_value:
        return cache_value

    if w - wv[i][0] >= 0:
        value = max(solve(i + 1, w), solve(i + 1, w - wv[i][0]) + wv[i][1])
        cache[i][w] = value
        return value
    else:
        value = solve(i + 1, w)
        cache[i][w] = value
        return value

print(solve(0, w))


Measured memory_bytes: 10832
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    map<string, int> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        m[s]++;
    }
    map<string, int> :: iterator it;
    ll A = 0;
    ll M = 0;
    ll R = 0;
    ll H = 0;
    ll C = 0;
    for(it = m.begin(); it != m.end(); it++){
        if(it->first[0] == 'A') A++;
        else if(it->first[0]=='C') C++;
        else if(it->first[0]=='R') R++;
        else if(it->first[0]=='M') M++;
        else if(it->first[0]=='H') H++;
    }
    cout <<A*C * (M + H + R) + M * (H+R) * (A+C) + H*R*(A + C + M);

}

Measured memory_bytes: 11648
//while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

const int nax=107;

int n;
int tab[nax];

int ile[nax];
int czas[nax];

int wyn=0;

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
		scanf("%d", &tab[i]);
	for (int i=0; i<=n; i++)
		ile[tab[i]]++;
	if (ile[0]>=2 || ile[12]>=2)
	{
		printf("0\n");
		return 0;
	}
	for (int i=1; i<12; i++)
	{
		if (ile[i]>=3)
		{
			printf("0\n");
			return 0;
		}
	}
	if (n+1>12)
	{
		printf("1\n");
		return 0;
	}
	for (int i=0; i<(1<<(1+n)); i++)
	{
		for (int j=0; j<=n; j++)
		{
			if (i&(1<<j))
				czas[j]=tab[j];
			else
				czas[j]=(24-tab[j])%24;
		}
		int tu=1000;
		sort(czas, czas+1+n);
		for (int j=0; j<=n; j++)
		{
			for (int l=j+1; l<=n; l++)
			{
				tu=min(tu, czas[l]-czas[j]);
				tu=min(tu, 24-(czas[l]-czas[j]));
			}
		}
		wyn=max(wyn, tu);
	}
	printf("%d\n", wyn);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

struct UnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;

    UnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y])   par[x] = y;
        else{
            par[y] = x;
            if(rank[x] == rank[y])  ++rank[x];
        }
    }
};

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

    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; ++i){
        int x, y, z;
        cin >> x >> y >> z;
        --x, --y;
        uf.unite(x, y);
    }
    vector<bool> used(n, false);
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int par = uf.find(i);
        if(used[par])   continue;
        used[par] = true;
        ++ans;
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  double suminv=0;
  double sum = 0;

  rep(i,n){
    suminv += 1.0/a[i];
  }
  sum = 1.0/suminv;
  cout << sum << endl;
  
  return 0;
}


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

int main()
{
    std::string str, tmp;
    char c;
    int N, cnt;

    while(1) {
        std::cin >> N;
        if (N == 0) break;
        std::cin >> str;
        for (int i = 0; i < N; i++) {
            c = str[0]; cnt = 1; tmp = "";
            for (unsigned long j = 1; j < str.size(); j++) {
                if (str[j] == c) {
                    cnt++;
                    continue;
                } else {
                    tmp += std::to_string(cnt) + c;
                    cnt = 1;
                    c = str[j];
                }
            }
            tmp += std::to_string(cnt) + c;
            str = tmp;
        }
        std::cout << str << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll a, b, t;
  cin >> a >> b >> t;
  cout << t / a * b << endl;
}

Measured memory_bytes: 256
#N,M,L = list(map(int, input().split()))

N=int(input());
L=[];
for i in range(N):
	L.append(input());

def calc(s):
	s_len=len(s);
	flag=0;
	check="Hoshino"
	hoshino_len=len(check);

	F=list(s);
	for i in range(s_len-hoshino_len+1):
		flag=0;
		if F[i]=='H':
			flag=1;
			for j in range(hoshino_len):
				if F[i+j]!=check[j]:
					flag=0;
					break;
			if flag==1:
				F[i+6]='a'
	F2="".join(F);
	print(F2);

for i in range(N):
	calc(L[i]);



Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  ll a=x,b=n-x;
  if(a<b) swap(a,b);
  ll ans=a+b;
  for(;b!=0;){
    //cout<<a<<" "<<b<<endl;
    ans=ans+(a/b)*2*b;
    if(a%b==0){
      ans-=b;
      break;
    }
    ll c=a;
    a=b;
    b=c%b;
  }
  cout<<ans<<endl;

  return 0;
}


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

int main() {
  int length, buf;
  vector<int> input;
  cin >> length;
  for (int i = 0; i < length; i++) {
      cin >> buf;
      input.push_back(buf);
  }

  int result = 0;
  for (int i = 0; i < length - 2; i++) {
      if (input[i] > input[i+1] && input[i+1] > input[i+2]) {
          result++;
      } else if (input[i] < input[i+1] && input[i+1] < input[i+2]) {
          result++;
      }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
class ABC131_A
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        if(str[0] != str[1] && str[1] != str[2] && str[2] != str[3])
        {
            Console.WriteLine("Good");
        }
        else { Console.WriteLine("Bad"); }
    }
}


Measured memory_bytes: 13140
X, Y = map(int, input().split())

count = 0
if 2 * X - Y >= 0 and 2 * Y - X >= 0:
    if (2*X-Y)%3 == 0 and (2*Y-X)%3 == 0:
        t = (2*X-Y)/3
        s = (2*Y-X)/3
        n = int(t+s)
        r = 0
        if t >= s:
            r = int(s)
        else:
            r = int(t)

        def cmb(n, r, mod):
            if ( r<0 or r>n ):
                return 0
            r = min(r, n-r)
            return g1[n] * g2[r] * g2[n-r] % mod

        mod = 10**9+7 #出力の制限
        N = 10**6
        g1 = [1, 1] # 元テーブル
        g2 = [1, 1] #逆元テーブル
        inverse = [0, 1] #逆元テーブル計算用テーブル

        for i in range( 2, N + 1 ):
            g1.append( ( g1[-1] * i ) % mod )
            inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
            g2.append( (g2[-1] * inverse[-1]) % mod )

        a = cmb(n,r,mod)
        count = a

    else:
        count = 0
else:
    count = 0

print(count)

Measured memory_bytes: 127560
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i,m,n) for(ll i=m ; i<n ; i++)
#define forr(i,m,n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N =2e5+5;
using namespace std;
int main()
{
    //IO;
    int n;
    cin>>n;
    ll freq[10][10]= {};
    forr(i,1,n)
    {
        string s=to_string(i);
        int u=s[0]-'0',v=s.back()-'0';
        freq[u][v]++;
    }
    ll ans=0;
    rep(i,0,10)
    {
        rep(j,0,10)
        {
            ans+=freq[i][j]*freq[j][i];
        }
    }


    cout<<ans;
}


Measured memory_bytes: 256
from math import sqrt,ceil,gcd
        
        
        
# t=int(input())

# n,m=map(int,input().split())

# a=list(map(int,input().split()))

arr=[[0 for i in range(201)] for j in range(201)]
for i in range(1,201):
    for j in range(1,201):
        arr[i][j]=gcd(i,j)



a=int(input())
b=a
c=a
ans=0
for i in range(1,a+1):
    for j in range(1,b+1):
        for k in range(1,c+1):
            x=arr[i][j]
            y=arr[x][k]
            ans+=y
print(ans)
    
    
    
    
    
    
    
    
    
    
    
        
 

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

int main() {
  fixed;
  setprecision(7);
  int N;
  double SUM=0;
  int L;
  double A;
  double B;
  cin >> N;
  vector<double> vec1(N);
  vector<double> vec2(N);
  
  for (int i=0; i<N; i++) {
    cin >> vec1[i] >> vec2[i];
  }
  for (int i=0; i<N-1; i++) {
    for (int j=1; j<N-i; j++) {
      A=(vec1[i+j]-vec1[i])*(vec1[i+j]-vec1[i])+(vec2[i+j]-vec2[i])*(vec2[i+j]-vec2[i]);
      B=sqrt(A);
      SUM += B;
    }
  }
  cout << fixed << setprecision(10)<< (N-1)*SUM*2/(N*(N-1)) << endl;
  return 0; 

}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long W, std::vector<std::string> s){
    // 上下左右にますがあるかないかを全探索
    bool ans = true;
    for(int i= 0; i < H; i++){
        bool i_flg = true;
        for(int j = 0; j < W; j++){
            if(s.at(i).at(j) == '.'){
                continue;
            } else { 
                bool flg = false;
                if(i - 1 >= 0 && s.at(i-1).at(j) == '#'){
                    flg = true;
                }
                if(j - 1 >= 0 && s.at(i).at(j-1) == '#'){
                    flg = true;
                }
                if(i + 1 < H && s.at(i+1).at(j) == '#'){
                    flg = true;
                }
                if(j + 1 < W && s.at(i).at(j+1) == '#'){
                    flg = true;
                }

                if(flg){
                    continue;
                } else { 
                    i_flg = false;
                    break;
                }
            }
        }
        if(i_flg){
            continue;
        } else { 
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> s(H);
    for(int i = 0 ; i < H ; i++){
        std::cin >> s[i];
    }
    solve(H, W, std::move(s));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 101;

int min(int a, int b);
int main(){
  int i, j, k, l;
  int n, p[N], m[N][N];
  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ){
    scanf("%d %d", &p[i-1], &p[i]);
  }

  for ( i = 1; i <= n; i++ ) m[i][i] = 0;
  for ( l = 2; l <= n; l++ ){
    for ( i = 0; i <= n-l+1; i++ ){
      j = i+l-1;
      m[i][j] = (1<<21);
      for ( k = i; k <= j-1; k++ ){
	m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n", m[1][n]);
  
  return 0;
}

int min(int a, int b){
  if(a<b){return a;
  }else{return b;
  }
}



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

int main() {
	string S; long long K;
	cin >> S >> K;
	for (int i = 0; i < min((long long)S.size(), K); i++) {
		if (S[i] >= '2') { cout << S[i] << endl; return 0; }
	}
	cout << '1' << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;

ll dp[10], dpp[10];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        dp[1] = a + max(dpp[2], dpp[3]);
        dp[2] = b + max(dpp[1], dpp[3]);
        dp[3] = c + max(dpp[2], dpp[1]);
        dpp[1] = dp[1];
        dpp[2] = dp[2];
        dpp[3] = dp[3];
    }
    cout << max(dp[1], max(dp[2], dp[3]));
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>
using namespace std;

bool mycomp(pair<string, pair<int, int>> &a, pair<string, pair<int, int>> &b)
{
	if (a.first < b.first)
	{
		return true;
	}
	if (a.first == b.first)
	{
		return a.second.first > b.second.first;
	}
	return false;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pair<string, pair<int,int>>> all;
	for (int i = 1; i <= n; i++)
	{
		string x;
		int a;
		cin >> x >> a;
		all.push_back({ x, {a,i} });
	}
	sort(all.begin(), all.end(), mycomp);
	for (auto i : all)
	{
		cout << i.second.second << "\n";
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;
const int mod = 1e9 + 7;
int n, a[MAXN], l[MAXN], r[MAXN];
lint fact[MAXN], invf[MAXN];

lint bino(int x, int y){
	if(y < 0 || x < y) return 0;
	return fact[x] * (invf[y] * invf[x-y] % mod) % mod;
}

lint ipow(int x, int p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

int main(){
	fact[0] = invf[0] = 1;
	for(int i=1; i<MAXN; i++){
		fact[i] = fact[i-1] * i % mod;
		invf[i] = ipow(fact[i], mod - 2);
	}
	cin >> n;
	memset(l, 0x3f, sizeof(l));
	for(int i=1; i<=n+1; i++){
		scanf("%d",&a[i]);
		l[a[i]] = min(l[a[i]], i);
		r[a[i]] = max(r[a[i]], i);
	}
	int x = 0;
	for(int i=1; i<=n; i++){
		if(l[i] != r[i]){
			x = l[i] - 1 + (n + 1 - r[i]);
		}
	}
	for(int k=1; k<=n+1; k++){
		lint ret = bino(n-1, k) + 2 * bino(n - 1, k - 1) - bino(x, k - 1) + bino(n - 1, k - 2);
		ret += mod;
		ret %= mod;
		printf("%lld\n", ret);
	}
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  map<lli,lli>mp;
  map<string,lli>ms;
  cin >> N >> K;
  Vec(P,lli,110,0);
  rep(i,0,K){
      cin >> A;
      P[A]=1;
    }
    num=INF;
    rep(i,-200,200){
        if(i>-1){
            if(!P[i])chmin(num,abs(i-N));    
        }
        else chmin(num,abs(i-N));
    }
    sum=INF;
    if(N-num>=0){
        if(!P[N-num])sum=(N-num);
    }
    if(sum==INF&&!P[N+num])sum=(N+num);
    Out(sum);

}

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

long long N;
long long total = 0;

int main(void){

    cin >> N;

    for (int i = 1;i <= N;i++){
        long long maxV = N / i;
        long long maxY = i * maxV;
        total += maxV * (maxV + 1) * i / 2;
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int []x = new int [n];
		
		for(int i = 0; i < n ; i++) {
			x[i] = sc.nextInt();
		}
		int now = x[0];
		
		long sum = 0;
		
		for(int i = 1 ; i < n ; i++) {
			int temp = x[i] - now;
			if((long)a * temp > b) {
				sum += b;
				
			}
			else {
				sum += (long) a * temp;
			}
			now = x[i];
		}
		
		System.out.println(sum);

	}

}


Measured memory_bytes: 50184
#include <stdio.h>

int main(void){
	
	int a,i=0,b;
	scanf("%d",&a);
	b=a;
	while(a>0){
		i=i+a%10;
		a=a/10;
	}
	if(b%i==0)printf("Yes\n");
	if(b%i!=0)printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string, int> s;
    int q, a, b, c;
    string key;
    cin >> q;
    rep(i, q) {
        cin >> a >> key;
        if(a == 0) {
            cin >> b;
            s[key] = b;
        } else if(a == 1) {
            cout << s.at(key) << "\n";
        }
    }
}



Measured memory_bytes: 25952
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 +10;
int n;
int h[maxn];

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    int temp = 0;
    int ans=0;
    for(int i=1;i<n;i++){
        if(h[i]>h[i-1]){
            ans=max(ans,temp);
            temp = 0;
        }
        else temp++;
    }
    ans = max(ans,temp);
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	string s, t; cin >> s >> t;
	string ss = "";
	for (int i = 0; i < n; i++) {
		ss += s[i];
		ss += t[i];
	}
	cout << ss << endl;
	return 0;
}

/*

*/

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;
ll a[1010], bit[1010];
ll dp[1010][(1<<12)+10];

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

  rep( i, M ) {
    ll b;
    std::cin >> a[i] >> b;

    rep( j, b ) {
      ll c;
      std::cin >> c;
      --c;

      bit[i] |= 1<<c;
    }
  }

  rep( i, M+1 ) rep( j, 1<<N )
    dp[i][j] = INF;

  dp[0][0] = 0;

  rep( i, M ) rep( j, 1<<N ) {
    chmin( dp[i+1][j], dp[i][j] );
    chmin( dp[i+1][j|bit[i]], dp[i][j]+a[i] );
  }

  std::cout << (dp[M][(1<<N)-1]!=INF ? dp[M][(1<<N)-1] : -1) << std::endl;

  return 0;
}

Measured memory_bytes: 32384
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj1137().doIt();
	}
	class aoj1137{
		char keta[] = {'i','x','c','m'};
		char keta2[] = {'2','3','4','5','6','7','8','9'};
		int number(char ctr[]){
			int result = 0;
			int num2 = 1;
			int num = 1;
			for(int i = 0;i < ctr.length;i++){
				for(int j = 0;j < 4;j++){
					if(keta[j] == ctr[i]){
						result = result + (num * num2);
						num2 = 1;
						break;
					}
					num = num * 10;
				}
				num = 1;
				for(int j = 0;j < 8;j++){
					if(keta2[j] == ctr[i])num2 = num2 * (j+2);
				}
			}
			return result;
 		}
		void doIt() {
			int n = sc.nextInt();
			for(int i = 0;i < n;i++){
				String a = sc.next();
				String b = sc.next();
				char ctra[] = a.toCharArray();
				char ctrb[] = b.toCharArray();
				int sum = number(ctra) + number(ctrb);
				int m = 1000;
				for(int j = 3;j >= 0;j--){
					int ans = sum / m;
					if(ans > 1){
						System.out.print(ans);
						System.out.print(keta[j]);
					}else if(ans == 1){
						System.out.print(keta[j]);
					}
					sum = sum % m;
					m = m / 10;
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 25972
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
y = []
sum = 0
1.upto(n) do |i|
  sum += a[i-1] * ((i % 2 == 1) ? 1 : -1)
end
y[0] = sum
2.upto(n) do |i|
  y[i-1] = 2 * (a[i-2] - y[i-2] / 2)
end
result = ''
y.each do |x|
  result << x.to_s << " "
end
result.chop!
puts result

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

#define endl '\n'

using namespace std;

const int MAXN=1e5+3;
int dp[MAXN],height[MAXN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>height[i];
        dp[i]=1e9;
    }
    dp[0]=0;
    for(int i=1;i<n;++i){
        for(int i2=1;i2<3;++i2){
            if(i2<=i){
                dp[i]=min(dp[i],dp[i-i2]+abs(height[i]-height[i-i2]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
return 0;
}

Measured memory_bytes: 1024
//@Author: wxyww
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
#include<cmath>
#include<map>
#include<string>
using namespace std;
typedef long long ll;

ll read() {
	ll x = 0,f = 1; char c = getchar();
	while(c < '0' || c > '9') {if(c == '-') f = -1;c = getchar();}
	while(c >= '0' && c <= '9') {x = x * 10 + c - '0',c = getchar();}
	return x * f;
}

int main() {
	int a = read(),b = read();
	for(int i = 0;i <= 3000;++i) {
		if(a * i - i + 1 >= b) {
			cout<<i<<endl;
			return 0;	
		}
	}

	return 0;
}

Measured memory_bytes: 256