akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    vector<vector<char>> c(2,vector<char>(2));
    c[0][0]='R';c[0][1]='D';c[1][0]='U';c[1][1]='L';
    vp v(n);
    rep(i,n)cin>>v[i].fi>>v[i].se;
    int b=(v[0].fi+v[0].se+inf+1)%2;
    REP(i,1,n)if((v[i].fi+v[i].se+inf+1)%2!=b)dame(-1);
    if(!b)rep(i,n)v[i].fi--;
    rep(i,n)v[i]=P(v[i].fi-v[i].se,v[i].fi+v[i].se);
    if(b)out(31);
    else out(32);
    for(ll k=30;k>=0;k--){
        cout<<(1<<k);
        if(k)cout<<' ';
        else if(b)cout<<endl;
        else cout<<' '<<1<<endl;
    }
    rep(i,n){
        for(ll k=30;k>=0;k--){
            int a=1,d=1;
            if(v[i].fi>=0){
                a=0;v[i].fi-=1<<k;
            }
            else v[i].fi+=1<<k;
            if(v[i].se>=0){
                d=0;v[i].se-=1<<k;
            }
            else v[i].se+=1<<k;
            cout<<c[a][d];
        }
        if(!b)out('R');
        else cout<<endl;
    }
}

Measured memory_bytes: 256
s = input()

indexa = 0
indexz = 0
for i in range(len(s)):
    if s[i] == 'A':
        indexa = i
        break

for i in range(len(s) - 1, 0, -1):
    if s[i] == 'Z':
        indexz = i
        break

print(indexz - indexa + 1)

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int N, K;
    cin >> N >> K;

    ll ruiseki[N+10];
    FILL0(ruiseki);
    ll mruiseki[N+10];
    FILL0(mruiseki);
    rep(i, N+1)
    {
        ruiseki[i+1]=ruiseki[i]+i;
        mruiseki[i+1]=mruiseki[i]+N-i; 
    }

    ll ans =0;

    for(int i=K; i<=N+1; i++)
    {
        ans+=mruiseki[i]-ruiseki[i]+1;
        ans%=MOD;
        //cout << i <<" " << mruiseki[i] << " " << ruiseki[i] << endl;
    }
/*
    rep(i, N+2)
    {
        cout << mruiseki[i] << endl;
    }
*/
    cout << ans << endl;
 

 


    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



Measured memory_bytes: 6728
function Main(input) {
  // 入力値（文字列）をスペースで区切り、配列として格納し各要素の値を数値に変換
  const result = input
  .split(/\s/);
  var test = Number(result[0]);
  if(0 <= test && test < 1000 ){
    console.log('ABC');
  }else {
    console.log('ABD');

  }
};
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n;
  cin >> n;
  vi32 l(n);
  rep(i, n) cin >> l[i];
  sort(all(l));
  int sum = 0;
  rep(i, n - 1) sum += l[i];
  if (sum <= l[n - 1]) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 384
import sys

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)
        self.potential=[0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            r = self.Find_Root(self.root[x])
            self.potential[x] += self.potential[self.root[x]]
            self.root[x]=r
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y, d):
        d+=self.potential[x]-self.potential[y]
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
            self.potential[y]=d

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            self.potential[x]=-d
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    
    def dist(self,x,y):
        if self.isSameGroup(x,y):
            return self.potential[y]-self.potential[x]
        else: return -10**10



INF=10**10

N,M=map(int,input().split())
if M==0: print("Yes"),sys.exit()

tree=UnionFind(N)
dist=[list(map(int,input().split())) for i in range(M)]

for i in range(M):
    l,r,d=dist[i]
    if tree.isSameGroup(l,r) and tree.dist(l,r)!=d: print("No"),sys.exit()
    tree.Unite(l,r,d)

print("Yes")

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


int main()
{
  	int N;
	long int count;
	cin >> N;
	count=0;
	string S[N];
	for (int i=0;i<N;i++){
		cin >> S[i];
		sort(S[i].begin(),S[i].end());
      	//cout << S[i] << endl;
	}
	sort(S, S+N);
	
	for (int i=0;i< N;i++){
		if (S[i]==S[i+1]){
			count++;
			for (int k=i+1;k< N;k++){
				if(S[i]==S[k+1])count = count+k-i+1;
				if(S[i]!=S[k+1]){
					i=k;
					break;
				}
			}
		}
	} 
	cout << count << endl;
	return 0;
}

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

const int MAX_N = 100010;
int par[MAX_N];

void init(int n){
    memset(par, -1, sizeof(par));
}

int root(int x){
    return par[x] < 0 ? x : par[x] = root(par[x]);
}

long long merge(int x, int y){
    x = root(x);
    y = root(y);
    
    if (x != y){
        if (par[x] > par[y])
            swap(x, y);
        
        long long ret = 1LL * par[x] * par[y];
        par[x] += par[y];
        par[y] = x;

        return ret;
    }

    return 0;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    
    vector<pair<int, int>> p;
    for (int i = 0; i < m; i++){
        pair<int, int> pp;
        cin >> pp.first >> pp.second;
        p.push_back(pp);
    }

    init(n);
    
    vector<long long> ans;
    long long cnt = 1LL * n * (n - 1) / 2;
    for (int i = m - 1; i >= 0; i--){
        ans.push_back(cnt);
        cnt -= merge(p[i].first, p[i].second);
    }

    reverse(ans.begin(), ans.end());
    for (auto i: ans)
        cout << i << '\n';

    return 0;
}


Measured memory_bytes: 3444
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;

//String With Rings
public class Main{

	List<Integer>[] e;
	int res;
	boolean[] v;
	
	void dfs(int k, int d){
		res = Math.max(res, d);
		for(int x:e[k])if(!v[x]){
			v[x] = true;
			dfs(x, d+1);
			v[x] = false;
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
//		sc.nextInt();
//		long T = System.currentTimeMillis();
		Random rand = new Random(1334259345907L);
//		System.out.println(T);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			e = new List[101];
			for(int i=1;i<101;i++)e[i]=new ArrayList<Integer>();
			boolean[] u = new boolean[101];
			while(n--!=0){
				int a = sc.nextInt(), b = sc.nextInt();
				u[a] = u[b] = true;
				e[a].add(b); e[b].add(a);
			}
			v = new boolean[101];
			res = 0;
//			int min = 150, max = 0;
//			for(int i=1;i<101;i++)if(u[i]){
//				min = Math.min(min, e[i].size()); max = Math.max(max, e[i].size());
//			}
			int[] a = new int[100];
			int id = 0;
			for(int i=1;i<101;i++)if(!e[i].isEmpty())a[id++] = i;
			Set<Integer> U = new HashSet<Integer>();
			for(int i=0;i<=id/3;i++){
				Arrays.fill(v, false);
				int s = rand.nextInt(id);
				while(U.contains(s))s = rand.nextInt(id);
				v[a[s]] = true;
				dfs(a[s], 1);
			}
//			for(int i=1;i<101;i++)if(u[i]){
//				Arrays.fill(v, false);
//				v[i] = true;
//				long S = System.currentTimeMillis();
//				dfs(i, 1);
//				System.out.println("S:"+i+" Time:"+(System.currentTimeMillis()-S)+" ms." + " RES:"+res);
//			}
			System.out.println(res);
		}
//		System.out.println((System.currentTimeMillis()-T)+" ms.");
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	cin >> input;
	int len = input.size();
	for (int i = 0; i < input.size(); i++)
	{
		cout << "x";
	}
	cout << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

class Program
{

    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var value = DateTime.Parse(S);
        var limit = new DateTime(2019, 4, 30);
        string result = null;
        if (value <= limit)
        {
            result = "Heisei";
        }
        else
        {
            result = "TBD";
        }

        Console.WriteLine(result);

    }
}



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

int main() {
  int n, m;
  cin >> n >> m;
  
  int a[m] = {};
  int b[m] = {};
  int cnt[n] = {};
  
  rep(i, m){
  	cin >> a[i] >> b[i];
  }
  
  rep(i, m){
    cnt[a[i]-1] += 1;
    cnt[b[i]-1] += 1;
  }
  
  rep(i, n){
  	cout << cnt[i] << endl;;
  }
  
}

Measured memory_bytes: 3528
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

typedef long long LL;
const int N = 100000 + 5;

int n;
int a[N];
vector<int> adj[N];

LL dfs(int u, int f)
{
    if (adj[u].size() == 1) {
        return a[u];
    }
    LL sum = 0;
    LL mx = 0;
    for(auto v: adj[u]) {
        if (v == f) continue;
        LL tmp = dfs(v, u);
        if (tmp < 0) return -1;
        mx = max(mx, tmp);
        sum += tmp;
    }
    LL x = sum - a[u];
    LL can = min(sum / 2, sum - mx);
    if (x < 0 || can < x) {
        return -1;
    }
    //cout << u << ' ' << a[u] - x << endl;
    return a[u] - x;
}

void solve()
{
    cin >> n;
    for(int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
    }
    for(int i = 1; i < n; ++ i) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u, --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    if (n == 2) {
        if (a[0] == a[1]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return;
    }
    for(int i = 0; i < n; ++ i) {
        if (adj[i].size() > 1) {
            LL tmp = dfs(i, -1);
            if (tmp) {
                cout << "NO" << endl;
            } else {
                cout << "YES" << endl;
            }
            return;
        }
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool recur(ll n,ll k){
    if(n==1)return 1;
    if(n<1)return 0;
    if(n%k==0)return recur(n/k,k);
    return recur(n-k,k);
}
ll solve(ll n){
    ll ans=0;
    for(ll k=2;k<=n;k++){
        if(recur(n,k))ans++;//cout<<k<<" ";
    }
    //cout<<endl;
   // cout<<"ANS: "<<ans<<" "<<n-ans<<endl;
    return ans;
}
ll brute(ll k,ll n){
    while(n%k==0)n/=k;
    return (n%k==1);
}
ll calc(ll div,ll n){
    ll ans=0;
    set<ll> st={n};
    for(ll i=2;i*i<=div;i++){
        if(div%i)continue;
        if(brute(i,n))st.insert(i);
        if(i*i!=n && brute(n/i,n))st.insert(n/i);
    }
    return st.size();
}
int main(){
   /*  for(ll n=2;n<=1e6;n++){
        ll v1=solve(n);
        ll v2=calc(n,n)+calc(n-1,n);
        cout<<n<<endl;
        if(v1==v2)continue;
        cout<<n<<"-->"<<v1<<" "<<v2<<endl;
    }*/
    ll n;cin>>n;
    if(n==2)return cout<<"1" , 0;
    ll ans = calc(n,n) + calc(n-1,n);
    cout<<ans;
}


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

int main() {
    long long k;
    long long x;
    cin >> k >> x;
    long long coins = (k * 500);
    if (coins >= x) {
        cout << "Yes" << endl; 
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
m = max(A) + 1
cnt = [0]*m
for i in A:
    cnt[i] += 1
ans = 0
for i in range(1,m):
    if cnt[i]:
        if cnt[i]==1:
            ans += 1
        for j in range(i,m,i):
            cnt[j] = 0
print(ans)

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

using namespace std;


int main() {
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if(h <= a && w <= b) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int n, q;
    cin >> n;
    vector<int> a(n);
    vector<ll> num(100001, 0);
    ll sum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i], sum += a[i];
        ++num[a[i]];
    }
    cin >> q;
    vector<int> b(q), c(q);
    for (int i = 0; i < q; ++i)
    {
        cin >> b[i] >> c[i];
    }
    vector<ll> res(q);
    for (int i = 0; i < q; ++i)
    {
        res[i] = sum - num[b[i]] * b[i] + num[b[i]] * c[i];
        sum = res[i];
        num[c[i]] += num[b[i]];
        num[b[i]] = 0;
    }
    for (int i = 0; i < q; ++i)
    {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;
const ll N = 2e5 + 5;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

vlli v[N+1];

ll ans[N] = {};

ll vis[N] = {};

void fn(ll x){
	
	if(!vis[x]){
		// cout<<x<<endl;
		vis[x] = 1;
		forn(i, 0, v[x].size()){
			if(!vis[v[x][i]]){
				ans[v[x][i]]+=ans[x];
			}
			// forn(j, 1, 5){
			// 	cout<<ans[j]<<" ";
			// }
			// cout<<endl;
			fn(v[x][i]);

		}
	}
}


int main(){
	fast;
	ll n, q;
	cin>>n>>q;
	ll x, y;
	forn(i, 0, n-1){
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}

	// forn(i, 1, n+1){
	// 	forn(j, 0, v[i].size()){
	// 		cout<<v[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	
	forn(i, 0, q){
		cin>>x>>y;
		ans[x]+=y;
	}
	// print(ans, 1, n+1);
	// cout<<endl;
	fn(1);

	print(ans, 1, n+1);
	cout<<endl;
}

Measured memory_bytes: 27068
s=input()
n=len(s)
for i in range(n-2):
  if s[i]==s[i+2]:
    print(i+1,i+3)
    break
  elif s[i]==s[i+1]:
    print(i+1,i+2)
    break
else:
  if s[n-2]==s[n-1]:
    print(n-1,n)
  else:
    print(-1,-1)

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

using namespace std;

typedef long long ll;

const int N = 2e5+5;

int n;
int a[N];
int b[N];
int c[N];

int main(){
    scanf("%d " , &n);
    for(int i = 1; i <= n; i++){
        scanf(" %d" , &a[i]);
    }
    for(int i = 1; i <= n; i++){
        scanf(" %d" , &b[i]);
    }
    for(int i = 1; i <= n; i++){
        scanf(" %d" , &c[i]);
    }
    sort(a + 1 , a + n + 1);
    sort(c + 1 , c + n + 1);

    long long ans = 0;
    for(int i = 1; i <= n; i++){
        //a < b < c
        auto f = upper_bound(a + 1 , a + n + 1 , b[i] - 1);
        auto s = upper_bound(c + 1 , c + n + 1 , b[i]);
        /*if(b[i] <= a[1])
            continue;
        if(b[i] >= c[n])
            continue;*/
        long long v1 = f - a - 1;
        long long v2 = n - (s - c) + 1;
        //cout << i << " " << v1 << " " << v2 << "\n";
        ans += v1 * v2;
    }
    printf("%lld\n" , ans);
}

Measured memory_bytes: 4988
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
using namespace std;

int main(void)
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int c2 = 2 * C;

	int cost;
	int ret = INT_MAX;
	for(int i=0; i<=max(X, Y); i++){
		cost = i * c2;
		cost += A * max(0, X-i);
		cost += B * max(0, Y-i);

		ret = min(ret, cost);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define pb           push_back
#define ff           first
#define ss           second
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
using namespace std;

ll expo(ll a,ll b,ll m = mod){
	a%=mod;
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%m;
		a = (a*a)%m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
const int N = 1e5+1;
vector<int> adj[N];
vector<int> dp(N,-1);
int dfs(int u){
    int len = 0;
    for(auto v:adj[u]){
        if(dp[v]!=-1)
        len = max(len,1+dp[v]);
        else
        len = max(len,1+dfs(v));
    }
    return dp[u]=len;
}
int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int n,m;
              cin>>n>>m;
              rep(i,0,m){
                  int u,v;
                  cin>>u>>v;
                  adj[u].pb(v);
              }
              rep(i,1,n+1){
                 if(dp[i]==-1)
                     dfs(i); 
              }
              int mx = 0;
              rep(i,1,n+1){
                  mx = max(mx,dp[i]);
              }
              cout<<mx<<"\n";
	}
    return 0;
}


Measured memory_bytes: 11008
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n;cin>>n;
    vector<LL> a(n);
    REP(i,n){
        cin>>a[i];
    }
    int offset = 3;

    vector<map<int,LL>> dp0(n);
    vector<map<int,LL>> dp1(n);
    REP(i,n){
        //dp0[i].resize(n,-INF_LL);
        //dp1[i].resize(n,-INF_LL);
        //dp0[i].resize(10,-INF_LL);
        //dp1[i].resize(10,-INF_LL);
    }
    //REP(j,n){
    //    dp1[0][j] = a[0];
    //}
    REP(i,n){
        int start = max(0,i/2 -2*offset);
        int end = min(n/2+1, i/2  +2*offset);
        FOR(j,start,end){
            dp0[i][j] = -INF_LL;
            dp1[i][j] = -INF_LL;
        }
    }
    dp0[0][0] = 0;
    dp1[0][1] = a[0];

    FOR(i,1,n){
        int start = max(0,i/2 -offset);
        int end = min(n/2+1, i/2  +offset);
        //int start = 0;
        //int end = n;

        FOR(j,start,end){
            dp0[i][j] = max(dp0[i-1][j],dp1[i-1][j]);
            if(j == 0){
                
            }
            else if(j == 1){
                dp1[i][j] = a[i];
            }
            else{
                dp1[i][j] = dp0[i-1][j-1] + a[i];
            }
        }
    }

    cout << max(dp0[n-1][n/2], dp1[n-1][n/2])<<endl;


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 323392
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
use utf8;


<STDIN>;

my @num;
{
    my $line_2nd = <STDIN>;
    my @n = split(/\s+/, $line_2nd);
    for(my $i=0;$i<=$#n;$i++){
        push(@num, {
                index => $i + 1,
                value => $n[$i]+0
            });
    }
}

my @reslut;
for(sort {$a->{value} <=> $b->{value}} @num){
    push(@reslut, $_->{index});
}

say "@reslut";


Measured memory_bytes: 43228
#include <iostream>
#include <vector>

using namespace std;

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

	vector<string> S(N);
	for (auto& i: S)
	{
		cin >> i;
	}

	int a = 0, b = 0, c= 0, d = 0;
	for (int i = 0; i < N; ++i)
	{
		if (S[i] == "AC") a++;
		if (S[i] == "WA") b++;
		if (S[i] == "TLE") c++;
		if (S[i] == "RE") d++;
	}

	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;

	return 0;
}

Measured memory_bytes: 6400
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

struct BipartiteMatching {
    int n, timestamp;
    vector<vector<int>> graph;
    vector<int> alive, used, match;
    BipartiteMatching(int n) : \
        n(n), timestamp(0), graph(n), alive(n, 1), used(n, 0), match(n, -1) { }
    void add_edge(int u, int v) {
        graph[u].emplace_back(v);
        graph[v].emplace_back(u);
    }
    bool dfs(int idx) {
        used[idx] = timestamp;
        for (auto &to: graph[idx]) if (alive[to]) {
            int to_match = match[to];
            if (to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
                match[idx] = to;
                match[to] = idx;
                return true;
            }
        }
        return false;
    }
    int bipartite_matching() {
        int ret = 0;
        for (int i = 0; i < n; i++) if (alive[i]) {
            if (match[i] == -1) ++timestamp, ret += dfs(i);
        }
        return ret;
    }
    friend ostream& operator<<(ostream& os, BipartiteMatching& bm) {
        for (int i = 0; i < bm.n; i++) if (i < bm.match[i]) {
            os << i << " - " << bm.match[i] << endl;
        }
        return os;
    }
};

int main() {
    int N, M, L;
    while (cin >> N >> M >> L, N) {
        vector<vector<int>> dist(N, vector<int>(N, INF));
        for (int i = 0; i < N; i++) dist[i][i] = 0;
        for (int i = 0; i < M; i++) {
            int u, v, d; cin >> u >> v >> d;
            dist[u][v] = dist[v][u] = d;
        }
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
        vector<int> p(L), t(L);
        for (int i = 0; i < L; i++) cin >> p[i] >> t[i];
        BipartiteMatching bm(2 * L);
        for (int i = 0; i < L; i++) for (int j = 0; j < L; j++) if (i != j) {
            if (dist[p[i]][p[j]] <= t[j] - t[i]) bm.add_edge(i, j + L);
        }
        cout << L - bm.bipartite_matching() << endl;
    }
    return 0;
}


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

int main() {
  long n,k,ans=0;
  cin >> n >> k;

  if(k==0) {
    ans=n*n;
  } else {
    for(long b=k+1;b<=n;b++) {
      ans+=n/b*(b-k);
      if(n%b>=k) ans+=n%b-k+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>

#define maxn 5010
#define inf (ll) 1<<30 

using namespace std ;
typedef long long ll ;
int A,B ;
int stack[maxn] ;
int top = 0 ;
string ans ;
char tmp[100] ;

int main(void){
	scanf("%d%d",&A,&B) ;
	if(A<=B) {
		printf("Impossible\n") ;
		return 0 ;
	}
	int total = A + B ;
	stack[top] = 0 ;top ++ ;
	for(int i=1; i<total; i++ ) {
		if(top==0) {
			stack[top] = i ; top ++ ;
		}
		else  {
			printf("? %d %d\n",stack[top-1],i) ;  fflush(stdout);
			char ch ;
			scanf("%*c%c",&ch) ;
			if(ch=='Y') {
				stack[top] = i ; top ++ ;
			} else {
				top-- ;
			}
		}
	}
//	for(int i=0; i<top; i++) printf("%d ",stack[i]) ;
//	printf("hahah\n") ;
	if(top==0) {
		printf("Impossible\n") ;
		return 0 ;	
	}
	ans = "! " ;  //! 101
	int k = stack[top-1] ;
	for(int i=0; i<total; i++) {
		if(i!=k) {
			printf("? %d %d\n",k,i) ;  fflush(stdout);
			char ch ;
			scanf("%*c%c",&ch) ;
			if(ch=='Y') ans += '1' ;
			else ans += '0' ;
			
		} else ans += '1' ;
	}

	printf("%s\n",ans.c_str()) ;


	return 0 ;

}

Measured memory_bytes: 724
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>

using namespace std;

int main(){
  int d,g; cin >> d >>g;
  int p[d],c[d];
  for(int i=0;i<d;i++){
    cin >> p[i] >> c[i];
  }
  
  int ans=1e8; long long res=0;
  for(int bit=0;bit<(1<<d);bit++){
    res=0; int last=-1,cnt=0;
    
    for(int i=0;i<d;i++){
      if((bit>>i&1)){
      res += p[i]*(i+1)*100+c[i];
      cnt +=p[i];
      }
    else last=i;
    }
   if(last != -1 && res<g && res+p[last]*(last+1)*100>=g){
     while(res<g){
      res+=(last+1)*100;
      cnt++;
     }
    ans=min(ans,cnt);
   }
  if(res>=g) ans=min(ans,cnt);
 }
cout << ans <<endl;
}
    

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N; cin >> N;
    VI a(N); REP(i,N) cin >> a[i];
    VI b(N,0);
    RREP(i,N){
        int tmp = 0;
        for(int j=2*(i+1)-1; j<N; j+=i+1) tmp += b[j];
        if(tmp%2 != a[i]) b[i] = 1;
    }
    int M = 0; REP(i,N) M += b[i];
    cout << M << endl;
    REP(i,N) if(b[i]) cout << i+1 << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
H,W=map(int, input().split())
S=[list(input()) for _ in range(H)]

def mine(i,j):
  if i<0 or j<0 or i>=H or j>=W:
    return 0
  else:
    if S[i][j]=="#":
      return 1
    else:
      return 0

ij=[-1,0,1]
    
    
for i in range(H):
  for j in range(W):
    if S[i][j]==".":
      tmp=0
      for ii in ij:
        for jj in ij:
          if ii==jj and ii==0:
            1
          else:
            tmp+=mine(i+ii,j+jj)
      S[i][j]=tmp
#print(S)

for i in range(H):
  print("".join(map(str,S[i])))

Measured memory_bytes: 3064
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;



int main(){
  int h,n,count,sum =0;
  cin >> h >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n) sum = sum + a.at(i);
  
  if(sum >= h){
    cout << "Yes";
  }
  else{
    cout << "No";
  }


}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; ++k)
#define trb(k,en,st) for(int k = en; k >= st ; --k)

using namespace std;


int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    
    
    int base = 1;
    while (base <= n) {
        base *= 2;
    }
    vector<int> tree(2*base);
    
    
    vector<int> dp(n+1), height(n), beauti(n);
    map<int, int> till_now;
    for (int i = 0 ; i < n; i++) {
        cin>>height[i];
    }
    for (int i = 0 ; i < n; i++) {
        cin>>beauti[i];
    }
    tr(pos,0,n-1){
        
        // finding with segment tree:
        int x = height[pos] + base;
        int best = 0;
        while (x > 1) {
            if (x%2 == 1) {
                best = max(best, tree[x-1]);
            }
            x/=2;
        }

        //        int ma = *max_element(dp.begin(), dp.begin() + height[pos]);
        dp[height[pos]] = beauti[pos] + best;
        
        for(int index = base + height[pos]; index >=1 ; index /=2){
            tree[index] = max(tree[index], dp[height[pos]]);
        }
        
    }
    cout<<*max_element(dp.begin(), dp.end())<<endl;
}


//  int n;
//  cin>>n;
//  vector<int> dp(n+1), height(n), beauti(n);
//  map<int, int> till_now;
//  fo`r (int i = 0 ; i < n; i++) {
//      cin>>height[i];
//  }
//  for (int i = 0 ; i < n; i++) {
//      cin>>beauti[i];
//      auto it = till_now.lower_bound(height[i]);
//      it--;
//      dp[i + 1] = max(dp[i] ,dp[it->second] + beauti[i]);
//      till_now.insert({height[i], i});
//  }
//  cout<<dp[n]<<endl;


Measured memory_bytes: 11976
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
    	Scanner itr = new Scanner(System.in);
      	long a = (long)itr.nextInt();
      	long b = (long)itr.nextInt();
      	long c = (long)itr.nextInt();
      
      	a *= 4;
      	b *= 4;
      	c *= 4;
    
      	long left = (c - a - b);
      	left /= 2;
      	
      	if (left < 0) {
          	System.out.println("No");
        	return;
        }
      	left = left * left;
      
      	if (a * b < left)
          System.out.println("Yes");
      	else
          System.out.println("No");
    } 
}


Measured memory_bytes: 21972
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa,bb=[0],[0]
for i in range(n):
    aa.append(aa[-1]+a[i])
for i in range(m):
    bb.append(bb[-1]+b[i])
ans,j=0,m
for i in range(n+1):
    if aa[i]>k:
        break
    while bb[j]>k-aa[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   ll n,k,a;
  cin>>n>>k;
  double p,q=0;
  for(ll i=1;i<=n;i++){
     a=i;
     p=n;
    while(a<=k-1){
      a*=2;
      p*=2;
    }
    q+=1/p;
}
  printf("%.10lf\n",q);
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast
    ll n;
    cin >> n;
    cout << n/2 + bool(n%2) << endl;
}


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

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

ll N, W;
ll table[110][100010];

int main(int argc, char **argv)
{
	cin >> N >> W;
	vector<ll> w(N), v(N);
	for (ll i = 0; i < N; ++i) cin >> w[i] >> v[i];

	for (ll i = 0; i < N; ++i)
	{
		for (ll weight = 0; weight <= W; ++weight)
		{
			if (weight - w[i] >= 0) chmax(table[i+1][weight], table[i][weight-w[i]] + v[i]);
			chmax(table[i+1][weight], table[i][weight]);
		}
	}
	std::cout << table[N][W] << std::endl;
}

Measured memory_bytes: 79360
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    complex<ld>   P;
#define    X   real()
#define    Y   imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf   1000000000000000001
#define    ninf   -1000000000000000001
#define    ima   1000000001
#define    imi   -1000000001
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
int n,k;
ll x,y;
cin>>n>>k>>x>>y;
ll an=0;
for(int i=0;i<n;i++)
{
	if(i+1<=k)
	an+=x;
	else
	an+=y;
}

cout<<an;

}return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N, A, B;

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

  cin >> N >> A >> B;

  cout << min(A*N, B) << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    S=tuple(map(int,input().split()))
    T=tuple(map(int,input().split()))
    dp=[[0]*(M+1) for _ in range(N+1)]
    SUM=[[0]*(M+2) for _ in range(N+2)]
    ans=1
    for s in range(N):
        for t in range(M):
            if S[s]==T[t]:
                dp[s+1][t+1]=SUM[s+1][t+1]+1
                ans+=dp[s+1][t+1]
                ans%=MOD
            else:
                dp[s+1][t+1]=0
            SUM[s+2][t+2]=SUM[s+1][t+2]+SUM[s+2][t+1]-SUM[s+1][t+1]+dp[s+1][t+1]
            SUM[s+2][t+2]%=MOD
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 104156
#include "bits/stdc++.h"
using namespace std;

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

	int screen = 1;
	int i = 0;
	while (screen * 2 < screen + K && i < N) {
		screen *= 2;
	    i++;
	}
	for (int j = 0; j < N - i; j++) {
		screen += K;
		}

	cout << screen << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 1; i < n; ++i) {
		if (a[i] == a[i - 1]) {
			cout << "NO\n";
			return 0;
		}
 	}
 	cout << "YES\n";
 	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    int d,e,flag=0,i;
    cin>>a>>b;
    if(a.size()>b.size())
        cout<<"GREATER"<<endl;
    else if(a.size() <b.size())
        cout<<"LESS"<<endl;
    else
    {
        for(i=0;i<a.size();i++)
        {
            d=a[i]-'0';
            e=b[i]-'0';
            if(d>e)
            {
                flag=1;
                break;
            }
            else if(d<e)
            {
                flag=2;
                break;
            }
        }
        if(flag==1)
            cout<<"GREATER"<<endl;
        else if(flag==2)
            cout<<"LESS"<<endl;
        else
            cout<<"EQUAL"<<endl;
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main()
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = N;
    for (int i = 0; i <= N; i++)
    {
        int tmp = 0;
        int k = i;
        int j = N - i;
        while (k > 0)
        {
            tmp += k % 9;
            k /= 9;
        }
        while (j > 0)
        {
            tmp += j % 6;
            j /= 6;
        }
        if (ans > tmp)
            ans = tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int c =0;
    REP(i,n-1){
        if(s[i]==s[i+1])
            c++;
    }
    cout << min(n-1,c+k*2)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){

  int i,j,n,mini,si,a1[37],a2[37],a3[37],count=1,f=0;
  char sc,c1[37],c2[37],c3[37];

  //load N
  scanf("%d",&n);

  //load number
  for(i=1;i<=n;i++){
    scanf(" %c%d",&c1[i],&a1[i]);
    a2[i]=a1[i];
    c2[i]=c1[i];
    a3[i]=a1[i];
    c3[i]=c1[i];
  }

  //normal Sort  
  for(i=1;i<=13;i++){
    for(j=1;j<=n;j++){
      if(a1[j]==i){
	a3[count]=a1[j];
	c3[count]=c1[j];
	count++;
      }
    }
  }

  //BubbleSort
  for(i=1;i<=n;i++){
    for(j=n;j>=i+1;j--){
      //swap
      if(a1[j]<a1[j-1]){
        si=a1[j];
        a1[j]=a1[j-1];
        a1[j-1]=si;
	sc=c1[j];
	c1[j]=c1[j-1];
	c1[j-1]=sc;

	}
    }
  }
  //print
  for(i=1;i<=n;i++){
    printf("%c%d",c1[i],a1[i]);
    if(i!=n){
      printf(" ");
    }
  }
    printf("\n");

    //stability
    for(i=1;i<=n;i++){
      if(c1[i]!=c3[i]){
	printf("Not stable\n");
	f=1;
	break;
      }
    }  
    if(f==0)printf("Stable\n");

  //SelectionSort
  for(i=1;i<=n;i++){
    mini=i;
    for(j=i;j<=n;j++){
      if(a2[j]<a2[mini]){
        mini=j;
      }
    }
      //swap
      si=a2[i];
      a2[i]=a2[mini];
      a2[mini]=si;
      sc=c2[i];
      c2[i]=c2[mini];
      c2[mini]=sc;
  }


  //print
  for(i=1;i<=n;i++){
    printf("%c%d",c2[i],a2[i]);
    if(i!=n){
      printf(" ");
    }
  }
  printf("\n");

  //stability
  f=0;
  for(i=1;i<=n;i++){
    if(c2[i]!=c3[i]){
      printf("Not stable\n");
      f=1;
      break;
    }
  }  
  if(f==0)printf("Stable\n");
  
  
  

  return 0;

}

Measured memory_bytes: 0