akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>

int main()
{
    int n, m, price;
    long long int minCost = 0;

    std::cin >> n >> m;

    std::priority_queue <int> pq;

    for(int i = 0; i < n; i++)
    {
        std::cin >> price;
        pq.push(price);
    }

    for(int i = 0; i < m; i++)
    {
        pq.push(pq.top()/2);
        pq.pop();
    }

    while(!pq.empty())
    {
        minCost += pq.top();
        pq.pop();
    }

    std::cout << minCost << std::endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	string S; cin>>S;
	int N=S.length();
	int std[N];
	for(int i=0; i<N; i++) {
		std[i]=0;
	}

	int series=1;
	bool rturn=true; //true:前マスがR
	int lcell;
	for(int i=1; i<N; i++) {
		/*
		for(int i=0; i<N-1; i++) {
			cout<<std[i]<<" ";
		}
		cout<<std[N-1]<<endl
		*/

		if(S.at(i)=='R') {
			if(rturn) {
				series++;
			}
			else {
				std[lcell]+=series/2+series%2;
				std[lcell-1]+=series/2;
				series=1;
				rturn=true;
			}
		}
		else {
			if(rturn) {
				std[i]+=series/2;
				std[i-1]+=series/2+series%2;
				lcell=i;
				series=1;
				rturn=false;
			}
			else {
				series++;
			}
		}
	}
	std[lcell]+=series/2+series%2;
	std[lcell-1]+=series/2;

	for(int i=0; i<N-1; i++) {
		cout<<std[i]<<" ";
	}
	cout<<std[N-1]<<endl;
}


Measured memory_bytes: 1024
import math
h,w = map(int,input().split())
if w == 1 or h == 1:
    print(1)
elif w%2 == 0:
    print(h*w//2)
else:
    a = w//2 + 1
    b = w//2
    na = math.ceil(h/2)
    nb = math.floor(h/2)
    print(a*na + b*nb)


Measured memory_bytes: 3060
const main = function(input){
  var nums = input.trim().split("\n")[0].split(" ").map(i=>parseInt(i));
  var H = nums[0];
  var W = nums[1];
  var board = input.trim().split("\n").slice(1);
  
  var delRowNums = [];
  for(var i=H-1;i>=0;i--){
  	var whiteRow = true;
    for(var j=0;j<W;j++){
      var char = board[i][j];
      if(char==="#"){
        whiteRow = false;
        break;
      }
    }
    if(whiteRow) board.splice(i,1);
  }
  H = board.length;
  for(var i=W-1;i>=0;i--){
    var whiteCol = true;
    for(var j=0;j<H;j++){
      var char = board[j][i];
      if(char==="#"){
        whiteCol = false;
        break;
      }
    }
    if(whiteCol){
      for(var j=0;j<H;j++){
        board[j] = board[j].slice(0,i)+ board[j].slice(i+1);
      }
    }
  }
  
  for(var i=0;i<H;i++){
    console.log(board[i]);
  }
  
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));

Measured memory_bytes: 7804
#include <iostream>

using namespace std;
int ap[300];
int n,i,j;
string s[5];
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<3;i++)
        cin>>s[i];
    int ans=0,mx;
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            ap[s[j][i]]++;
        }
        mx=0;
        for(j=0;j<3;j++)
        {
            mx=max(mx,ap[s[j][i]]);
            ap[s[j][i]]=0;
        }
        ans+=3-mx;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    val (A, B, C, X, Y) = readInputLine().split(" ").map{it.toLong()}
    
    if (A + B <= C * 2L) {
        println(A * X + B * Y)
        return
    }
    
    val more = if (X > Y) Pair(A, X) else Pair(B, Y)
    val less = if (X > Y) Pair(B, Y) else Pair(A, X)
    
    println(less.second * 2L * C + (more.second - less.second) * Math.min(2L * C, more.first))
}

fun readInputLine(): String {
    return readLine()!!
}


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

#define sz(a) ((int)a.size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i : (a))
#define all(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vl> vvvl;
typedef double T;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
typedef tuple<ll, int, int> tlii;

const int MOD = 1e9+7; // 998244353;
const int INF = 1e9+1;

using MaxValMinWeightPair = std::pair<int, int>;

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  vector<int> weights(n);
  vector<int> values(n);
  
  int V = 0;
  for (int i = 0; i < n; ++i) {
    cin >>weights[i] >> values[i];
    V += values[i];
  }
  //knapsack, state is n by sum(v);
  vector<vector<MaxValMinWeightPair>> dp(n, vector<MaxValMinWeightPair>(V, {0, INF}));

  // base case, n = 0 -> fill until v[0];
  for (int i = 0; i < V; ++i) {
    if (i < values[0]){
      dp[0][i] = {values[0], weights[0]};
    } else {
      break;
    }
  }

  for (int i = 1; i < n; ++i ) {

    for (int j = 0; j < V; ++j) {

      // we can either not take *anything* or take the current element

      int keepCost = dp[i-1][j].second;
      int keepValue = dp[i-1][j].first;

      if (j >= values[i] + 1) {
        auto prevPair = dp[i-1][j-values[i] + 1];
        int takeCost = prevPair.second + weights[i];
        int takeValue = prevPair.first + values[i];
        // maybe its not worth replacing
        dp[i][j] = takeCost < keepCost ? MaxValMinWeightPair{takeValue, takeCost} : MaxValMinWeightPair{keepValue, keepCost};
      } else {
        // it may be the case that values[i] only is more optimal.
        int takeCost = weights[i];
        int takeValue = values[i];
        dp[i][j] = takeCost < keepCost ? MaxValMinWeightPair{takeValue, takeCost} : MaxValMinWeightPair{keepValue, keepCost};
      }
    }
  }
  cout << (*max_element(dp.back().begin(), dp.back().end(), [w](MaxValMinWeightPair lhs, MaxValMinWeightPair rhs) {
       if (lhs.second > w) {
         return true; //im smaller
       } else if (rhs.second > w) {
         return false; //im smaller
       }
       return lhs.first < rhs.first;
  })).first<< endl;
}


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

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long  ll;
typedef unsigned long long  ull;
#define lp(i,n)      for(int i=0;i<n;i++)
#define lpi(i,j,n)   for(int i=j;i<n;i++)
#define lpd(i,j,n)   for(int i=j;i>=n;i--)
#define MP           make_pair
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define all(v)     (v.begin()),(v.end())
#define N 100005
const double pi = acos(-1);

ll n,t,m,k;

ll ans;
ll mod = 1e9 +7;


int main() {
 
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("e.txt","r",stdin); 
// freopen("e_out.txt","w",stdout); 
cout.precision(7);

cin>>n>>k;
vector<ll>a(n);
lp(i,n)cin>>a[i];
ans= 1e18;
sort(all(a));
for(int i=0;i+k<=n;i++){
  ans= min(ans, a[i+k-1]-a[i]);

}
cout<<ans;



  
}
  
 



// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

const int MAX_H = 20010;
int H, N;
ll A[1000], B[1000];
ll dp[20010];

ll solve(){
    REP(i, MAX_H) dp[i] = INT64_MAX;
    dp[0] = 0;
    REP(i, H + 1){
        REP(j, N){
            if(dp[i] == INT64_MAX) continue;
            dp[i + A[j]] = min(dp[i + A[j]], dp[i] + B[j]);
        }
    }
    ll ret = INT64_MAX;
    FOR(i, H, MAX_H){
        ret = min(ret, dp[i]);
    }
    return ret;
}

signed main(){
    cin >> H >> N;
    REP(i, N) cin >> A[i] >> B[i];
    PRINT(solve());
    return 0;
}

Measured memory_bytes: 384
N = int(input())
s = []
for i in range(N):
    s.append(input())

M = int(input())
t = []
for i in range(M):
    t.append(input())
    
cnt = {}

for S in s:
    if S not in cnt.keys():
        cnt[S] = 1
    else:
        cnt[S] += 1

for T in t:
    if T not in cnt.keys():
        cnt[T] = -1
    else:
        cnt[T] -= 1
        
if max(cnt.values()) < 0:
    print(0)
else:
    print(max(cnt.values()))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    string s;cin>>s;
    if(s=="SUN") cout<<7<<endl;
    if(s=="SAT") cout<<1<<endl;
    if(s=="FRI") cout<<2<<endl;
    if(s=="THU") cout<<3<<endl;
    if(s=="WED") cout<<4<<endl;
    if(s=="TUE") cout<<5<<endl;
    if(s=="MON") cout<<6<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	char s[101], t[101];
	scanf("%d", &n);
	scanf("%s %s", s, t);
	for (int i = 0; i < n; ++i) {
		printf("%c%c", s[i], t[i]);
	}

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define rep(i, n) for(int i=0;i<(int)(n);i++)

int main(void){
	int n;
	int i;
	scanf("%d",&n);
	if(n%2 == 1){
		printf("No\n");
		return 0;
	}
	char s[n+1];
	scanf("%s",s);
	rep(i,n/2){
		if(s[i] != s[i+n/2]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
    return 0; 
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;

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

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

int H,W;
cin >> H >> W;

vector<string> fi(H);
rep(h,H) cin >> fi[h];


bool ok = true;
rep(h,H) {
    rep(w,W) {
        if(fi[h][w] == '.') continue;
        bool cur = false;
        rep(i,4) {
            int x = h + dx[i];
            int y = w + dy[i];
            if(x < 0 || x >= H || y < 0 || y >= W) continue;
            if(fi[x][y] == '#') cur = true;
        }
        if(!cur) ok = false;
    }
}
if(ok) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);

    int n;
    cin>>n;
    if(n<1200)
        cout<<"ABC"<<endl;
    else
        cout<<"ARC"<<endl;
        


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main() {
	unsigned long long n;
	double a;
	double S, C;
	double PI = 3.141592653589;
	scanf("%lf", &a);
	S = a * a * PI;
	C = a * 2 * PI;
	
	printf("%f %f\n", S,C);

	return 0;
}

Measured memory_bytes: 2696
#include<iostream>
#include<algorithm>
using namespace std;
long long ttt(long long n,long long x,long long *arr,long long *brr)
{
	if(x<=0)
	{
		return 0;	
	}
	if(n==1)
	{
		if(x==1)
		{
			return 0;
		}
		else if(x==2)
		{
			return 1;
		}
		else if(x==3)
		{
			return 2;
		}
		else
		{
			return 3;
		}
		if(x==5)
		{
			return 3;
		}
	}
	if(n==0)
	{
		return 1;
	 } 
	 if(x==arr[n])
	 {
	 	return brr[n];
	 }
	while(1)
	{
		if(arr[n]/2==x)
		{
			return brr[n-1];
		}
		else if(arr[n]/2>x)
		{
			n--;
			x--;
		}
		else
		{
			break;
		}
		if(x<=0)
		{
			return 0;	
		}
	}
	if(x<=0)
	{
		return 0;	
	}
	long long sum=brr[n-1]+ttt(n-1,x-arr[n-1]-2,arr,brr)+1;
	return sum;
	
}
int main()
{
	long long n,x;
	cin>>n>>x;
	long long arr[51];
	long long brr[51];
	brr[0]=1;
	arr[0]=1;
	for(int i=1;i<=n;i++)
	{
		arr[i]=arr[i-1]*2+3;
		brr[i]=brr[i-1]*2+1;
	}
	long long sum=ttt(n,x,arr,brr);
	cout<<sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    map<int,int> mp;
    rep(i,N) mp[A[i]]++;


    ll ans1 = 0;

    for(auto it = mp.rbegin(); it != mp.rend(); it++){
        //cout << it->first << " " << it->second << endl;
        if(it -> second >= 2){
            ans1 = it -> first;
            it -> second -= 2;
            break;
        }
    }
    ll ans2 = 0;
    for(auto it = mp.rbegin(); it != mp.rend(); it++){
        if(it -> second >= 2){
            ans2 = it -> first;
            break;
        }
    }
    ll ans = ans1*ans2;
    cout << ans << endl;

}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
 	for(int i = 0; i < n; i++) {
        a[i] =x[i];
    }

    sort(x.begin(),x.end());
 
    bool flag=false;
    if(x[n/2-1]==x[n/2]) flag=true;
	for(int i = 0; i < n; i++) {
        if(flag) cout << x[n/2] << "\n";
        else{
            if(a[i]<x[n/2]) cout << x[n/2] << "\n";
            else            cout << x[n/2-1] << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<math.h>
#include <iterator>
#include<algorithm>
#include<fstream>
#include<map>
#include<string>
#include<set>
#include<math.h>
using namespace std;
int main()
{
    const double pi = 3.14159265359;
	int a, b, h, m; cin >> a >> b >> h >> m;
	double theta1 = (h * 60 + m) / 720.0 * 2 * pi;
	double theta2 = (m) / 60.0 * 2 * pi;
	double theta = fabs(theta1 - theta2);
	//cout << theta << endl;
	printf("%.20f\n", sqrt(a * a + b * b - 2.0 * a * b * cos(theta)));
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	ll ans =0;
	cin >>n;
	vector<ll> a(n), sm(n+1), xo(n+1);
	rep(i,n) cin >>a[i];
	
	rep(i,n) sm[i+1] = sm[i] + a[i];
	rep(i,n) xo[i+1] = xo[i] ^ a[i];
	
	
	/*rep(i,n){
		int hi=n+1, lw= i;
		while(hi - lw > 1){
			int md= (hi + lw) >> 1;
			if( (xo[md] ^ xo[i]) == sm[md] - sm[i])  lw = md;
			else hi = md;
		}
		//printf("%d:%d  ",i,lw);
		ans += lw -i;
	}
	*/
	
	for(int lf = 0, rt =0; lf <n; lf++){
		for(; rt <n+1 ; rt++) if((xo[rt] ^ xo[lf]) != sm[rt] - sm[lf]) break;
		//printf("%d:%d ",lf,rt);
		ans += rt - lf - 1;
	}
	
	cout << ans <<"\n";
	return 0;
}


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

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] a = new int[n + 1];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n + 1; i++)
            {
                a[i] = int.Parse(words[i]);
            }
        }

        int[] b = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                b[i] = int.Parse(words[i]);
            }
        }

        long answer = 0;
        int remainMons = a[n];
        for (int i = n - 1; i >= 0; i--)
        {
            int mons = a[i];
            int person = b[i];


            // i + 1
            if (remainMons >= person)
            {
                answer += person;
                remainMons = mons;
                continue;
            }
            else
            {
                answer += remainMons;
                person -= remainMons;
            }

            // i
            if (mons >= person)
            {
                answer += person;
                remainMons = mons - person;
            }
            else
            {
                answer += mons;
                remainMons = 0;
            }
        }

        Console.WriteLine(answer);
    }
}

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

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

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

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

    int N, C;
    cin >> N >> C;
    vector<vector<P>> table(C);
    for(int i = 0; i < N; ++i){
        int s, t, c;
        cin >> s >> t >> c;
        --c;
        table[c].emplace_back(s, t);
    }
    vector<int> S(100005, 0);
    for(int i = 0; i < C; ++i){
        sort(table[i].begin(), table[i].end());
        int n = table[i].size();
        table[i].emplace_back(100001, 100001);
        int s = table[i][0].first, t = table[i][0].second;
        for(int j = 1; j < n; ++j){
            if(table[i][j].first == t)  t = table[i][j].second;
            else{
                ++S[s], --S[t + 1];
                s = table[i][j].first, t = table[i][j].second;
            }
        }
        if(s != 100001) ++S[s], --S[t + 1];
    }
    int ans = 0;
    for(int i = 0; i <= 100000; ++i){
        chmax(ans, S[i]);
        S[i + 1] += S[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4916
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;

int main()
{
    string s;
    while(cin>>s)
    {
        int flag=true;
        for(int i=0;i<3;i++)
            if(s[i]==s[i+1])
                flag=false;
        if(flag)
            cout<<"Good"<<endl;
        else
            cout<<"Bad"<<endl;
    }
}

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

char chlit(char c){return c+32;}
char chbig(char c){return c-32;}

int main(){
  while(1){
    string X;cin >> X;
    int x = 0;
    for(int i=0;i<X.length();++i){
      int a = 0;
      if(X[i] == '1')a += 1;
      else if(X[i] == '2')a += 2;
      else if(X[i] == '3')a += 3;
      else if(X[i] == '4')a += 4;
      else if(X[i] == '5')a += 5;
      else if(X[i] == '6')a += 6;
      else if(X[i] == '7')a += 7;
      else if(X[i] == '8')a += 8;
      else if(X[i] == '9')a += 9;
      int k;
      for(int j=1;j<=i+1;j *= 10){
        k = j;
      }
      x += k*a;
    }
    if(x == 0)return 0;
    int sum = 0;
    rep(i,X.length()){
      if(X[i] == '1')sum += 1;
      else if(X[i] == '2')sum += 2;
      else if(X[i] == '3')sum += 3;
      else if(X[i] == '4')sum += 4;
      else if(X[i] == '5')sum += 5;
      else if(X[i] == '6')sum += 6;
      else if(X[i] == '7')sum += 7;
      else if(X[i] == '8')sum += 8;
      else if(X[i] == '9')sum += 9;
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <utility>
#include <map>
#define MAX_P 100000

using namespace std;
int H, W, N;
//int X[MAX_P],Y[MAX_P];
//18,446,744,073,709,551,615
//   999,999,996,000,000,004
//18,446,744,072,517,900,292
pair<int,int> pa[9] = {{0,0},{0,1},{0,2},{1,0},{1,1},{1,2},{2,0},{2,1},{2,2}};
unsigned long long int ans[10] = {0};

map<pair<int,int>,bool> map_,black;

bool test_(int x, int y){
     if(x <= 0 || y <= 0 || x > W-2 || y > H-2){ 
         return false;
     }return true;
}

int check(int x,int y){
    int count = 0;
    if(x <= 0 || y <= 0 || x > W -2|| y > H -2) return 0;
    for(auto p : pa){
            if(black[ make_pair(x+p.first,y+p.second) ] == true){
                count++;
            }
    }
    return count;
}

int main(){
    cin >> H >> W >> N;
    unsigned long long int b_count = 0,t;
    
    int x,y;
    for(int n = 0; n < N; n++){
        cin >> y >> x;
        black[ make_pair(x,y) ] = true;
        for(auto p : pa){
            if(test_(x-p.first,y-p.second)){
                map_[ make_pair(x-p.first, y-p.second)] = true;//候補の座標を格納
            }
        }
    }

    for(auto p : map_){
         //各々黒マスについて調べる
         ans[check(p.first.first,p.first.second)]++;
    }
    for(int d = 1; d < 10;d++){
        b_count += ans[d];
    }
    ans[0] = (H-2);
    ans[0] *= (W-2);
    ans[0] -= b_count;
    for(auto a:ans) cout << a << endl;

    return 0;
}


Measured memory_bytes: 212736
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 1e9 + 7;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vi c(n), d(n), s(2e5 + 1);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  s[c[0]] = 1;
  for (int i = 0; i < n; ++i) {
    d[i] = s[c[i]];
    if (i + 1 < n && c[i + 1] != c[i]) {
      s[c[i+1]] = (s[c[i+1]] + d[i]) % mod;
    }
  }
  cout << d.back() << endl;
  return 0;
}


Measured memory_bytes: 2560
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 2e5+7;

int main()
{
    
    int n;
    scf(n);
    
    if(n&1)
    prin(2*n);
    
    else
    prin(n);
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    string K;
    ll D;
    cin >> K >> D;
    ll s=K.size();
    ll dp[s+1][D][2];
    rep(i,s+1) rep(j,D) rep(k,2) dp[i][j][k]=0;
    dp[0][0][1]=1;
    rep(i,s){
        rep(j,D){
            rep(k,2){
                if (k==0) rep(l,10) dp[i+1][(j+l)%D][0]=(dp[i+1][(j+l)%D][0]+dp[i][j][k])%MOD;
                else {
                    int t=K[i]-'0';
                    rep(l,t) dp[i+1][(j+l)%D][0]=(dp[i+1][(j+l)%D][0]+dp[i][j][k])%MOD;
                    dp[i+1][(j+t)%D][1]=(dp[i+1][(j+t)%D][1]+dp[i][j][k])%MOD;
                }
            }
        }
    }
    cout << (dp[s][0][0]+dp[s][0][1]+MOD-1)%MOD << endl;
}

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

int main(){
  int a, b, c;
  cin>>a>>b>>c;

  int cnt = 0;
  for(int x = a; x <= b; x++){
    if(c % x == 0) cnt++;
  }

 cout<<cnt<<endl;

 return 0;
}


Measured memory_bytes: 3120
a, b, c = map(int, input().split())
if [a, b, c] == [7,5,5]:
    print('YES')
elif [a, b, c] == [5,7,5]:
    print('YES')
elif [a, b, c] == [5,5,7]:
    print('YES')
else:
    print('NO')

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

int main(){
    int a, b;
    cin >> a >> b;

    if(a >= b){
        for(int i =0; i<a; i++){
            cout << b;
        }
    }

    if(b > a){
        for(int i =0; i<b; i++){
            cout << a;
        }
    }

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int K = sc.nextInt();
		// スペース区切りの整数の入力
		int X = sc.nextInt();

		int min = X - K + 1;
		if(min < -1000000){
			min = -1000000;
		}
		int max = X + K - 1;
		if(max > 1000000){
			max = 1000000;
		}
		for(int i = min; i <= max; i++){
			System.out.print(i+ " " );
		}
	}
}

Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int f[20][1<<16],a[20],fac[1<<16],ifac[1<<16];
inline int C(int x,int y){
	if(y<0||y>x)return 0;
	return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}
inline int power(int a,int b){
	int c=1;
	while(b){
		if(b&1)c=1ll*c*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return c;
}
inline void add(int &x,int y){
	x+=y;
	if(x>=mod)x-=mod;
	if(x<0)x+=mod;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	fac[0]=1;
	for(int i=1;i<(1<<n);i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[(1<<n)-1]=power(fac[(1<<n)-1],mod-2);
	for(int i=(1<<n)-1;i>0;i--)ifac[i-1]=1ll*ifac[i]*i%mod;
	for(int i=1;i<=m;i++)if(i<m-i+1)swap(a[i],a[m-i+1]);
	f[0][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<(1<<n);j++)if(f[i][j]){
			add(f[i+1][j],f[i][j]);
			for(int k=0;k<n;k++)if(!((j>>k)&1))
				add(f[i+1][j|(1<<k)],1ll*C((1<<n)-j-a[i+1],(1<<k)-1)*fac[1<<k]%mod*f[i][j]%mod);
		}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		// printf("%d %d\n",i,f[m][i]);
		int cnt=0;
		for(int j=0;j<n;j++)if((i>>j)&1)cnt++;
		add(ans,(cnt&1?-1ll:1ll)*f[m][i]*fac[(1<<n)-i-1]%mod);
	}
	ans=1ll*ans*(1<<n)%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 4224
import java.util.Scanner;

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

		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();

		int dx, dy;
		if(tx < 0 || sx >= 0){
			dx = Math.max(Math.abs(sx), Math.abs(tx))-Math.min(Math.abs(sx), Math.abs(tx));
		}else{
			dx = tx-sx;
		}

		if(ty < 0 || sy >= 0){
			dy = Math.max(Math.abs(sy), Math.abs(ty))-Math.min(Math.abs(sy), Math.abs(ty));
		}else{
			dy = ty-sy;
		}
		String answer = "";

		for (int i = 0; i < 4; i++) {
			if (i % 2 == 0) {
				if(i == 2){
					answer += "LU";
				}
				for (int j = 0; j < dy; j++) {
					answer += "U";
				}

				for (int j = 0; j < dx; j++) {
					answer += "R";
				}

				if(i == 2){
					answer += "RD";
				}
			} else {
				if(i == 3){
					answer += "RD";
				}
				for (int j = 0; j < dy; j++) {
					answer += "D";
				}

				for (int j = 0; j < dx; j++) {
					answer += "L";
				}
				if(i == 3){
					answer += "LU";
				}
			}
		}

		System.out.println(answer);
	}
}

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

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

    string t = "abcdefghijklmnopqrstuvwxyz";

    sort(s.begin(), s.end());
    
    char ans;
    int flag = 0;
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < s.size(); j++){
            if(s[j] == t[i]){
                flag = 1;
                break;
            } else {
                ans  = t[i];
                flag = 0;
            }
        }
        if(flag == 0){
            cout << t[i] << endl;
            return 0;
        }
        flag = 0;
    }

    cout << "None" << endl;

}

Measured memory_bytes: 512
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
  int cnt;
  foreach (line; stdin.byLine) {
    if (cnt) writeln("");
    auto list = line.chomp.map!(a => a.to!char - '0').map!(to!int).array;
    string res[8];
    res[] = "";
    auto len = list.length;
    while (len < 5) {
      list = 0 ~ list;
      len++;
    }
    foreach (e; list) {
      if (e >= 5) {
        res[0] ~= ' ';
        res[1] ~= '*';
        e -= 5;
      } else {
        res[0] ~= '*';
        res[1] ~= ' '; 
      }
      int i;
      for (; i < e; i++) {
        res[i+3] ~= '*';
      }
      res[i+3] ~= ' ';
      foreach (j; i+1..5) {
        res[j+3] ~= '*';
      }
    }
    res[2] = "=====";
    foreach (e; res) {
      e.writeln;
    }
    cnt++;
  }
}

Measured memory_bytes: 1184
#include <stdio.h>

int main(void)
{
    char string[27];

    scanf("%s", string);
    for(int i=0;string[i] != '\0'; i++)
    {
        for (int j = i +1; string[j] != '\0'; j++)
        {
            if(string[i] == string[j])
            {
                    printf("no\n");
                    return (0);
            }
        }
    }
    printf("yes\n");
}

Measured memory_bytes: 1664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define from1(obj) obj.begin() + 1, obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbp(p) cerr << #p << ":(" << p.first << ", " << p.second << ") "
#define dbpl(p) cerr << #p << ":(" << p.first << ", " << p.second << ")\n"
#define dbt3(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ") "
#define dbt3l(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ")\n"
#define dbt4(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ") "
#define dbt4l(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ")\n"
#define dbv(vec) cerr << #vec << ":{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"
#define dbvv(vv) cerr << #vv << ":{\n"; for (auto vec : vv) { cerr << "{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"; } cerr << "}\n"
#define dbm(map) cerr << #map << ":{ "; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "}\n"
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pil = pair<int, ll> ; using pll = pair<ll, ll>; using pli = pair<ll, int>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mll = map<ll, ll>; using mli = map<ll, int>;

int main() {
	ll N, K; cin >> N >> K;
	ll ans;
	ans = min(N % K, K - N % K);
	cout << ans << endl;	
}

Measured memory_bytes: 256
import           Data.List (genericLength, minimumBy)
import           Data.Ord  (comparing)

main :: IO ()
main = do
  n <- readLn
  as <- take n . map read . words <$> getLine
  print $ f as

-- foldl で書いてみたい
f :: [Int] -> Int
f as = fst . minimumBy (comparing snd) . fmap (fmap (abs . subtract average . fromIntegral)) . zip [0..] $ as
  where
    average = fromIntegral (sum as) / genericLength as


Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    char now = s[0];
    int cnt = 1;

    for (int i = 1; i < n; ++i) {
        if (now != s[i]) {
            ++cnt;
            now = s[i];
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void)

{

   int a,b,c,x;

   scanf("%d %d %d",&a,&b,&c);

   if(a>b){

      x=a;

      a=b;

      b=x;

   }

   if(a>c){

      x=a;

      a=c;

      c=x;

   }

   if(b>c){

      x=b;

      b=c;

      c=x;

   }

   printf("%d %d %d\n",a,b,c);

   return 0;

}

Measured memory_bytes: 596
a,b=map(int,input().split())
c=g=1;e=f=0
while b:
    d,m=divmod(a,b)
    h=c-d*e
    i=f-d*g
    a,b=b,m
    c,e=e,h
    f,g=g,i
print(c,f)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int ans = 0;
    for (size_t i = 0; i < N-2; i++)
    {
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            ans++;
            i+=2;
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n,a,b; string s; ll jcount = 0; ll fcount = 0;
  cin >> n >> a >> b >> s;
  
  
  for(ll i=0; i < n; i++){
    
    if(s[i] == 'a'){
      if(jcount + fcount < a+b) cout << "Yes" << endl;
      else cout << "No" << endl;
      jcount++;
    }
    
    else if(s[i] == 'b'){
      if((jcount + fcount < a+b)&& fcount < b) cout << "Yes" << endl;
      else cout << "No" << endl;
      if(fcount < b) fcount++;
    }
    
    else cout << "No" << endl;
  }
  
  
 cout << endl;
}
    
    
  

Measured memory_bytes: 896
from bisect import bisect_right
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [-a for a in A]
B.sort()
C = [0]
for b in B:
    C.append(C[-1] + b)

def is_ok(m):
    p = 0
    for b in B:
        i = bisect_right(B, -b-m)
        p += i
        if p >= M: return True
    return False

ok = 0
ng = 2*10**5+1

while ng-ok > 1:
    m = (ok+ng) // 2
    if is_ok(m):
        ok = m
    else:
        ng = m

def calc(m):
    p = s = 0
    for b in B:
        i = bisect_right(B, -b-m)
        p += i
        s += C[i] + i*b
    return (p,-s)

p1,s1 = calc(ok)
p2,s2 = calc(ng)
ans = (s1-s2) // (p1-p2) * (M-p2) + s2
print(ans)

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

ll N, K, t, d, sum, ans;
vector<ll> F, S;
vector<pair<ll, ll>> v;
map<ll, ll> mp;

main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> t >> d;
        v.push_back(make_pair(t, d));
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < v.size(); i++) {
        pair<ll, ll> p = v[i];
        if (mp[p.first] == 0) F.push_back(p.second);
        else S.push_back(p.second);
        mp[p.first]++;
    }
    sort(F.rbegin(), F.rend());
    sort(S.rbegin(), S.rend());
    ll L = F.size(), M = S.size();
    for (int i = 0; i < min(K, L); i++) sum += F[i];
    if (K > L) {
        int check = 0;
        for (ll i = 0; i < K - L; i++, check = i) sum += S[i];
        ans = sum + L * L;
        for (ll j = L - 1; j > 0 && check < M; check++, j--) {
            sum = sum - F[j] + S[check];
            ans = max(ans, sum + j * j);
        }
        cout << ans << endl;
    }
    else {
        ans = sum + K * K;
        for (ll i = 0; i < K - 1 && i < M; i++) {
            sum -= F[K - 1 - i];
            sum += S[i];
            ans = max(ans, sum + (K - i - 1) * (K - i - 1));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 8816
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for(auto i = mp.begin(); i != mp.end(); i++){
        ll x = i->second;
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include<stdio.h>
int main()
{
    long long int n,k,q,i;
    scanf("%lld%lld%lld",&n,&k,&q);
    long long int a[q],p[n];
    for(i=0;i<n;i++){
        p[i]=k-q;
    }
    for(i=0;i<q;i++){
        scanf("%lld",&a[i]);
        p[a[i]-1]= p[a[i]-1]+1;
    }

    for(i=0;i<n;i++){
        if(p[i]>0){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;

}


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

int main()
{
    long long n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    for(int i=k;i<n;i++)
    {
        if(arr[i]>arr[i-k])
            cout<<"Yes"<<endl;
        else{
            cout<<"No"<<endl;
        }

    }

    return 0;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define fastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define scan(a) scanf("%d", &a)
#define scanll(a) scanf("%lld", &a)
#define scanD(a) scanf("%lf", &a)
#define print(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printD(a) printf("%lf\n", a)
#define printTwo(a) printf("%.2lf\n", a);
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest) {
        string b;
        for(; *it!=','; ++it)
            if(*it!=' ')
                b+=*it;
        cout << b << "=" << a << " ";
        call(++it, ed, rest...);
    }
};

/* ----------------------------------------------------------------------------------- */


void solve() {
	int n;
	scan(n);
	map<string, int> mp;

	while (n--) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}

int main() {
#ifdef Niloy
    read("input.txt");
    write("output.txt");
#endif

    solve();

    // __test {
    //     solve();
    // }

    showTime;
    return 0;
}




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int N, K, x[55], y[55];
int main() {
	cin >> N >> K;
	rep(i,N) cin >> x[i] >> y[i];
	long long ret = 1LL << 62;
	rep(i,N) rep(j,N) rep(k,N) rep(l,N) {
        if (x[i] <= x[j] && y[k] <= y[l]) {
            int cnt = 0;
            for (int p = 0; p < N; p++) {
                if (x[i] <= x[p] && x[p] <= x[j] && y[k] <= y[p] && y[p] <= y[l]) cnt++;
            }
            if (cnt >= K) ret = min(ret, 1LL * (x[j] - x[i]) * (y[l] - y[k]));
        }
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 384
/*
      author : nishi5451
      created: 11.08.2020 22:31:25
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    if(a<10 && b<10) cout << a*b << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3660