akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
long long  beki(long long  b, long long e)
{
    long long m=mod;
    long long ans = 1;

    while (e > 0) {
       if ((e & 1) == 1) ans = (ans * b) % m;
       e >>= 1;
       b = (b * b) % m;
    }

    return ans;
}
#define SIZE 400010
long long MOD=mod;
using namespace std;
long long ans;

long long fac[SIZE],finv[SIZE],inv[SIZE];

void make() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long C(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//重複組み合わせ
long long H(int x,int y){
    return C(x+y-1,y);
}

int main(){
    make();

    long long n,k;
    cin>>n>>k;


    long long ans=0;
    k=min(n-1,k);

    for(long long i=0;i<=k;i++){
        //空き部屋がi個ある場合の組み合わせ
        ans+=(C(n,i)*H(n-i,i))%mod;
        ans%=mod;
    }
    /*
    if(k>=n-1){
        cout<<C(n+(n-1),n-1)<<endl;
    }

    else{
        long long ans=C(n+(n-1),n-1);
        //最終的な状態は
        //i番目の部屋の人数Aiについて
        //Ai<=k+1が成り立つ
        for(long long i=n;i>=k+2;i--){
                    ans-=(n*C(n-i+n-2,n-2))%mod;
                    if(ans<0)ans+=mod;
        }
        /*
        for(long long i=n;i>=k+2;i--){

            if(i==n){
                ans-=n;
                if(ans<0)ans+=mod;
            }
            else{


                
            /*
            long long select=n-i;//隙間の数
            long long pole=n-1;//間に挟む仕切りの数
            if(select<pole){
                pole-=select;//残った仕切りの数
            }
            //仕切りを隙間に分配する分け方
            ans-=C(pole+select-1,select-1);
            //ans-=beki(select,pole);
            //ans%=mod;
            
            //if(ans<0)ans+=mod;
            
        }
        */
        cout<<ans<<endl;
    
    return 0;

}
/*


*/


Measured memory_bytes: 9600
a,b,c,d,e,f = map(int,input().split())

total = 0
sugar = 0
max_concentration = 0

for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        for k in range(f//c+1):
            for l in range(f//d+1):
                if 0 < 100*(a*i+b*j)+(c*k+d*l)<=f and c*k+d*l<=e*(a*i+b*j):
                    if max_concentration <= (c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l)):
                        max_concentration = (c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l))
                        total = 100*(a*i+b*j)+(c*k+d*l)
                        sugar = (c*k+d*l)
print(total,sugar)

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

string s;
int K;
int n;

int main () {
	cin >> s >> K;
	n = (int) s.length();
	for (int i = 0; i < n-1; i ++) {
		if (s[i] == 'a') continue;
		int rem = 'z'-s[i]+1;
		if (K >= rem) {
			s[i] = 'a';
			K -= rem;
		}
	}
	K %= 26;
	s[n-1] = 'a' + (s[n-1]-'a'+K)%26;
	cout << s << endl;
	return 0;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  int cost = 1e9;
  rep(i, n) {
    int c, t;
    cin >> c >> t;

    if (t <= T) {
      cost = min(c, cost);
    }
  }
  if (cost == 1e9) p("TLE");
  else p(cost);
}

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn adjacent4(x: usize, y: usize, sx: usize, sy: usize) -> Vec<(usize, usize)> {
    [(-1, 0), (1, 0), (0, -1), (0, 1)]
        .into_iter()
        .filter_map(|&(dx, dy)| {
            let nx = x as isize + dx;
            let ny = y as isize + dy;
            if nx >= 0 && nx < sx as isize && ny >= 0 && ny < sy as isize {
                Some((nx as usize, ny as usize))
            } else {
                None
            }
        })
        .collect()
}

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
fn main() {
    input! {
        a:usize,
        b:usize,
    }
    let digit = b.to_string().len();
    let sum: usize = (a * (10usize.pow(digit as u32))) + b;
    let mut ans = false;
    for i in 0..(((sum as f64).sqrt() as usize) + 2) {
        if i * i == sum {
            ans = true;
            break;
        }
    }
    if ans == true {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

typedef pair<int, int> II;
typedef pair<II, II> IIII;
typedef long long LL;

int main(int argc, char* argv[]) {
	int n, m, q;
	cin >> n >> m >> q;
	vector<IIII> v(q);
	for (int i = 0; i < q; ++i) {
		cin >> v[i].first.first >> v[i].first.second >> v[i].second.first >> v[i].second.second;
		v[i].first.first -= 1;
		v[i].first.second -= 1;
	}
	vector<vector<int>> seq;
	for (int i = 1; i <= m; ++i) {
		seq.emplace_back(vector<int>(1, i));
	}
	for (int i = 2; i <= n; ++i) {
		vector<vector<int>> next;
		for (auto v : seq) {
			for (int d = v.back(); d <= m; ++d) {
				vector<int> w = v;
				w.emplace_back(d);
				next.emplace_back(w);
			}
		}
		seq = next;
	}
	LL ans = 0;
	for (auto a : seq) {
		LL score = 0;
		for (int i = 0; i < q; ++i) {
			if (a[v[i].first.second] - a[v[i].first.first] == v[i].second.first) {
				score += v[i].second.second;
			}
		}
		ans = max(ans, score);
	}
	cout << ans << endl;
	return 0;
}


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

int findSumOfDigits(int n){
  int sum = 0;
  while(n > 0) {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  
  int total = 0;
  
  for(int i=1; i<=n; i++){
    int sum = findSumOfDigits(i);
    if(sum >= a && sum <= b){
      total += i;
    }
  }
  
  cout << total << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        string s;
        cin>>s;
        n=4;
        for(i=1;i<n;i++){
                if(s[i]==s[i-1]){
                        cout<<"Bad\n";
                        return;
                }
        }
        cout<<"Good\n";
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long flag[55557];

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
    
    long count=0;
    long i,j;
    for(i=2; i<=55555; i++) {
        if(flag[i]) continue;

        long tmp = i+i;
        while(tmp<=55555) {
            flag[tmp]=1;
            tmp+=i;
        }

        if(i%5==1) {
            //printf("[%ld]%ld\n", count, i);
            printf("%ld", i);
            count ++;
            if(count==n) {
                printf("\n");
                return 0;
            }
            else {
                printf(" ");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

int main() {

	int H, A;
	cin >> H >> A;

	int ans = (H + A - 1) / A;
	cout << ans << endl;

	return 0;

}

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

int main()
{
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int H = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int flag = 0;

    BigDecimal wBig = new BigDecimal(W);
    BigDecimal hBig = new BigDecimal(H);
    BigDecimal xBig = new BigDecimal(x);
    BigDecimal yBig = new BigDecimal(y);
    BigDecimal two = new BigDecimal(2);

    BigDecimal half = wBig.multiply(hBig).divide(two, 9, RoundingMode.DOWN);

    if(xBig.equals(wBig.divide(two)) && yBig.equals(hBig.divide(two))) {
    	flag = 1;
    }

    System.out.println(half + " " + flag);
  }
}

Measured memory_bytes: 22864
#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;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 2e5+555;
int const inf = 2e16;
int a[N];
int b[N];
int c[N];

void solve(){  
    int n,i,j,l,m;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        b[a[i]]++;
    }

    for(i=1;i<=n;i++){
        c[b[i]]++;
    }

    int ans = 0;
    for(i=2;i<=n;i++){
        int x = i*(i-1)/2;
        ans = ans + x*c[i];
    }

    for(i=0;i<n;i++){
        int x = a[i];
        int pc = b[a[i]];
        int res = ans;
        res = res - (pc*(pc-1)/2);
        pc--;
        res = res + (pc*(pc-1)/2);
        cout<<res<<endl;
    }
}       


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

*/

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

#define ull unsigned long long
#define ll long long
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

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

int main(int argc, char *argv[])
{
    ll n, d;
    int cnt = 0;

    cin >> n >> d;

    for (ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= d*d)
            cnt++;
    }

    cout << cnt;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#define rep(i,a) for(int i=0;i<(a);++i)

constexpr int MAX_N = 100000;

int N;
std::string s;
bool fl[MAX_N];
bool ok;

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

	rep(i, 2) rep(j, 2)
	{
		rep(k, N - 2)
		{
			fl[0] = i;
			fl[1] = j;

			fl[k ? k + 1 : N - 1] = ((s[k] == 'x') - fl[k] - (k ? fl[k - 1] : fl[k + 1]) + 2) % 2;
		}

		if ((fl[N - 2] + fl[N - 3] + fl[N - 1]) % 2 == (s[N - 2] == 'x') && (fl[N - 1] + fl[N - 2] + fl[0]) % 2 == (s[N - 1] == 'x'))
		{
			ok = true;

			goto end;
		}
	}

end:;

	if (ok)
	{
		rep(i, N)
			printf("%c", fl[i] ? 'W' : 'S');
		puts("");
	}
	else
		puts("-1");

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    int a, b, c, i;
    
    scanf("%d %d %d", &a, &b, &c);
    
    for (a; a <= b; a++)
    {
        if (c % a == 0){
            i++;
        }
    }
    
    printf("%d\n", i);
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll M = 1e9 + 7, N = 1e6 + 5;
int main()
{
    long double a;
    long double b;
    cin >> a >> b;
    long double c = (long double) a * b;
    cout << (ll)c;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    for (int i = A; i <= A * B; i += A) {
        if (i % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

static const double pi = 3.141592653589793;

void koch(int n, double *p1, double *p2) {
    if(n==0) {
        return;
    }

    double s[2], t[2], u[2];

    //sのx座標、y座標を計算する
    s[0] = (2 * p1[0] + 1 * p2[0]) / 3;
    s[1] = (2 * p1[1] + 1 * p2[1]) / 3;
    //tのx座標、y座標を計算する
    t[0] = (1 * p1[0] + 2 * p2[0]) / 3;
    t[1] = (1 * p1[1] + 2 * p2[1]) / 3;
    //uのx座標、y座標を計算する
    u[0] = (t[0] - s[0]) * cos(pi/3) - (t[1] - s[1]) * sin(pi/3) + s[0];
    u[1] = (t[0] - s[0]) * sin(pi/3) + (t[1] - s[1]) * cos(pi/3) + s[1];

    koch(n-1, p1, s);
    cout << s[0] << " " << s[1] << endl;
    koch(n-1, s, u);
    cout << u[0] << " " << u[1] << endl;
    koch(n-1, u, t);
    cout << t[0] << " " << t[1] << endl;
    koch(n-1, t, p2);
}

int main() {
    int n;
    double p1[2], p2[2];
    p1[0] = 0.0;
    p1[1] = 0.0;
    p2[0] = 100.0;
    p2[1] = 0.0;
    cin >> n;
    cout << p1[0] << " " << p1[1] << endl;
    koch(n, p1, p2);
    cout << p2[0] << " " << p2[1] << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
int main(){
	string str;
	getline(cin, str);
	for (int i = 0; i<str.size(); ++i){
		if (isupper(str[i])) str[i] = tolower(str[i]);
		else if (islower(str[i])) str[i] = toupper(str[i]);
	}
	cout << str << '\n';
}

Measured memory_bytes: 1180
#include <iostream>
#include<math.h>
using namespace std;

int main(){
  int N,D,tmp,i=1;

  std::cin >> D;
  std::cin >> N;

  while(i<=N){
    if(N==100) tmp=i*pow(10,D*2)+pow(10,D*2);
    else tmp=i*pow(10,D*2);
    i++;
  }
  std::cout << tmp << '\n';
}


Measured memory_bytes: 256
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  char c;
  cin >> c;
  if (c >= 'a' && c <= 'z')
    cout << "a" << endl;
  else
    cout << "A" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const double PI=3.1415926535;
ll a[2000];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    ll cnt=0;
    for(int i=2;i<n;i++)
    {
        if((a[i]<a[i-1]&&a[i]>a[i+1])||(a[i]>a[i-1]&&a[i]<a[i+1]))
            cnt++;
    }
    cout<<cnt<<'\n';





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int s[100010];
int t[50010];
int ans;

void bs(int *a, int l, int r, int k)
{
	if(l+1 == r){
		if(a[l] == k)
			ans++;
		return;
	}
	int m = (l+r)/2;
	if(a[m] > k)
		bs(a, l, m, k);
	else
		bs(a, m, r, k);
}

int main()
{
	int n, q;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> s[i];
	cin >> q;
	for(int j = 0; j < q; j++){
		cin >> t[j];
		bs(s, 0, n, t[j]);
	}

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

Measured memory_bytes: 3576
#include<vector>
#include<iostream>
#include<string>
#include<cmath>
#include<set>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
#define Cout(s) cout<<(s)<<endl;
using ll = long long;

using namespace std;

int main() {
	set<string> m;
	int N;
	cin >> N;
	rep(i, N) {
		string a;
		cin >> a;
		m.insert(a);
	}
	Cout(m.size());
	return 0;
}

Measured memory_bytes: 19228
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int color[10000];
int indeg[10000];

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for(int i=0;i<m;++i){
    int a,b;
    cin >> a >> b;
    g[a].emplace_back(b);
    indeg[b]++;
  }

  vector<int> out;
  for(int u=0;u<n;++u){
    if(indeg[u]==0&&color[u]==0){
      queue<int> q;
      q.push(u);
      color[u] = 1;
      while(!q.empty()){
        auto v = q.front();q.pop();

        out.push_back(v);
        for(const auto &w:g[v]){
          indeg[w]--;
          if(indeg[w]==0&&color[w]==0){
            color[w] = 1;
            q.push(w);
          }
        }
      }
    }
  }
  for(auto o:out) cout << o << endl;
}

Measured memory_bytes: 3692
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

int main(){
	
	int n;
	cin >> n;
	
	int A[200], B[200];
	
	for(int i = 0; i < n; i++){
		cin >> A[i] >> B[i];
	}
	
	long long int DP[101][101] = {};
	for(int i = 1; i < n; i++){
		for(int j = 0; j + i < n; j++){
			DP[j][j + i] = INF;
			for(int k = 0; k < i; k++){
				DP[j][j + i] = min(DP[j][j + i], DP[j][j + k] + DP[j + k + 1][j + i] + A[j] * B[j + k] * B[j + i]);
				//cout << DP[j][j + k] + DP[j + k + 1][j + i] + A[j + k] * B[j + k] * B[j + k + 1] << " ";
			}
			//cout << DP[j][j + i] << " ";
		}
		//cout << endl;
	}
	
	cout << DP[0][n - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,d;

    cin >> s >> d;

    if (s<d){
        cout << "<" ;
    }
    else if (s==d){
        cout << "=";
    }
    else{
        cout << ">";
    }

    return 0;
}

Measured memory_bytes: 256
//p_i = iなら〇, p_i ≠ iなら×をi=1,2,…について書いた列を考える。この列を×××…にするのが目的となる。
//〇×→××, 〇〇→××, ××→×× or 〇〇, に注意すると、〇の個数 - 「〇〇」をいくつ作れるか、が答えになりそうと分かる。
//(やみくもにバブルソートの交換回数を考えると嵌ります。)
//(操作を分かりやすく描けないか考えてみましょう。)
#include <iostream>
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;

int n;
int p[100000];
bool flag[100000];

int main() {
	int i;
	int ans = 0;
	
	cin >> n;
	rep(i, n) { cin >> p[i]; p[i]--; }
	rep(i, n) { flag[i] = (p[i] == i); ans += flag[i]; }
	
	rep(i, n - 1) {
		if (flag[i] && flag[i + 1]) {
			flag[i] = false;
			flag[i + 1] = false;
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 1100000;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, a, b;
    cin >> n >> a >> b;
    if (a + b > n + 1){
        cout << -1;
        return 0;
    }
    if (a * b < n){
        cout << -1;
        return 0;
    }
    if (a == 1){
        for (int i = 1; i <= n; i++) cout << n - i + 1 << " ";
        return 0;
    }
    int p = n - b + 1;
    int k = 1;
    vector < int > ans;
    a--;
    for (int i = a + 1; i <= n - b + 1; i += a){
        for (int j = p - a + 1; j <= p; j++){
            if (j > a + 1){
                ans.pb(j);
            }
        }
        p -= a;
    }
    for (int i = n; i >= n - b + 2; i--) ans.pb(i);
    for (int i = 1; i <= a + 1; i++) ans.pb(i);
    for (auto i: ans) cout << i << " ";
}


Measured memory_bytes: 6512
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let mut ans = 0;
    for i in 0..n {
        if i % 2 == 0 && a[i] % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2112
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

M = 10**9+7

dp = [[1]*(m+1) for _ in range(n+1)]

for i in range(n):
  for j in range(m):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1]
    else:
      dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j]
    dp[i+1][j+1] %= M

#print(dp)
print(dp[-1][-1]%M)

Measured memory_bytes: 72668
from sys import stdin
N=int(stdin.readline().rstrip())
a=[]
for i in range(N):
    a.append(input())
    
if len(set(a)) < N:
    print("No")
else:
    

  end=a[0][0]
  cnt=0
  for i in a:
      if end==i[0]:
          end=i[-1]
          cnt+=1
      else:
          print("No")
          break
  if cnt==N:
      print("Yes")

Measured memory_bytes: 3060
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x1, y1, x2, y2 = na()
vx, vy = x2 - x1, y2 - y1
e1 = [-vy, vx]
p3 = [x2 + e1[0], y2 + e1[1]]
p4 = [p3[0] - vx, p3[1] - vy]
print(*[p3[0], p3[1], p4[0], p4[1]])


Measured memory_bytes: 3064
N = input()
stra = N[0]
strb = N[1]
strc = N[2]
a = int(stra)
b = int(strb)
c = int(strc)
if a > b:
    print(3 * stra)
elif a < b:
    print(3 * str((a + 1)))
else:
    if b >= c:
        print(3*strb)
    else:
        print(3* str(a + 1))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol d, t, s;
  cin >> d >> t >> s;
  t *= s;
  cout << (d <= t ? "Yes\n" : "No\n");
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(31);
  int bit = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    bit ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (bit ^ a[i]) << ' ';
  }
  cout << '\n';
  return 0;
}

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

using uli = unsigned long int;
using lli = long long int;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define repa(a,i,x) for(int i=a;i<=x;i++)

int main(){
	int X;
	cin >> X;
	
	int ans = (X/500)*1000 + ((X%500)/5)*5;
	
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string s,temp;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		for (int j = i + 1; j < s.length(); j++) {
			if (s[i] == s[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}

	cout << "yes" << endl;
	return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	auto s = vector<vector<bool>>(m + 1, vector<bool>(n + 1));
	auto p = vector<int>(m + 1);
	for(auto i = 1; i <= m; ++i){
		int k;
		cin >> k;
		for(auto j = 0; j < k; ++j){
			int ss;
			cin >> ss;
			s[i][ss] = true;
		}
	}
	for(auto i = 1; i <= m; ++i){
		cin >> p[i];
	}
	int ans = 0;
	for(auto i = 0; i < (1 << n); ++i){
		auto on = vector<int>(m + 1);
		int t = i;
		for(auto j = 1; j <= n; ++j){
			bool f = t % 2;
			if(f){
				for(auto k = 1; k <= m; ++k){
					if(s[k][j]) ++on[k];
				}
			}
			t >>= 1;
		}
		int cnt = 0;
		for(auto j = 1; j <= m; ++j){
			if(on[j] % 2 == p[j]) ++cnt;
		}
		if(cnt == m) ++ans;
	}
	cout << ans << endl;
	return 0;
}

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



int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	
    int x;
    cin >> x;
    cout << 48 - x << endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int n,x,t;
signed main()
{
        scanf("%d %d %d",&n,&x,&t);
        cout<<(int) (((double) (ceil(1.0*n/x)))*t)<<"\n";
        return 0;
}


Measured memory_bytes: 3588
# 写経
# https://atcoder.jp/contests/dp/submissions/6401166
# 私が再帰関数でTLEした計算方法だが、
# 3重ループを使うと、間に合うらしい

def main():
    from collections import Counter

    def tami(i, j, k):
        if i is 0 and j is 0 and k is 0:
            return

        res = fN
        if i is not 0:
            res += dp[i - 1][j][k] * i
        if j is not 0:
            res += dp[i + 1][j - 1][k] * j
        if k is not 0:
            res += dp[i][j + 1][k - 1] * k
        res *= divTable[i + j + k]

        dp[i][j][k] = res
        return

    N = int(input())
    fN = float(N)
    a = list(map(int, input().split()))

    c = Counter(a)
    one = c[1]
    two = c[2]
    three = c[3]

    dp = tuple(tuple([0.0] * (N + 1) for _ in range(N + 1)) for _ in range(N + 1))

    divTable = [1]
    for i in range(1, N * 3 + 1):
        divTable.append(1.0 / i)

    for k in range(N + 1):
        for j in range(N - k + 1):
            for i in range(N - k - j + 1):
                tami(i, j, k)

    print(dp[one][two][three])


if __name__ == '__main__':
    main()


Measured memory_bytes: 256008
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(lambda: 0)
for i in range(N):
    a, b = map(int, input().split())
    d[a] += b
keys = sorted(d.keys())
t = 0
ans = 0
for k in keys:
    v = d[k]
    if t + v > M:
        ans += (M-t)*k
        break
    else:
        t += v
        ans += k*v
print(ans)

Measured memory_bytes: 18148
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

const int Maxn = 200005;

int n;
vector <int> neigh[Maxn];
int mx;
int dp[Maxn];

int Traverse(int v, int p)
{
    int best[2] = {0, 0};
    for (int i = 0; i < neigh[v].size(); i++) {
        int u = neigh[v][i];
        if (u == p) continue;
        int g = Traverse(u, v);
        if (g > best[0]) best[1] = best[0], best[0] = g;
        else if (g > best[1]) best[1] = g;
    }
    mx = max(mx, best[0] + 1 + best[1]);
    return best[0] + 1;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].push_back(b);
        neigh[b].push_back(a);
    }
    Traverse(1, 0);
    dp[1] = true;
    for (int i = 2; i <= mx; i++)
        dp[i] = !dp[i - 1] || i > 2 && !dp[i - 2];
    printf("%s\n", dp[mx]? "First": "Second");
    return 0;
}


Measured memory_bytes: 26880
//
// Created by たかえすみずき on 2017/07/15.
//

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> arr;
    vector<int> ans;
    arr.push_back(-1);
    for (int i = 1; i <= n; i++) {
        int tmp;
        cin >> tmp;
        arr.push_back(tmp);
    }

    if (n % 2 == 0) {
        for (int i = n; i > 0; i -= 2) {
            ans.push_back(arr[i]);
        }
        for (int i = 1; i < n; i += 2) {
            ans.push_back(arr[i]);
        }
    } else {
        for (int i = n; i > 0; i -= 2) {
            ans.push_back(arr[i]);
        }
        for (int i = 2; i < n; i += 2) {
            ans.push_back(arr[i]);
        }
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i];
        if (i - 1 < n) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3828
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

ll f(ll n){
    if(n==0)return INF;
    ll ret=0;
    while(n%2==0){
        n/=2;
        ret++;
    }
    return ret;
}

char rf(int n){
    if(n<26)return ('A'+n);
    else return ('a'+(n-26));
}

bool solve(){
    ll ans=0;
    ll n;cin>>n;
    vector<ll>A(n);
    rep(i,n)cin>>A[i];
    int mode=-1;
    rep(i,(int)A.size()-1){
        if(mode==-1){
            if(A[i]==A[i+1])continue;
            if(A[i]>A[i+1])mode=1;
            else mode=2;
        }else if(mode==1){
            if(A[i]<A[i+1]){
                ans++;
                mode=-1;
            }
        }else if(mode==2){
            if(A[i]>A[i+1]){
                ans++;
                mode=-1;
            }
        }
        // cout<<A[i]<<" "<<ans<<endl;
    }
    cout<<ans+1<<endl;
    return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 1024
while(x,y = gets.split)

a = x.to_i
b = y.to_i

if a == 0 and b == 0
  break
end

if a > b  
    puts"#{b} #{a}"
elsif a < b
    puts"#{a} #{b}"
else 
    puts"#{a} #{b}"
end

end


Measured memory_bytes: 6860
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll i,j,n,k;
  cin >> n >> k;
  mint ans=0;
  vector<mint> x(100010,0);
  for(i=k;i>=1;i--){
    x[i]+=modpow(k/i,n,mod);
    if(i==1){
      break;
    }
    for(j=1;j*j<=i;j++){
      if(i%j==0){
        x[j]-=x[i];
        if(j!=i/j && j!=1){
          x[i/j]-=x[i];
        }   
      }
    }
  }
  mint sum=0;
  for(i=1;i<=k;i++){
    sum+=x[i]*i;
  }
  printf("%lld\n",sum);
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
int N, K, X, Y, ans;
void read(int &);
int main()
{
	read(N), read(K), read(X), read(Y);
	for(int i=1; i<=N; i++)
		if(i<=K) ans+=X;
		else ans+=Y;
	printf("%d", ans);
	return 0;
}
void read(int &x)
{
	x=0;
	char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
} 

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define se second
#define fi first
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define y1 y12313312312
#define endl '\n'
#define gcd __gcd
#define tm tadsadaagsd
#define next nqweqweeqeqe
#define er erase
#define int ll

using namespace std;
//using namespace __gnu_pbds;

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

const int N = 1e5 + 40, T = 4 * N, logN = (int)log2(N) + 2, inf = 1e9 + 7, sx[4] = {1, -1, 0, 0}, sy[4] = {0, 0, 1, -1};

double n, m, r, l, e, o, z, ts, id, mx, mn = inf, w;
double a[N];
ll f;

void freop()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

void boos()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int bp (int x, int y) {
	if (y == 0) return 1;
	if (y % 2 == 1) return bp(x, y - 1) * x;
	else
    {
		int asd = bp(x, y / 2);
		return asd * asd;
	}
}

main()
{
    int x, y;
    setprecision(9);
    //freop();
    boos();
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        e += a[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] >= e / (4 * m)) f++;
    }
    if (f >= m)
    {
        cout << "Yes";
    }
    else cout << "No";
}


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

int main(){
    int64_t n, r = 0, g = 0, b = 0;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }
    int64_t ans = r * g * b;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int k = 2 * j - i;
            if(s[i] != s[j] && s[j] != s[k] && s[i] != s[k] && k < n) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
from collections import defaultdict
import itertools
d = defaultdict(int)
x='MARCH'
for i in range(5):
  d[x[i]]=i+1
x=[0]*5
N=int(input())
for i in range(N):
  S=input()
  a=d[S[0]]
  if a>0:
    x[a-1]+=1
ans=0
for i,j,k in itertools.combinations([i for i in range(5)], 3):
  ans+=x[i]*x[j]*x[k]
print(ans)

Measured memory_bytes: 9424
S = input()

max0 = 0
max1 = 0
amax0 = []
amax1 = []
mi0 = 0
mi1 = 0
h0 = 0
h1 = 0
for i, c in enumerate(S):
    if c=="1":
        h1 += 1
        if h1-mi1 > max1:
            max1 = h1-mi1
            amax1 = [i]
        elif h1-mi1 == max1:
            amax1.append(i)
        h0 -= 1
        if h0 < mi0:
            mi0 = h0
    elif c=="0":
        h1 -= 1
        if h1 < mi1:
            mi1 = h1
        h0 += 1
        if h0-mi0 > max0:
            max0 = h0-mi0
            amax0 = [i]
        elif h0-mi0 == max0:
            amax0.append(i)
    else:
        h1 -= 1
        if h1 < mi1:
            mi1 = h1
        h0 -= 1
        if h0 < mi0:
            mi0 = h0
if max0 < max1:
    if len(set([i%2 for i in amax1]))==1:
        print(max1)
    else:
        print(max1+1)
elif max0 > max1:
    if len(set([i%2 for i in amax0]))==1:
        print(max0)
    else:
        print(max0+1)
else:
    if len(set([i%2 for i in amax1]+[(max0+i)%2 for i in amax0]))==1:
        print(max0)
    else:
        print(max0+1)


Measured memory_bytes: 35172
N,M=[int(s) for s in input().split()] 
hito=[0 for i in range(N)]
edge=[set() for _ in range(N)]
for i in range(M):
  a,b=[int(s) for s in input().split()]
  edge[a-1].add(b-1)
  edge[b-1].add(a-1)


def dfs(start):
  count=1
  reach=set()
  reach.add(start)
  hito[start]=1
  while reach:
    _from=reach.pop()
    for _to in edge[_from]:
      if not(_to in reach) and hito[_to]==0:
        reach.add(_to)
        count+=1
        hito[_to]=1
  return(count)
 

ans=set()
for h in range(N):
  if hito[h]==0:
    ans.add(dfs(h))
print(max(ans))

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

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vstr;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it it!= m.end(); it++)

const char nl = '\n';
const int MOD = 1e9 +7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 + 5;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  int x; cin >> x;
  int tmp =x;
  int cnt = 1;
  for(int i =1; i <n; i++){
    cin >> x;
    if(x>= tmp){
      cnt++;
      tmp =x;
    }
  }
  cout << cnt << nl;



}


Measured memory_bytes: 3620
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<bool> dp(k+1, false);
    dp[0] = false;
    rep(i, k + 1){
        rep(j, n){
            if(i - a[j] < 0){
                continue;
            }
            if(not dp[i-a[j]]){
                dp[i] = true;
            }
        }
    }

    cout << (dp[k] ? "First" : "Second") << endl;

    return 0;
}


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

using namespace std;
#define int long long
#define endl '\n'


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1; // cin >> t;
    for (; t; t--) {
        int n; cin >> n;
        vector<int> ans(n);
        for (int a = 2; a*a <= 2 * n; a++) {
            for (int b = 2; b*b <= 2 * n; b++) {
                for (int c = 2 + abs(a - b); c*c <= 2 * n && c <= a + b - 2; c++) {
                    if ((a*a + b*b + c*c) % 2 == 0 && (a*a + b*b + c*c) <= 2 * n) {
                        ans[(a*a + b*b + c*c) / 2 - 1]++;
                    }
                }
            }
        }
        for (auto el : ans) cout << el << endl;
        cout << endl;
    }
    return 0;
}


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

int main(){
  int n;
  int matrix[10][10];
  int rowsum[10],colsum[10];
  int total;

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin >> matrix[i][j];
      }
    }
    for(int i=0;i<n;i++){
      rowsum[i] = 0;
      colsum[i] = 0;
    }
    total = 0;

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	printf("%5d",matrix[i][j]);
	rowsum[i] += matrix[i][j];
	colsum[j] += matrix[i][j];
      }
      printf("%5d\n",rowsum[i]);
    }

    for(int i=0;i<n;i++){
      printf("%5d",colsum[i]);
      total += colsum[i];
    }
    printf("%5d\n",total);
  }
}

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

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a-k>=0)cout<<k<<endl;
  else if(a+b-k>=0)cout<<a<<endl;
  else cout<<a-k+a+b<<endl;
  
  
  
}


Measured memory_bytes: 3600