akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define frst first
#define sec second
#define fast cin.tie(0) , ios_base :: sync_with_stdio(0)
#define db double
#define mod 1000000007
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}





string dp[4001][4001];

string lcs(string &s , ll c1 , string &t , ll c2)
{
	if (s.size() == c1 || t.size() == c2)return "";
	if (dp[s.size()][t.size()] != "-")return dp[c1][c2];
	string ans;
	if (s[c1] == t[c2]) {
		ans += s[c1];
		ans += lcs(s , c1 + 1 , t , c2 + 1);
		///cout << ans << " ";
		return dp[c1][c2] = ans;
	}
	string s1 = lcs(s , c1 + 1 , t , c2);
	string s2 = lcs(s , c1 , t , c2 + 1);
	if (s1.size() > s2.size())return dp[c1][c2] = s1;
	return dp[c1][c2] = s2;
}

string lcs1(string &s1 , string &s2)
{
	ll dp[s1.size() + 1][s2.size() + 1];
	memset(dp , 0 , sizeof dp);
	for (int i = 0; i <= s1.size(); ++i)
	{
		for (int j = 0; j <= s2.size(); ++j)
		{
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			if (s1[i - 1] == s2[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else dp[i][j] = max(dp[i - 1][j] , dp[i][j - 1]);
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	///cout << endl << " ";
	string ans;
	ll j = s2.size();
	for (int i = s1.size(); i > 0 || j > 0;)
	{
		//	cout << i << " " << j << endl;
		if (i > 0 && j > 0 && dp[i][j] == dp[i - 1][j - 1] + 1 && dp[i - 1][j - 1] >= dp[i - 1][j] && dp[i - 1][j - 1] >= dp[i][j - 1]) {
			//cout << i << " ";
////			cout << i << " " << j << " " << s1[i - 1] << endl;
			ans += s1[i - 1];
			i--;
			j--;
		}
		else if (i > 0 && j > 0 && dp[i - 1][j] > dp[i][j - 1])i--;
		else if (i > 0 && j > 0 && dp[i - 1][j] <= dp[i][j - 1])j--;
		else if (i > 0)i--;
		else j--;
		//	cout << i << " " << j << endl;
	}
	///cout << j << endl;
	reverse(ans.begin() , ans.end());
	return ans;
}

void go() {
	string s1 , s2;
	cin >> s1 >> s2;
	///cout << s1.size() << endl;
	//for (int i = 0; i < 4001; ++i)for (int j = 0; j < 4001; ++j)dp[i][j] = "-";
	cout << lcs1(s1 , s2);
}


int main() {
	fast;
	///online_judge();
	//cout << 2332;
	go();
}

Measured memory_bytes: 195712
MOD=10**9+7
N, K=map(int, input().split())
A=list(map(int, input().split()))
A.sort()

upp=[1]*(N+1)
for i in range(2, N+1):
  upp[i]=upp[i-1]*i
  upp[i]%=MOD
  
inv=[1]*(N+1)
inv[N]=pow(upp[N], MOD-2, MOD)
for i in range(N, 1, -1):
  inv[i-1]=inv[i]*i
  inv[i-1]%=MOD
  
def modcomb(n, k):
  out=upp[n]*inv[n-k]%MOD
  out=out*inv[k]%MOD
  return out

tasu=0
hiku=0
  
for i in range(N):
  if N-i-1>=K-1:
    hiku+=A[i]*modcomb(N-i-1, K-1)
    hiku%=MOD
  if i>=K-1:
    tasu+=A[i]*modcomb(i, K-1)
    tasu%=MOD

print((tasu-hiku)%MOD)

Measured memory_bytes: 14812
#include <iostream>
int main(){
    int tuyosa,zenntai,a,b;
    char kigou;
    int x[4][13] = {0};
                   std::cin >> zenntai;
    for(int d = 0;d < zenntai;d++){
        std::cin >> kigou;
        if(kigou == 'S'){
            a = 0;
        }
        if(kigou == 'H'){
            a = 1;
        }
        if(kigou == 'C'){
            a = 2;
        }
        if(kigou == 'D'){
            a = 3;
        }
        std::cin >> tuyosa;
        b = tuyosa - 1;
        x[a][b] = 1;
    }
    for(int e = 0;e < 4;e++){
        for(int f = 0;f < 13;f++){
            if(x[e][f]==0){
                if(e == 0){
                    kigou = 'S';
                }
                if(e == 1){
                    kigou = 'H';
                }
                if(e == 2){
                    kigou = 'C';
                }
                if(e == 3){
                    kigou = 'D';
                }
                tuyosa = f + 1;
            std::cout << kigou <<" "<< tuyosa<<std::endl;
            }
      }
    }
}

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0,k;
    cin >> n >> k ;
    if(n>k) cout << std::min(n%k,k-n%k);
    else cout << std::min(n,k-n) ;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<string>
#include <stdio.h>

#define MOD 1000000007LL
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(ll i=0; i < (n); i++)

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq_int; // sho-jun
typedef priority_queue<ll, vector<ll>, less<ll> > lpq_int; // ko-jun

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}



void fact(ll a, ll fact[]){
  ll i=2;
  ll original = a;
  fact[1]=1;
  rep(i, 1000000-1){
    int ii = i+2;
    while(a%ii==0){
      fact[ii] +=1;
      a = a/ii;
    }
  }
  if(a>1){
    fact[0]=a;
  }
  
  return;
}

ll N, K;
ll frac[10010];
ll fracinv[10010];

ll comb(ll n, ll k){
  ll tmp=1;
  tmp = mod(tmp * frac[n], MOD);
  tmp = mod(tmp * fracinv[k], MOD);
  tmp = mod(tmp * fracinv[n-k], MOD);
  return tmp;
}

int main(){
  cin >> N >> K;
  frac[0]=1;
  fracinv[0] = 1;
  rep(i, 10000){
    frac[i+1] = mod(frac[i]*(i+1), MOD);
    fracinv[i+1] = modinv(frac[i+1], MOD);
  }

  for(ll i=1;i<=K;i++){
    if(N-K+1<i){
      cout << 0 << endl;
    }else{
      ll tmp = comb(N-K+1, i);
      ll tmp2 = comb(K-1, i-1);
      cout << mod(tmp*tmp2, MOD) << endl;
    }
  }
  
}


Measured memory_bytes: 384
N, M = [int(n) for n in input().split()]
X = sorted([int(n) for n in input().split()])
if N>=M:
    print(0)
else:
    dx = []
    for j in range(M-1):
        dx.append(X[j+1]-X[j])
    ans = sorted(dx, reverse=True)
    print(sum(ans[N-1:]))


Measured memory_bytes: 13832
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long a=sc.nextLong();
		long b=sc.nextLong();
		long x[]=new long[n];
		for(int i=0; i<n; i++) {
			x[i]=sc.nextLong();
		}
		long ans = 0;
		for(int i=1; i<n; i++) {
			long tmp = (x[i]-x[i-1])*a;
			if(tmp>b) {
				ans += b;
			}else {
				ans += tmp;
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 52048
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int> > v(n,vector<int>(3));
    for(int i=0;i<n;i++){
        //int a,b,c;
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    vector<vector<int> > dp(3,vector<int>(n+1,0));
        for(int j=1;j<=n;j++){
            dp[0][j]=max(dp[1][j-1],dp[2][j-1])+v[j-1][0];
            dp[1][j]=max(dp[0][j-1],dp[2][j-1])+v[j-1][1];
            dp[2][j]=max(dp[0][j-1],dp[1][j-1])+v[j-1][2];
        }
    cout<<max(dp[0][n],max(dp[1][n],dp[2][n]));
    return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)
#define int long long int
#define F first
#define S second
#define pb push_back
#define M 1000000007
#define inf 1e18
#define endl "\n"
#define jam(x) cout<<"Case #"<<x<<": "
#define N 100005
#define float double
#define opFloating(x) cout<<fixed<<setprecision(10)<<x

void display2D( vector<vector<float> > &v ) {
	int n = v.size();
	int m = v[0].size();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}

std::vector<float> ph;
float ans;
int need;
// float sol(int cur, int n , int h, float temp) {
// 	if (cur == n and h >= need) {
// 		return temp;
// 	}
// 	else if (cur == n) return 0.0;

// 	float ans = 0.0;
// 	temp = temp * ph[cur];
// 	ans += sol( cur + 1, n , h + 1, temp);
// 	//temp = temp / ph[cur];
// 	temp = temp * (1 - ph[cur]);
// 	ans += sol( cur + 1, n , h, temp);

// 	return ans;
// }



int32_t main() {
	fastio;
#ifndef ONLINE_JUDGE
	fileIO;
#endif
	ans = 0;
	int n;
	cin >> n;
	need = (n / 2) + 1;
	ph.resize(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> ph[i];
	}
	//if (n == 1) {cout << ph[1]; return 0;}
	vector< vector<float> > dp(n + 1, vector<float>(n + 1, 0.0));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = dp[i - 1][0] * (1 - ph[i]);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = dp[i - 1][j] * (1 - ph[i]) + dp[i - 1][j - 1] * ph[i];
		}
	}

	float ans = 0;
	for (int i = need; i <= n; i++) {
		ans += dp[n][i];
	}
	//display2D(dp);
	opFloating(ans);
}

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

using namespace std;

int main(){
    long int n;
    string c;
    cin>>n;
    cin>>c;
    int co=0;
    for(int i=0;i<c.size();i++){
        if(i==c.size()-1){
            co++;
            break;
        }
        else{
            if(c[i]!=c[i+1]){
                co++;
            }
        }
    }
    cout<<co;

return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int ma=2e5;
typedef long long ll;
int a[ma],b[ma],c[ma];
int ans=0,n;
void solve()
{
	for(int i=1;i<=29;i++)
	{
		for(int j=1;j<=n;j++)c[j]=b[j]%(1<<i);
		sort(c+1,c+n+1);
		ll ones=0;
		for (int j = 1;j <= n;++j)
		{
			if ((a[j] & (1 << (i - 1))) == 0)
			{
				ones += lower_bound(c+1,c+n+1,(1<<i)-(a[j]%(1<<i))) - lower_bound(c + 1, c + n + 1, (1 << (i-1)) - (a[j] % (1 << i)));
			}
			else
			{
				ones += lower_bound(c + 1, c + n + 1, (1 << i) -(a[j] % (1 << i))) - c - 1;
				if (i != 1)
				{
					ones += n + 1 - (lower_bound(c + 1, c + n + 1, (1 << i) + (1 << (i-1)) - (a[j] % (1 << i))) - c);
				}
			}
		}
		if(ones&1)ans^=(1<<(i-1));
	}
}
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);
	solve();
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2560
N = int(input())
h = [0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
dp = [0] * (N + 1)
#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num = 2 ** (N).bit_length()
seg = [ide_ele] * 2 * num

def segfunc(x, y):
  return max(x, y) #ここ判定関数（ただし結合則があるもの）

def init(init_val):
  #set_val
  for i in range(N):
    seg[i + num - 1] = init_val[i]    
  #built
  for i in range(num - 2, -1, -1) :
    seg[i]=segfunc(seg[2 * i + 1], seg[2 * i + 2]) 
    
def update(k, x):
  k += num - 1
  seg[k] = x
  while k + 1:
    k = (k - 1) // 2
    seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])
    
def query(p, q):
  if q <= p:
    return ide_ele
  p += num - 1
  q += num - 2
  res = ide_ele
  while q - p > 1:
    if p & 1 == 0:
      res = segfunc(res, seg[p])
    if q & 1 == 1:
      res = segfunc(res, seg[q])
      q -= 1
    p = p // 2
    q = (q - 1) // 2
  if p == q:
    res = segfunc(res, seg[p])
  else:
    res = segfunc(segfunc(res, seg[p]), seg[q])
  return res


for i in range(N):
  temp = query(0, h[i + 1]) + a[i + 1]
  update(h[i + 1], temp)
print(query(0, N + 2))

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

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

int main()
{
  while(1){
    int N;
    cin >> N;
    if(N == 0){
      break;
    }else{
      int x, y;
      int planet[21][21];
      fill(&planet[0][0], &planet[21][0], 0);
      REP(i, N){
        cin >> x >> y;
        planet[x][y] = 1;
      }
      int M;
      char d;
      int l;
      int px, py;
      px = py = 10;
      cin >> M;
      REP(i, M){
        cin >> d >> l;
        if(d == 'N'){
          REP(j, l + 1)
            planet[px][py + j] = 0;
          py += l;
        }else if(d == 'E'){
          REP(j, l + 1)
            planet[px + j][py] = 0;
          px += l;
        }
        else if(d == 'S'){
          REP(j, l + 1)
            planet[px][py - j] = 0;
          py -= l;
        }else{
          REP(j, l + 1)
            planet[px - j][py] = 0;
          px -= l;
        }
      }
      int c = 0;
      REP(i, 21)
        REP(j, 21)
          if(planet[i][j])
            c++;
      if(c)
        cout << "No" << endl;
      else
        cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;

int main(void) {
    string s;
    cin >> s;
    ll a = count(begin(s), end(s), 'A');
    ll b = 3 - a;
    cout << ((!a || !b) ? "No" : "Yes") << endl;

    return 0;
}


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

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

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

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    sort(all(v));
    cout<<v[n-1]-v[0]<<endl;
    
    return 0;   
}




 
 


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, K, H[100010], dp[100010];

  void init() {
    cin >> N >> K;
    rep(i, N) cin >> H[i];
  }

  void solve() {
    dp[0] = 0;
    rep1(i, N) {
      dp[i] = LINF;
      ll lb = max(0LL, i-K);
      for(ll k = i-1; k>=lb; k--) {
        dp[i] = min(dp[i], dp[k] + abs(H[i] - H[k]));
      }
    }
    cout << dp[N-1] << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1792
import math
a = [int(input()) for _ in range(5)]
ans = 0
min0 = 10
for i in a:
    if i%10 != 0:
        i = str(i)
        ans += int(i)+10-int(i[-1])
        min0 = min(int(i[-1]), min0)
    else:
        ans += i
print(ans-10+min0)


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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

// Returns a const char* representation of a container, such as a vector.
// Works for a container whose iterator has begin() and end()
// E.g.
//       vector<ll> v = {1, 2, 3};
//       DLOG("v = %s", toString(v).c_str());    // You need c_str()  
string toString(auto v) {
  stringstream ss;
  ss << "[";
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin())  ss << ", ";
    // if the value_type is not printable, modify the following line.
    ss << *it;
    // e.g., if it is a pair, use "ss << pairToString(*it)"
  }
  ss << "]";
  return ss.str();
}

int N, A, B, C;
vector<int> l;
vector<int> v;
int nA, nB, nC;

bool subNext(int i) {
  if (i == N) return false;
  if (subNext(i+1)) return true;
  if (v.at(i) < 3) {
    v.at(i)++;
    return true;
  }else {
    v.at(i) = 0;
    return false;
  }
}

bool next() {
  return subNext(0);
}

int calCost(int goal, int c) {
  int sumlen = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (v.at(i) == c) {
      sumlen += l.at(i);
      cnt++;
    }
  }
  int retval;
  if (cnt == 0) {
    retval = (int)1e9;
  }else {
    retval = (cnt - 1) * 10 + abs(sumlen - goal);
  }
  DLOG("v = %s", toString(v).c_str());
  DLOG("calCost(%d, %d) = %d", goal, c, retval);
  return retval;
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> A >> B >> C;
  l.resize(N);
  for (int i = 0; i < N; i++) cin >> l.at(i);
  v.resize(N);
  int answer = 1e9;
  while(next()) {
    int cost = calCost(A, 1) + calCost(B, 2) + calCost(C, 3);
    answer = min(answer, cost);
  }
  cout << answer << endl;


  return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

var N int

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func primeFive() []int {
	arr := make([]int, 0)
	start := 2
	for len(arr) < N {
		if isPrime(start) && (start%5) == 1 {
			arr = append(arr, start)
		}
		start++
	}
	return arr
}
func main() {
	fmt.Scan(&N)
	arr := primeFive()
	for i := 0; i < N; i++ {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(arr[i])
	}
	fmt.Println()
}


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

int N, A[1 << 18], W[1 << 18], minx = (1 << 30);
int p[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> W[i];

	do {
		int sum = 0;
		for (int i = 0; i < N; i++) {
			if (A[p[i]] == 0) {
				if (A[p[(i + 1) % N]] == 1) sum += W[p[i]];
			}
			else {
				if (A[p[(i + N - 1) % N]] == 0) sum += W[p[i]];
			}
		}
		minx = min(minx, sum);
	} while (next_permutation(p, p + N));

	cout << minx << endl;
	return 0;
}


Measured memory_bytes: 3092
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t L[100010];
int32_t R[100010];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;

	for (size_t i = 0; i < N; i++)
	{
		in >> L[i]>>R[i];
	}

	std::sort(L, L + N, std::greater<>{});
	std::sort(R, R + N);
	L[N] = -10000000;
	R[N] = -10000000;

	int64_t max = 0;
	int64_t res = 0;
	int64_t count = 0;
	for (int32_t i = 0; i < N; i++)
	{
		res += 2 * L[i];
		while (true) {
			if (i + 2 <= count) { break; }
			if (count < i || 0 > R[count]) {
				res += -2 * R[count];
				++count;
			}
			else { break; }
		}
		max = std::max(res, max);
	}
	res = 0;
	count = 0;
	for (int32_t i = 0; i < N; i++)
	{
		res += -2 * R[i];
		while (true) {
			if (i + 2 <= count) { break; }
			if (count < i || 0 <= L[count]) {
				res += 2 * L[count];
				++count;
			}
			else { break; }
		}
		max = std::max(res, max);
	}
	out << max << endl;

	return 0;
}
#endif


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin(), a.end());
    cout << (a.at(2) - a.at(1)) + (a.at(1) - a.at(0)) << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  long a,b;
  cin >> a >> b;
  vector<long> x(n),dp(n);
  for(int i = 0;i < n;i++){
    cin >> x.at(i);
  }
  for(int i = 0;i < n-1;i++){
    dp.at(i+1) = min(dp.at(i)+a*(x.at(i+1)-x.at(i)),dp.at(i)+b);
  }
  cout << dp.at(n-1) << endl;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
#define INF 1000000000000000000
#define PI 3.1415926535897932846
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100, MAXK = 25;
const ll MOD = 1e9+7;

int n, m;
int dist[MAXN][3];
vi adj[MAXN];
int s, t;

void bfs () {
    FOR(i, 1, n) FOR(k, 0, 2) dist[i][k] = -1;
    dist[s][0] = 0;
    queue<pii> q;
    q.push({s, 0});
    while (!q.empty()) {
        int v = q.front().f, k = q.front().s;
        q.pop();
        for (int u : adj[v]) {
            if (dist[u][(k+1)%3] >= 0) continue;
            dist[u][(k+1)%3] = dist[v][k] + 1;
            q.push({u, (k+1)%3});
        }
    }
}

int main ()
{
    FAST_IO;

    cin >> n >> m;
    REP(m) {
        int u, v; cin >> u >> v;
        //FOR(k, 0, 2) adj[u][k].pb({v, (k+1)%3});
        adj[u].pb(v);
    }
    cin >> s >> t;

    bfs ();

    if (dist[t][0] == -1) cout << dist[t][0];
    else cout << dist[t][0]/3;

    return 0;
}


Measured memory_bytes: 6912
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
	String s = scan.nextLine();
    char[] ch = s.toCharArray();
    ch[3] = '8';
    s= String.valueOf(ch);
    System.out.println(s);
  }
}


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

typedef long long ll;

const int N = 1e5+5;

int n;

int main(){
	int a , b;
	cin >> n >> a >> b;
	int c = abs(a - b);
	if(~c & 1)printf("Alice\n");
	else printf("Borys\n");
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, k, u, v;
string s, t;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	vll a(n+1);
	ll cou = 0,maxi = 0,j;

	for(ll i=0;i<n;i++) cin>>a[i];
	
	for(ll i=0;i<n;i++) {
		cou = 0;
		j = i;
		while(j+1 < n && a[j]>=a[j+1]) {
			cou++;
			j++;
		}
		//deb1(i);
		i = j;
		maxi = max(maxi,cou);
	}
	cout<<maxi;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 4028
#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 <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 <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int64_t a, b, c;
  cin >> a >> b >> c;
  if(a*b*c % 2LL == 0LL) cout << 0 << endl;
  else cout << min({a*b, b*c, c*a}) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int a,b;
    cin >> a >> b;
    int ans = max(a+b,max(a-b,a*b));
    cout << ans << endl;
}

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

int main() {
	string s;
	list<char> ans;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'B') {
			if (!ans.empty()) {
				ans.pop_back();
			}
		}
		else ans.push_back(s[i]);
		
	}
	while (!ans.empty()) {
		cout << ans.front();
		ans.pop_front();
	}
	cout << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
 
if h%3 == 0 or w%3 == 0:
    print(0)
    exit()
 
#print(h, w)
min_ = float('inf')
for i in range(1, h):
    s1 = w*i
    s2 = (h-i)*(w//2)
    s3 = (h-i)*(w-w//2)
    d = max([s1, s2, s3]) - min([s1, s2, s3])
    #print(i, s1, s2, s3, d)
    min_ = min(min_, d)
 
    s2 = ((h-i)//2)*w
    s3 = ((h-i) - (h-i)//2)*w
    d = max([s1, s2, s3]) - min([s1, s2, s3])
    #print(i, s1, s2, s3, d)
    min_ = min(min_, d)
 
#print('-')
 
for i in range(1, w):
    s1 = h*i
    s2 = (w-i)*(h//2)
    s3 = (w-i)*(h-h//2)
    d = max([s1, s2, s3]) - min([s1, s2, s3])
    #print(i, s1, s2, s3, d)
    min_ = min(min_, d)
 
    s2 = ((w-i)//2)*h
    s3 = ((w-i) - (w-i)//2)*h
    d = max([s1, s2, s3]) - min([s1, s2, s3])
    #print(i, s1, s2, s3, d)
    min_ = min(min_, d)
 
print(min_)

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

int main(int argc, char const *argv[])
{
	int n; string s;
	cin >> n >> s;
	int cnt = 0;
	rep(i, (int)s.size() - 2) {
		if (s.substr(i, 3) == "ABC") {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,K,Q;
int A[1<<17];
main()
{
	cin>>N>>K>>Q;
	for(int i=0;i<Q;i++)
	{
		int id;cin>>id;id--;
		A[id]++;
	}
	for(int i=0;i<N;i++)
	{
		cout<<(A[i]-Q+K>0?"Yes":"No")<<endl;
	}
}


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

int prime[10000];

void GetPrime(int kosuu);
int main(){
	int n,sum[1000] = {0},cor = 0;
	GetPrime(10000);
	while(cin >> n){
		if(n == 0)
			break;
		for(int i = 0;i < n;i++){
			sum[cor] += prime[i];
		}
		cor++;
	}
	for(int i = 0;i < cor;i++){
		cout << sum[i] << endl;
	}
	return 0;
}

void GetPrime(int kosuu){
	int i,j,count = 0;
	for(i = 2;count < kosuu;i++){
		for(j = 0;j < count;j++){
			if(i%prime[j] == 0)
				break;
		}
		if(j < count)
			continue;
		prime[count] = i;
		count++;
	}
}

Measured memory_bytes: 1200
#include<stdio.h>
int main(){
  int i, k, N, M, A[101], B[101][101], lose[101], score[101] = {0};
  scanf("%d %d", &N, &M);
  for(i = 1; i <= M; i++){
    scanf("%d", &A[i]);
  }
  for(i = 1; i <= M; i++){
    for(k = 1; k <= N; k++){
      scanf("%d", &B[i][k]);
    }
  }
  for(i = 1; i <= M; i++){
    lose[i] = N - 1;
    for(k = 1; k <= N; k++){
      if(k != A[i] && B[i][k] == A[i]){
        score[k]++;
        lose[i]--;
      }
    }
  }
  for(i = 1; i <= M; i++){
    for(k = 1; k <= N; k++){
      if(k == A[i] && B[i][k] == A[i]){
        score[k] = score[k] + 1 + lose[i];
      }
    }
  }
  for(k = 1; k <= N; k++){
    printf("%d\n", score[k]);
  }
  return 0;
}

Measured memory_bytes: 636
<?php
# 文字列の入力
fscanf(STDIN, "%s", $s);

$max = 0;
$count = 0;
foreach (preg_split('//u', $s, -1, PREG_SPLIT_NO_EMPTY) as $c) {
	if ($c == 'R') {
		++$count;
	} else {
		$count = 0;
	}

	if ($max < $count) {
		$max = $count;
	}
}

# 出力
echo $max . "\n";


Measured memory_bytes: 16532
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


bool check(int n, vector<bool> dame) {
    while (n > 0) {
        int t = n % 10;
        if (!dame[t])
            return false;
        n /= 10;
    }
    return true;
}
int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> dame(10, true);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        dame[d] = false;
    }
    for (int i = n;; i++) {
        if (check(i, dame)) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }

  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }

  else {
    cout << "Right" << endl;
  }

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[2222];

bitset<2000010>bs;

signed main(){
    bs[0]=1;
    cin>>N;
    int S=0;
    rep(i,N){
        cin>>A[i];
        S+=A[i];
        bs|=bs<<A[i];
    }

    for(int i=S/2;i>=0;i--){
        if(bs[i]){
            cout<<S-i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1152
#!/usr/bin/env python
# coding: utf-8

# In[121]:


import numpy as np
import numpy.matlib


# In[126]:


S = list(str(input()))
Slist = np.array(list(map(int, S)))


# In[127]:


pattern = np.matlib.repmat((0, 1),1, len(S)).flatten()


# In[128]:


ans1 = np.sum(np.array(Slist) == pattern[1:len(Slist)+1])
ans2 = np.sum(np.array(Slist) == pattern[:len(Slist)])


# In[129]:


print(min(ans1,ans2))


# In[ ]:






Measured memory_bytes: 17368
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		// K個全員に配る
		// 残りを一人に
		// が最大の差
		// Kが一人の場合は引きようがないのか
		sc.close();
		if (K == 1)
			System.out.println(0);
		else
			System.out.println(N - K);
	}
}

Measured memory_bytes: 23124
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


n = readint()
a = []
b = []
for i in range(n):
    x,y = readints()
    a.append(x)
    b.append(y)
a.sort()
b.sort()

if n%2==1:
    l = a[n//2]
    r = b[n//2]
    print(r-l+1)
else:
    l = a[n//2] + a[n//2-1]
    r = b[n//2] + b[n//2-1]
    print(r-l+1)

Measured memory_bytes: 93504
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0; i<n; i++)
int N , M;
int P [100000] , Y [100000];
vector < int > yd [100001];


int main ()
{
scanf("%d%d", &N, &M);
rep(i, M) scanf("%d%d", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
rep(i, N) sort(yd[i+1].begin(), yd[i+1].end());
rep(i, M) printf("%012lld\n" , ll(P[i])*1000000+ int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin())+1);
}

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

ll solve() {
    ll N, M, x, y;
    cin >> N >> M;
    vector<vector<ll>> G(N);
    for ( int i = 0; i < N-1; i++ ) {
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    auto Add = [&](ll& x, ll y) { x = ( x % M + y % M ) % M; };
    auto Mul = [&](ll& x, ll y) { x = ( x % M * y % M ) % M; };
    vector<map<int,ll>> dp(N);

    function<void(int,int)> dfs1 = [&](int v, int p) {
        ll c = 1;
        for ( int u : G[v] ) {
            if ( u == p ) continue;
            dfs1(u, v);
            Mul(c, dp[v][u]);
        }
        Add(c, 1);
        if ( p >= 0 ) {
            dp[p][v] = c;
        }
    };
    dfs1(0,-1);

    function<void(int,int)> dfs2 = [&](int v, int p) {
        int vn = G[v].size();
        vector<ll> pl(vn,1), pr(vn,1);
        int i;
        i = 0;
        for ( auto it = G[v].begin(); it != G[v].end(); it++, i++ ) {
            if ( i > 0 ) Mul(pl[i], pl[i-1]);
            Mul(pl[i], dp[v][*it]);
        }
        i = vn-1;
        for ( auto it = G[v].rbegin(); it != G[v].rend(); it++, i-- ) {
            if ( i < vn-1 ) Mul(pr[i], pr[i+1]);
            Mul(pr[i], dp[v][*it]);
        }
        i = 0;
        for ( auto it = G[v].begin(); it != G[v].end(); it++, i++ ) {
            int u = *it;
            if ( u == p ) continue;
            ll c = 1;
            if ( i > 0 ) Mul(c, pl[i-1]);
            if ( i < G[v].size() - 1 ) Mul(c, pr[i+1]);
            Add(c, 1);
            dp[u][v] = c;
            dfs2(u, v);
        }
    };
    dfs2(0,-1);

    for ( int v = 0; v < N; v++ ) {
        ll c = 1;
        for ( int u : G[v] ) {
            Mul(c, dp[v][u]);
        }
        cout << c << "\n";
    }
    return 0;
}

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

Measured memory_bytes: 37248
N, M = map(int, input().split())

war = {}
for i in range(M):
    a, b = map(int, input().split())
    if(b in war):
        if(a > war[b]):
            war[b] = a
    else:
        war[b] = a

ans = 1
b_list = list(war.keys())
b_list = sorted(b_list)
r_bridge = b_list[0] - 1

for b in b_list:
    a = war[b]
    if(a <= r_bridge):
        continue
    else:
        r_bridge = b - 1
        ans += 1

print(ans)

Measured memory_bytes: 11364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, M;
    cin >> N >> M;

    vector<vector<int>> dp(M + 1, vector<int>(1 << N, 1e9));
    dp[0][0] = 0;
    for (int i = 0; i < M; ++i) {
        int a, b, bit = 0;
        cin >> a >> b;
        for (int j = 0; j < b; ++j) {
            int c;
            cin >> c;
            bit |= 1 << (c - 1);
        }
        for (int j = 0; j < 1 << N; ++j) {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
            dp[i + 1][j | bit] = min(dp[i][j] + a, dp[i + 1][j | bit]);
        }
    }

    cout << (dp[M][(1 << N) - 1] < 1e9 ? dp[M][(1 << N) - 1] : -1) << endl;

    return 0;
}


Measured memory_bytes: 19252
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>

void kochCurve(int n, std::pair<double, double> start, std::pair<double, double> end)
{
    if (n == 0)
    {
        std::cout << std::fixed << std::setprecision(5) << end.first   << " " << end.second   << std::endl;
        return;
    }

    std::pair<double, double> base = std::make_pair((end.first - start.first) / 3.0, (end.second - start.second) / 3.0);
    std::pair<double, double> s = std::make_pair(start.first + base.first, start.second + base.second);
    std::pair<double, double> t = std::make_pair(s.first + base.first, s.second + base.second);
    
    std::pair<double, double> st = std::make_pair(t.first - s.first, t.second - s.second);
    std::pair<double, double> u  = std::make_pair(s.first + st.first * cos(M_PI/3) - st.second * sin(M_PI/3), s.second + st.first * sin(M_PI/3) + st.second * cos(M_PI/3));

    //std::cout << "start:" << start.first << " " << start.second  << " end:" << end.first << " " << end.second << " ";
    //std::cout << "s:" << s.first << " " << s.second  << " u:" << u.first << " " << u.second  << " t:" << t.first << " " << t.second << std::endl;

    kochCurve(n-1, start, s);
    kochCurve(n-1, s, u);
    kochCurve(n-1, u, t);
    kochCurve(n-1, t, end);
}

int main()
{
    std::pair<double, double> start = std::make_pair(0.0  , 0.0);
    std::pair<double, double> end   = std::make_pair(100.0, 0.0);

    int n;
    std::cin >> n;

    std::cout << std::fixed << std::setprecision(5) << start.first << " " << start.second << std::endl;
    kochCurve(n, start, end);
}


Measured memory_bytes: 3300
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <numeric>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define runforestrun ios_base::sync_with_stdio(0)

int main() {
    runforestrun;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(i & 1){
            if(s[i] == 'R'){
                cout << "No";
                return 0;
            }
        }
        else{
            if(s[i] == 'L'){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;

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

    int X;
    cin >> X;
    if (X<4){
        cout << 1 << endl;
        return 0;
    }

    int ans = 0;
    for(int i=2; i<= X;i++){
        int p=2;
        int b = pow(i,p);
        if(b>X){
            break;
        }
        while(b<=X){
            p++;
            if(pow(i,p)>X) break;
            b=pow(i,p);
        }
        ans = max(ans, b);
    }

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


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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int c = n - a - b + 1;
  if(c < 0 || (b == 1 && c > 0)) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans;
  rep(i,a) ans.push_back(n-a+i+1);
  rep(i,b-1) ans.push_back(b-i-1);
  if(b == 1) {
    for(auto k: ans) cout << k << " ";
    cout << endl;
    return 0;
  }
  int d = (c+b-2)/(b-1);
  if(d > a-1) {
    cout << -1 << endl;
    return 0;
  }
  int p = 2*b - 2;
  int f = 0;
  while(ans.size() < n) {
    p = min(n-a,p);
    ans.push_back(p);
    p--; f++;
    if(f % (b-1) == 0) p += 2*b-2;
  }
  for(auto k : ans) cout << k << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

#define ALL(a)  (a).begin(),(a).end()

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    ll n, k;
    priority_queue <int> h;
    ll ans = 0;

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        int buff;
        cin >> buff;
        h.push (buff);
    }

    while (h.top () >= k && !h.empty()) {
        ans ++;
        h.pop();
    }

    cout << ans << endl;
    
}



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

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<long long>>nxy(n,vector<long long>(2));
  vector<vector<long long>>mxy(m,vector<long long>(2));
  for(int i = 0;i < n;i++){
    cin >> nxy.at(i).at(0) >> nxy.at(i).at(1);
  }
  for(int i = 0;i < m;i++){
    cin >> mxy.at(i).at(0) >> mxy.at(i).at(1);
  }
  for(int i = 0;i < n;i++){
    long long ans = 400000000;
    int ansn = 0;
    for(int j = 0;j < m;j++){
      if(abs(nxy.at(i).at(0)-mxy.at(j).at(0))+abs(nxy.at(i).at(1)-mxy.at(j).at(1)) < ans){
        ans = abs(nxy.at(i).at(0)-mxy.at(j).at(0))+abs(nxy.at(i).at(1)-mxy.at(j).at(1));
        ansn = j+1;
      }
    }
    cout << ansn << endl;
  }
}


Measured memory_bytes: 256
// counting sort
//
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

// preconditions;
// A[i] <= k for all i
// A, B are 1 origin.
void CountingSort(vector<ll> &A, vector<ll> &B, ll k) {
	// the i-th element of the array C has
	// the number of elements of A, which are less than or equal to i; 
	vector<ll> C(k+1, 0);
	for (ll j=1;j<A.size();++j) {
		C[A[j]]++;
	}
	for (ll i=1;i<k+1;++i) {
		C[i] += C[i-1];
	}
	// 
	for (ll j=A.size()-1; j>=0; --j) {
		B[C[A[j]]] = A[j]; 
		C[A[j]]--;
	}	
}

int main() {
	ll n;
	cin >> n;
	vector<ll> A(n+1,0);
	vector<ll> B(n+1,0);
	for (ll i=1;i<A.size();++i) scanf("%lld", &A[i]);
	ll k = *max_element(A.begin(), A.end()); 

	CountingSort(A, B, k);
	for (ll i=1;i<B.size();++i) {
		if (i != 1) cout << " ";
		cout << B[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 34284
from bisect import bisect_left
from bisect import bisect_right
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

ans = 0
for i in range(N):
  ans += bisect_left(A, B[i]) * (N - bisect_right(C, B[i]))
  
print(ans)

Measured memory_bytes: 23232
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

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

		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26120
#include<stdio.h>

void swap(int *a,int *b){
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

int bubbleSort(int *A,int N){
    int i,j;//i?????´?????????????????°
    int count=0;
    for(i=0;i<N;i++){
        for(j=N-1;j>i;j--){
            if(A[j]<A[j-1]){
                swap(&A[j],&A[j-1]);
                count++;
            }
        }
    }
    return count; 
}

int main(){
    int A[100];
    int i,N,count;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    count = bubbleSort(A,N);
    for(i=0;i<N;i++){
        if(i==0){
            printf("%d",A[i]);
        }else{
            printf(" %d",A[i]);
        }
    }
    printf("\n%d\n",count);
    return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
#define print(var) cout<<var<<endl;
#define DEBUG(var) cerr<<var<<endl;
// puts("str");

using ll = long long;
using P = pair<int,int>;
const int inf = 1000000000;//10^9

int main (){
  ll A,ans;
  double B;
  cin>>A>>B;
  ll ib=round(B*100);
  ans=(A*ib)/100;
  print(ans);


  return 0;

}


Measured memory_bytes: 3700