akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int n, m, x, t[10005], dmin[10005][405];
vector<vector<P> > g;

void dijkstra(){
    REP(i,n) fill(dmin[i], dmin[i]+(x+1)*2, IINF);
    dmin[0][0] = 0;
    priority_queue<P3, vector<P3>, greater<P3> > que;
    que.push({0,{0,0}});
    while(!que.empty()){
        P3 p = que.top();
        que.pop();
        int v = p.second.first, tv = p.second.second;
        if(p.first > dmin[v][tv])continue;
        for(auto &e : g[v]){
            int u = e.first, d = e.second, tu;
            if(tv<x && t[u]==2 && abs(x-tv)>d)continue;
            if(tv>x && t[u]==0 && abs(x-tv)>d)continue;
            if(t[u]==2) tu = x*2;
            else if(t[u]==0) tu = 0;
            else {
                if(tv<x) tu = min(x, tv+d);
                else tu = max(x,tv-d);
            }
            if(dmin[u][tu] > dmin[v][tv] + d){
                dmin[u][tu] = dmin[v][tv] + d;
                que.push({dmin[u][tu],{u,tu}});
            }
        }
    }
}

int main() {
    cin >> n >> m >> x;
    g.resize(n);
    REP(i,n) cin >> t[i];
    REP(i,m){
        int a, b, d;
        cin >> a >> b >> d;
        a--; b--;
        g[a].push_back({b,d});
        g[b].push_back({a,d});
    }
    dijkstra();
    int ans = IINF;
    REP(i,x*2+1) ans = min(ans, dmin[n-1][i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 19672
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    for (int i = 0; i < M; i++) cin >> X[i];

    sort(X.begin(), X.end());

    vector<int> dX(M - 1);
    for (int i = 0; i < M - 1; i++) dX[i] = X[i + 1] - X[i];

    sort(dX.begin(), dX.end(), greater<int>());

    int ans = 0;
    for (int i = N - 1; i < M - 1; i++) ans += dX[i];

    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M;
vector<pair<ll,pll>> jv;
ll ct[101010];
ll i, j,ans;
ll mk[101010];

ll gc[101010],ghn[101010], ghnd[101010];
ll gnxt[101010];
ll ggt(ll a){
    ll aa = a;
    while(gnxt[aa]!=aa){
        aa = gnxt[aa];
    }
    return gnxt[a] = aa;
}
int main(){
    scanf("%lld%lld", &N,&M);
    fornum(i,0,N){
        ll x;
        scanf("%lld", &x);
        gnxt[i+1] = i + 1;
        gc[i + 1] = x;
    }
    fornum(i, 0,M){
        ll a, b,c;
        scanf("%lld%lld%lld", &a, &b,&c);
        jv.push_back(mp(c,mp(a,b)));
    }
    sort(jv.begin(), jv.end());
    fornum(i,0,M){
        auto ja = jv[i];
        auto jp = ja.second;
        ll a = ggt(jp.first);
        ll b = ggt(jp.second);
        if(a!=b){
            gc[a] += gc[b];
            ghn[a] += ghn[b];
            ghnd[a] += ghnd[b];
            gnxt[b] = a;
        }
        ghnd[a]++;
        if(jv[i].first<=gc[a]){
            ghn[a] = ghnd[a];
        }
    }


    fornum(i,0,N){
        ll a = ggt(i + 1);
        if(mk[a]==0){
            mk[a] = 1;
            ans += ghnd[a] - ghn[a];
        }   
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n;

void solve(){
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if(s == t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] L = new int[N*2];
        for (int i=0; i<N*2; i++) {
            L[i] = sc.nextInt();
        }


        System.out.println(solve(N, L));
    }

    private static int solve(int N, int[] L) {
        int sum = 0;

        Arrays.sort(L);

        for (int i=0; i<L.length; i+=2) {
            sum += L[i];
        }

        return sum;
    }
}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
import random
random.seed(0)

D = int(input())
C = list(map(int, input().split()))
list_S = [list(map(int, input().split())) for _ in range(D)]

answer = []
L = [0 for _ in range(26)]
for S in list_S:
  contest_index = -1
  contest_manzoku = -10**9
  for i in range(26):
    i_manzoku = S[i]+C[i]+L[i]
    if i_manzoku > contest_manzoku:
      contest_index = i
      contest_manzoku = i_manzoku
  answer.append(contest_index)
  for i in range(26):
    if i==contest_index:
      L[i] = 0
    else:
      L[i] += C[i]

def manzoku(A):
  score = 0
  L = [0 for _ in range(26)]
  for i in range(D):
    contest_index = A[i]
    for j in range(26):
      if j==contest_index:
        L[j] = 0
        score += list_S[i][contest_index]
      else:
        L[j] += C[j]
        score -= L[j] 
  return score

manzoku_now = manzoku(answer)
answer_tmp = [answer[i] for i in range(D)]
for j in range(365):
  day = j%D
  contest = random.randrange(26)
  answer_tmp = [answer[i] for i in range(D)]
  answer_tmp[day] = contest
  manzoku_tmp = manzoku(answer_tmp)
  if manzoku_now < manzoku_tmp:
    manzoku_now = manzoku_tmp
    answer[day] = contest
  else:
    answer_tmp[day] = answer[day]

for index in answer:
  print(index+1)

Measured memory_bytes: 9744
from itertools import product
N, M = map(int, input().split())
cake = [list(map(int, input().split())) for i in range(N)]

ans = 0
for x, y, z in product((1, -1), repeat=3):
    S = []
    for a, b, c in cake:
        S.append(a*x + b*y + c*z)
    S.sort(reverse=True)
    ans = max(ans, sum(S[:M]))

print(ans)


Measured memory_bytes: 3376
#include <stdio.h>
#include <string.h>
int main() {char Tex[1005],i,j,ans=0;while (scanf("%s",&Tex)!=EOF) {for (j=strlen(Tex)-1,i=0;i<=j && Tex[i]==Tex[j];i++,j--);if (i>j) ans++;}printf("%d\n",ans);return 0;}

Measured memory_bytes: 0
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
//DP on Trees : Standard Problem

//No two adjacent vertices be painted black
//dp[i][0] : number of ways to paint ith vertex black
//dp[i][1] : number of ways to paint ith vertex white

//dp[i][0] = product of dp[child][1]
//dp[i][1] = product of (dp[child][0] + dp[child][1])


const int N = 1e5 + 10;

ll dp[N][2];
vi g[N];

void mul_self(ll &a, ll b){
    a *= b;
    a %= mod;
}

void dfs(int v, int p){

    dp[v][0] = 1ll, dp[v][1] = 1ll;

    for(int child : g[v]){
        if(child != p){
            dfs(child, v);
            mul_self(dp[v][0], dp[child][1]);
            mul_self(dp[v][1], (dp[child][0] + dp[child][1])%mod);
        }
    }

  
}

int main(){
   IOS

   int n; cin>>n;

   for(int i = 0; i < n-1; i++){
       int u, v;
       cin>>u>>v; u--, v--;

       g[u].pb(v), g[v].pb(u);
   }



   dfs(0, -1);


    cout<<(dp[0][0] + dp[0][1])%mod<<"\n";



}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 14208
#include <iostream>
#include <atomic>
#include <thread>
#include <mutex>
#include <string>
#include <string.h>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
class BigInt {
private:
	vector<int> number;
public:
	BigInt(string s) {
		for (int i = s.size() - 1; i >= 0; i--) {
			number.push_back(s[i] - '0');
		}
	}
	BigInt(vector<int> v) {
		number = v;
	}
	string get() {
		string s = "";
		for (int i = number.size() - 1; i >= 0; i--) {
			s = s + to_string(number[i]);
		}
		return s;
	}
	vector<int> vget() {
		return number;
	}
	int length() {
		return number.size();
	}
	void shift() {
		rep(i, number.size()) {
			if (number[i] >= 10) {
				if (i != number.size() - 1)number[i + 1] += number[i] / 10;
				else number.push_back(number[i] / 10);
				number[i] %= 10;
			}
		}
	}
};
bool operator<(BigInt a, BigInt b) {
	if (a.length() < b.length())return true;
	if (a.length() > b.length())return false;
	string s = a.get(), t = b.get();
	rep(i, a.length()) {
		if (s[i] < t[i])return true;
		if (s[i] > t[i])return false;
	}
	return false;
}
bool operator>(BigInt a, BigInt b) {
	return !(a < b);
}
BigInt operator+(BigInt a, BigInt b) {
	if (a < b)swap(a, b);
	vector<int> s = a.vget(), t = b.vget();
	rep(i, t.size()) {
		s[i] += t[i];
	}
	BigInt ans(s);
	ans.shift();
	return ans;
}
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		string s, t;
		cin >> s >> t;
		BigInt a(s), b(t);
		BigInt c = a + b;
		if (c.length() > 80)puts("overflow");
		else cout << c.get() << endl;
	}
	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long sum,fir =2,las = 1,temp;
    bool flag = 0;
    int n;
    cin>>n;
    if(n == 1) cout<<"1\n";
    else
    {
        flag =1;
        for(int i = 1; i<n; i++)
        {
            temp = fir +las;
            fir = las;
            las = temp;
        }
    }
    if(flag) cout<<temp;
}


Measured memory_bytes: 256
n,q=map(int,input().split())
a=list(map(int,input().split()))
size=2*n+1
bit=[0]*size
def bit_update(x,v):
    while x<size:
        bit[x]+=v
        x+=(x&-x)
def bit_sum(n):
    s=0
    if n==0:return 0
    x=n
    while x>0:
        s+=bit[x]
        x-=(x&-x)
    return s
for i,j in enumerate(a,1):
    bit_update(i,j)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        bit_update(b+1,c)
    else:
        print(bit_sum(c)-bit_sum(b))

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

using namespace std;

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

struct Node {
	int x, y, cost;
};
bool operator>(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}

const int inf = 1e9;

int m[501][501][4] = {0};
int main() {
	int W, H, N; cin >> W >> H >> N;
	int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
	map<char, int> tbl = {{'U', 0}, {'R', 1}, {'D', 2}, {'L', 3}};
	for (int i = 0; i < N; ++i) {
		int x, y; cin >> x >> y;
		int T; cin >> T;
		string s; cin >> s;
		for (int t = 0; t < T; ++t) {
			for (int j = 0; j < s.size(); ++j) {
				int d = tbl[s[j]];
				int x1, y1, d1;
				int nx = x + dx[d], ny = y + dy[d];
				if (0 <= nx && nx < W && 0 <= ny && ny < H) {
					switch (d) {
						case 0: x1 = x, y1 = y, d1 = 1; break;
						case 1: x1 = x+1, y1 = y+1, d1 = 0; break;
						case 2: x1 = x+1, y1 = y+1, d1 = 3; break;
						case 3: x1 = x, y1 = y, d1 = 2; break;
					}
//					cout << x1 << " " << y1 << " " << x1+dx[d1] << " " << y1+dy[d1] << endl;
					++m[y1][x1][d1];
					++m[y1+dy[d1]][x1+dx[d1]][(d1+2)%4];
					x = nx, y = ny;
				}
			}
		}
	}
	priority_queue<Node, vector<Node>, greater<Node> > Q;
	Q.push({sx, sy, 0});
	int dist[501][501]; fill(dist[0], dist[501], inf);
	dist[0][0] = 0;
	while ( !Q.empty() ) {
		Node node = Q.top(); Q.pop();
		int x = node.x, y = node.y, cost = node.cost;
//		cout << x << " " << y << " " << cost << endl;
		if (cost > dist[y][x]) continue;
		for (int d = 0; d < 4; ++d) {
			int nx = x + dx[d], ny = y + dy[d];
			int nc = cost + m[y][x][d];
			if (nx < 0 || nx > W || ny < 0 || ny > H ) continue;
			if (nc < dist[ny][nx]) {
				dist[ny][nx] = nc;
				Q.push({nx, ny, nc});
			}
		}
	}
	cout << dist[gy][gx] << endl;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  for(int i=0; i<3; i++){
    for(int j=0; j<n; j++){
      if(i==0){
        cin >> a[j];
      }else if(i == 1){
        cin >> b[j];
      }else
        cin >> c[j];
    }
  }
  sort(a, a+n);
  sort(b, b+n);
  sort(c, c+n);
  long long ans = 0;
  int j=0, k=0;
  for(int i=0; i<n; i++){
    while(a[j] < b[i] && j < n) j++;
    while(c[k] <= b[i] && k < n) k++;
    ans += 1ll * j * (n - k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(a));i>=((int)(b));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

vector<int> vt(9000, 50000);
#define dp(a) (vt[a+4500])

int main(void){
	int n, a, b; scanf("%d%d%d", &n, &a, &b);
	vector<pair<int, int>> x(n);
	rep(i, n){
		int ta, tb; scanf("%d%d%d", &ta, &tb, &x[i].sec);
		x[i].fir = tb*a-ta*b;
	}
	
	rep(i, n){
		dp(x[i].fir) = min(dp(x[i].fir), x[i].sec);
		if(x[i].fir < 0){
			reg(j, -4000, 4000){
				if(dp(j) != 50000 && j!=x[i].fir) dp(j+x[i].fir) = min(dp(j+x[i].fir), dp(j)+x[i].sec);
			}
		}else{
			ireg(j, 4000, -4000){
				if(dp(j) != 50000 && j!=x[i].fir) dp(j+x[i].fir) = min(dp(j+x[i].fir), dp(j)+x[i].sec);
			}
		}
	}
	
	if(dp(0) == 50000) cout << -1 << endl;
	else cout << dp(0) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  long long A[222222], acc[222222], acc2[222222];

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> A[i];

  acc[0] = acc2[0] = 0;

  for (int i = 0; i < N; i ++) {
    acc [i + 1] =  A[i]              + acc [i];
    acc2[i + 1] = (A[i] > 1 ? 1 : 0) + acc2[i];
  }

  long long cm = INF;

  for (int i = 0; i < N - 1; i ++) {
    long long x = acc[i + 1], y = acc[N] - x, u = acc2[i + 1], v = acc2[N] - u;

    cm = std::min(std::abs(x - y), cm);
  }

  std::cout << cm << std::endl;
  
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  ll N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  ll B[N]; rep(i,N) cin >> B[i];

  map<ll, ll> count; rep(i,N) { count[A[i]]++; count[B[i]]++; }
  for (auto x: count) if (x.second>N) { cout << "No" << endl; return 0; }
  cout << "Yes" << endl;

  reverse(B,B+N);
  ll lp = 0; while (A[lp]!=B[lp]&&lp!=N) lp++;
  ll rp = lp; while (A[rp]==B[rp]&&rp!=N) rp++;

  ll npl = 0, npr = N-1;
  repr(i,lp,rp) {
    if (A[npl]!=A[i]&&B[npl]!=B[i]) {
      swap(B[npl],B[i]);
      npl++;
    }
    else {
      swap(B[npr],B[i]);
      npr--;
    }
  }

  debug(B,B+N);
  return 0;
}

Measured memory_bytes: 19124
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let A = (0..N-1).map(|_| buf_it.next().unwrap().parse::<usize>().unwrap()-1).collect::<Vec<_>>();

    let mut C = (0..N).map(|_| Vec::new()).collect::<Vec<_>>();
    for i in 1..N{
        let a = A[i-1];
        C[a].push(i);
    }
    println!("{}",ans(&C,0));
}

fn ans(C:&Vec<Vec<usize>>,i:usize)->usize{
    if (*C[i]).len()==0{return 0;}
    let mut tmp = C[i].iter().map(|&c| ans(C,c)).collect::<Vec<_>>();
    tmp.sort();
    let l = tmp.len();
    for i in 0..l{
        tmp[i] += l-1-i;
    }
    *tmp.iter().max().unwrap() +1
}

Measured memory_bytes: 43772
N,T,E = map(int,input().split())
x = list(map(int,input().split()))
l=[]

for i in range(len(x)):
    for j in range(T-E,T+E+1):
            if j% x[i]==0:
                l.append(i)
                
if not l:
    print(-1)
else:
    for i in l:
        print(i+1)
        break
                            


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

using namespace std;
typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;

    if (n == 3)
    {
        if (s == "ABC")
            cnt++;
        
        cout << cnt << endl;
        return 0;
    }

    for (int i = 0; i < s.size() -2; i++)
    {
        if (s.at(i) == 'A')
        {
            if (s.at(i + 1) == 'B')
            {
                if (s.at(i + 2) == 'C')
                {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
# coding:utf-8

# ????????????
s = [False] * 13
# ?????????
h = [False] * 13 
# ?????????
c = [False] * 13
# ?????????
d = [False] * 13

T = {'S':s, 'H':h, 'C':c, 'D':d}

# ??\???
n = int(input())
for i in range(n):
    suit, num = input().split()
    num = int(num)
    T[suit][num-1] = True

for v in range(13):
    if not(T['S'][v]):
        print('S', v + 1)
for v in range(13):
    if not(T['H'][v]):
        print('H', v + 1)
for v in range(13):
    if not(T['C'][v]):
        print('C', v + 1)
for v in range(13):
    if not(T['D'][v]):
        print('D', v + 1)

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

int main() {
	int n;
	cin >> n;
	
	map<string, int> m;
	
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		m[s]++;
	}
	
	cout << m.size() << endl;
}

Measured memory_bytes: 19068
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			long k = sc.nextLong();
			String[] splited = s.split("");
			long num = 1;
			long ans = 0;
			String pre = null;
			String first = s.substring(0, 1);
			String end = s.substring(s.length() - 1, s.length());
			boolean top = true;
			Set<String> set = new HashSet<>();
			long topNum = 1;
			long bottomNum = 1;
			for(String hoge : splited) {
				set.add(hoge);
				if(pre == null) {
					pre = hoge;
				} else if(pre.equals(hoge)) {
					num++;
				} else {
					if(top) {
						topNum = num;
					}
					if(!first.equals(end) || !top) {
						ans += num / 2;
					}
					top = false;
					num = 1;
					pre = hoge;
				}
			}
			bottomNum = num;
			if(set.size() == 1) {
				System.out.println(s.length() * k / 2);
				return;
			}
			if(!first.equals(end)) {
				ans += num / 2;
				System.out.println(ans * k);
				return;
			}
			System.out.println(topNum / 2 + ans * k + ((topNum + bottomNum) / 2 * (k - 1)) + bottomNum / 2);
		}

	}

}


Measured memory_bytes: 35736
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int n, c;
bool inside(int r, int c) {
    if (not (0 <= r and r < n)) return false;
    if (not (0 <= c and c < n)) return false;
    return true;
}

int calc_cost(int t, int* count, int* cost) {
    int total_cost = 0;
    rep(i, c) {
        total_cost += count[i] * cost[i];
    }
    return total_cost;
}

int main(void) {
    cin >> n >> c;
    int d[c][c];
    int f[n][n];
    rep(i, c) rep(j, c) cin >> d[j][i];
    rep(i, n) rep(j, n) cin >> f[i][j];

    int total_count[3];
    rep(i, 3) total_count[i] = 0;
    int color_count[3][c];
    rep(i, 3) rep(j, c) color_count[i][j] = 0;

    rep(dist, 2*n-1) {
        int p = dist % 3;
        rep(r, dist+1) {
            int c = dist - r;
            if (not inside(r, c)) continue;
            total_count[p]++;
            color_count[p][f[r][c]-1]++;
        }
    }
    
    // rep(i, 3) {rep(cc, c) cout << color_count[i][cc] << " "; cout << endl;}

    int min_cost = 1<<30;
    rep(t1, c) {
        rep(t2, c) {
        if (t2 == t1) continue;
            rep(t3, c) {
                if (t3 == t1) continue;
                if (t3 == t2) continue;
                int cost = 0;
                cost += calc_cost(t1, color_count[0], d[t1]);
                cost += calc_cost(t2, color_count[1], d[t2]);
                cost += calc_cost(t3, color_count[2], d[t3]);
                min_cost = min(cost, min_cost);
            }
        }
    }
    cout << min_cost << endl;
}


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

int main() {
	
	int sx,sy,tx,ty,X,Y,x,y;
	
	cin >> sx;
	cin >> sy;
	cin >> tx;
	cin >> ty;
	
	X = tx-sx;
	Y = ty-sy;
	
	x=X;
	y=Y;
	
	while(y--){
		cout<<"U";
	}
	while(x--){
		cout<<"R";
	}
	
	x=X;
	y=Y;
	
	while(y--){
		cout<<"D";
	}
	while(x--){
		cout<<"L";
	}
	
	x=X+1;
	y=Y+1;
	
	cout<<"L";
	
	while(y--){
		cout<<"U";
	}	
	while(x--){
		cout<<"R";
	}
	cout<<"D";
	
	x=X+1;
	y=Y+1;
	
	
	cout<<"R";
	
	while(y--){
		cout<<"D";
	}	
	while(x--){
		cout<<"L";
	}
	cout<<"U";
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, pos = 1;
	cin>>n;
	for(int i = 0, t; i < n; ++i){
		cin>>t;
		if(t == pos) ++pos;
	}
	if(pos == 1) cout<<-1<<'\n';
	else	cout<<n-pos+1<<'\n';
	return 0;
}

Measured memory_bytes: 256
def Binary_Search_Count(A,x,sort=True,equal=False):
    """2分探索によって,x未満の要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"未満"がx"以下"になる
    """
    if sort:
        A.sort()
        
    N=len(A)
    if A[-1]<=x:
        return N
    elif x<A[0] or (not equal and x==A[0]):
        return 0

    L,R=0,N
    while R-L>1:
        C=L+(R-L)//2
        if x<A[C] or (not equal and x==A[C]):
            R=C
        else:
            L=C
    return R

def Binary_Search_High_Value(A,x,sort=True,equal=False):
    """Aのxを超える要素の中で最小のものを出力する.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"を超える"がx"以上"になる
    ※全ての要素がx以下(未満)場合はNoneが返される.
    """
    
    if sort:
        A.sort()

    K=Binary_Search_Count(A,x,sort=False,equal=not equal)
    if K==len(A):
        return None
    else:
        return A[K]

N=int(input())
T={i:[] for i in range(10)}

S=input()
for i in range(N):
    T[int(S[i])].append(i)

X=0
for k in range(10**3):
    a,b,c=(k//100),(k//10)%10,k%10

    if T[a]:
        x=T[a][0]
        if T[b]:
            y=Binary_Search_High_Value(T[b],x,False,False)
            if y!=None and T[c]:
                z=Binary_Search_High_Value(T[c],y,False,False)
                if z!=None:
                    X+=1
print(X)


Measured memory_bytes: 73772
import io.StdIn._

object Main extends App {
  val n = readInt()
  var as = readLine().split(' ').map(_.toInt)

  var sum = 0
  while (as.exists(_%2==0)) {
    sum += as.count(_%2==0)
    as = as.map(a => if (a%2==1) a else a/2)
  }
  
  println(sum)
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) rep(j, d) cin >> x[i][j];

  int ans = 0;
  rep(i, n) rep(j, i) {
    int sq = 0;
    rep(k, d) {
      int s = x[i][k] - x[j][k];
      sq += s * s;
    }
    int s = sqrt(sq) + 0.5;
    if (s*s == sq) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  long long k; cin >> k;
  vector<long long> a(n); REP(i, n) cin >> a[i];
  // dp[i][smaller?] = 下から i ビット目まで見たときの f の最大値
  vector<vector<long long> > dp(50, vector<long long>(2, -1));
  dp[49][true] = 0;
  for (int i = 48; i >= 0; --i) {
    long long mask = 1LL << i;
    int zero = 0, one = 0;
    REP(j, n) {
      if (a[j] & mask) ++one;
      else ++zero;
    }
    // 緩和されているのが存在している場合
    if (dp[i+1][false] >= 0) dp[i][false] = max(dp[i][false], dp[i+1][false] + mask * max(zero, one));
    if (dp[i+1][true] >= 0) {
      if (k & mask) {
        dp[i][true] = dp[i+1][true] + mask * zero;
        dp[i][false] = max(dp[i][false], dp[i+1][true] + mask * one);
      } else dp[i][true] = dp[i+1][true] + mask * one;
    }
  }
  cout << max(dp[0][true], dp[0][false]) << '\n';
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
li = []
for i in range(N):
  s = int(input())
  li.append(s)
  
new = sorted(li, reverse=True)

s = max(li)
for index, i in enumerate(li):
  if s == li[index]:
    print(new[1])
  else:
    print(new[0])

Measured memory_bytes: 14112
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};
    static int[] x8 = {-1, -1, 0, 1, 1, 1, 0, -1};
    static int[] y8 = {0, -1, -1, -1, 0, 1, 1, 1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();

        int[] X = new int[n+1];
        for(int i = 0; i < n; i++) {
            X[i] = in.nextInt();
        }
        X[n] = x;
        int[] Y = new int[m+1];
        for(int i = 0; i < m; i++) {
            Y[i] = in.nextInt();
        }
        Y[m] = y;

        Arrays.sort(X);
        Arrays.sort(Y);

        int a = X[n];
        int b = Y[0];

        if(a >= b) {
            System.out.println("War");
        }else{
            System.out.println("No War");
        }
    }

    static public void printArray2D(char[][] map) {
        for(int i = 0; i < map.length; i++) {
            for(int j = 0; j < map[i].length; j++) {
                System.out.format("%c\t", map[i][j]);
            }
            System.out.print("\n");
        }
    }

    static public void printArray2D(int[][] map) {
        for(int i = 0; i < map.length; i++) {
            for(int j = 0; j < map[i].length; j++) {
                System.out.format("%d\t", map[i][j]);
            }
            System.out.print("\n");
        }
    }
}


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

int main(int argc, char const *argv[]) {
        int H,W;
        std::cin >> H >> W;

        std::vector<std::string> pixcelItems;
        for(int height = 0; height < H; height++ )
        {
                std::string pixcelItem;
                std::cin >> pixcelItem;
                pixcelItems.push_back(pixcelItem);
        }

        for(const auto& item : pixcelItems)
        {
                std::cout << item << '\n';
                std::cout << item << '\n';
        }

        return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string t;
    cin >> t;
    int res = 0;
    for (auto i : t)
        if (i == '1')
            res++;
    cout << res << endl;
    return 0;
}

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

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

    for (int i=s.size()-2;i>=2;i-=2) {
        if(s.substr(0,i/2)==s.substr(i/2,i/2)){
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
N = int(input())

def solve() :
    print(0)
    zero = input()
    
    if zero == 'Vacant' :
        return
        
    ok, ng = 0, N
    while ng - ok > 1 :
        mid = (ok + ng) // 2
        
        print(mid)
        rep = input()
        if rep == 'Vacant' :
            return
            
        if (mid % 2 == 0 and rep != zero) or (mid % 2 == 1 and rep == zero) :
            ng = mid
        else :
            ok = mid
        
solve()

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

const ll INF = 1e18;

int main(){
    int n; cin >> n;
    ll ans = 0;
    vector<ll> lis(n);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
    }
    vector<vector<ll> > dp(n+1, vector<ll>(2, 0));
    dp[0][0] = 0;
    dp[0][1] = INF * -1;
    for(int i = 0; i < n; i++){
        dp[i+1][0] = max(dp[i][0] + lis[i], dp[i][1] - lis[i]);
        dp[i+1][1] = max(dp[i][0] - lis[i], dp[i][1] + lis[i]);
    }
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    ll n,ma=0,x;
    map<string,int>a;
    cin>>n;
    rep(i,n){
        string s;cin>>s;
       if(a.count(s)>0)a[s]=a.at(s)+1;
       else a[s]=1;
    }
    for(auto x : a){
        if(x.second>ma)ma=x.second;
    }
    for(auto x : a){
        if(x.second==ma)cout<<x.first<<endl;
    }
}


Measured memory_bytes: 25984
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
typedef long long ll;

using namespace std;

int main(){
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll s_size = s.size();
    if (s_size <= k){
        cout << s << endl;
    }
    else{
        s = s.erase(k);
        cout << s << "..." << endl;
    }
}

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

using namespace std;

int n,a[55]={7,17,37,47,67,97,107,127,137,157,167,197,227,257,277,307,317,337,347,367,397,457,467,487,547,557,577,587,607,617,647,677,727,757,787,797,827,857,877,887,907,937,947,967,977,997,1087,1097,1117,1187,1217,1237,1277,1297,1307};

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(n);
}

int main(){
	init();
	cout<<a[0];
	for(register int i=1;i<n;i++)
	cout<<" "<<a[i];
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
#include<set>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n;
	cin >> n;
	int ans = 1;
	while (ans <= n / 2) {
		ans *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    int[] r = new int[n + 1];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      r[a[i]]++;
    }
    for(int i = 0; i < n; i++) {
      b[i] = sc.nextInt();
      r[b[i]]++;
    }

    int p = 0;
    for(int i = 1; i <= n; i++) {
      if(r[i] > n) p++;
    }
    if(p > 0) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
      int[] c = new int[n];
      for(int i = n - 1; i >= 0; i--) {
        c[n - 1 - i] = b[i];
      }
      int q = 0;
      int x = 0;
      int t1 = n;
      int t2 = 0;
      for(int i = 0; i < n; i++) {
        if(a[i] == c[i]) {
          q++;
          x = a[i];
          t1 = Math.min(t1, i);
          t2 = Math.max(t2, i);
        }
      }
      if(q == 0) {
        for(int i = 0; i < n; i++) {
          System.out.print(c[i] + " ");
        }
      } else {
        int s11 = -1;
        int s12 = n;
        int s21 = -1;
        int s22 = n;
        
        for(int i = 0; i < n; i++) {
          if((a[i] != x) && (i < t1)) s11 = i;
          if((a[i] != x) && (i > t2)) s12 = Math.min(s12, i);
        }

        for(int i = 0; i < n; i++) {
          if((c[i] != x) && (i < t1)) s21 = i;
          if((c[i] != x) && (i > t2)) s22 = Math.min(s22, i);
        }

        int s = Math.min(s11, s21);
        int t = Math.max(s12, s22);
        
        int k = 0;
        for(int i = t1; i <= t2; i++) {
          int temp = c[i];
          if(k <= s) {
            c[i] = c[k];
            c[k] = temp;
            k++;
          } else if(k < t) {
             k = t;
            c[i] = c[k];
            c[k] = temp;
            k++;
          } else {
            c[i] = c[k];
            c[k] = temp;
            k++;
          }
        }
 
        for(int i = 0; i < n; i++) {
          System.out.print(c[i] + " ");
        }
      }
    }
  }
}

Measured memory_bytes: 66576
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::string S, std::string T, long long A, long long B, std::string U){
    if(U == S) A--;
    else B--;
    cout<<A <<" "<<B<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int x, y;
  int a=0;
  cin >> n;
  for(int i=0; i<=n; i++) {
    x = i * 1.08;
    if(x == n){
      a = 1;
      y = i;
    }
  }
  if(a){
    cout << y << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <limits>

template<class T = int,T divided_by = 10>
constexpr T PINF(){ return std::numeric_limits<T>::max()/divided_by; }
template<class T = int,T divided_by = 10>
constexpr T MINF(){ return std::numeric_limits<T>::lowest()/divided_by; }

using namespace std;

int main() {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int n,ma,mb;
	cin >> n >> ma >> mb;

	map<pair<int,int>, int> poss;

	poss[make_pair(0,0)] = 0;

	for(int i = 0; i < n; ++i){
		int a,b,cost;
		cin >> a >> b >> cost;
		// cout << a << " " << b << " " << cost << endl;

		map<pair<int,int>, int> newPoss;
		for(auto unko : poss) {
			int ua = unko.first.first;
			int ub = unko.first.second;
			int ucost = unko.second;
			// cout << ua << " " << ub << " " << ucost << endl;
			// prepare
			int nexta = ua+a, nextb = ub+b, nextCost = ucost + cost;

			newPoss[make_pair(nexta, nextb)] = nextCost;
		}
		for(auto unko : newPoss) {
			auto newKey = unko.first;
			int newCost = unko.second;
			if(poss.find(newKey) == poss.end()) {
				poss[newKey] = newCost;
			}else{
				int bestCost = poss[newKey];
				poss[newKey] = min(newCost, bestCost);

			}
		}
		// cout << "--------------" << endl;
	}
	int cur_ma = ma, cur_mb = mb;
	int ans = -1;
	while(cur_ma < 4002 && cur_mb < 4002) {
		// cout << cur_ma << " " << cur_mb << endl;
		if(poss.find(make_pair(cur_ma,cur_mb)) != poss.end()) {
			int bestCost = poss[make_pair(cur_ma,cur_mb)];

			if(ans==-1) {
				ans = bestCost;
			}else {
				ans = min(ans,bestCost);
			}
		}
		cur_ma += ma;
		cur_mb += mb;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

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

  vector < pair<ll, int> > CB;
  for (int i = 0; i < N; i++){
    ll A; cin >> A;
    CB.push_back(make_pair(A, 1));
  }
  for (int i = 0; i < M; i++){
    int B; ll C; cin >> B >> C;
    CB.push_back(make_pair(C, B));
  }
  sort(CB.begin(), CB.end(), greater<pair<ll, int> >());
  
  int cnt = 0; ll ans = 0;
  for (int i = 0; i < CB.size(); i++){
    ll C = CB[i].first; int B = CB[i].second;
    if (cnt + B < N){
      ans += C * B;
      cnt += B;
    }else{
      ans += C * (N - cnt);
      break;
    }
  }
  cout << ans << endl;
  
  return 0;
}


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

static const ll INF = 10000000000;
  
int main(){
  int N;
  cin >> N;
  ll xyh[N][3];
  for(int i = 0; i < N; ++i){
    cin >> xyh[i][0] >> xyh[i][1] >> xyh[i][2];
  }
  ll ans[3];
  for(int x = 0; x <= 100; ++x){
    for(int y = 0; y <= 100; ++y){
      ll maxH = INF;
      ll H = -1;
      bool flag = true;
      for(int i = 0; i < N; ++i){
	if(xyh[i][2] == 0 && maxH > 0){
	  maxH = min(maxH, abs(xyh[i][0]-x) + abs(xyh[i][1]-y));
	}else{
	  if(H == -1){
	    H = xyh[i][2] + abs(xyh[i][0]-x) + abs(xyh[i][1]-y);
	  }else{
	    if(H != xyh[i][2] + abs(xyh[i][0]-x) + abs(xyh[i][1]-y)){
	      flag = false;
	    }
	  }
	}
      }
      if(H > maxH) flag = false;
      if(flag){
	ans[0] = x;
	ans[1] = y;
	ans[2] = H;
      }
    }
  }
  for(int i = 0; i < 3; ++i){
    cout << ans[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
import heapq

N,M = map(int,input().split())
A = []
for i in range(N):
    a,b = map(int,input().split())
    A.append([a,b])

A.sort()
K = []
heapq.heapify(K)

j = 0
ans = 0
for i in range(1,M+1):
    if j == N:
        for i in range(M+1-i):
            ans += heapq.heappop(K)*(-1)
        break
    while(A[j][0] <= i):
        heapq.heappush(K, -A[j][1])
        j += 1
        if j == N:
            break
    if len(K) >= 1:
        ans += heapq.heappop(K)*(-1)
print(ans)

Measured memory_bytes: 71768
h, w = map(int, input().split())
s = [["."]*w] + [list(str(input())) for _ in range(h)] + [["."]*w]
for i in range(0, h+1) :
  s[i].insert(0, ".")
  s[i].insert(w+1, ".")
res = "Yes"
for i in range(1, h) :
  for j in range(1, w) :
    if(s[i][j] == "#") :
      if(s[i][j-1] == "." and s[i][j+1] == "." and s[i+1][j] == "." and s[i-1][j] == ".") : res = "No"
print(res)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n;

        while(true) {
            n = scan.nextInt();

            if(n==0) {
                break;
            }

            char tree[][] = new char[n][1501];
            for(int i=0;i<n; i++){
                for (int j=0; j<1501; j++){
                    tree[i][j] = '-';
                }
            }

            int s_max = 0;

            for (int i = 0; i < n; i++) {
                String s = scan.next();
                if(s.length()>s_max){
                    s_max = s.length();
                }
                for(int j=0; j<s.length(); j++){
                    tree[i][j] = s.charAt(j);
                }
            }

            int plus_row = 0;

            for(int j=0; j<s_max; j++){
                boolean plus_flag = false;
                for(int i=0; i<n; i++){
                    if (tree[i][j] == '.' && tree[i][j+1] != '.') {
                        tree[i][j] = '+';
                        plus_row = i;
                        plus_flag = true;
                    } else if(tree[i][j] == '.'){
                        tree[i][j] = '|';
                    } else if(tree[i][j] != '.' && plus_flag == true && tree[i-1][j] =='|'){
                        for(int k=plus_row+1; k<i; k++){
                            tree[k][j] = ' ';
                        }
                    }
                }

                if(tree[n-1][j] == '|'){
                    for(int k=plus_row+1; k<n; k++){
                        tree[k][j] = ' ';
                    }
                }
            }

            for(int i=0 ;i<n; i++){
                for(int j=0;j<s_max; j++) {
                    if(tree[i][j] == '-') {
                        break;
                    }
                    System.out.print(tree[i][j]);
                }
                System.out.println("");
            }
        }
    }
}

Measured memory_bytes: 75592
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;



int main(){
	int N;
	cin >> N;
	int X = 0;
	while (X < N) {
		X += 1000;
	}
	cout << X - N << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;
public 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();
		sc.close();
		System.out.println(a<b&&b<c?"Yes":"No");
		
	}

}

Measured memory_bytes: 17320
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
#define MAXN 10000001
//string alpha="abcdefghijklmnopqrstuvwxyz";
//int dx[]={1,-1,0,0};
//int dy[]={0,0,1,-1};
//int dx8[]={1,-1,0,0,1,1,-1,-1};
//int dy8[]={0,0,1,-1,1,-1,1,-1};
/*int spf[MAXN];
void sieve()
{
	int i,j;
	for(i=0;i<MAXN;i++)
	spf[i]=i;
	for(i=4;i<MAXN;i+=2)
	spf[i]=2;
	for(i=3;i*i<MAXN;i++)
	{
		if(spf[i]==i)
		{
			for(j=i*i;j<MAXN;j+=i)
			{
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}*/
/*bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}*/
/*bool isValid(int x,int y,int n,int m)
{
    if(x<0||x>n-1||y<0||y>m-1)return false;
    return true;
}*/
/*
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first==y.first)
        return x.second<y.second;
    return x.first>y.first;
}*/

int32_t main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    //sieve();
    while(T--)
    {
        int d,t,s;
        cin>>d>>t>>s;
        double ans=(d*1.0)/s;
        if(ans<=t)cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3636